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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? strata32.c

?? 一個基于三星S3C2413的全部驅(qū)動程序
?? C
字號:
//====================================================================
// File Name : strata32.c
// Function  : S3C2442 Intel Strata NOR Flash
// Program   : Lee, Sang Jo (LSJ)
// Date      : June 14, 2002
// Version   : 0.0
// History
//   0.0 : Programming start (June 14, 2002) -> LSJ
//         Arrangement source code(8/01/2002)-> SOP   
//====================================================================

#include <stdlib.h>
#include <string.h>
#include "def.h"
#include "option.h"
#include "2413addr.h"
#include "Console.h"
#include "strata32.h"

static void InputAddresses(void);

static int  Strata_ProgFlash(U32 realAddr,U32 data);
static void Strata_EraseSector(int targetAddr);
static int  Strata_CheckID(int targetAddr);
static int  Strata_CheckDevice(int targetAddr);
static int  Strata_CheckBlockLock(int targetAddr);
static int  Strata_BlankCheck(int targetAddr,int targetSize);
static int  _WAIT(void);

extern U32 downloadAddress;
extern U32 downloadProgramSize;

static U32 srcAddress;
static U32 targetOffset; 
static U32 targetAddress; 
static U32 targetSize; 

// Because S3C2442 is connected to Intel StrataFlash 28F128J3A,
// the addr parameter has to be a WORD address, so called in Intel specification.

    // by chc
#define _WR(addr,data)  *((volatile U32 *)(addr))=(U32)data 
#define _RD(addr)       ( *((volatile U32 *)(addr)) )       
    // _RESET() : Read Array
#define _RESET()    _WR(targetAddress,0x00ff00ff)

extern U32 downloadAddress;
extern U32 downloadProgramSize;

static int error_erase=0;       // Read Status Register, SR.5
static int error_program=0;     // Read Status Register, SR.4

//==========================================================================================
int Strata_CheckID(int targetAddr) 
{
    _RESET();
    _WR(targetAddr, 0x00900090); 
    return _RD(targetAddr); // Read Identifier Code, including lower, higher 16-bit, 8MB, Intel Strate Flash ROM
                            // targetAddress must be the beginning location of a Block Address
}

//==========================================================================================
int Strata_CheckDevice(int targetAddr) 
{
    _RESET();
    _WR(targetAddr, 0x00900090);
    return _RD(targetAddr+0x4); // Read Device Code, including lower, higher 16-bit, 8MB, Intel Strate Flash ROM
                                // targetAddress must be the beginning location of a Block Address
}

//==========================================================================================
int Strata_CheckBlockLock(int targetAddr) 
{
    _RESET();
    _WR(targetAddr, 0x00900090);
    return _RD(targetAddr+0x8); // Read Block Lock configuration, 
                                // targetAddress must be the beginning location of a Block Address
}

void Strata_Unlock(int targetAddr) 
{
    _RESET();
    _WR(targetAddr, 0x00600060);
    _WR(targetAddr, 0x00D000D0);
}

void Strata_SetBlockLock(int targetAddr)
{
	_RESET();
	_WR(targetAddr, 0x00600060);
	_WR(targetAddr, 0x00010001);
}

//==========================================================================================
void Strata_EraseSector(int targetAddress) 
{
    unsigned long ReadStatus;
    unsigned long bSR5;     // Erase and Clear Lock-bits Status, lower 16bit, 8MB Intel Strate Flash ROM
    unsigned long bSR5_2;   // Erase and Clear Lock-bits Status, higher 16bit, 8MB Intel Strate Flash ROM
    unsigned long bSR7;     // Write State Machine Status, lower 16bit, 8MB Intel Strate Flash ROM
    unsigned long bSR7_2;   // Write State Machine Status, higher 16bit, 8MB Intel Strate Flash ROM
    //_RESET();
//  _WR(targetAddress, 0x00200020);
//  _WR(targetAddress, 0x00d000d0);
    _WR(targetAddress, 0x00200020); // Block Erase, First Bus Cycle, targetAddress is the address withint the block
    _WR(targetAddress, 0x00d000d0); // Block Erase, Second Bus Cycle, targetAddress is the address withint the block
    
    //_RESET();
    _WR(targetAddress, 0x00700070); // Read Status Register, First Bus Cycle, targetAddress is any valid address within the device
    ReadStatus=_RD(targetAddress);  // Read Status Register, Second Bus Cycle, targetAddress is any valid address within the device
    bSR7=ReadStatus & (1<<7);       // lower 16-bit 8MB Strata
    bSR7_2=ReadStatus & (1<<(7+16));// higher 16-bit 8MB Strata
    while(!bSR7 | !bSR7_2) 
    {
        _WR(targetAddress, 0x00700070);
        ReadStatus=_RD(targetAddress);
        bSR7=ReadStatus & (1<<7);
        bSR7_2=ReadStatus & (1<<(7+16));
//      printf("wait !!\n");
    }

    _WR(targetAddress, 0x00700070); // When the block erase is complete, status register bit SR.5 should be checked. 
                    // If a block erase error is detected, the status register should be cleared before
                    // system software attempts correct actions.
    ReadStatus=_RD(targetAddress);  
    bSR5=ReadStatus & (1<<5);           // lower 16-bit 8MB Strata 
    bSR5_2=ReadStatus & (1<<(5+16));    // higher 16-bit 8MB Strata 
    if (bSR5==0 && bSR5_2==0) 
    {
        printf("Block_%x Erase O.K. \n",targetAddress);
    } 
    else 
    {
        //printf("Error in Block Erasure!!\n");
        _WR(targetAddress, 0x00500050); // Clear Status Register
        error_erase=1;                  // But not major, is it casual ?
    }

    _RESET();   // write 0xffh(_RESET()) after the last opoeration to reset the device to read array mode.
}

//==========================================================================================
int Strata_BlankCheck(int targetAddr,int targetSize) 
{
    int i,j;
    for (i=0; i<targetSize; i+=4) 
    {
        j=*((volatile U32 *)(i+targetAddr));
        if (j!=0xffffffff)      // In erasure it changes all block dta to 0xff
        {
            printf("E : %x = %x\n", (i+targetAddr), j);
            return 0;
        }
    }
    return 1;
}

//==========================================================================================
int Strata_ProgFlash(U32 realAddr,U32 data) 
{
    volatile U32 *ptargetAddr;
    unsigned long ReadStatus;
    unsigned long bSR4;    // Erase and Clear Lock-bits Status, lower 16bit, 8MB Intel Strate Flash ROM
    unsigned long bSR4_2;  // Erase and Clear Lock-bits Status, higher 16bit, 8MB Intel Strate Flash ROM
    unsigned long bSR7;    // Write State Machine Status, lower 16bit, 8MB Intel Strate Flash ROM
    unsigned long bSR7_2;  // Write State Machine Status, higher 16bit, 8MB Intel Strate Flash ROM

    ptargetAddr = (volatile U32 *)realAddr;
    //_RESET();

    _WR(realAddr, 0x00400040);  // realAddr is any valid adress within the device
                                // Word/Byte Program(or 0x00100010 can be used)
    *ptargetAddr=data;          // 32 bit data

    //_RESET();
    _WR(realAddr, 0x00700070);  // Read Status Register
    ReadStatus=_RD(realAddr);   // realAddr is any valid address within the device
    bSR7=ReadStatus & (1<<7);
    bSR7_2=ReadStatus & (1<<(7+16));
    while(!bSR7 || !bSR7_2) 
    {
        // _RESET();
        _WR(realAddr, 0x00700070);        // Read Status Register
        ReadStatus=_RD(realAddr);
        bSR7=ReadStatus & (1<<7);
        bSR7_2=ReadStatus & (1<<(7+16));
    }
    
    _WR(realAddr, 0x00700070); 
    ReadStatus=_RD(realAddr);             // Real Status Register
    bSR4=ReadStatus & (1<<4);
    bSR4_2=ReadStatus & (1<<(4+16));
    
    if (bSR4==0 && bSR4_2==0) 
    {
        //printf("Successful Program!!\n");
        ;
    } 
    else 
    {
        //printf("Error Program!!\n");
        _WR(realAddr, 0x00500050);          // Clear Status Register
        error_program=1;                    // But not major, is it casual ?
    }

    _RESET();
    return 0;
}

#define TARGET_ADDR_28F128      0x08000000  // nGCS4, 128MB area
#define SOURCE_ADDR_FOR_28F128  0x31000000  // After 16MB of SDRAM
                                            // 0x30000000 - 0x30ffffff : Area for this test program

//==========================================================================================                                            
void Program28F128J3A(void)
{
// FlashROM write program must reside at RAM region NOT ROM region
// In reading and writing all interrupts are disabled because the flash ROM
// strongly dislike to be disturbed by other stuff.
// And the region of flash ROM must be I/O region which means NO cacheable
// and NO bufferable in MMU. Check it out !!!
// 2001.6.18. Mon. It's local rain. I'll hope it eliminates the drought in Korea. by chc

    unsigned long interrupt_reservoir;
    int i;

    printf("\n[ 28F128J3A Flash Writing Program ]\n\n");
    printf("     *** Very Important Notes ***\n");
    printf("1. 28F128J3A must be located at 0x08000000.\n"
            " J1:1-2, J2:2-3, J3:2-3, J4:1-2 \n");
    printf("2. After programming, 28F128J3A may be located at 0x0.\n"
			 " J1:2-3, J2:1-2, J3:1-2, J4:2-3 \n");

    rINTMSK = BIT_ALLMSK;   
    targetAddress=TARGET_ADDR_28F128;
    targetSize=downloadProgramSize;
    //downloadAddress=0x31000000;

    if(targetSize==0)
    {
        printf("\nThe data must be downloaded using ICE or USB from 0x31000000\n");
        srcAddress=downloadAddress; 
    }
    else
    { 
        srcAddress=downloadAddress+4; //to discard the data head for the size
    }

    InputAddresses(); //srcAddress,targetSize,targetOffset will be determined.      
    printf("Source base address(0x31000000) = 0x%x\n",srcAddress);
    printf("Target base address(0x08000000) = 0x%x\n",targetAddress);
    printf("Target offset      (0x0)        = 0x%x\n",targetOffset);
    printf("Target size        (0x20000*n)  = 0x%x\n",targetSize);

    if ( (Strata_CheckID(targetAddress) & 0xffff) != 0x0089 )       // ID number = 0x0089
    {
		printf("Read ID : 0x%x\n", Strata_CheckID(targetAddress));
        printf("Identification check error !!\n");
        return ;
    }

    if ( (Strata_CheckDevice(targetAddress) & 0xffff) != 0x0018 )   // Device number=0x0018
    {
        printf("Device check error !!\n");
        return ;
    }

    printf("\nErase the sector : 0x%x.\n", targetAddress);

    for(i=0;i<targetSize;i+=0x20000)
    {
        Strata_EraseSector(targetAddress+targetOffset+i);
    }
    
    if(!Strata_BlankCheck(targetAddress+targetOffset,targetSize))
    {
        printf("Blank Check Error!!!\n");
        return;
    }

    printf("\nStart of the data writing...\n");

    for (i=0; i<targetSize; i+=4) 
    {
        Strata_ProgFlash(i+targetAddress+targetOffset, *((U32 *)(srcAddress+i)));
        if(i%0x10000==0xfffc)
            printf("[%x]",(i+4)/0x10000);
    }
    printf("\nEnd of the data writing \n");

    _RESET();

    printf("Verifying Start...\n");
    for (i=0; i<targetSize; i+=4) 
    {
        if (*((U32 *)(i+targetAddress+targetOffset)) !=*((U32 *)(srcAddress+i))) 
        {
            printf("verify error  src %08x = %08x\n", srcAddress+i, *((U32 *)(srcAddress+i)));
            printf("verify error  des %08x = %08x\n", i+targetAddress+targetOffset, *((U32 *)(i+targetAddress)));
            return;
        }
    }
    printf("Verifying End!!!");
}


void Erase28F128J3A(void)  // added by junon 10/29
{
// FlashROM write program must reside at RAM region NOT ROM region
// In reading and writing all interrupts are disabled because the flash ROM
// strongly dislike to be disturbed by other stuff.
// And the region of flash ROM must be I/O region which means NO cacheable
// and NO bufferable in MMU. Check it out !!!
// 2001.6.18. Mon. It's local rain. I'll hope it eliminates the drought in Korea. by chc

    unsigned long interrupt_reservoir;
    int i;

    printf("\n[ 28F128J3A Flash Writing Program ]\n\n");
    printf("     *** Very Important Notes ***\n");
    printf("1. 28F128J3A must be located at 0x08000000.\n"
            " J1:1-2, J2:2-3, J3:2-3, J4:1-2 \n");
    printf("2. After programming, 28F128J3A may be located at 0x0.\n"
			 " J1:2-3, J2:1-2, J3:1-2, J4:2-3 \n");

    rINTMSK = BIT_ALLMSK;   
    targetAddress=TARGET_ADDR_28F128;
    targetSize=downloadProgramSize;
    //downloadAddress=0x31000000;

    if(targetSize==0)
    {
        printf("\nThe data must be downloaded using ICE or USB from 0x31000000\n");
        srcAddress=downloadAddress; 
    }
    else
    { 
        srcAddress=downloadAddress+4; //to discard the data head for the size
    }

    InputAddresses(); //srcAddress,targetSize,targetOffset will be determined.      
    printf("Source base address(0x31000000) = 0x%x\n",srcAddress);
    printf("Target base address(0x08000000) = 0x%x\n",targetAddress);
    printf("Target offset      (0x0)        = 0x%x\n",targetOffset);
    printf("Target size        (0x20000*n)  = 0x%x\n",targetSize);

    if ( Strata_CheckID(targetAddress)  != 0x00890089 )       // ID number = 0x0089
    {
		printf("Read ID : 0x%x\n", Strata_CheckID(targetAddress));
        printf("Identification check error !!\n");
        return ;
    }

    if ( Strata_CheckDevice(targetAddress) != 0x00180018 )   // Device number=0x0018
    {
        printf("Device check error !!\n");
        return ;
    }
		
#if 1 // lock bit setting test 
//	Strata_SetBlockLock(targetAddress+0x10000); //just test
    for(i=0;i<10;i++)
		printf("%d block value is %d\n", i, Strata_CheckBlockLock(targetAddress+0x20000*i)&0x00010001);
//	    if ( Strata_CheckBlockLock(targetAddress+0x20000*i) != 0x0 )   // Device number=0x0018
//	        printf("%d block is locked !!\n", i);
	Strata_Unlock(targetAddress);
	for(i=0;i<10;i++)
	printf("%d block value is %d\n", i, Strata_CheckBlockLock(targetAddress+0x20000*i)&0x00010001);
#endif
//	Strata_Unlock(targetAddress);

    printf("\nErase the sector : 0x%x.\n", targetAddress);

    for(i=0;i<targetSize;i+=0x20000)
    {
        Strata_EraseSector(targetAddress+targetOffset+i);
    }
    
    if(!Strata_BlankCheck(targetAddress+targetOffset,targetSize))
    {
        printf("Blank Check Error!!!\n");
        return;
    }

}


//==========================================================================================
static void InputAddresses(void)
{
    printf("\n[ 28F128J3A Writing Program ]\n");

    printf("\nSource size [0x?] : 0h~%xh\n",downloadProgramSize);
    printf("\nAvailable Target Offset Address [0x?] : \n"); 
    printf("0h,20000h,40000h, ..., 1ce0000h\n");
    printf("Input target address offset [0x?] : ");
    targetOffset=GetIntNum();
    if(targetSize==0)
    {
        printf("Input target size [0x?] : ");
        targetSize=GetIntNum();
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合视频在线观看| 成人h动漫精品一区二| 69久久夜色精品国产69蝌蚪网| 亚洲欧美综合色| 99re视频精品| 亚洲国产中文字幕| 日韩精品中文字幕一区二区三区| 蜜臂av日日欢夜夜爽一区| 337p粉嫩大胆噜噜噜噜噜91av | 欧美专区亚洲专区| 亚洲午夜久久久久久久久电影网| 在线成人午夜影院| 国产一区激情在线| 亚洲色图在线视频| 欧美一区二区三区免费大片| 国产精品影视网| 亚洲欧美另类图片小说| 欧美日韩成人综合| 国产精品一区二区在线看| 亚洲美女免费视频| 日韩午夜在线影院| 成人午夜免费电影| 日产国产高清一区二区三区| 国产日韩精品久久久| 日本道色综合久久| 国产在线精品一区二区夜色| 亚洲丝袜另类动漫二区| 在线成人小视频| 成人毛片视频在线观看| 丝袜a∨在线一区二区三区不卡| xvideos.蜜桃一区二区| 色婷婷精品久久二区二区蜜臀av| 毛片av中文字幕一区二区| 中文字幕亚洲区| 精品国产区一区| 色老综合老女人久久久| 国产麻豆91精品| 日韩一区欧美二区| 中文字幕在线观看一区| 欧美精品一区二区三区久久久| 成人免费观看av| 精品一区免费av| 亚洲香肠在线观看| 国产精品女主播av| 日韩欧美亚洲一区二区| 色婷婷综合久久| 国产精品456| 免费看日韩精品| 亚洲精品国产a| 国产精品午夜在线| 精品国产成人系列| 91精品欧美一区二区三区综合在 | 欧美日本高清视频在线观看| jlzzjlzz欧美大全| 国产一区不卡视频| 精品在线一区二区| 日韩和欧美一区二区| 一区二区三区欧美日韩| 日本一区二区三区dvd视频在线| 777久久久精品| 欧美视频一区二区| 色婷婷综合久久| 99re8在线精品视频免费播放| 国产成人自拍网| 国产在线视频精品一区| 蜜桃精品视频在线| 免费在线看一区| 午夜精品一区二区三区三上悠亚| 亚洲综合激情另类小说区| 亚洲激情综合网| 一区二区高清免费观看影视大全| 亚洲人成人一区二区在线观看 | 亚洲女同女同女同女同女同69| 久久无码av三级| 久久久欧美精品sm网站| 久久免费电影网| 久久久久久久久久电影| 国产午夜精品一区二区三区四区| www一区二区| 国产亚洲短视频| 欧美国产日韩精品免费观看| 国产精品亲子伦对白| 国产精品色婷婷| 亚洲卡通欧美制服中文| 亚洲一区二区五区| 亚洲成国产人片在线观看| 无码av免费一区二区三区试看| 天天av天天翘天天综合网 | 中文字幕亚洲不卡| 亚洲日本一区二区| 亚洲成人免费看| 老司机一区二区| 国产最新精品精品你懂的| 国产成人精品三级麻豆| av网站一区二区三区| 91电影在线观看| 欧美日韩国产综合草草| 精品久久久久久久久久久久包黑料| 精品区一区二区| 国产精品视频线看| 亚洲一区中文日韩| 精久久久久久久久久久| 国产精华液一区二区三区| 91网站最新地址| 欧美日韩一区二区欧美激情 | 国产成人无遮挡在线视频| 成人av网站免费| 精品视频一区二区不卡| 欧美不卡视频一区| 中文字幕亚洲区| 日本成人在线电影网| 国产精华液一区二区三区| 91视频91自| 精品国产免费久久| 亚洲日本免费电影| 久久国产欧美日韩精品| 99re成人在线| 久久免费看少妇高潮| 亚洲自拍偷拍av| 国产成人免费xxxxxxxx| 在线观看精品一区| 国产欧美中文在线| 视频一区二区三区入口| 国产91高潮流白浆在线麻豆 | 日韩精品中文字幕一区二区三区 | 欧美亚洲一区二区三区四区| 欧美成人aa大片| 亚洲成av人片一区二区| 成人免费高清在线观看| 日韩免费观看2025年上映的电影| 亚洲欧洲日本在线| 久久99精品网久久| 欧美日韩精品免费| 中文字幕日韩av资源站| 韩国成人福利片在线播放| 欧美日韩在线不卡| 亚洲丝袜另类动漫二区| 国产成人av电影在线播放| 日韩三级在线观看| 亚洲国产日产av| 99国产精品国产精品毛片| 久久影院午夜片一区| 天堂一区二区在线免费观看| 一本大道久久a久久精品综合| 国产偷国产偷精品高清尤物| 免费成人在线视频观看| 欧美中文一区二区三区| 亚洲欧美影音先锋| 国产成人av福利| 精品久久久久久无| 日本91福利区| 欧美一区三区二区| 日韩国产高清在线| 欧美精品成人一区二区三区四区| 亚洲视频免费看| 国产v综合v亚洲欧| 久久综合999| 久久成人久久爱| 精品国内二区三区| 激情伊人五月天久久综合| 日韩三级av在线播放| 日韩不卡一区二区三区| 欧美精品日韩一区| 99久久综合狠狠综合久久| 久久久久久免费毛片精品| 美国毛片一区二区三区| 日韩精品一区二区三区在线观看 | 欧美久久一区二区| 亚洲国产综合在线| 欧美日韩国产高清一区二区三区| 亚洲一区二区欧美| 欧美精品99久久久**| 天堂精品中文字幕在线| 欧美人妇做爰xxxⅹ性高电影| 亚洲福利一区二区三区| 69堂成人精品免费视频| 久久精品国产久精国产爱| 久久一区二区三区四区| 国产成人免费视频网站| 中文字幕一区二区三区在线观看 | 亚洲欧美一区二区久久| 91搞黄在线观看| 午夜精品久久久久久久| 欧美一区二区三区四区五区 | 国产自产v一区二区三区c| 久久一二三国产| av亚洲精华国产精华精华| 亚洲线精品一区二区三区| 7777精品久久久大香线蕉| 久久疯狂做爰流白浆xx| 中文字幕第一区二区| 在线国产亚洲欧美| 麻豆成人在线观看| 亚洲国产高清aⅴ视频| 色狠狠色狠狠综合| 日韩专区在线视频| 国产亚洲欧洲一区高清在线观看| 99视频在线观看一区三区| 亚洲 欧美综合在线网络| 久久一区二区三区四区|