Skip to content

Commit 0761307

Browse files
committed
arch: define struct arch_esf and deprecate z_arch_esf_t
Make `struct arch_esf` compulsory for all architectures by declaring it in the `arch_interface.h` header. After this commit, the named struct `z_arch_esf_t` is only used internally to generate offsets, and is slated to be removed from the `arch_interface.h` header in the future. Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 0e4ab72 commit 0761307

File tree

105 files changed

+203
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+203
-222
lines changed

arch/arc/core/fatal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
2424

2525
#ifdef CONFIG_EXCEPTION_DEBUG
26-
static void dump_arc_esf(const z_arch_esf_t *esf)
26+
static void dump_arc_esf(const struct arch_esf *esf)
2727
{
2828
ARC_EXCEPTION_DUMP(" r0: 0x%" PRIxPTR " r1: 0x%" PRIxPTR " r2: 0x%" PRIxPTR
2929
" r3: 0x%" PRIxPTR "", esf->r0, esf->r1, esf->r2, esf->r3);
@@ -42,7 +42,7 @@ static void dump_arc_esf(const z_arch_esf_t *esf)
4242
}
4343
#endif
4444

45-
void z_arc_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
45+
void z_arc_fatal_error(unsigned int reason, const struct arch_esf *esf)
4646
{
4747
#ifdef CONFIG_EXCEPTION_DEBUG
4848
if (esf != NULL) {

arch/arc/core/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static void dump_exception_info(uint32_t vector, uint32_t cause, uint32_t parame
346346
* invokes the user provided routine k_sys_fatal_error_handler() which is
347347
* responsible for implementing the error handling policy.
348348
*/
349-
void _Fault(z_arch_esf_t *esf, uint32_t old_sp)
349+
void _Fault(struct arch_esf *esf, uint32_t old_sp)
350350
{
351351
uint32_t vector, cause, parameter;
352352
uint32_t exc_addr = z_arc_v2_aux_reg_read(_ARC_V2_EFA);

arch/arc/include/kernel_arch_func.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern void z_arc_userspace_enter(k_thread_entry_t user_entry, void *p1,
6262
void *p2, void *p3, uint32_t stack, uint32_t size,
6363
struct k_thread *thread);
6464

65-
extern void z_arc_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
65+
extern void z_arc_fatal_error(unsigned int reason, const struct arch_esf *esf);
6666

6767
extern void arch_sched_ipi(void);
6868

arch/arm/core/cortex_a_r/fault.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ bool z_arm_fault_undef_instruction_fp(void)
206206
*
207207
* @return Returns true if the fault is fatal
208208
*/
209-
bool z_arm_fault_undef_instruction(z_arch_esf_t *esf)
209+
bool z_arm_fault_undef_instruction(struct arch_esf *esf)
210210
{
211211
#if defined(CONFIG_FPU_SHARING)
212212
/*
@@ -243,7 +243,7 @@ bool z_arm_fault_undef_instruction(z_arch_esf_t *esf)
243243
*
244244
* @return Returns true if the fault is fatal
245245
*/
246-
bool z_arm_fault_prefetch(z_arch_esf_t *esf)
246+
bool z_arm_fault_prefetch(struct arch_esf *esf)
247247
{
248248
uint32_t reason = K_ERR_CPU_EXCEPTION;
249249

@@ -299,7 +299,7 @@ static const struct z_exc_handle exceptions[] = {
299299
*
300300
* @return true if error is recoverable, otherwise return false.
301301
*/
302-
static bool memory_fault_recoverable(z_arch_esf_t *esf)
302+
static bool memory_fault_recoverable(struct arch_esf *esf)
303303
{
304304
for (int i = 0; i < ARRAY_SIZE(exceptions); i++) {
305305
/* Mask out instruction mode */
@@ -321,7 +321,7 @@ static bool memory_fault_recoverable(z_arch_esf_t *esf)
321321
*
322322
* @return Returns true if the fault is fatal
323323
*/
324-
bool z_arm_fault_data(z_arch_esf_t *esf)
324+
bool z_arm_fault_data(struct arch_esf *esf)
325325
{
326326
uint32_t reason = K_ERR_CPU_EXCEPTION;
327327

arch/arm/core/cortex_a_r/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
7171
}
7272
#endif /* !CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
7373

74-
void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
74+
void z_arm_fatal_error(unsigned int reason, const struct arch_esf *esf);
7575

7676
/**
7777
*

arch/arm/core/cortex_m/coredump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct arm_arch_block {
4141
*/
4242
static struct arm_arch_block arch_blk;
4343

44-
void arch_coredump_info_dump(const z_arch_esf_t *esf)
44+
void arch_coredump_info_dump(const struct arch_esf *esf)
4545
{
4646
struct coredump_arch_hdr_t hdr = {
4747
.id = COREDUMP_ARCH_HDR_ID,

arch/arm/core/cortex_m/fault.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
146146
*/
147147

148148
#if (CONFIG_FAULT_DUMP == 1)
149-
static void fault_show(const z_arch_esf_t *esf, int fault)
149+
static void fault_show(const struct arch_esf *esf, int fault)
150150
{
151151
PR_EXC("Fault! EXC #%d", fault);
152152

@@ -165,7 +165,7 @@ static void fault_show(const z_arch_esf_t *esf, int fault)
165165
*
166166
* For Dump level 0, no information needs to be generated.
167167
*/
168-
static void fault_show(const z_arch_esf_t *esf, int fault)
168+
static void fault_show(const struct arch_esf *esf, int fault)
169169
{
170170
(void)esf;
171171
(void)fault;
@@ -185,7 +185,7 @@ static const struct z_exc_handle exceptions[] = {
185185
*
186186
* @return true if error is recoverable, otherwise return false.
187187
*/
188-
static bool memory_fault_recoverable(z_arch_esf_t *esf, bool synchronous)
188+
static bool memory_fault_recoverable(struct arch_esf *esf, bool synchronous)
189189
{
190190
#ifdef CONFIG_USERSPACE
191191
for (int i = 0; i < ARRAY_SIZE(exceptions); i++) {
@@ -228,7 +228,7 @@ uint32_t z_check_thread_stack_fail(const uint32_t fault_addr,
228228
*
229229
* @return error code to identify the fatal error reason
230230
*/
231-
static uint32_t mem_manage_fault(z_arch_esf_t *esf, int from_hard_fault,
231+
static uint32_t mem_manage_fault(struct arch_esf *esf, int from_hard_fault,
232232
bool *recoverable)
233233
{
234234
uint32_t reason = K_ERR_ARM_MEM_GENERIC;
@@ -387,7 +387,7 @@ static uint32_t mem_manage_fault(z_arch_esf_t *esf, int from_hard_fault,
387387
* @return error code to identify the fatal error reason.
388388
*
389389
*/
390-
static int bus_fault(z_arch_esf_t *esf, int from_hard_fault, bool *recoverable)
390+
static int bus_fault(struct arch_esf *esf, int from_hard_fault, bool *recoverable)
391391
{
392392
uint32_t reason = K_ERR_ARM_BUS_GENERIC;
393393

@@ -549,7 +549,7 @@ static int bus_fault(z_arch_esf_t *esf, int from_hard_fault, bool *recoverable)
549549
*
550550
* @return error code to identify the fatal error reason
551551
*/
552-
static uint32_t usage_fault(const z_arch_esf_t *esf)
552+
static uint32_t usage_fault(const struct arch_esf *esf)
553553
{
554554
uint32_t reason = K_ERR_ARM_USAGE_GENERIC;
555555

@@ -612,7 +612,7 @@ static uint32_t usage_fault(const z_arch_esf_t *esf)
612612
*
613613
* @return error code to identify the fatal error reason
614614
*/
615-
static uint32_t secure_fault(const z_arch_esf_t *esf)
615+
static uint32_t secure_fault(const struct arch_esf *esf)
616616
{
617617
uint32_t reason = K_ERR_ARM_SECURE_GENERIC;
618618

@@ -661,7 +661,7 @@ static uint32_t secure_fault(const z_arch_esf_t *esf)
661661
* See z_arm_fault_dump() for example.
662662
*
663663
*/
664-
static void debug_monitor(z_arch_esf_t *esf, bool *recoverable)
664+
static void debug_monitor(struct arch_esf *esf, bool *recoverable)
665665
{
666666
*recoverable = false;
667667

@@ -687,7 +687,7 @@ static void debug_monitor(z_arch_esf_t *esf, bool *recoverable)
687687
#error Unknown ARM architecture
688688
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
689689

690-
static inline bool z_arm_is_synchronous_svc(z_arch_esf_t *esf)
690+
static inline bool z_arm_is_synchronous_svc(struct arch_esf *esf)
691691
{
692692
uint16_t *ret_addr = (uint16_t *)esf->basic.pc;
693693
/* SVC is a 16-bit instruction. On a synchronous SVC
@@ -762,7 +762,7 @@ static inline bool z_arm_is_pc_valid(uintptr_t pc)
762762
*
763763
* @return error code to identify the fatal error reason
764764
*/
765-
static uint32_t hard_fault(z_arch_esf_t *esf, bool *recoverable)
765+
static uint32_t hard_fault(struct arch_esf *esf, bool *recoverable)
766766
{
767767
uint32_t reason = K_ERR_CPU_EXCEPTION;
768768

@@ -829,7 +829,7 @@ static uint32_t hard_fault(z_arch_esf_t *esf, bool *recoverable)
829829
* See z_arm_fault_dump() for example.
830830
*
831831
*/
832-
static void reserved_exception(const z_arch_esf_t *esf, int fault)
832+
static void reserved_exception(const struct arch_esf *esf, int fault)
833833
{
834834
ARG_UNUSED(esf);
835835

@@ -839,7 +839,7 @@ static void reserved_exception(const z_arch_esf_t *esf, int fault)
839839
}
840840

841841
/* Handler function for ARM fault conditions. */
842-
static uint32_t fault_handle(z_arch_esf_t *esf, int fault, bool *recoverable)
842+
static uint32_t fault_handle(struct arch_esf *esf, int fault, bool *recoverable)
843843
{
844844
uint32_t reason = K_ERR_CPU_EXCEPTION;
845845

@@ -893,7 +893,7 @@ static uint32_t fault_handle(z_arch_esf_t *esf, int fault, bool *recoverable)
893893
*
894894
* @param secure_esf Pointer to the secure stack frame.
895895
*/
896-
static void secure_stack_dump(const z_arch_esf_t *secure_esf)
896+
static void secure_stack_dump(const struct arch_esf *secure_esf)
897897
{
898898
/*
899899
* In case a Non-Secure exception interrupted the Secure
@@ -918,7 +918,7 @@ static void secure_stack_dump(const z_arch_esf_t *secure_esf)
918918
* Non-Secure exception entry.
919919
*/
920920
top_of_sec_stack += ADDITIONAL_STATE_CONTEXT_WORDS;
921-
secure_esf = (const z_arch_esf_t *)top_of_sec_stack;
921+
secure_esf = (const struct arch_esf *)top_of_sec_stack;
922922
sec_ret_addr = secure_esf->basic.pc;
923923
} else {
924924
/* Exception during Non-Secure function call.
@@ -947,11 +947,11 @@ static void secure_stack_dump(const z_arch_esf_t *secure_esf)
947947
*
948948
* @return ESF pointer on success, otherwise return NULL
949949
*/
950-
static inline z_arch_esf_t *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_return,
950+
static inline struct arch_esf *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_return,
951951
bool *nested_exc)
952952
{
953953
bool alternative_state_exc = false;
954-
z_arch_esf_t *ptr_esf = NULL;
954+
struct arch_esf *ptr_esf = NULL;
955955

956956
*nested_exc = false;
957957

@@ -979,14 +979,14 @@ static inline z_arch_esf_t *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_ret
979979
alternative_state_exc = true;
980980

981981
/* Dump the Secure stack before handling the actual fault. */
982-
z_arch_esf_t *secure_esf;
982+
struct arch_esf *secure_esf;
983983

984984
if (exc_return & EXC_RETURN_SPSEL_PROCESS) {
985985
/* Secure stack pointed by PSP */
986-
secure_esf = (z_arch_esf_t *)psp;
986+
secure_esf = (struct arch_esf *)psp;
987987
} else {
988988
/* Secure stack pointed by MSP */
989-
secure_esf = (z_arch_esf_t *)msp;
989+
secure_esf = (struct arch_esf *)msp;
990990
*nested_exc = true;
991991
}
992992

@@ -997,9 +997,9 @@ static inline z_arch_esf_t *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_ret
997997
* and supply it to the fault handing function.
998998
*/
999999
if (exc_return & EXC_RETURN_MODE_THREAD) {
1000-
ptr_esf = (z_arch_esf_t *)__TZ_get_PSP_NS();
1000+
ptr_esf = (struct arch_esf *)__TZ_get_PSP_NS();
10011001
} else {
1002-
ptr_esf = (z_arch_esf_t *)__TZ_get_MSP_NS();
1002+
ptr_esf = (struct arch_esf *)__TZ_get_MSP_NS();
10031003
}
10041004
}
10051005
#elif defined(CONFIG_ARM_NONSECURE_FIRMWARE)
@@ -1024,10 +1024,10 @@ static inline z_arch_esf_t *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_ret
10241024

10251025
if (exc_return & EXC_RETURN_SPSEL_PROCESS) {
10261026
/* Non-Secure stack frame on PSP */
1027-
ptr_esf = (z_arch_esf_t *)psp;
1027+
ptr_esf = (struct arch_esf *)psp;
10281028
} else {
10291029
/* Non-Secure stack frame on MSP */
1030-
ptr_esf = (z_arch_esf_t *)msp;
1030+
ptr_esf = (struct arch_esf *)msp;
10311031
}
10321032
} else {
10331033
/* Exception entry occurred in Non-Secure stack. */
@@ -1046,11 +1046,11 @@ static inline z_arch_esf_t *get_esf(uint32_t msp, uint32_t psp, uint32_t exc_ret
10461046
if (!alternative_state_exc) {
10471047
if (exc_return & EXC_RETURN_MODE_THREAD) {
10481048
/* Returning to thread mode */
1049-
ptr_esf = (z_arch_esf_t *)psp;
1049+
ptr_esf = (struct arch_esf *)psp;
10501050

10511051
} else {
10521052
/* Returning to handler mode */
1053-
ptr_esf = (z_arch_esf_t *)msp;
1053+
ptr_esf = (struct arch_esf *)msp;
10541054
*nested_exc = true;
10551055
}
10561056
}
@@ -1095,12 +1095,12 @@ void z_arm_fault(uint32_t msp, uint32_t psp, uint32_t exc_return,
10951095
uint32_t reason = K_ERR_CPU_EXCEPTION;
10961096
int fault = SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk;
10971097
bool recoverable, nested_exc;
1098-
z_arch_esf_t *esf;
1098+
struct arch_esf *esf;
10991099

11001100
/* Create a stack-ed copy of the ESF to be used during
11011101
* the fault handling process.
11021102
*/
1103-
z_arch_esf_t esf_copy;
1103+
struct arch_esf esf_copy;
11041104

11051105
/* Force unlock interrupts */
11061106
arch_irq_unlock(0);
@@ -1123,13 +1123,13 @@ void z_arm_fault(uint32_t msp, uint32_t psp, uint32_t exc_return,
11231123

11241124
/* Copy ESF */
11251125
#if !defined(CONFIG_EXTRA_EXCEPTION_INFO)
1126-
memcpy(&esf_copy, esf, sizeof(z_arch_esf_t));
1126+
memcpy(&esf_copy, esf, sizeof(struct arch_esf));
11271127
ARG_UNUSED(callee_regs);
11281128
#else
11291129
/* the extra exception info is not present in the original esf
11301130
* so we only copy the fields before those.
11311131
*/
1132-
memcpy(&esf_copy, esf, offsetof(z_arch_esf_t, extra_info));
1132+
memcpy(&esf_copy, esf, offsetof(struct arch_esf, extra_info));
11331133
esf_copy.extra_info = (struct __extra_esf_info) {
11341134
.callee = callee_regs,
11351135
.exc_return = exc_return,

arch/arm/core/cortex_m/irq_manage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void z_arm_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
9494

9595
#endif /* !defined(CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER) */
9696

97-
void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf);
97+
void z_arm_fatal_error(unsigned int reason, const struct arch_esf *esf);
9898

9999
/**
100100
*

arch/arm/core/fatal.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL);
1919

2020
#ifdef CONFIG_EXCEPTION_DEBUG
21-
static void esf_dump(const z_arch_esf_t *esf)
21+
static void esf_dump(const struct arch_esf *esf)
2222
{
2323
LOG_ERR("r0/a1: 0x%08x r1/a2: 0x%08x r2/a3: 0x%08x",
2424
esf->basic.a1, esf->basic.a2, esf->basic.a3);
@@ -66,7 +66,7 @@ static void esf_dump(const z_arch_esf_t *esf)
6666
}
6767
#endif /* CONFIG_EXCEPTION_DEBUG */
6868

69-
void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
69+
void z_arm_fatal_error(unsigned int reason, const struct arch_esf *esf)
7070
{
7171
#ifdef CONFIG_EXCEPTION_DEBUG
7272
if (esf != NULL) {
@@ -102,7 +102,7 @@ void z_arm_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
102102
* @param esf exception frame
103103
* @param callee_regs Callee-saved registers (R4-R11)
104104
*/
105-
void z_do_kernel_oops(const z_arch_esf_t *esf, _callee_saved_t *callee_regs)
105+
void z_do_kernel_oops(const struct arch_esf *esf, _callee_saved_t *callee_regs)
106106
{
107107
#if !(defined(CONFIG_EXTRA_EXCEPTION_INFO) && defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE))
108108
ARG_UNUSED(callee_regs);
@@ -130,9 +130,9 @@ void z_do_kernel_oops(const z_arch_esf_t *esf, _callee_saved_t *callee_regs)
130130
#if !defined(CONFIG_EXTRA_EXCEPTION_INFO)
131131
z_arm_fatal_error(reason, esf);
132132
#else
133-
z_arch_esf_t esf_copy;
133+
struct arch_esf esf_copy;
134134

135-
memcpy(&esf_copy, esf, offsetof(z_arch_esf_t, extra_info));
135+
memcpy(&esf_copy, esf, offsetof(struct arch_esf, extra_info));
136136
#if defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
137137
/* extra exception info is collected in callee_reg param
138138
* on CONFIG_ARMV7_M_ARMV8_M_MAINLINE
@@ -156,7 +156,7 @@ void z_do_kernel_oops(const z_arch_esf_t *esf, _callee_saved_t *callee_regs)
156156
FUNC_NORETURN void arch_syscall_oops(void *ssf_ptr)
157157
{
158158
uint32_t *ssf_contents = ssf_ptr;
159-
z_arch_esf_t oops_esf = { 0 };
159+
struct arch_esf oops_esf = { 0 };
160160

161161
/* TODO: Copy the rest of the register set out of ssf_ptr */
162162
oops_esf.basic.pc = ssf_contents[3];

arch/arm/core/gdbstub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int is_bkpt(unsigned int exc_cause)
4242
}
4343

4444
/* Wrapper function to save and restore execution c */
45-
void z_gdb_entry(z_arch_esf_t *esf, unsigned int exc_cause)
45+
void z_gdb_entry(struct arch_esf *esf, unsigned int exc_cause)
4646
{
4747
/* Disable the hardware breakpoint in case it was set */
4848
__asm__ volatile("mcr p14, 0, %0, c0, c0, 5" ::"r"(0x0) :);

0 commit comments

Comments
 (0)