Index: sys/boot/Makefile =================================================================== --- sys/boot/Makefile +++ sys/boot/Makefile @@ -1,7 +1,6 @@ # $FreeBSD$ .include -.include .if ${MK_FORTH} != "no" # Build the add-in FORTH interpreter. @@ -13,8 +12,6 @@ .if exists(${.CURDIR}/${ADIR}/.) SUBDIR+= ${ADIR} .endif -.if ${MACHINE} == "amd64" -SUBDIR+= i386 -.endif +.include .include Index: sys/boot/Makefile.amd64 =================================================================== --- sys/boot/Makefile.amd64 +++ sys/boot/Makefile.amd64 @@ -8,3 +8,5 @@ .if ${MK_FORTH} != "no" SUBDIR+= ficl32 .endif + +SUBDIR+= i386 Index: sys/boot/amd64/Makefile =================================================================== --- sys/boot/amd64/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $FreeBSD$ - -.include - -SUBDIR= efi boot1.efi - -.include Index: sys/boot/amd64/Makefile.inc =================================================================== --- sys/boot/amd64/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# Common defines for all of /sys/boot/amd64/ -# -# $FreeBSD$ - -BINDIR?= /boot - -# See conf/kern.mk for the correct set of these -CFLAGS+= -ffreestanding -mno-red-zone -CFLAGS+= -mno-mmx -mno-sse -mno-aes -mno-avx -msoft-float -LDFLAGS+= -nostdlib - -.include "../Makefile.inc" Index: sys/boot/amd64/boot1.efi/Makefile.fat =================================================================== --- /dev/null +++ sys/boot/amd64/boot1.efi/Makefile.fat @@ -1,3 +0,0 @@ -# This file autogenerated by generate-fat.sh - DO NOT EDIT -# $FreeBSD$ -BOOT1_OFFSET=0x2d Index: sys/boot/amd64/boot1.efi/boot1.c =================================================================== --- /dev/null +++ sys/boot/amd64/boot1.efi/boot1.c @@ -1,552 +0,0 @@ -/*- - * Copyright (c) 1998 Robert Nordier - * All rights reserved. - * Copyright (c) 2001 Robert Drehmel - * All rights reserved. - * Copyright (c) 2014 Nathan Whitehorn - * All rights reserved. - * - * Redistribution and use in source and binary forms are freely - * permitted provided that the above copyright notice and this - * paragraph and the following disclaimer are duplicated in all - * such forms. - * - * This software is provided "AS IS" and without any express or - * implied warranties, including, without limitation, the implied - * warranties of merchantability and fitness for a particular - * purpose. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include -#include - -#define _PATH_LOADER "/boot/loader.efi" -#define _PATH_KERNEL "/boot/kernel/kernel" - -#define BSIZEMAX 16384 - -typedef int putc_func_t(char c, void *arg); - -struct sp_data { - char *sp_buf; - u_int sp_len; - u_int sp_size; -}; - -static const char digits[] = "0123456789abcdef"; - -static void panic(const char *fmt, ...) __dead2; -static int printf(const char *fmt, ...); -static int putchar(char c, void *arg); -static int vprintf(const char *fmt, va_list ap); -static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); - -static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap); -static int __putc(char c, void *arg); -static int __puts(const char *s, putc_func_t *putc, void *arg); -static int __sputc(char c, void *arg); -static char *__uitoa(char *buf, u_int val, int base); -static char *__ultoa(char *buf, u_long val, int base); - -static int domount(EFI_DEVICE_PATH *device, EFI_BLOCK_IO *blkio, int quiet); -static void load(const char *fname); - -EFI_SYSTEM_TABLE *systab; -EFI_HANDLE *image; - -static void -bcopy(const void *src, void *dst, size_t len) -{ - const char *s = src; - char *d = dst; - - while (len-- != 0) - *d++ = *s++; -} - -static void -memcpy(void *dst, const void *src, size_t len) -{ - bcopy(src, dst, len); -} - -static void -bzero(void *b, size_t len) -{ - char *p = b; - - while (len-- != 0) - *p++ = 0; -} - -static int -strcmp(const char *s1, const char *s2) -{ - for (; *s1 == *s2 && *s1; s1++, s2++) - ; - return ((u_char)*s1 - (u_char)*s2); -} - -static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; -static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; -static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; -static EFI_GUID ConsoleControlGUID = EFI_CONSOLE_CONTROL_PROTOCOL_GUID; - -static EFI_BLOCK_IO *bootdev; -static EFI_DEVICE_PATH *bootdevpath; -static EFI_HANDLE *bootdevhandle; - -EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE* Xsystab) -{ - EFI_HANDLE handles[128]; - EFI_BLOCK_IO *blkio; - UINTN i, nparts = sizeof(handles); - EFI_STATUS status; - EFI_DEVICE_PATH *devpath; - EFI_BOOT_SERVICES *BS; - EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl = NULL; - char *path = _PATH_LOADER; - - systab = Xsystab; - image = Ximage; - - BS = systab->BootServices; - status = BS->LocateProtocol(&ConsoleControlGUID, NULL, - (VOID **)&ConsoleControl); - if (status == EFI_SUCCESS) - (void)ConsoleControl->SetMode(ConsoleControl, - EfiConsoleControlScreenText); - - printf(" \n>> FreeBSD EFI boot block\n"); - printf(" Loader path: %s\n", path); - - status = systab->BootServices->LocateHandle(ByProtocol, - &BlockIoProtocolGUID, NULL, &nparts, handles); - nparts /= sizeof(handles[0]); - - for (i = 0; i < nparts; i++) { - status = systab->BootServices->HandleProtocol(handles[i], - &DevicePathGUID, (void **)&devpath); - if (EFI_ERROR(status)) - continue; - - while (!IsDevicePathEnd(NextDevicePathNode(devpath))) - devpath = NextDevicePathNode(devpath); - - status = systab->BootServices->HandleProtocol(handles[i], - &BlockIoProtocolGUID, (void **)&blkio); - if (EFI_ERROR(status)) - continue; - - if (!blkio->Media->LogicalPartition) - continue; - - if (domount(devpath, blkio, 1) >= 0) - break; - } - - if (i == nparts) - panic("No bootable partition found"); - - bootdevhandle = handles[i]; - load(path); - - panic("Load failed"); - - return EFI_SUCCESS; -} - -static int -dskread(void *buf, u_int64_t lba, int nblk) -{ - EFI_STATUS status; - int size; - - lba = lba / (bootdev->Media->BlockSize / DEV_BSIZE); - size = nblk * DEV_BSIZE; - status = bootdev->ReadBlocks(bootdev, bootdev->Media->MediaId, lba, - size, buf); - - if (EFI_ERROR(status)) - return (-1); - - return (0); -} - -#include "ufsread.c" - -static ssize_t -fsstat(ufs_ino_t inode) -{ -#ifndef UFS2_ONLY - static struct ufs1_dinode dp1; - ufs1_daddr_t addr1; -#endif -#ifndef UFS1_ONLY - static struct ufs2_dinode dp2; -#endif - static struct fs fs; - static ufs_ino_t inomap; - char *blkbuf; - void *indbuf; - size_t n, nb, size, off, vboff; - ufs_lbn_t lbn; - ufs2_daddr_t addr2, vbaddr; - static ufs2_daddr_t blkmap, indmap; - u_int u; - - blkbuf = dmadat->blkbuf; - indbuf = dmadat->indbuf; - if (!dsk_meta) { - inomap = 0; - for (n = 0; sblock_try[n] != -1; n++) { - if (dskread(dmadat->sbbuf, sblock_try[n] / DEV_BSIZE, - SBLOCKSIZE / DEV_BSIZE)) - return -1; - memcpy(&fs, dmadat->sbbuf, sizeof(struct fs)); - if (( -#if defined(UFS1_ONLY) - fs.fs_magic == FS_UFS1_MAGIC -#elif defined(UFS2_ONLY) - (fs.fs_magic == FS_UFS2_MAGIC && - fs.fs_sblockloc == sblock_try[n]) -#else - fs.fs_magic == FS_UFS1_MAGIC || - (fs.fs_magic == FS_UFS2_MAGIC && - fs.fs_sblockloc == sblock_try[n]) -#endif - ) && - fs.fs_bsize <= MAXBSIZE && - fs.fs_bsize >= sizeof(struct fs)) - break; - } - if (sblock_try[n] == -1) { - printf("Not ufs\n"); - return -1; - } - dsk_meta++; - } else - memcpy(&fs, dmadat->sbbuf, sizeof(struct fs)); - if (!inode) - return 0; - if (inomap != inode) { - n = IPERVBLK(&fs); - if (dskread(blkbuf, INO_TO_VBA(&fs, n, inode), DBPERVBLK)) - return -1; - n = INO_TO_VBO(n, inode); -#if defined(UFS1_ONLY) - memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, - sizeof(struct ufs1_dinode)); -#elif defined(UFS2_ONLY) - memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, - sizeof(struct ufs2_dinode)); -#else - if (fs.fs_magic == FS_UFS1_MAGIC) - memcpy(&dp1, (struct ufs1_dinode *)blkbuf + n, - sizeof(struct ufs1_dinode)); - else - memcpy(&dp2, (struct ufs2_dinode *)blkbuf + n, - sizeof(struct ufs2_dinode)); -#endif - inomap = inode; - fs_off = 0; - blkmap = indmap = 0; - } - size = DIP(di_size); - n = size - fs_off; - return (n); -} - -static struct dmadat __dmadat; - -static int -domount(EFI_DEVICE_PATH *device, EFI_BLOCK_IO *blkio, int quiet) -{ - - dmadat = &__dmadat; - bootdev = blkio; - bootdevpath = device; - if (fsread(0, NULL, 0)) { - if (!quiet) - printf("domount: can't read superblock\n"); - return (-1); - } - if (!quiet) - printf("Succesfully mounted UFS filesystem\n"); - return (0); -} - -static void -load(const char *fname) -{ - ufs_ino_t ino; - EFI_STATUS status; - EFI_HANDLE loaderhandle; - EFI_LOADED_IMAGE *loaded_image; - void *buffer; - size_t bufsize; - - if ((ino = lookup(fname)) == 0) { - printf("File %s not found\n", fname); - return; - } - - bufsize = fsstat(ino); - status = systab->BootServices->AllocatePool(EfiLoaderData, - bufsize, &buffer); - fsread(ino, buffer, bufsize); - - /* XXX: For secure boot, we need our own loader here */ - status = systab->BootServices->LoadImage(TRUE, image, bootdevpath, - buffer, bufsize, &loaderhandle); - if (EFI_ERROR(status)) - printf("LoadImage failed with error %d\n", status); - - status = systab->BootServices->HandleProtocol(loaderhandle, - &LoadedImageGUID, (VOID**)&loaded_image); - if (EFI_ERROR(status)) - printf("HandleProtocol failed with error %d\n", status); - - loaded_image->DeviceHandle = bootdevhandle; - - status = systab->BootServices->StartImage(loaderhandle, NULL, NULL); - if (EFI_ERROR(status)) - printf("StartImage failed with error %d\n", status); -} - -static void -panic(const char *fmt, ...) -{ - char buf[128]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, sizeof buf, fmt, ap); - printf("panic: %s\n", buf); - va_end(ap); - - while (1) {} -} - -static int -printf(const char *fmt, ...) -{ - va_list ap; - int ret; - - /* Don't annoy the user as we probe for partitions */ - if (strcmp(fmt,"Not ufs\n") == 0) - return 0; - - va_start(ap, fmt); - ret = vprintf(fmt, ap); - va_end(ap); - return (ret); -} - -static int -putchar(char c, void *arg) -{ - CHAR16 buf[2]; - - if (c == '\n') { - buf[0] = '\r'; - buf[1] = 0; - systab->ConOut->OutputString(systab->ConOut, buf); - } - buf[0] = c; - buf[1] = 0; - systab->ConOut->OutputString(systab->ConOut, buf); - return (1); -} - -static int -vprintf(const char *fmt, va_list ap) -{ - int ret; - - ret = __printf(fmt, putchar, 0, ap); - return (ret); -} - -static int -vsnprintf(char *str, size_t sz, const char *fmt, va_list ap) -{ - struct sp_data sp; - int ret; - - sp.sp_buf = str; - sp.sp_len = 0; - sp.sp_size = sz; - ret = __printf(fmt, __sputc, &sp, ap); - return (ret); -} - -static int -__printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap) -{ - char buf[(sizeof(long) * 8) + 1]; - char *nbuf; - u_long ul; - u_int ui; - int lflag; - int sflag; - char *s; - int pad; - int ret; - int c; - - nbuf = &buf[sizeof buf - 1]; - ret = 0; - while ((c = *fmt++) != 0) { - if (c != '%') { - ret += putc(c, arg); - continue; - } - lflag = 0; - sflag = 0; - pad = 0; -reswitch: c = *fmt++; - switch (c) { - case '#': - sflag = 1; - goto reswitch; - case '%': - ret += putc('%', arg); - break; - case 'c': - c = va_arg(ap, int); - ret += putc(c, arg); - break; - case 'd': - if (lflag == 0) { - ui = (u_int)va_arg(ap, int); - if (ui < (int)ui) { - ui = -ui; - ret += putc('-', arg); - } - s = __uitoa(nbuf, ui, 10); - } else { - ul = (u_long)va_arg(ap, long); - if (ul < (long)ul) { - ul = -ul; - ret += putc('-', arg); - } - s = __ultoa(nbuf, ul, 10); - } - ret += __puts(s, putc, arg); - break; - case 'l': - lflag = 1; - goto reswitch; - case 'o': - if (lflag == 0) { - ui = (u_int)va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 8); - } else { - ul = (u_long)va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 8); - } - ret += __puts(s, putc, arg); - break; - case 'p': - ul = (u_long)va_arg(ap, void *); - s = __ultoa(nbuf, ul, 16); - ret += __puts("0x", putc, arg); - ret += __puts(s, putc, arg); - break; - case 's': - s = va_arg(ap, char *); - ret += __puts(s, putc, arg); - break; - case 'u': - if (lflag == 0) { - ui = va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 10); - } else { - ul = va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 10); - } - ret += __puts(s, putc, arg); - break; - case 'x': - if (lflag == 0) { - ui = va_arg(ap, u_int); - s = __uitoa(nbuf, ui, 16); - } else { - ul = va_arg(ap, u_long); - s = __ultoa(nbuf, ul, 16); - } - if (sflag) - ret += __puts("0x", putc, arg); - ret += __puts(s, putc, arg); - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - pad = pad * 10 + c - '0'; - goto reswitch; - default: - break; - } - } - return (ret); -} - -static int -__sputc(char c, void *arg) -{ - struct sp_data *sp; - - sp = arg; - if (sp->sp_len < sp->sp_size) - sp->sp_buf[sp->sp_len++] = c; - sp->sp_buf[sp->sp_len] = '\0'; - return (1); -} - -static int -__puts(const char *s, putc_func_t *putc, void *arg) -{ - const char *p; - int ret; - - ret = 0; - for (p = s; *p != '\0'; p++) - ret += putc(*p, arg); - return (ret); -} - -static char * -__uitoa(char *buf, u_int ui, int base) -{ - char *p; - - p = buf; - *p = '\0'; - do - *--p = digits[ui % base]; - while ((ui /= base) != 0); - return (p); -} - -static char * -__ultoa(char *buf, u_long ul, int base) -{ - char *p; - - p = buf; - *p = '\0'; - do - *--p = digits[ul % base]; - while ((ul /= base) != 0); - return (p); -} - Index: sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu =================================================================== --- /dev/null +++ sys/boot/amd64/boot1.efi/fat.tmpl.bz2.uu @@ -1,20 +0,0 @@ -FAT template boot filesystem created by generate-fat.sh -DO NOT EDIT -$FreeBSD$ -begin 644 fat.tmpl.bz2 -M0EIH.3%!629362AK*D(`&I+____[ZZKJZ_^N_ZO^Z_Z_OJ[L`4`!7I0$#&$" -M0$!$3&(I-DTU,)ZAZ0VA-!M0T'J`>H#"9 -M'I#0-H&HQI&0&3&FH>H>*`JHHU3V]1%/4/2``T#0`!H``#0`````#1H,@``6 -M'1&G'&@?$6[T#A)?X8$A160"20BO#")0J4TB1*4GXF$B4I,&>43+=_?K=#3* -M6]R"ZNKJZI,9*68E8*E2Q -M4J5*E3'(1830A"$(12A-"<(0A#]VD)H0A"$,>I0FA"$(0I\>P^=F5:M6K5JU -M:DI3:64UN;[7%5B]Y-^\]@_K@B:N\/,5F%&H<\G#IXQXAEFC&D?![6%0'6MR -MX1@@%FC"FD`M7,/SXFNG:2`'-0<-C$8^+$N.7M1B,^6)9,DV9,0A\OL<:C"L -ML1V&,<\9YRB>XV#BG")'6NKRK^("UF2XO?_L!#29">MGDF$R3).!PX&%E,4C -M''=(FL1.`_3?CN@-IB2PI3!FF\<8X.X@D,>CA90I)#M$XRPNDFJELL<3=1?8 -M2B7\5Z64,!7Z;EEBW-MXN-4IJ@W$462]-*\YCR,-B,5[W?=3&L/U>SX,WV#\ -M\B`:I"'0Z)5"$1B.E)(K[5I4RS`%R$>Y\D0NR*,;<9CZ:^V3P(I?D Makefile.fat -echo '# $FreeBSD$' >> Makefile.fat -echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.fat - -bzip2 $OUTPUT_FILE -echo 'FAT template boot filesystem created by generate-fat.sh' > $OUTPUT_FILE.bz2.uu -echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu -echo '$FreeBSD$' >> $OUTPUT_FILE.bz2.uu - -uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu -rm $OUTPUT_FILE.bz2 - Index: sys/boot/amd64/efi/amd64_tramp.S =================================================================== --- /dev/null +++ sys/boot/amd64/efi/amd64_tramp.S @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Benno Rice under sponsorship from - * the FreeBSD Foundation. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include - - .text - .globl amd64_tramp - -/* - * void amd64_tramp(uint64_t stack, void *copy_finish, uint64_t kernend, - * uint64_t modulep, uint64_t pagetable, uint64_t entry) - */ -amd64_tramp: - cli /* Make sure we don't get interrupted. */ - movq %rdi,%rsp /* Switch to our temporary stack. */ - - movq %rdx,%r12 /* Stash the kernel values for later. */ - movq %rcx,%r13 - movq %r8,%r14 - movq %r9,%r15 - - callq *%rsi /* Call copy_finish so we're all ready to go. */ - - pushq %r12 /* Push kernend. */ - salq $32,%r13 /* Shift modulep and push it. */ - pushq %r13 - pushq %r15 /* Push the entry address. */ - movq %r14,%cr3 /* Switch page tables. */ - ret /* "Return" to kernel entry. */ - - ALIGN_TEXT -amd64_tramp_end: - - .data - .globl amd64_tramp_size -amd64_tramp_size: - .long amd64_tramp_end-amd64_tramp Index: sys/boot/amd64/efi/framebuffer.h =================================================================== --- /dev/null +++ sys/boot/amd64/efi/framebuffer.h @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Benno Rice under sponsorship from - * the FreeBSD Foundation. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#ifndef _EFIFB_H_ -#define _EFIFB_H_ - -int efi_find_framebuffer(struct efi_fb *efifb); - -#endif /* _EFIFB_H_ */ Index: sys/boot/amd64/efi/framebuffer.c =================================================================== --- /dev/null +++ sys/boot/amd64/efi/framebuffer.c @@ -1,85 +0,0 @@ -/*- - * Copyright (c) 2013 The FreeBSD Foundation - * All rights reserved. - * - * This software was developed by Benno Rice under sponsorship from - * the FreeBSD Foundation. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -#include -#include -#include - -static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; - -int -efi_find_framebuffer(struct efi_fb *efifb) -{ - EFI_GRAPHICS_OUTPUT *gop; - EFI_STATUS status; - EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *mode; - EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info; - - status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop); - if (EFI_ERROR(status)) - return (1); - - mode = gop->Mode; - info = gop->Mode->Info; - - efifb->fb_addr = mode->FrameBufferBase; - efifb->fb_size = mode->FrameBufferSize; - efifb->fb_height = info->VerticalResolution; - efifb->fb_width = info->HorizontalResolution; - efifb->fb_stride = info->PixelsPerScanLine; - - switch (info->PixelFormat) { - case PixelRedGreenBlueReserved8BitPerColor: - efifb->fb_mask_red = 0x000000ff; - efifb->fb_mask_green = 0x0000ff00; - efifb->fb_mask_blue = 0x00ff0000; - efifb->fb_mask_reserved = 0xff000000; - break; - case PixelBlueGreenRedReserved8BitPerColor: - efifb->fb_mask_red = 0x00ff0000; - efifb->fb_mask_green = 0x0000ff00; - efifb->fb_mask_blue = 0x000000ff; - efifb->fb_mask_reserved = 0xff000000; - break; - case PixelBitMask: - efifb->fb_mask_red = info->PixelInformation.RedMask; - efifb->fb_mask_green = info->PixelInformation.GreenMask; - efifb->fb_mask_blue = info->PixelInformation.BlueMask; - efifb->fb_mask_reserved = - info->PixelInformation.ReservedMask; - break; - default: - return (1); - } - return (0); -} Index: sys/boot/amd64/efi/ldscript.amd64 =================================================================== --- /dev/null +++ sys/boot/amd64/efi/ldscript.amd64 @@ -1,67 +0,0 @@ -/* $FreeBSD$ */ -OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd") -OUTPUT_ARCH(i386:x86-64) -ENTRY(_start) -SECTIONS -{ - /* Read-only sections, merged into text segment: */ - . = 0; - ImageBase = .; - .hash : { *(.hash) } /* this MUST come first! */ - . = ALIGN(4096); - .eh_frame : - { - *(.eh_frame) - } - . = ALIGN(4096); - .text : { - *(.text .stub .text.* .gnu.linkonce.t.*) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.plt) - } =0x00300000010070000002000001000400 - . = ALIGN(4096); - .data : { - *(.rodata .rodata.* .gnu.linkonce.r.*) - *(.rodata1) - *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) - *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) - *(.opd) - *(.data .data.* .gnu.linkonce.d.*) - *(.data1) - *(.plabel) - *(.dynbss) - *(.bss .bss.* .gnu.linkonce.b.*) - *(COMMON) - } - . = ALIGN(4096); - set_Xcommand_set : { - __start_set_Xcommand_set = .; - *(set_Xcommand_set) - __stop_set_Xcommand_set = .; - } - . = ALIGN(4096); - __gp = .; - .sdata : { - *(.got.plt .got) - *(.sdata .sdata.* .gnu.linkonce.s.*) - *(dynsbss) - *(.sbss .sbss.* .gnu.linkonce.sb.*) - *(.scommon) - } - . = ALIGN(4096); - .dynamic : { *(.dynamic) } - . = ALIGN(4096); - .rela.dyn : { - *(.rela.data*) - *(.rela.got) - *(.rela.stab) - *(.relaset_*) - } - . = ALIGN(4096); - .reloc : { *(.reloc) } - . = ALIGN(4096); - .dynsym : { *(.dynsym) } - . = ALIGN(4096); - .dynstr : { *(.dynstr) } -} Index: sys/boot/amd64/efi/reloc.c =================================================================== --- /dev/null +++ sys/boot/amd64/efi/reloc.c @@ -1,107 +0,0 @@ -/*- - * Copyright (c) 2008-2010 Rui Paulo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#ifdef __i386__ -#define ElfW_Rel Elf32_Rel -#define ElfW_Dyn Elf32_Dyn -#define ELFW_R_TYPE ELF32_R_TYPE -#elif __amd64__ -#define ElfW_Rel Elf64_Rel -#define ElfW_Dyn Elf64_Dyn -#define ELFW_R_TYPE ELF64_R_TYPE -#endif - -/* - * A simple relocator for IA32/AMD64 EFI binaries. - */ -EFI_STATUS -_reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle, - EFI_SYSTEM_TABLE *system_table) -{ - unsigned long relsz, relent; - unsigned long *newaddr; - ElfW_Rel *rel; - ElfW_Dyn *dynp; - - /* - * Find the relocation address, its size and the relocation entry. - */ - relsz = 0; - relent = 0; - for (dynp = dynamic; dynp->d_tag != DT_NULL; dynp++) { - switch (dynp->d_tag) { - case DT_REL: - case DT_RELA: - rel = (ElfW_Rel *) ((unsigned long) dynp->d_un.d_ptr + - ImageBase); - break; - case DT_RELSZ: - case DT_RELASZ: - relsz = dynp->d_un.d_val; - break; - case DT_RELENT: - case DT_RELAENT: - relent = dynp->d_un.d_val; - break; - default: - break; - } - } - - /* - * Perform the actual relocation. - * XXX: We are reusing code for the amd64 version of this, but - * we must make sure the relocation types are the same. - */ - CTASSERT(R_386_NONE == R_X86_64_NONE); - CTASSERT(R_386_RELATIVE == R_X86_64_RELATIVE); - for (; relsz > 0; relsz -= relent) { - switch (ELFW_R_TYPE(rel->r_info)) { - case R_386_NONE: - /* No relocation needs be performed. */ - break; - case R_386_RELATIVE: - /* Address relative to the base address. */ - newaddr = (unsigned long *)(ImageBase + rel->r_offset); - *newaddr += ImageBase; - break; - default: - /* XXX: do we need other relocations ? */ - break; - } - rel = (ElfW_Rel *) ((caddr_t) rel + relent); - } - - return (EFI_SUCCESS); -} Index: sys/boot/amd64/efi/start.S =================================================================== --- /dev/null +++ sys/boot/amd64/efi/start.S @@ -1,76 +0,0 @@ -/*- - * Copyright (C) 1999 Hewlett-Packard Co. - * Contributed by David Mosberger . - * Copyright (C) 2005 Intel Co. - * Contributed by Fenghua Yu . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Hewlett-Packard Co. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * crt0-efi-x86_64.S - x86_64 EFI startup code. - * $FreeBSD$ - */ - - .text - .align 4 - - .globl _start -_start: - subq $8, %rsp - pushq %rcx - pushq %rdx - -0: - lea ImageBase(%rip), %rdi - lea _DYNAMIC(%rip), %rsi - - popq %rcx - popq %rdx - pushq %rcx - pushq %rdx - call _reloc - - popq %rdi - popq %rsi - - call efi_main - addq $8, %rsp - -.exit: - ret - - /* - * hand-craft a dummy .reloc section so EFI knows it's a relocatable - * executable: - */ - - .data - .section .reloc, "a" - .long 0 - .long 10 - .word 0 Index: sys/boot/amd64/efi/version =================================================================== --- /dev/null +++ sys/boot/amd64/efi/version @@ -1,7 +0,0 @@ -$FreeBSD$ - -NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this -file is important. Make sure the current version number is on line 6. - -1.1: Keep in sync with i386 version. -0.1: Initial i386 version. Derived from ia64. Index: sys/boot/efi/Makefile =================================================================== --- sys/boot/efi/Makefile +++ sys/boot/efi/Makefile @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= libefi +SUBDIR= libefi loader boot1 .include Index: sys/boot/efi/Makefile.inc =================================================================== --- sys/boot/efi/Makefile.inc +++ sys/boot/efi/Makefile.inc @@ -7,7 +7,10 @@ .endif # Options used when building app-specific efi components +# See conf/kern.mk for the correct set of these CFLAGS+= -ffreestanding -fshort-wchar -Wformat +CFLAGS+= -mno-red-zone +CFLAGS+= -mno-mmx -mno-sse -mno-aes -mno-avx -msoft-float LDFLAGS+= -nostdlib .include "../Makefile.inc" Index: sys/boot/efi/boot1/Makefile =================================================================== --- sys/boot/efi/boot1/Makefile +++ sys/boot/efi/boot1/Makefile @@ -17,19 +17,19 @@ CFLAGS+= -fPIC CFLAGS+= -I. -CFLAGS+= -I${.CURDIR}/../../efi/include -CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH} +CFLAGS+= -I${.CURDIR}/../include +CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH} CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include CFLAGS+= -I${.CURDIR}/../../.. # Always add MI sources and REGULAR efi loader bits -.PATH: ${.CURDIR}/../efi ${.CURDIR}/../../common +.PATH: ${.CURDIR}/../loader/arch/amd64 ${.CURDIR}/../../common CFLAGS+= -I${.CURDIR}/../../common FILES= boot1.efi boot1.efifat FILESMODE_boot1.efi= ${BINMODE} -LDSCRIPT= ${.CURDIR}/../efi/ldscript.${MACHINE_CPUARCH} +LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE_CPUARCH}/ldscript.${MACHINE_CPUARCH} LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc ${PROG}: ${LDSCRIPT} @@ -39,7 +39,7 @@ .if ${MACHINE_CPUARCH} == "amd64" EFI_TARGET= efi-app-x86_64 -.else +.elif ${MACHINE_CPUARCH} == "i386" EFI_TARGET= efi-app-ia32 .endif Index: sys/boot/efi/loader/Makefile =================================================================== --- sys/boot/efi/loader/Makefile +++ sys/boot/efi/loader/Makefile @@ -12,27 +12,24 @@ PROG= loader.sym INTERNALPROG= +.PATH: ${.CURDIR}/../../efi/loader # architecture-specific loader code SRCS= autoload.c \ bootinfo.c \ conf.c \ copy.c \ devicename.c \ - elf64_freebsd.c \ - framebuffer.c \ main.c \ - reloc.c \ vers.c -SRCS+= amd64_tramp.S \ - start.S -.PATH: ${.CURDIR}/../../i386/libi386 -SRCS+= nullconsole.c \ - comconsole.c + +.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH} +.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc" CFLAGS+= -fPIC -CFLAGS+= -I. -CFLAGS+= -I${.CURDIR}/../../efi/include -CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH} +CFLAGS+= -I${.CURDIR} +CFLAGS+= -I${.CURDIR}/arch/${MACHINE_CPUARCH} +CFLAGS+= -I${.CURDIR}/../include +CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH} CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include CFLAGS+= -I${.CURDIR}/../../.. CFLAGS+= -DNO_PCI @@ -60,14 +57,14 @@ FILES= loader.efi FILESMODE_loader.efi= ${BINMODE} -LDSCRIPT= ${.CURDIR}/ldscript.${MACHINE_CPUARCH} +LDSCRIPT= ${.CURDIR}/arch/${MACHINE_CPUARCH}/ldscript.${MACHINE_CPUARCH} LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc CLEANFILES= vers.c loader.efi NEWVERSWHAT= "EFI loader" ${MACHINE_CPUARCH} -vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version +vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/../../efi/loader/version sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT} OBJCOPY?= objcopy @@ -75,7 +72,7 @@ .if ${MACHINE_CPUARCH} == "amd64" EFI_TARGET= efi-app-x86_64 -.else +.elif ${MACHINE_CPUARCH} == "i386" EFI_TARGET= efi-app-ia32 .endif @@ -89,7 +86,7 @@ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} -LIBEFI= ${.OBJDIR}/../../efi/libefi/libefi.a +LIBEFI= ${.OBJDIR}/../libefi/libefi.a DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT} LDADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} Index: sys/boot/efi/loader/arch/amd64/Makefile.inc =================================================================== --- /dev/null +++ sys/boot/efi/loader/arch/amd64/Makefile.inc @@ -0,0 +1,10 @@ + +SRCS+= amd64_tramp.S \ + start.S \ + framebuffer.c \ + elf64_freebsd.c \ + reloc.c + +.PATH: ${.CURDIR}/../../i386/libi386 +SRCS+= nullconsole.c \ + comconsole.c Index: sys/boot/efi/loader/arch/amd64/elf64_freebsd.c =================================================================== --- sys/boot/efi/loader/arch/amd64/elf64_freebsd.c +++ sys/boot/efi/loader/arch/amd64/elf64_freebsd.c @@ -47,7 +47,7 @@ #include "actypes.h" #include "actbl.h" -#include "x86_efi.h" +#include "loader_efi.h" static EFI_GUID acpi_guid = ACPI_TABLE_GUID; static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; @@ -57,8 +57,14 @@ static int elf64_exec(struct preloaded_file *amp); static int elf64_obj_exec(struct preloaded_file *amp); -struct file_format amd64_elf = { elf64_loadfile, elf64_exec }; -struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec }; +static struct file_format amd64_elf = { elf64_loadfile, elf64_exec }; +static struct file_format amd64_elf_obj = { elf64_obj_loadfile, elf64_obj_exec }; + +struct file_format *file_formats[] = { + &amd64_elf, + &amd64_elf_obj, + NULL +}; #define PG_V 0x001 #define PG_RW 0x002 @@ -168,7 +174,7 @@ if (err != 0) return(err); - status = BS->ExitBootServices(IH, x86_efi_mapkey); + status = BS->ExitBootServices(IH, efi_mapkey); if (EFI_ERROR(status)) { printf("%s: ExitBootServices() returned 0x%lx\n", __func__, (long)status); @@ -177,7 +183,7 @@ dev_cleanup(); - trampoline(trampstack, x86_efi_copy_finish, kernend, modulep, PT4, + trampoline(trampstack, efi_copy_finish, kernend, modulep, PT4, ehdr->e_entry); panic("exec returned"); Index: sys/boot/efi/loader/autoload.c =================================================================== --- sys/boot/efi/loader/autoload.c +++ sys/boot/efi/loader/autoload.c @@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$"); int -x86_efi_autoload(void) +efi_autoload(void) { return (0); Index: sys/boot/efi/loader/bootinfo.c =================================================================== --- sys/boot/efi/loader/bootinfo.c +++ sys/boot/efi/loader/bootinfo.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -45,9 +46,9 @@ #include "bootstrap.h" #include "framebuffer.h" -#include "x86_efi.h" +#include "loader_efi.h" -UINTN x86_efi_mapkey; +UINTN efi_mapkey; static const char howto_switches[] = "aCdrgDmphsv"; static int howto_masks[] = { @@ -260,7 +261,7 @@ * one is marked as being loader data. */ sz = 0; - BS->GetMemoryMap(&sz, NULL, &x86_efi_mapkey, &mmsz, &mmver); + BS->GetMemoryMap(&sz, NULL, &efi_mapkey, &mmsz, &mmver); sz += mmsz; sz = (sz + 0xf) & ~0xf; pages = EFI_SIZE_TO_PAGES(sz + efisz); @@ -280,7 +281,7 @@ efihdr = (struct efi_map_header *)addr; mm = (void *)((uint8_t *)efihdr + efisz); sz = (EFI_PAGE_SIZE * pages) - efisz; - status = BS->GetMemoryMap(&sz, mm, &x86_efi_mapkey, &mmsz, &mmver); + status = BS->GetMemoryMap(&sz, mm, &efi_mapkey, &mmsz, &mmver); if (EFI_ERROR(status)) { printf("%s: GetMemoryMap() returned 0x%lx\n", __func__, (long)status); @@ -333,7 +334,7 @@ } /* Try reading the /etc/fstab file to select the root device */ - getrootmount(x86_efi_fmtdev((void *)rootdev)); + getrootmount(efi_fmtdev((void *)rootdev)); addr = 0; for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) { @@ -375,6 +376,6 @@ /* Copy module list and metadata. */ (void)bi_copymodules(addr); - + return (0); } Index: sys/boot/efi/loader/conf.c =================================================================== --- sys/boot/efi/loader/conf.c +++ sys/boot/efi/loader/conf.c @@ -53,15 +53,6 @@ NULL }; -extern struct file_format amd64_elf; -extern struct file_format amd64_elf_obj; - -struct file_format *file_formats[] = { - &amd64_elf, - &amd64_elf_obj, - NULL -}; - extern struct console efi_console; extern struct console comconsole; extern struct console nullconsole; Index: sys/boot/efi/loader/copy.c =================================================================== --- sys/boot/efi/loader/copy.c +++ sys/boot/efi/loader/copy.c @@ -48,7 +48,7 @@ ssize_t stage_offset; int -x86_efi_copy_init(void) +efi_copy_init(void) { EFI_STATUS status; @@ -65,7 +65,7 @@ } ssize_t -x86_efi_copyin(const void *src, vm_offset_t dest, const size_t len) +efi_copyin(const void *src, vm_offset_t dest, const size_t len) { if (!stage_offset_set) { @@ -83,7 +83,7 @@ } ssize_t -x86_efi_copyout(const vm_offset_t src, void *dest, const size_t len) +efi_copyout(const vm_offset_t src, void *dest, const size_t len) { /* XXX: Callers do not check for failure. */ @@ -97,7 +97,7 @@ ssize_t -x86_efi_readin(const int fd, vm_offset_t dest, const size_t len) +efi_readin(const int fd, vm_offset_t dest, const size_t len) { if (dest + stage_offset + len > staging_end) { @@ -108,7 +108,7 @@ } void -x86_efi_copy_finish(void) +efi_copy_finish(void) { uint64_t *src, *dst, *last; Index: sys/boot/efi/loader/devicename.c =================================================================== --- sys/boot/efi/loader/devicename.c +++ sys/boot/efi/loader/devicename.c @@ -36,7 +36,7 @@ #include #include -static int x86_efi_parsedev(struct devdesc **, const char *, const char **); +static int efi_parsedev(struct devdesc **, const char *, const char **); /* * Point (dev) at an allocated device specifier for the device matching the @@ -44,7 +44,7 @@ * use that. If not, use the default device. */ int -x86_efi_getdev(void **vdev, const char *devspec, const char **path) +efi_getdev(void **vdev, const char *devspec, const char **path) { struct devdesc **dev = (struct devdesc **)vdev; int rv; @@ -54,14 +54,14 @@ * use the current device instead. */ if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) { - rv = x86_efi_parsedev(dev, getenv("currdev"), NULL); + rv = efi_parsedev(dev, getenv("currdev"), NULL); if (rv == 0 && path != NULL) *path = devspec; return (rv); } /* Parse the device name off the beginning of the devspec. */ - return (x86_efi_parsedev(dev, devspec, path)); + return (efi_parsedev(dev, devspec, path)); } /* @@ -78,7 +78,7 @@ * fs: */ static int -x86_efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) +efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) { struct devdesc *idev; struct devsw *dv; @@ -132,7 +132,7 @@ } char * -x86_efi_fmtdev(void *vdev) +efi_fmtdev(void *vdev) { struct devdesc *dev = (struct devdesc *)vdev; static char buf[32]; /* XXX device length constant? */ @@ -154,12 +154,12 @@ * Set currdev to suit the value being supplied in (value) */ int -x86_efi_setcurrdev(struct env_var *ev, int flags, const void *value) +efi_setcurrdev(struct env_var *ev, int flags, const void *value) { struct devdesc *ncurr; int rv; - rv = x86_efi_parsedev(&ncurr, value, NULL); + rv = efi_parsedev(&ncurr, value, NULL); if (rv != 0) return(rv); Index: sys/boot/efi/loader/loader_efi.h =================================================================== --- sys/boot/efi/loader/loader_efi.h +++ sys/boot/efi/loader/loader_efi.h @@ -28,22 +28,24 @@ * $FreeBSD$ */ -#ifndef _X86_EFI_COPY_H_ -#define _X86_EFI_COPY_H_ +#ifndef _LOADER_EFI_COPY_H_ +#define _LOADER_EFI_COPY_H_ -int x86_efi_autoload(void); +int efi_autoload(void); -int x86_efi_getdev(void **vdev, const char *devspec, const char **path); -char *x86_efi_fmtdev(void *vdev); -int x86_efi_setcurrdev(struct env_var *ev, int flags, const void *value); +int efi_getdev(void **vdev, const char *devspec, const char **path); +char *efi_fmtdev(void *vdev); +int efi_setcurrdev(struct env_var *ev, int flags, const void *value); -int x86_efi_copy_init(void); -void x86_efi_copy_finish(void); +int efi_copy_init(void); -ssize_t x86_efi_copyin(const void *src, vm_offset_t dest, const size_t len); -ssize_t x86_efi_copyout(const vm_offset_t src, void *dest, const size_t len); -ssize_t x86_efi_readin(const int fd, vm_offset_t dest, const size_t len); +ssize_t efi_copyin(const void *src, vm_offset_t dest, const size_t len); +ssize_t efi_copyout(const vm_offset_t src, void *dest, const size_t len); +ssize_t efi_readin(const int fd, vm_offset_t dest, const size_t len); +void * efi_translate(vm_offset_t ptr); -extern UINTN x86_efi_mapkey; +extern UINTN efi_mapkey; -#endif /* _X86_EFI_COPY_H_ */ +void efi_copy_finish(void); + +#endif /* _LOADER_EFI_COPY_H_ */ Index: sys/boot/efi/loader/main.c =================================================================== --- sys/boot/efi/loader/main.c +++ sys/boot/efi/loader/main.c @@ -36,7 +36,7 @@ #include #include -#include "x86_efi.h" +#include "loader_efi.h" extern char bootprog_name[]; extern char bootprog_rev[]; @@ -73,7 +73,7 @@ */ cons_probe(); - if (x86_efi_copy_init()) { + if (efi_copy_init()) { printf("failed to allocate staging area\n"); return (EFI_BUFFER_TOO_SMALL); } @@ -115,18 +115,18 @@ */ BS->SetWatchdogTimer(0, 0, 0, NULL); - env_setenv("currdev", EV_VOLATILE, x86_efi_fmtdev(&currdev), - x86_efi_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, x86_efi_fmtdev(&currdev), env_noset, + env_setenv("currdev", EV_VOLATILE, efi_fmtdev(&currdev), + efi_setcurrdev, env_nounset); + env_setenv("loaddev", EV_VOLATILE, efi_fmtdev(&currdev), env_noset, env_nounset); setenv("LINES", "24", 1); /* optional */ - archsw.arch_autoload = x86_efi_autoload; - archsw.arch_getdev = x86_efi_getdev; - archsw.arch_copyin = x86_efi_copyin; - archsw.arch_copyout = x86_efi_copyout; - archsw.arch_readin = x86_efi_readin; + archsw.arch_autoload = efi_autoload; + archsw.arch_getdev = efi_getdev; + archsw.arch_copyin = efi_copyin; + archsw.arch_copyout = efi_copyout; + archsw.arch_readin = efi_readin; interact(NULL); /* doesn't return */