📄 docsys.c
字号:
/****************************************************************************** * * * Project: DOC Driver for Linux 2.4 Block device driver for mDOC H3 family * * of devices under Linux kernel 2.4. * * * * Version: 1.0 * * Email questions to: oemsupport@sandisk.com * * Copyright (C) SanDisk IL Ltd. 1995 - 2007 * * SanDisk IL Ltd., 7 Atir Yeda Street, Kfar Saba 44425, Israel * * * ****************************************************************************** * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * * Software Foundation; either version 2 of the License, or any later version.* * This program is distributed in the hope that it will be useful, but WITHOUT* * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details, which is set forth in the readme.txt file. * * You should have received a copy of the GNU General Public License along * * with this program; if not, write to the Free Software Foundation, Inc., 51 * * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * * * This License does not grant you any right to use the trademarks, service * * marks or logos of SanDisk IL Ltd. or SanDisk Corporation. * * Subject to the foregoing, SanDisk IL Ltd., for itself and on behalf of its * * licensors, hereby reserves all intellectual property rights in the program,* * except for the rights expressly granted in this License. * * * ******************************************************************************//*
* $Log: V:/PVCSDB/DiskOnChip/archives/Testing/TrueFFS 6.3/Drop 2.5/3/bddoc/src/docsys.c-arc $
*
* Rev 1.6.1.0 Nov 13 2006 15:13:50 Yaniv.Iarovici
* Added environment variable - 'FL_DISABLE_MEMCPY'.
*
* Rev 1.6 Oct 05 2006 11:00:48 yaniv.iarovici
* Removed support for flUse8Bit.
*
* Rev 1.5 Sep 11 2006 13:45:18 yaniv.iarovici
* Legal header added
*
* Rev 1.4 Aug 09 2006 16:52:44 Polina.Marimont
* initial for DOC Driver 1.0
*/
#include "docsys.h"
#ifdef FL_PARALLEL_MTD_SUPPORT
#include "pacclayr.h"
#endif /* FL_PARALLEL_MTD_SUPPORT */
FLBoolean flPreventMemcpy = 0;
#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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -