summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-12-05 21:44:47 +0000
committerjhb <jhb@FreeBSD.org>2005-12-05 21:44:47 +0000
commit6df33a8d26246dfd19b65fe387f54ec15efdbaf7 (patch)
treeafc316c1f725b4742e923bcc4536421465d0cb3a
parent7bb88a772a30446af67a12d5695731078cb24d5a (diff)
downloadFreeBSD-src-6df33a8d26246dfd19b65fe387f54ec15efdbaf7.zip
FreeBSD-src-6df33a8d26246dfd19b65fe387f54ec15efdbaf7.tar.gz
- Move PUSH_FRAME and POP_FRAME into machine/asmacros.h.
- Add a new SET_KERNEL_SREGS macro that sets up %ds and %es to point to kernel data and %fs to point to per-CPU data and use the new macro in several kernel entry points including trap and interrupt handlers. - Convert the IPI_STOP handler Xcpustop to push a standard trap frame rather than an application frame. - Make the TRAP() macro private to exception.s since it is only used there. - Move the PCPU_*() macros in asmacros.h out of the middle of the profiling macros. Reviewed by: bde Requested by: bde (4, 5)
-rw-r--r--sys/i386/i386/apic_vector.s76
-rw-r--r--sys/i386/i386/exception.s20
-rw-r--r--sys/i386/include/asmacros.h47
-rw-r--r--sys/i386/isa/atpic_vector.s13
4 files changed, 54 insertions, 102 deletions
diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s
index b3bee69..650042a 100644
--- a/sys/i386/i386/apic_vector.s
+++ b/sys/i386/i386/apic_vector.s
@@ -44,24 +44,6 @@
#include "assym.s"
/*
- * Macros to create and destroy a trap frame.
- */
-#define PUSH_FRAME \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; /* 8 ints */ \
- pushl %ds ; /* save data and extra segments ... */ \
- pushl %es ; \
- pushl %fs
-
-#define POP_FRAME \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp
-
-/*
* I/O Interrupt Entry Point. Rather than having one entry point for
* each interrupt source, we use one entry point for each 32-bit word
* in the ISR. The handler determines the highest bit set in the ISR,
@@ -73,11 +55,7 @@
SUPERALIGN_TEXT ; \
IDTVEC(vec_name) ; \
PUSH_FRAME ; \
- movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
- movl %eax, %ds ; \
- movl %eax, %es ; \
- movl $KPSEL, %eax ; /* reload with per-CPU data segment */ \
- movl %eax, %fs ; \
+ SET_KERNEL_SREGS ; \
FAKE_MCOUNT(TF_EIP(%esp)) ; \
movl lapic, %edx ; /* pointer to local APIC */ \
movl LA_ISR + 16 * (index)(%edx), %eax ; /* load ISR */ \
@@ -123,11 +101,7 @@ IDTVEC(spuriousint)
SUPERALIGN_TEXT
IDTVEC(timerint)
PUSH_FRAME
- movl $KDSEL, %eax /* reload with kernel's data segment */
- movl %eax, %ds
- movl %eax, %es
- movl $KPSEL, %eax
- movl %eax, %fs
+ SET_KERNEL_SREGS
movl lapic, %edx
movl $0, LA_EOI(%edx) /* End Of Interrupt to APIC */
@@ -271,13 +245,8 @@ IDTVEC(invlrng)
.text
SUPERALIGN_TEXT
IDTVEC(ipi_intr_bitmap_handler)
-
PUSH_FRAME
- movl $KDSEL, %eax /* reload with kernel's data segment */
- movl %eax, %ds
- movl %eax, %es
- movl $KPSEL, %eax
- movl %eax, %fs
+ SET_KERNEL_SREGS
movl lapic, %edx
movl $0, LA_EOI(%edx) /* End Of Interrupt to APIC */
@@ -300,20 +269,8 @@ IDTVEC(ipi_intr_bitmap_handler)
.text
SUPERALIGN_TEXT
IDTVEC(cpustop)
- pushl %ebp
- movl %esp, %ebp
- pushl %eax
- pushl %ecx
- pushl %edx
- pushl %ds /* save current data segment */
- pushl %es
- pushl %fs
-
- movl $KDSEL, %eax
- movl %eax, %ds /* use KERNEL data segment */
- movl %eax, %es
- movl $KPSEL, %eax
- movl %eax, %fs
+ PUSH_FRAME
+ SET_KERNEL_SREGS
movl lapic, %eax
movl $0, LA_EOI(%eax) /* End Of Interrupt to APIC */
@@ -348,14 +305,7 @@ IDTVEC(cpustop)
call *%eax
2:
- popl %fs
- popl %es
- popl %ds /* restore previous data segment */
- popl %edx
- popl %ecx
- popl %eax
- movl %ebp, %esp
- popl %ebp
+ POP_FRAME
iret
/*
@@ -367,11 +317,7 @@ IDTVEC(cpustop)
SUPERALIGN_TEXT
IDTVEC(rendezvous)
PUSH_FRAME
- movl $KDSEL, %eax
- movl %eax, %ds /* use KERNEL data segment */
- movl %eax, %es
- movl $KPSEL, %eax
- movl %eax, %fs
+ SET_KERNEL_SREGS
#ifdef COUNT_IPIS
movl PCPU(CPUID), %eax
@@ -392,11 +338,7 @@ IDTVEC(rendezvous)
SUPERALIGN_TEXT
IDTVEC(lazypmap)
PUSH_FRAME
- movl $KDSEL, %eax
- movl %eax, %ds /* use KERNEL data segment */
- movl %eax, %es
- movl $KPSEL, %eax
- movl %eax, %fs
+ SET_KERNEL_SREGS
#ifdef COUNT_IPIS
movl PCPU(CPUID), %eax
@@ -405,7 +347,7 @@ IDTVEC(lazypmap)
#endif
call pmap_lazyfix_action
- movl lapic, %eax
+ movl lapic, %eax
movl $0, LA_EOI(%eax) /* End Of Interrupt to APIC */
POP_FRAME
iret
diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s
index 2e69ab8..1f285c8 100644
--- a/sys/i386/i386/exception.s
+++ b/sys/i386/i386/exception.s
@@ -74,6 +74,8 @@
MCOUNT_LABEL(user)
MCOUNT_LABEL(btrap)
+#define TRAP(a) pushl $(a) ; jmp alltraps
+
IDTVEC(div)
pushl $0; TRAP(T_DIVIDE)
IDTVEC(dbg)
@@ -129,11 +131,7 @@ alltraps:
pushl %es
pushl %fs
alltraps_with_regs_pushed:
- movl $KDSEL,%eax
- movl %eax,%ds
- movl %eax,%es
- movl $KPSEL,%eax
- movl %eax,%fs
+ SET_KERNEL_SREGS
FAKE_MCOUNT(TF_EIP(%esp))
calltrap:
call trap
@@ -166,11 +164,7 @@ IDTVEC(lcall_syscall)
pushl %ds
pushl %es
pushl %fs
- movl $KDSEL,%eax /* switch to kernel segments */
- movl %eax,%ds
- movl %eax,%es
- movl $KPSEL,%eax
- movl %eax,%fs
+ SET_KERNEL_SREGS
FAKE_MCOUNT(TF_EIP(%esp))
call syscall
MEXITCOUNT
@@ -191,11 +185,7 @@ IDTVEC(int0x80_syscall)
pushl %ds
pushl %es
pushl %fs
- movl $KDSEL,%eax /* switch to kernel segments */
- movl %eax,%ds
- movl %eax,%es
- movl $KPSEL,%eax
- movl %eax,%fs
+ SET_KERNEL_SREGS
FAKE_MCOUNT(TF_EIP(%esp))
call syscall
MEXITCOUNT
diff --git a/sys/i386/include/asmacros.h b/sys/i386/include/asmacros.h
index 9b77bd0..b9f027e 100644
--- a/sys/i386/include/asmacros.h
+++ b/sys/i386/include/asmacros.h
@@ -59,12 +59,6 @@
#define NON_GPROF_ENTRY(name) GEN_ENTRY(name)
#define NON_GPROF_RET .byte 0xc3 /* opcode for `ret' */
-#ifdef LOCORE
-#define PCPU(member) %fs:PC_ ## member
-#define PCPU_ADDR(member, reg) movl %fs:PC_PRVSPACE,reg; \
- addl $PC_ ## member,reg
-#endif
-
#ifdef GPROF
/*
* __mcount is like [.]mcount except that doesn't require its caller to set
@@ -136,12 +130,47 @@
#ifdef LOCORE
/*
- * Convenience macros for declaring interrupt entry points and trap
- * stubs.
+ * Convenience macro for declaring interrupt entry points.
*/
#define IDTVEC(name) ALIGN_TEXT; .globl __CONCAT(X,name); \
.type __CONCAT(X,name),@function; __CONCAT(X,name):
-#define TRAP(a) pushl $(a) ; jmp alltraps
+
+/*
+ * Macros to create and destroy a trap frame.
+ */
+#define PUSH_FRAME \
+ pushl $0 ; /* dummy error code */ \
+ pushl $0 ; /* dummy trap type */ \
+ pushal ; /* 8 ints */ \
+ pushl %ds ; /* save data and extra segments ... */ \
+ pushl %es ; \
+ pushl %fs
+
+#define POP_FRAME \
+ popl %fs ; \
+ popl %es ; \
+ popl %ds ; \
+ popal ; \
+ addl $4+4,%esp
+
+/*
+ * Access per-CPU data.
+ */
+#define PCPU(member) %fs:PC_ ## member
+
+#define PCPU_ADDR(member, reg) \
+ movl %fs:PC_PRVSPACE, reg ; \
+ addl $PC_ ## member, reg
+
+/*
+ * Setup the kernel segment registers.
+ */
+#define SET_KERNEL_SREGS \
+ movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
+ movl %eax, %ds ; \
+ movl %eax, %es ; \
+ movl $KPSEL, %eax ; /* reload with per-CPU data segment */ \
+ movl %eax, %fs
#endif /* LOCORE */
diff --git a/sys/i386/isa/atpic_vector.s b/sys/i386/isa/atpic_vector.s
index 52aaded..dcf4135 100644
--- a/sys/i386/isa/atpic_vector.s
+++ b/sys/i386/isa/atpic_vector.s
@@ -47,17 +47,8 @@
.text ; \
SUPERALIGN_TEXT ; \
IDTVEC(vec_name) ; \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; /* 8 ints */ \
- pushl %ds ; /* save data and extra segments ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
- movl %eax, %ds ; \
- movl %eax, %es ; \
- movl $KPSEL, %eax ; /* reload with per-CPU data segment */ \
- movl %eax, %fs ; \
+ PUSH_FRAME ; \
+ SET_KERNEL_SREGS ; \
; \
FAKE_MCOUNT(TF_EIP(%esp)) ; \
pushl $irq_num; /* pass the IRQ */ \
OpenPOWER on IntegriCloud