Debian Codegraph @

i386/i386at/int_init.c

raw
1 /*
2 * Copyright (c) 1994 The University of Utah and
3 * the Computer Systems Laboratory at the University of Utah (CSL).
4 * All rights reserved.
5 *
6 * Permission to use, copy, modify and distribute this software is hereby
7 * granted provided that (1) source code retains these copyright, permission,
8 * and disclaimer notices, and (2) redistributions including binaries
9 * reproduce the notices in supporting documentation, and (3) all advertising
10 * materials mentioning features or use of this software display the following
11 * acknowledgement: ``This product includes software developed by the
12 * Computer Systems Laboratory at the University of Utah.''
13 *
14 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
15 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
16 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * CSL requests users of this software to return to [email protected] any
19 * improvements that they make and grant CSL redistribution rights.
20 *
21 * Author: Bryan Ford, University of Utah CSL
22 */
23
24 #include <i386at/idt.h>
25 #include <i386at/int_init.h>
26 #include <i386/gdt.h>
27 #include <i386/mp_desc.h>
28 #include <kern/printf.h>
29 #ifdef APIC
30 #include <i386/apic.h>
31 #endif
32
33 /* defined in locore.S */
34 extern vm_offset_t int_entry_table[];
35
36 static void
37 int_fill(struct real_gate *myidt)
38 {
39 int i;
40 #ifndef APIC
41 int base = PIC_INT_BASE;
42 int nirq = 16;
43 #else
44 int base = IOAPIC_INT_BASE;
45 int nirq = NINTR;
46 #endif
47
48 for (i = 0; i < nirq; i++) {
49 fill_idt_gate(myidt, base + i,
50 int_entry_table[i], KERNEL_CS,
51 ACC_PL_K|ACC_INTR_GATE, 0);
52 }
53 #if NCPUS > 1
54 fill_idt_gate(myidt, CALL_AST_CHECK,
55 int_entry_table[i], KERNEL_CS,
56 ACC_PL_K|ACC_INTR_GATE, 0);
57 i++;
58 fill_idt_gate(myidt, CALL_PMAP_UPDATE,
59 int_entry_table[i], KERNEL_CS,
60 ACC_PL_K|ACC_INTR_GATE, 0);
61 i++;
62 #endif
63 #ifdef APIC
64 fill_idt_gate(myidt, IOAPIC_SPURIOUS_BASE,
65 int_entry_table[i], KERNEL_CS,
66 ACC_PL_K|ACC_INTR_GATE, 0);
67 i++;
68 #endif
69 }
70
71 void
72 int_init(void)
73 {
74 int_fill(idt);
75 }
76
77 #if NCPUS > 1
78 void ap_int_init(int cpu)
79 {
80 int_fill(mp_desc_table[cpu]->idt);
81 }
82 #endif