From owner-svn-src-all@freebsd.org Tue Jan 26 10:29:08 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 386ACA6E60D for ; Tue, 26 Jan 2016 10:29:08 +0000 (UTC) (envelope-from steven.hartland@multiplay.co.uk) Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CB67B1A18 for ; Tue, 26 Jan 2016 10:29:07 +0000 (UTC) (envelope-from steven.hartland@multiplay.co.uk) Received: by mail-wm0-x233.google.com with SMTP id r129so98019307wmr.0 for ; Tue, 26 Jan 2016 02:29:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=multiplay-co-uk.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=GcASHzqCVTaO/N5UPAwhEVB3hzeZzAN3xdJKdmKvzDc=; b=Y/fJ0ar4Z1UlPCe7e9OGfopvtcYJNLtqyomkHpa16t8YgpbEDuvqSC8dCuRcWIn4It WdAdGh9FOgtPS2eFV//9NGLU3oVgk3RTNKDQ2qVe32E3jou2NECA2Qn1zksRyGtcKvnW 1Mhr++XnlG3DD14g37mwFDKh4lafpKUWxV5/Etp1HhXO/3O5jV9svOFg0gdvjJqS5LT9 QH0reMdUTVY5FdLcUOmICNGJj4/udB2/aMSrYTyge4vVCQUXajU4GitakEX5pzUUvUN2 jheM9WubzJMYzUv9Cx87kPZJHkzQ5FJG5vOSEb7YpY6RghpOyu01hniJLvXxYPrxAyr5 qaBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=GcASHzqCVTaO/N5UPAwhEVB3hzeZzAN3xdJKdmKvzDc=; b=HjNS1yUuiMqApuWMZDrCDoGPtuBz4Aic5Qyu7RRkWh79wPbSbwt5xaO0vUvK7FYYoW PrSnuPM+DhCzpeCTiqbz0nJBPlus5V6Y4EPbhEKysgNuCN/Dna1BkNfpzvzZJ7/0KG9/ X0YAw9EIPcRVgt2UqWB5YilkWdmutCgoLiGRhfz1Vcebh5BY7Z9S1DRYGmKbvZ8rtqse tZP3CJbUN7Y77yg6jPOCRLMUMX9hlWMB6K2KdUZGCURNPCnCRCnFeAwpuvYNEhpkNDY0 sD74TvFFf6irbcawfmiXHA8nl/LLc5JCRKDQLC5fmXy+FnPo44e8BIqk3emvAk0u6f9n DyEA== X-Gm-Message-State: AG10YOQFarPr2kgRkFdJwoLMUYHl/jWCtgiq5MNNgp+Inz37+vkan4u5VZckMMDGaVxqel9O X-Received: by 10.194.117.134 with SMTP id ke6mr25465666wjb.94.1453804145881; Tue, 26 Jan 2016 02:29:05 -0800 (PST) Received: from [10.10.1.58] (liv3d.labs.multiplay.co.uk. [82.69.141.171]) by smtp.gmail.com with ESMTPSA id s2sm730623wjs.43.2016.01.26.02.29.04 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jan 2016 02:29:04 -0800 (PST) Subject: Re: svn commit: r294767 - head/sys/boot/efi/loader To: Warner Losh , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201601260626.u0Q6QkIk003440@repo.freebsd.org> From: Steven Hartland Message-ID: <56A74A7D.8010903@multiplay.co.uk> Date: Tue, 26 Jan 2016 10:29:17 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <201601260626.u0Q6QkIk003440@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2016 10:29:08 -0000 No plan to MFC these changes? On 26/01/2016 06:26, Warner Losh wrote: > Author: imp > Date: Tue Jan 26 06:26:46 2016 > New Revision: 294767 > URL: https://svnweb.freebsd.org/changeset/base/294767 > > Log: > Parse the command line arguments, and do it before we initialize the > console so it can be changed by the command line arguments. > > Differential Revision: https://reviews.freebsd.org/D5038 > > Modified: > head/sys/boot/efi/loader/main.c > > Modified: head/sys/boot/efi/loader/main.c > ============================================================================== > --- head/sys/boot/efi/loader/main.c Tue Jan 26 06:26:44 2016 (r294766) > +++ head/sys/boot/efi/loader/main.c Tue Jan 26 06:26:46 2016 (r294767) > @@ -29,6 +29,8 @@ > __FBSDID("$FreeBSD$"); > > #include > +#include > +#include > #include > #include > #include > @@ -83,13 +85,22 @@ print_str16(const CHAR16 *str) > printf("%c", (char)str[i]); > } > > +static void > +cp16to8(const CHAR16 *src, char *dst, size_t len) > +{ > + size_t i; > + > + for (i = 0; i < len && src[i]; i++) > + dst[i] = (char)src[i]; > +} > + > EFI_STATUS > main(int argc, CHAR16 *argv[]) > { > char var[128]; > EFI_LOADED_IMAGE *img; > EFI_GUID *guid; > - int i, j, vargood, unit; > + int i, j, vargood, unit, howto; > struct devsw *dev; > uint64_t pool_guid; > UINTN k; > @@ -113,27 +124,97 @@ main(int argc, CHAR16 *argv[]) > cons_probe(); > > /* > + * Parse the args to set the console settings, etc > + * boot1.efi passes these in, if it can read /boot.config or /boot/config > + * or iPXE may be setup to pass these in. > + * > * Loop through the args, and for each one that contains an '=' that is > * not the first character, add it to the environment. This allows > * loader and kernel env vars to be passed on the command line. Convert > * args from UCS-2 to ASCII (16 to 8 bit) as they are copied. > */ > + howto = 0; > for (i = 1; i < argc; i++) { > - vargood = 0; > - for (j = 0; argv[i][j] != 0; j++) { > - if (j == sizeof(var)) { > - vargood = 0; > - break; > + 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 'm': > + howto |= RB_MUTE; > + 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 'S': > + if (argv[i][j + 1] == 0) { > + if (i + 1 == argc) { > + setenv("comconsole_speed", "115200", 1); > + } else { > + cp16to8(&argv[i + 1][0], var, > + sizeof(var)); > + setenv("comconsole_speedspeed", var, 1); > + } > + i++; > + break; > + } else { > + cp16to8(&argv[i][j + 1], var, > + sizeof(var)); > + setenv("comconsole_speed", var, 1); > + break; > + } > + case 'v': > + howto |= RB_VERBOSE; > + break; > + } > + } > + } else { > + vargood = 0; > + for (j = 0; argv[i][j] != 0; j++) { > + if (j == sizeof(var)) { > + vargood = 0; > + break; > + } > + if (j > 0 && argv[i][j] == '=') > + vargood = 1; > + var[j] = (char)argv[i][j]; > + } > + if (vargood) { > + var[j] = 0; > + putenv(var); > } > - if (j > 0 && argv[i][j] == '=') > - vargood = 1; > - var[j] = (char)argv[i][j]; > - } > - if (vargood) { > - var[j] = 0; > - putenv(var); > } > } > + for (i = 0; howto_names[i].ev != NULL; i++) > + if (howto & howto_names[i].mask) > + setenv(howto_names[i].ev, "YES", 1); > + if (howto & RB_MULTIPLE) { > + if (howto & RB_SERIAL) > + setenv("console", "comconsole efi" , 1); > + else > + setenv("console", "efi comconsole" , 1); > + } else if (howto & RB_SERIAL) { > + setenv("console", "comconsole" , 1); > + } > > if (efi_copy_init()) { > printf("failed to allocate staging area\n"); >