From owner-svn-src-head@freebsd.org Fri Jul 13 16:43:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3F74104381B; Fri, 13 Jul 2018 16:43:27 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D26B78E339; Fri, 13 Jul 2018 16:43:25 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE4E112D06; Fri, 13 Jul 2018 16:43:24 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6DGhOPL088961; Fri, 13 Jul 2018 16:43:24 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6DGhNeq088956; Fri, 13 Jul 2018 16:43:23 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201807131643.w6DGhNeq088956@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 13 Jul 2018 16:43:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336246 - in head/stand: common efi/loader i386/libi386 userboot/userboot X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head/stand: common efi/loader i386/libi386 userboot/userboot X-SVN-Commit-Revision: 336246 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2018 16:43:28 -0000 Author: imp Date: Fri Jul 13 16:43:23 2018 New Revision: 336246 URL: https://svnweb.freebsd.org/changeset/base/336246 Log: Eliminate boot loader copies of boot arg parsing. Eliminate 4 of the copies of the arg parsing in /boot/laoder by using boot_parse_cmdline. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D16205 Modified: head/stand/common/metadata.c head/stand/efi/loader/main.c head/stand/i386/libi386/bootinfo.c head/stand/userboot/userboot/bootinfo.c Modified: head/stand/common/metadata.c ============================================================================== --- head/stand/common/metadata.c Fri Jul 13 16:43:17 2018 (r336245) +++ head/stand/common/metadata.c Fri Jul 13 16:43:23 2018 (r336246) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #if defined(LOADER_FDT_SUPPORT) #include @@ -96,61 +97,10 @@ md_bootserial(void) static int md_getboothowto(char *kargs) { - char *cp; int howto; - int active; /* Parse kargs */ - howto = 0; - if (kargs != NULL) { - cp = kargs; - active = 0; - while (*cp != 0) { - if (!active && (*cp == '-')) { - active = 1; - } else if (active) - switch (*cp) { - case 'a': - howto |= RB_ASKNAME; - break; - case 'C': - howto |= RB_CDROM; - break; - case 'd': - howto |= RB_KDB; - break; - case 'D': - howto |= RB_MULTIPLE; - break; - case 'm': - howto |= RB_MUTE; - break; - case 'g': - howto |= RB_GDB; - break; - case 'h': - howto |= RB_SERIAL; - break; - case 'p': - howto |= RB_PAUSE; - break; - case 'r': - howto |= RB_DFLTROOT; - break; - case 's': - howto |= RB_SINGLE; - break; - case 'v': - howto |= RB_VERBOSE; - break; - default: - active = 0; - break; - } - cp++; - } - } - + howto = boot_parse_cmdline(kargs); howto |= bootenv_flags(); #if defined(__sparc64__) if (md_bootserial() != -1) Modified: head/stand/efi/loader/main.c ============================================================================== --- head/stand/efi/loader/main.c Fri Jul 13 16:43:17 2018 (r336245) +++ head/stand/efi/loader/main.c Fri Jul 13 16:43:23 2018 (r336246) @@ -420,79 +420,10 @@ parse_args(int argc, CHAR16 *argv[], bool has_kbd) */ howto = 0; for (i = 1; i < argc; i++) { - if (argv[i][0] == '-') { - for (j = 1; argv[i][j] != 0; j++) { - int ch; - - ch = argv[i][j]; - switch (ch) { - case 'a': - howto |= RB_ASKNAME; - break; - case 'd': - howto |= RB_KDB; - break; - case 'D': - howto |= RB_MULTIPLE; - break; - case 'h': - howto |= RB_SERIAL; - break; - case 'm': - howto |= RB_MUTE; - break; - case 'p': - howto |= RB_PAUSE; - break; - case 'P': - if (!has_kbd) - howto |= RB_SERIAL | RB_MULTIPLE; - break; - case 'r': - howto |= RB_DFLTROOT; - break; - case 's': - howto |= RB_SINGLE; - break; - case 'S': - if (argv[i][j + 1] == 0) { - if (i + 1 == argc) { - setenv("comconsole_speed", "115200", 1); - } else { - cpy16to8(&argv[i + 1][0], var, - sizeof(var)); - setenv("comconsole_speed", var, 1); - } - i++; - break; - } else { - cpy16to8(&argv[i][j + 1], var, - sizeof(var)); - setenv("comconsole_speed", var, 1); - break; - } - case 'v': - howto |= RB_VERBOSE; - break; - } - } - } else { - vargood = false; - for (j = 0; argv[i][j] != 0; j++) { - if (j == sizeof(var)) { - vargood = false; - break; - } - if (j > 0 && argv[i][j] == '=') - vargood = true; - var[j] = (char)argv[i][j]; - } - if (vargood) { - var[j] = 0; - putenv(var); - } - } + cpy16to8(argv[i], var, sizeof(var)); + howto |= boot_parse_arg(var); } + return (howto); } Modified: head/stand/i386/libi386/bootinfo.c ============================================================================== --- head/stand/i386/libi386/bootinfo.c Fri Jul 13 16:43:17 2018 (r336245) +++ head/stand/i386/libi386/bootinfo.c Fri Jul 13 16:43:23 2018 (r336246) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "bootstrap.h" #include "libi386.h" @@ -38,62 +39,11 @@ __FBSDID("$FreeBSD$"); int bi_getboothowto(char *kargs) { - char *cp; char *curpos, *next, *string; int howto; - int active; int vidconsole; - /* Parse kargs */ - howto = 0; - if (kargs != NULL) { - cp = kargs; - active = 0; - while (*cp != 0) { - if (!active && (*cp == '-')) { - active = 1; - } else if (active) - switch (*cp) { - case 'a': - howto |= RB_ASKNAME; - break; - case 'C': - howto |= RB_CDROM; - break; - case 'd': - howto |= RB_KDB; - break; - case 'D': - howto |= RB_MULTIPLE; - break; - case 'm': - howto |= RB_MUTE; - break; - case 'g': - howto |= RB_GDB; - break; - case 'h': - howto |= RB_SERIAL; - break; - case 'p': - howto |= RB_PAUSE; - break; - case 'r': - howto |= RB_DFLTROOT; - break; - case 's': - howto |= RB_SINGLE; - break; - case 'v': - howto |= RB_VERBOSE; - break; - default: - active = 0; - break; - } - cp++; - } - } + howto = boot_parse_cmdline(kargs); howto |= bootenv_flags(); /* Enable selected consoles */ Modified: head/stand/userboot/userboot/bootinfo.c ============================================================================== --- head/stand/userboot/userboot/bootinfo.c Fri Jul 13 16:43:17 2018 (r336245) +++ head/stand/userboot/userboot/bootinfo.c Fri Jul 13 16:43:23 2018 (r336246) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "bootstrap.h" @@ -38,63 +39,11 @@ __FBSDID("$FreeBSD$"); int bi_getboothowto(char *kargs) { - char *cp; char *curpos, *next, *string; int howto; - int active; int vidconsole; - /* Parse kargs */ - howto = 0; - if (kargs != NULL) { - cp = kargs; - active = 0; - while (*cp != 0) { - if (!active && (*cp == '-')) { - active = 1; - } else if (active) - switch (*cp) { - case 'a': - howto |= RB_ASKNAME; - break; - case 'C': - howto |= RB_CDROM; - break; - case 'd': - howto |= RB_KDB; - break; - case 'D': - howto |= RB_MULTIPLE; - break; - case 'm': - howto |= RB_MUTE; - break; - case 'g': - howto |= RB_GDB; - break; - case 'h': - howto |= RB_SERIAL; - break; - case 'p': - howto |= RB_PAUSE; - break; - case 'r': - howto |= RB_DFLTROOT; - break; - case 's': - howto |= RB_SINGLE; - break; - case 'v': - howto |= RB_VERBOSE; - break; - default: - active = 0; - break; - } - cp++; - } - } - + howto = boot_parse_cmdline(kargs); howto |= bootenv_flags(); /* Enable selected consoles */ @@ -117,7 +66,8 @@ bi_getboothowto(char *kargs) /* * XXX: Note that until the kernel is ready to respect multiple consoles - * for the boot messages, the first named console is the primary console + * for the messages from /etc/rc, the first named console is the primary + * console */ if (!strcmp(string, "vidconsole")) howto &= ~RB_SERIAL;