From owner-svn-src-projects@FreeBSD.ORG Thu Feb 28 10:48:29 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CFD84158; Thu, 28 Feb 2013 10:48:29 +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 C1B9B1AAA; Thu, 28 Feb 2013 10:48:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1SAmT7O055224; Thu, 28 Feb 2013 10:48:29 GMT (envelope-from benno@svn.freebsd.org) Received: (from benno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1SAmTog055222; Thu, 28 Feb 2013 10:48:29 GMT (envelope-from benno@svn.freebsd.org) Message-Id: <201302281048.r1SAmTog055222@svn.freebsd.org> From: Benno Rice Date: Thu, 28 Feb 2013 10:48:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r247455 - projects/uefi/sys/boot/amd64/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 10:48:29 -0000 Author: benno Date: Thu Feb 28 10:48:29 2013 New Revision: 247455 URL: http://svnweb.freebsd.org/changeset/base/247455 Log: Merge bootinfo.c into bootinfo64.c Deleted: projects/uefi/sys/boot/amd64/efi/bootinfo.c Modified: projects/uefi/sys/boot/amd64/efi/Makefile projects/uefi/sys/boot/amd64/efi/bootinfo64.c Modified: projects/uefi/sys/boot/amd64/efi/Makefile ============================================================================== --- projects/uefi/sys/boot/amd64/efi/Makefile Thu Feb 28 10:46:54 2013 (r247454) +++ projects/uefi/sys/boot/amd64/efi/Makefile Thu Feb 28 10:48:29 2013 (r247455) @@ -11,7 +11,7 @@ INTERNALPROG= # architecture-specific loader code SRCS= main.c conf.c vers.c reloc.c elf64_freebsd.c -SRCS+= copy.c bootinfo.c bootinfo64.c autoload.c devicename.c efimd.c +SRCS+= copy.c bootinfo64.c autoload.c devicename.c efimd.c SRCS+= framebuffer.c amd64_tramp.S start.S CFLAGS+= -fPIC Modified: projects/uefi/sys/boot/amd64/efi/bootinfo64.c ============================================================================== --- projects/uefi/sys/boot/amd64/efi/bootinfo64.c Thu Feb 28 10:46:54 2013 (r247454) +++ projects/uefi/sys/boot/amd64/efi/bootinfo64.c Thu Feb 28 10:48:29 2013 (r247455) @@ -28,16 +28,122 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include #include #include #include + +#include +#include + #include "bootstrap.h" #include "x86_efi.h" /* + * Return a 'boothowto' value corresponding to the kernel arguments in + * (kargs) and any relevant environment variables. + */ +static struct +{ + const char *ev; + int mask; +} howto_names[] = { + { "boot_askname", RB_ASKNAME}, + { "boot_cdrom", RB_CDROM}, + { "boot_ddb", RB_KDB}, + { "boot_dfltroot", RB_DFLTROOT}, + { "boot_gdb", RB_GDB}, + { "boot_multicons", RB_MULTIPLE}, + { "boot_mute", RB_MUTE}, + { "boot_pause", RB_PAUSE}, + { "boot_serial", RB_SERIAL}, + { "boot_single", RB_SINGLE}, + { "boot_verbose", RB_VERBOSE}, + { NULL, 0} +}; + +static const char howto_switches[] = "aCdrgDmphsv"; +static int howto_masks[] = { + RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE, + RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE +}; + +static int +bi_getboothowto(char *kargs) +{ + const char *sw; + char *opts; + int howto, i; + + howto = 0; + + /* Get the boot options from the environment first. */ + for (i = 0; howto_names[i].ev != NULL; i++) { + if (getenv(howto_names[i].ev) != NULL) + howto |= howto_names[i].mask; + } + + /* Parse kargs */ + if (kargs == NULL) + return (howto); + + opts = strchr(kargs, '-'); + while (opts != NULL) { + while (*(++opts) != '\0') { + sw = strchr(howto_switches, *opts); + if (sw == NULL) + break; + howto |= howto_masks[sw - howto_switches]; + } + opts = strchr(opts, '-'); + } + + return (howto); +} + +/* + * Copy the environment into the load area starting at (addr). + * Each variable is formatted as =, with a single nul + * separating each variable, and a double nul terminating the environment. + */ +static vm_offset_t +bi_copyenv(vm_offset_t start) +{ + struct env_var *ep; + vm_offset_t addr, last; + size_t len; + + addr = last = start; + + /* Traverse the environment. */ + for (ep = environ; ep != NULL; ep = ep->ev_next) { + len = strlen(ep->ev_name); + if (x86_efi_copyin(ep->ev_name, addr, len) != len) + break; + addr += len; + if (x86_efi_copyin("=", addr, 1) != 1) + break; + addr++; + if (ep->ev_value != NULL) { + len = strlen(ep->ev_value); + if (x86_efi_copyin(ep->ev_value, addr, len) != len) + break; + addr += len; + } + if (x86_efi_copyin("", addr, 1) != 1) + break; + last = ++addr; + } + + if (x86_efi_copyin("", last++, 1) != 1) + last = start; + return(last); +} + +/* * Copy module-related data into the load area, where it can be * used as a directory for loaded modules. *