xv6

port of xv6 to x86-64
git clone http://frotz.net/git/xv6.git
Log | Files | Refs | README | LICENSE

vectors.pl (989B)


      1 #!/usr/bin/perl -w
      2 
      3 # Generate vectors.S, the trap/interrupt entry points.
      4 # There has to be one entry point per interrupt number
      5 # since otherwise there's no way for trap() to discover
      6 # the interrupt number.
      7 
      8 print "# generated by vectors.pl - do not edit\n";
      9 print "# handlers\n";
     10 print ".globl alltraps\n";
     11 for(my $i = 0; $i < 256; $i++){
     12     print ".globl vector$i\n";
     13     print "vector$i:\n";
     14     if(!($i == 8 || ($i >= 10 && $i <= 14) || $i == 17)){
     15         print "  pushl \$0\n";
     16     }
     17     print "  pushl \$$i\n";
     18     print "  jmp alltraps\n";
     19 }
     20 
     21 print "\n# vector table\n";
     22 print ".data\n";
     23 print ".globl vectors\n";
     24 print "vectors:\n";
     25 for(my $i = 0; $i < 256; $i++){
     26     print "  .long vector$i\n";
     27 }
     28 
     29 # sample output:
     30 #   # handlers
     31 #   .globl alltraps
     32 #   .globl vector0
     33 #   vector0:
     34 #     pushl $0
     35 #     pushl $0
     36 #     jmp alltraps
     37 #   ...
     38 #   
     39 #   # vector table
     40 #   .data
     41 #   .globl vectors
     42 #   vectors:
     43 #     .long vector0
     44 #     .long vector1
     45 #     .long vector2
     46 #   ...
     47