This patch shows in boot menu only available devices.

This patch has been tested with Bochs BIOS version from the KVM source tree.

Signed-off-by: Laurent Vivier <[EMAIL PROTECTED]>
---
 bios/rombios.c |   54 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/bios/rombios.c b/bios/rombios.c
index 70b3584..d2a7c09 100644
--- a/bios/rombios.c
+++ b/bios/rombios.c
@@ -1981,18 +1981,6 @@ init_boot_vectors()
   memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
   count++;
 
-  /* First HDD */
-  e.type = IPL_TYPE_HARDDISK; e.flags = 0; e.vector = 0; e.description = 0; 
e.reserved = 0;
-  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
-  count++;
-
-#if BX_ELTORITO_BOOT
-  /* CDROM */
-  e.type = IPL_TYPE_CDROM; e.flags = 0; e.vector = 0; e.description = 0; 
e.reserved = 0;
-  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
-  count++;
-#endif
-
   /* Remember how many devices we have */
   write_word(IPL_SEG, IPL_COUNT_OFFSET, count);
   /* Not tried booting anything yet */
@@ -2027,15 +2015,19 @@ Bit16u i;
   if (i >= count) return 0;
   type = read_word(IPL_SEG, IPL_TABLE_OFFSET + i * sizeof (ipl_entry_t),
                    sizeof(Bit16u));
-  if (type != IPL_TYPE_HARDDISK)
+  if (type == IPL_TYPE_HARDDISK)
+    drv = 0x80;
+  else if(type == IPL_TYPE_CDROM)
+    drv = 0xe0;
+  else
     return 0;
-  for (curr = 0, drv = 0; curr < i; curr++) {
+  for (curr = 0; curr < i; curr++) {
     curr_type = read_word(IPL_SEG,
                           IPL_TABLE_OFFSET + curr * sizeof (ipl_entry_t),
                           sizeof(Bit16u));
     if (type == curr_type) drv++;
   }
-  return 0x80 + drv;
+  return drv;
 }
 
 #if BX_ELTORITO_BOOT
@@ -2082,6 +2074,9 @@ interactive_bootkey()
               memcpyb(ss, &description, (Bit16u)(e.description >> 16), 
(Bit16u)(e.description & 0xffff), 32);
               description[32] = 0;
               printf(" [%S]", ss, description);
+           } else {
+               Bit16u drive = get_bootdrv(i);
+               if (drive) printf(" (0x%02x)", drive);
            }
            printf("\n");
            break;
@@ -2484,6 +2479,9 @@ void ata_detect( )
   Bit16u ebda_seg=read_word(0x0040,0x000E);
   Bit8u  hdcount, cdcount, device, type;
   Bit8u  buffer[0x0200];
+  Bit16u ss = get_SS();
+  ipl_entry_t e;
+  Bit16u count;
 
 #if BX_MAX_ATA_INTERFACES > 0
   write_byte(ebda_seg,&EbdaData->ata.channels[0].iface,ATA_IFACE_ISA);
@@ -2750,6 +2748,16 @@ void ata_detect( )
             printf(" ATA-%d Hard-Disk (%4u MBytes)\n", version, 
(Bit16u)sizeinmb);
          else
             printf(" ATA-%d Hard-Disk (%4u GBytes)\n", version, 
(Bit16u)(sizeinmb>>10));
+          /* add to IPL list */
+          count = read_word(IPL_SEG, IPL_COUNT_OFFSET);
+          e.type = IPL_TYPE_HARDDISK;
+          e.flags = 0;
+          e.vector = 0;
+          e.description = 0;
+          e.reserved = 0;
+          memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e),
+                  ss, &e, sizeof (e));
+          write_word(IPL_SEG, IPL_COUNT_OFFSET, count + 1);
           break;
         case ATA_TYPE_ATAPI:
           printf("ata%d %s: ",channel,slave?" slave":"master");
@@ -2758,6 +2766,18 @@ void ata_detect( )
             printf(" ATAPI-%d CD-Rom/DVD-Rom\n",version);
           else
             printf(" ATAPI-%d Device\n",version);
+          /* add to IPL list */
+#if BX_ELTORITO_BOOT
+          count = read_word(IPL_SEG, IPL_COUNT_OFFSET);
+          e.type = IPL_TYPE_CDROM;
+          e.flags = 0;
+          e.vector = 0;
+          e.description = 0;
+          e.reserved = 0;
+          memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e),
+                  ss, &e, sizeof (e));
+          write_word(IPL_SEG, IPL_COUNT_OFFSET, count + 1);
+#endif
           break;
         case ATA_TYPE_UNKNOWN:
           printf("ata%d %s: Unknown device\n",channel,slave?" slave":"master");
@@ -10663,6 +10683,8 @@ post_default_ints:
   ;;
   call hard_drive_post
 
+  call _init_boot_vectors
+
 #if BX_USE_ATADRV
 
   ;;
@@ -10682,8 +10704,6 @@ post_default_ints:
   ;;
 #endif // BX_ELTORITO_BOOT
 
-  call _init_boot_vectors
-
   mov  cx, #0xc800  ;; init option roms
   mov  ax, #0xe000
   call rom_scan
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to