diff options
| author | Anup Patel <[email protected]> | 2024-09-23 13:46:12 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2024-10-25 23:00:10 +0530 |
| commit | f609fd85846ac35e2780df50ba0ad801622e13d8 (patch) | |
| tree | c4fbfbc3d6bdf87727f336f30039d4afc64eadc8 /include | |
| parent | 81d79913a0c23d7acc38ade7e8d8e3d48a388a3f (diff) | |
lib: sbi_domain: Use domain data support for per-domain hart context
The per-domain hartindex_to_context_table[] is yet another per-domain
data required for implementing hart entry into (or exit from) domain.
Use the recently added domain data support for per-domain hart context
so that a dedicated hartindex_to_context_table[] in struct sbi_domain
is not needed.
Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Yu Chien Peter Lin <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/sbi/sbi_domain.h | 2 | ||||
| -rw-r--r-- | include/sbi/sbi_domain_context.h | 56 |
2 files changed, 10 insertions, 48 deletions
diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index cf09344f..8a2b123d 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -176,8 +176,6 @@ struct sbi_domain { char name[64]; /** Possible HARTs in this domain */ const struct sbi_hartmask *possible_harts; - /** Contexts for possible HARTs indexed by hartindex */ - struct sbi_context *hartindex_to_context_table[SBI_HARTMASK_MAX_BITS]; /** Array of memory regions terminated by a region with order zero */ struct sbi_domain_memregion *regions; /** HART id of the HART booting this domain */ diff --git a/include/sbi/sbi_domain_context.h b/include/sbi/sbi_domain_context.h index 1f5a4f56..31a3a7f8 100644 --- a/include/sbi/sbi_domain_context.h +++ b/include/sbi/sbi_domain_context.h @@ -8,55 +8,9 @@ #define __SBI_DOMAIN_CONTEXT_H__ #include <sbi/sbi_types.h> -#include <sbi/sbi_trap.h> struct sbi_domain; -/** Context representation for a hart within a domain */ -struct sbi_context { - /** Trap-related states such as GPRs, mepc, and mstatus */ - struct sbi_trap_context trap_ctx; - - /** Supervisor status register */ - unsigned long sstatus; - /** Supervisor interrupt enable register */ - unsigned long sie; - /** Supervisor trap vector base address register */ - unsigned long stvec; - /** Supervisor scratch register for temporary storage */ - unsigned long sscratch; - /** Supervisor exception program counter register */ - unsigned long sepc; - /** Supervisor cause register */ - unsigned long scause; - /** Supervisor trap value register */ - unsigned long stval; - /** Supervisor interrupt pending register */ - unsigned long sip; - /** Supervisor address translation and protection register */ - unsigned long satp; - /** Counter-enable register */ - unsigned long scounteren; - /** Supervisor environment configuration register */ - unsigned long senvcfg; - - /** Reference to the owning domain */ - struct sbi_domain *dom; - /** Previous context (caller) to jump to during context exits */ - struct sbi_context *prev_ctx; - /** Is context initialized and runnable */ - bool initialized; -}; - -/** Get the context pointer for a given hart index and domain */ -#define sbi_hartindex_to_domain_context(__hartindex, __d) \ - (__d)->hartindex_to_context_table[__hartindex] - -/** Macro to obtain the current hart's context pointer */ -#define sbi_domain_context_thishart_ptr() \ - sbi_hartindex_to_domain_context(current_hartindex(), \ - sbi_domain_thishart_ptr()) - /** * Enter a specific domain context synchronously * @param dom pointer to domain @@ -74,4 +28,14 @@ int sbi_domain_context_enter(struct sbi_domain *dom); */ int sbi_domain_context_exit(void); +/** + * Initialize domain context support + * + * @return 0 on success and negative error code on failure + */ +int sbi_domain_context_init(void); + +/* Deinitialize domain context support */ +void sbi_domain_context_deinit(void); + #endif // __SBI_DOMAIN_CONTEXT_H__ |
