void stage_cache_load_stage(int stage_id, struct prog *stage) { struct imd *imd; struct stage_cache *meta; const struct imd_entry *e; void *c; size_t size; imd = imd_get(); e = imd_entry_find(imd, CBMEM_ID_STAGEx_META + stage_id); if (e == NULL) { printk(BIOS_DEBUG, "Error: Can't find %x metadata in imd\n", CBMEM_ID_STAGEx_META + stage_id); return; } meta = imd_entry_at(imd, e); e = imd_entry_find(imd, CBMEM_ID_STAGEx_CACHE + stage_id); if (e == NULL) { printk(BIOS_DEBUG, "Error: Can't find stage_cache %x in imd\n", CBMEM_ID_STAGEx_CACHE + stage_id); return; } c = imd_entry_at(imd, e); size = imd_entry_size(imd, e); memcpy((void *)(uintptr_t)meta->load_addr, c, size); prog_set_area(stage, (void *)(uintptr_t)meta->load_addr, size); prog_set_entry(stage, (void *)(uintptr_t)meta->entry_addr, (void *)(uintptr_t)meta->arg); }
/* Retrieve a region provided a given id. */ const struct cbmem_entry *cbmem_entry_find(u32 id) { struct imd *imd; struct imd imd_backing; const struct imd_entry *e; imd = imd_init_backing_with_recover(&imd_backing); e = imd_entry_find(imd, id); return imd_to_cbmem(e); }
const struct imd_entry *imd_entry_find_or_add(const struct imd *imd, uint32_t id, size_t size) { const struct imd_entry *e; e = imd_entry_find(imd, id); if (e != NULL) return e; return imd_entry_add(imd, id, size); }
void *cbmem_find(u32 id) { struct imd *imd; struct imd imd_backing; const struct imd_entry *e; imd = imd_init_backing_with_recover(&imd_backing); e = imd_entry_find(imd, id); if (e == NULL) return NULL; return imd_entry_at(imd, e); }
void stage_cache_get_raw(int stage_id, void **base, size_t *size) { struct imd *imd; const struct imd_entry *e; imd = imd_get(); e = imd_entry_find(imd, CBMEM_ID_STAGEx_RAW + stage_id); if (e == NULL) { printk(BIOS_DEBUG, "Error: Can't find %x raw data to imd\n", CBMEM_ID_STAGEx_RAW + stage_id); return; } *base = imd_entry_at(imd, e); *size = imd_entry_size(imd, e); }