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

📄 docsys.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
   register int         i;
   register word        tmp;

   if( (dword)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 */
         FLWRITE_IO_WORD(tmp,swin);
        }
   }
   else /* mainstream case */
   {
#ifdef USE_TFFS_COPY
      TFFSCPY_TO_IO(win + offset, src, count );
#else
#ifdef ENVIRONMENT_VARS
      if (flUse8Bit == 0)
      {
         FLCPY_TO_IO(win + offset,src,count);
      }
      else
#endif /* ENVIRONMENT_VARS */
      {
         /* write in short words */
         for (i = 0, count = count >> 1; i < (int)count; i++)
           /* while increamenting DiskOnChip offset */
           /* but do not increament DiskOnChip offset */
         FLWRITE_IO_WORD(((word FAR1 *)src)[i],swin);
      }
#endif /* USE_TFFS_COPY */
   }
}

/*----------------------------------------------------------------------
   f l 1 6 b i t D o c S e t N o S h i f t

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

void fl16bitDocSetNoShift ( volatile  byte FAR0 * win , word offset ,
                                  word count , byte val)
{
#ifdef USE_TFFS_COPY
   TFFSSET_IO(win + offset, val, count );
#else

   volatile word FAR0 * swin = (volatile word FAR0 *)( win + offset);
   register int         i;
   word                 tmpVal = (word)val * 0x0101;

#ifdef ENVIRONMENT_VARS
   if (flUse8Bit == 0)
   {
       FLSET_IO(win + offset, val, count );
   }
   else
#endif /* ENVIRONMENT_VARS */
   {   /* write in short words */
      for (i = 0; i < (int)count; i+=2)
       FLWRITE_IO_WORD(tmpVal,swin);
   }
#endif /* USE_TFFS_COPY */
}

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

/*----------------------------------------------------------------------
   f l 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 fl16bitDocReadNoShiftIgnoreHigher8bits(volatile  byte FAR0 * win, word offset, byte FAR1 * dest, word count )
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + offset);
   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++)
   {
#ifndef FL_XSCALE_BOOT_MODE
      /* Read while increamenting DiskOnChip window offset */
#ifdef FL_BIG_ENDIAN
      dest[i] = (byte)(FLREAD_IO_WORD((volatile void FAR0 *)(swin+i))>>8);
#else
      dest[i] = (byte)FLREAD_IO_WORD((volatile void FAR0 *)(swin+i));
#endif /* FL_BIG_ENDIAN */
#else
      /* Read while not increamenting DiskOnChip window offset */
#ifdef FL_BIG_ENDIAN
dest[i] = (byte)(FLREAD_IO_WORD(swin)>>8);
#else
dest[i] = (byte)(FLREAD_IO_WORD(swin));
#endif /* FL_BIG_ENDIAN */
#endif /* FL_XSCALE_BOOT_MODE */
   }
}

/*----------------------------------------------------------------------
   f l 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 fl16bitDocWriteNoShiftIgnoreHigher8bits ( volatile  byte FAR0 * win , word offset ,
                             byte FAR1 * src, word count )
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + offset);
   register int         i;

   for (i = 0; i < (int)count; i++)
   {
      /* Write while not increamenting DiskOnChip window offset */
#ifdef FL_BIG_ENDIAN
      FLWRITE_IO_WORD((((word)src[i])<<8),swin);
#else
      FLWRITE_IO_WORD((word)src[i],swin);
#endif /* FL_BIG_ENDIAN */
   }
}

/*----------------------------------------------------------------------
   f l 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 fl16bitDocSetNoShiftIgnoreHigher8bits ( volatile  byte FAR0 * win , word offset ,
                                  word count , byte val)
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + offset );
   register int         i;
   word                 tmpVal = val * 0x0101;

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

/****************************************/
/*   16-Bit DiskOnChip - Single Shift   */
/****************************************/

/*----------------------------------------------------------------------
   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
 
   Read 'count' bytes from M+ DiskOnChip with none shifted address bus.
------------------------------------------------------------------------*/

void fl16bitDocReadSingleShift (volatile  byte FAR0 * win, word offset, byte FAR1 * dest, word count )
{
   volatile dword FAR0 * swin = ((volatile dword FAR0 *)win) + (offset>>1);
   register int         i;
   register dword       tmp;

#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 */

   if( (dword)dest & 0x1 )
   {
      /* rare case: unaligned target buffer */
      for (i = 0; i < (int)count; )
      {
         tmp = FLREAD_IO_DWORD(swin);
#ifdef FL_BIG_ENDIAN
         dest[i++] = (byte)(tmp>>24);
         dest[i++] = (byte)(tmp>>16);
#else
         dest[i++] = (byte)tmp;
         dest[i++] = (byte)(tmp>>8);
#endif /* FL_BIG_ENDIAN */
      }
   }
   else
   {   /* mainstream case */
      for (i = 0, count = count >> 1; i < (int)count; i++)
      {
#ifdef FL_BIG_ENDIAN         
         ((word FAR1 *)dest)[i]=(word)(FLREAD_IO_DWORD(swin+i)>>16);
#else
         ((word FAR1 *)dest)[i] = (word)FLREAD_IO_DWORD(swin+i);
#endif /* FL_BIG_ENDIAN */
      }
   }
}

/*----------------------------------------------------------------------
   f l 1 6 b i t D o c W r i t e S i n g l e S h i f t
 
   Write 'count' bytes to M+ DiskOnChip with none shifted address bus.
------------------------------------------------------------------------*/

void fl16bitDocWriteSingleShift ( volatile  byte FAR0 * win , word offset ,
                             byte FAR1 * src, word count )
{
   volatile dword FAR0 * swin = ((volatile dword FAR0 *)win)+ (offset>>1);
   register int         i;
   register dword       tmp;

   if( (dword)src & 0x1 ) /* rare case: unaligned source buffer */
   {       
       for (i = 0; i < (int)count; i+=2)
       {
#ifdef FL_BIG_ENDIAN
          tmp = (((dword)src[i])<<24) + (((dword)src[i+1])<<16);
#else
          tmp = (dword)src[i] + (((dword)src[i+1])<<8);
#endif /* FL_BIG_ENDIAN */
           FLWRITE_IO_DWORD(tmp,swin);
       }
   }
   else /* mainstream case */
   {    
      for (i = 0, count = count >> 1; i < (int)count; i++)
#ifdef FL_BIG_ENDIAN
        FLWRITE_IO_DWORD(((dword)((word FAR1 *)src)[i])<<16,swin);
#else
        FLWRITE_IO_DWORD(((dword)((word FAR1 *)src)[i]),swin);
#endif /* FL_BIG_ENDIAN */
   }
}

/*----------------------------------------------------------------------
   f l 1 6 b i t D o c S e t S i n g l e S h i f t
 
   Set 'count' bytes of M+ DiskOnChip with none shifted address bus
------------------------------------------------------------------------*/

void fl16bitDocSetSingleShift ( volatile  byte FAR0 * win , word offset ,
                                  word count , byte val)
{
   volatile dword FAR0 * swin = ((volatile dword FAR0 *)win)+ (offset>>1);
   register int          i;
   register dword        tmpVal = (dword)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 fl16bitDocReadSingleShiftIgnoreHigher8bits(volatile  byte FAR0 * win, word offset, byte FAR1 * dest, word count )
{
   volatile dword FAR0* swin = ((volatile dword FAR0 *)win)+ (offset>>1);
   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++)

⌨️ 快捷键说明

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