]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
fix the problem that savedefault doesn't work with Stage 1.5.
authorokuji <okuji@localhost>
Fri, 2 Feb 2001 13:31:03 +0000 (13:31 +0000)
committerokuji <okuji@localhost>
Fri, 2 Feb 2001 13:31:03 +0000 (13:31 +0000)
ChangeLog
grub/asmstub.c
stage2/asm.S
stage2/disk_io.c
stage2/fsys_ext2fs.c
stage2/fsys_fat.c
stage2/fsys_ffs.c
stage2/fsys_minix.c
stage2/fsys_reiserfs.c
stage2/shared.h
stage2/stage1_5.c

index 6ab5b58c4852f11dc359de921cebae846d7b613e..db8915475fc539804c48cededc64603a870e001d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2001-02-02  OKUJI Yoshinori  <okuji@gnu.org>
+
+       Make savedefault workable even with Stage 1.5. Reported by
+       Thierry Laronde <thierry@cri74.org>.
+       
+       * 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  <okuji@gnu.org>
 
        * netboot/config.c [GRUB && INCLUDE_PCI] (pci_dispatch_table):
index 0066b29f5380e91cbdf1c8f966f46e066438a93c..9011ba449a79ecb63125fdc74a67d830600b9a78 100644 (file)
@@ -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 ();
 }
index d4f3b76f5380110ac4c8771600ce96ab6b8405a7..dc490c1374efbdc9327468d1eff64f65b8d735c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 1996   Erich Boleyn  <erich@uruk.org>
- *  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
 
index da4789aa7a2d03e03c2957c06f957a4c8411126a..ea98ef393f9e61e4699cb765cdbf26b5c790d957 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 1996  Erich Boleyn  <erich@uruk.org>
- *  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
 # include <device.h>
 #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;
index 014ae8f2ea63d50f63a13fec29622cbf87b4dcf6..3001817fef1f3c391853ff51ab159a7a23eea218 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 1996  Erich Boleyn  <erich@uruk.org>
- *  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;
index 27644abbd2ba5a2e05a507b1fb8fb3e3430b364f..bbf27459662ceac6a38ac717efd1b50863710f88 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 1996   Erich Boleyn  <erich@uruk.org>
- *  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;
index 0333e9f87aa9ace535926c75d6a11fdcaf39ea61..52ae828900b23fa6cfae90c53be3ffef18003417 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 1996  Erich Boleyn  <erich@uruk.org>
- *  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;
index 6b5c6cf5ebe7b9ddac3c34e178f954e6e0485545..6a18e55f0951b8de420cfe3f710b36f1fa2532d3 100644 (file)
@@ -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;
index c01cd0cf89759159081444f57bcb6fc1f142361a..94fe6827a9e617df97c4f84aaa5738e7ac99d48f 100644 (file)
@@ -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;
index 46fceb457f8c6b0735d4d160ff868a09f7a05b88..96d19a63dc527ee168ae05152b153ef9fe8f5808 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  GRUB  --  GRand Unified Bootloader
  *  Copyright (C) 1996  Erich Boleyn  <erich@uruk.org>
- *  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 */
index 3b4e481a16691ffe4ef950720519caf5f0ca1c2e..1f47b2a36d926b1bba65efc8a28b61045f77470b 100644 (file)
 
 #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);
     }
 
   /*