On Tue, Nov 22, 2016 at 11:02:55PM -0500, Ian Sutton wrote:
> Hi,
> 
> Patch adds armv8/aarch64 EFI payload image build support. With
> patrick@'s aarch64-none-elf- toolchain referenced in my last mail on
> this list, you can build it via...
> 
> $ MACHINE=armv8 armmake64-aarch64 -f Makefile.arm64
> 
> ...where armmake64-aarch64 is a simple env wrapper for the toolchain,
> uploaded here:
> 
> https://ce.gl/armmake64-aarch64.txt
> 
> I've tested this on the pine64, it works up until boot(0) is called
> which fails as there is no bootable disk/aarch64 kernel yet.
> 
> I've put this in the armv7 directory pending a proper
> armv8/aarch64/arm64 one.
> 
> Ian

Ok, so I have extracted the actual diff between the new files you added
and the ones that were there before.

--- efiboot.c   Fri Oct 28 10:18:22 2016
+++ efiboot64.c Mon Nov 28 23:27:50 2016
@@ -63,13 +63,14 @@
 
        status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
            (void **)&imgp);
+
        if (status == EFI_SUCCESS)
                status = EFI_CALL(BS->HandleProtocol, imgp->DeviceHandle,
                    &devp_guid, (void **)&dp);
        if (status == EFI_SUCCESS)
                efi_bootdp = dp;
 
-       progname = "BOOTARM";
+       progname = "BOOTAA64";

this could be a simple.

#ifdef ARM
        progname = "BOOTARM";
#else
        progname = "BOOTAA64";
#define

 
        boot(0);
 
@@ -244,7 +245,7 @@
 efi_makebootargs(char *bootargs, uint32_t *board_id)
 {
        void *fdt = NULL;
-       u_char bootduid[8];
+       char bootduid[8];
        u_char zero[8];
        void *node;
        size_t len;
--- efidev.c    Sun Jul 24 15:06:23 2016
+++ efidev64.c  Mon Nov 28 23:27:50 2016
@@ -114,7 +114,8 @@
        int sector;
        size_t rsize;
        struct disklabel *lp;
-       unsigned char buf[DEV_BSIZE];
+       char buf[DEV_BSIZE];
+       uint16_t buf_sighold;
 
        /*
         * Find OpenBSD Partition in DOS partition table.
@@ -123,7 +124,9 @@
        if (efistrategy(dip, F_READ, DOSBBSECTOR, DEV_BSIZE, buf, &rsize))
                return EOFFSET;
 
-       if (*(u_int16_t *)&buf[DOSMBR_SIGNATURE_OFF] == DOSMBR_SIGNATURE) {
+       memcpy(&buf_sighold, &(buf[DOSMBR_SIGNATURE_OFF]), sizeof(uint16_t));

Was that a compiler warning?  Might not hurt to do this for ARM either.

+
+       if (buf_sighold == DOSMBR_SIGNATURE) {
                int i;
                struct dos_partition *dp = (struct dos_partition *)buf;
 
--- exec.c      Fri Oct 14 09:57:44 2016
+++ exec64.c    Mon Nov 28 23:27:50 2016
@@ -43,6 +43,7 @@
        char *cp;
        void *fdt;
        uint32_t board_id = 0;
+       uint64_t board_id_pad = 0;
        int i;
 
        /*
@@ -82,7 +83,9 @@
 
        efi_cleanup();
 
-       (*(startfuncp)(marks[MARK_ENTRY]))((void *)esym, (void *)board_id, fdt);
+       memcpy(&board_id_pad, &board_id, sizeof(board_id));
+
+       (*(startfuncp)(marks[MARK_ENTRY]))((void *)esym, (void *)board_id_pad, 
fdt);

I bet this is just another compiler warning?  This shouldn't hurt as it
was before for arm64 as well.  Not sure why this had to change.

 
        /* NOTREACHED */
 }
--- Makefile    Wed Nov  9 20:59:14 2016
+++ Makefile.arm64      Mon Nov 28 23:27:50 2016
@@ -2,13 +2,13 @@
 
 NOMAN=         #
 
-.if ${MACHINE} == "armv7"
+.if ${MACHINE} == "armv8"
 
-PROG=          BOOTARM.EFI
+PROG=          BOOTAA64.EFI
 OBJFMT=                binary
 INSTALL_STRIP=
 BINDIR=                /usr/mdec
-SRCS=          start.S self_reloc.c efiboot.c conf.c exec.c efidev.c fdt.c
+SRCS=          start64.S self_reloc.c efiboot64.c conf.c exec64.c efidev64.c 
fdt.c
 
 S=             ${.CURDIR}/../../../..
 EFIDIR=                ${S}/stand/efi
@@ -16,7 +16,7 @@
 OBJCOPY?=      objcopy
 OBJDUMP?=      objdump
 
-LDFLAGS+=-nostdlib -T ${.CURDIR}/ldscript.arm -Bsymbolic -shared
+LDFLAGS+=-nostdlib -T ${.CURDIR}/ldscript.arm64 -Bsymbolic -shared
 
 .PATH: ${S}/stand/boot
 SRCS+= boot.c cmd.c vars.c
@@ -31,7 +31,8 @@
 SRCS+= ufs.c
 
 .PATH: ${S}/lib/libkern/arch/arm ${S}/lib/libkern
-SRCS+= divsi3.S divdi3.c moddi3.c qdivrem.c strlcpy.c strlen.c
+#SRCS+=        divsi3.S divdi3.c moddi3.c qdivrem.c strlcpy.c strlen.c
+SRCS+= divdi3.c moddi3.c qdivrem.c strlcpy.c strlen.c
 
 .PATH: ${S}/lib/libz
 SRCS+= adler32.c crc32.c inflate.c inftrees.c
@@ -42,6 +43,7 @@
 CPPFLAGS+=     -D_STANDALONE
 CPPFLAGS+=     -DSMALL -DSLOW -DNOBYFOUR -D__INTERNAL_LIBSA_CREAD
 CPPFLAGS+=     -DNEEDS_HEAP_H
+COPTS+=                -Wno-attributes -Wno-format
 COPTS+=                -ffreestanding -fno-stack-protector
 COPTS+=                -fshort-wchar -fPIC -fno-builtin
 COPTS+=                -Wall -Werror

All this stuff here can stay in the same Makefile and just be compiled
with MACHINE=arm64 or MACHINE=armv7 and a few .ifdef MACHINE.

Feels like we can simply change the existing files without adding new
ones (apart from start64.S and ldscript.arm64 of course).

Patrick

Reply via email to