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

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

?? managednandflash.c

?? at91sam9263操作NAND FLASH代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to allocate.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_AllocateBlock(
    struct ManagedNandFlash *managed,
    unsigned short block)
{
    trace_LOG(INFO, "ManagedNandFlash_AllocateBlock(%d)\n\r", block);

    // Check that block is FREE
    if (managed->blockStatuses[block].status != NandBlockStatus_FREE) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_AllocateBlock: Block must be FREE\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Change block status to LIVE
    managed->blockStatuses[block].status = NandBlockStatus_LIVE;
    return WriteBlockStatus(managed, block);
}

//------------------------------------------------------------------------------
/// Releases a LIVE block of a nandflash and marks it as DIRTY.
/// Returns 0 if successful; otherwise returns NandCommon_ERROR_WRONGSTATUS if
/// the block is not LIVE, or a RawNandFlash_WritePage error.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to release.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_ReleaseBlock(
    struct ManagedNandFlash *managed,
    unsigned short block)
{
    unsigned char spare[NandCommon_MAXPAGESPARESIZE];

    trace_LOG(INFO, "ManagedNandFlash_ReleaseBlock(%d)\n\r", block);

    // Check that block is LIVE
    if (managed->blockStatuses[block].status != NandBlockStatus_LIVE) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_ReleaseBlock: Block must be LIVE\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Change block status to DIRTY
    managed->blockStatuses[block].status = NandBlockStatus_DIRTY;
    return WriteBlockStatus(managed, block);
}

//------------------------------------------------------------------------------
/// Erases a DIRTY block of a managed NandFlash.
/// Returns the RawNandFlash_EraseBlock code or NandCommon_ERROR_WRONGSTATUS.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to erase.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_EraseBlock(
    struct ManagedNandFlash *managed,
    unsigned short block)
{
    unsigned char error;
    unsigned char spare[NandCommon_MAXPAGESPARESIZE];

    trace_LOG(INFO, "ManagedNandFlash_EraseBlock(%d)\n\r", block);

    // Check block status
    if (managed->blockStatuses[block].status != NandBlockStatus_DIRTY) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_EraseBlock: Block must be DIRTY\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Erase block
    error = RawNandFlash_EraseBlock(RAW(managed), block);
    if (error) {

        return error;
    }

    // Update block status
    managed->blockStatuses[block].status = NandBlockStatus_FREE;
    managed->blockStatuses[block].eraseCount++;
    return WriteBlockStatus(managed, block);
}

//------------------------------------------------------------------------------
/// Reads the data and/or the spare area of a page on a managed nandflash. If
/// the data pointer is not 0, then the block MUST be LIVE.
/// Returns NandCommon_ERROR_WRONGSTATUS if the block is not LIVE and the data
/// pointer is not null; Otherwise, returns EccNandFlash_ReadPage().
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of block to read page from.
/// \param page  Number of page to read inside the given block.
/// \param data  Data area buffer, can be 0.
/// \param spare  Spare area buffer, can be 0.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_ReadPage(
    const struct ManagedNandFlash *managed,
    unsigned short block,
    unsigned short page,
    void *data,
    void *spare)
{
    // Check that the block is LIVE if data is requested
    if ((managed->blockStatuses[block].status != NandBlockStatus_LIVE)
        && (managed->blockStatuses[block].status != NandBlockStatus_DIRTY)) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_ReadPage: Block must be LIVE or DIRTY.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Read data with ECC verification
    return EccNandFlash_ReadPage(ECC(managed), block, page, data, spare);
}

//------------------------------------------------------------------------------
/// Writes the data and/or spare area of a LIVE page on a managed NandFlash.
/// Returns NandCommon_ERROR_WRONGSTATUS if the page is not LIVE; otherwise,
/// returns EccNandFlash_WritePage().
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Number of the block to write.
/// \param page  Number of the page to write inside the given block.
/// \param data  Data area buffer.
/// \param spare  Spare area buffer.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_WritePage(
    const struct ManagedNandFlash *managed,
    unsigned short block,
    unsigned short page,
    void *data,
    void *spare)
{
    // Check that the block is LIVE
    if (managed->blockStatuses[block].status != NandBlockStatus_LIVE) {

        trace_LOG(trace_ERROR, "ManagedNandFlash_WritePage: Block must be LIVE.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // Write data with ECC calculation
    return EccNandFlash_WritePage(ECC(managed), block, page, data, spare);
}

//------------------------------------------------------------------------------
/// Copy the data & spare area of one page to another page. The source block
/// can be either LIVE or DIRTY, and the destination block must be LIVE; they
/// must both have the same parity.
/// Returns 0 if successful; NandCommon_ERROR_WRONGSTATUS if one or more page
/// is not live; otherwise returns an NandCommon_ERROR_xxx code.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param sourceBlock  Source block number.
/// \param sourcePage  Number of source page inside the source block.
/// \param destBlock  Destination block number.
/// \param destPage  Number of destination page inside the dest block.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_CopyPage(
    const struct ManagedNandFlash *managed,
    unsigned short sourceBlock,
    unsigned short sourcePage,
    unsigned short destBlock,
    unsigned short destPage)
{
    unsigned char error;

    ASSERT((sourcePage & 1) == (destPage & 1),
           "ManagedNandFlash_CopyPage: source & dest pages must have the same parity\n\r");

    trace_LOG(INFO, "ManagedNandFlash_CopyPage(B#%d:P#%d -> B#%d:P#%d)\n\r",
              sourceBlock, sourcePage, destBlock, destPage);

    // Check block statuses
    if ((managed->blockStatuses[sourceBlock].status != NandBlockStatus_LIVE)
         && (managed->blockStatuses[sourceBlock].status != NandBlockStatus_DIRTY)) {

        trace_LOG(trace_ERROR,
                  "ManagedNandFlash_CopyPage: Source block must be LIVE or DIRTY.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }
    if (managed->blockStatuses[destBlock].status != NandBlockStatus_LIVE) {

        trace_LOG(trace_ERROR,
                  "ManagedNandFlash_CopyPage: Destination block must be LIVE.\n\r");
        return NandCommon_ERROR_WRONGSTATUS;
    }

    // If destination page is page #0, block status information must not be
    // overwritten
    if (destPage == 0) {

        unsigned char data[NandCommon_MAXPAGEDATASIZE];
        unsigned char spare[NandCommon_MAXPAGESPARESIZE];

        // Read data & spare to copy
        error = EccNandFlash_ReadPage(ECC(managed), sourceBlock, sourcePage, data, spare);
        if (error) {

            return error;
        }

        // Write destination block status information in spare
        NandSpareScheme_WriteExtra(NandFlashModel_GetScheme(MODEL(managed)),
                                   spare,
                                   &(managed->blockStatuses[destBlock]),
                                   4,
                                   0);

        // Write page
        error = RawNandFlash_WritePage(RAW(managed), destBlock, destPage, data, spare);
        if (error) {

            return error;
        }
    }
    // Otherwise, a normal copy can be done
    else {

        return RawNandFlash_CopyPage(RAW(managed),
                                     sourceBlock,
                                     sourcePage,
                                     destBlock,
                                     destPage);
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Copies the data from a whole block to another block on a nandflash. Both
/// blocks must be LIVE.
/// Returns 0 if successful; otherwise returns NandCommon_ERROR_WRONGSTATUS if
/// at least one of the blocks is not free, or a NandCommon_ERROR_xxx code.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param sourceBlock  Source block number.
/// \param destBlock  Destination block number.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_CopyBlock(
    const struct ManagedNandFlash *managed,
    unsigned short sourceBlock,
    unsigned short destBlock)
{
    unsigned short numPages = NandFlashModel_GetBlockSizeInPages(MODEL(managed));
    unsigned char error;
    unsigned short page;

    ASSERT(sourceBlock != destBlock,
           "ManagedNandFlash_CopyBlock: Source block must be different from dest. block\n\r");

    trace_LOG(INFO, "ManagedNandFlash_CopyBlock(B#%d->B#%d)\n\r",
              sourceBlock, destBlock);

    // Copy all pages
    for (page=0; page < numPages; page++) {

        error = ManagedNandFlash_CopyPage(managed,
                                          sourceBlock,
                                          page,
                                          destBlock,
                                          page);
        if (error) {

            trace_LOG(trace_ERROR,
                      "ManagedNandFlash_CopyPage: Failed to copy page %d\n\r",
                      page);
            return error;
        }
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Erases all the blocks which are currently marked as DIRTY.
/// Returns 0 if successful; otherwise, returns a NandCommon_ERROR code.
/// \param managed  Pointer to a ManagedNandFlash instance.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_EraseDirtyBlocks(
    struct ManagedNandFlash *managed)
{
    unsigned int i;
    unsigned char error;

    // Erase all dirty blocks
    for (i=0; i < NandFlashModel_GetDeviceSizeInBlocks(MODEL(managed)); i++) {

        if (managed->blockStatuses[i].status == NandBlockStatus_DIRTY) {

            error = ManagedNandFlash_EraseBlock(managed, i);
            if (error) {

                return error;
            }
        }
    }

    return 0;
}

//------------------------------------------------------------------------------
/// Looks for the youngest block having the desired status among the blocks
/// of a managed nandflash. If a block is found, its index is stored inside
/// the provided variable (if pointer is not 0).
/// Returns 0 if a block has been found; otherwise returns either
/// NandCommon_ERROR_NOBLOCKFOUND if there are no blocks having the desired
/// status.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param block  Pointer to the block number variable.
//------------------------------------------------------------------------------
unsigned char ManagedNandFlash_FindYoungestBlock(
    const struct ManagedNandFlash *managed,
    unsigned char status,
    unsigned short *block)
{
    unsigned char found = 0;
    unsigned short bestBlock = 0;
    unsigned int i;

    // Go through the block array
    for (i=0; i < NandFlashModel_GetDeviceSizeInBlocks(MODEL(managed)); i++) {

        // Check status
        if (managed->blockStatuses[i].status == status) {

            // If no block was found, i becomes the best block
            if (!found) {

                found = 1;
                bestBlock = i;
            }
            // Compare the erase counts otherwise
            else if (managed->blockStatuses[i].eraseCount
                     < managed->blockStatuses[bestBlock].eraseCount) {

                bestBlock = i;
            }
        }
    }

    if (found) {

        if (block) {

            *block = bestBlock;
        }
        return 0;
    }
    else {

        return NandCommon_ERROR_NOBLOCKFOUND;
    }
}

//------------------------------------------------------------------------------
/// Counts and returns the number of blocks having the given status in a
/// managed nandflash.
/// \param managed  Pointer to a ManagedNandFlash instance.
/// \param status  Desired block status.
//------------------------------------------------------------------------------
unsigned short ManagedNandFlash_CountBlocks(
    const struct ManagedNandFlash *managed,
    unsigned char status)
{
    unsigned int i;
    unsigned short count = 0;

    // Examine each block
    for (i=0; i < NandFlashModel_GetDeviceSizeInBlocks(MODEL(managed)); i++) {

        if (managed->blockStatuses[i].status == status) {

            count++;
        }
    }

    return count;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美专区日韩专区| 蜜臀久久久99精品久久久久久| 在线观看亚洲a| 久99久精品视频免费观看| 中文字幕乱码日本亚洲一区二区| 欧美日韩在线播放一区| 成人手机电影网| 日韩不卡免费视频| 有码一区二区三区| 国产精品午夜电影| 日韩欧美一级二级三级| 91久久人澡人人添人人爽欧美| 国产在线精品一区二区不卡了| 亚洲一区二区中文在线| 日本一区二区三区在线观看| 欧美一区二区三区四区在线观看| 色哟哟一区二区在线观看| 国产真实乱偷精品视频免| 丝袜亚洲另类欧美综合| 亚洲精品久久久蜜桃| 国产精品你懂的在线| 精品国产99国产精品| 欧美日韩国产片| 欧美亚洲另类激情小说| 成人ar影院免费观看视频| 国产精品69毛片高清亚洲| 日本亚洲电影天堂| 日韩中文字幕91| 亚洲最大成人综合| 亚洲激情一二三区| 亚洲天堂福利av| 国产精品国产三级国产a| 久久久不卡影院| 亚洲精品在线三区| 91精品国产综合久久精品| 欧美日韩视频一区二区| 欧美怡红院视频| 欧美性受xxxx黑人xyx性爽| 色综合久久九月婷婷色综合| 岛国精品在线观看| 成人高清伦理免费影院在线观看| 豆国产96在线|亚洲| 成人午夜免费电影| 成人综合婷婷国产精品久久免费| 国产在线精品一区二区夜色| 国产精品1区2区3区| 国产河南妇女毛片精品久久久| 国产剧情一区二区三区| 国产激情精品久久久第一区二区 | 日韩欧美色电影| 日韩欧美国产精品一区| 精品福利在线导航| 久久久精品国产免费观看同学| 久久蜜桃一区二区| 国产精品久久午夜夜伦鲁鲁| 一区二区中文字幕在线| 国产精品免费视频网站| 亚洲欧美成人一区二区三区| 亚洲午夜国产一区99re久久| 日韩精品一二三| 狠狠色综合色综合网络| 成人污污视频在线观看| 91论坛在线播放| 欧美久久婷婷综合色| 欧美一区二区三区电影| 久久久久久久久免费| 一区精品在线播放| 五月天亚洲婷婷| 国产一区在线观看麻豆| 成人午夜在线播放| 欧美专区日韩专区| 欧美变态tickle挠乳网站| 国产清纯在线一区二区www| 自拍偷拍亚洲综合| 日本最新不卡在线| 国产精品一区二区免费不卡| 91浏览器打开| 日韩精品一区二区三区三区免费| 中文一区在线播放| 婷婷一区二区三区| 国产福利一区二区三区视频 | 日本欧美一区二区三区乱码 | 成人av在线资源| 91蜜桃网址入口| 日韩一区二区免费电影| 日本一区二区三区在线不卡| 亚洲国产综合色| 国产成a人无v码亚洲福利| 在线观看一区二区视频| 久久在线观看免费| 亚洲综合成人网| 国产成人aaa| 欧美丰满一区二区免费视频| 中文字幕av一区二区三区高| 婷婷中文字幕一区三区| www.爱久久.com| 欧美一级夜夜爽| 一区二区视频在线看| 国产一区二区三区四区在线观看| 一本大道久久a久久精二百| 日韩欧美久久久| 一区二区三区欧美在线观看| 国产成人综合网站| 欧美精品一级二级| 自拍视频在线观看一区二区| 麻豆国产一区二区| 欧美又粗又大又爽| 国产精品久久久久久久裸模 | 蜜桃视频在线观看一区| 一本大道综合伊人精品热热| 国产亚洲成aⅴ人片在线观看| 午夜电影网一区| 在线观看日产精品| 国产精品久久久久影院色老大| 激情六月婷婷综合| 91精品国产综合久久香蕉麻豆| 亚洲码国产岛国毛片在线| 成人免费高清视频| 亚洲精品一区二区三区蜜桃下载| 日韩精品高清不卡| 欧美午夜寂寞影院| 亚洲狼人国产精品| 99视频精品免费视频| 国产视频911| 国产乱码字幕精品高清av| 欧美一区二区大片| 日本视频一区二区| 欧美日韩亚洲综合一区二区三区| 亚洲精品久久7777| 91免费国产在线观看| 亚洲嫩草精品久久| 9i在线看片成人免费| 国产精品亲子伦对白| 国产精品香蕉一区二区三区| 久久久久久久久99精品| 极品少妇一区二区| 久久女同性恋中文字幕| 国产精品一区二区91| 久久综合九色综合欧美亚洲| 极品少妇一区二区| 久久麻豆一区二区| 国产精品一线二线三线精华| 国产亚洲一区二区在线观看| 国产麻豆精品久久一二三| www精品美女久久久tv| 国内精品久久久久影院色| 欧美xxxxxxxx| 国内精品视频一区二区三区八戒| 精品免费国产一区二区三区四区| 日本不卡在线视频| 3d成人h动漫网站入口| 亚洲欧美电影一区二区| 91亚洲大成网污www| 亚洲男人的天堂av| 99re热视频精品| 亚洲国产人成综合网站| 欧美性淫爽ww久久久久无| 亚洲国产美国国产综合一区二区| 色综合咪咪久久| 天堂成人国产精品一区| 91精品国产综合久久久蜜臀粉嫩| 日韩国产欧美一区二区三区| 99久久久免费精品国产一区二区| 中文字幕国产一区| 顶级嫩模精品视频在线看| 国产日产亚洲精品系列| a亚洲天堂av| 一区二区三区精密机械公司| 欧美日韩在线播| 免费观看久久久4p| 国产精品久久久久影院亚瑟| 色域天天综合网| 亚洲成人自拍一区| 欧美日韩精品欧美日韩精品一综合| 蜜臀a∨国产成人精品| 久久青草国产手机看片福利盒子 | 国产精品一线二线三线| 亚洲九九爱视频| 欧美精品1区2区3区| 麻豆视频观看网址久久| 2024国产精品视频| 精品一区二区三区日韩| 欧美α欧美αv大片| 国产乱码精品一区二区三区av | 亚洲免费观看高清完整版在线 | 欧美日韩精品久久久| 日韩1区2区3区| 久久这里只有精品视频网| 国产999精品久久久久久绿帽| 亚洲福利一区二区| 精品欧美黑人一区二区三区| 不卡的av在线| 亚洲午夜在线视频| 国产欧美中文在线| 欧美午夜理伦三级在线观看| 久久国产乱子精品免费女| 亚洲美女区一区| 久久综合五月天婷婷伊人| 91视频免费看| 国产在线精品免费av|