lib/stage_cache: Add save/get raw storage
Leverage the stage_cache mechanism to store a non-specific type of data. This is not interesting when the location for the cache is in cbmem. However it will be more useful when an external location is used, e.g. when the cache is in TSEG, locked from user modification. Change-Id: Iaf0b25ebe14c176bbd24fc8942f902f627ca8e6f Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/23518 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
Martin Roth
parent
ac1cd44525
commit
8d6e0e0a72
@@ -45,6 +45,35 @@ void stage_cache_add(int stage_id, const struct prog *stage)
|
||||
memcpy(c, prog_start(stage), prog_size(stage));
|
||||
}
|
||||
|
||||
void stage_cache_add_raw(int stage_id, const void *base, const size_t size)
|
||||
{
|
||||
void *c;
|
||||
|
||||
c = cbmem_add(CBMEM_ID_STAGEx_RAW + stage_id, size);
|
||||
if (c == NULL) {
|
||||
printk(BIOS_DEBUG, "Error: Can't add %x raw data to cbmem\n",
|
||||
CBMEM_ID_STAGEx_RAW + stage_id);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(c, base, size);
|
||||
}
|
||||
|
||||
void stage_cache_get_raw(int stage_id, void **base, size_t *size)
|
||||
{
|
||||
const struct cbmem_entry *e;
|
||||
|
||||
e = cbmem_entry_find(CBMEM_ID_STAGEx_RAW + stage_id);
|
||||
if (e == NULL) {
|
||||
printk(BIOS_ERR, "Error: Can't find raw %x data in cbmem\n",
|
||||
CBMEM_ID_STAGEx_RAW + stage_id);
|
||||
return;
|
||||
}
|
||||
|
||||
*base = cbmem_entry_start(e);
|
||||
*size = cbmem_entry_size(e);
|
||||
}
|
||||
|
||||
void stage_cache_load_stage(int stage_id, struct prog *stage)
|
||||
{
|
||||
struct stage_cache *meta;
|
||||
|
@@ -93,6 +93,47 @@ void stage_cache_add(int stage_id, const struct prog *stage)
|
||||
memcpy(c, prog_start(stage), prog_size(stage));
|
||||
}
|
||||
|
||||
void stage_cache_add_raw(int stage_id, const void *base, const size_t size)
|
||||
{
|
||||
struct imd *imd;
|
||||
const struct imd_entry *e;
|
||||
void *c;
|
||||
|
||||
imd = imd_get();
|
||||
e = imd_entry_add(imd, CBMEM_ID_STAGEx_RAW + stage_id, size);
|
||||
if (e == NULL) {
|
||||
printk(BIOS_DEBUG, "Error: Can't add %x raw data to imd\n",
|
||||
CBMEM_ID_STAGEx_RAW + stage_id);
|
||||
return;
|
||||
}
|
||||
|
||||
c = imd_entry_at(imd, e);
|
||||
if (c == NULL) {
|
||||
printk(BIOS_DEBUG, "Error: Can't get %x raw entry in imd\n",
|
||||
CBMEM_ID_STAGEx_RAW + stage_id);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(c, base, size);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void stage_cache_load_stage(int stage_id, struct prog *stage)
|
||||
{
|
||||
struct imd *imd;
|
||||
|
Reference in New Issue
Block a user