static void ssd_load_keystore_from_emmc() { uint64_t ptn = 0; int index = -1; uint32_t size = SSD_PARTITION_SIZE; int ret = -1; uint32_t *buffer = (uint32_t *)memalign(CACHE_LINE, ROUNDUP(SSD_PARTITION_SIZE, CACHE_LINE)); if (!buffer) { dprintf(CRITICAL, "Error Allocating memory for SSD buffer\n"); ASSERT(0); } index = partition_get_index("ssd"); ptn = partition_get_offset(index); if(ptn == 0) { dprintf(CRITICAL,"ERROR: ssd parition not found"); return; } if(mmc_read(ptn, buffer, size)) { dprintf(CRITICAL,"ERROR:Cannot read data\n"); return; } ret = scm_protect_keystore((uint32_t *)&buffer[0],size); if(ret != 0) dprintf(CRITICAL,"ERROR: scm_protect_keystore Failed"); free(buffer); }
void target_load_ssd_keystore(void) { uint64_t ptn; int index; uint64_t size; uint32_t *buffer; if (!target_is_ssd_enabled()) return; index = partition_get_index("ssd"); ptn = partition_get_offset(index); if (ptn == 0){ dprintf(CRITICAL, "Error: ssd partition not found\n"); return; } size = partition_get_size(index); if (size == 0) { dprintf(CRITICAL, "Error: invalid ssd partition size\n"); return; } buffer = memalign(CACHE_LINE, ROUNDUP(size, CACHE_LINE)); if (!buffer) { dprintf(CRITICAL, "Error: allocating memory for ssd buffer\n"); return; } if (mmc_read(ptn, buffer, size)) { dprintf(CRITICAL, "Error: cannot read data\n"); free(buffer); return; } clock_ce_enable(SSD_CE_INSTANCE); scm_protect_keystore(buffer, size); clock_ce_disable(SSD_CE_INSTANCE); free(buffer); }