Skip to content

Commit

Permalink
Separate more clearly bootloader from xv6 by renaming multiboot.S to …
Browse files Browse the repository at this point in the history
…entry.S etc.

Maybe the string boot shouldn't appear in xv6 code?
  • Loading branch information
Frans Kaashoek committed Aug 15, 2011
1 parent c95ce31 commit c60a355
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,20 @@ bootblock: bootasm.S bootmain.c
$(OBJCOPY) -S -O binary -j .text bootblock.o bootblock
./sign.pl bootblock

bootother: bootother.S
$(CC) $(CFLAGS) -fno-pic -nostdinc -I. -c bootother.S
$(LD) $(LDFLAGS) -N -e start -Ttext 0x7000 -o bootblockother.o bootother.o
$(OBJCOPY) -S -O binary -j .text bootblockother.o bootother
$(OBJDUMP) -S bootblockother.o > bootother.asm
entryother: entryother.S
$(CC) $(CFLAGS) -fno-pic -nostdinc -I. -c entryother.S
$(LD) $(LDFLAGS) -N -e start -Ttext 0x7000 -o bootblockother.o entryother.o
$(OBJCOPY) -S -O binary -j .text bootblockother.o entryother
$(OBJDUMP) -S bootblockother.o > entryother.asm

initcode: initcode.S
$(CC) $(CFLAGS) -nostdinc -I. -c initcode.S
$(LD) $(LDFLAGS) -N -e start -Ttext 0 -o initcode.out initcode.o
$(OBJCOPY) -S -O binary initcode.out initcode
$(OBJDUMP) -S initcode.o > initcode.asm

kernel: $(OBJS) multiboot.o data.o bootother initcode
$(LD) $(LDFLAGS) -T kernel.ld -e multiboot_entry -o kernel multiboot.o data.o $(OBJS) -b binary initcode bootother
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
$(OBJDUMP) -S kernel > kernel.asm
$(OBJDUMP) -t kernel | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym

Expand All @@ -121,12 +121,12 @@ kernel: $(OBJS) multiboot.o data.o bootother initcode
# great for testing the kernel on real hardware without
# needing a scratch disk.
MEMFSOBJS = $(filter-out ide.o,$(OBJS)) memide.o
kernelmemfs: $(MEMFSOBJS) multiboot.o data.o bootother initcode fs.img
$(LD) $(LDFLAGS) -Ttext 0x100000 -e main -o kernelmemfs multiboot.o data.o $(MEMFSOBJS) -b binary initcode bootother fs.img
kernelmemfs: $(MEMFSOBJS) entry.o data.o entryother initcode fs.img
$(LD) $(LDFLAGS) -Ttext 0x100000 -e main -o kernelmemfs entry.o data.o $(MEMFSOBJS) -b binary initcode entryother fs.img
$(OBJDUMP) -S kernelmemfs > kernelmemfs.asm
$(OBJDUMP) -t kernelmemfs | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernelmemfs.sym

tags: $(OBJS) bootother.S _init
tags: $(OBJS) entryother.S _init
etags *.S *.c

vectors.S: vectors.pl
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion bootother.S → entryother.S
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ start32:
orl $(CR0_PE|CR0_PG|CR0_WP), %eax
movl %eax, %cr0

# Switch to the stack allocated by bootothers()
# Switch to the stack allocated by entryothers()
movl (start-4), %esp
# Call mpboot()
call *(start-8)
Expand Down
22 changes: 11 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "proc.h"
#include "x86.h"

static void bootothers(void);
static void enterothers(void);
static void mpmain(void) __attribute__((noreturn));
extern pde_t *kpgdir;

Expand All @@ -33,14 +33,14 @@ main(void)
ideinit(); // disk
if(!ismp)
timerinit(); // uniprocessor timer
bootothers(); // start other processors (must come before kinit; must use boot_alloc)
enterothers(); // start other processors (must come before kinit; must use boot_alloc)
kinit(); // initialize memory allocator
userinit(); // first user process (must come after kinit)
// Finish setting up this processor in mpmain.
mpmain();
}

// Other CPUs jump here from bootother.S.
// Other CPUs jump here from entryother.S.
static void
mpboot(void)
{
Expand All @@ -56,32 +56,32 @@ mpmain(void)
{
cprintf("cpu%d: starting\n", cpu->id);
idtinit(); // load idt register
xchg(&cpu->booted, 1); // tell bootothers() we're up
xchg(&cpu->booted, 1); // tell enterothers() we're up
scheduler(); // start running processes
}

pde_t bootpgdir[];

// Start the non-boot processors.
static void
bootothers(void)
enterothers(void)
{
extern uchar _binary_bootother_start[], _binary_bootother_size[];
extern uchar _binary_entryother_start[], _binary_entryother_size[];
uchar *code;
struct cpu *c;
char *stack;

// Write bootstrap code to unused memory at 0x7000.
// The linker has placed the image of bootother.S in
// _binary_bootother_start.
// The linker has placed the image of entryother.S in
// _binary_entryother_start.
code = p2v(0x7000);
memmove(code, _binary_bootother_start, (uint)_binary_bootother_size);
memmove(code, _binary_entryother_start, (uint)_binary_entryother_size);

for(c = cpus; c < cpus+ncpu; c++){
if(c == cpus+cpunum()) // We've started already.
continue;

// Tell bootother.S what stack to use, the address of mpboot and pgdir;
// Tell entryother.S what stack to use, the address of mpboot 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
// above 4Mbyte (the machine may have much more physical memory than 4Mbyte), which
Expand All @@ -101,7 +101,7 @@ bootothers(void)
}
}

// Boot page table used in multiboot.S and bootother.S.
// Boot page table used in multiboot.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"
Expand Down

0 comments on commit c60a355

Please sign in to comment.