The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=1c33a94ab06bb8274c8a50257a8b94e209a2e2ee
commit 1c33a94ab06bb8274c8a50257a8b94e209a2e2ee Author: Andrew Turner <and...@freebsd.org> AuthorDate: 2023-03-22 12:18:41 +0000 Commit: Andrew Turner <and...@freebsd.org> CommitDate: 2023-03-22 15:08:03 +0000 Add macros for arm64 pcb register offsets Add macros for offsets of macros we set in the arm64 pcb pcb_x array. This will simplift reducing the size of this array in a later change. Sponsored by: Arm Ltd --- sys/arm64/arm64/db_trace.c | 2 +- sys/arm64/arm64/stack_machdep.c | 2 +- sys/arm64/arm64/vm_machdep.c | 12 ++++++------ sys/arm64/include/pcb.h | 4 ++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sys/arm64/arm64/db_trace.c b/sys/arm64/arm64/db_trace.c index 4d68cd513bce..2b47ae2a89c7 100644 --- a/sys/arm64/arm64/db_trace.c +++ b/sys/arm64/arm64/db_trace.c @@ -144,7 +144,7 @@ db_trace_thread(struct thread *thr, int count) if (thr != curthread) { ctx = kdb_thr_ctx(thr); - frame.fp = (uintptr_t)ctx->pcb_x[29]; + frame.fp = (uintptr_t)ctx->pcb_x[PCB_FP]; frame.pc = (uintptr_t)ctx->pcb_lr; db_stack_trace_cmd(thr, &frame); } else diff --git a/sys/arm64/arm64/stack_machdep.c b/sys/arm64/arm64/stack_machdep.c index 706beb05761c..8a3e8ce7dbc7 100644 --- a/sys/arm64/arm64/stack_machdep.c +++ b/sys/arm64/arm64/stack_machdep.c @@ -68,7 +68,7 @@ stack_save_td(struct stack *st, struct thread *td) if (TD_IS_RUNNING(td)) return (EOPNOTSUPP); - frame.fp = td->td_pcb->pcb_x[29]; + frame.fp = td->td_pcb->pcb_x[PCB_FP]; frame.pc = ADDR_MAKE_CANONICAL(td->td_pcb->pcb_lr); stack_capture(td, st, &frame); diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c index 006bf5127d25..dee42a8b568d 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -105,8 +105,8 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) td2->td_frame = tf; /* Set the return value registers for fork() */ - td2->td_pcb->pcb_x[19] = (uintptr_t)fork_return; - td2->td_pcb->pcb_x[20] = (uintptr_t)td2; + td2->td_pcb->pcb_x[PCB_X19] = (uintptr_t)fork_return; + td2->td_pcb->pcb_x[PCB_X20] = (uintptr_t)td2; td2->td_pcb->pcb_lr = (uintptr_t)fork_trampoline; td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame; @@ -183,8 +183,8 @@ cpu_copy_thread(struct thread *td, struct thread *td0) bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe)); bcopy(td0->td_pcb, td->td_pcb, sizeof(struct pcb)); - td->td_pcb->pcb_x[19] = (uintptr_t)fork_return; - td->td_pcb->pcb_x[20] = (uintptr_t)td; + td->td_pcb->pcb_x[PCB_X19] = (uintptr_t)fork_return; + td->td_pcb->pcb_x[PCB_X20] = (uintptr_t)td; td->td_pcb->pcb_lr = (uintptr_t)fork_trampoline; td->td_pcb->pcb_sp = (uintptr_t)td->td_frame; @@ -287,8 +287,8 @@ void cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg) { - td->td_pcb->pcb_x[19] = (uintptr_t)func; - td->td_pcb->pcb_x[20] = (uintptr_t)arg; + td->td_pcb->pcb_x[PCB_X19] = (uintptr_t)func; + td->td_pcb->pcb_x[PCB_X20] = (uintptr_t)arg; } void diff --git a/sys/arm64/include/pcb.h b/sys/arm64/include/pcb.h index a7416d65b344..8767a9e4dba3 100644 --- a/sys/arm64/include/pcb.h +++ b/sys/arm64/include/pcb.h @@ -36,6 +36,10 @@ struct trapframe; +#define PCB_X19 19 +#define PCB_X20 20 +#define PCB_FP 29 + struct pcb { uint64_t pcb_x[30]; uint64_t pcb_lr;