Skip to content

Commit

Permalink
Use static page table for boot, mapping first 4Mbyte; no more segment…
Browse files Browse the repository at this point in the history
… trick

Allocate proper kernel page table immediately in main using boot allocator
Remove pginit
Simplify address space layout a tiny bit
More to come (e.g., superpages to simplify static table)
  • Loading branch information
Frans Kaashoek committed Aug 10, 2011
1 parent 3a03810 commit 66ba807
Show file tree
Hide file tree
Showing 9 changed files with 1,101 additions and 103 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ AS = $(TOOLPREFIX)gas
LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer
#CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
ASFLAGS = -m32 -gdwarf-2 -Wa,-divide
# FreeBSD ld wants ``elf_i386_fbsd''
Expand Down Expand Up @@ -198,7 +199,7 @@ QEMUGDB = $(shell if $(QEMU) -help | grep -q '^-gdb'; \
then echo "-gdb tcp::$(GDBPORT)"; \
else echo "-s -p $(GDBPORT)"; fi)
ifndef CPUS
CPUS := 2
CPUS := 1
endif
QEMUOPTS = -hdb fs.img xv6.img -smp $(CPUS) -m 512

Expand Down
5 changes: 2 additions & 3 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern uchar ioapicid;
void ioapicinit(void);

// kalloc.c
char* pgalloc(void);
char* boot_alloc(void);
char* kalloc(void);
void kfree(char*);
void kinit(void);
Expand Down Expand Up @@ -161,11 +161,10 @@ void uartintr(void);
void uartputc(int);

// vm.c
void pginit(char* (*alloc)());
void seginit(void);
void kvmalloc(void);
void vmenable(void);
pde_t* setupkvm(void);
pde_t* setupkvm(char* (*alloc)());
char* uva2ka(pde_t*, char*);
int allocuvm(pde_t*, uint, uint);
int deallocuvm(pde_t*, uint, uint);
Expand Down
2 changes: 1 addition & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exec(char *path, char **argv)
if(elf.magic != ELF_MAGIC)
goto bad;

if((pgdir = setupkvm()) == 0)
if((pgdir = setupkvm(kalloc)) == 0)
goto bad;

// Load program into memory.
Expand Down
4 changes: 3 additions & 1 deletion kalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ char *newend;

// simple page allocator to get off the ground during boot
char *
pgalloc(void)
boot_alloc(void)
{
if (newend == 0)
newend = end;

if ((uint) newend >= KERNBASE + 0x400000)
panic("only first 4Mbyte are mapped during boot");
void *p = (void*)PGROUNDUP((uint)newend);
memset(p, 0, PGSIZE);
newend = newend + PGSIZE;
Expand Down
Loading

0 comments on commit 66ba807

Please sign in to comment.