* GRUB on OLPC / XO
@ 2008-01-12 3:14 Robert Millan
2008-01-15 11:31 ` Marco Gerards
0 siblings, 1 reply; 13+ messages in thread
From: Robert Millan @ 2008-01-12 3:14 UTC (permalink / raw)
To: devel; +Cc: grub-devel
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
Hi!
I've been working for a few hours in a GRUB port to i386/OFW. There's
quite a bit of things that need cleanup/fix before it can be considered
complete, but it's in a stage that boots and lets you do basic things (like
listing storage devices).
It's known to work on OLPC / XO. I don't have a working unit myself, but
someone from #olpc was kind enough to test it and even provided a screenshot:
http://kwzs.be/pic6/P1010018.JPG
I'll be gradually integrating this into official GRUB tree. In the meantime,
if you want to try it:
- checkout GRUB cvs (grub2 module)
- apply attached patch
- ./autogen.sh && ./configure --with-platform=ieee1275 && make kernel.elf
--
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 /.)
[-- Attachment #2: grub-i386-ofw.diff --]
[-- Type: text/x-diff, Size: 14126 bytes --]
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/conf/i386-ieee1275.rmk ./conf/i386-ieee1275.rmk
--- ../../grub2/conf/i386-ieee1275.rmk 1970-01-01 01:00:00.000000000 +0100
+++ ./conf/i386-ieee1275.rmk 2008-01-12 03:04:50.000000000 +0100
@@ -0,0 +1,117 @@
+# -*- makefile -*-
+
+COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
+COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
+COMMON_LDFLAGS = -nostdlib -static -lgcc
+
+# Images.
+pkglib_PROGRAMS = kernel.elf
+
+# For kernel.elf.
+kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
+ kern/powerpc/ieee1275/init.c \
+ kern/powerpc/ieee1275/cmain.c kern/powerpc/ieee1275/openfw.c \
+ kern/main.c kern/device.c \
+ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
+ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
+ kern/i386/dl.c kern/parser.c kern/partition.c \
+ kern/env.c \
+ kern/ieee1275/ieee1275.c \
+ term/ieee1275/ofconsole.c disk/ieee1275/ofdisk.c \
+ 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
+kernel_elf_CFLAGS = $(COMMON_CFLAGS)
+kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x100000,-Bstatic
+
+MOSTLYCLEANFILES += symlist.c kernel_syms.lst
+DEFSYMFILES += kernel_syms.lst
+
+symlist.c: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h gensymlist.sh
+ /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+
+kernel_syms.lst: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h genkernsyms.sh
+ /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+
+# Utilities.
+bin_UTILITIES = grub-mkimage
+sbin_UTILITIES = grub-mkdevicemap grub-probe
+ifeq ($(enable_grub_emu), yes)
+sbin_UTILITIES += grub-emu
+endif
+
+# For grub-mkimage.
+grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+ util/resolve.c
+grub_mkimage_LDFLAGS = $(LIBLZO)
+
+# For grub-mkdevicemap.
+grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c \
+ util/i386/get_disk_name.c
+
+# For grub-probe.
+util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
+grub_probe_SOURCES = util/grub-probe.c \
+ util/biosdisk.c util/misc.c util/getroot.c \
+ kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
+ fs/ext2.c kern/parser.c kern/partition.c \
+ partmap/pc.c partmap/apple.c partmap/gpt.c \
+ fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/ntfs.c fs/ntfscomp.c \
+ fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c \
+ kern/fs.c \
+ kern/env.c fs/fshelp.c \
+ disk/lvm.c disk/raid.c grub_probe_init.c
+
+# For grub-emu.
+grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h \
+ grub_emu_init.h
+grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
+ commands/configfile.c commands/echo.c commands/help.c \
+ commands/terminal.c commands/ls.c commands/test.c \
+ commands/search.c commands/blocklist.c commands/hexdump.c \
+ commands/i386/pc/halt.c commands/i386/pc/reboot.c \
+ commands/i386/cpuid.c \
+ disk/host.c disk/loopback.c disk/raid.c disk/lvm.c \
+ fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c \
+ fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c fs/hfsplus.c \
+ fs/ntfs.c fs/ntfscomp.c fs/cpio.c \
+ io/gzio.c \
+ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \
+ kern/err.c \
+ normal/execute.c kern/file.c kern/fs.c normal/lexer.c \
+ kern/loader.c kern/main.c kern/misc.c kern/parser.c \
+ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \
+ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\
+ normal/completion.c normal/main.c \
+ normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \
+ normal/color.c \
+ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
+ partmap/acorn.c partmap/gpt.c \
+ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
+ util/biosdisk.c util/getroot.c \
+ util/i386/pc/misc.c grub_emu_init.c
+
+grub_emu_LDFLAGS = $(LIBCURSES)
+
+# Modules.
+pkglib_MODULES = normal.mod cpuid.mod
+
+# For normal.mod.
+normal_mod_DEPENDENCIES = grub_script.tab.c grub_script.tab.h
+normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
+ normal/completion.c normal/execute.c \
+ normal/function.c normal/lexer.c normal/main.c normal/menu.c \
+ normal/menu_entry.c normal/misc.c grub_script.tab.c \
+ normal/script.c normal/i386/setjmp.S normal/color.c
+normal_mod_CFLAGS = $(COMMON_CFLAGS)
+normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
+normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For cpuid.mod.
+cpuid_mod_SOURCES = commands/i386/cpuid.c
+cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
+cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+include $(srcdir)/conf/common.mk
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/configure.ac ./configure.ac
--- ../../grub2/configure.ac 2007-12-25 10:09:42.000000000 +0100
+++ ./configure.ac 2008-01-12 03:27:24.000000000 +0100
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
#
# This configure.ac is free software; the author
# gives unlimited permission to copy and/or distribute it,
@@ -79,6 +79,7 @@ case "$target_cpu"-"$platform" in
i386-efi) ;;
i386-pc) ;;
i386-linuxbios) ;;
+ i386-ieee1275) ;;
powerpc-ieee1275) ;;
sparc64-ieee1275) ;;
*) AC_MSG_ERROR([unsupported machine type]) ;;
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/console.h ./include/grub/i386/ieee1275/console.h
--- ../../grub2/include/grub/i386/ieee1275/console.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/console.h 2008-01-12 00:00:56.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/console.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/ieee1275.h ./include/grub/i386/ieee1275/ieee1275.h
--- ../../grub2/include/grub/i386/ieee1275/ieee1275.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/ieee1275.h 2008-01-12 00:01:36.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/ieee1275.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/kernel.h ./include/grub/i386/ieee1275/kernel.h
--- ../../grub2/include/grub/i386/ieee1275/kernel.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/kernel.h 2008-01-12 00:01:13.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/kernel.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/time.h ./include/grub/i386/ieee1275/time.h
--- ../../grub2/include/grub/i386/ieee1275/time.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/time.h 2008-01-11 23:59:29.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/time.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/i386/ieee1275/init.c ./kern/i386/ieee1275/init.c
--- ../../grub2/kern/i386/ieee1275/init.c 1970-01-01 01:00:00.000000000 +0100
+++ ./kern/i386/ieee1275/init.c 2008-01-12 03:26:35.000000000 +0100
@@ -0,0 +1,35 @@
+/* init.c -- Initialize GRUB on Open Firmware. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003, 2004, 2005, 2007 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/>.
+ */
+
+#include <grub/types.h>
+
+void
+grub_exit (void)
+{
+ /* Trap to Open Firmware. */
+ /* FIXME. */
+
+ for (;;);
+}
+
+void
+grub_arch_sync_caches (void *address __attribute__ ((unused)),
+ grub_size_t len __attribute__ ((unused)))
+{
+}
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/i386/ieee1275/startup.S ./kern/i386/ieee1275/startup.S
--- ../../grub2/kern/i386/ieee1275/startup.S 1970-01-01 01:00:00.000000000 +0100
+++ ./kern/i386/ieee1275/startup.S 2008-01-12 03:27:13.000000000 +0100
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,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 <http://www.gnu.org/licenses/>.
+ */
+
+#define ASM_FILE 1
+
+#include <grub/symbol.h>
+
+/*
+ * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
+ * So the first three arguments are passed in %eax, %edx, and %ecx,
+ * respectively, and if a function has a fixed number of arguments
+ * and the number if greater than three, the function must return
+ * with "ret $N" where N is ((the number of arguments) - 3) * 4.
+ */
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+
+start:
+_start:
+ movl %eax, EXT_C(grub_ieee1275_entry_fn)
+ jmp EXT_C(cmain)
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/main.c ./kern/main.c
--- ../../grub2/kern/main.c 2008-01-05 13:04:35.000000000 +0100
+++ ./kern/main.c 2008-01-12 03:03:04.000000000 +0100
@@ -120,7 +120,7 @@ grub_main (void)
/* Load pre-loaded modules and free the space. */
grub_register_exported_symbols ();
- grub_load_modules ();
+// grub_load_modules ();
/* It is better to set the root device as soon as possible,
for convenience. */
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/cmain.c ./kern/powerpc/ieee1275/cmain.c
--- ../../grub2/kern/powerpc/ieee1275/cmain.c 2007-12-30 09:52:05.000000000 +0100
+++ ./kern/powerpc/ieee1275/cmain.c 2008-01-12 03:12:01.000000000 +0100
@@ -58,7 +58,7 @@ grub_ieee1275_find_options (void)
grub_ieee1275_finddevice ("/options", &options);
rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
sizeof realmode, 0);
- if ((rc >= 0) && realmode)
+// if ((rc >= 0) && realmode)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
grub_ieee1275_finddevice ("/openprom", &openprom);
@@ -102,12 +102,9 @@ grub_ieee1275_find_options (void)
}
}
-void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
void
-cmain (UNUSED uint32_t r3, UNUSED uint32_t r4, uint32_t r5)
+cmain (void)
{
- grub_ieee1275_entry_fn = (int (*)(void *)) r5;
-
grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
grub_ieee1275_find_options ();
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/init.c ./kern/powerpc/ieee1275/init.c
--- ../../grub2/kern/powerpc/ieee1275/init.c 2008-01-03 23:43:46.000000000 +0100
+++ ./kern/powerpc/ieee1275/init.c 2008-01-12 03:26:06.000000000 +0100
@@ -52,15 +52,6 @@ grub_millisleep (grub_uint32_t ms)
grub_millisleep_generic (ms);
}
-void
-grub_exit (void)
-{
- /* Trap to Open Firmware. */
- asm ("trap");
-
- for (;;);
-}
-
/* Translate an OF filesystem path (separated by backslashes), into a GRUB
path (separated by forward slashes). */
static void
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/openfw.c ./kern/powerpc/ieee1275/openfw.c
--- ../../grub2/kern/powerpc/ieee1275/openfw.c 2007-12-30 09:52:05.000000000 +0100
+++ ./kern/powerpc/ieee1275/openfw.c 2008-01-12 02:53:01.000000000 +0100
@@ -163,18 +163,18 @@ grub_err_t grub_available_iterate (int (
/* Decode each entry and call `hook'. */
i = 0;
- while (i < sizeof (available))
+ while (i < sizeof (available) && available[i])
{
grub_uint64_t address;
grub_uint64_t size;
- address = available[i++];
+ address = grub_be_to_cpu32 (available[i++]);
if (address_cells == 2)
- address = (address << 32) | available[i++];
+ address = (address << 32) | grub_be_to_cpu32 (available[i++]);
- size = available[i++];
+ size = grub_be_to_cpu32 (available[i++]);
if (size_cells == 2)
- size = (size << 32) | available[i++];
+ size = (size << 32) | grub_be_to_cpu32 (available[i++]);
if (hook (address, size))
break;
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/term/ieee1275/ofconsole.c ./term/ieee1275/ofconsole.c
--- ../../grub2/term/ieee1275/ofconsole.c 2007-12-25 12:10:47.000000000 +0100
+++ ./term/ieee1275/ofconsole.c 2008-01-12 03:09:02.000000000 +0100
@@ -369,9 +369,6 @@ static struct grub_term grub_ofconsole_t
.getwh = grub_ofconsole_getwh,
.gotoxy = grub_ofconsole_gotoxy,
.cls = grub_ofconsole_cls,
- .setcolorstate = grub_ofconsole_setcolorstate,
- .setcolor = grub_ofconsole_setcolor,
- .getcolor = grub_ofconsole_getcolor,
.setcursor = grub_ofconsole_setcursor,
.refresh = grub_ofconsole_refresh,
.flags = 0,
^ permalink raw reply [flat|nested] 13+ messages in thread
* GRUB on OLPC / XO
@ 2008-01-12 13:42 Robert Millan
2008-01-12 14:00 ` Robert Millan
0 siblings, 1 reply; 13+ messages in thread
From: Robert Millan @ 2008-01-12 13:42 UTC (permalink / raw)
To: devel; +Cc: grub-devel
[-- Attachment #1: Type: text/plain, Size: 825 bytes --]
Hi!
I've been working for a few hours in a GRUB port to i386/OFW. There's
quite a bit of things that need cleanup/fix before it can be considered
complete, but it's in a stage that boots and lets you do basic things (like
listing storage devices).
It's known to work on OLPC / XO. I don't have a working unit myself, but
someone from #olpc was kind enough to test it and even provided a screenshot:
http://kwzs.be/pic6/P1010018.JPG
I'll be gradually integrating this into official GRUB tree. In the meantime,
if you want to try it:
- checkout GRUB cvs (grub2 module)
- apply attached patch
- ./autogen.sh && ./configure --with-platform=ieee1275 && make kernel.elf
--
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 /.)
[-- Attachment #2: grub-i386-ofw.diff --]
[-- Type: text/x-diff, Size: 14126 bytes --]
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/conf/i386-ieee1275.rmk ./conf/i386-ieee1275.rmk
--- ../../grub2/conf/i386-ieee1275.rmk 1970-01-01 01:00:00.000000000 +0100
+++ ./conf/i386-ieee1275.rmk 2008-01-12 03:04:50.000000000 +0100
@@ -0,0 +1,117 @@
+# -*- makefile -*-
+
+COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
+COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
+COMMON_LDFLAGS = -nostdlib -static -lgcc
+
+# Images.
+pkglib_PROGRAMS = kernel.elf
+
+# For kernel.elf.
+kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
+ kern/powerpc/ieee1275/init.c \
+ kern/powerpc/ieee1275/cmain.c kern/powerpc/ieee1275/openfw.c \
+ kern/main.c kern/device.c \
+ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
+ kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
+ kern/i386/dl.c kern/parser.c kern/partition.c \
+ kern/env.c \
+ kern/ieee1275/ieee1275.c \
+ term/ieee1275/ofconsole.c disk/ieee1275/ofdisk.c \
+ 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
+kernel_elf_CFLAGS = $(COMMON_CFLAGS)
+kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x100000,-Bstatic
+
+MOSTLYCLEANFILES += symlist.c kernel_syms.lst
+DEFSYMFILES += kernel_syms.lst
+
+symlist.c: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h gensymlist.sh
+ /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+
+kernel_syms.lst: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h genkernsyms.sh
+ /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+
+# Utilities.
+bin_UTILITIES = grub-mkimage
+sbin_UTILITIES = grub-mkdevicemap grub-probe
+ifeq ($(enable_grub_emu), yes)
+sbin_UTILITIES += grub-emu
+endif
+
+# For grub-mkimage.
+grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
+ util/resolve.c
+grub_mkimage_LDFLAGS = $(LIBLZO)
+
+# For grub-mkdevicemap.
+grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c \
+ util/i386/get_disk_name.c
+
+# For grub-probe.
+util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
+grub_probe_SOURCES = util/grub-probe.c \
+ util/biosdisk.c util/misc.c util/getroot.c \
+ kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
+ fs/ext2.c kern/parser.c kern/partition.c \
+ partmap/pc.c partmap/apple.c partmap/gpt.c \
+ fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/ntfs.c fs/ntfscomp.c \
+ fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c \
+ kern/fs.c \
+ kern/env.c fs/fshelp.c \
+ disk/lvm.c disk/raid.c grub_probe_init.c
+
+# For grub-emu.
+grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h \
+ grub_emu_init.h
+grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
+ commands/configfile.c commands/echo.c commands/help.c \
+ commands/terminal.c commands/ls.c commands/test.c \
+ commands/search.c commands/blocklist.c commands/hexdump.c \
+ commands/i386/pc/halt.c commands/i386/pc/reboot.c \
+ commands/i386/cpuid.c \
+ disk/host.c disk/loopback.c disk/raid.c disk/lvm.c \
+ fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c \
+ fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c fs/hfsplus.c \
+ fs/ntfs.c fs/ntfscomp.c fs/cpio.c \
+ io/gzio.c \
+ kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \
+ kern/err.c \
+ normal/execute.c kern/file.c kern/fs.c normal/lexer.c \
+ kern/loader.c kern/main.c kern/misc.c kern/parser.c \
+ grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \
+ normal/arg.c normal/cmdline.c normal/command.c normal/function.c\
+ normal/completion.c normal/main.c \
+ normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \
+ normal/color.c \
+ partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
+ partmap/acorn.c partmap/gpt.c \
+ util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
+ util/biosdisk.c util/getroot.c \
+ util/i386/pc/misc.c grub_emu_init.c
+
+grub_emu_LDFLAGS = $(LIBCURSES)
+
+# Modules.
+pkglib_MODULES = normal.mod cpuid.mod
+
+# For normal.mod.
+normal_mod_DEPENDENCIES = grub_script.tab.c grub_script.tab.h
+normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
+ normal/completion.c normal/execute.c \
+ normal/function.c normal/lexer.c normal/main.c normal/menu.c \
+ normal/menu_entry.c normal/misc.c grub_script.tab.c \
+ normal/script.c normal/i386/setjmp.S normal/color.c
+normal_mod_CFLAGS = $(COMMON_CFLAGS)
+normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
+normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For cpuid.mod.
+cpuid_mod_SOURCES = commands/i386/cpuid.c
+cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
+cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+include $(srcdir)/conf/common.mk
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/configure.ac ./configure.ac
--- ../../grub2/configure.ac 2007-12-25 10:09:42.000000000 +0100
+++ ./configure.ac 2008-01-12 03:27:24.000000000 +0100
@@ -1,6 +1,6 @@
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
#
# This configure.ac is free software; the author
# gives unlimited permission to copy and/or distribute it,
@@ -79,6 +79,7 @@ case "$target_cpu"-"$platform" in
i386-efi) ;;
i386-pc) ;;
i386-linuxbios) ;;
+ i386-ieee1275) ;;
powerpc-ieee1275) ;;
sparc64-ieee1275) ;;
*) AC_MSG_ERROR([unsupported machine type]) ;;
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/console.h ./include/grub/i386/ieee1275/console.h
--- ../../grub2/include/grub/i386/ieee1275/console.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/console.h 2008-01-12 00:00:56.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/console.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/ieee1275.h ./include/grub/i386/ieee1275/ieee1275.h
--- ../../grub2/include/grub/i386/ieee1275/ieee1275.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/ieee1275.h 2008-01-12 00:01:36.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/ieee1275.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/kernel.h ./include/grub/i386/ieee1275/kernel.h
--- ../../grub2/include/grub/i386/ieee1275/kernel.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/kernel.h 2008-01-12 00:01:13.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/kernel.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/time.h ./include/grub/i386/ieee1275/time.h
--- ../../grub2/include/grub/i386/ieee1275/time.h 1970-01-01 01:00:00.000000000 +0100
+++ ./include/grub/i386/ieee1275/time.h 2008-01-11 23:59:29.000000000 +0100
@@ -0,0 +1 @@
+#include <grub/powerpc/ieee1275/time.h>
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/i386/ieee1275/init.c ./kern/i386/ieee1275/init.c
--- ../../grub2/kern/i386/ieee1275/init.c 1970-01-01 01:00:00.000000000 +0100
+++ ./kern/i386/ieee1275/init.c 2008-01-12 03:26:35.000000000 +0100
@@ -0,0 +1,35 @@
+/* init.c -- Initialize GRUB on Open Firmware. */
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003, 2004, 2005, 2007 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/>.
+ */
+
+#include <grub/types.h>
+
+void
+grub_exit (void)
+{
+ /* Trap to Open Firmware. */
+ /* FIXME. */
+
+ for (;;);
+}
+
+void
+grub_arch_sync_caches (void *address __attribute__ ((unused)),
+ grub_size_t len __attribute__ ((unused)))
+{
+}
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/i386/ieee1275/startup.S ./kern/i386/ieee1275/startup.S
--- ../../grub2/kern/i386/ieee1275/startup.S 1970-01-01 01:00:00.000000000 +0100
+++ ./kern/i386/ieee1275/startup.S 2008-01-12 03:27:13.000000000 +0100
@@ -0,0 +1,38 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 1999,2000,2001,2002,2003,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 <http://www.gnu.org/licenses/>.
+ */
+
+#define ASM_FILE 1
+
+#include <grub/symbol.h>
+
+/*
+ * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
+ * So the first three arguments are passed in %eax, %edx, and %ecx,
+ * respectively, and if a function has a fixed number of arguments
+ * and the number if greater than three, the function must return
+ * with "ret $N" where N is ((the number of arguments) - 3) * 4.
+ */
+
+ .file "startup.S"
+ .text
+ .globl start, _start
+
+start:
+_start:
+ movl %eax, EXT_C(grub_ieee1275_entry_fn)
+ jmp EXT_C(cmain)
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/main.c ./kern/main.c
--- ../../grub2/kern/main.c 2008-01-05 13:04:35.000000000 +0100
+++ ./kern/main.c 2008-01-12 03:03:04.000000000 +0100
@@ -120,7 +120,7 @@ grub_main (void)
/* Load pre-loaded modules and free the space. */
grub_register_exported_symbols ();
- grub_load_modules ();
+// grub_load_modules ();
/* It is better to set the root device as soon as possible,
for convenience. */
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/cmain.c ./kern/powerpc/ieee1275/cmain.c
--- ../../grub2/kern/powerpc/ieee1275/cmain.c 2007-12-30 09:52:05.000000000 +0100
+++ ./kern/powerpc/ieee1275/cmain.c 2008-01-12 03:12:01.000000000 +0100
@@ -58,7 +58,7 @@ grub_ieee1275_find_options (void)
grub_ieee1275_finddevice ("/options", &options);
rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
sizeof realmode, 0);
- if ((rc >= 0) && realmode)
+// if ((rc >= 0) && realmode)
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
grub_ieee1275_finddevice ("/openprom", &openprom);
@@ -102,12 +102,9 @@ grub_ieee1275_find_options (void)
}
}
-void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
void
-cmain (UNUSED uint32_t r3, UNUSED uint32_t r4, uint32_t r5)
+cmain (void)
{
- grub_ieee1275_entry_fn = (int (*)(void *)) r5;
-
grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
grub_ieee1275_find_options ();
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/init.c ./kern/powerpc/ieee1275/init.c
--- ../../grub2/kern/powerpc/ieee1275/init.c 2008-01-03 23:43:46.000000000 +0100
+++ ./kern/powerpc/ieee1275/init.c 2008-01-12 03:26:06.000000000 +0100
@@ -52,15 +52,6 @@ grub_millisleep (grub_uint32_t ms)
grub_millisleep_generic (ms);
}
-void
-grub_exit (void)
-{
- /* Trap to Open Firmware. */
- asm ("trap");
-
- for (;;);
-}
-
/* Translate an OF filesystem path (separated by backslashes), into a GRUB
path (separated by forward slashes). */
static void
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/openfw.c ./kern/powerpc/ieee1275/openfw.c
--- ../../grub2/kern/powerpc/ieee1275/openfw.c 2007-12-30 09:52:05.000000000 +0100
+++ ./kern/powerpc/ieee1275/openfw.c 2008-01-12 02:53:01.000000000 +0100
@@ -163,18 +163,18 @@ grub_err_t grub_available_iterate (int (
/* Decode each entry and call `hook'. */
i = 0;
- while (i < sizeof (available))
+ while (i < sizeof (available) && available[i])
{
grub_uint64_t address;
grub_uint64_t size;
- address = available[i++];
+ address = grub_be_to_cpu32 (available[i++]);
if (address_cells == 2)
- address = (address << 32) | available[i++];
+ address = (address << 32) | grub_be_to_cpu32 (available[i++]);
- size = available[i++];
+ size = grub_be_to_cpu32 (available[i++]);
if (size_cells == 2)
- size = (size << 32) | available[i++];
+ size = (size << 32) | grub_be_to_cpu32 (available[i++]);
if (hook (address, size))
break;
diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/term/ieee1275/ofconsole.c ./term/ieee1275/ofconsole.c
--- ../../grub2/term/ieee1275/ofconsole.c 2007-12-25 12:10:47.000000000 +0100
+++ ./term/ieee1275/ofconsole.c 2008-01-12 03:09:02.000000000 +0100
@@ -369,9 +369,6 @@ static struct grub_term grub_ofconsole_t
.getwh = grub_ofconsole_getwh,
.gotoxy = grub_ofconsole_gotoxy,
.cls = grub_ofconsole_cls,
- .setcolorstate = grub_ofconsole_setcolorstate,
- .setcolor = grub_ofconsole_setcolor,
- .getcolor = grub_ofconsole_getcolor,
.setcursor = grub_ofconsole_setcursor,
.refresh = grub_ofconsole_refresh,
.flags = 0,
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-12 13:42 GRUB on OLPC / XO Robert Millan
@ 2008-01-12 14:00 ` Robert Millan
[not found] ` <4789009B.8030403@laptop.org>
0 siblings, 1 reply; 13+ messages in thread
From: Robert Millan @ 2008-01-12 14:00 UTC (permalink / raw)
To: devel; +Cc: grub-devel
Some comments on things that need polishing. Some are more addressed at one
of the two lists than the others, but feel free to join in either case.
(also, if you feel this is off-topic in olpc-devel, feel free to ki^W let
me know)
btw, Mitch mentioned to me on IRC that the ELF loader on XO has some "weird"
modifications to support Minix. Is this documented somewhere?
On Sat, Jan 12, 2008 at 02:42:30PM +0100, Robert Millan wrote:
> +void
> +grub_exit (void)
> +{
> + /* Trap to Open Firmware. */
> + /* FIXME. */
> +
> + for (;;);
> +}
We used to run "trap" insttruction on powerpc. I assume for exitting via trap
on i386 we need to generate an interrupt; I'm just not sure which is the right
number for it.
> /* Load pre-loaded modules and free the space. */
> grub_register_exported_symbols ();
> - grub_load_modules ();
> +// grub_load_modules ();
This generates an out of bounds exception. GRUB puts modules above _end
(0x1000-aligned). Is access to that address allowed by OFW ?
> grub_ieee1275_finddevice ("/options", &options);
> rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
> sizeof realmode, 0);
> - if ((rc >= 0) && realmode)
> +// if ((rc >= 0) && realmode)
> grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
This OFW operates in what GRUB calls "real mode" (not to be confused with
x86 realmode!), but /options/real-mode? doesn't exist. Should we probe
for the actual feature (/chosen/mmu IIRC), probe for firmware version, or
#ifdef it for x86 CPUs?
> -void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
> void
> -cmain (UNUSED uint32_t r3, UNUSED uint32_t r4, uint32_t r5)
> +cmain (void)
> {
> - grub_ieee1275_entry_fn = (int (*)(void *)) r5;
> -
This was the only powerpc-specific part of that file, that I can tell. I
moved grub_ieee1275_entry_fn initialisation to startup.S. I'd suggest doing
the same on powerpc/sparc and move cmain.c out of powerpc/ directory.
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/init.c ./kern/powerpc/ieee1275/init.c
> --- ../../grub2/kern/powerpc/ieee1275/init.c 2008-01-03 23:43:46.000000000 +0100
> +++ ./kern/powerpc/ieee1275/init.c 2008-01-12 03:26:06.000000000 +0100
> @@ -52,15 +52,6 @@ grub_millisleep (grub_uint32_t ms)
> grub_millisleep_generic (ms);
> }
>
> -void
> -grub_exit (void)
> -{
> - /* Trap to Open Firmware. */
> - asm ("trap");
> -
> - for (;;);
> -}
Same here.
> /* Decode each entry and call `hook'. */
> i = 0;
> - while (i < sizeof (available))
> + while (i < sizeof (available) && available[i])
Here we were attempting to claim a region that starts at 0x0 and
ends at INT_MAX !! I suppose we just need to check for available property
length. Need to look more into this.
> - address = available[i++];
> + address = grub_be_to_cpu32 (available[i++]);
> if (address_cells == 2)
> - address = (address << 32) | available[i++];
> + address = (address << 32) | grub_be_to_cpu32 (available[i++]);
>
> - size = available[i++];
> + size = grub_be_to_cpu32 (available[i++]);
> if (size_cells == 2)
> - size = (size << 32) | available[i++];
> + size = (size << 32) | grub_be_to_cpu32 (available[i++]);
Integer properties are always in network byte order (thanks Mitch for
clarifiing).
I wonder if we should byteswap all callers of getprop or just mangle the
result in the getprop function instead (the latter seems cleaner, but it wasn't
obvious how to do it without breaking non-integer properties).
Ah, and for some reason address_cells is set to a garbage number. Might be
a pointer dereference issue, will look into this.
> --- ../../grub2/term/ieee1275/ofconsole.c 2007-12-25 12:10:47.000000000 +0100
> +++ ./term/ieee1275/ofconsole.c 2008-01-12 03:09:02.000000000 +0100
> @@ -369,9 +369,6 @@ static struct grub_term grub_ofconsole_t
> .getwh = grub_ofconsole_getwh,
> .gotoxy = grub_ofconsole_gotoxy,
> .cls = grub_ofconsole_cls,
> - .setcolorstate = grub_ofconsole_setcolorstate,
> - .setcolor = grub_ofconsole_setcolor,
> - .getcolor = grub_ofconsole_getcolor,
> .setcursor = grub_ofconsole_setcursor,
> .refresh = grub_ofconsole_refresh,
> .flags = 0,
Not really a porting issue, but when using serial terminal GRUB still tries to
set white/black color on it, which becomes very ugly in my black/white
gnome-terminal :-)
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
[not found] ` <4789009B.8030403@laptop.org>
@ 2008-01-12 18:58 ` Robert Millan
[not found] ` <47891639.7070500@laptop.org>
0 siblings, 1 reply; 13+ messages in thread
From: Robert Millan @ 2008-01-12 18:58 UTC (permalink / raw)
To: Mitch Bradley; +Cc: grub-devel, devel
On Sat, Jan 12, 2008 at 08:02:03AM -1000, Mitch Bradley wrote:
> Robert Millan wrote:
> >Some comments on things that need polishing. Some are more addressed at
> >one
> >of the two lists than the others, but feel free to join in either case.
> >
> >(also, if you feel this is off-topic in olpc-devel, feel free to ki^W let
> >me know)
> >
> >btw, Mitch mentioned to me on IRC that the ELF loader on XO has some
> >"weird"
> >modifications to support Minix. Is this documented somewhere?
> >
>
> I was mistaken about Minix - there are no Minix-specific hacks in the
> ELF loader. The only Minix support is a handler for the Minix
> filesystem layout, which doesn't affect the ELF loader.
>
> The ELF loader has two special cases, which are not documented anywhere
> except the source code (cpu/x86/pc/olpc/linux.fth : ?memtest-elf-map-in ) :
>
> a) It recognizes the memtest86 binary that is embedded in OFW, setting
> up some special mappings that memtest requires (or at least used to require)
>
> b) It recognizes the ELF form of the Linux binary and sets up a mapping
> from virtual c0xx.xxxx to physical 00xx.xxxx . Normally this isn't
> used, because we load the bzImage version of Linux. But OFW can load
> the ELF portion of the Linux kernel, without the bzImage wrapper. If
> you do it that way, OFW has access to the ELF symbol table and can thus
> resolve symbolic names for addresses inside Linux.
Ok, thanks for the explanation. It doesn't seem like GRUB would be affected
then.
> >On Sat, Jan 12, 2008 at 02:42:30PM +0100, Robert Millan wrote:
> >
> >>+void
> >>+grub_exit (void)
> >>+{
> >>+ /* Trap to Open Firmware. */
> >>+ /* FIXME. */
> >>+
> >>+ for (;;);
> >>+}
> >>
> >
> >We used to run "trap" insttruction on powerpc. I assume for exitting via
> >trap
> >on i386 we need to generate an interrupt; I'm just not sure which is the
> >right
> >number for it.
> >
>
> To exit to OFW, call the "exit()" client service.
I see. Is this one expected to work everywhere including Apple etc? We'd
probably be better off ditching the __asm__("trap") altogether.
> To reboot, call "boot()" with an empty string as the single IN argument.
For this we used "reset-all". The standard seems to indicate both are
equally fine; is that it?
> To power off, call "interpret()" with a cmd string of "power-off".
We used "shut-down" for this one. Unfortunately not mentioned in the
standard (not sure where it came from). Is there a portable way to do this?
> >> /* Load pre-loaded modules and free the space. */
> >> grub_register_exported_symbols ();
> >>- grub_load_modules ();
> >>+// grub_load_modules ();
> >>
> >
> >This generates an out of bounds exception. GRUB puts modules above _end
> >(0x1000-aligned). Is access to that address allowed by OFW ?
> >
>
> The ELF loader will map in anything listed in a program header of type
> PT_LOAD , according to the vaddr, memsize, and filesize fields. If the
> module area is covered by such a program header, they should be accessible.
Ah, that hints at a known bug in our ELF generator (affecting LinuxBI^W
Coreboot). I'll check if the patches for that one help.
> >> grub_ieee1275_finddevice ("/options", &options);
> >> rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
> >> sizeof realmode, 0);
> >>- if ((rc >= 0) && realmode)
> >>+// if ((rc >= 0) && realmode)
> >> grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
> >>
> >
> >This OFW operates in what GRUB calls "real mode" (not to be confused with
> >x86 realmode!), but /options/real-mode? doesn't exist. Should we probe
> >for the actual feature (/chosen/mmu IIRC), probe for firmware version, or
> >#ifdef it for x86 CPUs?
> >
>
> This OFW operates in virtual mode, but happens to have an identity
> mapping of low memory for convenience.
/chosen/mmu is set to 0, at least on my (qemu) environment. Should clients
interpret this as identity mapping, or is this unintended?
Thank you!
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
[not found] ` <47891889.5020402@laptop.org>
@ 2008-01-12 20:30 ` Robert Millan
0 siblings, 0 replies; 13+ messages in thread
From: Robert Millan @ 2008-01-12 20:30 UTC (permalink / raw)
To: Mitch Bradley; +Cc: grub-devel, devel
On Sat, Jan 12, 2008 at 09:44:09AM -1000, Mitch Bradley wrote:
>
> I was wrong about the mmu thing.
>
> I just checked the patch instructions at
> http://openbios.org/Open_Firmware and noticed that the patch comments
> out "create virtual-mode". So if you build with that patch, you get
> physical addressing.
>
> I don't know what is "right", because this build configuration is not
> for a real product, so the requirements are unclear.
Ok, so for XO it is enabled?
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-12 3:14 Robert Millan
@ 2008-01-15 11:31 ` Marco Gerards
2008-01-15 12:06 ` Robert Millan
0 siblings, 1 reply; 13+ messages in thread
From: Marco Gerards @ 2008-01-15 11:31 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
Robert Millan <rmh@aybabtu.com> writes:
Hi,
> I've been working for a few hours in a GRUB port to i386/OFW. There's
> quite a bit of things that need cleanup/fix before it can be considered
> complete, but it's in a stage that boots and lets you do basic things (like
> listing storage devices).
OLPC is OF!? I didn't expect this :-). Who made the firmware?
> It's known to work on OLPC / XO. I don't have a working unit myself, but
> someone from #olpc was kind enough to test it and even provided a screenshot:
>
> http://kwzs.be/pic6/P1010018.JPG
Nice :-)
> I'll be gradually integrating this into official GRUB tree. In the meantime,
> if you want to try it:
>
> - checkout GRUB cvs (grub2 module)
> - apply attached patch
> - ./autogen.sh && ./configure --with-platform=ieee1275 && make kernel.elf
>
Great! I'll just review the patch! :-)
> <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 /.)
>
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/conf/i386-ieee1275.rmk ./conf/i386-ieee1275.rmk
> --- ../../grub2/conf/i386-ieee1275.rmk 1970-01-01 01:00:00.000000000 +0100
> +++ ./conf/i386-ieee1275.rmk 2008-01-12 03:04:50.000000000 +0100
> @@ -0,0 +1,117 @@
> +# -*- makefile -*-
> +
> +COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
> +COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
> +COMMON_LDFLAGS = -nostdlib -static -lgcc
Why mregparm? I don't think we need this for OF? Do you call
assembler functions?
> +# Images.
> +pkglib_PROGRAMS = kernel.elf
> +
> +# For kernel.elf.
> +kernel_elf_SOURCES = kern/i386/ieee1275/startup.S kern/i386/ieee1275/init.c \
> + kern/powerpc/ieee1275/init.c \
> + kern/powerpc/ieee1275/cmain.c kern/powerpc/ieee1275/openfw.c \
> + kern/main.c kern/device.c \
> + kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
> + kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
> + kern/i386/dl.c kern/parser.c kern/partition.c \
> + kern/env.c \
> + kern/ieee1275/ieee1275.c \
> + term/ieee1275/ofconsole.c disk/ieee1275/ofdisk.c \
> + 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
> +kernel_elf_CFLAGS = $(COMMON_CFLAGS)
> +kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x100000,-Bstatic
> +
> +MOSTLYCLEANFILES += symlist.c kernel_syms.lst
> +DEFSYMFILES += kernel_syms.lst
> +
> +symlist.c: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h gensymlist.sh
> + /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
> +
> +kernel_syms.lst: $(addprefix include/grub/,$(kernel_elf_HEADERS)) config.h genkernsyms.sh
> + /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
> +
> +# Utilities.
> +bin_UTILITIES = grub-mkimage
> +sbin_UTILITIES = grub-mkdevicemap grub-probe
> +ifeq ($(enable_grub_emu), yes)
> +sbin_UTILITIES += grub-emu
> +endif
> +
> +# For grub-mkimage.
> +grub_mkimage_SOURCES = util/elf/grub-mkimage.c util/misc.c \
> + util/resolve.c
> +grub_mkimage_LDFLAGS = $(LIBLZO)
> +
> +# For grub-mkdevicemap.
> +grub_mkdevicemap_SOURCES = util/grub-mkdevicemap.c util/misc.c \
> + util/i386/get_disk_name.c
> +
> +# For grub-probe.
> +util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
> +grub_probe_SOURCES = util/grub-probe.c \
> + util/biosdisk.c util/misc.c util/getroot.c \
> + kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
> + fs/ext2.c kern/parser.c kern/partition.c \
> + partmap/pc.c partmap/apple.c partmap/gpt.c \
> + fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/ntfs.c fs/ntfscomp.c \
> + fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c \
> + kern/fs.c \
> + kern/env.c fs/fshelp.c \
> + disk/lvm.c disk/raid.c grub_probe_init.c
> +
> +# For grub-emu.
> +grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h \
> + grub_emu_init.h
> +grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
> + commands/configfile.c commands/echo.c commands/help.c \
> + commands/terminal.c commands/ls.c commands/test.c \
> + commands/search.c commands/blocklist.c commands/hexdump.c \
> + commands/i386/pc/halt.c commands/i386/pc/reboot.c \
> + commands/i386/cpuid.c \
> + disk/host.c disk/loopback.c disk/raid.c disk/lvm.c \
> + fs/affs.c fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c \
> + fs/jfs.c fs/minix.c fs/sfs.c fs/ufs.c fs/xfs.c fs/hfsplus.c \
> + fs/ntfs.c fs/ntfscomp.c fs/cpio.c \
> + io/gzio.c \
> + kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \
> + kern/err.c \
> + normal/execute.c kern/file.c kern/fs.c normal/lexer.c \
> + kern/loader.c kern/main.c kern/misc.c kern/parser.c \
> + grub_script.tab.c kern/partition.c kern/rescue.c kern/term.c \
> + normal/arg.c normal/cmdline.c normal/command.c normal/function.c\
> + normal/completion.c normal/main.c \
> + normal/menu.c normal/menu_entry.c normal/misc.c normal/script.c \
> + normal/color.c \
> + partmap/amiga.c partmap/apple.c partmap/pc.c partmap/sun.c \
> + partmap/acorn.c partmap/gpt.c \
> + util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
> + util/biosdisk.c util/getroot.c \
> + util/i386/pc/misc.c grub_emu_init.c
> +
> +grub_emu_LDFLAGS = $(LIBCURSES)
> +
> +# Modules.
> +pkglib_MODULES = normal.mod cpuid.mod
> +
> +# For normal.mod.
> +normal_mod_DEPENDENCIES = grub_script.tab.c grub_script.tab.h
> +normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c \
> + normal/completion.c normal/execute.c \
> + normal/function.c normal/lexer.c normal/main.c normal/menu.c \
> + normal/menu_entry.c normal/misc.c grub_script.tab.c \
> + normal/script.c normal/i386/setjmp.S normal/color.c
> +normal_mod_CFLAGS = $(COMMON_CFLAGS)
> +normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
> +normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +
> +# For cpuid.mod.
> +cpuid_mod_SOURCES = commands/i386/cpuid.c
> +cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
> +cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
> +
> +include $(srcdir)/conf/common.mk
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/configure.ac ./configure.ac
> --- ../../grub2/configure.ac 2007-12-25 10:09:42.000000000 +0100
> +++ ./configure.ac 2008-01-12 03:27:24.000000000 +0100
> @@ -1,6 +1,6 @@
> # Process this file with autoconf to produce a configure script.
>
> -# Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
> +# Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
> #
> # This configure.ac is free software; the author
> # gives unlimited permission to copy and/or distribute it,
> @@ -79,6 +79,7 @@ case "$target_cpu"-"$platform" in
> i386-efi) ;;
> i386-pc) ;;
> i386-linuxbios) ;;
> + i386-ieee1275) ;;
> powerpc-ieee1275) ;;
> sparc64-ieee1275) ;;
> *) AC_MSG_ERROR([unsupported machine type]) ;;
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/console.h ./include/grub/i386/ieee1275/console.h
> --- ../../grub2/include/grub/i386/ieee1275/console.h 1970-01-01 01:00:00.000000000 +0100
> +++ ./include/grub/i386/ieee1275/console.h 2008-01-12 00:00:56.000000000 +0100
> @@ -0,0 +1 @@
> +#include <grub/powerpc/ieee1275/console.h>
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/ieee1275.h ./include/grub/i386/ieee1275/ieee1275.h
> --- ../../grub2/include/grub/i386/ieee1275/ieee1275.h 1970-01-01 01:00:00.000000000 +0100
> +++ ./include/grub/i386/ieee1275/ieee1275.h 2008-01-12 00:01:36.000000000 +0100
> @@ -0,0 +1 @@
> +#include <grub/powerpc/ieee1275/ieee1275.h>
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/kernel.h ./include/grub/i386/ieee1275/kernel.h
> --- ../../grub2/include/grub/i386/ieee1275/kernel.h 1970-01-01 01:00:00.000000000 +0100
> +++ ./include/grub/i386/ieee1275/kernel.h 2008-01-12 00:01:13.000000000 +0100
> @@ -0,0 +1 @@
> +#include <grub/powerpc/ieee1275/kernel.h>
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/include/grub/i386/ieee1275/time.h ./include/grub/i386/ieee1275/time.h
> --- ../../grub2/include/grub/i386/ieee1275/time.h 1970-01-01 01:00:00.000000000 +0100
> +++ ./include/grub/i386/ieee1275/time.h 2008-01-11 23:59:29.000000000 +0100
> @@ -0,0 +1 @@
> +#include <grub/powerpc/ieee1275/time.h>
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/i386/ieee1275/init.c ./kern/i386/ieee1275/init.c
> --- ../../grub2/kern/i386/ieee1275/init.c 1970-01-01 01:00:00.000000000 +0100
> +++ ./kern/i386/ieee1275/init.c 2008-01-12 03:26:35.000000000 +0100
> @@ -0,0 +1,35 @@
> +/* init.c -- Initialize GRUB on Open Firmware. */
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 2003, 2004, 2005, 2007 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/>.
> + */
> +
> +#include <grub/types.h>
> +
> +void
> +grub_exit (void)
> +{
> + /* Trap to Open Firmware. */
> + /* FIXME. */
> +
> + for (;;);
> +}
> +
> +void
> +grub_arch_sync_caches (void *address __attribute__ ((unused)),
> + grub_size_t len __attribute__ ((unused)))
> +{
> +}
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/i386/ieee1275/startup.S ./kern/i386/ieee1275/startup.S
> --- ../../grub2/kern/i386/ieee1275/startup.S 1970-01-01 01:00:00.000000000 +0100
> +++ ./kern/i386/ieee1275/startup.S 2008-01-12 03:27:13.000000000 +0100
> @@ -0,0 +1,38 @@
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 1999,2000,2001,2002,2003,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 <http://www.gnu.org/licenses/>.
> + */
> +
> +#define ASM_FILE 1
> +
> +#include <grub/symbol.h>
> +
> +/*
> + * Note: GRUB is compiled with the options -mrtd and -mregparm=3.
> + * So the first three arguments are passed in %eax, %edx, and %ecx,
> + * respectively, and if a function has a fixed number of arguments
> + * and the number if greater than three, the function must return
> + * with "ret $N" where N is ((the number of arguments) - 3) * 4.
> + */
> +
> + .file "startup.S"
> + .text
> + .globl start, _start
> +
> +start:
> +_start:
> + movl %eax, EXT_C(grub_ieee1275_entry_fn)
> + jmp EXT_C(cmain)
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/main.c ./kern/main.c
> --- ../../grub2/kern/main.c 2008-01-05 13:04:35.000000000 +0100
> +++ ./kern/main.c 2008-01-12 03:03:04.000000000 +0100
> @@ -120,7 +120,7 @@ grub_main (void)
>
> /* Load pre-loaded modules and free the space. */
> grub_register_exported_symbols ();
> - grub_load_modules ();
> +// grub_load_modules ();
Why?
>
> /* It is better to set the root device as soon as possible,
> for convenience. */
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/cmain.c ./kern/powerpc/ieee1275/cmain.c
> --- ../../grub2/kern/powerpc/ieee1275/cmain.c 2007-12-30 09:52:05.000000000 +0100
> +++ ./kern/powerpc/ieee1275/cmain.c 2008-01-12 03:12:01.000000000 +0100
> @@ -58,7 +58,7 @@ grub_ieee1275_find_options (void)
> grub_ieee1275_finddevice ("/options", &options);
> rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
> sizeof realmode, 0);
> - if ((rc >= 0) && realmode)
> +// if ((rc >= 0) && realmode)
> grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
Ehm?
>
> grub_ieee1275_finddevice ("/openprom", &openprom);
> @@ -102,12 +102,9 @@ grub_ieee1275_find_options (void)
> }
> }
>
> -void cmain (uint32_t r3, uint32_t r4, uint32_t r5);
> void
> -cmain (UNUSED uint32_t r3, UNUSED uint32_t r4, uint32_t r5)
> +cmain (void)
> {
> - grub_ieee1275_entry_fn = (int (*)(void *)) r5;
> -
> grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
>
> grub_ieee1275_find_options ();
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/init.c ./kern/powerpc/ieee1275/init.c
> --- ../../grub2/kern/powerpc/ieee1275/init.c 2008-01-03 23:43:46.000000000 +0100
> +++ ./kern/powerpc/ieee1275/init.c 2008-01-12 03:26:06.000000000 +0100
> @@ -52,15 +52,6 @@ grub_millisleep (grub_uint32_t ms)
> grub_millisleep_generic (ms);
> }
>
> -void
> -grub_exit (void)
> -{
> - /* Trap to Open Firmware. */
> - asm ("trap");
> -
> - for (;;);
> -}
> -
> /* Translate an OF filesystem path (separated by backslashes), into a GRUB
> path (separated by forward slashes). */
> static void
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/openfw.c ./kern/powerpc/ieee1275/openfw.c
> --- ../../grub2/kern/powerpc/ieee1275/openfw.c 2007-12-30 09:52:05.000000000 +0100
> +++ ./kern/powerpc/ieee1275/openfw.c 2008-01-12 02:53:01.000000000 +0100
> @@ -163,18 +163,18 @@ grub_err_t grub_available_iterate (int (
>
> /* Decode each entry and call `hook'. */
> i = 0;
> - while (i < sizeof (available))
> + while (i < sizeof (available) && available[i])
> {
> grub_uint64_t address;
> grub_uint64_t size;
>
> - address = available[i++];
> + address = grub_be_to_cpu32 (available[i++]);
Why do you do this? Isn't this information available in native byte order?
> if (address_cells == 2)
> - address = (address << 32) | available[i++];
> + address = (address << 32) | grub_be_to_cpu32 (available[i++]);
>
> - size = available[i++];
> + size = grub_be_to_cpu32 (available[i++]);
> if (size_cells == 2)
> - size = (size << 32) | available[i++];
> + size = (size << 32) | grub_be_to_cpu32 (available[i++]);
>
> if (hook (address, size))
> break;
> diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/term/ieee1275/ofconsole.c ./term/ieee1275/ofconsole.c
> --- ../../grub2/term/ieee1275/ofconsole.c 2007-12-25 12:10:47.000000000 +0100
> +++ ./term/ieee1275/ofconsole.c 2008-01-12 03:09:02.000000000 +0100
> @@ -369,9 +369,6 @@ static struct grub_term grub_ofconsole_t
> .getwh = grub_ofconsole_getwh,
> .gotoxy = grub_ofconsole_gotoxy,
> .cls = grub_ofconsole_cls,
> - .setcolorstate = grub_ofconsole_setcolorstate,
> - .setcolor = grub_ofconsole_setcolor,
> - .getcolor = grub_ofconsole_getcolor,
Why do you do this?
--
Marco
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-15 11:31 ` Marco Gerards
@ 2008-01-15 12:06 ` Robert Millan
2008-01-15 12:23 ` Marco Gerards
2008-01-15 16:36 ` Robert Millan
0 siblings, 2 replies; 13+ messages in thread
From: Robert Millan @ 2008-01-15 12:06 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
On Tue, Jan 15, 2008 at 12:31:30PM +0100, Marco Gerards wrote:
> Robert Millan <rmh@aybabtu.com> writes:
>
> Hi,
>
> > I've been working for a few hours in a GRUB port to i386/OFW. There's
> > quite a bit of things that need cleanup/fix before it can be considered
> > complete, but it's in a stage that boots and lets you do basic things (like
> > listing storage devices).
>
> OLPC is OF!? I didn't expect this :-). Who made the firmware?
Mitch Bradley (author of Open Firmware).
> > I'll be gradually integrating this into official GRUB tree. In the meantime,
> > if you want to try it:
> >
> > - checkout GRUB cvs (grub2 module)
> > - apply attached patch
> > - ./autogen.sh && ./configure --with-platform=ieee1275 && make kernel.elf
> >
>
> Great! I'll just review the patch! :-)
Please don't. It's not meant for review, was just a proof of concept. The
patches I actually intend to get merged are being sent separately (see my later
mails on this).
Oh well, too late.. :-)
> > +COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
> > +COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
> > +COMMON_LDFLAGS = -nostdlib -static -lgcc
>
> Why mregparm? I don't think we need this for OF? Do you call
> assembler functions?
OFW expects %eax to be the first parameter in callbacks. Other than this,
I assumed -mregparm is a useful size optimization. Is that not it? Why
do we have it on i386-pc then?
> > /* Load pre-loaded modules and free the space. */
> > grub_register_exported_symbols ();
> > - grub_load_modules ();
> > +// grub_load_modules ();
>
> Why?
I still don't know. Memory corruption I think. I'm investigating.
> > diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/cmain.c ./kern/powerpc/ieee1275/cmain.c
> > --- ../../grub2/kern/powerpc/ieee1275/cmain.c 2007-12-30 09:52:05.000000000 +0100
> > +++ ./kern/powerpc/ieee1275/cmain.c 2008-01-12 03:12:01.000000000 +0100
> > @@ -58,7 +58,7 @@ grub_ieee1275_find_options (void)
> > grub_ieee1275_finddevice ("/options", &options);
> > rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
> > sizeof realmode, 0);
> > - if ((rc >= 0) && realmode)
> > +// if ((rc >= 0) && realmode)
> > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
>
> Ehm?
Nothing to see here. Move along.... :-)
> > - while (i < sizeof (available))
> > + while (i < sizeof (available) && available[i])
> > {
> > grub_uint64_t address;
> > grub_uint64_t size;
> >
> > - address = available[i++];
> > + address = grub_be_to_cpu32 (available[i++]);
>
> Why do you do this? Isn't this information available in native byte order?
See my other mail about IEEE-1275 and endianess.
> > diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/term/ieee1275/ofconsole.c ./term/ieee1275/ofconsole.c
> > --- ../../grub2/term/ieee1275/ofconsole.c 2007-12-25 12:10:47.000000000 +0100
> > +++ ./term/ieee1275/ofconsole.c 2008-01-12 03:09:02.000000000 +0100
> > @@ -369,9 +369,6 @@ static struct grub_term grub_ofconsole_t
> > .getwh = grub_ofconsole_getwh,
> > .gotoxy = grub_ofconsole_gotoxy,
> > .cls = grub_ofconsole_cls,
> > - .setcolorstate = grub_ofconsole_setcolorstate,
> > - .setcolor = grub_ofconsole_setcolor,
> > - .getcolor = grub_ofconsole_getcolor,
>
> Why do you do this?
GRUB still wants to set light-gray/black color when run over serial port
(or OFW terminal which could pipe to serial port). This is very ugly
when your serial port is mapped to a black/white gnome-terminal.
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-15 12:06 ` Robert Millan
@ 2008-01-15 12:23 ` Marco Gerards
2008-01-15 12:32 ` Robert Millan
2008-01-15 16:36 ` Robert Millan
1 sibling, 1 reply; 13+ messages in thread
From: Marco Gerards @ 2008-01-15 12:23 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
Robert Millan <rmh@aybabtu.com> writes:
[...]
>> Great! I'll just review the patch! :-)
>
> Please don't. It's not meant for review, was just a proof of concept. The
> patches I actually intend to get merged are being sent separately (see my later
> mails on this).
>
> Oh well, too late.. :-)
Whoops ;-)
>> > +COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
>> > +COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
>> > +COMMON_LDFLAGS = -nostdlib -static -lgcc
>>
>> Why mregparm? I don't think we need this for OF? Do you call
>> assembler functions?
>
> OFW expects %eax to be the first parameter in callbacks. Other than this,
> I assumed -mregparm is a useful size optimization. Is that not it? Why
> do we have it on i386-pc then?
On i386-pc the size restrictions are more important. On OF the binary
is loaded from the filesystem.
>> > /* Load pre-loaded modules and free the space. */
>> > grub_register_exported_symbols ();
>> > - grub_load_modules ();
>> > +// grub_load_modules ();
>>
>> Why?
>
> I still don't know. Memory corruption I think. I'm investigating.
Ah :-)
>> > diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/kern/powerpc/ieee1275/cmain.c ./kern/powerpc/ieee1275/cmain.c
>> > --- ../../grub2/kern/powerpc/ieee1275/cmain.c 2007-12-30 09:52:05.000000000 +0100
>> > +++ ./kern/powerpc/ieee1275/cmain.c 2008-01-12 03:12:01.000000000 +0100
>> > @@ -58,7 +58,7 @@ grub_ieee1275_find_options (void)
>> > grub_ieee1275_finddevice ("/options", &options);
>> > rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
>> > sizeof realmode, 0);
>> > - if ((rc >= 0) && realmode)
>> > +// if ((rc >= 0) && realmode)
>> > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
>>
>> Ehm?
>
> Nothing to see here. Move along.... :-)
:-)
>> > - while (i < sizeof (available))
>> > + while (i < sizeof (available) && available[i])
>> > {
>> > grub_uint64_t address;
>> > grub_uint64_t size;
>> >
>> > - address = available[i++];
>> > + address = grub_be_to_cpu32 (available[i++]);
>>
>> Why do you do this? Isn't this information available in native byte order?
>
> See my other mail about IEEE-1275 and endianess.
Which subject?
>> > diff -x '*.mk' -x '*~' -x CVS -x .svn -x configure -x config.h.in -Nurp ../../grub2/term/ieee1275/ofconsole.c ./term/ieee1275/ofconsole.c
>> > --- ../../grub2/term/ieee1275/ofconsole.c 2007-12-25 12:10:47.000000000 +0100
>> > +++ ./term/ieee1275/ofconsole.c 2008-01-12 03:09:02.000000000 +0100
>> > @@ -369,9 +369,6 @@ static struct grub_term grub_ofconsole_t
>> > .getwh = grub_ofconsole_getwh,
>> > .gotoxy = grub_ofconsole_gotoxy,
>> > .cls = grub_ofconsole_cls,
>> > - .setcolorstate = grub_ofconsole_setcolorstate,
>> > - .setcolor = grub_ofconsole_setcolor,
>> > - .getcolor = grub_ofconsole_getcolor,
>>
>> Why do you do this?
>
> GRUB still wants to set light-gray/black color when run over serial port
> (or OFW terminal which could pipe to serial port). This is very ugly
> when your serial port is mapped to a black/white gnome-terminal.
I see.
--
Marco
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-15 12:23 ` Marco Gerards
@ 2008-01-15 12:32 ` Robert Millan
2008-01-15 12:48 ` Marco Gerards
0 siblings, 1 reply; 13+ messages in thread
From: Robert Millan @ 2008-01-15 12:32 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
On Tue, Jan 15, 2008 at 01:23:30PM +0100, Marco Gerards wrote:
> > OFW expects %eax to be the first parameter in callbacks. Other than this,
> > I assumed -mregparm is a useful size optimization. Is that not it? Why
> > do we have it on i386-pc then?
>
> On i386-pc the size restrictions are more important. On OF the binary
> is loaded from the filesystem.
We need at least -mregparm=1. Does it make sense to move from 3 to 1 ? I
think it's better to stay at 3 for consistency.
> >> Why do you do this? Isn't this information available in native byte order?
> >
> > See my other mail about IEEE-1275 and endianess.
>
> Which subject?
"[PATCH] fix endianess in IEEE-1275 integer properties"
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-15 12:32 ` Robert Millan
@ 2008-01-15 12:48 ` Marco Gerards
0 siblings, 0 replies; 13+ messages in thread
From: Marco Gerards @ 2008-01-15 12:48 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
Robert Millan <rmh@aybabtu.com> writes:
> On Tue, Jan 15, 2008 at 01:23:30PM +0100, Marco Gerards wrote:
>> > OFW expects %eax to be the first parameter in callbacks. Other than this,
>> > I assumed -mregparm is a useful size optimization. Is that not it? Why
>> > do we have it on i386-pc then?
>>
>> On i386-pc the size restrictions are more important. On OF the binary
>> is loaded from the filesystem.
>
> We need at least -mregparm=1. Does it make sense to move from 3 to 1 ? I
> think it's better to stay at 3 for consistency.
Sure. What you have is fine to me.
>> >> Why do you do this? Isn't this information available in native byte order?
>> >
>> > See my other mail about IEEE-1275 and endianess.
>>
>> Which subject?
>
> "[PATCH] fix endianess in IEEE-1275 integer properties"
Found and replied.
--
Marco
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-15 12:06 ` Robert Millan
2008-01-15 12:23 ` Marco Gerards
@ 2008-01-15 16:36 ` Robert Millan
2008-01-21 10:24 ` Marco Gerards
1 sibling, 1 reply; 13+ messages in thread
From: Robert Millan @ 2008-01-15 16:36 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
On Tue, Jan 15, 2008 at 01:06:43PM +0100, Robert Millan wrote:
> > > /* Load pre-loaded modules and free the space. */
> > > grub_register_exported_symbols ();
> > > - grub_load_modules ();
> > > +// grub_load_modules ();
> >
> > Why?
>
> I still don't know. Memory corruption I think. I'm investigating.
Ok, this would explain it:
_start: 0x10000, _end: 0x1f804
Using memory for heap: addr=0x100000, end=0x400000
Using memory for heap: addr=0x2000, end=0x9ffff
Welcome to GRUB!
See how our core image and the second heap chunk overlap. I'm not sure if this
is a bug in OFW's /memory/available, but in any case it doesn't hurt to add a
generic sanity check in our memory manager to avoid this sort of breakage.
It's also be useful to protect our own stack, etc..
What do you think?
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-15 16:36 ` Robert Millan
@ 2008-01-21 10:24 ` Marco Gerards
2008-01-21 11:33 ` Robert Millan
0 siblings, 1 reply; 13+ messages in thread
From: Marco Gerards @ 2008-01-21 10:24 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
Robert Millan <rmh@aybabtu.com> writes:
> On Tue, Jan 15, 2008 at 01:06:43PM +0100, Robert Millan wrote:
>> > > /* Load pre-loaded modules and free the space. */
>> > > grub_register_exported_symbols ();
>> > > - grub_load_modules ();
>> > > +// grub_load_modules ();
>> >
>> > Why?
>>
>> I still don't know. Memory corruption I think. I'm investigating.
>
> Ok, this would explain it:
>
> _start: 0x10000, _end: 0x1f804
> Using memory for heap: addr=0x100000, end=0x400000
> Using memory for heap: addr=0x2000, end=0x9ffff
> Welcome to GRUB!
>
> See how our core image and the second heap chunk overlap. I'm not sure if this
> is a bug in OFW's /memory/available, but in any case it doesn't hurt to add a
> generic sanity check in our memory manager to avoid this sort of breakage.
>
> It's also be useful to protect our own stack, etc..
>
> What do you think?
At least some kind of check should be available. It could also be in
init.c.
--
Marco
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: GRUB on OLPC / XO
2008-01-21 10:24 ` Marco Gerards
@ 2008-01-21 11:33 ` Robert Millan
0 siblings, 0 replies; 13+ messages in thread
From: Robert Millan @ 2008-01-21 11:33 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: devel
On Mon, Jan 21, 2008 at 11:24:52AM +0100, Marco Gerards wrote:
> >
> > _start: 0x10000, _end: 0x1f804
> > Using memory for heap: addr=0x100000, end=0x400000
> > Using memory for heap: addr=0x2000, end=0x9ffff
> > Welcome to GRUB!
> >
> > See how our core image and the second heap chunk overlap. I'm not sure if this
> > is a bug in OFW's /memory/available, but in any case it doesn't hurt to add a
> > generic sanity check in our memory manager to avoid this sort of breakage.
> >
> > It's also be useful to protect our own stack, etc..
> >
> > What do you think?
>
> At least some kind of check should be available. It could also be in
> init.c.
Yep.
I concluded that there's nothing usefuly portable about having this in kern/,
and proposed:
[PATCH] safety check in claim_heap()
see my other mail below.
--
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 /.)
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2008-01-21 11:35 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-12 13:42 GRUB on OLPC / XO Robert Millan
2008-01-12 14:00 ` Robert Millan
[not found] ` <4789009B.8030403@laptop.org>
2008-01-12 18:58 ` Robert Millan
[not found] ` <47891639.7070500@laptop.org>
[not found] ` <47891889.5020402@laptop.org>
2008-01-12 20:30 ` Robert Millan
-- strict thread matches above, loose matches on Subject: below --
2008-01-12 3:14 Robert Millan
2008-01-15 11:31 ` Marco Gerards
2008-01-15 12:06 ` Robert Millan
2008-01-15 12:23 ` Marco Gerards
2008-01-15 12:32 ` Robert Millan
2008-01-15 12:48 ` Marco Gerards
2008-01-15 16:36 ` Robert Millan
2008-01-21 10:24 ` Marco Gerards
2008-01-21 11:33 ` Robert Millan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.