亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? flash.c

?? 《嵌入式固件開發》一書的源碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* This file contains all of the flash support code that does not need   to be relocated to RAM.  Two separate files (flash.c and flashpic.c)   are maintained because under certain compilers, they may need to be   compiled with different options to be made position independent.   NOTE: THESE FUNCTIONS ARE NOT RE-ENTRANT!!!  All of the FLASH routines   assume they can copy themselves into the array FlashFunc[]; hence, only   one operation can be active at any time.*/#include "config.h"#if INCLUDE_FLASH#include "cpu.h"#include "flash.h"typedef unsigned char uchar;typedef unsigned short ushort;typedef unsigned long ulong;typedef volatile unsigned char vuchar;typedef volatile unsigned short vushort;typedef volatile unsigned long vulong;typedef volatile unsigned int vuint;typedef volatile int vint;extern int FLASHTYPE();extern int ENDFLASHTYPE();extern int FLASHWRITE();extern int ENDFLASHWRITE();extern int FLASHEWRITE();extern int ENDFLASHEWRITE();extern int FLASHERASE();extern int ENDFLASHERASE();int FlashOpError();/* FlashFunc[]:   This array will contain the flash operation function that is executing.   Recall that to operate on the flash, you cannot be executing out of it.   The flash functions are copied here, then executed through the function   pointer flashfunc which is set to point to FlashFunc.*/long    FlashFunc[FLASHFUNCSIZE];int (*flashfunc)();/* FlashProtectWindow:   Must be set to allow any flash operation to be done on space assumed   to be boot code.*/int FlashProtectWindow;/* FlashBank[]:   This structure contains all of the information that must be made available   to the various flash operation commands.  It is initialized by flashtype()   and used thereafter by the other operations.*/struct  flashinfo FlashBank[FLASHBANKS];/* FlashNamId[]:   Used to correlate between the ID and a string representing the name   of the flash device.  */struct flashdesc FlashNamId[] = {        AMD29LV160B,    "AMD-29LV160B",        AMD29LV160T,    "AMD-29LV160T",};/* SectorSizes160B:    There are a total of 35 sectors for this part.  This table reflects the    size of each sector based on the fact that this configuration is for a    x32 configuration (2 devices are used, each in x16 mode).  */int SectorSizes160B[] = {        0x8000,  0x4000,  0x4000,  0x10000, 0x20000,        0x20000, 0x20000, 0x20000, 0x20000, 0x20000,        0x20000, 0x20000, 0x20000, 0x20000, 0x20000,        0x20000, 0x20000, 0x20000, 0x20000, 0x20000,        0x20000, 0x20000, 0x20000, 0x20000, 0x20000,        0x20000, 0x20000, 0x20000, 0x20000, 0x20000,        0x20000, 0x20000, 0x20000, 0x20000, 0x20000,};showflashtype(id)ulong id;{    int i;    for(i=0;i<sizeof FlashNamId/sizeof(struct flashdesc);i++) {        if (id == FlashNamId[i].id) {            printf("Device = %s\n",FlashNamId[i].desc);            return(0);        }    }    printf("Flash id 0x%04x not recognized\n",id);    return(-1);}showflashinfo(fdev)struct flashinfo *fdev;{    int i;    if (showflashtype(fdev->id) < 0)        return(-1);    printf("  Base addr   : 0x%08x\n",fdev->base);    printf("  Sectors     : %d\n",fdev->sectorcnt);    printf("  Bank width  : %d bytes\n",fdev->width);    printf("  Sector     Begin       End        Size     SW-Protected?\n");    for(i=0;i<fdev->sectorcnt;i++) {        printf("    %2d    0x%08x  0x%08x  0x%06x      %s\n",            i,fdev->sectors[i].begin,fdev->sectors[i].end,            fdev->sectors[i].size,            fdev->sectors[i].protected ? "yes" : " no");    }    return(0);}/* flashopload():   Used by all flash operations to load the appropriate flash function into   ram.  It first verifies that the request is not larger than the allocated   area (FlashFunc[]), then it copies, and verifies the copy.  Finally,   caches are flushed.   Note that this function is copying code into data space with the intent   that the code will be executed shortly.  This means that after the code   is copied to data space the data cache MUST be flushed (to insure that the   code is in physical memory) and the instruction cache MUST be invalidated   (to insure that there is no instruction cached from a previous run of   this function that may have copied different code to the data space).   The generic calls to preFlashopload() and postFlashopload() are used   to keep this function generic.*/flashopload(begin,end)ulong   *begin, *end;{    extern  ulong preFlashopload(), postFlashopload();    volatile ulong  *bp, *copy;    int ret, mode;    /* Verify space availability: */    if (((int)end - (int)begin) >= sizeof FlashFunc) {        printf("flashopload overflow ((0x%x-0x%x) > 0x%x)\n",            end,begin,sizeof FlashFunc);        return(-1);    }    ret = 0;    mode = preFlashopload((char *)FlashFunc,        (char *)(&FlashFunc[FLASHFUNCSIZE-1]));    /* Copy function() to RAM, then verify: */    copy = (ulong *)FlashFunc;    bp = begin;    while(bp <= end) {        *copy = *bp;        if (*copy++ != *bp++) {            printf("flashopload failed\n");            ret = -1;            break;        }    }    postFlashopload(mode,(char *)FlashFunc,        (char *)(&FlashFunc[FLASHFUNCSIZE-1]));    flashfunc = (int(*)())FlashFunc;    return(ret);}/* flashtype():   Copy the Flashtype() function to the array FlashFunc[], then use   the function pointer flashfunc to call the routine relocated to   RAM space.*/flashtype(fdev)struct flashinfo *fdev;{    int ret;    if (flashopload((ulong *)FLASHTYPE,(ulong *)ENDFLASHTYPE) < 0)        return(-1);    ret = flashfunc(fdev);    return(ret);}/* flasherase():   Copy the Flasherase() function to the array FlashFunc[], then use   the function pointer flashfunc to call the routine relocated to   RAM space.*/flasherase(fdev,snum)struct  flashinfo *fdev;int snum;{    if (flashopload((ulong *)FLASHERASE,(ulong *)ENDFLASHERASE) < 0)        return(-1);    return(flashfunc(fdev,snum));}/* flashwrite():   Copy the Flashwrite() function to the array FlashFunc[], then use   the function pointer flashfunc to call the routine relocated to   RAM space.   First make a few checks on the request, then write to flash if all   checks succeed.*/flashwrite(fdev,dest,src,bytecnt)struct  flashinfo *fdev;uchar   *src, *dest;long    bytecnt;{    int i, j, lowsector, highsector;    register uchar  *dp, *sp, *edp;    dp = dest;    sp = src;    edp = (dest + bytecnt) - 1;    /* If outside the devices space, return failed.. */    if ((edp < fdev->sectors[0].begin) ||        (dp > fdev->sectors[fdev->sectorcnt-1].end)) {        printf("flashwrite() failed: dest out of flash range\n");        return(-1);    }    /* Make sure the destination is not within a protected sector */    if (FlashProtectWindow == FLASH_PROTECT_WINDOW_CLOSED) {        /* First determine the sectors that overlap with the */        /* flash space to be written... */        lowsector = highsector = -1;        for(j=0;j<fdev->sectorcnt;j++) {            if ((dp >= fdev->sectors[j].begin) &&                (dp <= fdev->sectors[j].end))                lowsector = j;        }        for(j=0;j<fdev->sectorcnt;j++) {            if ((edp >= fdev->sectors[j].begin) &&                (edp <= fdev->sectors[j].end))                highsector = j;        }        if ((lowsector == -1) || (highsector == -1)) {            printf("flashwrite() failed: can't find sector\n");            return(-1);        }        /* Now that the range of affected sectors is known, */        /* verify that those sectors are not protected... */        for(j=lowsector;j<=highsector;j++) {            if (fdev->sectors[j].protected) {                printf("flashwrite() failed: sector protected\n");                return(-1);            }        }    }    /* Now make sure that there is no attempt to transition a bit */    /* in the affected range from 0 to 1...  A flash write can only */    /* bring bits low (erase brings them  high). */    while(dp < edp) {        if ((*dp & *sp) != *sp) {            printf("flashwrite() failed: bit 0->1 rqst denied.\n");            return(-1);        }        dp++;         sp++;    }    if (flashopload((ulong *)FLASHWRITE,(ulong *)ENDFLASHWRITE) < 0) {        printf("flashopload() failed\n");        return(-1);    }    return(flashfunc(fdev,dest,src,bytecnt));}/* flashewrite():   Copy the Flashewrite() function to the array FlashFunc[], then use   the function pointer flashfunc to call the routine relocated to   RAM space.*/flashewrite(fdev,dest,src,bytecnt)struct  flashinfo *fdev;ulong   *src, *dest;long    bytecnt;{    int i;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一级二级三级久久久| 亚洲精品欧美激情| 国产盗摄精品一区二区三区在线 | 国产欧美一区二区精品性色 | 欧美大片在线观看一区二区| 国内精品伊人久久久久av一坑| 精品国产精品一区二区夜夜嗨| 韩国毛片一区二区三区| 欧美国产乱子伦 | 国产午夜精品久久久久久免费视 | 欧美日韩精品三区| 视频一区二区不卡| 国产精品一区在线| 欧美日韩一区成人| 亚洲成av人影院| 欧美v国产在线一区二区三区| 黄一区二区三区| 国产精品视频一二三区| 色久综合一二码| 日本午夜一区二区| 久久精品夜色噜噜亚洲a∨| 国产成人一区在线| 一区二区三区中文字幕在线观看| 欧美高清精品3d| 麻豆国产欧美日韩综合精品二区| 国产日韩精品久久久| 欧美综合天天夜夜久久| 久久99国产精品久久99| 国产精品网曝门| 欧美视频一区二区三区四区| 久久精品国产精品亚洲红杏| 综合亚洲深深色噜噜狠狠网站| 欧美日本不卡视频| 国产成人aaa| 亚洲午夜三级在线| 久久久久国产成人精品亚洲午夜| 一本大道久久精品懂色aⅴ| 人禽交欧美网站| 中文字幕中文字幕在线一区| 亚洲精品免费视频| 日韩久久免费av| 91视频精品在这里| 久久不见久久见免费视频1| 亚洲视频一区二区在线观看| 欧美草草影院在线视频| 色综合中文字幕国产| 天天操天天干天天综合网| 国产亚洲成aⅴ人片在线观看| 欧美三级在线视频| 成人性生交大片免费看中文| 三级不卡在线观看| 中文字幕一区二区在线播放 | 欧美mv和日韩mv的网站| 色老汉一区二区三区| 国产精品一区二区久久精品爱涩| 亚洲国产综合色| 中文字幕精品综合| 欧美不卡一区二区| 欧美在线观看一二区| 国产成人丝袜美腿| 日本不卡的三区四区五区| 亚洲精品亚洲人成人网在线播放| 26uuu国产日韩综合| 欧美卡1卡2卡| 91蜜桃免费观看视频| 国产麻豆精品久久一二三| 日韩影视精彩在线| 亚洲激情欧美激情| 中文字幕欧美国产| 精品国产免费一区二区三区四区 | 日韩一级成人av| 日本韩国欧美一区二区三区| 国产成人免费xxxxxxxx| 麻豆91精品91久久久的内涵| 亚洲一二三四区| 自拍偷拍欧美精品| 国产欧美一区二区精品性| 精品欧美乱码久久久久久| 欧美日本一区二区三区| 日本高清无吗v一区| 成人h版在线观看| 国产精品自在欧美一区| 久久成人免费电影| 日韩经典一区二区| 亚洲成人av一区二区三区| 综合分类小说区另类春色亚洲小说欧美| 久久久亚洲精华液精华液精华液 | 91精品国产综合久久久久久漫画| 欧美中文字幕不卡| 91精品福利视频| 91女人视频在线观看| 不卡在线视频中文字幕| 国产精品性做久久久久久| 国内精品久久久久影院色| 日本vs亚洲vs韩国一区三区| 无码av中文一区二区三区桃花岛| 亚洲一区二区美女| 亚洲一级在线观看| 香蕉av福利精品导航| 亚洲一二三专区| 亚洲444eee在线观看| 亚洲一区二区三区自拍| 亚洲午夜成aⅴ人片| 亚洲午夜羞羞片| 亚洲mv大片欧洲mv大片精品| 五月激情综合婷婷| 日韩二区三区在线观看| 日韩和欧美一区二区三区| 日韩电影免费一区| 美女爽到高潮91| 久久av资源站| 精品一区二区免费视频| 国产一区二区三区免费播放| 国产综合色在线| 国产成人在线视频网址| 成人涩涩免费视频| 9人人澡人人爽人人精品| 91丨九色丨蝌蚪丨老版| 色婷婷国产精品久久包臀| 欧美在线观看一区| 91精品国产91久久久久久最新毛片| 91精品国产一区二区三区| 日韩欧美专区在线| xnxx国产精品| 欧美国产激情二区三区 | 日韩精品1区2区3区| 欧美日韩一区二区三区在线看 | 日韩欧美专区在线| 久久久国产一区二区三区四区小说 | 91精品国产综合久久小美女| 精品奇米国产一区二区三区| 国产日本欧美一区二区| 亚洲欧美一区二区三区久本道91| 夜夜爽夜夜爽精品视频| 视频一区欧美精品| 国内精品久久久久影院薰衣草 | 欧美日韩国产123区| 91麻豆精品国产91久久久久| 精品处破学生在线二十三| 欧美—级在线免费片| 一区二区三区成人| 蜜桃视频免费观看一区| 国产乱码精品一区二区三| www.日韩大片| 欧美日韩电影一区| 26uuu精品一区二区| 亚洲丝袜美腿综合| 日本人妖一区二区| 国产91露脸合集magnet| 欧洲亚洲国产日韩| 久久中文字幕电影| 亚洲欧美日韩在线不卡| 免费成人在线影院| 成人午夜av电影| 欧美三级在线看| 久久久www成人免费无遮挡大片 | 精品在线一区二区| 99亚偷拍自图区亚洲| 正在播放亚洲一区| 国产精品天美传媒| 天天操天天色综合| 风间由美性色一区二区三区| 在线观看免费一区| 精品美女一区二区三区| 亚洲欧洲三级电影| 毛片av中文字幕一区二区| av在线不卡免费看| 欧美一区二区成人6969| 国产精品无人区| 久热成人在线视频| 色美美综合视频| 亚洲精品一区二区精华| 亚洲综合免费观看高清在线观看| 精品系列免费在线观看| 色播五月激情综合网| 久久美女高清视频| 五月激情综合网| av中文字幕不卡| 26uuu久久天堂性欧美| 亚洲高清中文字幕| 懂色av中文字幕一区二区三区| 欧美高清精品3d| 亚洲欧美国产77777| 激情深爱一区二区| 欧美日韩另类一区| 中文字幕欧美一| 国内成人精品2018免费看| 欧美视频一区二区在线观看| 国产精品国产三级国产三级人妇 | 精品在线一区二区三区| 欧美性色综合网| 国产精品久久久一本精品| 麻豆一区二区三| 欧美午夜电影网| 中文字幕一区在线| 国产传媒日韩欧美成人| 欧美一区二区三区日韩| 夜夜嗨av一区二区三区网页| 成人激情免费网站| 久久免费看少妇高潮|