]> Devi Nivas Git - cs3210-lab0.git/commitdiff
fix some trap bugs
authorrtm <rtm>
Tue, 13 Jun 2006 22:08:20 +0000 (22:08 +0000)
committerrtm <rtm>
Tue, 13 Jun 2006 22:08:20 +0000 (22:08 +0000)
Notes
main.c
trap.c
vectors.pl

diff --git a/Notes b/Notes
index cee3b3d9f79bd3974d6248af5660226811233aee..4c06e746963a7592396c3e67ccf9e00d67359b3d 100644 (file)
--- a/Notes
+++ b/Notes
@@ -73,3 +73,9 @@ setupsegs() may modify current segment table, is that legal?
 trap() ought to lgdt on return, since currently only done in swtch()
 
 protect hardware interrupt vectors from user INT instructions?
+
+i'm getting a curious interrupt when jumping into user space. maybe
+it's IRQ 0, but it comes at a weird and changing vector (e.g. 119) if
+you don't initialize the PIC. why doesn't jos see this? if i
+initialize the PIC with IRQ_OFFSET 32, the interrupt arrives at vector
+32.
diff --git a/main.c b/main.c
index 7c3677ec3a78ee264e923239b7d2df70268c04ea..3c75389316f52717a35e9663d177900b549ee8c5 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,12 +5,20 @@
 #include "defs.h"
 #include "x86.h"
 
-char junk1[20000];
-char junk2[20000] = { 1 };
+extern char edata[], end[];
 
 main()
 {
   struct proc *p;
+  
+  // clear BSS
+  memset(edata, 0, end - edata);
+
+  // partially initizialize PIC
+  outb(0x20+1, 0xFF); // IO_PIC1
+  outb(0xA0+1, 0xFF); // IO_PIC2
+  outb(0x20, 0x11);
+  outb(0x20+1, 32);
 
   cprintf("\nxV6\n\n");
 
diff --git a/trap.c b/trap.c
index 9d867fee12f24d65916a38ae82fabdb104b98af1..ace4c95fe7d1bea9d224885cf3fa0aafd6f06e30 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -12,11 +12,15 @@ extern unsigned vectors[]; /* vectors.S, array of 256 entry point addresses */
 extern void trapenter();
 extern void trapenter1();
 
+
+int xx;
+
 void
 tinit()
 {
   int i;
 
+  xx = 0;
   for(i = 0; i < 256; i++){
     SETGATE(idt[i], 1, SEG_KCODE << 3, vectors[i], 3);
   }
@@ -27,8 +31,10 @@ void
 trap(struct Trapframe *tf)
 {
   /* which process are we running? */
-  cprintf("trap %d tf %x\n", tf->tf_trapno, tf);
-  while(1)
-    ;
+  if(xx < 10)
+    cprintf("%d\n", tf->tf_trapno);
+  xx++;
+  //while(1)
+  //;
   // XXX probably ought to lgdt on trap return
 }
index 29187ba171d7c8b5242eff8ab98599a20840c630..9438b2dfa3dc11238ff82989566e7b83c22ee1af 100755 (executable)
@@ -14,7 +14,7 @@ for(my $i = 0; $i < 256; $i++){
     if(($i < 8 || $i > 14) && $i != 17){
         print "\tpushl \$0\n";
     }
-    print "\tpushl $i\n";
+    print "\tpushl \$$i\n";
     print "\tjmp alltraps\n";
 }
 print ".data\n";