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

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

?? zl5011xmm.c

?? Zalink50114----TDMoIP芯片驅動源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
    zl5011xMmAlloc

 Description:
   A memory area is allocated from the heap. A table in the device structure
   is used to track these memory allocations. The size of the table is fixed (to
   avoid dynamic allocation).
   A very simple algorithm is used, which just allocates from the start of the heap.
   A list in the structure is used to track the allocations, and to track memory
   being free抎 and released.

   Array in structure contains
        pBlockStart
        pBlockEnd
        iNextBlock
        iPrevBlock
   the last block in chain is 'labelled' with iNextBlock = zero.

 Inputs:
    zl5011xParams  Pointer to the structure for this device instance
   allocSize      size of the memory to allocate

 Outputs:
   pMemory        address of allocated block.

 Returns:
   zlStatusE

 Remarks:
   see also  zl5011xMmFree()
   Memory is allocated in 8 byte chunks and an allocation will be aligned to
   an 8 byte boundary. The allocation size is rounded up to the next 8 bytes.

*******************************************************************************/

extern zlStatusE zl5011xMmAlloc(zl5011xParamsS  *zl5011xParams, Uint32T allocSize, Uint32T *pMemory)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T size = 0;
   /* index variables for accessing the allocation table */
   Uint32T iNew = 0, iExisting, iNext;
   Uint32T temp;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmAlloc: size %08X", allocSize, 0, 0, 0, 0, 0);

   if ((zl5011xParams->packetMemory.heapStartAddress == (Uint32T)ZL5011X_NOT_INITIALISED) ||
      (zl5011xParams->packetMemory.heapEndAddress == (Uint32T)ZL5011X_NOT_INITIALISED))
   {
      status = ZL5011X_ERROR;
   }

   if (status == ZL5011X_OK)
   {
      /* round up the requested alloc size to a multiple of 8 bytes */
      size = (allocSize + ZL5011X_MM_GRANULARITY_MASK) & ~ZL5011X_MM_GRANULARITY_MASK;

      iNew = 0;
      /* find free item in array by looking for pStart = zero */
      while(iNew < ZL5011X_MEMORY_NUM_HEAP_ALLOCS)
      {
         if (zl5011xParams->packetMemory.allocTable[iNew].pBlockStart == 0)
         {
            break;
         }
         iNew++;
      }

      if (iNew == ZL5011X_MEMORY_NUM_HEAP_ALLOCS)
      {
         /* we reached the end */
         status = ZL5011X_PACKET_MEMORY_FAIL;
      }
   }

   /* find free area in memory */
   iExisting = 0;
   while((status == ZL5011X_OK) && (iExisting < ZL5011X_MEMORY_NUM_HEAP_ALLOCS))
   {
      iNext = zl5011xParams->packetMemory.allocTable[iExisting].iNextBlock;

      /* detect last block to be allocated  with iNext = zero */
      if (iNext == 0)
      {
         /* see if there is room for New block */
         temp = zl5011xParams->packetMemory.heapEndAddress -
               zl5011xParams->packetMemory.allocTable[iExisting].pBlockEnd;

         if (temp < size)
         {
            status = ZL5011X_PACKET_MEMORY_FAIL;
         }

         break;
      }

      /* detect if there is room between this existing block and next */
      if ((zl5011xParams->packetMemory.allocTable[zl5011xParams->packetMemory.allocTable[iExisting].iNextBlock].pBlockStart -
         zl5011xParams->packetMemory.allocTable[iExisting].pBlockEnd) > size)
      {
         break;
      }

      /* try the next block in the chain */
      iExisting = iNext;
   }

   /* check for end of existing blocks but no room found */
   if (status == ZL5011X_OK)
   {
      if (iExisting == ZL5011X_MEMORY_NUM_HEAP_ALLOCS)
      {
         status = ZL5011X_PACKET_MEMORY_FAIL;
      }
   }

   /* place new block */
   if (status == ZL5011X_OK)
   {
      /* place new block above existing block */
      zl5011xParams->packetMemory.allocTable[iNew].pBlockStart = zl5011xParams->packetMemory.allocTable[iExisting].pBlockEnd + 1;
      zl5011xParams->packetMemory.allocTable[iNew].pBlockEnd = zl5011xParams->packetMemory.allocTable[iExisting].pBlockEnd + size;
      zl5011xParams->packetMemory.allocTable[iNew].iNextBlock = zl5011xParams->packetMemory.allocTable[iExisting].iNextBlock;
      zl5011xParams->packetMemory.allocTable[iNew].iPrevBlock = iExisting;
      zl5011xParams->packetMemory.allocTable[zl5011xParams->packetMemory.allocTable[iExisting].iNextBlock].iPrevBlock = iNew;
      zl5011xParams->packetMemory.allocTable[iExisting].iNextBlock = iNew;

      /* output pointer to allocated block */
      *pMemory = zl5011xParams->packetMemory.allocTable[iNew].pBlockStart;
      ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmAlloc: size %08x, address %08x",
               size, *pMemory, 0, 0, 0, 0);
   }

   return(status);
}

/*******************************************************************************

 Function:
    zl5011xMmFree

 Description:
   The memory is released back into the heap by MmFree.
   A list in the structure is used to track the allocations and  frees.
   Normally clear start & end pointers and copy next & prev to their appropriate
   positions in prev & next blocks.

   Special behaviour for first item in array. Don't really free it, but leave next
   etc alone. leave start at zl5011xParams->packetMemory.heapStartAddress and 'zero' the block
   length (but maintain word alignment). Index is wasted but too bad.

 Inputs:
    zl5011xParams      Pointer to the structure for this device instance
   start address     pointer to start of block being freed.
   size

 Outputs:

 Returns:
   zlStatusE

 Remarks:
   see also  zl5011xMmAlloc()

*******************************************************************************/

extern zlStatusE zl5011xMmFree(zl5011xParamsS  *zl5011xParams, Uint32T pMemory)
{
   zlStatusE status = ZL5011X_OK;
   Uint32T index = 0;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmFree: address 0x%08x ", pMemory, 0, 0, 0, 0, 0);

   /* find item in array with this value of pStart */
   while(index < ZL5011X_MEMORY_NUM_HEAP_ALLOCS)
   {
      if (zl5011xParams->packetMemory.allocTable[index].pBlockStart == pMemory)
      {
         break;
      }

      index++;
   }

   if (index == ZL5011X_MEMORY_NUM_HEAP_ALLOCS)
   {
      /* we reached the end */
      status = ZL5011X_PARAMETER_INVALID;
   }

   /* remove the block */
   if (status == ZL5011X_OK)
   {
      if (index == 0)
      { /* special behaviour for first item - cannot be removed */
         status = ZL5011X_PARAMETER_INVALID;
      }
      else if (zl5011xParams->packetMemory.allocTable[index].iNextBlock == 0)
      {
       /* special behaviour for last block in chain
          * no change for iPrevBlock[iNextBlock[index]]
          */
         zl5011xParams->packetMemory.allocTable[zl5011xParams->packetMemory.allocTable[index].iPrevBlock].iNextBlock = 0;
         zl5011xParams->packetMemory.allocTable[index].pBlockStart = 0;
         zl5011xParams->packetMemory.allocTable[index].pBlockEnd = 0;
         zl5011xParams->packetMemory.allocTable[index].iNextBlock = 0;
         zl5011xParams->packetMemory.allocTable[index].iPrevBlock = 0;
      }
      else
      {  /* normal behaviour:  removal of block */
         zl5011xParams->packetMemory.allocTable[zl5011xParams->packetMemory.allocTable[index].iNextBlock].iPrevBlock = zl5011xParams->packetMemory.allocTable[index].iPrevBlock;
         zl5011xParams->packetMemory.allocTable[zl5011xParams->packetMemory.allocTable[index].iPrevBlock].iNextBlock = zl5011xParams->packetMemory.allocTable[index].iNextBlock;
         zl5011xParams->packetMemory.allocTable[index].pBlockStart = 0;
         zl5011xParams->packetMemory.allocTable[index].pBlockEnd = 0;
         zl5011xParams->packetMemory.allocTable[index].iNextBlock = 0;
         zl5011xParams->packetMemory.allocTable[index].iPrevBlock = 0;
      }
   }

   return(status);
}

/*******************************************************************************

 Function:
    zl5011xMmSetHeap

 Description:
   This defines the location of a packet memory heap. The alloc and free
   functions are used to access the heap.

 Inputs:
   zl5011xParams   Pointer to the structure for this device instance
   startHeap      start address for the memory heap
   endHeap        end address of the memory heap

 Outputs:

 Returns:
   zlStatusE

 Remarks:
   Addresses should be 8 byte aligned, since that is the minimum size that can
   be allocated.

*******************************************************************************/

extern zlStatusE zl5011xMmSetHeap(zl5011xParamsS  *zl5011xParams, Uint32T startHeap, Uint32T endHeap)
{
   zlStatusE status = ZL5011X_OK;
   Sint32T heapSize;

   ZL5011X_TRACE(ZL5011X_MM_FN_ID, "zl5011xMmSetHeap: start %08x, end %08x", startHeap, endHeap, 0, 0, 0, 0);

   /* the device uses 8 byte words, so round down / up the bottom 3 bits
      of the address as required */
   startHeap = startHeap & ~ZL5011X_MM_GRANULARITY_MASK;
   endHeap = endHeap | ZL5011X_MM_GRANULARITY_MASK;

   /* if the heap is requested to start at 0, actually make it start one
      location in, to help with the allocation function */
   if (startHeap == 0)
   {
      startHeap += ZL5011X_MM_GRANULARITY_MASK + 1;
   }

   /* if the start of the heap is in external memory, then check the end of the
      heap is also in the external memory */
   if ((startHeap > ZL5011X_EXT_MEM_BASE) &&
      (startHeap < (ZL5011X_EXT_MEM_BASE + zl5011xParams->packetMemory.extMemSizeBytes)))
   {
      if ((endHeap < ZL5011X_EXT_MEM_BASE) ||
         (endHeap > (ZL5011X_EXT_MEM_BASE + zl5011xParams->packetMemory.extMemSizeBytes)))
      {
         status = ZL5011X_PARAMETER_INVALID;
      }
   }

   if (status == ZL5011X_OK)
   {
      /* if the end of the heap is in internal memory, then check the end of the
         heap is also in the internal memory */
      if ((startHeap > ZL5011X_INT_MEM_BASE) &&
         (startHeap < (ZL5011X_INT_MEM_BASE + ZL5011X_INT_MEMORY_SIZE_IN_BYTES)))
      {
         if ((endHeap < ZL5011X_INT_MEM_BASE) ||
            (endHeap > (ZL5011X_INT_MEM_BASE + ZL5011X_INT_MEMORY_SIZE_IN_BYTES)))
         {
            status = ZL5011X_PARAMETER_INVALID;
         }
      }
   }

   if (status == ZL5011X_OK)
   {
      heapSize = endHeap - startHeap + 1;   /* +1 because both startHeap and endHeap are inclusive */

      if (heapSize < ZL5011X_MM_MIN_HEAP_SIZE)
      {
         status = ZL5011X_PARAMETER_INVALID;
      }
   }

   if (status == ZL5011X_OK)
   {
      zl5011xParams->packetMemory.heapStartAddress = startHeap;
      zl5011xParams->packetMemory.heapEndAddress = endHeap;

      /* the heap is now set up, so zero out the structure */
      (void)memset(zl5011xParams->packetMemory.allocTable, 0,
            sizeof(zl5011xParams->packetMemory.allocTable));

      /* initialise the first block for the allocation function. The first block
         is special, and must always be present */
      zl5011xParams->packetMemory.allocTable[0].pBlockStart = startHeap;
      zl5011xParams->packetMemory.allocTable[0].pBlockEnd = startHeap + ZL5011X_MM_GRANULARITY_MASK;
   }

   return(status);
}


/*****************   END   ****************************************************/


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美国产午夜精品| 91麻豆精品国产91| 奇米精品一区二区三区在线观看一| 美腿丝袜亚洲综合| 91年精品国产| 日韩精品一区在线| 日韩电影在线一区二区三区| www.成人在线| 久久久久高清精品| 国产精品三级电影| 1区2区3区欧美| 国产乱码精品一区二区三区五月婷| 色综合久久88色综合天天| 久久久噜噜噜久久中文字幕色伊伊| 首页综合国产亚洲丝袜| 91蝌蚪porny成人天涯| 91久久久免费一区二区| 中文字幕第一区综合| 中文字幕av资源一区| 久久爱www久久做| 正在播放亚洲一区| 日韩成人免费电影| 欧美日韩国产乱码电影| 一区二区三区精品| 91丨porny丨户外露出| 国产精品乱人伦| 国产成人欧美日韩在线电影| 日韩欧美视频一区| 蜜臀av性久久久久av蜜臀妖精| 欧美三级在线看| 亚洲一本大道在线| 欧美日韩国产美女| 欧美国产一区二区在线观看| 亚洲女同ⅹxx女同tv| 亚洲成人精品一区| 在线国产电影不卡| 精品99999| 久久99精品久久久久婷婷| 日韩一级片网站| 亚洲视频一二三区| 麻豆视频观看网址久久| 日韩视频在线观看一区二区| 青青草原综合久久大伊人精品优势| 国产成人av影院| 欧美军同video69gay| 日本伊人色综合网| 日韩精品一区二区三区在线观看| 亚洲欧美一区二区三区久本道91 | 久久综合久久久久88| 久久精品国产99国产| 精品国内二区三区| 成人黄色大片在线观看| 国产精品白丝在线| 在线观看日韩毛片| 美女一区二区在线观看| 久久久精品蜜桃| 91日韩精品一区| 欧美成人免费网站| 国产99久久久国产精品免费看| 国产精品第13页| 欧美日韩一区二区在线观看| 久久精品国产免费看久久精品| 久久九九国产精品| 韩国av一区二区| 欧美日韩国产综合一区二区 | 亚洲日本va在线观看| 精品视频一区三区九区| 狠狠久久亚洲欧美| 中文字幕一区二区三区精华液| 欧美日韩一区不卡| 国产丶欧美丶日本不卡视频| 一区二区高清在线| 26uuu另类欧美亚洲曰本| 在线看一区二区| 国产一区二区看久久| 国产一区二区三区免费| 欧美日韩国产在线观看| 成人免费高清在线观看| 欧美国产乱子伦| 欧美日韩精品一区二区天天拍小说 | 欧美日韩三级在线| 国内不卡的二区三区中文字幕| 亚洲欧美日韩国产一区二区三区| 成人黄色网址在线观看| 久久精品视频免费观看| 欧美日韩电影在线| 日韩黄色在线观看| 亚洲欧洲性图库| 亚洲精品一区二区三区精华液| 在线看日本不卡| 丝袜美腿亚洲色图| 亚洲欧美日韩人成在线播放| 精品国产青草久久久久福利| 欧美日韩激情在线| 91久久国产最好的精华液| 亚洲国产视频一区| 亚洲欧洲国产专区| 欧洲在线/亚洲| 成人午夜免费电影| 国产在线播放一区| 国产日韩在线不卡| 亚洲精品一区二区三区精华液| 成人午夜免费电影| 亚洲电影欧美电影有声小说| 国产精品免费久久| 欧美国产禁国产网站cc| 日韩亚洲电影在线| 欧美久久久久中文字幕| 欧美午夜在线观看| 久久99精品久久久久久国产越南| 图片区日韩欧美亚洲| 久久久无码精品亚洲日韩按摩| 欧美精品丝袜久久久中文字幕| 激情亚洲综合在线| 亚洲色图另类专区| 欧美精品1区2区3区| 国产白丝精品91爽爽久久| 亚洲欧美日韩人成在线播放| 中文字幕中文在线不卡住| 亚洲欧洲一区二区三区| 日韩视频123| 色婷婷精品大在线视频| 91天堂素人约啪| 色综合久久中文字幕| 色婷婷综合久久久久中文| 蓝色福利精品导航| 伊人夜夜躁av伊人久久| 亚洲综合色区另类av| 久久久亚洲高清| 中文字幕的久久| 亚洲女性喷水在线观看一区| 亚洲国产日韩在线一区模特| 久久久久国产成人精品亚洲午夜| 国产午夜精品理论片a级大结局| 欧美激情一区二区三区在线| 国产精品成人免费在线| 久久综合九色综合97婷婷 | 久久成人免费电影| 国产成人av电影在线观看| 91毛片在线观看| 在线播放亚洲一区| 一本一本大道香蕉久在线精品 | 99亚偷拍自图区亚洲| 91久久香蕉国产日韩欧美9色| 欧美绝品在线观看成人午夜影视| 久久亚洲捆绑美女| 亚洲色图视频网| 久久精品国产秦先生| 亚洲一区在线视频| 国产在线精品视频| 色婷婷综合久久久中文一区二区| 成人精品国产福利| 国产在线观看一区二区| 一本一本大道香蕉久在线精品 | 欧美久久一二区| 在线视频综合导航| 精品国产精品网麻豆系列| |精品福利一区二区三区| 国产精品网站在线观看| 久久久影院官网| 亚洲图片自拍偷拍| 亚洲一区av在线| 国产一区二区三区高清播放| 日本二三区不卡| 久久蜜臀精品av| 日本伊人色综合网| 国模无码大尺度一区二区三区| 九色|91porny| 国产精品一区2区| 国产成人99久久亚洲综合精品| 欧美日韩一区三区四区| 国产精品美女久久久久aⅴ| 日本大胆欧美人术艺术动态| 91麻豆国产精品久久| 国产亚洲短视频| 日本成人在线视频网站| 欧美性极品少妇| 亚洲欧洲日韩女同| 国产精品一二三区| 97精品视频在线观看自产线路二| 欧美成人综合网站| 亚洲电影中文字幕在线观看| 成人黄色免费短视频| 久久久久久**毛片大全| 看片的网站亚洲| 高清shemale亚洲人妖| 91视频在线看| 国产精品久线在线观看| 国产激情91久久精品导航| 91猫先生在线| 日韩一区二区影院| 日本aⅴ亚洲精品中文乱码| 在线观看日韩国产| 欧美刺激午夜性久久久久久久| 亚洲国产精品激情在线观看| 亚洲一区自拍偷拍| 国产一区二区美女诱惑| 欧美成人video| 久久99热这里只有精品| 欧美不卡123|