1
1
/* grub-setup.c - make GRUB usable */
3
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
4
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
6
* GRUB is free software; you can redistribute it and/or modify
6
* GRUB is free software: you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
8
* the Free Software Foundation, either version 3 of the License, or
9
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
11
* GRUB is distributed in the hope that it will be useful,
12
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
* GNU General Public License for more details.
16
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21
20
#include <config.h>
50
51
#define DEFAULT_BOOT_FILE "boot.img"
51
52
#define DEFAULT_CORE_FILE "core.img"
54
/* NetBSD uses /boot for its boot block. */
55
# define DEFAULT_DIRECTORY "/grub"
57
# define DEFAULT_DIRECTORY "/boot/grub"
60
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
62
54
/* This is the blocklist used in the diskboot image. */
63
55
struct boot_blocklist
115
107
grub_file_t file;
117
109
unsigned long first_start = ~0UL;
110
int able_to_embed = 1;
119
auto void save_first_sector (grub_disk_addr_t sector, unsigned offset,
112
auto void NESTED_FUNC_ATTR save_first_sector (grub_disk_addr_t sector, unsigned offset,
120
113
unsigned length);
121
auto void save_blocklists (grub_disk_addr_t sector, unsigned offset,
114
auto void NESTED_FUNC_ATTR save_blocklists (grub_disk_addr_t sector, unsigned offset,
122
115
unsigned length);
124
117
auto int find_first_partition_start (grub_disk_t disk,
140
void save_first_sector (grub_disk_addr_t sector, unsigned offset,
133
void NESTED_FUNC_ATTR save_first_sector (grub_disk_addr_t sector, unsigned offset,
143
136
grub_util_info ("the first sector is <%llu,%u,%u>",
149
142
first_sector = sector;
152
void save_blocklists (grub_disk_addr_t sector, unsigned offset,
145
void NESTED_FUNC_ATTR save_blocklists (grub_disk_addr_t sector, unsigned offset,
155
148
struct boot_blocklist *prev = block + 1;
663
661
/* Initialize the emulated biosdisk driver. */
664
662
grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP);
665
grub_pc_partition_map_init ();
666
grub_gpt_partition_map_init ();
664
/* Initialize all modules. */
668
667
dest_dev = get_device_name (argv[optind]);
758
749
root_dev, dest_dev, must_embed);
760
751
/* Free resources. */
768
grub_gpt_partition_map_fini ();
769
grub_pc_partition_map_fini ();
770
753
grub_util_biosdisk_fini ();
772
755
free (boot_file);