Index: sys/arch/sparc64/conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/sparc64/conf/GENERIC,v retrieving revision 1.191 diff -u -r1.191 GENERIC --- sys/arch/sparc64/conf/GENERIC 22 Jun 2016 20:12:59 -0000 1.191 +++ sys/arch/sparc64/conf/GENERIC 14 Aug 2016 19:19:27 -0000 @@ -277,6 +277,7 @@ # Virtual devices for sun4v systems. vrtc0 at vbus? +vdsk* at cbus? #### Serial port configuration Index: sys/arch/sparc64/conf/files.sparc64 =================================================================== RCS file: /cvsroot/src/sys/arch/sparc64/conf/files.sparc64,v retrieving revision 1.151 diff -u -r1.151 files.sparc64 --- sys/arch/sparc64/conf/files.sparc64 22 Jun 2016 20:12:59 -0000 1.151 +++ sys/arch/sparc64/conf/files.sparc64 14 Aug 2016 19:19:27 -0000 @@ -325,3 +325,11 @@ device vrtc attach vrtc at vbus file arch/sparc64/dev/vrtc.c vrtc + +define ldc +file arch/sparc64/dev/ldc.c ldc + +# Virtual disk +device vdsk: ldc, scsi +attach vdsk at cbus +file arch/sparc64/dev/vdsk.c vdsk Index: sys/arch/sparc64/sparc64/autoconf.c =================================================================== RCS file: /cvsroot/src/sys/arch/sparc64/sparc64/autoconf.c,v retrieving revision 1.207 diff -u -r1.207 autoconf.c --- sys/arch/sparc64/sparc64/autoconf.c 16 Dec 2015 08:01:19 -0000 1.207 +++ sys/arch/sparc64/sparc64/autoconf.c 14 Aug 2016 19:19:27 -0000 @@ -93,6 +93,7 @@ #include #include #include +#include #include #include @@ -980,6 +981,11 @@ dev_path_drive_match(dev, ofnode, adev->adev_channel*2+ adev->adev_drv_data->drive, 0, 0); return; + } else if (device_is_a(dev, "vdsk")) { + struct cbus_attach_args *ca = aux; + ofnode = ca->ca_node; + /* Ensure that the devices ofnode is stored for later use */ + device_setofnode(dev, ofnode); } if (busdev == NULL) @@ -1317,6 +1323,49 @@ } } } + + if (CPU_ISSUN4V) { + + /* + * Special sun4v handling in case the kernel is running in a + * secondary logical domain + * + * The bootpath looks something like this: + * /virtual-devices@100/channel-devices@200/disk@1:a + * + * The device hierarchy constructed during autoconfiguration is: + * mainbus/vbus/vdsk/scsibus/sd + * + * The logic to figure out the boot device is to look at the + * grandparent to the 'sd' device and if this is a 'vdsk' device + * and the ofnode matches the bootpaths ofnode then we have located + * the boot device. + */ + + int ofnode; + + /* Cache the vdsk ofnode for later use later/below with sd device */ + if (device_is_a(dev, "vdsk")) { + ofnode = device_ofnode(dev); + device_setofnode(dev, ofnode); + } + + /* Examine if this is a sd device */ + if (device_is_a(dev, "sd")) { + device_t parent = device_parent(dev); + device_t parent_parent = device_parent(parent); + if (device_is_a(parent_parent, "vdsk")) { + ofnode = device_ofnode(parent_parent); + if (ofnode == ofbootpackage) { + booted_device = dev; + DPRINTF(ACDB_BOOTDEV, ("booted_device: %s\n", + device_xname(dev))); + return; + } + } + } + } + } static void