+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):
/* 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
void
-chain_stage2 (unsigned long segment, unsigned long offset)
+chain_stage2 (unsigned long segment, unsigned long offset, int second_sector)
{
stop ();
}
/*
* 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
#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
/* 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
/*
* 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;
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.
*/
(*disk_read_func) (sector_num, 0, length);
}
}
-#endif /* STAGE1_5 */
+
memmove (buf, (char *) bufaddr, size);
buf += size;
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;
/*
* 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
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;
/*
* 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
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;
/*
* 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
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;
/*
* 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
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;
/* 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
if (to_read > len)
to_read = len;
-#ifndef STAGE1_5
if (disk_read_hook != NULL)
{
disk_read_func = disk_read_hook;
disk_read_func = NULL;
}
else
-#endif /* ! STAGE1_5 */
memcpy (buf, INFO->current_item + offset, to_read);
goto update_buf_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
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;
/*
* 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
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 */
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 */
#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)
{
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);
}
/*