Received: from eggs.gnu.org ([140.186.70.92]:42512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWJW3-0006t4-C7 for qemu-devel@nongnu.org; Mon, 13 Jun 2011 22:38:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWJW0-0006gv-HS for qemu-devel@nongnu.org; Mon, 13 Jun 2011 22:38:07 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:51334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWJVy-0006gG-Uq for qemu-devel@nongnu.org; Mon, 13 Jun 2011 22:38:04 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 14 Jun 2011 04:37:39 +0200 Message-Id: <1308019077-61957-6-git-send-email-andreas.faerber@web.de> In-Reply-To: <1308019077-61957-5-git-send-email-andreas.faerber@web.de> References: <1308019077-61957-1-git-send-email-andreas.faerber@web.de> <1308019077-61957-2-git-send-email-andreas.faerber@web.de> <1308019077-61957-3-git-send-email-andreas.faerber@web.de> <1308019077-61957-4-git-send-email-andreas.faerber@web.de> <1308019077-61957-5-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: andreas.faerber@web.de Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC 05/23] prep: Add i82374 DMA emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= Signed-off-by: Herv=C3=A9 Poussineau Confine to CONFIG_I82374. Signed-off-by: Andreas F=C3=A4rber --- Makefile.objs | 1 + default-configs/ppc-softmmu.mak | 1 + hw/i82374.c | 133 +++++++++++++++++++++++++++++++++= ++++++ 3 files changed, 135 insertions(+), 0 deletions(-) create mode 100644 hw/i82374.c diff --git a/Makefile.objs b/Makefile.objs index 509ab39..b0e4c09 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -201,6 +201,7 @@ hw-obj-$(CONFIG_FDC) +=3D fdc.o hw-obj-$(CONFIG_ACPI) +=3D acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) +=3D pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) +=3D dma.o +hw-obj-$(CONFIG_I82374) +=3D i82374.o hw-obj-$(CONFIG_HPET) +=3D hpet.o hw-obj-$(CONFIG_APPLESMC) +=3D applesmc.o hw-obj-$(CONFIG_SMARTCARD) +=3D usb-ccid.o ccid-card-passthru.o diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmm= u.mak index 4563742..1d1a7c2 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -11,6 +11,7 @@ CONFIG_I8254=3Dy CONFIG_PCKBD=3Dy CONFIG_FDC=3Dy CONFIG_DMA=3Dy +CONFIG_I82374=3Dy CONFIG_OPENPIC=3Dy CONFIG_PREP_PCI=3Dy CONFIG_MACIO=3Dy diff --git a/hw/i82374.c b/hw/i82374.c new file mode 100644 index 0000000..383cf1b --- /dev/null +++ b/hw/i82374.c @@ -0,0 +1,133 @@ +/* + * QEMU Intel 82374 emulation (Enhanced DMA controller) + * + * Copyright (c) 2010 Herve Poussineau + * + * Permission is hereby granted, free of charge, to any person obtaining= a copy + * of this software and associated documentation files (the "Software"),= to deal + * in the Software without restriction, including without limitation the= rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or = sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be includ= ed in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHA= LL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING= S IN + * THE SOFTWARE. + */ + +#include "isa.h" + +//#define DEBUG_I82374 + +#ifdef DEBUG_I82374 +#define DPRINTF(fmt, ...) \ +do { fprintf(stderr, "i82374: " fmt , ## __VA_ARGS__); } while (0) +#else +#define DPRINTF(fmt, ...) \ +do {} while (0) +#endif +#define BADF(fmt, ...) \ +do { fprintf(stderr, "i82374 ERROR: " fmt , ## __VA_ARGS__); } while (0) + +typedef struct I82374State { + uint8_t commands[8]; +} I82374State; + +static uint32_t i82374_read_isr(void *opaque, uint32_t nport) +{ + uint32_t val =3D 0; + + BADF("%s: %08x\n", __func__, nport); + + DPRINTF("%s: %08x=3D%08x\n", __func__, nport, val); + return val; +} + +static void i82374_write_command(void *opaque, uint32_t nport, uint32_t = data) +{ + DPRINTF("%s: %08x=3D%08x\n", __func__, nport, data); + + if (data !=3D 0x42) { + /* Not Stop S/G command */ + BADF("%s: %08x=3D%08x\n", __func__, nport, data); + } +} + +static uint32_t i82374_read_status(void *opaque, uint32_t nport) +{ + uint32_t val =3D 0; + + BADF("%s: %08x\n", __func__, nport); + + DPRINTF("%s: %08x=3D%08x\n", __func__, nport, val); + return val; +} + +static void i82374_write_descriptor(void *opaque, uint32_t nport, uint32= _t data) +{ + DPRINTF("%s: %08x=3D%08x\n", __func__, nport, data); + + BADF("%s: %08x=3D%08x\n", __func__, nport, data); +} + +static uint32_t i82374_read_descriptor(void *opaque, uint32_t nport) +{ + uint32_t val =3D 0; + + BADF("%s: %08x\n", __func__, nport); + + DPRINTF("%s: %08x=3D%08x\n", __func__, nport, val); + return val; +} + +static void i82374_init(I82374State *s) +{ + DMA_init(1, NULL); + memset(s->commands, 0, sizeof(s->commands)); +} + +typedef struct ISAi82374State { + ISADevice dev; + uint32_t iobase; + I82374State state; +} ISAi82374State; + +static int i82374_isa_init(ISADevice *dev) +{ + ISAi82374State *isa =3D DO_UPCAST(ISAi82374State, dev, dev); + I82374State *s =3D &isa->state; + + register_ioport_read(isa->iobase + 0x0A, 1, 1, i82374_read_isr, s); + register_ioport_write(isa->iobase + 0x10, 8, 1, i82374_write_command= , s); + register_ioport_read(isa->iobase + 0x18, 8, 1, i82374_read_status, s= ); + register_ioport_write(isa->iobase + 0x20, 0x20, 1, i82374_write_desc= riptor, s); + register_ioport_read(isa->iobase + 0x20, 0x20, 1, i82374_read_descri= ptor, s); + + i82374_init(s); + + return 0; +} + +static ISADeviceInfo i82374_isa_info =3D { + .qdev.name =3D "i82374", + .qdev.size =3D sizeof(ISAi82374State), + .init =3D i82374_isa_init, + .qdev.props =3D (Property[]) { + DEFINE_PROP_HEX32("iobase", ISAi82374State, iobase, 0x400), + DEFINE_PROP_END_OF_LIST() + }, +}; + +static void i82374_register_devices(void) +{ + isa_qdev_register(&i82374_isa_info); +} + +device_init(i82374_register_devices) --=20 1.7.5.3