Skip to content

Commit

Permalink
arch: remove the use of z_arch_esf_t completely from internal
Browse files Browse the repository at this point in the history
Created `GEN_OFFSET_STRUCT` & `GEN_NAMED_OFFSET_STRUCT` that
works for `struct`, and remove the use of `z_arch_esf_t`
completely.

Signed-off-by: Yong Cong Sin <[email protected]>
  • Loading branch information
ycsin authored and MaureenHelm committed Jun 4, 2024
1 parent e54b27b commit 6a3cb93
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 190 deletions.
6 changes: 3 additions & 3 deletions arch/mips/core/isr.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <mips/regdef.h>
#include <mips/mipsregs.h>

#define ESF_O(FIELD) __z_arch_esf_t_##FIELD##_OFFSET
#define ESF_O(FIELD) __struct_arch_esf_##FIELD##_OFFSET
#define THREAD_O(FIELD) _thread_offset_to_##FIELD

/* Convenience macros for loading/storing register states. */
Expand Down Expand Up @@ -58,12 +58,12 @@
op v1, ESF_O(v1)(sp) ;

#define STORE_CALLER_SAVED() \
addi sp, sp, -__z_arch_esf_t_SIZEOF ;\
addi sp, sp, -__struct_arch_esf_SIZEOF ;\
DO_CALLER_SAVED(OP_STOREREG) ;

#define LOAD_CALLER_SAVED() \
DO_CALLER_SAVED(OP_LOADREG) ;\
addi sp, sp, __z_arch_esf_t_SIZEOF ;
addi sp, sp, __struct_arch_esf_SIZEOF ;

/* imports */
GTEXT(_Fault)
Expand Down
52 changes: 26 additions & 26 deletions arch/mips/core/offsets/offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@ GEN_OFFSET_SYM(_callee_saved_t, s6);
GEN_OFFSET_SYM(_callee_saved_t, s7);
GEN_OFFSET_SYM(_callee_saved_t, s8);

GEN_OFFSET_SYM(z_arch_esf_t, ra);
GEN_OFFSET_SYM(z_arch_esf_t, gp);
GEN_OFFSET_SYM(z_arch_esf_t, t0);
GEN_OFFSET_SYM(z_arch_esf_t, t1);
GEN_OFFSET_SYM(z_arch_esf_t, t2);
GEN_OFFSET_SYM(z_arch_esf_t, t3);
GEN_OFFSET_SYM(z_arch_esf_t, t4);
GEN_OFFSET_SYM(z_arch_esf_t, t5);
GEN_OFFSET_SYM(z_arch_esf_t, t6);
GEN_OFFSET_SYM(z_arch_esf_t, t7);
GEN_OFFSET_SYM(z_arch_esf_t, t8);
GEN_OFFSET_SYM(z_arch_esf_t, t9);
GEN_OFFSET_SYM(z_arch_esf_t, a0);
GEN_OFFSET_SYM(z_arch_esf_t, a1);
GEN_OFFSET_SYM(z_arch_esf_t, a2);
GEN_OFFSET_SYM(z_arch_esf_t, a3);
GEN_OFFSET_SYM(z_arch_esf_t, v0);
GEN_OFFSET_SYM(z_arch_esf_t, v1);
GEN_OFFSET_SYM(z_arch_esf_t, at);
GEN_OFFSET_SYM(z_arch_esf_t, epc);
GEN_OFFSET_SYM(z_arch_esf_t, badvaddr);
GEN_OFFSET_SYM(z_arch_esf_t, hi);
GEN_OFFSET_SYM(z_arch_esf_t, lo);
GEN_OFFSET_SYM(z_arch_esf_t, status);
GEN_OFFSET_SYM(z_arch_esf_t, cause);
GEN_OFFSET_STRUCT(arch_esf, ra);
GEN_OFFSET_STRUCT(arch_esf, gp);
GEN_OFFSET_STRUCT(arch_esf, t0);
GEN_OFFSET_STRUCT(arch_esf, t1);
GEN_OFFSET_STRUCT(arch_esf, t2);
GEN_OFFSET_STRUCT(arch_esf, t3);
GEN_OFFSET_STRUCT(arch_esf, t4);
GEN_OFFSET_STRUCT(arch_esf, t5);
GEN_OFFSET_STRUCT(arch_esf, t6);
GEN_OFFSET_STRUCT(arch_esf, t7);
GEN_OFFSET_STRUCT(arch_esf, t8);
GEN_OFFSET_STRUCT(arch_esf, t9);
GEN_OFFSET_STRUCT(arch_esf, a0);
GEN_OFFSET_STRUCT(arch_esf, a1);
GEN_OFFSET_STRUCT(arch_esf, a2);
GEN_OFFSET_STRUCT(arch_esf, a3);
GEN_OFFSET_STRUCT(arch_esf, v0);
GEN_OFFSET_STRUCT(arch_esf, v1);
GEN_OFFSET_STRUCT(arch_esf, at);
GEN_OFFSET_STRUCT(arch_esf, epc);
GEN_OFFSET_STRUCT(arch_esf, badvaddr);
GEN_OFFSET_STRUCT(arch_esf, hi);
GEN_OFFSET_STRUCT(arch_esf, lo);
GEN_OFFSET_STRUCT(arch_esf, status);
GEN_OFFSET_STRUCT(arch_esf, cause);

GEN_ABSOLUTE_SYM(__z_arch_esf_t_SIZEOF, STACK_ROUND_UP(sizeof(z_arch_esf_t)));
GEN_ABSOLUTE_SYM(__struct_arch_esf_SIZEOF, STACK_ROUND_UP(sizeof(struct arch_esf)));

GEN_ABS_SYM_END
78 changes: 39 additions & 39 deletions arch/nios2/core/exception.S
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ GTEXT(_offload_routine)
*/
SECTION_FUNC(exception.entry, _exception)
/* Reserve thread stack space for saving context */
subi sp, sp, __z_arch_esf_t_SIZEOF
subi sp, sp, __struct_arch_esf_SIZEOF

/* Preserve all caller-saved registers onto the thread's stack */
stw ra, __z_arch_esf_t_ra_OFFSET(sp)
stw r1, __z_arch_esf_t_r1_OFFSET(sp)
stw r2, __z_arch_esf_t_r2_OFFSET(sp)
stw r3, __z_arch_esf_t_r3_OFFSET(sp)
stw r4, __z_arch_esf_t_r4_OFFSET(sp)
stw r5, __z_arch_esf_t_r5_OFFSET(sp)
stw r6, __z_arch_esf_t_r6_OFFSET(sp)
stw r7, __z_arch_esf_t_r7_OFFSET(sp)
stw r8, __z_arch_esf_t_r8_OFFSET(sp)
stw r9, __z_arch_esf_t_r9_OFFSET(sp)
stw r10, __z_arch_esf_t_r10_OFFSET(sp)
stw r11, __z_arch_esf_t_r11_OFFSET(sp)
stw r12, __z_arch_esf_t_r12_OFFSET(sp)
stw r13, __z_arch_esf_t_r13_OFFSET(sp)
stw r14, __z_arch_esf_t_r14_OFFSET(sp)
stw r15, __z_arch_esf_t_r15_OFFSET(sp)
stw ra, __struct_arch_esf_ra_OFFSET(sp)
stw r1, __struct_arch_esf_r1_OFFSET(sp)
stw r2, __struct_arch_esf_r2_OFFSET(sp)
stw r3, __struct_arch_esf_r3_OFFSET(sp)
stw r4, __struct_arch_esf_r4_OFFSET(sp)
stw r5, __struct_arch_esf_r5_OFFSET(sp)
stw r6, __struct_arch_esf_r6_OFFSET(sp)
stw r7, __struct_arch_esf_r7_OFFSET(sp)
stw r8, __struct_arch_esf_r8_OFFSET(sp)
stw r9, __struct_arch_esf_r9_OFFSET(sp)
stw r10, __struct_arch_esf_r10_OFFSET(sp)
stw r11, __struct_arch_esf_r11_OFFSET(sp)
stw r12, __struct_arch_esf_r12_OFFSET(sp)
stw r13, __struct_arch_esf_r13_OFFSET(sp)
stw r14, __struct_arch_esf_r14_OFFSET(sp)
stw r15, __struct_arch_esf_r15_OFFSET(sp)

/* Store value of estatus control register */
rdctl et, estatus
stw et, __z_arch_esf_t_estatus_OFFSET(sp)
stw et, __struct_arch_esf_estatus_OFFSET(sp)

/* ea-4 is the address of the instruction when the exception happened,
* put this in the stack frame as well
*/
addi r15, ea, -4
stw r15, __z_arch_esf_t_instr_OFFSET(sp)
stw r15, __struct_arch_esf_instr_OFFSET(sp)

/* Figure out whether we are here because of an interrupt or an
* exception. If an interrupt, switch stacks and enter IRQ handling
Expand Down Expand Up @@ -157,7 +157,7 @@ not_interrupt:
*
* We earlier put ea - 4 in the stack frame, replace it with just ea
*/
stw ea, __z_arch_esf_t_instr_OFFSET(sp)
stw ea, __struct_arch_esf_instr_OFFSET(sp)

#ifdef CONFIG_IRQ_OFFLOAD
/* Check the contents of _offload_routine. If non-NULL, jump into
Expand Down Expand Up @@ -193,35 +193,35 @@ _exception_exit:
* and return to the interrupted context */

/* Return address from the exception */
ldw ea, __z_arch_esf_t_instr_OFFSET(sp)
ldw ea, __struct_arch_esf_instr_OFFSET(sp)

/* Restore estatus
* XXX is this right??? */
ldw r5, __z_arch_esf_t_estatus_OFFSET(sp)
ldw r5, __struct_arch_esf_estatus_OFFSET(sp)
wrctl estatus, r5

/* Restore caller-saved registers */
ldw ra, __z_arch_esf_t_ra_OFFSET(sp)
ldw r1, __z_arch_esf_t_r1_OFFSET(sp)
ldw r2, __z_arch_esf_t_r2_OFFSET(sp)
ldw r3, __z_arch_esf_t_r3_OFFSET(sp)
ldw r4, __z_arch_esf_t_r4_OFFSET(sp)
ldw r5, __z_arch_esf_t_r5_OFFSET(sp)
ldw r6, __z_arch_esf_t_r6_OFFSET(sp)
ldw r7, __z_arch_esf_t_r7_OFFSET(sp)
ldw r8, __z_arch_esf_t_r8_OFFSET(sp)
ldw r9, __z_arch_esf_t_r9_OFFSET(sp)
ldw r10, __z_arch_esf_t_r10_OFFSET(sp)
ldw r11, __z_arch_esf_t_r11_OFFSET(sp)
ldw r12, __z_arch_esf_t_r12_OFFSET(sp)
ldw r13, __z_arch_esf_t_r13_OFFSET(sp)
ldw r14, __z_arch_esf_t_r14_OFFSET(sp)
ldw r15, __z_arch_esf_t_r15_OFFSET(sp)
ldw ra, __struct_arch_esf_ra_OFFSET(sp)
ldw r1, __struct_arch_esf_r1_OFFSET(sp)
ldw r2, __struct_arch_esf_r2_OFFSET(sp)
ldw r3, __struct_arch_esf_r3_OFFSET(sp)
ldw r4, __struct_arch_esf_r4_OFFSET(sp)
ldw r5, __struct_arch_esf_r5_OFFSET(sp)
ldw r6, __struct_arch_esf_r6_OFFSET(sp)
ldw r7, __struct_arch_esf_r7_OFFSET(sp)
ldw r8, __struct_arch_esf_r8_OFFSET(sp)
ldw r9, __struct_arch_esf_r9_OFFSET(sp)
ldw r10, __struct_arch_esf_r10_OFFSET(sp)
ldw r11, __struct_arch_esf_r11_OFFSET(sp)
ldw r12, __struct_arch_esf_r12_OFFSET(sp)
ldw r13, __struct_arch_esf_r13_OFFSET(sp)
ldw r14, __struct_arch_esf_r14_OFFSET(sp)
ldw r15, __struct_arch_esf_r15_OFFSET(sp)

/* Put the stack pointer back where it was when we entered
* exception state
*/
addi sp, sp, __z_arch_esf_t_SIZEOF
addi sp, sp, __struct_arch_esf_SIZEOF

/* All done, copy estatus into status and transfer to ea */
eret
38 changes: 19 additions & 19 deletions arch/nios2/core/offsets/offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ GEN_OFFSET_SYM(_callee_saved_t, sp);
GEN_OFFSET_SYM(_callee_saved_t, key);
GEN_OFFSET_SYM(_callee_saved_t, retval);

GEN_OFFSET_SYM(z_arch_esf_t, ra);
GEN_OFFSET_SYM(z_arch_esf_t, r1);
GEN_OFFSET_SYM(z_arch_esf_t, r2);
GEN_OFFSET_SYM(z_arch_esf_t, r3);
GEN_OFFSET_SYM(z_arch_esf_t, r4);
GEN_OFFSET_SYM(z_arch_esf_t, r5);
GEN_OFFSET_SYM(z_arch_esf_t, r6);
GEN_OFFSET_SYM(z_arch_esf_t, r7);
GEN_OFFSET_SYM(z_arch_esf_t, r8);
GEN_OFFSET_SYM(z_arch_esf_t, r9);
GEN_OFFSET_SYM(z_arch_esf_t, r10);
GEN_OFFSET_SYM(z_arch_esf_t, r11);
GEN_OFFSET_SYM(z_arch_esf_t, r12);
GEN_OFFSET_SYM(z_arch_esf_t, r13);
GEN_OFFSET_SYM(z_arch_esf_t, r14);
GEN_OFFSET_SYM(z_arch_esf_t, r15);
GEN_OFFSET_SYM(z_arch_esf_t, estatus);
GEN_OFFSET_SYM(z_arch_esf_t, instr);
GEN_ABSOLUTE_SYM(__z_arch_esf_t_SIZEOF, sizeof(z_arch_esf_t));
GEN_OFFSET_STRUCT(arch_esf, ra);
GEN_OFFSET_STRUCT(arch_esf, r1);
GEN_OFFSET_STRUCT(arch_esf, r2);
GEN_OFFSET_STRUCT(arch_esf, r3);
GEN_OFFSET_STRUCT(arch_esf, r4);
GEN_OFFSET_STRUCT(arch_esf, r5);
GEN_OFFSET_STRUCT(arch_esf, r6);
GEN_OFFSET_STRUCT(arch_esf, r7);
GEN_OFFSET_STRUCT(arch_esf, r8);
GEN_OFFSET_STRUCT(arch_esf, r9);
GEN_OFFSET_STRUCT(arch_esf, r10);
GEN_OFFSET_STRUCT(arch_esf, r11);
GEN_OFFSET_STRUCT(arch_esf, r12);
GEN_OFFSET_STRUCT(arch_esf, r13);
GEN_OFFSET_STRUCT(arch_esf, r14);
GEN_OFFSET_STRUCT(arch_esf, r15);
GEN_OFFSET_STRUCT(arch_esf, estatus);
GEN_OFFSET_STRUCT(arch_esf, instr);
GEN_ABSOLUTE_SYM(__struct_arch_esf_SIZEOF, sizeof(struct arch_esf));

GEN_ABS_SYM_END
Loading

0 comments on commit 6a3cb93

Please sign in to comment.