Redo makefiles.
[pintos-anon] / src / threads / intr-stubs.pl
1 #! /usr/bin/perl
2
3 print <<'EOF';
4 #include "threads/loader.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 ".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         # Save caller's registers.
35         pushl %ds
36         pushl %es
37         pushal
38
39         # Set up kernel environment.
40         cld
41         movl $SEL_KDSEG, %eax
42         movl %eax, %ds
43         movl %eax, %es
44
45         # Call interrupt handler.
46         pushl %esp
47 .globl intr_handler
48         call intr_handler
49         addl $4, %esp
50
51 .globl intr_exit
52 intr_exit:
53         # Restore caller's registers.
54         popal
55         popl %es
56         popl %ds
57         addl $8, %esp
58
59         # Return to caller.
60         iret
61 EOF