Split coreboot and multiboot ports.

* conf/i386-multiboot.rmk: New file.
	* configure.ac: Add multiboot port.
	* include/grub/i386/multiboot/boot.h: New file.
	* include/grub/i386/multiboot/console.h: Likewise.
	* include/grub/i386/multiboot/init.h: Likewise.
	* include/grub/i386/multiboot/kernel.h: Likewise.
	* include/grub/i386/multiboot/loader.h: Likewise.
	* include/grub/i386/multiboot/memory.h: Likewise.
	* include/grub/i386/multiboot/serial.h: Likewise.
	* include/grub/i386/multiboot/time.h: Likewise.
	* include/grub/multiboot.h: Add GRUB_MACHINE_MULTIBOOT to ifdef.
	* loader/multiboot.c: Likewise.
	* loader/multiboot_mbi2.c: Likewise.
	* util/grub-mkrescue.in: Generate multiboot rescue.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-05-01 14:06:53 +02:00
parent 3080f7a7bd
commit 7210dca942
15 changed files with 118 additions and 15 deletions

View file

@ -1,3 +1,22 @@
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
Split coreboot and multiboot ports.
* conf/i386-multiboot.rmk: New file.
* configure.ac: Add multiboot port.
* include/grub/i386/multiboot/boot.h: New file.
* include/grub/i386/multiboot/console.h: Likewise.
* include/grub/i386/multiboot/init.h: Likewise.
* include/grub/i386/multiboot/kernel.h: Likewise.
* include/grub/i386/multiboot/loader.h: Likewise.
* include/grub/i386/multiboot/memory.h: Likewise.
* include/grub/i386/multiboot/serial.h: Likewise.
* include/grub/i386/multiboot/time.h: Likewise.
* include/grub/multiboot.h: Add GRUB_MACHINE_MULTIBOOT to ifdef.
* loader/multiboot.c: Likewise.
* loader/multiboot_mbi2.c: Likewise.
* util/grub-mkrescue.in: Generate multiboot rescue.
2010-05-01 Vladimir Serbinenko <phcoder@gmail.com> 2010-05-01 Vladimir Serbinenko <phcoder@gmail.com>
* kern/parser.c (grub_parser_execute): Cope with read-only config. * kern/parser.c (grub_parser_execute): Cope with read-only config.

74
conf/i386-multiboot.rmk Normal file
View file

@ -0,0 +1,74 @@
# -*- makefile -*-
COMMON_CFLAGS = -mrtd -mregparm=3
# Images.
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
pkglib_PROGRAMS += kernel.img
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
kern/i386/misc.S \
kern/i386/coreboot/init.c \
kern/i386/multiboot_mmap.c \
kern/i386/halt.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/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
kern/i386/tsc.c kern/i386/pit.c \
kern/generic/rtc_get_time_ms.c \
kern/generic/millisleep.c \
kern/env.c \
term/i386/pc/vga_text.c term/i386/vga_common.c \
symlist.c
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in
bin_SCRIPTS += grub-mkrescue
grub_mkrescue_SOURCES = util/grub-mkrescue.in
# Modules.
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
# For mmap.mod.
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
# For linux.mod.
linux_mod_SOURCES = loader/i386/linux.c
linux_mod_CFLAGS = $(COMMON_CFLAGS)
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For halt.mod.
halt_mod_SOURCES = commands/halt.c
halt_mod_CFLAGS = $(COMMON_CFLAGS)
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For aout.mod.
aout_mod_SOURCES = loader/aout.c
aout_mod_CFLAGS = $(COMMON_CFLAGS)
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For bsd.mod
pkglib_MODULES += bsd.mod
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
# For datetime.mod
datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/i386.mk
include $(srcdir)/conf/common.mk

View file

@ -102,6 +102,7 @@ case "$target_cpu"-"$platform" in
i386-efi) ;; i386-efi) ;;
x86_64-efi) ;; x86_64-efi) ;;
i386-pc) ;; i386-pc) ;;
i386-multiboot) ;;
i386-coreboot) ;; i386-coreboot) ;;
i386-linuxbios) platform=coreboot ;; i386-linuxbios) platform=coreboot ;;
i386-ieee1275) ;; i386-ieee1275) ;;
@ -136,6 +137,7 @@ esac
case "$platform" in case "$platform" in
coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;; coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
multiboot) machine_CFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;; efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;; ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;; qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;

View file

@ -0,0 +1 @@
#include <grub/i386/coreboot/boot.h>

View file

@ -0,0 +1 @@
#include <grub/i386/coreboot/console.h>

View file

@ -0,0 +1 @@
#include <grub/i386/coreboot/init.h>

View file

@ -0,0 +1 @@
#include <grub/i386/coreboot/kernel.h>

View file

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

View file

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

View file

@ -0,0 +1 @@
#include <grub/i386/coreboot/serial.h>

View file

@ -0,0 +1 @@
#include <grub/i386/coreboot/time.h>

View file

@ -49,7 +49,7 @@ void grub_multiboot_set_bootdev (void);
grub_uint32_t grub_get_multiboot_mmap_count (void); grub_uint32_t grub_get_multiboot_mmap_count (void);
grub_err_t grub_multiboot_set_video_mode (void); grub_err_t grub_multiboot_set_video_mode (void);
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
#include <grub/i386/pc/vbe.h> #include <grub/i386/pc/vbe.h>
#define GRUB_MACHINE_HAS_VGA_TEXT 1 #define GRUB_MACHINE_HAS_VGA_TEXT 1
#else #else

View file

@ -50,7 +50,7 @@
#include <grub/efi/efi.h> #include <grub/efi/efi.h>
#endif #endif
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
#define DEFAULT_VIDEO_MODE "text" #define DEFAULT_VIDEO_MODE "text"
#else #else
#define DEFAULT_VIDEO_MODE "auto" #define DEFAULT_VIDEO_MODE "auto"

View file

@ -32,7 +32,7 @@
#include <grub/env.h> #include <grub/env.h>
#include <grub/video.h> #include <grub/video.h>
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_MULTIBOOT) || defined (GRUB_MACHINE_QEMU)
#include <grub/i386/pc/vbe.h> #include <grub/i386/pc/vbe.h>
#define HAS_VGA_TEXT 1 #define HAS_VGA_TEXT 1
#else #else

View file

@ -30,7 +30,7 @@ target_cpu=@target_cpu@
native_platform=@platform@ native_platform=@platform@
pkglib_DATA="@pkglib_DATA@" pkglib_DATA="@pkglib_DATA@"
coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-coreboot multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-multiboot
pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
# Usage: usage # Usage: usage
@ -122,45 +122,45 @@ process_input_dir ()
} }
if [ "${override_dir}" = "" ] ; then if [ "${override_dir}" = "" ] ; then
if test -e "${coreboot_dir}" ; then if test -e "${multiboot_dir}" ; then
process_input_dir ${coreboot_dir} coreboot process_input_dir ${multiboot_dir} multiboot
fi fi
if test -e "${pc_dir}" ; then if test -e "${pc_dir}" ; then
process_input_dir ${pc_dir} pc process_input_dir ${pc_dir} pc
fi fi
else else
process_input_dir ${override_dir} ${native_platform} process_input_dir ${override_dir} ${native_platform}
coreboot_dir= multiboot_dir=
pc_dir= pc_dir=
case "${native_platform}" in case "${native_platform}" in
coreboot) coreboot_dir=${override_dir} ;; multiboot) multiboot_dir=${override_dir} ;;
pc) pc_dir=${override_dir} ;; pc) pc_dir=${override_dir} ;;
esac esac
fi fi
# build coreboot core.img # build multiboot core.img
if test -e "${coreboot_dir}" ; then if test -e "${multiboot_dir}" ; then
echo "Enabling coreboot support ..." echo "Enabling multiboot support ..."
memdisk_img=`mktemp "$MKTEMP_TEMPLATE"` memdisk_img=`mktemp "$MKTEMP_TEMPLATE"`
memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"` memdisk_dir=`mktemp -d "$MKTEMP_TEMPLATE"`
mkdir -p ${memdisk_dir}/boot/grub mkdir -p ${memdisk_dir}/boot/grub
# obtain date-based UUID # obtain date-based UUID
iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00) iso_uuid=$(date -u +%Y-%m-%d-%H-%M-%S-00)
modules="$(cat ${coreboot_dir}/partmap.lst) ${modules}" modules="$(cat ${multiboot_dir}/partmap.lst) ${modules}"
cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg cat << EOF > ${memdisk_dir}/boot/grub/grub.cfg
search --fs-uuid --set ${iso_uuid} search --fs-uuid --set ${iso_uuid}
set prefix=(\${root})/boot/grub/${target_cpu}-coreboot set prefix=(\${root})/boot/grub/${target_cpu}-multiboot
EOF EOF
(for i in ${modules} ; do (for i in ${modules} ; do
echo "insmod $i" echo "insmod $i"
done ; \ done ; \
echo "source /boot/grub/grub.cfg") \ echo "source /boot/grub/grub.cfg") \
> ${iso9660_dir}/boot/grub/i386-coreboot/grub.cfg > ${iso9660_dir}/boot/grub/i386-multiboot/grub.cfg
tar -C ${memdisk_dir} -cf ${memdisk_img} boot tar -C ${memdisk_dir} -cf ${memdisk_img} boot
rm -rf ${memdisk_dir} rm -rf ${memdisk_dir}
grub-mkelfimage -d ${coreboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \ grub-mkelfimage -d ${multiboot_dir}/ -m ${memdisk_img} -o ${iso9660_dir}/boot/multiboot.img \
memdisk tar search iso9660 configfile sh \ memdisk tar search iso9660 configfile sh \
ata at_keyboard ata at_keyboard
rm -f ${memdisk_img} rm -f ${memdisk_img}