aarch64: Remove redundant init_stack_frame

The init_stack_frame is the same as the the ESF. No need to have two
separate structs. Consolidate everything into one single struct and make
register entries explicit.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2020-11-11 15:19:24 +01:00 committed by Anas Nashif
commit daa94e5e59
3 changed files with 38 additions and 60 deletions

View file

@ -148,26 +148,16 @@ static void dump_esr(uint64_t esr, bool *dump_far)
static void esf_dump(const z_arch_esf_t *esf)
{
LOG_ERR("x0: 0x%016llx x1: 0x%016llx",
esf->basic.regs[18], esf->basic.regs[19]);
LOG_ERR("x2: 0x%016llx x3: 0x%016llx",
esf->basic.regs[16], esf->basic.regs[17]);
LOG_ERR("x4: 0x%016llx x5: 0x%016llx",
esf->basic.regs[14], esf->basic.regs[15]);
LOG_ERR("x6: 0x%016llx x7: 0x%016llx",
esf->basic.regs[12], esf->basic.regs[13]);
LOG_ERR("x8: 0x%016llx x9: 0x%016llx",
esf->basic.regs[10], esf->basic.regs[11]);
LOG_ERR("x10: 0x%016llx x11: 0x%016llx",
esf->basic.regs[8], esf->basic.regs[9]);
LOG_ERR("x12: 0x%016llx x13: 0x%016llx",
esf->basic.regs[6], esf->basic.regs[7]);
LOG_ERR("x14: 0x%016llx x15: 0x%016llx",
esf->basic.regs[4], esf->basic.regs[5]);
LOG_ERR("x16: 0x%016llx x17: 0x%016llx",
esf->basic.regs[2], esf->basic.regs[3]);
LOG_ERR("x18: 0x%016llx x30: 0x%016llx",
esf->basic.regs[0], esf->basic.regs[1]);
LOG_ERR("x0: 0x%016llx x1: 0x%016llx", esf->x0, esf->x1);
LOG_ERR("x2: 0x%016llx x3: 0x%016llx", esf->x2, esf->x3);
LOG_ERR("x4: 0x%016llx x5: 0x%016llx", esf->x4, esf->x5);
LOG_ERR("x6: 0x%016llx x7: 0x%016llx", esf->x6, esf->x7);
LOG_ERR("x8: 0x%016llx x9: 0x%016llx", esf->x8, esf->x9);
LOG_ERR("x10: 0x%016llx x11: 0x%016llx", esf->x10, esf->x11);
LOG_ERR("x12: 0x%016llx x13: 0x%016llx", esf->x12, esf->x13);
LOG_ERR("x14: 0x%016llx x15: 0x%016llx", esf->x14, esf->x15);
LOG_ERR("x16: 0x%016llx x17: 0x%016llx", esf->x16, esf->x17);
LOG_ERR("x18: 0x%016llx x30: 0x%016llx", esf->x18, esf->x30);
}
#endif /* CONFIG_EXCEPTION_DEBUG */

View file

@ -16,35 +16,6 @@
#include <wait_q.h>
#include <arch/cpu.h>
struct init_stack_frame {
/* top of the stack / most recently pushed */
/* SPSR_ELn and ELR_ELn */
uint64_t spsr;
uint64_t elr;
/*
* Registers restored by z_arm64_exit_exc(). We are not interested in
* registers x4 -> x18 + x30 but we need to account for those anyway
*/
uint64_t unused[16];
/*
* z_arm64_exit_exc() pulls these off the stack and into argument
* registers before calling z_thread_entry():
* - x2 <- arg2
* - x3 <- arg3
* - x0 <- entry_point
* - x1 <- arg1
*/
uint64_t arg2;
uint64_t arg3;
uint64_t entry_point;
uint64_t arg1;
/* least recently pushed */
};
/*
* An initial context, to be "restored" by z_arm64_context_switch(), is put at
* the other end of the stack, and thus reusable by the stack when not needed
@ -54,14 +25,14 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
char *stack_ptr, k_thread_entry_t entry,
void *p1, void *p2, void *p3)
{
struct init_stack_frame *pInitCtx;
z_arch_esf_t *pInitCtx;
pInitCtx = Z_STACK_PTR_TO_FRAME(struct init_stack_frame, stack_ptr);
pInitCtx = Z_STACK_PTR_TO_FRAME(struct __esf, stack_ptr);
pInitCtx->entry_point = (uint64_t)entry;
pInitCtx->arg1 = (uint64_t)p1;
pInitCtx->arg2 = (uint64_t)p2;
pInitCtx->arg3 = (uint64_t)p3;
pInitCtx->x0 = (uint64_t)entry;
pInitCtx->x1 = (uint64_t)p1;
pInitCtx->x2 = (uint64_t)p2;
pInitCtx->x3 = (uint64_t)p3;
/*
* - ELR_ELn: to be used by eret in z_arm64_exit_exc() to return

View file

@ -25,11 +25,28 @@ extern "C" {
#endif
struct __esf {
struct __basic_sf {
uint64_t spsr;
uint64_t elr;
uint64_t regs[20];
} basic;
uint64_t spsr;
uint64_t elr;
uint64_t x18;
uint64_t x30;
uint64_t x16;
uint64_t x17;
uint64_t x14;
uint64_t x15;
uint64_t x12;
uint64_t x13;
uint64_t x10;
uint64_t x11;
uint64_t x8;
uint64_t x9;
uint64_t x6;
uint64_t x7;
uint64_t x4;
uint64_t x5;
uint64_t x2;
uint64_t x3;
uint64_t x0;
uint64_t x1;
};
typedef struct __esf z_arch_esf_t;