From 31cf34f84903dec0c8fae716f80e46e57501ff19 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 7 Aug 2015 14:52:07 -0400 Subject: or1k: Allow exception nesting Allow exceptions to be nested, which is especially useful with urgent interrupts while processing an exception. The implementation counts up the nesting level with each call to an exception. In the outer exception (level 1), the exception stack is started. All nested exceptions just reserve the redzone (scratch memory that may be used by compiler) and exception context on the stack, but then process on the same scratch. Restriction: Impure pointers are shared among all exceptions. This may be solved by creating an impure data structure in the stack frame with each nested exception. * or1k/crt0.S: Add exception nesting * or1k/exceptions-asm.S: ditto * or1k/util.c: ditto --- libgloss/or1k/util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libgloss/or1k/util.c') diff --git a/libgloss/or1k/util.c b/libgloss/or1k/util.c index 74071719e..5e853f359 100644 --- a/libgloss/or1k/util.c +++ b/libgloss/or1k/util.c @@ -23,8 +23,13 @@ #include "or1k-internals.h" #ifdef __OR1K_MULTICORE__ +// Define pointers to arrays uint32_t* *_or1k_stack_core; uint32_t* *_or1k_exception_stack_core; +uint32_t* *_or1k_exception_level; +#else +// Define scalar +uint32_t _or1k_exception_level; #endif uint32_t* _or1k_stack_top; @@ -68,6 +73,15 @@ void _or1k_init() { #else _or1k_exception_handler_table[6] = _or1k_interrupt_handler; #endif + +#ifdef __OR1K_MULTICORE__ + _or1k_exception_level = _sbrk_r(0, 4 * or1k_numcores()); + for (c = 0; c < or1k_numcores(); c++) { + _or1k_exception_level[c] = 0; + } +#else + _or1k_exception_level = 0; +#endif } uint32_t or1k_critical_begin() { -- cgit v1.2.3