Replace grub_module_iterate with FOR_MODULES.
* grub-core/disk/memdisk.c (GRUB_MOD_INIT): Switched to new interface. * grub-core/kern/efi/efi.c (grub_arch_modules_addr): Renamed to... (grub_efi_modules_addr): ...this. * grub-core/kern/efi/init.c (grub_modbase): New variable. (grub_efi_init): Set grub_modbase. * grub-core/kern/emu/main.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. * grub-core/kern/i386/coreboot/init.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. (grub_machine_init): Set grub_modbase. * grub-core/kern/i386/pc/init.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. (grub_machine_init): Set grub_modbase. * grub-core/kern/ieee1275/init.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. (grub_machine_init): Set grub_modbase. * grub-core/kern/main.c (grub_module_iterate): Remove. (grub_modules_get_end): Use grub_modbase. (grub_load_modules): Use FOR_MODULES. (grub_load_config): Likewise. * grub-core/kern/mips/arc/init.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. (grub_machine_init): Set grub_modbase. * grub-core/kern/mips/loongson/init.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. (grub_machine_init): Set grub_modbase. * grub-core/kern/mips/qemu_mips/init.c (grub_arch_modules_addr): Removed. (grub_modbase): New variable. (grub_machine_init): Set grub_modbase. * include/grub/efi/efi.h (grub_efi_modules_addr): New declaration. * include/grub/kernel.h (grub_arch_modules_addr): Removed. (grub_module_iterate): Likewise. (grub_modbase): New variable declaration. (FOR_MODULES): New macro.
This commit is contained in:
parent
2afb7f6cbf
commit
39705fadd7
14 changed files with 117 additions and 126 deletions
40
ChangeLog
40
ChangeLog
|
@ -1,3 +1,43 @@
|
||||||
|
2011-10-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Replace grub_module_iterate with FOR_MODULES.
|
||||||
|
|
||||||
|
* grub-core/disk/memdisk.c (GRUB_MOD_INIT): Switched to new interface.
|
||||||
|
* grub-core/kern/efi/efi.c (grub_arch_modules_addr): Renamed to...
|
||||||
|
(grub_efi_modules_addr): ...this.
|
||||||
|
* grub-core/kern/efi/init.c (grub_modbase): New variable.
|
||||||
|
(grub_efi_init): Set grub_modbase.
|
||||||
|
* grub-core/kern/emu/main.c (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
* grub-core/kern/i386/coreboot/init.c (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
(grub_machine_init): Set grub_modbase.
|
||||||
|
* grub-core/kern/i386/pc/init.c (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
(grub_machine_init): Set grub_modbase.
|
||||||
|
* grub-core/kern/ieee1275/init.c (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
(grub_machine_init): Set grub_modbase.
|
||||||
|
* grub-core/kern/main.c (grub_module_iterate): Remove.
|
||||||
|
(grub_modules_get_end): Use grub_modbase.
|
||||||
|
(grub_load_modules): Use FOR_MODULES.
|
||||||
|
(grub_load_config): Likewise.
|
||||||
|
* grub-core/kern/mips/arc/init.c (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
(grub_machine_init): Set grub_modbase.
|
||||||
|
* grub-core/kern/mips/loongson/init.c (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
(grub_machine_init): Set grub_modbase.
|
||||||
|
* grub-core/kern/mips/qemu_mips/init.c (grub_arch_modules_addr):
|
||||||
|
Removed.
|
||||||
|
(grub_modbase): New variable.
|
||||||
|
(grub_machine_init): Set grub_modbase.
|
||||||
|
* include/grub/efi/efi.h (grub_efi_modules_addr): New declaration.
|
||||||
|
* include/grub/kernel.h (grub_arch_modules_addr): Removed.
|
||||||
|
(grub_module_iterate): Likewise.
|
||||||
|
(grub_modbase): New variable declaration.
|
||||||
|
(FOR_MODULES): New macro.
|
||||||
|
|
||||||
2011-10-16 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-10-16 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* configure.ac: Check for __ctzdi2 and __ctzsi2.
|
* configure.ac: Check for __ctzdi2 and __ctzsi2.
|
||||||
|
|
|
@ -86,9 +86,8 @@ static struct grub_disk_dev grub_memdisk_dev =
|
||||||
|
|
||||||
GRUB_MOD_INIT(memdisk)
|
GRUB_MOD_INIT(memdisk)
|
||||||
{
|
{
|
||||||
auto int hook (struct grub_module_header *);
|
struct grub_module_header *header;
|
||||||
int hook (struct grub_module_header *header)
|
FOR_MODULES (header)
|
||||||
{
|
|
||||||
if (header->type == OBJ_TYPE_MEMDISK)
|
if (header->type == OBJ_TYPE_MEMDISK)
|
||||||
{
|
{
|
||||||
char *memdisk_orig_addr;
|
char *memdisk_orig_addr;
|
||||||
|
@ -103,13 +102,8 @@ GRUB_MOD_INIT(memdisk)
|
||||||
grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);
|
grub_memmove (memdisk_addr, memdisk_orig_addr, memdisk_size);
|
||||||
|
|
||||||
grub_disk_dev_register (&grub_memdisk_dev);
|
grub_disk_dev_register (&grub_memdisk_dev);
|
||||||
return 1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
grub_module_iterate (hook);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(memdisk)
|
GRUB_MOD_FINI(memdisk)
|
||||||
|
|
|
@ -218,7 +218,7 @@ grub_get_rtc (void)
|
||||||
/* Search the mods section from the PE32/PE32+ image. This code uses
|
/* Search the mods section from the PE32/PE32+ image. This code uses
|
||||||
a PE32 header, but should work with PE32+ as well. */
|
a PE32 header, but should work with PE32+ as well. */
|
||||||
grub_addr_t
|
grub_addr_t
|
||||||
grub_arch_modules_addr (void)
|
grub_efi_modules_addr (void)
|
||||||
{
|
{
|
||||||
grub_efi_loaded_image_t *image;
|
grub_efi_loaded_image_t *image;
|
||||||
struct grub_pe32_header *header;
|
struct grub_pe32_header *header;
|
||||||
|
|
|
@ -26,9 +26,12 @@
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
|
|
||||||
|
grub_addr_t grub_modbase;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_efi_init (void)
|
grub_efi_init (void)
|
||||||
{
|
{
|
||||||
|
grub_modbase = grub_efi_modules_addr ();
|
||||||
/* First of all, initialize the console so that GRUB can display
|
/* First of all, initialize the console so that GRUB can display
|
||||||
messages. */
|
messages. */
|
||||||
grub_console_init ();
|
grub_console_init ();
|
||||||
|
|
|
@ -53,11 +53,7 @@ static char *root_dev = NULL, *dir = NULL;
|
||||||
|
|
||||||
int grub_no_autoload;
|
int grub_no_autoload;
|
||||||
|
|
||||||
grub_addr_t
|
grub_addr_t grub_modbase = 0;
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_reboot (void)
|
grub_reboot (void)
|
||||||
|
|
|
@ -56,10 +56,18 @@ grub_exit (void)
|
||||||
grub_cpu_idle ();
|
grub_cpu_idle ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_QEMU
|
||||||
|
grub_addr_t grub_modbase;
|
||||||
|
#else
|
||||||
|
grub_addr_t grub_modbase = ALIGN_UP((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_machine_init (void)
|
grub_machine_init (void)
|
||||||
{
|
{
|
||||||
#ifdef GRUB_MACHINE_QEMU
|
#ifdef GRUB_MACHINE_QEMU
|
||||||
|
grub_modbase = grub_core_entry_addr + grub_kernel_image_size;
|
||||||
|
|
||||||
grub_qemu_init_cirrus ();
|
grub_qemu_init_cirrus ();
|
||||||
#endif
|
#endif
|
||||||
/* Initialize the console as early as possible. */
|
/* Initialize the console as early as possible. */
|
||||||
|
@ -118,14 +126,3 @@ grub_machine_fini (void)
|
||||||
grub_vga_text_fini ();
|
grub_vga_text_fini ();
|
||||||
grub_stop_floppy ();
|
grub_stop_floppy ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the end of the core image. */
|
|
||||||
grub_addr_t
|
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
#ifdef GRUB_MACHINE_QEMU
|
|
||||||
return grub_core_entry_addr + grub_kernel_image_size;
|
|
||||||
#else
|
|
||||||
return ALIGN_UP((grub_addr_t) _end, GRUB_KERNEL_MACHINE_MOD_ALIGN);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -129,6 +129,8 @@ compact_mem_regions (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_addr_t grub_modbase;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_machine_init (void)
|
grub_machine_init (void)
|
||||||
{
|
{
|
||||||
|
@ -137,6 +139,9 @@ grub_machine_init (void)
|
||||||
int grub_lower_mem;
|
int grub_lower_mem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
grub_modbase = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR
|
||||||
|
+ (grub_kernel_image_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
|
||||||
|
|
||||||
/* Initialize the console as early as possible. */
|
/* Initialize the console as early as possible. */
|
||||||
grub_console_init ();
|
grub_console_init ();
|
||||||
|
|
||||||
|
@ -206,11 +211,3 @@ grub_machine_fini (void)
|
||||||
grub_console_fini ();
|
grub_console_fini ();
|
||||||
grub_stop_floppy ();
|
grub_stop_floppy ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the end of the core image. */
|
|
||||||
grub_addr_t
|
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
return GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR
|
|
||||||
+ (grub_kernel_image_size - GRUB_KERNEL_MACHINE_RAW_SIZE);
|
|
||||||
}
|
|
||||||
|
|
|
@ -256,9 +256,14 @@ grub_parse_cmdline (void)
|
||||||
|
|
||||||
static grub_uint64_t ieee1275_get_time_ms (void);
|
static grub_uint64_t ieee1275_get_time_ms (void);
|
||||||
|
|
||||||
|
grub_addr_t grub_modbase;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_machine_init (void)
|
grub_machine_init (void)
|
||||||
{
|
{
|
||||||
|
grub_modbase = ALIGN_UP((grub_addr_t) _end
|
||||||
|
+ GRUB_KERNEL_MACHINE_MOD_GAP,
|
||||||
|
GRUB_KERNEL_MACHINE_MOD_ALIGN);
|
||||||
grub_ieee1275_init ();
|
grub_ieee1275_init ();
|
||||||
|
|
||||||
grub_console_init_early ();
|
grub_console_init_early ();
|
||||||
|
@ -293,9 +298,3 @@ grub_get_rtc (void)
|
||||||
{
|
{
|
||||||
return ieee1275_get_time_ms ();
|
return ieee1275_get_time_ms ();
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_addr_t
|
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
return ALIGN_UP((grub_addr_t) _end + GRUB_KERNEL_MACHINE_MOD_GAP, GRUB_KERNEL_MACHINE_MOD_ALIGN);
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,45 +30,20 @@
|
||||||
#include <grub/reader.h>
|
#include <grub/reader.h>
|
||||||
#include <grub/parser.h>
|
#include <grub/parser.h>
|
||||||
|
|
||||||
void
|
|
||||||
grub_module_iterate (int (*hook) (struct grub_module_header *header))
|
|
||||||
{
|
|
||||||
struct grub_module_info *modinfo;
|
|
||||||
struct grub_module_header *header;
|
|
||||||
grub_addr_t modbase;
|
|
||||||
|
|
||||||
modbase = grub_arch_modules_addr ();
|
|
||||||
modinfo = (struct grub_module_info *) modbase;
|
|
||||||
|
|
||||||
/* Check if there are any modules. */
|
|
||||||
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (header = (struct grub_module_header *) (modbase + modinfo->offset);
|
|
||||||
header < (struct grub_module_header *) (modbase + modinfo->size);
|
|
||||||
header = (struct grub_module_header *) ((char *) header + header->size))
|
|
||||||
{
|
|
||||||
if (hook (header))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is actualy platform-independant but used only on loongson and sparc. */
|
/* This is actualy platform-independant but used only on loongson and sparc. */
|
||||||
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_SPARC64)
|
#if defined (GRUB_MACHINE_MIPS_LOONGSON) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_SPARC64)
|
||||||
grub_addr_t
|
grub_addr_t
|
||||||
grub_modules_get_end (void)
|
grub_modules_get_end (void)
|
||||||
{
|
{
|
||||||
struct grub_module_info *modinfo;
|
struct grub_module_info *modinfo;
|
||||||
grub_addr_t modbase;
|
|
||||||
|
|
||||||
modbase = grub_arch_modules_addr ();
|
modinfo = (struct grub_module_info *) grub_modbase;
|
||||||
modinfo = (struct grub_module_info *) modbase;
|
|
||||||
|
|
||||||
/* Check if there are any modules. */
|
/* Check if there are any modules. */
|
||||||
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
|
if ((modinfo == 0) || modinfo->magic != GRUB_MODULE_MAGIC)
|
||||||
return modbase;
|
return grub_modbase;
|
||||||
|
|
||||||
return modbase + modinfo->size;
|
return grub_modbase + modinfo->size;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -76,12 +51,12 @@ grub_modules_get_end (void)
|
||||||
static void
|
static void
|
||||||
grub_load_modules (void)
|
grub_load_modules (void)
|
||||||
{
|
{
|
||||||
auto int hook (struct grub_module_header *);
|
struct grub_module_header *header;
|
||||||
int hook (struct grub_module_header *header)
|
FOR_MODULES (header)
|
||||||
{
|
{
|
||||||
/* Not an ELF module, skip. */
|
/* Not an ELF module, skip. */
|
||||||
if (header->type != OBJ_TYPE_ELF)
|
if (header->type != OBJ_TYPE_ELF)
|
||||||
return 0;
|
continue;
|
||||||
|
|
||||||
if (! grub_dl_load_core ((char *) header + sizeof (struct grub_module_header),
|
if (! grub_dl_load_core ((char *) header + sizeof (struct grub_module_header),
|
||||||
(header->size - sizeof (struct grub_module_header))))
|
(header->size - sizeof (struct grub_module_header))))
|
||||||
|
@ -89,29 +64,23 @@ grub_load_modules (void)
|
||||||
|
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
grub_print_error ();
|
grub_print_error ();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_module_iterate (hook);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_load_config (void)
|
grub_load_config (void)
|
||||||
{
|
{
|
||||||
auto int hook (struct grub_module_header *);
|
struct grub_module_header *header;
|
||||||
int hook (struct grub_module_header *header)
|
FOR_MODULES (header)
|
||||||
{
|
{
|
||||||
/* Not an embedded config, skip. */
|
/* Not an embedded config, skip. */
|
||||||
if (header->type != OBJ_TYPE_CONFIG)
|
if (header->type != OBJ_TYPE_CONFIG)
|
||||||
return 0;
|
continue;
|
||||||
|
|
||||||
grub_parser_execute ((char *) header +
|
grub_parser_execute ((char *) header +
|
||||||
sizeof (struct grub_module_header));
|
sizeof (struct grub_module_header));
|
||||||
return 1;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_module_iterate (hook);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write hook for the environment variables of root. Remove surrounding
|
/* Write hook for the environment variables of root. Remove surrounding
|
||||||
|
|
|
@ -125,12 +125,14 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern grub_uint32_t grub_total_modules_size;
|
extern grub_uint32_t grub_total_modules_size;
|
||||||
|
grub_addr_t grub_modbase;
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_machine_init (void)
|
grub_machine_init (void)
|
||||||
{
|
{
|
||||||
struct grub_arc_memory_descriptor *cur = NULL;
|
struct grub_arc_memory_descriptor *cur = NULL;
|
||||||
|
|
||||||
|
grub_modbase = GRUB_KERNEL_MIPS_ARC_LINK_ADDR - grub_total_modules_size;
|
||||||
grub_console_init_early ();
|
grub_console_init_early ();
|
||||||
|
|
||||||
/* FIXME: measure this. */
|
/* FIXME: measure this. */
|
||||||
|
@ -164,12 +166,6 @@ grub_machine_init (void)
|
||||||
grub_arcdisk_init ();
|
grub_arcdisk_init ();
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_addr_t
|
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
return GRUB_KERNEL_MIPS_ARC_LINK_ADDR - grub_total_modules_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
grub_machine_fini (void)
|
grub_machine_fini (void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -298,9 +298,5 @@ grub_reboot (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char _end[];
|
extern char _end[];
|
||||||
|
grub_addr_t grub_modbase = (grub_addr_t) _end;
|
||||||
|
|
||||||
grub_addr_t
|
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
return (grub_addr_t) _end;
|
|
||||||
}
|
|
||||||
|
|
|
@ -113,9 +113,5 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char _end[];
|
extern char _end[];
|
||||||
|
grub_addr_t grub_modbase = (grub_addr_t) _end;
|
||||||
|
|
||||||
grub_addr_t
|
|
||||||
grub_arch_modules_addr (void)
|
|
||||||
{
|
|
||||||
return (grub_addr_t) _end;
|
|
||||||
}
|
|
||||||
|
|
|
@ -70,6 +70,8 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
|
||||||
char **device,
|
char **device,
|
||||||
char **path);
|
char **path);
|
||||||
|
|
||||||
|
grub_addr_t grub_efi_modules_addr (void);
|
||||||
|
|
||||||
void grub_efi_mm_init (void);
|
void grub_efi_mm_init (void);
|
||||||
void grub_efi_mm_fini (void);
|
void grub_efi_mm_fini (void);
|
||||||
void grub_efi_init (void);
|
void grub_efi_init (void);
|
||||||
|
|
|
@ -68,9 +68,15 @@ struct grub_module_info64
|
||||||
#define grub_module_info grub_module_info32
|
#define grub_module_info grub_module_info32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern grub_addr_t grub_arch_modules_addr (void);
|
extern grub_addr_t EXPORT_VAR (grub_modbase);
|
||||||
|
|
||||||
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
|
#define FOR_MODULES(var) for (\
|
||||||
|
var = grub_modbase ? (struct grub_module_header *) \
|
||||||
|
(grub_modbase + (((struct grub_module_info *) grub_modbase)->offset)) : 0;\
|
||||||
|
var && (grub_addr_t) var \
|
||||||
|
< (grub_modbase + (((struct grub_module_info *) grub_modbase)->size)); \
|
||||||
|
var = (struct grub_module_header *) \
|
||||||
|
((char *) var + ((struct grub_module_header *) var)->size))
|
||||||
|
|
||||||
grub_addr_t grub_modules_get_end (void);
|
grub_addr_t grub_modules_get_end (void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue