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

📄 docsys.c

📁 DOC文件系统驱动源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
 * $Log:   V:/Flite/archives/TrueFFS5/Src/DOCSYS.C_V  $
 * 
 *    Rev 1.23   Nov 12 2002 18:39:38   OriS
 * Replaced the direct memory calls to the DiskOnChip memory window with macros to allow their customization.
 * 
 *    Rev 1.22   Oct 21 2002 22:59:28   oris
 * Removed conversion from virtual pointer to physical before checking for unaligned addresses.
 *
 *    Rev 1.21   Aug 22 2002 17:26:10   oris
 * Added FL_XSCALE_BOOT_MODE compilation flag - support for xscale special mode.
 *
 *    Rev 1.20   Jul 07 2002 09:06:54   oris
 * Removed & signed from access routines - caused warning on some compilers.
 *
 *    Rev 1.19   Jun 11 2002 21:31:04   doronc
 * Bugs fix regarding access routines for big endian.
 *
 *    Rev 1.18   May 01 2002 19:03:00   oris
 * Moved FL_INIT_MMU_PAGES to flsystem.h and changed it into a negative flag FL_NO_INIT_MMU_PAGES
 *
 *    Rev 1.17   Apr 21 2002 23:04:10   oris
 * Bug fix - type error caused some of the BIG_EDNIAN code not to compile. FL_BIG_EDNIAN was defined as FL_BIG_ENDAIN.
 *
 *    Rev 1.16   Apr 15 2002 08:30:30   oris
 * Added support for USE_TFFS_COPY compilation flag. This flag is used by bios driver a Boot SDK in order to improove performance.
 *
 *    Rev 1.15   Apr 15 2002 07:35:56   oris
 * Reorganized for final release.
 *
 *    Rev 1.14   Jan 28 2002 21:24:10   oris
 * Removed static prefix to all runtime configurable memory access routines.
 * Replaced FLFlash argument with DiskOnChip memory base pointer.
 * Changed interface of write and set routines (those that handle more then 8/16 bits) so that instead of FLFlash record they receive the DiskOnChip memory window base pointer and offset (2 separated arguments). The previous implementation did not support address shifting properly.
 * Changed tffscpy and tffsset to flcpy and flset when flUse8bit equals 0.
 * Changed memWinowSize to memWindowSize
 *
 *    Rev 1.13   Jan 17 2002 22:59:30   oris
 * Completely revised, to support runtime customization and all M-Systems
 * DiskOnChip devices.
 *
 *    Rev 1.12   Sep 25 2001 15:35:02   oris
 * Restored to OSAK 4.3 implementation.
 *
 */

/************************************************************************/
/*                                                                      */
/*      FAT-FTL Lite Software Development Kit                           */
/*      Copyright (C) M-Systems Ltd. 1995-2001                          */
/*                                                                      */
/************************************************************************/

#include "docsys.h"

#ifndef FL_NO_USE_FUNC

/*********************************************************/
/*     Report DiskOnChip Memory size                     */
/*********************************************************/

/*----------------------------------------------------------------------
   f l D o c M e m W i n S i z e N o S h i f t

   This routine is called from MTD to quary the size of the DiskOnChip
   memory window for none shifted DiskOnChip.
------------------------------------------------------------------------*/

dword flDocMemWinSizeNoShift(void)
{
  return 0x2000;
}

/*----------------------------------------------------------------------
   f l D o c M e m W i n S i z e S i n g l e S h i f t

   This routine is called from MTD to quary the size of the DiskOnChip
   memory window for DiskOnChip connected with a single addres shift.
------------------------------------------------------------------------*/

dword flDocMemWinSizeSingleShift(void)
{
  return 0x4000;
}

/*----------------------------------------------------------------------
   f l D o c M e m W i n S i z e D o u b l e S h i f t

   This routine is called from MTD to quary the size of the DiskOnChip
   memory window for DiskOnChip connected with a double addres shift.
------------------------------------------------------------------------*/

dword flDocMemWinSizeDoubleShift(void)
{
  return 0x8000;
}

/*********************************************************/
/*     Write 16 bits to DiskOnChip memory window         */
/*********************************************************/

/*----------------------------------------------------------------------
   f l W r i t e 1 6 b i t D u m m y

   Dummy routine - write 16-bits to memory (does nothing).
------------------------------------------------------------------------*/

void flWrite16bitDummy(volatile  byte FAR0 * win, word offset,Reg16bitType val)
{
  DEBUG_PRINT(("Wrong customization - 16bit write was used with no implemented.\r\n"));
}

/*----------------------------------------------------------------------
   f l W r i t e 1 6 b i t U s i n g 1 6 b i t s N o S h i f t

   Note : offset must be 16-bits aligned.

   Write 16-bit Using 16-bits operands with no address shifted.
------------------------------------------------------------------------*/

void flWrite16bitUsing16bitsNoShift(volatile  byte FAR0 * win, word offset,Reg16bitType val)
{
	FLWRITE_IO_WORD(val,((volatile word FAR0 *)win + (offset>>1)));
}

/*----------------------------------------------------------------------
   f l W r i t e 1 6 b i t U s i n g 3 2 b i t s S i n g l e S h i f t

   Note : offset must be 16-bits aligned.

   Write 16-bit Using 16-bits operands with a single address shifted.
------------------------------------------------------------------------*/

void flWrite16bitUsing32bitsSingleShift(volatile  byte FAR0 * win, word offset,Reg16bitType val)
{
#ifdef FL_BIG_ENDIAN
	FLWRITE_IO_DWORD(((dword)val)<<16,((volatile dword FAR0 *)win)+(offset>>1));
#else
	FLWRITE_IO_DWORD((dword)val,((volatile dword FAR0 *)win)+(offset>>1));
#endif /* FL_BIG_ENDIAN */
}

/*********************************************************/
/*     Read 16 bits from DiskOnChip memory window        */
/*********************************************************/

/*----------------------------------------------------------------------
   f l R e a d 1 6 b i t D u m m y

   Dummy routine - read 16-bits from memory (does nothing).
------------------------------------------------------------------------*/

Reg16bitType flRead16bitDummy(volatile  byte FAR0 * win,word offset)
{
  DEBUG_PRINT(("Wrong customization - 16bit read was issued with no implementation.\r\n"));
  return 0;
}

/*----------------------------------------------------------------------
   f l R e a d 1 6 b i t U s i n g 1 6 b i t s N o S h i f t

   Note : offset must be 16-bits aligned.

   Read 16-bit Using 16-bits operands with no address shifted.
------------------------------------------------------------------------*/

Reg16bitType flRead16bitUsing16bitsNoShift(volatile  byte FAR0 * win,word offset)
{
	return( FLREAD_IO_WORD(((volatile word FAR0 *)win + (offset>>1))) );
}

/*----------------------------------------------------------------------
   f l R e a d 1 6 b i t U s i n g 3 2 b i t s S i n g l e S h i f t

   Note : offset must be 16-bits aligned.

   Read 16-bit Using 16-bits operands with single address shifted.
------------------------------------------------------------------------*/

Reg16bitType flRead16bitUsing32bitsSingleShift(volatile  byte FAR0 * win,word offset)
{
#ifdef FL_BIG_ENDIAN
	return (Reg16bitType) (FLREAD_IO_DWORD(((volatile dword FAR0*)win)+(offset>>1))>>16);
#else
	return((Reg16bitType)FLREAD_IO_DWORD(((volatile dword FAR0 *)win)+(offset>>1)));
#endif /* FL_BIG_ENDIAN */
}

/*********************************************************/
/*     Write 8 bits to DiskOnChip memory window          */
/*********************************************************/

/*----------------------------------------------------------------------
   f l W r i t e 8 b i t U s i n g 8 b i t s N o S h i f t

   Write 8-bits Using 8-bits operands with no address shifted.
------------------------------------------------------------------------*/

void flWrite8bitUsing8bitsNoShift(volatile byte FAR0 * win, word offset,Reg8bitType val)
{
	FLWRITE_IO_BYTE(val,win + offset);
}

/*----------------------------------------------------------------------
   f l W r i t e 8 b i t U s i n g 16 b i t s N o S h i f t

   Note : DiskOnChip is connected with 16-bit data bus.
   Note : Data is written only to lower memory addresses.

   Write 8-bits Using 16-bits operands with no address shifted.
------------------------------------------------------------------------*/

void flWrite8bitUsing16bitsNoShift(volatile  byte FAR0 * win, word offset,Reg8bitType val)
{
#ifdef FL_BIG_ENDIAN
	FLWRITE_IO_WORD(((word)val)<<8,((volatile word FAR0 *)win)+(offset>>1));
#else
	FLWRITE_IO_WORD((word)val,((volatile word FAR0 *)win)+(offset>>1));
#endif /* FL_BIG_ENDIAN */
}

/*----------------------------------------------------------------------
   f l W r i t e 8 b i t U s i n g 16 b i t s S i n g l e S h i f t

   Note : Data is written only to 8-LSB.

   Write 8-bits Using 16-bits operands with Single address shifted.
------------------------------------------------------------------------*/

void flWrite8bitUsing16bitsSingleShift(volatile  byte FAR0 * win, word offset,Reg8bitType val)
{
	FLWRITE_IO_WORD((word)val,((volatile word FAR0 *)win)+offset);
}

/*----------------------------------------------------------------------
   f l W r i t e 8 b i t U s i n g 32 b i t s S i n g l e S h i f t

   Note : DiskOnChip is connected with 16-bit data bus.
   Note : Data is written to both data bus 8-bits

   Write 8-bits Using 32-bits operands with single address shifted.
------------------------------------------------------------------------*/

void flWrite8bitUsing32bitsSingleShift(volatile  byte FAR0 * win, word offset,Reg8bitType val)
{
#ifdef FL_BIG_ENDIAN
	FLWRITE_IO_DWORD((dword)val*0x01010101L,((volatile dword FAR0 *)win)+(offset>>1));
#else
	FLWRITE_IO_DWORD((dword)val,((volatile dword FAR0 *)win)+(offset>>1));
#endif /* FL_BIG_ENDIAN */
}

/*----------------------------------------------------------------------
   f l W r i t e 8 b i t U s i n g 32 b i t s D o u b l e S h i f t

   Note : Data is written only to 8-LSB.

   Write 8-bits Using 32-bits operands with Double address shifted.
------------------------------------------------------------------------*/

void flWrite8bitUsing32bitsDoubleShift(volatile  byte FAR0 * win, word offset,Reg8bitType val)
{
	FLWRITE_IO_DWORD((dword)val,((volatile dword FAR0 *)win)+offset);
}

/*********************************************************/
/*     Read 8 bits to DiskOnChip memory window           */
/*********************************************************/

/*----------------------------------------------------------------------
   f l R e a d 8 b i t U s i n g 8 b i t s N o S h i f t

   Read 8-bits Using 8-bits operands with no address shifted.
------------------------------------------------------------------------*/

Reg8bitType flRead8bitUsing8bitsNoShift(volatile  byte FAR0 * win,word offset)
{
	return FLREAD_IO_BYTE((volatile void FAR0 *)(win + offset));
}

/*----------------------------------------------------------------------
   f l R e a d 8 b i t U s i n g 16 b i t s N o S h i f t

   Note : DiskOnChip is connected with 16-bit data bus.

   Read 8-bits Using 16-bits operands with no address shifted.
------------------------------------------------------------------------*/

Reg8bitType flRead8bitUsing16bitsNoShift(volatile  byte FAR0 * win,word offset)
{
#ifdef FL_BIG_ENDIAN
   return (((offset & 0x1) == 0) ?
#else
   return (( offset & 0x1      ) ?
#endif /* FL_BIG_ENDIAN */
		(Reg8bitType)(FLREAD_IO_WORD(((volatile word FAR0 *)win + (offset>>1))) >> 8) :
		(Reg8bitType)(FLREAD_IO_WORD(((volatile word FAR0 *)win + (offset>>1)))) );
}

⌨️ 快捷键说明

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