Skip to content

Commit c798219

Browse files
committed
Read PMP region configuration from shadow state
Retrieves the address range, permissions, priority, and lock status of a configured region from the shadow configuration state.
1 parent f72728e commit c798219

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

arch/riscv/pmp.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,28 @@ int32_t pmp_lock_region(pmp_config_t *config, uint8_t region_idx)
400400

401401
return ERR_OK;
402402
}
403+
404+
int32_t pmp_get_region(const pmp_config_t *config,
405+
uint8_t region_idx,
406+
pmp_region_t *region)
407+
{
408+
if (!config || !region)
409+
return ERR_PMP_INVALID_REGION;
410+
411+
/* Validate region index is within bounds */
412+
if (region_idx >= PMP_MAX_REGIONS)
413+
return ERR_PMP_INVALID_REGION;
414+
415+
uint8_t pmpcfg_idx, pmpcfg_offset;
416+
pmp_get_cfg_indices(region_idx, &pmpcfg_idx, &pmpcfg_offset);
417+
418+
/* Read the address and configuration from shadow configuration */
419+
region->addr_start = config->regions[region_idx].addr_start;
420+
region->addr_end = config->regions[region_idx].addr_end;
421+
region->permissions = config->regions[region_idx].permissions;
422+
region->priority = config->regions[region_idx].priority;
423+
region->region_id = region_idx;
424+
region->locked = config->regions[region_idx].locked;
425+
426+
return ERR_OK;
427+
}

0 commit comments

Comments
 (0)