1 | This document describes the internals of the port for OpenRISC |
---|
2 | 1000. The API is documented in or1k-support.h as Doxygen comments. |
---|
3 | |
---|
4 | # Data Structures |
---|
5 | |
---|
6 | +----------------+ 0x0 |
---|
7 | | vectors | |
---|
8 | +----------------+ |
---|
9 | | text,data,.. | |
---|
10 | +----------------+ |
---|
11 | | bss | |
---|
12 | +----------------+ |
---|
13 | | heap | |
---|
14 | | vv | |
---|
15 | | | |
---|
16 | | ^^ | |
---|
17 | | stack(s) | |
---|
18 | +----------------+ _or1k_board_mem_base + |
---|
19 | _or1k_board_mem_size |
---|
20 | |
---|
21 | ## Stack and Heap |
---|
22 | |
---|
23 | The stack is allocated at the end of available physical memory which |
---|
24 | is defined by each board as _or1k_board_mem_base and |
---|
25 | _or1k_board_mem_size. The _or1k_stack_top and _or1k_stack_bottom are |
---|
26 | determined by those variables and _or1k_stack_size (which may be |
---|
27 | overwritten in _or1k_board_init_early). |
---|
28 | |
---|
29 | A second stack for exceptions is allocated as we allow exceptions to |
---|
30 | be arbitrary complex and call C functions etc. It is not an option to |
---|
31 | re-use the current software stack as we want to be so generic, that |
---|
32 | this can also be a virtual memory stack at moment of exception. The |
---|
33 | exception starts below the normal software stack and is |
---|
34 | _or1k_exception_stack_size large. |
---|
35 | |
---|
36 | Multicore: For each core a stack and exception stack is allocated and |
---|
37 | the stack pointer set at boot. That is: sp(core0) = _or1k_stack_top, |
---|
38 | sp(core1) = _or1k_stack_top - _or1k_stack_size, etc. |
---|
39 | |
---|
40 | ## _or1k_stack_core (multicore only) |
---|
41 | |
---|
42 | An array of pointers to the software stacks (size: |
---|
43 | 4*or1k_numcores()). It is dynamically allocated from heap in or1k_init |
---|
44 | by calling sbrk(). The pointers contain the values for stack top |
---|
45 | pointers as described above. This variable is essentially used on boot |
---|
46 | of the slave cores to configure the stack register. |
---|
47 | |
---|
48 | ## _or1k_exception_stack_core (multicore only) |
---|
49 | |
---|
50 | An array of pointers to the exception stacks (size: |
---|
51 | 4*or1k_numcores()). It is allocated identical as the stack_core |
---|
52 | array. It is loaded whenever an exception occurs to start with a clean |
---|
53 | stack in the exception. |
---|
54 | |
---|
55 | ## _or1k_exception_handler_table |
---|
56 | |
---|
57 | A table of function pointers to the handlers of the exceptions. The |
---|
58 | generic exception handler checks if an exception handler is registered |
---|
59 | and calls it. There are 30 exceptions defined (0x0 is not an exception |
---|
60 | vector and 0x100 is reset which is static). This array resides in BSS |
---|
61 | and is therefore initialized as 0 (no handler registered) after start. |
---|
62 | |
---|
63 | Multicore: As the number of course is not known at compile time, the |
---|
64 | variable is a pointer to and array of arrays (cores x 30) which is |
---|
65 | allocated in or1k_init() on heap (using sbrk). |
---|
66 | |
---|
67 | ## _or1k_interrupt_handler_table and _or1k_interrupt_handler_table_data_ptr |
---|
68 | |
---|
69 | The interrupt handlers are stored identical to to the exception handler table. |
---|
70 | |
---|
71 | ## _or1k_reent |
---|
72 | |
---|
73 | The struct _or1k_reent contains formerly global data and allows for |
---|
74 | reentrancy. In the single core case, this is an allocated object, |
---|
75 | while it is a pointer to an array of structs in the multicore library. |
---|
76 | It is allocated in _or1k_reent_init() on the heap. |
---|
77 | |
---|