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

📄 docsys.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
   {
#ifdef FL_BIG_ENDIAN
	  dest[i] = (byte)(FLREAD_IO_DWORD(swin+i)>>24);
#else
      dest[i] = (byte)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 fl16bitDocWriteSingleShiftIgnoreHigher8bits ( volatile  byte FAR0 * win , word offset ,
                             byte FAR1 * src, word count )
{
   volatile dword FAR0 * swin = ((volatile dword FAR0 *)win)+ (offset>>1);
   register int         i;

   for (i = 0; i < (int)count; i++)
   {
#ifdef FL_BIG_ENDIAN
    FLWRITE_IO_DWORD(((dword)src[i]<<24),swin);
#else
    FLWRITE_IO_DWORD(((dword)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 fl16bitDocSetSingleShiftIgnoreHigher8bits ( volatile  byte FAR0 * win , word offset ,
                                  word count , byte val)
{
   volatile dword FAR0 * swin = ((volatile dword FAR0 *)win) + (offset>>1);
   register int         i;
   dword                tmpVal = (dword)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  setBusTypeOfFlash(FLFlash * flash,dword access)
{
   /* sanity checks here if needed */
   if(flash==NULL)
   {
      DEBUG_PRINT(("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)
               {
                  DEBUG_PRINT(("ERROR: TrueFFS requires 8-bit access to DiskOnChip memory window\r\n"));
                  DEBUG_PRINT(("       for 8-bit DiskOnChip connected with no address shift.\r\n"));
                  return flBadParameter;
               }

               flash->memWrite8bit  = flWrite8bitUsing8bitsNoShift;
               flash->memRead8bit   = flRead8bitUsing8bitsNoShift;
               flash->memRead16bit  = flRead16bitDummy;
               flash->memWrite16bit = flWrite16bitDummy;
               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)
               {
                  DEBUG_PRINT(("ERROR: TrueFFS requires 16-bit access to DiskOnChip memory window\r\n"));
                  DEBUG_PRINT(("       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:
                     DEBUG_PRINT(("TrueFFS does not support this flash access type (setBusTypeOfFlash).\r\n"));
                     return flBadParameter;
               }
               break;

            default:
               DEBUG_PRINT(("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)
               {
                  DEBUG_PRINT(("ERROR: TrueFFS requires 16-bit access to DiskOnChip memory window\r\n"));
                  DEBUG_PRINT(("       for 8-bit DiskOnChip connected with a single address shift.\r\n"));
                  return flBadParameter;
               }

               flash->memWrite8bit  = flWrite8bitUsing16bitsSingleShift;
               flash->memRead8bit   = flRead8bitUsing16bitsSingleShift;
               flash->memRead16bit  = flRead16bitDummy;
               flash->memWrite16bit = flWrite16bitDummy;
               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)
               {
                  DEBUG_PRINT(("ERROR: TrueFFS requires 32-bit access to DiskOnChip memory window\r\n"));
                  DEBUG_PRINT(("       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:
                     DEBUG_PRINT(("TrueFFS does not support this flash access type (setBusTypeOfFlash).\r\n"));
                     return flBadParameter;
               }
               break;

            default:
               DEBUG_PRINT(("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)
               {
                  DEBUG_PRINT(("ERROR: TrueFFS requires 32-bit access to DiskOnChip memory window\r\n"));
                  DEBUG_PRINT(("       for 8-bit DiskOnChip connected with a double address shift.\r\n"));
                  return flBadParameter;
               }

               flash->memWrite8bit  = flWrite8bitUsing32bitsDoubleShift;
               flash->memRead8bit   = flRead8bitUsing32bitsDoubleShift;
               flash->memRead16bit  = flRead16bitDummy;
               flash->memWrite16bit = flWrite16bitDummy;
               flash->memRead       = fl8bitDocReadDoubleShift;
               flash->memWrite      = fl8bitDocWriteDoubleShift;
               flash->memSet        = fl8bitDocSetDoubleShift;
               break;

            default:
               DEBUG_PRINT(("TrueFFS does not support this number of DiskOnChip data bits\r\n"));
               DEBUG_PRINT(("when connected with a double address shift (setBusTypeOfFlash).\r\n"));
               return flBadParameter;
         }
         break;

      default:
         DEBUG_PRINT(("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 + -