The _init_box8 function initializes a fixed block size memory pool with 8-byte alignment. When the memory pool is initialized, the RTX kernel handles memory requests by allocating a block of memory from the memory pool. The box_mem specifies the start address of the memory pool, and this address must be 8-byte aligned. The box_size argument specifies the size of the memory pool, in bytes. The blk_size argument specifies the size, in bytes, of the blocks in the memory pool. You can set the block size to any value from 1 to box_size-16. However, the blk_size is rounded up to the next multiple of 8, to maintain 8-byte alignment of the blocks. For example if you initialize a memory pool for 10-byte blocks, the _init_box8 function actually initializes the memory pool for 16-byte blocks. The _init_box8 function is implemented as a macro and is part of RL-RTX. The definition is in rtl.h. Note - The first 16 bytes from the memory pool are reserved for storing pointers and size information that can be used by the functions that handle the memory pool. The box_size must therefore be more than 16 bytes long.
- If the start address is not 8-byte aligned, the memory pool handling functions might fail.
|