Author: ian
Date: Mon Dec  3 04:07:18 2018
New Revision: 341421
URL: https://svnweb.freebsd.org/changeset/base/341421

Log:
  MFC r341071, r341160
  
  r341071:
  Restore the ability to override the disk unit/partition at the boot: prompt
  in gptboot.
  
  When arch-independent geli support was added, a new static 'gdsk' struct
  was added, but there was still a static 'dsk' struct, and when you typed
  in an alternate disk/partition, the string was parsed into that struct,
  which was then never used for anything.  Now the string gets parsed into
  gdsk.dsk, the struct that's actually used.
  
  r341160:
  Add comments describing the bootargs handoff between loader(8) and gptboot
  or zfsboot, when loader(8) is the BTX loader.  No functional changes.

Modified:
  stable/12/stand/i386/common/bootargs.h
  stable/12/stand/i386/gptboot/gptboot.c
  stable/12/stand/i386/zfsboot/zfsboot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/i386/common/bootargs.h
==============================================================================
--- stable/12/stand/i386/common/bootargs.h      Mon Dec  3 03:58:30 2018        
(r341420)
+++ stable/12/stand/i386/common/bootargs.h      Mon Dec  3 04:07:18 2018        
(r341421)
@@ -43,6 +43,24 @@
 
 #ifndef __ASSEMBLER__
 
+/*
+ * This struct describes the contents of the stack on entry to btxldr.S.  This
+ * is the data that follows the return address, so it begins at 4(%esp).  On
+ * the sending side, this data is passed as individual args to __exec().  On 
the
+ * receiving side, code in btxldr.S copies the data from the entry stack to a
+ * known fixed location in the new address space.  Then, btxcsu.S sets the
+ * global variable __args to point to that known fixed location before calling
+ * main(), which casts __args to a struct bootargs pointer to access the data.
+ * The btxldr.S code is aware of KARGS_FLAGS_EXTARG, and if it's set, the extra
+ * args data is copied along with the other bootargs from the entry stack to 
the
+ * fixed location in the new address space.
+ *
+ * The bootinfo field is actually a pointer to a bootinfo struct that has been
+ * converted to uint32_t using VTOP().  On the receiving side it must be
+ * converted back to a pointer using PTOV().  Code in btxldr.S is aware of this
+ * field and if it's non-NULL it copies the data it points to into another 
known
+ * fixed location, and adjusts the bootinfo field to point to that new 
location.
+ */
 struct bootargs
 {
        uint32_t                        howto;

Modified: stable/12/stand/i386/gptboot/gptboot.c
==============================================================================
--- stable/12/stand/i386/gptboot/gptboot.c      Mon Dec  3 03:58:30 2018        
(r341420)
+++ stable/12/stand/i386/gptboot/gptboot.c      Mon Dec  3 04:07:18 2018        
(r341421)
@@ -81,7 +81,6 @@ uint32_t opts;
 static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
 
-static struct dsk dsk;
 static char kname[1024];
 static int comspeed = SIOSPD;
 static struct bootinfo bootinfo;
@@ -488,6 +487,12 @@ load(void)
        geliargs.keybuf_sentinel = KEYBUF_SENTINEL;
        geliargs.keybuf = gelibuf;
 #endif
+       /*
+        * Note that the geliargs struct is passed by value, not by pointer.
+        * Code in btxldr.S copies the values from the entry stack to a fixed
+        * location within loader(8) at startup due to the presence of the
+        * KARGS_FLAGS_EXTARG flag.
+        */
        __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
            MAKEBOOTDEV(dev_maj[gdsk.dsk.type], gdsk.dsk.part + 1, 
gdsk.dsk.unit, 0xff),
 #ifdef LOADER_GELI_SUPPORT
@@ -569,22 +574,22 @@ parse_cmds(char *cmdstr, int *dskupdated)
                                    arg[1] != dev_nm[i][1]; i++)
                                        if (i == NDEV - 1)
                                                return (-1);
-                               dsk.type = i;
+                               gdsk.dsk.type = i;
                                arg += 3;
-                               dsk.unit = *arg - '0';
-                               if (arg[1] != 'p' || dsk.unit > 9)
+                               gdsk.dsk.unit = *arg - '0';
+                               if (arg[1] != 'p' || gdsk.dsk.unit > 9)
                                        return (-1);
                                arg += 2;
-                               dsk.part = *arg - '0';
-                               if (dsk.part < 1 || dsk.part > 9)
+                               gdsk.dsk.part = *arg - '0';
+                               if (gdsk.dsk.part < 1 || gdsk.dsk.part > 9)
                                        return (-1);
                                arg++;
                                if (arg[0] != ')')
                                        return (-1);
                                arg++;
                                if (drv == -1)
-                                       drv = dsk.unit;
-                               dsk.drive = (dsk.type <= TYPE_MAXHARD
+                                       drv = gdsk.dsk.unit;
+                               gdsk.dsk.drive = (gdsk.dsk.type <= TYPE_MAXHARD
                                    ? DRV_HARD : 0) + drv;
                                *dskupdated = 1;
                        }

Modified: stable/12/stand/i386/zfsboot/zfsboot.c
==============================================================================
--- stable/12/stand/i386/zfsboot/zfsboot.c      Mon Dec  3 03:58:30 2018        
(r341420)
+++ stable/12/stand/i386/zfsboot/zfsboot.c      Mon Dec  3 04:07:18 2018        
(r341421)
@@ -1005,6 +1005,11 @@ load(void)
        zfsargs.primary_vdev = primary_vdev->v_guid;
     else
        printf("failed to detect primary vdev\n");
+    /*
+     * Note that the zfsargs struct is passed by value, not by pointer.  Code 
in
+     * btxldr.S copies the values from the entry stack to a fixed location
+     * within loader(8) at startup due to the presence of KARGS_FLAGS_EXTARG.
+     */
     __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
           bootdev,
           KARGS_FLAGS_ZFS | KARGS_FLAGS_EXTARG,
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to