diff options
Diffstat (limited to 'bootmain.c')
-rw-r--r-- | bootmain.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -9,16 +9,16 @@ * DISK LAYOUT * * This program(boot.S and main.c) is the bootloader. It should * be stored in the first sector of the disk. - * + * * * The 2nd sector onward holds the kernel image. - * + * * * The kernel image must be in ELF format. * - * BOOT UP STEPS + * BOOT UP STEPS * * when the CPU boots it loads the BIOS into memory and executes it * * * the BIOS intializes devices, sets of the interrupt routines, and - * reads the first sector of the boot device(e.g., hard-drive) + * reads the first sector of the boot device(e.g., hard-drive) * into memory and jumps to it. * * * Assuming this boot loader is stored in the first sector of the @@ -31,7 +31,7 @@ **********************************************************************/ #define SECTSIZE 512 -#define ELFHDR ((struct elfhdr *) 0x10000) // scratch space +#define ELFHDR ((struct elfhdr*) 0x10000) // scratch space void readsect(void*, uint); void readseg(uint, uint, uint); @@ -45,18 +45,18 @@ cmain(void) readseg((uint) ELFHDR, SECTSIZE*8, 0); // is this a valid ELF? - if (ELFHDR->magic != ELF_MAGIC) + if(ELFHDR->magic != ELF_MAGIC) goto bad; // load each program segment (ignores ph flags) - ph = (struct proghdr *) ((uchar *) ELFHDR + ELFHDR->phoff); + ph = (struct proghdr*) ((uchar*) ELFHDR + ELFHDR->phoff); eph = ph + ELFHDR->phnum; - for (; ph < eph; ph++) + for(; ph < eph; ph++) readseg(ph->va, ph->memsz, ph->offset); // call the entry point from the ELF header // note: does not return! - ((void (*)(void)) (ELFHDR->entry & 0xFFFFFF))(); + ((void(*)(void)) (ELFHDR->entry & 0xFFFFFF))(); bad: outw(0x8A00, 0x8A00); @@ -74,7 +74,7 @@ readseg(uint va, uint count, uint offset) va &= 0xFFFFFF; end_va = va + count; - + // round down to sector boundary va &= ~(SECTSIZE - 1); @@ -84,7 +84,7 @@ readseg(uint va, uint count, uint offset) // If this is too slow, we could read lots of sectors at a time. // We'd write more to memory than asked, but it doesn't matter -- // we load in increasing order. - while (va < end_va) { + while(va < end_va) { readsect((uchar*) va, offset); va += SECTSIZE; offset++; @@ -95,7 +95,7 @@ void waitdisk(void) { // wait for disk reaady - while ((inb(0x1F7) & 0xC0) != 0x40) + while((inb(0x1F7) & 0xC0) != 0x40) /* do nothing */; } |