aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-03-24 21:42:12 +0000
committerPeter Maydell <peter.maydell@linaro.org>2016-03-24 21:42:40 +0000
commit84a5a8014801a83d1b8d15fa7f0fde03db081530 (patch)
tree9b7090464e9b910d6e083f44ed54e9afe85b7ff2 /include
parentb68a80139e37e806f004237e55311ebc42151434 (diff)
parent0f70ed4759a29ca932af1e9525729f4f455642f8 (diff)
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* Log filtering from Alex and Peter * Chardev fix from Marc-André * config.status tweak from David * Header file tweaks from Markus, myself and Veronia (Outreachy candidate) * get_ticks_per_sec() removal from Rutuja (Outreachy candidate) * Coverity fix from myself * PKE implementation from myself, based on rth's XSAVE support # gpg: Signature made Thu 24 Mar 2016 20:15:11 GMT using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" * remotes/bonzini/tags/for-upstream: (28 commits) target-i386: implement PKE for TCG config.status: Pass extra parameters char: translate from QIOChannel error to errno exec: fix error handling in file_ram_alloc cputlb: modernise the debug support qemu-log: support simple pid substitution for logs target-arm: dfilter support for in_asm qemu-log: dfilter-ise exec, out_asm, op and opt_op qemu-log: new option -dfilter to limit output qemu-log: Improve the "exec" TB execution logging qemu-log: Avoid function call for disabled qemu_log_mask logging qemu-log: correct help text for -d cpu tcg: pass down TranslationBlock to tcg_code_gen util: move declarations out of qemu-common.h Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND hw: explicitly include qemu-common.h and cpu.h include/crypto: Include qapi-types.h or qemu/bswap.h instead of qemu-common.h isa: Move DMA_transfer_handler from qemu-common.h to hw/isa/isa.h Move ParallelIOArg from qemu-common.h to sysemu/char.h Move QEMU_ALIGN_*() from qemu-common.h to qemu/osdep.h ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Conflicts: scripts/clean-includes
Diffstat (limited to 'include')
-rw-r--r--include/block/accounting.h2
-rw-r--r--include/block/aio.h1
-rw-r--r--include/block/block.h2
-rw-r--r--include/block/write-threshold.h2
-rw-r--r--include/crypto/cipher.h2
-rw-r--r--include/crypto/hash.h2
-rw-r--r--include/crypto/init.h2
-rw-r--r--include/crypto/secret.h1
-rw-r--r--include/crypto/tlscreds.h1
-rw-r--r--include/exec/cpu-common.h1
-rw-r--r--include/exec/exec-all.h5
-rw-r--r--include/exec/memory.h1
-rw-r--r--include/hw/acpi/acpi.h3
-rw-r--r--include/hw/acpi/pcihp.h1
-rw-r--r--include/hw/acpi/piix4.h2
-rw-r--r--include/hw/acpi/tco.h1
-rw-r--r--include/hw/boards.h1
-rw-r--r--include/hw/char/digic-uart.h1
-rw-r--r--include/hw/hotplug.h1
-rw-r--r--include/hw/hw.h4
-rw-r--r--include/hw/i386/pc.h1
-rw-r--r--include/hw/isa/i8257.h2
-rw-r--r--include/hw/isa/isa.h5
-rw-r--r--include/hw/nvram/fw_cfg.h50
-rw-r--r--include/hw/nvram/fw_cfg_keys.h46
-rw-r--r--include/hw/pci/pci.h11
-rw-r--r--include/hw/ppc/mac_dbdma.h1
-rw-r--r--include/hw/qdev-core.h1
-rw-r--r--include/hw/scsi/scsi.h1
-rw-r--r--include/hw/timer/digic-timer.h1
-rw-r--r--include/hw/usb.h1
-rw-r--r--include/hw/vfio/vfio.h2
-rw-r--r--include/hw/xen/xen.h1
-rw-r--r--include/monitor/qdev.h1
-rw-r--r--include/net/filter.h1
-rw-r--r--include/qapi/error.h5
-rw-r--r--include/qapi/visitor.h1
-rw-r--r--include/qemu-common.h321
-rw-r--r--include/qemu/bcd.h15
-rw-r--r--include/qemu/bswap.h6
-rw-r--r--include/qemu/coroutine.h1
-rw-r--r--include/qemu/cutils.h183
-rw-r--r--include/qemu/help_option.h22
-rw-r--r--include/qemu/id.h13
-rw-r--r--include/qemu/iov.h30
-rw-r--r--include/qemu/log.h28
-rw-r--r--include/qemu/option.h1
-rw-r--r--include/qemu/osdep.h24
-rw-r--r--include/qemu/path.h7
-rw-r--r--include/qemu/range.h1
-rw-r--r--include/qemu/timer.h10
-rw-r--r--include/qemu/typedefs.h2
-rw-r--r--include/qemu/unicode.h6
-rw-r--r--include/qom/cpu.h1
-rw-r--r--include/qom/object.h2
-rw-r--r--include/sysemu/accel.h1
-rw-r--r--include/sysemu/block-backend.h2
-rw-r--r--include/sysemu/char.h5
-rw-r--r--include/sysemu/memory_mapping.h1
-rw-r--r--include/sysemu/replay.h1
-rw-r--r--include/sysemu/sysemu.h1
-rw-r--r--include/ui/console.h1
-rw-r--r--include/ui/qemu-pixman.h2
-rw-r--r--include/ui/qemu-spice.h2
64 files changed, 409 insertions, 447 deletions
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/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/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/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
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/exec-all.h b/include/exec/exec-all.h
index 05a151da4a..736209505a 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -379,6 +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_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/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..e0978c8b92 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -19,7 +19,6 @@
* <http://www.gnu.org/licenses/>.
*/
-#include "qemu/typedefs.h"
#include "qemu/notify.h"
#include "qemu/option.h"
#include "exec/memory.h"
@@ -155,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/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 <qemu/typedefs.h>
#include "hw/acpi/acpi.h"
#include "migration/vmstate.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/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/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/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/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 4315f4e582..d5169895dc 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -1,55 +1,9 @@
#ifndef FW_CFG_H
#define FW_CFG_H
-#ifndef NO_QEMU_PROTOS
-
#include "exec/hwaddr.h"
-#include "qemu/typedefs.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 */
@@ -221,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
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/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/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/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/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/error.h b/include/qapi/error.h
index 02e9dd20a7..11be2327c0 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -118,11 +118,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
* enum names.
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..163bcbb861 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__)
@@ -24,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 */
@@ -59,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))
@@ -304,26 +95,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;
-};
-
-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);
@@ -365,36 +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)
-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);
void qemu_progress_end(void);
void qemu_progress_print(float delta, int max);
@@ -409,76 +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);
-}
-
-/* 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"
/*
- * 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 <altivec.h>
-/* 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 <emmintrin.h>
-#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/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/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/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/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/qemu/log.h b/include/qemu/log.h
index 40c24fda40..cf38adbdb0 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -66,10 +66,32 @@ 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)
+/* 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: */
@@ -115,6 +137,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
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/osdep.h b/include/qemu/osdep.h
index 5bb374c3c6..408783f532 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
@@ -101,8 +103,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
@@ -129,6 +130,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
@@ -142,6 +152,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
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/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 <qemu/typedefs.h>
#include "qemu/queue.h"
/*
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 7197d0859a..471969a24d 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"
@@ -784,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;
}
/*
@@ -821,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
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index fd039e0e81..1dcf6f5d53 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;
@@ -65,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;
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
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 4a6def7117..b7a10f791a 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -26,7 +26,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 eda16df005..21bb5ff149 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -15,8 +15,8 @@
#define QEMU_OBJECT_H
#include <glib.h>
+#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..c62b6fe96d 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -13,7 +13,7 @@
#ifndef BLOCK_BACKEND_H
#define BLOCK_BACKEND_H
-#include "qemu/typedefs.h"
+#include "qemu/iov.h"
/*
* TODO Have to include block/block.h for a bunch of block layer
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
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
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 <spice.h>
-
#include "qemu/option.h"
#include "qemu/config-file.h"