??????????????????????????????????????????????????????????????rawos?????????????rawos????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????л???????????????rawos??mempool??????????????

typedef struct MEM_POOL
  {
   RAW_COMMON_BLOCK_OBJECT       common_block_obj;
  
   /* Define the number of available memory blocks in the pool.  */
   RAW_U32      raw_block_pool_available;
 
   /* Define the head pointer of the available block pool.  */
   RAW_U8      *raw_block_pool_available_list;
 
  } MEM_POOL;
 

?????????????????????????????????????block?????block????????????????????????block?????block???С???????????block??????????????????????????????????????????????mempool?????????????????????????????????????

RAW_U16  raw_block_pool_create(MEM_POOL *pool_ptr?? RAW_U8  *name_ptr?? RAW_U32  block_size?? RAW_VOID  *pool_start?? RAW_U32  pool_size)
  {
 
   //MEM_POOL   *tail_ptr;                  /* Working block pool pointer  */
   RAW_U32       blocks;                     /* Number of blocks in pool    */
   RAW_U8        *block_ptr;                  /* Working block pointer       */
   RAW_U8        *next_block_ptr;             /* Next block pointer          */
   RAW_U8        *end_of_pool;                /* End of pool area            */
   RAW_U8    block_align_mask;
  
   #if (RAW_BLOCK_FUNCTION_CHECK > 0)
      /* Check for invalid pool size.  */
  
     if (pool_size < (block_size +  block_size) ) {
   
    return RAW_BLOCK_SIZE_ERROR;
   }
 
   if (pool_ptr == 0) {
   
    return RAW_NULL_OBJECT;
   }
  
   if (pool_start == 0) {
   
    return RAW_NULL_POINTER;
   }
  
   #endif
 
    block_align_mask = sizeof(void *) - 1u;
 
   if (((RAW_U32)pool_start & block_align_mask)){                           
 
    return RAW_INVALID_ALIGN;
 
   }
  
   if ((pool_size & block_align_mask)) { 
   
    return RAW_INVALID_ALIGN;
   }
 
   if ((block_size & block_align_mask)) { 
   
    return RAW_INVALID_ALIGN;
   }
  
   /*Init the list*/
   list_init(&pool_ptr->common_block_obj.block_list);
 
   /* Setup the basic block pool fields.  */
   pool_ptr ->common_block_obj.name =  name_ptr;
   pool_ptr ->common_block_obj.block_way = 0;
  
   /* Calculate the end of the pool's memory area.  */
   end_of_pool =  (RAW_U8  *) pool_start + pool_size;
 
   /* Walk through the pool area?? setting up the available block list.  */
   blocks =            0;
   block_ptr =         (RAW_U8  *) pool_start;
   next_block_ptr =    block_ptr + block_size;
  
   while (next_block_ptr <= end_of_pool) {
 
     blocks++;
    
     if (next_block_ptr == end_of_pool) {
     
      break;
 
     }
 
     /* Setup the link to the next block.  */
     *((RAW_U8  * *) block_ptr) =  next_block_ptr;
 
     /* Advance to the next block.  */
     block_ptr =   next_block_ptr;
 
     /* Update the next block pointer.  */
     next_block_ptr =  block_ptr + block_size;
   }
 
   /* Set the last block's forward pointer to NULL.  */
   *((RAW_U8  * *) block_ptr) =  0;
 
   /* Save the remaining information in the pool control block.  */
   pool_ptr ->raw_block_pool_available =  blocks;
 
 
   pool_ptr ->raw_block_pool_available_list =  (RAW_U8  *) pool_start;
 
 
   return RAW_SUCCESS;
  }