9725860b24b297b70175cbaac1618a200f153e0b
[pintos-anon] / src / threads / intr-stubs.pl
1 #! /usr/bin/perl
2
3 print <<'EOF';
4 #include "mmu.h"
5
6         .data
7         .globl intr_stubs
8 intr_stubs:
9 EOF
10
11 for $i (0...255) {
12     $x = sprintf ("%02x", $i);
13     print "\t.long intr${x}_stub\n";
14 }
15
16 print <<'EOF';
17
18         .text
19 EOF
20
21 for $i (0...255) {
22     $x = sprintf ("%02x", $i);
23     print "\t.globl intr${x}_stub\n";
24     print "intr${x}_stub:\n";
25     print "\tpushl \$0\n"
26         if ($i != 8 && $i != 10 && $i != 11
27             && $i != 13 && $i != 14 && $i != 17);
28     print "\tpushl \$0x$x\n";
29     print "\tjmp intr_entry\n";
30 }
31
32 print <<'EOF';
33 intr_entry:
34         # FIXME: build a fake stack frame to improve backtraces.
35         # Save caller's registers.
36         pushl %ds
37         pushl %es
38         pushal
39
40         # Set up kernel environment.
41         cld
42         movl $SEL_KDSEG, %eax
43         movl %eax, %ds
44         movl %eax, %es
45
46         # Call handler.
47         pushl %esp
48         .globl intr_handler
49         call intr_handler
50         addl $4, %esp
51
52         .globl intr_exit
53 intr_exit:
54
55         # Restore caller's registers.
56         popal
57         popl %es
58         popl %ds
59         addl $8, %esp
60         iret
61 EOF