Hi tech@,

With this patch,

- 'cd0' is used for the name of the disk for CD-ROM
- 'cd0a' is used for the 'device' variable when it's booted from CD-ROM

----
probing: pc0 com0 com1 mem[640K 3049M 16M 4M 64K 1024M]
disk: hd0* cd0
>> OpenBSD/amd64 BOOTX64 3.33
boot> set
>> OpenBSD/amd64 BOOTX64 3.33
addr     0x0
howto    
device   cd0a
tty      pc0
image    /bsd.rd
timeout  0
db_console       unset
boot> machine diskinfo
Disk    BlkSiz  IoAlign Size    Flags   Checksum
hd0     512     0       32GB    0x0     0x0     
cd0     2048    0       13MB    0xa     0x0     Removable
----

# should efiboot version be bumped?

Index: sys/arch/amd64/stand/efiboot/efiboot.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efiboot.c,v
retrieving revision 1.20
diff -u -p -r1.20 efiboot.c
--- sys/arch/amd64/stand/efiboot/efiboot.c      1 Jun 2017 11:32:15 -0000       
1.20
+++ sys/arch/amd64/stand/efiboot/efiboot.c      21 Jul 2017 05:57:44 -0000
@@ -91,9 +91,14 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TA
        if (status == EFI_SUCCESS) {
                for (dp = dp0; !IsDevicePathEnd(dp);
                    dp = NextDevicePathNode(dp)) {
-                       if (DevicePathType(dp) == MEDIA_DEVICE_PATH &&
-                           DevicePathSubType(dp) == MEDIA_HARDDRIVE_DP) {
+                       if (DevicePathType(dp) != MEDIA_DEVICE_PATH)
+                               continue;
+                       if (DevicePathSubType(dp) == MEDIA_HARDDRIVE_DP) {
                                bios_bootdev = 0x80;
+                               efi_bootdp = dp0;
+                               break;
+                       } else if (DevicePathSubType(dp) == MEDIA_CDROM_DP) {
+                               bios_bootdev = 0x100;
                                efi_bootdp = dp0;
                                break;
                        }
Index: sys/arch/amd64/stand/efiboot/efidev.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/stand/efiboot/efidev.c,v
retrieving revision 1.27
diff -u -p -r1.27 efidev.c
--- sys/arch/amd64/stand/efiboot/efidev.c       21 Jul 2017 01:21:42 -0000      
1.27
+++ sys/arch/amd64/stand/efiboot/efidev.c       21 Jul 2017 05:57:44 -0000
@@ -787,7 +787,8 @@ efi_dump_diskinfo(void)
                        sizu = "GB";
                }
 
-               printf("hd%d\t%u\t%u\t%u%s\t0x%x\t0x%x\t%s\n",
+               printf("%cd%d\t%u\t%u\t%u%s\t0x%x\t0x%x\t%s\n",
+                   (bdi->flags & BDI_EL_TORITO) ? 'c' : 'h',
                    (bdi->bios_number & 0x7f),
                    ed->blkio->Media->BlockSize,
                    ed->blkio->Media->IoAlign, (unsigned)siz, sizu,
Index: sys/arch/amd64/stand/libsa/diskprobe.c
===================================================================
RCS file: /cvs/src/sys/arch/amd64/stand/libsa/diskprobe.c,v
retrieving revision 1.20
diff -u -p -r1.20 diskprobe.c
--- sys/arch/amd64/stand/libsa/diskprobe.c      21 Jul 2017 01:21:42 -0000      
1.20
+++ sys/arch/amd64/stand/libsa/diskprobe.c      21 Jul 2017 05:57:44 -0000
@@ -186,22 +186,24 @@ hardprobe(void)
 static void
 efi_hardprobe(void)
 {
-       int              n;
        struct diskinfo *dip, *dipt;
-       u_int            bsdunit, type = 0;
-       u_int            scsi= 0, ide = 0;
+       u_int            bsdunit, type;
+       u_int            scsi = 0, ide = 0, atapi = 0;
+       u_int            n;
+       char             c;
        extern struct disklist_lh
                         efi_disklist;
 
-       n = 0;
        TAILQ_FOREACH_SAFE(dip, &efi_disklist, list, dipt) {
                TAILQ_REMOVE(&efi_disklist, dip, list);
-               printf(" hd%u", n);
 
+               c = 'h';
+               n = scsi + ide;
                dip->bios_info.bios_number = 0x80 | n;
                /* Try to find the label, to figure out device type */
                if ((efi_getdisklabel(dip->efi_info, &dip->disklabel))) {
-                       printf("*");
+                       printf(" %cd%u*", c, n);
+                       type = 0;       /* XXX let it be IDE */
                        bsdunit = ide++;
                } else {
                        /* Best guess */
@@ -219,11 +221,23 @@ efi_hardprobe(void)
                                dip->bios_info.flags |= BDI_GOODLABEL;
                                break;
 
+                       case DTYPE_ATAPI:
+                               c = 'c';
+                               n = atapi;
+                               dip->bios_info.bios_number = n;
+                               type = 6;
+                               bsdunit = atapi++;
+                               dip->bios_info.flags |=
+                                   BDI_GOODLABEL | BDI_EL_TORITO;
+                               break;
+
                        default:
                                dip->bios_info.flags |= BDI_BADLABEL;
                                type = 0;       /* XXX Suggest IDE */
                                bsdunit = ide++;
                        }
+
+                       printf(" %cd%u", c, n);
                }
 
                dip->bios_info.checksum = 0; /* just in case */
@@ -234,7 +248,6 @@ efi_hardprobe(void)
 
                /* Add to queue of disks */
                TAILQ_INSERT_TAIL(&disklist, dip, list);
-               n++;
        }
 }
 #endif

Reply via email to