From: Ben Pfaff Date: Tue, 31 Aug 2004 04:09:44 +0000 (+0000) Subject: Small loader cleanups. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8063d8f3b3a778e9a15eff66dfd1b08652bae523;p=pintos-anon Small loader cleanups. --- diff --git a/src/threads/init.c b/src/threads/init.c index 63ec7fa..79cd3d0 100644 --- a/src/threads/init.c +++ b/src/threads/init.c @@ -36,12 +36,11 @@ void power_off (void); static void main_thread (void *aux UNUSED) { - disk_init (); - #ifdef FILESYS + disk_init (); filesys_init (true); -#endif filesys_self_test (); +#endif } int @@ -174,15 +173,17 @@ ram_init (void) loader, so we have to zero it ourselves. */ memset (&_start_bss, 0, &_end_bss - &_start_bss); - /* Calculate how much RAM the kernel uses, and find out from - the bootloader how much RAM this machine has. */ + /* Calculate how much RAM the kernel uses, + and find out from the bootloader how much RAM this machine + has. */ kernel_pages = (&_end - &_start + 4095) / 4096; - ram_pages = *(uint32_t *) (LOADER_BASE + LOADER_RAM_PAGES); + ram_pages = *(uint32_t *) ptov (LOADER_BASE + LOADER_RAM_PAGES); } void argv_init (void) { + char *cmd_line = ptov (LOADER_BASE + LOADER_CMD_LINE); } void diff --git a/src/threads/loader.S b/src/threads/loader.S index 5a0262b..970d2e2 100644 --- a/src/threads/loader.S +++ b/src/threads/loader.S @@ -206,17 +206,17 @@ panicmsg: .byte 0 ##### Memory size in 4 kB pages. - .org LOADER_RAM_PAGES + .org LOADER_RAM_PAGES - LOADER_BASE ram_pages: .long 0 ##### Command-line arguments inserted by another utility. ##### The loader doesn't use these, but we note their ##### location here for easy reference. - .org LOADER_CMD_LINE + .org LOADER_CMD_LINE - LOADER_BASE cmd_line: .fill 0x80, 1, 0 ##### Boot-sector signature for BIOS inspection. - .org LOADER_BIOS_SIG + .org LOADER_BIOS_SIG - LOADER_BASE .word 0xaa55 diff --git a/src/threads/loader.h b/src/threads/loader.h index 8bd603f..6ae2856 100644 --- a/src/threads/loader.h +++ b/src/threads/loader.h @@ -3,7 +3,7 @@ /* Constants fixed by the PC BIOS. */ #define LOADER_BASE 0x7c00 /* Physical address of loader's base. */ -#define LOADER_SIZE 0x200 /* Loader size in bytes (one disk sector). */ +#define LOADER_END 0x7e00 /* Physical address of end of loader. */ /* Physical address of kernel base. */ #define LOADER_KERN_BASE 0x100000 /* 1 MB. */ @@ -18,7 +18,7 @@ #define LOADER_PHYS_BASE 0xc0000000 /* 3 GB. */ /* Offsets within the loader. */ -#define LOADER_BIOS_SIG (LOADER_SIZE - 2) /* aa55 BIOS signature. */ +#define LOADER_BIOS_SIG (LOADER_END - 2) /* 0xaa55 BIOS signature. */ #define LOADER_CMD_LINE (LOADER_BIOS_SIG - 0x80) /* Kernel command line. */ #define LOADER_RAM_PAGES (LOADER_CMD_LINE - 4) /* # of pages of RAM. */ diff --git a/src/threads/thread.c b/src/threads/thread.c index be607cf..218305c 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -197,7 +197,9 @@ void schedule_tail (struct thread *prev); void schedule_tail (struct thread *prev) { +#ifdef USERPROG struct thread *cur = thread_current (); +#endif ASSERT (intr_get_level () == IF_OFF);