mkinstalldirs = $(srcdir)/mkinstalldirs
+ LIBS = @LIBS@ $(LIBINTL)
+
CC = @CC@
CFLAGS = @CFLAGS@
- LDFLAGS = @LDFLAGS@
- CPPFLAGS = @CPPFLAGS@ -I. -Iinclude -I$(srcdir)/include -Wall -W \
- -DGRUB_LIBDIR=\"$(pkglibdir)\"
+ ASFLAGS = @ASFLAGS@
+ LDFLAGS = @LDFLAGS@ $(LIBS)
+ CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
+ -DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
TARGET_CC = @TARGET_CC@
TARGET_CFLAGS = @TARGET_CFLAGS@
- TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I. -Iinclude -I$(srcdir)/include \
+ TARGET_ASFLAGS = @TARGET_ASFLAGS@
+ TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
+ TARGET_APPLE_CC = @TARGET_APPLE_CC@
+ OBJCONV = @OBJCONV@
+ TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
-Wall -W
TARGET_LDFLAGS = @TARGET_LDFLAGS@
- STRIP_FLAGS=--strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment
+ TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
+ TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
+ TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
+ TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
++STRIP_FLAGS = --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment
+ EXEEXT = @EXEEXT@
OBJCOPY = @OBJCOPY@
STRIP = @STRIP@
NM = @NM@
--- /dev/null
--- /dev/null
++/* acpi.c - Display acpi tables. */
++/*
++ * GRUB -- GRand Unified Bootloader
++ * Copyright (C) 2008 Free Software Foundation, Inc.
++ *
++ * GRUB is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation, either version 3 of the License, or
++ * (at your option) any later version.
++ *
++ * GRUB is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
++ */
++#include <grub/types.h>
++#include <grub/mm.h>
++#include <grub/misc.h>
++#include <grub/normal.h>
++
++static grub_uint32_t read16 (grub_uint8_t *p)
++{
++ return grub_le_to_cpu16 (*(grub_uint16_t *)p);
++}
++
++static grub_uint32_t read32 (grub_uint8_t *p)
++{
++ return grub_le_to_cpu32 (*(grub_uint32_t *)p);
++}
++
++static grub_uint64_t read64 (grub_uint8_t *p)
++{
++ return grub_le_to_cpu64 (*(grub_uint64_t *)p);
++}
++
++static void
++disp_acpi_table (grub_uint8_t *t)
++{
++ int i;
++ grub_printf ("%c%c%c%c %4dB rev=%d OEM=", t[0], t[1], t[2], t[3],
++ read32 (t + 4), t[8]);
++ for (i = 0; i < 6; i++)
++ grub_printf ("%c", t[10 + i]);
++ grub_printf (" ");
++ for (i = 0; i < 8; i++)
++ grub_printf ("%c", t[16 + i]);
++ grub_printf (" V=%08lx ", read32 (t + 24));
++ for (i = 0; i < 4; i++)
++ grub_printf ("%c", t[28 + i]);
++ grub_printf (" %08lx\n", read32 (t + 32));
++
++}
++
++static void
++disp_acpi_apic_table (grub_uint8_t *t)
++{
++ grub_uint8_t *d;
++ grub_uint32_t len;
++ grub_uint32_t flags;
++
++ disp_acpi_table (t);
++ grub_printf ("Local APIC=%08lx Flags=%08lx\n",
++ read32 (t + 36), read32 (t + 40));
++ len = read32 (t + 4);
++ len -= 44;
++ d = t + 44;
++ while (len > 0)
++ {
++ grub_uint32_t l = d[1];
++ grub_printf (" type=%x l=%d ", d[0], l);
++
++ switch (d[0])
++ {
++ case 2:
++ grub_printf ("Int Override bus=%x src=%x GSI=%08x Flags=%04x",
++ d[2], d[3], read32 (d + 4), read16 (d + 8));
++ break;
++ case 6:
++ grub_printf ("IOSAPIC Id=%02x GSI=%08x Addr=%016llx",
++ d[2], read32 (d + 4), read64 (d + 8));
++ break;
++ case 7:
++ flags = read32 (d + 8);
++ grub_printf ("LSAPIC ProcId=%02x ID=%02x EID=%02x Flags=%x",
++ d[2], d[3], d[4], flags);
++ if (flags & 1)
++ grub_printf (" Enabled");
++ else
++ grub_printf (" Disabled");
++ if (l >= 17)
++ grub_printf ("\n"
++ " UID val=%08x, Str=%s", read32 (d + 12), d + 16);
++ break;
++ case 8:
++ grub_printf ("Platform INT flags=%04x type=%02x (",
++ read16 (d + 2), d[4]);
++ if (d[4] <= 3)
++ {
++ static const char * const platint_type[4] =
++ {"Nul", "PMI", "INIT", "CPEI"};
++ grub_printf ("%s", platint_type[d[4]]);
++ }
++ else
++ grub_printf ("??");
++ grub_printf (") ID=%02x EID=%02x\n", d[5], d[6]);
++ grub_printf (" IOSAPIC Vec=%02x GSI=%08x source flags=%08x",
++ d[7], read32 (d + 8), read32 (d + 12));
++ break;
++ default:
++ grub_printf (" ??");
++ }
++ grub_printf ("\n");
++ d += l;
++ len -= l;
++ }
++}
++
++static void
++disp_acpi_xsdt_table (grub_uint8_t *t)
++{
++ grub_uint32_t len;
++ grub_uint8_t *desc;
++
++ disp_acpi_table (t);
++ len = read32 (t + 4) - 36;
++ desc = t + 36;
++ while (len > 0)
++ {
++ t = read64 (desc);
++
++ if (t[0] == 'A' && t[1] == 'P' && t[2] == 'I' && t[3] == 'C')
++ disp_acpi_apic_table (t);
++ else
++ disp_acpi_table (t);
++ desc += 8;
++ len -= 8;
++ }
++}
++
++static void
++disp_acpi_rsdt_table (grub_uint8_t *t)
++{
++ grub_uint32_t len;
++ grub_uint8_t *desc;
++
++ disp_acpi_table (t);
++ len = read32 (t + 4) - 36;
++ desc = t + 36;
++ while (len > 0)
++ {
++ t = read32 (desc);
++
++ if (t != NULL)
++ disp_acpi_table (t);
++ desc += 4;
++ len -= 4;
++ }
++}
++
++void
++disp_acpi_rsdp_table (grub_uint8_t *rsdp)
++{
++ grub_uint8_t *t = rsdp;
++ int i;
++ grub_uint8_t *xsdt;
++
++ grub_printf ("RSDP signature:");
++ for (i = 0; i < 8; i++)
++ grub_printf ("%c", t[i]);
++ grub_printf (" chksum:%02x, OEM-ID: ", t[8]);
++ for (i = 0; i < 6; i++)
++ grub_printf ("%c", t[9 + i]);
++ grub_printf (" rev=%d\n", t[15]);
++ grub_printf ("RSDT=%08lx", read32 (t + 16));
++ if (t[15] == 2)
++ {
++ xsdt = read64 (t + 24);
++ grub_printf (" len=%d XSDT=%016llx\n", read32 (t + 20), xsdt);
++ grub_printf ("\n");
++ disp_acpi_xsdt_table (xsdt);
++ }
++ else
++ {
++ grub_printf ("\n");
++ disp_acpi_rsdt_table (read32 (t + 16));
++ }
++}
case "$target_cpu"-"$target_vendor" in
i386-apple) platform=efi ;;
i386-*) platform=pc ;;
+ x86_64-apple) platform=efi ;;
+ x86_64-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;;
+ powerpc64-*) platform=ieee1275 ;;
sparc64-*) platform=ieee1275 ;;
- ia64*) platform=efi ;;
- *) AC_MSG_ERROR([unsupported machine type]) ;;
++ ia64-*) platform=efi ;;
+ *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
esac
else
platform="$with_platform"
fi
- # Sanity check.
+ # Adjust CPU unless target was explicitly specified.
+ if test -z "$target_alias"; then
+ case "$target_cpu"-"$platform" in
+ x86_64-efi) ;;
+ x86_64-*) target_cpu=i386 ;;
+ powerpc64-ieee1275) target_cpu=powerpc ;;
+ esac
+ fi
+
+ # Check if the platform is supported, make final adjustments.
case "$target_cpu"-"$platform" in
i386-efi) ;;
+ x86_64-efi) ;;
i386-pc) ;;
- i386-linuxbios) ;;
+ i386-coreboot) ;;
+ i386-linuxbios) platform=coreboot ;;
i386-ieee1275) ;;
+ i386-qemu) ;;
powerpc-ieee1275) ;;
sparc64-ieee1275) ;;
- *) AC_MSG_ERROR([unsupported machine type]) ;;
+ ia64-efi) ;;
+ *-emu) ;;
+ *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
+ esac
+
+ case "$target_cpu" in
+ i386 | powerpc) target_m32=1 ;;
+ x86_64 | sparc64) target_m64=1 ;;
+ esac
+
+ case "$host_os" in
+ mingw32*) host_os=cygwin ;;
+ esac
+
+ # This normalizes the names, and creates a new variable ("host_kernel")
+ # while at it, since the mapping is not always 1:1 (e.g. different OSes
+ # using the same kernel type).
+ case "$host_os" in
+ gnu*) host_kernel=hurd ;;
+ linux*) host_kernel=linux ;;
+ freebsd* | kfreebsd*-gnu) host_kernel=kfreebsd ;;
+ cygwin) host_kernel=windows ;;
+ esac
+
+ case "$platform" in
+ coreboot) machine_CFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
+ efi) machine_CFLAGS="-DGRUB_MACHINE_EFI=1" ;;
+ ieee1275) machine_CFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
+ qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
+ pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
+ emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
esac
+ CFLAGS="$CFLAGS $machine_CFLAGS"
+ TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
+ TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
+
+ AC_SUBST(host_cpu)
+ AC_SUBST(host_os)
+ AC_SUBST(host_kernel)
AC_SUBST(target_cpu)
AC_SUBST(platform)
undsym = 'und-' + @name.suffix('lst')
mod_name = File.basename(@name, '.mod')
symbolic_name = mod_name.sub(/\.[^\.]*$/, '')
-
- "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym}
+
+ "
+ clean-module-#{@name}.#{@rule_count}:
+ rm -f #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{undsym}
+
+ CLEAN_MODULE_TARGETS += clean-module-#{@name}.#{@rule_count}
+
ifneq ($(#{prefix}_EXPORTS),no)
- CLEANFILES += #{defsym}
+ clean-module-#{@name}-symbol.#{@rule_count}:
+ rm -f #{defsym}
+
+ CLEAN_MODULE_TARGETS += clean-module-#{@name}-symbol.#{@rule_count}
DEFSYMFILES += #{defsym}
endif
- MOSTLYCLEANFILES += #{deps_str}
+ mostlyclean-module-#{@name}.#{@rule_count}:
+ rm -f #{deps_str}
+
+ MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
UNDSYMFILES += #{undsym}
- #{@name}: #{pre_obj} #{mod_obj}
+ ifneq ($(TARGET_APPLE_CC),1)
+ #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
-rm -f $@
- $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
+ $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
+ if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
- $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@
+ $(STRIP) $(STRIP_FLAGS) $@
+ else
+ #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
+ -rm -f $@
+ -rm -f $@.bin
+ $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj}
+ $(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@
+ -rm -f $@.bin
+ endif
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
-rm -f $@
static void \
grub_mod_fini (void)
+ #ifdef APPLE_CC
+ #define GRUB_MOD_NAME(name) \
+ static char grub_modname[] __attribute__ ((section ("_modname, _modname"), used)) = #name;
+
+ #define GRUB_MOD_DEP(name) \
+ __asm__ (".section _moddeps, _moddeps\n.asciz \"" #name "\"\n")
+ #else
#define GRUB_MOD_NAME(name) \
-__asm__ (".section .modname\n.asciz \"" #name "\"\n")
+static const char grub_module_name_##name[] \
+ __attribute__((section(".modname"), __used__)) = #name
#define GRUB_MOD_DEP(name) \
-__asm__ (".section .moddeps\n.asciz \"" #name "\"\n")
+static const char grub_module_depend_##name[] \
+ __attribute__((section(".moddeps"), __used__)) = #name
+ #endif
struct grub_dl_segment
{
#define NEXT_MEMORY_DESCRIPTOR(desc, size) \
((grub_efi_memory_descriptor_t *) ((char *) (desc) + (size)))
-#define BYTES_TO_PAGES(bytes) ((bytes) >> 12)
+#define BYTES_TO_PAGES(bytes) ((bytes + 0xfff) >> 12)
#define PAGES_TO_BYTES(pages) ((pages) << 12)
+ /* The size of a memory map obtained from the firmware. This must be
+ a multiplier of 4KB. */
+ #define MEMORY_MAP_SIZE 0x3000
+
/* Maintain the list of allocated pages. */
struct allocated_page
{
{
/* Uggh, the address 0 was allocated... This is too annoying,
so reallocate another one. */
- status = b->allocate_pages (type, GRUB_EFI_LOADER_DATA, pages, &address);
- address = 0xffffffff;
+ status = efi_call_4 (b->allocate_pages, type, GRUB_EFI_LOADER_DATA, pages, &address);
- grub_efi_free_pages (0, pages);
+ grub_efi_free_boot_pages (0, pages);
if (status != GRUB_EFI_SUCCESS)
return 0;
}
-
- return (void *)address;
+
- if (allocated_pages)
++ return (void *) address;
+}
+
+/* Free pages starting from ADDRESS. */
+void
+grub_efi_free_boot_pages (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages)
+{
+ grub_efi_boot_services_t *b;
+
+ b = grub_efi_system_table->boot_services;
+ b->free_pages (address, pages);
+}
+
+/* Allocate pages. Return the pointer to the first of allocated pages. */
+void *
+grub_efi_allocate_pages (grub_efi_physical_address_t address,
+ grub_efi_uintn_t pages)
+{
+ address = grub_efi_allocate_boot_pages (address, pages);
+
- if (address != 0 && allocated_pages)
++ if (address && allocated_pages)
{
unsigned i;
NEXT_MEMORY_DESCRIPTOR (memory_map, map_size));
grub_abort ();
#endif
-
+
/* Release the memory maps. */
grub_efi_free_pages ((grub_addr_t) memory_map,
- 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
+ 2 * BYTES_TO_PAGES (memory_map_size));
}
void