summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-08-10 22:08:14 +0000
committerrtm <rtm>2006-08-10 22:08:14 +0000
commit5be0039ce9e22f140a29e167526c64c723c5be3c (patch)
tree4096ed2b728cbee37dd2adee06e83f0e908f72b6 /main.c
parent8a8be1b8c36e38f58f8ba3e425b6e701ad65abf3 (diff)
downloadxv6-labs-5be0039ce9e22f140a29e167526c64c723c5be3c.tar.gz
xv6-labs-5be0039ce9e22f140a29e167526c64c723c5be3c.tar.bz2
xv6-labs-5be0039ce9e22f140a29e167526c64c723c5be3c.zip
interrupts could be recursive since lapic_eoi() called before rti
so fast interrupts overflow the kernel stack fix: cli() before lapic_eoi()
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/main.c b/main.c
index b558e41..a7209b6 100644
--- a/main.c
+++ b/main.c
@@ -15,8 +15,6 @@ extern uchar _binary_user1_start[], _binary_user1_size[];
extern uchar _binary_usertests_start[], _binary_usertests_size[];
extern uchar _binary_userfs_start[], _binary_userfs_size[];
-extern int use_console_lock;
-
// CPU 0 starts running C code here.
// This is called main0 not main so that it can have
// a void return type. Gcc can't handle functions named
@@ -27,28 +25,36 @@ main0(void)
int i;
struct proc *p;
+ lcr4(0); // xxx copy of cpu #
+
// clear BSS
memset(edata, 0, end - edata);
// Make sure interrupts stay disabled on all processors
// until each signals it is ready, by pretending to hold
// an extra lock.
- for(i=0; i<NCPU; i++)
+ // xxx maybe replace w/ acquire remembering if FL_IF
+ for(i=0; i<NCPU; i++){
cpus[i].nlock++;
+ cpus[i].guard1 = 0xdeadbeef;
+ cpus[i].guard2 = 0xdeadbeef;
+ }
mp_init(); // collect info about this machine
- use_console_lock = 1;
-
lapic_init(mp_bcpu());
cprintf("\n\ncpu%d: booting xv6\n\n", cpu());
+ pinit();
+ binit();
pic_init(); // initialize PIC
ioapic_init();
kinit(); // physical memory allocator
tvinit(); // trap vectors
idtinit(); // this CPU's idt register
+ fd_init();
+ iinit();
// create a fake process per CPU
// so each CPU always has a tss and a gdt
@@ -101,6 +107,8 @@ main0(void)
void
mpmain(void)
{
+ lcr4(1); // xxx copy of cpu #
+
cprintf("cpu%d: starting\n", cpu());
idtinit(); // CPU's idt
if(cpu() == 0)