Remove any awareness of *.c util files about target.

* Makefile.util.def (grub-setup): Split to ...
	(grub-bios-setup): ... and this.
	(grub-sparc64-setup): ... and this.
	* configure.ac: Don't add machine_CPPFLAGS into HOST_CPPFLAGS.
	* docs/man/grub-setup.h2m: Split into ...
	* docs/man/grub-sparc64-setup.h2m: ... this.
	* docs/man/grub-bios-setup.h2m: ... and this.
	* include/grub/dl.h (grub_dl) [GRUB_UTIL]: Remove struct.
	* include/grub/elf.h (Elf_*) [GRUB_UTIL]: Remove types.
	(GRUB_TARGET_WORDSIZE) [GRUB_UTIL]: Remove.
	(grub_target_addr_t): Remove.
	(grub_target_size_t): Remove.
	(grub_target_ssize_t): Remove.
	* util/grub-install.in: Use new grub-*-setup.
	* util/grub-mkimagexx.c (Elf_Word): New define.
	(Elf_Half): Likewise.
	(Elf_Section): Likewise.
	(ELF_ST_TYPE): Likewise.
	* util/grub-setup.c: Switch from GRUB_MACHINE_SPARC64 to
	GRUB_SETUP_SPARC64 and from GRUB_MACHINE_PCBIOS to GRUB_SETUP_BIOS.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-27 14:24:22 +01:00
parent 584b2f8a22
commit c36e5cd162
11 changed files with 104 additions and 40 deletions

View File

@ -1,3 +1,28 @@
2012-02-27 Vladimir Serbinenko <phcoder@gmail.com>
Remove any awareness of *.c util files about target.
* Makefile.util.def (grub-setup): Split to ...
(grub-bios-setup): ... and this.
(grub-sparc64-setup): ... and this.
* configure.ac: Don't add machine_CPPFLAGS into HOST_CPPFLAGS.
* docs/man/grub-setup.h2m: Split into ...
* docs/man/grub-sparc64-setup.h2m: ... this.
* docs/man/grub-bios-setup.h2m: ... and this.
* include/grub/dl.h (grub_dl) [GRUB_UTIL]: Remove struct.
* include/grub/elf.h (Elf_*) [GRUB_UTIL]: Remove types.
(GRUB_TARGET_WORDSIZE) [GRUB_UTIL]: Remove.
(grub_target_addr_t): Remove.
(grub_target_size_t): Remove.
(grub_target_ssize_t): Remove.
* util/grub-install.in: Use new grub-*-setup.
* util/grub-mkimagexx.c (Elf_Word): New define.
(Elf_Half): Likewise.
(Elf_Section): Likewise.
(ELF_ST_TYPE): Likewise.
* util/grub-setup.c: Switch from GRUB_MACHINE_SPARC64 to
GRUB_SETUP_SPARC64 and from GRUB_MACHINE_PCBIOS to GRUB_SETUP_BIOS.
2012-02-27 Vladimir Serbinenko <phcoder@gmail.com>
Replace grub_target_addr with more appropriate types.

View File

@ -300,7 +300,7 @@ program = {
};
program = {
name = grub-setup;
name = grub-bios-setup;
installdir = sbin;
mansection = 8;
common = util/grub-setup.c;
@ -308,16 +308,30 @@ program = {
common = grub-core/kern/emu/argp_common.c;
common = grub-core/lib/reed_solomon.c;
sparc64_ieee1275 = util/ieee1275/ofpath.c;
ldadd = libgrubmods.a;
ldadd = libgrubkern.a;
ldadd = libgrubgcry.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
cppflags = '-DGRUB_SETUP_BIOS=1';
};
program = {
name = grub-sparc64-setup;
installdir = sbin;
mansection = 8;
common = util/grub-setup.c;
common = util/lvm.c;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/lib/reed_solomon.c;
common = util/ieee1275/ofpath.c;
ldadd = libgrubmods.a;
ldadd = libgrubkern.a;
ldadd = libgrubgcry.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
enable = i386_pc;
enable = sparc64_ieee1275;
cppflags = '-DGRUB_SETUP_SPARC64=1';
};
program = {

View File

@ -180,7 +180,6 @@ else
machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,` -DGRUB_TARGET_CPU_`echo ${target_cpu} | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`=1"
fi
HOST_CPPFLAGS="$HOST_CPPFLAGS $machine_CPPFLAGS"
TARGET_CPPFLAGS="$TARGET_CPPFLAGS $machine_CPPFLAGS"
AC_SUBST(host_cpu)

View File

@ -0,0 +1,6 @@
[NAME]
grub-setup \- set up a device to boot using GRUB
[SEE ALSO]
.BR grub-install (8),
.BR grub-mkimage (1),
.BR grub-mkrescue (1)

View File

@ -147,6 +147,7 @@ struct grub_dl_dep
};
typedef struct grub_dl_dep *grub_dl_dep_t;
#ifndef GRUB_UTIL
struct grub_dl
{
char *name;
@ -164,6 +165,7 @@ struct grub_dl
grub_size_t sz;
struct grub_dl *next;
};
#endif
typedef struct grub_dl *grub_dl_t;
grub_dl_t grub_dl_load_file (const char *filename);

View File

@ -2331,6 +2331,7 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_X86_64_NUM 24
#ifndef GRUB_UTIL
#if GRUB_TARGET_WORDSIZE == 32
typedef Elf32_Addr Elf_Addr;
@ -2377,5 +2378,6 @@ typedef Elf64_Xword Elf_Xword;
#define ELF_R_INFO(sym, type) ELF64_R_INFO(sym, type)
#endif /* GRUB_TARGET_WORDSIZE == 64 */
#endif
#endif /* ! GRUB_ELF_H */

View File

@ -20,7 +20,9 @@
#define GRUB_TYPES_HEADER 1
#include <config.h>
#ifndef GRUB_UTIL
#include <grub/cpu/types.h>
#endif
#ifdef GRUB_UTIL
# define GRUB_CPU_SIZEOF_VOID_P SIZEOF_VOID_P
@ -48,7 +50,7 @@
# error "This architecture is not supported because sizeof(void *) != 4 and sizeof(void *) != 8"
#endif
#ifndef GRUB_TARGET_WORDSIZE
#if !defined (GRUB_UTIL) & !defined (GRUB_TARGET_WORDSIZE)
# if GRUB_TARGET_SIZEOF_VOID_P == 4
# define GRUB_TARGET_WORDSIZE 32
# elif GRUB_TARGET_SIZEOF_VOID_P == 8
@ -82,15 +84,6 @@ typedef unsigned long long grub_uint64_t;
#endif
/* Misc types. */
#if GRUB_TARGET_SIZEOF_VOID_P == 8
typedef grub_uint64_t grub_target_addr_t;
typedef grub_uint64_t grub_target_size_t;
typedef grub_int64_t grub_target_ssize_t;
#else
typedef grub_uint32_t grub_target_addr_t;
typedef grub_uint32_t grub_target_size_t;
typedef grub_int32_t grub_target_ssize_t;
#endif
#if GRUB_CPU_SIZEOF_VOID_P == 8
typedef grub_uint64_t grub_addr_t;

View File

@ -41,7 +41,6 @@ localedir="@datadir@/locale"
self="`basename $0`"
grub_setup="${sbindir}/`echo grub-setup | sed ${transform}`"
grub_mkimage="${bindir}/`echo grub-mkimage | sed ${transform}`"
grub_probe="${sbindir}/`echo grub-probe | sed ${transform}`"
grub_editenv="${bindir}/`echo grub-editenv | sed ${transform}`"
@ -261,6 +260,14 @@ do
esac
done
if test "x$grub_setup" = x && [ "${target_cpu}-${platform}" = "i386-pc" ]; then
grub_setup="${sbindir}/`echo grub-bios-setup | sed ${transform}`"
fi
if test "x$grub_setup" = x && [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]; then
grub_setup="${sbindir}/`echo grub-sparc64-setup | sed ${transform}`"
fi
if test "x$install_device" = x && ([ "${target_cpu}-${platform}" = "i386-pc" ] \
|| [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ]); then
gettext "Install device isn't specified." 1>&2

View File

@ -31,8 +31,12 @@
# define Elf_Shdr Elf32_Shdr
# define Elf_Rela Elf32_Rela
# define Elf_Rel Elf32_Rel
# define Elf_Word Elf32_Word
# define Elf_Half Elf32_Half
# define Elf_Section Elf32_Section
# define ELF_R_SYM(val) ELF32_R_SYM(val)
# define ELF_R_TYPE(val) ELF32_R_TYPE(val)
# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val)
#elif defined(MKIMAGE_ELF64)
# define SUFFIX(x) x ## 64
# define ELFCLASSXX ELFCLASS64
@ -44,8 +48,12 @@
# define Elf_Shdr Elf64_Shdr
# define Elf_Rela Elf64_Rela
# define Elf_Rel Elf64_Rel
# define Elf_Word Elf64_Word
# define Elf_Half Elf64_Half
# define Elf_Section Elf64_Section
# define ELF_R_SYM(val) ELF64_R_SYM(val)
# define ELF_R_TYPE(val) ELF64_R_TYPE(val)
# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val)
#else
#error "I'm confused"
#endif
@ -1095,3 +1103,7 @@ SUFFIX (load_image) (const char *kernel_path, grub_size_t *exec_size,
#undef Elf_Rel
#undef ELF_R_TYPE
#undef ELF_R_SYM
#undef Elf_Word
#undef Elf_Half
#undef Elf_Section
#undef ELF_ST_TYPE

View File

@ -28,13 +28,16 @@
#include <grub/partition.h>
#include <grub/env.h>
#include <grub/emu/hostdisk.h>
#include <grub/machine/boot.h>
#include <grub/machine/kernel.h>
#include <grub/term.h>
#include <grub/i18n.h>
#include <grub/util/lvm.h>
#ifdef GRUB_MACHINE_IEEE1275
#ifdef GRUB_SETUP_SPARC64
#include <grub/util/ofpath.h>
#include <grub/sparc64/ieee1275/boot.h>
#include <grub/sparc64/ieee1275/kernel.h>
#else
#include <grub/i386/pc/boot.h>
#include <grub/i386/pc/kernel.h>
#endif
#include <stdio.h>
@ -77,14 +80,14 @@
#define DEFAULT_BOOT_FILE "boot.img"
#define DEFAULT_CORE_FILE "core.img"
#ifdef GRUB_MACHINE_SPARC64
#ifdef GRUB_SETUP_SPARC64
#define grub_target_to_host16(x) grub_be_to_cpu16(x)
#define grub_target_to_host32(x) grub_be_to_cpu32(x)
#define grub_target_to_host64(x) grub_be_to_cpu64(x)
#define grub_host_to_target16(x) grub_cpu_to_be16(x)
#define grub_host_to_target32(x) grub_cpu_to_be32(x)
#define grub_host_to_target64(x) grub_cpu_to_be64(x)
#elif defined (GRUB_MACHINE_PCBIOS)
#elif defined (GRUB_SETUP_BIOS)
#define grub_target_to_host16(x) grub_le_to_cpu16(x)
#define grub_target_to_host32(x) grub_le_to_cpu32(x)
#define grub_target_to_host64(x) grub_le_to_cpu64(x)
@ -99,7 +102,7 @@ static void
write_rootdev (char *core_img, grub_device_t root_dev,
char *boot_img, grub_uint64_t first_sector)
{
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
{
grub_uint8_t *boot_drive;
grub_disk_addr_t *kernel_sector;
@ -113,7 +116,7 @@ write_rootdev (char *core_img, grub_device_t root_dev,
*kernel_sector = grub_cpu_to_le64 (first_sector);
}
#endif
#ifdef GRUB_MACHINE_IEEE1275
#ifdef GRUB_SETUP_SPARC64
{
grub_disk_addr_t *kernel_byte;
kernel_byte = (grub_disk_addr_t *) (boot_img
@ -124,7 +127,7 @@ write_rootdev (char *core_img, grub_device_t root_dev,
#endif
}
#ifdef GRUB_MACHINE_IEEE1275
#ifdef GRUB_SETUP_SPARC64
#define BOOT_SECTOR 1
#else
#define BOOT_SECTOR 0
@ -145,9 +148,9 @@ setup (const char *dir,
struct grub_boot_blocklist *first_block, *block;
char *tmp_img;
grub_disk_addr_t first_sector;
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
grub_uint16_t current_segment
= GRUB_BOOT_MACHINE_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4);
= GRUB_BOOT_I386_PC_KERNEL_SEG + (GRUB_DISK_SECTOR_SIZE >> 4);
#endif
grub_uint16_t last_length = GRUB_DISK_SECTOR_SIZE;
grub_file_t file;
@ -196,7 +199,7 @@ setup (const char *dir,
{
block->start = grub_host_to_target64 (sector);
block->len = grub_host_to_target16 (1);
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
block->segment = grub_host_to_target16 (current_segment);
#endif
@ -206,7 +209,7 @@ setup (const char *dir,
}
last_length = length;
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
current_segment += GRUB_DISK_SECTOR_SIZE >> 4;
#endif
}
@ -226,7 +229,7 @@ setup (const char *dir,
>> GRUB_DISK_SECTOR_BITS);
if (core_size < GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is too small"), core_path);
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
if (core_size > 0xFFFF * GRUB_DISK_SECTOR_SIZE)
grub_util_error (_("the size of `%s' is too large"), core_path);
#endif
@ -293,14 +296,14 @@ setup (const char *dir,
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
/* Read the original sector from the disk. */
tmp_img = xmalloc (GRUB_DISK_SECTOR_SIZE);
if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img))
grub_util_error ("%s", grub_errmsg);
#endif
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
{
grub_uint16_t *boot_drive_check;
boot_drive_check = (grub_uint16_t *) (boot_img
@ -319,7 +322,7 @@ setup (const char *dir,
}
#endif
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
{
grub_partition_map_t dest_partmap = NULL;
grub_partition_t container = dest_dev->disk->partition;
@ -374,7 +377,7 @@ setup (const char *dir,
is_ldm = grub_util_is_ldm (dest_dev->disk);
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
if (fs_probe)
{
if (!fs && !dest_partmap)
@ -551,7 +554,7 @@ unable_to_embed:
grub_util_error ("%s", _("embedding is not possible, but this is required for "
"RAID and LVM install"));
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
if (dest_dev->disk->id != root_dev->disk->id
|| dest_dev->disk->dev->id != root_dev->disk->dev->id)
/* TRANSLATORS: cross-disk refers to /boot being on one disk
@ -651,7 +654,7 @@ unable_to_embed:
{
block->start = 0;
block->len = 0;
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
block->segment = 0;
#endif
@ -678,7 +681,7 @@ unable_to_embed:
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
grub_util_error ("%s", _("failed to read the rest sectors of the core image"));
#ifdef GRUB_MACHINE_IEEE1275
#ifdef GRUB_SETUP_SPARC64
{
char *boot_devpath;
boot_devpath = (char *) (boot_img
@ -691,7 +694,8 @@ unable_to_embed:
dest_ofpath
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk));
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
strncpy (boot_devpath, dest_ofpath, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
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;
@ -723,7 +727,7 @@ unable_to_embed:
grub_util_write_image (core_img, GRUB_DISK_SECTOR_SIZE * 2, fp, core_path);
fclose (fp);
#ifdef GRUB_MACHINE_PCBIOS
#ifdef GRUB_SETUP_BIOS
finish:
#endif
@ -919,7 +923,7 @@ main (int argc, char *argv[])
exit(1);
}
#ifdef GRUB_MACHINE_IEEE1275
#ifdef GRUB_SETUP_SPARC64
arguments.force = 1;
#endif