The following example demonstrates how to manage reserved areas within the physical memory map. By explicitly initializing and joining only the available memory regions, the reserved ranges are effectively excluded from dynamic allocation.
/*
Memory map:
0000:0000 - 0000:03FF - Interrupt Vectors Table (reserved)
0000:0400 - 0000:FFFF - Available for memory allocation
0001:0000 - 0002:FFFF - Reserved for program code (reserved)
0003:0000 - 0009:FFFF - Available for memory allocation
000A:0000 - 000F:FFFF - Reserved for BIOS (reserved)
*/
#include <stdio.h>
#include "ST_API.h"
int main(void)
{
PVOID MemoryPool;
/* Initialization */
arInit();
stInit();
/* Initialize memory area from 0x00000400 to 0x00010000 */
MemoryPool = (PVOID) 0x00000400;
stMemoryInit(MemoryPool, 0xFC00);
/* Add memory area from 0x00030000 to 0x000A0000 */
stMemoryExpand(MemoryPool, (PVOID) 0x00030000, 0x70000);
/* TODO: Insert application code here. */
/* The MemoryPool is now ready for use, respecting the reserved areas. */
/* ... */
/* Deinitialization */
arDeinit();
return 0;
}