flash_amd.h

来自「ADS下的bios工程」· C头文件 代码 · 共 154 行

H
154
字号
/************************************************************************//*                                                                      *//*  AMD Flash Memory Drivers                                            *//*  File name: FLASH.H                                                  *//*  Revision:  1.1  5/07/98                                             *//*                                                                      *//* Copyright (c) 1998 ADVANCED MICRO DEVICES, INC. All Rights Reserved. *//* This software is unpublished and contains the trade secrets and      *//* confidential proprietary information of AMD. Unless otherwise        *//* provided in the Software Agreement associated herewith, it is        *//* licensed in confidence "AS IS" and is not to be reproduced in whole  *//* or part by any means except for backup. Use, duplication, or         *//* disclosure by the Government is subject to the restrictions in       *//* paragraph (b) (3) (B) of the Rights in Technical Data and Computer   *//* Software clause in DFAR 52.227-7013 (a) (Oct 1988).                  *//* Software owned by                                                    *//* Advanced Micro Devices, Inc.,                                        *//* One AMD Place,                                                       *//* P.O. Box 3453                                                        *//* Sunnyvale, CA 94088-3453.                                            *//************************************************************************//*  This software constitutes a basic shell of source code for          *//*  programming all AMD Flash components. AMD                           *//*  will not be responsible for misuse or illegal use of this           *//*  software for devices not supported herein. AMD is providing         *//*  this source code "AS IS" and will not be responsible for            *//*  issues arising from incorrect user implementation of the            *//*  source code herein. It is the user's responsibility to              *//*  properly design-in this source code.                                *//*                                                                      */ /************************************************************************/#ifndef _FLASH_H#define _FLASH_H#define MAXSECTORS  22      /* maximum number of sectors supported *//* A structure for identifying a flash part.  There is one for each * of the flash part definitions.  We need to keep track of the * sector organization, the address register used, and the size * of the sectors. */struct flashinfo {	 char *name;         /* "Am29DL800T", etc. */	 unsigned long addr; /* physical address, once translated */	 int areg;           /* Can be set to zero for all parts */	 int nsect;          /* # of sectors -- 19 in LV, 22 in DL */	 int bank1start;     /* first sector # in bank 1 */	 int bank2start;     /* first sector # in bank 2, if DL part */ struct {	long size;           /* # of bytes in this sector */	long base;           /* offset from beginning of device */	int bank;            /* 1 or 2 for DL; 1 for LV */	 } sec[MAXSECTORS];  /* per-sector info */};/* Standard Boolean declarations */#define TRUE 				1#define FALSE 				0/* Command codes for the flash_command routine */#define FLASH_SELECT    0       /* no command; just perform the mapping */#define FLASH_RESET     1       /* reset to read mode */#define FLASH_READ      1       /* reset to read mode, by any other name */#define FLASH_AUTOSEL   2       /* autoselect (fake Vid on pin 9) */#define FLASH_PROG      3       /* program a word */#define FLASH_CERASE    4       /* chip erase */#define FLASH_SERASE    5       /* sector erase */#define FLASH_ESUSPEND  6       /* suspend sector erase */#define FLASH_ERESUME   7       /* resume sector erase */#define FLASH_UB        8       /* go into unlock bypass mode */#define FLASH_UBPROG    9       /* program a word using unlock bypass */#define FLASH_UBRESET   10      /* reset to read mode from unlock bypass mode */#define FLASH_LASTCMD   10      /* used for parameter checking *//* Return codes from flash_status */#define STATUS_READY    0       /* ready for action */#define STATUS_BUSY     1       /* operation in progress */#define STATUS_ERSUSP   2       /* erase suspended */#define STATUS_TIMEOUT  3       /* operation timed out */#define STATUS_ERROR    4       /* unclassified but unhappy status */#define STATUS_TIMEOUT_AUTOERASE	5#define STATUS_TIMEOUT_PREPROGRAM	6#define STATUS_BUSY_PROGRAMMING		7#define STATUS_BUSY_ERASING		8#define STATUS_BUSY_ERASE_WINDOW_OPEN	9#define STATUS_ERASE_SUSPENDED		10/* Typedefs which should be set by every compiler */typedef unsigned char byte;typedef unsigned short word;typedef unsigned long dword;/* Used to mask of bytes from word data */#define HIGH_BYTE(a) (a >> 8)#define LOW_BYTE(a)  (a & 0xFF)/* AMD's manufacturer ID */#define AMDPART   	0x01/* A list of 4 AMD device ID's - add others as needed */#define ID_AM29DL800T   0x224A#define ID_AM29DL800B   0x22CB#define ID_AM29LV800T   0x22DA#define ID_AM29LV800B   0x225B#define ID_AM29LV160B   0x2249#define ID_AM29LV160T   0x22C4#define ID_AM29LV400B   0x22BA/* An index into the memdesc organization array.  Is set by init_flash *//* so the proper sector tables are used in the correct device          *//* Add others as needed, and as added to the device ID section         */#define AM29DL800T 	0#define AM29DL800B 	1#define AM29LV800T 	2#define AM29LV800B 	3#define AM29LV160B	4#define AM29LV400B	5/* NOTE: some compilers are unhappy if function prototypes are not     *//* provided before they are called.  They can be added in the rare     *//* case they are needed below.                                         */ extern unsigned int init_flash(unsigned int);extern void flash_command(int, int, int, unsigned int);extern int flash_write(int, unsigned short, unsigned char *, unsigned int, int);extern int flash_status(volatile unsigned short *);extern unsigned char flash_sector_erase(unsigned char);extern unsigned char flash_sector_erase_int(unsigned char);extern unsigned char flash_reset(void);extern unsigned short flash_get_device_id(unsigned char);extern unsigned char flash_get_manuf_code(unsigned char);extern unsigned char flash_sector_protect_verify(unsigned char);extern unsigned char flash_get_status(unsigned char);extern unsigned char flash_chip_erase(unsigned char);extern unsigned char flash_write_word(unsigned char, unsigned short, unsigned short);extern unsigned short flash_read_word(unsigned char, unsigned short);extern unsigned char flash_write_string(unsigned char, unsigned short, unsigned char *, unsigned int);extern unsigned char flash_erase_suspend(unsigned char);extern unsigned char flash_erase_resume(unsigned char);extern unsigned char flash_get_sector_size(unsigned char, unsigned int *);extern unsigned char flash_ub(unsigned char);extern unsigned char flash_write_word_ub(unsigned char, unsigned short, unsigned short);extern unsigned char flash_write_string_ub(unsigned char, unsigned short, unsigned char *, unsigned short);extern unsigned char flash_reset_ub(void);extern void flash_get_numsectors(unsigned short *);/* Some Useful macro funtions */#define SECTOR0_SIZE    4096  /* 4K bytes */#endif

⌨️ 快捷键说明

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