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

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

?? blockalloc.c.bak

?? AMD公司官方版FLASH文件系統(tǒng)。有詳細說明文檔和Windows仿真測試環(huán)境。
?? BAK
字號:
/**
 * BlockAlloc.c
 * Contains functions that keep track of available blocks and
 *   garbage blocks.  It maintains an available block FIFO
 *   in the form of a linked list of CELL_TABLE_ENTRY's.
 *   It also keeps an array containing the number of garbage
 *   blocks in each sector.
 * Determines which sector is the best sector to erase for a
 *   cleanup.
 *
 * BlockAlloc functions are to be initialized and used by
 *   CellTable functions only.
 *
 * Functions in this file do not read or write to the flash
 *   they only organize and store the data given to them.
 *
 * Usage is a follows:
 *   dms_BlockAllocInitialize() is called at the beginning of
 *     the flash initialization process.  At this time the memory
 *     and data structures are allocated and initialized.
 *   dms_BlockAddAvailable() and dms_BlockIncrememtGarbageCount()
 *     are called foreach block found in each sector durring a 
 *     dms_SectorInitialize() (Through CellTable).
 *   At the end of initialization dms_BlockAllocComputeMinimum-
 *     AllowableBlocksFree() is called with the needed cell
 *     information that was collected by CellInfo.
 *   Durring a block write dms_BlockAlloc() is called to get a
 *     CELL_TABLE_ENTRY to the next available cell.  If the
 *     number of free blocks are less than the computed allowable
 *     minimum the the function returns NULL.  At this time
 *     a cleanup should be called.
 *   The cleanup operation uses dms_BlockGetBestSectorToErase() to
 *     determine which sector to erase.  This function also deletes
 *     all blocks in the  available block list which belong to that
 *     sector and clears the garbage count for that sector. 
 *   Durring a cleanup dms_BlockAllocNoMinimum() is used to get
 *     available blocks for moving blocks out of old sectors.
 *   dms_BlockFree() is called for each old block it frees the 
 *     CELL_TABLE_ENTRY memory and increments the garbage count
 *     for the sector of the block.
 *   dms_BlockAllocFinalize() is called durring a shutdown.  It
 *     frees all dynamic memory used by these functions.
 */

#include "BlockAlloc.h"
#include "SectorInfo.h"
#include <malloc.h>

/* localy used variables */
static CELL_TABLE_ENTRY *lpAvailableBlockList = NULL;     /* pointer to the head of the list */
static CELL_TABLE_ENTRY **lpAvailableBlockListEnd = NULL; /* pointer to the pointer (*pNext)      */
                                                          /* of the last node for quick additions */
                                                          /* to end of list                       */
static WORD lwAvailableBlockListSize;
static WORD *lwSectorGarbageBlockCountList = NULL;
static WORD lwSectorGarbageBlockCountListSize;
static WORD lwMinimumAllowableBlocksFree;

/* localy used functions */
void dms_lBlockAllocRemoveAvailableInSector(WORD awSectorIndex);

/**
 * dms_BlockAllocInitialize()
 * Must be called before any other functions in these file.
 * Creates and initializes memory for lwSectorGarbageBlockCountList.
 * Does not have any requirements of predefined/calculated globals.
 *
 * Prerequisites:
 *   None. 
 * Uses:
 *   malloc()
 * Used By:
 *   dms_CellTableInitialize()
 *   
 */
DMS_STATUS dms_BlockAllocInitialize(WORD awSectorCount){
  WORD wIndex;
   
  /* This will free existing memory if any */
  dms_BlockAllocFinalize();

  /* Initialize AvailableBlockList */
  lpAvailableBlockList = NULL;
  lwAvailableBlockListSize = 0;
  lpAvailableBlockListEnd = &lpAvailableBlockList; /* the first added not will be added to the head */

  /* Create array */
  lwSectorGarbageBlockCountList = (WORD*)malloc(sizeof(WORD) * awSectorCount);
  if (lwSectorGarbageBlockCountList == NULL) {
    return Out_Of_Memory_Error;
  }
  /* Initialize array */
  for (wIndex = 0; wIndex < awSectorCount; wIndex++){
    lwSectorGarbageBlockCountList[wIndex] = 0;
  }
  lwSectorGarbageBlockCountListSize = awSectorCount;

  /*
   * Set minimum allowable free data blocks to MAX_WORD.
   * It will be computed later when the largest cell size is known.
   */
  lwMinimumAllowableBlocksFree = MAX_WORD;

  return No_Error;
}

/**
 * dms_BlockAllocComputeMinimumAllowableBlocksFree()
 * This must be called before dms_BlockAlloc() is called otherwise 
 *   dms_BlockAlloc will always return NULL because
 *   lwMinimumAllowableBlocksFree will be set to MAX_WORD 0xFFFF.
 * Computes the value of the minimum allowable blocks free and stores
 *   it in a file local variable to be used by dms_BlockAlloc().
 * 
 * Returns:
 *   The computed value of the minimum allowable blocks free.
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 * Uses:
 *   Nothing other than provided arguments.
 * Used By:
 *   dms_CellTableCheckValidity()
 *   
 */
WORD dms_BlockAllocComputeMinimumAllowableBlocksFree(WORD awLargestSectorBlockCount, WORD awLargestCellBlockCount){
  /* compute the minimum allowable free data blocks */
  return lwMinimumAllowableBlocksFree = (WORD) (awLargestSectorBlockCount + 1);
}

/**
 * dms_BlockAlloc()
 * Gets pointer to next available block.
 * The block returned is the oldest block in the list.  ie. FIFO.
 * Returns NULL if number of available blocks less than or equal
 *   to minimum allowable blocks.
 *
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 *   dms_BlockAllocComputeMinumumAllowableBlocksFree() 
 * Uses:
 *   Nothing outside this file.
 *   dms_BlockAllocNoMinimum()
 * Used By:
 *   dms_CellTableCheckValidity()
 */
CELL_TABLE_ENTRY *dms_BlockAlloc(void){
  if (dms_BlockAllocIsAvailable()){ 
    return dms_BlockAllocNoMinimum();
  } else {
    return NULL;
  }
}

/**
 * dms_BlockAllocIsAvailable()
 * Returns non-zero if the number of available blocks is above the minimum
 *   allowable free blocks.
 * 
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 *   dms_BlockAllocComputeMinumumAllowableBlocksFree() 
 * Uses:
 *   Nothing outside this file.
 * Used By:
 *   dms_CellTableIsBlockAvailable()
 */
BYTE dms_BlockAllocIsAvailable(void){
  return ((BYTE) (lwAvailableBlockListSize > lwMinimumAllowableBlocksFree));
}

/**
 * dms_BlockAllocNoMinimum()
 * Returns a pointer to an available block and deletes the
 *   block from the available list.
 * The block returned is the oldest block in the list.  ie. FIFO.
 *   Blocks are inserted at the end of the list by dms_BlockAddAvailable()
 *   and removed from the front of the list.
 * This function is intended to be called ONLY by cleanup 
 *   while moving blocks to erase a sector.
 *
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 * Uses:
 *   Nothing outside this file.
 * Used By:
 *   dms_CellTableMoveBlock()
 *   dms_BlockAlloc()
 */
CELL_TABLE_ENTRY *dms_BlockAllocNoMinimum(void){
  CELL_TABLE_ENTRY *pBlockNode;
  /* Check if list is empty */
  if (lpAvailableBlockList == NULL) {
    return NULL;
  }
  /* Allocate first block in list */
  pBlockNode = lpAvailableBlockList; 
  lpAvailableBlockList = lpAvailableBlockList->pNext;
  pBlockNode->pNext = NULL;
  lwAvailableBlockListSize--;

  /* If the last block was taken then lpAvailableBlockListEnd must be set to  */
  /* the address of lpAvailableBlockList so that BlockAddAvailable() will */
  /* add the next block correctly */
  if (lpAvailableBlockList == NULL) {
    lpAvailableBlockListEnd = &lpAvailableBlockList;
  }
  return pBlockNode;
}

/**
 * dms_BlockFree()
 * Increments the garbage block count in the sector containing the
 * block and then frees the memory used by the CELL_TABLE_ENTRY.
 *
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 * Uses:
 *   dms_BlockIncrementGarbageCount()
 *   free()
 * Used By:
 *   dms_CellTableDeleteCellInProcess()
 *   dms_CellTableDeleteBlockInProcess()
 */
void dms_BlockFree(CELL_TABLE_ENTRY *apBlockEntry){
  if (apBlockEntry != NULL){
    dms_BlockIncrementGarbageCount(apBlockEntry->wSectorIndex);
    free(apBlockEntry);
  }
} 

/**
 * dms_BlockIncrementGarbageCount()
 * Increments the garbage block count in the sector.
 *
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 * Uses:
 *   Nothing outside this file.
 * Used By:
 *   dms_CellTableAddGarbageBlock()
 */
void dms_BlockIncrementGarbageCount(WORD awSectorIndex){
  lwSectorGarbageBlockCountList[awSectorIndex]++;
} 

/**
 * dms_BlockAddAvailable()
 * Allocates memory for new CELL_TABLE_ENTRY structure
 *   and adds to list of available to be used by BlockAlloc().
 * NOTE: This function is to be called durring a sector initialize.
 *
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 * Uses:
 *   malloc()
 * Used By:
 *   dms_CellTableAddAvailableBlock()
 */
DMS_STATUS dms_BlockAddAvailable(WORD awSectorIndex, WORD awSectorBlockIndex){
  CELL_TABLE_ENTRY *pNewEntry;

  pNewEntry = (CELL_TABLE_ENTRY*) malloc(sizeof(CELL_TABLE_ENTRY));				
  if (pNewEntry == NULL) {
    return Out_Of_Memory_Error; 
  }
  /* Initialize structure */
  pNewEntry->wBlockIndex = 0;
  pNewEntry->bCellStatus = CellErase;
  pNewEntry->wSectorIndex = awSectorIndex;
  pNewEntry->wSectorBlockIndex = awSectorBlockIndex;
  pNewEntry->pNext = NULL;
  /* Add block to end of list */
  *lpAvailableBlockListEnd = pNewEntry;
  lpAvailableBlockListEnd = &(pNewEntry->pNext);
  lwAvailableBlockListSize++;
  return No_Error;
}


/**
 * dms_BlockGetBestSectorToErase()
 * Chooses which sector should be erased for a cleanup.
 * Also assumes that the sector is getting erased and 
 *   calls dms_BlockAllocRemoveAvailableInSector and
 *   zeros out the garbage block count for that sector.
 *
 * Returns:
 *   No_Garbage_Blocks if all sector are clean and have no
 *     dirty blocks.
 *   No_Error if it has sector to erase and assignes the
 *     sector number to apwSectorIndex.
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 *   dms_SectorInfoDefineArchitecture()
 * Uses:
 *   dms_BlockAllocRemoveAvailableInSector()
     dms_SectorInfoGetBlockCount()
 * Used By:
 *   dms_CellTableGetBestSectorToErase()
 */
DMS_STATUS dms_BlockGetBestSectorToErase(WORD *apwSectorIndex){
  static WORD wSectorOffset = 0;
  WORD wSectorIndex, wIndex;
  WORD wLargestSectorIndex;
  WORD wLargestGarbageCount;
  /*
   * The best sector is the first one with the most
   * garbage blocks or the last one with all garbage blocks.
   * The search starts at the sSectorOffset'th sector and
   *   wSectorOffset is incremented each time this function
   *   is called.  This will allow for better distribution
   *   of sector erases for all sectors in the system.
   */
  wLargestSectorIndex = 0;
  wLargestGarbageCount = 0;
  for (wIndex = 0; wIndex < lwSectorGarbageBlockCountListSize; wIndex++){
    wSectorIndex = (WORD)((wIndex + wSectorOffset) % lwSectorGarbageBlockCountListSize);
    if (lwSectorGarbageBlockCountList[wSectorIndex] == dms_SectorInfoGetBlockCount(wSectorIndex)){
      wLargestGarbageCount = MAX_WORD;
      wLargestSectorIndex = wSectorIndex;
    } else if (lwSectorGarbageBlockCountList[wSectorIndex] > wLargestGarbageCount){
      wLargestGarbageCount = lwSectorGarbageBlockCountList[wSectorIndex];
      wLargestSectorIndex = wSectorIndex;
    }
  }
  /* Increment the starting sector for the next time */
  wSectorOffset = (WORD)((wSectorOffset + 1) % lwSectorGarbageBlockCountListSize);

  if (wLargestGarbageCount == 0) {
    return No_Garbage_Blocks;
  }
  /* remove all available blocks from the list that are in the sector */
  dms_lBlockAllocRemoveAvailableInSector(wLargestSectorIndex);
  /* reset the garbage count to zero */
  lwSectorGarbageBlockCountList[wLargestSectorIndex] = 0;
  /* set the result */
  *apwSectorIndex = wLargestSectorIndex;
  return No_Error; 
}

/**
 * dms_BlockAllocFinalize
 * Must be called when shutting down DMS software.
 * Frees list CELL_TABLE_ENTRY
 *
 * Prerequisites:
 *   None.
 * Uses:
 *   free()
 * Used By:
 *   dms_BlockAllocInitialize() 
 *   dms_CellTableInitialize()
 *   dms_CellTableFinalize()
 */
DMS_STATUS dms_BlockAllocFinalize(void){
  CELL_TABLE_ENTRY *pTmpEntry;
  if (lwSectorGarbageBlockCountList != NULL){
    free(lwSectorGarbageBlockCountList);
  }
  lwSectorGarbageBlockCountList = NULL;
  while (lpAvailableBlockList != NULL){
    pTmpEntry = lpAvailableBlockList;
    lpAvailableBlockList = lpAvailableBlockList->pNext;
    free(pTmpEntry);
  }
  lpAvailableBlockList = NULL;
  lpAvailableBlockListEnd = NULL;
  lwMinimumAllowableBlocksFree = MAX_WORD;
  return No_Error;
}

/**
 * dms_lBlockAllocRemoveAvailableInSector()
 * Traverses through the list and removes the entry whose wBlockIndex
 *   matches the provided awSectorIndex.
 *
 * Prerequisites:
 *   dms_BlockAllocInitialize() 
 * Uses:
 *   Nothing outside this file.
 * Used By:
 *   dms_BlockGetBestSectorToErase();
 */
void dms_lBlockAllocRemoveAvailableInSector(WORD awSectorIndex){
  CELL_TABLE_ENTRY **ppCell;
  CELL_TABLE_ENTRY *pTmpEntry;
  CELL_TABLE_ENTRY **pLastEntry = &lpAvailableBlockList;
  ppCell = &lpAvailableBlockList;
  while (*ppCell != NULL){
    if ((*ppCell)->wSectorIndex == awSectorIndex){
      pTmpEntry = (*ppCell);
      (*ppCell) = (*ppCell)->pNext;
      free(pTmpEntry);
      lwAvailableBlockListSize--;
    } else {
      /*
       *  Keep a pointer to the pNext of the last undeleted block in the list.
       */
      ppCell = &((*ppCell)->pNext);
      pLastEntry = ppCell;
    }
  }
  lpAvailableBlockListEnd = pLastEntry;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
综合精品久久久| 欧美日韩五月天| 国产三级欧美三级日产三级99| 日本美女一区二区三区视频| 91麻豆精品国产91久久久更新时间| 午夜国产不卡在线观看视频| 91精品在线免费| 精品亚洲国内自在自线福利| 久久久亚洲午夜电影| 成人污污视频在线观看| 亚洲品质自拍视频| 欧美肥妇毛茸茸| 美腿丝袜亚洲综合| 中文字幕不卡在线播放| 色哟哟一区二区在线观看| 一区二区国产盗摄色噜噜| 欧美精品久久天天躁| 狠狠色丁香久久婷婷综合丁香| 国产日韩精品一区二区三区在线| 色综合天天综合狠狠| 午夜精品久久久久影视| 精品久久久三级丝袜| 不卡av在线网| 日韩黄色片在线观看| 久久久久国产免费免费| 色婷婷激情综合| 久久99精品久久只有精品| 最新高清无码专区| 欧美一级黄色片| 99精品热视频| 久久爱www久久做| 亚洲精品少妇30p| 欧美大片在线观看一区二区| 99国产精品视频免费观看| 日韩av在线播放中文字幕| 国产精品视频一二三区| 69久久夜色精品国产69蝌蚪网| 国产成人免费网站| 日本不卡免费在线视频| 中文字幕亚洲电影| 精品国产91久久久久久久妲己| 色成人在线视频| 国产91丝袜在线播放0| 日本vs亚洲vs韩国一区三区二区| 国产精品国产成人国产三级 | 在线观看免费视频综合| 精品一区二区在线视频| 亚洲午夜久久久久久久久久久 | 亚洲va在线va天堂| 国产精品久久二区二区| 日韩欧美国产综合| 欧美色综合久久| www.av精品| 国产精品一区久久久久| 日韩国产欧美在线观看| 亚洲精品视频在线观看免费| 国产片一区二区三区| 日韩亚洲电影在线| 欧美日本韩国一区| 91福利精品第一导航| 成人激情动漫在线观看| 国产一本一道久久香蕉| 麻豆精品在线看| 日韩成人午夜精品| 五月婷婷另类国产| 亚洲一区二区三区四区在线 | 91国内精品野花午夜精品| 大尺度一区二区| 国产福利一区二区三区在线视频| 日韩国产一二三区| 日日摸夜夜添夜夜添国产精品 | 高清视频一区二区| 国内精品伊人久久久久av一坑| 丝袜美腿成人在线| 视频一区二区不卡| 午夜伦欧美伦电影理论片| 亚洲最新在线观看| 一区二区三区.www| 亚洲成a人片在线不卡一二三区 | 国产99久久久久| 国产精品自拍一区| 国产99久久精品| 9久草视频在线视频精品| 成人高清视频免费观看| av成人动漫在线观看| 99久免费精品视频在线观看| 91在线视频观看| 色哟哟在线观看一区二区三区| 在线亚洲高清视频| 91麻豆精品久久久久蜜臀| 欧美成人精品二区三区99精品| 欧美电影免费观看高清完整版在线观看| 精品欧美乱码久久久久久1区2区| 精品av综合导航| 国产精品日日摸夜夜摸av| 亚洲欧美日韩国产手机在线| 亚洲资源中文字幕| 调教+趴+乳夹+国产+精品| 日本va欧美va精品| 国产一区二区三区黄视频| 成人免费av在线| 色噜噜狠狠色综合中国| 欧美人狂配大交3d怪物一区| 日韩精品中文字幕一区| 久久日韩精品一区二区五区| 亚洲国产精品二十页| 亚洲精品第一国产综合野| 日韩在线一区二区三区| 国产麻豆视频一区二区| 99精品偷自拍| 日韩欧美美女一区二区三区| 国产精品天天看| 香蕉加勒比综合久久| 精品亚洲成a人在线观看| 91丨九色丨黑人外教| 欧美精品免费视频| 国产目拍亚洲精品99久久精品| 一个色在线综合| 国产中文字幕一区| 91浏览器在线视频| 欧美精品一区二区三区高清aⅴ| 中文字幕精品综合| 亚洲成av人片一区二区梦乃| 国产一区二区三区免费在线观看| 一本色道亚洲精品aⅴ| 日韩久久久久久| 亚洲女爱视频在线| 国产一区二区三区久久久| 欧美日韩综合在线免费观看| 久久久综合激的五月天| 三级欧美在线一区| 99re视频这里只有精品| 精品国产免费人成在线观看| 亚洲精品成人在线| 国产成人av一区二区| 91精品久久久久久蜜臀| 亚洲日本在线视频观看| 国产一区二区成人久久免费影院| 日本电影欧美片| 中文字幕av一区二区三区高| 日本亚洲电影天堂| 在线看不卡av| 成人欧美一区二区三区视频网页| 精品一区二区综合| 4438x成人网最大色成网站| 一区二区在线观看不卡| 成人久久视频在线观看| www国产精品av| 日本亚洲电影天堂| 欧美亚洲动漫精品| 亚洲欧美一区二区视频| 国产999精品久久久久久| 精品久久久久久久久久久久包黑料 | 91超碰这里只有精品国产| 亚洲免费大片在线观看| av中文字幕一区| 欧美国产97人人爽人人喊| 国产精品一区二区在线观看网站| 日韩精品一区二区三区在线播放| 秋霞午夜av一区二区三区| 欧美久久久一区| 天天操天天综合网| 欧美日韩成人综合在线一区二区| 亚洲一区二区av电影| 色94色欧美sute亚洲线路一ni| 国产精品成人免费在线| 白白色 亚洲乱淫| 日韩一区欧美小说| 91年精品国产| 一区二区成人在线| 欧美日韩黄色影视| 日本sm残虐另类| 精品欧美一区二区三区精品久久| 黄色成人免费在线| 久久久久久久久久久电影| 国产精品123区| 中文字幕一区二区在线观看 | 免费av成人在线| 精品少妇一区二区三区在线视频| 久久成人免费日本黄色| 精品国产一区二区三区av性色| 韩国三级在线一区| 中文字幕第一区第二区| 91麻豆精品一区二区三区| 亚洲综合激情另类小说区| 91 com成人网| 国产一区二区导航在线播放| 欧美国产综合色视频| 色婷婷综合在线| 日本亚洲天堂网| 国产精品免费人成网站| 91成人免费在线视频| 免费观看久久久4p| 国产日产精品1区| 91久久精品一区二区二区| 日韩一区欧美二区| 国产日韩欧美一区二区三区乱码 | 久久66热re国产| ●精品国产综合乱码久久久久| 欧美综合视频在线观看|