- 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)
This commit is contained in:
parent
5714e9ea59
commit
48c8cbcb82
@ -43,24 +43,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
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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 */ \
|
||||
|
Loading…
Reference in New Issue
Block a user