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

📄 docsys.c

📁 电子盘DEMO板程序
💻 C
📖 第 1 页 / 共 4 页
字号:
/******************************************************************************/
/*                                                                            */
/*  Copyright (C), 1995-2006, msystems Ltd. All rights reserved.              */
/*                                                                            */
/*  Redistribution and use in source and binary forms, with or without        */
/*  modification, are permitted provided that the following conditions are    */
/*  met:                                                                      */
/*  1. Redistributions of source code must retain the above copyright notice, */
/*     this list of conditions and the following disclaimer.                  */
/*  2. Redistributions in binary form must reproduce the above copyright      */
/*     notice, this list of conditions and the following disclaimer in the    */
/*     documentation and/or other materials provided with the distribution.   */
/*  3. Neither the name of msystems nor the names of its contributors may be  */
/*     used to endorse or promote products derived from this software without */
/*     specific prior written permission.                                     */
/*                                                                            */
/*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       */
/*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
/*  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR             */
/*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      */
/*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,     */
/*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  */
/*  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    */
/*  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
/*  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      */
/*  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        */
/*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
/*                                                                            */
/******************************************************************************/
/*
 * $Log:   V:/PVCSDB/DiskOnChip/archives/Testing/TrueFFS 6.3/Drop 2.5/3/bddoc/src/docsys.c-arc  $
 * 
 *    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 */

#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.

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

void FAR1 flWrite8bitUsing16bitsSingleShift(volatile  FLByte FAR0 * win, FLWord offset,Reg8bitType val)
{

⌨️ 快捷键说明

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