亚洲欧美第一页_禁久久精品乱码_粉嫩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 Flashtype29F040_8();extern int EndFlashtype29F040_8();extern int Flasherase29F040_8();extern int EndFlasherase29F040_8();extern int Flashwrite29F040_8();extern int EndFlashwrite29F040_8();extern int Flashewrite29F040_8();extern int EndFlashewrite29F040_8();extern int Flashtype29F800B_16();extern int EndFlashtype29F800B_16();extern int Flasherase29F800B_16();extern int EndFlasherase29F800B_16();extern int Flashwrite29F800B_16();extern int EndFlashwrite29F800B_16();extern int Flashewrite29F800B_16();extern int EndFlashewrite29F800B_16();struct flashinfo *addrtobank();int CurrentBank;/* FlashXXXFbufYYY[]:    Where XXX is the function to be stored in the buffer and YYY is the    device that the function is to operate on.    These arrays are loaded with the flash operation function (TYPE, ERASE,    WRITE & EWRITE) that must run in different memory space than the device    that is being operated on.  Recall that to operate on the flash, you    cannot be executing out of it.    The flash functions are copied here, then executed through a function    pointer flashfunc which is set (in FlashInit) to point to the buffer.*/long    FlashTypeFbuf040[FLASHFUNCSIZE];long    FlashWriteFbuf040[FLASHFUNCSIZE];long    FlashEraseFbuf040[FLASHFUNCSIZE];long    FlashEwriteFbuf040[FLASHFUNCSIZE];long    FlashTypeFbuf800[FLASHFUNCSIZE];long    FlashWriteFbuf800[FLASHFUNCSIZE];long    FlashEraseFbuf800[FLASHFUNCSIZE];long    FlashEwriteFbuf800[FLASHFUNCSIZE];/* FlashProtectWindow:   Must be set to allow any flash operation to be done on space assumed   to be boot code.*/int FlashProtectWindow;/* FlashNamId[]:   Used to correlate between the ID and a string representing the name   of the flash device.*/struct flashdesc FlashNamId[] = {    AMD29F800B, "AMD-29F800B",    AMD29F800T, "AMD-29F800T",    SGS29F040,  "SGS-29F040",    AMD29F040,  "AMD-29F040",    AMD29F010,  "AMD-29F010",    FLASHRAM,   "FLASH-RAM",};int SectorSizes29F040_8[] = {        0x10000, 0x10000, 0x10000, 0x10000,        0x10000, 0x10000, 0x10000, 0x10000,};int SectorSizes29F800B_16[] = {        0x4000,     0x2000,     0x2000,     0x8000,        0x10000,    0x10000,    0x10000,    0x10000,        0x10000,    0x10000,    0x10000,    0x10000,        0x10000,    0x10000,    0x10000,    0x10000,        0x10000,    0x10000,    0x10000};struct sectorinfo sinfo800[19], sinfo040[8];struct sectorinfo sinfoRAM[(FLASHRAM_SIZE/FLASHRAM_SSIZE)];/* FlashBank[]:    This table contains all of the information that is needed to keep the    flash code somewhat generic across multiple flash devices.*/struct  flashinfo FlashBank[FLASHBANKS];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%x 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\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",            fdev->sectors[i].snum,            fdev->sectors[i].begin,fdev->sectors[i].end,            fdev->sectors[i].size,            fdev->sectors[i].protected ? "yes" : " no");    }    return(0);}/* flashopload():    Copy flash operation to ram space.      Note that this function assumes that cache is disabled at this point.    This is important because we are copying text into bss space and if    cache was on, there could be a coherency problem.*/flashopload(ulong *begin,ulong *end,ulong *copy,int size){    volatile ulong  *bp;    int ret, mode;    /* Verify space availability: */    if (((int)end - (int)begin) >= size) {        printf("flashopload overflow ((0x%x-0x%x) > 0x%x)\n",end,begin,size);        return(-1);    }    ret = 0;    /* Copy function() to RAM, then verify: */    bp = begin;    while(bp <= end) {        *copy = *bp;        if (*copy++ != *bp++) {            printf("flashopload failed\n");            ret = -1;            break;        }    }    return(ret);}/* flashtype():    Use the device-specific function pointer to call the routine    relocated to RAM space.*/flashtype(fdev)struct flashinfo *fdev;{    return(fdev->fltype(fdev));}/* flasherase():    Use the device-specific function pointer to call the routine    relocated to RAM space.    Note that flasherase() is called with a sector number.  The sector    number is relative to the entire system, not just the particular device.    This means that if there is more than one flash device in the system that    the actual sector number (relative to the device) may not be the same    value.  This adjustment is made here so that the underlying code that is    pumped into ram for execution does not have to be aware of this.*/flasherase(fdev,snum)struct  flashinfo *fdev;int snum;{    int size;    char *base, *end;    if (fdev->id == FLASHRAM) {        if (snum == ALL_SECTORS) {            size = fdev->end - fdev->base;            base = fdev->base;        }        else {            sectortoaddr(snum,&size,&base);        }        end = base+size;        while(base < end) {            *base = 0xff;            if (*base++ != 0xff)                return(-1);        }        return(0);    }    if ((snum != ALL_SECTORS) && (fdev->sectors[0].snum != 0)) {/*      printf("Adjusting snum from %d to",snum); */        snum -= fdev->sectors[0].snum;/*      printf(" %d.\n",snum); */    }    return(fdev->flerase(fdev,snum));}/* flashwrite():    Use the device-specific function pointer 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;    if (fdev->id == FLASHRAM) {        uchar *sp, *dp, *end;        sp = src;        dp = dest;        end = dp+bytecnt;        while(dp < end) {            *dp = *sp;            if (*dp != *sp)                return(-1);            dp++; sp++;        }        return(0);    }    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++;    }    return(fdev->flwrite(fdev,dest,src,bytecnt));}/* flashewrite():    Use the device-specific function pointer to call the routine    relocated to RAM space.*/flashewrite(fdev,dest,src,bytecnt)struct  flashinfo *fdev;ulong   *src, *dest;long    bytecnt;{    int i;    /* Source and destination addresses must be long-aligned. */    if (((int)src & 3) || ((int)dest & 3))        return(-1);    /* If the protection window is closed, then verify that no protected */    /* sectors will be written over... */    if (FlashProtectWindow == FLASH_PROTECT_WINDOW_CLOSED) {        for (i=0;i<fdev->sectorcnt;i++) {            if((((uchar *)dest) > (fdev->sectors[i].end)) ||                (((uchar *)dest+bytecnt) < (fdev->sectors[i].begin)))                continue;            else                if (fdev->sectors[i].protected)                    return(-1);        }    }    return(fdev->flewrite(fdev,dest,src,bytecnt));}AppFlashWrite(dest,src,bytecnt)ulong   *src, *dest;long bytecnt;{    struct flashinfo *fbnk;    ulong   oints;    int ret;    fbnk = addrtobank(dest);    if (!fbnk)        return(-1);    oints = intsoff();    ret = flashwrite(fbnk,dest,src,bytecnt);    intsrestore(oints);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲美女区一区| 久久精品国产99国产精品| 日本在线播放一区二区三区| 国产成人亚洲综合色影视| 91九色02白丝porn| 欧美国产综合色视频| 不卡的电影网站| 日韩免费视频一区二区| 亚洲一区二区五区| voyeur盗摄精品| 欧美精品一区二区三区在线| 亚欧色一区w666天堂| 91丨porny丨首页| 日本一区免费视频| 久久国产人妖系列| 欧美一区二区视频在线观看2020| 亚洲天堂福利av| 福利视频网站一区二区三区| 精品福利二区三区| 日韩 欧美一区二区三区| 欧美日韩高清在线播放| 亚洲欧美日韩成人高清在线一区| 国产成人在线免费| 久久综合色婷婷| 九九**精品视频免费播放| 538prom精品视频线放| 亚洲aⅴ怡春院| 欧美色图片你懂的| 亚洲午夜免费福利视频| 91黄色激情网站| 亚洲精品午夜久久久| 91丨九色丨蝌蚪丨老版| 狠狠色狠狠色综合| 日韩免费性生活视频播放| 免费成人av在线播放| 91精品在线麻豆| 久久精品国产精品青草| 日韩一区和二区| 韩国欧美一区二区| 久久综合九色综合97婷婷| 国模冰冰炮一区二区| 久久品道一品道久久精品| 岛国av在线一区| 亚洲欧美在线视频观看| 91福利视频网站| 日韩精品每日更新| 精品国产伦一区二区三区观看方式 | 国产91丝袜在线播放九色| 国产亚洲一区字幕| 波多野结衣精品在线| 亚洲精品免费播放| 精品视频在线免费看| 青娱乐精品视频在线| 欧美精品一区二区蜜臀亚洲| 国产激情视频一区二区三区欧美| 国产精品视频yy9299一区| 91久久一区二区| 日韩电影在线免费| 国产欧美一区二区三区鸳鸯浴 | 蜜臀av性久久久久蜜臀aⅴ| 欧美成人女星排名| 成人美女视频在线观看| 亚洲一区二区三区中文字幕| 日韩欧美国产麻豆| 99精品视频中文字幕| 日韩精品免费视频人成| 国产三级久久久| 欧美日韩国产大片| 国产精品亚洲综合一区在线观看| 亚洲精品久久久久久国产精华液 | 色婷婷久久久综合中文字幕 | 亚洲国产精品一区二区www在线| 日韩一级黄色片| 波多野结衣一区二区三区| 天天综合天天综合色| 国产日韩精品一区| 欧美日韩精品综合在线| 国产成人在线色| 日本亚洲一区二区| 亚洲欧美国产三级| 国产亚洲综合在线| 欧美激情在线免费观看| 91黄色在线观看| 国内外精品视频| 在线观看一区二区视频| 国产毛片精品视频| 日本网站在线观看一区二区三区| 国产欧美精品一区aⅴ影院| 777色狠狠一区二区三区| 99热在这里有精品免费| 精品亚洲免费视频| 亚洲国产日韩av| 中文字幕一区二区在线播放| 日韩丝袜美女视频| 91精品午夜视频| 欧美最猛黑人xxxxx猛交| 成人av电影在线观看| 国产自产2019最新不卡| 日韩高清在线一区| 性久久久久久久久| 依依成人精品视频| 国产精品成人网| 欧美高清一级片在线观看| 精品免费视频一区二区| 日韩一区二区三区免费看 | 久久久久久久电影| 日韩视频一区在线观看| 制服丝袜一区二区三区| 欧美日韩专区在线| 在线免费av一区| 91香蕉视频污| 不卡av在线网| 成人综合婷婷国产精品久久蜜臀 | 亚洲曰韩产成在线| 亚洲一区二区综合| 亚洲精品一二三四区| √…a在线天堂一区| 椎名由奈av一区二区三区| 国产精品国产三级国产aⅴ入口 | 91小视频在线免费看| av网站免费线看精品| 97久久超碰精品国产| 久久精品亚洲乱码伦伦中文| 久久久综合九色合综国产精品| 欧美精品一区二区三区蜜桃| 久久综合九色综合欧美98| 日本一区免费视频| 亚洲人成精品久久久久久 | 国产精品不卡一区二区三区| 欧美国产1区2区| 亚洲视频电影在线| 午夜视频久久久久久| 日韩激情av在线| 久久99精品国产.久久久久久| 国模一区二区三区白浆| 国产成人精品三级麻豆| 一本色道久久加勒比精品| 欧美性高清videossexo| 91精品国产色综合久久ai换脸| 日韩精品一区二区三区四区视频| 久久综合久色欧美综合狠狠| 国产精品三级视频| 亚洲成人福利片| 精品一区二区三区欧美| 国产高清成人在线| 欧美中文字幕一二三区视频| 日韩情涩欧美日韩视频| 国产精品丝袜黑色高跟| 亚洲一区二区av电影| 免费精品99久久国产综合精品| 国产很黄免费观看久久| 欧美午夜视频网站| 精品久久久影院| 亚洲黄网站在线观看| 精品在线你懂的| 色噜噜狠狠色综合欧洲selulu| 制服丝袜国产精品| 风间由美一区二区av101| 色综合天天天天做夜夜夜夜做| 欧美一区二区免费观在线| 亚洲天堂2014| 国产真实精品久久二三区| 色猫猫国产区一区二在线视频| 欧美成人video| 一区二区三区在线观看国产| 国产一区高清在线| 欧美日韩成人综合| 国产精品护士白丝一区av| 蜜臀av性久久久久蜜臀av麻豆| 99riav一区二区三区| 精品国产髙清在线看国产毛片| 亚洲精品成人悠悠色影视| 国产剧情在线观看一区二区| 67194成人在线观看| 一级中文字幕一区二区| 成人av在线一区二区| 精品日韩成人av| 午夜伊人狠狠久久| 99re成人在线| 国产欧美精品一区二区色综合朱莉 | 精品成人私密视频| 五月天激情综合网| 日本精品视频一区二区三区| 中国色在线观看另类| 黑人巨大精品欧美黑白配亚洲| 欧美乱熟臀69xxxxxx| 亚洲男同1069视频| voyeur盗摄精品| 中文字幕乱码久久午夜不卡 | 五月天精品一区二区三区| 欧美在线不卡视频| 亚洲精品水蜜桃| 白白色亚洲国产精品| 欧美激情在线一区二区| 高清视频一区二区| 国产欧美日韩一区二区三区在线观看| 狠狠色丁香婷婷综合| 欧美va亚洲va| 激情五月婷婷综合网| 久久伊人蜜桃av一区二区|