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

📄 flash.h

📁 傅里叶变换
💻 H
字号:
/************************************************************************/
/*                                                                      */
/*  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_AUTOSEL_EXIT   12       /* 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_PROG2          11      /* used for TMS320C5410 direct addressing */
#define FLASH_LASTCMD        11      /* 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 */

/* 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
#define SSTPART     0xBF

/* 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                                        
#define ID_SST39XF400   0x2780
#define ID_SST39XF800   0x2781
#define ID_SST39XF160   0x2782

/* 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
#define SST39XF800  6
#define SST39XF160  7

/* 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.                                         */


#endif
extern struct flashinfo *meminfo; /* A pointer into a specific field defined
                             in memdesc below */
extern struct flashinfo memdesc[];          

unsigned long get_flash_memptr(int sector);
void write_prog(unsigned long address, unsigned int data);
void read_prog(unsigned long address, unsigned int *data);
unsigned int init_flash(unsigned int flashtype);
void flash_command(int command, int sector, unsigned int offset,unsigned int data);
int flash_write(int sector, unsigned offset, byte *buf,int nbytes, int ub);
int flash_status(unsigned long fp);
byte flash_sector_erase(byte sector);
byte flash_sector_erase_int(byte sector);
byte flash_reset(void);
word flash_get_device_id(byte sector);
byte flash_get_manuf_code(byte sector);
byte flash_sector_protect_verify(byte sector);
byte flash_get_status(byte sector);
byte flash_chip_erase(byte sector);
byte flash_write_word(byte sector, word offset, word data);
byte flash_write_word2(unsigned long address, word data);
word flash_read_word(byte sector, word offset);
byte flash_write_string(byte sector, word offset,byte *buffer, word numbytes);
byte flash_erase_suspend(byte sector);
byte flash_erase_resume(byte sector);
byte flash_get_sector_size(byte sector, dword *size);
byte flash_ub(byte sector);
byte flash_write_word_ub(byte sector, word offset, word data);
byte flash_write_string_ub(byte sector, word offset,byte *buffer, word numbytes);
byte flash_reset_ub(void);
void flash_get_numsectors(int *num);

⌨️ 快捷键说明

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