1N/A/*
1N/A * GRUB -- GRand Unified Bootloader
1N/A * Copyright (C) 2001,2002 Free Software Foundation, Inc.
1N/A *
1N/A * This program is free software; you can redistribute it and/or modify
1N/A * it under the terms of the GNU General Public License as published by
1N/A * the Free Software Foundation; either version 2 of the License, or
1N/A * (at your option) any later version.
1N/A *
1N/A * This program is distributed in the hope that it will be useful,
1N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A * GNU General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU General Public License
1N/A * along with this program; if not, write to the Free Software
1N/A * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1N/A */
1N/A
1N/A#include "shared.h"
1N/A
1N/Astatic unsigned int saved_sector = (unsigned int)-1;
1N/A
1N/Astatic void
1N/Adisk_read_savesect_func (unsigned int sector, int offset, int length)
1N/A{
1N/A saved_sector = sector;
1N/A}
1N/A
1N/Avoid
1N/Acmain (void)
1N/A{
1N/A grub_printf ("\n\nGRUB loading, please wait...\n");
1N/A
1N/A /*
1N/A * Here load the true second-stage boot-loader.
1N/A */
1N/A
1N/A if (grub_open (config_file))
1N/A {
1N/A int ret;
1N/A
1N/A disk_read_hook = disk_read_savesect_func;
1N/A grub_read ((char *) 0x8000, SECTOR_SIZE * 2);
1N/A disk_read_hook = NULL;
1N/A
1N/A /* Sanity check: catch an internal error. */
1N/A if (saved_sector == (unsigned int)-1)
1N/A {
1N/A grub_printf ("internal error: the second sector of Stage 2 is unknown.");
1N/A stop ();
1N/A }
1N/A
1N/A ret = grub_read ((char *) 0x8000 + SECTOR_SIZE * 2, -1);
1N/A
1N/A grub_close ();
1N/A
1N/A if (ret)
1N/A chain_stage2 (0, 0x8200, saved_sector);
1N/A }
1N/A
1N/A /*
1N/A * If not, then print error message and die.
1N/A */
1N/A
1N/A print_error ();
1N/A
1N/A stop ();
1N/A}