enable xnu on all platforms

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-05-02 22:06:44 +02:00
parent db292d391f
commit 05f602fc51
15 changed files with 145 additions and 90 deletions

View file

@ -22,6 +22,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
kern/env.c \
term/i386/pc/vga_text.c term/i386/vga_common.c \
symlist.c
kernel_img_HEADERS += i386/pit.h
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x8200,-Bstatic
@ -71,6 +72,22 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += efiemu.mod
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
efiemu/i386/loadcore64.c efiemu/i386/pc/cfgtables.c \
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
efiemu/loadcore32.c efiemu/loadcore64.c \
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
efiemu/i386/coredetect.c
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
efiemu_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For acpi.mod.
pkglib_MODULES += acpi.mod
acpi_mod_SOURCES = commands/acpi.c commands/i386/pc/acpi.c
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
BOOTTARGET=coreboot
QEMU32=qemu-system-i386

View file

@ -64,5 +64,15 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += efiemu.mod
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
efiemu/i386/loadcore64.c efiemu/i386/nocfgtables.c \
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
efiemu/loadcore32.c efiemu/loadcore64.c \
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
efiemu/i386/coredetect.c
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
efiemu_mod_LDFLAGS = $(COMMON_LDFLAGS)
include $(srcdir)/conf/i386.mk
include $(srcdir)/conf/common.mk

View file

@ -24,6 +24,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
kern/env.c \
term/i386/pc/vga_text.c term/i386/vga_common.c \
symlist.c
kernel_img_HEADERS += i386/pit.h
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
@ -35,7 +36,7 @@ bin_SCRIPTS += grub-mkrescue
grub_mkrescue_SOURCES = util/grub-mkrescue.in
# Modules.
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
pkglib_MODULES = linux.mod halt.mod datetime.mod mmap.mod
# For mmap.mod.
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
@ -53,17 +54,21 @@ 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)
pkglib_MODULES += efiemu.mod
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
efiemu/i386/loadcore64.c efiemu/i386/pc/cfgtables.c \
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
efiemu/loadcore32.c efiemu/loadcore64.c \
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
efiemu/i386/coredetect.c
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
efiemu_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 acpi.mod.
pkglib_MODULES += acpi.mod
acpi_mod_SOURCES = commands/acpi.c commands/i386/pc/acpi.c
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For datetime.mod
datetime_mod_SOURCES = lib/cmos_datetime.c

View file

@ -92,7 +92,7 @@ grub_mkrescue_SOURCES = util/grub-mkrescue.in
pkglib_MODULES = biosdisk.mod chain.mod halt.mod vbe.mod vbetest.mod \
vbeinfo.mod vga.mod pxe.mod pxecmd.mod datetime.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
usb_keyboard.mod mmap.mod drivemap.mod
# For drivemap.mod.
drivemap_mod_SOURCES = commands/i386/pc/drivemap.c \
@ -101,17 +101,8 @@ drivemap_mod_ASFLAGS = $(COMMON_ASFLAGS)
drivemap_mod_CFLAGS = $(COMMON_CFLAGS)
drivemap_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For efiemu.mod.
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
efiemu/i386/loadcore64.c efiemu/i386/pc/cfgtables.c \
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
efiemu/loadcore32.c efiemu/loadcore64.c \
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
efiemu/i386/coredetect.c
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
efiemu_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For acpi.mod.
pkglib_MODULES += acpi.mod
acpi_mod_SOURCES = commands/acpi.c commands/i386/pc/acpi.c
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
@ -144,12 +135,15 @@ linux16_mod_SOURCES = loader/i386/pc/linux.c
linux16_mod_CFLAGS = $(COMMON_CFLAGS)
linux16_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
pkglib_MODULES += efiemu.mod
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
efiemu/i386/loadcore64.c efiemu/i386/pc/cfgtables.c \
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
efiemu/loadcore32.c efiemu/loadcore64.c \
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
efiemu/i386/coredetect.c
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
efiemu_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For halt.mod.
halt_mod_SOURCES = commands/i386/pc/halt.c
@ -231,52 +225,6 @@ hdparm_mod_SOURCES = commands/hdparm.c lib/hexdump.c
hdparm_mod_CFLAGS = $(COMMON_CFLAGS)
hdparm_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifeq ($(enable_efiemu), yes)
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
-rm -f $@
ifeq ($(TARGET_APPLE_CC), 1)
-rm -f $@.bin
$(TARGET_CC) -c -m32 -DELF32 -DAPPLE_CC -o $@.bin -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
$(OBJCONV) -felf32 -nu -nd $@.bin $@
-rm -f $@.bin
else
$(TARGET_CC) -c -m32 -DELF32 -o $@ -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
endif
efiemu64_c.o: efiemu/runtime/efiemu.c
ifeq ($(TARGET_APPLE_CC), 1)
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
else
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
endif
efiemu64_s.o: efiemu/runtime/efiemu.S
-rm -f $@
ifeq ($(TARGET_APPLE_CC), 1)
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
else
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
endif
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELF)
-rm -f $@
ifeq ($(TARGET_APPLE_CC), 1)
-rm -f $@.bin
$(TARGET_CC) -m64 -o $@.bin -Wl,-r $^ -nostdlib
$(OBJCONV) -felf64 -nu -nd $@.bin $@
-rm -f $@.bin
else
$(TARGET_CC) -m64 -o $@ -Wl,-r $^ -nostdlib
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
endif
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
pkglib_DATA += efiemu32.o efiemu64.o
endif
BOOTTARGET=cd
QEMU32=qemu-system-i386

View file

@ -31,6 +31,7 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \
kern/env.c \
term/i386/pc/vga_text.c term/i386/vga_common.c \
symlist.c
kernel_img_HEADERS += i386/pit.h
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
@ -61,6 +62,16 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += efiemu.mod
efiemu_mod_SOURCES = efiemu/main.c efiemu/i386/loadcore32.c \
efiemu/i386/loadcore64.c efiemu/i386/nocfgtables.c \
efiemu/mm.c efiemu/loadcore_common.c efiemu/symbols.c \
efiemu/loadcore32.c efiemu/loadcore64.c \
efiemu/prepare32.c efiemu/prepare64.c efiemu/pnvram.c \
efiemu/i386/coredetect.c
efiemu_mod_CFLAGS = $(COMMON_CFLAGS)
efiemu_mod_LDFLAGS = $(COMMON_LDFLAGS)
BOOTTARGET=qemu
QEMU32=qemu-system-i386

View file

@ -105,6 +105,59 @@ play_mod_SOURCES = commands/i386/pc/play.c
play_mod_CFLAGS = $(COMMON_CFLAGS)
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
ifeq ($(enable_efiemu), yes)
efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
-rm -f $@
ifeq ($(TARGET_APPLE_CC), 1)
-rm -f $@.bin
$(TARGET_CC) -c -m32 -DELF32 -DAPPLE_CC -o $@.bin -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
$(OBJCONV) -felf32 -nu -nd $@.bin $@
-rm -f $@.bin
else
$(TARGET_CC) -c -m32 -DELF32 -o $@ -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
endif
efiemu64_c.o: efiemu/runtime/efiemu.c
ifeq ($(TARGET_APPLE_CC), 1)
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
else
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
endif
efiemu64_s.o: efiemu/runtime/efiemu.S
-rm -f $@
ifeq ($(TARGET_APPLE_CC), 1)
$(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
else
$(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude
endif
efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELF)
-rm -f $@
ifeq ($(TARGET_APPLE_CC), 1)
-rm -f $@.bin
$(TARGET_CC) -m64 -o $@.bin -Wl,-r $^ -nostdlib
$(OBJCONV) -felf64 -nu -nd $@.bin $@
-rm -f $@.bin
else
$(TARGET_CC) -m64 -o $@ -Wl,-r $^ -nostdlib
if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
endif
CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o
pkglib_DATA += efiemu32.o efiemu64.o
endif
linux.init.x86_64: $(srcdir)/tests/boot/linux.init-x86_64.S
$(TARGET_CC) -o $@ $< -m64 -nostdlib -nostdinc -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\"
@ -161,6 +214,10 @@ bootcheck-linux-x86_64: linux-initramfs.x86_64 $(GRUB_PAYLOADS_DIR)/linux.x86_64
BOOTCHECKS += bootcheck-linux-i386 bootcheck-linux-x86_64 \
bootcheck-kfreebsd-i386 bootcheck-knetbsd-x86_64
ifneq ($(platform), coreboot)
BOOTCHECKS += bootcheck-kfreebsd-i386
endif
.PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \
bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64

View file

@ -87,13 +87,6 @@ efi_gop_mod_SOURCES = video/efi_gop.c
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
pkglib_MODULES += xnu.mod
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c \
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
BOOTTARGET=cd
include $(srcdir)/conf/i386.mk

View file

@ -542,6 +542,12 @@ AC_ARG_ENABLE([efiemu],
if test x"$enable_efiemu" = xno ; then
efiemu_excuse="explicitly disabled"
fi
if test x"$target_cpu" != xi386 ; then
efiemu_excuse="only available on i386"
fi
if test x"$platform" != xefi ; then
efiemu_excuse="not available on efi"
fi
if test x"$efiemu_excuse" = x ; then
AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"

View file

@ -17,7 +17,6 @@
*/
#include <grub/efiemu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/command.h>
#define cpuid(num,a,b,c,d) \

View file

@ -1,3 +1,4 @@
/* Register SMBIOS and ACPI tables. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
@ -16,9 +17,14 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_MACHINE_EFI_EMU_HEADER
#define GRUB_MACHINE_EFI_EMU_HEADER 1
#include <grub/err.h>
#include <grub/efiemu/efiemu.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/acpi.h>
grub_err_t grub_machine_efiemu_init_tables (void);
#endif
grub_err_t
grub_machine_efiemu_init_tables (void)
{
return GRUB_ERR_NONE;
}

View file

@ -19,7 +19,6 @@
#include <grub/err.h>
#include <grub/efiemu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/acpi.h>

View file

@ -22,7 +22,6 @@
#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/cpu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/elf.h>
/* ELF symbols and their values */

View file

@ -29,7 +29,6 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/efiemu/efiemu.h>
#include <grub/machine/efiemu.h>
#include <grub/command.h>
/* System table. Two version depending on mode */

View file

@ -282,4 +282,6 @@ grub_efiemu_set_virtual_address_map (grub_efi_uintn_t memory_map_size,
__attribute__ ((unused)),
grub_efi_memory_descriptor_t *virtual_map);
grub_err_t grub_machine_efiemu_init_tables (void);
#endif /* ! GRUB_EFI_EMU_HEADER */

View file

@ -123,6 +123,7 @@ static grub_uint64_t
guessfsb (void)
{
const grub_uint64_t sane_value = 100000000;
#ifndef GRUB_MACHINE_IEEE1275
grub_uint32_t manufacturer[3], max_cpuid, capabilities, msrlow;
grub_uint64_t start_tsc;
grub_uint64_t end_tsc;
@ -208,6 +209,9 @@ guessfsb (void)
return grub_divmod64 (2000 * tsc_ticks_per_ms,
((msrlow >> 7) & 0x3e) + ((msrlow >> 14) & 1), 0);
#else
return sane_value;
#endif
}
struct property_descriptor