Date: Fri, 5 Jul 2002 17:43:26 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: Peter Wemm <peter@wemm.org> Cc: FreeBSD current users <current@FreeBSD.ORG> Subject: i386 trap code Message-ID: <Pine.BSF.4.21.0207051736540.14813-100000@InterJet.elischer.org>
index | next in thread | raw e-mail
Looking at i386/exception.s
one sees:
###################################
.globl alltraps
.type alltraps,@function
alltraps:
pushal
pushl %ds
pushl %es
pushl %fs
alltraps_with_regs_pushed:
mov $KDSEL,%ax
mov %ax,%ds
mov %ax,%es
mov $KPSEL,%ax
mov %ax,%fs
FAKE_MCOUNT(13*4(%esp))
calltrap:
FAKE_MCOUNT(btrap) /* init "from" btrap -> calltrap
*/
call trap
/*
* Return via doreti to handle ASTs.
*/
MEXITCOUNT
jmp doreti
#######################################
but one has to look in isa/ipl.s to find:
########################################
SUPERALIGN_TEXT
.type doreti,@function
doreti:
FAKE_MCOUNT(bintr) /* init "from" bintr -> doreti */
doreti_next:
/*
* Check if ASTs can be handled now. PSL_VM must be checked first
* since segment registers only have an RPL in non-VM86 mode.
*/
testl $PSL_VM,TF_EFLAGS(%esp) /* are we in vm86 mode? */
jz doreti_notvm86
cmpl $1,in_vm86call /* are we in a vm86 call? */
jne doreti_ast /* can handle ASTs now if not */
jmp doreti_exit
doreti_notvm86:
testb $SEL_RPL_MASK,TF_CS(%esp) /* are we in user mode? */
jz doreti_exit /* can't handle ASTs now if not */
doreti_ast:
/*
* Check for ASTs atomically with returning. Disabling CPU
* interrupts provides sufficient locking evein the SMP case,
* since we will be informed of any new ASTs by an IPI.
*/
cli
movl PCPU(CURTHREAD),%eax
movl TD_KSE(%eax), %eax
testl $KEF_ASTPENDING | KEF_NEEDRESCHED,KE_FLAGS(%eax)
je doreti_exit
sti
pushl %esp /* pass a pointer to the trapframe
*/
call ast
add $4,%esp
jmp doreti_ast
/*
* doreti_exit: pop registers, iret.
*
* The segment register pop is a special case, since it may
* fault if (for example) a sigreturn specifies bad segment
* registers. The fault is handled in trap.c.
*/
doreti_exit:
MEXITCOUNT
.globl doreti_popl_fs
doreti_popl_fs:
popl %fs
.globl doreti_popl_es
doreti_popl_es:
popl %es
.globl doreti_popl_ds
doreti_popl_ds:
popl %ds
popal
addl $8,%esp
.globl doreti_iret
doreti_iret:
iret
Now:
would it not make a lot of sense to put doreti immediatly after
calltrap: in the same file
so that one could follow the entire picture without having to bounce back
and forth between two files?
(also gets rid of the jmp in the common case)
Julian
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0207051736540.14813-100000>
