2005-01-04 Hollis Blanchard <hollis@penguinppc.org>

* TODO: Add note about endianness in grub-mkimage.
	* boot/powerpc/ieee1275/crt0.S (note): Remove unused .note
	section.
	* conf/powerpc-ieee1275.rmk (bin_UTILITIES): Add grub-mkimage.
	(grub_mkimage_SOURCES): New target.
	* include/grub/kernel.h (grub_start_addr): Remove variable.
	(grub_end_addr): Likewise.
	(grub_total_module_size): Likewise.
	(grub_kernel_image_size): Likewise.
	(GRUB_MODULE_MAGIC): New constant.
	(grub_module_info): New structure.
	(grub_arch_modules_addr): New prototype.
	(grub_get_end_addr): Remove prototype.
	* include/grub/i386/pc/kernel.h (grub_end_addr): New prototype.
	* include/grub/powerpc/ieee1275/kernel.h: New file.
	* include/grub/util/misc.h (grub_util_get_fp_size): New
	prototype.
	(grub_util_read_at): Likewise.
	(grub_util_write_image_at): Likewise.
	* kern/main.c (grub_get_end_addr): Remove function.
	(grub_load_modules): Call grub_arch_modules_addr instead of using
	grub_end_addr.  Look for a grub_module_info struct in memory.  Use
	the grub_module_info fields instead of calling grub_get_end_addr
	as loop conditions.  Move grub_add_unused_region code here.
	(grub_add_unused_region): Remove function.
	* kern/i386/pc/init.c: Include grub/cache.h.
	(grub_machine_init): Remove call to grub_get_end_addr.  Remove
	one call to add_mem_region.
	(grub_arch_modules_addr): New function.
	* kern/powerpc/ieee1275/init.c (grub_end_addr): Remove variable.
	(grub_total_module_size): Likewise.
	Include grub/machine/kernel.h.
	(grub_arch_modules_addr): New function.
	* util/grub-emu.c (grub_end_addr): Remove variable.
	(grub_total_module_size): Likewise.
	(grub_arch_modules_addr): New function.
	* util/misc.c: Include unistd.h.
	(grub_util_get_fp_size): New function.
	(grub_util_read_at): Likewise.
	(grub_util_write_image_at): Likewise.
	(grub_util_read_image): Call grub_util_read_at.
	(grub_util_write_image): Call grub_util_write_image_at.
	* util/i386/pc/grub-mkimage.c (generate_image): Allocate
	additional memory in kernel_img for a struct grub_module_info.
	Fill in that grub_module_info.
	* util/powerpc/ieee1275/grub-mkimage.c: New file.
This commit is contained in:
marco_g 2005-01-04 14:01:45 +00:00
parent 458786f8fc
commit 0b412211b3
15 changed files with 488 additions and 70 deletions

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
*
* 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
@ -30,6 +30,7 @@
#include <grub/misc.h>
#include <grub/loader.h>
#include <grub/env.h>
#include <grub/cache.h>
struct mem_region
{
@ -126,7 +127,6 @@ grub_machine_init (void)
grub_uint32_t cont;
struct grub_machine_mmap_entry *entry
= (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
grub_addr_t end_addr = grub_get_end_addr ();
int i;
/* Initialize the console as early as possible. */
@ -148,8 +148,6 @@ grub_machine_init (void)
add_mem_region (GRUB_MEMORY_MACHINE_RESERVED_END,
grub_lower_mem - GRUB_MEMORY_MACHINE_RESERVED_END);
add_mem_region (end_addr, GRUB_MEMORY_MACHINE_RESERVED_START - end_addr);
/* Check if grub_get_mmap_entry works. */
cont = grub_get_mmap_entry (entry, 0);
@ -233,3 +231,10 @@ grub_machine_init (void)
/* Initialize the prefix. */
grub_env_set ("prefix", make_install_device ());
}
/* Return the end of the core image. */
grub_addr_t
grub_arch_modules_addr (void)
{
return grub_end_addr;
}

View file

@ -1,7 +1,7 @@
/* main.c - the kernel main routine */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
* Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
*
* 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
@ -29,35 +29,32 @@
#include <grub/device.h>
#include <grub/env.h>
/* Return the end of the core image. */
grub_addr_t
grub_get_end_addr (void)
{
return grub_total_module_size + grub_end_addr;
}
/* Load all modules in core. */
static void
grub_load_modules (void)
{
struct grub_module_info *modinfo;
struct grub_module_header *header;
grub_addr_t modbase;
for (header = (struct grub_module_header *) grub_end_addr;
header < (struct grub_module_header *) grub_get_end_addr ();
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 (! grub_dl_load_core ((char *) header + header->offset,
(header->size - header->offset)))
grub_fatal ("%s", grub_errmsg);
}
}
/* Add the region where modules reside into dynamic memory. */
static void
grub_add_unused_region (void)
{
if (grub_total_module_size)
grub_mm_init_region ((void *) grub_end_addr, grub_total_module_size);
/* Add the region where modules reside into dynamic memory. */
grub_mm_init_region ((void *) modinfo, modinfo->size);
}
/* Set the root device according to the dl prefix. */
@ -111,7 +108,6 @@ grub_main (void)
/* Load pre-loaded modules and free the space. */
grub_register_exported_symbols ();
grub_load_modules ();
grub_add_unused_region ();
/* Load the normal mode module. */
grub_load_normal_mode ();

View file

@ -1,7 +1,7 @@
/* init.c -- Initialize GRUB on the newworld mac (PPC). */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004,2005 Free Software Foundation, Inc.
* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
*
* 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
@ -31,10 +31,7 @@
#include <grub/misc.h>
#include <grub/machine/init.h>
#include <grub/machine/time.h>
/* XXX: Modules are not yet supported. */
grub_addr_t grub_end_addr = -1;
grub_addr_t grub_total_module_size = 0;
#include <grub/machine/kernel.h>
void
abort (void)
@ -89,3 +86,9 @@ grub_get_rtc (void)
return msecs;
}
grub_addr_t
grub_arch_modules_addr (void)
{
return GRUB_IEEE1275_MODULE_BASE;
}