⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flxscale.c

📁 Intel PXA270 Wince5.0 BSP
💻 C
📖 第 1 页 / 共 2 页
字号:

   Write 'count' bytes to M+ DiskOnChip with none shifted address bus.
------------------------------------------------------------------------*/

void flXscale16bitDocWriteNoShift ( volatile  byte FAR0 * win , word offset ,
                             byte FAR1 * src, word count )
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + 0x802);
   register int         i;
   register word        tmp;

   if( pointerToPhysical(src) & 0x1 ) /* rare case: unaligned source buffer */
   {       
       for (i = 0; i < (int)count; i+=2)
       {
          /* tmp variable is just a precation from compiler optimizations */
#ifdef FL_BIG_ENDIAN
          tmp = ((word)src[i]<<8) + (word)src[i+1];
#else
          tmp = (word)src[i] + ((word)src[i+1]<<8);
#endif /* FL_BIG_ENDIAN */
          *swin = tmp;
		 }
   }
   else /* mainstream case */
   {    /* write in short words */      
      for (i = 0, count = count >> 1; i < (int)count; i++)
        *swin = ((word FAR1 *)src)[i];
   }
}

/*----------------------------------------------------------------------
   f l X s c a l e 1 6 b i t D o c S e t N o S h i f t
 
   Note : Offset is always set to the DiskOnChip IO registers (0x800)

   Set 'count' bytes of M+ DiskOnChip with none shifted address bus
------------------------------------------------------------------------*/

void flXscale16bitDocSetNoShift ( volatile  byte FAR0 * win , word offset ,
                                  word count , byte val)
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + 0x802);
   register int         i;
   word                 tmpVal = (word)val * 0x0101;

   /* write in short words */
   for (i = 0; i < (int)count; i+=2)
      *swin = tmpVal;
}

/*********************************************************/
/*                   Interleave - 1                      */
/*********************************************************/

/*************************************************************/
/*    16-Bit DiskOnChip - No Shift - Only 8 bits are valid   */
/*************************************************************/

/*----------------------------------------------------------------------
   f l X s c a l e 1 6 b i t D o c R e a d N o S h i f t I g n o r e H i g h e r 8 B i t s

   Note : offset must be 16-bits aligned.
  
   Read 'count' bytes from M+ DiskOnChip connected with all 16 data bits, but
   in interleave-1 mode , therefore only one of the 8 bits contains actual data.
   The DiskOnChip is connected without an address shift.
------------------------------------------------------------------------*/

void flXscale16bitDocReadNoShiftIgnoreHigher8bits(volatile  byte FAR0 * win, word offset, byte FAR1 * dest, word count )
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + 0x802);
   register int         i;

#ifndef FL_NO_INIT_MMU_PAGES 
  if (count == 0)
     return;

  *dest = (byte)0;
  *((byte FAR1*)addToFarPointer(dest, (count - 1)) ) = (byte)0;
#endif /* FL_NO_INIT_MMU_PAGES */

   for (i = 0; i < (int)count; i++)
   {
#ifdef FL_BIG_ENDIAN
      dest[i] = (byte)((*swin)>>8);
#else
      dest[i] = (byte)*swin;
#endif /* FL_BIG_ENDIAN */
   }
}

/*----------------------------------------------------------------------
   f l X s c a l e 1 6 D o c W r i t e N o S h i f t I g n o r e H i g h e r 8 b i t s

   Note : offset must be 16-bits aligned.

   Write 'count' bytes to M+ DiskOnChip connected with all 16 data bits, but
   in interleave-1 mode , therefore only one of the 8bits contains actual data.
   The DiskOnChip is connected without an address shift.
------------------------------------------------------------------------*/

void flXscale16bitDocWriteNoShiftIgnoreHigher8bits ( volatile  byte FAR0 * win , word offset ,
                             byte FAR1 * src, word count )
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + 0x802);
   register int         i;

   for (i = 0; i < (int)count; i++)
   {
#ifdef FL_BIG_ENDIAN
      *swin  = ((word)src[i])<<8;
#else
      *swin  = (word)src[i];
#endif /* FL_BIG_ENDIAN */
   }
}

/*----------------------------------------------------------------------
   f l X s c a l e 1 6 D o c S e t N o S h i f t I g n o r e H i g h e r 8 b i t s

   Note : offset must be 16-bits aligned.

   Set 'count' bytes to M+ DiskOnChip connected with all 16 data bits, but
   in interleave-1 mode , therefore only one of the 8bits contains actual data.
   The DiskOnChip is connected without an address shift.
------------------------------------------------------------------------*/

void flXscale16bitDocSetNoShiftIgnoreHigher8bits ( volatile  byte FAR0 * win , word offset ,
                                  word count , byte val)
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + 0x802);
   register int         i;
   word                 tmpVal = val * 0x0101;

   for (i = 0; i < (int)count; i++)
      *swin = tmpVal;
}

/***********************************/
/***    Registeration Routine    ***/
/***********************************/

/*----------------------------------------------------------------------*/
/*               f l I n s t a l l X s c a l e S u p p o r t            */
/*                                                                      */
/* Call back routine called by the MTD to install the proper access     */
/* routines for Xscale platform using 16-bit DiskOnChip configured with */
/* no address shift and if_cfg set to 16-bit interface.                 */
/*                                                                      */
/* D O   N O T   C A L L   T H I S   R O U T I N E                      */
/*                                                                      */
/* Use "flSetPlatformIsXscale" routine to install the X-Scale support.  */
/* This routine is called by the MTD, using the call back mechanism of  */
/* when chainging the interleave factor.                                */
/*                                                                      */
/* Parameters:                                                          */
/*      interleave : The device interleave factor.                      */
/*      socketNo   : The socket number for which to install the support */
/*      flags      : Must be set to 0.                                  */
/*----------------------------------------------------------------------*/

FLStatus flInstallXscaleSupport(byte interleave , byte socketNo , dword flags)
{
  FLFlash* flash;

  flash = flFlashOf(socketNo);

  flBusConfig[socketNo]  = FL_ACCESS_USER_DEFINED;
  flash->memWindowSize = flXscaleDocMemWinSizeNoShift;
  flash->memRead8bit   = flXscaleRead8bitUsing16bitsNoShift;
  flash->memWrite8bit  = flXscaleWrite8bitUsing16bitsNoShift;
  flash->memRead16bit  = flXscaleRead16bitUsing16bitsNoShift;
  flash->memWrite16bit = flXscaleWrite16bitUsing16bitsNoShift;
  flash->memSetGetMode = flInstallXscaleSupport;

  switch(interleave)
  {
    case 1:
       flash->memRead  = flXscale16bitDocReadNoShiftIgnoreHigher8bits;
       flash->memWrite = flXscale16bitDocWriteNoShiftIgnoreHigher8bits;
       flash->memSet   = flXscale16bitDocSetNoShiftIgnoreHigher8bits;
       break;

    case 2:
       flash->memRead  = flXscale16bitDocReadNoShift;
       flash->memWrite = flXscale16bitDocWriteNoShift;
       flash->memSet   = flXscale16bitDocSetNoShift;
       break;

    default:
       DEBUG_PRINT(("Error in access routines\r\n"));
       return flGeneralFailure;
  }

  return flOK;
}

/*----------------------------------------------------------------------*/
/*               f l S e t P l a t f o r m I s X s c a l e              */
/*                                                                      */
/* Initialize the SDK to support Xscale bus for 16-bit DiskOnChip       */
/* Configured with no address shift and if_cfg of 16bit                 */
/*                                                                      */
/* Parameters:                                                          */
/*      socketNo   : The socket number for which to install the support */
/*      flags      : Must be set to 0.                                  */
/*----------------------------------------------------------------------*/

FLStatus flSetPlatformIsXscale(byte socketNo , dword flags)
{
   /* Arg sanity check */
   if (socketNo >= SOCKETS)
   {
      DEBUG_PRINT(("Error : change SOCKETS definition to support that many sockets.\r\n"));
      return flFeatureNotSupported;
   }

   /* Make sure global variables are initialized to their default values */
#ifdef MTD_STANDALONE
   bdkInit();          /* Boot SDK initialization */
#else
   flInitGlobalVars(); /* TrueFFS SDK initialization */
#endif /* MTD_STANDALONE */

  /* Install access routine for X-Scale proccessor 
   *
   * Note that although we use call "flInstallXscaleSupport" with interleave-1. 
   * The MTD will autonatically call this routine again with the proper 
   * interleave factor once it was detected.
   */
   return flInstallXscaleSupport(1,socketNo,flags);
}

#endif /* FL_NO_USE_FUNC */
#endif /* XSCALE_H       */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -