From 8874cbbded80526db0e0049b1bd0f7a9a252e06a Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Wed, 13 Jan 2010 21:04:19 +0100 Subject: [PATCH] Initial multi-i386 support for *BSD --- conf/i386-coreboot.rmk | 14 +------------- conf/i386-pc.rmk | 13 +------------ conf/i386.rmk | 13 +++++++++++++ loader/i386/bsd.c | 15 +++++++++++++++ 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk index ec67bb30f..6ed6c54ac 100644 --- a/conf/i386-coreboot.rmk +++ b/conf/i386-coreboot.rmk @@ -102,7 +102,7 @@ bin_SCRIPTS += grub-mkrescue grub_mkrescue_SOURCES = util/grub-mkrescue.in # Modules. -pkglib_MODULES = aout.mod play.mod serial.mod \ +pkglib_MODULES = play.mod serial.mod \ memdisk.mod pci.mod lspci.mod reboot.mod \ halt.mod datetime.mod date.mod datehook.mod \ lsmmap.mod mmap.mod @@ -150,18 +150,6 @@ multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2 multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS) multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS) -# 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 -bsd_mod_CFLAGS = $(COMMON_CFLAGS) -bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) -bsd_mod_ASFLAGS = $(COMMON_ASFLAGS) - # For play.mod. play_mod_SOURCES = commands/i386/pc/play.c play_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index dbec54398..0a90bd746 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -119,7 +119,7 @@ pkglib_MODULES = biosdisk.mod chain.mod \ reboot.mod halt.mod \ vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \ vga.mod memdisk.mod pci.mod lspci.mod \ - aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \ + pxe.mod pxecmd.mod datetime.mod date.mod \ datehook.mod lsmmap.mod ata_pthru.mod hdparm.mod \ usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \ efiemu.mod mmap.mod acpi.mod drivemap.mod @@ -253,17 +253,6 @@ lspci_mod_SOURCES = commands/lspci.c lspci_mod_CFLAGS = $(COMMON_CFLAGS) lspci_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 -bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c -bsd_mod_CFLAGS = $(COMMON_CFLAGS) -bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) -bsd_mod_ASFLAGS = $(COMMON_ASFLAGS) - # For usb.mod usb_mod_SOURCES = bus/usb/usb.c bus/usb/usbtrans.c bus/usb/usbhub.c usb_mod_CFLAGS = $(COMMON_CFLAGS) diff --git a/conf/i386.rmk b/conf/i386.rmk index bf6d7425b..cebe67eaf 100644 --- a/conf/i386.rmk +++ b/conf/i386.rmk @@ -33,3 +33,16 @@ pkglib_MODULES += linux.mod linux_mod_SOURCES = loader/i386/linux.c linux_mod_CFLAGS = $(COMMON_CFLAGS) linux_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For aout.mod +pkglib_MODULES += 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 +bsd_mod_CFLAGS = $(COMMON_CFLAGS) +bsd_mod_LDFLAGS = $(COMMON_LDFLAGS) +bsd_mod_ASFLAGS = $(COMMON_ASFLAGS) diff --git a/loader/i386/bsd.c b/loader/i386/bsd.c index f2ac4043d..801eb9dfd 100644 --- a/loader/i386/bsd.c +++ b/loader/i386/bsd.c @@ -37,6 +37,9 @@ #ifdef GRUB_MACHINE_PCBIOS #include #endif +#ifdef GRUB_MACHINE_EFI +#include +#endif #include #include #include @@ -553,6 +556,9 @@ grub_freebsd_boot (void) if (err) return err; + if (! grub_efi_finish_boot_services ()) + grub_fatal ("cannot exit boot services"); + pagetable = p - (4096 * 3); fill_bsd64_pagetable (pagetable, (pagetable - p0) + p_target); @@ -579,6 +585,9 @@ grub_freebsd_boot (void) if (err) return err; + if (! grub_efi_finish_boot_services ()) + grub_fatal ("cannot exit boot services"); + grub_memcpy (&stack[8], &bi, sizeof (bi)); state.eip = entry; state.esp = stack_target; @@ -684,6 +693,9 @@ grub_openbsd_boot (void) buf = (grub_uint8_t *) pa; argbuf_target_end = buf - buf0 + buf_target; + if (! grub_efi_finish_boot_services ()) + grub_fatal ("cannot exit boot services"); + state.eip = entry; state.esp = ((grub_uint8_t *) stack - buf0) + buf_target; stack[0] = entry; @@ -804,6 +816,9 @@ grub_netbsd_boot (void) if (err) return err; + if (! grub_efi_finish_boot_services ()) + grub_fatal ("cannot exit boot services"); + state.eip = entry; state.esp = stack_target; stack[0] = entry;