Patchwork PC machine types switched to SeaBIOS/gPXE

login
register
mail settings
Submitter Kevin O'Connor
Date Nov. 3, 2009, 6:02 a.m.
Message ID <20091103060223.GB13492@morn.localdomain>
Download mbox | patch
Permalink /patch/37487/
State New
Headers show

Comments

Kevin O'Connor - Nov. 3, 2009, 6:02 a.m.
On Tue, Nov 03, 2009 at 07:01:52AM +0200, Avi Kivity wrote:
> That works too, but if firmware config can use rep/ins, that's one less  
> interface we have to add.

The following patch to seabios seems to work.  I'm not sure if there
are any special implications to qemu.

-Kevin
Avi Kivity - Nov. 3, 2009, 6:08 a.m.
On 11/03/2009 08:02 AM, Kevin O'Connor wrote:
> On Tue, Nov 03, 2009 at 07:01:52AM +0200, Avi Kivity wrote:
>    
>> That works too, but if firmware config can use rep/ins, that's one less
>> interface we have to add.
>>      
> The following patch to seabios seems to work.  I'm not sure if there
> are any special implications to qemu.
>
> -Kevin
>
>
>
> --- a/src/paravirt.c
> +++ b/src/paravirt.c
> @@ -23,8 +23,7 @@ qemu_cfg_select(u16 f)
>   static void
>   qemu_cfg_read(u8 *buf, int len)
>   {
> -    while (len--)
> -        *(buf++) = inb(PORT_QEMU_CFG_DATA);
> +    insb(PORT_QEMU_CFG_DATA, buf, len);
>   }
>    

Should make sure to use the 32-bit address size version so we use ecx, 
not cx, in case len doesn't fit in 16 bits.
Kevin O'Connor - Nov. 3, 2009, 1:42 p.m.
On Tue, Nov 03, 2009 at 08:08:25AM +0200, Avi Kivity wrote:
> On 11/03/2009 08:02 AM, Kevin O'Connor wrote:
>> On Tue, Nov 03, 2009 at 07:01:52AM +0200, Avi Kivity wrote:
>> --- a/src/paravirt.c
>> +++ b/src/paravirt.c
>> @@ -23,8 +23,7 @@ qemu_cfg_select(u16 f)
>>   static void
>>   qemu_cfg_read(u8 *buf, int len)
>>   {
>> -    while (len--)
>> -        *(buf++) = inb(PORT_QEMU_CFG_DATA);
>> +    insb(PORT_QEMU_CFG_DATA, buf, len);
>>   }
>
> Should make sure to use the 32-bit address size version so we use ecx,  
> not cx, in case len doesn't fit in 16 bits.

I think SeaBIOS has the 32bit version as of commit 7edaa658:

static inline void insb(u16 port, u8 *data, u32 count) {
    asm volatile("rep insb (%%dx), %%es:(%%edi)"
                 : "+c"(count), "+D"(data) : "d"(port) : "memory");
}

-Kevin

Patch

--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -23,8 +23,7 @@  qemu_cfg_select(u16 f)
 static void
 qemu_cfg_read(u8 *buf, int len)
 {
-    while (len--)
-        *(buf++) = inb(PORT_QEMU_CFG_DATA);
+    insb(PORT_QEMU_CFG_DATA, buf, len);
 }
 
 static void