📄 docsys.c
字号:
/***********************************************************************************/
/* M-Systems Confidential */
/* Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2003 */
/* All Rights Reserved */
/***********************************************************************************/
/* NOTICE OF M-SYSTEMS OEM */
/* SOFTWARE LICENSE AGREEMENT */
/* */
/* THE USE OF THIS SOFTWARE IS GOVERNED BY A SEPARATE LICENSE */
/* AGREEMENT BETWEEN THE OEM AND M-SYSTEMS. REFER TO THAT AGREEMENT */
/* FOR THE SPECIFIC TERMS AND CONDITIONS OF USE, */
/* OR CONTACT M-SYSTEMS FOR LICENSE ASSISTANCE: */
/* E-MAIL = info@m-sys.com */
/***********************************************************************************/
/*
* $Log: V:/PVCSDB/DiskOnChip/archives/general storage/TrueFFS/src/access/docsys.c-arc $
*
* Rev 1.8 Sep 01 2003 19:09:26 oris
* - Bug fix - 8 bit Big endian platforms with double address shift when accessing a 16bit register.
* - Bug fix - 8 bit Big endian platforms with single address shift when accessing a 16bit register.
*
* Rev 1.7 Jun 18 2003 21:16:00 OriS
* Removed warnings
*
* Rev 1.6 Jun 16 2003 01:18:00 oris
* Added some parenthesis.
*
* Rev 1.5 May 22 2003 06:51:50 oris
* Bug fix for OREN based devices in if_cfg = 8bit and address shift
*
* Rev 1.4 May 21 2003 09:36:04 oris
* Bug fix for M512 single Address shift if_cfg=16
*
* Rev 1.3 May 16 2003 00:56:48 OriS
* Compilation error for big endian.
*
* Rev 1.2 May 12 2003 22:54:02 oris
* Added support for if_Cfg = 8 for M512 devices with address shift.
*
* Rev 1.1 May 06 2003 11:57:06 OriS
* Removed USE_TFFS_CPY macro
* Support new customization model for 8 bit registers
*
* Rev 1.0 Apr 09 2003 12:16:04 OriS
* Initial revision.
*
*/
#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.------------------------------------------------------------------------*/FLDword FAR1 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.------------------------------------------------------------------------*/FLDword FAR1 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.------------------------------------------------------------------------*/FLDword FAR1 flDocMemWinSizeDoubleShift(void){ return 0x8000;}/*********************************************************//* Write 16 bits to DiskOnChip memory window *//*********************************************************//*---------------------------------------------------------------------- f l W r i t e 16 b i t U s i n g 8 b i t s N o S h i f t Write 16-bits Using 8-bits operands and 8 bit data With no address shifted.
------------------------------------------------------------------------*/void FAR1 flWrite16bitUsing8bitsNoShift(volatile FLByte FAR0 * win, FLWord offset,FLWord val){
#ifndef FL_BIG_ENDIAN FLWRITE_IO_BYTE((FLByte)val,(win + offset)); FLWRITE_IO_BYTE((FLByte)(val>>0x8),(win + offset+1));
#else
FLWRITE_IO_BYTE((FLByte)(val>>0x8),(win + offset));
FLWRITE_IO_BYTE((FLByte)val,(win + offset + 1));
#endif /* FL_BIG_ENDIAN */}/*---------------------------------------------------------------------- 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.
Note2 : Used for if_cfg = 16 when using address shift.
Write 16-bit Using 16-bits operands and 16-bits of data
with no address shifted.
------------------------------------------------------------------------*/
void FAR1 flWrite16bitUsing16bitsNoShift(volatile FLByte FAR0 * win, FLWord offset,Reg16bitType val)
{
FLWRITE_IO_WORD(val,((volatile FLWord 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 32-bits operands and 16-bits of data
With a single address shifted.
------------------------------------------------------------------------*/
void FAR1 flWrite16bitUsing32bitsSingleShift(volatile FLByte FAR0 * win, FLWord offset,Reg16bitType val)
{
#ifdef FL_BIG_ENDIAN
FLWRITE_IO_DWORD((FLDword)(((FLDword)val)<<16),(((volatile FLDword FAR0 *)win)+(offset>>1)));
#else
FLWRITE_IO_DWORD((FLDword)val,(((volatile FLDword FAR0 *)win)+(offset>>1)));
#endif /* FL_BIG_ENDIAN */
}
/*----------------------------------------------------------------------
f l W r i t e 1 6 b i t U s i n g 1 6 b i t s S i n g l e S h i f t
Note : offset must be 16-bits aligned.
Note2 : Used for if_cfg = 8 when using address shift.
Write 16-bit Using 16-bits operands and 8-bits of data
with a single address shifted.
------------------------------------------------------------------------*/
void FAR1 flWrite16bitUsing16bitsSingleShift(volatile FLByte FAR0 * win, FLWord offset,Reg16bitType val)
{
#ifdef FL_BIG_ENDIAN
FLWRITE_IO_WORD((FLWord)(val>>8),(((volatile FLWord FAR0 *)win) + offset));
FLWRITE_IO_WORD((FLWord)(val),(((volatile FLWord FAR0 *)win) + (offset+1)));
#else
FLWRITE_IO_WORD(val,(((volatile FLWord FAR0 *)win) + offset));
FLWRITE_IO_WORD((FLWord)(val>>8),(((volatile FLWord FAR0 *)win) + (offset + 1)));
#endif /* FL_BIG_ENDIAN */
}
/*----------------------------------------------------------------------
f l W r i t e 1 6 b i t U s i n g 3 2 b i t s D o u b l e S h i f t
Note : offset must be 16-bits aligned.
Note2 : Used for if_cfg = 8 when using address shift.
Write 16-bit Using 32-bits operands and 8-bits of data
with a single address shifted.
------------------------------------------------------------------------*/
void FAR1 flWrite16bitUsing32bitsDoubleShift(volatile FLByte FAR0 * win, FLWord offset,Reg16bitType val)
{
#ifdef FL_BIG_ENDIAN
FLWRITE_IO_DWORD(((FLDword)(val>>8)),(((volatile FLDword FAR0 *)win) + offset));
FLWRITE_IO_DWORD(((FLDword)((FLByte)val)),(((volatile FLDword FAR0 *)win) + (offset + 1)));
#else
FLWRITE_IO_DWORD(((FLDword)((FLByte)val)),(((volatile FLDword FAR0 *)win) + offset));
FLWRITE_IO_DWORD(((FLDword)(val>>8)),(((volatile FLDword FAR0 *)win) + (offset + 1)));
#endif /* FL_BIG_ENDIAN */
}
/*********************************************************/
/* Read 16 bits from DiskOnChip memory window */
/*********************************************************/
/*----------------------------------------------------------------------
f l R e a d 16 b i t U s i n g 8 b i t s N o S h i f t
Read 16-bits Using 8-bits operands and 8-bits of data
With no address shifted.
------------------------------------------------------------------------*/
FLWord FAR1 flRead16bitUsing8bitsNoShift(volatile FLByte FAR0 * win,FLWord offset)
{
#ifndef FL_BIG_ENDIAN
register FLWord val = (FLWord)FLREAD_IO_BYTE((win+offset));
return val | (((FLWord)FLREAD_IO_BYTE((win+offset+1)))<<8);
#else
register FLWord val = ((FLWord)FLREAD_IO_BYTE(win+offset))<<8;
return val | ((FLWord)FLREAD_IO_BYTE(win+offset+1));
#endif /* FL_BIG_ENDIAN */
}
/*----------------------------------------------------------------------
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 and 16-bits of data
With no address shifted.
------------------------------------------------------------------------*/
Reg16bitType FAR1 flRead16bitUsing16bitsNoShift(volatile FLByte FAR0 * win,FLWord offset)
{
return( FLREAD_IO_WORD(((volatile FLWord 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.
Note2 : Used for if_cfg = 16 when using address shift.
Read 16-bit Using 32-bits operands and 16-bits of data
With single address shifted.
------------------------------------------------------------------------*/
Reg16bitType FAR1 flRead16bitUsing32bitsSingleShift(volatile FLByte FAR0 * win,FLWord offset)
{
#ifdef FL_BIG_ENDIAN
return (Reg16bitType) (FLREAD_IO_DWORD(((volatile FLDword FAR0*)win)+(offset>>1))>>16);
#else
return((Reg16bitType)FLREAD_IO_DWORD(((volatile FLDword FAR0 *)win)+(offset>>1)));
#endif /* FL_BIG_ENDIAN */
}
/*----------------------------------------------------------------------
f l R e a d 1 6 b i t U s i n g 1 6 b i t s S i n g l e S h i f t
Note : offset must be 16-bits aligned.
Note2 : Used for if_cfg = 8 when using address shift.
Read 16-bit Using 16-bits operands and 8-bits of data
With single address shifted.
------------------------------------------------------------------------*/
Reg16bitType FAR1 flRead16bitUsing16bitsSingleShift(volatile FLByte FAR0 * win,FLWord offset)
{
FLByte val[2];
val[0] = ((Reg8bitType)(FLREAD_IO_WORD(((volatile FLWord FAR0 *)win)+offset)));
val[1] = ((Reg8bitType)(FLREAD_IO_WORD(((volatile FLWord FAR0 *)win)+(offset+1))));
return *((Reg16bitType *)val);
}
/*----------------------------------------------------------------------
f l R e a d 1 6 b i t U s i n g 3 2 b i t s D o u b l e S h i f t
Note : offset must be 16-bits aligned.
Note2 : Used for if_cfg = 8 when using address shift.
Read 16-bit Using 32-bits operands and 8-bits of data
With double address shifted.
------------------------------------------------------------------------*/
Reg16bitType FAR1 flRead16bitUsing32bitsDoubleShift(volatile FLByte FAR0 * win,FLWord offset)
{
FLByte val[2];
val[0] = ((Reg8bitType)(FLREAD_IO_DWORD(((volatile FLDword FAR0 *)win)+offset)));
val[1] = ((Reg8bitType)(FLREAD_IO_DWORD(((volatile FLDword FAR0 *)win)+(offset+1))));
return *((Reg16bitType *)val);
}
/*********************************************************/
/* 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 FAR1 flWrite8bitUsing8bitsNoShift(volatile FLByte FAR0 * win, FLWord 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 FAR1 flWrite8bitUsing16bitsNoShift(volatile FLByte FAR0 * win, FLWord offset,Reg8bitType val){#ifdef FL_BIG_ENDIAN FLWRITE_IO_WORD(((FLWord)val)<<8,((volatile FLWord FAR0 *)win)+(offset>>1));#else FLWRITE_IO_WORD((FLWord)val,(((volatile FLWord 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -