Skip to content

Commit 920d586

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 3ec255e commit 920d586

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

arch/riscv/pmp.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,27 @@ int32_t pmp_lock_region(pmp_config_t *config, uint8_t region_idx)
320320

321321
return ERR_OK;
322322
}
323+
324+
int32_t pmp_get_region(const pmp_config_t *config, uint8_t region_idx,
325+
pmp_region_t *region)
326+
{
327+
if (!config || !region)
328+
return ERR_PMP_INVALID_REGION;
329+
330+
/* Validate region index is within bounds */
331+
if (region_idx >= PMP_MAX_REGIONS)
332+
return ERR_PMP_INVALID_REGION;
333+
334+
uint8_t pmpcfg_idx, pmpcfg_offset;
335+
pmp_get_cfg_indices(region_idx, &pmpcfg_idx, &pmpcfg_offset);
336+
337+
/* Read the address and configuration from shadow configuration */
338+
region->addr_start = config->regions[region_idx].addr_start;
339+
region->addr_end = config->regions[region_idx].addr_end;
340+
region->permissions = config->regions[region_idx].permissions;
341+
region->priority = config->regions[region_idx].priority;
342+
region->region_id = region_idx;
343+
region->locked = config->regions[region_idx].locked;
344+
345+
return ERR_OK;
346+
}

0 commit comments

Comments
 (0)