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