From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDtYp-00044J-3N for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:11:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDtYi-0000lF-W2 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 09:11:45 -0400 From: Efimov Vasily Date: Fri, 17 Jun 2016 16:10:56 +0300 Message-Id: <1466169069-29375-1-git-send-email-real@ispras.ru> Subject: [Qemu-devel] [PATCH 00/13] Make Q35 devices closer to Qemu object model. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Efimov Vasily , John Snow , qemu-block@nongnu.org, Gerd Hoffmann , "Michael S. Tsirkin" , Kevin Wolf , Max Reitz , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Peter Maydell , Kirill Batuzov The patch series makes several devices closer to Qemu object model. I am developing a tool that automatize creation of device and machine models. Recently, I've take part in development of several models. And I noticed that a significant part of code is same. The examples are: - Each device represented by a header and a source. - The device or machine class is described by a set of callbacks containing in TypeInfo structure. - Each TypeInfo structure is accounted by a register function. - A register function is sheduled by a type_init macro. - Class and state structures of an inherited type are prepended by ones of the parent type. - A device must have VM state description. - A device or a machine can have properties. - A device can use internal APIs such as: timer, chardev, blockdev, IRQ, system bys memory and port mapping, PCI BARs, PCI MSI(X), etc. - A machine consists of devices and memory tree. Devices are linked by IRQs and buses and assigned property values. - All of the above should follow the Qemu coding style. For every listed item can be generated a stub code. All stubs can be generated with respect to each other forming compileable device (or machine). Ideally, a programmer have to implement custom device/machine logic and to assign meaningful names to variables, functions, macroses etc. using a refactoring tool. Of cource, a device/machine description for the tool has to be significantly smaller than the code the tool produced. A GUI constructor is preferred too. I've chosed Q35 machine to test the tool. The Q35 is one of the most complex boards. I have implemented 64-bit CPU, soft MMU, 1GB RAM, 1 HDD, PCI, USB machine variant. Most of devices is instantiated using the object model. Some logic (I/O port 80, I/O port F0, A20 line) is dedicated to new devices. The stubs for thay is also generated by the tool. In course of implementing Q35 I've noticed that some device models does not follow Qemu object model close enough. The patch series is desined to make them closer. Efimov Vasily (13): ide: move headers to include folder pcspk: convert "pit" property type from ptr to link vmport: identify vmport type by macro TYPE_VMPORT pflash: make TYPE_CFI_PFLASH0{1,2} macros public Q35: implement property interfece to several parameters pc_q35: configure Q35 instance using properties pckbd: handle A20 IRQ as GPIO port92: handle A20 IRQ as GPIO ICH9 SMB: make TYPE_ICH9_SMB_DEVICE macro public ICH9 LPC: handle PIC and I/O APIC IRQs as qdev GPIO ICH9 LPC: move call of isa_bus_irqs to 'realize' method MC146818 RTC: add GPIO access to output IRQ ICH9 LPC: configure PCI IRQs routing internally hw/audio/pcspk.c | 7 +- hw/block/pflash_cfi01.c | 1 - hw/block/pflash_cfi02.c | 1 - hw/i2c/smbus_ich9.c | 1 - hw/i386/pc.c | 10 +- hw/i386/pc_q35.c | 35 ++- hw/ide/ahci.c | 2 +- hw/ide/ahci.h | 405 ----------------------------- hw/ide/internal.h | 635 ---------------------------------------------- hw/ide/pci.h | 76 ------ hw/input/pckbd.c | 21 +- hw/isa/lpc_ich9.c | 16 +- hw/misc/vmport.c | 1 - hw/pci-host/q35.c | 20 ++ hw/timer/mc146818rtc.c | 4 +- include/hw/audio/pcspk.h | 2 +- include/hw/block/flash.h | 3 + include/hw/i386/ich9.h | 9 +- include/hw/i386/pc.h | 5 +- include/hw/ide/ahci.h | 405 +++++++++++++++++++++++++++++ include/hw/ide/internal.h | 635 ++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ide/pci.h | 76 ++++++ include/hw/pci-host/q35.h | 5 + 23 files changed, 1208 insertions(+), 1167 deletions(-) delete mode 100644 hw/ide/ahci.h delete mode 100644 hw/ide/internal.h delete mode 100644 hw/ide/pci.h create mode 100644 include/hw/ide/ahci.h create mode 100644 include/hw/ide/internal.h create mode 100644 include/hw/ide/pci.h -- 2.7.4