diff options
| author | Anup Patel <apatel@ventanamicro.com> | 2025-12-09 19:22:35 +0530 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2025-12-16 20:16:47 +0530 |
| commit | 5eec86eec8ee92f9c7d4211c34fddf794609ed71 (patch) | |
| tree | 6d731d97f7a413ecb71362b11dd1aab810a2a975 /include | |
| parent | 42139bb9b7dc10dcf5432cc34eb1bf2e233ef359 (diff) | |
| download | opensbi-5eec86eec8ee92f9c7d4211c34fddf794609ed71.tar.gz opensbi-5eec86eec8ee92f9c7d4211c34fddf794609ed71.tar.bz2 opensbi-5eec86eec8ee92f9c7d4211c34fddf794609ed71.zip | |
lib: sbi: Factor-out PMP programming into separate sources
The PMP programming is a significant part of sbi_hart.c so factor-out
this into separate sources sbi_hart_pmp.c and sbi_hart_pmp.h for better
maintainability.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Link: https://lore.kernel.org/r/20251209135235.423391-6-apatel@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/sbi/sbi_hart.h | 22 | ||||
| -rw-r--r-- | include/sbi/sbi_hart_pmp.h | 20 |
2 files changed, 23 insertions, 19 deletions
diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index bbd8026e..a788b34c 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -107,21 +107,6 @@ enum sbi_hart_csrs { SBI_HART_CSR_MAX, }; -/* - * Smepmp enforces access boundaries between M-mode and - * S/U-mode. When it is enabled, the PMPs are programmed - * such that M-mode doesn't have access to S/U-mode memory. - * - * To give M-mode R/W access to the shared memory between M and - * S/U-mode, first entry is reserved. It is disabled at boot. - * When shared memory access is required, the physical address - * should be programmed into the first PMP entry with R/W - * permissions to the M-mode. Once the work is done, it should be - * unmapped. sbi_hart_protection_map_range/sbi_hart_protection_unmap_range - * function pair should be used to map/unmap the shared memory. - */ -#define SBI_SMEPMP_RESV_ENTRY 0 - struct sbi_hart_features { bool detected; int priv_version; @@ -134,6 +119,9 @@ struct sbi_hart_features { unsigned int mhpm_bits; }; +extern unsigned long hart_features_offset; +#define sbi_hart_features_ptr(__s) sbi_scratch_offset_ptr(__s, hart_features_offset) + struct sbi_scratch; int sbi_hart_reinit(struct sbi_scratch *scratch); @@ -144,11 +132,7 @@ extern void (*sbi_hart_expected_trap)(void); unsigned int sbi_hart_mhpm_mask(struct sbi_scratch *scratch); void sbi_hart_delegation_dump(struct sbi_scratch *scratch, const char *prefix, const char *suffix); -unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch); -unsigned int sbi_hart_pmp_log2gran(struct sbi_scratch *scratch); -unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch); unsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch); -bool sbi_hart_smepmp_is_fw_region(unsigned int pmp_idx); int sbi_hart_priv_version(struct sbi_scratch *scratch); void sbi_hart_get_priv_version_str(struct sbi_scratch *scratch, char *version_str, int nvstr); diff --git a/include/sbi/sbi_hart_pmp.h b/include/sbi/sbi_hart_pmp.h new file mode 100644 index 00000000..f54e8b2a --- /dev/null +++ b/include/sbi/sbi_hart_pmp.h @@ -0,0 +1,20 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Ventana Micro Systems Inc. + */ + +#ifndef __SBI_HART_PMP_H__ +#define __SBI_HART_PMP_H__ + +#include <sbi/sbi_types.h> + +struct sbi_scratch; + +unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch); +unsigned int sbi_hart_pmp_log2gran(struct sbi_scratch *scratch); +unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch); +bool sbi_hart_smepmp_is_fw_region(unsigned int pmp_idx); +int sbi_hart_pmp_init(struct sbi_scratch *scratch); + +#endif |
