]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i386/isa/ipl.s
Use the MI ithread helper functions in the x86 interrupt code.
[FreeBSD/FreeBSD.git] / sys / i386 / isa / ipl.s
1 /*-
2  * Copyright (c) 1989, 1990 William F. Jolitz.
3  * Copyright (c) 1990 The Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * William Jolitz.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by the University of
20  *      California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *      @(#)ipl.s
38  *
39  * $FreeBSD$
40  */
41
42
43 /*
44  * AT/386
45  * Vector interrupt control section
46  */
47
48         .text
49
50 /*
51  * void doreti(struct trapframe)
52  *
53  * Handle return from interrupts, traps and syscalls.
54  */
55         SUPERALIGN_TEXT
56         .type   _doreti,@function
57 _doreti:
58         FAKE_MCOUNT(_bintr)             /* init "from" _bintr -> _doreti */
59 doreti_next:
60         /* Check for ASTs that can be handled now. */
61         testl   $AST_PENDING,PCPU(ASTPENDING)
62         je      doreti_exit             /* no AST, exit */
63         testb   $SEL_RPL_MASK,TF_CS(%esp)  /* are we in user mode? */
64         jne     doreti_ast              /* yes, do it now. */
65         testl   $PSL_VM,TF_EFLAGS(%esp) /* kernel mode */
66         je      doreti_exit             /* and not VM86 mode, defer */
67         cmpl    $1,_in_vm86call         /* are we in a VM86 call? */
68         jne     doreti_ast              /* yes, we can do it */
69
70         /*
71          * doreti_exit: release MP lock, pop registers, iret.
72          *
73          *      Note that the syscall trap shortcuts to doreti_syscall_ret.
74          *      The segment register pop is a special case, since it may
75          *      fault if (for example) a sigreturn specifies bad segment
76          *      registers.  The fault is handled in trap.c.
77          */
78 doreti_exit:
79         MEXITCOUNT
80
81         .globl  doreti_popl_fs
82         .globl  doreti_syscall_ret
83 doreti_syscall_ret:
84 doreti_popl_fs:
85         popl    %fs
86         .globl  doreti_popl_es
87 doreti_popl_es:
88         popl    %es
89         .globl  doreti_popl_ds
90 doreti_popl_ds:
91         popl    %ds
92         popal
93         addl    $8,%esp
94         .globl  doreti_iret
95 doreti_iret:
96         iret
97
98         /*
99          * doreti_iret_fault and friends.  Alternative return code for
100          * the case where we get a fault in the doreti_exit code
101          * above.  trap() (i386/i386/trap.c) catches this specific
102          * case, sends the process a signal and continues in the
103          * corresponding place in the code below.
104          */
105         ALIGN_TEXT
106         .globl  doreti_iret_fault
107 doreti_iret_fault:
108         subl    $8,%esp
109         pushal
110         pushl   %ds
111         .globl  doreti_popl_ds_fault
112 doreti_popl_ds_fault:
113         pushl   %es
114         .globl  doreti_popl_es_fault
115 doreti_popl_es_fault:
116         pushl   %fs
117         .globl  doreti_popl_fs_fault
118 doreti_popl_fs_fault:
119         movl    $0,TF_ERR(%esp) /* XXX should be the error code */
120         movl    $T_PROTFLT,TF_TRAPNO(%esp)
121         jmp     alltraps_with_regs_pushed
122
123         ALIGN_TEXT
124 doreti_ast:
125         andl    $~AST_PENDING,PCPU(ASTPENDING)
126         sti
127         movl    $T_ASTFLT,TF_TRAPNO(%esp)
128         call    _ast
129         jmp     doreti_next
130
131 #ifdef APIC_IO
132 #include "i386/isa/apic_ipl.s"
133 #else
134 #include "i386/isa/icu_ipl.s"
135 #endif /* APIC_IO */