summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2011-08-15 20:11:13 -0400
committerFrans Kaashoek <[email protected]>2011-08-15 20:11:13 -0400
commita4b213cf49cccc8287e638badaac10d0521d5886 (patch)
tree095d550b12eeb48d224193a7401e6793fe7c1d50
parent944964685325aa63a59e5e84d8fd0ba5af45ec8c (diff)
downloadxv6-labs-a4b213cf49cccc8287e638badaac10d0521d5886.tar.gz
xv6-labs-a4b213cf49cccc8287e638badaac10d0521d5886.tar.bz2
xv6-labs-a4b213cf49cccc8287e638badaac10d0521d5886.zip
Avoid "boot" in xv6
-rw-r--r--Makefile2
-rw-r--r--defs.h2
-rw-r--r--entry.S10
-rw-r--r--entryother.S10
-rw-r--r--kalloc.c6
-rw-r--r--lapic.c4
-rw-r--r--main.c50
-rw-r--r--mp.c2
-rw-r--r--proc.h2
-rw-r--r--sysproc.c2
-rw-r--r--vm.c4
11 files changed, 43 insertions, 51 deletions
diff --git a/Makefile b/Makefile
index a497992..f3983fb 100644
--- a/Makefile
+++ b/Makefile
@@ -110,7 +110,7 @@ initcode: initcode.S
$(OBJDUMP) -S initcode.o > initcode.asm
kernel: $(OBJS) entry.o data.o entryother initcode
- $(LD) $(LDFLAGS) -T kernel.ld -e multiboot_entry -o kernel entry.o data.o $(OBJS) -b binary initcode entryother
+ $(LD) $(LDFLAGS) -T kernel.ld -e entry -o kernel entry.o data.o $(OBJS) -b binary initcode entryother
$(OBJDUMP) -S kernel > kernel.asm
$(OBJDUMP) -t kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym
diff --git a/defs.h b/defs.h
index b1cdefb..e5a7ef4 100644
--- a/defs.h
+++ b/defs.h
@@ -62,7 +62,7 @@ extern uchar ioapicid;
void ioapicinit(void);
// kalloc.c
-char* boot_alloc(void);
+char* enter_alloc(void);
char* kalloc(void);
void kfree(char*);
void kinit(void);
diff --git a/entry.S b/entry.S
index 46fcca6..cf45bf3 100644
--- a/entry.S
+++ b/entry.S
@@ -34,17 +34,17 @@ multiboot_header:
.long multiboot_header
.long edata
.long end
- .long multiboot_entry
+ .long entry
-# Multiboot entry point. Machine is mostly set up.
-.globl multiboot_entry
-multiboot_entry:
+# Entering xv6 on boot processor. Machine is mostly set up.
+.globl entry
+entry:
# Turn on page size extension for 4Mbyte pages
movl %cr4, %eax
orl $(CR4_PSE), %eax
movl %eax, %cr4
# Set page directory
- movl $(V2P_WO(bootpgdir)), %eax
+ movl $(V2P_WO(enterpgdir)), %eax
movl %eax, %cr3
# Turn on paging.
movl %cr0, %eax
diff --git a/entryother.S b/entryother.S
index 56651e6..1dfbb1a 100644
--- a/entryother.S
+++ b/entryother.S
@@ -14,8 +14,8 @@
# Bootothers (in main.c) sends the STARTUPs one at a time.
# It copies this code (start) at 0x7000.
# It puts the address of a newly allocated per-core stack in start-4,
-# the address of the place to jump to (mpboot) in start-8, and the physical
-# address of bootpgdir in start-12.
+# the address of the place to jump to (mpenter) in start-8, and the physical
+# address of enterpgdir in start-12.
#
#
# This code is identical to bootasm.S except:
@@ -54,7 +54,7 @@ start32:
movl %cr4, %eax
orl $(CR4_PSE), %eax
movl %eax, %cr4
- # Use bootpgdir as our initial page table
+ # Use enterpgdir as our initial page table
movl (start-12), %eax
movl %eax, %cr3
# Turn on paging.
@@ -62,9 +62,9 @@ start32:
orl $(CR0_PE|CR0_PG|CR0_WP), %eax
movl %eax, %cr0
- # Switch to the stack allocated by enterothers()
+ # Switch to the stack allocated by startothers()
movl (start-4), %esp
- # Call mpboot()
+ # Call mpenter()
call *(start-8)
movw $0x8a00, %ax
diff --git a/kalloc.c b/kalloc.c
index cf89dd4..4cc4202 100644
--- a/kalloc.c
+++ b/kalloc.c
@@ -21,15 +21,15 @@ struct {
extern char end[]; // first address after kernel loaded from ELF file
char *newend;
-// simple page allocator to get off the ground during boot
+// simple page allocator to get off the ground during entry
char *
-boot_alloc(void)
+enter_alloc(void)
{
if (newend == 0)
newend = end;
if ((uint) newend >= KERNBASE + 0x400000)
- panic("only first 4Mbyte are mapped during boot");
+ panic("only first 4Mbyte are mapped during entry");
void *p = (void*)PGROUNDUP((uint)newend);
memset(p, 0, PGSIZE);
newend = newend + PGSIZE;
diff --git a/lapic.c b/lapic.c
index 7554f73..ef006a0 100644
--- a/lapic.c
+++ b/lapic.c
@@ -132,7 +132,7 @@ microdelay(int us)
#define IO_RTC 0x70
-// Start additional processor running bootstrap code at addr.
+// Start additional processor running entry code at addr.
// See Appendix B of MultiProcessor Specification.
void
@@ -158,7 +158,7 @@ lapicstartap(uchar apicid, uint addr)
lapicw(ICRLO, INIT | LEVEL);
microdelay(100); // should be 10ms, but too slow in Bochs!
- // Send startup IPI (twice!) to enter bootstrap code.
+ // Send startup IPI (twice!) to enter code.
// Regular hardware is supposed to only accept a STARTUP
// when it is in the halted state due to an INIT. So the second
// should be ignored, but it is part of the official Intel algorithm.
diff --git a/main.c b/main.c
index d4d677d..129a0e9 100644
--- a/main.c
+++ b/main.c
@@ -6,7 +6,7 @@
#include "proc.h"
#include "x86.h"
-static void enterothers(void);
+static void startothers(void);
static void mpmain(void) __attribute__((noreturn));
extern pde_t *kpgdir;
@@ -33,7 +33,7 @@ main(void)
ideinit(); // disk
if(!ismp)
timerinit(); // uniprocessor timer
- enterothers(); // start other processors (must come before kinit; must use boot_alloc)
+ startothers(); // start other processors (must come before kinit; must use enter_alloc)
kinit(); // initialize memory allocator
userinit(); // first user process (must come after kinit)
// Finish setting up this processor in mpmain.
@@ -42,7 +42,7 @@ main(void)
// Other CPUs jump here from entryother.S.
static void
-mpboot(void)
+mpenter(void)
{
switchkvm();
seginit();
@@ -56,22 +56,22 @@ mpmain(void)
{
cprintf("cpu%d: starting\n", cpu->id);
idtinit(); // load idt register
- xchg(&cpu->booted, 1); // tell enterothers() we're up
+ xchg(&cpu->started, 1); // tell startothers() we're up
scheduler(); // start running processes
}
-pde_t bootpgdir[];
+pde_t enterpgdir[];
-// Start the non-boot processors.
+// Start the non-boot (AP) processors.
static void
-enterothers(void)
+startothers(void)
{
extern uchar _binary_entryother_start[], _binary_entryother_size[];
uchar *code;
struct cpu *c;
char *stack;
- // Write bootstrap code to unused memory at 0x7000.
+ // Write entry code to unused memory at 0x7000.
// The linker has placed the image of entryother.S in
// _binary_entryother_start.
code = p2v(0x7000);
@@ -81,44 +81,36 @@ enterothers(void)
if(c == cpus+cpunum()) // We've started already.
continue;
- // Tell entryother.S what stack to use, the address of mpboot 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
- // memory, so we use bootpgdir for the APs too. kalloc can return addresses
+ // memory, so we use enterpgdir for the APs too. kalloc can return addresses
// above 4Mbyte (the machine may have much more physical memory than 4Mbyte), which
- // aren't mapped by bootpgdir, so we must allocate a stack using boot_alloc();
+ // aren't mapped by enterpgdir, so we must allocate a stack using enter_alloc();
// This introduces the constraint that xv6 cannot use kalloc until after these
- // last boot_alloc invocations.
- stack = boot_alloc();
+ // last enter_alloc invocations.
+ stack = enter_alloc();
*(void**)(code-4) = stack + KSTACKSIZE;
- *(void**)(code-8) = mpboot;
- *(int**)(code-12) = (void *) v2p(bootpgdir);
+ *(void**)(code-8) = mpenter;
+ *(int**)(code-12) = (void *) v2p(enterpgdir);
lapicstartap(c->id, v2p(code));
// wait for cpu to finish mpmain()
- while(c->booted == 0)
+ while(c->started == 0)
;
}
}
-// Boot page table used in multiboot.S and entryother.S.
+// Boot page table used in entry.S and entryother.S.
// Page directories (and page tables), must start on a page boundary,
-// hence the "__aligned__" attribute. Also, because of restrictions
-// related to linking and static initializers, we use "x + PTE_P"
-// here, rather than the more standard "x | PTE_P". Everywhere else
-// you should use "|" to combine flags.
+// hence the "__aligned__" attribute.
// Use PTE_PS in page directory entry to enable 4Mbyte pages.
-pte_t dev_pgtable[NPTENTRIES];
-pte_t entry_pgtable[NPTENTRIES];
-
__attribute__((__aligned__(PGSIZE)))
-pde_t bootpgdir[NPDENTRIES] = {
+pde_t enterpgdir[NPDENTRIES] = {
// 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)
- [KERNBASE>>PDXSHIFT]
- = (0) + PTE_P + PTE_W + PTE_PS,
+ [KERNBASE>>PDXSHIFT] = (0) + PTE_P + PTE_W + PTE_PS,
};
//PAGEBREAK!
diff --git a/mp.c b/mp.c
index d2791ea..5b52a98 100644
--- a/mp.c
+++ b/mp.c
@@ -1,4 +1,4 @@
-// Multiprocessor bootstrap.
+// Multiprocessor support
// Search memory for MP description structures.
// http://developer.intel.com/design/pentium/datashts/24201606.pdf
diff --git a/proc.h b/proc.h
index 2b30187..385a92f 100644
--- a/proc.h
+++ b/proc.h
@@ -7,7 +7,7 @@ struct cpu {
struct context *scheduler; // swtch() here to enter scheduler
struct taskstate ts; // Used by x86 to find stack for interrupt
struct segdesc gdt[NSEGS]; // x86 global descriptor table
- volatile uint booted; // Has the CPU started?
+ volatile uint started; // Has the CPU started?
int ncli; // Depth of pushcli nesting.
int intena; // Were interrupts enabled before pushcli?
diff --git a/sysproc.c b/sysproc.c
index 2a92c48..c66339e 100644
--- a/sysproc.c
+++ b/sysproc.c
@@ -77,7 +77,7 @@ sys_sleep(void)
}
// return how many clock tick interrupts have occurred
-// since boot.
+// since start.
int
sys_uptime(void)
{
diff --git a/vm.c b/vm.c
index 049a25e..aa7f659 100644
--- a/vm.c
+++ b/vm.c
@@ -12,7 +12,7 @@ pde_t *kpgdir; // for use in scheduler()
struct segdesc gdt[NSEGS];
// Set up CPU's kernel segment descriptors.
-// Run once at boot time on each CPU.
+// Run once on entry on each CPU.
void
seginit(void)
{
@@ -146,7 +146,7 @@ setupkvm(char* (*alloc)(void))
void
kvmalloc(void)
{
- kpgdir = setupkvm(boot_alloc);
+ kpgdir = setupkvm(enter_alloc);
switchkvm();
}