From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHZY8-0006sd-Vk for qemu-devel@nongnu.org; Fri, 08 Jan 2016 11:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHZY6-0002Ls-2E for qemu-devel@nongnu.org; Fri, 08 Jan 2016 11:06:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59740) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHZY5-0002Lg-Tn for qemu-devel@nongnu.org; Fri, 08 Jan 2016 11:05:58 -0500 Date: Fri, 8 Jan 2016 17:05:51 +0100 From: Marc =?UTF-8?B?TWFyw60=?= Message-ID: <20160108170551.304fe666@markmb_rh> In-Reply-To: <568FDB9F.7080709@redhat.com> References: <1452265115-27177-1-git-send-email-markmb@redhat.com> <568FDB9F.7080709@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Add optionrom compatible with fw_cfg DMA version List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: "Gabriel L. Somlo" , Kevin O'Connor , Laszlo Ersek , qemu-devel , Stefan Hajnoczi On Fri, 8 Jan 2016 16:54:07 +0100 Paolo Bonzini wrote: >=20 >=20 > On 08/01/2016 15:58, Marc Mar=C3=AD wrote: > >=20 > > +static inline uint16_t readw_addr32(const void *addr) { > > + uint16_t val; > > + asm("addr32 movw %1, %0" : "=3Dr"(val) : "g"(addr)); > > + barrier(); > > + return val; > > +} > > + >=20 > Does SeaBIOS ensure that DS base is zero here? DS =3D CS: " movw %cs, %ax\n" " movw %ax, %ds\n" At the beginning of the ROM. =20 > > +static void transition32(void) > > +{ > > + extern void *gdt; > > + uint32_t data_segment; > > + struct length_addr rombios_gdt; > > + > > + data_segment =3D read_ds(); > > + rombios_gdt.addr =3D (uint32_t)((data_segment << 4) + > > (uint32_t)(&gdt)); > > + rombios_gdt.length =3D (3 * 8) - 1; > > + > > + /* Load GDT */ > > + asm("data32 lgdt %0" : : "m"(rombios_gdt): "memory"); > > + > > + /* Get us to protected mode and set ES to a 32 bit segment > > */ > > + asm("mov $1, %%eax\n" > > + "mov %%eax, %%cr0\n" > > + "mov $0x10, %%eax\n" > > + "mov %%eax, %%es\n" > > + : : : "eax"); > > + > > + /* We're now running in 16-bit CS, but 32-bit ES! */ > > +} >=20 > Do you even need to go to 32-bit mode? The only reason to do so in > the original ROM was to do a "rep insb" above 1 GB, but here fw_cfg > can do DMA to high addresses for you. There's no need of course. I was looking at the original ROM and I did not think this through. Thanks for your comments Marc