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

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

?? nandflsh.c

?? Cirrus Logic EP7312處理器部分控制程序。
?? C
?? 第 1 頁 / 共 2 頁
字號:
//****************************************************************************
//
// NANDFLSH.C - Routines to access the NAND FLASH and SmartMedia
//
// Copyright (c) 1999 - 2001 Cirrus Logic, Inc.
//
//****************************************************************************
#include "ep7312.h"
#include "lib7312.h"

//****************************************************************************
//
// The following table contains the mapping from the NAND device ID to the
// physical layout of the NAND memory array.
//
//****************************************************************************
#define NOP __asm { nop }
#define NUMIDS 7
static const struct
{
    unsigned char ucID;
    unsigned char ucPageSize;
    unsigned char ucPagesPerBlock;
    unsigned char ucBlocks;
} sNANDMap[NUMIDS] =
{
    { 0xEA, 0, 16, 1 }, // 256bytes * 16pages * 512blocks = 2Meg
    { 0xE3, 1, 16, 1 }, // 512bytes * 16pages * 512blocks = 4Meg
    { 0xE5, 1, 16, 1 }, // 512bytes * 16pages * 512blocks = 4Meg
    { 0xE6, 1, 16, 2 }, // 512bytes * 16pages * 1024blocks = 8Meg
    { 0x73, 1, 32, 2 }, // 512bytes * 32pages * 1024blocks = 16Meg
    { 0x75, 1, 32, 4 }, // 512bytes * 32pages * 2048blocks = 32Meg
    { 0x76, 1, 32, 8 }, // 512bytes * 32pages * 4096blocks = 64Meg
};

//****************************************************************************
//
// The layout of the on-board NAND FLASH.
//
//****************************************************************************
static unsigned long ulNANDReadID = 0;
static unsigned long ulNANDPageSize;
static unsigned long ulNANDPagesPerBlock;
static unsigned long ulNANDNumBlocks;

//****************************************************************************
//
// The layout of the SmartMedia card.
//
//****************************************************************************
static unsigned long ulSMPageSize;
static unsigned long ulSMPagesPerBlock;
static unsigned long ulSMNumBlocks;

//****************************************************************************
//
// NANDGetSize determines the size and layout of the on-board NAND FLASH based
// on the device ID read from the NAND FLASH.
//
//****************************************************************************
long
NANDGetSize(unsigned long *pulDeviceSize, unsigned long *pulPageSize,
            unsigned long *pulPagesPerBlock, unsigned long *pulNumBlocks)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwNANDAddress;
    unsigned char * volatile pucPortB = (unsigned char *)(HwBaseAddress +
                                                          HwPortB);
    unsigned char * volatile pucPortBdir = (unsigned char *)(HwBaseAddress + 
                                                            HwDdrB);
    unsigned long * volatile pulMemPtr = (unsigned long *)(HwBaseAddress +
                                                           HwMemConfig1);
    unsigned char volatile ucTemp;
    long lIdx;

    //
    // Set up chip select 1 for bus width of 32 bits
    //
    *pulMemPtr |= 0x1900;

    //
    // Set the port B data direction register.
    //
    *pucPortBdir = 0xFA;

    //
    // Set the initial value of port B, with both the NAND and Smart
    // Media chip selects set to 0.
    //
    *pucPortB = 0x00;

    //
    // Select the NAND FLASH.
    //
    *pucPortB |= HwPortBNANDCS;

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the read id command.
    //
    *pulPtr = 0x00000090;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Assert ALE.
    //
    *pucPortB |= HwPortBALE;

    //
    // Write the address.
    //
    *pulPtr = 0x00000000;

    //
    // Deassert ALE.
    //
    *pucPortB &= ~HwPortBALE;

    //
    // Read the maker ID.
    //
    ucTemp = *pulPtr;

    //
    // Read the device ID.
    //
    ucTemp = *pulPtr;

    //
    // Deassert the NAND FLASH.
    //
    *pucPortB &= ~HwPortBNANDCS;

    //
    // Find this device ID in our table.
    //
    for(lIdx = 0; lIdx < NUMIDS; lIdx++)
    {
        if((ucTemp & 255) == sNANDMap[lIdx].ucID)
        {
            break;
        }
    }

    //
    // Return an error if we could not find this device ID.
    //
    if(lIdx == NUMIDS)
    {
        return(0);
    }

    //
    // Fill in the NAND FLASH globals based on the physical layout of the NAND
    // devices on the board.
    //
    ulNANDPageSize = sNANDMap[lIdx].ucPageSize ? 512 : 256;
    ulNANDPagesPerBlock = sNANDMap[lIdx].ucPagesPerBlock;
    ulNANDNumBlocks = (unsigned long)sNANDMap[lIdx].ucBlocks << 9;
    ulNANDReadID = 1;

    //
    // If requested, return the size of the NAND memory.
    //
    if(pulDeviceSize)
    {
        *pulDeviceSize = ulNANDPageSize * ulNANDPagesPerBlock *
                         ulNANDNumBlocks * 4;
        *pulPageSize = ulNANDPageSize;
        *pulPagesPerBlock = ulNANDPagesPerBlock;
        *pulNumBlocks = ulNANDNumBlocks;
    }

    //
    // Success.
    //
    return(1);
}

//****************************************************************************
//
// NANDReadPage reads data from the specified page of the on-board NAND FLASH.
//
//****************************************************************************
void
NANDReadPage(unsigned long ulPage, int bReadSpare, unsigned char *pucBuffer)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwNANDAddress;
    unsigned char * volatile pucPortB = (unsigned char *)(HwBaseAddress +
                                                          HwPortB);
    long lIdx;

    //
    // Make sure that we know the layout of the on-board NAND FLASH.
    //
    if(!ulNANDReadID)
    {
        NANDGetSize(0, 0, 0, 0);
    }

    //
    // Select the NAND FLASH.
    //
    *pucPortB |= HwPortBNANDCS;

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the read1 command.
    //
    *pulPtr = 0x00;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Assert ALE.
    //
    *pucPortB |= HwPortBALE;

    //
    // Write the address.
    //
    *pulPtr = 0x00;
    lIdx = ulPage & 0xFF;
    *pulPtr = lIdx;
    lIdx = (ulPage >> 8) & 0xFF;
    *pulPtr = lIdx;
    
    //
    // Deassert ALE.
    //
    *pucPortB &= ~HwPortBALE;

    //
    // Wait for at least 7uS for the row to copy from the cell array.
    //
    for(lIdx = 0; lIdx < 256; lIdx++)
    {
    }

    //
    // Read the data from this page.
    //
    for(lIdx = 0; lIdx < ulNANDPageSize; lIdx++)
    {
        pucBuffer[lIdx] = *pulPtr;
    }

    //
    // Read the spare area if requested.
    //
    if(bReadSpare)
    {
        for(lIdx = 0; lIdx < (ulNANDPageSize / 32); lIdx++)
        {
            pucBuffer[ulNANDPageSize + lIdx] = *pulPtr;
        }
    }

    //
    // De-select the NAND FLASH.
    //
    *pucPortB &= ~HwPortBNANDCS;
}

//****************************************************************************
//
// NANDEraseBlock erases the specified block of the on-board NAND FLASH.
//
//****************************************************************************
void
NANDEraseBlock(unsigned long ulBlock)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwNANDAddress;
    unsigned char * volatile pucPortB = (unsigned char *)(HwBaseAddress +
                                                          HwPortB);
    long lIdx;

    //
    // Make sure that we know the layout of the on-board NAND FLASH.
    //
    if(!ulNANDReadID)
    {
        NANDGetSize(0, 0, 0, 0);
    }

    //
    // Convert the block number into the page number of the first page of the
    // block.  This is dependent on the number of pages per block.
    //
    switch(ulNANDPagesPerBlock)
    {
        case 16:
        {
            ulBlock <<= 4;
            break;
        }

        case 32:
        {
            ulBlock <<= 5;
            break;
        }
    }

    //
    // Select the NAND FLASH.
    //
    *pucPortB |= HwPortBNANDCS;

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the auto block erase setup command.
    //
    *pulPtr = 0x60;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Assert ALE.
    //
    *pucPortB |= HwPortBALE;

    //
    // Write the address.
    //
    lIdx = ulBlock & 0xFF;
    *pulPtr = lIdx;
    lIdx = (ulBlock >> 8) & 0xFF;
    *pulPtr = lIdx;
    
    //
    // Deassert ALE.
    //
    *pucPortB &= ~HwPortBALE;

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the erase command.
    //
    *pulPtr = 0xd0;

    //
    // Write the read status command.
    //
    *pulPtr = 0x70;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Wait until the erase has completed.
    //
    while((*pulPtr & 0x40) != 0x40)
    {
        for(lIdx = 0; lIdx < 1024; lIdx++)
        {
        }
    }

    //
    // Deselect the NAND FLASH.
    //
    *pucPortB &= ~HwPortBNANDCS;
}

//****************************************************************************
//
// NANDWritePage writes data to the specified page of the on-board NAND FLASH.
//
//****************************************************************************
void
NANDWritePage(unsigned long ulPage, int bWriteSpare, unsigned char *pucBuffer)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwNANDAddress;
    unsigned char * volatile pucPortB = (unsigned char *)(HwBaseAddress +
                                                          HwPortB);
    long lIdx;

    //
    // Make sure that we know the layout of the on-board NAND FLASH.
    //
    if(!ulNANDReadID)
    {
        NANDGetSize(0, 0, 0, 0);
    }

    //
    // Select the NAND FLASH.
    //
    *pucPortB |= HwPortBNANDCS;

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the sequential data input command.
    //
    *pulPtr = 0x80;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Assert ALE.
    //
    *pucPortB |= HwPortBALE;

    //
    // Write the address.
    //
    *pulPtr = 0x00;
    lIdx = ulPage & 0xFF;
    *pulPtr = lIdx;
    lIdx = (ulPage >> 8) & 0xFF;
    *pulPtr = lIdx;

    //
    // Deassert ALE.
    //
    *pucPortB &= ~HwPortBALE;

    //
    // Write the data to this page.
    //
    for(lIdx = 0; lIdx < ulNANDPageSize; lIdx++)
    {
        *pulPtr = pucBuffer[lIdx];
    }

    //
    // Write data for the spare area if requested.
    //
    if(bWriteSpare)
    {
        for(lIdx = 0; lIdx < (ulNANDPageSize / 32); lIdx++)
        {
            *pulPtr = pucBuffer[ulNANDPageSize + lIdx];
        }
    }

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the program command.
    //
    *pulPtr = 0x10;

    //
    // Write the read status command.
    //
    *pulPtr = 0x70;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Wait until the program has completed.
    //
    while((*pulPtr & 0x40) != 0x40)
    {
        for(lIdx = 0; lIdx < 1024; lIdx++)
        {
        }
    }

    //
    // Deselect the NAND FLASH.
    //
    *pucPortB &= ~HwPortBNANDCS;
}

//****************************************************************************
//
// SMGetSize determines the size and layout of the SmartMedia card based on
// the device ID read from the SmartMedia card.  If an invalid ID is read, or
// the Smart Media card is not inserted, an error will be returned.
//
//****************************************************************************
long
SMGetSize(unsigned long *pulDeviceSize, unsigned long *pulPageSize,
            unsigned long *pulPagesPerBlock, unsigned long *pulNumBlocks)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwNANDAddress;
    unsigned char * volatile pucPortB = (unsigned char *)(HwBaseAddress +
                                                          HwPortB);
    unsigned char * volatile pucPortBdir = (unsigned char *)(HwBaseAddress + 
                                                            HwDdrB);
    
    
    unsigned char volatile ucTemp;
    long lIdx;

    //
    // Set the port B data direction register.
    //
    *pucPortBdir = 0xFA;

    //
    // Set the initial value of port B, with both the NAND and Smart
    // Media chip selects set to 0.
    //
    *pucPortB = 0x00;

    //
    // Select the SmartMedia card.
    //
    *pucPortB |= HwPortBSMCS;

    //
    // Assert CLE.
    //
    *pucPortB |= HwPortBCLE;

    //
    // Write the read id command.
    //
    *pulPtr = 0x90;

    //
    // Deassert CLE.
    //
    *pucPortB &= ~HwPortBCLE;

    //
    // Assert ALE.
    //
    *pucPortB |= HwPortBALE;

    //
    // Write the address.
    //
    *pulPtr = 0x00;

    //
    // Deassert ALE.
    //
    *pucPortB &= ~HwPortBALE;

    //
    // Read the maker ID.
    //
    ucTemp = *pulPtr;

    //
    // Read the device ID.
    //
    ucTemp = *pulPtr;

    //
    // Deassert the SmartMedia card.
    //
    *pucPortB &= ~HwPortBSMCS;

    //
    // Find this device ID in our table.
    //
    for(lIdx = 0; lIdx < NUMIDS; lIdx++)
    {
        if(ucTemp == sNANDMap[lIdx].ucID)
        {
            break;
        }
    }

    //
    // Return an error if we could not find this device ID.
    //
    if(lIdx == NUMIDS)
    {
        return(0);
    }

    //
    // Fill in the SmartMedia globals based on the physical layout of the
    // SmartMedia card.
    //
    ulSMPageSize = sNANDMap[lIdx].ucPageSize ? 512 : 256;
    ulSMPagesPerBlock = sNANDMap[lIdx].ucPagesPerBlock;
    ulSMNumBlocks = (unsigned long)sNANDMap[lIdx].ucBlocks << 9;

    //
    // If requested, return the size of the SmartMedia card.
    //
    if(pulDeviceSize)
    {
        *pulDeviceSize = ulSMPageSize * ulSMPagesPerBlock * ulSMNumBlocks;
        *pulPageSize = ulSMPageSize;
        *pulPagesPerBlock = ulSMPagesPerBlock;
        *pulNumBlocks = ulSMNumBlocks;
    }

    //
    // Success.
    //
    return(1);
}

//****************************************************************************
//
// SMReadPage reads data from the specified page of the SmartMedia card.
//
//****************************************************************************
#if 0
long
SMReadPage(unsigned long ulPage, int bReadSpare, unsigned char *pucBuffer)
{
    unsigned long * volatile pulPtr = (unsigned long *)HwNANDAddress;
    unsigned char * volatile pucPortB = (unsigned char *)(HwBaseAddress +
                                                          HwPortB);
    long lIdx;

    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国成人福利片在线播放| 欧美一区二区三区视频免费| 色av综合在线| 久久综合九色综合97_久久久 | 91麻豆免费观看| 精品日韩在线一区| 亚洲成a人片综合在线| www.99精品| 久久久影视传媒| 日韩成人免费电影| 91久久久免费一区二区| 国产三级精品三级| 国内精品国产三级国产a久久| 欧美在线色视频| 一区在线观看视频| 盗摄精品av一区二区三区| 欧美va亚洲va香蕉在线| 午夜精品视频一区| 91精品福利视频| 日韩理论在线观看| 成人黄色777网| 国产欧美va欧美不卡在线| 精品系列免费在线观看| 欧美日韩国产综合一区二区| 一级中文字幕一区二区| 91久久精品一区二区| 亚洲日本免费电影| proumb性欧美在线观看| 国产精品久久毛片| 懂色av噜噜一区二区三区av| 国产欧美日本一区视频| 国产精品白丝jk黑袜喷水| 久久精品欧美日韩| 国产一区不卡精品| 欧美激情中文字幕一区二区| 国产成人欧美日韩在线电影| 欧美激情一区二区三区全黄| 国产成人8x视频一区二区| 国产日本欧美一区二区| 成人午夜在线免费| 曰韩精品一区二区| 欧美日韩精品一区二区三区蜜桃 | 国产无人区一区二区三区| 精品一区二区在线视频| 精品成人一区二区三区| 国产精品一二三区| 1000精品久久久久久久久| 日本韩国一区二区三区视频| 五月婷婷色综合| 久久久久久一级片| 成人一级片在线观看| 亚洲欧美国产毛片在线| 欧美色视频在线| 捆绑调教美女网站视频一区| 久久精品一区二区三区av| 91论坛在线播放| 天天综合网天天综合色| xnxx国产精品| 91原创在线视频| 免费在线观看成人| 久久久久久97三级| 色菇凉天天综合网| 久久国产欧美日韩精品| 国产精品人成在线观看免费| 在线日韩av片| 激情成人综合网| 亚洲精品第一国产综合野| 日韩一区二区三区视频| av电影在线观看一区| 毛片av一区二区| 综合欧美一区二区三区| 欧美一区二区三区视频在线| 91网站最新地址| 精品综合久久久久久8888| 亚洲人成伊人成综合网小说| 在线不卡一区二区| 本田岬高潮一区二区三区| 日本午夜精品视频在线观看| 欧美激情在线看| 欧美成人精品1314www| 色域天天综合网| 韩国av一区二区三区| 亚洲韩国一区二区三区| 国产午夜一区二区三区| 欧美一区中文字幕| 在线观看视频一区二区欧美日韩| 激情综合色丁香一区二区| 亚洲成va人在线观看| 亚洲欧洲综合另类| 国产欧美一区二区精品性色| 日韩欧美激情四射| 欧美三级韩国三级日本一级| 99在线热播精品免费| 久久99精品国产91久久来源| 午夜精品福利一区二区蜜股av| 国产精品私人影院| 26uuu国产日韩综合| 日韩午夜电影在线观看| 在线播放中文一区| 欧美视频在线观看一区二区| 91麻豆免费看片| 91在线一区二区| 成人亚洲精品久久久久软件| 国产成人在线网站| 国产激情精品久久久第一区二区 | 亚洲中国最大av网站| 日本一区二区三区四区在线视频| 精品第一国产综合精品aⅴ| 日韩写真欧美这视频| 欧美一级午夜免费电影| 日韩欧美美女一区二区三区| 91精品国产91久久久久久一区二区| 欧美日韩一级视频| 7777精品伊人久久久大香线蕉完整版| 欧美体内she精高潮| 91精彩视频在线观看| 色噜噜狠狠一区二区三区果冻| 91亚洲精华国产精华精华液| 色婷婷亚洲精品| 欧美优质美女网站| 欧美日韩在线播| 欧美日韩免费在线视频| 欧美丰满嫩嫩电影| 日韩欧美一区二区视频| 久久美女高清视频 | 26uuu亚洲综合色欧美| 2023国产精品视频| 国产精品美女www爽爽爽| 一区在线观看免费| 亚洲高清免费在线| 麻豆精品一区二区| 国产一区二区久久| 97久久精品人人澡人人爽| 在线免费观看日本欧美| 欧美一级淫片007| 国产欧美日韩麻豆91| 亚洲码国产岛国毛片在线| 亚洲成人动漫av| 国产一区二区三区黄视频| 成人午夜激情在线| 欧美吻胸吃奶大尺度电影| 日韩三级.com| 国产精品视频一区二区三区不卡| 亚洲精品国产a| 麻豆91精品91久久久的内涵| 成人高清视频在线| 欧美少妇一区二区| 久久久99久久| 天堂va蜜桃一区二区三区| 国产寡妇亲子伦一区二区| 日本韩国视频一区二区| 精品久久人人做人人爽| 亚洲欧美日韩一区二区三区在线观看| 日韩高清在线一区| 成人免费视频视频在线观看免费| 欧美在线观看一区| 久久久影视传媒| 亚洲电影欧美电影有声小说| 国产精品一区二区男女羞羞无遮挡 | 不卡一区二区在线| 91精品国产麻豆国产自产在线 | 99久久久久久99| 日韩欧美精品在线| 一二三区精品视频| 成人黄色免费短视频| 欧美一级免费观看| 一区二区三区欧美久久| 国产成人在线免费观看| 5858s免费视频成人| 中文字幕视频一区| 国产在线观看一区二区| 欧美一区二区三区日韩视频| 亚洲毛片av在线| 成人激情小说乱人伦| 精品国产免费视频| 日本不卡在线视频| 欧美在线观看禁18| ...中文天堂在线一区| 国产一区 二区| 欧美成人官网二区| 视频一区中文字幕国产| 欧美三级蜜桃2在线观看| 亚洲精品日产精品乱码不卡| 国产一区二区三区| 久久久综合九色合综国产精品| 免费观看在线综合| 欧美一级在线观看| 麻豆精品一二三| 日韩精品在线看片z| 美女一区二区三区| 欧美一级专区免费大片| 日韩精品电影在线观看| 欧美日韩国产一二三| 亚洲一二三四久久| 欧美午夜一区二区| 亚瑟在线精品视频| 欧美一区中文字幕| 精品一区二区三区视频| 精品久久久久一区二区国产| 国产呦精品一区二区三区网站|