The _init_box function initializes a fixed block size memory pool. 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 4-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-12. However, the blk_size is rounded up to the next multiple of 4 to maintain 4-byte address alignment of the blocks. For example if you initialize a memory pool for 10-byte blocks, the _init_box function actually initializes the memory pool for 12-byte blocks. The _init_box function is in the RL-RTX library. The prototype is defined in rtl.h. Note - The first 12 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 12 bytes long.
- If the start address is not 4-byte aligned, the memory pool handling functions might fail.
|