From 6944770e0c35b76daf37ba35928fce170d57e22d Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 13 Nov 2009 13:30:55 +0000 Subject: [PATCH 01/14] 2009-11-13 Robert Millan * include/multiboot2.h (multiboot_word): Rename from this ... (multiboot2_word): ... to this. Update all users. (multiboot_header): Rename from this ... (multiboot2_header): ... to this. Update all users. (multiboot_tag_header): Rename from this ... (multiboot2_tag_header): ... to this. Update all users. (multiboot_tag_start): Rename from this ... (multiboot2_tag_start): ... to this. Update all users. (multiboot_tag_name): Rename from this ... (multiboot2_tag_name): ... to this. Update all users. (multiboot_tag_module): Rename from this ... (multiboot2_tag_module): ... to this. Update all users. (multiboot_tag_memory): Rename from this ... (multiboot2_tag_memory): ... to this. Update all users. (multiboot_tag_unused): Rename from this ... (multiboot2_tag_unused): ... to this. Update all users. (multiboot_tag_end): Rename from this ... (multiboot2_tag_end): ... to this. Update all users. --- include/grub/multiboot2.h | 6 ++--- include/multiboot2.h | 44 ++++++++++++++++++------------------ loader/i386/pc/multiboot2.c | 8 +++---- loader/ieee1275/multiboot2.c | 8 +++---- loader/multiboot2.c | 40 ++++++++++++++++---------------- 5 files changed, 53 insertions(+), 53 deletions(-) diff --git a/include/grub/multiboot2.h b/include/grub/multiboot2.h index 2c9780996..af10cdc21 100644 --- a/include/grub/multiboot2.h +++ b/include/grub/multiboot2.h @@ -30,7 +30,7 @@ typedef grub_uint64_t uint64_t; #define __WORDSIZE GRUB_TARGET_WORDSIZE #endif -struct multiboot_tag_header; +struct multiboot2_tag_header; grub_err_t grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len); @@ -42,7 +42,7 @@ void grub_mb2_arch_boot (grub_addr_t entry, void *tags); void -grub_mb2_arch_unload (struct multiboot_tag_header *tags); +grub_mb2_arch_unload (struct multiboot2_tag_header *tags); grub_err_t grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load); @@ -65,6 +65,6 @@ grub_module2 (int argc, char *argv[]); #define for_each_tag(tag, tags) \ for (tag = tags; \ tag && tag->key != MULTIBOOT2_TAG_END; \ - tag = (struct multiboot_tag_header *)((char *)tag + tag->len)) + tag = (struct multiboot2_tag_header *)((char *)tag + tag->len)) #endif /* ! GRUB_MULTIBOOT2_HEADER */ diff --git a/include/multiboot2.h b/include/multiboot2.h index c87c3d175..e55af8392 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -40,18 +40,18 @@ /* XXX not portable? */ #if __WORDSIZE == 64 -typedef uint64_t multiboot_word; +typedef uint64_t multiboot2_word; #else -typedef uint32_t multiboot_word; +typedef uint32_t multiboot2_word; #endif -struct multiboot_header +struct multiboot2_header { uint32_t magic; uint32_t flags; }; -struct multiboot_tag_header +struct multiboot2_tag_header { uint32_t key; uint32_t len; @@ -61,48 +61,48 @@ struct multiboot_tag_header #define MULTIBOOT2_TAG_RESERVED2 (~0) #define MULTIBOOT2_TAG_START 1 -struct multiboot_tag_start +struct multiboot2_tag_start { - struct multiboot_tag_header header; - multiboot_word size; /* Total size of all multiboot tags. */ + struct multiboot2_tag_header header; + multiboot2_word size; /* Total size of all multiboot tags. */ }; #define MULTIBOOT2_TAG_NAME 2 -struct multiboot_tag_name +struct multiboot2_tag_name { - struct multiboot_tag_header header; + struct multiboot2_tag_header header; char name[1]; }; #define MULTIBOOT2_TAG_MODULE 3 -struct multiboot_tag_module +struct multiboot2_tag_module { - struct multiboot_tag_header header; - multiboot_word addr; - multiboot_word size; + struct multiboot2_tag_header header; + multiboot2_word addr; + multiboot2_word size; char type[36]; char cmdline[1]; }; #define MULTIBOOT2_TAG_MEMORY 4 -struct multiboot_tag_memory +struct multiboot2_tag_memory { - struct multiboot_tag_header header; - multiboot_word addr; - multiboot_word size; - multiboot_word type; + struct multiboot2_tag_header header; + multiboot2_word addr; + multiboot2_word size; + multiboot2_word type; }; #define MULTIBOOT2_TAG_UNUSED 5 -struct multiboot_tag_unused +struct multiboot2_tag_unused { - struct multiboot_tag_header header; + struct multiboot2_tag_header header; }; #define MULTIBOOT2_TAG_END 0xffff -struct multiboot_tag_end +struct multiboot2_tag_end { - struct multiboot_tag_header header; + struct multiboot2_tag_header header; }; #endif /* ! ASM_FILE */ diff --git a/loader/i386/pc/multiboot2.c b/loader/i386/pc/multiboot2.c index 3baf4883b..e2d649613 100644 --- a/loader/i386/pc/multiboot2.c +++ b/loader/i386/pc/multiboot2.c @@ -95,17 +95,17 @@ grub_mb2_arch_boot (grub_addr_t entry, void *tags) } void -grub_mb2_arch_unload (struct multiboot_tag_header *tags) +grub_mb2_arch_unload (struct multiboot2_tag_header *tags) { - struct multiboot_tag_header *tag; + struct multiboot2_tag_header *tag; /* Free all module memory in the tag list. */ for_each_tag (tag, tags) { if (tag->key == MULTIBOOT2_TAG_MODULE) { - struct multiboot_tag_module *module = - (struct multiboot_tag_module *) tag; + struct multiboot2_tag_module *module = + (struct multiboot2_tag_module *) tag; grub_free((void *) module->addr); } } diff --git a/loader/ieee1275/multiboot2.c b/loader/ieee1275/multiboot2.c index fda62fc4b..3646e8091 100644 --- a/loader/ieee1275/multiboot2.c +++ b/loader/ieee1275/multiboot2.c @@ -115,17 +115,17 @@ grub_mb2_tags_arch_create (void) /* Release the memory we claimed from Open Firmware above. */ void -grub_mb2_arch_unload (struct multiboot_tag_header *tags) +grub_mb2_arch_unload (struct multiboot2_tag_header *tags) { - struct multiboot_tag_header *tag; + struct multiboot2_tag_header *tag; /* Free all module memory in the tag list. */ for_each_tag (tag, tags) { if (tag->key == MULTIBOOT2_TAG_MODULE) { - struct multiboot_tag_module *module = - (struct multiboot_tag_module *) tag; + struct multiboot2_tag_module *module = + (struct multiboot2_tag_module *) tag; grub_ieee1275_release (module->addr, module->size); } } diff --git a/loader/multiboot2.c b/loader/multiboot2.c index 62f923a9b..976285b85 100644 --- a/loader/multiboot2.c +++ b/loader/multiboot2.c @@ -51,7 +51,7 @@ grub_mb2_tags_free (void) grub_err_t grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len) { - struct multiboot_tag_header *tag; + struct multiboot2_tag_header *tag; grub_size_t used; grub_size_t needed; @@ -59,7 +59,7 @@ grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len) key, (unsigned long) len); used = grub_mb2_tags_pos - grub_mb2_tags; - len = ALIGN_UP (len, sizeof (multiboot_word)); + len = ALIGN_UP (len, sizeof (multiboot2_word)); needed = used + len; @@ -83,7 +83,7 @@ grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len) grub_mb2_tags_pos = newarea + used; } - tag = (struct multiboot_tag_header *) grub_mb2_tags_pos; + tag = (struct multiboot2_tag_header *) grub_mb2_tags_pos; grub_mb2_tags_pos += len; tag->key = key; @@ -103,24 +103,24 @@ static grub_err_t grub_mb2_tag_start_create (void) { return grub_mb2_tag_alloc (0, MULTIBOOT2_TAG_START, - sizeof (struct multiboot_tag_start)); + sizeof (struct multiboot2_tag_start)); } static grub_err_t grub_mb2_tag_name_create (void) { - struct multiboot_tag_name *name; + struct multiboot2_tag_name *name; grub_addr_t name_addr; grub_err_t err; const char *grub_version = PACKAGE_STRING; err = grub_mb2_tag_alloc (&name_addr, MULTIBOOT2_TAG_NAME, - sizeof (struct multiboot_tag_name) + + sizeof (struct multiboot2_tag_name) + sizeof (grub_version) + 1); if (err) return err; - name = (struct multiboot_tag_name *) name_addr; + name = (struct multiboot2_tag_name *) name_addr; grub_strcpy (name->name, grub_version); return GRUB_ERR_NONE; @@ -159,17 +159,17 @@ error: static grub_err_t grub_mb2_tags_finish (void) { - struct multiboot_tag_start *start; + struct multiboot2_tag_start *start; grub_err_t err; /* Create the `end' tag. */ err = grub_mb2_tag_alloc (0, MULTIBOOT2_TAG_END, - sizeof (struct multiboot_tag_end)); + sizeof (struct multiboot2_tag_end)); if (err) goto error; /* We created the `start' tag first. Update it now. */ - start = (struct multiboot_tag_start *) grub_mb2_tags; + start = (struct multiboot2_tag_start *) grub_mb2_tags; start->size = grub_mb2_tags_pos - grub_mb2_tags; return GRUB_ERR_NONE; @@ -195,17 +195,17 @@ grub_mb2_boot (void) static grub_err_t grub_mb2_unload (void) { - struct multiboot_tag_header *tag; - struct multiboot_tag_header *tags = - (struct multiboot_tag_header *) grub_mb2_tags; + struct multiboot2_tag_header *tag; + struct multiboot2_tag_header *tags = + (struct multiboot2_tag_header *) grub_mb2_tags; /* Free all module memory in the tag list. */ for_each_tag (tag, tags) { if (tag->key == MULTIBOOT2_TAG_MODULE) { - struct multiboot_tag_module *module = - (struct multiboot_tag_module *) tag; + struct multiboot2_tag_module *module = + (struct multiboot2_tag_module *) tag; grub_free ((void *) module->addr); } } @@ -233,7 +233,7 @@ static grub_err_t grub_mb2_tag_module_create (grub_addr_t modaddr, grub_size_t modsize, char *type, int key, int argc, char *argv[]) { - struct multiboot_tag_module *module; + struct multiboot2_tag_module *module; grub_ssize_t argslen = 0; grub_err_t err; char *p; @@ -246,11 +246,11 @@ grub_mb2_tag_module_create (grub_addr_t modaddr, grub_size_t modsize, /* Note: includes implicit 1-byte cmdline. */ err = grub_mb2_tag_alloc (&module_addr, key, - sizeof (struct multiboot_tag_module) + argslen); + sizeof (struct multiboot2_tag_module) + argslen); if (err) return grub_errno; - module = (struct multiboot_tag_module *) module_addr; + module = (struct multiboot2_tag_module *) module_addr; module->addr = modaddr; module->size = modsize; grub_strcpy(module->type, type); @@ -308,7 +308,7 @@ grub_multiboot2 (int argc, char *argv[]) char *buffer; grub_file_t file = 0; grub_elf_t elf = 0; - struct multiboot_header *header = 0; + struct multiboot2_header *header = 0; char *p; grub_ssize_t len; grub_err_t err; @@ -344,7 +344,7 @@ grub_multiboot2 (int argc, char *argv[]) be at least 8 bytes and aligned on a 8-byte boundary. */ for (p = buffer; p <= buffer + len - 8; p += 8) { - header = (struct multiboot_header *) p; + header = (struct multiboot2_header *) p; if (header->magic == MULTIBOOT2_HEADER_MAGIC) { header_found = 1; From a73f5969463740ecc8b06adb07fca0d4b39f8073 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 13 Nov 2009 13:32:22 +0000 Subject: [PATCH 02/14] Forgot to commit ChangeLog ... --- ChangeLog | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6d7c7fe42..a98329dcd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2009-11-13 Robert Millan + + * include/multiboot2.h (multiboot_word): Rename from this ... + (multiboot2_word): ... to this. Update all users. + (multiboot_header): Rename from this ... + (multiboot2_header): ... to this. Update all users. + (multiboot_tag_header): Rename from this ... + (multiboot2_tag_header): ... to this. Update all users. + (multiboot_tag_start): Rename from this ... + (multiboot2_tag_start): ... to this. Update all users. + (multiboot_tag_name): Rename from this ... + (multiboot2_tag_name): ... to this. Update all users. + (multiboot_tag_module): Rename from this ... + (multiboot2_tag_module): ... to this. Update all users. + (multiboot_tag_memory): Rename from this ... + (multiboot2_tag_memory): ... to this. Update all users. + (multiboot_tag_unused): Rename from this ... + (multiboot2_tag_unused): ... to this. Update all users. + (multiboot_tag_end): Rename from this ... + (multiboot2_tag_end): ... to this. Update all users. + 2009-11-13 Robert Millan Disable Multiboot2 in i386-ieee1275. It didn't actually work, and on From 8d0edf4abde936f09d9fc5acad9bbad2199129e7 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 13 Nov 2009 13:34:51 +0000 Subject: [PATCH 03/14] 2009-11-13 Robert Millan * include/grub/multiboot.h (struct grub_multiboot_header): Move from here ... * include/multiboot.h (struct multiboot_header): ... to here. Update all users. * include/grub/multiboot.h (struct grub_multiboot_info): Move from here ... * include/multiboot.h (struct multiboot_info): ... to here. Update all users. * include/grub/multiboot.h (struct grub_multiboot_mmap_entry): Move from here ... * include/multiboot.h (struct multiboot_mmap_entry): ... to here. Update all users. * include/grub/multiboot.h (struct grub_mod_list): Move from here ... * include/multiboot.h (struct multiboot_mod_list): ... to here. Update all users. --- ChangeLog | 19 +++++++ include/grub/i386/multiboot.h | 4 +- include/grub/multiboot.h | 101 --------------------------------- include/multiboot.h | 103 +++++++++++++++++++++++++++++++++- kern/i386/multiboot_mmap.c | 10 ++-- loader/i386/multiboot.c | 32 +++++------ loader/multiboot_loader.c | 6 +- 7 files changed, 147 insertions(+), 128 deletions(-) diff --git a/ChangeLog b/ChangeLog index a98329dcd..487c0f3ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2009-11-13 Robert Millan + + * include/grub/multiboot.h (struct grub_multiboot_header): Move + from here ... + * include/multiboot.h (struct multiboot_header): ... to here. Update + all users. + * include/grub/multiboot.h (struct grub_multiboot_info): Move + from here ... + * include/multiboot.h (struct multiboot_info): ... to here. Update + all users. + * include/grub/multiboot.h (struct grub_multiboot_mmap_entry): Move + from here ... + * include/multiboot.h (struct multiboot_mmap_entry): ... to here. + Update all users. + * include/grub/multiboot.h (struct grub_mod_list): Move + from here ... + * include/multiboot.h (struct multiboot_mod_list): ... to here. + Update all users. + 2009-11-13 Robert Millan * include/multiboot2.h (multiboot_word): Rename from this ... diff --git a/include/grub/i386/multiboot.h b/include/grub/i386/multiboot.h index 2dd7ec008..b8cab9d24 100644 --- a/include/grub/i386/multiboot.h +++ b/include/grub/i386/multiboot.h @@ -21,10 +21,10 @@ /* The asm part of the multiboot loader. */ void grub_multiboot_real_boot (grub_addr_t entry, - struct grub_multiboot_info *mbi) + struct multiboot_info *mbi) __attribute__ ((noreturn)); void grub_multiboot2_real_boot (grub_addr_t entry, - struct grub_multiboot_info *mbi) + struct multiboot_info *mbi) __attribute__ ((noreturn)); extern grub_addr_t grub_multiboot_payload_orig; diff --git a/include/grub/multiboot.h b/include/grub/multiboot.h index 2cb00a06d..c54874942 100644 --- a/include/grub/multiboot.h +++ b/include/grub/multiboot.h @@ -25,105 +25,4 @@ void grub_multiboot (int argc, char *argv[]); void grub_module (int argc, char *argv[]); -#ifndef ASM_FILE - -#include - -struct grub_multiboot_header -{ - /* Must be MULTIBOOT_MAGIC - see above. */ - grub_uint32_t magic; - - /* Feature flags. */ - grub_uint32_t flags; - - /* The above fields plus this one must equal 0 mod 2^32. */ - grub_uint32_t checksum; - - /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ - grub_uint32_t header_addr; - grub_uint32_t load_addr; - grub_uint32_t load_end_addr; - grub_uint32_t bss_end_addr; - grub_uint32_t entry_addr; - - /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ - grub_uint32_t mode_type; - grub_uint32_t width; - grub_uint32_t height; - grub_uint32_t depth; -}; - -struct grub_multiboot_info -{ - /* Multiboot info version number */ - grub_uint32_t flags; - - /* Available memory from BIOS */ - grub_uint32_t mem_lower; - grub_uint32_t mem_upper; - - /* "root" partition */ - grub_uint32_t boot_device; - - /* Kernel command line */ - grub_uint32_t cmdline; - - /* Boot-Module list */ - grub_uint32_t mods_count; - grub_uint32_t mods_addr; - - grub_uint32_t syms[4]; - - /* Memory Mapping buffer */ - grub_uint32_t mmap_length; - grub_uint32_t mmap_addr; - - /* Drive Info buffer */ - grub_uint32_t drives_length; - grub_uint32_t drives_addr; - - /* ROM configuration table */ - grub_uint32_t config_table; - - /* Boot Loader Name */ - grub_uint32_t boot_loader_name; - - /* APM table */ - grub_uint32_t apm_table; - - /* Video */ - grub_uint32_t vbe_control_info; - grub_uint32_t vbe_mode_info; - grub_uint16_t vbe_mode; - grub_uint16_t vbe_interface_seg; - grub_uint16_t vbe_interface_off; - grub_uint16_t vbe_interface_len; -}; - -struct grub_multiboot_mmap_entry -{ - grub_uint32_t size; - grub_uint64_t addr; - grub_uint64_t len; -#define GRUB_MULTIBOOT_MEMORY_AVAILABLE 1 -#define GRUB_MULTIBOOT_MEMORY_RESERVED 2 - grub_uint32_t type; -} __attribute__((packed)); - -struct grub_mod_list -{ - /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ - grub_uint32_t mod_start; - grub_uint32_t mod_end; - - /* Module command line */ - grub_uint32_t cmdline; - - /* padding to take it to 16 bytes (must be zero) */ - grub_uint32_t pad; -}; - -#endif /* ! ASM_FILE */ - #endif /* ! GRUB_MULTIBOOT_HEADER */ diff --git a/include/multiboot.h b/include/multiboot.h index 110ad2f17..f6e240b7b 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -1,7 +1,7 @@ /* multiboot.h - multiboot header file. */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2003,2007,2009 Free Software Foundation, Inc. + * Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc. * * GRUB is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,4 +92,105 @@ /* Is there video information? */ #define MULTIBOOT_INFO_VIDEO_INFO 0x00000800 +#ifndef ASM_FILE + +#include + +struct multiboot_header +{ + /* Must be MULTIBOOT_MAGIC - see above. */ + grub_uint32_t magic; + + /* Feature flags. */ + grub_uint32_t flags; + + /* The above fields plus this one must equal 0 mod 2^32. */ + grub_uint32_t checksum; + + /* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */ + grub_uint32_t header_addr; + grub_uint32_t load_addr; + grub_uint32_t load_end_addr; + grub_uint32_t bss_end_addr; + grub_uint32_t entry_addr; + + /* These are only valid if MULTIBOOT_VIDEO_MODE is set. */ + grub_uint32_t mode_type; + grub_uint32_t width; + grub_uint32_t height; + grub_uint32_t depth; +}; + +struct multiboot_info +{ + /* Multiboot info version number */ + grub_uint32_t flags; + + /* Available memory from BIOS */ + grub_uint32_t mem_lower; + grub_uint32_t mem_upper; + + /* "root" partition */ + grub_uint32_t boot_device; + + /* Kernel command line */ + grub_uint32_t cmdline; + + /* Boot-Module list */ + grub_uint32_t mods_count; + grub_uint32_t mods_addr; + + grub_uint32_t syms[4]; + + /* Memory Mapping buffer */ + grub_uint32_t mmap_length; + grub_uint32_t mmap_addr; + + /* Drive Info buffer */ + grub_uint32_t drives_length; + grub_uint32_t drives_addr; + + /* ROM configuration table */ + grub_uint32_t config_table; + + /* Boot Loader Name */ + grub_uint32_t boot_loader_name; + + /* APM table */ + grub_uint32_t apm_table; + + /* Video */ + grub_uint32_t vbe_control_info; + grub_uint32_t vbe_mode_info; + grub_uint16_t vbe_mode; + grub_uint16_t vbe_interface_seg; + grub_uint16_t vbe_interface_off; + grub_uint16_t vbe_interface_len; +}; + +struct multiboot_mmap_entry +{ + grub_uint32_t size; + grub_uint64_t addr; + grub_uint64_t len; +#define MULTIBOOT_MEMORY_AVAILABLE 1 +#define MULTIBOOT_MEMORY_RESERVED 2 + grub_uint32_t type; +} __attribute__((packed)); + +struct multiboot_mod_list +{ + /* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */ + grub_uint32_t mod_start; + grub_uint32_t mod_end; + + /* Module command line */ + grub_uint32_t cmdline; + + /* padding to take it to 16 bytes (must be zero) */ + grub_uint32_t pad; +}; + +#endif /* ! ASM_FILE */ + #endif /* ! MULTIBOOT_HEADER */ diff --git a/kern/i386/multiboot_mmap.c b/kern/i386/multiboot_mmap.c index 67d824313..0f463c23c 100644 --- a/kern/i386/multiboot_mmap.c +++ b/kern/i386/multiboot_mmap.c @@ -26,15 +26,15 @@ grub_size_t grub_lower_mem, grub_upper_mem; /* A pointer to the MBI in its initial location. */ -struct grub_multiboot_info *startup_multiboot_info; +struct multiboot_info *startup_multiboot_info; /* The MBI has to be copied to our BSS so that it won't be overwritten. This is its final location. */ -static struct grub_multiboot_info kern_multiboot_info; +static struct multiboot_info kern_multiboot_info; /* Unfortunately we can't use heap at this point. But 32 looks like a sane limit (used by memtest86). */ -static grub_uint8_t mmap_entries[sizeof (struct grub_multiboot_mmap_entry) * 32]; +static grub_uint8_t mmap_entries[sizeof (struct multiboot_mmap_entry) * 32]; void grub_machine_mmap_init () @@ -43,7 +43,7 @@ grub_machine_mmap_init () grub_fatal ("Unable to find Multiboot Information (is CONFIG_MULTIBOOT disabled in coreboot?)"); /* Move MBI to a safe place. */ - grub_memmove (&kern_multiboot_info, startup_multiboot_info, sizeof (struct grub_multiboot_info)); + grub_memmove (&kern_multiboot_info, startup_multiboot_info, sizeof (struct multiboot_info)); if ((kern_multiboot_info.flags & MULTIBOOT_INFO_MEM_MAP) == 0) grub_fatal ("Missing Multiboot memory information"); @@ -73,7 +73,7 @@ grub_machine_mmap_init () grub_err_t grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uint64_t, grub_uint32_t)) { - struct grub_multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr; + struct multiboot_mmap_entry *entry = (void *) kern_multiboot_info.mmap_addr; while ((unsigned long) entry < kern_multiboot_info.mmap_addr + kern_multiboot_info.mmap_length) { diff --git a/loader/i386/multiboot.c b/loader/i386/multiboot.c index 8c3139b57..d1ea307d2 100644 --- a/loader/i386/multiboot.c +++ b/loader/i386/multiboot.c @@ -50,7 +50,7 @@ #endif extern grub_dl_t my_mod; -static struct grub_multiboot_info *mbi, *mbi_dest; +static struct multiboot_info *mbi, *mbi_dest; static grub_addr_t entry; static char *playground = 0; @@ -74,9 +74,9 @@ grub_multiboot_unload (void) for (i = 0; i < mbi->mods_count; i++) { grub_free ((void *) - ((struct grub_mod_list *) mbi->mods_addr)[i].mod_start); + ((struct multiboot_mod_list *) mbi->mods_addr)[i].mod_start); grub_free ((void *) - ((struct grub_mod_list *) mbi->mods_addr)[i].cmdline); + ((struct multiboot_mod_list *) mbi->mods_addr)[i].cmdline); } grub_free ((void *) mbi->mods_addr); grub_free (playground); @@ -107,14 +107,14 @@ grub_get_multiboot_mmap_len (void) grub_mmap_iterate (hook); - return count * sizeof (struct grub_multiboot_mmap_entry); + return count * sizeof (struct multiboot_mmap_entry); } /* Fill previously allocated Multiboot mmap. */ static void -grub_fill_multiboot_mmap (struct grub_multiboot_mmap_entry *first_entry) +grub_fill_multiboot_mmap (struct multiboot_mmap_entry *first_entry) { - struct grub_multiboot_mmap_entry *mmap_entry = (struct grub_multiboot_mmap_entry *) first_entry; + struct multiboot_mmap_entry *mmap_entry = (struct multiboot_mmap_entry *) first_entry; auto int NESTED_FUNC_ATTR hook (grub_uint64_t, grub_uint64_t, grub_uint32_t); int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type) @@ -122,7 +122,7 @@ grub_fill_multiboot_mmap (struct grub_multiboot_mmap_entry *first_entry) mmap_entry->addr = addr; mmap_entry->len = size; mmap_entry->type = type; - mmap_entry->size = sizeof (struct grub_multiboot_mmap_entry) - sizeof (mmap_entry->size); + mmap_entry->size = sizeof (struct multiboot_mmap_entry) - sizeof (mmap_entry->size); mmap_entry++; return 0; @@ -197,7 +197,7 @@ grub_multiboot (int argc, char *argv[]) { grub_file_t file = 0; char buffer[MULTIBOOT_SEARCH], *cmdline = 0, *p; - struct grub_multiboot_header *header; + struct multiboot_header *header; grub_ssize_t len, cmdline_length, boot_loader_name_length; grub_uint32_t mmap_length; int i; @@ -228,9 +228,9 @@ grub_multiboot (int argc, char *argv[]) /* Look for the multiboot header in the buffer. The header should be at least 12 bytes and aligned on a 4-byte boundary. */ - for (header = (struct grub_multiboot_header *) buffer; + for (header = (struct multiboot_header *) buffer; ((char *) header <= buffer + len - 12) || (header = 0); - header = (struct grub_multiboot_header *) ((char *) header + 4)) + header = (struct multiboot_header *) ((char *) header + 4)) { if (header->magic == MULTIBOOT_MAGIC && !(header->magic + header->flags + header->checksum)) @@ -275,12 +275,12 @@ grub_multiboot (int argc, char *argv[]) #define boot_loader_name_addr(x) \ ((void *) ((x) + code_size + cmdline_length)) #define mbi_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length)) -#define mmap_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length + sizeof (struct grub_multiboot_info))) +#define mmap_addr(x) ((void *) ((x) + code_size + cmdline_length + boot_loader_name_length + sizeof (struct multiboot_info))) grub_multiboot_payload_size = cmdline_length /* boot_loader_name_length might need to grow for mbi,etc to be aligned (see below) */ + boot_loader_name_length + 3 - + sizeof (struct grub_multiboot_info) + mmap_length; + + sizeof (struct multiboot_info) + mmap_length; if (header->flags & MULTIBOOT_AOUT_KLUDGE) { @@ -324,7 +324,7 @@ grub_multiboot (int argc, char *argv[]) mbi = mbi_addr (grub_multiboot_payload_orig); mbi_dest = mbi_addr (grub_multiboot_payload_dest); - grub_memset (mbi, 0, sizeof (struct grub_multiboot_info)); + grub_memset (mbi, 0, sizeof (struct multiboot_info)); mbi->mmap_length = mmap_length; grub_fill_multiboot_mmap (mmap_addr (grub_multiboot_payload_orig)); @@ -462,10 +462,10 @@ grub_module (int argc, char *argv[]) if (mbi->flags & MULTIBOOT_INFO_MODS) { - struct grub_mod_list *modlist = (struct grub_mod_list *) mbi->mods_addr; + struct multiboot_mod_list *modlist = (struct multiboot_mod_list *) mbi->mods_addr; modlist = grub_realloc (modlist, (mbi->mods_count + 1) - * sizeof (struct grub_mod_list)); + * sizeof (struct multiboot_mod_list)); if (! modlist) goto fail; mbi->mods_addr = (grub_uint32_t) modlist; @@ -478,7 +478,7 @@ grub_module (int argc, char *argv[]) } else { - struct grub_mod_list *modlist = grub_zalloc (sizeof (struct grub_mod_list)); + struct multiboot_mod_list *modlist = grub_zalloc (sizeof (struct multiboot_mod_list)); if (! modlist) goto fail; modlist->mod_start = (grub_uint32_t) module; diff --git a/loader/multiboot_loader.c b/loader/multiboot_loader.c index 986ee0b04..168e821c7 100644 --- a/loader/multiboot_loader.c +++ b/loader/multiboot_loader.c @@ -44,7 +44,7 @@ static unsigned int module_version_status = 1; static int find_multi_boot1_header (grub_file_t file) { - struct grub_multiboot_header *header; + struct multiboot_header *header; char buffer[MULTIBOOT_SEARCH]; int found_status = 0; grub_ssize_t len; @@ -55,9 +55,9 @@ find_multi_boot1_header (grub_file_t file) /* Look for the multiboot header in the buffer. The header should be at least 12 bytes and aligned on a 4-byte boundary. */ - for (header = (struct grub_multiboot_header *) buffer; + for (header = (struct multiboot_header *) buffer; ((char *) header <= buffer + len - 12) || (header = 0); - header = (struct grub_multiboot_header *) ((char *) header + 4)) + header = (struct multiboot_header *) ((char *) header + 4)) { if (header->magic == MULTIBOOT_MAGIC && !(header->magic + header->flags + header->checksum)) From 2e035eb9ba43ed4162f64f01e805e47ac0d6601b Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Fri, 13 Nov 2009 17:32:22 +0000 Subject: [PATCH 04/14] Add .bzrignore --- .bzrignore | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .bzrignore diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 000000000..91e959171 --- /dev/null +++ b/.bzrignore @@ -0,0 +1,55 @@ +00_header +10_* +30_os-prober +40_custom +autom4te.cache +build_env.mk +.bzrignore +config.cache +config.h +config.h.in +config.log +config.status +configure +conf/*.mk +*.d +DISTLIST +docs/*.info +docs/stamp-vti +docs/version.texi +*.elf +*.exec +genkernsyms.sh +gensymlist.sh +grub-dumpbios +grub-editenv +grub-emu +grub_emu_init.c +grub_emu_init.h +grub-fstest +grub_fstest_init.c +grub_fstest_init.h +grub-install +grub-mk* +grub-pe2elf +grub-probe +grub_probe_init.c +grub_probe_init.h +grub_script.tab.c +grub_script.tab.h +grub-setup +grub_setup_init.c +grub_setup_init.h +*.img +include/grub/cpu +include/grub/machine +*.lst +Makefile +*.mod +mod-*.c +*.pf2 +stamp-h +stamp-h1 +stamp-h.in +symlist.c +update-grub_lib From fc2208b0ef19af29e52e0eba05f1a343d3354e3d Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sat, 14 Nov 2009 18:38:11 +0000 Subject: [PATCH 05/14] 2009-11-14 Robert Millan * conf/i386-coreboot.rmk (grub_mkrescue_SOURCES): Replace `util/i386/coreboot/grub-mkrescue.in' with `util/grub-mkrescue.in'. * conf/i386-pc.rmk (grub_mkrescue_SOURCES): Replace `util/i386/pc/grub-mkrescue.in' with `util/grub-mkrescue.in'. (bin_SCRIPTS): Add `grub-mkfloppy'. (grub_mkfloppy_SOURCES): New variable. * util/grub-mkrescue.in: New file. * util/i386/pc/grub-mkfloppy.in: New file. * util/i386/coreboot/grub-mkrescue.in: Remove. * util/i386/pc/grub-mkrescue.in: Remove. --- ChangeLog | 15 ++ conf/i386-coreboot.rmk | 2 +- conf/i386-pc.rmk | 13 +- util/grub-mkrescue.in | 151 +++++++++++++++ .../grub-mkrescue.in => pc/grub-mkfloppy.in} | 74 ++----- util/i386/pc/grub-mkrescue.in | 180 ------------------ 6 files changed, 194 insertions(+), 241 deletions(-) create mode 100644 util/grub-mkrescue.in rename util/i386/{coreboot/grub-mkrescue.in => pc/grub-mkfloppy.in} (54%) delete mode 100644 util/i386/pc/grub-mkrescue.in diff --git a/ChangeLog b/ChangeLog index 487c0f3ef..04ff39c84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2009-11-14 Robert Millan + + * conf/i386-coreboot.rmk (grub_mkrescue_SOURCES): Replace + `util/i386/coreboot/grub-mkrescue.in' with `util/grub-mkrescue.in'. + * conf/i386-pc.rmk (grub_mkrescue_SOURCES): Replace + `util/i386/pc/grub-mkrescue.in' with `util/grub-mkrescue.in'. + (bin_SCRIPTS): Add `grub-mkfloppy'. + (grub_mkfloppy_SOURCES): New variable. + + * util/grub-mkrescue.in: New file. + * util/i386/pc/grub-mkfloppy.in: New file. + + * util/i386/coreboot/grub-mkrescue.in: Remove. + * util/i386/pc/grub-mkrescue.in: Remove. + 2009-11-13 Robert Millan * include/grub/multiboot.h (struct grub_multiboot_header): Move diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index b65833776..9a60db785 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -153,7 +153,7 @@ sbin_SCRIPTS += grub-install grub_install_SOURCES = util/grub-install.in bin_SCRIPTS += grub-mkrescue -grub_mkrescue_SOURCES = util/i386/coreboot/grub-mkrescue.in +grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. pkglib_MODULES = linux.mod multiboot.mod \ diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 74b88f0df..a3aae6bad 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -168,15 +168,14 @@ grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \ grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB) endif -# Scripts. -sbin_SCRIPTS = grub-install -bin_SCRIPTS = grub-mkrescue - -# For grub-install. +sbin_SCRIPTS += grub-install grub_install_SOURCES = util/grub-install.in -# For grub-mkrescue. -grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in +bin_SCRIPTS += grub-mkrescue +grub_mkrescue_SOURCES = util/grub-mkrescue.in + +bin_SCRIPTS += grub-mkfloppy +grub_mkfloppy_SOURCES = util/i386/pc/grub-mkfloppy.in pkglib_MODULES = biosdisk.mod chain.mod \ multiboot.mod reboot.mod halt.mod \ diff --git a/util/grub-mkrescue.in b/util/grub-mkrescue.in new file mode 100644 index 000000000..5db287a38 --- /dev/null +++ b/util/grub-mkrescue.in @@ -0,0 +1,151 @@ +#! /bin/sh -e + +# Make GRUB rescue image +# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +# Initialize some variables. +transform="@program_transform_name@" + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@ +libdir=@libdir@ +PACKAGE_NAME=@PACKAGE_NAME@ +PACKAGE_TARNAME=@PACKAGE_TARNAME@ +PACKAGE_VERSION=@PACKAGE_VERSION@ +target_cpu=@target_cpu@ + +coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot +pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc +grub_mkisofs="grub-mkisofs" + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "$0 (GNU GRUB ${PACKAGE_VERSION})" + exit 0 ;; + --modules=*) + modules=`echo "$option" | sed 's/--modules=//'` ;; + --output=*) + output_image=`echo "$option" | sed 's/--output=//'` ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + source="${source} ${option}" ;; + esac +done + +iso9660_dir=`mktemp -d` +mkdir -p ${iso9660_dir}/boot/grub + +for platform in pc coreboot ; do + input_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-${platform} + if test -e ${input_dir} ; then + mkdir -p ${iso9660_dir}/boot/grub/${target_cpu}-${platform} + for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \ + ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ + ${input_dir}/handler.lst ${input_dir}/parttool.lst; do + if test -f "$file"; then + cp -f "$file" ${iso9660_dir}/boot/grub/${target_cpu}-${platform}/ + fi + done + fi +done + +# build coreboot core.img +if test -e ${coreboot_dir} ; then + memdisk_img=`mktemp` + memdisk_dir=`mktemp -d` + mkdir -p ${memdisk_dir}/boot/grub + # obtain date-based UUID + iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00) + + modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}" + cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg +search --fs-uuid --set ${iso_uuid} +set prefix=(\${root})/boot/grub/${target_cpu}-coreboot +EOF + (for i in ${modules} ; do + echo "insmod $i" + done ; \ + echo "source /boot/grub/grub.cfg") \ + > ${iso9660_dir}/boot/grub/i386-pc/grub.cfg + + tar -C ${memdisk_dir} -cf ${memdisk_img} boot + rm -rf ${memdisk_dir} + grub-mkelfimage -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \ + memdisk tar search iso9660 configfile sh \ + ata at_keyboard + rm -f ${memdisk_img} + grub_mkisofs="${grub_mkisofs} --modification-date=$(echo ${iso_uuid} | sed -e s/-//g)" +fi + +if [ "${source}" != "" ] ; then + for d in ${source}; do + echo "Processing $d" + cp -dpRl "${d}" ${iso9660_dir}/ + done +fi + +# build eltorito core.img +if test -e ${pc_dir} ; then + core_img=`mktemp` + grub-mkimage -d ${pc_dir}/ -o ${core_img} --prefix=/boot/grub/i386-pc \ + memdisk tar search iso9660 configfile sh \ + biosdisk + cat ${pc_dir}/cdboot.img ${core_img} > ${iso9660_dir}/boot/grub/i386-pc/eltorito.img + rm -f ${core_img} + + modules="$(cat ${pc_dir}/partmap.lst) ${modules}" + (for i in ${modules} ; do + echo "insmod $i" + done ; \ + echo "source /boot/grub/grub.cfg") \ + > ${iso9660_dir}/boot/grub/i386-pc/grub.cfg + + grub_mkisofs="${grub_mkisofs} -b boot/grub/i386-pc/eltorito.img -boot-info-table" +fi + +# build iso image +${grub_mkisofs} -o ${output_image} -r -J ${iso9660_dir} +rm -rf ${iso9660_dir} + +exit 0 diff --git a/util/i386/coreboot/grub-mkrescue.in b/util/i386/pc/grub-mkfloppy.in similarity index 54% rename from util/i386/coreboot/grub-mkrescue.in rename to util/i386/pc/grub-mkfloppy.in index 6731e748e..3b5518690 100644 --- a/util/i386/coreboot/grub-mkrescue.in +++ b/util/i386/pc/grub-mkfloppy.in @@ -1,7 +1,7 @@ #! /bin/sh -e -# Make GRUB rescue image -# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +# Make GRUB rescue floppy +# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. # # GRUB is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,26 +30,19 @@ target_cpu=@target_cpu@ platform=@platform@ pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` -grub_mkimage=${bindir}/`echo grub-mkelfimage | sed ${transform}` -grub_mkisofs=${bindir}/`echo grub-mkisofs | sed ${transform}` - # Usage: usage # Print the usage. usage () { cat <. EOF @@ -68,14 +61,8 @@ for option in "$@"; do exit 0 ;; --modules=*) modules=`echo "$option" | sed 's/--modules=//'` ;; - --overlay=*) - overlay=${overlay}${overlay:+ }`echo "$option" | sed 's/--overlay=//'` ;; - --pkglibdir=*) - input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;; - --grub-mkimage=*) - grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; - --grub-mkisofs=*) - grub_mkisofs=`echo "$option" | sed 's/--grub-mkisofs=//'` ;; + --output=*) + output_image=`echo "$option" | sed 's/--output=//'` ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage @@ -96,53 +83,34 @@ if test "x$output_image" = x; then exit 1 fi -memdisk_dir=`mktemp -d` -iso9660_dir=`mktemp -d` -mkdir -p ${memdisk_dir}/boot/grub ${iso9660_dir}/boot/grub +aux_dir=`mktemp -d` +mkdir -p ${aux_dir}/boot/grub for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \ ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ ${input_dir}/handler.lst ${input_dir}/parttool.lst; do if test -f "$file"; then - cp -f "$file" ${iso9660_dir}/boot/grub/ + cp -f "$file" ${aux_dir}/boot/grub/ fi done -# obtain date-based UUID -iso_uuid=$(date +%Y-%m-%d-%H-%M-%S-00) - -# first-stage grub.cfg -cat << EOF >> ${memdisk_dir}/boot/grub/grub.cfg -search --fs-uuid --set ${iso_uuid} -set prefix=(\${root})/boot/grub -source /boot/grub/grub.cfg -EOF +modules="$(cat ${input_dir}/partmap.lst) ${modules}" +for i in ${modules} ; do + echo "insmod $i" +done > ${aux_dir}/boot/grub/grub.cfg # build memdisk memdisk_img=`mktemp` -tar -C ${memdisk_dir} -cf ${memdisk_img} boot -rm -rf ${memdisk_dir} +tar -C ${aux_dir} -cf ${memdisk_img} boot +rm -rf ${aux_dir} # build core.img -mkdir -p ${iso9660_dir}/boot/grub -${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \ - at_keyboard memdisk tar ata search iso9660 configfile sh +core_img=`mktemp` +grub-mkimage -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar biosdisk rm -f ${memdisk_img} -for d in ${overlay}; do - echo "Overlaying $d" - cp -dpR "${d}"/* "${iso9660_dir}"/ -done - -# second-stage grub.cfg -modules="`cat ${input_dir}/partmap.lst` ${modules}" -for i in ${modules} ; do - echo "insmod $i" -done > ${iso9660_dir}/boot/grub/grub.cfg - -# build iso image -${grub_mkisofs} \ - --modification-date=$(echo ${iso_uuid} | sed -e s/-//g) \ - -o ${output_image} -r -J ${iso9660_dir} +# build floppy image +cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${output_image} +rm -f ${core_img} exit 0 diff --git a/util/i386/pc/grub-mkrescue.in b/util/i386/pc/grub-mkrescue.in deleted file mode 100644 index cc581bffe..000000000 --- a/util/i386/pc/grub-mkrescue.in +++ /dev/null @@ -1,180 +0,0 @@ -#! /bin/sh -e - -# Make GRUB rescue image -# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. -# -# GRUB is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# GRUB is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GRUB. If not, see . - -# Initialize some variables. -transform="@program_transform_name@" - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -libdir=@libdir@ -PACKAGE_NAME=@PACKAGE_NAME@ -PACKAGE_TARNAME=@PACKAGE_TARNAME@ -PACKAGE_VERSION=@PACKAGE_VERSION@ -target_cpu=@target_cpu@ -platform=@platform@ -pkglibdir=${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform} | sed ${transform}` - -grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}` - -# Usage: usage -# Print the usage. -usage () { - cat <. -EOF -} - -image_type=cdrom -input_dir=${pkglibdir} -emulation=none - -# Check the arguments. -for option in "$@"; do - case "$option" in - -h | --help) - usage - exit 0 ;; - -v | --version) - echo "$0 (GNU GRUB ${PACKAGE_VERSION})" - exit 0 ;; - --modules=*) - modules=`echo "$option" | sed 's/--modules=//'` ;; - --overlay=*) - overlay=${overlay}${overlay:+ }`echo "$option" | sed 's/--overlay=//'` ;; - --pkglibdir=*) - input_dir=`echo "$option" | sed 's/--pkglibdir=//'` ;; - --grub-mkimage=*) - grub_mkimage=`echo "$option" | sed 's/--grub-mkimage=//'` ;; - --image-type=*) - image_type=`echo "$option" | sed 's/--image-type=//'` - case "$image_type" in - floppy|cdrom) ;; - *) - echo "Unknown image type \`$image_type'" 1>&2 - exit 1 ;; - esac ;; - --emulation=*) - emulation=`echo "$option" | sed 's/--emulation=//'` - case "$emulation" in - floppy|none) ;; - *) - echo "Unknown emulation type \`$emulation'" 1>&2 - exit 1 ;; - esac ;; - -*) - echo "Unrecognized option \`$option'" 1>&2 - usage - exit 1 - ;; - *) - if test "x$output_image" != x; then - echo "Unrecognized option \`$option'" 1>&2 - usage - exit 1 - fi - output_image="${option}" ;; - esac -done - -if test "x$output_image" = x; then - usage - exit 1 -fi - -aux_dir=`mktemp -d` -mkdir -p ${aux_dir}/boot/grub - -for file in ${input_dir}/*.mod ${input_dir}/efiemu??.o \ - ${input_dir}/command.lst ${input_dir}/moddep.lst ${input_dir}/fs.lst \ - ${input_dir}/handler.lst ${input_dir}/parttool.lst; do - if test -f "$file"; then - cp -f "$file" ${aux_dir}/boot/grub/ - fi -done - -modules="biosdisk `cat ${input_dir}/partmap.lst` ${modules}" -for i in ${modules} ; do - echo "insmod $i" -done > ${aux_dir}/boot/grub/grub.cfg - -for d in ${overlay}; do - echo "Overlaying $d" - cp -dpR "${d}"/* "${aux_dir}"/ -done - -if [ "x${image_type}" = xfloppy -o "x${emulation}" = xfloppy ] ; then - # build memdisk - memdisk_img=`mktemp` - tar -C ${aux_dir} -cf ${memdisk_img} boot - rm -rf ${aux_dir} - - # build core.img - core_img=`mktemp` - ${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk tar - rm -f ${memdisk_img} - - # build floppy image - if [ "x${image_type}" = xcdrom ] ; then - floppy_dir=`mktemp -d` - floppy_img=${floppy_dir}/grub_floppy.img - else - floppy_img=${output_image} - fi - cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${floppy_img} - rm -f ${core_img} - - if [ "x${image_type}" = xcdrom ] ; then - # build iso image - genisoimage -b grub_floppy.img \ - -o ${output_image} -r -J ${floppy_dir} - rm -rf ${floppy_dir} - fi -else - # build core.img - core_img=`mktemp` - ${grub_mkimage} -d ${input_dir}/ -o ${core_img} biosdisk iso9660 - - # build grub_eltorito image - cat ${input_dir}/cdboot.img ${core_img} > ${aux_dir}/boot/grub/grub_eltorito - rm -f ${core_img} - - # build iso image - genisoimage -b boot/grub/grub_eltorito \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ - -o ${output_image} -r -J ${aux_dir} - rm -rf ${aux_dir} -fi - -exit 0 From 6621b0e70686d3527a1a6a225e6b136d9869004e Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sat, 14 Nov 2009 22:08:07 +0100 Subject: [PATCH 06/14] 2009-11-14 Vladimir Serbinenko * fs/i386/pc/pxe.c (grub_pxefs_open): Correctly handle PXE choosing blocksize different from specified. (grub_pxefs_read): Likewise. --- ChangeLog.pxefix | 6 ++++++ fs/i386/pc/pxe.c | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 ChangeLog.pxefix diff --git a/ChangeLog.pxefix b/ChangeLog.pxefix new file mode 100644 index 000000000..a599f9eef --- /dev/null +++ b/ChangeLog.pxefix @@ -0,0 +1,6 @@ +2009-11-14 Vladimir Serbinenko + + * fs/i386/pc/pxe.c (grub_pxefs_open): Correctly handle PXE choosing + blocksize different from specified. + (grub_pxefs_read): Likewise. + diff --git a/fs/i386/pc/pxe.c b/fs/i386/pc/pxe.c index 4032e1254..6c41d4298 100644 --- a/fs/i386/pc/pxe.c +++ b/fs/i386/pc/pxe.c @@ -150,7 +150,7 @@ grub_pxefs_open (struct grub_file *file, const char *name) if (! data) return grub_errno; - data->block_size = grub_pxe_blksize; + data->block_size = c.c2.packet_size; grub_strcpy (data->filename, name); file_int = grub_malloc (sizeof (*file_int)); @@ -205,13 +205,14 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len) o.gateway_ip = grub_pxe_gateway_ip; grub_strcpy ((char *)&o.filename[0], data->filename); o.tftp_port = grub_cpu_to_be16 (GRUB_PXE_TFTP_PORT); - o.packet_size = data->block_size; + o.packet_size = grub_pxe_blksize; grub_pxe_call (GRUB_PXENV_TFTP_OPEN, &o); if (o.status) { grub_error (GRUB_ERR_BAD_FS, "open fails"); return -1; } + data->block_size = o.packet_size; data->packet_number = 0; curr_file = file; } @@ -219,7 +220,7 @@ grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len) c.buffer = SEGOFS (GRUB_MEMORY_MACHINE_SCRATCH_ADDR); while (pn >= data->packet_number) { - c.buffer_size = grub_pxe_blksize; + c.buffer_size = data->block_size; grub_pxe_call (GRUB_PXENV_TFTP_READ, &c); if (c.status) { From a415847694c8cdc12bb1007caced479d4a5f38ad Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sat, 14 Nov 2009 21:20:02 +0000 Subject: [PATCH 07/14] 2009-11-14 Robert Millan Fix help2man generation for mkisofs. * util/mkisofs/mkisofs.c (ld_options): Recognize --help. (usage): Send output to stdout (rather than stderr). --- ChangeLog | 7 +++++++ util/mkisofs/mkisofs.c | 24 +++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04ff39c84..2b5c24e96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-14 Robert Millan + + Fix help2man generation for mkisofs. + + * util/mkisofs/mkisofs.c (ld_options): Recognize --help. + (usage): Send output to stdout (rather than stderr). + 2009-11-14 Robert Millan * conf/i386-coreboot.rmk (grub_mkrescue_SOURCES): Replace diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index 0c89a2d8c..bc63967d0 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -227,6 +227,8 @@ static const struct ld_option ld_options[] = 'f', NULL, "Follow symbolic links", ONE_DASH }, { {"help", no_argument, NULL, OPTION_HELP}, '\0', NULL, "Print option help", ONE_DASH }, + { {"help", no_argument, NULL, OPTION_HELP}, + '\0', NULL, "Print option help", TWO_DASHES }, { {"hide", required_argument, NULL, OPTION_I_HIDE}, '\0', "GLOBFILE", "Hide ISO9660/RR file" , ONE_DASH }, { {"hide-joliet", required_argument, NULL, OPTION_J_HIDE}, @@ -476,9 +478,9 @@ void usage(){ unsigned int i; /* const char **targets, **pp;*/ - fprintf (stderr, "Usage: %s [options] file...\n", program_name); + printf ("Usage: %s [options] file...\n", program_name); - fprintf (stderr, "Options:\n"); + printf ("Options:\n"); for (i = 0; i < OPTION_COUNT; i++) { if (ld_options[i].doc != NULL) @@ -487,7 +489,7 @@ void usage(){ int len; unsigned int j; - fprintf (stderr, " "); + printf (" "); comma = FALSE; len = 2; @@ -498,16 +500,16 @@ void usage(){ if (ld_options[j].shortopt != '\0' && ld_options[j].control != NO_HELP) { - fprintf (stderr, "%s-%c", comma ? ", " : "", ld_options[j].shortopt); + printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt); len += (comma ? 2 : 0) + 2; if (ld_options[j].arg != NULL) { if (ld_options[j].opt.has_arg != optional_argument) { - fprintf (stderr, " "); + putchar (' '); ++len; } - fprintf (stderr, "%s", ld_options[j].arg); + printf ("%s", ld_options[j].arg); len += strlen (ld_options[j].arg); } comma = TRUE; @@ -522,7 +524,7 @@ void usage(){ if (ld_options[j].opt.name != NULL && ld_options[j].control != NO_HELP) { - fprintf (stderr, "%s-%s%s", + printf ("%s-%s%s", comma ? ", " : "", ld_options[j].control == TWO_DASHES ? "-" : "", ld_options[j].opt.name); @@ -532,7 +534,7 @@ void usage(){ + strlen (ld_options[j].opt.name)); if (ld_options[j].arg != NULL) { - fprintf (stderr, " %s", ld_options[j].arg); + printf (" %s", ld_options[j].arg); len += 1 + strlen (ld_options[j].arg); } comma = TRUE; @@ -543,14 +545,14 @@ void usage(){ if (len >= 30) { - fprintf (stderr, "\n"); + printf ("\n"); len = 0; } for (; len < 30; len++) - fputc (' ', stderr); + putchar (' '); - fprintf (stderr, "%s\n", ld_options[i].doc); + printf ("%s\n", ld_options[i].doc); } } exit(1); From 16a88c491cc847ef6ef00d9dc32d082f2b58b660 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Sun, 15 Nov 2009 13:41:25 +0100 Subject: [PATCH 08/14] 2009-11-15 Felix Zielcke * Makefile.in (TARGET_CPPFLAGS): Replace `-isystem=$(srcdir)/include' with `-nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)'. --- ChangeLog | 5 +++++ Makefile.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 2b5c24e96..b94848080 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-15 Felix Zielcke + + * Makefile.in (TARGET_CPPFLAGS): Replace `-isystem=$(srcdir)/include' + with `-nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)'. + 2009-11-14 Robert Millan Fix help2man generation for mkisofs. diff --git a/Makefile.in b/Makefile.in index 61b966995..89d5189eb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,7 +75,7 @@ TARGET_ASFLAGS = @TARGET_ASFLAGS@ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@ TARGET_APPLE_CC = @TARGET_APPLE_CC@ OBJCONV = @OBJCONV@ -TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -isystem=$(srcdir)/include -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \ +TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \ -Wall -W TARGET_LDFLAGS = @TARGET_LDFLAGS@ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@ From fd6fd3d770f73712a132eae81e4d404105779859 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 15 Nov 2009 14:02:33 +0000 Subject: [PATCH 09/14] 2009-11-15 Robert Millan Support --version in grub-mkisofs. * util/mkisofs/mkisofs.c (rcsid): Remove variable. (OPTION_VERSION): New macro. (ld_options): Recognize --version. (usage): Move `program_name' from here ... (program_name): ... to here. Add `static' qualifier. (main): Recognize `OPTION_VERSION'. --- ChangeLog | 11 +++++++++++ util/mkisofs/mkisofs.c | 21 +++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b94848080..b0958fc91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-11-15 Robert Millan + + Support --version in grub-mkisofs. + + * util/mkisofs/mkisofs.c (rcsid): Remove variable. + (OPTION_VERSION): New macro. + (ld_options): Recognize --version. + (usage): Move `program_name' from here ... + (program_name): ... to here. Add `static' qualifier. + (main): Recognize `OPTION_VERSION'. + 2009-11-15 Felix Zielcke * Makefile.in (TARGET_CPPFLAGS): Replace `-isystem=$(srcdir)/include' diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index bc63967d0..8d2af16ff 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -22,7 +22,7 @@ along with this program; if not, see . Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -static char rcsid[] ="$Id: mkisofs.c,v 1.32 1999/03/07 21:48:49 eric Exp $"; +static const char *program_name = "grub-mkisofs"; #include #include "config.h" @@ -195,6 +195,8 @@ struct ld_option #define OPTION_NO_EMUL_BOOT 171 #define OPTION_ELTORITO_EMUL_FLOPPY 172 +#define OPTION_VERSION 173 + static const struct ld_option ld_options[] = { { {"all-files", no_argument, NULL, 'a'}, @@ -229,6 +231,8 @@ static const struct ld_option ld_options[] = '\0', NULL, "Print option help", ONE_DASH }, { {"help", no_argument, NULL, OPTION_HELP}, '\0', NULL, "Print option help", TWO_DASHES }, + { {"version", no_argument, NULL, OPTION_VERSION}, + '\0', NULL, "Print version information and exit", TWO_DASHES }, { {"hide", required_argument, NULL, OPTION_I_HIDE}, '\0', "GLOBFILE", "Hide ISO9660/RR file" , ONE_DASH }, { {"hide-joliet", required_argument, NULL, OPTION_J_HIDE}, @@ -464,17 +468,6 @@ int goof = 0; #endif void usage(){ - const char * program_name = "mkisofs"; -#if 0 - fprintf(stderr,"Usage:\n"); - fprintf(stderr, -"mkisofs [-o outfile] [-R] [-V volid] [-v] [-a] \ -[-T]\n [-l] [-d] [-V] [-D] [-L] [-p preparer]" -"[-P publisher] [ -A app_id ] [-z] \n \ -[-b boot_image_name] [-c boot_catalog-name] \ -[-x path -x path ...] path\n"); -#endif - unsigned int i; /* const char **targets, **pp;*/ @@ -888,6 +881,10 @@ int FDECL2(main, int, argc, char **, argv){ usage (); exit (0); break; + case OPTION_VERSION: + printf ("%s (%s %s)\n", program_name, PACKAGE_NAME, PACKAGE_VERSION); + exit (0); + break; case OPTION_NOSPLIT_SL_COMPONENT: split_SL_component = 0; break; From 83bdecaf2a60d7a8ba0f7b23ce34930eb543b11e Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 15 Nov 2009 23:22:45 +0000 Subject: [PATCH 10/14] 2009-11-16 Robert Millan Relicense multiboot.h, with RMS' blessing. * include/multiboot.h: Change to X11 license. --- ChangeLog | 6 ++++++ include/multiboot.h | 27 +++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0958fc91..2e4875916 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-16 Robert Millan + + Relicense multiboot.h, with RMS' blessing. + + * include/multiboot.h: Change to X11 license. + 2009-11-15 Robert Millan Support --version in grub-mkisofs. diff --git a/include/multiboot.h b/include/multiboot.h index f6e240b7b..9ce34f437 100644 --- a/include/multiboot.h +++ b/include/multiboot.h @@ -1,20 +1,23 @@ -/* multiboot.h - multiboot header file. */ /* - * GRUB -- GRand Unified Bootloader + * multiboot.h - Multiboot header file. * Copyright (C) 2003,2007,2008,2009 Free Software Foundation, Inc. * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ANY + * DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR + * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef MULTIBOOT_HEADER From 2af8f0f4fc7bfe13cbac545a14512e8bac9873b4 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Mon, 16 Nov 2009 16:01:15 +0100 Subject: [PATCH 11/14] 2009-11-16 Felix Zielcke Enable ata.mod on x86_64-efi, i386-efi and i386-ieee1275. * disk/ata.c (grub_ata_dumpinfo): Add a cast. (grub_ata_readwrite): Likewise. Update 2 format strings. (grub_atapi_read): Likewise. * conf/i386-coreboot.rmk (pkglib_MODULES): Move `ata.mod' from here ... * conf/i386.rmk (pkglib_MODULES): ... to here ... * conf/x86_64-efi.rmk (pkglib_MODULES): ... and here. * conf/i386-coreboot.rmk (ata_mod_SOURCES, ata_mod_CFLAGS) (ata_mod_LDFLAGS): Move from here ... * conf/i386.rmk: ... to here ... * conf/x86_64-efi.rmk: ... and here. * conf/i386-pc.rmk (pkglib_MODULES): Remove `ata.mod' (ata_mod_SOURCES, ata_mod_CFLAGS, ata_mod_LDFLAGS): Remove. --- ChangeLog | 18 ++++++++++++++++++ conf/i386-coreboot.rmk | 7 +------ conf/i386-pc.rmk | 17 ++++++----------- conf/i386.rmk | 5 +++++ conf/x86_64-efi.rmk | 9 +++++++-- disk/ata.c | 8 ++++---- 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e4875916..c7ba18d1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2009-11-16 Felix Zielcke + + Enable ata.mod on x86_64-efi, i386-efi and i386-ieee1275. + + * disk/ata.c (grub_ata_dumpinfo): Add a cast. + (grub_ata_readwrite): Likewise. Update 2 format strings. + (grub_atapi_read): Likewise. + + * conf/i386-coreboot.rmk (pkglib_MODULES): Move `ata.mod' from here ... + * conf/i386.rmk (pkglib_MODULES): ... to here ... + * conf/x86_64-efi.rmk (pkglib_MODULES): ... and here. + * conf/i386-coreboot.rmk (ata_mod_SOURCES, ata_mod_CFLAGS) + (ata_mod_LDFLAGS): Move from here ... + * conf/i386.rmk: ... to here ... + * conf/x86_64-efi.rmk: ... and here. + * conf/i386-pc.rmk (pkglib_MODULES): Remove `ata.mod' + (ata_mod_SOURCES, ata_mod_CFLAGS, ata_mod_LDFLAGS): Remove. + 2009-11-16 Robert Millan Relicense multiboot.h, with RMS' blessing. diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index 9a60db785..c506e4153 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -157,7 +157,7 @@ grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. pkglib_MODULES = linux.mod multiboot.mod \ - aout.mod play.mod serial.mod ata.mod \ + aout.mod play.mod serial.mod \ memdisk.mod pci.mod lspci.mod reboot.mod \ halt.mod datetime.mod date.mod datehook.mod \ lsmmap.mod mmap.mod @@ -221,11 +221,6 @@ play_mod_SOURCES = commands/i386/pc/play.c play_mod_CFLAGS = $(COMMON_CFLAGS) play_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For ata.mod. -ata_mod_SOURCES = disk/ata.c -ata_mod_CFLAGS = $(COMMON_CFLAGS) -ata_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For memdisk.mod. memdisk_mod_SOURCES = disk/memdisk.c memdisk_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index a3aae6bad..90bc2b2e3 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -177,12 +177,12 @@ grub_mkrescue_SOURCES = util/grub-mkrescue.in bin_SCRIPTS += grub-mkfloppy grub_mkfloppy_SOURCES = util/i386/pc/grub-mkfloppy.in -pkglib_MODULES = biosdisk.mod chain.mod \ - multiboot.mod reboot.mod halt.mod \ - vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \ - ata.mod vga.mod memdisk.mod pci.mod lspci.mod \ - aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \ - datehook.mod lsmmap.mod ata_pthru.mod hdparm.mod \ +pkglib_MODULES = biosdisk.mod chain.mod \ + multiboot.mod reboot.mod halt.mod \ + vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \ + vga.mod memdisk.mod pci.mod lspci.mod \ + aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \ + datehook.mod lsmmap.mod ata_pthru.mod hdparm.mod \ usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \ efiemu.mod mmap.mod acpi.mod drivemap.mod @@ -293,11 +293,6 @@ play_mod_SOURCES = commands/i386/pc/play.c play_mod_CFLAGS = $(COMMON_CFLAGS) play_mod_LDFLAGS = $(COMMON_LDFLAGS) -# For ata.mod. -ata_mod_SOURCES = disk/ata.c -ata_mod_CFLAGS = $(COMMON_CFLAGS) -ata_mod_LDFLAGS = $(COMMON_LDFLAGS) - # For vga.mod. vga_mod_SOURCES = term/i386/pc/vga.c vga_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386.rmk b/conf/i386.rmk index 93f84ce39..bf102a9b6 100644 --- a/conf/i386.rmk +++ b/conf/i386.rmk @@ -14,3 +14,8 @@ pkglib_MODULES += vga_text.mod vga_text_mod_SOURCES = term/i386/pc/vga_text.c term/i386/vga_common.c vga_text_mod_CFLAGS = $(COMMON_CFLAGS) vga_text_mod_LDFLAGS = $(COMMON_LDFLAGS) + +pkglib_MODULES += ata.mod +ata_mod_SOURCES = disk/ata.c +ata_mod_CFLAGS = $(COMMON_CFLAGS) +ata_mod_LDFLAGS = $(COMMON_LDFLAGS) diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk index 5be1b404f..f536746ef 100644 --- a/conf/x86_64-efi.rmk +++ b/conf/x86_64-efi.rmk @@ -81,10 +81,10 @@ sbin_SCRIPTS = grub-install grub_install_SOURCES = util/i386/efi/grub-install.in # Modules. -pkglib_MODULES = kernel.mod chain.mod appleldr.mod \ +pkglib_MODULES = kernel.mod chain.mod appleldr.mod \ halt.mod reboot.mod linux.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ - fixvideo.mod mmap.mod acpi.mod + fixvideo.mod mmap.mod acpi.mod ata.mod # For kernel.mod. kernel_mod_EXPORTS = no @@ -129,6 +129,11 @@ acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c acpi_mod_CFLAGS = $(COMMON_CFLAGS) acpi_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For ata.mod +ata_mod_SOURCES = disk/ata.c +ata_mod_CFLAGS = $(COMMON_CFLAGS) +ata_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For mmap.mod. mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \ mmap/efi/mmap.c diff --git a/disk/ata.c b/disk/ata.c index 78d396526..11489828f 100644 --- a/disk/ata.c +++ b/disk/ata.c @@ -140,7 +140,7 @@ grub_ata_dumpinfo (struct grub_ata_device *dev, char *info) if (! dev->atapi) { grub_dprintf ("ata", "Addressing: %d\n", dev->addr); - grub_dprintf ("ata", "Sectors: %lld\n", dev->size); + grub_dprintf ("ata", "Sectors: %lld\n", (unsigned long long) dev->size); } } @@ -569,7 +569,7 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector, { struct grub_ata_device *dev = (struct grub_ata_device *) disk->data; - grub_dprintf("ata", "grub_ata_readwrite (size=%u, rw=%d)\n", size, rw); + grub_dprintf("ata", "grub_ata_readwrite (size=%llu, rw=%d)\n", (unsigned long long) size, rw); grub_ata_addressing_t addressing = dev->addr; grub_size_t batch; @@ -596,7 +596,7 @@ grub_ata_readwrite (grub_disk_t disk, grub_disk_addr_t sector, if (size - nsectors < batch) batch = size - nsectors; - grub_dprintf("ata", "rw=%d, sector=%llu, batch=%u\n", rw, sector, batch); + grub_dprintf("ata", "rw=%d, sector=%llu, batch=%llu\n", rw, (unsigned long long) sector, (unsigned long long) batch); /* Send read/write command. */ if (grub_ata_setaddress (dev, addressing, sector, batch)) @@ -755,7 +755,7 @@ grub_atapi_read (struct grub_scsi *scsi, { struct grub_ata_device *dev = (struct grub_ata_device *) scsi->data; - grub_dprintf("ata", "grub_atapi_read (size=%u)\n", size); + grub_dprintf("ata", "grub_atapi_read (size=%llu)\n", (unsigned long long) size); if (grub_atapi_packet (dev, cmd, size)) return grub_errno; From 73fb3dd5f0750cb6f69979d806bbc9e56dc89e60 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Mon, 16 Nov 2009 19:47:10 +0100 Subject: [PATCH 12/14] 2009-11-16 Felix Zielcke * util/mkisofs/name.c (FDECL3): Use isascii macro instead of relying that char is signed. --- ChangeLog | 5 +++++ util/mkisofs/name.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb159de75..affe343d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-11-16 Felix Zielcke + + * util/mkisofs/name.c (FDECL3): Use isascii macro instead of + relying that char is signed. + 2009-11-16 Vladimir Serbinenko * fs/i386/pc/pxe.c (grub_pxefs_open): Correctly handle PXE choosing diff --git a/util/mkisofs/name.c b/util/mkisofs/name.c index 4df5b9de4..5d4597ae6 100644 --- a/util/mkisofs/name.c +++ b/util/mkisofs/name.c @@ -213,7 +213,7 @@ int FDECL3(iso9660_file_length, } if(current_length < 30) { - if( *pnt < 0 ) + if( !isascii (*pnt)) { *result++ = '_'; } @@ -281,7 +281,7 @@ int FDECL3(iso9660_file_length, switch (*pnt) { default: - if( *pnt < 0 ) + if( !isascii (*pnt) ) { *result++ = '_'; } From af2f93ac474b0ec2db48776060e41ef8605e132b Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Mon, 16 Nov 2009 18:49:44 +0000 Subject: [PATCH 13/14] 2009-11-16 Robert Millan Fix build for systems without error(). * gnulib/error.c: New file (imported from Gnulib). * gnulib/error.h: Likewise. * conf/common.rmk (grub_mkisofs_SOURCES): Add `gnulib/error.c'. * util/mkisofs/mkisofs.c (program_name): Remove `static' qualifier (this variable is now used by error()). --- ChangeLog | 10 ++ conf/common.rmk | 3 +- gnulib/error.c | 352 +++++++++++++++++++++++++++++++++++++++++ gnulib/error.h | 65 ++++++++ util/mkisofs/mkisofs.c | 2 +- 5 files changed, 430 insertions(+), 2 deletions(-) create mode 100644 gnulib/error.c create mode 100644 gnulib/error.h diff --git a/ChangeLog b/ChangeLog index affe343d9..a7cb6af24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-11-16 Robert Millan + + Fix build for systems without error(). + + * gnulib/error.c: New file (imported from Gnulib). + * gnulib/error.h: Likewise. + * conf/common.rmk (grub_mkisofs_SOURCES): Add `gnulib/error.c'. + * util/mkisofs/mkisofs.c (program_name): Remove `static' qualifier + (this variable is now used by error()). + 2009-11-16 Felix Zielcke * util/mkisofs/name.c (FDECL3): Use isascii macro instead of diff --git a/conf/common.rmk b/conf/common.rmk index a66bd97fd..54bec37b0 100644 --- a/conf/common.rmk +++ b/conf/common.rmk @@ -36,7 +36,8 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \ util/mkisofs/rock.c util/mkisofs/tree.c \ util/mkisofs/write.c \ \ - gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c + gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c \ + gnulib/error.c grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \ -I$(srcdir)/util/mkisofs/include -I$(srcdir)/gnulib \ -Wno-all -Werror diff --git a/gnulib/error.c b/gnulib/error.c new file mode 100644 index 000000000..af2287b27 --- /dev/null +++ b/gnulib/error.c @@ -0,0 +1,352 @@ +/* Error handler for noninteractive utilities + Copyright (C) 1990-1998, 2000-2007, 2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by David MacKenzie . */ + +#if !_LIBC +# include +#endif + +#include "error.h" + +#include +#include +#include +#include + +#if !_LIBC && ENABLE_NLS +# include "gettext.h" +# define _(msgid) gettext (msgid) +#endif + +#ifdef _LIBC +# include +# include +# include +# include +# define mbsrtowcs __mbsrtowcs +#endif + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + +#ifndef _ +# define _(String) String +#endif + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +void (*error_print_progname) (void); + +/* This variable is incremented each time `error' is called. */ +unsigned int error_message_count; + +#ifdef _LIBC +/* In the GNU C library, there is a predefined variable for this. */ + +# define program_name program_invocation_name +# include +# include +# include + +/* In GNU libc we want do not want to use the common name `error' directly. + Instead make it a weak alias. */ +extern void __error (int status, int errnum, const char *message, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); +extern void __error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, + ...) + __attribute__ ((__format__ (__printf__, 5, 6)));; +# define error __error +# define error_at_line __error_at_line + +# include +# define fflush(s) INTUSE(_IO_fflush) (s) +# undef putc +# define putc(c, fp) INTUSE(_IO_putc) (c, fp) + +# include + +#else /* not _LIBC */ + +# include + +# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P +# ifndef HAVE_DECL_STRERROR_R +"this configure-time declaration test was not run" +# endif +char *strerror_r (); +# endif + +/* The calling program should define program_name and set it to the + name of the executing program. */ +extern char *program_name; + +# if HAVE_STRERROR_R || defined strerror_r +# define __strerror_r strerror_r +# endif /* HAVE_STRERROR_R || defined strerror_r */ +#endif /* not _LIBC */ + +static void +print_errno_message (int errnum) +{ + char const *s; + +#if defined HAVE_STRERROR_R || _LIBC + char errbuf[1024]; +# if STRERROR_R_CHAR_P || _LIBC + s = __strerror_r (errnum, errbuf, sizeof errbuf); +# else + if (__strerror_r (errnum, errbuf, sizeof errbuf) == 0) + s = errbuf; + else + s = 0; +# endif +#else + s = strerror (errnum); +#endif + +#if !_LIBC + if (! s) + s = _("Unknown system error"); +#endif + +#if _LIBC + __fxprintf (NULL, ": %s", s); +#else + fprintf (stderr, ": %s", s); +#endif +} + +static void +error_tail (int status, int errnum, const char *message, va_list args) +{ +#if _LIBC + if (_IO_fwide (stderr, 0) > 0) + { +# define ALLOCA_LIMIT 2000 + size_t len = strlen (message) + 1; + wchar_t *wmessage = NULL; + mbstate_t st; + size_t res; + const char *tmp; + bool use_malloc = false; + + while (1) + { + if (__libc_use_alloca (len * sizeof (wchar_t))) + wmessage = (wchar_t *) alloca (len * sizeof (wchar_t)); + else + { + if (!use_malloc) + wmessage = NULL; + + wchar_t *p = (wchar_t *) realloc (wmessage, + len * sizeof (wchar_t)); + if (p == NULL) + { + free (wmessage); + fputws_unlocked (L"out of memory\n", stderr); + return; + } + wmessage = p; + use_malloc = true; + } + + memset (&st, '\0', sizeof (st)); + tmp = message; + + res = mbsrtowcs (wmessage, &tmp, len, &st); + if (res != len) + break; + + if (__builtin_expect (len >= SIZE_MAX / 2, 0)) + { + /* This really should not happen if everything is fine. */ + res = (size_t) -1; + break; + } + + len *= 2; + } + + if (res == (size_t) -1) + { + /* The string cannot be converted. */ + if (use_malloc) + { + free (wmessage); + use_malloc = false; + } + wmessage = (wchar_t *) L"???"; + } + + __vfwprintf (stderr, wmessage, args); + + if (use_malloc) + free (wmessage); + } + else +#endif + vfprintf (stderr, message, args); + va_end (args); + + ++error_message_count; + if (errnum) + print_errno_message (errnum); +#if _LIBC + __fxprintf (NULL, "\n"); +#else + putc ('\n', stderr); +#endif + fflush (stderr); + if (status) + exit (status); +} + + +/* Print the program name and error message MESSAGE, which is a printf-style + format string with optional args. + If ERRNUM is nonzero, print its corresponding system error message. + Exit with status STATUS if it is nonzero. */ +void +error (int status, int errnum, const char *message, ...) +{ + va_list args; + +#if defined _LIBC && defined __libc_ptf_call + /* We do not want this call to be cut short by a thread + cancellation. Therefore disable cancellation for now. */ + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + 0); +#endif + +#if !_LIBC && defined F_GETFL + /* POSIX states that fflush (stdout) after fclose is unspecified; it + is safe in glibc, but not on all other platforms. fflush (NULL) + is always defined, but too draconian. */ + if (0 <= fcntl (1, F_GETFL)) +#endif + fflush (stdout); +#ifdef _LIBC + _IO_flockfile (stderr); +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC + __fxprintf (NULL, "%s: ", program_name); +#else + fprintf (stderr, "%s: ", program_name); +#endif + } + + va_start (args, message); + error_tail (status, errnum, message, args); + +#ifdef _LIBC + _IO_funlockfile (stderr); +# ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +# endif +#endif +} + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +int error_one_per_line; + +void +error_at_line (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, ...) +{ + va_list args; + + if (error_one_per_line) + { + static const char *old_file_name; + static unsigned int old_line_number; + + if (old_line_number == line_number + && (file_name == old_file_name + || strcmp (old_file_name, file_name) == 0)) + /* Simply return and print nothing. */ + return; + + old_file_name = file_name; + old_line_number = line_number; + } + +#if defined _LIBC && defined __libc_ptf_call + /* We do not want this call to be cut short by a thread + cancellation. Therefore disable cancellation for now. */ + int state = PTHREAD_CANCEL_ENABLE; + __libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state), + 0); +#endif + +#if !_LIBC && defined F_GETFL + /* POSIX states that fflush (stdout) after fclose is unspecified; it + is safe in glibc, but not on all other platforms. fflush (NULL) + is always defined, but too draconian. */ + if (0 <= fcntl (1, F_GETFL)) +#endif + fflush (stdout); +#ifdef _LIBC + _IO_flockfile (stderr); +#endif + if (error_print_progname) + (*error_print_progname) (); + else + { +#if _LIBC + __fxprintf (NULL, "%s:", program_name); +#else + fprintf (stderr, "%s:", program_name); +#endif + } + +#if _LIBC + __fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ", + file_name, line_number); +#else + fprintf (stderr, file_name != NULL ? "%s:%d: " : " ", + file_name, line_number); +#endif + + va_start (args, message); + error_tail (status, errnum, message, args); + +#ifdef _LIBC + _IO_funlockfile (stderr); +# ifdef __libc_ptf_call + __libc_ptf_call (pthread_setcancelstate, (state, NULL), 0); +# endif +#endif +} + +#ifdef _LIBC +/* Make the weak alias. */ +# undef error +# undef error_at_line +weak_alias (__error, error) +weak_alias (__error_at_line, error_at_line) +#endif diff --git a/gnulib/error.h b/gnulib/error.h new file mode 100644 index 000000000..6d4968114 --- /dev/null +++ b/gnulib/error.h @@ -0,0 +1,65 @@ +/* Declaration for error-reporting function + Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef _ERROR_H +#define _ERROR_H 1 + +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +# define __attribute__(Spec) /* empty */ +# endif +/* The __-protected variants of `format' and `printf' attributes + are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __format__ format +# define __printf__ printf +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Print a message with `fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ + +extern void error (int __status, int __errnum, const char *__format, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +extern void error_at_line (int __status, int __errnum, const char *__fname, + unsigned int __lineno, const char *__format, ...) + __attribute__ ((__format__ (__printf__, 5, 6))); + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +extern void (*error_print_progname) (void); + +/* This variable is incremented each time `error' is called. */ +extern unsigned int error_message_count; + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +extern int error_one_per_line; + +#ifdef __cplusplus +} +#endif + +#endif /* error.h */ diff --git a/util/mkisofs/mkisofs.c b/util/mkisofs/mkisofs.c index 8d2af16ff..4d1132cc8 100644 --- a/util/mkisofs/mkisofs.c +++ b/util/mkisofs/mkisofs.c @@ -22,7 +22,7 @@ along with this program; if not, see . Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -static const char *program_name = "grub-mkisofs"; +const char *program_name = "grub-mkisofs"; #include #include "config.h" From 814f5e9698de934ec44b08d6564e0813fba30ce6 Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Mon, 16 Nov 2009 19:54:23 +0100 Subject: [PATCH 14/14] Use real function name in ChangeLog entry for r1837 --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7cb6af24..19204e992 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,8 +10,8 @@ 2009-11-16 Felix Zielcke - * util/mkisofs/name.c (FDECL3): Use isascii macro instead of - relying that char is signed. + * util/mkisofs/name.c (iso9660_file_length): Use isascii macro + instead of relying that char is signed. 2009-11-16 Vladimir Serbinenko