From eea6c3444051364931386c18d2a7d0c025a19099 Mon Sep 17 00:00:00 2001 From: gord Date: Tue, 23 Mar 1999 14:28:59 +0000 Subject: [PATCH] Finished basic loading support. --- ChangeLog | 8 ++++++++ debian/README.debian | 7 ++++++- shared_src/boot.c | 4 ++-- shared_src/char_io.c | 16 +++++++++++----- shared_src/cmdline.c | 35 ++++++++++++++++++++--------------- shared_src/disk_io.c | 4 +++- 6 files changed, 50 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index d56fa5893..a7adc5e55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1999-03-22 Gordon Matzigkeit + + * shared_src/cmdline.c (enter_cmdline): Check the return value of + set_device in the `root' command. + + * shared_src/char_io.c (memcheck): Special-case cur_part_desc and + reenable memory checking. + 1999-03-21 Gordon Matzigkeit * shared_src/boot.c (load_image): Make sure we use the mapped diff --git a/debian/README.debian b/debian/README.debian index 5848ecb4a..f0a2c7c57 100644 --- a/debian/README.debian +++ b/debian/README.debian @@ -15,6 +15,11 @@ edit configuration files or rerun a special installation program. NOTE: GRUB does not yet have a simple installation mechanism, but we're working on this, so please don't report it as a bug. Until then, read the documentation (starting with docs/grub.html or -docs/install.html), and use the binary files in /usr/share/grub. +docs/install.html), and copy the binary files in /share/grub/$(HWARCH) +to /boot/grub. + +WARNING: Never use the binary files in /share/grub directly +(i.e. without first copying them to /boot/grub), or else your system +will break the next time you upgrade. Gordon Matzigkeit , Sat, 13 Mar 1999 17:30:29 -0600 diff --git a/shared_src/boot.c b/shared_src/boot.c index 1a151f4bc..4f3b60191 100644 --- a/shared_src/boot.c +++ b/shared_src/boot.c @@ -365,9 +365,9 @@ load_image (void) /* offset into file */ filepos = phdr->p_offset; filesiz = phdr->p_filesz; - memaddr = phdr->p_vaddr; + memaddr = RAW_ADDR (phdr->p_vaddr); memsiz = phdr->p_memsz; - if (memaddr < 0x100000) + if (memaddr < RAW_ADDR (0x100000)) errnum = ERR_BELOW_1MB; /* make sure we only load what we're supposed to! */ if (filesiz > memsiz) diff --git a/shared_src/char_io.c b/shared_src/char_io.c index af417d03f..7db5903b9 100644 --- a/shared_src/char_io.c +++ b/shared_src/char_io.c @@ -563,18 +563,24 @@ strstr (char *s1, char *s2) int memcheck (int start, int len) { - /* FIXME: Don't bother checking memory for now, since our globals - are out of range. */ -#ifndef GRUB_UTIL +#ifdef GRUB_UTIL + /* FIXME: cur_part_desc is the only global variable that we bcopy + to. We should fix this so that we don't need a special case + (i.e. so that it lives on the stack, or somewhere inside + grub_scratch_mem). */ + extern char cur_part_desc[]; + if (start >= (int) cur_part_desc && start + len <= (int) cur_part_desc + 16) + return ! errnum; +#endif /* GRUB_UTIL */ + if ((start < RAW_ADDR (0x1000)) || (start < RAW_ADDR (0x100000) && RAW_ADDR (mbi.mem_lower * 1024) < (start + len)) || (start >= RAW_ADDR (0x100000) && RAW_ADDR (mbi.mem_upper * 1024) < ((start - 0x100000) + len))) errnum = ERR_WONT_FIT; -#endif /* GRUB_UTIL */ - return (!errnum); + return ! errnum; } diff --git a/shared_src/cmdline.c b/shared_src/cmdline.c index 9353e8a51..910005dd8 100644 --- a/shared_src/cmdline.c +++ b/shared_src/cmdline.c @@ -284,28 +284,33 @@ returnit: else if (substring("root", cur_heap) < 1) { int hdbias = 0; - char *biasptr = skip_to(0, set_device(cur_cmdline)); + char *next_cmd = set_device (cur_cmdline); - /* this will respond to any "rootn" command, - but that's OK */ - if (!errnum && (cur_heap[4] == 'n' || open_device() - || errnum == ERR_FSYS_MOUNT)) + if (next_cmd) { - errnum = 0; - saved_partition = current_partition; - saved_drive = current_drive; + char *biasptr = skip_to (0, next_cmd); - if (cur_heap[4] != 'n') + /* this will respond to any "rootn" command, + but that's OK */ + if (!errnum && (cur_heap[4] == 'n' || open_device() + || errnum == ERR_FSYS_MOUNT)) { - /* BSD and chainloading evil hacks !! */ - safe_parse_maxint(&biasptr, &hdbias); errnum = 0; - bootdev = set_bootdev(hdbias); + saved_partition = current_partition; + saved_drive = current_drive; - print_fsys_type(); + if (cur_heap[4] != 'n') + { + /* BSD and chainloading evil hacks !! */ + safe_parse_maxint(&biasptr, &hdbias); + errnum = 0; + bootdev = set_bootdev(hdbias); + + print_fsys_type(); + } + else + current_drive = -1; } - else - current_drive = -1; } } else if (substring("kernel", cur_heap) < 1) diff --git a/shared_src/disk_io.c b/shared_src/disk_io.c index 8ce5da3db..1e49bd62f 100644 --- a/shared_src/disk_io.c +++ b/shared_src/disk_io.c @@ -385,7 +385,9 @@ check_BSD_parts (int flags) #if !defined(STAGE1_5) || !defined(NO_BLOCK_FILES) -static char cur_part_desc[16]; +/* This isn't static, because the GRUB utility's char_io.c (memcheck) + needs to know about it as a special case. */ +char cur_part_desc[16]; static int real_open_partition (int flags)