kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][BIOS] Add BCV option rom in boot menu
@ 2008-12-05 16:19 Laurent Vivier
  2008-12-07 16:33 ` [Bochs-developers] " Sebastian Herbszt
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Vivier @ 2008-12-05 16:19 UTC (permalink / raw)
  To: bochs-developers; +Cc: kvm, Laurent Vivier

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.

Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
---
 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 @@
 #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
 #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;
+  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...
+  cmp  ax, #0x0000  ;; the Boots Entry Vector, or zero if there is none.
+  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
+
+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:
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Bochs-developers] [PATCH][BIOS] Add BCV option rom in boot menu
  2008-12-05 16:19 [PATCH][BIOS] Add BCV option rom in boot menu Laurent Vivier
@ 2008-12-07 16:33 ` Sebastian Herbszt
  2008-12-07 16:59   ` Anthony Liguori
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Herbszt @ 2008-12-07 16:33 UTC (permalink / raw)
  To: Laurent Vivier, bochs-developers; +Cc: Laurent Vivier, kvm

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 <Laurent.Vivier@bull.net>
> ---
> 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bochs-developers] [PATCH][BIOS] Add BCV option rom in boot menu
  2008-12-07 16:33 ` [Bochs-developers] " Sebastian Herbszt
@ 2008-12-07 16:59   ` Anthony Liguori
  2008-12-09  3:58     ` Nguyen Anh Quynh
  2008-12-12  4:28     ` Michael Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Anthony Liguori @ 2008-12-07 16:59 UTC (permalink / raw)
  To: Sebastian Herbszt; +Cc: Laurent Vivier, bochs-developers, kvm

Sebastian Herbszt wrote:
> 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?

I think the plan is to replace extboot with gPXE, and load it by default 
in QEMU.  Since it supports BCV and BEV, we can rely on passing a boot 
index to choose which device to boot from.

I was thinking about what to do about SCSI boot support.  We could add 
an LSI driver to gPXE too.  That seems like a bit much though.  We could 
add a special virtio transport for gPXE and then reuse virtio-blk to 
boot from arbitrary devices.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bochs-developers] [PATCH][BIOS] Add BCV option rom in boot menu
  2008-12-07 16:59   ` Anthony Liguori
@ 2008-12-09  3:58     ` Nguyen Anh Quynh
  2008-12-12  4:28     ` Michael Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Nguyen Anh Quynh @ 2008-12-09  3:58 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Sebastian Herbszt, Laurent Vivier, bochs-developers, kvm

On Mon, Dec 8, 2008 at 1:59 AM, Anthony Liguori <anthony@codemonkey.ws> wrote:
> Sebastian Herbszt wrote:
>>
>> 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?
>
> I think the plan is to replace extboot with gPXE, and load it by default in
> QEMU.  Since it supports BCV and BEV, we can rely on passing a boot index to
> choose which device to boot from.
>
> I was thinking about what to do about SCSI boot support.  We could add an
> LSI driver to gPXE too.  That seems like a bit much though.  We could add a
> special virtio transport for gPXE and then reuse virtio-blk to boot from
> arbitrary devices.

So are you still interested in rewriting extboot in C, which I
submitted the draft a while ago?
If it can be merged, I will adapt it to QEMU and resubmit again soon.

Thanks,
Quynh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH][BIOS] Add BCV option rom in boot menu
  2008-12-07 16:59   ` Anthony Liguori
  2008-12-09  3:58     ` Nguyen Anh Quynh
@ 2008-12-12  4:28     ` Michael Brown
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Brown @ 2008-12-12  4:28 UTC (permalink / raw)
  To: bochs-developers; +Cc: Laurent Vivier, kvm, Anthony Liguori

On Sunday 07 December 2008 16:59:54 Anthony Liguori wrote:
> I was thinking about what to do about SCSI boot support.  We could add
> an LSI driver to gPXE too.  That seems like a bit much though.  We could
> add a special virtio transport for gPXE and then reuse virtio-blk to
> boot from arbitrary devices.

Adding an LSI driver is reasonable.  We already have a generic SCSI layer, 
which gets used for iSCSI connections, so you can plug in to this.

Michael

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-12  4:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-05 16:19 [PATCH][BIOS] Add BCV option rom in boot menu Laurent Vivier
2008-12-07 16:33 ` [Bochs-developers] " Sebastian Herbszt
2008-12-07 16:59   ` Anthony Liguori
2008-12-09  3:58     ` Nguyen Anh Quynh
2008-12-12  4:28     ` Michael Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).