2008-01-23 Robert Millan <rmh@aybabtu.com>

* 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.
This commit is contained in:
robertmh 2008-01-23 09:57:26 +00:00
parent 2563862970
commit dbb475a441
12 changed files with 262 additions and 9 deletions

View file

@ -1,3 +1,41 @@
2008-01-23 Robert Millan <rmh@aybabtu.com>
* 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.
2008-01-22 Robert Millan <rmh@aybabtu.com>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): When

View file

@ -153,6 +153,9 @@ include/grub/i386/types.h
include/grub/i386/efi/kernel.h
include/grub/i386/efi/loader.h
include/grub/i386/efi/time.h
include/grub/i386/ieee1275/loader.h
include/grub/i386/ieee1275/machine.h
include/grub/i386/ieee1275/memory.h
include/grub/i386/io.h
include/grub/i386/linuxbios/boot.h
include/grub/i386/linuxbios/console.h

View file

@ -128,7 +128,7 @@ kernel_elf-symlist.o: symlist.c
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
@ -686,7 +686,8 @@ grub_emu-grub_emu_init.o: grub_emu_init.c $(grub_emu_init.c_DEPENDENCIES)
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
@ -956,6 +957,142 @@ 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
CLEANFILES += _multiboot.mod mod-_multiboot.o mod-_multiboot.c pre-_multiboot.o _multiboot_mod-loader_powerpc_ieee1275_multiboot2.o _multiboot_mod-loader_multiboot2.o _multiboot_mod-loader_multiboot_loader.o und-_multiboot.lst
ifneq ($(_multiboot_mod_EXPORTS),no)
CLEANFILES += def-_multiboot.lst
DEFSYMFILES += def-_multiboot.lst
endif
MOSTLYCLEANFILES += _multiboot_mod-loader_powerpc_ieee1275_multiboot2.d _multiboot_mod-loader_multiboot2.d _multiboot_mod-loader_multiboot_loader.d
UNDSYMFILES += und-_multiboot.lst
_multiboot.mod: pre-_multiboot.o mod-_multiboot.o
-rm -f $@
$(TARGET_CC) $(_multiboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-_multiboot.o: $(_multiboot_mod_DEPENDENCIES) _multiboot_mod-loader_powerpc_ieee1275_multiboot2.o _multiboot_mod-loader_multiboot2.o _multiboot_mod-loader_multiboot_loader.o
-rm -f $@
$(TARGET_CC) $(_multiboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ _multiboot_mod-loader_powerpc_ieee1275_multiboot2.o _multiboot_mod-loader_multiboot2.o _multiboot_mod-loader_multiboot_loader.o
mod-_multiboot.o: mod-_multiboot.c
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -c -o $@ $<
mod-_multiboot.c: moddep.lst genmodsrc.sh
sh $(srcdir)/genmodsrc.sh '_multiboot' $< > $@ || (rm -f $@; exit 1)
ifneq ($(_multiboot_mod_EXPORTS),no)
def-_multiboot.lst: pre-_multiboot.o
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 _multiboot/' > $@
endif
und-_multiboot.lst: pre-_multiboot.o
echo '_multiboot' > $@
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
_multiboot_mod-loader_powerpc_ieee1275_multiboot2.o: loader/powerpc/ieee1275/multiboot2.c
$(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -MD -c -o $@ $<
-include _multiboot_mod-loader_powerpc_ieee1275_multiboot2.d
CLEANFILES += cmd-_multiboot_mod-loader_powerpc_ieee1275_multiboot2.lst fs-_multiboot_mod-loader_powerpc_ieee1275_multiboot2.lst
COMMANDFILES += cmd-_multiboot_mod-loader_powerpc_ieee1275_multiboot2.lst
FSFILES += fs-_multiboot_mod-loader_powerpc_ieee1275_multiboot2.lst
cmd-_multiboot_mod-loader_powerpc_ieee1275_multiboot2.lst: loader/powerpc/ieee1275/multiboot2.c gencmdlist.sh
set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _multiboot > $@ || (rm -f $@; exit 1)
fs-_multiboot_mod-loader_powerpc_ieee1275_multiboot2.lst: loader/powerpc/ieee1275/multiboot2.c genfslist.sh
set -e; $(TARGET_CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh _multiboot > $@ || (rm -f $@; exit 1)
_multiboot_mod-loader_multiboot2.o: loader/multiboot2.c
$(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -MD -c -o $@ $<
-include _multiboot_mod-loader_multiboot2.d
CLEANFILES += cmd-_multiboot_mod-loader_multiboot2.lst fs-_multiboot_mod-loader_multiboot2.lst
COMMANDFILES += cmd-_multiboot_mod-loader_multiboot2.lst
FSFILES += fs-_multiboot_mod-loader_multiboot2.lst
cmd-_multiboot_mod-loader_multiboot2.lst: loader/multiboot2.c gencmdlist.sh
set -e; $(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _multiboot > $@ || (rm -f $@; exit 1)
fs-_multiboot_mod-loader_multiboot2.lst: loader/multiboot2.c genfslist.sh
set -e; $(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh _multiboot > $@ || (rm -f $@; exit 1)
_multiboot_mod-loader_multiboot_loader.o: loader/multiboot_loader.c
$(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -MD -c -o $@ $<
-include _multiboot_mod-loader_multiboot_loader.d
CLEANFILES += cmd-_multiboot_mod-loader_multiboot_loader.lst fs-_multiboot_mod-loader_multiboot_loader.lst
COMMANDFILES += cmd-_multiboot_mod-loader_multiboot_loader.lst
FSFILES += fs-_multiboot_mod-loader_multiboot_loader.lst
cmd-_multiboot_mod-loader_multiboot_loader.lst: loader/multiboot_loader.c gencmdlist.sh
set -e; $(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _multiboot > $@ || (rm -f $@; exit 1)
fs-_multiboot_mod-loader_multiboot_loader.lst: loader/multiboot_loader.c genfslist.sh
set -e; $(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh _multiboot > $@ || (rm -f $@; exit 1)
_multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
_multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For multiboot.mod.
multiboot_mod_SOURCES = loader/multiboot_loader_normal.c
CLEANFILES += multiboot.mod mod-multiboot.o mod-multiboot.c pre-multiboot.o multiboot_mod-loader_multiboot_loader_normal.o und-multiboot.lst
ifneq ($(multiboot_mod_EXPORTS),no)
CLEANFILES += def-multiboot.lst
DEFSYMFILES += def-multiboot.lst
endif
MOSTLYCLEANFILES += multiboot_mod-loader_multiboot_loader_normal.d
UNDSYMFILES += und-multiboot.lst
multiboot.mod: pre-multiboot.o mod-multiboot.o
-rm -f $@
$(TARGET_CC) $(multiboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
pre-multiboot.o: $(multiboot_mod_DEPENDENCIES) multiboot_mod-loader_multiboot_loader_normal.o
-rm -f $@
$(TARGET_CC) $(multiboot_mod_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ multiboot_mod-loader_multiboot_loader_normal.o
mod-multiboot.o: mod-multiboot.c
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(multiboot_mod_CFLAGS) -c -o $@ $<
mod-multiboot.c: moddep.lst genmodsrc.sh
sh $(srcdir)/genmodsrc.sh 'multiboot' $< > $@ || (rm -f $@; exit 1)
ifneq ($(multiboot_mod_EXPORTS),no)
def-multiboot.lst: pre-multiboot.o
$(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 multiboot/' > $@
endif
und-multiboot.lst: pre-multiboot.o
echo 'multiboot' > $@
$(NM) -u -P -p $< | cut -f1 -d' ' >> $@
multiboot_mod-loader_multiboot_loader_normal.o: loader/multiboot_loader_normal.c
$(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(multiboot_mod_CFLAGS) -MD -c -o $@ $<
-include multiboot_mod-loader_multiboot_loader_normal.d
CLEANFILES += cmd-multiboot_mod-loader_multiboot_loader_normal.lst fs-multiboot_mod-loader_multiboot_loader_normal.lst
COMMANDFILES += cmd-multiboot_mod-loader_multiboot_loader_normal.lst
FSFILES += fs-multiboot_mod-loader_multiboot_loader_normal.lst
cmd-multiboot_mod-loader_multiboot_loader_normal.lst: loader/multiboot_loader_normal.c gencmdlist.sh
set -e; $(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh multiboot > $@ || (rm -f $@; exit 1)
fs-multiboot_mod-loader_multiboot_loader_normal.lst: loader/multiboot_loader_normal.c genfslist.sh
set -e; $(TARGET_CC) -Iloader -I$(srcdir)/loader $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/genfslist.sh multiboot > $@ || (rm -f $@; exit 1)
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For suspend.mod
suspend_mod_SOURCES = commands/ieee1275/suspend.c
CLEANFILES += suspend.mod mod-suspend.o mod-suspend.c pre-suspend.o suspend_mod-commands_ieee1275_suspend.o und-suspend.lst

View file

@ -22,7 +22,7 @@ kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
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 commands/cat.c commands/cmp.c \
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)

View file

@ -0,0 +1 @@
#include <grub/cpu/loader.h>

View file

@ -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 */

View file

@ -0,0 +1 @@
#include <grub/i386/pc/memory.h>

View file

@ -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);

View file

@ -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)))

View file

@ -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"

View file

@ -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 argc, char *argv[])
/* 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",

View file

@ -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
}