Skip to contentSkip to conversation

multiboot

DISCUSSION Johan Rydberg 3 participants 14 messages Dec 7, 2004 – Dec 9, 2004

lore
Share & tools
lore
#0 lore raw

What's the status of the multiboot module in GRUB2? Has anyone (Jeroen?) tried to boot for example the Hurd (or Hurd/L4)?

~j

#1 lore raw
Quoted 2 lines · Johan Rydberg

What's the status of the multiboot module in GRUB2? Has anyone (Jeroen?) tried to boot for example the Hurd (or Hurd/L4)?

AFAIK it can be used to boot GNU/Hurd. IIRC I used that. But there were some problems with the multiboot scripts as they are used. The variables are parsed by GRUB 2 as well so you have to escape them.

Just have a look at my script to create boot floppies, IIRC that one worked for booting GNU/Hurd.

I did not test :4 Hurd yet.

--
Marco

#2 lore raw
Quoted 6 lines · Marco Gerards

AFAIK it can be used to boot GNU/Hurd. IIRC I used that. But there were some problems with the multiboot scripts as they are used. The variables are parsed by GRUB 2 as well so you have to escape them.

Just have a look at my script to create boot floppies, IIRC that one worked for booting GNU/Hurd.

Great to hear.

This brings me to the next issue; have someone tried to boot GRUB2/PPC with U-Boot? It would be a fun experiment to try to run GRUB on a development board like Ebony or Atlantis.

So, what do I need to get going? A powerpc-elf (or should I use some other target?) cross-compiler?

~j

#3 lore raw
Quoted 3 lines · Johan Rydberg

This brings me to the next issue; have someone tried to boot GRUB2/PPC with U-Boot? It would be a fun experiment to try to run GRUB on a development board like Ebony or Atlantis.

U-Boot is another PPC firmware, right? Something like OF, but not compatible?

Quoted 2 lines

So, what do I need to get going? A powerpc-elf (or should I use some other target?) cross-compiler?

You can use a cross-compiler to compile grubof.

--
Marco

#4 lore raw
Quoted 6 lines · Marco Gerards
Quoted 3 lines

This brings me to the next issue; have someone tried to boot GRUB2/PPC with U-Boot? It would be a fun experiment to try to run GRUB on a development board like Ebony or Atlantis.

U-Boot is another PPC firmware, right? Something like OF, but not compatible?

It's a boot loader that is used to boot GNU/Linux on PPC (and other) platforms. More information can be found at http://ppcboot.sourceforge.net/

I don't think it has a firmware layer at all, so I suppose you must implement things like IDE and console in GRUB itself. Which of course can be rather boring and error prune.

The real question I guess is whether or not things like drivers should be included in GRUB2 at all, or should GRUB always depend on an underlying layer to provide those facilities?

Quoted 4 lines
Quoted 2 lines

So, what do I need to get going? A powerpc-elf (or should I use some other target?) cross-compiler?

You can use a cross-compiler to compile grubof.

I didn't manage to do so. I'll research it a bit and probably send in a patch.

~j

#5 lore raw
Quoted 7 lines · Johan Rydberg

I don't think it has a firmware layer at all, so I suppose you must implement things like IDE and console in GRUB itself. Which of course can be rather boring and error prune.

The real question I guess is whether or not things like drivers should be included in GRUB2 at all, or should GRUB always depend on an underlying layer to provide those facilities?

In some cases, yes. For example a framebuffer driver like we have on the PC. Perhaps we can do the same for the PPC. The disadvantage is that we need several drivers (ATI, nvidia, matrox, etc).

An IDE/ATAPI driver for the PC would be nice too IMHO. In that case we can support CDROM drives without relying on the BIOS.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So, what do I need to get going? A powerpc-elf (or should I use some other target?) cross-compiler?

You can use a cross-compiler to compile grubof.

I didn't manage to do so. I'll research it a bit and probably send in a patch.

Nice.

Thanks,
Marco

#6 lore raw
Quoted 4 lines · Marco Gerards
Quoted 2 lines

I didn't manage to do so. I'll research it a bit and probably send in a patch.

Nice.

The initial problem was that AC_CHECK_SIZEOF doesn't work if you're cross-compiling. I fixed this by using AC_COMPILE_CHECK_SIZEOF [1] instead.

But the major problem is that parts of GRUB2 requires a C library to be installed, at least headers such as alloca.h and stdint.h. Is this really a valid demand?

Another issue regarding BUILD_CC. The normal convention is that if you want to build something that should run on the build machine, you use something similar to BUILD_CC. That's why I think the following patch is self-explaining.

configure.ac 8 Dec 2004 12:57:07 -0000 renamed from configure.ac 4 Apr 2004 13:45:59 -0000 1.9 +1 -1
@@ -109,7 +109,7 @@
 AC_PATH_PROG(RUBY, ruby)
 
 # For cross-compiling.
-if test "x$build" = "x$host"; then
+if test "x$build" != "x$host"; then
   AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
                 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
 else
@@ -127,8 +127,8 @@
 

That brings us the next issue; BUILD_CC is used to build _everything_, including the host-specific object files, and since BUILD_CC is set to /usr/bin/gcc in my cross-compiler environment it will try to compile PPC assembler sources with a i386 compiler. Not good.

My suggestion is to create a new class for programs that should be host-specific, and let Utilities be compiled on the build machine. See the patch.

~j

[1] http://ac-archive.sourceforge.net/Miscellaneous/ac_compile_check_sizeof.html

Index: genmk.rb
===================================================================
RCS file: /cvsroot/grub/grub2/genmk.rb,v
retrieving revision 1.8

genmk.rb +53 -0

74 lines not on this page · raw message

Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.15

powerpc-ieee1275.rmk +3 -1
diff -u -r1.15 powerpc-ieee1275.rmk
@@ -15,8 +15,10 @@
 kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh
 	sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@
 
+# Programs.
+sbin_PROGRAMS = grubof
+
 # Utilities.
-sbin_UTILITIES = grubof
 bin_UTILITIES = grub-emu
 noinst_UTILITIES = genmoddep
 
#7 lore raw

genmk.rb line 229

Quoted 2 lines · Johan Rydberg
genmk.rb +2 -0
+#{@name}: #{objs_str}
+	$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(#{prefix}_LDFLAGS)

Should be $(CC) of course. Anyway, the patch was just to promote my idea.

~j

#8 lore raw
In reply to Johan Rydberg
Quoted 3 lines · Johan Rydberg

The initial problem was that AC_CHECK_SIZEOF doesn't work if you're cross-compiling. I fixed this by using AC_COMPILE_CHECK_SIZEOF [1] instead.

This sounds right to me, but I do not see this in the patch...

Quoted 3 lines

But the major problem is that parts of GRUB2 requires a C library to be installed, at least headers such as alloca.h and stdint.h. Is this really a valid demand?

Is this required for grubof? IIRC those headers are not a part of the C library, but a part of gcc or libgcc or so. Am I right about that?

Instead of alloca we can also use something like:

...

{
int foo[size]
...
}

In most cases that will remove the dependency on alloca. IMHO it is better not to use alloca.

Quoted 4 lines

Another issue regarding BUILD_CC. The normal convention is that if you want to build something that should run on the build machine, you use something similar to BUILD_CC. That's why I think the following patch is self-explaining.

That sounds sane to me. I assume this fixes Timothy's problem as well.

Quoted 8 lines

That brings us the next issue; BUILD_CC is used to build _everything_, including the host-specific object files, and since BUILD_CC is set to /usr/bin/gcc in my cross-compiler environment it will try to compile PPC assembler sources with a i386 compiler. Not good.

My suggestion is to create a new class for programs that should be host-specific, and let Utilities be compiled on the build machine. See the patch.

Ok, that sounds sane. But what if you really want to cross-compile a complete system (including libc, GRUB, etc)?

Can you make one big patch with a changelog entry so it can be committed after Okuji agrees with the patch?

Thanks,
Marco

#9 lore raw
Quoted 7 lines · Marco Gerards
Quoted 3 lines · Johan Rydberg

The initial problem was that AC_CHECK_SIZEOF doesn't work if you're cross-compiling. I fixed this by using AC_COMPILE_CHECK_SIZEOF [1] instead.

This sounds right to me, but I do not see this in the patch...

Of course not. I didn't include it :) I'm sure you can download the m4 macro, install it in acinclude.m4 and change AC_CHECK_SIZEOF to AC_COMPILE_CHECK_SIZEOF. If you're as lazy as I am, I can include it in a later patch.

Quoted 6 lines
Quoted 3 lines

But the major problem is that parts of GRUB2 requires a C library to be installed, at least headers such as alloca.h and stdint.h. Is this really a valid demand?

Is this required for grubof? IIRC those headers are not a part of the C library, but a part of gcc or libgcc or so. Am I right about that?

My GCC installation (3.2.2 configured for powerpc-elf) installed the following headers:

/gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/syslimits.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/stdarg.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/stddef.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/varargs.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/stdbool.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/iso646.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/ppc-asm.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/altivec.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/limits.h /gnu/lib/gcc-lib/powerpc-elf/3.2.2/include/float.h

And my native installation of GCC (3.3.4 configured for i486-linux) includes:

/usr/lib/gcc-lib/i486-linux/3.3.4/include/iso646.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/float.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/limits.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdarg.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/stdbool.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/stddef.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/syslimits.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/unwind.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/varargs.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/mmintrin.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/emmintrin.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/pmmintrin.h /usr/lib/gcc-lib/i486-linux/3.3.4/include/xmmintrin.h

A little more research shows that both stdint.h and alloca.h is part of glibc:

$ head -2 /usr/include/stdint.h 
/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
$ head -2 /usr/include/alloca.h 
/* Copyright (C) 1992, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

So either we stop using then, or write our own versions.

Quoted 4 lines

Instead of alloca we can also use something like:
[...]
In most cases that will remove the dependency on alloca. IMHO it is better not to use alloca.

It is also possible to use __builtin_alloca if alloca.h is missing, provided that there's a requirement for GCC.

Quoted 11 lines
Quoted 8 lines

That brings us the next issue; BUILD_CC is used to build _everything_, including the host-specific object files, and since BUILD_CC is set to /usr/bin/gcc in my cross-compiler environment it will try to compile PPC assembler sources with a i386 compiler. Not good.

My suggestion is to create a new class for programs that should be host-specific, and let Utilities be compiled on the build machine. See the patch.

Ok, that sounds sane. But what if you really want to cross-compile a complete system (including libc, GRUB, etc)?

Good call. I'm not sure what to do. Got any ideas?

Quoted 2 lines

Can you make one big patch with a changelog entry so it can be committed after Okuji agrees with the patch?

I would prefer Okuji looked at the changes to genmk.rb before that.

~j

#10 lore raw
Quoted 8 lines · Johan Rydberg
Quoted 6 lines · Marco Gerards
Quoted 3 lines · Johan Rydberg

The initial problem was that AC_CHECK_SIZEOF doesn't work if you're cross-compiling. I fixed this by using AC_COMPILE_CHECK_SIZEOF [1] instead.

Quoted 6 lines
Quoted 1 line

This sounds right to me, but I do not see this in the patch...

Of course not. I didn't include it :) I'm sure you can download the m4 macro, install it in acinclude.m4 and change AC_CHECK_SIZEOF to AC_COMPILE_CHECK_SIZEOF. If you're as lazy as I am, I can include it in a later patch.

As you know, I am lazy... ;)

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

But the major problem is that parts of GRUB2 requires a C library to be installed, at least headers such as alloca.h and stdint.h. Is this really a valid demand?

Is this required for grubof? IIRC those headers are not a part of the C library, but a part of gcc or libgcc or so. Am I right about that?

My GCC installation (3.2.2 configured for powerpc-elf) installed the following headers:

[...]

Quoted 2 lines

A little more research shows that both stdint.h and alloca.h is part of glibc:

[...]

Quoted 1 line

So either we stop using then, or write our own versions.

Ok, agreed.

Quoted 7 lines
Quoted 4 lines

Instead of alloca we can also use something like:
[...]
In most cases that will remove the dependency on alloca. IMHO it is better not to use alloca.

It is also possible to use __builtin_alloca if alloca.h is missing, provided that there's a requirement for GCC.

There is a gcc requirement already, that is not a problem.

Thanks,
Marco

#11 lore raw
In reply to Johan Rydberg
Quoted 3 lines · Johan Rydberg

The initial problem was that AC_CHECK_SIZEOF doesn't work if you're cross-compiling. I fixed this by using AC_COMPILE_CHECK_SIZEOF [1] instead.

Ok.

Quoted 3 lines

But the major problem is that parts of GRUB2 requires a C library to be installed, at least headers such as alloca.h and stdint.h. Is this really a valid demand?

Why do we use stdint.h? As far as I see, it is used only for powerpc-specific code. This should be removed. GRUB must use its own types defined in include/grub/types.h.

alloca should not be used. It must be replaced with something else (e.g. grub_malloc). Note that alloca requires a C library in some architectures.

Quoted 4 lines

Another issue regarding BUILD_CC. The normal convention is that if you want to build something that should run on the build machine, you use something similar to BUILD_CC. That's why I think the following patch is self-explaining.

You are right. I didn't notice the bug, because I usually specify CC and BUILD_CC manually.

Quoted 5 lines

That brings us the next issue; BUILD_CC is used to build _everything_, including the host-specific object files, and since BUILD_CC is set to /usr/bin/gcc in my cross-compiler environment it will try to compile PPC assembler sources with a i386 compiler. Not good.

Why? Host-specific objects are compiled by CC instead of BUILD_CC.

Okuji

#12 lore raw
Quoted 7 lines · Yoshinori K. Okuji
Quoted 5 lines

That brings us the next issue; BUILD_CC is used to build _everything_, including the host-specific object files, and since BUILD_CC is set to /usr/bin/gcc in my cross-compiler environment it will try to compile PPC assembler sources with a i386 compiler. Not good.

Why? Host-specific objects are compiled by CC instead of BUILD_CC.

Not for the powerpc target, where everything is "utilities" including grubof.

~j

#13 lore raw
Quoted 8 lines · Johan Rydberg
Quoted 6 lines · Yoshinori K. Okuji
Quoted 5 lines

That brings us the next issue; BUILD_CC is used to build _everything_, including the host-specific object files, and since BUILD_CC is set to /usr/bin/gcc in my cross-compiler environment it will try to compile PPC assembler sources with a i386 compiler. Not good.

Quoted 4 lines
Quoted 1 line

Why? Host-specific objects are compiled by CC instead of BUILD_CC.

Not for the powerpc target, where everything is "utilities" including grubof.

Right, but that is just a "bug" that should be fixed after module loading works.

As for module loading. It already works, but in grubof it crashes when jumping into the module. This is most likely a problem with the protection of the memory. Johan told me to have a look at the ibat registers, etc. I'll do that.

I can check in the kern/powerpc/dl.c + powerpc-ieee1275.rmk changes so it becomes easy for Hollis to finish grub-mkimage, IIRC he still wanted to do some things there, although it worked fine for me.

That way we can get module loading quite soon and fix the problem with utilities as well... Hacking around this problem while it is not crucial does not seem right to me.

Thanks,
Marco