diff options
| author | Anup Patel <[email protected]> | 2019-05-21 16:55:04 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2019-05-24 08:22:47 +0530 |
| commit | bb915780ac76b146f3de47f105a95359e02f158c (patch) | |
| tree | 515737e6271e516beeefc0cc347766245527d021 /lib | |
| parent | a22c6891b718a155b2b8429be62760860b4d6109 (diff) | |
lib: Add per-HART trap info pointer
This patch adds per-HART trap info pointer which can be used to
communicate trap information to sbi_trap_handler().
Signed-off-by: Anup Patel <[email protected]>
Reviewed-by: Atish Patra <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbi_hart.c | 34 | ||||
| -rw-r--r-- | lib/sbi_init.c | 4 |
2 files changed, 35 insertions, 3 deletions
diff --git a/lib/sbi_hart.c b/lib/sbi_hart.c index b35d4fa7..187b4937 100644 --- a/lib/sbi_hart.c +++ b/lib/sbi_hart.c @@ -182,10 +182,19 @@ static int pmp_init(struct sbi_scratch *scratch, u32 hartid) return 0; } -int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid) +static unsigned long trap_info_offset; + +int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) { int rc; + if (cold_boot) { + trap_info_offset = sbi_scratch_alloc_offset(__SIZEOF_POINTER__, + "HART_TRAP_INFO"); + if (!trap_info_offset) + return SBI_ENOMEM; + } + mstatus_init(scratch, hartid); rc = fp_init(hartid); @@ -199,6 +208,29 @@ int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid) return pmp_init(scratch, hartid); } +void *sbi_hart_get_trap_info(struct sbi_scratch *scratch) +{ + unsigned long *trap_info; + + if (!trap_info_offset) + return NULL; + + trap_info = sbi_scratch_offset_ptr(scratch, trap_info_offset); + + return (void *)(*trap_info); +} + +void sbi_hart_set_trap_info(struct sbi_scratch *scratch, void *data) +{ + unsigned long *trap_info; + + if (!trap_info_offset) + return; + + trap_info = sbi_scratch_offset_ptr(scratch, trap_info_offset); + *trap_info = (unsigned long)data; +} + void __attribute__((noreturn)) sbi_hart_hang(void) { while (1) diff --git a/lib/sbi_init.c b/lib/sbi_init.c index 5c74b45d..4f47a6c8 100644 --- a/lib/sbi_init.c +++ b/lib/sbi_init.c @@ -66,7 +66,7 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); - rc = sbi_hart_init(scratch, hartid); + rc = sbi_hart_init(scratch, hartid, TRUE); if (rc) sbi_hart_hang(); @@ -115,7 +115,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); - rc = sbi_hart_init(scratch, hartid); + rc = sbi_hart_init(scratch, hartid, FALSE); if (rc) sbi_hart_hang(); |
