Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86_64 Rearrange the trapframe and mcontext to put ...
details: https://anonhg.NetBSD.org/src/rev/b136077ac91b
branches: trunk
changeset: 542316:b136077ac91b
user: fvdl <fvdl%NetBSD.org@localhost>
date: Sun Jan 26 14:12:10 2003 +0000
description:
Rearrange the trapframe and mcontext to put the registers used for
argument passing to be in front, in order. Define constants for
offsets inside frames, to avoid having to redo asm code should they
change again.
diffstat:
sys/arch/x86_64/include/frame.h | 42 +++++++++++-----------
sys/arch/x86_64/include/frameasm.h | 70 +++++++++++++++++++-------------------
sys/arch/x86_64/include/mcontext.h | 35 ++++++++++--------
sys/arch/x86_64/x86_64/genassym.cf | 33 ++++++++++++-----
4 files changed, 99 insertions(+), 81 deletions(-)
diffs (278 lines):
diff -r 130757fa5800 -r b136077ac91b sys/arch/x86_64/include/frame.h
--- a/sys/arch/x86_64/include/frame.h Sun Jan 26 13:20:12 2003 +0000
+++ b/sys/arch/x86_64/include/frame.h Sun Jan 26 14:12:10 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: frame.h,v 1.6 2003/01/26 00:05:37 fvdl Exp $ */
+/* $NetBSD: frame.h,v 1.7 2003/01/26 14:12:10 fvdl Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -92,20 +92,20 @@
* Exception/Trap Stack Frame
*/
struct trapframe {
- int64_t tf_r15;
- int64_t tf_r14;
- int64_t tf_r13;
- int64_t tf_r12;
- int64_t tf_r11;
- int64_t tf_r10;
- int64_t tf_r9;
- int64_t tf_r8;
int64_t tf_rdi;
int64_t tf_rsi;
+ int64_t tf_rdx;
+ int64_t tf_rcx;
+ int64_t tf_r8;
+ int64_t tf_r9;
+ int64_t tf_r10;
+ int64_t tf_r11;
+ int64_t tf_r12;
+ int64_t tf_r13;
+ int64_t tf_r14;
+ int64_t tf_r15;
int64_t tf_rbp;
int64_t tf_rbx;
- int64_t tf_rdx;
- int64_t tf_rcx;
int64_t tf_rax;
int64_t tf_gs;
int64_t tf_fs;
@@ -127,20 +127,20 @@
*/
struct intrframe {
int64_t if_ppl;
- int64_t if_r15;
- int64_t if_r14;
- int64_t if_r13;
- int64_t if_r12;
- int64_t if_r11;
- int64_t if_r10;
- int64_t if_r9;
- int64_t if_r8;
int64_t if_rdi;
int64_t if_rsi;
+ int64_t if_rdx;
+ int64_t if_rcx;
+ int64_t if_r8;
+ int64_t if_r9;
+ int64_t if_r10;
+ int64_t if_r11;
+ int64_t if_r12;
+ int64_t if_r13;
+ int64_t if_r14;
+ int64_t if_r15;
int64_t if_rbp;
int64_t if_rbx;
- int64_t if_rdx;
- int64_t if_rcx;
int64_t if_rax;
int64_t tf_gs;
int64_t tf_fs;
diff -r 130757fa5800 -r b136077ac91b sys/arch/x86_64/include/frameasm.h
--- a/sys/arch/x86_64/include/frameasm.h Sun Jan 26 13:20:12 2003 +0000
+++ b/sys/arch/x86_64/include/frameasm.h Sun Jan 26 14:12:10 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: frameasm.h,v 1.5 2003/01/26 00:05:37 fvdl Exp $ */
+/* $NetBSD: frameasm.h,v 1.6 2003/01/26 14:12:10 fvdl Exp $ */
#ifndef _X86_64_MACHINE_FRAMEASM_H
#define _X86_64_MACHINE_FRAMEASM_H
@@ -13,38 +13,38 @@
*/
#define INTR_SAVE_GPRS \
subq $120,%rsp ; \
- movq %r15,0(%rsp) ; \
- movq %r14,8(%rsp) ; \
- movq %r13,16(%rsp) ; \
- movq %r12,24(%rsp) ; \
- movq %r11,32(%rsp) ; \
- movq %r10,40(%rsp) ; \
- movq %r9,48(%rsp) ; \
- movq %r8,56(%rsp) ; \
- movq %rdi,64(%rsp) ; \
- movq %rsi,72(%rsp) ; \
- movq %rbp,80(%rsp) ; \
- movq %rbx,88(%rsp) ; \
- movq %rdx,96(%rsp) ; \
- movq %rcx,104(%rsp) ; \
- movq %rax,112(%rsp)
+ movq %r15,TF_R15(%rsp) ; \
+ movq %r14,TF_R14(%rsp) ; \
+ movq %r13,TF_R13(%rsp) ; \
+ movq %r12,TF_R12(%rsp) ; \
+ movq %r11,TF_R11(%rsp) ; \
+ movq %r10,TF_R10(%rsp) ; \
+ movq %r9,TF_R9(%rsp) ; \
+ movq %r8,TF_R8(%rsp) ; \
+ movq %rdi,TF_RDI(%rsp) ; \
+ movq %rsi,TF_RSI(%rsp) ; \
+ movq %rbp,TF_RBP(%rsp) ; \
+ movq %rbx,TF_RBX(%rsp) ; \
+ movq %rdx,TF_RDX(%rsp) ; \
+ movq %rcx,TF_RCX(%rsp) ; \
+ movq %rax,TF_RAX(%rsp)
#define INTR_RESTORE_GPRS \
- movq 0(%rsp),%r15 ; \
- movq 8(%rsp),%r14 ; \
- movq 16(%rsp),%r13 ; \
- movq 24(%rsp),%r12 ; \
- movq 32(%rsp),%r11 ; \
- movq 40(%rsp),%r10 ; \
- movq 48(%rsp),%r9 ; \
- movq 56(%rsp),%r8 ; \
- movq 64(%rsp),%rdi ; \
- movq 72(%rsp),%rsi ; \
- movq 80(%rsp),%rbp ; \
- movq 88(%rsp),%rbx ; \
- movq 96(%rsp),%rdx ; \
- movq 104(%rsp),%rcx ; \
- movq 112(%rsp),%rax ; \
+ movq TF_R15(%rsp),%r15 ; \
+ movq TF_R14(%rsp),%r14 ; \
+ movq TF_R13(%rsp),%r13 ; \
+ movq TF_R12(%rsp),%r12 ; \
+ movq TF_R11(%rsp),%r11 ; \
+ movq TF_R10(%rsp),%r10 ; \
+ movq TF_R9(%rsp),%r9 ; \
+ movq TF_R8(%rsp),%r8 ; \
+ movq TF_RDI(%rsp),%rdi ; \
+ movq TF_RSI(%rsp),%rsi ; \
+ movq TF_RBP(%rsp),%rbp ; \
+ movq TF_RBX(%rsp),%rbx ; \
+ movq TF_RDX(%rsp),%rdx ; \
+ movq TF_RCX(%rsp),%rcx ; \
+ movq TF_RAX(%rsp),%rax ; \
addq $120,%rsp
#define INTRENTRY \
@@ -54,8 +54,8 @@
swapgs ; \
movw %gs,0(%rsp) ; \
movw %fs,8(%rsp) ; \
- movw %ds,16(%rsp) ; \
- movw %es,24(%rsp) ; \
+ movw %es,16(%rsp) ; \
+ movw %ds,24(%rsp) ; \
98: INTR_SAVE_GPRS
#define INTRFASTEXIT \
@@ -66,8 +66,8 @@
swapgs ; \
movw 0(%rsp),%gs ; \
movw 8(%rsp),%fs ; \
- movw 16(%rsp),%ds ; \
- movw 24(%rsp),%es ; \
+ movw 16(%rsp),%es ; \
+ movw 24(%rsp),%ds ; \
99: addq $48,%rsp ; \
iretq
diff -r 130757fa5800 -r b136077ac91b sys/arch/x86_64/include/mcontext.h
--- a/sys/arch/x86_64/include/mcontext.h Sun Jan 26 13:20:12 2003 +0000
+++ b/sys/arch/x86_64/include/mcontext.h Sun Jan 26 14:12:10 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.1 2003/01/26 00:05:37 fvdl Exp $ */
+/* $NetBSD: mcontext.h,v 1.2 2003/01/26 14:12:10 fvdl Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -51,20 +51,24 @@
typedef long __greg_t;
typedef __greg_t __gregset_t[_NGREG];
-#define _REG_R15 0
-#define _REG_R14 1
-#define _REG_R13 2
-#define _REG_R12 3
-#define _REG_R11 4
-#define _REG_R10 5
-#define _REG_R9 6
-#define _REG_R8 7
-#define _REG_RDI 8
-#define _REG_RSI 9
-#define _REG_RBP 10
-#define _REG_RBX 11
-#define _REG_RDX 12
-#define _REG_RCX 13
+/*
+ * This is laid out to match trapframe and intrframe (see <machine/frame.h>).
+ * Hence, memcpy between gregs and a trapframe is possible.
+ */
+#define _REG_RDI 0
+#define _REG_RSI 1
+#define _REG_RDX 2
+#define _REG_RCX 3
+#define _REG_R8 4
+#define _REG_R9 5
+#define _REG_R10 6
+#define _REG_R11 7
+#define _REG_R12 8
+#define _REG_R13 9
+#define _REG_R14 10
+#define _REG_R15 11
+#define _REG_RBP 12
+#define _REG_RBX 13
#define _REG_RAX 14
#define _REG_GS 15
#define _REG_FS 16
@@ -89,6 +93,7 @@
} mcontext_t;
#define _UC_UCONTEXT_ALIGN (~0xf)
+#define _UC_MACHINE_PAD 1
#ifdef _KERNEL
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_URSP])
diff -r 130757fa5800 -r b136077ac91b sys/arch/x86_64/x86_64/genassym.cf
--- a/sys/arch/x86_64/x86_64/genassym.cf Sun Jan 26 13:20:12 2003 +0000
+++ b/sys/arch/x86_64/x86_64/genassym.cf Sun Jan 26 14:12:10 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.9 2003/01/26 00:05:39 fvdl Exp $
+# $NetBSD: genassym.cf,v 1.10 2003/01/26 14:12:11 fvdl Exp $
#
# Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -158,19 +158,32 @@
define PCB_LDT_SEL offsetof(struct pcb, pcb_ldt_sel)
define PCB_ONFAULT offsetof(struct pcb, pcb_onfault)
-define TF_CS offsetof(struct trapframe, tf_cs)
-define TF_DS offsetof(struct trapframe, tf_ds)
+define TF_RDI offsetof(struct trapframe, tf_rdi)
+define TF_RSI offsetof(struct trapframe, tf_rsi)
+define TF_RDX offsetof(struct trapframe, tf_rdx)
+define TF_RCX offsetof(struct trapframe, tf_rcx)
+define TF_R8 offsetof(struct trapframe, tf_r8)
+define TF_R9 offsetof(struct trapframe, tf_r9)
+define TF_R10 offsetof(struct trapframe, tf_r10)
+define TF_R11 offsetof(struct trapframe, tf_r11)
+define TF_R12 offsetof(struct trapframe, tf_r12)
+define TF_R13 offsetof(struct trapframe, tf_r13)
+define TF_R14 offsetof(struct trapframe, tf_r14)
+define TF_R15 offsetof(struct trapframe, tf_r15)
+define TF_RBP offsetof(struct trapframe, tf_rbp)
+define TF_RBX offsetof(struct trapframe, tf_rbx)
+define TF_RAX offsetof(struct trapframe, tf_rax)
+define TF_GS offsetof(struct trapframe, tf_gs)
+define TF_FS offsetof(struct trapframe, tf_fs)
define TF_ES offsetof(struct trapframe, tf_es)
-define TF_FS offsetof(struct trapframe, tf_fs)
-define TF_GS offsetof(struct trapframe, tf_gs)
+define TF_DS offsetof(struct trapframe, tf_ds)
+define TF_TRAPNO offsetof(struct trapframe, tf_trapno)
+define TF_ERR offsetof(struct trapframe, tf_err)
define TF_RIP offsetof(struct trapframe, tf_rip)
+define TF_CS offsetof(struct trapframe, tf_cs)
+define TF_RFLAGS offsetof(struct trapframe, tf_rflags)
define TF_RSP offsetof(struct trapframe, tf_rsp)
-define TF_RAX offsetof(struct trapframe, tf_rax)
-define TF_RDI offsetof(struct trapframe, tf_rdi)
define TF_SS offsetof(struct trapframe, tf_ss)
-define TF_ERR offsetof(struct trapframe, tf_err)
-define TF_TRAPNO offsetof(struct trapframe, tf_trapno)
-define TF_RFLAGS offsetof(struct trapframe, tf_rflags)
define FRAMESIZE sizeof(struct trapframe)
Home |
Main Index |
Thread Index |
Old Index