Re: svn commit: r294767 - head/sys/boot/efi/loader

2016-01-26 Thread Steven Hartland

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([i + 
1][0], var,
+   sizeof(var));
+   
setenv("comconsole_speedspeed", var, 1);
+   }
+   i++;
+   break;
+   } else {
+   cp16to8([i][j + 1], var,
+   sizeof(var));
+   setenv("comconsole_speed", var, 
1);
+   break;
+   }
+   case 'v':
+   howto |= RB_VERBOSE;
+   break;
+ 

Re: svn commit: r294767 - head/sys/boot/efi/loader

2016-01-26 Thread Warner Losh
Just forgot to add Mac after 1week. But with all the churn here, predicting 
when may be tough.

Warner

On January 26, 2016, at 3:29 AM, Steven Hartland 
 wrote:

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([i + 
> 1][0], var,
> + sizeof(var));
> + 
> setenv("comconsole_speedspeed", var, 1);
> + }
> + i++;
> + break;
> + } else {
> + cp16to8([i][j + 1], var,
> + sizeof(var));
> + setenv("comconsole_speed", 

svn commit: r294767 - head/sys/boot/efi/loader

2016-01-25 Thread Warner Losh
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([i + 
1][0], var,
+   sizeof(var));
+   
setenv("comconsole_speedspeed", var, 1);
+   }
+   i++;
+   break;
+   } else {
+   cp16to8([i][j + 1], var,
+   sizeof(var));
+   setenv("comconsole_speed", var, 
1);
+   break;
+   }
+   case 'v':
+   howto |= RB_VERBOSE;
+   break;
+   }
+   }
+   } else {
+   vargood =