Source-Changes-HG archive

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

[src/sommerfeld_i386mp_1]: src/sys/arch/i386 Move the IDTVEC() macro to <mach...



details:   https://anonhg.NetBSD.org/src/rev/57504a3f6194
branches:  sommerfeld_i386mp_1
changeset: 482537:57504a3f6194
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri May 31 18:07:32 2002 +0000

description:
Move the IDTVEC() macro to <machine/asm.h>, and make it work with
an ISO C preprocessor.

diffstat:

 sys/arch/i386/i386/mach_sigcode.s |  199 ++++++++++++++++++++++++++++++++++++++
 sys/arch/i386/include/asm.h       |  162 ++++++++++++++++++++++++++++++
 2 files changed, 361 insertions(+), 0 deletions(-)

diffs (truncated from 369 to 300 lines):

diff -r ab2d779bcd83 -r 57504a3f6194 sys/arch/i386/i386/mach_sigcode.s
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/i386/mach_sigcode.s Fri May 31 18:07:32 2002 +0000
@@ -0,0 +1,199 @@
+/*     $NetBSD: mach_sigcode.s,v 1.3.2.2 2002/05/31 18:07:32 thorpej Exp $     */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)locore.s    7.3 (Berkeley) 5/13/91
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_vm86.h"
+#endif
+
+#include "assym.h"
+
+#include <machine/psl.h>
+#include <machine/segments.h>
+#include <machine/trap.h>
+#include <compat/mach/mach_syscall.h>
+
+/*
+ * override user-land alignment before including asm.h
+ */
+#ifdef __ELF__
+#define        ALIGN_DATA      .align  4
+#define        ALIGN_TEXT      .align  4,0x90  /* 4-byte boundaries, NOP-filled */
+#define        SUPERALIGN_TEXT .align  16,0x90 /* 16-byte boundaries better for 486 */
+#else
+#define        ALIGN_DATA      .align  2
+#define        ALIGN_TEXT      .align  2,0x90  /* 4-byte boundaries, NOP-filled */
+#define        SUPERALIGN_TEXT .align  4,0x90  /* 16-byte boundaries better for 486 */
+#endif
+#define _ALIGN_TEXT    ALIGN_TEXT
+#include <machine/asm.h>
+
+/*
+ * These are used on interrupt or trap entry or exit.
+ */
+#define        INTRENTRY \
+       pushl   %eax            ; \
+       pushl   %ecx            ; \
+       pushl   %edx            ; \
+       pushl   %ebx            ; \
+       movl    $GSEL(GDATA_SEL, SEL_KPL),%eax  ; \
+       pushl   %ebp            ; \
+       pushl   %esi            ; \
+       pushl   %edi            ; \
+       pushl   %ds             ; \
+       pushl   %es             ; \
+       movl    %eax,%ds        ; \
+       movl    %eax,%es        ; \
+       pushl   %fs             ; \
+       pushl   %gs             ; \
+       movl    %eax,%fs        ; \
+       movl    %eax,%gs        ; \
+
+#define        INTRFASTEXIT \
+       popl    %gs             ; \
+       popl    %fs             ; \
+       popl    %es             ; \
+       popl    %ds             ; \
+       popl    %edi            ; \
+       popl    %esi            ; \
+       popl    %ebp            ; \
+       popl    %ebx            ; \
+       popl    %edx            ; \
+       popl    %ecx            ; \
+       popl    %eax            ; \
+       addl    $8,%esp         ; \
+       iret
+
+
+/*
+ * Signal trampoline; copied to top of user stack.
+ */
+/* LINTSTUB: Var: char mach_sigcode[1], mach_esigcode[1]; */
+NENTRY(mach_sigcode)
+/*
+       call    MACH_SIGF_HANDLER(%esp)
+       leal    MACH_SIGF_UC(%esp),%eax # ucp (the call may have clobbered the
+                                       # copy at SIGF_UCP(%esp))
+       pushl   %eax
+       pushl   $1                      # setcontext(p) == syscontext(1, p) 
+       pushl   %eax                    # junk to fake return address
+       movl    $MACH_SYS_context,%eax
+       int     $0x80                   # enter kernel with args on stack
+       movl    $MACH_SYS_exit,%eax
+       int     $0x80                   # exit if sigreturn fails
+*/
+       .globl  _C_LABEL(mach_esigcode)
+_C_LABEL(mach_esigcode):
+
+IDTVEC(mach_trap)
+       /* Set eflags in trap frame. */
+       pushfl
+       popl    8(%esp)
+       pushl   $7              # size of instruction for restart
+       pushl   $T_ASTFLT       # trap # for doing ASTs
+       INTRENTRY
+       movl    _C_LABEL(curproc),%edx  # get pointer to curproc
+#ifdef DIAGNOSTIC
+       movl    _C_LABEL(cpl),%ebx
+#endif /* DIAGNOSTIC */
+       movl    %esp,P_MD_REGS(%edx)    # save pointer to frame
+       call    _C_LABEL(mach_trap)
+2:     /* Check for ASTs on exit to user mode. */
+       cli
+       cmpb    $0,_C_LABEL(astpending)
+       je      1f
+       /* Always returning to user mode here. */
+       movb    $0,_C_LABEL(astpending)
+       sti
+       /* Pushed T_ASTFLT into tf_trapno on entry. */
+       call    _C_LABEL(trap)
+       jmp     2b
+#ifndef DIAGNOSTIC
+1:     INTRFASTEXIT
+#else /* DIAGNOSTIC */
+1:     cmpl    _C_LABEL(cpl),%ebx
+       jne     3f
+       INTRFASTEXIT
+3:     sti
+       pushl   $4f
+       call    _C_LABEL(printf)
+       addl    $4,%esp
+#ifdef DDB
+       int     $3
+#endif /* DDB */
+       movl    %ebx,_C_LABEL(cpl)
+       jmp     2b
+4:     .asciz  "WARNING: SPL NOT LOWERED ON SYSCALL EXIT\n"
+#endif /* DIAGNOSTIC */
diff -r ab2d779bcd83 -r 57504a3f6194 sys/arch/i386/include/asm.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/i386/include/asm.h       Fri May 31 18:07:32 2002 +0000
@@ -0,0 +1,162 @@
+/*     $NetBSD: asm.h,v 1.21.2.2 2002/05/31 18:07:32 thorpej Exp $     */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)asm.h       5.5 (Berkeley) 5/7/91
+ */
+
+#ifndef _I386_ASM_H_
+#define _I386_ASM_H_
+
+#ifdef PIC
+#define PIC_PROLOGUE   \
+       pushl   %ebx;   \
+       call    1f;     \
+1:                     \
+       popl    %ebx;   \
+       addl    $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+#define PIC_EPILOGUE   \
+       popl    %ebx
+#define PIC_PLT(x)     x@PLT
+#define PIC_GOT(x)     x@GOT(%ebx)
+#define PIC_GOTOFF(x)  x@GOTOFF(%ebx)
+#else
+#define PIC_PROLOGUE
+#define PIC_EPILOGUE
+#define PIC_PLT(x)     x
+#define PIC_GOT(x)     x
+#define PIC_GOTOFF(x)  x
+#endif
+
+#ifdef __ELF__
+# define _C_LABEL(x)   x
+#else
+# ifdef __STDC__
+#  define _C_LABEL(x)  _ ## x
+# else
+#  define _C_LABEL(x)  _/**/x
+# endif
+#endif
+#define        _ASM_LABEL(x)   x
+
+#ifdef __STDC__
+# define __CONCAT(x,y) x ## y
+# define __STRING(x)   #x
+#else
+# define __CONCAT(x,y) x/**/y
+# define __STRING(x)   "x"
+#endif
+
+/* let kernels and others override entrypoint alignment */
+#ifndef _ALIGN_TEXT
+# ifdef __ELF__
+#  define _ALIGN_TEXT .align 4
+# else
+#  define _ALIGN_TEXT .align 2
+# endif
+#endif
+
+#define _ENTRY(x) \
+       .text; _ALIGN_TEXT; .globl x; .type x,@function; x:



Home | Main Index | Thread Index | Old Index