From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Swkgs-00057W-C2 for qemu-devel@nongnu.org; Wed, 01 Aug 2012 21:59:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Swkgq-0003RM-Uw for qemu-devel@nongnu.org; Wed, 01 Aug 2012 21:59:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34632 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Swkgq-0003RI-Ks for qemu-devel@nongnu.org; Wed, 01 Aug 2012 21:59:04 -0400 Message-ID: <5019DEE3.9020307@suse.de> Date: Thu, 02 Aug 2012 03:58:59 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1343840383-28138-1-git-send-email-hpoussin@reactos.org> In-Reply-To: <1343840383-28138-1-git-send-email-hpoussin@reactos.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] esp: add Tekram DC-390 emulation (PC SCSI adapter) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?SGVydsOpIFBvdXNzaW5lYXU=?= Cc: Blue Swirl , Paolo Bonzini , qemu-devel@nongnu.org Am 01.08.2012 18:59, schrieb Herv=C3=A9 Poussineau: > Difference with AMD PCscsi is that DC-390 contains a EEPROM, > and that a romfile is available to add INT13 support. >=20 > This has been successfully tested on: > - MS DOS 6.22 (using DC390 ASPI driver) > - MS Windows 98 SE (using DC390 driver) > - MS Windows NT 3.1 (using DC390 driver) > - MS Windows NT 4.0 (using DC390 driver) > - hard disk and cdrom boot >=20 > Signed-off-by: Herv=C3=A9 Poussineau >=20 > --- >=20 > You're now able to install MS Windows NT 3.1 (which does not support > IDE cdroms) directly on an empty VM, without installing MS-DOS first! >=20 > hw/esp.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 116 insertions(+) >=20 > diff --git a/hw/esp.c b/hw/esp.c > index c6422ad..423e311 100644 > --- a/hw/esp.c > +++ b/hw/esp.c > @@ -26,6 +26,7 @@ > #include "sysbus.h" > #include "pci.h" > #include "scsi.h" > +#include "eeprom93xx.h" > #include "esp.h" > #include "trace.h" > #include "qemu-log.h" > @@ -1185,10 +1186,125 @@ static TypeInfo esp_pci_info =3D { > .class_init =3D esp_pci_class_init, > }; > =20 > +typedef struct { > + PCIESPState pci; > + eeprom_t *eeprom; > +} DC390State; > + > +static uint32_t dc390_read_config(PCIDevice *dev, uint32_t addr, int l= ) > +{ > + DC390State *pci =3D DO_UPCAST(DC390State, pci.dev, dev); Using QOM cast macros in place of DO_UPCAST() would be preferred. > + uint32_t val; > + > + val =3D pci_default_read_config(dev, addr, l); > + > + if (addr =3D=3D 0x00 && l =3D=3D 1) { > + /* First byte of address space is AND-ed with EEPROM DO line *= / > + if (!eeprom93xx_read(pci->eeprom)) { > + val &=3D ~0xff; > + } > + } > + > + return val; > +} > + > +static void dc390_write_config(PCIDevice *dev, > + uint32_t addr, uint32_t val, int l) > +{ > + DC390State *pci =3D DO_UPCAST(DC390State, pci.dev, dev); > + if (addr =3D=3D 0x80) { > + /* EEPROM write */ > + int eesk =3D val & 0x80 ? 1 : 0; > + int eedi =3D val & 0x40 ? 1 : 0; > + eeprom93xx_write(pci->eeprom, 1, eesk, eedi); > + } else if (addr =3D=3D 0xc0) { > + /* EEPROM CS low */ > + eeprom93xx_write(pci->eeprom, 0, 0, 0); > + } else { > + pci_default_write_config(dev, addr, val, l); > + } > +} > + > +static int dc390_scsi_init(PCIDevice *dev) > +{ > + DC390State *pci =3D DO_UPCAST(DC390State, pci.dev, dev); > + uint8_t *contents; > + uint16_t chksum =3D 0; > + int i, ret; > + > + /* init base class */ > + ret =3D esp_pci_scsi_init(dev); > + if (ret < 0) { > + return ret; > + } > + > + /* EEPROM */ > + pci->eeprom =3D eeprom93xx_new(&dev->qdev, 64); DEVICE(dev) > + > + /* set default eeprom values */ > + contents =3D (uint8_t *)eeprom93xx_data(pci->eeprom); > + > +#define EE_ADAPT_SCSI_ID 64 > +#define EE_MODE2 65 > +#define EE_DELAY 66 > +#define EE_TAG_CMD_NUM 67 > +#define EE_ADAPT_OPTIONS 68 > +#define EE_BOOT_SCSI_ID 69 > +#define EE_BOOT_SCSI_LUN 70 > +#define EE_CHKSUM1 126 > +#define EE_CHKSUM2 127 > + > +#define OPTION_F6_F8_AT_BOOT 0x01 > +#define OPTION_BOOT_FROM_CDROM 0x02 > +#define OPTION_INT13 0x04 > +#define OPTION_SCAM_SUPPORT 0x08 Usually such constants are requested not to be in the middle of a functio= n. > + > + for (i =3D 0; i < 16; i++) { > + contents[i * 2] =3D 0x57; > + contents[i * 2 + 1] =3D 0x00; > + } > + contents[EE_ADAPT_SCSI_ID] =3D 7; > + contents[EE_MODE2] =3D 0x0f; > + contents[EE_TAG_CMD_NUM] =3D 0x04; > + contents[EE_ADAPT_OPTIONS] =3D OPTION_F6_F8_AT_BOOT > + | OPTION_BOOT_FROM_CDROM > + | OPTION_INT13; > + > + /* update eeprom checksum */ > + for (i =3D 0; i < EE_CHKSUM1; i +=3D 2) { > + chksum +=3D contents[i] + (((uint16_t)contents[i + 1]) << 8); > + } > + chksum =3D 0x1234 - chksum; > + contents[EE_CHKSUM1] =3D chksum & 0xff; > + contents[EE_CHKSUM2] =3D chksum >> 8; > + > + return 0; > +} > + > +static void dc390_class_init(ObjectClass *klass, void *data) > +{ > + DeviceClass *dc =3D DEVICE_CLASS(klass); > + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); > + > + k->init =3D dc390_scsi_init; > + k->romfile =3D "INT13.BIN"; > + k->config_read =3D dc390_read_config; > + k->config_write =3D dc390_write_config; > + dc->desc =3D "Tekram DC-390 SCSI adapter"; > +} > + > +static TypeInfo dc390_info =3D { static const please. > + .name =3D "dc390", > + .parent =3D "am53c974", Introduce a TYPE_... constant for the parent to avoid runtime breakage if renamed? Andreas > + .instance_size =3D sizeof(DC390State), > + .class_init =3D dc390_class_init, > +}; > + > static void esp_register_types(void) > { > type_register_static(&sysbus_esp_info); > type_register_static(&esp_pci_info); > + type_register_static(&dc390_info); > } > =20 > type_init(esp_register_types) >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg