From owner-freebsd-current Fri Jul 5 18: 0:25 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1578537B400 for ; Fri, 5 Jul 2002 18:00:17 -0700 (PDT) Received: from sccrmhc01.attbi.com (sccrmhc01.attbi.com [204.127.202.61]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8261043E09 for ; Fri, 5 Jul 2002 18:00:16 -0700 (PDT) (envelope-from julian@elischer.org) Received: from InterJet.elischer.org ([12.232.206.8]) by sccrmhc01.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020706010015.NZPH29588.sccrmhc01.attbi.com@InterJet.elischer.org>; Sat, 6 Jul 2002 01:00:15 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id RAA15609; Fri, 5 Jul 2002 17:43:27 -0700 (PDT) Date: Fri, 5 Jul 2002 17:43:26 -0700 (PDT) From: Julian Elischer To: Peter Wemm Cc: FreeBSD current users Subject: i386 trap code Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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