Hi,
I recently played around with LinuxBIOS and FreeBSD. In short, it somewhat works in QEMU using ADLO, see [1]. While trying to build LinuxBIOS and ADLO on FreeBSD, I came across some problems. They all come from the assumption that "make" is "GNU make" which isn't true on the BSDs. I've uploaded some really hackish patches to [2]. Unfortunately, I have no idea how to detect FreeBSD from a Makefile or a Python script. But maybe someone on this list knows and wants enhance the patches so they can be included in the LinuxBIOS tree.
Regards,
Philip
[1] http://linuxbios.org/index.php/Booting_FreeBSD_using_LinuxBIOS [2] http://linuxbios.org/images/b/b6/LinuxBIOS_ADLO_FreeBSD.tgz
On Thu, Oct 25, 2007 at 04:44:28PM +0200, Philip Schulz wrote:
I recently played around with LinuxBIOS and FreeBSD. In short, it somewhat works in QEMU using ADLO, see [1]. While trying to build
Great to hear, thanks!
LinuxBIOS and ADLO on FreeBSD, I came across some problems. They all come from the assumption that "make" is "GNU make" which isn't true on the BSDs. I've uploaded some really hackish patches to [2].
Please post all patches to the list, with a Signed-off-by: http://linuxbios.org/index.php/Development_Guidelines#Sign-off_Procedure
Much easier to review that way, and we don't commit any patches which are lacking a proper Signed-off-by line.
Unfortunately, I have no idea how to detect FreeBSD from a Makefile or a Python script. But maybe someone on this list knows and wants enhance the patches so they can be included in the LinuxBIOS tree.
There are some good hints in the Debian GNU/kFreeBSD porting website: http://glibc-bsd.alioth.debian.org/porting/PORTING
Partly Debian/kFreeBSD specific, but most of it should also be true for plain FreeBSD.
Most of your patch is just make -> gmake, so it should be easy to use $(MAKE) everywhere and set that to "gmake" on FreeBSD and "make" everywhere else.
[1] http://linuxbios.org/index.php/Booting_FreeBSD_using_LinuxBIOS
Nice, thanks for adding that page!
Can you please attach a license to that wiki page? Either GPL, or Creative Commons, or public domain, anything free-ish will do. There are wiki templates you can use, e.g. {{GPL}}, {{PD-self}} etc.
Thanks, Uwe.
Am 25.10.2007 18:54, Uwe Hermann schrieb: [...]
Please post all patches to the list, with a Signed-off-by: http://linuxbios.org/index.php/Development_Guidelines#Sign-off_Procedure
Much easier to review that way, and we don't commit any patches which are lacking a proper Signed-off-by line.
Thanks for the pointer.
Unfortunately, I have no idea how to detect FreeBSD from a Makefile or a Python script. But maybe someone on this list knows and wants enhance the patches so they can be included in the LinuxBIOS tree.
There are some good hints in the Debian GNU/kFreeBSD porting website: http://glibc-bsd.alioth.debian.org/porting/PORTING
Partly Debian/kFreeBSD specific, but most of it should also be true for plain FreeBSD.
Most of your patch is just make -> gmake, so it should be easy to use $(MAKE) everywhere and set that to "gmake" on FreeBSD and "make" everywhere else.
Ok, thanks for the hints. I'll see what I can come up with.
[1] http://linuxbios.org/index.php/Booting_FreeBSD_using_LinuxBIOS
Nice, thanks for adding that page!
Can you please attach a license to that wiki page? Either GPL, or Creative Commons, or public domain, anything free-ish will do. There are wiki templates you can use, e.g. {{GPL}}, {{PD-self}} etc.
Done.
On Fri, Oct 26, 2007 at 08:14:35AM +0200, Philip Schulz wrote:
Can you please attach a license to that wiki page? Either GPL, or Creative Commons, or public domain, anything free-ish will do. There are wiki templates you can use, e.g. {{GPL}}, {{PD-self}} etc.
Done.
Thanks!
Btw, you mention in the wiki that VGA won't work. AFAIK it _should_ work with the latest LinuxBIOSv2 version and the required (patched) vgabios-cirrus.bin file in your $HOME (or whereever your bios.bin is stored). Also, I know for sure that VGA works in v3, too. While v3 is still in development, the QEMU target works fine already (including VGA).
HTH, Uwe.
Uwe Hermann wrote:
Btw, you mention in the wiki that VGA won't work. AFAIK it _should_ work with the latest LinuxBIOSv2 version and the required (patched) vgabios-cirrus.bin file in your $HOME (or whereever your bios.bin is stored). Also, I know for sure that VGA works in v3, too. While v3 is still in development, the QEMU target works fine already (including VGA).
I didn't try VGA because I explicitly want a system w/o VGA. That's not so important for QEMU, but I'd like to try things out on real hardware sometime soon.
Anyways, I assume you're talking about the vgabios-cirrus.bin file build from (patched) sources by the project at http://www.nongnu.org/vgabios/? If so, I've just downloaded version 0.6a and tried to build it, but it fails. The failure is documented below, if anyone is interested.
Regards,
Philip
--
vgabios-06a build failure follows:
[phs@thinkpad ~/vgabios-0.6a]$ gmake gcc -o biossums biossums.c biossums.c: In function 'main': biossums.c:63: warning: incompatible implicit declaration of built-in function 'memset' gcc -o vbetables-gen vbetables-gen.c ./vbetables-gen > vbetables.h gcc -E vgabios.c -DVBE "-DVGABIOS_DATE="`date '+%d %b %Y'`"" > _vgabios_.c bcc -o vgabios.s -C-c -D__i86__ -S -0 _vgabios_.c _vgabios_.c:1: error: Unknown preprocessor directive _vgabios_.c:2: error: Unknown preprocessor directive _vgabios_.c:3: error: Unknown preprocessor directive _vgabios_.c:4: error: Unknown preprocessor directive _vgabios_.c:5: error: Unknown preprocessor directive _vgabios_.c:6: error: Unknown preprocessor directive
[...]
[phs@thinkpad ~/vgabios-0.6a]$ head _vgabios_.c # 1 "vgabios.c" # 1 "<built-in>" # 1 "<command-line>" # 1 "vgabios.c" # 51 "vgabios.c" # 1 "vgabios.h" 1
Hi,
On 10/25/07 18:54, Uwe Hermann wrote:
On Thu, Oct 25, 2007 at 04:44:28PM +0200, Philip Schulz wrote:
[...]
Unfortunately, I have no idea how to detect FreeBSD from a Makefile or a Python script. But maybe someone on this list knows and wants enhance the patches so they can be included in the LinuxBIOS tree.
[...]
Most of your patch is just make -> gmake, so it should be easy to use $(MAKE) everywhere and set that to "gmake" on FreeBSD and "make" everywhere else.
It seems that on FreeBSD, ${MAKE} is set to the name of the binary you invoke (gnumake is a hard-link to gmake in this example):
[phs@thinkpad ~]$ cat Makefile all: echo ${MAKE}
[phs@thinkpad ~]$ make echo make make [phs@thinkpad ~]$ gmake echo gmake gmake [phs@thinkpad ~]$ gnumake echo gnumake gnumake
Anyways, attached is an updated version of the initial patch. It hopefully doesn't brake builds on Linux and makes LinuxBIOS (and ADLO) compile on FreeBSD. Also, this uses "domainname" instead of "dnsdomainname" on FreeBSD.
Signed-off-by: Philip Schulz phs@deadc0.de
I hope this is the correct way to post a patch.
Regards,
Philip
Index: src/config/Config.lb =================================================================== --- src/config/Config.lb (revision 2944) +++ src/config/Config.lb (working copy) @@ -5,7 +5,7 @@
makedefine CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name) -makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: (.*)/\1include/gp") +makedefine GCC_INC_DIR := $(shell if [ `uname` = "FreeBSD" ] ; then echo "/usr/include" ; else $(CC) -print-search-dirs | sed -ne "s/install: (.*)/\1include/gp" ; fi )
makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS) makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin -Wall Index: src/config/Options.lb =================================================================== --- src/config/Options.lb (revision 2944) +++ src/config/Options.lb (working copy) @@ -134,7 +134,7 @@ end
define LINUXBIOS_COMPILE_DOMAIN - default "$(shell dnsdomainname)" + default "$(shell if [ `uname` = "FreeBSD" ] ; then domainname ; else dnsdomainname ; fi )" export always format ""%s"" comment "Build domain name" Index: util/ADLO/Makefile =================================================================== --- util/ADLO/Makefile (revision 2944) +++ util/ADLO/Makefile (working copy) @@ -40,7 +40,7 @@ #-------------------------------------------------
bios: - ( cd ${BOCHS_B} ; make ) + ( cd ${BOCHS_B} ; ${MAKE} ) sync
#------------------------------------------------- @@ -101,7 +101,7 @@
clean: rm -rf *.o ${PAYLOAD} - (cd ${BOCHS_B} ; make clean ) + (cd ${BOCHS_B} ; ${MAKE} clean )
distclean: clean rm -rf ${BOCHS_C} Index: util/newconfig/config.g =================================================================== --- util/newconfig/config.g (revision 2944) +++ util/newconfig/config.g (working copy) @@ -2158,7 +2158,7 @@ for i, o in romimages.items(): file.write("%s/linuxbios.rom:\n" % o.getname()) file.write("\tif (cd %s; \\n" % o.getname()) - file.write("\t\tmake linuxbios.rom)\\n") + file.write("\t\t${MAKE} linuxbios.rom)\\n") file.write("\tthen true; else exit 1; fi;\n\n") file.write("clean: ") for i in romimages.keys(): @@ -2166,7 +2166,7 @@ file.write("\n\n") for i, o in romimages.items(): file.write("%s-clean:\n" % o.getname()) - file.write("\t(cd %s; make clean)\n\n" % o.getname()) + file.write("\t(cd %s; ${MAKE} clean)\n\n" % o.getname())
for i in buildroms: file.write("%s:" % i.name)
On Thu, Oct 25, 2007 at 04:44:28PM +0200, Philip Schulz wrote:
I recently played around with LinuxBIOS and FreeBSD. In short, it somewhat works in QEMU using ADLO
Cool!
Do you know the FBSD boot process internals well?
I discussed this at Linuxforum.dk this spring with some FBSD people and have a contact I can dig up if you want to pick up the ball.
The idea is to short-circuit all the BIOS junk that ADLO emulates and have LB/elfboot/FILO start the kernel directly, as is done with Linux.
Since the *BSD boot process is split into several steps that may not be quite as easy as with Linux however.
//Peter
Am 26.10.2007 02:07, Peter Stuge schrieb:
On Thu, Oct 25, 2007 at 04:44:28PM +0200, Philip Schulz wrote:
I recently played around with LinuxBIOS and FreeBSD. In short, it somewhat works in QEMU using ADLO
Cool!
Do you know the FBSD boot process internals well?
No, I'm still learning.
I discussed this at Linuxforum.dk this spring with some FBSD people and have a contact I can dig up if you want to pick up the ball.
I'm afraid I've just started so I might not even be qualified to ask good questions. But thanks for the offer anyways, I might get back to you once I've made some progress.
The idea is to short-circuit all the BIOS junk that ADLO emulates and have LB/elfboot/FILO start the kernel directly, as is done with Linux.
Since the *BSD boot process is split into several steps that may not be quite as easy as with Linux however.
Yes, the FreeBSD/i386 boot process is split into several steps. FWIW, there's a man page describing the boot process at [1]. While you could probably use the FreeBSD kernel as a payload to LinuxBIOS, I don't think it would be a good idea. First, the FreeBSD GENERIC kernel, i.e. default kernel, is about 8.6 MBytes. The size could be reduced by removing drivers and options, but then it'd still be a few MBytes in size. Maybe gzipping the kernel image would work, I don't know. But there's a second and more important reason not to boot the kernel directly: The FreeBSD kernel doesn't understand command line options like "--init=/bin/sh" which I think the Linux kernel does. Instead, the FreeBSD kernel relies on a little program called "loader" to supply it with boot time options, e.g. selecting the default console or telling the kernel to boot in single-user mode. Also, the loader takes care of loading kernel modules at boot time. The loader will look for options in a file called /boot/loader.conf, parse it and then load the kernel from /boot/kernel/kernel. Obviously, the loader has to understand a fair amount of UFS in order to do that. So in short, I think the loader should be used as a LinuxBIOS payload instead of the kernel (which is what I'm going to try one of these days). I'm no expert though, so I might be wrong.
Regards,
Philip
[1]http://www.freebsd.org/cgi/man.cgi?query=boot&apropos=0&sektion=0&am...