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

📄 flxscale.c

📁 Intel PXA270 Wince5.0 BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * $Log:   V:/Flite/archives/TrueFFS5/Src/ext_acc/flxscale.c_V  $
 * 
 *    Rev 1.0   Jun 17 2002 13:22:46   oris
 * Initial revision.
 */

/***********************************************************************************/
/*                        M-Systems Confidential                                   */
/*           Copyright (C) M-Systems Flash Disk Pioneers Ltd. 1995-2002            */
/*                         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                            */
/***********************************************************************************/

/************************************************************************/
/* File Header                                                          */
/* -----------                                                          */
/* Name : flxscale.c                                                    */
/*                                                                      */
/* Description : This file contains the memory access layer code for    */
/*               DiskOnChip MTD customized for the X-Scale CPU.         */
/*                                                                      */
/* Note : The code support a 16bit DiskOnChip connected with no address */
/*        shift on to a platform that supports 16-bit access to the     */
/*        DiskOnChip memory range and is configured with if_cfg set to  */
/*        16-bit interface.                                             */
/* Note : The implementation takes into acount that read, write and set */
/*        routines are always called with the offset of 0x800. Which is */
/*        the case for the mdocplus.c MTD.                              */
/*                                                                      */
/************************************************************************/

/**************************************************************************/
/* Instructions for including X-Scale support                             */
/* ------------------------------------------                             */
/* 1. Include flxscale.c in your application/driver project               */
/* 2. Before calling any SDK routine (even initialization  routines) add  */
/*    the following lines of code:                                        */
/*   a. #include "docsys.h"                                               */
/*   b. extern FLStatus flSetPlatformIsXscale(byte socketNo,dword flags); */
/*   c. flSetPlatformIsXscale(x,0);                                       */
/*                                                                        */
/* Notes                                                                  */
/* -----                                                                  */
/* 1. The first argument of 2.c should in fact be the socket number for   */
/*    which you want to add X-Scale support. If you have only 1           */
/*    DiskOnChip device in your target platform, then you should use 0.   */
/*    In any other case use a for loop to initialize all of your socket.  */
/*    When using the Boot SDK the first argument must be set to 0         */
/* 2. The support for X-Scale processors can be disabled by calling:      */
/*   a. bdkInit() routine while using the Boot SDK.                       */
/*   b. flExit() routine while using the TrueFFS SDK.                     */
/* 3. If you know you are using an X-Scale platform, you can remove the   */
/*    extra code found in docsys.c simply by leaving it out of the build  */
/*    and uncomment the setBusTypeOfFlash routine found bellow.           */
/**************************************************************************/

#ifndef XSCALE_H
#define XSCALE_H

#include "docsys.h"

#ifndef MTD_STANDALONE
void flInitGlobalVars(void);
#endif /* MTD_STANDALONE */

#ifndef FL_NO_USE_FUNC

/* 
 * If you want to remove the docsys.c file out of the build uncomment 
 * the following lines:
 */

/* FLStatus  setBusTypeOfFlash(FLFlash * flash,dword access)
 * {
 *   return flOK;
 * }
 */

/*********************************************************/
/*     Report DiskOnChip Memory Size                     */
/*********************************************************/

/*---------------------------------------------------------------------- 
   f l X s c a l e 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 flXscaleDocMemWinSizeNoShift(void)
{
  return 0x2000;
}

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

/*---------------------------------------------------------------------- 
   f l X s c a l e 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 flXscaleWrite16bitUsing16bitsNoShift(volatile  byte FAR0 * win, word offset,Reg16bitType val)
{
  ((volatile word FAR0*)win)[offset>>1] = val;
}

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

/*----------------------------------------------------------------------
   f l X s c a l e 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 flXscaleRead16bitUsing16bitsNoShift(volatile  byte FAR0 * win,word offset)
{
  return ((volatile word FAR0*)win)[offset>>1];
}

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

/*----------------------------------------------------------------------
   f l X s c a l e 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 flXscaleWrite8bitUsing16bitsNoShift(volatile  byte FAR0 * win, word offset,Reg8bitType val)
{
#ifdef FL_BIG_ENDIAN
  ((volatile word FAR0 *)win)[offset>>1] = ((word)val)<<8;
#else
  ((volatile word FAR0 *)win)[offset>>1] = (word)val;
#endif /* FL_BIG_ENDIAN */
}

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

/*----------------------------------------------------------------------
   f l X s c a l e 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 flXscaleRead8bitUsing16bitsNoShift(volatile  byte FAR0 * win,word offset)
{
#ifdef FL_BIG_ENDIAN
   return (((offset & 0x1) == 0) ?
#else
   return (( offset & 0x1      ) ?
#endif /* FL_BIG_ENDIAN */
           (Reg8bitType)(((volatile word FAR0 *)win)[offset>>1]>>8) :
           (Reg8bitType) ((volatile word FAR0 *)win)[offset>>1]    );
}

/*********************************************************/
/***    Operation on several bytes (read/write/set)    ***/
/*********************************************************/

/*********************************************************/
/*                   Interleave - 2                      */
/*********************************************************/

/*----------------------------------------------------------------------
   f l X s c a l e 1 6 b i t D o c R e a d N o S h i f t
 
   Note : Offset is always set to the DiskOnChip IO registers (0x800)

   Read 'count' bytes from M+ DiskOnChip with none shifted address bus.
------------------------------------------------------------------------*/

void flXscale16bitDocReadNoShift (volatile  byte FAR0 * win, word offset, byte FAR1 * dest, word count )
{
   volatile word FAR0 * swin = (volatile word FAR0 *)( win + 0x802);
   register int         i;
   register word        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( pointerToPhysical(dest) & 0x1 )
   {
      /* rare case: unaligned target buffer */
      for (i = 0; i < (int)count; )
      {
         tmp = *swin;
#ifdef FL_BIG_ENDIAN
         dest[i++] = (byte)(tmp>>8);
         dest[i++] = (byte)tmp;
#else
         dest[i++] = (byte)tmp;
         dest[i++] = (byte)(tmp>>8);
#endif /* FL_BIG_ENDIAN */
      }
   }
   else
   {  /* mainstream case */
      /* read in short words */
      for (i = 0, count = count >> 1; i < (int)count; i++)
         ((word FAR1 *)dest)[i] = *swin;
   }
}

/*----------------------------------------------------------------------
   f l X s c a l e 1 6 b i t D o c W r i t e N o S h i f t
 
   Note : Offset is always set to the DiskOnChip IO registers (0x800)

⌨️ 快捷键说明

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