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

📄 flashdev.h

📁 完整的Bell实验室的嵌入式文件系统TFS
💻 H
字号:
/* flashdev.h:   Header file for use with 29LV160 for 32 bit mode (2 devices in x16 mode,   or 4 devices in x8 mode).*//* FLASHFUNCSIZE:    Size (in longs) of the array used by the flash operations to copy    functions into RAM space for execution out of non-flash memory.*/#define FLASHFUNCSIZE       500#define FLASH_TIMEOUT       1000000#define WIDTH   4#define ftype               volatile unsigned long#define FLASHERASE          Flasherase32#define ENDFLASHERASE       EndFlasherase32#define FLASHWRITE          Flashwrite32#define ENDFLASHWRITE       EndFlashwrite32#define FLASHEWRITE         Flashewrite32#define ENDFLASHEWRITE      EndFlashewrite32#define FLASHTYPE           Flashtype32#define ENDFLASHTYPE        EndFlashtype32/* Manufacturer and device ids... */#define SWAPPED_AMD29LV160T_X16     0x0100C422#define SWAPPED_AMD29LV160B_X16     0x01004922#define AMD29LV160T_X16         0x000122C4#define AMD29LV160B_X16         0x00012249#define SWAPPED_AMD29LV160T_X8      0xC401#define SWAPPED_AMD29LV160B_X8      0x4901#define AMD29LV160T_X8          0x01C4#define AMD29LV160B_X8          0x0149#define SWAPPED_AMD29DL323DT_X16    0x01005022#define SWAPPED_AMD29DL323DB_X16    0x01005322#define AMD29DL323DT_X16        0x00012250#define AMD29DL323DB_X16        0x00012253#define SWAPPED_AMD29DL323DT_X8     0x5001#define SWAPPED_AMD29DL323DB_X8     0x5301#define AMD29DL323DT_X8         0x0150#define AMD29DL323DB_X8         0x0153#define SWAPPED_AMD29F016D_X8       0xAD01#define AMD29F016D_X8           0x01AD#define AMD29LV160  0   /* AMD29LV160 */#define AMD29DL323DT    1   /* AMD29DL323DT */#define AMD29DL323DB    2   /* AMD29DL323DB */#define AMD29F016D  3   /* AMD29F016D */#define FLASH_TYPES 4/* Different modes that flash devices can be configured. * Some devices can only be configured in x8 mode (X8_ONLY), * eg, AMD29F016D. Some devices can be configured in both x8 * and x16 mode, but on this board are currently configured in x8 * mode (X8_BOTH), eg, AMD29DL323DB on the CLLF-860T board. */#define X8_ONLY     1#define X16_ONLY    2#define X8_BOTH     3#define X16_BOTH    4/* Devices that support only x8 mode or support both x16 and x8, * but are configured for x16. */#if (FLASH_DEV_MODE == X8_ONLY) || (FLASH_DEV_MODE == X16_BOTH)#define BUS_CYCLE_1(V)  (*((ftype *)(fdev->base)+0x555) = \                (V<<24) | (V<<16) | (V<<8) | (V))#define BUS_CYCLE_2(V)  (*((ftype *)(fdev->base)+0x2aa) = \                (V<<24) | (V<<16) | (V<<8) | (V))#define DEVID_OFFSET    (1)#else/* Devices that support x16 and x8 modes, but are configured for x8 mode */#define BUS_CYCLE_1(V)  (*((ftype *)(fdev->base)+0xaaa) = \                (V<<24) | (V<<16) | (V<<8) | (V))#define BUS_CYCLE_2(V)  (*((ftype *)(fdev->base)+0x555) = \                (V<<24) | (V<<16) | (V<<8) | (V))#define DEVID_OFFSET    (2)#endif#if (FLASH_DEV_MODE == X16_ONLY) || (FLASH_DEV_MODE == X16_BOTH)/* Devices configured for x16 mode. */#define FLASH_DEV_WIDTH (sizeof(unsigned short))#define FLASH_DEV_MASK  0x0000FFFF#else/* Devices configured for x8 mode. */#define FLASH_DEV_WIDTH (sizeof(unsigned char))#define FLASH_DEV_MASK  0x000000FF#endif#define BUS_CYCLE_3(V)  BUS_CYCLE_1(V)#define FLASH_RESET     (*(ftype *)fdev->base = 0xf0f0f0f0)#define FLASH_AUTOSELECT    BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    BUS_CYCLE_3(0x90)#define FLASH_GET_MANUF(M)  FLASH_AUTOSELECT; \                M = (*(ftype *)(fdev->base) & FLASH_DEV_MASK)#define FLASH_GET_DEV(D)    FLASH_AUTOSELECT; \                D = (*((ftype *)(fdev->base)+DEVID_OFFSET) & FLASH_DEV_MASK)#define FLASH_GET_ID(M,D)   (((M) << (8*FLASH_DEV_WIDTH))  | (D))#define FLASH_PROGRAM(T,F)  BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    BUS_CYCLE_3(0xa0); \                    *(ftype *)T = *(ftype *)F/* Unlock bypass must be done before FLASH_UNLOCK_BYP_PROG */#define FLASH_UNLOCK_BYP    BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    BUS_CYCLE_3(0x20)#define FLASH_UNLOCK_BYP_PROG(T,F)  *(ftype *)fdev->base = 0xa0a0a0a0; \                        *(ftype *)T = *(ftype *)F#define FLASH_UNLOCK_BYP_RESET      *(ftype *)fdev->base = 0x90909090; \                        *(ftype *)fdev->base = 0x0#define FLASH_CHIP_ERASE    BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    BUS_CYCLE_3(0x80); \                    BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    BUS_CYCLE_3(0x10)#define FLASH_SECTOR_ERASE(SA)  BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    BUS_CYCLE_3(0x80); \                    BUS_CYCLE_1(0xaa); \                    BUS_CYCLE_2(0x55); \                    *(ftype *)(SA) = 0x30303030#define Is_ff(add)          (*(ftype *)add == 0xffffffff)#define Is_not_ff(add)      (*(ftype *)add != 0xffffffff)#define D5_Timeout(add)     ((*(ftype *)add & 0x20202020) == 0x20202020)#define NotAligned(ptr)     ((long)ptr & 3)#define Fwrite(to,frm)      (*(ftype *)to = *(ftype *)frm)#define Is_Equal(p1,p2)     (*(ftype *)p1 == *(ftype *)p2)#define Is_Not_Equal(p1,p2) (*(ftype *)p1 != *(ftype *)p2)

⌨️ 快捷键说明

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