Example 4-2 is the HotRebootDesc structure definition provided in kernel/include/chorus/bki/reboot.h.
/* * PrstChunk::status bit values */ #define PRST_CHUNK_ALLOCATED 0x1 #define PRST_CHUNK_MAPPED 0x2 /* * Descriptor of a chunk of persistent memory */ typedef struct PrstChunk { char* id; /* name string */ int status; /* status bit string */ VmSize size; /* size in bytes */ PhAddr paddr; /* starting physical address * valid if PRST_CHUNK_ALLOCATED is set */ VmAddr vaddr; /* starting virtual address */ * valid if PRST_CHUNK_MAPPED is set */ } PrstChunk; /* * Persistent memory descriptor */ typedef struct PrstMem { int maxChunks; /* max number of persistent memory chunks */ int numChunks; /* number of persistent memory chunks */ PrstChunk* chunks; /* array of persistent memory chunks */ int maxStrLen; /* max cumulated size of chunk ids */ int curStrLen; /* current cumulated size of chunk ids */ char* str; /* chunk ids buffer*/ } PrstMem; /* * The state kept over a hot reboot */ typedef struct HotRebootDesc { PrstMem prstMem; /* persistent memory descriptor */ } HotRebootDesc;
The prstMem field of HotRebootDesc describes the persistent memory (the portion of system RAM that must remain the same during subsequent hot reboots). The description is an array of PrstChunk structures, each one describing a persistent memory device (a contiguous named portion of persistent memory). The array is statically allocated in the reboot program data segment.
A persistent memory device is described by its symbolic name, id, the starting physical address, paddr, the starting virtual addresses, vaddr, and the size.
Different operating system components are involved in persistent memory device allocations:
The allocation request comes from the sysReboot() system call. The system call specifies the name and size of the device to be created during the subsequent hot boot.
The reboot program allocates a new PrstChunk descriptor and initializes the id and size fields with the values specified by the sysReboot() call. See "Hot Reboot" for details.
Then, after reboot, the bootstrap program dynamically allocates RAM blocks and initializes the paddr field. It also sets the PRST_CHUNK_ALLOCATED bit in the status field. See "kernel_start()" for details.
Finally, the micro-kernel allocates a virtual address range and sets the vaddr field. It also sets the PRST_CHUNK_MAPPED bit in the status field.