Skip to content

Commit cdfd2c8

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 7cc13b3 commit cdfd2c8

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
@@ -44,6 +44,14 @@ static const mempool_t kernel_mempools[] = {
4444
#define KERNEL_MEMPOOL_COUNT \
4545
(sizeof(kernel_mempools) / sizeof(kernel_mempools[0]))
4646

47+
/* Global PMP configuration (shadow of hardware state) */
48+
static pmp_config_t pmp_global_config;
49+
50+
pmp_config_t *pmp_get_config(void)
51+
{
52+
return &pmp_global_config;
53+
}
54+
4755
int32_t pmp_init_pools(pmp_config_t *config,
4856
const mempool_t *pools,
4957
size_t count)

arch/riscv/pmp.h

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

77
#pragma once
88

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

1112
#include "hal.h"
1213

13-
/* Forward declaration */
14-
typedef struct mempool mempool_t;
15-
1614
/* PMP Region Priority Levels (lower value = higher priority)
1715
*
1816
* Used for eviction decisions when hardware PMP regions are exhausted.
@@ -45,6 +43,9 @@ typedef struct {
4543

4644
/* PMP Management Functions */
4745

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

0 commit comments

Comments
 (0)