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

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

?? cell.c

?? AMD公司官方版FLASH文件系統(tǒng)。有詳細(xì)說明文檔和Windows仿真測試環(huán)境。
?? C
字號:
/**
 * Cell.c
 * 
 */

#include "Cell.h"
#include "CellTable.h"
#include "CellInfo.h"
#include "Block.h"
#include "BlockTable.h"
#include "Sector.h"
#include "SectorInfo.h"
#include "SectorHeader.h"
#include <malloc.h>
                       
extern SECTOR_DESCRIPTIOR gpDeviceArchitecture[];
                       
/**
 * dms_CellRead
 *
 * This function reads cell data from the Flash.  The location 
 *   that the data is stored is designated in apData.  apData 
 *   must be allocated before calling this function.  
 *
 * Arguments
 *   aiCellNumber    The cell number to read
 *   apData          The location to put the cell data
 *                     that is stored in the flash.
 * Prerequisites:
 *   dms_CellInitialize();
 * Uses:
 *   dms_CellTableResetBlockPointer()
 *   dms_CellTableGetNextBlock()
 *   dms_BlockRead()
 * Used By:
 *   dms_Read()
 */
DMS_STATUS dms_CellRead (WORD awCellIndex, BYTE *apData){
  DMS_STATUS eStatus;
  WORD wSectorIndex;
  WORD wSectorBlockIndex;
  WORD wBlockIndex;

  /*
   * Read each block.
   */
  wBlockIndex = 0;
  dms_CellTableResetBlockPointer(awCellIndex);
  while (dms_CellTableGetNextBlock(&wSectorIndex,&wSectorBlockIndex)){
    eStatus = dms_BlockRead(wSectorIndex,wSectorBlockIndex,apData+(((DWORD)sizeof(DATABLOCK))*((DWORD)wBlockIndex)));
    if (eStatus != No_Error){
      return eStatus;
    }
    wBlockIndex++;
  }

  return No_Error;
}

/**
 * dms_CellWrite
 *
 * Writes the apData to the flash in the defined cell.
 * The old cell data is destroyed when writing of the new
 *   cell has completed.
 * This function will not return to the calling program until the
 *   write completes. 
 * The Cell Write Process:
 *   Foreach block in existing cell
 *     write CellValid2 in cell status.
 *   Foreach block in cell
 *     Get new block.
 *     Write BlockBeingWritten in block status.
 *     Write cell number.
 *     Write block number.
 *     Write CellValid1 in cell status.
 *     Write block data.
 *     Write BlockValid in block status.
 *   Foreach old block in cell
 *     Write BlockErase in block status.
 *     Add block to garbage count.
 *
 * Arguments
 *   aiCellNumber    The cell number to write
 *   apData          The location containing the cell data
 *                     that is to be written to the flash.
 * Prerequisites:
 *   dms_CellInitialize();
 * Uses:
 *   dms_CellInfoGetBlockCount()
 *   dms_CellTableResetBlockPointer()
 *   dms_CellTableGetNextBlock()
 *   dms_CellTableSetCellInProcess()
 *   dms_CellTableGetAvailableBlock()
 *   dms_CellTableDeleteCellInProcess()
 *   dms_BlockWrite()
 *   dms_BlockTableWriteCellStatus()
 *   dms_BlockTableWriteBlockStatus()
 *   dms_SectorCleanup()
 * Used By:
 *   dms_Write()
 */
DMS_STATUS dms_CellWrite(WORD awCellIndex, BYTE *apData){
  DMS_STATUS eStatus;
  WORD wBlockIndex;
  WORD wSectorIndex;
  WORD wSectorBlockIndex;

  /*
   * Change cell status of each existing block in cell.
   */
  dms_CellTableResetBlockPointer(awCellIndex);
  while (dms_CellTableGetNextBlock(&wSectorIndex,&wSectorBlockIndex)){
    eStatus = dms_BlockTableWriteCellStatus(wSectorIndex,wSectorBlockIndex,CellValid2);
    if (eStatus != No_Error){
      return eStatus;
    }
  }

  /* dmsdbg_Printf("  Cell Start Write Of New\n"); */
  /* Move cell from cell table to cell in process */
  eStatus = dms_CellTableSetCellInProcess(awCellIndex);
  if (eStatus != No_Error){
    return eStatus;
  }

  /*
   * Get a new block and write the new data for each block in the cell.
   * It is better here to write the blocks in reverse order to allow
   *   efficient insertion of the block entries into the cell table.
   *   (Adding the block at the beginning of the list instead of having to
   *   traverse through all the blocks to insert at the end.)
   * The condition on the look cannot be wBlockIndex >= 0 because wBlockIndex
   *   is a WORD which is always positive therefore wBlockIndex + 1 != 0 is
   *   used.
   */
  wBlockIndex = dms_CellInfoGetBlockCount(awCellIndex);
  do {
    wBlockIndex--;  /* Pre-decrement */
    eStatus = dms_CellTableGetAvailableBlock(awCellIndex,wBlockIndex,&wSectorIndex,&wSectorBlockIndex);
    /* dmsdbg_Printf("  New Block: Status=%d\n",eStatus); */
    /* dmsdbg_Printf("  New Block: Cell=%d,  Block=%d,  Sector=%d,  SectorBlock=%d\n",awCellIndex,wBlockIndex,wSectorIndex,wSectorBlockIndex); */
    if (eStatus == No_Available_Blocks){
      /* perform a clean to free blocks */
      eStatus = dms_SectorCleanup();
      if (eStatus != No_Error) {
        return eStatus;
      }
      eStatus = dms_CellTableGetAvailableBlock(awCellIndex,wBlockIndex,&wSectorIndex,&wSectorBlockIndex);
      if (eStatus != No_Error) {
        /* something is wrong because a clean should at least clean one block. */
        return eStatus;
      }
    } else if (eStatus != No_Error) {
      return eStatus;
    }
    eStatus = dms_BlockWrite(awCellIndex,wBlockIndex,(BYTE)CellValid1,wSectorIndex,wSectorBlockIndex,
                             apData+(((DWORD)sizeof(DATABLOCK))*((DWORD)wBlockIndex)));
    if (eStatus != No_Error) {
      return eStatus;
    }
  } while (wBlockIndex != 0);

  /* Cleanup any cell that was in process one block at a time. */
  while (dms_CellTableDeleteCellInProcess(&wSectorIndex,&wSectorBlockIndex)){
    eStatus = dms_BlockTableWriteBlockStatus(wSectorIndex,wSectorBlockIndex,BlockErase);
    if (eStatus != No_Error) {
      return eStatus;
    }
  }
  return No_Error;
}

/**
 * dms_CellInitialize
 * Prepairs the DMS software to do Reads and Writes.
 *
 * Prerequisites:
 *   gpDeviceArchitecture must be defined.
 * Uses:
 *   dms_SectorInfoDefineArchitecture()
 *   dms_SectorInfoGetCount()
 *   dms_SectorInfoFinalize()
 *   dms_SectorHeaderGetCellCount()
 *   dms_CellTableInitialize()
 *   dms_CellTableCheckValidity()
 *   dms_CellTableDeleteBlockInProcess()
 *   dms_CellTableDeleteCellInProcess()
 *   dms_CellTableIsBlockAvailable()
 *   dms_CellTableFinalize()
 *   dms_BlockTableWriteBlockStatus()
 *   dms_SectorInitialize()
 *   dms_SectorCleanup()
 * Used By:
 *   dms_Initialize()
 */
DMS_STATUS dms_CellInitialize(void)
{
  DMS_STATUS eStatus;
  WORD wSectorIndex;
  WORD wSectorBlockIndex;
  WORD wCellCount;

  /* dmsdbg_Printf("CellInitialize\n"); */

  eStatus = dms_SectorInfoDefineArchitecture(gpDeviceArchitecture);
  if (eStatus != No_Error) {
    dms_SectorInfoFinalize();
    return eStatus;
  }

  eStatus = dms_SectorHeaderGetCellCount(&wCellCount);
  if (eStatus != No_Error) {
    dms_SectorInfoFinalize();
    return eStatus;
  }

  eStatus = dms_CellTableInitialize(wCellCount);
  if (eStatus != No_Error) {
    dms_SectorInfoFinalize();
    return eStatus;
  }

  for (wSectorIndex = 0; wSectorIndex < dms_SectorInfoGetCount(); wSectorIndex++){
    /* 
     * Reads block table of sector and adds blocks to cell table and
     *   block allocate list
     */
    eStatus = dms_SectorInitialize(wSectorIndex);
    if (eStatus != No_Error) {
      dms_CellTableFinalize();
      dms_SectorInfoFinalize();
      return eStatus;
    }
  }

  /*
   * Check that all the blocks are in each cell.  (Note: Cannot detect if
   *   the last block is missing because it uses the blocks that are found
   *   to determine the size of each cell.
   * Check for a partial cell that was in-process durring a power loss.
   */
  eStatus = dms_CellTableCheckValidity();
  if (eStatus != No_Error) {
    dms_CellTableFinalize();
    dms_SectorInfoFinalize();
    return eStatus;
  }

  /* Cleanup any block that was in process */
  if(dms_CellTableDeleteBlockInProcess(&wSectorIndex,&wSectorBlockIndex)){
    eStatus = dms_BlockTableWriteBlockStatus(wSectorIndex,wSectorBlockIndex,BlockErase);
    if (eStatus != No_Error) {
      dms_CellTableFinalize();
      dms_SectorInfoFinalize();
      return eStatus;
    }
  }

  /* Cleanup any cell that was in process one block at a time. */
  while (dms_CellTableDeleteCellInProcess(&wSectorIndex,&wSectorBlockIndex)){
    eStatus = dms_BlockTableWriteBlockStatus(wSectorIndex,wSectorBlockIndex,BlockErase);
    if (eStatus != No_Error) {
      dms_CellTableFinalize();
      dms_SectorInfoFinalize();
      return eStatus;
    }
  }
  /*
   * Everything is initialized and ok.
   * It is time to do some cleanups.
   * If power was lost durring a cleanup where there could be 
   *   many less available blocks than the allowable minimum.
   *   In which case it may take several ceanups to get above
   *   the allowable minimum.  A dmsWrite allows for only one 
   *   cleanup per block so it would fail if it took more than
   *   one cleanup to get above the minumum allowable available
   *   blocks.
   * By doing "SectorCount" number of cleanups it guarantees that
   *   all sectors will be clean and there will be the maximum
   *   amount of available blocks.
   * Stops doing cleanups when the number of free blocks is
   *   greater than the minimum allowable free block count or
   *   when no sectors are dirty.
   */
  for (wSectorIndex = 0; wSectorIndex < dms_SectorInfoGetCount(); wSectorIndex++){
    /* 
     *  do a sector cleanup
     */
    if (dms_CellTableIsBlockAvailable()){
      /*
       * Done enough cleanup for now.
       */
      break;
    }
    eStatus = dms_SectorCleanup();
    if (eStatus == No_Garbage_Blocks){
      /*
       * All Sectors are clean.
       * break out of for loop.
       */
      break;
    } else if (eStatus != No_Error) {
      dms_CellTableFinalize();
      dms_SectorInfoFinalize();
      return eStatus;
    } 
  }
  
  /*
   * Ready to read and write.
   */
  return No_Error;
}


/**
 * dms_CellFormat
 *
 * Upon completion of dms_CellFormat() the DMS software is
 *   completely shutdown.
 *
 * If dms_CellFormat returns anything other than No_Error then
 *   the flash must be reformated.
 *
 * Arguments
 *   aCellSize           Array of DWORDS that contains the size, 
 *                       in bytes, of each cell.  The array index
 *                       is the Cell number and the value in the
 *                       index is the size of the cell. 
 *   awCellCount         The number of elements in the array.
 * Prerequisites:
 *   gpDeviceArchitecture must be defined.
 * Uses:
 *   dms_SectorInfoDefineArchitecture()
 *   dms_SectorInfoGetBlockCount()
 *   dms_SectorInfoGetCount()
 *   dms_SectorInfoFinalize()
 *   dms_SectorFormatAll()
 *   dms_CellInfoDefineCellList()
 *   dms_CellInfoGetCount()
 *   dms_CellInfoGetBlockCount()
 *   dms_CellInfoFinalize()
 *   dms_BlockWrite()
 *   malloc()
 *   free()
 * Used By:
 *   dms_Format()
 */
DMS_STATUS dms_CellFormat (DWORD *apdwCellSize, WORD awCellCount)
{
    DMS_STATUS eStatus;
    WORD wSectorIndex;
    WORD wSectorBlockCount;
    WORD wCellIndex;
    WORD wBlockIndex;
    WORD wIndex;
    BYTE *bEmptyData;
                            
    /* dmsdbg_Printf("CellFormat\n"); */

    eStatus = dms_SectorInfoDefineArchitecture(gpDeviceArchitecture);
    if (eStatus != No_Error) {
      return eStatus;
    }

    eStatus = dms_CellInfoDefineCellList(apdwCellSize, awCellCount);
    if (eStatus != No_Error) {
      dms_SectorInfoFinalize();
      return eStatus;
    }

    /* erase sectors and write header information */
    eStatus = dms_SectorFormatAll(dms_CellInfoGetCount());
    if (eStatus != No_Error) {
      dms_CellInfoFinalize();
      dms_SectorInfoFinalize();
      return eStatus;
    }
   
    /* Create empty data to fill each new block with */
    bEmptyData = (BYTE*) malloc(sizeof(DATABLOCK));
    if (bEmptyData == NULL){
      dms_CellInfoFinalize();
      dms_SectorInfoFinalize();
      return Out_Of_Memory_Error;
    }
    /* Initialize data to 0 */
    for (wIndex = 0; wIndex < sizeof(DATABLOCK); wIndex++) bEmptyData[wIndex] = 0;
   
    /* Write each block of each cell into sector block table */
    wSectorIndex = 0;
    wSectorBlockCount = 0;
    for (wCellIndex = 0; wCellIndex < dms_CellInfoGetCount(); wCellIndex++){
      for (wBlockIndex = 0; wBlockIndex < dms_CellInfoGetBlockCount(wCellIndex); wBlockIndex++){
        if (wSectorBlockCount >= dms_SectorInfoGetBlockCount(wSectorIndex)){
          /* Increment through sectors as needed */
          wSectorIndex++;
          wSectorBlockCount = 0;
          if (wSectorIndex >= dms_SectorInfoGetCount()){
            free(bEmptyData);
            dms_CellInfoFinalize();
            dms_SectorInfoFinalize();
            return Total_Cell_Size_Too_Large;
          }
        }
        eStatus = dms_BlockWrite(wCellIndex,wBlockIndex,(BYTE)CellValid1,wSectorIndex,wSectorBlockCount,bEmptyData);
        if (eStatus != No_Error) {
          free(bEmptyData);
          dms_CellInfoFinalize();
          dms_SectorInfoFinalize();
          return eStatus;
        }
        wSectorBlockCount++;  
	  }
    }
    /* leave format with everything shut down */
    free(bEmptyData);
    dms_CellInfoFinalize();
    dms_SectorInfoFinalize();
    return No_Error;
}


/**
 * dms_CellFinalize
 * Frees all dynamic memory used by the dms software.
 * After this function is called then dms_CellInitialize()
 *   must be called to use dms again.
 * Prerequisites:
 *   None.
 * Uses:
 *   dms_CellTableFinalize()
 *   dms_SectorInfoFinalize()
 * Used By:
 *   dms_Shutdown()
 */
void dms_CellFinalize(void)
{
  dms_CellTableFinalize();
  dms_SectorInfoFinalize();
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕亚洲一区二区av在线| 国产欧美日韩麻豆91| 狠狠色综合色综合网络| 欧美激情在线一区二区| 91成人免费网站| 国产一区二区三区四区五区入口 | 91九色02白丝porn| 老司机午夜精品99久久| 亚洲天堂福利av| 日韩精品一区二区三区四区视频 | 亚洲成人1区2区| 精品国产伦理网| 欧美又粗又大又爽| 美日韩一区二区| 中文字幕一区二区三区在线播放| 欧美一级黄色大片| 一本色道久久综合亚洲91| 狠狠色综合日日| 亚洲最大的成人av| 欧美成人综合网站| 欧美性生活一区| 不卡电影一区二区三区| 麻豆国产精品官网| 亚洲第一会所有码转帖| 国产精品麻豆久久久| 日韩欧美美女一区二区三区| 日本韩国视频一区二区| 成人爽a毛片一区二区免费| 日本亚洲电影天堂| 国产精品电影一区二区| 在线观看一区不卡| 成人app下载| 国产成a人亚洲精| 九九精品一区二区| 视频在线观看国产精品| 一区二区激情视频| 亚洲日本中文字幕区| 26uuu国产电影一区二区| 欧美日韩aaaaaa| 91黄色免费版| 高清不卡在线观看| 国产成人精品午夜视频免费 | 国产一区啦啦啦在线观看| 亚洲第一综合色| 亚洲一区二区三区视频在线播放| 亚洲手机成人高清视频| 一色桃子久久精品亚洲| 中文一区二区完整视频在线观看| 久久久精品免费免费| 欧美大片在线观看一区| 91麻豆精品国产无毒不卡在线观看| 欧美专区在线观看一区| 日本电影亚洲天堂一区| 一本大道av一区二区在线播放| 成人高清免费观看| av电影在线观看一区| 成人午夜视频在线观看| 不卡的电视剧免费网站有什么| 丁香婷婷综合激情五月色| 成人性视频免费网站| 国产一区亚洲一区| 国产乱码精品一区二区三区av | 欧美精品久久一区二区三区| 欧美日韩一本到| 欧美欧美午夜aⅴ在线观看| 欧美高清一级片在线| 91麻豆精品国产91| 精品国产不卡一区二区三区| 26uuu国产一区二区三区| 欧美一级片免费看| 久久伊人蜜桃av一区二区| 国产欧美一区二区精品婷婷| 综合在线观看色| 亚洲激情成人在线| 日韩电影在线观看电影| 精品在线免费视频| 成人高清伦理免费影院在线观看| 99久久精品免费观看| 欧洲精品中文字幕| 欧美日韩中字一区| 精品处破学生在线二十三| 国产女人18水真多18精品一级做 | 亚洲精品日韩一| 亚洲成a天堂v人片| 蜜臀av一级做a爰片久久| 欧美日本视频在线| 久久―日本道色综合久久| 中文字幕日韩精品一区| 国产精品伦一区| 亚洲6080在线| 国产一区二区视频在线播放| 91蝌蚪porny九色| 日韩一级黄色大片| 国产精品久久久99| 日韩影院免费视频| 成人一区在线观看| 欧美精品日韩一区| 精品国产一区久久| 亚洲天堂2016| 日韩福利电影在线观看| 成人美女视频在线看| 色欧美88888久久久久久影院| 欧美日韩激情一区| 欧美激情一区二区三区| 亚洲v日本v欧美v久久精品| 国产精品亚洲第一区在线暖暖韩国 | 欧美顶级少妇做爰| 国产日产精品1区| 午夜精品免费在线| 国产成人综合网站| 欧美精品一二三四| 亚洲丝袜另类动漫二区| 国产一区在线看| 欧美日韩国产片| 欧美激情艳妇裸体舞| 美女视频黄 久久| 日本韩国欧美三级| 国产精品另类一区| 久久91精品国产91久久小草| 色哟哟一区二区三区| 欧美国产日本韩| 卡一卡二国产精品| 欧美人伦禁忌dvd放荡欲情| 亚洲欧美综合色| 国产高清不卡一区| 欧美一级理论性理论a| 一区av在线播放| gogogo免费视频观看亚洲一| 精品福利在线导航| 天堂久久一区二区三区| 欧美亚洲精品一区| 中文字幕中文乱码欧美一区二区| 久草在线在线精品观看| 免费在线观看不卡| 久久网站热最新地址| 久久爱www久久做| 美日韩一区二区| 一区二区三区中文在线观看| 欧美天天综合网| 亚洲人吸女人奶水| 99久久免费视频.com| 国产精品福利一区| 欧美精品一区二区三区蜜桃| 东方aⅴ免费观看久久av| 亚洲a一区二区| 日韩视频一区二区在线观看| 亚洲黄一区二区三区| 一区二区三区中文在线观看| 在线日韩国产精品| 婷婷激情综合网| 日韩一级免费一区| 国产成人亚洲综合a∨猫咪| 亚洲国产精品成人综合色在线婷婷| 成人毛片视频在线观看| 国产精品美女久久久久aⅴ| 99在线精品一区二区三区| 亚洲综合一区二区精品导航| 欧美日韩一本到| 国产在线看一区| 中文字幕一区二区三区四区 | 精品一区二区三区影院在线午夜| 久久久久久亚洲综合影院红桃| 成人短视频下载| 亚洲第一激情av| 精品sm捆绑视频| 99re视频这里只有精品| 亚洲国产成人av网| 精品成人在线观看| 色婷婷精品大在线视频| 日本午夜一区二区| 中文在线一区二区| 欧美久久一二区| 国产69精品久久777的优势| 亚洲一区二区三区四区在线观看| 欧美成人女星排名| 91视频在线观看| 久久 天天综合| 亚洲在线视频免费观看| 2021久久国产精品不只是精品| 91麻豆蜜桃一区二区三区| 奇米777欧美一区二区| 国产精品动漫网站| 日韩天堂在线观看| 91免费在线看| 国产一区二区三区免费看| 亚洲综合在线视频| 国产亚洲福利社区一区| 欧美日韩夫妻久久| jizz一区二区| 紧缚捆绑精品一区二区| 亚洲国产另类av| 中文字幕一区在线观看视频| 欧美一级精品大片| 欧美中文字幕一二三区视频| 国产一区二区三区| 日本大胆欧美人术艺术动态 | 亚洲色图20p| 2020国产精品自拍| 91精品国产综合久久国产大片| 色综合久久中文字幕综合网|