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

📄 docsys.c

📁 M-System DOC(Disk on a Chip) Flash芯片映像读写工具, 可以进行二片Flash芯片的内容互相拷贝, 提高烧录程序的效率.
💻 C
📖 第 1 页 / 共 4 页
字号:
   register int          i;   register FLDword        tmpVal = (FLDword)val * 0x01010101L;   for (i = 0; i < (int)count; i+=2)    FLWRITE_IO_DWORD(tmpVal,swin);}/**************************************************************//*  16-Bit DiskOnChip - Single Shift - Only 8 bits are valid  *//**************************************************************//*----------------------------------------------------------------------   f l 1 6 b i t D o c R e a d S i n g l e 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 FAR1 fl16bitDocReadSingleShiftIgnoreHigher8bits(volatile  FLByte FAR0 * win, FLWord offset, FLByte FAR1 * dest, FLWord count ){   volatile FLDword FAR0* swin = ((volatile FLDword FAR0 *)win)+ (offset>>1);   register int         i;#ifndef FL_NO_INIT_MMU_PAGES   if (count == 0)     return;  dest[0] = 0;  *((FLByte FAR1*)addToFarPointer(dest, (count - 1)) ) = (FLByte)0;#endif /* FL_NO_INIT_MMU_PAGES */   for (i = 0; i < (int)count; i++)   {#ifdef FL_BIG_ENDIAN     dest[i] = (FLByte)(FLREAD_IO_DWORD(swin+i)>>24);#else      dest[i] = (FLByte)FLREAD_IO_DWORD(swin+i);#endif /* FL_BIG_ENDIAN */   }}/*----------------------------------------------------------------------   f l 1 6 D o c W r i t e S i n g l e 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 FAR1 fl16bitDocWriteSingleShiftIgnoreHigher8bits ( volatile  FLByte FAR0 * win , FLWord offset ,                             FLByte FAR1 * src, FLWord count ){   volatile FLDword FAR0 * swin = ((volatile FLDword FAR0 *)win)+ (offset>>1);   register int         i;   for (i = 0; i < (int)count; i++)   {#ifdef FL_BIG_ENDIAN    FLWRITE_IO_DWORD(((FLDword)src[i]<<24),swin);#else    FLWRITE_IO_DWORD(((FLDword)src[i]),swin);#endif /* FL_BIG_ENDIAN */   }}/*----------------------------------------------------------------------   f l 1 6 D o c S e t S i n g l e 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 FAR1 fl16bitDocSetSingleShiftIgnoreHigher8bits ( volatile  FLByte FAR0 * win , FLWord offset ,                                  FLWord count , FLByte val){   volatile FLDword FAR0 * swin = ((volatile FLDword FAR0 *)win) + (offset>>1);   register int         i;   register FLDword        tmpVal = (FLDword)val * 0x01010101L;   for (i = 0; i < (int)count; i++)    FLWRITE_IO_DWORD(tmpVal,swin);}/**********************************************************//* Set proper access type routines into the proper record *//**********************************************************//*----------------------------------------------------------------------*//*                 s e t B u s T y p e O f F l a s h                    *//*                                                                      *//* Set DiskOnChip socket / flash memory access routine.                 *//* This routine must be called by the MTD prior to any access to the    *//* DiskOnChip                                                           *//*                                                                      *//* Parameters:                                                          *//*    flflash    : Pointer to sockets flash record.                     *//*    access     : Type of memory access routines to install            *//*                                                                      *//* Note: The possible type of memory access routine are comprised of:   *//*                                                                      *//*    Address shift:                                                    *//*         FL_NO_ADDR_SHIFT         - No address shift                  *//*         FL_SINGLE_ADDR_SHIFT     - Single address shift              *//*         FL_DOUBLE_ADDR_SHIFT     - Double address shift              *//*                                                                      *//*    Platform bus capabilities (access width):                         *//*         FL_BUS_HAS_8BIT_ACCESS   -  Bus can access 8-bit             *//*         FL_BUS_HAS_16BIT_ACCESS  -  Bus can access 16-bit            *//*         FL_BUS_HAS_32BIT_ACCESS  -  Bus can access 32-bit            *//*                                                                      *//*    Number of data bits connected to the DiskOnChip (if_cfg):         *//*         FL_8BIT_DOC_ACCESS       - DiskOnChip has 8 data bits        *//*         FL_16BIT_DOC_ACCESS      - DiskOnChip has 16 data bits       *//*                                                                      *//*    Flash data bits that can be accessed in a bus cycle (interleave): *//*         FL_8BIT_FLASH_ACCESS     - 8 bits of flash per cycle         *//*         FL_16BIT_FLASH_ACCESS    - 16 bits of flash per cycle        *//*                                                                      *//*    Ignore all of the above and use user defined access routines:     *//*         FL_ACCESS_USER_DEFINED - Do not install any routine since    *//*                                  user already installed custome made *//*                                  routines                            *//*                                                                      *//* Returns:                                                             *//*        FLStatus        : 0 on success, otherwise failed              *//*----------------------------------------------------------------------*/FLStatus FAR1 setBusTypeOfFlash(FLFlash * flash,FLDword access){   /* sanity checks here if needed */   if(flash==NULL)   {      DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: Flash record passed to setBusTypeOfFlash is NULL.\r\n");      return flBadParameter;   }   /* check if user already defined the memory access routines */   if ((access & FL_ACCESS_USER_DEFINED) != 0)      return flOK;   /************************************/   /* install requested access methods */   /************************************/   switch(access & FL_XX_ADDR_SHIFT_MASK)   {      case FL_NO_ADDR_SHIFT:         flash->memWindowSize = flDocMemWinSizeNoShift;         switch(access & FL_XX_DATA_BITS_MASK)         {            case FL_8BIT_DOC_ACCESS:  /* if_cfg set to 8-bits */               /* Make sure bus supports 8 bit access */               if((access & FL_BUS_HAS_8BIT_ACCESS) == 0)               {                  DBG_PRINT_WRN(FLZONE_MTD,"Warning: TrueFFS requires 8-bit access to DiskOnChip memory window\r\n");                  DBG_PRINT_WRN(FLZONE_MTD,"         for 8-bit DiskOnChip connected with no address shift.\r\n");                  return flBadParameter;               }               flash->memWrite8bit  = flWrite8bitUsing8bitsNoShift;               flash->memRead8bit   = flRead8bitUsing8bitsNoShift;               flash->memRead16bit  = flRead16bitUsing8bitsNoShift;               flash->memWrite16bit = flWrite16bitUsing8bitsNoShift;               flash->memRead       = fl8bitDocReadNoShift;               flash->memWrite      = fl8bitDocWriteNoShift;               flash->memSet        = fl8bitDocSetNoShift;               break;            case FL_16BIT_DOC_ACCESS: /* if_cfg set to 16-bits (Plus family) */               /* Make sure bus supports 16 bit access */               if((access & FL_BUS_HAS_16BIT_ACCESS) == 0)               {                  DBG_PRINT_WRN(FLZONE_MTD,"Warning: TrueFFS requires 16-bit access to DiskOnChip memory window\r\n");                  DBG_PRINT_WRN(FLZONE_MTD,"         for 16-bit DiskOnChip connected with no address shift.\r\n");                  return flBadParameter;               }               flash->memWrite8bit  = flWrite8bitUsing16bitsNoShift;               flash->memRead8bit   = flRead8bitUsing16bitsNoShift;               flash->memRead16bit  = flRead16bitUsing16bitsNoShift;               flash->memWrite16bit = flWrite16bitUsing16bitsNoShift;               switch(access & FL_XX_FLASH_ACCESS_MASK) /* Interleave */               {                  case FL_8BIT_FLASH_ACCESS:  /* Interleave - 1 */                     flash->memRead       = fl16bitDocReadNoShiftIgnoreHigher8bits;                     flash->memWrite      = fl16bitDocWriteNoShiftIgnoreHigher8bits;                     flash->memSet        = fl16bitDocSetNoShiftIgnoreHigher8bits;                     break;                  case FL_16BIT_FLASH_ACCESS: /* Interleave - 2 */                     flash->memRead       = fl16bitDocReadNoShift;                     flash->memWrite      = fl16bitDocWriteNoShift;                     flash->memSet        = fl16bitDocSetNoShift;                     break;                  default:                     DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: TrueFFS does not support this flash access type (setBusTypeOfFlash).\r\n");                     return flBadParameter;               }               break;            default:               DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: TrueFFS does not support this number of DiskOnChip data bits (setBusTypeOfFlash).\r\n");               return flBadParameter;         }         break;      case FL_SINGLE_ADDR_SHIFT:         /* Install memory window size routine */         flash->memWindowSize = flDocMemWinSizeSingleShift;         switch(access & FL_XX_DATA_BITS_MASK)         {            case FL_8BIT_DOC_ACCESS:  /* if_cfg set to 8bits (None plus family)*/               /* Make sure bus supports 16 bit access */               if((access & FL_BUS_HAS_16BIT_ACCESS) == 0)               {                  DBG_PRINT_WRN(FLZONE_MTD,"Warning: TrueFFS requires 16-bit access to DiskOnChip memory window\r\n");                  DBG_PRINT_WRN(FLZONE_MTD,"         for 8-bit DiskOnChip connected with a single address shift.\r\n");                  return flBadParameter;               }               flash->memWrite8bit  = flWrite8bitUsing16bitsSingleShift;               flash->memRead8bit   = flRead8bitUsing16bitsSingleShift;			   flash->memWrite16bit = flWrite16bitUsing16bitsSingleShift;               flash->memRead16bit  = flRead16bitUsing16bitsSingleShift;                              flash->memRead       = fl8bitDocReadSingleShift;               flash->memWrite      = fl8bitDocWriteSingleShift;               flash->memSet        = fl8bitDocSetSingleShift;               break;            case FL_16BIT_DOC_ACCESS: /* if_cfg set to 8bits (Plus family) */               /* Make sure bus supports 32 bit access */               if((access & FL_BUS_HAS_32BIT_ACCESS) == 0)               {                  DBG_PRINT_WRN(FLZONE_MTD,"Warning: TrueFFS requires 32-bit access to DiskOnChip memory window\r\n");                  DBG_PRINT_WRN(FLZONE_MTD,"         for 16-bit DiskOnChip connected with a single address shift.\r\n");                  return flBadParameter;               }               flash->memWrite8bit  = flWrite8bitUsing32bitsSingleShift;               flash->memRead8bit   = flRead8bitUsing32bitsSingleShift;               flash->memRead16bit  = flRead16bitUsing32bitsSingleShift;               flash->memWrite16bit = flWrite16bitUsing32bitsSingleShift;               switch(access & FL_XX_FLASH_ACCESS_MASK) /* Interleave */               {                  case FL_8BIT_FLASH_ACCESS:  /* Interleave - 1 */                     flash->memRead       = fl16bitDocReadSingleShiftIgnoreHigher8bits;                     flash->memWrite      = fl16bitDocWriteSingleShiftIgnoreHigher8bits;                     flash->memSet        = fl16bitDocSetSingleShiftIgnoreHigher8bits;                     break;                  case FL_16BIT_FLASH_ACCESS: /* Interleave - 2 */                     flash->memRead       = fl16bitDocReadSingleShift;                     flash->memWrite      = fl16bitDocWriteSingleShift;                     flash->memSet        = fl16bitDocSetSingleShift;                     break;                  default:                     DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: TrueFFS does not support this flash access type (setBusTypeOfFlash).\r\n");                     return flBadParameter;               }               break;            default:               DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: TrueFFS does not support this number of DiskOnChip data bits (setBusTypeOfFlash).\r\n");
               return flBadParameter;         }         break;      case FL_DOUBLE_ADDR_SHIFT:         /* Install memory window size routine */         flash->memWindowSize = flDocMemWinSizeDoubleShift;         switch(access & FL_XX_DATA_BITS_MASK)         {            case FL_8BIT_DOC_ACCESS:  /* if_cfg set to 8bits or none plus family */               /* Make sure bus supports 32 bit access */               if((access & FL_BUS_HAS_32BIT_ACCESS) == 0)               {                  DBG_PRINT_WRN(FLZONE_MTD,"Warning: TrueFFS requires 32-bit access to DiskOnChip memory window\r\n");                  DBG_PRINT_WRN(FLZONE_MTD,"         for 8-bit DiskOnChip connected with a double address shift.\r\n");                  return flBadParameter;               }               flash->memWrite8bit  = flWrite8bitUsing32bitsDoubleShift;               flash->memRead8bit   = flRead8bitUsing32bitsDoubleShift;			   flash->memWrite16bit = flWrite16bitUsing32bitsDoubleShift;               flash->memRead16bit  = flRead16bitUsing32bitsDoubleShift;                              flash->memRead       = fl8bitDocReadDoubleShift;               flash->memWrite      = fl8bitDocWriteDoubleShift;               flash->memSet        = fl8bitDocSetDoubleShift;               break;            default:               DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: TrueFFS does not support this number of DiskOnChip data bits\r\n");               DBG_PRINT_ERR(FLZONE_MTD,"                            when connected with a double address shift (setBusTypeOfFlash).\r\n");               return flBadParameter;         }         break;      default:         DBG_PRINT_ERR(FLZONE_MTD,"ERROR in setBusTypeOfFlash: TrueFFS does not support this kind of address shifting (setBusTypeOfFlash).\r\n");         return flBadParameter;   }   /* Store access type in flash record */   flash->busAccessType = access;   return flOK;}#endif /* FL_NO_USE_FUNC */

⌨️ 快捷键说明

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