This makes multiboot2 work on i386-ieee1275. Tested both with elf32 and elf64 images.
In case of elf32 OFW images, they won't work because EAX is used for multiboot information and can't hold the needed pointer to OFW callback interface. See the comment I added to the draft: http://grub.enbug.org/MultibootDraft#head-84d7c3521d0235f08f7fffaf35e2d06ced2f0a68 -- Robert Millan <GPLv2> I know my rights; I want my phone call! <DRM> What use is a phone call… if you are unable to speak? (as seen on /.)
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Add `machine/loader.h' and `machine/memory.h'. (pkglib_MODULES): Add `multiboot.mod' and `_multiboot.mod'. (_multiboot_mod_SOURCES): New variable. (_multiboot_mod_CFLAGS): Likewise. (_multiboot_mod_LDFLAGS): Likewise. (multiboot_mod_SOURCES): Likewise. (multiboot_mod_CFLAGS): Likewise. (multiboot_mod_LDFLAGS): Likewise. * include/grub/i386/ieee1275/loader.h: New file. * include/grub/i386/ieee1275/machine.h: Likewise. * include/grub/i386/ieee1275/memory.h: Likewise. * include/grub/i386/pc/init.h (grub_os_area_addr): Remove (redundant) variable declaration. (grub_os_area_size): Likewise. * kern/i386/ieee1275/init.c (grub_os_area_addr, grub_os_area_size) (grub_lower_mem, grub_upper_mem): New variables. (grub_stop_floppy): New function (just to make grub_multiboot2_real_boot() happy). * kern/i386/ieee1275/startup.S: Include `<grub/machine/memory.h>', `<grub/cpu/linux.h>', `<multiboot.h>' and `<multiboot2.h>'. (grub_stop): New function. Include `"../realmode.S"' and `"../loader.S"'. * loader/multiboot_loader.c: Include `<grub/machine/machine.h>'. Replace `__i386__' #ifdefs with `GRUB_MACHINE_PCBIOS'. * loader/powerpc/ieee1275/multiboot2.c (grub_mb2_arch_boot): On i386, rely on grub_multiboot2_real_boot() for final boot. diff -x '*.mk' -Nurp grub2/conf/i386-ieee1275.rmk mb/conf/i386-ieee1275.rmk --- grub2/conf/i386-ieee1275.rmk 2008-01-15 21:05:44.000000000 +0100 +++ mb/conf/i386-ieee1275.rmk 2008-01-21 01:08:42.000000000 +0100 @@ -22,7 +22,7 @@ kernel_elf_SOURCES = kern/i386/ieee1275/ kernel_elf_HEADERS = arg.h cache.h device.h disk.h dl.h elf.h elfload.h \ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \ partition.h pc_partition.h rescue.h symbol.h term.h time.h types.h \ - ieee1275/ieee1275.h machine/kernel.h + ieee1275/ieee1275.h machine/kernel.h machine/loader.h machine/memory.h kernel_elf_CFLAGS = $(COMMON_CFLAGS) kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic @@ -96,7 +96,8 @@ grub_emu_SOURCES = commands/boot.c comma grub_emu_LDFLAGS = $(LIBCURSES) # Modules. -pkglib_MODULES = normal.mod halt.mod reboot.mod suspend.mod cpuid.mod +pkglib_MODULES = normal.mod halt.mod reboot.mod suspend.mod cpuid.mod \ + multiboot.mod _multiboot.mod # For normal.mod. normal_mod_DEPENDENCIES = grub_script.tab.c grub_script.tab.h @@ -109,6 +110,18 @@ normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For _multiboot.mod. +_multiboot_mod_SOURCES = loader/powerpc/ieee1275/multiboot2.c \ + loader/multiboot2.c \ + loader/multiboot_loader.c +_multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +_multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For multiboot.mod. +multiboot_mod_SOURCES = loader/multiboot_loader_normal.c +multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For suspend.mod suspend_mod_SOURCES = commands/ieee1275/suspend.c suspend_mod_CFLAGS = $(COMMON_CFLAGS) diff -x '*.mk' -Nurp grub2/include/grub/i386/ieee1275/loader.h mb/include/grub/i386/ieee1275/loader.h --- grub2/include/grub/i386/ieee1275/loader.h 1970-01-01 01:00:00.000000000 +0100 +++ mb/include/grub/i386/ieee1275/loader.h 2008-01-21 01:06:52.000000000 +0100 @@ -0,0 +1 @@ +#include <grub/cpu/loader.h> diff -x '*.mk' -Nurp grub2/include/grub/i386/ieee1275/machine.h mb/include/grub/i386/ieee1275/machine.h --- grub2/include/grub/i386/ieee1275/machine.h 1970-01-01 01:00:00.000000000 +0100 +++ mb/include/grub/i386/ieee1275/machine.h 2008-01-21 02:22:33.000000000 +0100 @@ -0,0 +1,24 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef GRUB_MACHINE_MACHINE_HEADER +#define GRUB_MACHINE_MACHINE_HEADER 1 + +#define GRUB_MACHINE_IEEE1275 1 + +#endif /* ! GRUB_MACHINE_MACHINE_HEADER */ diff -x '*.mk' -Nurp grub2/include/grub/i386/ieee1275/memory.h mb/include/grub/i386/ieee1275/memory.h --- grub2/include/grub/i386/ieee1275/memory.h 1970-01-01 01:00:00.000000000 +0100 +++ mb/include/grub/i386/ieee1275/memory.h 2008-01-21 01:07:04.000000000 +0100 @@ -0,0 +1 @@ +#include <grub/i386/pc/memory.h> diff -x '*.mk' -Nurp grub2/include/grub/i386/pc/init.h mb/include/grub/i386/pc/init.h --- grub2/include/grub/i386/pc/init.h 2007-11-18 08:10:47.000000000 +0100 +++ mb/include/grub/i386/pc/init.h 2008-01-21 01:04:58.000000000 +0100 @@ -22,9 +22,6 @@ #include <grub/types.h> #include <grub/symbol.h> -extern grub_addr_t EXPORT_VAR(grub_os_area_addr); -extern grub_size_t EXPORT_VAR(grub_os_area_size); - /* Get the memory size in KB. If EXTENDED is zero, return conventional memory, otherwise return extended memory. */ grub_uint16_t grub_get_memsize (int extended); diff -x '*.mk' -Nurp grub2/kern/i386/ieee1275/init.c mb/kern/i386/ieee1275/init.c --- grub2/kern/i386/ieee1275/init.c 2008-01-15 21:05:44.000000000 +0100 +++ mb/kern/i386/ieee1275/init.c 2008-01-21 02:30:18.000000000 +0100 @@ -19,6 +19,15 @@ #include <grub/types.h> +grub_addr_t grub_os_area_addr; +grub_size_t grub_os_area_size; +grub_size_t grub_lower_mem, grub_upper_mem; + +void +grub_stop_floppy (void) +{ +} + void grub_arch_sync_caches (void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) diff -x '*.mk' -Nurp grub2/kern/i386/ieee1275/startup.S mb/kern/i386/ieee1275/startup.S --- grub2/kern/i386/ieee1275/startup.S 2008-01-19 21:55:50.000000000 +0100 +++ mb/kern/i386/ieee1275/startup.S 2008-01-21 01:52:00.000000000 +0100 @@ -19,6 +19,10 @@ #define ASM_FILE 1 #include <grub/symbol.h> +#include <grub/machine/memory.h> +#include <grub/cpu/linux.h> +#include <multiboot.h> +#include <multiboot2.h> /* * Note: GRUB is compiled with the options -mrtd and -mregparm=3. @@ -36,3 +40,22 @@ start: _start: movl %eax, EXT_C(grub_ieee1275_entry_fn) jmp EXT_C(cmain) + +/* + * This call is special... it never returns... in fact it should simply + * hang at this point! + */ +FUNCTION(grub_stop) + hlt + jmp EXT_C(grub_stop) + +/* + * prot_to_real and associated structures (but NOT real_to_prot, that is + * only needed for BIOS gates). + */ +#include "../realmode.S" + +/* + * Routines needed by Linux and Multiboot loaders. + */ +#include "../loader.S" diff -x '*.mk' -Nurp grub2/loader/multiboot_loader.c mb/loader/multiboot_loader.c --- grub2/loader/multiboot_loader.c 2007-12-30 09:49:57.000000000 +0100 +++ mb/loader/multiboot_loader.c 2008-01-21 02:21:44.000000000 +0100 @@ -18,6 +18,7 @@ */ #include <multiboot2.h> +#include <grub/machine/machine.h> #include <grub/multiboot_loader.h> #include <grub/multiboot.h> #include <grub/multiboot2.h> @@ -113,7 +114,7 @@ grub_rescue_cmd_multiboot_loader (int ar /* XXX Find a better way to identify this. This is for i386-pc */ -#ifdef __i386__ +#ifdef GRUB_MACHINE_PCBIOS if (header_multi_ver_found == 1) { grub_dprintf ("multiboot_loader", @@ -143,7 +144,7 @@ void grub_rescue_cmd_module_loader (int argc, char *argv[]) { -#ifdef __i386__ +#ifdef GRUB_MACHINE_PCBIOS if (module_version_status == 1) { grub_dprintf("multiboot_loader", diff -x '*.mk' -Nurp grub2/loader/powerpc/ieee1275/multiboot2.c mb/loader/powerpc/ieee1275/multiboot2.c --- grub2/loader/powerpc/ieee1275/multiboot2.c 2007-07-25 02:44:03.000000000 +0200 +++ mb/loader/powerpc/ieee1275/multiboot2.c 2008-01-21 02:24:58.000000000 +0100 @@ -115,5 +115,11 @@ void grub_mb2_arch_boot (grub_addr_t entry_addr, void *tags) { kernel_entry_t entry = (kernel_entry_t) entry_addr; +#if defined(__powerpc__) entry (MULTIBOOT2_BOOTLOADER_MAGIC, tags, grub_ieee1275_entry_fn, 0, 0); +#elif defined(__i386__) + grub_multiboot2_real_boot (entry, tags); +#else +#error +#endif }
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel