From da34e65cb4025728566d6504a99916f6e7e1dd6a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Mar 2016 09:01:28 +0100 Subject: include/qemu/osdep.h: Don't include qapi/error.h Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the Error typedef. Since then, we've moved to include qemu/osdep.h everywhere. Its file comment explains: "To avoid getting into possible circular include dependencies, this file should not include any other QEMU headers, with the exceptions of config-host.h, compiler.h, os-posix.h and os-win32.h, all of which are doing a similar job to this file and are under similar constraints." qapi/error.h doesn't do a similar job, and it doesn't adhere to similar constraints: it includes qapi-types.h. That's in excess of 100KiB of crap most .c files don't actually need. Add the typedef to qemu/typedefs.h, and include that instead of qapi/error.h. Include qapi/error.h in .c files that need it and don't get it now. Include qapi-types.h in qom/object.h for uint16List. Update scripts/clean-includes accordingly. Update it further to match reality: replace config.h by config-target.h, add sysemu/os-posix.h, sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h comment quoted above similarly. This reduces the number of objects depending on qapi/error.h from "all of them" to less than a third. Unfortunately, the number depending on qapi-types.h shrinks only a little. More work is needed for that one. Signed-off-by: Markus Armbruster [Fix compilation without the spice devel packages. - Paolo] Signed-off-by: Paolo Bonzini --- include/qapi/error.h | 5 ----- include/qemu/osdep.h | 9 +++++---- include/qemu/typedefs.h | 1 + include/qom/object.h | 1 + include/ui/qemu-spice.h | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/qapi/error.h b/include/qapi/error.h index 02e9dd20a7..11be2327c0 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -117,11 +117,6 @@ #include "qapi-types.h" -/* - * Opaque error object. - */ -typedef struct Error Error; - /* * Overall category of an error. * Based on the qapi type QapiErrorClass, but reproduced here for nicer diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 4538fdca42..1c0ce4a1c7 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -7,8 +7,10 @@ * * To avoid getting into possible circular include dependencies, this * file should not include any other QEMU headers, with the exceptions - * of config-host.h, compiler.h, os-posix.h and os-win32.h, all of which - * are doing a similar job to this file and are under similar constraints. + * of config-host.h, config-target.h, qemu/compiler.h, + * sysemu/os-posix.h, sysemu/os-win32.h, glib-compat.h and + * qemu/typedefs.h, all of which are doing a similar job to this file + * and are under similar constraints. * * This header also contains prototypes for functions defined in * os-*.c and util/oslib-*.c; those would probably be better split @@ -98,8 +100,7 @@ extern int daemon(int, int); #endif #include "glib-compat.h" - -#include "qapi/error.h" +#include "qemu/typedefs.h" #ifndef O_LARGEFILE #define O_LARGEFILE 0 diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index fd039e0e81..c987db6ddf 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -26,6 +26,7 @@ typedef struct DisplayChangeListener DisplayChangeListener; typedef struct DisplayState DisplayState; typedef struct DisplaySurface DisplaySurface; typedef struct DriveInfo DriveInfo; +typedef struct Error Error; typedef struct EventNotifier EventNotifier; typedef struct FWCfgIoState FWCfgIoState; typedef struct FWCfgMemState FWCfgMemState; diff --git a/include/qom/object.h b/include/qom/object.h index eda16df005..0eba22ef83 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -15,6 +15,7 @@ #define QEMU_OBJECT_H #include +#include "qapi-types.h" #include "qemu/queue.h" #include "qemu/typedefs.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 2dabe49f41..aa2436355f 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -18,11 +18,11 @@ #ifndef QEMU_SPICE_H #define QEMU_SPICE_H +#include "qapi/error.h" #ifdef CONFIG_SPICE #include - #include "qemu/option.h" #include "qemu/config-file.h" -- cgit v1.2.3 From 14b6d44d4720681a57b5d2c58cabdfc6364f8263 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Mar 2016 10:00:42 +0100 Subject: Use scripts/clean-includes to drop redundant qemu/typedefs.h Re-run scripts/clean-includes to apply the previous commit's corrections and updates. Besides redundant qemu/typedefs.h, this only finds a redundant config-host.h include in ui/egl-helpers.c. No idea how that escaped the previous runs. Some manual whitespace trimming around dropped includes squashed in. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/block/accounting.h | 2 -- include/block/aio.h | 1 - include/block/write-threshold.h | 2 -- include/exec/cpu-common.h | 1 - include/exec/memory.h | 1 - include/hw/acpi/acpi.h | 1 - include/hw/acpi/piix4.h | 2 -- include/hw/acpi/tco.h | 1 - include/hw/boards.h | 1 - include/hw/char/digic-uart.h | 1 - include/hw/hotplug.h | 1 - include/hw/i386/pc.h | 1 - include/hw/nvram/fw_cfg.h | 1 - include/hw/qdev-core.h | 1 - include/hw/scsi/scsi.h | 1 - include/hw/timer/digic-timer.h | 1 - include/hw/vfio/vfio.h | 2 -- include/hw/xen/xen.h | 1 - include/monitor/qdev.h | 1 - include/net/filter.h | 1 - include/qapi/visitor.h | 1 - include/qemu-common.h | 1 - include/qemu/coroutine.h | 1 - include/qemu/option.h | 1 - include/qemu/timer.h | 1 - include/qom/cpu.h | 1 - include/qom/object.h | 1 - include/sysemu/accel.h | 1 - include/sysemu/block-backend.h | 2 -- include/sysemu/memory_mapping.h | 1 - include/sysemu/replay.h | 1 - include/sysemu/sysemu.h | 1 - include/ui/console.h | 1 - include/ui/qemu-pixman.h | 2 -- 34 files changed, 40 deletions(-) (limited to 'include') diff --git a/include/block/accounting.h b/include/block/accounting.h index 2db2a009a1..20891639d5 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -25,8 +25,6 @@ #ifndef BLOCK_ACCOUNTING_H #define BLOCK_ACCOUNTING_H - -#include "qemu/typedefs.h" #include "qemu/timed-average.h" typedef struct BlockAcctTimedStats BlockAcctTimedStats; diff --git a/include/block/aio.h b/include/block/aio.h index e086e3b4ee..88a64eeb3c 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -14,7 +14,6 @@ #ifndef QEMU_AIO_H #define QEMU_AIO_H -#include "qemu/typedefs.h" #include "qemu-common.h" #include "qemu/queue.h" #include "qemu/event_notifier.h" diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h index 8a79505ada..234d2193e0 100644 --- a/include/block/write-threshold.h +++ b/include/block/write-threshold.h @@ -12,8 +12,6 @@ #ifndef BLOCK_WRITE_THRESHOLD_H #define BLOCK_WRITE_THRESHOLD_H - -#include "qemu/typedefs.h" #include "qemu-common.h" /* diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index a0ad2acb43..9e839e50cd 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -14,7 +14,6 @@ #include "qemu/bswap.h" #include "qemu/queue.h" #include "qemu/fprintf-fn.h" -#include "qemu/typedefs.h" /** * CPUListState: diff --git a/include/exec/memory.h b/include/exec/memory.h index 2de789871d..e2a3e9953c 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -31,7 +31,6 @@ #include "qemu/notify.h" #include "qom/object.h" #include "qemu/rcu.h" -#include "qemu/typedefs.h" #define MAX_PHYS_ADDR_SPACE_BITS 62 #define MAX_PHYS_ADDR (((hwaddr)1 << MAX_PHYS_ADDR_SPACE_BITS) - 1) diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 7462e20fe3..443687d484 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -19,7 +19,6 @@ * . */ -#include "qemu/typedefs.h" #include "qemu/notify.h" #include "qemu/option.h" #include "exec/memory.h" diff --git a/include/hw/acpi/piix4.h b/include/hw/acpi/piix4.h index 65e6fd7aa0..26c2370e30 100644 --- a/include/hw/acpi/piix4.h +++ b/include/hw/acpi/piix4.h @@ -1,8 +1,6 @@ #ifndef HW_ACPI_PIIX4_H #define HW_ACPI_PIIX4_H -#include "qemu/typedefs.h" - Object *piix4_pm_find(void); #endif diff --git a/include/hw/acpi/tco.h b/include/hw/acpi/tco.h index c63afc8ca3..52ad767ddd 100644 --- a/include/hw/acpi/tco.h +++ b/include/hw/acpi/tco.h @@ -9,7 +9,6 @@ #ifndef HW_ACPI_TCO_H #define HW_ACPI_TCO_H -#include "qemu/typedefs.h" #include "qemu-common.h" /* As per ICH9 spec, the internal timer has an error of ~0.6s on every tick */ diff --git a/include/hw/boards.h b/include/hw/boards.h index 8efce0f91e..aad5f2a99f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -3,7 +3,6 @@ #ifndef HW_BOARDS_H #define HW_BOARDS_H -#include "qemu/typedefs.h" #include "sysemu/blockdev.h" #include "sysemu/accel.h" #include "hw/qdev.h" diff --git a/include/hw/char/digic-uart.h b/include/hw/char/digic-uart.h index ef83a3059c..7b3f145372 100644 --- a/include/hw/char/digic-uart.h +++ b/include/hw/char/digic-uart.h @@ -19,7 +19,6 @@ #define HW_CHAR_DIGIC_UART_H #include "hw/sysbus.h" -#include "qemu/typedefs.h" #define TYPE_DIGIC_UART "digic-uart" #define DIGIC_UART(obj) \ diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h index 2db025d0bd..da1d0e4ab8 100644 --- a/include/hw/hotplug.h +++ b/include/hw/hotplug.h @@ -13,7 +13,6 @@ #define HOTPLUG_H #include "qom/object.h" -#include "qemu/typedefs.h" #define TYPE_HOTPLUG_HANDLER "hotplug-handler" diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 847d92f550..96f0b66c77 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -2,7 +2,6 @@ #define HW_PC_H #include "qemu-common.h" -#include "qemu/typedefs.h" #include "exec/memory.h" #include "hw/boards.h" #include "hw/isa/isa.h" diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 4315f4e582..10a99715b2 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -4,7 +4,6 @@ #ifndef NO_QEMU_PROTOS #include "exec/hwaddr.h" -#include "qemu/typedefs.h" #endif #define FW_CFG_SIGNATURE 0x00 diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index c3ff99f975..1ce02b20da 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -3,7 +3,6 @@ #include "qemu/queue.h" #include "qemu/option.h" -#include "qemu/typedefs.h" #include "qemu/bitmap.h" #include "qom/object.h" #include "hw/irq.h" diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 29052f81a5..8acd3fa998 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -2,7 +2,6 @@ #define QEMU_HW_SCSI_H #include "hw/qdev.h" -#include "qemu/typedefs.h" #include "hw/block/block.h" #include "sysemu/sysemu.h" #include "qemu/notify.h" diff --git a/include/hw/timer/digic-timer.h b/include/hw/timer/digic-timer.h index ae913482c6..d9e67fe291 100644 --- a/include/hw/timer/digic-timer.h +++ b/include/hw/timer/digic-timer.h @@ -19,7 +19,6 @@ #define HW_TIMER_DIGIC_TIMER_H #include "hw/sysbus.h" -#include "qemu/typedefs.h" #include "hw/ptimer.h" #define TYPE_DIGIC_TIMER "digic-timer" diff --git a/include/hw/vfio/vfio.h b/include/hw/vfio/vfio.h index 7153604cd1..f27d599220 100644 --- a/include/hw/vfio/vfio.h +++ b/include/hw/vfio/vfio.h @@ -1,8 +1,6 @@ #ifndef VFIO_API_H #define VFIO_API_H -#include "qemu/typedefs.h" - bool vfio_eeh_as_ok(AddressSpace *as); int vfio_eeh_as_op(AddressSpace *as, uint32_t op); diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index bf3fe97927..6eb815aace 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -9,7 +9,6 @@ #include "hw/irq.h" #include "qemu-common.h" -#include "qemu/typedefs.h" /* xen-machine.c */ enum xen_mode { diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index 50ec2ffc12..c4b8a05146 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -2,7 +2,6 @@ #define QEMU_QDEV_MONITOR_H #include "hw/qdev-core.h" -#include "qemu/typedefs.h" /*** monitor commands ***/ diff --git a/include/net/filter.h b/include/net/filter.h index cfb11728df..0c4a2ea6c9 100644 --- a/include/net/filter.h +++ b/include/net/filter.h @@ -11,7 +11,6 @@ #include "qom/object.h" #include "qemu-common.h" -#include "qemu/typedefs.h" #include "net/queue.h" #define TYPE_NETFILTER "netfilter" diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 1000da2bda..9a8d0105fb 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -14,7 +14,6 @@ #ifndef QAPI_VISITOR_CORE_H #define QAPI_VISITOR_CORE_H -#include "qemu/typedefs.h" #include "qapi/qmp/qobject.h" /* This struct is layout-compatible with all other *List structs diff --git a/include/qemu-common.h b/include/qemu-common.h index 887ca71c8a..2de4ce2019 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -12,7 +12,6 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "qemu/typedefs.h" #include "qemu/fprintf-fn.h" #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 99b939846b..305fe76c29 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -15,7 +15,6 @@ #ifndef QEMU_COROUTINE_H #define QEMU_COROUTINE_H -#include "qemu/typedefs.h" #include "qemu/queue.h" #include "qemu/timer.h" diff --git a/include/qemu/option.h b/include/qemu/option.h index 8809ce1e75..8542d2dfd6 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -28,7 +28,6 @@ #include "qemu/queue.h" #include "qapi/qmp/qdict.h" -#include "qemu/typedefs.h" const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); const char *get_opt_value(char *buf, int buf_size, const char *p); diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 7197d0859a..028e309b7b 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -1,7 +1,6 @@ #ifndef QEMU_TIMER_H #define QEMU_TIMER_H -#include "qemu/typedefs.h" #include "qemu-common.h" #include "qemu/notify.h" #include "qemu/host-utils.h" diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 7052eee7b7..0b6fa2507c 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -27,7 +27,6 @@ #include "exec/memattrs.h" #include "qemu/queue.h" #include "qemu/thread.h" -#include "qemu/typedefs.h" typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size, void *opaque); diff --git a/include/qom/object.h b/include/qom/object.h index 0eba22ef83..21bb5ff149 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -17,7 +17,6 @@ #include #include "qapi-types.h" #include "qemu/queue.h" -#include "qemu/typedefs.h" struct TypeImpl; typedef struct TypeImpl *Type; diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 997720f36c..a74b2faf5f 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -23,7 +23,6 @@ #ifndef HW_ACCEL_H #define HW_ACCEL_H -#include "qemu/typedefs.h" #include "qom/object.h" typedef struct AccelState { diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index d839bffeb0..70f4eaf1e7 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -13,8 +13,6 @@ #ifndef BLOCK_BACKEND_H #define BLOCK_BACKEND_H -#include "qemu/typedefs.h" - /* * TODO Have to include block/block.h for a bunch of block layer * types. Unfortunately, this pulls in the whole BlockDriverState diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h index d46d879b94..706152d533 100644 --- a/include/sysemu/memory_mapping.h +++ b/include/sysemu/memory_mapping.h @@ -15,7 +15,6 @@ #define MEMORY_MAPPING_H #include "qemu/queue.h" -#include "qemu/typedefs.h" #include "exec/memory.h" typedef struct GuestPhysBlock { diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index e7989199fc..5854adc4e6 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -13,7 +13,6 @@ */ #include "qapi-types.h" -#include "qemu/typedefs.h" /* replay clock kinds */ enum ReplayClockKind { diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 3bb8897727..38fb3cad35 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -2,7 +2,6 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ -#include "qemu/typedefs.h" #include "qemu/option.h" #include "qemu/queue.h" #include "qemu/timer.h" diff --git a/include/ui/console.h b/include/ui/console.h index f63697182f..eb9419dfd6 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -5,7 +5,6 @@ #include "qom/object.h" #include "qapi/qmp/qdict.h" #include "qemu/notify.h" -#include "qemu/typedefs.h" #include "qapi-types.h" #ifdef CONFIG_OPENGL diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h index e34c4effcb..4a67e01232 100644 --- a/include/ui/qemu-pixman.h +++ b/include/ui/qemu-pixman.h @@ -16,8 +16,6 @@ #pragma GCC diagnostic pop #endif -#include "qemu/typedefs.h" - /* * pixman image formats are defined to be native endian, * that means host byte order on qemu. So we go define -- cgit v1.2.3 From c80f6e9caa7647b576966534aaa0dc8f1b480f2b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Mar 2016 11:25:21 +0100 Subject: Clean up includes some more Manually drop redundant includes that scripts/clean-includes misses, e.g. because they're hidden in generator programs, or they use the wrong kind of delimiter. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/hw/acpi/pcihp.h | 1 - include/qemu/range.h | 1 - 2 files changed, 2 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h index 31b7820b6f..79a43923e8 100644 --- a/include/hw/acpi/pcihp.h +++ b/include/hw/acpi/pcihp.h @@ -27,7 +27,6 @@ #ifndef HW_ACPI_PCIHP_H #define HW_ACPI_PCIHP_H -#include #include "hw/acpi/acpi.h" #include "migration/vmstate.h" diff --git a/include/qemu/range.h b/include/qemu/range.h index 9fc547b9cb..c903eb574a 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -1,7 +1,6 @@ #ifndef QEMU_RANGE_H #define QEMU_RANGE_H -#include #include "qemu/queue.h" /* -- cgit v1.2.3 From 6f061ea10f28c6cbe3ea588e84ef1f5fd27f0299 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 10 Mar 2016 14:09:58 +0100 Subject: fw_cfg: Split fw_cfg_keys.h off fw_cfg.h Much of fw_cfg.h's contents is #ifndef NO_QEMU_PROTOS. This lets a few places include it without satisfying the dependencies of the suppressed code. If you somehow include it with NO_QEMU_PROTOS, any future includes are ignored. Unnecessarily unclean. Move the stuff not under NO_QEMU_PROTOS into its own header fw_cfg_keys.h, and include it as appropriate. Tidy up the moved code to please checkpatch. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/hw/nvram/fw_cfg.h | 49 +----------------------------------------- include/hw/nvram/fw_cfg_keys.h | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 48 deletions(-) create mode 100644 include/hw/nvram/fw_cfg_keys.h (limited to 'include') diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 10a99715b2..d5169895dc 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -1,54 +1,9 @@ #ifndef FW_CFG_H #define FW_CFG_H -#ifndef NO_QEMU_PROTOS - #include "exec/hwaddr.h" -#endif +#include "hw/nvram/fw_cfg_keys.h" -#define FW_CFG_SIGNATURE 0x00 -#define FW_CFG_ID 0x01 -#define FW_CFG_UUID 0x02 -#define FW_CFG_RAM_SIZE 0x03 -#define FW_CFG_NOGRAPHIC 0x04 -#define FW_CFG_NB_CPUS 0x05 -#define FW_CFG_MACHINE_ID 0x06 -#define FW_CFG_KERNEL_ADDR 0x07 -#define FW_CFG_KERNEL_SIZE 0x08 -#define FW_CFG_KERNEL_CMDLINE 0x09 -#define FW_CFG_INITRD_ADDR 0x0a -#define FW_CFG_INITRD_SIZE 0x0b -#define FW_CFG_BOOT_DEVICE 0x0c -#define FW_CFG_NUMA 0x0d -#define FW_CFG_BOOT_MENU 0x0e -#define FW_CFG_MAX_CPUS 0x0f -#define FW_CFG_KERNEL_ENTRY 0x10 -#define FW_CFG_KERNEL_DATA 0x11 -#define FW_CFG_INITRD_DATA 0x12 -#define FW_CFG_CMDLINE_ADDR 0x13 -#define FW_CFG_CMDLINE_SIZE 0x14 -#define FW_CFG_CMDLINE_DATA 0x15 -#define FW_CFG_SETUP_ADDR 0x16 -#define FW_CFG_SETUP_SIZE 0x17 -#define FW_CFG_SETUP_DATA 0x18 -#define FW_CFG_FILE_DIR 0x19 - -#define FW_CFG_FILE_FIRST 0x20 -#define FW_CFG_FILE_SLOTS 0x10 -#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS) - -#define FW_CFG_WRITE_CHANNEL 0x4000 -#define FW_CFG_ARCH_LOCAL 0x8000 -#define FW_CFG_ENTRY_MASK ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL) - -#define FW_CFG_INVALID 0xffff - -/* width in bytes of fw_cfg control register */ -#define FW_CFG_CTL_SIZE 0x02 - -#define FW_CFG_MAX_FILE_PATH 56 - -#ifndef NO_QEMU_PROTOS typedef struct FWCfgFile { uint32_t size; /* file size */ uint16_t select; /* write this to 0x510 to read it */ @@ -220,6 +175,4 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, FWCfgState *fw_cfg_find(void); -#endif /* NO_QEMU_PROTOS */ - #endif diff --git a/include/hw/nvram/fw_cfg_keys.h b/include/hw/nvram/fw_cfg_keys.h new file mode 100644 index 0000000000..0f3e871884 --- /dev/null +++ b/include/hw/nvram/fw_cfg_keys.h @@ -0,0 +1,46 @@ +#ifndef FW_CFG_KEYS_H +#define FW_CFG_KEYS_H + +#define FW_CFG_SIGNATURE 0x00 +#define FW_CFG_ID 0x01 +#define FW_CFG_UUID 0x02 +#define FW_CFG_RAM_SIZE 0x03 +#define FW_CFG_NOGRAPHIC 0x04 +#define FW_CFG_NB_CPUS 0x05 +#define FW_CFG_MACHINE_ID 0x06 +#define FW_CFG_KERNEL_ADDR 0x07 +#define FW_CFG_KERNEL_SIZE 0x08 +#define FW_CFG_KERNEL_CMDLINE 0x09 +#define FW_CFG_INITRD_ADDR 0x0a +#define FW_CFG_INITRD_SIZE 0x0b +#define FW_CFG_BOOT_DEVICE 0x0c +#define FW_CFG_NUMA 0x0d +#define FW_CFG_BOOT_MENU 0x0e +#define FW_CFG_MAX_CPUS 0x0f +#define FW_CFG_KERNEL_ENTRY 0x10 +#define FW_CFG_KERNEL_DATA 0x11 +#define FW_CFG_INITRD_DATA 0x12 +#define FW_CFG_CMDLINE_ADDR 0x13 +#define FW_CFG_CMDLINE_SIZE 0x14 +#define FW_CFG_CMDLINE_DATA 0x15 +#define FW_CFG_SETUP_ADDR 0x16 +#define FW_CFG_SETUP_SIZE 0x17 +#define FW_CFG_SETUP_DATA 0x18 +#define FW_CFG_FILE_DIR 0x19 + +#define FW_CFG_FILE_FIRST 0x20 +#define FW_CFG_FILE_SLOTS 0x10 +#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST + FW_CFG_FILE_SLOTS) + +#define FW_CFG_WRITE_CHANNEL 0x4000 +#define FW_CFG_ARCH_LOCAL 0x8000 +#define FW_CFG_ENTRY_MASK (~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)) + +#define FW_CFG_INVALID 0xffff + +/* width in bytes of fw_cfg control register */ +#define FW_CFG_CTL_SIZE 0x02 + +#define FW_CFG_MAX_FILE_PATH 56 + +#endif -- cgit v1.2.3 From daf015ef5ab7b67f4676fcbe74c57b1709f6cb70 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 9 Mar 2016 10:52:44 +0100 Subject: include/qemu/iov.h: Don't include qemu-common.h qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." qemu/iov.h includes qemu-common.h for QEMUIOVector stuff. Move all that to qemu/iov.h and drop the ill-advised include. Include qemu/iov.h where the QEMUIOVector stuff is now missing. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/block/block.h | 2 +- include/hw/ppc/mac_dbdma.h | 1 + include/hw/usb.h | 1 + include/qemu-common.h | 28 ---------------------------- include/qemu/iov.h | 30 ++++++++++++++++++++++++++++-- include/sysemu/block-backend.h | 2 ++ 6 files changed, 33 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index 01349efad5..47e80bc204 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -2,7 +2,7 @@ #define BLOCK_H #include "block/aio.h" -#include "qemu-common.h" +#include "qemu/iov.h" #include "qemu/option.h" #include "qemu/coroutine.h" #include "block/accounting.h" diff --git a/include/hw/ppc/mac_dbdma.h b/include/hw/ppc/mac_dbdma.h index c6870212e9..0cce4e8bb4 100644 --- a/include/hw/ppc/mac_dbdma.h +++ b/include/hw/ppc/mac_dbdma.h @@ -23,6 +23,7 @@ #define HW_MAC_DBDMA_H 1 #include "exec/memory.h" +#include "qemu/iov.h" typedef struct DBDMA_io DBDMA_io; diff --git a/include/hw/usb.h b/include/hw/usb.h index c8b6e7b571..163fe0490b 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -26,6 +26,7 @@ */ #include "hw/qdev.h" +#include "qemu/iov.h" #include "qemu/queue.h" /* Constants related to the USB / PCI interaction */ diff --git a/include/qemu-common.h b/include/qemu-common.h index 2de4ce2019..b8fbd9ea62 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -364,34 +364,6 @@ ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send); #define qemu_co_send(sockfd, buf, bytes) \ qemu_co_send_recv(sockfd, buf, bytes, true) -typedef struct QEMUIOVector { - struct iovec *iov; - int niov; - int nalloc; - size_t size; -} QEMUIOVector; - -void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); -void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov); -void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); -void qemu_iovec_concat(QEMUIOVector *dst, - QEMUIOVector *src, size_t soffset, size_t sbytes); -size_t qemu_iovec_concat_iov(QEMUIOVector *dst, - struct iovec *src_iov, unsigned int src_cnt, - size_t soffset, size_t sbytes); -bool qemu_iovec_is_zero(QEMUIOVector *qiov); -void qemu_iovec_destroy(QEMUIOVector *qiov); -void qemu_iovec_reset(QEMUIOVector *qiov); -size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, - void *buf, size_t bytes); -size_t qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset, - const void *buf, size_t bytes); -size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, - int fillc, size_t bytes); -ssize_t qemu_iovec_compare(QEMUIOVector *a, QEMUIOVector *b); -void qemu_iovec_clone(QEMUIOVector *dest, const QEMUIOVector *src, void *buf); -void qemu_iovec_discard_back(QEMUIOVector *qiov, size_t bytes); - bool buffer_is_zero(const void *buf, size_t len); void qemu_progress_init(int enabled, float min_skip); diff --git a/include/qemu/iov.h b/include/qemu/iov.h index 28475516eb..bd9fd55b0a 100644 --- a/include/qemu/iov.h +++ b/include/qemu/iov.h @@ -14,8 +14,6 @@ #ifndef IOV_H #define IOV_H -#include "qemu-common.h" - /** * count and return data size, in bytes, of an iovec * starting at `iov' of `iov_cnt' number of elements. @@ -138,4 +136,32 @@ size_t iov_discard_front(struct iovec **iov, unsigned int *iov_cnt, size_t iov_discard_back(struct iovec *iov, unsigned int *iov_cnt, size_t bytes); +typedef struct QEMUIOVector { + struct iovec *iov; + int niov; + int nalloc; + size_t size; +} QEMUIOVector; + +void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); +void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov); +void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); +void qemu_iovec_concat(QEMUIOVector *dst, + QEMUIOVector *src, size_t soffset, size_t sbytes); +size_t qemu_iovec_concat_iov(QEMUIOVector *dst, + struct iovec *src_iov, unsigned int src_cnt, + size_t soffset, size_t sbytes); +bool qemu_iovec_is_zero(QEMUIOVector *qiov); +void qemu_iovec_destroy(QEMUIOVector *qiov); +void qemu_iovec_reset(QEMUIOVector *qiov); +size_t qemu_iovec_to_buf(QEMUIOVector *qiov, size_t offset, + void *buf, size_t bytes); +size_t qemu_iovec_from_buf(QEMUIOVector *qiov, size_t offset, + const void *buf, size_t bytes); +size_t qemu_iovec_memset(QEMUIOVector *qiov, size_t offset, + int fillc, size_t bytes); +ssize_t qemu_iovec_compare(QEMUIOVector *a, QEMUIOVector *b); +void qemu_iovec_clone(QEMUIOVector *dest, const QEMUIOVector *src, void *buf); +void qemu_iovec_discard_back(QEMUIOVector *qiov, size_t bytes); + #endif diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 70f4eaf1e7..c62b6fe96d 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -13,6 +13,8 @@ #ifndef BLOCK_BACKEND_H #define BLOCK_BACKEND_H +#include "qemu/iov.h" + /* * TODO Have to include block/block.h for a bunch of block layer * types. Unfortunately, this pulls in the whole BlockDriverState -- cgit v1.2.3 From 0137fdc0941cfe214e91c5c1444f3fcf6a5548b8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 9 Mar 2016 12:19:37 +0100 Subject: include/hw/hw.h: Don't include qemu-common.h qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." hw/hw.h includes qemu-common.h, but its users generally need only hw_error() and qemu/module.h from it. Move the former to hw/hw.h, include the latter there, and drop the ill-advised include. hw/misc/cbus.c now misses hw_error(), so include hw/hw.h there. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/hw/hw.h | 4 +++- include/qemu-common.h | 4 ---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/hw/hw.h b/include/hw/hw.h index cd3d410f97..2cb69d5f5b 100644 --- a/include/hw/hw.h +++ b/include/hw/hw.h @@ -2,7 +2,6 @@ #ifndef QEMU_HW_H #define QEMU_HW_H -#include "qemu-common.h" #if !defined(CONFIG_USER_ONLY) && !defined(NEED_CPU_H) #include "exec/cpu-common.h" @@ -13,6 +12,7 @@ #include "block/aio.h" #include "migration/vmstate.h" #include "qemu/log.h" +#include "qemu/module.h" #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 @@ -41,6 +41,8 @@ typedef void QEMUResetHandler(void *opaque); void qemu_register_reset(QEMUResetHandler *func, void *opaque); void qemu_unregister_reset(QEMUResetHandler *func, void *opaque); +void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); + #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 #define VMSTATE_UINTTL_V(_f, _s, _v) \ diff --git a/include/qemu-common.h b/include/qemu-common.h index b8fbd9ea62..ba37968503 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -303,10 +303,6 @@ int qemu_openpty_raw(int *aslave, char *pty_name); sendto(sockfd, buf, len, flags, destaddr, addrlen) #endif -/* Error handling. */ - -void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); - struct ParallelIOArg { void *buffer; int count; -- cgit v1.2.3 From a7c4d9c7ca5178d32236fa5b31fa7fed4e4a7a9c Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 9 Mar 2016 13:44:19 +0100 Subject: hw/pci/pci.h: Don't include qemu-common.h qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." hw/pci/pci.h includes qemu-common.h, but its users only need pcibus_t and PCIHostDeviceAddress from it. Move them to hw/pci/pci.h and drop the ill-advised include. Include hw/pci/pci.h where the moved stuff is now missing. Except we can't in target-i386/kvm_i386.h, because that would break the i386-linux-user compile. Add PCIHostDeviceAddress to qemu/typedefs.h instead. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/hw/pci/pci.h | 11 +++++++++-- include/qemu-common.h | 9 --------- include/qemu/typedefs.h | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 0be07c8352..ef6ba51f6c 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -1,8 +1,6 @@ #ifndef QEMU_PCI_H #define QEMU_PCI_H -#include "qemu-common.h" - #include "hw/qdev.h" #include "exec/memory.h" #include "sysemu/dma.h" @@ -97,6 +95,15 @@ #define FMT_PCIBUS PRIx64 +typedef uint64_t pcibus_t; + +struct PCIHostDeviceAddress { + unsigned int domain; + unsigned int bus; + unsigned int slot; + unsigned int function; +}; + typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, uint32_t address, uint32_t data, int len); typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev, diff --git a/include/qemu-common.h b/include/qemu-common.h index ba37968503..5a2d9972bd 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -310,15 +310,6 @@ struct ParallelIOArg { typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); -typedef uint64_t pcibus_t; - -typedef struct PCIHostDeviceAddress { - unsigned int domain; - unsigned int bus; - unsigned int slot; - unsigned int function; -} PCIHostDeviceAddress; - void tcg_exec_init(unsigned long tb_size); bool tcg_enabled(void); diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index c987db6ddf..1dcf6f5d53 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -66,6 +66,7 @@ typedef struct PCIEPort PCIEPort; typedef struct PCIESlot PCIESlot; typedef struct PCIExpressDevice PCIExpressDevice; typedef struct PCIExpressHost PCIExpressHost; +typedef struct PCIHostDeviceAddress PCIHostDeviceAddress; typedef struct PCIHostState PCIHostState; typedef struct PCMachineClass PCMachineClass; typedef struct PCMachineState PCMachineState; -- cgit v1.2.3 From a8139632161d7546218b696cada0a4f64cc78fb7 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 11 Mar 2016 13:41:13 +0100 Subject: Move HOST_LONG_BITS from qemu-common.h to qemu/osdep.h qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." One of the reasons for headers to include it is HOST_LONG_BITS. Move that to its more natural home qemu/osdep.h, to facilitate removing these ill-advised includes later on. This also lets us use HOST_LONG_BITS in bswap.h instead of duplicating its definition there to avoid cyclic inclusion. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/qemu-common.h | 9 --------- include/qemu/bswap.h | 6 ++---- include/qemu/osdep.h | 9 +++++++++ 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/qemu-common.h b/include/qemu-common.h index 5a2d9972bd..fbd999cbcd 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -23,15 +23,6 @@ #include "qemu/option.h" #include "qemu/host-utils.h" -/* HOST_LONG_BITS is the size of a native pointer in bits. */ -#if UINTPTR_MAX == UINT32_MAX -# define HOST_LONG_BITS 32 -#elif UINTPTR_MAX == UINT64_MAX -# define HOST_LONG_BITS 64 -#else -# error Unknown pointer size -#endif - void cpu_ticks_init(void); /* icount */ diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 95071ba9e8..fcedf0d249 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -419,11 +419,9 @@ static inline void stfq_be_p(void *ptr, float64 v) static inline unsigned long leul_to_cpu(unsigned long v) { - /* In order to break an include loop between here and - qemu-common.h, don't rely on HOST_LONG_BITS. */ -#if ULONG_MAX == UINT32_MAX +#if HOST_LONG_BITS == 32 return le_bswap(v, 32); -#elif ULONG_MAX == UINT64_MAX +#elif HOST_LONG_BITS == 64 return le_bswap(v, 64); #else # error Unknown sizeof long diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 1c0ce4a1c7..64b06e30cd 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -127,6 +127,15 @@ extern int daemon(int, int); #define TIME_MAX LONG_MAX #endif +/* HOST_LONG_BITS is the size of a native pointer in bits. */ +#if UINTPTR_MAX == UINT32_MAX +# define HOST_LONG_BITS 32 +#elif UINTPTR_MAX == UINT64_MAX +# define HOST_LONG_BITS 64 +#else +# error Unknown pointer size +#endif + #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -- cgit v1.2.3 From e07e540aaa08718c9ff8213067a3dcef31b3e313 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 11 Mar 2016 16:27:23 +0100 Subject: Move QEMU_ALIGN_*() from qemu-common.h to qemu/osdep.h qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." One of the reasons for headers to include it is QEMU_ALIGN_UP() and QEMU_ALIGN_DOWN(). Move them next to ROUND_UP() in qemu/osdep.h, to facilitate removing these ill-advised includes later on. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/qemu-common.h | 6 ------ include/qemu/osdep.h | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/qemu-common.h b/include/qemu-common.h index fbd999cbcd..f2727523e0 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -369,12 +369,6 @@ static inline uint8_t from_bcd(uint8_t val) return ((val >> 4) * 10) + (val & 0x0f); } -/* Round number down to multiple */ -#define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) - -/* Round number up to multiple */ -#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) - #include "qemu/module.h" /* diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 64b06e30cd..97a7fa22e8 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -149,6 +149,12 @@ extern int daemon(int, int); #define MIN_NON_ZERO(a, b) (((a) != 0 && (a) < (b)) ? (a) : (b)) #endif +/* Round number down to multiple */ +#define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m)) + +/* Round number up to multiple */ +#define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) + #ifndef ROUND_UP #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d)) #endif -- cgit v1.2.3 From 8a98ecada310b14b4a2c133822674e070a7ba350 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 9 Mar 2016 12:21:49 +0100 Subject: Move ParallelIOArg from qemu-common.h to sysemu/char.h ParallelIOArg is shared between just qemu-char.c and hw/char/parallel.c, and as such has no business in qemu-common.h. Move it to sysemu/char.h. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/qemu-common.h | 5 ----- include/sysemu/char.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/qemu-common.h b/include/qemu-common.h index f2727523e0..e7bd1f852f 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -294,11 +294,6 @@ int qemu_openpty_raw(int *aslave, char *pty_name); sendto(sockfd, buf, len, flags, destaddr, addrlen) #endif -struct ParallelIOArg { - void *buffer; - int count; -}; - typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); void tcg_exec_init(unsigned long tb_size); diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 4c2f777ad1..307fd8fde4 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -41,6 +41,11 @@ typedef struct { #define CHR_IOCTL_PP_EPP_WRITE 11 #define CHR_IOCTL_PP_DATA_DIR 12 +struct ParallelIOArg { + void *buffer; + int count; +}; + #define CHR_IOCTL_SERIAL_SET_TIOCM 13 #define CHR_IOCTL_SERIAL_GET_TIOCM 14 -- cgit v1.2.3 From bd36a618ccb61ea0fddb92e75f3754c4e1a7fbfe Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 9 Mar 2016 12:55:26 +0100 Subject: isa: Move DMA_transfer_handler from qemu-common.h to hw/isa/isa.h DMA_transfer_handler is actually an ISA thing, and as such has no business in qemu-common.h. Move it to hw/isa/isa.h, and rename it to IsaDmaTransferHandler. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/hw/isa/i8257.h | 2 +- include/hw/isa/isa.h | 5 ++++- include/qemu-common.h | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/isa/i8257.h b/include/hw/isa/i8257.h index 8d34ed17b7..8c44d36282 100644 --- a/include/hw/isa/i8257.h +++ b/include/hw/isa/i8257.h @@ -11,7 +11,7 @@ typedef struct I8257Regs { uint8_t pageh; uint8_t dack; uint8_t eop; - DMA_transfer_handler transfer_handler; + IsaDmaTransferHandler transfer_handler; void *opaque; } I8257Regs; diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index 0bbe21cd48..ffb2ea7cdf 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -54,6 +54,9 @@ typedef enum { ISADMA_TRANSFER_ILLEGAL, } IsaDmaTransferMode; +typedef int (*IsaDmaTransferHandler)(void *opaque, int nchan, int pos, + int size); + typedef struct IsaDmaClass { InterfaceClass parent; @@ -65,7 +68,7 @@ typedef struct IsaDmaClass { void (*release_DREQ)(IsaDma *obj, int nchan); void (*schedule)(IsaDma *obj); void (*register_channel)(IsaDma *obj, int nchan, - DMA_transfer_handler transfer_handler, + IsaDmaTransferHandler transfer_handler, void *opaque); } IsaDmaClass; diff --git a/include/qemu-common.h b/include/qemu-common.h index e7bd1f852f..bbb45b2e64 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -294,8 +294,6 @@ int qemu_openpty_raw(int *aslave, char *pty_name); sendto(sockfd, buf, len, flags, destaddr, addrlen) #endif -typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); - void tcg_exec_init(unsigned long tb_size); bool tcg_enabled(void); -- cgit v1.2.3 From 7136fc1da2690a2a8a6444311484283de0190065 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 11 Mar 2016 09:20:17 +0100 Subject: include/crypto: Include qapi-types.h or qemu/bswap.h instead of qemu-common.h qemu-common.h should only be included by .c files. Its file comment explains why: "No header file should depend on qemu-common.h, as this would easily lead to circular header dependencies." Several include/crypto/ headers include qemu-common.h, but either need just qapi-types.h from it, or qemu/bswap.h, or nothing at all. Replace or drop the include accordingly. tests/test-crypto-secret.c now misses qemu/module.h, so include it there. Signed-off-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/crypto/cipher.h | 2 +- include/crypto/hash.h | 2 +- include/crypto/init.h | 2 -- include/crypto/secret.h | 1 - include/crypto/tlscreds.h | 1 - 5 files changed, 2 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index c04c3ac9b9..d770c4835a 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -21,7 +21,7 @@ #ifndef QCRYPTO_CIPHER_H__ #define QCRYPTO_CIPHER_H__ -#include "qemu-common.h" +#include "qapi-types.h" typedef struct QCryptoCipher QCryptoCipher; diff --git a/include/crypto/hash.h b/include/crypto/hash.h index aebccd1386..f38caed669 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -21,7 +21,7 @@ #ifndef QCRYPTO_HASH_H__ #define QCRYPTO_HASH_H__ -#include "qemu-common.h" +#include "qapi-types.h" /* See also "QCryptoHashAlgorithm" defined in qapi/crypto.json */ diff --git a/include/crypto/init.h b/include/crypto/init.h index 4836a37e3f..2513ed0986 100644 --- a/include/crypto/init.h +++ b/include/crypto/init.h @@ -21,8 +21,6 @@ #ifndef QCRYPTO_INIT_H__ #define QCRYPTO_INIT_H__ -#include "qemu-common.h" - int qcrypto_init(Error **errp); #endif /* QCRYPTO_INIT_H__ */ diff --git a/include/crypto/secret.h b/include/crypto/secret.h index 60f2a502b7..b7392c6ba0 100644 --- a/include/crypto/secret.h +++ b/include/crypto/secret.h @@ -21,7 +21,6 @@ #ifndef QCRYPTO_SECRET_H__ #define QCRYPTO_SECRET_H__ -#include "qemu-common.h" #include "qom/object.h" #define TYPE_QCRYPTO_SECRET "secret" diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h index 4bf1d2e255..8e2babd533 100644 --- a/include/crypto/tlscreds.h +++ b/include/crypto/tlscreds.h @@ -21,7 +21,6 @@ #ifndef QCRYPTO_TLSCRED_H__ #define QCRYPTO_TLSCRED_H__ -#include "qemu-common.h" #include "qom/object.h" #ifdef CONFIG_GNUTLS -- cgit v1.2.3 From 73bcb24d932912f8e75e1d88da0fc0ac6d4bce78 Mon Sep 17 00:00:00 2001 From: Rutuja Shah Date: Mon, 21 Mar 2016 21:32:30 +0530 Subject: Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND This patch replaces get_ticks_per_sec() calls with the macro NANOSECONDS_PER_SECOND. Also, as there are no callers, get_ticks_per_sec() is then removed. This replacement improves the readability and understandability of code. For example, timer_mod(fdctrl->result_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() / 50)); NANOSECONDS_PER_SECOND makes it obvious that qemu_clock_get_ns matches the unit of the expression on the right side of the plus. Signed-off-by: Rutuja Shah Signed-off-by: Paolo Bonzini --- include/hw/acpi/acpi.h | 2 +- include/qemu/timer.h | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 443687d484..e0978c8b92 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -154,7 +154,7 @@ void acpi_pm_tmr_reset(ACPIREGS *ar); static inline int64_t acpi_pm_tmr_get_clock(void) { return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), PM_TIMER_FREQUENCY, - get_ticks_per_sec()); + NANOSECONDS_PER_SECOND); } /* PM1a_EVT: piix and ich9 don't implement PM1b. */ diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 028e309b7b..471969a24d 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -783,18 +783,13 @@ void cpu_enable_ticks(void); /* Caller must hold BQL */ void cpu_disable_ticks(void); -static inline int64_t get_ticks_per_sec(void) -{ - return 1000000000LL; -} - static inline int64_t get_max_clock_jump(void) { /* This should be small enough to prevent excessive interrupts from being * generated by the RTC on clock jumps, but large enough to avoid frequent * unnecessary resets in idle VMs. */ - return 60 * get_ticks_per_sec(); + return 60 * NANOSECONDS_PER_SECOND; } /* @@ -820,7 +815,7 @@ static inline int64_t get_clock(void) { LARGE_INTEGER ti; QueryPerformanceCounter(&ti); - return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); + return muldiv64(ti.QuadPart, NANOSECONDS_PER_SECOND, clock_freq); } #else -- cgit v1.2.3 From f348b6d1a53e5271cf1c9f9acc4646b4b98c1771 Mon Sep 17 00:00:00 2001 From: Veronia Bahaa Date: Sun, 20 Mar 2016 19:16:19 +0200 Subject: util: move declarations out of qemu-common.h Move declarations out of qemu-common.h for functions declared in utils/ files: e.g. include/qemu/path.h for utils/path.c. Move inline functions out of qemu-common.h and into new files (e.g. include/qemu/bcd.h) Signed-off-by: Veronia Bahaa Signed-off-by: Paolo Bonzini --- include/qemu-common.h | 257 --------------------------------------------- include/qemu/bcd.h | 15 +++ include/qemu/cutils.h | 183 ++++++++++++++++++++++++++++++++ include/qemu/help_option.h | 22 ++++ include/qemu/id.h | 13 +++ include/qemu/path.h | 7 ++ include/qemu/unicode.h | 6 ++ 7 files changed, 246 insertions(+), 257 deletions(-) create mode 100644 include/qemu/bcd.h create mode 100644 include/qemu/cutils.h create mode 100644 include/qemu/help_option.h create mode 100644 include/qemu/id.h create mode 100644 include/qemu/path.h create mode 100644 include/qemu/unicode.h (limited to 'include') diff --git a/include/qemu-common.h b/include/qemu-common.h index bbb45b2e64..163bcbb861 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -49,205 +49,6 @@ int qemu_main(int argc, char **argv, char **envp); void qemu_get_timedate(struct tm *tm, int offset); int qemu_timedate_diff(struct tm *tm); -/** - * is_help_option: - * @s: string to test - * - * Check whether @s is one of the standard strings which indicate - * that the user is asking for a list of the valid values for a - * command option like -cpu or -M. The current accepted strings - * are 'help' and '?'. '?' is deprecated (it is a shell wildcard - * which makes it annoying to use in a reliable way) but provided - * for backwards compatibility. - * - * Returns: true if @s is a request for a list. - */ -static inline bool is_help_option(const char *s) -{ - return !strcmp(s, "?") || !strcmp(s, "help"); -} - -/* util/cutils.c */ -/** - * pstrcpy: - * @buf: buffer to copy string into - * @buf_size: size of @buf in bytes - * @str: string to copy - * - * Copy @str into @buf, including the trailing NUL, but do not - * write more than @buf_size bytes. The resulting buffer is - * always NUL terminated (even if the source string was too long). - * If @buf_size is zero or negative then no bytes are copied. - * - * This function is similar to strncpy(), but avoids two of that - * function's problems: - * * if @str fits in the buffer, pstrcpy() does not zero-fill the - * remaining space at the end of @buf - * * if @str is too long, pstrcpy() will copy the first @buf_size-1 - * bytes and then add a NUL - */ -void pstrcpy(char *buf, int buf_size, const char *str); -/** - * strpadcpy: - * @buf: buffer to copy string into - * @buf_size: size of @buf in bytes - * @str: string to copy - * @pad: character to pad the remainder of @buf with - * - * Copy @str into @buf (but *not* its trailing NUL!), and then pad the - * rest of the buffer with the @pad character. If @str is too large - * for the buffer then it is truncated, so that @buf contains the - * first @buf_size characters of @str, with no terminator. - */ -void strpadcpy(char *buf, int buf_size, const char *str, char pad); -/** - * pstrcat: - * @buf: buffer containing existing string - * @buf_size: size of @buf in bytes - * @s: string to concatenate to @buf - * - * Append a copy of @s to the string already in @buf, but do not - * allow the buffer to overflow. If the existing contents of @buf - * plus @str would total more than @buf_size bytes, then write - * as much of @str as will fit followed by a NUL terminator. - * - * @buf must already contain a NUL-terminated string, or the - * behaviour is undefined. - * - * Returns: @buf. - */ -char *pstrcat(char *buf, int buf_size, const char *s); -/** - * strstart: - * @str: string to test - * @val: prefix string to look for - * @ptr: NULL, or pointer to be written to indicate start of - * the remainder of the string - * - * Test whether @str starts with the prefix @val. - * If it does (including the degenerate case where @str and @val - * are equal) then return true. If @ptr is not NULL then a - * pointer to the first character following the prefix is written - * to it. If @val is not a prefix of @str then return false (and - * @ptr is not written to). - * - * Returns: true if @str starts with prefix @val, false otherwise. - */ -int strstart(const char *str, const char *val, const char **ptr); -/** - * stristart: - * @str: string to test - * @val: prefix string to look for - * @ptr: NULL, or pointer to be written to indicate start of - * the remainder of the string - * - * Test whether @str starts with the case-insensitive prefix @val. - * This function behaves identically to strstart(), except that the - * comparison is made after calling qemu_toupper() on each pair of - * characters. - * - * Returns: true if @str starts with case-insensitive prefix @val, - * false otherwise. - */ -int stristart(const char *str, const char *val, const char **ptr); -/** - * qemu_strnlen: - * @s: string - * @max_len: maximum number of bytes in @s to scan - * - * Return the length of the string @s, like strlen(), but do not - * examine more than @max_len bytes of the memory pointed to by @s. - * If no NUL terminator is found within @max_len bytes, then return - * @max_len instead. - * - * This function has the same behaviour as the POSIX strnlen() - * function. - * - * Returns: length of @s in bytes, or @max_len, whichever is smaller. - */ -int qemu_strnlen(const char *s, int max_len); -/** - * qemu_strsep: - * @input: pointer to string to parse - * @delim: string containing delimiter characters to search for - * - * Locate the first occurrence of any character in @delim within - * the string referenced by @input, and replace it with a NUL. - * The location of the next character after the delimiter character - * is stored into @input. - * If the end of the string was reached without finding a delimiter - * character, then NULL is stored into @input. - * If @input points to a NULL pointer on entry, return NULL. - * The return value is always the original value of *@input (and - * so now points to a NUL-terminated string corresponding to the - * part of the input up to the first delimiter). - * - * This function has the same behaviour as the BSD strsep() function. - * - * Returns: the pointer originally in @input. - */ -char *qemu_strsep(char **input, const char *delim); -time_t mktimegm(struct tm *tm); -int qemu_fdatasync(int fd); -int fcntl_setfl(int fd, int flag); -int qemu_parse_fd(const char *param); -int qemu_strtol(const char *nptr, const char **endptr, int base, - long *result); -int qemu_strtoul(const char *nptr, const char **endptr, int base, - unsigned long *result); -int qemu_strtoll(const char *nptr, const char **endptr, int base, - int64_t *result); -int qemu_strtoull(const char *nptr, const char **endptr, int base, - uint64_t *result); - -int parse_uint(const char *s, unsigned long long *value, char **endptr, - int base); -int parse_uint_full(const char *s, unsigned long long *value, int base); - -/* - * qemu_strtosz() suffixes used to specify the default treatment of an - * argument passed to qemu_strtosz() without an explicit suffix. - * These should be defined using upper case characters in the range - * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument - * prior to comparison. - */ -#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E' -#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P' -#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T' -#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G' -#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M' -#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K' -#define QEMU_STRTOSZ_DEFSUFFIX_B 'B' -int64_t qemu_strtosz(const char *nptr, char **end); -int64_t qemu_strtosz_suffix(const char *nptr, char **end, - const char default_suffix); -int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end, - const char default_suffix, int64_t unit); -#define K_BYTE (1ULL << 10) -#define M_BYTE (1ULL << 20) -#define G_BYTE (1ULL << 30) -#define T_BYTE (1ULL << 40) -#define P_BYTE (1ULL << 50) -#define E_BYTE (1ULL << 60) - -/* used to print char* safely */ -#define STR_OR_NULL(str) ((str) ? (str) : "null") - -/* id.c */ - -typedef enum IdSubSystems { - ID_QDEV, - ID_BLOCK, - ID_MAX /* last element, used as array size */ -} IdSubSystems; - -char *id_generate(IdSubSystems id); -bool id_wellformed(const char *id); - -/* path.c */ -void init_paths(const char *prefix); -const char *path(const char *pathname); - #define qemu_isalnum(c) isalnum((unsigned char)(c)) #define qemu_isalpha(c) isalpha((unsigned char)(c)) #define qemu_iscntrl(c) iscntrl((unsigned char)(c)) @@ -335,8 +136,6 @@ ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send); #define qemu_co_send(sockfd, buf, bytes) \ qemu_co_send_recv(sockfd, buf, bytes, true) -bool buffer_is_zero(const void *buf, size_t len); - void qemu_progress_init(int enabled, float min_skip); void qemu_progress_end(void); void qemu_progress_print(float delta, int max); @@ -351,70 +150,14 @@ void os_setup_early_signal_handling(void); char *os_find_datadir(void); void os_parse_cmd_args(int index, const char *optarg); -/* Convert a byte between binary and BCD. */ -static inline uint8_t to_bcd(uint8_t val) -{ - return ((val / 10) << 4) | (val % 10); -} - -static inline uint8_t from_bcd(uint8_t val) -{ - return ((val >> 4) * 10) + (val & 0x0f); -} - #include "qemu/module.h" -/* - * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) - * Input is limited to 14-bit numbers - */ - -int uleb128_encode_small(uint8_t *out, uint32_t n); -int uleb128_decode_small(const uint8_t *in, uint32_t *n); - -/* unicode.c */ -int mod_utf8_codepoint(const char *s, size_t n, char **end); - /* * Hexdump a buffer to a file. An optional string prefix is added to every line */ void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size); -/* vector definitions */ -#ifdef __ALTIVEC__ -#include -/* The altivec.h header says we're allowed to undef these for - * C++ compatibility. Here we don't care about C++, but we - * undef them anyway to avoid namespace pollution. - */ -#undef vector -#undef pixel -#undef bool -#define VECTYPE __vector unsigned char -#define SPLAT(p) vec_splat(vec_ld(0, p), 0) -#define ALL_EQ(v1, v2) vec_all_eq(v1, v2) -#define VEC_OR(v1, v2) ((v1) | (v2)) -/* altivec.h may redefine the bool macro as vector type. - * Reset it to POSIX semantics. */ -#define bool _Bool -#elif defined __SSE2__ -#include -#define VECTYPE __m128i -#define SPLAT(p) _mm_set1_epi8(*(p)) -#define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 0xFFFF) -#define VEC_OR(v1, v2) (_mm_or_si128(v1, v2)) -#else -#define VECTYPE unsigned long -#define SPLAT(p) (*(p) * (~0UL / 255)) -#define ALL_EQ(v1, v2) ((v1) == (v2)) -#define VEC_OR(v1, v2) ((v1) | (v2)) -#endif - -#define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8 -bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len); -size_t buffer_find_nonzero_offset(const void *buf, size_t len); - /* * helper to parse debug environment variables */ diff --git a/include/qemu/bcd.h b/include/qemu/bcd.h new file mode 100644 index 0000000000..b4c9b64b8f --- /dev/null +++ b/include/qemu/bcd.h @@ -0,0 +1,15 @@ +#ifndef QEMU_BCD_H +#define QEMU_BCD_H 1 + +/* Convert a byte between binary and BCD. */ +static inline uint8_t to_bcd(uint8_t val) +{ + return ((val / 10) << 4) | (val % 10); +} + +static inline uint8_t from_bcd(uint8_t val) +{ + return ((val >> 4) * 10) + (val & 0x0f); +} + +#endif diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h new file mode 100644 index 0000000000..db7adadcf9 --- /dev/null +++ b/include/qemu/cutils.h @@ -0,0 +1,183 @@ +#ifndef QEMU_CUTILS_H +#define QEMU_CUTILS_H 1 + +#include "qemu/fprintf-fn.h" + +/** + * pstrcpy: + * @buf: buffer to copy string into + * @buf_size: size of @buf in bytes + * @str: string to copy + * + * Copy @str into @buf, including the trailing NUL, but do not + * write more than @buf_size bytes. The resulting buffer is + * always NUL terminated (even if the source string was too long). + * If @buf_size is zero or negative then no bytes are copied. + * + * This function is similar to strncpy(), but avoids two of that + * function's problems: + * * if @str fits in the buffer, pstrcpy() does not zero-fill the + * remaining space at the end of @buf + * * if @str is too long, pstrcpy() will copy the first @buf_size-1 + * bytes and then add a NUL + */ +void pstrcpy(char *buf, int buf_size, const char *str); +/** + * strpadcpy: + * @buf: buffer to copy string into + * @buf_size: size of @buf in bytes + * @str: string to copy + * @pad: character to pad the remainder of @buf with + * + * Copy @str into @buf (but *not* its trailing NUL!), and then pad the + * rest of the buffer with the @pad character. If @str is too large + * for the buffer then it is truncated, so that @buf contains the + * first @buf_size characters of @str, with no terminator. + */ +void strpadcpy(char *buf, int buf_size, const char *str, char pad); +/** + * pstrcat: + * @buf: buffer containing existing string + * @buf_size: size of @buf in bytes + * @s: string to concatenate to @buf + * + * Append a copy of @s to the string already in @buf, but do not + * allow the buffer to overflow. If the existing contents of @buf + * plus @str would total more than @buf_size bytes, then write + * as much of @str as will fit followed by a NUL terminator. + * + * @buf must already contain a NUL-terminated string, or the + * behaviour is undefined. + * + * Returns: @buf. + */ +char *pstrcat(char *buf, int buf_size, const char *s); +/** + * strstart: + * @str: string to test + * @val: prefix string to look for + * @ptr: NULL, or pointer to be written to indicate start of + * the remainder of the string + * + * Test whether @str starts with the prefix @val. + * If it does (including the degenerate case where @str and @val + * are equal) then return true. If @ptr is not NULL then a + * pointer to the first character following the prefix is written + * to it. If @val is not a prefix of @str then return false (and + * @ptr is not written to). + * + * Returns: true if @str starts with prefix @val, false otherwise. + */ +int strstart(const char *str, const char *val, const char **ptr); +/** + * stristart: + * @str: string to test + * @val: prefix string to look for + * @ptr: NULL, or pointer to be written to indicate start of + * the remainder of the string + * + * Test whether @str starts with the case-insensitive prefix @val. + * This function behaves identically to strstart(), except that the + * comparison is made after calling qemu_toupper() on each pair of + * characters. + * + * Returns: true if @str starts with case-insensitive prefix @val, + * false otherwise. + */ +int stristart(const char *str, const char *val, const char **ptr); +/** + * qemu_strnlen: + * @s: string + * @max_len: maximum number of bytes in @s to scan + * + * Return the length of the string @s, like strlen(), but do not + * examine more than @max_len bytes of the memory pointed to by @s. + * If no NUL terminator is found within @max_len bytes, then return + * @max_len instead. + * + * This function has the same behaviour as the POSIX strnlen() + * function. + * + * Returns: length of @s in bytes, or @max_len, whichever is smaller. + */ +int qemu_strnlen(const char *s, int max_len); +/** + * qemu_strsep: + * @input: pointer to string to parse + * @delim: string containing delimiter characters to search for + * + * Locate the first occurrence of any character in @delim within + * the string referenced by @input, and replace it with a NUL. + * The location of the next character after the delimiter character + * is stored into @input. + * If the end of the string was reached without finding a delimiter + * character, then NULL is stored into @input. + * If @input points to a NULL pointer on entry, return NULL. + * The return value is always the original value of *@input (and + * so now points to a NUL-terminated string corresponding to the + * part of the input up to the first delimiter). + * + * This function has the same behaviour as the BSD strsep() function. + * + * Returns: the pointer originally in @input. + */ +char *qemu_strsep(char **input, const char *delim); +time_t mktimegm(struct tm *tm); +int qemu_fdatasync(int fd); +int fcntl_setfl(int fd, int flag); +int qemu_parse_fd(const char *param); +int qemu_strtol(const char *nptr, const char **endptr, int base, + long *result); +int qemu_strtoul(const char *nptr, const char **endptr, int base, + unsigned long *result); +int qemu_strtoll(const char *nptr, const char **endptr, int base, + int64_t *result); +int qemu_strtoull(const char *nptr, const char **endptr, int base, + uint64_t *result); + +int parse_uint(const char *s, unsigned long long *value, char **endptr, + int base); +int parse_uint_full(const char *s, unsigned long long *value, int base); + +/* + * qemu_strtosz() suffixes used to specify the default treatment of an + * argument passed to qemu_strtosz() without an explicit suffix. + * These should be defined using upper case characters in the range + * A-Z, as qemu_strtosz() will use qemu_toupper() on the given argument + * prior to comparison. + */ +#define QEMU_STRTOSZ_DEFSUFFIX_EB 'E' +#define QEMU_STRTOSZ_DEFSUFFIX_PB 'P' +#define QEMU_STRTOSZ_DEFSUFFIX_TB 'T' +#define QEMU_STRTOSZ_DEFSUFFIX_GB 'G' +#define QEMU_STRTOSZ_DEFSUFFIX_MB 'M' +#define QEMU_STRTOSZ_DEFSUFFIX_KB 'K' +#define QEMU_STRTOSZ_DEFSUFFIX_B 'B' +int64_t qemu_strtosz(const char *nptr, char **end); +int64_t qemu_strtosz_suffix(const char *nptr, char **end, + const char default_suffix); +int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end, + const char default_suffix, int64_t unit); +#define K_BYTE (1ULL << 10) +#define M_BYTE (1ULL << 20) +#define G_BYTE (1ULL << 30) +#define T_BYTE (1ULL << 40) +#define P_BYTE (1ULL << 50) +#define E_BYTE (1ULL << 60) + +/* used to print char* safely */ +#define STR_OR_NULL(str) ((str) ? (str) : "null") + +bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len); +size_t buffer_find_nonzero_offset(const void *buf, size_t len); +bool buffer_is_zero(const void *buf, size_t len); + +/* + * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) + * Input is limited to 14-bit numbers + */ + +int uleb128_encode_small(uint8_t *out, uint32_t n); +int uleb128_decode_small(const uint8_t *in, uint32_t *n); + +#endif diff --git a/include/qemu/help_option.h b/include/qemu/help_option.h new file mode 100644 index 0000000000..e39a66e77b --- /dev/null +++ b/include/qemu/help_option.h @@ -0,0 +1,22 @@ +#ifndef QEMU_HELP_OPTION_H +#define QEMU_HELP_OPTION_H 1 + +/** + * is_help_option: + * @s: string to test + * + * Check whether @s is one of the standard strings which indicate + * that the user is asking for a list of the valid values for a + * command option like -cpu or -M. The current accepted strings + * are 'help' and '?'. '?' is deprecated (it is a shell wildcard + * which makes it annoying to use in a reliable way) but provided + * for backwards compatibility. + * + * Returns: true if @s is a request for a list. + */ +static inline bool is_help_option(const char *s) +{ + return !strcmp(s, "?") || !strcmp(s, "help"); +} + +#endif diff --git a/include/qemu/id.h b/include/qemu/id.h new file mode 100644 index 0000000000..7d90335afb --- /dev/null +++ b/include/qemu/id.h @@ -0,0 +1,13 @@ +#ifndef QEMU_ID_H +#define QEMU_ID_H 1 + +typedef enum IdSubSystems { + ID_QDEV, + ID_BLOCK, + ID_MAX /* last element, used as array size */ +} IdSubSystems; + +char *id_generate(IdSubSystems id); +bool id_wellformed(const char *id); + +#endif diff --git a/include/qemu/path.h b/include/qemu/path.h new file mode 100644 index 0000000000..ed5fee086f --- /dev/null +++ b/include/qemu/path.h @@ -0,0 +1,7 @@ +#ifndef QEMU_PATH_H +#define QEMU_PATH_H 1 + +void init_paths(const char *prefix); +const char *path(const char *pathname); + +#endif diff --git a/include/qemu/unicode.h b/include/qemu/unicode.h new file mode 100644 index 0000000000..d8731652d2 --- /dev/null +++ b/include/qemu/unicode.h @@ -0,0 +1,6 @@ +#ifndef QEMU_UNICODE_H +#define QEMU_UNICODE_H 1 + +int mod_utf8_codepoint(const char *s, size_t n, char **end); + +#endif -- cgit v1.2.3 From 7ee606230e6b7645d92365d9b39179368e83ac54 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 15 Mar 2016 19:12:03 +0100 Subject: qemu-log: Avoid function call for disabled qemu_log_mask logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make qemu_log_mask() a macro which only calls the function to do the actual work if the logging is enabled. This avoids making a function call in possible fast paths where logging is disabled. Signed-off-by: Peter Maydell Signed-off-by: Alex Bennée Reviewed-by: Andreas Färber Signed-off-by: Paolo Bonzini --- include/qemu/log.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qemu/log.h b/include/qemu/log.h index 40c24fda40..523c886078 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -66,10 +66,17 @@ qemu_log_vprintf(const char *fmt, va_list va) } } -/* log only if a bit is set on the current loglevel mask +/* log only if a bit is set on the current loglevel mask: + * @mask: bit to check in the mask + * @fmt: printf-style format string + * @args: optional arguments for format string */ -void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); - +#define qemu_log_mask(MASK, FMT, ...) \ + do { \ + if (unlikely(qemu_loglevel_mask(MASK))) { \ + qemu_log(FMT, ## __VA_ARGS__); \ + } \ + } while (0) /* Maintenance: */ -- cgit v1.2.3 From 1a830635229e14c403600167823ea6b3b79d3097 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 15 Mar 2016 14:30:19 +0000 Subject: qemu-log: Improve the "exec" TB execution logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Improve the TB execution logging so that it is easier to identify what is happening from trace logs: * move the "Trace" logging of executed TBs into cpu_tb_exec() so that it is emitted if and only if we actually execute a TB, and for consistency for the CPU state logging * log when we link two TBs together via tb_add_jump() * log when cpu_tb_exec() returns early from a chain of TBs The new style logging looks like this: Trace 0x7fb7cc822ca0 [ffffffc0000dce00] Linking TBs 0x7fb7cc822ca0 [ffffffc0000dce00] index 0 -> 0x7fb7cc823110 [ffffffc0000dce10] Trace 0x7fb7cc823110 [ffffffc0000dce10] Trace 0x7fb7cc823420 [ffffffc000302688] Trace 0x7fb7cc8234a0 [ffffffc000302698] Trace 0x7fb7cc823520 [ffffffc0003026a4] Trace 0x7fb7cc823560 [ffffffc0000dce44] Linking TBs 0x7fb7cc823560 [ffffffc0000dce44] index 1 -> 0x7fb7cc8235d0 [ffffffc0000dce70] Trace 0x7fb7cc8235d0 [ffffffc0000dce70] Stopped execution of TB chain before 0x7fb7cc8235d0 [ffffffc0000dce70] Trace 0x7fb7cc8235d0 [ffffffc0000dce70] Trace 0x7fb7cc822fd0 [ffffffc0000dd52c] Signed-off-by: Peter Maydell Signed-off-by: Alex Bennée [AJB: reword patch title, Abandoned->Stopped] Reviewed-by: Aurelien Jarno Reviewed-by: Richard Henderson Message-Id: <1458052224-9316-6-git-send-email-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- include/exec/exec-all.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 05a151da4a..1823ee3c78 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -379,6 +379,9 @@ static inline void tb_add_jump(TranslationBlock *tb, int n, { /* NOTE: this test is only needed for thread safety */ if (!tb->jmp_next[n]) { + qemu_log_mask(CPU_LOG_EXEC, "Linking TBs %p [" TARGET_FMT_lx + "] index %d -> %p [" TARGET_FMT_lx "]\n", + tb->tc_ptr, tb->pc, n, tb_next->tc_ptr, tb_next->pc); /* patch the native jump address */ tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr); -- cgit v1.2.3 From 3514552e04388d8e7686bcf89efd022e892acb5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Tue, 15 Mar 2016 14:30:20 +0000 Subject: qemu-log: new option -dfilter to limit output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When debugging big programs or system emulation sometimes you want both the verbosity of cpu,exec et all but don't want to generate lots of logs for unneeded stuff. This patch adds a new option -dfilter which allows you to specify interesting address ranges in the form: -dfilter 0x8000..0x8fff,0xffffffc000080000+0x200,... Then logging code can use the new qemu_log_in_addr_range() function to decide if it will output logging information for the given range. Signed-off-by: Alex Bennée Message-Id: <1458052224-9316-7-git-send-email-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- include/qemu/log.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/qemu/log.h b/include/qemu/log.h index 523c886078..1d0222dd2e 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -122,6 +122,8 @@ static inline void qemu_set_log(int log_flags) } void qemu_set_log_filename(const char *filename); +void qemu_set_dfilter_ranges(const char *ranges); +bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); /* Print a usage message listing all the valid logging categories -- cgit v1.2.3 From d977e1c2dbc9e63454b2000f91954d02543bf43b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Tue, 15 Mar 2016 14:30:21 +0000 Subject: qemu-log: dfilter-ise exec, out_asm, op and opt_op MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures the code generation debug code will honour -dfilter if set. For the "exec" tracing I've added a new inline macro for efficiency's sake. Signed-off-by: Alex Bennée Reviewed-by: Aurelien Jarno Reviewed-by: Richard Henderson Message-Id: <1458052224-9316-8-git-send-email-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- include/exec/exec-all.h | 8 +++++--- include/qemu/log.h | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 1823ee3c78..736209505a 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -379,9 +379,11 @@ static inline void tb_add_jump(TranslationBlock *tb, int n, { /* NOTE: this test is only needed for thread safety */ if (!tb->jmp_next[n]) { - qemu_log_mask(CPU_LOG_EXEC, "Linking TBs %p [" TARGET_FMT_lx - "] index %d -> %p [" TARGET_FMT_lx "]\n", - tb->tc_ptr, tb->pc, n, tb_next->tc_ptr, tb_next->pc); + qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc, + "Linking TBs %p [" TARGET_FMT_lx + "] index %d -> %p [" TARGET_FMT_lx "]\n", + tb->tc_ptr, tb->pc, n, + tb_next->tc_ptr, tb_next->pc); /* patch the native jump address */ tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr); diff --git a/include/qemu/log.h b/include/qemu/log.h index 1d0222dd2e..cf38adbdb0 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -78,6 +78,21 @@ qemu_log_vprintf(const char *fmt, va_list va) } \ } while (0) +/* log only if a bit is set on the current loglevel mask + * and we are in the address range we care about: + * @mask: bit to check in the mask + * @addr: address to check in dfilter + * @fmt: printf-style format string + * @args: optional arguments for format string + */ +#define qemu_log_mask_and_addr(MASK, ADDR, FMT, ...) \ + do { \ + if (unlikely(qemu_loglevel_mask(MASK)) && \ + qemu_log_in_addr_range(ADDR)) { \ + qemu_log(FMT, ## __VA_ARGS__); \ + } \ + } while (0) + /* Maintenance: */ /* fflush() the log file */ -- cgit v1.2.3