diff --git a/ChangeLog b/ChangeLog index 6ab5b58c4..db8915475 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2001-02-02 OKUJI Yoshinori + + Make savedefault workable even with Stage 1.5. Reported by + Thierry Laronde . + + * grub/asmstub.c (chain_stage2): Added an additional argument, + SECOND_SECTOR. + * stage2/asm.S [STAGE1_5] (chain_stage2): Set %ebp to + SECOND_SECTOR. + * stage2/disk_io.c [STAGE1_5] (disk_read_hook): Defined. + [STAGE1_5] (disk_read_func): Likewise. + (rawread) [STAGE1_5]: Handle DISK_READ_FUNC. + (grub_read) [STAGE1_5]: Likewise. + * stage2/fsys_ext2fs.c (ext2fs_read) [STAGE1_5]: Likewise. + * stage2/fsys_fat.c (fat_read) [STAGE1_5]: Likewise. + * stage2/fsys_ffs.c (ffs_read) [STAGE1_5]: Likewise. + * stage2/fsys_minix.c (minix_read) [STAGE1_5]: Likewise. + * stage2/fsys_reiserfs.c (reiserfs_read) [STAGE1_5]: Likewise. + 2001-02-02 OKUJI Yoshinori * netboot/config.c [GRUB && INCLUDE_PCI] (pci_dispatch_table): diff --git a/grub/asmstub.c b/grub/asmstub.c index 0066b29f5..9011ba449 100644 --- a/grub/asmstub.c +++ b/grub/asmstub.c @@ -1,7 +1,7 @@ /* asmstub.c - a version of shared_src/asm.S that works under Unix */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -274,7 +274,7 @@ chain_stage1 (unsigned long segment, unsigned long offset, void -chain_stage2 (unsigned long segment, unsigned long offset) +chain_stage2 (unsigned long segment, unsigned long offset, int second_sector) { stop (); } diff --git a/stage2/asm.S b/stage2/asm.S index d4f3b76f5..dc490c137 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -1,7 +1,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -761,7 +761,7 @@ ENTRY(chain_stage1) #ifdef STAGE1_5 /* - * chain_stage2(segment, offset) + * chain_stage2(segment, offset, second_sector) * * This starts another stage2 loader, at segment:offset. It presumes * that the other one starts with this same "asm.S" file, and passes @@ -791,6 +791,9 @@ ENTRY(chain_stage2) /* set up to pass the drive where stage2 is located in */ movb EXT_C(current_drive), %dl + /* set up to pass the second sector of stage2 */ + movl 0xc(%esp), %ebp + call EXT_C(prot_to_real) .code16 diff --git a/stage2/disk_io.c b/stage2/disk_io.c index da4789aa7..ea98ef393 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -2,7 +2,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,11 +28,11 @@ # include #endif -#ifndef STAGE1_5 /* instrumentation variables */ void (*disk_read_hook) (int, int, int) = NULL; void (*disk_read_func) (int, int, int) = NULL; +#ifndef STAGE1_5 int print_possibilities; static int do_completion; @@ -209,7 +209,6 @@ rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) if (size > ((num_sect * SECTOR_SIZE) - byte_offset)) size = (num_sect * SECTOR_SIZE) - byte_offset; -#ifndef STAGE1_5 /* * Instrumentation to tell which sectors were read and used. */ @@ -231,7 +230,7 @@ rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) (*disk_read_func) (sector_num, 0, length); } } -#endif /* STAGE1_5 */ + memmove (buf, (char *) bufaddr, size); buf += size; @@ -1577,17 +1576,13 @@ grub_read (char *buf, int len) if (size > len) size = len; -#ifndef STAGE1_5 disk_read_func = disk_read_hook; -#endif /* STAGE1_5 */ /* read current block and put it in the right place in memory */ devread (BLK_BLKSTART (BLK_CUR_BLKLIST) + BLK_CUR_BLKNUM, off, size, buf); -#ifndef STAGE1_5 disk_read_func = NULL; -#endif /* STAGE1_5 */ len -= size; filepos += size; diff --git a/stage2/fsys_ext2fs.c b/stage2/fsys_ext2fs.c index 014ae8f2e..3001817fe 100644 --- a/stage2/fsys_ext2fs.c +++ b/stage2/fsys_ext2fs.c @@ -1,7 +1,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -433,16 +433,12 @@ ext2fs_read (char *buf, int len) if (size > len) size = len; -#ifndef STAGE1_5 disk_read_func = disk_read_hook; -#endif /* STAGE1_5 */ devread (map * (EXT2_BLOCK_SIZE (SUPERBLOCK) / DEV_BSIZE), offset, size, buf); -#ifndef STAGE1_5 disk_read_func = NULL; -#endif /* STAGE1_5 */ buf += size; len -= size; diff --git a/stage2/fsys_fat.c b/stage2/fsys_fat.c index 27644abbd..bbf274596 100644 --- a/stage2/fsys_fat.c +++ b/stage2/fsys_fat.c @@ -1,7 +1,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -244,15 +244,11 @@ fat_read (char *buf, int len) if (size > len) size = len; -#ifndef STAGE1_5 disk_read_func = disk_read_hook; -#endif /* STAGE1_5 */ devread(sector, offset, size, buf); -#ifndef STAGE1_5 disk_read_func = NULL; -#endif /* STAGE1_5 */ len -= size; buf += size; diff --git a/stage2/fsys_ffs.c b/stage2/fsys_ffs.c index 0333e9f87..52ae82890 100644 --- a/stage2/fsys_ffs.c +++ b/stage2/fsys_ffs.c @@ -1,7 +1,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -161,15 +161,11 @@ ffs_read (char *buf, int len) if (size > len) size = len; -#ifndef STAGE1_5 disk_read_func = disk_read_hook; -#endif /* STAGE1_5 */ devread (fsbtodb (SUPERBLOCK, map), off, size, buf); -#ifndef STAGE1_5 disk_read_func = NULL; -#endif /* STAGE1_5 */ buf += size; len -= size; diff --git a/stage2/fsys_minix.c b/stage2/fsys_minix.c index 6b5c6cf5e..6a18e55f0 100644 --- a/stage2/fsys_minix.c +++ b/stage2/fsys_minix.c @@ -1,6 +1,6 @@ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -268,16 +268,12 @@ minix_read (char *buf, int len) if (size > len) size = len; -#ifndef STAGE1_5 disk_read_func = disk_read_hook; -#endif /* STAGE1_5 */ devread (map * (BLOCK_SIZE / DEV_BSIZE), offset, size, buf); -#ifndef STAGE1_5 disk_read_func = NULL; -#endif /* STAGE1_5 */ buf += size; len -= size; diff --git a/stage2/fsys_reiserfs.c b/stage2/fsys_reiserfs.c index c01cd0cf8..94fe6827a 100644 --- a/stage2/fsys_reiserfs.c +++ b/stage2/fsys_reiserfs.c @@ -1,7 +1,7 @@ /* fsys_reiserfs.c - an implementation for the ReiserFS filesystem */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -910,7 +910,6 @@ reiserfs_read (char *buf, int len) if (to_read > len) to_read = len; -#ifndef STAGE1_5 if (disk_read_hook != NULL) { disk_read_func = disk_read_hook; @@ -921,7 +920,6 @@ reiserfs_read (char *buf, int len) disk_read_func = NULL; } else -#endif /* ! STAGE1_5 */ memcpy (buf, INFO->current_item + offset, to_read); goto update_buf_len; } @@ -939,9 +937,7 @@ reiserfs_read (char *buf, int len) if (to_read > len) to_read = len; -#ifndef STAGE1_5 disk_read_func = disk_read_hook; -#endif /* ! STAGE1_5 */ /* Journal is only for meta data. Data blocks can be read * directly without using block_read @@ -949,9 +945,7 @@ reiserfs_read (char *buf, int len) devread (blocknr << INFO->blocksize_shift, blk_offset, to_read, buf); -#ifndef STAGE1_5 disk_read_func = NULL; -#endif /* ! STAGE1_5 */ update_buf_len: len -= to_read; buf += to_read; diff --git a/stage2/shared.h b/stage2/shared.h index 46fceb457..96d19a63d 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -2,7 +2,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -601,10 +601,11 @@ extern int no_decompression; extern int compressed_file; #endif -#ifndef STAGE1_5 /* instrumentation variables */ extern void (*disk_read_hook) (int, int, int); extern void (*disk_read_func) (int, int, int); + +#ifndef STAGE1_5 /* The flag for debug mode. */ extern int debug; /* Color settings */ @@ -705,7 +706,8 @@ extern unsigned short io_map[]; void chain_stage1 (unsigned long segment, unsigned long offset, unsigned long part_table_addr) __attribute__ ((noreturn)); -void chain_stage2 (unsigned long segment, unsigned long offset) +void chain_stage2 (unsigned long segment, unsigned long offset, + int second_sector) __attribute__ ((noreturn)); /* do some funky stuff, then boot linux */ diff --git a/stage2/stage1_5.c b/stage2/stage1_5.c index 3b4e481a1..1f47b2a36 100644 --- a/stage2/stage1_5.c +++ b/stage2/stage1_5.c @@ -19,6 +19,14 @@ #include "shared.h" +static int saved_sector; + +static void +disk_read_savesect_func (int sector, int offset, int length) +{ + saved_sector = sector; +} + void cmain (void) { @@ -30,12 +38,18 @@ cmain (void) if (grub_open (config_file)) { - int ret = grub_read ((char *) 0x8000, -1); + int ret; + + disk_read_hook = disk_read_savesect_func; + grub_read ((char *) 0x8000, SECTOR_SIZE * 2); + disk_read_hook = NULL; + + ret = grub_read ((char *) 0x8000 + SECTOR_SIZE * 2, -1); grub_close (); if (ret) - chain_stage2 (0, 0x8200); + chain_stage2 (0, 0x8200, saved_sector); } /*