Skip to content

Commit

Permalink
libstb: export CVC/securerom code memory range
Browse files Browse the repository at this point in the history
This is useful to capture a real in-memory image for use in a simulator
(such as Mambo) without having to go through the complexity of setting
up the in-memory image yourself.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[oliver: s/CVC/cvc/]
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
  • Loading branch information
stewartsmith authored and oohal committed Nov 27, 2019
1 parent 52952ac commit 12610da
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion libstb/cvc.c
Expand Up @@ -127,6 +127,7 @@ static void cvc_service_register(uint32_t id, uint32_t offset, uint32_t version)
static int cvc_reserved_mem_init(struct dt_node *parent) {
struct dt_node *node, *service;
struct dt_node *reserved_mem;
struct dt_node *exports;
uint32_t phandle;
uint64_t addr, size;

Expand Down Expand Up @@ -156,6 +157,13 @@ static int cvc_reserved_mem_init(struct dt_node *parent) {
addr = dt_get_address(cvc_resv_mem, 0, &size);
cvc_register(addr, addr + size-1);

exports = dt_find_by_path(dt_root, "/ibm,opal/firmware/exports");
if (!exports) {
prerror("OCC: dt node /ibm,opal/firmware/exports not found\n");
return false;
}
dt_add_property_u64s(exports, "cvc", addr, size - 1);

/*
* Each child of the CVC node describes a CVC service
*/
Expand Down Expand Up @@ -184,8 +192,9 @@ static int cvc_reserved_mem_init(struct dt_node *parent) {

static int cvc_secure_rom_init(void) {
const uint32_t reg_addr = SECURE_ROM_XSCOM_ADDRESS;
uint64_t reg_data;
struct dt_node *exports;
struct proc_chip *chip;
uint64_t reg_data;

if (!secure_rom_mem) {
secure_rom_mem = malloc(SECURE_ROM_MEMORY_SIZE);
Expand All @@ -203,6 +212,16 @@ static int cvc_secure_rom_init(void) {
SECURE_ROM_MEMORY_SIZE);
cvc_register((uint64_t)secure_rom_mem,
(uint64_t)secure_rom_mem + SECURE_ROM_MEMORY_SIZE-1);

exports = dt_find_by_path(dt_root, "/ibm,opal/firmware/exports");
if (!exports) {
prerror("OCC: dt node /ibm,opal/firmware/exports not found\n");
return false;
}

dt_add_property_u64s(exports, "securerom", (uint64_t)secure_rom_mem,
SECURE_ROM_MEMORY_SIZE-1);

cvc_service_register(CVC_SHA512_SERVICE, SECURE_ROM_SHA512_OFFSET, 1);
cvc_service_register(CVC_VERIFY_SERVICE, SECURE_ROM_VERIFY_OFFSET, 1);
return 0;
Expand Down

0 comments on commit 12610da

Please sign in to comment.