diff options
Diffstat (limited to 'bootmain.c')
-rw-r--r-- | bootmain.c | 55 |
1 files changed, 28 insertions, 27 deletions
@@ -25,6 +25,7 @@ // * cmain() in this file takes over, // reads in the kernel and jumps to it. +//PAGEBREAK! #include "types.h" #include "elf.h" #include "x86.h" @@ -32,7 +33,6 @@ #define SECTSIZE 512 #define ELFHDR ((struct elfhdr*) 0x10000) // scratch space -void readsect(void*, uint); void readseg(uint, uint, uint); void @@ -64,32 +64,6 @@ bad: ; } -// Read 'count' bytes at 'offset' from kernel into virtual address 'va'. -// Might copy more than asked -void -readseg(uint va, uint count, uint offset) -{ - uint end_va; - - va &= 0xFFFFFF; - end_va = va + count; - - // round down to sector boundary - va &= ~(SECTSIZE - 1); - - // translate from bytes to sectors, and kernel starts at sector 1 - offset = (offset / SECTSIZE) + 1; - - // 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) { - readsect((uchar*) va, offset); - va += SECTSIZE; - offset++; - } -} - void waitdisk(void) { @@ -98,6 +72,7 @@ waitdisk(void) ; } +// Read a single sector at offset into dst. void readsect(void *dst, uint offset) { @@ -118,3 +93,29 @@ readsect(void *dst, uint offset) insl(0x1F0, dst, SECTSIZE/4); } +// Read 'count' bytes at 'offset' from kernel into virtual address 'va'. +// Might copy more than asked. +void +readseg(uint va, uint count, uint offset) +{ + uint end_va; + + va &= 0xFFFFFF; + end_va = va + count; + + // round down to sector boundary + va &= ~(SECTSIZE - 1); + + // translate from bytes to sectors, and kernel starts at sector 1 + offset = (offset / SECTSIZE) + 1; + + // 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) { + readsect((uchar*) va, offset); + va += SECTSIZE; + offset++; + } +} + |