Laurent Vivier wrote:
This patch allows to select and boot from an option ROM
with a Boot Connection Vector (BCV) entry.

The BIOS detects the BCV option ROM and adds it to the IPL table, and then
you are able to select it to boot.

This patch has been tested with Bochs BIOS version from the KVM source tree
and a gPXE ROM modified to be a BCV one.

Any plans to convert extboot into a compatible option rom?

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

diff --git a/bios/rombios.c b/bios/rombios.c
index 9a1cdd6..70b3584 100644
--- a/bios/rombios.c
+++ b/bios/rombios.c
@@ -180,7 +180,11 @@

might as well also add

#define IPL_TYPE_RESERVED 0x00

#define IPL_TYPE_FLOPPY      0x01
#define IPL_TYPE_HARDDISK    0x02
#define IPL_TYPE_CDROM       0x03
+#define IPL_TYPE_PCMCIA      0x04
+#define IPL_TYPE_USBDEVICE   0x05
+#define IPL_TYPE_NETWORK     0x06

Should this be somehow marked as embedded network? Maybe a comment.

#define IPL_TYPE_BEV         0x80
+#define IPL_TYPE_UNKNOWN     0xff

  // Sanity Checks
#if BX_USE_ATADRV && BX_CPU<3
@@ -2009,6 +2013,31 @@ Bit16u i; ipl_entry_t *e;
  return 1;
}

+static Bit8u
+get_bootdrv(i)
+Bit16u i;
+{
+  Bit16u count;
+  Bit16u type;
+  Bit16u curr_type;
+  Bit16u curr;
+  Bit16u drv;
+  /* Get the count of boot devices, and refuse to overrun the array */
+  count = read_word(IPL_SEG, IPL_COUNT_OFFSET);
+  if (i >= count) return 0;

Add a comment that we return "floppy" on overrun?

+  type = read_word(IPL_SEG, IPL_TABLE_OFFSET + i * sizeof (ipl_entry_t),
+                   sizeof(Bit16u));
+  if (type != IPL_TYPE_HARDDISK)
+    return 0;
+  for (curr = 0, drv = 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;
+}
+
#if BX_ELTORITO_BOOT
  void
interactive_bootkey()
@@ -2047,8 +2076,15 @@ interactive_bootkey()
          case IPL_TYPE_FLOPPY:
          case IPL_TYPE_HARDDISK:
          case IPL_TYPE_CDROM:
-            printf("%s\n", drivetypes[e.type]);
-            break;
+            printf("%s", drivetypes[e.type]);
+            if (e.description != 0)
+            {
+              memcpyb(ss, &description, (Bit16u)(e.description >> 16), 
(Bit16u)(e.description & 0xffff), 32);
+              description[32] = 0;
+              printf(" [%S]", ss, description);
+           }
+           printf("\n");
+           break;
          case IPL_TYPE_BEV:
            printf("%s", drivetypes[4]);
            if (e.description != 0)
@@ -8045,7 +8081,7 @@ Bit16u seq_nr;
  case IPL_TYPE_FLOPPY: /* FDD */
  case IPL_TYPE_HARDDISK: /* HDD */

-    bootdrv = (e.type == IPL_TYPE_HARDDISK) ? 0x80 : 0x00;
+    bootdrv = get_bootdrv(bootdev);
    bootseg = 0x07c0;
    status = 0;

@@ -10245,10 +10281,11 @@ block_count_rounded:
  mov  bx, 0x001a   ;; 0x1A is the offset into ROM header that contains...
  mov  ax, [bx]     ;; the offset of PnP expansion header, where...
  cmp  ax, #0x5024  ;; we look for signature "$PnP"
-  jne  no_bev
+  jne  no_pnp
  mov  ax, 2[bx]
  cmp  ax, #0x506e
-  jne  no_bev
+  jne  no_pnp
+  ;; Look for the Bootstrap Entry Vector (BEV)
  mov  ax, 0x1a[bx] ;; 0x1A is also the offset into the expansion header of...
  cmp  ax, #0x0000  ;; the Bootstrap Entry Vector, or zero if there is none.
  je   no_bev
@@ -10259,9 +10296,29 @@ block_count_rounded:
  mov  ds, bx
  mov  bx, IPL_COUNT_OFFSET    ;; Read the number of entries so far
  cmp  bx, #IPL_TABLE_ENTRIES
-  je   no_bev                  ;; Get out if the table is full
+  je   no_pnp                  ;; Get out if the table is full
  shl  bx, #0x4                ;; Turn count into offset (entries are 16 bytes)
  mov  0[bx], #IPL_TYPE_BEV    ;; This entry is a BEV device
+  jmp add_ipl
+
+no_bev:
+  ;; Look for the Boot Connection Vector (BCV)
+  mov  ax, 0x16[bx] ;; 0x16 is also the offset into the expansion header of...

"also" is wrong in this comment

+  cmp  ax, #0x0000  ;; the Boots Entry Vector, or zero if there is none.

Boot Connection Vector

+  je   no_pnp
+
+  ;; Found a device that thinks it can boot the system.
+  mov  di, 0x10[bx]            ;; Pointer to the product name string or zero 
if none
+  mov  bx, #IPL_SEG            ;; Go to the segment where the IPL table lives
+  mov  ds, bx
+  mov  bx, IPL_COUNT_OFFSET    ;; Read the number of entries so far
+  cmp  bx, #IPL_TABLE_ENTRIES
+  je   no_pnp                  ;; Get out if the table is full
+  shl  bx, #0x4                ;; Turn count into offset (entries are 16 bytes)
+  mov  0[bx], #IPL_TYPE_HARDDISK    ;; This entry is a BEV device

BCV device

+
+add_ipl:
+
  mov  6[bx], cx               ;; Build a far pointer from the segment...
  mov  4[bx], ax               ;; and the offset
  cmp  di, #0x0000
@@ -10273,7 +10330,7 @@ no_prod_str:
  inc  bx                      ;; We have one more entry now
  mov  IPL_COUNT_OFFSET, bx    ;; Remember that.

-no_bev:
+no_pnp:
  pop  di       ;; Restore DI
  pop  ax       ;; Restore AX
rom_scan_increment:
--

- Sebastian

--
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