The prstInstall() function is used by the bootstrap program to check whether:
there are RAM blocks already occupied by persistent memory devices that must be registered (tagged) as allocated
there are requests for additional RAM blocks to be allocated for new persistent memory devices
Code Example 4-9 is prstInstall() source code provided in source_dir/nucleus/bsp/src/boot_tools/prstInstall.c.
void prstInstall() { int i; RamDesc* ram = &bootConf->ramAllocator; RebootDesc* rd = bootConf->rebootDesc; /* * Tag existing persistent memory as allocated */ for (i = 0; i < rd->hot.prstMem.numChunks; ++i) { PrstChunk* chunk = &rd->hot.prstMem.chunks[i]; ASSERT(CEILING2(chunk->size, PAGE_SIZE_f) == chunk->size); if (chunk->status & PRST_CHUNK_ALLOCATED) { ram_tag(ram, chunk->paddr, (PhSize) chunk->size, PH_RAM_ALLOCATED); } } /* * Extend persistent memory */ for (i = 0; i < rd->hot.prstMem.numChunks; ++i) { PrstChunk* chunk = &rd->hot.prstMem.chunks[i]; ASSERT(CEILING2(chunk->size, PAGE_SIZE_f) == chunk->size); if (!(chunk->status & PRST_CHUNK_ALLOCATED)) { if (!ram_alloc(ram, &chunk->paddr, (PhSize) chunk->size, PAGE_SIZE_f)) { printf ("can't allocate 0x%x bytes of persistent memory\n", chunk->size); ASSERT(0); } else { chunk->status |= PRST_CHUNK_ALLOCATED; } } } }