From d307c28ca9dba7a0677035c9244198b05164c873 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Mon, 9 Jan 2017 11:40:20 +0000 Subject: i2c: Allow I2C devices to NAK start events Add a return value to the event handler. Some I2C devices will NAK if they have no data, so allow them to do this. This required the following changes: Go through all the event handlers and change them to return int and return 0. Modify i2c_start_transfer to terminate the transaction on a NAK. Modify smbus handing to not assert if a NAK occurs on a second operation, and terminate the transaction and return -1 instead. Add some information on semantics to I2CSlaveClass. Signed-off-by: Corey Minyard Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/i2c/i2c.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index c4085aa366..2ce611d4c8 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -32,14 +32,22 @@ typedef struct I2CSlaveClass /* Callbacks provided by the device. */ int (*init)(I2CSlave *dev); - /* Master to slave. */ + /* Master to slave. Returns non-zero for a NAK, 0 for success. */ int (*send)(I2CSlave *s, uint8_t data); - /* Slave to master. */ + /* + * Slave to master. This cannot fail, the device should always + * return something here. Negative values probably result in 0xff + * and a possible log from the driver, and shouldn't be used. + */ int (*recv)(I2CSlave *s); - /* Notify the slave of a bus state change. */ - void (*event)(I2CSlave *s, enum i2c_event event); + /* + * Notify the slave of a bus state change. For start event, + * returns non-zero to NAK an operation. For other events the + * return code is not used and should be zero. + */ + int (*event)(I2CSlave *s, enum i2c_event event); } I2CSlaveClass; struct I2CSlave -- cgit v1.2.3 From 6e2ed65f4a523afa740f61ffe887a5fd62ef2644 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:21 +0000 Subject: hw/arm/virt-acpi-build: name GIC CPU Interface Structure appropriately Also move the enabled flag definition from mach-virt code to acpi common. Signed-off-by: Andrew Jones Message-id: 20170102200153.28864-3-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/acpi/acpi-defs.h | 9 ++++++--- include/hw/arm/virt-acpi-build.h | 2 -- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 154f3b82f6..510f23c931 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -290,7 +290,7 @@ typedef struct AcpiMultipleApicTable AcpiMultipleApicTable; #define ACPI_APIC_XRUPT_SOURCE 8 #define ACPI_APIC_LOCAL_X2APIC 9 #define ACPI_APIC_LOCAL_X2APIC_NMI 10 -#define ACPI_APIC_GENERIC_INTERRUPT 11 +#define ACPI_APIC_GENERIC_CPU_INTERFACE 11 #define ACPI_APIC_GENERIC_DISTRIBUTOR 12 #define ACPI_APIC_GENERIC_MSI_FRAME 13 #define ACPI_APIC_GENERIC_REDISTRIBUTOR 14 @@ -361,7 +361,7 @@ struct AcpiMadtLocalX2ApicNmi { } QEMU_PACKED; typedef struct AcpiMadtLocalX2ApicNmi AcpiMadtLocalX2ApicNmi; -struct AcpiMadtGenericInterrupt { +struct AcpiMadtGenericCpuInterface { ACPI_SUB_HEADER_DEF uint16_t reserved; uint32_t cpu_interface_number; @@ -378,7 +378,10 @@ struct AcpiMadtGenericInterrupt { uint64_t arm_mpidr; } QEMU_PACKED; -typedef struct AcpiMadtGenericInterrupt AcpiMadtGenericInterrupt; +typedef struct AcpiMadtGenericCpuInterface AcpiMadtGenericCpuInterface; + +/* GICC CPU Interface Flags */ +#define ACPI_MADT_GICC_ENABLED 1 struct AcpiMadtGenericDistributor { ACPI_SUB_HEADER_DEF diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h index f5ec749b8f..2bcd22265c 100644 --- a/include/hw/arm/virt-acpi-build.h +++ b/include/hw/arm/virt-acpi-build.h @@ -24,8 +24,6 @@ #include "hw/arm/virt.h" #include "qemu/notify.h" -#define ACPI_GICC_ENABLED 1 - typedef struct VirtGuestInfo { int smp_cpus; FWCfgState *fw_cfg; -- cgit v1.2.3 From aca4bbf4a36fcaff6b7dbe45e2fc5bcb6b2dc4ab Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:21 +0000 Subject: hw/arm/virt-acpi-build: gtdt: improve flag naming Also remove all unused flags. Signed-off-by: Andrew Jones Message-id: 20170102200153.28864-4-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/acpi/acpi-defs.h | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 510f23c931..8fe0996e15 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -430,21 +430,8 @@ typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator; /* * Generic Timer Description Table (GTDT) */ - -#define ACPI_GTDT_INTERRUPT_MODE (1 << 0) -#define ACPI_GTDT_INTERRUPT_POLARITY (1 << 1) -#define ACPI_GTDT_ALWAYS_ON (1 << 2) - -/* Triggering */ - -#define ACPI_LEVEL_SENSITIVE ((uint8_t) 0x00) -#define ACPI_EDGE_SENSITIVE ((uint8_t) 0x01) - -/* Polarity */ - -#define ACPI_ACTIVE_HIGH ((uint8_t) 0x00) -#define ACPI_ACTIVE_LOW ((uint8_t) 0x01) -#define ACPI_ACTIVE_BOTH ((uint8_t) 0x02) +#define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0) +#define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2) struct AcpiGenericTimerTable { ACPI_TABLE_HEADER_DEF -- cgit v1.2.3 From 8c92c6a43e3d0aabe5bb81e5fb709d2791e9c4c4 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:21 +0000 Subject: hw/arm/virt-acpi-build: fadt: improve flag naming Signed-off-by: Andrew Jones Message-id: 20170102200153.28864-5-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/acpi/acpi-defs.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 8fe0996e15..d15b7e5cd3 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -191,10 +191,8 @@ struct AcpiFadtDescriptorRev5_1 { typedef struct AcpiFadtDescriptorRev5_1 AcpiFadtDescriptorRev5_1; -enum { - ACPI_FADT_ARM_USE_PSCI_G_0_2 = 0, - ACPI_FADT_ARM_PSCI_USE_HVC = 1, -}; +#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) +#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1) /* * Serial Port Console Redirection Table (SPCR), Rev. 1.02 -- cgit v1.2.3 From 054f4dc961490b81139304106e4312c356303a6f Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:22 +0000 Subject: hw/arm/virt: eliminate struct VirtGuestInfoState Instead of allocating a new struct just for VirtGuestInfo and the machine_done Notifier, place them inside VirtMachineState. This is the mach-virt equivalent of "pc: Eliminate struct PcGuestInfoState" Suggested-by: Eduardo Habkost Signed-off-by: Andrew Jones Reviewed-by: Igor Mammedov Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-8-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/virt-acpi-build.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h index 2bcd22265c..925c434738 100644 --- a/include/hw/arm/virt-acpi-build.h +++ b/include/hw/arm/virt-acpi-build.h @@ -34,12 +34,6 @@ typedef struct VirtGuestInfo { bool no_its; } VirtGuestInfo; - -typedef struct VirtGuestInfoState { - VirtGuestInfo info; - Notifier machine_done; -} VirtGuestInfoState; - void virt_acpi_setup(VirtGuestInfo *guest_info); #endif -- cgit v1.2.3 From d05fdab46d9c5a33654de1bd54fca375347341ce Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:22 +0000 Subject: hw/arm/virt: remove include/hw/arm/virt-acpi-build.h include/hw/arm/virt-acpi-build.h is only used for VirtGuestInfo, which doesn't even necessarily have to be ACPI specific. Move VirtGuestInfo to include/hw/arm/virt.h, allowing us to remove include/hw/arm/virt-acpi-build.h, and to prepare for even more code motion. Signed-off-by: Andrew Jones Reviewed-by: Igor Mammedov Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-9-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/virt-acpi-build.h | 39 --------------------------------------- include/hw/arm/virt.h | 14 +++++++++++++- 2 files changed, 13 insertions(+), 40 deletions(-) delete mode 100644 include/hw/arm/virt-acpi-build.h (limited to 'include') diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h deleted file mode 100644 index 925c434738..0000000000 --- a/include/hw/arm/virt-acpi-build.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. - * - * Author: Shannon Zhao - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2 or later, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -#ifndef QEMU_VIRT_ACPI_BUILD_H -#define QEMU_VIRT_ACPI_BUILD_H - -#include "qemu-common.h" -#include "hw/arm/virt.h" -#include "qemu/notify.h" - -typedef struct VirtGuestInfo { - int smp_cpus; - FWCfgState *fw_cfg; - const MemMapEntry *memmap; - const int *irqmap; - bool use_highmem; - int gic_version; - bool no_its; -} VirtGuestInfo; - -void virt_acpi_setup(VirtGuestInfo *guest_info); - -#endif diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 9650193253..69f78474e0 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -32,6 +32,7 @@ #include "qemu-common.h" #include "exec/hwaddr.h" +#include "qemu/notify.h" #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -74,5 +75,16 @@ typedef struct MemMapEntry { hwaddr size; } MemMapEntry; +typedef struct VirtGuestInfo { + int smp_cpus; + FWCfgState *fw_cfg; + const MemMapEntry *memmap; + const int *irqmap; + bool use_highmem; + int gic_version; + bool no_its; +} VirtGuestInfo; -#endif +void virt_acpi_setup(VirtGuestInfo *guest_info); + +#endif /* QEMU_ARM_VIRT_H */ -- cgit v1.2.3 From a72d4363875ed086acedab657d34f6fc82a7d8aa Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:22 +0000 Subject: hw/arm/virt: move VirtMachineState/Class to virt.h In preparation to share more Virt machine state than just guest-info with other mach-virt source files, move the State and Class structures to virt.h Signed-off-by: Andrew Jones Reviewed-by: Igor Mammedov Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-10-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/virt.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'include') diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 69f78474e0..91dbd69def 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -33,6 +33,8 @@ #include "qemu-common.h" #include "exec/hwaddr.h" #include "qemu/notify.h" +#include "hw/boards.h" +#include "hw/arm/arm.h" #define NUM_GICV2M_SPIS 64 #define NUM_VIRTIO_TRANSPORTS 32 @@ -85,6 +87,41 @@ typedef struct VirtGuestInfo { bool no_its; } VirtGuestInfo; +typedef struct { + MachineClass parent; + bool disallow_affinity_adjustment; + bool no_its; + bool no_pmu; + bool claim_edge_triggered_timers; +} VirtMachineClass; + +typedef struct { + MachineState parent; + VirtGuestInfo acpi_guest_info; + Notifier machine_done; + bool secure; + bool highmem; + int32_t gic_version; + struct arm_boot_info bootinfo; + const MemMapEntry *memmap; + const int *irqmap; + int smp_cpus; + void *fdt; + int fdt_size; + uint32_t clock_phandle; + uint32_t gic_phandle; + uint32_t msi_phandle; + bool using_psci; +} VirtMachineState; + +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +#define VIRT_MACHINE(obj) \ + OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE) +#define VIRT_MACHINE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(VirtMachineClass, obj, TYPE_VIRT_MACHINE) +#define VIRT_MACHINE_CLASS(klass) \ + OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) + void virt_acpi_setup(VirtGuestInfo *guest_info); #endif /* QEMU_ARM_VIRT_H */ -- cgit v1.2.3 From e9a8e474fbdedca787623f0c55f7b6e9cb97bdfc Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:22 +0000 Subject: hw/arm/virt: pass VirtMachineState instead of VirtGuestInfo Only two functions take VirtGuestInfo parameters. Now that guest-info is part of VirtMachineState, and VirtMachineState is defined in the virt header, pass that instead. Signed-off-by: Andrew Jones Reviewed-by: Igor Mammedov Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-11-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/virt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 91dbd69def..b1eed52d3b 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -122,6 +122,6 @@ typedef struct { #define VIRT_MACHINE_CLASS(klass) \ OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE) -void virt_acpi_setup(VirtGuestInfo *guest_info); +void virt_acpi_setup(VirtMachineState *vms); #endif /* QEMU_ARM_VIRT_H */ -- cgit v1.2.3 From da4f09a7dce6878b6fd27a0fb70d08701551df17 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:22 +0000 Subject: hw/arm/virt-acpi-build: remove redundant members from VirtGuestInfo Now that we pass VirtMachineState, and guest-info is just part of that state, we can remove all the redundant members and access the VirtMachineState directly. Signed-off-by: Andrew Jones Reviewed-by: Igor Mammedov Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-12-drjones@redhat.com Signed-off-by: Peter Maydell --- include/hw/arm/virt.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index b1eed52d3b..d200542d0d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -78,13 +78,7 @@ typedef struct MemMapEntry { } MemMapEntry; typedef struct VirtGuestInfo { - int smp_cpus; FWCfgState *fw_cfg; - const MemMapEntry *memmap; - const int *irqmap; - bool use_highmem; - int gic_version; - bool no_its; } VirtGuestInfo; typedef struct { -- cgit v1.2.3 From af1f60a4022664b0169f9d10a3f7d732e8571617 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:23 +0000 Subject: hw/arm/virt: remove VirtGuestInfo by moving VirtGuestInfo.fw_cfg to VirtMachineState. This is the mach-virt equivalent of "pc: Move PcGuestInfo.fw_cfg to PCMachineState" and "pc: Eliminate PcGuestInfo struct" combined. Signed-off-by: Andrew Jones Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-14-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/arm/virt.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include') diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index d200542d0d..eb1c63d688 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -77,10 +77,6 @@ typedef struct MemMapEntry { hwaddr size; } MemMapEntry; -typedef struct VirtGuestInfo { - FWCfgState *fw_cfg; -} VirtGuestInfo; - typedef struct { MachineClass parent; bool disallow_affinity_adjustment; @@ -91,8 +87,8 @@ typedef struct { typedef struct { MachineState parent; - VirtGuestInfo acpi_guest_info; Notifier machine_done; + FWCfgState *fw_cfg; bool secure; bool highmem; int32_t gic_version; -- cgit v1.2.3 From 8dd845d3c434cf2c799e0f86a1b53b33057b61ab Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Mon, 9 Jan 2017 11:40:23 +0000 Subject: hw/arm/virt-acpi-build: Don't incorrectly claim architectural timer to be edge-triggered This is the ACPI equivalent to "hw/arm/virt: Don't incorrectly claim architectural timer to be edge-triggered" which fixes the DT for machine types 2.9 and later. Signed-off-by: Andrew Jones Acked-by: Michael S. Tsirkin Message-id: 20170102200153.28864-15-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/acpi/acpi-defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index d15b7e5cd3..d43ec005cb 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -428,6 +428,7 @@ typedef struct AcpiMadtGenericTranslator AcpiMadtGenericTranslator; /* * Generic Timer Description Table (GTDT) */ +#define ACPI_GTDT_INTERRUPT_MODE_LEVEL (0 << 0) #define ACPI_GTDT_INTERRUPT_MODE_EDGE (1 << 0) #define ACPI_GTDT_CAP_ALWAYS_ON (1 << 2) -- cgit v1.2.3