Skip to content

Commit e6aaec7

Browse files
committed
Initialize global PMP configuration state
Adds centralized management of PMP hardware state through a global configuration instance. This enables the memory protection subsystem to track and coordinate PMP register usage across the kernel without requiring each component to maintain its own state. Provides controlled access to the configuration through a dedicated accessor function, maintaining encapsulation while supporting dynamic region allocation and eviction during task switching.
1 parent 36f9b68 commit e6aaec7

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

arch/riscv/pmp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ static const mempool_t kernel_mempools[] = {
2929
#define KERNEL_MEMPOOL_COUNT \
3030
(sizeof(kernel_mempools) / sizeof(kernel_mempools[0]))
3131

32+
/* Global PMP configuration (shadow of hardware state) */
33+
static pmp_config_t pmp_global_config;
34+
35+
pmp_config_t *pmp_get_config(void)
36+
{
37+
return &pmp_global_config;
38+
}
39+
3240
int32_t pmp_init_pools(pmp_config_t *config, const mempool_t *pools,
3341
size_t count)
3442
{

arch/riscv/pmp.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
#pragma once
88

9+
#include <sys/memprot.h>
910
#include <types.h>
1011

11-
/* Forward declaration */
12-
typedef struct mempool mempool_t;
13-
1412
/* PMP Region Priority Levels (lower value = higher priority)
1513
*
1614
* Used for eviction decisions when hardware PMP regions are exhausted.
@@ -43,6 +41,9 @@ typedef struct {
4341

4442
/* PMP Management Functions */
4543

44+
/* Returns pointer to global PMP configuration */
45+
pmp_config_t *pmp_get_config(void);
46+
4647
/* Initializes the PMP hardware and configuration state.
4748
* @config : Pointer to pmp_config_t structure to be initialized.
4849
* Returns 0 on success, or negative error code on failure.

0 commit comments

Comments
 (0)