From owner-svn-src-projects@FreeBSD.ORG Thu Feb 28 04:43:47 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3E44258E; Thu, 28 Feb 2013 04:43:47 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 305F797F; Thu, 28 Feb 2013 04:43:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1S4hlQX045749; Thu, 28 Feb 2013 04:43:47 GMT (envelope-from benno@svn.freebsd.org) Received: (from benno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1S4hjOk045734; Thu, 28 Feb 2013 04:43:45 GMT (envelope-from benno@svn.freebsd.org) Message-Id: <201302280443.r1S4hjOk045734@svn.freebsd.org> From: Benno Rice Date: Thu, 28 Feb 2013 04:43:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r247444 - projects/uefi/sys/boot/i386/efi X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2013 04:43:47 -0000 Author: benno Date: Thu Feb 28 04:43:44 2013 New Revision: 247444 URL: http://svnweb.freebsd.org/changeset/base/247444 Log: Remove usage of i386_ prefixes and unneeded references to libi386. Added: projects/uefi/sys/boot/i386/efi/copy.c - copied unchanged from r247443, projects/uefi/sys/boot/i386/efi/x86_efi_copy.c projects/uefi/sys/boot/i386/efi/x86_efi.h - copied, changed from r247443, projects/uefi/sys/boot/i386/efi/x86_efi_copy.h Deleted: projects/uefi/sys/boot/i386/efi/x86_efi_copy.c projects/uefi/sys/boot/i386/efi/x86_efi_copy.h Modified: projects/uefi/sys/boot/i386/efi/Makefile projects/uefi/sys/boot/i386/efi/autoload.c projects/uefi/sys/boot/i386/efi/bootinfo.c projects/uefi/sys/boot/i386/efi/bootinfo64.c projects/uefi/sys/boot/i386/efi/devicename.c projects/uefi/sys/boot/i386/efi/elf64_freebsd.c projects/uefi/sys/boot/i386/efi/main.c Modified: projects/uefi/sys/boot/i386/efi/Makefile ============================================================================== --- projects/uefi/sys/boot/i386/efi/Makefile Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/Makefile Thu Feb 28 04:43:44 2013 (r247444) @@ -11,7 +11,7 @@ INTERNALPROG= # architecture-specific loader code SRCS= main.c conf.c vers.c reloc.c elf64_freebsd.c -SRCS+= x86_efi_copy.c bootinfo.c bootinfo64.c autoload.c devicename.c efimd.c +SRCS+= copy.c bootinfo.c bootinfo64.c autoload.c devicename.c efimd.c SRCS+= efifb.c amd64_tramp.S start.S CFLAGS+= -fPIC Modified: projects/uefi/sys/boot/i386/efi/autoload.c ============================================================================== --- projects/uefi/sys/boot/i386/efi/autoload.c Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/autoload.c Thu Feb 28 04:43:44 2013 (r247444) @@ -28,7 +28,7 @@ __FBSDID("$FreeBSD$"); int -i386_autoload(void) +x86_efi_autoload(void) { return (0); Modified: projects/uefi/sys/boot/i386/efi/bootinfo.c ============================================================================== --- projects/uefi/sys/boot/i386/efi/bootinfo.c Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/bootinfo.c Thu Feb 28 04:43:44 2013 (r247444) @@ -38,9 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include "bootstrap.h" -#include "libi386.h" - -#include "x86_efi_copy.h" +#include "x86_efi.h" /* * Return a 'boothowto' value corresponding to the kernel arguments in Modified: projects/uefi/sys/boot/i386/efi/bootinfo64.c ============================================================================== --- projects/uefi/sys/boot/i386/efi/bootinfo64.c Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/bootinfo64.c Thu Feb 28 04:43:44 2013 (r247444) @@ -35,8 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include "bootstrap.h" -#include "libi386.h" -#include "x86_efi_copy.h" +#include "x86_efi.h" /* * Copy module-related data into the load area, where it can be @@ -140,7 +139,7 @@ int bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernendp) { struct preloaded_file *xp, *kfp; - struct i386_devdesc *rootdev; + struct devdesc *rootdev; struct file_metadata *md; vm_offset_t addr; u_int64_t kernend; @@ -157,14 +156,14 @@ bi_load64(char *args, vm_offset_t *modul * MI code before launching the kernel. */ rootdevname = getenv("rootdev"); - i386_getdev((void **)(&rootdev), rootdevname, NULL); + x86_efi_getdev((void **)(&rootdev), rootdevname, NULL); if (rootdev == NULL) { /* bad $rootdev/$currdev */ printf("can't determine root device\n"); return(EINVAL); } /* Try reading the /etc/fstab file to select the root device */ - getrootmount(i386_fmtdev((void *)rootdev)); + getrootmount(x86_efi_fmtdev((void *)rootdev)); /* find the last module in the chain */ addr = 0; Copied: projects/uefi/sys/boot/i386/efi/copy.c (from r247443, projects/uefi/sys/boot/i386/efi/x86_efi_copy.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/uefi/sys/boot/i386/efi/copy.c Thu Feb 28 04:43:44 2013 (r247444, copy of r247443, projects/uefi/sys/boot/i386/efi/x86_efi_copy.c) @@ -0,0 +1,102 @@ +/*- + * 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 +#include + +#define STAGE_PAGES 8192 /* 32MB */ + +EFI_PHYSICAL_ADDRESS staging; +int stage_offset_set = 0; +ssize_t stage_offset; + +int +x86_efi_copy_init(void) +{ + EFI_STATUS status; + + status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData, + STAGE_PAGES, &staging); + if (EFI_ERROR(status)) { + printf("failed to allocate staging area: %d\n", + status & EFI_ERROR_MASK); + return (status); + } + + return (0); +} + +ssize_t +x86_efi_copyin(const void *src, vm_offset_t dest, const size_t len) +{ + + if (!stage_offset_set) { + stage_offset = (vm_offset_t)staging - dest; + stage_offset_set = 1; + } + + bcopy(src, (void *)(dest + stage_offset), len); + return (len); +} + +ssize_t +x86_efi_copyout(const vm_offset_t src, void *dest, const size_t len) +{ + + bcopy((void *)(src + stage_offset), dest, len); + return (len); +} + + +ssize_t +x86_efi_readin(const int fd, vm_offset_t dest, const size_t len) +{ + + return (read(fd, (void *)(dest + stage_offset), len)); +} + +void +x86_efi_copy_finish(void) +{ + uint64_t *src, *dst, *last; + + src = (uint64_t *)staging; + dst = (uint64_t *)(staging - stage_offset); + last = (uint64_t *)(staging + STAGE_PAGES * EFI_PAGE_SIZE); + + while (src < last) + *dst++ = *src++; +} Modified: projects/uefi/sys/boot/i386/efi/devicename.c ============================================================================== --- projects/uefi/sys/boot/i386/efi/devicename.c Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/devicename.c Thu Feb 28 04:43:44 2013 (r247444) @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include -static int i386_parsedev(struct devdesc **, const char *, const char **); +static int x86_efi_parsedev(struct devdesc **, const char *, const char **); /* * Point (dev) at an allocated device specifier for the device matching the @@ -44,7 +44,7 @@ static int i386_parsedev(struct devdesc * use that. If not, use the default device. */ int -i386_getdev(void **vdev, const char *devspec, const char **path) +x86_efi_getdev(void **vdev, const char *devspec, const char **path) { struct devdesc **dev = (struct devdesc **)vdev; int rv; @@ -54,14 +54,14 @@ i386_getdev(void **vdev, const char *dev * use the current device instead. */ if (devspec == NULL || *devspec == '/' || !strchr(devspec, ':')) { - rv = i386_parsedev(dev, getenv("currdev"), NULL); + rv = x86_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 (i386_parsedev(dev, devspec, path)); + return (x86_efi_parsedev(dev, devspec, path)); } /* @@ -78,7 +78,7 @@ i386_getdev(void **vdev, const char *dev * fs: */ static int -i386_parsedev(struct devdesc **dev, const char *devspec, const char **path) +x86_efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) { struct devdesc *idev; struct devsw *dv; @@ -132,7 +132,7 @@ i386_parsedev(struct devdesc **dev, cons } char * -i386_fmtdev(void *vdev) +x86_efi_fmtdev(void *vdev) { struct devdesc *dev = (struct devdesc *)vdev; static char buf[32]; /* XXX device length constant? */ @@ -154,12 +154,12 @@ i386_fmtdev(void *vdev) * Set currdev to suit the value being supplied in (value) */ int -i386_setcurrdev(struct env_var *ev, int flags, const void *value) +x86_efi_setcurrdev(struct env_var *ev, int flags, const void *value) { struct devdesc *ncurr; int rv; - rv = i386_parsedev(&ncurr, value, NULL); + rv = x86_efi_parsedev(&ncurr, value, NULL); if (rv != 0) return(rv); Modified: projects/uefi/sys/boot/i386/efi/elf64_freebsd.c ============================================================================== --- projects/uefi/sys/boot/i386/efi/elf64_freebsd.c Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/elf64_freebsd.c Thu Feb 28 04:43:44 2013 (r247444) @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include "actypes.h" #include "actbl.h" -#include "x86_efi_copy.h" +#include "x86_efi.h" static EFI_GUID acpi_guid = ACPI_TABLE_GUID; static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; Modified: projects/uefi/sys/boot/i386/efi/main.c ============================================================================== --- projects/uefi/sys/boot/i386/efi/main.c Thu Feb 28 04:16:47 2013 (r247443) +++ projects/uefi/sys/boot/i386/efi/main.c Thu Feb 28 04:43:44 2013 (r247444) @@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include "../libi386/libi386.h" - -#include "x86_efi_copy.h" +#include "x86_efi.h" extern char bootprog_name[]; extern char bootprog_rev[]; @@ -113,15 +111,15 @@ main(int argc, CHAR16 *argv[]) */ BS->SetWatchdogTimer(0, 0, 0, NULL); - env_setenv("currdev", EV_VOLATILE, i386_fmtdev(&currdev), - i386_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, i386_fmtdev(&currdev), env_noset, + 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_nounset); setenv("LINES", "24", 1); /* optional */ - archsw.arch_autoload = i386_autoload; - archsw.arch_getdev = i386_getdev; + 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; Copied and modified: projects/uefi/sys/boot/i386/efi/x86_efi.h (from r247443, projects/uefi/sys/boot/i386/efi/x86_efi_copy.h) ============================================================================== --- projects/uefi/sys/boot/i386/efi/x86_efi_copy.h Thu Feb 28 04:16:47 2013 (r247443, copy source) +++ projects/uefi/sys/boot/i386/efi/x86_efi.h Thu Feb 28 04:43:44 2013 (r247444) @@ -31,6 +31,12 @@ #ifndef _X86_EFI_COPY_H_ #define _X86_EFI_COPY_H_ +int x86_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 x86_efi_copy_init(void); void x86_efi_copy_finish(void);