* boot/sparc64/ieee1275/boot.S: Various size-reducing changes.
Retrieve chosen/bootpath if bootpath isn't hardcoded. * conf/sparc64-ieee1275.rmk (grub_setup_SOURCES): Add util/ieee1275/ofpath.c. * util/sparc64/ieee1275/grub-ofpathname.c: Renamed to ... * util/ieee1275/grub-ofpathname.c: ... this. All users updated * include/grub/sparc64/ieee1275/boot.h (GRUB_BOOT_MACHINE_KERNEL_SECTOR): Renamed to ... (GRUB_BOOT_MACHINE_KERNEL_BYTE): ...this. Moved 8 bytes lower. * util/hostdisk.c (grub_util_biosdisk_get_osdev): New function. * util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Make argument const char *. * util/sparc64/ieee1275/grub-setup.c (compute_dest_ofpath): Removed. (setup): Use KERNEL_BYTE instead of KERNEL_SECTOR. Use grub_util_devname_to_ofpath. Zero-fill boot_devpath on same disk install.
This commit is contained in:
commit
0037de3fa3
10 changed files with 102 additions and 68 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2010-04-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* boot/sparc64/ieee1275/boot.S: Various size-reducing changes.
|
||||
Retrieve chosen/bootpath if bootpath isn't hardcoded.
|
||||
* conf/sparc64-ieee1275.rmk (grub_setup_SOURCES): Add
|
||||
util/ieee1275/ofpath.c.
|
||||
* util/sparc64/ieee1275/grub-ofpathname.c: Renamed to ...
|
||||
* util/ieee1275/grub-ofpathname.c: ... this. All users updated
|
||||
* include/grub/sparc64/ieee1275/boot.h
|
||||
(GRUB_BOOT_MACHINE_KERNEL_SECTOR): Renamed to ...
|
||||
(GRUB_BOOT_MACHINE_KERNEL_BYTE): ...this. Moved 8 bytes lower.
|
||||
* util/hostdisk.c (grub_util_biosdisk_get_osdev): New function.
|
||||
* util/ieee1275/ofpath.c (grub_util_devname_to_ofpath): Make argument
|
||||
const char *.
|
||||
* util/sparc64/ieee1275/grub-setup.c (compute_dest_ofpath): Removed.
|
||||
(setup): Use KERNEL_BYTE instead of KERNEL_SECTOR.
|
||||
Use grub_util_devname_to_ofpath. Zero-fill boot_devpath on same disk
|
||||
install.
|
||||
|
||||
2010-04-18 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||
|
||||
* util/grub-mkconfig.in: Corrected two == equality tests.
|
||||
|
|
|
@ -45,8 +45,9 @@ boot_version: .byte GRUB_BOOT_VERSION_MAJOR, GRUB_BOOT_VERSION_MINOR
|
|||
* load address plus the size of the prepended A.OUT header (32 bytes).
|
||||
*/
|
||||
boot_path:
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR
|
||||
kernel_sector: .xword 2
|
||||
. = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE
|
||||
boot_path_end:
|
||||
kernel_byte: .xword (2 << 9)
|
||||
kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
|
||||
|
||||
prom_finddev_name: .asciz "finddevice"
|
||||
|
@ -77,11 +78,23 @@ prom_error:
|
|||
/* %o0: OF call name
|
||||
* %o1: input arg 1
|
||||
*/
|
||||
prom_call_1_1:
|
||||
mov 1, %g1
|
||||
ba prom_call
|
||||
mov 1, %o5
|
||||
prom_call_1_1_o2:
|
||||
clr %o2
|
||||
ba prom_call_x_1
|
||||
mov 1, %g1
|
||||
|
||||
prom_call_getprop:
|
||||
mov 4, %g1
|
||||
stx %g1, [%l1 + 256]
|
||||
mov CHOSEN_NODE_REG, %o1
|
||||
ba prom_call_x_1
|
||||
GET_ABS(prom_getprop_name, %o0)
|
||||
|
||||
prom_call_3_1_o1:
|
||||
ba prom_call_3_1
|
||||
mov BOOTDEV_REG, %o1
|
||||
|
||||
|
||||
/* %o2: message string
|
||||
* %o3: message length
|
||||
*/
|
||||
|
@ -95,8 +108,9 @@ console_write:
|
|||
* %o2: input arg 2
|
||||
* %o3: input arg 3
|
||||
*/
|
||||
prom_call_3_1:
|
||||
prom_call_3_1:
|
||||
mov 3, %g1
|
||||
prom_call_x_1:
|
||||
mov 1, %o5
|
||||
/* fallthru */
|
||||
|
||||
|
@ -126,23 +140,17 @@ boot_continue:
|
|||
* chosen_node = prom_finddevice("/chosen")
|
||||
*/
|
||||
GET_ABS(prom_finddev_name, %o0)
|
||||
GET_ABS(prom_chosen_path, %o1)
|
||||
call prom_call_1_1
|
||||
clr %o2
|
||||
call prom_call_1_1_o2
|
||||
GET_ABS(prom_chosen_path, %o1)
|
||||
|
||||
ldx [%l1 + 0x20], CHOSEN_NODE_REG
|
||||
brz CHOSEN_NODE_REG, prom_error
|
||||
|
||||
/* getprop(chosen_node, "stdout", &buffer, buffer_size) */
|
||||
GET_ABS(prom_getprop_name, %o0)
|
||||
mov 4, %g1
|
||||
mov 1, %o5
|
||||
mov CHOSEN_NODE_REG, %o1
|
||||
GET_ABS(prom_stdout_name, %o2)
|
||||
GET_ABS(prom_stdout_name, %o2)
|
||||
add %l1, 256, %o3
|
||||
mov 1024, %o4
|
||||
call prom_call
|
||||
stx %g1, [%l1 + 256]
|
||||
call prom_call_getprop
|
||||
mov 1024, %o4
|
||||
|
||||
lduw [%l1 + 256], STDOUT_NODE_REG
|
||||
brz,pn STDOUT_NODE_REG, prom_error
|
||||
|
@ -152,15 +160,25 @@ boot_continue:
|
|||
call console_write
|
||||
mov GRUB_NAME_LEN, %o3
|
||||
|
||||
GET_ABS(boot_path, %o3)
|
||||
ldub [%o3], %o1
|
||||
brnz,pn %o1, bootpath_known
|
||||
|
||||
/* getprop(chosen_node, "bootpath", &buffer, buffer_size) */
|
||||
GET_ABS(prom_bootpath_name, %o2)
|
||||
call prom_call_getprop
|
||||
mov (boot_path_end - boot_path), %o4
|
||||
|
||||
bootpath_known:
|
||||
|
||||
/* Open up the boot_path, and use that handle to read the
|
||||
* first block of the GRUB kernel image.
|
||||
*
|
||||
* bootdev_handle = open(boot_path)
|
||||
*/
|
||||
GET_ABS(prom_open_name, %o0)
|
||||
GET_ABS(boot_path, %o1)
|
||||
call prom_call_1_1
|
||||
clr %o2
|
||||
call prom_call_1_1_o2
|
||||
GET_ABS(boot_path, %o1)
|
||||
|
||||
ldx [%l1 + 0x20], BOOTDEV_REG
|
||||
brz,pn BOOTDEV_REG, prom_open_error
|
||||
|
@ -168,28 +186,23 @@ boot_continue:
|
|||
/* Since we have 64-bit cells, the high cell of the seek offset
|
||||
* is zero and the low cell is the entire value.
|
||||
*
|
||||
* seek(bootdev, 0, *kernel_sector << 9)
|
||||
* seek(bootdev, 0, *kernel_byte)
|
||||
*/
|
||||
GET_ABS(prom_seek_name, %o0)
|
||||
mov BOOTDEV_REG, %o1
|
||||
clr %o2
|
||||
LDX_ABS(kernel_sector, 0x00, %o3)
|
||||
call prom_call_3_1
|
||||
sllx %o3, 9, %o3
|
||||
call prom_call_3_1_o1
|
||||
LDX_ABS(kernel_byte, 0x00, %o3)
|
||||
|
||||
/* read(bootdev, *kernel_address, 512) */
|
||||
GET_ABS(prom_read_name, %o0)
|
||||
mov BOOTDEV_REG, %o1
|
||||
LDUW_ABS(kernel_address, 0x00, %o2)
|
||||
call prom_call_3_1
|
||||
call prom_call_3_1_o1
|
||||
mov 512, %o3
|
||||
|
||||
LDUW_ABS(kernel_address, 0x00, %o2)
|
||||
jmpl %o2, %o7
|
||||
nop
|
||||
|
||||
1: ba,a 1b
|
||||
|
||||
. = _start + GRUB_BOOT_MACHINE_CODE_END
|
||||
|
||||
/* the last 4 bytes in the sector 0 contain the signature */
|
||||
|
|
|
@ -50,6 +50,7 @@ grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
|||
# For grub-setup.
|
||||
util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
||||
util/ieee1275/ofpath.c \
|
||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
||||
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
||||
|
@ -69,7 +70,7 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
|||
grub_setup_init.c
|
||||
|
||||
# For grub-ofpathname.
|
||||
grub_ofpathname_SOURCES = util/sparc64/ieee1275/grub-ofpathname.c \
|
||||
grub_ofpathname_SOURCES = util/ieee1275/grub-ofpathname.c \
|
||||
util/ieee1275/ofpath.c util/misc.c gnulib/progname.c
|
||||
|
||||
# Scripts.
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH_END 0x80
|
||||
|
||||
#define GRUB_BOOT_MACHINE_KERNEL_SECTOR 0x88
|
||||
#define GRUB_BOOT_MACHINE_KERNEL_BYTE 0x80
|
||||
|
||||
#define GRUB_BOOT_MACHINE_CODE_END \
|
||||
(0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE)
|
||||
|
|
|
@ -20,8 +20,11 @@
|
|||
#ifndef GRUB_BIOSDISK_MACHINE_UTIL_HEADER
|
||||
#define GRUB_BIOSDISK_MACHINE_UTIL_HEADER 1
|
||||
|
||||
#include <grub/disk.h>
|
||||
|
||||
void grub_util_biosdisk_init (const char *dev_map);
|
||||
void grub_util_biosdisk_fini (void);
|
||||
char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
|
||||
const char *grub_util_biosdisk_get_osdev (grub_disk_t disk);
|
||||
|
||||
#endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef GRUB_OFPATH_MACHINE_UTIL_HEADER
|
||||
#define GRUB_OFPATH_MACHINE_UTIL_HEADER 1
|
||||
|
||||
char *grub_util_devname_to_ofpath (char *devname);
|
||||
char *grub_util_devname_to_ofpath (const char *devname);
|
||||
|
||||
#endif /* ! GRUB_OFPATH_MACHINE_UTIL_HEADER */
|
||||
|
|
|
@ -1352,3 +1352,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return make_device_name (drive, -1, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *
|
||||
grub_util_biosdisk_get_osdev (grub_disk_t disk)
|
||||
{
|
||||
return map[disk->id].device;
|
||||
}
|
||||
|
|
|
@ -368,7 +368,7 @@ strip_trailing_digits (const char *p)
|
|||
}
|
||||
|
||||
char *
|
||||
grub_util_devname_to_ofpath (char *devname)
|
||||
grub_util_devname_to_ofpath (const char *devname)
|
||||
{
|
||||
char *name_buf, *device, *devnode, *devicenode, *ofpath;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <grub/term.h>
|
||||
#include <grub/util/raid.h>
|
||||
#include <grub/util/lvm.h>
|
||||
#include <grub/util/ofpath.h>
|
||||
|
||||
#include <grub_setup_init.h>
|
||||
|
||||
|
@ -103,28 +104,6 @@ grub_refresh (void)
|
|||
fflush (stdout);
|
||||
}
|
||||
|
||||
static char *compute_dest_ofpath (const char *dest)
|
||||
{
|
||||
int len = strlen (dest);
|
||||
char *res, *p, c;
|
||||
|
||||
res = xmalloc (len);
|
||||
p = res;
|
||||
while ((c = *dest++) != '\0')
|
||||
{
|
||||
if (c == '\\' && *dest == ',')
|
||||
{
|
||||
*p++ = ',';
|
||||
dest++;
|
||||
}
|
||||
else
|
||||
*p++ = c;
|
||||
}
|
||||
*p++ = '\0';
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
setup (const char *prefix, const char *dir,
|
||||
const char *boot_file, const char *core_file,
|
||||
|
@ -135,8 +114,8 @@ setup (const char *prefix, const char *dir,
|
|||
size_t boot_size, core_size;
|
||||
grub_uint16_t core_sectors;
|
||||
grub_device_t root_dev, dest_dev;
|
||||
char *boot_devpath, *dest_ofpath;
|
||||
grub_disk_addr_t *kernel_sector;
|
||||
char *boot_devpath;
|
||||
grub_disk_addr_t *kernel_byte;
|
||||
struct boot_blocklist *first_block, *block;
|
||||
char *tmp_img;
|
||||
int i;
|
||||
|
@ -195,8 +174,6 @@ setup (const char *prefix, const char *dir,
|
|||
last_length = length;
|
||||
}
|
||||
|
||||
dest_ofpath = compute_dest_ofpath (dest);
|
||||
|
||||
/* Read the boot image by the OS service. */
|
||||
boot_path = grub_util_get_path (dir, boot_file);
|
||||
boot_size = grub_util_get_image_size (boot_path);
|
||||
|
@ -210,9 +187,9 @@ setup (const char *prefix, const char *dir,
|
|||
boot_devpath = (char *) (boot_img
|
||||
+ GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_BOOT_DEVPATH);
|
||||
kernel_sector = (grub_disk_addr_t *) (boot_img
|
||||
+ GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_KERNEL_SECTOR);
|
||||
kernel_byte = (grub_disk_addr_t *) (boot_img
|
||||
+ GRUB_BOOT_AOUT_HEADER_SIZE
|
||||
+ GRUB_BOOT_MACHINE_KERNEL_BYTE);
|
||||
|
||||
core_path = grub_util_get_path (dir, core_file);
|
||||
core_size = grub_util_get_image_size (core_path);
|
||||
|
@ -229,8 +206,7 @@ setup (const char *prefix, const char *dir,
|
|||
+ GRUB_DISK_SECTOR_SIZE
|
||||
- sizeof (*block));
|
||||
|
||||
grub_util_info ("root is `%s', dest is `%s', and dest_ofpath is `%s'",
|
||||
root, dest, dest_ofpath);
|
||||
grub_util_info ("root is `%s', dest is `%s'", root, dest);
|
||||
|
||||
/* Open the root device and the destination device. */
|
||||
grub_util_info ("Opening root");
|
||||
|
@ -351,14 +327,30 @@ setup (const char *prefix, const char *dir,
|
|||
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
|
||||
grub_util_error ("failed to read the rest sectors of the core image");
|
||||
|
||||
if (file->device->disk->id != dest_dev->disk->id)
|
||||
{
|
||||
const char *dest_ofpath;
|
||||
dest_ofpath
|
||||
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (file->device->disk));
|
||||
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
|
||||
strncpy (boot_devpath, dest_ofpath, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
|
||||
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_util_info ("non cross-disk install");
|
||||
memset (boot_devpath, 0, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
|
||||
- GRUB_BOOT_MACHINE_BOOT_DEVPATH);
|
||||
}
|
||||
|
||||
grub_file_close (file);
|
||||
|
||||
free (core_path);
|
||||
free (tmp_img);
|
||||
|
||||
*kernel_sector = grub_cpu_to_be64 (first_sector);
|
||||
|
||||
strcpy(boot_devpath, dest_ofpath);
|
||||
*kernel_byte = grub_cpu_to_be64 (first_sector << GRUB_DISK_SECTOR_BITS);
|
||||
|
||||
grub_util_info ("boot device path %s, prefix is %s, dest is %s",
|
||||
boot_devpath, prefix, dest);
|
||||
|
|
Loading…
Reference in a new issue