commit 78a1c79b59a1545fe6105ab3919a05c772c45873
parent 55ca7a8d1176fc6a03d9471870c949dd546ca424
Author: Brian Swetland <swetland@frotz.net>
Date: Mon, 30 Dec 2013 18:17:54 -0800
trap/vector/irq glue for the 64bit world
Diffstat:
2 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/kernel/trapasm64.S b/kernel/trapasm64.S
@@ -0,0 +1,46 @@
+
+ # vectors.S sends all traps here.
+.globl alltraps
+alltraps:
+ # Build trap frame.
+ push %r15
+ push %r14
+ push %r13
+ push %r12
+ push %r11
+ push %r10
+ push %r9
+ push %r8
+ push %rdi
+ push %rsi
+ push %rbp
+ push %rdx
+ push %rcx
+ push %rbx
+ push %rax
+
+ mov %rsp, %rdi # frame in arg1
+ call trap
+
+ # Return falls through to trapret...
+.globl trapret
+trapret:
+ pop %rax
+ pop %rbx
+ pop %rcx
+ pop %rdx
+ pop %rbp
+ pop %rsi
+ pop %rdi
+ pop %r8
+ pop %r9
+ pop %r10
+ pop %r11
+ pop %r12
+ pop %r13
+ pop %r14
+ pop %r15
+
+ # discard trapnum and errorcode
+ add $16, %rsp
+ iretq
diff --git a/tools/vectors64.pl b/tools/vectors64.pl
@@ -0,0 +1,27 @@
+#!/usr/bin/perl -w
+
+# Generate vectors.S, the trap/interrupt entry points.
+# There has to be one entry point per interrupt number
+# since otherwise there's no way for trap() to discover
+# the interrupt number.
+
+print "# generated by vectors.pl - do not edit\n";
+print "# handlers\n";
+print ".globl alltraps\n";
+for(my $i = 0; $i < 256; $i++){
+ print ".globl vector$i\n";
+ print "vector$i:\n";
+ if(!($i == 8 || ($i >= 10 && $i <= 14) || $i == 17)){
+ print " push \$0\n";
+ }
+ print " push \$$i\n";
+ print " jmp alltraps\n";
+}
+
+print "\n# vector table\n";
+print ".data\n";
+print ".globl vectors\n";
+print "vectors:\n";
+for(my $i = 0; $i < 256; $i++){
+ print " .quad vector$i\n";
+}