9664 loader: need UEFI32 support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Andrew Stormont <andyjstormont@gmail.com>
Approved by: Gordon Ross <gwr@nexenta.com>
diff --git a/usr/src/boot/sys/boot/Makefile b/usr/src/boot/sys/boot/Makefile
index 7f25b8f..fbda113 100644
--- a/usr/src/boot/sys/boot/Makefile
+++ b/usr/src/boot/sys/boot/Makefile
@@ -18,7 +18,7 @@
include $(SRC)/Makefile.master
INSTDIRS = i386 efi
-SUBDIRS = libstand ficl zfs $(INSTDIRS)
+SUBDIRS = libstand libficl zfs $(INSTDIRS)
all := TARGET = all
clean := TARGET = clean
diff --git a/usr/src/boot/sys/boot/common/bootstrap.h b/usr/src/boot/sys/boot/common/bootstrap.h
index 8ea4c6f..ed95d14 100644
--- a/usr/src/boot/sys/boot/common/bootstrap.h
+++ b/usr/src/boot/sys/boot/common/bootstrap.h
@@ -317,7 +317,7 @@
/*
* Interface to release the load address.
*/
- void (*arch_free_loadaddr)(uint64_t addr, uint64_t pages);
+ void (*arch_free_loadaddr)(vm_offset_t addr, size_t pages);
/*
* Interface to inform MD code about a loaded (ELF) segment. This
diff --git a/usr/src/boot/sys/boot/common/multiboot2.c b/usr/src/boot/sys/boot/common/multiboot2.c
index 386bcf2..c0477ec 100644
--- a/usr/src/boot/sys/boot/common/multiboot2.c
+++ b/usr/src/boot/sys/boot/common/multiboot2.c
@@ -1038,6 +1038,7 @@
}
#if defined (EFI)
+#ifdef __LP64__
{
multiboot_tag_efi64_t *tag;
tag = (multiboot_tag_efi64_t *)
@@ -1047,6 +1048,17 @@
tag->mb_size = sizeof (*tag);
tag->mb_pointer = (uint64_t)(uintptr_t)ST;
}
+#else
+ {
+ multiboot_tag_efi32_t *tag;
+ tag = (multiboot_tag_efi32_t *)
+ mb_malloc(sizeof (*tag));
+
+ tag->mb_type = MULTIBOOT_TAG_TYPE_EFI32;
+ tag->mb_size = sizeof (*tag);
+ tag->mb_pointer = (uint32_t)ST;
+ }
+#endif /* __LP64__ */
if (have_framebuffer == true) {
multiboot_tag_framebuffer_t *tag;
@@ -1218,7 +1230,7 @@
MULTIBOOT_TAG_ALIGN);
}
chunk = &relocator->rel_chunklist[i++];
- chunk->chunk_vaddr = (EFI_VIRTUAL_ADDRESS)mbi;
+ chunk->chunk_vaddr = (EFI_VIRTUAL_ADDRESS)(uintptr_t)mbi;
chunk->chunk_paddr = efi_physaddr(module, tmp, map,
map_size / desc_size, desc_size, mbi->mbi_total_size);
chunk->chunk_size = mbi->mbi_total_size;
@@ -1247,7 +1259,7 @@
free(cmdline);
#if defined (EFI)
if (mbi != NULL)
- efi_free_loadaddr((uint64_t)mbi, EFI_SIZE_TO_PAGES(size));
+ efi_free_loadaddr((vm_offset_t)mbi, EFI_SIZE_TO_PAGES(size));
#endif
return (error);
}
diff --git a/usr/src/boot/sys/boot/common/paths.h b/usr/src/boot/sys/boot/common/paths.h
index cb154b6..3934ef4 100644
--- a/usr/src/boot/sys/boot/common/paths.h
+++ b/usr/src/boot/sys/boot/common/paths.h
@@ -30,7 +30,7 @@
#define PATH_DOTCONFIG "/boot.config"
#define PATH_CONFIG "/boot/config"
#define PATH_LOADER "/boot/loader"
-#define PATH_LOADER_EFI "/boot/loader.efi"
+#define PATH_LOADER_EFI "/boot/" LOADER_EFI
#define PATH_KERNEL "/boot/kernel/kernel"
#endif /* _PATHS_H_ */
diff --git a/usr/src/boot/sys/boot/efi/Makefile.inc b/usr/src/boot/sys/boot/efi/Makefile.inc
index 2253891..d25885f 100644
--- a/usr/src/boot/sys/boot/efi/Makefile.inc
+++ b/usr/src/boot/sys/boot/efi/Makefile.inc
@@ -17,8 +17,9 @@
# Options used when building app-specific efi components
# See conf/kern.mk for the correct set of these
-CFLAGS += -m64 -fPIC -ffreestanding -Wformat -msoft-float
-CFLAGS += -mno-mmx -mno-sse -mno-avx -fshort-wchar -mno-red-zone -mno-aes
+CFLAGS += -fPIC -ffreestanding -Wformat -msoft-float
+CFLAGS += -mno-mmx -mno-3dnow -mno-sse2 -mno-sse3 -mno-sse
+CFLAGS += -mno-avx -fshort-wchar -mno-aes
CFLAGS += -std=gnu99 -Wno-pointer-sign -Wno-empty-body
#CFLAGS += -Wsystem-headers -Werror -Wall -Wno-format-y2k -W
@@ -28,4 +29,5 @@
#CFLAGS += -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls
#CFLAGS += -Wold-style-definition
+ASFLAGS += -fPIC
# include ../Makefile.inc
diff --git a/usr/src/boot/sys/boot/efi/boot1/Makefile b/usr/src/boot/sys/boot/efi/boot1/Makefile
index 29014c6..fa72aae 100644
--- a/usr/src/boot/sys/boot/efi/boot1/Makefile
+++ b/usr/src/boot/sys/boot/efi/boot1/Makefile
@@ -11,126 +11,22 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
-# Copyright 2016 RackTop Systems.
#
+.KEEP_STATE:
+
include $(SRC)/Makefile.master
-include $(SRC)/boot/Makefile.version
-CC= $(GNUC_ROOT)/bin/gcc
-LD= $(GNU_ROOT)/bin/gld
-OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
-OBJDUMP= $(GNU_ROOT)/bin/gobjdump
+SUBDIRS = $(MACH) $(MACH64)
-PROG= boot1.sym
-MACHINE=$(MACH64)
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
-# architecture-specific loader code
-SRCS= multiboot.S boot1.c self_reloc.c start.S ufs_module.c zfs_module.c \
- devopen.c
-OBJS= multiboot.o boot1.o self_reloc.o start.o ufs_module.o zfs_module.o \
- devopen.o
+all clean clobber install: $(SUBDIRS)
-ASFLAGS=-m64 -fPIC
-CFLAGS= -O2
-CPPFLAGS= -nostdinc -D_STANDALONE
-CPPFLAGS += -I.
-CPPFLAGS += -I./../include
-CPPFLAGS += -I./../include/${MACHINE}
-CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
-CPPFLAGS += -I./../../../../include
-CPPFLAGS += -I./../../../sys
-CPPFLAGS += -I./../../..
-CPPFLAGS += -I../../../../lib/libstand
-CPPFLAGS += -DUFS1_ONLY
-# CPPFLAGS += -DEFI_DEBUG
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
-CPPFLAGS += -I./../../zfs/
-CPPFLAGS += -I./../../../cddl/boot/zfs/
-
-# Always add MI sources and REGULAR efi loader bits
-CPPFLAGS += -I./../../common
-
-# For sys/skein.h
-CPPFLAGS += -I$(SRC)/uts/common
-
-include ../Makefile.inc
-
-FILES= boot1.efi
-FILEMODE= 0555
-ROOT_BOOT= $(ROOT)/boot
-ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
-
-LDSCRIPT= ./../loader/arch/${MACHINE}/ldscript.${MACHINE}
-LDFLAGS= -nostdlib --eh-frame-hdr -znocombreloc
-LDFLAGS += -shared --hash-style=both --enable-new-dtags
-LDFLAGS += -T${LDSCRIPT} -Bsymbolic
-
-all: boot1.efi
-
-install: all $(ROOTBOOTFILES)
-
-LIBEFI= ../libefi/libefi.a
-#
-# Add libstand for the runtime functions used by the compiler - for example
-# __aeabi_* (arm) or __divdi3 (i386).
-# as well as required string and memory functions for all platforms.
-#
-LIBSTAND= ../../libstand/$(MACH64)/libstand.a
-LIBZFSBOOT= ../../zfs/$(MACH64)/libzfsboot.a
-DPADD= $(LIBEFI) $(LIBZFSBOOT) $(LIBSTAND)
-LDADD= -L../libefi -lefi
-LDADD += -L../../zfs/$(MACH64) -lzfsboot
-LDADD += -L../../libstand/$(MACH64) -lstand
-
-DPADD += ${LDSCRIPT}
-
-EFI_TARGET= pei-x86-64
-
-boot1.efi: ${PROG}
- if [ `${OBJDUMP} -t ${PROG} | fgrep '*UND*' | wc -l` != 0 ]; then \
- ${OBJDUMP} -t ${PROG} | fgrep '*UND*'; \
- exit 1; \
- fi
- ${OBJCOPY} --readonly-text -j .peheader -j .text -j .sdata -j .data \
- -j .dynamic -j .dynsym -j .rel.dyn \
- -j .rela.dyn -j .reloc -j .eh_frame \
- --output-target=${EFI_TARGET} --subsystem efi-app ${PROG} $@
- $(BTXLD) -V ${BOOT_VERSION} -o $@ $@
-
-boot1.o: ./../../common/ufsread.c
-
-CLEANFILES= boot1.efi ${PROG}
-
-${PROG}: $(OBJS) $(DPADD)
- $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
-
-CLEANFILES += machine x86
-
-machine:
- $(RM) machine
- $(SYMLINK) ./../../../${MACHINE}/include machine
-
-x86:
- $(RM) x86
- $(SYMLINK) ./../../../x86/include x86
-
-$(OBJS): machine x86
-
-clean clobber:
- $(RM) $(CLEANFILES) $(OBJS)
-
-%.o: ../loader/arch/${MACHINE}/%.S
- $(COMPILE.S) $<
-
-%.o: ../loader/%.c
- $(COMPILE.c) $<
-
-%.o: ../../common/%.S
- $(COMPILE.S) $<
-
-%.o: ../../common/%.c
- $(COMPILE.c) $<
-
-$(ROOT_BOOT)/%: %
- $(INS.file)
+FRC:
diff --git a/usr/src/boot/sys/boot/efi/boot1/Makefile.com b/usr/src/boot/sys/boot/efi/boot1/Makefile.com
new file mode 100644
index 0000000..90a0ad0
--- /dev/null
+++ b/usr/src/boot/sys/boot/efi/boot1/Makefile.com
@@ -0,0 +1,131 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Toomas Soome <tsoome@me.com>
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/boot/Makefile.version
+
+CC= $(GNUC_ROOT)/bin/gcc
+LD= $(GNU_ROOT)/bin/gld
+OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
+OBJDUMP= $(GNU_ROOT)/bin/gobjdump
+
+PROG= boot1.sym
+
+# architecture-specific loader code
+SRCS= multiboot.S boot1.c self_reloc.c start.S ufs_module.c zfs_module.c \
+ devopen.c
+OBJS= multiboot.o boot1.o self_reloc.o start.o ufs_module.o zfs_module.o \
+ devopen.o
+
+CFLAGS= -O2
+CPPFLAGS= -nostdinc -D_STANDALONE
+CPPFLAGS += -I.
+CPPFLAGS += -I../../include
+CPPFLAGS += -I../../include/$(MACHINE)
+CPPFLAGS += -I../../../../../include
+CPPFLAGS += -I../../../../sys
+CPPFLAGS += -I../../../..
+CPPFLAGS += -I../../../../../lib/libstand
+CPPFLAGS += -DUFS1_ONLY
+# CPPFLAGS += -DEFI_DEBUG
+
+CPPFLAGS += -I../../../zfs/
+CPPFLAGS += -I../../../../cddl/boot/zfs/
+
+# Always add MI sources and REGULAR efi loader bits
+CPPFLAGS += -I../../../common
+
+# For sys/skein.h
+CPPFLAGS += -I$(SRC)/uts/common
+
+include ../../Makefile.inc
+
+FILES= $(EFIPROG)
+FILEMODE= 0555
+ROOT_BOOT= $(ROOT)/boot
+ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
+
+LDSCRIPT= ../../loader/arch/$(MACHINE)/ldscript.$(MACHINE)
+LDFLAGS= -nostdlib --eh-frame-hdr
+LDFLAGS += -shared --hash-style=both --enable-new-dtags
+LDFLAGS += -T$(LDSCRIPT) -Bsymbolic
+
+install: all $(ROOTBOOTFILES)
+
+LIBEFI= ../../libefi/$(MACHINE)/libefi.a
+#
+# Add libstand for the runtime functions used by the compiler - for example
+# __aeabi_* (arm) or __divdi3 (i386).
+# as well as required string and memory functions for all platforms.
+#
+LIBSTAND= ../../../libstand/$(MACHINE)/libstand.a
+LIBZFSBOOT= ../../../zfs/$(MACHINE)/libzfsboot.a
+DPADD= $(LIBEFI) $(LIBZFSBOOT) $(LIBSTAND)
+LDADD= -L../../libefi/$(MACHINE) -lefi
+LDADD += -L../../../zfs/$(MACHINE) -lzfsboot
+LDADD += -L../../../libstand/$(MACHINE) -lstand
+
+DPADD += $(LDSCRIPT)
+
+$(EFIPROG): $(PROG)
+ if [ `$(OBJDUMP) -t $(PROG) | fgrep '*UND*' | wc -l` != 0 ]; then \
+ $(OBJDUMP) -t $(PROG) | fgrep '*UND*'; \
+ exit 1; \
+ fi
+ $(OBJCOPY) --readonly-text -j .peheader -j .text -j .sdata -j .data \
+ -j .dynamic -j .dynsym -j .rel.dyn \
+ -j .rela.dyn -j .reloc -j .eh_frame \
+ --output-target=$(EFI_TARGET) --subsystem efi-app $(PROG) $@
+ $(BTXLD) -V $(BOOT_VERSION) -o $@ $@
+
+boot1.o: ../../../common/ufsread.c
+
+CLEANFILES= $(EFIPROG) $(PROG)
+
+$(PROG): $(OBJS) $(DPADD)
+ $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
+
+machine:
+ $(RM) machine
+ $(SYMLINK) ../../../../$(MACHINE)/include machine
+
+x86:
+ $(RM) x86
+ $(SYMLINK) ../../../../x86/include x86
+
+clean clobber:
+ $(RM) $(CLEANFILES) $(OBJS)
+
+%.o: ../../../common/%.S
+ $(COMPILE.S) $<
+
+%.o: ../%.c
+ $(COMPILE.c) $<
+
+#
+# using -W to silence gas here, as for 32bit build, it will generate warning
+# for start.S because hand crafted .reloc section does not have group name
+#
+%.o: ../../loader/arch/$(MACHINE)/%.S
+ $(COMPILE.S) -Wa,-W $<
+
+%.o: ../../loader/%.c
+ $(COMPILE.c) $<
+
+%.o: ../../../common/%.c
+ $(COMPILE.c) $<
+
+$(ROOT_BOOT)/%: %
+ $(INS.file)
diff --git a/usr/src/boot/sys/boot/ficl/amd64/Makefile b/usr/src/boot/sys/boot/efi/boot1/amd64/Makefile
similarity index 63%
copy from usr/src/boot/sys/boot/ficl/amd64/Makefile
copy to usr/src/boot/sys/boot/efi/boot1/amd64/Makefile
index e9187ba..24d3c17 100644
--- a/usr/src/boot/sys/boot/ficl/amd64/Makefile
+++ b/usr/src/boot/sys/boot/efi/boot1/amd64/Makefile
@@ -11,16 +11,23 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
-include $(SRC)/Makefile.master
-
MACHINE= $(MACH64)
+ASFLAGS= -m64
+EFIPROG= bootx64.efi
-all install: lib
+all: $(EFIPROG)
-include ../Makefile.inc
+include ../Makefile.com
-CFLAGS += -fPIC -m64 -mno-red-zone
+EFI_TARGET= pei-x86-64
+LDFLAGS += -znocombreloc
-FRC:
+CPPFLAGS += -DLOADER_EFI=\"loader64.efi\"
+CFLAGS += -m64 -mno-red-zone
+
+CLEANFILES += machine x86
+
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/ficl/i386/Makefile b/usr/src/boot/sys/boot/efi/boot1/i386/Makefile
similarity index 64%
copy from usr/src/boot/sys/boot/ficl/i386/Makefile
copy to usr/src/boot/sys/boot/efi/boot1/i386/Makefile
index 10e0c32..4d01edc 100644
--- a/usr/src/boot/sys/boot/ficl/i386/Makefile
+++ b/usr/src/boot/sys/boot/efi/boot1/i386/Makefile
@@ -11,17 +11,23 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
-include $(SRC)/Makefile.master
-
MACHINE= $(MACH)
+ASFLAGS= -m32
+EFIPROG= bootia32.efi
-all install: lib
+all: $(EFIPROG)
-include ../Makefile.inc
+include ../Makefile.com
-CFLAGS += -m32 -march=i386 -mpreferred-stack-boundary=2
-CFLAGS += -fno-reorder-functions
+EFI_TARGET= pei-i386
+LDFLAGS += -znocombreloc
-FRC:
+CPPFLAGS += -DLOADER_EFI=\"loader32.efi\"
+CFLAGS += -m32
+
+CLEANFILES += machine x86
+
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/efi/boot1/zfs_module.c b/usr/src/boot/sys/boot/efi/boot1/zfs_module.c
index a60e443..6617e41 100644
--- a/usr/src/boot/sys/boot/efi/boot1/zfs_module.c
+++ b/usr/src/boot/sys/boot/efi/boot1/zfs_module.c
@@ -180,8 +180,9 @@
if ((status = BS->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf))
!= EFI_SUCCESS) {
- printf("Failed to allocate load buffer %zd for pool '%s' for '%s' "
- "(%lu)\n", st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status));
+ printf("Failed to allocate load buffer %zd for pool '%s' "
+ "for '%s' (%lu)\n", (ssize_t)st.st_size, spa->spa_name,
+ filepath, EFI_ERROR_CODE(status));
return (EFI_INVALID_PARAMETER);
}
diff --git a/usr/src/boot/sys/boot/efi/include/amd64/efibind.h b/usr/src/boot/sys/boot/efi/include/amd64/efibind.h
index 6b0465b..4cd25ed 100644
--- a/usr/src/boot/sys/boot/efi/include/amd64/efibind.h
+++ b/usr/src/boot/sys/boot/efi/include/amd64/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
@@ -29,57 +28,6 @@
#include <sys/stdint.h>
-#if 0
-//
-// Basic int types of various widths
-//
-
-#if (__STDC_VERSION__ < 199901L )
-
- // No ANSI C 1999/2000 stdint.h integer width declarations
-
- #ifdef _MSC_EXTENSIONS
-
- // Use Microsoft C compiler integer width declarations
-
- typedef unsigned __int64 uint64_t;
- typedef __int64 int64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
- #ifdef UNIX_LP64
-
- // Use LP64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long uint64_t;
- typedef long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
-
- // Assume P64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long long uint64_t;
- typedef long long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #endif
- #endif
-#endif
-#endif
-
//
// Basic EFI types of various widths
//
@@ -249,19 +197,6 @@
#endif // EFI_FW_NT
#define INTERFACE_DECL(x) struct x
-#if 0
-//
-// Some compilers don't support the forward reference construct:
-// typedef struct XXXXX
-//
-// The following macro provide a workaround for such cases.
-//
-#ifdef NO_INTERFACE_DECL
-#define INTERFACE_DECL(x)
-#else
-#define INTERFACE_DECL(x) typedef struct x
-#endif
-#endif /* __FreeBSD__ */
#ifdef _MSC_EXTENSIONS
#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
diff --git a/usr/src/boot/sys/boot/efi/include/i386/efibind.h b/usr/src/boot/sys/boot/efi/include/i386/efibind.h
index fee8d3a..3bbed66 100644
--- a/usr/src/boot/sys/boot/efi/include/i386/efibind.h
+++ b/usr/src/boot/sys/boot/efi/include/i386/efibind.h
@@ -1,4 +1,3 @@
-/* $FreeBSD$ */
/*++
Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved
@@ -28,58 +27,7 @@
#pragma pack()
-#ifdef __FreeBSD__
#include <sys/stdint.h>
-#else
-//
-// Basic int types of various widths
-//
-
-#if (__STDC_VERSION__ < 199901L )
-
- // No ANSI C 1999/2000 stdint.h integer width declarations
-
- #ifdef _MSC_EXTENSIONS
-
- // Use Microsoft C compiler integer width declarations
-
- typedef unsigned __int64 uint64_t;
- typedef __int64 int64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
- #ifdef UNIX_LP64
-
- // Use LP64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long uint64_t;
- typedef long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #else
-
- // Assume P64 programming model from C_FLAGS for integer width declarations
-
- typedef unsigned long long uint64_t;
- typedef long long int64_t;
- typedef unsigned int uint32_t;
- typedef int int32_t;
- typedef unsigned short uint16_t;
- typedef short int16_t;
- typedef unsigned char uint8_t;
- typedef char int8_t;
- #endif
- #endif
-#endif
-#endif /* __FreeBSD__ */
//
// Basic EFI types of various widths
@@ -245,23 +193,8 @@
#endif // EFI_FW_NT
-#ifdef __FreeBSD__
#define INTERFACE_DECL(x) struct x
-#else
-//
-// Some compilers don't support the forward reference construct:
-// typedef struct XXXXX
-//
-// The following macro provide a workaround for such cases.
-//
-#ifdef NO_INTERFACE_DECL
-#define INTERFACE_DECL(x)
-#else
-#define INTERFACE_DECL(x) typedef struct x
-#endif
-#endif /* __FreeBSD__ */
#ifdef _MSC_EXTENSIONS
#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP
#endif
-
diff --git a/usr/src/boot/sys/boot/efi/libefi/Makefile b/usr/src/boot/sys/boot/efi/libefi/Makefile
index 768c792..482bfd2 100644
--- a/usr/src/boot/sys/boot/efi/libefi/Makefile
+++ b/usr/src/boot/sys/boot/efi/libefi/Makefile
@@ -10,86 +10,25 @@
#
#
-# Copyright 2015 Toomas Soome <tsoome@me.com>
-# Copyright 2016 RackTop Systems.
+# Copyright 2016 Toomas Soome <tsoome@me.com>
#
+.KEEP_STATE:
+
include $(SRC)/Makefile.master
-CC= $(GNUC_ROOT)/bin/gcc
+SUBDIRS = $(MACH) $(MACH64)
-LIB= efi
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
-all: lib$(LIB).a
+all clean clobber: $(SUBDIRS)
-install:
+install: all
-SRCS= delay.c \
- devicename.c \
- devpath.c \
- efi_console.c \
- efi_driver_utils.c \
- efichar.c \
- efienv.c \
- efinet.c \
- efipart.c \
- efizfs.c \
- env.c \
- errno.c \
- handles.c \
- libefi.c \
- time.c \
- wchar.c
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
-#.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
-#SRCS += time.c
-#.elif ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm"
-#SRCS+= time_event.c
-#.endif
-
-OBJS= $(SRCS:%.c=%.o)
-
-CPPFLAGS= -D_STANDALONE
-CFLAGS = -O2
-
-#.if ${MACHINE_CPUARCH} == "aarch64"
-#CFLAGS+= -msoft-float -mgeneral-regs-only
-#.endif
-#.if ${MACHINE_ARCH} == "amd64"
-CFLAGS += -fPIC
-#.endif
-
-CFLAGS += -nostdinc -I. -I../../../../include -I../../..
-CFLAGS += -I$(SRC)/common/ficl -I../../ficl
-CFLAGS += -I../include
-CFLAGS += -I../include/${MACH64}
-CFLAGS += -I../../../../lib/libstand
-CFLAGS += -I./../../zfs
-CFLAGS += -I./../../../cddl/boot/zfs
-
-# Pick up the bootstrap header for some interface items
-CFLAGS += -I../../common
-
-# Handle FreeBSD specific %b and %D printf format specifiers
-# CFLAGS+= ${FORMAT_EXTENSIONS}
-# CFLAGS += -D__printf__=__freebsd_kprintf__
-CFLAGS += -DTERM_EMU
-
-include ../Makefile.inc
-
-lib$(LIB).a: $(SRCS) $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
-
-clean: clobber
-clobber:
- $(RM) $(CLEANFILES) $(OBJS) machine x86 lib$(LIB).a
-
-machine:
- $(RM) machine
- $(SYMLINK) ../../../amd64/include machine
-
-x86:
- $(RM) x86
- $(SYMLINK) ../../../x86/include x86
-
-$(OBJS): machine x86
+FRC:
diff --git a/usr/src/boot/sys/boot/efi/libefi/Makefile.com b/usr/src/boot/sys/boot/efi/libefi/Makefile.com
new file mode 100644
index 0000000..84fffc9
--- /dev/null
+++ b/usr/src/boot/sys/boot/efi/libefi/Makefile.com
@@ -0,0 +1,73 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Toomas Soome <tsoome@me.com>
+#
+
+include $(SRC)/Makefile.master
+
+CC= $(GNUC_ROOT)/bin/gcc
+
+install:
+
+SRCS += delay.c \
+ devicename.c \
+ devpath.c \
+ efi_console.c \
+ efi_driver_utils.c \
+ efichar.c \
+ efienv.c \
+ efinet.c \
+ efipart.c \
+ efizfs.c \
+ env.c \
+ errno.c \
+ handles.c \
+ libefi.c \
+ wchar.c
+
+OBJS= $(SRCS:%.c=%.o)
+
+CPPFLAGS= -D_STANDALONE
+CFLAGS = -O2
+
+CPPFLAGS += -nostdinc -I. -I../../../../../include -I../../../..
+CPPFLAGS += -I$(SRC)/common/ficl -I../../../libficl
+CPPFLAGS += -I../../include
+CPPFLAGS += -I../../include/$(MACHINE)
+CPPFLAGS += -I../../../../../lib/libstand
+CPPFLAGS += -I../../../zfs
+CPPFLAGS += -I../../../../cddl/boot/zfs
+
+# Pick up the bootstrap header for some interface items
+CPPFLAGS += -I../../../common
+CPPFLAGS += -DTERM_EMU
+
+include ../../Makefile.inc
+
+libefi.a: $(OBJS)
+ $(AR) $(ARFLAGS) $@ $(OBJS)
+
+clean: clobber
+clobber:
+ $(RM) $(CLEANFILES) $(OBJS) libefi.a
+
+machine:
+ $(RM) machine
+ $(SYMLINK) ../../../../$(MACHINE)/include machine
+
+x86:
+ $(RM) x86
+ $(SYMLINK) ../../../../x86/include x86
+
+%.o: ../%.c
+ $(COMPILE.c) $<
diff --git a/usr/src/boot/sys/boot/ficl/amd64/Makefile b/usr/src/boot/sys/boot/efi/libefi/amd64/Makefile
similarity index 74%
copy from usr/src/boot/sys/boot/ficl/amd64/Makefile
copy to usr/src/boot/sys/boot/efi/libefi/amd64/Makefile
index e9187ba..5994a68 100644
--- a/usr/src/boot/sys/boot/ficl/amd64/Makefile
+++ b/usr/src/boot/sys/boot/efi/libefi/amd64/Makefile
@@ -11,16 +11,19 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
-include $(SRC)/Makefile.master
-
MACHINE= $(MACH64)
+ASFLAGS= -m64
-all install: lib
+all: libefi.a
-include ../Makefile.inc
+SRCS= time.c
+include ../Makefile.com
-CFLAGS += -fPIC -m64 -mno-red-zone
+CFLAGS += -m64
-FRC:
+CLEANFILES += machine x86
+
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/ficl/i386/Makefile b/usr/src/boot/sys/boot/efi/libefi/i386/Makefile
similarity index 74%
copy from usr/src/boot/sys/boot/ficl/i386/Makefile
copy to usr/src/boot/sys/boot/efi/libefi/i386/Makefile
index 10e0c32..8e96916 100644
--- a/usr/src/boot/sys/boot/ficl/i386/Makefile
+++ b/usr/src/boot/sys/boot/efi/libefi/i386/Makefile
@@ -11,17 +11,19 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
-include $(SRC)/Makefile.master
-
MACHINE= $(MACH)
+ASFLAGS= -m32
-all install: lib
+all: libefi.a
-include ../Makefile.inc
+SRCS= time.c
+include ../Makefile.com
-CFLAGS += -m32 -march=i386 -mpreferred-stack-boundary=2
-CFLAGS += -fno-reorder-functions
+CFLAGS += -m32
-FRC:
+CLEANFILES += machine x86
+
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/efi/loader/Makefile b/usr/src/boot/sys/boot/efi/loader/Makefile
index 40b1198..fa72aae 100644
--- a/usr/src/boot/sys/boot/efi/loader/Makefile
+++ b/usr/src/boot/sys/boot/efi/loader/Makefile
@@ -11,157 +11,22 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
-# Copyright 2016 RackTop Systems.
#
+.KEEP_STATE:
+
include $(SRC)/Makefile.master
-include $(SRC)/boot/Makefile.version
-CC= $(GNUC_ROOT)/bin/gcc
-LD= $(GNU_ROOT)/bin/gld
-OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
-OBJDUMP= $(GNU_ROOT)/bin/gobjdump
+SUBDIRS = $(MACH) $(MACH64)
-PROG= loader.sym
-MACHINE= $(MACH64)
+all := TARGET = all
+clean := TARGET = clean
+clobber := TARGET = clobber
+install := TARGET = install
-# architecture-specific loader code
-SRCS= autoload.c bootinfo.c conf.c copy.c efi_main.c main.c \
- self_reloc.c smbios.c acpi.c vers.c memmap.c multiboot2.c
-OBJS= autoload.o bootinfo.o conf.o copy.o efi_main.o main.o \
- self_reloc.o smbios.o acpi.o vers.o memmap.o multiboot2.o
+all clean clobber install: $(SUBDIRS)
-ASFLAGS=-m64 -fPIC
-CFLAGS= -O2
-CPPFLAGS= -nostdinc -I../../../../include -I../../..
-CPPFLAGS += -I../../../../lib/libstand
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
-include ../Makefile.inc
-
-include arch/${MACHINE}/Makefile.inc
-
-CPPFLAGS += -I.
-CPPFLAGS += -I./arch/${MACHINE}
-CPPFLAGS += -I./../include
-CPPFLAGS += -I./../include/${MACHINE}
-CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
-CPPFLAGS += -I./../../..
-CPPFLAGS += -I./../../i386/libi386
-CPPFLAGS += -I./../../zfs
-CPPFLAGS += -I./../../../cddl/boot/zfs
-CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
-
-# Export serial numbers, UUID, and asset tag from loader.
-CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
-# Use little-endian UUID format as defined in SMBIOS 2.6.
-CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
-# Use network-endian UUID format for backward compatibility.
-#CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
-
-LIBSTAND= ../../libstand/${MACHINE}/libstand.a
-
-BOOT_FORTH= yes
-CPPFLAGS += -DBOOT_FORTH -D_STANDALONE
-CPPFLAGS += -I$(SRC)/common/ficl
-CPPFLAGS += -I../../ficl
-LIBFICL= ../../ficl/${MACHINE}/libficl.a
-
-CPPFLAGS += -I../../zfs
-LIBZFSBOOT= ../../zfs/${MACHINE}/libzfsboot.a
-
-#LOADER_FDT_SUPPORT?= no
-#.if ${MK_FDT} != "no" && ${LOADER_FDT_SUPPORT} != "no"
-#CFLAGS+= -I${.CURDIR}/../../fdt
-#CFLAGS+= -I${.OBJDIR}/../../fdt
-#CFLAGS+= -DLOADER_FDT_SUPPORT
-#LIBEFI_FDT= ${.OBJDIR}/../../efi/fdt/libefi_fdt.a
-#LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
-#.endif
-
-# Always add MI sources
-include ./Makefile.common
-CPPFLAGS += -I../../common
-
-# For multiboot2.h, must be last, to avoid conflicts
-CPPFLAGS += -I$(SRC)/uts/common
-
-FILES= loader.efi
-FILEMODE= 0555
-ROOT_BOOT= $(ROOT)/boot
-ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
-
-LDSCRIPT= ./arch/${MACHINE}/ldscript.${MACHINE}
-LDFLAGS = -nostdlib --eh-frame-hdr -znocombreloc
-LDFLAGS += -shared --hash-style=both --enable-new-dtags
-LDFLAGS += -T${LDSCRIPT} -Bsymbolic
-
-CLEANFILES= vers.c loader.efi
-
-NEWVERSWHAT= "EFI loader" ${MACHINE}
-
-all: loader.efi
-
-install: all $(ROOTBOOTFILES)
-
-vers.c: ../../common/newvers.sh $(SRC)/boot/Makefile.version
- $(SH) ../../common/newvers.sh ${LOADER_VERSION} ${NEWVERSWHAT}
-
-EFI_TARGET= pei-x86-64
-
-loader.efi: loader.sym
- if [ `${OBJDUMP} -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
- ${OBJDUMP} -t loader.sym | fgrep '*UND*'; \
- exit 1; \
- fi
- ${OBJCOPY} --readonly-text -j .peheader -j .text -j .sdata -j .data \
- -j .dynamic -j .dynsym -j .rel.dyn \
- -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
- -j set_Xficl_compile_set \
- --output-target=${EFI_TARGET} --subsystem efi-app loader.sym $@
-
-LIBEFI= ../libefi/libefi.a
-
-DPADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
- ${LIBSTAND} ${LDSCRIPT}
-LDADD= ${LIBFICL} ${LIBZFSBOOT} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} \
- ${LIBSTAND}
-
-
-loader.sym: $(OBJS) $(DPADD)
- $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
-
-CLEANFILES += machine x86
-
-machine:
- $(RM) machine
- $(SYMLINK) ../../../${MACHINE}/include machine
-
-x86:
- $(RM) x86
- $(SYMLINK) ../../../x86/include x86
-
-$(OBJS): machine x86
-
-clean clobber:
- $(RM) $(CLEANFILES) $(OBJS) loader.sym loader.efi
-
-%.o: %.c
- $(COMPILE.c) $<
-
-%.o: ./arch/${MACHINE}/%.c
- $(COMPILE.c) $<
-
-%.o: ./arch/${MACHINE}/%.S
- $(COMPILE.S) $<
-
-%.o: ../../common/%.c
- $(COMPILE.c) $<
-
-%.o: ../../common/linenoise/%.c
- $(COMPILE.c) $<
-
-%.o: ../../i386/libi386/%.c
- $(COMPILE.c) $<
-
-$(ROOT_BOOT)/%: %
- $(INS.file)
+FRC:
diff --git a/usr/src/boot/sys/boot/efi/loader/Makefile.com b/usr/src/boot/sys/boot/efi/loader/Makefile.com
new file mode 100644
index 0000000..e9397e1
--- /dev/null
+++ b/usr/src/boot/sys/boot/efi/loader/Makefile.com
@@ -0,0 +1,156 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2016 Toomas Soome <tsoome@me.com>
+#
+
+include $(SRC)/Makefile.master
+include $(SRC)/boot/Makefile.version
+
+CC= $(GNUC_ROOT)/bin/gcc
+LD= $(GNU_ROOT)/bin/gld
+OBJCOPY= $(GNU_ROOT)/bin/gobjcopy
+OBJDUMP= $(GNU_ROOT)/bin/gobjdump
+
+PROG= loader.sym
+
+# architecture-specific loader code
+SRCS= autoload.c bootinfo.c conf.c copy.c efi_main.c framebuffer.c main.c \
+ self_reloc.c smbios.c acpi.c vers.c memmap.c multiboot2.c
+
+OBJS= autoload.o bootinfo.o conf.o copy.o efi_main.o framebuffer.o main.o \
+ self_reloc.o smbios.o acpi.o vers.o memmap.o multiboot2.o
+
+CFLAGS= -O2
+CPPFLAGS= -nostdinc -I../../../../../include -I../../..../
+CPPFLAGS += -I../../../../../lib/libstand
+
+include ../../Makefile.inc
+
+include ../arch/$(MACHINE)/Makefile.inc
+
+CPPFLAGS += -I. -I..
+CPPFLAGS += -I../../include
+CPPFLAGS += -I../../include/$(MACHINE)
+CPPFLAGS += -I../../../..
+CPPFLAGS += -I../../../i386/libi386
+CPPFLAGS += -I../../../zfs
+CPPFLAGS += -I../../../../cddl/boot/zfs
+CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
+CPPFLAGS += -DEFI_ZFS_BOOT
+CPPFLAGS += -DNO_PCI -DEFI -DTERM_EMU
+
+# Export serial numbers, UUID, and asset tag from loader.
+CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS
+# Use little-endian UUID format as defined in SMBIOS 2.6.
+CPPFLAGS += -DSMBIOS_LITTLE_ENDIAN_UUID
+# Use network-endian UUID format for backward compatibility.
+#CPPFLAGS += -DSMBIOS_NETWORK_ENDIAN_UUID
+
+LIBSTAND= ../../../libstand/$(MACHINE)/libstand.a
+
+BOOT_FORTH= yes
+CPPFLAGS += -DBOOT_FORTH -D_STANDALONE
+CPPFLAGS += -I$(SRC)/common/ficl
+CPPFLAGS += -I../../../libficl
+LIBFICL= ../../../libficl/$(MACHINE)/libficl.a
+
+CPPFLAGS += -I../../../zfs
+LIBZFSBOOT= ../../../zfs/$(MACHINE)/libzfsboot.a
+
+# Always add MI sources
+include ../Makefile.common
+CPPFLAGS += -I../../../common
+
+# For multiboot2.h, must be last, to avoid conflicts
+CPPFLAGS += -I$(SRC)/uts/common
+
+FILES= $(EFIPROG)
+FILEMODE= 0555
+ROOT_BOOT= $(ROOT)/boot
+ROOTBOOTFILES=$(FILES:%=$(ROOT_BOOT)/%)
+
+LDSCRIPT= ../arch/$(MACHINE)/ldscript.$(MACHINE)
+LDFLAGS = -nostdlib --eh-frame-hdr
+LDFLAGS += -shared --hash-style=both --enable-new-dtags
+LDFLAGS += -T$(LDSCRIPT) -Bsymbolic
+
+CLEANFILES= 8x16.c vers.c
+
+NEWVERSWHAT= "EFI loader" $(MACHINE)
+
+install: all $(ROOTBOOTFILES)
+
+vers.c: ../../../common/newvers.sh $(SRC)/boot/Makefile.version
+ $(SH) ../../../common/newvers.sh $(LOADER_VERSION) $(NEWVERSWHAT)
+
+$(EFIPROG): loader.sym
+ if [ `$(OBJDUMP) -t loader.sym | fgrep '*UND*' | wc -l` != 0 ]; then \
+ $(OBJDUMP) -t loader.sym | fgrep '*UND*'; \
+ exit 1; \
+ fi
+ $(OBJCOPY) --readonly-text -j .peheader -j .text -j .sdata -j .data \
+ -j .dynamic -j .dynsym -j .rel.dyn \
+ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
+ -j set_Xficl_compile_set \
+ --output-target=$(EFI_TARGET) --subsystem efi-app loader.sym $@
+
+LIBEFI= ../../libefi/$(MACHINE)/libefi.a
+
+DPADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND) $(LDSCRIPT)
+LDADD= $(LIBFICL) $(LIBZFSBOOT) $(LIBEFI) $(LIBSTAND)
+
+
+loader.sym: $(OBJS) $(DPADD)
+ $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDADD)
+
+machine:
+ $(RM) machine
+ $(SYMLINK) ../../../../$(MACHINE)/include machine
+
+x86:
+ $(RM) x86
+ $(SYMLINK) ../../../../x86/include x86
+
+clean clobber:
+ $(RM) $(CLEANFILES) $(OBJS) loader.sym
+
+%.o: ../%.c
+ $(COMPILE.c) $<
+
+%.o: ../arch/$(MACHINE)/%.c
+ $(COMPILE.c) $<
+
+#
+# using -W to silence gas here, as for 32bit build, it will generate warning
+# for start.S because hand crafted .reloc section does not have group name
+#
+%.o: ../arch/$(MACHINE)/%.S
+ $(COMPILE.S) -Wa,-W $<
+
+%.o: ../../../common/%.c
+ $(COMPILE.c) $<
+
+%.o: ../../../common/linenoise/%.c
+ $(COMPILE.c) $<
+
+%.o: ../../../i386/libi386/%.c
+ $(COMPILE.c) $<
+
+%.o: $(SRC)/common/list/%.c
+ $(COMPILE.c) -DNDEBUG $<
+
+%.o: $(SRC)/uts/common/io/font/%.c
+ $(COMPILE.c) $<
+
+$(ROOT_BOOT)/%: %
+ $(INS.file)
diff --git a/usr/src/boot/sys/boot/ficl/amd64/Makefile b/usr/src/boot/sys/boot/efi/loader/amd64/Makefile
similarity index 62%
copy from usr/src/boot/sys/boot/ficl/amd64/Makefile
copy to usr/src/boot/sys/boot/efi/loader/amd64/Makefile
index e9187ba..540894d 100644
--- a/usr/src/boot/sys/boot/ficl/amd64/Makefile
+++ b/usr/src/boot/sys/boot/efi/loader/amd64/Makefile
@@ -11,16 +11,23 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
-include $(SRC)/Makefile.master
-
MACHINE= $(MACH64)
+ASFLAGS= -m64
+EFIPROG= loader64.efi
-all install: lib
+all: $(EFIPROG)
-include ../Makefile.inc
+include ../Makefile.com
-CFLAGS += -fPIC -m64 -mno-red-zone
+EFI_TARGET= pei-x86-64
+LDFLAGS += -znocombreloc
-FRC:
+efi_main.o := CPPFLAGS += -DLOADER_EFI=L\"loader64.efi\"
+CFLAGS += -m64
+
+CLEANFILES += machine x86 $(EFIPROG)
+
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/amd64/Makefile.inc b/usr/src/boot/sys/boot/efi/loader/arch/amd64/Makefile.inc
index 47dd322..be90666 100644
--- a/usr/src/boot/sys/boot/efi/loader/arch/amd64/Makefile.inc
+++ b/usr/src/boot/sys/boot/efi/loader/arch/amd64/Makefile.inc
@@ -1,13 +1,11 @@
SRCS += multiboot_tramp.S \
start.S \
- framebuffer.c \
trap.c \
exc.S
OBJS += multiboot_tramp.o \
start.o \
- framebuffer.o \
trap.o \
exc.o
@@ -18,6 +16,3 @@
OBJS += nullconsole.o \
spinconsole.o \
comconsole.o
-
-CFLAGS += -fPIC
-LDFLAGS += -znocombreloc
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/amd64/multiboot_tramp.S b/usr/src/boot/sys/boot/efi/loader/arch/amd64/multiboot_tramp.S
index 061c638..e8ba513 100644
--- a/usr/src/boot/sys/boot/efi/loader/arch/amd64/multiboot_tramp.S
+++ b/usr/src/boot/sys/boot/efi/loader/arch/amd64/multiboot_tramp.S
@@ -18,16 +18,15 @@
.file "multiboot_tramp.s"
/*
- * The current dboot in illumos kernel is running in 32bit mode
- * and expecting following 32-bit multiboot execution environment:
+ * dboot expects a 32-bit multiboot environment and to execute in 32-bit mode.
*
* EAX: MB magic
* EBX: 32-bit physical address of MBI
* CS: 32-bit read/execute code segment with offset 0 and limit 0xFFFFFFFF
- * DS: 32-bit read/write code segment with offset 0 and limit 0xFFFFFFFF
- * ES: 32-bit read/write code segment with offset 0 and limit 0xFFFFFFFF
- * FS: 32-bit read/write code segment with offset 0 and limit 0xFFFFFFFF
- * GS: 32-bit read/write code segment with offset 0 and limit 0xFFFFFFFF
+ * DS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * ES: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * FS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * GS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
* SS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
* A20 enabled
* CR0: PG cleared, PE set
@@ -45,7 +44,7 @@
/*
* void multiboot_tramp(uint32_t magic, struct relocator *relocator,
- * uint64_t entry)
+ * vm_offset_t entry)
*/
multiboot_tramp:
cli
@@ -103,6 +102,15 @@
/* GDT record */
.p2align 4
gdt:
+/*
+ * This will create access for 4GB flat memory with
+ * base = 0x00000000, segment limit = 0xffffffff
+ * page granulariy 4k
+ * 32-bit protected mode
+ * ring 0
+ * code segment is executable RW
+ * data segment is not-executable RW
+ */
.word 0x0, 0x0 /* NULL entry */
.byte 0x0, 0x0, 0x0, 0x0
.word 0xffff, 0x0 /* code segment */
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/i386/Makefile.inc b/usr/src/boot/sys/boot/efi/loader/arch/i386/Makefile.inc
index 4e08c53..7adb6b2 100644
--- a/usr/src/boot/sys/boot/efi/loader/arch/i386/Makefile.inc
+++ b/usr/src/boot/sys/boot/efi/loader/arch/i386/Makefile.inc
@@ -1,13 +1,14 @@
-# $FreeBSD$
-SRCS+= start.S \
- efimd.c \
- elf32_freebsd.c \
- exec.c
+SRCS += multiboot_tramp.S \
+ start.S
-.PATH: ${.CURDIR}/../../i386/libi386
-SRCS+= nullconsole.c \
+OBJS += multiboot_tramp.o \
+ start.o
+
+SRCS += nullconsole.c \
+ spinconsole.c \
comconsole.c
-CFLAGS+= -fPIC
-LDFLAGS+= -Wl,-znocombreloc
+OBJS += nullconsole.o \
+ spinconsole.o \
+ comconsole.o
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/i386/ldscript.i386 b/usr/src/boot/sys/boot/efi/loader/arch/i386/ldscript.i386
index e17212a..4920a31 100644
--- a/usr/src/boot/sys/boot/efi/loader/arch/i386/ldscript.i386
+++ b/usr/src/boot/sys/boot/efi/loader/arch/i386/ldscript.i386
@@ -1,5 +1,4 @@
-/* $FreeBSD$ */
-OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd")
+OUTPUT_FORMAT("elf32-i386-sol2", "elf32-i386-sol2", "elf32-i386-sol2")
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/i386/multiboot_tramp.S b/usr/src/boot/sys/boot/efi/loader/arch/i386/multiboot_tramp.S
new file mode 100644
index 0000000..60be6a3
--- /dev/null
+++ b/usr/src/boot/sys/boot/efi/loader/arch/i386/multiboot_tramp.S
@@ -0,0 +1,150 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2016 Toomas Soome <tsoome@me.com>
+ */
+
+#include <x86/specialreg.h>
+
+ .file "multiboot_tramp.s"
+
+/*
+ * dboot expects a 32-bit multiboot environment and to execute in 32-bit mode.
+ *
+ * EAX: MB magic
+ * EBX: 32-bit physical address of MBI
+ * CS: 32-bit read/execute code segment with offset 0 and limit 0xFFFFFFFF
+ * DS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * ES: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * FS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * GS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * SS: 32-bit read/write data segment with offset 0 and limit 0xFFFFFFFF
+ * A20 enabled
+ * CR0: PG cleared, PE set
+ * EFLAGS: VM cleared, IF cleared
+ * interrupts disabled
+ */
+
+ .set SEL_SCODE,0x8
+ .set SEL_SDATA,0x10
+
+ .text
+ .p2align 4
+ .globl multiboot_tramp
+ .type multiboot_tramp, STT_FUNC
+
+/*
+ * Note as we are running in 32-bit mode, all pointers are 32-bit.
+ * void multiboot_tramp(uint32_t magic, struct relocator *relocator,
+ * vm_offset_t entry)
+ */
+multiboot_tramp:
+ cli
+ pushl %ebp /* keep familiar stack frame */
+ movl %esp, %ebp /* current SP */
+ movl 0xc(%ebp),%eax /* relocator */
+ movl (%eax), %eax /* new SP */
+ movl %eax, %esp
+
+ /* now copy arguments to new stack */
+ movl 0x10(%ebp),%eax /* entry */
+ pushl %eax
+ movl 0xc(%ebp),%eax /* relocator */
+ pushl %eax
+ movl 0x8(%ebp),%eax /* magic */
+ pushl %eax
+ xorl %eax,%eax
+ pushl %eax /* fake IP, just to keep stack frame */
+ pushl %ebp
+ movl %esp, %ebp
+ subl $0x30, %esp /* local mbi, gdt and gdt desc */
+
+ movl 0xc(%ebp), %eax /* relocator */
+ pushl %eax
+ movl 0x4(%eax), %eax /* relocator->copy */
+ call *%eax
+ addl $0x4, %esp
+ movl %eax, -0x4(%ebp) /* save MBI */
+
+ /* set up GDT descriptor */
+ lea -0x1c(%ebp), %eax /* address of GDT */
+ movw $0x17, -0x22(%ebp) /* limit */
+ movl %eax, -0x20(%ebp) /* base */
+
+/*
+ * set up following GDT:
+ * .word 0x0, 0x0 NULL entry
+ * .byte 0x0, 0x0, 0x0, 0x0
+ * .word 0xffff, 0x0 code segment
+ * .byte 0x0, 0x9a, 0xcf, 0x0
+ * .word 0xffff, 0x0 data segment
+ * .byte 0x0, 0x92, 0xcf, 0x0
+ *
+ * This will create access for 4GB flat memory with
+ * base = 0x00000000, segment limit = 0xffffffff
+ * page granulariy 4k
+ * 32-bit protected mode
+ * ring 0
+ * code segment is executable RW
+ * data segment is not-executable RW
+ */
+ movw $0x0, -0x1c(%ebp)
+ movw $0x0, -0x1a(%ebp)
+ movb $0x0, -0x18(%ebp)
+ movb $0x0, -0x17(%ebp)
+ movb $0x0, -0x16(%ebp)
+ movb $0x0, -0x15(%ebp)
+
+ movw $0xffff, -0x14(%ebp)
+ movw $0x0, -0x12(%ebp)
+ movb $0x0, -0x10(%ebp)
+ movb $0x9a, -0xf(%ebp)
+ movb $0xcf, -0xe(%ebp)
+ movb $0x0, -0xd(%ebp)
+
+ movw $0xffff, -0xc(%ebp)
+ movw $0x0, -0xa(%ebp)
+ movb $0x0, -0x8(%ebp)
+ movb $0x92, -0x7(%ebp)
+ movb $0xcf, -0x6(%ebp)
+ movb $0x0, -0x5(%ebp)
+
+ lea -0x22(%ebp), %eax /* address of GDT */
+ lgdt (%eax)
+
+ movl 0x8(%ebp), %edx /* magic */
+ movl -0x4(%ebp), %ebx /* MBI */
+ movl 0x10(%ebp), %esi /* entry */
+
+ movl $SEL_SDATA, %eax
+ movw %ax, %ss
+ movw %ax, %ds
+ movw %ax, %es
+ movw %ax, %fs
+ movw %ax, %gs
+
+ /*
+ * We most likely don't need to push SEL_SDATA and esp
+ * because we do not expect to perform a privilege transition.
+ * However, it doesn't hurt us to push them as dboot will set
+ * up its own stack.
+ */
+ movl %esp, %eax
+ pushl $SEL_SDATA
+ pushl %eax
+ pushf
+ pushl $SEL_SCODE
+ pushl %esi
+ movl %edx, %eax
+ iretl
+
+multiboot_tramp_end:
diff --git a/usr/src/boot/sys/boot/efi/loader/bootinfo.c b/usr/src/boot/sys/boot/efi/loader/bootinfo.c
index 6c90871..81d6480 100644
--- a/usr/src/boot/sys/boot/efi/loader/bootinfo.c
+++ b/usr/src/boot/sys/boot/efi/loader/bootinfo.c
@@ -300,7 +300,7 @@
* memory map on a 16-byte boundary (the bootinfo block is page
* aligned).
*/
- efihdr = (struct efi_map_header *)addr;
+ efihdr = (struct efi_map_header *)(uintptr_t)addr;
mm = (void *)((uint8_t *)efihdr + efisz);
sz = (EFI_PAGE_SIZE * pages) - efisz;
diff --git a/usr/src/boot/sys/boot/efi/loader/copy.c b/usr/src/boot/sys/boot/efi/loader/copy.c
index 9658a65..9392350 100644
--- a/usr/src/boot/sys/boot/efi/loader/copy.c
+++ b/usr/src/boot/sys/boot/efi/loader/copy.c
@@ -153,8 +153,8 @@
* address, we can not make any assumptions about actual location or
* about the order of the allocated blocks.
*/
-uint64_t
-efi_loadaddr(u_int type, void *data, uint64_t addr)
+vm_offset_t
+efi_loadaddr(u_int type, void *data, vm_offset_t addr)
{
EFI_PHYSICAL_ADDRESS paddr;
struct stat st;
@@ -192,7 +192,7 @@
}
void
-efi_free_loadaddr(uint64_t addr, uint64_t pages)
+efi_free_loadaddr(vm_offset_t addr, size_t pages)
{
(void) BS->FreePages(addr, pages);
}
@@ -249,7 +249,7 @@
/* MBI is the last chunk in the list. */
head = &relocator->rel_chunk_head;
chunk = STAILQ_LAST(head, chunk, chunk_next);
- mbi = (multiboot2_info_header_t *)chunk->chunk_paddr;
+ mbi = (multiboot2_info_header_t *)(uintptr_t)chunk->chunk_paddr;
/*
* If chunk paddr == vaddr, the chunk is in place.
@@ -304,8 +304,8 @@
}
/* If there are no conflicts, move to place and restart. */
if (c == NULL) {
- move((void *)chunk->chunk_paddr,
- (void *)chunk->chunk_vaddr,
+ move((void *)(uintptr_t)chunk->chunk_paddr,
+ (void *)(uintptr_t)chunk->chunk_vaddr,
chunk->chunk_size);
chunk->chunk_vaddr = chunk->chunk_paddr;
chunk = NULL;
diff --git a/usr/src/boot/sys/boot/efi/loader/efi_main.c b/usr/src/boot/sys/boot/efi/loader/efi_main.c
index de6e137..86917da 100644
--- a/usr/src/boot/sys/boot/efi/loader/efi_main.c
+++ b/usr/src/boot/sys/boot/efi/loader/efi_main.c
@@ -197,7 +197,7 @@
argv = malloc((argc + 1) * sizeof(CHAR16*));
argc = 0;
if (addprog)
- argv[argc++] = (CHAR16 *)L"loader.efi";
+ argv[argc++] = (CHAR16 *)LOADER_EFI;
argp = args;
while (argp != NULL && *argp != 0) {
argp = arg_skipsep(argp);
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/amd64/framebuffer.c b/usr/src/boot/sys/boot/efi/loader/framebuffer.c
similarity index 99%
rename from usr/src/boot/sys/boot/efi/loader/arch/amd64/framebuffer.c
rename to usr/src/boot/sys/boot/efi/loader/framebuffer.c
index f31704b..77d01df 100644
--- a/usr/src/boot/sys/boot/efi/loader/arch/amd64/framebuffer.c
+++ b/usr/src/boot/sys/boot/efi/loader/framebuffer.c
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 2013 The FreeBSD Foundation
* All rights reserved.
*
@@ -27,11 +27,10 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+#include <stand.h>
#include <bootstrap.h>
#include <sys/endian.h>
-#include <stand.h>
#include <efi.h>
#include <efilib.h>
diff --git a/usr/src/boot/sys/boot/efi/loader/arch/amd64/framebuffer.h b/usr/src/boot/sys/boot/efi/loader/framebuffer.h
similarity index 100%
rename from usr/src/boot/sys/boot/efi/loader/arch/amd64/framebuffer.h
rename to usr/src/boot/sys/boot/efi/loader/framebuffer.h
diff --git a/usr/src/boot/sys/boot/ficl/i386/Makefile b/usr/src/boot/sys/boot/efi/loader/i386/Makefile
similarity index 62%
copy from usr/src/boot/sys/boot/ficl/i386/Makefile
copy to usr/src/boot/sys/boot/efi/loader/i386/Makefile
index 10e0c32..c4a451f 100644
--- a/usr/src/boot/sys/boot/ficl/i386/Makefile
+++ b/usr/src/boot/sys/boot/efi/loader/i386/Makefile
@@ -11,17 +11,23 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
-include $(SRC)/Makefile.master
-
MACHINE= $(MACH)
+ASFLAGS= -m32
+EFIPROG= loader32.efi
-all install: lib
+all: $(EFIPROG)
-include ../Makefile.inc
+include ../Makefile.com
-CFLAGS += -m32 -march=i386 -mpreferred-stack-boundary=2
-CFLAGS += -fno-reorder-functions
+EFI_TARGET= pei-i386
+LDFLAGS += -znocombreloc
-FRC:
+efi_main.o := CPPFLAGS += -DLOADER_EFI=L\"loader32.efi\"
+CFLAGS += -m32
+
+CLEANFILES += machine x86 $(EFIPROG)
+
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/efi/loader/loader_efi.h b/usr/src/boot/sys/boot/efi/loader/loader_efi.h
index 7339515..cba9bf7 100644
--- a/usr/src/boot/sys/boot/efi/loader/loader_efi.h
+++ b/usr/src/boot/sys/boot/efi/loader/loader_efi.h
@@ -39,16 +39,16 @@
struct chunk {
EFI_VIRTUAL_ADDRESS chunk_vaddr;
EFI_PHYSICAL_ADDRESS chunk_paddr;
- UINT64 chunk_size;
+ size_t chunk_size;
STAILQ_ENTRY(chunk) chunk_next;
};
STAILQ_HEAD(chunk_head, chunk);
struct relocator {
- UINT64 rel_stack;
- UINT64 rel_copy;
- UINT64 rel_memmove;
+ vm_offset_t rel_stack;
+ vm_offset_t rel_copy;
+ vm_offset_t rel_memmove;
struct chunk_head rel_chunk_head;
struct chunk rel_chunklist[];
};
@@ -58,8 +58,8 @@
ssize_t efi_copyin(const void *, vm_offset_t, const size_t);
ssize_t efi_copyout(const vm_offset_t, void *, const size_t);
ssize_t efi_readin(const int, vm_offset_t, const size_t);
-uint64_t efi_loadaddr(u_int, void *, uint64_t);
-void efi_free_loadaddr(uint64_t, uint64_t);
+vm_offset_t efi_loadaddr(u_int, void *, vm_offset_t);
+void efi_free_loadaddr(vm_offset_t, size_t);
void * efi_translate(vm_offset_t);
vm_offset_t efi_physaddr(multiboot_tag_module_t *, vm_offset_t,
EFI_MEMORY_DESCRIPTOR *, size_t, UINTN, size_t);
diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c
index fe4281e..ef917ac 100644
--- a/usr/src/boot/sys/boot/efi/loader/main.c
+++ b/usr/src/boot/sys/boot/efi/loader/main.c
@@ -535,11 +535,9 @@
for (i = 0, p = map; i < ndesc;
i++, p = NextMemoryDescriptor(p, dsz)) {
- snprintf(line, 80, "%23s %012lx %012lx %08lx ",
- efi_memory_type(p->Type),
- p->PhysicalStart,
- p->VirtualStart,
- p->NumberOfPages);
+ snprintf(line, 80, "%23s %012jx %012jx %08jx ",
+ efi_memory_type(p->Type), p->PhysicalStart,
+ p->VirtualStart, p->NumberOfPages);
rv = pager_output(line);
if (rv)
break;
diff --git a/usr/src/boot/sys/boot/i386/Makefile b/usr/src/boot/sys/boot/i386/Makefile
index 55e7d5c..d2cd7d3 100644
--- a/usr/src/boot/sys/boot/i386/Makefile
+++ b/usr/src/boot/sys/boot/i386/Makefile
@@ -10,7 +10,7 @@
#
#
-# Copyright 2015 Toomas Soome <tsoome@me.com>
+# Copyright 2017 Toomas Soome <tsoome@me.com>
#
include $(SRC)/Makefile.master
@@ -33,7 +33,9 @@
install: all .WAIT $(INSTDIRS)
+loader: libi386
pxeldr: loader
+cdboot gptzfsboot loader pxeldr: btx
FRC:
diff --git a/usr/src/boot/sys/boot/i386/Makefile.inc b/usr/src/boot/sys/boot/i386/Makefile.inc
index 5398b4b..5ef179f 100644
--- a/usr/src/boot/sys/boot/i386/Makefile.inc
+++ b/usr/src/boot/sys/boot/i386/Makefile.inc
@@ -19,13 +19,11 @@
ROOTBOOTPROG=$(PROG:%=$(ROOT_BOOT)/%)
LOADER_ADDRESS=0x200000
-CFLAGS += -march=i386 -ffreestanding
-CFLAGS += -mpreferred-stack-boundary=2
+CFLAGS += -m32 -ffreestanding
CFLAGS += -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
-CFLAGS += -std=gnu99 -fno-reorder-functions
+CFLAGS += -std=gnu99
LDFLAGS += -nostdlib
-CFLAGS += -m32
ACFLAGS += -m32
AFLAGS += --32
diff --git a/usr/src/boot/sys/boot/i386/btx/btx/Makefile b/usr/src/boot/sys/boot/i386/btx/btx/Makefile
index 3642e6e..8fe11ab 100644
--- a/usr/src/boot/sys/boot/i386/btx/btx/Makefile
+++ b/usr/src/boot/sys/boot/i386/btx/btx/Makefile
@@ -48,7 +48,7 @@
LDFLAGS=-e start -Ttext ${ORG} -N -S --oformat binary
-all: $(PROG)
+all install: $(PROG)
$(PROG): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
diff --git a/usr/src/boot/sys/boot/i386/btx/btxldr/Makefile b/usr/src/boot/sys/boot/i386/btx/btxldr/Makefile
index 4792ee0..151c95f 100644
--- a/usr/src/boot/sys/boot/i386/btx/btxldr/Makefile
+++ b/usr/src/boot/sys/boot/i386/btx/btxldr/Makefile
@@ -32,14 +32,14 @@
LDFLAGS=-e start -Ttext ${LOADER_ADDRESS} -N -S --oformat binary
+all install: $(PROG)
+
$(PROG): $(OBJS)
$(LD) $(LDFLAGS) -o $@ $(OBJS)
.S.o:
$(COMPILE.S) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
-all: $(PROG)
-
clobber: clean
clean:
diff --git a/usr/src/boot/sys/boot/i386/btx/lib/Makefile b/usr/src/boot/sys/boot/i386/btx/lib/Makefile
index 68dd201..bf89dbc 100644
--- a/usr/src/boot/sys/boot/i386/btx/lib/Makefile
+++ b/usr/src/boot/sys/boot/i386/btx/lib/Makefile
@@ -31,7 +31,7 @@
LDFLAGS=-Wl,-r -nostdlib
-all: $(PROG)
+all install: $(PROG)
$(PROG): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS)
diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile b/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile
index 97eb446..892a9d7 100644
--- a/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile
+++ b/usr/src/boot/sys/boot/i386/gptzfsboot/Makefile
@@ -63,8 +63,8 @@
LD_FLAGS=-static -N --gc-sections
CCASFLAGS=-Wa,--divide
-LIBSTAND= ../../libstand/i386/libstand.a
-LIBZFSBOOT= ../../zfs/i386/libzfsboot.a
+LIBSTAND= ../../libstand/$(MACH)/libstand.a
+LIBZFSBOOT= ../../zfs/$(MACH)/libzfsboot.a
include ../Makefile.inc
diff --git a/usr/src/boot/sys/boot/i386/libi386/Makefile b/usr/src/boot/sys/boot/i386/libi386/Makefile
index 8b0d0bf..951a2dd 100644
--- a/usr/src/boot/sys/boot/i386/libi386/Makefile
+++ b/usr/src/boot/sys/boot/i386/libi386/Makefile
@@ -19,7 +19,7 @@
CFLAGS= -O2 -I../../../../include -I../../..
CPPFLAGS= -D_STANDALONE -DLOADER_ZFS_SUPPORT
-all: libi386.a
+all install: libi386.a
clean: clobber
clobber:
@@ -74,7 +74,7 @@
# XXX: make alloca() useable
CFLAGS += -Dalloca=__builtin_alloca
-CFLAGS += -I$(SRC)/common/ficl -I../../ficl \
+CFLAGS += -I$(SRC)/common/ficl -I../../libficl \
-I../../common -I../common \
-I../btx/lib \
-I$(SRC)/uts/intel/sys/acpi \
diff --git a/usr/src/boot/sys/boot/i386/loader/Makefile b/usr/src/boot/sys/boot/i386/loader/Makefile
index e38284d..ec9c612 100644
--- a/usr/src/boot/sys/boot/i386/loader/Makefile
+++ b/usr/src/boot/sys/boot/i386/loader/Makefile
@@ -17,7 +17,7 @@
include $(SRC)/Makefile.master
include $(SRC)/boot/Makefile.version
-CFLAGS= -O2
+CFLAGS= -O2 -fno-reorder-functions
CPPFLAGS= -D_STANDALONE -nostdinc -I../../../../include -I../../..
CPPFLAGS += -I$(SRC)/uts/intel/sys/acpi
LOADER= loader
@@ -26,7 +26,7 @@
# Set by loader Makefile
CPPFLAGS += -DLOADER_ZFS_SUPPORT -I../../zfs
CPPFLAGS += -I../libi386
-LIBZFSBOOT= ../../zfs/i386/libzfsboot.a
+LIBZFSBOOT= ../../zfs/$(MACH)/libzfsboot.a
LIBI386= ../libi386/libi386.a
# loader.help build needs better awk
@@ -57,8 +57,8 @@
CPPFLAGS += -DLOADER_GZIP_SUPPORT
# Enable BootForth
-CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../ficl
-LIBFICL= ../../ficl/i386/libficl.a
+CPPFLAGS += -DBOOT_FORTH -I$(SRC)/common/ficl -I../../libficl
+LIBFICL= ../../libficl/$(MACH)/libficl.a
# Always add MI sources
SRCS += boot.c commands.c console.c devopen.c interp.c
@@ -94,7 +94,7 @@
# i386 standalone support library
CPPFLAGS += -I.. -I../../../../lib/libstand
-LIBSTAND= ../../libstand/i386/libstand.a
+LIBSTAND= ../../libstand/$(MACH)/libstand.a
# BTX components
CPPFLAGS += -I../btx/lib
diff --git a/usr/src/boot/sys/boot/ficl/Makefile b/usr/src/boot/sys/boot/libficl/Makefile
similarity index 100%
rename from usr/src/boot/sys/boot/ficl/Makefile
rename to usr/src/boot/sys/boot/libficl/Makefile
diff --git a/usr/src/boot/sys/boot/ficl/Makefile.inc b/usr/src/boot/sys/boot/libficl/Makefile.com
similarity index 83%
rename from usr/src/boot/sys/boot/ficl/Makefile.inc
rename to usr/src/boot/sys/boot/libficl/Makefile.com
index 0213ace..3226faf 100644
--- a/usr/src/boot/sys/boot/ficl/Makefile.inc
+++ b/usr/src/boot/sys/boot/libficl/Makefile.com
@@ -11,23 +11,18 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
-# Copyright 2016 RackTop Systems.
#
CC= $(GNUC_ROOT)/bin/gcc
FICLDIR= $(SRC)/common/ficl
-all: lib
-
-CPPFLAGS= -D_STANDALONE -I. -I.. -I../../../../include
+CPPFLAGS= -nostdinc -D_STANDALONE -I. -I.. -I../../../../include
CPPFLAGS += -I../../../../lib/libstand
CPPFLAGS += -I../../.. -I$(FICLDIR) -I../../common
-CFLAGS= -O2 -Wall -nostdinc
-CFLAGS += -ffreestanding
-CFLAGS += -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
-CFLAGS += -std=gnu99
+CFLAGS= -O2 -fPIC -Wall -ffreestanding -mno-mmx -mno-3dnow -mno-sse
+CFLAGS += -mno-sse2 -mno-sse3 -msoft-float -std=gnu99
OBJECTS= dictionary.o system.o fileaccess.o float.o double.o prefix.o search.o
OBJECTS += softcore.o stack.o tools.o vm.o primitives.o unix.o utility.o
@@ -52,8 +47,6 @@
$(RM) x86
$(SYMLINK) ../../../x86/include x86
-$(OBJECTS): machine x86
-
%.o: ../softcore/%.c $(HEADERS)
$(COMPILE.c) $<
diff --git a/usr/src/boot/sys/boot/ficl/amd64/Makefile b/usr/src/boot/sys/boot/libficl/amd64/Makefile
similarity index 82%
rename from usr/src/boot/sys/boot/ficl/amd64/Makefile
rename to usr/src/boot/sys/boot/libficl/amd64/Makefile
index e9187ba..bd9b9b4 100644
--- a/usr/src/boot/sys/boot/ficl/amd64/Makefile
+++ b/usr/src/boot/sys/boot/libficl/amd64/Makefile
@@ -11,6 +11,7 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
include $(SRC)/Makefile.master
@@ -19,8 +20,10 @@
all install: lib
-include ../Makefile.inc
+include ../Makefile.com
-CFLAGS += -fPIC -m64 -mno-red-zone
+CFLAGS += -m64 -mno-red-zone
+
+$(OBJECTS): machine x86
FRC:
diff --git a/usr/src/boot/sys/boot/ficl/ficllocal.h b/usr/src/boot/sys/boot/libficl/ficllocal.h
similarity index 100%
rename from usr/src/boot/sys/boot/ficl/ficllocal.h
rename to usr/src/boot/sys/boot/libficl/ficllocal.h
diff --git a/usr/src/boot/sys/boot/ficl/i386/Makefile b/usr/src/boot/sys/boot/libficl/i386/Makefile
similarity index 82%
rename from usr/src/boot/sys/boot/ficl/i386/Makefile
rename to usr/src/boot/sys/boot/libficl/i386/Makefile
index 10e0c32..f4478a4 100644
--- a/usr/src/boot/sys/boot/ficl/i386/Makefile
+++ b/usr/src/boot/sys/boot/libficl/i386/Makefile
@@ -11,6 +11,7 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
include $(SRC)/Makefile.master
@@ -19,9 +20,10 @@
all install: lib
-include ../Makefile.inc
+include ../Makefile.com
-CFLAGS += -m32 -march=i386 -mpreferred-stack-boundary=2
-CFLAGS += -fno-reorder-functions
+CFLAGS += -m32
+
+$(OBJECTS): machine x86
FRC:
diff --git a/usr/src/boot/sys/boot/ficl/softcore/Makefile b/usr/src/boot/sys/boot/libficl/softcore/Makefile
similarity index 100%
rename from usr/src/boot/sys/boot/ficl/softcore/Makefile
rename to usr/src/boot/sys/boot/libficl/softcore/Makefile
diff --git a/usr/src/boot/sys/boot/libstand/Makefile.com b/usr/src/boot/sys/boot/libstand/Makefile.com
index fe4b002..6b9bf4e 100644
--- a/usr/src/boot/sys/boot/libstand/Makefile.com
+++ b/usr/src/boot/sys/boot/libstand/Makefile.com
@@ -11,7 +11,6 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
-# Copyright 2016 RackTop Systems.
#
include $(SRC)/Makefile.master
@@ -20,29 +19,26 @@
LD= $(GNU_ROOT)/bin/gld
CC= $(GNUC_ROOT)/bin/gcc
-LIBRARY= libstand.a
-
-all install: $(LIBRARY)
-
LIB_BASE= $(SRC)/boot/lib
LIBSTAND_SRC= $(LIB_BASE)/libstand
-CPPFLAGS = -nostdinc -I../../../../include -I${LIBSTAND_SRC} -I../../..
-CPPFLAGS += -I../../../sys -I. -I$(SRC)/common/bzip2
+ASFLAGS = -fPIC
+CPPFLAGS = -nostdinc -I../../../../include -I$(LIBSTAND_SRC)
+CPPFLAGS += -I../../.. -I../../../sys -I. -I$(SRC)/common/bzip2
CPPFLAGS += -D_STANDALONE
-CFLAGS = -O2 -ffreestanding -Wformat
+CFLAGS = -O2 -fPIC -ffreestanding -Wformat
CFLAGS += -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
CFLAGS += -Wall -Werror
-include ${LIBSTAND_SRC}/Makefile.inc
-
$(LIBRARY): $(SRCS) $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
+include $(LIBSTAND_SRC)/Makefile.inc
+
clean: clobber
clobber:
- $(RM) $(CLEANFILES) $(OBJS) machine x86 libstand.a
+ $(RM) $(CLEANFILES) $(OBJS) machine $(LIBRARY)
machine:
$(RM) machine
@@ -52,8 +48,6 @@
$(RM) x86
$(SYMLINK) ../../../x86/include x86
-$(OBJS): machine x86
-
%.o: $(LIBSTAND_SRC)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/boot/sys/boot/libstand/amd64/Makefile b/usr/src/boot/sys/boot/libstand/amd64/Makefile
index 3516128..de23592 100644
--- a/usr/src/boot/sys/boot/libstand/amd64/Makefile
+++ b/usr/src/boot/sys/boot/libstand/amd64/Makefile
@@ -11,14 +11,20 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
+MACHINE= $(MACH64)
+LIBRARY= libstand.a
+
+all install: $(LIBRARY)
+
include ../Makefile.com
-MACHINE= $(MACH64)
+CFLAGS += -m64 -mno-red-zone
+ASFLAGS += -m64
-CFLAGS += -m64 -fPIC -mno-red-zone
-ASFLAGS = -m64 -fPIC
+CLEANFILES += x86
# _setjmp/_longjmp
SRCS += $(LIBSTAND_SRC)/amd64/_setjmp.S
@@ -26,5 +32,7 @@
$(LIBRARY): $(SRCS) $(OBJS)
+$(OBJS): machine x86
+
%.o: $(LIBSTAND_SRC)/amd64/%.S
$(COMPILE.S) $<
diff --git a/usr/src/boot/sys/boot/libstand/i386/Makefile b/usr/src/boot/sys/boot/libstand/i386/Makefile
index 80983da..8a26d7b 100644
--- a/usr/src/boot/sys/boot/libstand/i386/Makefile
+++ b/usr/src/boot/sys/boot/libstand/i386/Makefile
@@ -11,14 +11,20 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
+MACHINE= $(MACH)
+LIBRARY= libstand.a
+
+all install: $(LIBRARY)
+
include ../Makefile.com
-MACHINE= $(MACH)
+CFLAGS += -m32
+ASFLAGS += -m32
-CFLAGS += -m32 -fno-reorder-functions
-CFLAGS += -mpreferred-stack-boundary=2
+CLEANFILES += x86
# _setjmp/_longjmp
SRCS += $(LIBSTAND_SRC)/i386/_setjmp.S
@@ -26,5 +32,7 @@
$(LIBRARY): $(SRCS) $(OBJS)
+$(OBJS): machine x86
+
%.o: $(LIBSTAND_SRC)/i386/%.S
$(COMPILE.S) $<
diff --git a/usr/src/boot/sys/boot/usb/Makefile b/usr/src/boot/sys/boot/usb/Makefile
index 1b94b3d..6ad13d0 100644
--- a/usr/src/boot/sys/boot/usb/Makefile
+++ b/usr/src/boot/sys/boot/usb/Makefile
@@ -43,7 +43,6 @@
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -march=i386
-CFLAGS.gcc+= -mpreferred-stack-boundary=2
.endif
.if ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -m32
diff --git a/usr/src/boot/sys/boot/usb/Makefile.test b/usr/src/boot/sys/boot/usb/Makefile.test
index 7c6a66d..9b6478a 100644
--- a/usr/src/boot/sys/boot/usb/Makefile.test
+++ b/usr/src/boot/sys/boot/usb/Makefile.test
@@ -40,7 +40,6 @@
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -march=i386
-CFLAGS.gcc+= -mpreferred-stack-boundary=2
.endif
.if ${MACHINE_CPUARCH} == "amd64"
CFLAGS+= -m32
diff --git a/usr/src/boot/sys/boot/zfs/Makefile b/usr/src/boot/sys/boot/zfs/Makefile
index 025cd56..660b8e3 100644
--- a/usr/src/boot/sys/boot/zfs/Makefile
+++ b/usr/src/boot/sys/boot/zfs/Makefile
@@ -10,12 +10,12 @@
#
#
-# Copyright 2015 Toomas Soome <tsoome@me.com>
+# Copyright 2016 Toomas Soome <tsoome@me.com>
#
include $(SRC)/Makefile.master
-SUBDIRS= i386 amd64
+SUBDIRS= $(MACH) $(MACH64)
all:= TARGET= all
install:= TARGET= install
diff --git a/usr/src/boot/sys/boot/zfs/Makefile.com b/usr/src/boot/sys/boot/zfs/Makefile.com
index 7ece715..96adde7 100644
--- a/usr/src/boot/sys/boot/zfs/Makefile.com
+++ b/usr/src/boot/sys/boot/zfs/Makefile.com
@@ -11,45 +11,44 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
-# Copyright 2016 RackTop Systems.
#
include $(SRC)/Makefile.master
LIB= zfsboot
-all: libzfsboot.a
-
clean: clobber
clobber:
$(RM) machine x86 $(OBJS) libzfsboot.a
CC= $(GNUC_ROOT)/bin/gcc
-CPPFLAGS=
-SRCS += ../zfs.c ../gzip.c
+CFLAGS= -O2
+CFLAGS += -fPIC -ffreestanding -msoft-float
+CFLAGS += -mno-mmx -mno-3dnow -mno-sse2 -mno-sse3 -mno-sse
+CFLAGS += -mno-avx -mno-aes -std=gnu99
+
+SRCS += $(SRC)/boot/sys/boot/zfs/zfs.c $(SRC)/boot/sys/boot/zfs/gzip.c
SRCS += $(SRC)/common/crypto/edonr/edonr.c
SRCS += $(SRC)/common/crypto/skein/skein.c
SRCS += $(SRC)/common/crypto/skein/skein_iv.c
SRCS += $(SRC)/common/crypto/skein/skein_block.c
OBJS += zfs.o gzip.o edonr.o skein.o skein_iv.o skein_block.o
-CFLAGS= -O2 -D_STANDALONE -nostdinc -I../../../../include -I../../..
-CFLAGS += -I../../common -I../../.. -I.. -I.
-CFLAGS += -I../../../../lib/libstand
-CFLAGS += -I../../../../lib/libz
-CFLAGS += -I../../../cddl/boot/zfs
-CFLAGS += -I$(SRC)/uts/common
+CPPFLAGS= -D_STANDALONE -nostdinc -I../../../../include -I../..
+CPPFLAGS += -I../../common -I../../.. -I.. -I.
+CPPFLAGS += -I../../../../lib/libstand
+CPPFLAGS += -I../../../../lib/libz
+CPPFLAGS += -I../../../cddl/boot/zfs
+CPPFLAGS += -I$(SRC)/uts/common
# Do not unroll skein loops, reduce code size
-CFLAGS += -DSKEIN_LOOP=111
+CPPFLAGS += -DSKEIN_LOOP=111
-CFLAGS += -ffreestanding
-CFLAGS += -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
-CFLAGS += -Wformat -Wall -std=gnu99
+#include ../../Makefile.inc
-CLEANFILES += machine x86
+CLEANFILES += machine
machine:
$(RM) machine
@@ -59,12 +58,10 @@
$(RM) x86
$(SYMLINK) ../../../x86/include x86
-$(OBJS): machine x86
-
libzfsboot.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
-%.o: ../%.c
+%.o: $(SRC)/boot/sys/boot/zfs/%.c
$(COMPILE.c) -o $@ $<
%.o: $(SRC)/common/crypto/edonr/%.c
@@ -73,4 +70,4 @@
%.o: $(SRC)/common/crypto/skein/%.c
$(COMPILE.c) -o $@ $<
-zfs.o: ../zfsimpl.c
+zfs.o: $(SRC)/boot/sys/boot/zfs/zfsimpl.c
diff --git a/usr/src/boot/sys/boot/zfs/amd64/Makefile b/usr/src/boot/sys/boot/zfs/amd64/Makefile
index 80eb330..da13c92 100644
--- a/usr/src/boot/sys/boot/zfs/amd64/Makefile
+++ b/usr/src/boot/sys/boot/zfs/amd64/Makefile
@@ -11,10 +11,16 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
+MACHINE= $(MACH64)
+
+all install: libzfsboot.a
+
include ../Makefile.com
-CFLAGS += -mno-red-zone -m64 -fPIC
+CLEANFILES += x86
+CFLAGS += -mno-red-zone -m64
-MACHINE= $(MACH64)
+$(OBJS): machine x86
diff --git a/usr/src/boot/sys/boot/zfs/i386/Makefile b/usr/src/boot/sys/boot/zfs/i386/Makefile
index f2bb545..3875f9a 100644
--- a/usr/src/boot/sys/boot/zfs/i386/Makefile
+++ b/usr/src/boot/sys/boot/zfs/i386/Makefile
@@ -11,11 +11,16 @@
#
# Copyright 2016 Toomas Soome <tsoome@me.com>
+# Copyright 2016 RackTop Systems.
#
+MACHINE= $(MACH)
+
+all install: libzfsboot.a
+
include ../Makefile.com
-CFLAGS += -march=i386 -m32 -fno-reorder-functions
-CFLAGS += -mpreferred-stack-boundary=2
+CLEANFILES += x86
+CFLAGS += -m32
-MACHINE= $(MACH)
+$(OBJS): machine x86
diff --git a/usr/src/pkg/manifests/system-boot-loader.mf b/usr/src/pkg/manifests/system-boot-loader.mf
index 346acbc..ce0af6a 100644
--- a/usr/src/pkg/manifests/system-boot-loader.mf
+++ b/usr/src/pkg/manifests/system-boot-loader.mf
@@ -43,7 +43,8 @@
$(i386_ONLY)dir path=usr/share/man/man3
$(i386_ONLY)dir path=usr/share/man/man4
$(i386_ONLY)dir path=usr/share/man/man5
-$(i386_ONLY)file path=boot/boot1.efi group=sys mode=0555
+$(i386_ONLY)file path=boot/bootia32.efi group=sys mode=0555
+$(i386_ONLY)file path=boot/bootx64.efi group=sys mode=0555
$(i386_ONLY)file path=boot/cdboot group=sys mode=0444
$(i386_ONLY)file path=boot/defaults/loader.conf group=sys mode=0444
$(i386_ONLY)file path=boot/forth/beadm.4th group=sys mode=0444
@@ -73,9 +74,10 @@
$(i386_ONLY)file path=boot/forth/version.4th group=sys mode=0444
$(i386_ONLY)file path=boot/gptzfsboot group=sys mode=0444
$(i386_ONLY)file path=boot/loader group=sys mode=0444
-$(i386_ONLY)file path=boot/loader.efi group=sys mode=0555
$(i386_ONLY)file path=boot/loader.help group=sys mode=0444
$(i386_ONLY)file path=boot/loader.rc group=sys mode=0444
+$(i386_ONLY)file path=boot/loader32.efi group=sys mode=0555
+$(i386_ONLY)file path=boot/loader64.efi group=sys mode=0555
$(i386_ONLY)file path=boot/pmbr group=sys mode=0444
$(i386_ONLY)file path=boot/pxeboot group=sys mode=0444
$(i386_ONLY)file path=usr/share/man/man4/loader.conf.4