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

📄 flash.c

📁 WRITE AMD 29LV010 FLASH easy to read and use
💻 C
📖 第 1 页 / 共 3 页
字号:
/************************************************************************/
/*                                                                      */
/*  AMD Flash Memory Drivers                                            */
/*  File name: FLASH.C                                                  */
/*  Re/geon:  1.2  1/07/99                                             */
/*                                                                      */
/* Copyright (c) 1999 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.                                */
/*                                                                      */
/************************************************************************/                                                                        
#include "flash.h"
#include "GBLMACRO.H"              /* Global Constant or Macro definition */
#include "GBLTYPE.H"               /* Global Data Type definitions        */
#include "GBLFUNC.H"               /* Global Function Prototype           */
#include "EXTDATA.H"               /* Global Data definitions             */

/*********************************************************************/
/* The purpose of get_flash_memptr() is to return a memory pointer   */
/* which points to the beginning of memory space allocated for the   */
/* flash.  All function pointers are then referenced from this       */
/* pointer.                                                          */
/*                                                                   */
/* Different systems will implement this in different ways:          */
/* possibilities include:                                            */
/*  - A direct memory pointer                                        */
/*  - A pointer to a memory map                                      */
/*  - A pointer to a hardware port from which the linear             */
/*    address is translated                                          */
/*  - Output of an MMU function / service                            */
/*                                                                   */
/* Also note that this function expects the pointer to a specific    */
/* sector of the device.  This can be provided by dereferencing      */
/* the pointer from a translated offset of the sector from a         */
/* global base pointer (e.g. flashptr = base_pointer + sector_offset)*/
/*                                                                   */
/* Important: Many AMD flash devices need both bank and or sector    */
/* address bits to be correctly set (bank address bits are A18-A16,  */
/* and sector address bits are A18-A12, or A12-A15).  Flash parts    */
/* which do not need these bits will ignore them, so it is safe to   */
/* assume that every part will require these bits to be set.         */
/*********************************************************************/

dword get_flash_memptr(int sector);

struct flashinfo *meminfo; /* A pointer into a specific field defined
                              in memdesc below */
/*********************************************************************/
/* Memdesc is a global storage array for sector and bank parameters. */
/* This can be found and inputted directly from any AMD specification*/
/* sheet.  If minimal static data storage is required, all other     */
/* declarations can be removed except for the flash component being  */
/* used in the application.                                          */
/* Four examples are provided of common flash devices                */
/* Also note the specifics to bank / sector locations when dealing   */
/* with DL flash parts.                                              */
/*********************************************************************/

struct flashinfo memdesc[] = {
         /* DL800T */
        {"Am29DL800T", 0L, 0, 22, 14, 0 ,{
        {65536,     0x00000,    2},
        {65536,     0x10000,    2},
        {65536,     0x20000,    2},
        {65536,     0x30000,    2},
        {65536,     0x40000,    2},
        {65536,     0x50000,    2},
        {65536,     0x60000,    2},
        {65536,     0x70000,    2},
        {65536,     0x80000,    2},
        {65536,     0x90000,    2},
        {65536,     0xA0000,    2},
        {65536,     0xB0000,    2},
        {65536,     0xC0000,    2},
        {65536,     0xD0000,    2},
        {16384,     0xE0000,    1},
        {32768,     0xE4000,    1},
        {8192,      0xEC000,    1},
        {8192,      0xEE000,    1},
        {8192,      0xF0000,    1},
        {8192,      0xF2000,    1},
        {32768,     0xF4000,    1},
        {16384,     0xFC000,    1}
        }
         },
         /* DL800B */
        {"Am29DL800B", 0L, 0, 22, 0, 8 ,{
        {16384,     0x00000,    1},
        {32768,     0x04000,    1},
        {8192,      0x0C000,    1},
        {8192,      0x0E000,    1},
        {8192,      0x10000,    1},
        {8192,      0x12000,    1},
        {32768,     0x14000,    1},
        {16384,     0x1C000,    1},
        {65536,     0x20000,    2},
        {65536,     0x30000,    2},
        {65536,     0x40000,    2},
        {65536,     0x50000,    2},
        {65536,     0x60000,    2},
        {65536,     0x70000,    2},
        {65536,     0x80000,    2},
        {65536,     0x90000,    2},
        {65536,     0xA0000,    2},
        {65536,     0xB0000,    2},
        {65536,     0xC0000,    2},
        {65536,     0xD0000,    2},
        {65536,     0xE0000,    2},
        {65536,     0xF0000,    2}
        }
        },
         /* LV800T */
        {"Am29LV800T", 0L, 0, 19, 0, 4 ,{
        {65536,     0x00000,    1},
        {65536,     0x10000,    1},
        {65536,     0x20000,    1},
        {65536,     0x30000,    1},
        {65536,     0x40000,    1},
        {65536,     0x50000,    1},
        {65536,     0x60000,    1},
        {65536,     0x70000,    1},
        {65536,     0x80000,    1},
        {65536,     0x90000,    1},
        {65536,     0xA0000,    1},
        {65536,     0xB0000,    1},
        {65536,     0xC0000,    1},
        {65536,     0xD0000,    1},
        {65536,     0xE0000,    1},
        {32768,     0xF0000,    1},
        {8192,      0xF8000,    1},
        {8192,      0xFA000,    1},
        {16384,     0xFC000,    1}
        }
        },
         /* LV800B */
        {"Am29LV800B", 0L, 0, 19, 0, 4 ,{
        {16384,     0x00000,    1},
        {8192,      0x04000,    1},
        {8192,      0x06000,    1},
        {32768,     0x08000,    1},
        {65536,     0x10000,    1},
        {65536,     0x20000,    1},
        {65536,     0x30000,    1},
        {65536,     0x40000,    1},
        {65536,     0x50000,    1},
        {65536,     0x60000,    1},
        {65536,     0x70000,    1},
        {65536,     0x90000,    1},
        {65536,     0xA0000,    1},
        {65536,     0xB0000,    1},
        {65536,     0xC0000,    1},
        {65536,     0xD0000,    1},
        {65536,     0xE0000,    1},
        {65536,     0xF0000,    1}
        }
        },
        /* LV160B - same as LV800B, but limited to 2MB addressing window*/
        {"Am29LV160B", 0L, 0, 19, 0, 0 ,{
        {8192,     0x00000,    1},
        {4096,     0x02000,    1},
        {4096,     0x03000,    1},
        {16384,    0x04000,    1},
        {32768,    0x08000,    1},
        {32768,    0x10000,    1},
        {32768,    0x18000,    1},
        {32768,    0x20000,    1},
        {32768,    0x28000,    1},
        {32768,    0x30000,    1},
        {32768,    0x38000,    1},
        {32768,    0x40000,    1},
        {32768,    0x48000,    1},
        {32768,    0x50000,    1},
        {32768,    0x58000,    1},
        {32768,    0x60000,    1},
        {32768,    0x68000,    1},
        {32768,    0x70000,    1},
        {32768,    0x78000,    1}
        }
        },
/*      {"Am29LV160B", 0L, 0, 19, 0, 0 ,{
        {16384,     0x00000,    1},
        {8192,      0x04000,    1},
        {8192,      0x06000,    1},
        {32768,     0x08000,    1},
        {65536,     0x10000,    1},
        {65536,     0x20000,    1},
        {65536,     0x30000,    1},
        {65536,     0x40000,    1},
        {65536,     0x50000,    1},
        {65536,     0x60000,    1},
        {65536,     0x70000,    1},
        {65536,     0x80000,    1},
        {65536,     0x90000,    1},
        {65536,     0xA0000,    1},
        {65536,     0xB0000,    1},
        {65536,     0xC0000,    1},
        {65536,     0xD0000,    1},
        {65536,     0xE0000,    1},
        {65536,     0xF0000,    1}
        }
        },         */
        /* LV400B */
        {"Am29LV400B", 0L, 0, 11, 0, 0 ,{
        {16384,     0x00000,    1},
        {8192,      0x04000,    1},
        {8192,      0x06000,    1},
        {32768,     0x08000,    1},
        {65536,     0x10000,    1},
        {65536,     0x20000,    1},
        {65536,     0x30000,    1},
        {65536,     0x40000,    1},
        {65536,     0x50000,    1},
        {65536,     0x60000,    1},
        {65536,     0x70000,    1},
        }
        }
};

/*********************************************************************/
/* init_flash() performs any initial memory allocation, setting of   */
/* parameters, and also initializes the appropriate sector table     */
/* defined above.                                                    */
/* Memory mapping or allocation specifics will need to be provided   */
/* by the programmer of the driver, and will be highly dependant on  */
/* on the system being used.                                         */
/*********************************************************************/

unsigned int init_flash(unsigned int flashtype)
{
  /* Insert any memory initialization or memory mapping here */

  meminfo = &memdesc[flashtype];

  return(1);
}
dword get_flash_memptr(int sector)
{
  dword addr;
  addr=0x5600000+0x10000*sector;
  return addr;
}

/*********************************************************************/
/* Flash_command() is the main driver function.  It performs         */
/* every possible command available to AMD B revision                */
/* flash parts. Note that this command is not used directly, but     */
/* rather called through the API wrapper functions provided below.   */
/* This function can be called directly if desired (see wrapper      */
/* functions defined below.                                          */
/*********************************************************************/

void flash_command(int command, int sector, int offset,
                                                 unsigned int data)
{
         static byte base;    /* base offset for our sector */

⌨️ 快捷键说明

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