📄 i28f640.c
字号:
/* * $Log: V:/i28f008.c_v $ * * Rev 1.16 06 Oct 1997 18:37:30 ANDRY * no COBUX * * Rev 1.15 05 Oct 1997 15:32:40 ANDRY * COBUX (16-bit Motorola M68360 board) * * Rev 1.14 05 Oct 1997 14:35:36 ANDRY * flNeedVpp() and flDontNeedVpp() are under #ifdef SOCKET_12_VOLTS * * Rev 1.13 10 Sep 1997 16:18:10 danig * Got rid of generic names * * Rev 1.12 04 Sep 1997 18:47:20 danig * Debug messages * * Rev 1.11 31 Aug 1997 15:06:40 danig * Registration routine return status * * Rev 1.10 24 Jul 1997 17:52:30 amirban * FAR to FAR0 * * Rev 1.9 21 Jul 1997 14:44:06 danig * No parallelLimit * * Rev 1.8 20 Jul 1997 17:17:00 amirban * No watchDogTimer * * Rev 1.7 07 Jul 1997 15:22:06 amirban * Ver 2.0 * * Rev 1.6 15 Apr 1997 19:16:40 danig * Pointer conversions. * * Rev 1.5 29 Aug 1996 14:17:48 amirban * Warnings * * Rev 1.4 18 Aug 1996 13:48:44 amirban * Comments * * Rev 1.3 31 Jul 1996 14:31:10 amirban * Background stuff * * Rev 1.2 04 Jul 1996 18:20:06 amirban * New flag field * * Rev 1.1 03 Jun 1996 16:28:58 amirban * Cobra additions * * Rev 1.0 20 Mar 1996 13:33:06 amirban * Initial revision. *//************************************************************************//* *//* FAT-FTL Lite Software Development Kit *//* Copyright (C) M-Systems Ltd. 1995-1996 *//* *//************************************************************************//*----------------------------------------------------------------------*//* *//* This MTD supports the following Flash technologies: *//* *//* - Intel 28F008/Cobra 8-mbit devices *//* - Intel 28F016SA/28016SV/Cobra 16-mbit devices (byte-mode operation) *//* *//* And (among else), the following Flash media and cards: *//* *//* - Intel Series-2 PCMCIA cards *//* - Intel Series-2+ PCMCIA cards *//* - M-Systems ISA/Tiny/PC-104 Flash Disks *//* - M-Systems NOR PCMCIA cards *//* - Intel Value-100 cards *//* *//*----------------------------------------------------------------------*/#include "tffs/flflash.h"#include "tffs/backgrnd.h"#include "flash.h" /* add by zoutl 2003/2/21 */#define flash (*pFlash)#define SETUP_ERASE 0x20#define SETUP_WRITE 0x40#define CLEAR_STATUS 0x50#define READ_STATUS 0x70#define READ_ID 0x90#define SUSPEND_ERASE 0xb0#define CONFIRM_ERASE 0xd0#define RESUME_ERASE 0xd0#define READ_ARRAY 0xff#define WSM_ERROR 0x38#define WSM_VPP_ERROR 0x08#define WSM_SUSPENDED 0x40#define WSM_READY 0x80/* JEDEC ids for this MTD */#define I28F008_FLASH 0x89a2#define I28F016_FLASH 0x89a0#define COBRA004_FLASH 0x89a7#define COBRA008_FLASH 0x89a6#define COBRA016_FLASH 0x89aa#define MOBILE_MAX_INLV_4 0x8989#define LDP_1MB_IN_16BIT_MODE 0x89ff/* Definition of MTD specific vol.flags bits: */#define NO_12VOLTS 0x100 /* Card does not need 12 Volts Vpp */unsigned char data[4*1024];/*----------------------------------------------------------------------*//* i 2 8 f 6 4 0 W r i t e *//* *//* Write a block of bytes to Flash *//* *//* This routine will be registered as the MTD vol.write routine *//* *//* Parameters: *//* vol : Pointer identifying drive *//* address : Card address to write to *//* buffer : Address of data to write *//* length : Number of bytes to write *//* overwrite : TRUE if overwriting old Flash contents *//* FALSE if old contents are known to be erased *//* *//* Returns: *//* FLStatus : 0 on success, failed otherwise *//*----------------------------------------------------------------------*/static FLStatus i28f640Write(FLFlash vol, CardAddress address, const void FAR1 *buffer, int length, FLBoolean overwrite){ int rtValue; /* printf("i28f640Write written address is %#x and length is %#x\n",address,length);*//* printf("write address is: 0x%x\n",address); printf("Write value is:\n"); for (i=0;i<length;i++) { if(i%16==0&&i!=0) printf("\n"); printf("%02x ",*((UCHAR *)buffer+i)); }*/ rtValue = FlashWrite(address,(ULONG)length,(UCHAR *)buffer); if (rtValue == ERROR) { printf("Write failed!\n"); return flWriteFault; } /*printf("\n\nLeaving i28f640Write() successful!\n\n");*/ return flOK;}static FLStatus i28f640Read(FLFlash vol, CardAddress address, void FAR1 *buffer, int length, FLBoolean overwrite){ int rtValue; /* printf("i28f640Write written address is %#x and length is %#x\n",address,length);*/ rtValue = FlashRead(address,(ULONG)length,(UCHAR *)buffer);/* printf("read address is: 0x%x\n",address); printf("read value is:\n"); for (i=0;i<length;i++) { if(i%16==0&&i!=0) printf("\n"); printf("%02x ",*((UCHAR *)buffer+i)); } printf("\n");*/ if (rtValue == ERROR) { printf("Read failed!\n"); return flWriteFault; } /*printf("Leaving i28f640Read() successful!\n\n");*/ return flOK;}/*----------------------------------------------------------------------*//* i 2 8 f 6 4 0 E r a s e *//* *//* Erase one or more contiguous Flash erasable blocks *//* *//* This routine will be registered as the MTD vol.erase routine *//* *//* Parameters: *//* vol : Pointer identifying drive *//* firstErasableBlock : Number of first block to erase *//* numOfErasableBlocks: Number of blocks to erase *//* *//* Returns: *//* FLStatus : 0 on success, failed otherwise *//*----------------------------------------------------------------------*/static FLStatus i28f640Erase(FLFlash vol, int firstErasableBlock, int numOfErasableBlocks){ CardAddress SectorAddr; int i; SectorAddr = firstErasableBlock * vol.erasableBlockSize ; printf("\nEntering i28f640Erase()\n erased address is %x\n",(unsigned int)SectorAddr); /* modified by zoutl 2003/2/21 */ for (i=0; i< numOfErasableBlocks; i++) { if(ERROR==FlashEraseSector(SectorAddr)) { printf("FlashEraseSector failed!\n"); return flWriteFault; } SectorAddr += (vol.erasableBlockSize); } /*printf("Leaving i28f640Erase() successful\n\n");*/ return flOK; }/*static void FAR0 * i28f640Map ( FLFlash vol, CardAddress address, int length ){ i28f640Read(&vol,address,data,length, 0); vol.socket->remapped = TRUE; return (void FAR0 *)data;}*//*----------------------------------------------------------------------*//* i 2 8 f 6 4 0 I d e n t i f y *//* *//* Identifies media based on Intel 28F008 and Intel 28F016 and *//* registers as an MTD for such *//* *//* This routine will be placed on the MTD list in custom.h. It must be *//* an extern routine. *//* *//* On successful identification, the Flash structure is filled out and *//* the write and erase routines registered. *//* *//* Parameters: *//* vol : Pointer identifying drive *//* *//* Returns: *//* FLStatus : 0 on positive identificaion, failed otherwise *//*----------------------------------------------------------------------*/FLStatus i28f640Identify(FLFlash vol){ vol.erasableBlockSize = (/*0x20000L * 2*/128*1024); /* Each chip is 0x10000 and there are 8 chips total */ vol.chipSize =0x800000/*512*1024*/; /* This is actually less then the size of each chip, but this way tffs is fooled into thinking that the flash memory space is smaller then it is. This is to prevent tffs from writing over the bootrom stored at 0xfff00000 */ vol.noOfChips = 1; /* Tffs uses chipSize and noOfChips to calculate tfs memory size vol.chipSize * vol.noOfChips */ vol.interleaving = 1; vol.chipSize = flFitInSocketWindow (vol.chipSize, vol.interleaving, vol.socket->window.size); vol.read = i28f640Read; vol.write = i28f640Write; /*vol.map = i28f640Map;*/ /*vol.write = i28f016Write;*/ vol.erase = i28f640Erase; return flOK;}FLStatus flRegisterI28F640(void){ if (noOfMTDs >= MTDS) return flTooManyComponents; mtdTable[noOfMTDs++] = i28f640Identify; return flOK;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -