enterpgdir -> entrypgdir

This commit is contained in:
Robert Morris 2011-08-30 20:50:19 -04:00
parent 1ddfbbb194
commit 5e08357827
3 changed files with 24 additions and 11 deletions

View file

@ -44,11 +44,11 @@ entry:
orl $(CR4_PSE), %eax orl $(CR4_PSE), %eax
movl %eax, %cr4 movl %eax, %cr4
# Set page directory # Set page directory
movl $(V2P_WO(enterpgdir)), %eax movl $(V2P_WO(entrypgdir)), %eax
movl %eax, %cr3 movl %eax, %cr3
# Turn on paging. # Turn on paging.
movl %cr0, %eax movl %cr0, %eax
orl $(CR0_PE|CR0_PG|CR0_WP), %eax orl $(CR0_PG|CR0_WP), %eax
movl %eax, %cr0 movl %eax, %cr0
# now switch to using addresses above KERNBASE # now switch to using addresses above KERNBASE

10
main.c
View file

@ -60,7 +60,7 @@ mpmain(void)
scheduler(); // start running processes scheduler(); // start running processes
} }
pde_t enterpgdir[]; // For entry.S pde_t entrypgdir[]; // For entry.S
// Start the non-boot (AP) processors. // Start the non-boot (AP) processors.
static void static void
@ -83,15 +83,15 @@ startothers(void)
// Tell entryother.S what stack to use, the address of mpenter and pgdir; // Tell entryother.S what stack to use, the address of mpenter and pgdir;
// We cannot use kpgdir yet, because the AP processor is running in low // We cannot use kpgdir yet, because the AP processor is running in low
// memory, so we use enterpgdir for the APs too. kalloc can return addresses // memory, so we use entrypgdir for the APs too. kalloc can return addresses
// above 4Mbyte (the machine may have much more physical memory than 4Mbyte), which // above 4Mbyte (the machine may have much more physical memory than 4Mbyte), which
// aren't mapped by enterpgdir, so we must allocate a stack using enter_alloc(); // aren't mapped by entrypgdir, so we must allocate a stack using enter_alloc();
// This introduces the constraint that xv6 cannot use kalloc until after these // This introduces the constraint that xv6 cannot use kalloc until after these
// last enter_alloc invocations. // last enter_alloc invocations.
stack = enter_alloc(); stack = enter_alloc();
*(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-4) = stack + KSTACKSIZE;
*(void**)(code-8) = mpenter; *(void**)(code-8) = mpenter;
*(int**)(code-12) = (void *) v2p(enterpgdir); *(int**)(code-12) = (void *) v2p(entrypgdir);
lapicstartap(c->id, v2p(code)); lapicstartap(c->id, v2p(code));
@ -106,7 +106,7 @@ startothers(void)
// hence the "__aligned__" attribute. // hence the "__aligned__" attribute.
// Use PTE_PS in page directory entry to enable 4Mbyte pages. // Use PTE_PS in page directory entry to enable 4Mbyte pages.
__attribute__((__aligned__(PGSIZE))) __attribute__((__aligned__(PGSIZE)))
pde_t enterpgdir[NPDENTRIES] = { pde_t entrypgdir[NPDENTRIES] = {
// Map VA's [0, 4MB) to PA's [0, 4MB) // Map VA's [0, 4MB) to PA's [0, 4MB)
[0] = (0) + PTE_P + PTE_W + PTE_PS, [0] = (0) + PTE_P + PTE_W + PTE_PS,
// Map VA's [KERNBASE, KERNBASE+4MB) to PA's [0, 4MB) // Map VA's [KERNBASE, KERNBASE+4MB) to PA's [0, 4MB)

View file

@ -1,3 +1,4 @@
#include "param.h"
#include "types.h" #include "types.h"
#include "stat.h" #include "stat.h"
#include "user.h" #include "user.h"
@ -240,8 +241,10 @@ pipe1(void)
if(cc > sizeof(buf)) if(cc > sizeof(buf))
cc = sizeof(buf); cc = sizeof(buf);
} }
if(total != 5 * 1033) if(total != 5 * 1033){
printf(1, "pipe1 oops 3 total %d\n", total); printf(1, "pipe1 oops 3 total %d\n", total);
exit();
}
close(fds[0]); close(fds[0]);
wait(); wait();
} else { } else {
@ -401,10 +404,12 @@ sharedfd(void)
} }
close(fd); close(fd);
unlink("sharedfd"); unlink("sharedfd");
if(nc == 10000 && np == 10000) if(nc == 10000 && np == 10000){
printf(1, "sharedfd ok\n"); printf(1, "sharedfd ok\n");
else } else {
printf(1, "sharedfd oops %d %d\n", nc, np); printf(1, "sharedfd oops %d %d\n", nc, np);
exit();
}
} }
// two processes write two different files at the same // two processes write two different files at the same
@ -423,7 +428,7 @@ twofiles(void)
pid = fork(); pid = fork();
if(pid < 0){ if(pid < 0){
printf(1, "fork failed\n"); printf(1, "fork failed\n");
return; exit();
} }
fname = pid ? "f1" : "f2"; fname = pid ? "f1" : "f2";
@ -1582,6 +1587,14 @@ fsfull()
printf(1, "fsfull test finished\n"); printf(1, "fsfull test finished\n");
} }
unsigned long randstate = 1;
unsigned int
rand()
{
randstate = randstate * 1664525 + 1013904223;
return randstate;
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {