Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode/target/i386 Use knowledge of ...



details:   https://anonhg.NetBSD.org/src/rev/ef663591c331
branches:  trunk
changeset: 319138:ef663591c331
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Fri May 18 20:21:14 2018 +0000

description:
Use knowledge of mcontext for i386 support

diffstat:

 sys/arch/usermode/target/i386/cpu_i386.c |  29 ++++++++++++-----------------
 1 files changed, 12 insertions(+), 17 deletions(-)

diffs (115 lines):

diff -r 2e19dedbf096 -r ef663591c331 sys/arch/usermode/target/i386/cpu_i386.c
--- a/sys/arch/usermode/target/i386/cpu_i386.c  Fri May 18 20:11:48 2018 +0000
+++ b/sys/arch/usermode/target/i386/cpu_i386.c  Fri May 18 20:21:14 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $ */
+/* $NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <reinoud%netbsd.org@localhost>
@@ -27,14 +27,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/*
- * Note that this machdep.c uses the `dummy' mcontext_t defined for usermode.
- * This is basicly a blob of PAGE_SIZE big. We might want to switch over to
- * non-generic mcontext_t's one day, but will this break non-NetBSD hosts?
- */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.4 2012/03/03 21:15:16 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_i386.c,v 1.5 2018/05/18 20:21:14 reinoud Exp $");
 
 #include <sys/types.h>
 #include <sys/systm.h>
@@ -117,7 +112,7 @@
        KASSERT(mutex_owned(p->p_lock));
 
        ucp = &pcb->pcb_userret_ucp;
-       reg = (register_t *) &ucp->uc_mcontext;
+       reg = (register_t *) &ucp->uc_mcontext.__gregs;
 #if 0
        thunk_printf("%s: ", __func__);
        thunk_printf("flags %d, ", (int) ksi->ksi_flags);
@@ -198,7 +193,7 @@
 
        /* set up the user context */
        ucp = &pcb->pcb_userret_ucp;
-       reg = (int *) &ucp->uc_mcontext;
+       reg = (int *) &ucp->uc_mcontext.__gregs;
        for (i = 4; i < 11; i++)
                reg[i] = 0;
 
@@ -228,7 +223,7 @@
 void
 md_syscall_get_syscallnumber(ucontext_t *ucp, uint32_t *code)
 {
-       uint *reg = (int *) &ucp->uc_mcontext;
+       uint *reg = (int *) &ucp->uc_mcontext.__gregs;
        *code = reg[11];                        /* EAX */
 }
 
@@ -236,7 +231,7 @@
 md_syscall_getargs(lwp_t *l, ucontext_t *ucp, int nargs, int argsize,
        register_t *args)
 {
-       uint *reg = (int *) &ucp->uc_mcontext;
+       uint *reg = (int *) &ucp->uc_mcontext.__gregs;
        register_t *sp = (register_t *) reg[17];/* ESP */
        int ret;
 
@@ -250,7 +245,7 @@
 md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp,
        int error, register_t *rval)
 {
-       register_t *reg = (register_t *) &ucp->uc_mcontext;
+       register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs;
 
        reg[16] &= ~PSL_C;              /* EFL */
        if (error > 0) {
@@ -270,7 +265,7 @@
 md_get_pc(ucontext_t *ucp)
 {
        KASSERT(ucp);
-       register_t *reg = (register_t *) &ucp->uc_mcontext;
+       register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs;
 
        return reg[14];                 /* EIP */
 }
@@ -279,7 +274,7 @@
 md_get_sp(ucontext_t *ucp)
 {
        KASSERT(ucp);
-       register_t *reg = (register_t *) &ucp->uc_mcontext;
+       register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs;
 
        return reg[17];                 /* ESP */
 }
@@ -307,7 +302,7 @@
 md_syscall_get_opcode(ucontext_t *ucp, uint32_t *opcode)
 {
        KASSERT(ucp);
-       register_t *reg = (register_t *) &ucp->uc_mcontext;
+       register_t *reg = (register_t *) &ucp->uc_mcontext.__gregs;
 //     uint8_t  *p8  = (uint8_t *) (reg[14]);
        uint16_t *p16 = (uint16_t*) (reg[14]);  /* EIP */
 
@@ -328,7 +323,7 @@
 md_syscall_inc_pc(ucontext_t *ucp, uint32_t opcode)
 {
        KASSERT(ucp);
-       uint *reg = (int *) &ucp->uc_mcontext;
+       uint *reg = (int *) &ucp->uc_mcontext.__gregs;
 
        /* advance program counter */
        switch (opcode) {
@@ -349,7 +344,7 @@
 md_syscall_dec_pc(ucontext_t *ucp, uint32_t opcode)
 {
        KASSERT(ucp);
-       uint *reg = (int *) &ucp->uc_mcontext;
+       uint *reg = (int *) &ucp->uc_mcontext.__gregs;
 
        switch (opcode) {
        case 0xff0f:    /* UD1      */



Home | Main Index | Thread Index | Old Index