From 99afc91d6ccdbe45258cff66fd0ce0142820c366 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Mon, 20 Aug 2012 15:31:38 +0100 Subject: qapi: add 'query-target' command to return target arch Add a 'query-target' QAPI command to allow management applications to determine what target architecture a QEMU binary is emulating without having to parse the binary name or -help output $ qmp-shell -p /tmp/qemu (QEMU) query-target { u'return': { u'arch': u'x86_64' }} Signed-off-by: Daniel P. Berrange Signed-off-by: Anthony Liguori --- arch_init.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 9b46bfcaa5..5a1173e29a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -44,6 +44,7 @@ #include "exec-memory.h" #include "hw/pcspk.h" #include "qemu/page_cache.h" +#include "qmp-commands.h" #ifdef DEBUG_ARCH_INIT #define DPRINTF(fmt, ...) \ @@ -1080,3 +1081,13 @@ int xen_available(void) return 0; #endif } + + +TargetInfo *qmp_query_target(Error **errp) +{ + TargetInfo *info = g_malloc0(sizeof(*info)); + + info->arch = TARGET_TYPE; + + return info; +} -- cgit v1.2.3-55-g7522 From ef37a699a06f96e098ee00683b7052b5fbb6ad7d Mon Sep 17 00:00:00 2001 From: Igor Mitsyanko Date: Wed, 5 Sep 2012 13:04:56 +0400 Subject: arch_init.c: add missing '%' symbols before PRIu64 in debug printfs '%' symbols were missing in front of PRIu64 macros in DPRINTF() messages in arch_init.c, this caused compilation warnings when compiled with DEBUG_ARCH_INIT defined. Signed-off-by: Igor Mitsyanko Signed-off-by: Stefan Hajnoczi --- arch_init.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 5a1173e29a..47977de7c6 100644 --- a/arch_init.c +++ b/arch_init.c @@ -562,7 +562,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) if ((i & 63) == 0) { uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; if (t1 > MAX_WAIT) { - DPRINTF("big wait: " PRIu64 " milliseconds, %d iterations\n", + DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n", t1, i); break; } @@ -587,7 +587,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; - DPRINTF("ram_save_live: expected(" PRIu64 ") <= max(" PRIu64 ")?\n", + DPRINTF("ram_save_live: expected(%" PRIu64 ") <= max(%" PRIu64 ")?\n", expected_time, migrate_max_downtime()); if (expected_time <= migrate_max_downtime()) { @@ -799,8 +799,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) } while (!(flags & RAM_SAVE_FLAG_EOS)); done: - DPRINTF("Completed load of VM with exit code %d seq iteration " PRIu64 "\n", - ret, seq_iter); + DPRINTF("Completed load of VM with exit code %d seq iteration " + "%" PRIu64 "\n", ret, seq_iter); return ret; } -- cgit v1.2.3-55-g7522 From 55d4fd3c24bd253bd96270c7fdf1bb862f3a3400 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Wed, 19 Sep 2012 14:51:38 +0100 Subject: arch_init.c: Improve '-soundhw help' for non-HAS_AUDIO_CHOICE archs For architectures which don't set HAS_AUDIO_CHOICE, improve the '-soundhw help' message so that it doesn't simply print an empty list, implying no sound support at all. Signed-off-by: Peter Maydell Signed-off-by: malc --- arch_init.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 47977de7c6..f849f9b872 100644 --- a/arch_init.c +++ b/arch_init.c @@ -922,11 +922,16 @@ void select_soundhw(const char *optarg) if (is_help_option(optarg)) { show_valid_cards: +#ifdef HAS_AUDIO_CHOICE printf("Valid sound card names (comma separated):\n"); for (c = soundhw; c->name; ++c) { printf ("%-11s %s\n", c->name, c->descr); } printf("\n-soundhw all will enable all of the above\n"); +#else + printf("Machine has no user-selectable audio hardware " + "(it may or may not have always-present audio hardware).\n"); +#endif exit(!is_help_option(optarg)); } else { -- cgit v1.2.3-55-g7522 From ba6212d8a809b89151a9d76b452b814836474029 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 5 Sep 2012 17:41:11 -0300 Subject: Eliminate cpus-x86_64.conf file This file is not needed anymore, as QEMU won't ship any config-based cpudefs out of the box, relying only on the builtin CPU models. Signed-off-by: Eduardo Habkost Reviewed-by: Igor Mammedov Signed-off-by: Andreas Färber --- Makefile | 1 - arch_init.c | 1 - sysconfigs/target/cpus-x86_64.conf | 1 - 3 files changed, 3 deletions(-) delete mode 100644 sysconfigs/target/cpus-x86_64.conf (limited to 'arch_init.c') diff --git a/Makefile b/Makefile index 971e92fd79..def2ae23cd 100644 --- a/Makefile +++ b/Makefile @@ -298,7 +298,6 @@ install-confdir: install-sysconfig: install-datadir install-confdir $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/target-x86_64.conf "$(DESTDIR)$(qemu_confdir)" - $(INSTALL_DATA) $(SRC_PATH)/sysconfigs/target/cpus-x86_64.conf "$(DESTDIR)$(qemu_datadir)" install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig install-datadir $(INSTALL_DIR) "$(DESTDIR)$(bindir)" diff --git a/arch_init.c b/arch_init.c index f849f9b872..9904f95478 100644 --- a/arch_init.c +++ b/arch_init.c @@ -136,7 +136,6 @@ static struct defconfig_file { /* Indicates it is an user config file (disabled by -no-user-config) */ bool userconfig; } default_config_files[] = { - { CONFIG_QEMU_DATADIR "/cpus-" TARGET_ARCH ".conf", false }, { CONFIG_QEMU_CONFDIR "/qemu.conf", true }, { CONFIG_QEMU_CONFDIR "/target-" TARGET_ARCH ".conf", true }, { NULL }, /* end of list */ diff --git a/sysconfigs/target/cpus-x86_64.conf b/sysconfigs/target/cpus-x86_64.conf deleted file mode 100644 index 3902189836..0000000000 --- a/sysconfigs/target/cpus-x86_64.conf +++ /dev/null @@ -1 +0,0 @@ -# The CPU models from this file are now built-in in the QEMU source code -- cgit v1.2.3-55-g7522 From 79536f4f16934d6759a1d67f0342b4e7ceb66671 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Fri, 3 Aug 2012 12:58:16 +0200 Subject: fix migration sync Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini --- arch_init.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 9904f95478..671d3545cc 100644 --- a/arch_init.c +++ b/arch_init.c @@ -517,6 +517,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } memory_global_dirty_log_start(); + memory_global_sync_dirty_bitmap(get_system_memory()); qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); -- cgit v1.2.3-55-g7522 From c00012f68b736c0ad9d0ff245373c7005ea0721a Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Mon, 13 Aug 2012 09:36:36 +0200 Subject: migration: rename expected_time to expected_downtime Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini Reviewed-by: Orit Wasserman --- arch_init.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 671d3545cc..1d6dda8449 100644 --- a/arch_init.c +++ b/arch_init.c @@ -538,7 +538,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) double bwidth = 0; int ret; int i; - uint64_t expected_time; + uint64_t expected_downtime; bytes_transferred_last = bytes_transferred; bwidth = qemu_get_clock_ns(rt_clock); @@ -577,24 +577,24 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) bwidth = qemu_get_clock_ns(rt_clock) - bwidth; bwidth = (bytes_transferred - bytes_transferred_last) / bwidth; - /* if we haven't transferred anything this round, force expected_time to a - * a very high value, but without crashing */ + /* if we haven't transferred anything this round, force + * expected_downtime to a very high value, but without + * crashing */ if (bwidth == 0) { bwidth = 0.000001; } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; + expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; + DPRINTF("ram_save_live: expected(%" PRIu64 ") <= max(" PRIu64 ")?\n", + expected_downtime, migrate_max_downtime()); - DPRINTF("ram_save_live: expected(%" PRIu64 ") <= max(%" PRIu64 ")?\n", - expected_time, migrate_max_downtime()); - - if (expected_time <= migrate_max_downtime()) { + if (expected_downtime <= migrate_max_downtime()) { memory_global_sync_dirty_bitmap(get_system_memory()); - expected_time = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; + expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; - return expected_time <= migrate_max_downtime(); + return expected_downtime <= migrate_max_downtime(); } return 0; } -- cgit v1.2.3-55-g7522 From 2c52ddf1cb3057bc2c6ae256857077627f6da43a Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Mon, 13 Aug 2012 09:53:12 +0200 Subject: migration: print expected downtime in info migrate Signed-off-by: Juan Quintela --- arch_init.c | 2 ++ hmp.c | 4 ++++ migration.c | 2 ++ migration.h | 1 + qapi-schema.json | 5 +++++ qmp-commands.hx | 6 ++++++ 6 files changed, 20 insertions(+) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 1d6dda8449..3fddb38179 100644 --- a/arch_init.c +++ b/arch_init.c @@ -539,6 +539,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) int ret; int i; uint64_t expected_downtime; + MigrationState *s = migrate_get_current(); bytes_transferred_last = bytes_transferred; bwidth = qemu_get_clock_ns(rt_clock); @@ -593,6 +594,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) if (expected_downtime <= migrate_max_downtime()) { memory_global_sync_dirty_bitmap(get_system_memory()); expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; + s->expected_downtime = expected_downtime / 1000000; /* ns -> ms */ return expected_downtime <= migrate_max_downtime(); } diff --git a/hmp.c b/hmp.c index a8e5aea7c3..96e21742ec 100644 --- a/hmp.c +++ b/hmp.c @@ -152,6 +152,10 @@ void hmp_info_migrate(Monitor *mon) monitor_printf(mon, "Migration status: %s\n", info->status); monitor_printf(mon, "total time: %" PRIu64 " milliseconds\n", info->total_time); + if (info->has_expected_downtime) { + monitor_printf(mon, "expected downtime: %" PRIu64 " milliseconds\n", + info->expected_downtime); + } if (info->has_downtime) { monitor_printf(mon, "downtime: %" PRIu64 " milliseconds\n", info->downtime); diff --git a/migration.c b/migration.c index fc615c8096..8d3e018dc0 100644 --- a/migration.c +++ b/migration.c @@ -169,6 +169,8 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->has_total_time = true; info->total_time = qemu_get_clock_ms(rt_clock) - s->total_time; + info->has_expected_downtime = true; + info->expected_downtime = s->expected_downtime; info->has_ram = true; info->ram = g_malloc0(sizeof(*info->ram)); diff --git a/migration.h b/migration.h index dabc333f5b..552200c348 100644 --- a/migration.h +++ b/migration.h @@ -41,6 +41,7 @@ struct MigrationState MigrationParams params; int64_t total_time; int64_t downtime; + int64_t expected_downtime; bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; int64_t xbzrle_cache_size; }; diff --git a/qapi-schema.json b/qapi-schema.json index 720068706a..bcb5edb89d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -442,6 +442,10 @@ # total downtime in milliseconds for the guest. # (since 1.3) # +# @expected-downtime: #optional only present while migration is active +# expected downtime in milliseconds for the guest in last walk +# of the dirty bitmap. (since 1.3) +# # Since: 0.14.0 ## { 'type': 'MigrationInfo', @@ -449,6 +453,7 @@ '*disk': 'MigrationStats', '*xbzrle-cache': 'XBZRLECacheStats', '*total-time': 'int', + '*expected-downtime': 'int', '*downtime': 'int'} } ## diff --git a/qmp-commands.hx b/qmp-commands.hx index 4686057050..5ba8c48cb4 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2306,6 +2306,9 @@ The main json-object contains the following: time (json-int) - "downtime": only present when migration has finished correctly total amount in ms for downtime that happened (json-int) +- "expected-downtime": only present while migration is active + total amount in ms for downtime that was calculated on + the last bitmap round (json-int) - "ram": only present if "status" is "active", it is a json-object with the following RAM information (in bytes): - "transferred": amount transferred (json-int) @@ -2367,6 +2370,7 @@ Examples: "remaining":123, "total":246, "total-time":12345, + "expected-downtime":12345, "duplicate":123, "normal":123, "normal-bytes":123456 @@ -2385,6 +2389,7 @@ Examples: "remaining":1053304, "transferred":3720, "total-time":12345, + "expected-downtime":12345, "duplicate":123, "normal":123, "normal-bytes":123456 @@ -2409,6 +2414,7 @@ Examples: "remaining":1053304, "transferred":3720, "total-time":12345, + "expected-downtime":12345, "duplicate":10, "normal":3333, "normal-bytes":3412992 -- cgit v1.2.3-55-g7522 From 5a17077529f7feec559e1881792e89554c2ae5b6 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 17 Jul 2012 17:02:24 +0200 Subject: savevm: Factorize ram globals reset in its own function Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini Reviewed-by: Orit Wasserman --- arch_init.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 3fddb38179..6b9f949db3 100644 --- a/arch_init.c +++ b/arch_init.c @@ -481,6 +481,14 @@ static void ram_migration_cancel(void *opaque) migration_end(); } + +static void reset_ram_globals(void) +{ + last_block = NULL; + last_offset = 0; + sort_ram_list(); +} + #define MAX_WAIT 50 /* ms, half buffered_file limit */ static int ram_save_setup(QEMUFile *f, void *opaque) @@ -489,9 +497,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) RAMBlock *block; bytes_transferred = 0; - last_block = NULL; - last_offset = 0; - sort_ram_list(); + reset_ram_globals(); if (migrate_use_xbzrle()) { XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() / -- cgit v1.2.3-55-g7522 From e44d26c8f3894a220f29ff5b27abf87f570d2c07 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Fri, 20 Jul 2012 10:16:08 +0200 Subject: ram: introduce migration_bitmap_set_dirty() It just marks a region of memory as dirty. Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini Reviewed-by: Orit Wasserman --- arch_init.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 6b9f949db3..fa470515db 100644 --- a/arch_init.c +++ b/arch_init.c @@ -331,6 +331,18 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, static RAMBlock *last_block; static ram_addr_t last_offset; +static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length) +{ + ram_addr_t addr; + + for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) { + if (!memory_region_get_dirty(mr, addr, TARGET_PAGE_SIZE, + DIRTY_MEMORY_MIGRATION)) { + memory_region_set_dirty(mr, addr, TARGET_PAGE_SIZE); + } + } +} + /* * ram_save_block: Writes a page of memory to the stream f * @@ -493,7 +505,6 @@ static void reset_ram_globals(void) static int ram_save_setup(QEMUFile *f, void *opaque) { - ram_addr_t addr; RAMBlock *block; bytes_transferred = 0; @@ -514,12 +525,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) /* Make sure all dirty bits are set */ QLIST_FOREACH(block, &ram_list.blocks, next) { - for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) { - if (!memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION)) { - memory_region_set_dirty(block->mr, addr, TARGET_PAGE_SIZE); - } - } + migration_bitmap_set_dirty(block->mr, block->length); } memory_global_dirty_log_start(); -- cgit v1.2.3-55-g7522 From 69268cde142d169e2e47836bcf0a26341e30218a Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Fri, 20 Jul 2012 10:36:12 +0200 Subject: ram: Introduce migration_bitmap_test_and_reset_dirty() It just test if the dirty bit is set, and clears it. Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini Reviewed-by: Orit Wasserman --- arch_init.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index fa470515db..90a722e6c9 100644 --- a/arch_init.c +++ b/arch_init.c @@ -331,6 +331,19 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, static RAMBlock *last_block; static ram_addr_t last_offset; +static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr, + ram_addr_t offset) +{ + bool ret = memory_region_get_dirty(mr, offset, TARGET_PAGE_SIZE, + DIRTY_MEMORY_MIGRATION); + + if (ret) { + memory_region_reset_dirty(mr, offset, TARGET_PAGE_SIZE, + DIRTY_MEMORY_MIGRATION); + } + return ret; +} + static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length) { ram_addr_t addr; @@ -364,14 +377,10 @@ static int ram_save_block(QEMUFile *f, bool last_stage) do { mr = block->mr; - if (memory_region_get_dirty(mr, offset, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION)) { + if (migration_bitmap_test_and_reset_dirty(mr, offset)) { uint8_t *p; int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0; - memory_region_reset_dirty(mr, offset, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION); - p = memory_region_get_ram_ptr(mr) + offset; if (is_dup_page(p)) { -- cgit v1.2.3-55-g7522 From dd2df737ef3930f6d88116520d6ca7ff3cf0c41f Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Fri, 20 Jul 2012 10:52:51 +0200 Subject: ram: introduce migration_bitmap_sync() Helper that we use each time that we need to syncronize the migration bitmap with the other dirty bitmaps. Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini --- arch_init.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 90a722e6c9..3a5fecccc7 100644 --- a/arch_init.c +++ b/arch_init.c @@ -356,6 +356,12 @@ static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length) } } +static void migration_bitmap_sync(void) +{ + memory_global_sync_dirty_bitmap(get_system_memory()); +} + + /* * ram_save_block: Writes a page of memory to the stream f * @@ -613,7 +619,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) expected_downtime, migrate_max_downtime()); if (expected_downtime <= migrate_max_downtime()) { - memory_global_sync_dirty_bitmap(get_system_memory()); + migration_bitmap_sync(); expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; s->expected_downtime = expected_downtime / 1000000; /* ns -> ms */ @@ -624,7 +630,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) static int ram_save_complete(QEMUFile *f, void *opaque) { - memory_global_sync_dirty_bitmap(get_system_memory()); + migration_bitmap_sync(); /* try transferring iterative blocks of memory */ -- cgit v1.2.3-55-g7522 From 3c12193d998249bcbe5099edf85039bcd25c3a80 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 4 Sep 2012 13:08:57 +0200 Subject: ram: create trace event for migration sync bitmap Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini --- arch_init.c | 6 ++++++ trace-events | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 3a5fecccc7..cec3ead8de 100644 --- a/arch_init.c +++ b/arch_init.c @@ -45,6 +45,7 @@ #include "hw/pcspk.h" #include "qemu/page_cache.h" #include "qmp-commands.h" +#include "trace.h" #ifdef DEBUG_ARCH_INIT #define DPRINTF(fmt, ...) \ @@ -358,7 +359,12 @@ static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length) static void migration_bitmap_sync(void) { + uint64_t num_dirty_pages_init = ram_list.dirty_pages; + + trace_migration_bitmap_sync_start(); memory_global_sync_dirty_bitmap(get_system_memory()); + trace_migration_bitmap_sync_end(ram_list.dirty_pages + - num_dirty_pages_init); } diff --git a/trace-events b/trace-events index 42b66f19f4..e2d4580d4c 100644 --- a/trace-events +++ b/trace-events @@ -921,6 +921,10 @@ ppm_save(const char *filename, void *display_surface) "%s surface=%p" savevm_section_start(void) "" savevm_section_end(unsigned int section_id) "section_id %u" +# arch_init.c +migration_bitmap_sync_start(void) "" +migration_bitmap_sync_end(uint64_t dirty_pages) "dirty_pages %" PRIu64"" + # hw/qxl.c disable qxl_interface_set_mm_time(int qid, uint32_t mm_time) "%d %d" disable qxl_io_write_vga(int qid, const char *mode, uint32_t addr, uint32_t val) "%d %s addr=%u val=%u" -- cgit v1.2.3-55-g7522 From c6bf8e0e0cf04b40a8a22426e00ebbd727331d8b Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Fri, 20 Jul 2012 12:33:00 +0200 Subject: Separate migration bitmap This patch creates a migration bitmap, which is periodically kept in sync with the qemu bitmap. A separate copy of the dirty bitmap for the migration limits the amount of concurrent access to the qemu bitmap from iothread and migration thread (which requires taking the big lock). We use the qemu bitmap type. We have to "undo" the dirty_pages counting optimization on the general dirty bitmap and do the counting optimization with the migration local bitmap. Signed-off-by: Umesh Deshpande Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- arch_init.c | 63 +++++++++++++++++++++++++++++++++++++++------------------ cpu-all.h | 1 - exec-obsolete.h | 10 --------- 3 files changed, 43 insertions(+), 31 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index cec3ead8de..d918844028 100644 --- a/arch_init.c +++ b/arch_init.c @@ -31,6 +31,8 @@ #include "config.h" #include "monitor.h" #include "sysemu.h" +#include "bitops.h" +#include "bitmap.h" #include "arch_init.h" #include "audio/audio.h" #include "hw/pc.h" @@ -331,39 +333,57 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, static RAMBlock *last_block; static ram_addr_t last_offset; +static unsigned long *migration_bitmap; +static uint64_t migration_dirty_pages; static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr, ram_addr_t offset) { - bool ret = memory_region_get_dirty(mr, offset, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION); + bool ret; + int nr = (mr->ram_addr + offset) >> TARGET_PAGE_BITS; + + ret = test_and_clear_bit(nr, migration_bitmap); if (ret) { - memory_region_reset_dirty(mr, offset, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION); + migration_dirty_pages--; } return ret; } -static inline void migration_bitmap_set_dirty(MemoryRegion *mr, int length) +static inline bool migration_bitmap_set_dirty(MemoryRegion *mr, + ram_addr_t offset) { - ram_addr_t addr; + bool ret; + int nr = (mr->ram_addr + offset) >> TARGET_PAGE_BITS; - for (addr = 0; addr < length; addr += TARGET_PAGE_SIZE) { - if (!memory_region_get_dirty(mr, addr, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION)) { - memory_region_set_dirty(mr, addr, TARGET_PAGE_SIZE); - } + ret = test_and_set_bit(nr, migration_bitmap); + + if (!ret) { + migration_dirty_pages++; } + return ret; } static void migration_bitmap_sync(void) { - uint64_t num_dirty_pages_init = ram_list.dirty_pages; + RAMBlock *block; + ram_addr_t addr; + uint64_t num_dirty_pages_init = migration_dirty_pages; trace_migration_bitmap_sync_start(); memory_global_sync_dirty_bitmap(get_system_memory()); - trace_migration_bitmap_sync_end(ram_list.dirty_pages + + QLIST_FOREACH(block, &ram_list.blocks, next) { + for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) { + if (memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE, + DIRTY_MEMORY_MIGRATION)) { + migration_bitmap_set_dirty(block->mr, addr); + } + } + memory_region_reset_dirty(block->mr, 0, block->length, + DIRTY_MEMORY_MIGRATION); + } + trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init); } @@ -442,7 +462,7 @@ static uint64_t bytes_transferred; static ram_addr_t ram_save_remaining(void) { - return ram_list.dirty_pages; + return migration_dirty_pages; } uint64_t ram_bytes_remaining(void) @@ -527,6 +547,11 @@ static void reset_ram_globals(void) static int ram_save_setup(QEMUFile *f, void *opaque) { RAMBlock *block; + int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS; + + migration_bitmap = bitmap_new(ram_pages); + bitmap_set(migration_bitmap, 1, ram_pages); + migration_dirty_pages = ram_pages; bytes_transferred = 0; reset_ram_globals(); @@ -544,13 +569,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque) acct_clear(); } - /* Make sure all dirty bits are set */ - QLIST_FOREACH(block, &ram_list.blocks, next) { - migration_bitmap_set_dirty(block->mr, block->length); - } - memory_global_dirty_log_start(); - memory_global_sync_dirty_bitmap(get_system_memory()); + migration_bitmap_sync(); qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); @@ -655,6 +675,9 @@ static int ram_save_complete(QEMUFile *f, void *opaque) qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + g_free(migration_bitmap); + migration_bitmap = NULL; + return 0; } diff --git a/cpu-all.h b/cpu-all.h index 287b0003ea..6aa7e58cb1 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -500,7 +500,6 @@ typedef struct RAMBlock { typedef struct RAMList { uint8_t *phys_dirty; QLIST_HEAD(, RAMBlock) blocks; - uint64_t dirty_pages; } RAMList; extern RAMList ram_list; diff --git a/exec-obsolete.h b/exec-obsolete.h index 286e2f75e1..6d35d4b83e 100644 --- a/exec-obsolete.h +++ b/exec-obsolete.h @@ -75,11 +75,6 @@ static inline int cpu_physical_memory_get_dirty(ram_addr_t start, static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, int dirty_flags) { - if ((dirty_flags & MIGRATION_DIRTY_FLAG) && - !cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE, - MIGRATION_DIRTY_FLAG)) { - ram_list.dirty_pages++; - } return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; } @@ -93,11 +88,6 @@ static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, { int mask = ~dirty_flags; - if ((dirty_flags & MIGRATION_DIRTY_FLAG) && - cpu_physical_memory_get_dirty(addr, TARGET_PAGE_SIZE, - MIGRATION_DIRTY_FLAG)) { - ram_list.dirty_pages--; - } return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; } -- cgit v1.2.3-55-g7522 From 8d017193e2b66a65adf53e46a6372e55470fe7fd Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Mon, 13 Aug 2012 12:31:25 +0200 Subject: migration: Add dirty_pages_rate to query migrate output It indicates how many pages were dirtied during the last second. Signed-off-by: Juan Quintela --- arch_init.c | 18 ++++++++++++++++++ hmp.c | 4 ++++ migration.c | 2 ++ migration.h | 1 + qapi-schema.json | 8 ++++++-- 5 files changed, 31 insertions(+), 2 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index d918844028..e6effe809a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -369,6 +369,14 @@ static void migration_bitmap_sync(void) RAMBlock *block; ram_addr_t addr; uint64_t num_dirty_pages_init = migration_dirty_pages; + MigrationState *s = migrate_get_current(); + static int64_t start_time; + static int64_t num_dirty_pages_period; + int64_t end_time; + + if (!start_time) { + start_time = qemu_get_clock_ms(rt_clock); + } trace_migration_bitmap_sync_start(); memory_global_sync_dirty_bitmap(get_system_memory()); @@ -385,6 +393,16 @@ static void migration_bitmap_sync(void) } trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init); + num_dirty_pages_period += migration_dirty_pages - num_dirty_pages_init; + end_time = qemu_get_clock_ms(rt_clock); + + /* more than 1 second = 1000 millisecons */ + if (end_time > start_time + 1000) { + s->dirty_pages_rate = num_dirty_pages_period * 1000 + / (end_time - start_time); + start_time = end_time; + num_dirty_pages_period = 0; + } } diff --git a/hmp.c b/hmp.c index 96e21742ec..2b979826ee 100644 --- a/hmp.c +++ b/hmp.c @@ -175,6 +175,10 @@ void hmp_info_migrate(Monitor *mon) info->ram->normal); monitor_printf(mon, "normal bytes: %" PRIu64 " kbytes\n", info->ram->normal_bytes >> 10); + if (info->ram->dirty_pages_rate) { + monitor_printf(mon, "dirty pages rate: %" PRIu64 " pages\n", + info->ram->dirty_pages_rate); + } } if (info->has_disk) { diff --git a/migration.c b/migration.c index 8d3e018dc0..330c16a97f 100644 --- a/migration.c +++ b/migration.c @@ -180,6 +180,8 @@ MigrationInfo *qmp_query_migrate(Error **errp) info->ram->duplicate = dup_mig_pages_transferred(); info->ram->normal = norm_mig_pages_transferred(); info->ram->normal_bytes = norm_mig_bytes_transferred(); + info->ram->dirty_pages_rate = s->dirty_pages_rate; + if (blk_mig_active()) { info->has_disk = true; diff --git a/migration.h b/migration.h index 552200c348..66d7f68bb8 100644 --- a/migration.h +++ b/migration.h @@ -42,6 +42,7 @@ struct MigrationState int64_t total_time; int64_t downtime; int64_t expected_downtime; + int64_t dirty_pages_rate; bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; int64_t xbzrle_cache_size; }; diff --git a/qapi-schema.json b/qapi-schema.json index bcb5edb89d..c615ee212d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -383,13 +383,17 @@ # # @normal : number of normal pages (since 1.2) # -# @normal-bytes : number of normal bytes sent (since 1.2) +# @normal-bytes: number of normal bytes sent (since 1.2) +# +# @dirty-pages-rate: number of pages dirtied by second by the +# guest (since 1.3) # # Since: 0.14.0 ## { 'type': 'MigrationStats', 'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' , - 'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int' } } + 'duplicate': 'int', 'normal': 'int', 'normal-bytes': 'int', + 'dirty-pages-rate' : 'int' } } ## # @XBZRLECacheStats -- cgit v1.2.3-55-g7522 From 7ec81e56edc2b2007ce0ae3982aa5c18af9546ab Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 4 Dec 2012 11:38:38 +1100 Subject: Fix off-by-1 error in RAM migration code The code for migrating (or savevm-ing) memory pages starts off by creating a dirty bitmap and filling it with 1s. Except, actually, because bit addresses are 0-based it fills every bit except bit 0 with 1s and puts an extra 1 beyond the end of the bitmap, potentially corrupting unrelated memory. Oops. This patch fixes it. Signed-off-by: David Gibson Signed-off-by: Anthony Liguori --- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index e6effe809a..b75a4c5580 100644 --- a/arch_init.c +++ b/arch_init.c @@ -568,7 +568,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS; migration_bitmap = bitmap_new(ram_pages); - bitmap_set(migration_bitmap, 1, ram_pages); + bitmap_set(migration_bitmap, 0, ram_pages); migration_dirty_pages = ram_pages; bytes_transferred = 0; -- cgit v1.2.3-55-g7522 From 45e6cee42b98d10e2e14885ab656541a9ffd5187 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 4 Dec 2012 11:38:39 +1100 Subject: migration: Fix madvise breakage if host and guest have different page sizes madvise(DONTNEED) will throw away the contents of the whole page at the given address, even if the given length is less than the page size. One can argue about whether that's the correct behaviour, but that's what it's done for a long time in Linux at least. That means that the madvise() in ram_load(), on a setup where TARGET_PAGE_SIZE is smaller than the host page size, can throw away data in guest pages adjacent to the one it's actually processing right now, leading to guest memory corruption on an incoming migration. This patch therefore, disables the madvise() if the host page size is larger than TARGET_PAGE_SIZE. This means we don't get the benefits of that madvise() in this case, but a more complete fix is more difficult to accomplish. This at least fixes the guest memory corruption. Signed-off-by: David Gibson Reported-by: Alexey Kardashevskiy Signed-off-by: Anthony Liguori --- arch_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index b75a4c5580..83dcc53ff5 100644 --- a/arch_init.c +++ b/arch_init.c @@ -840,7 +840,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) memset(host, ch, TARGET_PAGE_SIZE); #ifndef _WIN32 if (ch == 0 && - (!kvm_enabled() || kvm_has_sync_mmu())) { + (!kvm_enabled() || kvm_has_sync_mmu()) && + getpagesize() <= TARGET_PAGE_SIZE) { qemu_madvise(host, TARGET_PAGE_SIZE, QEMU_MADV_DONTNEED); } #endif -- cgit v1.2.3-55-g7522 From a2cb15b0ddfa05f81a42d7b65dd0c7c50e420c33 Mon Sep 17 00:00:00 2001 From: Michael S. Tsirkin Date: Wed, 12 Dec 2012 14:24:50 +0200 Subject: pci: update all users to look in pci/ update all users so we can remove the makefile hack. Signed-off-by: Michael S. Tsirkin --- arch_init.c | 2 +- hw/ac97.c | 2 +- hw/acpi_ich9.c | 2 +- hw/acpi_piix4.c | 2 +- hw/alpha_sys.h | 4 ++-- hw/apb_pci.c | 8 ++++---- hw/apic.c | 2 +- hw/apm.c | 2 +- hw/bonito.c | 4 ++-- hw/cirrus_vga.c | 2 +- hw/dec_pci.c | 8 ++++---- hw/e1000.c | 2 +- hw/eepro100.c | 2 +- hw/es1370.c | 2 +- hw/esp-pci.c | 2 +- hw/grackle_pci.c | 4 ++-- hw/gt64xxx.c | 4 ++-- hw/hda-audio.c | 2 +- hw/i82378.c | 2 +- hw/i82801b11.c | 2 +- hw/ich9.h | 8 ++++---- hw/ide.h | 2 +- hw/ide/ahci.c | 4 ++-- hw/ide/cmd646.c | 2 +- hw/ide/core.c | 2 +- hw/ide/ich.c | 4 ++-- hw/ide/pci.c | 2 +- hw/ide/piix.c | 2 +- hw/ide/via.c | 2 +- hw/intel-hda.c | 4 ++-- hw/ioh3420.c | 6 +++--- hw/ioh3420.h | 2 +- hw/ivshmem.c | 4 ++-- hw/kvm/apic.c | 2 +- hw/kvm/pci-assign.c | 4 ++-- hw/lpc_ich9.c | 8 ++++---- hw/lsi53c895a.c | 2 +- hw/macio.c | 2 +- hw/megasas.c | 4 ++-- hw/mips_fulong2e.c | 2 +- hw/mips_malta.c | 2 +- hw/ne2000.c | 2 +- hw/openpic.c | 2 +- hw/pc.c | 4 ++-- hw/pc_piix.c | 4 ++-- hw/pci_bridge_dev.c | 12 ++++++------ hw/pcnet-pci.c | 2 +- hw/piix4.c | 2 +- hw/piix_pci.c | 4 ++-- hw/ppc/e500.c | 2 +- hw/ppc440_bamboo.c | 2 +- hw/ppc4xx.h | 2 +- hw/ppc4xx_pci.c | 4 ++-- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 4 ++-- hw/ppce500_pci.c | 4 ++-- hw/prep_pci.c | 4 ++-- hw/q35.h | 4 ++-- hw/qxl.h | 2 +- hw/r2d.c | 2 +- hw/realview.c | 2 +- hw/rtl8139.c | 2 +- hw/serial-pci.c | 2 +- hw/sga.c | 2 +- hw/sh_pci.c | 4 ++-- hw/smbus_ich9.c | 2 +- hw/spapr.c | 4 ++-- hw/spapr_pci.c | 10 +++++----- hw/spapr_pci.h | 4 ++-- hw/sun4u.c | 2 +- hw/unin_pci.c | 4 ++-- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 6 +++--- hw/versatile_pci.c | 4 ++-- hw/versatilepb.c | 2 +- hw/vfio_pci.c | 6 +++--- hw/vga-pci.c | 2 +- hw/vga.c | 2 +- hw/virtio-balloon.h | 2 +- hw/virtio-net.h | 2 +- hw/virtio-pci.c | 6 +++--- hw/virtio-scsi.h | 2 +- hw/vmware_vga.c | 2 +- hw/vt82c686.c | 4 ++-- hw/wdt_i6300esb.c | 2 +- hw/xen-host-pci-device.h | 2 +- hw/xen_apic.c | 2 +- hw/xen_platform.c | 2 +- hw/xen_pt.c | 2 +- hw/xen_pt.h | 2 +- hw/xio3130_downstream.c | 6 +++--- hw/xio3130_downstream.h | 2 +- hw/xio3130_upstream.c | 6 +++--- hw/xio3130_upstream.h | 2 +- kvm-all.c | 2 +- kvm-stub.c | 2 +- monitor.c | 2 +- target-i386/kvm.c | 2 +- xen-all.c | 2 +- 102 files changed, 159 insertions(+), 159 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index e6effe809a..e307b23310 100644 --- a/arch_init.c +++ b/arch_init.c @@ -36,7 +36,7 @@ #include "arch_init.h" #include "audio/audio.h" #include "hw/pc.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "hw/audiodev.h" #include "kvm.h" #include "migration.h" diff --git a/hw/ac97.c b/hw/ac97.c index ce6a1dc609..3e659b38df 100644 --- a/hw/ac97.c +++ b/hw/ac97.c @@ -20,7 +20,7 @@ #include "hw.h" #include "audiodev.h" #include "audio/audio.h" -#include "pci.h" +#include "pci/pci.h" #include "dma.h" enum { diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 85d441c33c..755fa050f7 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -25,7 +25,7 @@ */ #include "hw.h" #include "pc.h" -#include "pci.h" +#include "pci/pci.h" #include "qemu-timer.h" #include "sysemu.h" #include "acpi.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 0b5b0d3d3e..46f9843891 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -22,7 +22,7 @@ #include "pc.h" #include "apm.h" #include "pm_smbus.h" -#include "pci.h" +#include "pci/pci.h" #include "acpi.h" #include "sysemu.h" #include "range.h" diff --git a/hw/alpha_sys.h b/hw/alpha_sys.h index 7604d09c80..b1e52585b3 100644 --- a/hw/alpha_sys.h +++ b/hw/alpha_sys.h @@ -3,8 +3,8 @@ #ifndef HW_ALPHA_H #define HW_ALPHA_H 1 -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "ide.h" #include "net.h" #include "pc.h" diff --git a/hw/apb_pci.c b/hw/apb_pci.c index 054814fd4b..de594f8c0b 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -27,10 +27,10 @@ the secondary PCI bridge. */ #include "sysbus.h" -#include "pci.h" -#include "pci_host.h" -#include "pci_bridge.h" -#include "pci_internals.h" +#include "pci/pci.h" +#include "pci/pci_host.h" +#include "pci/pci_bridge.h" +#include "pci/pci_internals.h" #include "apb_pci.h" #include "sysemu.h" #include "exec-memory.h" diff --git a/hw/apic.c b/hw/apic.c index f73fc877aa..d66a476aac 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -20,7 +20,7 @@ #include "apic_internal.h" #include "apic.h" #include "ioapic.h" -#include "msi.h" +#include "pci/msi.h" #include "host-utils.h" #include "trace.h" #include "pc.h" diff --git a/hw/apm.c b/hw/apm.c index e988ad9939..2e1b1372d2 100644 --- a/hw/apm.c +++ b/hw/apm.c @@ -22,7 +22,7 @@ #include "apm.h" #include "hw.h" -#include "pci.h" +#include "pci/pci.h" //#define DEBUG diff --git a/hw/bonito.c b/hw/bonito.c index 0bf6d4aa5f..a1fc38c784 100644 --- a/hw/bonito.c +++ b/hw/bonito.c @@ -40,10 +40,10 @@ #include #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "pc.h" #include "mips.h" -#include "pci_host.h" +#include "pci/pci_host.h" #include "sysemu.h" #include "exec-memory.h" diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c index 40efa8a523..7d021f2e1d 100644 --- a/hw/cirrus_vga.c +++ b/hw/cirrus_vga.c @@ -27,7 +27,7 @@ * available at http://home.worldonline.dk/~finth/ */ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "console.h" #include "vga_int.h" #include "loader.h" diff --git a/hw/dec_pci.c b/hw/dec_pci.c index c30ade38bd..a6a7c846fd 100644 --- a/hw/dec_pci.c +++ b/hw/dec_pci.c @@ -25,10 +25,10 @@ #include "dec_pci.h" #include "sysbus.h" -#include "pci.h" -#include "pci_host.h" -#include "pci_bridge.h" -#include "pci_internals.h" +#include "pci/pci.h" +#include "pci/pci_host.h" +#include "pci/pci_bridge.h" +#include "pci/pci_internals.h" /* debug DEC */ //#define DEBUG_DEC diff --git a/hw/e1000.c b/hw/e1000.c index 5537ad2fc4..c89c8d22ab 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -26,7 +26,7 @@ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "net/checksum.h" #include "loader.h" diff --git a/hw/eepro100.c b/hw/eepro100.c index a189474d31..992f03ace7 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -42,7 +42,7 @@ #include /* offsetof */ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "eeprom93xx.h" #include "sysemu.h" diff --git a/hw/es1370.c b/hw/es1370.c index e0c9729dc9..65365788e1 100644 --- a/hw/es1370.c +++ b/hw/es1370.c @@ -29,7 +29,7 @@ #include "hw.h" #include "audiodev.h" #include "audio/audio.h" -#include "pci.h" +#include "pci/pci.h" #include "dma.h" /* Missing stuff: diff --git a/hw/esp-pci.c b/hw/esp-pci.c index d9a8e59c98..d433473d6a 100644 --- a/hw/esp-pci.c +++ b/hw/esp-pci.c @@ -23,7 +23,7 @@ * THE SOFTWARE. */ -#include "pci.h" +#include "pci/pci.h" #include "eeprom93xx.h" #include "esp.h" #include "trace.h" diff --git a/hw/grackle_pci.c b/hw/grackle_pci.c index 67da307284..948416632a 100644 --- a/hw/grackle_pci.c +++ b/hw/grackle_pci.c @@ -23,9 +23,9 @@ * THE SOFTWARE. */ -#include "pci_host.h" +#include "pci/pci_host.h" #include "ppc_mac.h" -#include "pci.h" +#include "pci/pci.h" /* debug Grackle */ //#define DEBUG_GRACKLE diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c index 95d491d932..5aa49c6148 100644 --- a/hw/gt64xxx.c +++ b/hw/gt64xxx.c @@ -24,8 +24,8 @@ #include "hw.h" #include "mips.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "pc.h" #include "exec-memory.h" diff --git a/hw/hda-audio.c b/hw/hda-audio.c index 36761dd2de..92a91b5ab1 100644 --- a/hw/hda-audio.c +++ b/hw/hda-audio.c @@ -18,7 +18,7 @@ */ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "intel-hda.h" #include "intel-hda-defs.h" #include "audio/audio.h" diff --git a/hw/i82378.c b/hw/i82378.c index 99f35d41ef..c6b0b5ec55 100644 --- a/hw/i82378.c +++ b/hw/i82378.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ -#include "pci.h" +#include "pci/pci.h" #include "pc.h" #include "i8254.h" #include "pcspk.h" diff --git a/hw/i82801b11.c b/hw/i82801b11.c index 3d1f996b2f..3dc10000a4 100644 --- a/hw/i82801b11.c +++ b/hw/i82801b11.c @@ -41,7 +41,7 @@ * License along with this library; if not, see */ -#include "pci.h" +#include "pci/pci.h" #include "ich9.h" diff --git a/hw/ich9.h b/hw/ich9.h index 34e216f142..ddd12934d5 100644 --- a/hw/ich9.h +++ b/hw/ich9.h @@ -8,13 +8,13 @@ #include "pc.h" #include "apm.h" #include "ioapic.h" -#include "pci.h" -#include "pcie_host.h" -#include "pci_bridge.h" +#include "pci/pci.h" +#include "pci/pcie_host.h" +#include "pci/pci_bridge.h" #include "acpi.h" #include "acpi_ich9.h" #include "pam.h" -#include "pci_internals.h" +#include "pci/pci_internals.h" void ich9_lpc_set_irq(void *opaque, int irq_num, int level); int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx); diff --git a/hw/ide.h b/hw/ide.h index add742c4a8..081c710d56 100644 --- a/hw/ide.h +++ b/hw/ide.h @@ -2,7 +2,7 @@ #define HW_IDE_H #include "isa.h" -#include "pci.h" +#include "pci/pci.h" #include "memory.h" #define MAX_IDE_DEVS 2 diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 67562db041..2ea64bd316 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -22,9 +22,9 @@ */ #include -#include +#include #include -#include +#include #include #include "monitor.h" diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index 804db60ffe..88210eabc8 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -24,7 +24,7 @@ */ #include #include -#include +#include #include #include "block.h" #include "sysemu.h" diff --git a/hw/ide/core.c b/hw/ide/core.c index c4f93d0e47..adc4aa41b9 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -24,7 +24,7 @@ */ #include #include -#include +#include #include #include "qemu-error.h" #include "qemu-timer.h" diff --git a/hw/ide/ich.c b/hw/ide/ich.c index 272b7734b5..8e1a48e257 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -61,9 +61,9 @@ */ #include -#include +#include #include -#include +#include #include #include "block.h" #include "dma.h" diff --git a/hw/ide/pci.c b/hw/ide/pci.c index bcdd70e450..23a0e237fb 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -24,7 +24,7 @@ */ #include #include -#include +#include #include #include "block.h" #include "dma.h" diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 9431badadf..5cf39cf8f0 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include "blockdev.h" #include "sysemu.h" diff --git a/hw/ide/via.c b/hw/ide/via.c index efda1733d9..8b4a24e5c2 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -25,7 +25,7 @@ */ #include #include -#include +#include #include #include "block.h" #include "sysemu.h" diff --git a/hw/intel-hda.c b/hw/intel-hda.c index a68c3685e3..c21bf7204a 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -18,8 +18,8 @@ */ #include "hw.h" -#include "pci.h" -#include "msi.h" +#include "pci/pci.h" +#include "pci/msi.h" #include "qemu-timer.h" #include "audiodev.h" #include "intel-hda.h" diff --git a/hw/ioh3420.c b/hw/ioh3420.c index 4d314733b9..d706e195df 100644 --- a/hw/ioh3420.c +++ b/hw/ioh3420.c @@ -20,9 +20,9 @@ * with this program; if not, see . */ -#include "pci_ids.h" -#include "msi.h" -#include "pcie.h" +#include "pci/pci_ids.h" +#include "pci/msi.h" +#include "pci/pcie.h" #include "ioh3420.h" #define PCI_DEVICE_ID_IOH_EPORT 0x3420 /* D0:F0 express mode */ diff --git a/hw/ioh3420.h b/hw/ioh3420.h index 68c523ab46..046cf2c281 100644 --- a/hw/ioh3420.h +++ b/hw/ioh3420.h @@ -1,7 +1,7 @@ #ifndef QEMU_IOH3420_H #define QEMU_IOH3420_H -#include "pcie_port.h" +#include "pci/pcie_port.h" PCIESlot *ioh3420_init(PCIBus *bus, int devfn, bool multifunction, const char *bus_name, pci_map_irq_fn map_irq, diff --git a/hw/ivshmem.c b/hw/ivshmem.c index f6dbb212f2..cf64f32ac0 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -18,8 +18,8 @@ */ #include "hw.h" #include "pc.h" -#include "pci.h" -#include "msix.h" +#include "pci/pci.h" +#include "pci/msix.h" #include "kvm.h" #include "migration.h" #include "qerror.h" diff --git a/hw/kvm/apic.c b/hw/kvm/apic.c index 8b65d513db..beb418de8d 100644 --- a/hw/kvm/apic.c +++ b/hw/kvm/apic.c @@ -10,7 +10,7 @@ * See the COPYING file in the top-level directory. */ #include "hw/apic_internal.h" -#include "hw/msi.h" +#include "hw/pci/msi.h" #include "kvm.h" static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic, diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index e80dad009c..42291592e3 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -34,8 +34,8 @@ #include "monitor.h" #include "range.h" #include "sysemu.h" -#include "hw/pci.h" -#include "hw/msi.h" +#include "hw/pci/pci.h" +#include "hw/pci/msi.h" #include "kvm_i386.h" #define MSIX_PAGE_SIZE 0x1000 diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index 7a113633ed..811bf261c3 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -35,14 +35,14 @@ #include "pc.h" #include "apm.h" #include "ioapic.h" -#include "pci.h" -#include "pcie_host.h" -#include "pci_bridge.h" +#include "pci/pci.h" +#include "pci/pcie_host.h" +#include "pci/pci_bridge.h" #include "ich9.h" #include "acpi.h" #include "acpi_ich9.h" #include "pam.h" -#include "pci_internals.h" +#include "pci/pci_internals.h" #include "exec-memory.h" #include "sysemu.h" diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 04f2faef42..4aac9a0cff 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -13,7 +13,7 @@ #include #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "scsi.h" #include "dma.h" diff --git a/hw/macio.c b/hw/macio.c index eb15b890b1..362afdc7ec 100644 --- a/hw/macio.c +++ b/hw/macio.c @@ -24,7 +24,7 @@ */ #include "hw.h" #include "ppc_mac.h" -#include "pci.h" +#include "pci/pci.h" #include "escc.h" typedef struct MacIOState diff --git a/hw/megasas.c b/hw/megasas.c index 61b6527928..f4fbe9790a 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -19,9 +19,9 @@ */ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "dma.h" -#include "msix.h" +#include "pci/msix.h" #include "iov.h" #include "scsi.h" #include "scsi-defs.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 5fcf900e04..d5cf33b4b6 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -29,7 +29,7 @@ #include "flash.h" #include "mips.h" #include "mips_cpudevs.h" -#include "pci.h" +#include "pci/pci.h" #include "qemu-char.h" #include "sysemu.h" #include "audio/audio.h" diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 4d2464a02c..571903dfc5 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -33,7 +33,7 @@ #include "flash.h" #include "mips.h" #include "mips_cpudevs.h" -#include "pci.h" +#include "pci/pci.h" #include "qemu-char.h" #include "sysemu.h" #include "arch_init.h" diff --git a/hw/ne2000.c b/hw/ne2000.c index d3dd9a6f26..fb78e5b252 100644 --- a/hw/ne2000.c +++ b/hw/ne2000.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "ne2000.h" #include "loader.h" diff --git a/hw/openpic.c b/hw/openpic.c index 8b3784a6bd..4791dc6eaf 100644 --- a/hw/openpic.c +++ b/hw/openpic.c @@ -35,7 +35,7 @@ */ #include "hw.h" #include "ppc_mac.h" -#include "pci.h" +#include "pci/pci.h" #include "openpic.h" //#define DEBUG_OPENPIC diff --git a/hw/pc.c b/hw/pc.c index b11e7c4adc..d1b102c879 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -27,7 +27,7 @@ #include "apic.h" #include "fdc.h" #include "ide.h" -#include "pci.h" +#include "pci/pci.h" #include "monitor.h" #include "fw_cfg.h" #include "hpet_emul.h" @@ -38,7 +38,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "pcspk.h" -#include "msi.h" +#include "pci/msi.h" #include "sysbus.h" #include "sysemu.h" #include "kvm.h" diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 19e342aeb4..c2b4cb07e5 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -27,8 +27,8 @@ #include "hw.h" #include "pc.h" #include "apic.h" -#include "pci.h" -#include "pci_ids.h" +#include "pci/pci.h" +#include "pci/pci_ids.h" #include "usb.h" #include "net.h" #include "boards.h" diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c index f7063961a0..5c9fc5036b 100644 --- a/hw/pci_bridge_dev.c +++ b/hw/pci_bridge_dev.c @@ -19,13 +19,13 @@ * with this program; if not, see . */ -#include "pci_bridge.h" -#include "pci_ids.h" -#include "msi.h" -#include "shpc.h" -#include "slotid_cap.h" +#include "pci/pci_bridge.h" +#include "pci/pci_ids.h" +#include "pci/msi.h" +#include "pci/shpc.h" +#include "pci/slotid_cap.h" #include "memory.h" -#include "pci_internals.h" +#include "pci/pci_internals.h" #define REDHAT_PCI_VENDOR_ID 0x1b36 #define PCI_BRIDGE_DEV_VENDOR_ID REDHAT_PCI_VENDOR_ID diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c index 0bf438ffee..c1abbf8d0d 100644 --- a/hw/pcnet-pci.c +++ b/hw/pcnet-pci.c @@ -27,7 +27,7 @@ * AMD Publication# 19436 Rev:E Amendment/0 Issue Date: June 2000 */ -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "loader.h" #include "qemu-timer.h" diff --git a/hw/piix4.c b/hw/piix4.c index ce4eb0d1ae..799ed1729c 100644 --- a/hw/piix4.c +++ b/hw/piix4.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" -#include "pci.h" +#include "pci/pci.h" #include "isa.h" #include "sysbus.h" diff --git a/hw/piix_pci.c b/hw/piix_pci.c index ba1b3de749..b5ea68bc61 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -24,8 +24,8 @@ #include "hw.h" #include "pc.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "isa.h" #include "sysbus.h" #include "range.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 6749ffffb3..f77c488af7 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -20,7 +20,7 @@ #include "net.h" #include "hw/hw.h" #include "hw/serial.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "hw/boards.h" #include "sysemu.h" #include "kvm.h" diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index cc85607cb7..0b39a81ec5 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "net.h" #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "boards.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/hw/ppc4xx.h b/hw/ppc4xx.h index d795ced57e..2b96d47f36 100644 --- a/hw/ppc4xx.h +++ b/hw/ppc4xx.h @@ -25,7 +25,7 @@ #if !defined(PPC_4XX_H) #define PPC_4XX_H -#include "pci.h" +#include "pci/pci.h" /* PowerPC 4xx core initialization */ CPUPPCState *ppc4xx_init (const char *cpu_model, diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c index d3ad6a0b79..3e8af11f08 100644 --- a/hw/ppc4xx_pci.c +++ b/hw/ppc4xx_pci.c @@ -22,8 +22,8 @@ #include "hw.h" #include "ppc.h" #include "ppc4xx.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "exec-memory.h" #undef DEBUG diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 664747ead3..c1ff9d7c31 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -52,7 +52,7 @@ #include "adb.h" #include "mac_dbdma.h" #include "nvram.h" -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "sysemu.h" #include "boards.h" diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index e8138c091e..3bc29c619c 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "net.h" #include "isa.h" -#include "pci.h" +#include "pci/pci.h" #include "boards.h" #include "fw_cfg.h" #include "escc.h" diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index bf15730d8b..f6ffb593b7 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -29,8 +29,8 @@ #include "net.h" #include "sysemu.h" #include "isa.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "ppc.h" #include "boards.h" #include "qemu-log.h" diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index 2ff7438d09..39022aada0 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -15,8 +15,8 @@ */ #include "hw.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "bswap.h" #ifdef DEBUG_PCI diff --git a/hw/prep_pci.c b/hw/prep_pci.c index 0bc479cd1f..5f22de647a 100644 --- a/hw/prep_pci.c +++ b/hw/prep_pci.c @@ -23,8 +23,8 @@ */ #include "hw.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "pc.h" #include "exec-memory.h" diff --git a/hw/q35.h b/hw/q35.h index e34f7c165f..2f951c8a94 100644 --- a/hw/q35.h +++ b/hw/q35.h @@ -29,8 +29,8 @@ #include "pc.h" #include "apm.h" #include "apic.h" -#include "pci.h" -#include "pcie_host.h" +#include "pci/pci.h" +#include "pci/pcie_host.h" #include "acpi.h" #include "acpi_ich9.h" #include "pam.h" diff --git a/hw/qxl.h b/hw/qxl.h index e583cfb750..41246c7554 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -2,7 +2,7 @@ #include "console.h" #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "vga_int.h" #include "qemu-thread.h" diff --git a/hw/r2d.c b/hw/r2d.c index 66212e9cda..e18c23b28b 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -29,7 +29,7 @@ #include "devices.h" #include "sysemu.h" #include "boards.h" -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "sh7750_regs.h" #include "ide.h" diff --git a/hw/realview.c b/hw/realview.c index e789c159a9..149bb562af 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -11,7 +11,7 @@ #include "arm-misc.h" #include "primecell.h" #include "devices.h" -#include "pci.h" +#include "pci/pci.h" #include "net.h" #include "sysemu.h" #include "boards.h" diff --git a/hw/rtl8139.c b/hw/rtl8139.c index e3aa8bfb11..e294a2a5e3 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -52,7 +52,7 @@ #include #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "dma.h" #include "qemu-timer.h" #include "net.h" diff --git a/hw/serial-pci.c b/hw/serial-pci.c index 95dc5c8d2f..6a2548a515 100644 --- a/hw/serial-pci.c +++ b/hw/serial-pci.c @@ -26,7 +26,7 @@ /* see docs/specs/pci-serial.txt */ #include "serial.h" -#include "pci.h" +#include "pci/pci.h" #define PCI_SERIAL_MAX_PORTS 4 diff --git a/hw/sga.c b/hw/sga.c index a666349f82..5d80efd0c2 100644 --- a/hw/sga.c +++ b/hw/sga.c @@ -24,7 +24,7 @@ * sgabios code originally available at code.google.com/p/sgabios * */ -#include "pci.h" +#include "pci/pci.h" #include "pc.h" #include "loader.h" #include "sysemu.h" diff --git a/hw/sh_pci.c b/hw/sh_pci.c index fdec71b9e8..9ea08c8f8e 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -23,8 +23,8 @@ */ #include "sysbus.h" #include "sh.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "bswap.h" #include "exec-memory.h" diff --git a/hw/smbus_ich9.c b/hw/smbus_ich9.c index d202664a36..b7bddc80d3 100644 --- a/hw/smbus_ich9.c +++ b/hw/smbus_ich9.c @@ -27,7 +27,7 @@ #include "hw.h" #include "pc.h" #include "pm_smbus.h" -#include "pci.h" +#include "pci/pci.h" #include "sysemu.h" #include "i2c.h" #include "smbus.h" diff --git a/hw/spapr.c b/hw/spapr.c index ad3f0ea7fc..b0125a892c 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -41,11 +41,11 @@ #include "hw/spapr_vio.h" #include "hw/spapr_pci.h" #include "hw/xics.h" -#include "hw/msi.h" +#include "hw/pci/msi.h" #include "kvm.h" #include "kvm_ppc.h" -#include "pci.h" +#include "pci/pci.h" #include "exec-memory.h" #include "hw/usb.h" diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c index 3c5b855bc0..2386164d5d 100644 --- a/hw/spapr_pci.c +++ b/hw/spapr_pci.c @@ -23,17 +23,17 @@ * THE SOFTWARE. */ #include "hw.h" -#include "pci.h" -#include "msi.h" -#include "msix.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/msi.h" +#include "pci/msix.h" +#include "pci/pci_host.h" #include "hw/spapr.h" #include "hw/spapr_pci.h" #include "exec-memory.h" #include #include "trace.h" -#include "hw/pci_internals.h" +#include "hw/pci/pci_internals.h" /* Copied from the kernel arch/powerpc/platforms/pseries/msi.c */ #define RTAS_QUERY_FN 0 diff --git a/hw/spapr_pci.h b/hw/spapr_pci.h index e307ac8035..7b26ba1561 100644 --- a/hw/spapr_pci.h +++ b/hw/spapr_pci.h @@ -23,8 +23,8 @@ #if !defined(__HW_SPAPR_PCI_H__) #define __HW_SPAPR_PCI_H__ -#include "hw/pci.h" -#include "hw/pci_host.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" #include "hw/xics.h" #define SPAPR_MSIX_MAX_DEVS 32 diff --git a/hw/sun4u.c b/hw/sun4u.c index b2b51e30c2..47bcf9382d 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "pci.h" +#include "pci/pci.h" #include "apb_pci.h" #include "pc.h" #include "serial.h" diff --git a/hw/unin_pci.c b/hw/unin_pci.c index 9981d949d2..46757924b6 100644 --- a/hw/unin_pci.c +++ b/hw/unin_pci.c @@ -23,8 +23,8 @@ */ #include "hw.h" #include "ppc_mac.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" /* debug UniNorth */ //#define DEBUG_UNIN diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 41dbb539f2..8b043966f6 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -16,7 +16,7 @@ */ #include "hw/usb/hcd-ehci.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "range.h" typedef struct EHCIPCIState { diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index e16a2ecab4..4faf8e1aed 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -29,7 +29,7 @@ #include "hw/hw.h" #include "qemu-timer.h" #include "hw/usb.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "hw/sysbus.h" #include "hw/qdev-dma.h" diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index d053791de0..04c944613c 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -27,7 +27,7 @@ */ #include "hw/hw.h" #include "hw/usb.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "qemu-timer.h" #include "iov.h" #include "dma.h" diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index efb509e423..220c3b536a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -21,9 +21,9 @@ #include "hw/hw.h" #include "qemu-timer.h" #include "hw/usb.h" -#include "hw/pci.h" -#include "hw/msi.h" -#include "hw/msix.h" +#include "hw/pci/pci.h" +#include "hw/pci/msi.h" +#include "hw/pci/msix.h" #include "trace.h" //#define DEBUG_XHCI diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index e0c3ee36a5..7a543b47d0 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -8,8 +8,8 @@ */ #include "sysbus.h" -#include "pci.h" -#include "pci_host.h" +#include "pci/pci.h" +#include "pci/pci_host.h" #include "exec-memory.h" typedef struct { diff --git a/hw/versatilepb.c b/hw/versatilepb.c index 25e652b1aa..41e39d8fb9 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -12,7 +12,7 @@ #include "devices.h" #include "net.h" #include "sysemu.h" -#include "pci.h" +#include "pci/pci.h" #include "i2c.h" #include "boards.h" #include "blockdev.h" diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 7c27834e06..45d90ab490 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -31,9 +31,9 @@ #include "exec-memory.h" #include "kvm.h" #include "memory.h" -#include "msi.h" -#include "msix.h" -#include "pci.h" +#include "pci/msi.h" +#include "pci/msix.h" +#include "pci/pci.h" #include "qemu-common.h" #include "qemu-error.h" #include "qemu-queue.h" diff --git a/hw/vga-pci.c b/hw/vga-pci.c index 947e35c76f..0cb318eab6 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -25,7 +25,7 @@ */ #include "hw.h" #include "console.h" -#include "pci.h" +#include "pci/pci.h" #include "vga_int.h" #include "pixel_ops.h" #include "qemu-timer.h" diff --git a/hw/vga.c b/hw/vga.c index 2b0200a164..6d56f8a5d9 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -25,7 +25,7 @@ #include "vga.h" #include "console.h" #include "pc.h" -#include "pci.h" +#include "pci/pci.h" #include "vga_int.h" #include "pixel_ops.h" #include "qemu-timer.h" diff --git a/hw/virtio-balloon.h b/hw/virtio-balloon.h index 73300ddc86..b1828f4a48 100644 --- a/hw/virtio-balloon.h +++ b/hw/virtio-balloon.h @@ -16,7 +16,7 @@ #define _QEMU_VIRTIO_BALLOON_H #include "virtio.h" -#include "pci.h" +#include "pci/pci.h" /* from Linux's linux/virtio_balloon.h */ diff --git a/hw/virtio-net.h b/hw/virtio-net.h index 36aa463812..b13be7ccb5 100644 --- a/hw/virtio-net.h +++ b/hw/virtio-net.h @@ -16,7 +16,7 @@ #include "virtio.h" #include "net.h" -#include "pci.h" +#include "pci/pci.h" #define ETH_ALEN 6 diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 71f4fb5dc6..e9b722dd96 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -22,10 +22,10 @@ #include "virtio-net.h" #include "virtio-serial.h" #include "virtio-scsi.h" -#include "pci.h" +#include "pci/pci.h" #include "qemu-error.h" -#include "msi.h" -#include "msix.h" +#include "pci/msi.h" +#include "pci/msix.h" #include "net.h" #include "loader.h" #include "kvm.h" diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h index 91924f6dfc..7d7cba752d 100644 --- a/hw/virtio-scsi.h +++ b/hw/virtio-scsi.h @@ -16,7 +16,7 @@ #include "virtio.h" #include "net.h" -#include "pci.h" +#include "pci/pci.h" /* The ID for virtio_scsi */ #define VIRTIO_ID_SCSI 8 diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index 834588daf6..333ec8cebe 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -24,7 +24,7 @@ #include "hw.h" #include "loader.h" #include "console.h" -#include "pci.h" +#include "pci/pci.h" #undef VERBOSE #define HW_RECT_ACCEL diff --git a/hw/vt82c686.c b/hw/vt82c686.c index 57d16c0134..f963912112 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -15,7 +15,7 @@ #include "vt82c686.h" #include "i2c.h" #include "smbus.h" -#include "pci.h" +#include "pci/pci.h" #include "isa.h" #include "sysbus.h" #include "mips.h" @@ -27,7 +27,7 @@ #include "exec-memory.h" typedef uint32_t pci_addr_t; -#include "pci_host.h" +#include "pci/pci_host.h" //#define DEBUG_VT82C686B #ifdef DEBUG_VT82C686B diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c index da15c73918..181774220d 100644 --- a/hw/wdt_i6300esb.c +++ b/hw/wdt_i6300esb.c @@ -25,7 +25,7 @@ #include "qemu-timer.h" #include "watchdog.h" #include "hw.h" -#include "pci.h" +#include "pci/pci.h" /*#define I6300ESB_DEBUG 1*/ diff --git a/hw/xen-host-pci-device.h b/hw/xen-host-pci-device.h index 0079daca51..942b24dccc 100644 --- a/hw/xen-host-pci-device.h +++ b/hw/xen-host-pci-device.h @@ -1,7 +1,7 @@ #ifndef XEN_HOST_PCI_DEVICE_H #define XEN_HOST_PCI_DEVICE_H -#include "pci.h" +#include "pci/pci.h" enum { XEN_HOST_PCI_REGION_TYPE_IO = 1 << 1, diff --git a/hw/xen_apic.c b/hw/xen_apic.c index fc4536651a..a6632fe798 100644 --- a/hw/xen_apic.c +++ b/hw/xen_apic.c @@ -10,7 +10,7 @@ * later. See the COPYING file in the top-level directory. */ #include "hw/apic_internal.h" -#include "hw/msi.h" +#include "hw/pci/msi.h" #include "xen.h" static uint64_t xen_apic_mem_read(void *opaque, hwaddr addr, diff --git a/hw/xen_platform.c b/hw/xen_platform.c index a54e7a2cdb..10bb560073 100644 --- a/hw/xen_platform.c +++ b/hw/xen_platform.c @@ -27,7 +27,7 @@ #include "hw.h" #include "pc.h" -#include "pci.h" +#include "pci/pci.h" #include "irq.h" #include "xen_common.h" #include "net.h" diff --git a/hw/xen_pt.c b/hw/xen_pt.c index 7a3846e649..c782cdb283 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -54,7 +54,7 @@ #include -#include "pci.h" +#include "pci/pci.h" #include "xen.h" #include "xen_backend.h" #include "xen_pt.h" diff --git a/hw/xen_pt.h b/hw/xen_pt.h index f15e69a290..e3497302cf 100644 --- a/hw/xen_pt.h +++ b/hw/xen_pt.h @@ -3,7 +3,7 @@ #include "qemu-common.h" #include "xen_common.h" -#include "pci.h" +#include "pci/pci.h" #include "xen-host-pci-device.h" void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3); diff --git a/hw/xio3130_downstream.c b/hw/xio3130_downstream.c index 0d8a5e7020..2dcd46bff1 100644 --- a/hw/xio3130_downstream.c +++ b/hw/xio3130_downstream.c @@ -19,9 +19,9 @@ * with this program; if not, see . */ -#include "pci_ids.h" -#include "msi.h" -#include "pcie.h" +#include "pci/pci_ids.h" +#include "pci/msi.h" +#include "pci/pcie.h" #include "xio3130_downstream.h" #define PCI_DEVICE_ID_TI_XIO3130D 0x8233 /* downstream port */ diff --git a/hw/xio3130_downstream.h b/hw/xio3130_downstream.h index 010487f2d9..559dff6565 100644 --- a/hw/xio3130_downstream.h +++ b/hw/xio3130_downstream.h @@ -1,7 +1,7 @@ #ifndef QEMU_XIO3130_DOWNSTREAM_H #define QEMU_XIO3130_DOWNSTREAM_H -#include "pcie_port.h" +#include "pci/pcie_port.h" PCIESlot *xio3130_downstream_init(PCIBus *bus, int devfn, bool multifunction, const char *bus_name, pci_map_irq_fn map_irq, diff --git a/hw/xio3130_upstream.c b/hw/xio3130_upstream.c index d46b86c74d..713caf2dda 100644 --- a/hw/xio3130_upstream.c +++ b/hw/xio3130_upstream.c @@ -19,9 +19,9 @@ * with this program; if not, see . */ -#include "pci_ids.h" -#include "msi.h" -#include "pcie.h" +#include "pci/pci_ids.h" +#include "pci/msi.h" +#include "pci/pcie.h" #include "xio3130_upstream.h" #define PCI_DEVICE_ID_TI_XIO3130U 0x8232 /* upstream port */ diff --git a/hw/xio3130_upstream.h b/hw/xio3130_upstream.h index e9969975ff..fa09656b35 100644 --- a/hw/xio3130_upstream.h +++ b/hw/xio3130_upstream.h @@ -1,7 +1,7 @@ #ifndef QEMU_XIO3130_UPSTREAM_H #define QEMU_XIO3130_UPSTREAM_H -#include "pcie_port.h" +#include "pci/pcie_port.h" PCIEPort *xio3130_upstream_init(PCIBus *bus, int devfn, bool multifunction, const char *bus_name, pci_map_irq_fn map_irq, diff --git a/kvm-all.c b/kvm-all.c index 8e9a8d8fd2..bfa09ad05b 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -26,7 +26,7 @@ #include "qemu-config.h" #include "sysemu.h" #include "hw/hw.h" -#include "hw/msi.h" +#include "hw/pci/msi.h" #include "gdbstub.h" #include "kvm.h" #include "bswap.h" diff --git a/kvm-stub.c b/kvm-stub.c index a3455e2203..d65fd04507 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -12,7 +12,7 @@ #include "qemu-common.h" #include "hw/hw.h" -#include "hw/msi.h" +#include "hw/pci/msi.h" #include "cpu.h" #include "gdbstub.h" #include "kvm.h" diff --git a/monitor.c b/monitor.c index c0e32d60c3..a92ab44384 100644 --- a/monitor.c +++ b/monitor.c @@ -27,7 +27,7 @@ #include "hw/usb.h" #include "hw/pcmcia.h" #include "hw/pc.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "hw/watchdog.h" #include "hw/loader.h" #include "gdbstub.h" diff --git a/target-i386/kvm.c b/target-i386/kvm.c index f669281e13..0901589a88 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -31,7 +31,7 @@ #include "hw/apic.h" #include "ioport.h" #include "hyperv.h" -#include "hw/pci.h" +#include "hw/pci/pci.h" //#define DEBUG_KVM diff --git a/xen-all.c b/xen-all.c index 046cc2ac37..e3a51ccc81 100644 --- a/xen-all.c +++ b/xen-all.c @@ -10,7 +10,7 @@ #include -#include "hw/pci.h" +#include "hw/pci/pci.h" #include "hw/pc.h" #include "hw/xen_common.h" #include "hw/xen_backend.h" -- cgit v1.2.3-55-g7522 From 077805fa92b9089137c6b6b196d449ee05cc342f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 25 Sep 2012 10:04:17 +0200 Subject: janitor: do not rely on indirect inclusions of or from qemu-char.h Various header files rely on qemu-char.h including qemu-config.h or main-loop.h, but they really do not need qemu-char.h at all (particularly interesting is the case of the block layer!). Clean this up, and also add missing inclusions of qemu-char.h itself. Signed-off-by: Paolo Bonzini --- arch_init.c | 1 + audio/alsaaudio.c | 1 + audio/ossaudio.c | 1 + block/blkdebug.c | 1 + block/iscsi.c | 1 + bt-host.c | 1 + bt-vhci.c | 1 + event_notifier-posix.c | 1 + exec.c | 1 + hw/arm_boot.c | 1 + hw/dma.c | 1 + hw/fw_cfg.c | 1 + hw/jazz_led.c | 1 + hw/mac_dbdma.c | 1 + hw/ppc/e500.c | 1 + hw/puv3.c | 2 ++ hw/qdev-monitor.c | 1 + hw/qdev-properties.c | 1 + hw/s390x/sclpconsole.c | 1 + hw/spapr.c | 1 + hw/tcx.c | 1 + hw/usb/dev-network.c | 1 + net.c | 1 + qemu-config.h | 1 + spice-qemu-char.c | 1 + target-i386/kvm.c | 1 + 26 files changed, 27 insertions(+) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 1645f3079a..ef866cdea4 100644 --- a/arch_init.c +++ b/arch_init.c @@ -46,6 +46,7 @@ #include "exec-memory.h" #include "hw/pcspk.h" #include "qemu/page_cache.h" +#include "qemu-config.h" #include "qmp-commands.h" #include "trace.h" diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index cb45b49c2a..564d632d0c 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -23,6 +23,7 @@ */ #include #include "qemu-common.h" +#include "main-loop.h" #include "qemu-char.h" #include "audio.h" diff --git a/audio/ossaudio.c b/audio/ossaudio.c index df51b7cc58..45abe39a6d 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -31,6 +31,7 @@ #include #endif #include "qemu-common.h" +#include "main-loop.h" #include "host-utils.h" #include "qemu-char.h" #include "audio.h" diff --git a/block/blkdebug.c b/block/blkdebug.c index 294e983306..65556e73e5 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -23,6 +23,7 @@ */ #include "qemu-common.h" +#include "qemu-config.h" #include "block_int.h" #include "module.h" diff --git a/block/iscsi.c b/block/iscsi.c index c0b70b3d32..33b93d8000 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -27,6 +27,7 @@ #include #include #include "qemu-common.h" +#include "qemu-config.h" #include "qemu-error.h" #include "block_int.h" #include "trace.h" diff --git a/bt-host.c b/bt-host.c index 0d3ad28e8c..8b47370b26 100644 --- a/bt-host.c +++ b/bt-host.c @@ -21,6 +21,7 @@ #include "qemu-char.h" #include "net.h" #include "bt-host.h" +#include "main-loop.h" #ifndef _WIN32 # include diff --git a/bt-vhci.c b/bt-vhci.c index bbc1029854..878460aeb5 100644 --- a/bt-vhci.c +++ b/bt-vhci.c @@ -21,6 +21,7 @@ #include "qemu-char.h" #include "net.h" #include "hw/bt.h" +#include "main-loop.h" #define VHCI_DEV "/dev/vhci" #define VHCI_UDEV "/dev/hci_vhci" diff --git a/event_notifier-posix.c b/event_notifier-posix.c index 6f3239a3fc..f0bd839acd 100644 --- a/event_notifier-posix.c +++ b/event_notifier-posix.c @@ -13,6 +13,7 @@ #include "qemu-common.h" #include "event_notifier.h" #include "qemu-char.h" +#include "main-loop.h" #ifdef CONFIG_EVENTFD #include diff --git a/exec.c b/exec.c index 4c1246a9f9..986084146c 100644 --- a/exec.c +++ b/exec.c @@ -33,6 +33,7 @@ #include "kvm.h" #include "hw/xen.h" #include "qemu-timer.h" +#include "qemu-config.h" #include "memory.h" #include "dma.h" #include "exec-memory.h" diff --git a/hw/arm_boot.c b/hw/arm_boot.c index ec3b8d5d12..63ff559cf7 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -15,6 +15,7 @@ #include "loader.h" #include "elf.h" #include "device_tree.h" +#include "qemu-config.h" #define KERNEL_ARGS_ADDR 0x100 #define KERNEL_LOAD_ADDR 0x00010000 diff --git a/hw/dma.c b/hw/dma.c index c2d7b21562..364f54d2d7 100644 --- a/hw/dma.c +++ b/hw/dma.c @@ -23,6 +23,7 @@ */ #include "hw.h" #include "isa.h" +#include "main-loop.h" /* #define DEBUG_DMA */ diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 2b92cda98a..7b0e50f70d 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -27,6 +27,7 @@ #include "fw_cfg.h" #include "sysbus.h" #include "qemu-error.h" +#include "qemu-config.h" /* debug firmware config */ //#define DEBUG_FW_CFG diff --git a/hw/jazz_led.c b/hw/jazz_led.c index 640e75ef2f..09c77429e8 100644 --- a/hw/jazz_led.c +++ b/hw/jazz_led.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu-common.h" #include "console.h" #include "pixel_ops.h" #include "trace.h" diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c index e551156af9..41eee50a35 100644 --- a/hw/mac_dbdma.c +++ b/hw/mac_dbdma.c @@ -39,6 +39,7 @@ #include "hw.h" #include "isa.h" #include "mac_dbdma.h" +#include "main-loop.h" /* debug DBDMA */ //#define DEBUG_DBDMA diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 8fab508c07..2b1558b16e 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -19,6 +19,7 @@ #include "e500.h" #include "e500-ccsr.h" #include "net.h" +#include "qemu-config.h" #include "hw/hw.h" #include "hw/serial.h" #include "hw/pci/pci.h" diff --git a/hw/puv3.c b/hw/puv3.c index 3d7734936b..6f89c44e32 100644 --- a/hw/puv3.c +++ b/hw/puv3.c @@ -8,6 +8,8 @@ * published by the Free Software Foundation, or any later version. * See the COPYING file in the top-level directory. */ + +#include "qemu-common.h" #include "console.h" #include "elf.h" #include "exec-memory.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index a1b4d6ae5f..5aaf74b98a 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -21,6 +21,7 @@ #include "monitor.h" #include "qmp-commands.h" #include "arch_init.h" +#include "qemu-config.h" /* * Aliases were a bad idea from the start. Let's keep them diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 81d901c6c4..b9cd3c0077 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -5,6 +5,7 @@ #include "hw/block-common.h" #include "net/hub.h" #include "qapi/qapi-visit-core.h" +#include "qemu-char.h" void *qdev_get_prop_ptr(DeviceState *dev, Property *prop) { diff --git a/hw/s390x/sclpconsole.c b/hw/s390x/sclpconsole.c index fece878e88..9ad297c999 100644 --- a/hw/s390x/sclpconsole.c +++ b/hw/s390x/sclpconsole.c @@ -17,6 +17,7 @@ #include "sclp.h" #include "event-facility.h" +#include "qemu-char.h" typedef struct ASCIIConsoleData { EventBufferHeader ebh; diff --git a/hw/spapr.c b/hw/spapr.c index 9bd2fd5c8c..7306ab368a 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -49,6 +49,7 @@ #include "exec-memory.h" #include "hw/usb.h" +#include "qemu-config.h" #include diff --git a/hw/tcx.c b/hw/tcx.c index 7aee2a9bd3..a66fbeefdb 100644 --- a/hw/tcx.c +++ b/hw/tcx.c @@ -22,6 +22,7 @@ * THE SOFTWARE. */ +#include "qemu-common.h" #include "console.h" #include "pixel_ops.h" #include "sysbus.h" diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index 30cb03373e..0552e6f438 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -28,6 +28,7 @@ #include "hw/usb/desc.h" #include "net.h" #include "qemu-queue.h" +#include "qemu-config.h" #include "sysemu.h" #include "iov.h" diff --git a/net.c b/net.c index e8ae13e283..4f3d642468 100644 --- a/net.c +++ b/net.c @@ -32,6 +32,7 @@ #include "monitor.h" #include "qemu-common.h" #include "qemu_socket.h" +#include "qemu-config.h" #include "qmp-commands.h" #include "hw/qdev.h" #include "iov.h" diff --git a/qemu-config.h b/qemu-config.h index 812c4c5b10..eb50eca838 100644 --- a/qemu-config.h +++ b/qemu-config.h @@ -4,6 +4,7 @@ #include #include "qemu-option.h" #include "error.h" +#include "qemu-option.h" extern QemuOptsList qemu_fsdev_opts; extern QemuOptsList qemu_virtfs_opts; diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 09aa22d566..5f95c937f3 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -1,6 +1,7 @@ #include "config-host.h" #include "trace.h" #include "ui/qemu-spice.h" +#include "qemu-char.h" #include #include diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0901589a88..824930c749 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -27,6 +27,7 @@ #include "cpu.h" #include "gdbstub.h" #include "host-utils.h" +#include "qemu-config.h" #include "hw/pc.h" #include "hw/apic.h" #include "ioport.h" -- cgit v1.2.3-55-g7522 From 7fa22f2bf7a06d5345283a00a7c6d86b8a345228 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 24 Oct 2012 09:36:33 +0200 Subject: net: do not include net.h everywhere Signed-off-by: Paolo Bonzini --- arch_init.c | 1 - hw/alpha_sys.h | 1 - hw/device-hotplug.c | 1 - hw/lm32_boards.c | 1 - hw/milkymist-hw.h | 1 + hw/milkymist.c | 1 - hw/s390-virtio-bus.c | 1 - hw/spapr_vscsi.c | 1 - hw/virtex_ml507.c | 1 - hw/virtio-net.h | 1 - hw/virtio-pci.c | 1 - hw/virtio-scsi.h | 1 - hw/xen_backend.h | 1 - hw/xen_platform.c | 1 - input.c | 1 - qemu-char.c | 1 - qemu-timer.c | 1 - 17 files changed, 1 insertion(+), 16 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index ef866cdea4..e479a2566c 100644 --- a/arch_init.c +++ b/arch_init.c @@ -40,7 +40,6 @@ #include "hw/audiodev.h" #include "kvm.h" #include "migration.h" -#include "net.h" #include "gdbstub.h" #include "hw/smbios.h" #include "exec-memory.h" diff --git a/hw/alpha_sys.h b/hw/alpha_sys.h index b1e52585b3..348f55c27e 100644 --- a/hw/alpha_sys.h +++ b/hw/alpha_sys.h @@ -6,7 +6,6 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "ide.h" -#include "net.h" #include "pc.h" #include "irq.h" diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 839b9ea1d4..336ffc2274 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -24,7 +24,6 @@ #include "hw.h" #include "boards.h" -#include "net.h" #include "blockdev.h" #include "qemu-config.h" #include "sysemu.h" diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c index 772cb8b053..f59d3bfef8 100644 --- a/hw/lm32_boards.c +++ b/hw/lm32_boards.c @@ -19,7 +19,6 @@ #include "sysbus.h" #include "hw.h" -#include "net.h" #include "flash.h" #include "devices.h" #include "boards.h" diff --git a/hw/milkymist-hw.h b/hw/milkymist-hw.h index 96b2a7f863..0253b7ab26 100644 --- a/hw/milkymist-hw.h +++ b/hw/milkymist-hw.h @@ -3,6 +3,7 @@ #include "qdev.h" #include "qdev-addr.h" +#include "net.h" static inline DeviceState *milkymist_uart_create(hwaddr base, qemu_irq irq) diff --git a/hw/milkymist.c b/hw/milkymist.c index 4c8111a74d..c26ea4aed2 100644 --- a/hw/milkymist.c +++ b/hw/milkymist.c @@ -19,7 +19,6 @@ #include "sysbus.h" #include "hw.h" -#include "net.h" #include "flash.h" #include "sysemu.h" #include "devices.h" diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index e0ac2d1ec2..169dd4683d 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -20,7 +20,6 @@ #include "hw.h" #include "block.h" #include "sysemu.h" -#include "net.h" #include "boards.h" #include "monitor.h" #include "loader.h" diff --git a/hw/spapr_vscsi.c b/hw/spapr_vscsi.c index e3d4b237f1..2d811320ca 100644 --- a/hw/spapr_vscsi.c +++ b/hw/spapr_vscsi.c @@ -34,7 +34,6 @@ #include "hw.h" #include "scsi.h" #include "scsi-defs.h" -#include "net.h" /* Remove that when we can */ #include "srp.h" #include "hw/qdev.h" #include "hw/spapr.h" diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 6ab8fee0c1..1fdbc497cc 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -25,7 +25,6 @@ #include "sysbus.h" #include "hw.h" #include "serial.h" -#include "net.h" #include "flash.h" #include "sysemu.h" #include "devices.h" diff --git a/hw/virtio-net.h b/hw/virtio-net.h index b13be7ccb5..2566ea13ec 100644 --- a/hw/virtio-net.h +++ b/hw/virtio-net.h @@ -15,7 +15,6 @@ #define _QEMU_VIRTIO_NET_H #include "virtio.h" -#include "net.h" #include "pci/pci.h" #define ETH_ALEN 6 diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index d0d6a5e816..a2355dc867 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -26,7 +26,6 @@ #include "qemu-error.h" #include "pci/msi.h" #include "pci/msix.h" -#include "net.h" #include "loader.h" #include "kvm.h" #include "blockdev.h" diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h index 7d7cba752d..8d9d15f093 100644 --- a/hw/virtio-scsi.h +++ b/hw/virtio-scsi.h @@ -15,7 +15,6 @@ #define _QEMU_VIRTIO_SCSI_H #include "virtio.h" -#include "net.h" #include "pci/pci.h" /* The ID for virtio_scsi */ diff --git a/hw/xen_backend.h b/hw/xen_backend.h index fea86dd78b..3305630903 100644 --- a/hw/xen_backend.h +++ b/hw/xen_backend.h @@ -4,7 +4,6 @@ #include "xen_common.h" #include "sysemu.h" #include "net.h" -#include "net/hub.h" /* ------------------------------------------------------------- */ diff --git a/hw/xen_platform.c b/hw/xen_platform.c index 10bb560073..023499eb55 100644 --- a/hw/xen_platform.c +++ b/hw/xen_platform.c @@ -30,7 +30,6 @@ #include "pci/pci.h" #include "irq.h" #include "xen_common.h" -#include "net.h" #include "xen_backend.h" #include "trace.h" #include "exec-memory.h" diff --git a/input.c b/input.c index 25d3973e21..123bb237d4 100644 --- a/input.c +++ b/input.c @@ -23,7 +23,6 @@ */ #include "sysemu.h" -#include "net.h" #include "monitor.h" #include "console.h" #include "error.h" diff --git a/qemu-char.c b/qemu-char.c index 242b799909..f066ad0654 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -22,7 +22,6 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "net.h" #include "monitor.h" #include "console.h" #include "sysemu.h" diff --git a/qemu-timer.c b/qemu-timer.c index 0d2bb94289..9b9585b259 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -23,7 +23,6 @@ */ #include "sysemu.h" -#include "net.h" #include "monitor.h" #include "console.h" -- cgit v1.2.3-55-g7522 From 022c62cbbcf1ff40b23c92874f8670cddfec2414 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:19:49 +0100 Subject: exec: move include files to include/exec/ Signed-off-by: Paolo Bonzini --- arch_init.c | 4 +- balloon.c | 2 +- bsd-user/qemu.h | 4 +- cpu-all.h | 522 ---------------------- cpu-common.h | 112 ----- cpu-defs.h | 213 --------- cpus.c | 2 +- cputlb.c | 18 +- cputlb.h | 46 -- def-helper.h | 275 ------------ dma.h | 2 +- dump.c | 6 +- exec-all.h | 412 ------------------ exec-memory.h | 41 -- exec.c | 8 +- gdbstub.c | 2 +- gdbstub.h | 53 --- gen-icount.h | 53 --- hw/acpi_ich9.c | 2 +- hw/acpi_piix4.c | 4 +- hw/alpha_typhoon.c | 4 +- hw/an5206.c | 2 +- hw/apb_pci.c | 2 +- hw/apic_internal.h | 2 +- hw/apm.h | 2 +- hw/arm-misc.h | 2 +- hw/armv7m_nvic.c | 2 +- hw/axis_dev88.c | 2 +- hw/bonito.c | 2 +- hw/collie.c | 2 +- hw/dummy_m68k.c | 2 +- hw/etraxfs_dma.c | 2 +- hw/exynos4210.h | 2 +- hw/exynos4210_fimd.c | 2 +- hw/exynos4_boards.c | 2 +- hw/flash.h | 2 +- hw/framebuffer.h | 2 +- hw/gt64xxx.c | 2 +- hw/gumstix.c | 2 +- hw/highbank.c | 2 +- hw/hw.h | 4 +- hw/ide.h | 2 +- hw/ide/ahci.c | 2 +- hw/ide/internal.h | 2 +- hw/integratorcp.c | 2 +- hw/ioapic_internal.h | 2 +- hw/isa-bus.c | 2 +- hw/isa.h | 4 +- hw/isa_mmio.c | 2 +- hw/kzm.c | 2 +- hw/leon3.c | 2 +- hw/lm32_boards.c | 2 +- hw/loader.c | 4 +- hw/lpc_ich9.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.h | 2 +- hw/mainstone.c | 2 +- hw/mcf5206.c | 2 +- hw/mcf5208.c | 2 +- hw/mcf_fec.c | 2 +- hw/mcf_intc.c | 2 +- hw/mcf_uart.c | 2 +- hw/milkymist.c | 2 +- hw/mips.h | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_jazz.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_mipssim.c | 2 +- hw/mips_r4k.c | 2 +- hw/musicpal.c | 2 +- hw/ne2000-isa.c | 2 +- hw/nseries.c | 2 +- hw/omap.h | 2 +- hw/omap_gpmc.c | 4 +- hw/omap_sx1.c | 2 +- hw/omap_uart.c | 2 +- hw/onenand.c | 4 +- hw/openrisc_sim.c | 2 +- hw/palm.c | 2 +- hw/pam.h | 2 +- hw/pc.c | 4 +- hw/pc.h | 6 +- hw/pc_piix.c | 4 +- hw/pc_q35.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pci.h | 2 +- hw/pci/pcie_host.c | 2 +- hw/pci/pcie_host.h | 2 +- hw/pci/shpc.h | 2 +- hw/pci_bridge_dev.c | 2 +- hw/pcnet.h | 2 +- hw/petalogix_ml605_mmu.c | 2 +- hw/petalogix_s3adsp1800_mmu.c | 2 +- hw/pflash_cfi01.c | 2 +- hw/pflash_cfi02.c | 2 +- hw/ppc/e500.c | 2 +- hw/ppc405_boards.c | 2 +- hw/ppc405_uc.c | 2 +- hw/ppc440_bamboo.c | 2 +- hw/ppc4xx_devs.c | 2 +- hw/ppc4xx_pci.c | 2 +- hw/ppc_mac.h | 2 +- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/ppc_prep.c | 2 +- hw/ppce500_pci.c | 2 +- hw/prep_pci.c | 2 +- hw/puv3.c | 2 +- hw/pxa.h | 2 +- hw/qdev-addr.c | 2 +- hw/r2d.c | 2 +- hw/realview.c | 2 +- hw/s390-virtio.c | 2 +- hw/s390x/sclp.c | 2 +- hw/serial.c | 2 +- hw/serial.h | 2 +- hw/sh7750.c | 2 +- hw/sh_intc.h | 2 +- hw/sh_pci.c | 2 +- hw/sh_serial.c | 2 +- hw/sh_timer.c | 2 +- hw/shix.c | 2 +- hw/soc_dma.h | 2 +- hw/spapr.c | 2 +- hw/spapr_iommu.c | 2 +- hw/spapr_pci.c | 2 +- hw/spitz.c | 2 +- hw/stellaris.c | 2 +- hw/strongarm.h | 2 +- hw/sun4u.c | 2 +- hw/sysbus.c | 2 +- hw/sysbus.h | 2 +- hw/tosa.c | 2 +- hw/usb/libhw.c | 2 +- hw/versatile_pci.c | 2 +- hw/versatilepb.c | 2 +- hw/vexpress.c | 2 +- hw/vfio_pci.c | 4 +- hw/vga_int.h | 2 +- hw/vhost.c | 2 +- hw/vhost.h | 2 +- hw/virtex_ml507.c | 2 +- hw/virtio-balloon.c | 2 +- hw/vt82c686.c | 2 +- hw/xen_platform.c | 2 +- hw/xen_pt.c | 2 +- hw/xilinx_zynq.c | 2 +- hw/xtensa_lx60.c | 4 +- hw/xtensa_sim.c | 4 +- hw/z2.c | 2 +- hwaddr.h | 24 -- include/exec/address-spaces.h | 41 ++ include/exec/cpu-all.h | 522 ++++++++++++++++++++++ include/exec/cpu-common.h | 112 +++++ include/exec/cpu-defs.h | 213 +++++++++ include/exec/cputlb.h | 46 ++ include/exec/def-helper.h | 275 ++++++++++++ include/exec/exec-all.h | 412 ++++++++++++++++++ include/exec/gdbstub.h | 53 +++ include/exec/gen-icount.h | 53 +++ include/exec/hwaddr.h | 24 ++ include/exec/ioport.h | 78 ++++ include/exec/iorange.h | 31 ++ include/exec/memory-internal.h | 141 ++++++ include/exec/memory.h | 882 ++++++++++++++++++++++++++++++++++++++ include/exec/poison.h | 64 +++ include/exec/softmmu-semi.h | 77 ++++ include/exec/softmmu_defs.h | 37 ++ include/exec/softmmu_exec.h | 163 +++++++ include/exec/softmmu_header.h | 213 +++++++++ include/exec/softmmu_template.h | 354 +++++++++++++++ include/exec/spinlock.h | 49 +++ include/exec/user/abitypes.h | 36 ++ include/exec/user/thunk.h | 189 ++++++++ ioport.c | 4 +- ioport.h | 78 ---- iorange.h | 31 -- kvm-all.c | 6 +- kvm-stub.c | 2 +- linux-user/qemu.h | 6 +- memory-internal.h | 141 ------ memory.c | 8 +- memory.h | 882 -------------------------------------- memory_mapping-stub.c | 2 +- memory_mapping.c | 2 +- monitor.c | 4 +- poison.h | 64 --- qemu-lock.h | 49 --- qemu-user-types.h | 36 -- qtest.c | 4 +- savevm.c | 2 +- scripts/feature_to_c.sh | 2 +- softmmu-semi.h | 77 ---- softmmu_defs.h | 37 -- softmmu_exec.h | 163 ------- softmmu_header.h | 213 --------- softmmu_template.h | 354 --------------- target-alpha/cpu.h | 6 +- target-alpha/helper.h | 4 +- target-alpha/mem_helper.c | 10 +- target-alpha/translate.c | 2 +- target-arm/arm-semi.c | 4 +- target-arm/cpu.h | 6 +- target-arm/helper.c | 2 +- target-arm/helper.h | 4 +- target-arm/iwmmxt_helper.c | 2 +- target-arm/neon_helper.c | 2 +- target-arm/op_helper.c | 10 +- target-arm/translate.c | 2 +- target-cris/cpu.h | 6 +- target-cris/helper.h | 4 +- target-cris/op_helper.c | 10 +- target-cris/translate.c | 2 +- target-i386/arch_dump.c | 2 +- target-i386/arch_memory_mapping.c | 2 +- target-i386/cpu.h | 6 +- target-i386/fpu_helper.c | 2 +- target-i386/helper.h | 4 +- target-i386/ioport-user.c | 2 +- target-i386/kvm.c | 4 +- target-i386/mem_helper.c | 10 +- target-i386/misc_helper.c | 4 +- target-i386/seg_helper.c | 2 +- target-i386/svm_helper.c | 4 +- target-i386/translate.c | 2 +- target-lm32/cpu.h | 6 +- target-lm32/helper.h | 4 +- target-lm32/op_helper.c | 8 +- target-lm32/translate.c | 2 +- target-m68k/cpu.h | 6 +- target-m68k/helper.c | 2 +- target-m68k/helpers.h | 4 +- target-m68k/m68k-semi.c | 4 +- target-m68k/op_helper.c | 10 +- target-m68k/translate.c | 2 +- target-microblaze/cpu.h | 6 +- target-microblaze/helper.h | 4 +- target-microblaze/op_helper.c | 10 +- target-microblaze/translate.c | 2 +- target-mips/cpu.h | 6 +- target-mips/helper.h | 4 +- target-mips/op_helper.c | 10 +- target-mips/translate.c | 2 +- target-openrisc/cpu.h | 6 +- target-openrisc/helper.h | 4 +- target-openrisc/interrupt.c | 2 +- target-openrisc/mmu.c | 2 +- target-openrisc/mmu_helper.c | 10 +- target-openrisc/translate.c | 4 +- target-ppc/cpu.h | 6 +- target-ppc/helper.h | 4 +- target-ppc/kvm_ppc.h | 2 +- target-ppc/mem_helper.c | 10 +- target-ppc/translate.c | 2 +- target-ppc/translate_init.c | 2 +- target-s390x/cpu.h | 6 +- target-s390x/fpu_helper.c | 2 +- target-s390x/helper.c | 2 +- target-s390x/helper.h | 4 +- target-s390x/mem_helper.c | 10 +- target-s390x/misc_helper.c | 4 +- target-s390x/translate.c | 2 +- target-sh4/cpu.h | 6 +- target-sh4/helper.h | 4 +- target-sh4/op_helper.c | 10 +- target-sh4/translate.c | 2 +- target-sparc/cpu.h | 6 +- target-sparc/helper.h | 4 +- target-sparc/ldst_helper.c | 10 +- target-sparc/mmu_helper.c | 2 +- target-sparc/translate.c | 2 +- target-unicore32/cpu.h | 6 +- target-unicore32/helper.c | 2 +- target-unicore32/helper.h | 4 +- target-unicore32/op_helper.c | 8 +- target-unicore32/translate.c | 2 +- target-xtensa/core-dc232b.c | 4 +- target-xtensa/core-dc233c.c | 4 +- target-xtensa/core-fsf.c | 4 +- target-xtensa/cpu.h | 6 +- target-xtensa/helper.c | 4 +- target-xtensa/helper.h | 4 +- target-xtensa/op_helper.c | 8 +- target-xtensa/translate.c | 4 +- tcg/arm/tcg-target.c | 2 +- tcg/hppa/tcg-target.c | 2 +- tcg/i386/tcg-target.c | 2 +- tcg/ia64/tcg-target.c | 2 +- tcg/mips/tcg-target.c | 2 +- tcg/ppc/tcg-target.c | 2 +- tcg/ppc64/tcg-target.c | 2 +- tcg/s390/tcg-target.c | 2 +- tcg/sparc/tcg-target.c | 2 +- tci.c | 2 +- thunk.c | 2 +- thunk.h | 189 -------- translate-all.c | 6 +- vl.c | 2 +- xen-all.c | 2 +- xen-stub.c | 2 +- 300 files changed, 4474 insertions(+), 4474 deletions(-) delete mode 100644 cpu-all.h delete mode 100644 cpu-common.h delete mode 100644 cpu-defs.h delete mode 100644 cputlb.h delete mode 100644 def-helper.h delete mode 100644 exec-all.h delete mode 100644 exec-memory.h delete mode 100644 gdbstub.h delete mode 100644 gen-icount.h delete mode 100644 hwaddr.h create mode 100644 include/exec/address-spaces.h create mode 100644 include/exec/cpu-all.h create mode 100644 include/exec/cpu-common.h create mode 100644 include/exec/cpu-defs.h create mode 100644 include/exec/cputlb.h create mode 100644 include/exec/def-helper.h create mode 100644 include/exec/exec-all.h create mode 100644 include/exec/gdbstub.h create mode 100644 include/exec/gen-icount.h create mode 100644 include/exec/hwaddr.h create mode 100644 include/exec/ioport.h create mode 100644 include/exec/iorange.h create mode 100644 include/exec/memory-internal.h create mode 100644 include/exec/memory.h create mode 100644 include/exec/poison.h create mode 100644 include/exec/softmmu-semi.h create mode 100644 include/exec/softmmu_defs.h create mode 100644 include/exec/softmmu_exec.h create mode 100644 include/exec/softmmu_header.h create mode 100644 include/exec/softmmu_template.h create mode 100644 include/exec/spinlock.h create mode 100644 include/exec/user/abitypes.h create mode 100644 include/exec/user/thunk.h delete mode 100644 ioport.h delete mode 100644 iorange.h delete mode 100644 memory-internal.h delete mode 100644 memory.h delete mode 100644 poison.h delete mode 100644 qemu-lock.h delete mode 100644 qemu-user-types.h delete mode 100644 softmmu-semi.h delete mode 100644 softmmu_defs.h delete mode 100644 softmmu_exec.h delete mode 100644 softmmu_header.h delete mode 100644 softmmu_template.h delete mode 100644 thunk.h (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index e479a2566c..e15cedad04 100644 --- a/arch_init.c +++ b/arch_init.c @@ -40,9 +40,9 @@ #include "hw/audiodev.h" #include "kvm.h" #include "migration.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "hw/smbios.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/pcspk.h" #include "qemu/page_cache.h" #include "qemu-config.h" diff --git a/balloon.c b/balloon.c index 610fe6d626..c24458b5f9 100644 --- a/balloon.c +++ b/balloon.c @@ -25,7 +25,7 @@ */ #include "monitor.h" -#include "cpu-common.h" +#include "exec/cpu-common.h" #include "kvm.h" #include "balloon.h" #include "trace.h" diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index d2688995bd..c64c3ccca3 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -11,7 +11,7 @@ #include #endif /* DEBUG_REMAP */ -#include "qemu-user-types.h" +#include "exec/user/abitypes.h" enum BSDType { target_freebsd, @@ -23,7 +23,7 @@ extern enum BSDType bsd_type; #include "syscall_defs.h" #include "syscall.h" #include "target_signal.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #if defined(CONFIG_USE_NPTL) #define THREAD __thread diff --git a/cpu-all.h b/cpu-all.h deleted file mode 100644 index d6b2b19743..0000000000 --- a/cpu-all.h +++ /dev/null @@ -1,522 +0,0 @@ -/* - * defines common to all virtual CPUs - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef CPU_ALL_H -#define CPU_ALL_H - -#include "qemu-common.h" -#include "qemu-tls.h" -#include "cpu-common.h" - -/* some important defines: - * - * WORDS_ALIGNED : if defined, the host cpu can only make word aligned - * memory accesses. - * - * HOST_WORDS_BIGENDIAN : if defined, the host cpu is big endian and - * otherwise little endian. - * - * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet)) - * - * TARGET_WORDS_BIGENDIAN : same for target cpu - */ - -#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) -#define BSWAP_NEEDED -#endif - -#ifdef BSWAP_NEEDED - -static inline uint16_t tswap16(uint16_t s) -{ - return bswap16(s); -} - -static inline uint32_t tswap32(uint32_t s) -{ - return bswap32(s); -} - -static inline uint64_t tswap64(uint64_t s) -{ - return bswap64(s); -} - -static inline void tswap16s(uint16_t *s) -{ - *s = bswap16(*s); -} - -static inline void tswap32s(uint32_t *s) -{ - *s = bswap32(*s); -} - -static inline void tswap64s(uint64_t *s) -{ - *s = bswap64(*s); -} - -#else - -static inline uint16_t tswap16(uint16_t s) -{ - return s; -} - -static inline uint32_t tswap32(uint32_t s) -{ - return s; -} - -static inline uint64_t tswap64(uint64_t s) -{ - return s; -} - -static inline void tswap16s(uint16_t *s) -{ -} - -static inline void tswap32s(uint32_t *s) -{ -} - -static inline void tswap64s(uint64_t *s) -{ -} - -#endif - -#if TARGET_LONG_SIZE == 4 -#define tswapl(s) tswap32(s) -#define tswapls(s) tswap32s((uint32_t *)(s)) -#define bswaptls(s) bswap32s(s) -#else -#define tswapl(s) tswap64(s) -#define tswapls(s) tswap64s((uint64_t *)(s)) -#define bswaptls(s) bswap64s(s) -#endif - -/* CPU memory access without any memory or io remapping */ - -/* - * the generic syntax for the memory accesses is: - * - * load: ld{type}{sign}{size}{endian}_{access_type}(ptr) - * - * store: st{type}{size}{endian}_{access_type}(ptr, val) - * - * type is: - * (empty): integer access - * f : float access - * - * sign is: - * (empty): for floats or 32 bit size - * u : unsigned - * s : signed - * - * size is: - * b: 8 bits - * w: 16 bits - * l: 32 bits - * q: 64 bits - * - * endian is: - * (empty): target cpu endianness or 8 bit access - * r : reversed target cpu endianness (not implemented yet) - * be : big endian (not implemented yet) - * le : little endian (not implemented yet) - * - * access_type is: - * raw : host memory access - * user : user mode access using soft MMU - * kernel : kernel mode access using soft MMU - */ - -/* target-endianness CPU memory access functions */ -#if defined(TARGET_WORDS_BIGENDIAN) -#define lduw_p(p) lduw_be_p(p) -#define ldsw_p(p) ldsw_be_p(p) -#define ldl_p(p) ldl_be_p(p) -#define ldq_p(p) ldq_be_p(p) -#define ldfl_p(p) ldfl_be_p(p) -#define ldfq_p(p) ldfq_be_p(p) -#define stw_p(p, v) stw_be_p(p, v) -#define stl_p(p, v) stl_be_p(p, v) -#define stq_p(p, v) stq_be_p(p, v) -#define stfl_p(p, v) stfl_be_p(p, v) -#define stfq_p(p, v) stfq_be_p(p, v) -#else -#define lduw_p(p) lduw_le_p(p) -#define ldsw_p(p) ldsw_le_p(p) -#define ldl_p(p) ldl_le_p(p) -#define ldq_p(p) ldq_le_p(p) -#define ldfl_p(p) ldfl_le_p(p) -#define ldfq_p(p) ldfq_le_p(p) -#define stw_p(p, v) stw_le_p(p, v) -#define stl_p(p, v) stl_le_p(p, v) -#define stq_p(p, v) stq_le_p(p, v) -#define stfl_p(p, v) stfl_le_p(p, v) -#define stfq_p(p, v) stfq_le_p(p, v) -#endif - -/* MMU memory access macros */ - -#if defined(CONFIG_USER_ONLY) -#include -#include "qemu-user-types.h" - -/* On some host systems the guest address space is reserved on the host. - * This allows the guest address space to be offset to a convenient location. - */ -#if defined(CONFIG_USE_GUEST_BASE) -extern unsigned long guest_base; -extern int have_guest_base; -extern unsigned long reserved_va; -#define GUEST_BASE guest_base -#define RESERVED_VA reserved_va -#else -#define GUEST_BASE 0ul -#define RESERVED_VA 0ul -#endif - -/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ -#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE)) - -#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS -#define h2g_valid(x) 1 -#else -#define h2g_valid(x) ({ \ - unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ - (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \ - (!RESERVED_VA || (__guest < RESERVED_VA)); \ -}) -#endif - -#define h2g(x) ({ \ - unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ - /* Check if given address fits target address space */ \ - assert(h2g_valid(x)); \ - (abi_ulong)__ret; \ -}) - -#define saddr(x) g2h(x) -#define laddr(x) g2h(x) - -#else /* !CONFIG_USER_ONLY */ -/* NOTE: we use double casts if pointers and target_ulong have - different sizes */ -#define saddr(x) (uint8_t *)(intptr_t)(x) -#define laddr(x) (uint8_t *)(intptr_t)(x) -#endif - -#define ldub_raw(p) ldub_p(laddr((p))) -#define ldsb_raw(p) ldsb_p(laddr((p))) -#define lduw_raw(p) lduw_p(laddr((p))) -#define ldsw_raw(p) ldsw_p(laddr((p))) -#define ldl_raw(p) ldl_p(laddr((p))) -#define ldq_raw(p) ldq_p(laddr((p))) -#define ldfl_raw(p) ldfl_p(laddr((p))) -#define ldfq_raw(p) ldfq_p(laddr((p))) -#define stb_raw(p, v) stb_p(saddr((p)), v) -#define stw_raw(p, v) stw_p(saddr((p)), v) -#define stl_raw(p, v) stl_p(saddr((p)), v) -#define stq_raw(p, v) stq_p(saddr((p)), v) -#define stfl_raw(p, v) stfl_p(saddr((p)), v) -#define stfq_raw(p, v) stfq_p(saddr((p)), v) - - -#if defined(CONFIG_USER_ONLY) - -/* if user mode, no other memory access functions */ -#define ldub(p) ldub_raw(p) -#define ldsb(p) ldsb_raw(p) -#define lduw(p) lduw_raw(p) -#define ldsw(p) ldsw_raw(p) -#define ldl(p) ldl_raw(p) -#define ldq(p) ldq_raw(p) -#define ldfl(p) ldfl_raw(p) -#define ldfq(p) ldfq_raw(p) -#define stb(p, v) stb_raw(p, v) -#define stw(p, v) stw_raw(p, v) -#define stl(p, v) stl_raw(p, v) -#define stq(p, v) stq_raw(p, v) -#define stfl(p, v) stfl_raw(p, v) -#define stfq(p, v) stfq_raw(p, v) - -#define cpu_ldub_code(env1, p) ldub_raw(p) -#define cpu_ldsb_code(env1, p) ldsb_raw(p) -#define cpu_lduw_code(env1, p) lduw_raw(p) -#define cpu_ldsw_code(env1, p) ldsw_raw(p) -#define cpu_ldl_code(env1, p) ldl_raw(p) -#define cpu_ldq_code(env1, p) ldq_raw(p) - -#define cpu_ldub_data(env, addr) ldub_raw(addr) -#define cpu_lduw_data(env, addr) lduw_raw(addr) -#define cpu_ldsw_data(env, addr) ldsw_raw(addr) -#define cpu_ldl_data(env, addr) ldl_raw(addr) -#define cpu_ldq_data(env, addr) ldq_raw(addr) - -#define cpu_stb_data(env, addr, data) stb_raw(addr, data) -#define cpu_stw_data(env, addr, data) stw_raw(addr, data) -#define cpu_stl_data(env, addr, data) stl_raw(addr, data) -#define cpu_stq_data(env, addr, data) stq_raw(addr, data) - -#define cpu_ldub_kernel(env, addr) ldub_raw(addr) -#define cpu_lduw_kernel(env, addr) lduw_raw(addr) -#define cpu_ldsw_kernel(env, addr) ldsw_raw(addr) -#define cpu_ldl_kernel(env, addr) ldl_raw(addr) -#define cpu_ldq_kernel(env, addr) ldq_raw(addr) - -#define cpu_stb_kernel(env, addr, data) stb_raw(addr, data) -#define cpu_stw_kernel(env, addr, data) stw_raw(addr, data) -#define cpu_stl_kernel(env, addr, data) stl_raw(addr, data) -#define cpu_stq_kernel(env, addr, data) stq_raw(addr, data) - -#define ldub_kernel(p) ldub_raw(p) -#define ldsb_kernel(p) ldsb_raw(p) -#define lduw_kernel(p) lduw_raw(p) -#define ldsw_kernel(p) ldsw_raw(p) -#define ldl_kernel(p) ldl_raw(p) -#define ldq_kernel(p) ldq_raw(p) -#define ldfl_kernel(p) ldfl_raw(p) -#define ldfq_kernel(p) ldfq_raw(p) -#define stb_kernel(p, v) stb_raw(p, v) -#define stw_kernel(p, v) stw_raw(p, v) -#define stl_kernel(p, v) stl_raw(p, v) -#define stq_kernel(p, v) stq_raw(p, v) -#define stfl_kernel(p, v) stfl_raw(p, v) -#define stfq_kernel(p, vt) stfq_raw(p, v) - -#define cpu_ldub_data(env, addr) ldub_raw(addr) -#define cpu_lduw_data(env, addr) lduw_raw(addr) -#define cpu_ldl_data(env, addr) ldl_raw(addr) - -#define cpu_stb_data(env, addr, data) stb_raw(addr, data) -#define cpu_stw_data(env, addr, data) stw_raw(addr, data) -#define cpu_stl_data(env, addr, data) stl_raw(addr, data) -#endif /* defined(CONFIG_USER_ONLY) */ - -/* page related stuff */ - -#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) -#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) - -/* ??? These should be the larger of uintptr_t and target_ulong. */ -extern uintptr_t qemu_real_host_page_size; -extern uintptr_t qemu_host_page_size; -extern uintptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) - -/* same as PROT_xxx */ -#define PAGE_READ 0x0001 -#define PAGE_WRITE 0x0002 -#define PAGE_EXEC 0x0004 -#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) -#define PAGE_VALID 0x0008 -/* original state of the write flag (used when tracking self-modifying - code */ -#define PAGE_WRITE_ORG 0x0010 -#if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) -/* FIXME: Code that sets/uses this is broken and needs to go away. */ -#define PAGE_RESERVED 0x0020 -#endif - -#if defined(CONFIG_USER_ONLY) -void page_dump(FILE *f); - -typedef int (*walk_memory_regions_fn)(void *, abi_ulong, - abi_ulong, unsigned long); -int walk_memory_regions(void *, walk_memory_regions_fn); - -int page_get_flags(target_ulong address); -void page_set_flags(target_ulong start, target_ulong end, int flags); -int page_check_range(target_ulong start, target_ulong len, int flags); -#endif - -CPUArchState *cpu_copy(CPUArchState *env); -CPUArchState *qemu_get_cpu(int cpu); - -#define CPU_DUMP_CODE 0x00010000 -#define CPU_DUMP_FPU 0x00020000 /* dump FPU register state, not just integer */ -/* dump info about TCG QEMU's condition code optimization state */ -#define CPU_DUMP_CCOP 0x00040000 - -void cpu_dump_state(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, - int flags); -void cpu_dump_statistics(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, - int flags); - -void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...) - GCC_FMT_ATTR(2, 3); -extern CPUArchState *first_cpu; -DECLARE_TLS(CPUArchState *,cpu_single_env); -#define cpu_single_env tls_var(cpu_single_env) - -/* Flags for use in ENV->INTERRUPT_PENDING. - - The numbers assigned here are non-sequential in order to preserve - binary compatibility with the vmstate dump. Bit 0 (0x0001) was - previously used for CPU_INTERRUPT_EXIT, and is cleared when loading - the vmstate dump. */ - -/* External hardware interrupt pending. This is typically used for - interrupts from devices. */ -#define CPU_INTERRUPT_HARD 0x0002 - -/* Exit the current TB. This is typically used when some system-level device - makes some change to the memory mapping. E.g. the a20 line change. */ -#define CPU_INTERRUPT_EXITTB 0x0004 - -/* Halt the CPU. */ -#define CPU_INTERRUPT_HALT 0x0020 - -/* Debug event pending. */ -#define CPU_INTERRUPT_DEBUG 0x0080 - -/* Several target-specific external hardware interrupts. Each target/cpu.h - should define proper names based on these defines. */ -#define CPU_INTERRUPT_TGT_EXT_0 0x0008 -#define CPU_INTERRUPT_TGT_EXT_1 0x0010 -#define CPU_INTERRUPT_TGT_EXT_2 0x0040 -#define CPU_INTERRUPT_TGT_EXT_3 0x0200 -#define CPU_INTERRUPT_TGT_EXT_4 0x1000 - -/* Several target-specific internal interrupts. These differ from the - preceding target-specific interrupts in that they are intended to - originate from within the cpu itself, typically in response to some - instruction being executed. These, therefore, are not masked while - single-stepping within the debugger. */ -#define CPU_INTERRUPT_TGT_INT_0 0x0100 -#define CPU_INTERRUPT_TGT_INT_1 0x0400 -#define CPU_INTERRUPT_TGT_INT_2 0x0800 -#define CPU_INTERRUPT_TGT_INT_3 0x2000 - -/* First unused bit: 0x4000. */ - -/* The set of all bits that should be masked when single-stepping. */ -#define CPU_INTERRUPT_SSTEP_MASK \ - (CPU_INTERRUPT_HARD \ - | CPU_INTERRUPT_TGT_EXT_0 \ - | CPU_INTERRUPT_TGT_EXT_1 \ - | CPU_INTERRUPT_TGT_EXT_2 \ - | CPU_INTERRUPT_TGT_EXT_3 \ - | CPU_INTERRUPT_TGT_EXT_4) - -#ifndef CONFIG_USER_ONLY -typedef void (*CPUInterruptHandler)(CPUArchState *, int); - -extern CPUInterruptHandler cpu_interrupt_handler; - -static inline void cpu_interrupt(CPUArchState *s, int mask) -{ - cpu_interrupt_handler(s, mask); -} -#else /* USER_ONLY */ -void cpu_interrupt(CPUArchState *env, int mask); -#endif /* USER_ONLY */ - -void cpu_reset_interrupt(CPUArchState *env, int mask); - -void cpu_exit(CPUArchState *s); - -/* Breakpoint/watchpoint flags */ -#define BP_MEM_READ 0x01 -#define BP_MEM_WRITE 0x02 -#define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE) -#define BP_STOP_BEFORE_ACCESS 0x04 -#define BP_WATCHPOINT_HIT 0x08 -#define BP_GDB 0x10 -#define BP_CPU 0x20 - -int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags, - CPUBreakpoint **breakpoint); -int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags); -void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint); -void cpu_breakpoint_remove_all(CPUArchState *env, int mask); -int cpu_watchpoint_insert(CPUArchState *env, target_ulong addr, target_ulong len, - int flags, CPUWatchpoint **watchpoint); -int cpu_watchpoint_remove(CPUArchState *env, target_ulong addr, - target_ulong len, int flags); -void cpu_watchpoint_remove_by_ref(CPUArchState *env, CPUWatchpoint *watchpoint); -void cpu_watchpoint_remove_all(CPUArchState *env, int mask); - -#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */ -#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */ -#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */ - -void cpu_single_step(CPUArchState *env, int enabled); - -#if !defined(CONFIG_USER_ONLY) - -/* Return the physical page corresponding to a virtual one. Use it - only for debugging because no protection checks are done. Return -1 - if no page found. */ -hwaddr cpu_get_phys_page_debug(CPUArchState *env, target_ulong addr); - -/* memory API */ - -extern int phys_ram_fd; -extern ram_addr_t ram_size; - -/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ -#define RAM_PREALLOC_MASK (1 << 0) - -typedef struct RAMBlock { - struct MemoryRegion *mr; - uint8_t *host; - ram_addr_t offset; - ram_addr_t length; - uint32_t flags; - char idstr[256]; - QLIST_ENTRY(RAMBlock) next; -#if defined(__linux__) && !defined(TARGET_S390X) - int fd; -#endif -} RAMBlock; - -typedef struct RAMList { - uint8_t *phys_dirty; - QLIST_HEAD(, RAMBlock) blocks; -} RAMList; -extern RAMList ram_list; - -extern const char *mem_path; -extern int mem_prealloc; - -/* Flags stored in the low bits of the TLB virtual address. These are - defined so that fast path ram access is all zeros. */ -/* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << 3) -/* Set if TLB entry references a clean RAM page. The iotlb entry will - contain the page physical address. */ -#define TLB_NOTDIRTY (1 << 4) -/* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << 5) - -void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); -ram_addr_t last_ram_offset(void); -#endif /* !CONFIG_USER_ONLY */ - -int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, - uint8_t *buf, int len, int is_write); - -#endif /* CPU_ALL_H */ diff --git a/cpu-common.h b/cpu-common.h deleted file mode 100644 index d2fbafac9c..0000000000 --- a/cpu-common.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef CPU_COMMON_H -#define CPU_COMMON_H 1 - -/* CPU interfaces that are target independent. */ - -#include "hwaddr.h" - -#ifndef NEED_CPU_H -#include "poison.h" -#endif - -#include "bswap.h" -#include "qemu-queue.h" - -#if !defined(CONFIG_USER_ONLY) - -enum device_endian { - DEVICE_NATIVE_ENDIAN, - DEVICE_BIG_ENDIAN, - DEVICE_LITTLE_ENDIAN, -}; - -/* address in the RAM (different from a physical address) */ -#if defined(CONFIG_XEN_BACKEND) -typedef uint64_t ram_addr_t; -# define RAM_ADDR_MAX UINT64_MAX -# define RAM_ADDR_FMT "%" PRIx64 -#else -typedef uintptr_t ram_addr_t; -# define RAM_ADDR_MAX UINTPTR_MAX -# define RAM_ADDR_FMT "%" PRIxPTR -#endif - -/* memory API */ - -typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value); -typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr); - -void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); -/* This should only be used for ram local to a device. */ -void *qemu_get_ram_ptr(ram_addr_t addr); -void qemu_put_ram_ptr(void *addr); -/* This should not be used by devices. */ -int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); -ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); -void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev); - -void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, - int len, int is_write); -static inline void cpu_physical_memory_read(hwaddr addr, - void *buf, int len) -{ - cpu_physical_memory_rw(addr, buf, len, 0); -} -static inline void cpu_physical_memory_write(hwaddr addr, - const void *buf, int len) -{ - cpu_physical_memory_rw(addr, (void *)buf, len, 1); -} -void *cpu_physical_memory_map(hwaddr addr, - hwaddr *plen, - int is_write); -void cpu_physical_memory_unmap(void *buffer, hwaddr len, - int is_write, hwaddr access_len); -void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)); - -bool cpu_physical_memory_is_io(hwaddr phys_addr); - -/* Coalesced MMIO regions are areas where write operations can be reordered. - * This usually implies that write operations are side-effect free. This allows - * batching which can make a major impact on performance when using - * virtualization. - */ -void qemu_flush_coalesced_mmio_buffer(void); - -uint32_t ldub_phys(hwaddr addr); -uint32_t lduw_le_phys(hwaddr addr); -uint32_t lduw_be_phys(hwaddr addr); -uint32_t ldl_le_phys(hwaddr addr); -uint32_t ldl_be_phys(hwaddr addr); -uint64_t ldq_le_phys(hwaddr addr); -uint64_t ldq_be_phys(hwaddr addr); -void stb_phys(hwaddr addr, uint32_t val); -void stw_le_phys(hwaddr addr, uint32_t val); -void stw_be_phys(hwaddr addr, uint32_t val); -void stl_le_phys(hwaddr addr, uint32_t val); -void stl_be_phys(hwaddr addr, uint32_t val); -void stq_le_phys(hwaddr addr, uint64_t val); -void stq_be_phys(hwaddr addr, uint64_t val); - -#ifdef NEED_CPU_H -uint32_t lduw_phys(hwaddr addr); -uint32_t ldl_phys(hwaddr addr); -uint64_t ldq_phys(hwaddr addr); -void stl_phys_notdirty(hwaddr addr, uint32_t val); -void stq_phys_notdirty(hwaddr addr, uint64_t val); -void stw_phys(hwaddr addr, uint32_t val); -void stl_phys(hwaddr addr, uint32_t val); -void stq_phys(hwaddr addr, uint64_t val); -#endif - -void cpu_physical_memory_write_rom(hwaddr addr, - const uint8_t *buf, int len); - -extern struct MemoryRegion io_mem_ram; -extern struct MemoryRegion io_mem_rom; -extern struct MemoryRegion io_mem_unassigned; -extern struct MemoryRegion io_mem_notdirty; - -#endif - -#endif /* !CPU_COMMON_H */ diff --git a/cpu-defs.h b/cpu-defs.h deleted file mode 100644 index 3669241faf..0000000000 --- a/cpu-defs.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * common defines for all CPUs - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef CPU_DEFS_H -#define CPU_DEFS_H - -#ifndef NEED_CPU_H -#error cpu.h included from common code -#endif - -#include "config.h" -#include -#include -#include -#include "osdep.h" -#include "qemu-queue.h" -#include "hwaddr.h" - -#ifndef TARGET_LONG_BITS -#error TARGET_LONG_BITS must be defined before including this header -#endif - -#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) - -typedef int16_t target_short __attribute__ ((aligned(TARGET_SHORT_ALIGNMENT))); -typedef uint16_t target_ushort __attribute__((aligned(TARGET_SHORT_ALIGNMENT))); -typedef int32_t target_int __attribute__((aligned(TARGET_INT_ALIGNMENT))); -typedef uint32_t target_uint __attribute__((aligned(TARGET_INT_ALIGNMENT))); -typedef int64_t target_llong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); -typedef uint64_t target_ullong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); -/* target_ulong is the type of a virtual address */ -#if TARGET_LONG_SIZE == 4 -typedef int32_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -typedef uint32_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -#define TARGET_FMT_lx "%08x" -#define TARGET_FMT_ld "%d" -#define TARGET_FMT_lu "%u" -#elif TARGET_LONG_SIZE == 8 -typedef int64_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); -#define TARGET_FMT_lx "%016" PRIx64 -#define TARGET_FMT_ld "%" PRId64 -#define TARGET_FMT_lu "%" PRIu64 -#else -#error TARGET_LONG_SIZE undefined -#endif - -#define EXCP_INTERRUPT 0x10000 /* async interruption */ -#define EXCP_HLT 0x10001 /* hlt instruction reached */ -#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ -#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */ - -#define TB_JMP_CACHE_BITS 12 -#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) - -/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for - addresses on the same page. The top bits are the same. This allows - TLB invalidation to quickly clear a subset of the hash table. */ -#define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2) -#define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS) -#define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) -#define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE) - -#if !defined(CONFIG_USER_ONLY) -#define CPU_TLB_BITS 8 -#define CPU_TLB_SIZE (1 << CPU_TLB_BITS) - -#if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32 -#define CPU_TLB_ENTRY_BITS 4 -#else -#define CPU_TLB_ENTRY_BITS 5 -#endif - -typedef struct CPUTLBEntry { - /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address - bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not - go directly to ram. - bit 3 : indicates that the entry is invalid - bit 2..0 : zero - */ - target_ulong addr_read; - target_ulong addr_write; - target_ulong addr_code; - /* Addend to virtual address to get host address. IO accesses - use the corresponding iotlb value. */ - uintptr_t addend; - /* padding to get a power of two size */ - uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - - (sizeof(target_ulong) * 3 + - ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) + - sizeof(uintptr_t))]; -} CPUTLBEntry; - -extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1]; - -#define CPU_COMMON_TLB \ - /* The meaning of the MMU modes is defined in the target code. */ \ - CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ - hwaddr iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ - target_ulong tlb_flush_addr; \ - target_ulong tlb_flush_mask; - -#else - -#define CPU_COMMON_TLB - -#endif - - -#ifdef HOST_WORDS_BIGENDIAN -typedef struct icount_decr_u16 { - uint16_t high; - uint16_t low; -} icount_decr_u16; -#else -typedef struct icount_decr_u16 { - uint16_t low; - uint16_t high; -} icount_decr_u16; -#endif - -struct kvm_run; -struct KVMState; -struct qemu_work_item; - -typedef struct CPUBreakpoint { - target_ulong pc; - int flags; /* BP_* */ - QTAILQ_ENTRY(CPUBreakpoint) entry; -} CPUBreakpoint; - -typedef struct CPUWatchpoint { - target_ulong vaddr; - target_ulong len_mask; - int flags; /* BP_* */ - QTAILQ_ENTRY(CPUWatchpoint) entry; -} CPUWatchpoint; - -#define CPU_TEMP_BUF_NLONGS 128 -#define CPU_COMMON \ - struct TranslationBlock *current_tb; /* currently executing TB */ \ - /* soft mmu support */ \ - /* in order to avoid passing too many arguments to the MMIO \ - helpers, we store some rarely used information in the CPU \ - context) */ \ - uintptr_t mem_io_pc; /* host pc at which the memory was \ - accessed */ \ - target_ulong mem_io_vaddr; /* target virtual addr at which the \ - memory was accessed */ \ - uint32_t halted; /* Nonzero if the CPU is in suspend state */ \ - uint32_t interrupt_request; \ - volatile sig_atomic_t exit_request; \ - CPU_COMMON_TLB \ - struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ - /* buffer for temporaries in the code generator */ \ - long temp_buf[CPU_TEMP_BUF_NLONGS]; \ - \ - int64_t icount_extra; /* Instructions until next timer event. */ \ - /* Number of cycles left, with interrupt flag in high bit. \ - This allows a single read-compare-cbranch-write sequence to test \ - for both decrementer underflow and exceptions. */ \ - union { \ - uint32_t u32; \ - icount_decr_u16 u16; \ - } icount_decr; \ - uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \ - \ - /* from this point: preserved by CPU reset */ \ - /* ice debug support */ \ - QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ - int singlestep_enabled; \ - \ - QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ - CPUWatchpoint *watchpoint_hit; \ - \ - struct GDBRegisterState *gdb_regs; \ - \ - /* Core interrupt code */ \ - jmp_buf jmp_env; \ - int exception_index; \ - \ - CPUArchState *next_cpu; /* next CPU sharing TB cache */ \ - int cpu_index; /* CPU index (informative) */ \ - uint32_t host_tid; /* host thread ID */ \ - int numa_node; /* NUMA node this cpu is belonging to */ \ - int nr_cores; /* number of cores within this CPU package */ \ - int nr_threads;/* number of threads within this CPU */ \ - int running; /* Nonzero if cpu is currently running(usermode). */ \ - /* user data */ \ - void *opaque; \ - \ - const char *cpu_model_str; \ - struct KVMState *kvm_state; \ - struct kvm_run *kvm_run; \ - int kvm_fd; \ - int kvm_vcpu_dirty; - -#endif diff --git a/cpus.c b/cpus.c index d9c332fcb8..8926873ad1 100644 --- a/cpus.c +++ b/cpus.c @@ -27,7 +27,7 @@ #include "monitor.h" #include "sysemu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "dma.h" #include "kvm.h" #include "qmp-commands.h" diff --git a/cputlb.c b/cputlb.c index d6d0372615..88239c494a 100644 --- a/cputlb.c +++ b/cputlb.c @@ -19,13 +19,13 @@ #include "config.h" #include "cpu.h" -#include "exec-all.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/exec-all.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" -#include "cputlb.h" +#include "exec/cputlb.h" -#include "memory-internal.h" +#include "exec/memory-internal.h" //#define DEBUG_TLB //#define DEBUG_TLB_CHECK @@ -347,15 +347,15 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) #define SOFTMMU_CODE_ACCESS #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #undef env diff --git a/cputlb.h b/cputlb.h deleted file mode 100644 index 733c885a1f..0000000000 --- a/cputlb.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Common CPU TLB handling - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef CPUTLB_H -#define CPUTLB_H - -#if !defined(CONFIG_USER_ONLY) -/* cputlb.c */ -void tlb_protect_code(ram_addr_t ram_addr); -void tlb_unprotect_code_phys(CPUArchState *env, ram_addr_t ram_addr, - target_ulong vaddr); -void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start, - uintptr_t length); -MemoryRegionSection *phys_page_find(struct AddressSpaceDispatch *d, - hwaddr index); -void cpu_tlb_reset_dirty_all(ram_addr_t start1, ram_addr_t length); -void tlb_set_dirty(CPUArchState *env, target_ulong vaddr); -extern int tlb_flush_count; - -/* exec.c */ -void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr); -hwaddr memory_region_section_get_iotlb(CPUArchState *env, - MemoryRegionSection *section, - target_ulong vaddr, - hwaddr paddr, - int prot, - target_ulong *address); -bool memory_region_is_unassigned(MemoryRegion *mr); - -#endif -#endif diff --git a/def-helper.h b/def-helper.h deleted file mode 100644 index 022a9ceb6a..0000000000 --- a/def-helper.h +++ /dev/null @@ -1,275 +0,0 @@ -/* Helper file for declaring TCG helper functions. - Should be included at the start and end of target-foo/helper.h. - - Targets should use DEF_HELPER_N and DEF_HELPER_FLAGS_N to declare helper - functions. Names should be specified without the helper_ prefix, and - the return and argument types specified. 3 basic types are understood - (i32, i64 and ptr). Additional aliases are provided for convenience and - to match the types used by the C helper implementation. - - The target helper.h should be included in all files that use/define - helper functions. THis will ensure that function prototypes are - consistent. In addition it should be included an extra two times for - helper.c, defining: - GEN_HELPER 1 to produce op generation functions (gen_helper_*) - GEN_HELPER 2 to do runtime registration helper functions. - */ - -#ifndef DEF_HELPER_H -#define DEF_HELPER_H 1 - -#define HELPER(name) glue(helper_, name) - -#define GET_TCGV_i32 GET_TCGV_I32 -#define GET_TCGV_i64 GET_TCGV_I64 -#define GET_TCGV_ptr GET_TCGV_PTR - -/* Some types that make sense in C, but not for TCG. */ -#define dh_alias_i32 i32 -#define dh_alias_s32 i32 -#define dh_alias_int i32 -#define dh_alias_i64 i64 -#define dh_alias_s64 i64 -#define dh_alias_f32 i32 -#define dh_alias_f64 i64 -#if TARGET_LONG_BITS == 32 -#define dh_alias_tl i32 -#else -#define dh_alias_tl i64 -#endif -#define dh_alias_ptr ptr -#define dh_alias_void void -#define dh_alias_noreturn noreturn -#define dh_alias_env ptr -#define dh_alias(t) glue(dh_alias_, t) - -#define dh_ctype_i32 uint32_t -#define dh_ctype_s32 int32_t -#define dh_ctype_int int -#define dh_ctype_i64 uint64_t -#define dh_ctype_s64 int64_t -#define dh_ctype_f32 float32 -#define dh_ctype_f64 float64 -#define dh_ctype_tl target_ulong -#define dh_ctype_ptr void * -#define dh_ctype_void void -#define dh_ctype_noreturn void QEMU_NORETURN -#define dh_ctype_env CPUArchState * -#define dh_ctype(t) dh_ctype_##t - -/* We can't use glue() here because it falls foul of C preprocessor - recursive expansion rules. */ -#define dh_retvar_decl0_void void -#define dh_retvar_decl0_noreturn void -#define dh_retvar_decl0_i32 TCGv_i32 retval -#define dh_retvar_decl0_i64 TCGv_i64 retval -#define dh_retvar_decl0_ptr TCGv_ptr retval -#define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t)) - -#define dh_retvar_decl_void -#define dh_retvar_decl_noreturn -#define dh_retvar_decl_i32 TCGv_i32 retval, -#define dh_retvar_decl_i64 TCGv_i64 retval, -#define dh_retvar_decl_ptr TCGv_ptr retval, -#define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t)) - -#define dh_retvar_void TCG_CALL_DUMMY_ARG -#define dh_retvar_noreturn TCG_CALL_DUMMY_ARG -#define dh_retvar_i32 GET_TCGV_i32(retval) -#define dh_retvar_i64 GET_TCGV_i64(retval) -#define dh_retvar_ptr GET_TCGV_ptr(retval) -#define dh_retvar(t) glue(dh_retvar_, dh_alias(t)) - -#define dh_is_64bit_void 0 -#define dh_is_64bit_noreturn 0 -#define dh_is_64bit_i32 0 -#define dh_is_64bit_i64 1 -#define dh_is_64bit_ptr (TCG_TARGET_REG_BITS == 64) -#define dh_is_64bit(t) glue(dh_is_64bit_, dh_alias(t)) - -#define dh_is_signed_void 0 -#define dh_is_signed_noreturn 0 -#define dh_is_signed_i32 0 -#define dh_is_signed_s32 1 -#define dh_is_signed_i64 0 -#define dh_is_signed_s64 1 -#define dh_is_signed_f32 0 -#define dh_is_signed_f64 0 -#define dh_is_signed_tl 0 -#define dh_is_signed_int 1 -/* ??? This is highly specific to the host cpu. There are even special - extension instructions that may be required, e.g. ia64's addp4. But - for now we don't support any 64-bit targets with 32-bit pointers. */ -#define dh_is_signed_ptr 0 -#define dh_is_signed_env dh_is_signed_ptr -#define dh_is_signed(t) dh_is_signed_##t - -#define dh_sizemask(t, n) \ - sizemask |= dh_is_64bit(t) << (n*2); \ - sizemask |= dh_is_signed(t) << (n*2+1) - -#define dh_arg(t, n) \ - args[n - 1] = glue(GET_TCGV_, dh_alias(t))(glue(arg, n)); \ - dh_sizemask(t, n) - -#define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n) - - -#define DEF_HELPER_0(name, ret) \ - DEF_HELPER_FLAGS_0(name, 0, ret) -#define DEF_HELPER_1(name, ret, t1) \ - DEF_HELPER_FLAGS_1(name, 0, ret, t1) -#define DEF_HELPER_2(name, ret, t1, t2) \ - DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2) -#define DEF_HELPER_3(name, ret, t1, t2, t3) \ - DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3) -#define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \ - DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4) -#define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \ - DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5) - -/* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ - -#endif /* DEF_HELPER_H */ - -#ifndef GEN_HELPER -/* Function prototypes. */ - -#define DEF_HELPER_FLAGS_0(name, flags, ret) \ -dh_ctype(ret) HELPER(name) (void); - -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1)); - -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2)); - -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3)); - -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ - dh_ctype(t4)); - -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ -dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ - dh_ctype(t4), dh_ctype(t5)); - -#undef GEN_HELPER -#define GEN_HELPER -1 - -#elif GEN_HELPER == 1 -/* Gen functions. */ - -#define DEF_HELPER_FLAGS_0(name, flags, ret) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ -{ \ - int sizemask; \ - sizemask = dh_is_64bit(ret); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 0, NULL); \ -} - -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1)) \ -{ \ - TCGArg args[1]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 1, args); \ -} - -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ - dh_arg_decl(t2, 2)) \ -{ \ - TCGArg args[2]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 2, args); \ -} - -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ - dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ -{ \ - TCGArg args[3]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - dh_arg(t3, 3); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 3, args); \ -} - -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ - dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ -{ \ - TCGArg args[4]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - dh_arg(t3, 3); \ - dh_arg(t4, 4); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 4, args); \ -} - -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ -static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ - dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ - dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \ -{ \ - TCGArg args[5]; \ - int sizemask = 0; \ - dh_sizemask(ret, 0); \ - dh_arg(t1, 1); \ - dh_arg(t2, 2); \ - dh_arg(t3, 3); \ - dh_arg(t4, 4); \ - dh_arg(t5, 5); \ - tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 5, args); \ -} - -#undef GEN_HELPER -#define GEN_HELPER -1 - -#elif GEN_HELPER == 2 -/* Register helpers. */ - -#define DEF_HELPER_FLAGS_0(name, flags, ret) \ -tcg_register_helper(HELPER(name), #name); - -#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ -DEF_HELPER_FLAGS_0(name, flags, ret) - -#undef GEN_HELPER -#define GEN_HELPER -1 - -#elif GEN_HELPER == -1 -/* Undefine macros. */ - -#undef DEF_HELPER_FLAGS_0 -#undef DEF_HELPER_FLAGS_1 -#undef DEF_HELPER_FLAGS_2 -#undef DEF_HELPER_FLAGS_3 -#undef DEF_HELPER_FLAGS_4 -#undef DEF_HELPER_FLAGS_5 -#undef GEN_HELPER - -#endif diff --git a/dma.h b/dma.h index 40280365ce..fd68f74c5b 100644 --- a/dma.h +++ b/dma.h @@ -11,7 +11,7 @@ #define DMA_H #include -#include "memory.h" +#include "exec/memory.h" #include "hw/hw.h" #include "block/block.h" #include "kvm.h" diff --git a/dump.c b/dump.c index 7b45b53a8f..e70e0f3b21 100644 --- a/dump.c +++ b/dump.c @@ -14,8 +14,8 @@ #include "qemu-common.h" #include "elf.h" #include "cpu.h" -#include "cpu-all.h" -#include "hwaddr.h" +#include "exec/cpu-all.h" +#include "exec/hwaddr.h" #include "monitor.h" #include "kvm.h" #include "dump.h" @@ -23,7 +23,7 @@ #include "memory_mapping.h" #include "qapi/error.h" #include "qmp-commands.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" static uint16_t cpu_convert_to_target16(uint16_t val, int endian) { diff --git a/exec-all.h b/exec-all.h deleted file mode 100644 index e9b07cd986..0000000000 --- a/exec-all.h +++ /dev/null @@ -1,412 +0,0 @@ -/* - * internal execution defines for qemu - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef _EXEC_ALL_H_ -#define _EXEC_ALL_H_ - -#include "qemu-common.h" - -/* allow to see translation results - the slowdown should be negligible, so we leave it */ -#define DEBUG_DISAS - -/* Page tracking code uses ram addresses in system mode, and virtual - addresses in userspace mode. Define tb_page_addr_t to be an appropriate - type. */ -#if defined(CONFIG_USER_ONLY) -typedef abi_ulong tb_page_addr_t; -#else -typedef ram_addr_t tb_page_addr_t; -#endif - -/* is_jmp field values */ -#define DISAS_NEXT 0 /* next instruction can be analyzed */ -#define DISAS_JUMP 1 /* only pc was modified dynamically */ -#define DISAS_UPDATE 2 /* cpu state was modified dynamically */ -#define DISAS_TB_JUMP 3 /* only pc was modified statically */ - -struct TranslationBlock; -typedef struct TranslationBlock TranslationBlock; - -/* XXX: make safe guess about sizes */ -#define MAX_OP_PER_INSTR 208 - -#if HOST_LONG_BITS == 32 -#define MAX_OPC_PARAM_PER_ARG 2 -#else -#define MAX_OPC_PARAM_PER_ARG 1 -#endif -#define MAX_OPC_PARAM_IARGS 5 -#define MAX_OPC_PARAM_OARGS 1 -#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) - -/* A Call op needs up to 4 + 2N parameters on 32-bit archs, - * and up to 4 + N parameters on 64-bit archs - * (N = number of input arguments + output arguments). */ -#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) -#define OPC_BUF_SIZE 640 -#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) - -/* Maximum size a TCG op can expand to. This is complicated because a - single op may require several host instructions and register reloads. - For now take a wild guess at 192 bytes, which should allow at least - a couple of fixup instructions per argument. */ -#define TCG_MAX_OP_SIZE 192 - -#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) - -#include "qemu-log.h" - -void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); -void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); -void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, - int pc_pos); - -void cpu_gen_init(void); -int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb, - int *gen_code_size_ptr); -bool cpu_restore_state(CPUArchState *env, uintptr_t searched_pc); - -void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); -void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); -TranslationBlock *tb_gen_code(CPUArchState *env, - target_ulong pc, target_ulong cs_base, int flags, - int cflags); -void cpu_exec_init(CPUArchState *env); -void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1); -int page_unprotect(target_ulong address, uintptr_t pc, void *puc); -void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access); -void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end, - int is_cpu_write_access); -#if !defined(CONFIG_USER_ONLY) -/* cputlb.c */ -void tlb_flush_page(CPUArchState *env, target_ulong addr); -void tlb_flush(CPUArchState *env, int flush_global); -void tlb_set_page(CPUArchState *env, target_ulong vaddr, - hwaddr paddr, int prot, - int mmu_idx, target_ulong size); -void tb_invalidate_phys_addr(hwaddr addr); -#else -static inline void tlb_flush_page(CPUArchState *env, target_ulong addr) -{ -} - -static inline void tlb_flush(CPUArchState *env, int flush_global) -{ -} -#endif - -#define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ - -#define CODE_GEN_PHYS_HASH_BITS 15 -#define CODE_GEN_PHYS_HASH_SIZE (1 << CODE_GEN_PHYS_HASH_BITS) - -/* estimated block size for TB allocation */ -/* XXX: use a per code average code fragment size and modulate it - according to the host CPU */ -#if defined(CONFIG_SOFTMMU) -#define CODE_GEN_AVG_BLOCK_SIZE 128 -#else -#define CODE_GEN_AVG_BLOCK_SIZE 64 -#endif - -#if defined(__arm__) || defined(_ARCH_PPC) \ - || defined(__x86_64__) || defined(__i386__) \ - || defined(__sparc__) \ - || defined(CONFIG_TCG_INTERPRETER) -#define USE_DIRECT_JUMP -#endif - -struct TranslationBlock { - target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */ - target_ulong cs_base; /* CS base for this block */ - uint64_t flags; /* flags defining in which context the code was generated */ - uint16_t size; /* size of target code for this block (1 <= - size <= TARGET_PAGE_SIZE) */ - uint16_t cflags; /* compile flags */ -#define CF_COUNT_MASK 0x7fff -#define CF_LAST_IO 0x8000 /* Last insn may be an IO access. */ - - uint8_t *tc_ptr; /* pointer to the translated code */ - /* next matching tb for physical address. */ - struct TranslationBlock *phys_hash_next; - /* first and second physical page containing code. The lower bit - of the pointer tells the index in page_next[] */ - struct TranslationBlock *page_next[2]; - tb_page_addr_t page_addr[2]; - - /* the following data are used to directly call another TB from - the code of this one. */ - uint16_t tb_next_offset[2]; /* offset of original jump target */ -#ifdef USE_DIRECT_JUMP - uint16_t tb_jmp_offset[2]; /* offset of jump instruction */ -#else - uintptr_t tb_next[2]; /* address of jump generated code */ -#endif - /* list of TBs jumping to this one. This is a circular list using - the two least significant bits of the pointers to tell what is - the next pointer: 0 = jmp_next[0], 1 = jmp_next[1], 2 = - jmp_first */ - struct TranslationBlock *jmp_next[2]; - struct TranslationBlock *jmp_first; - uint32_t icount; -}; - -static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) -{ - target_ulong tmp; - tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); - return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; -} - -static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) -{ - target_ulong tmp; - tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); - return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) - | (tmp & TB_JMP_ADDR_MASK)); -} - -static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) -{ - return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); -} - -void tb_free(TranslationBlock *tb); -void tb_flush(CPUArchState *env); -void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); - -extern TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE]; - -#if defined(USE_DIRECT_JUMP) - -#if defined(CONFIG_TCG_INTERPRETER) -static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) -{ - /* patch the branch destination */ - *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); - /* no need to flush icache explicitly */ -} -#elif defined(_ARCH_PPC) -void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr); -#define tb_set_jmp_target1 ppc_tb_set_jmp_target -#elif defined(__i386__) || defined(__x86_64__) -static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) -{ - /* patch the branch destination */ - *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); - /* no need to flush icache explicitly */ -} -#elif defined(__arm__) -static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) -{ -#if !QEMU_GNUC_PREREQ(4, 1) - register unsigned long _beg __asm ("a1"); - register unsigned long _end __asm ("a2"); - register unsigned long _flg __asm ("a3"); -#endif - - /* we could use a ldr pc, [pc, #-4] kind of branch and avoid the flush */ - *(uint32_t *)jmp_addr = - (*(uint32_t *)jmp_addr & ~0xffffff) - | (((addr - (jmp_addr + 8)) >> 2) & 0xffffff); - -#if QEMU_GNUC_PREREQ(4, 1) - __builtin___clear_cache((char *) jmp_addr, (char *) jmp_addr + 4); -#else - /* flush icache */ - _beg = jmp_addr; - _end = jmp_addr + 4; - _flg = 0; - __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); -#endif -} -#elif defined(__sparc__) -void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr); -#else -#error tb_set_jmp_target1 is missing -#endif - -static inline void tb_set_jmp_target(TranslationBlock *tb, - int n, uintptr_t addr) -{ - uint16_t offset = tb->tb_jmp_offset[n]; - tb_set_jmp_target1((uintptr_t)(tb->tc_ptr + offset), addr); -} - -#else - -/* set the jump target */ -static inline void tb_set_jmp_target(TranslationBlock *tb, - int n, uintptr_t addr) -{ - tb->tb_next[n] = addr; -} - -#endif - -static inline void tb_add_jump(TranslationBlock *tb, int n, - TranslationBlock *tb_next) -{ - /* NOTE: this test is only needed for thread safety */ - if (!tb->jmp_next[n]) { - /* patch the native jump address */ - tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr); - - /* add in TB jmp circular list */ - tb->jmp_next[n] = tb_next->jmp_first; - tb_next->jmp_first = (TranslationBlock *)((uintptr_t)(tb) | (n)); - } -} - -#include "qemu-lock.h" - -extern spinlock_t tb_lock; - -extern int tb_invalidated_flag; - -/* The return address may point to the start of the next instruction. - Subtracting one gets us the call instruction itself. */ -#if defined(CONFIG_TCG_INTERPRETER) -/* Softmmu, Alpha, MIPS, SH4 and SPARC user mode emulations call GETPC(). - For all others, GETPC remains undefined (which makes TCI a little faster. */ -# if defined(CONFIG_SOFTMMU) || \ - defined(TARGET_ALPHA) || defined(TARGET_MIPS) || \ - defined(TARGET_SH4) || defined(TARGET_SPARC) -extern uintptr_t tci_tb_ptr; -# define GETPC() tci_tb_ptr -# endif -#elif defined(__s390__) && !defined(__s390x__) -# define GETPC() \ - (((uintptr_t)__builtin_return_address(0) & 0x7fffffffUL) - 1) -#elif defined(__arm__) -/* Thumb return addresses have the low bit set, so we need to subtract two. - This is still safe in ARM mode because instructions are 4 bytes. */ -# define GETPC() ((uintptr_t)__builtin_return_address(0) - 2) -#else -# define GETPC() ((uintptr_t)__builtin_return_address(0) - 1) -#endif - -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION) && defined(CONFIG_SOFTMMU) -/* qemu_ld/st optimization split code generation to fast and slow path, thus, - it needs special handling for an MMU helper which is called from the slow - path, to get the fast path's pc without any additional argument. - It uses a tricky solution which embeds the fast path pc into the slow path. - - Code flow in slow path: - (1) pre-process - (2) call MMU helper - (3) jump to (5) - (4) fast path information (implementation specific) - (5) post-process (e.g. stack adjust) - (6) jump to corresponding code of the next of fast path - */ -# if defined(__i386__) || defined(__x86_64__) -/* To avoid broken disassembling, long jmp is used for embedding fast path pc, - so that the destination is the next code of fast path, though this jmp is - never executed. - - call MMU helper - jmp POST_PROC (2byte) <- GETRA() - jmp NEXT_CODE (5byte) - POST_PROCESS ... <- GETRA() + 7 - */ -# define GETRA() ((uintptr_t)__builtin_return_address(0)) -# define GETPC_LDST() ((uintptr_t)(GETRA() + 7 + \ - *(int32_t *)((void *)GETRA() + 3) - 1)) -# elif defined (_ARCH_PPC) && !defined (_ARCH_PPC64) -# define GETRA() ((uintptr_t)__builtin_return_address(0)) -# define GETPC_LDST() ((uintptr_t) ((*(int32_t *)(GETRA() - 4)) - 1)) -# else -# error "CONFIG_QEMU_LDST_OPTIMIZATION needs GETPC_LDST() implementation!" -# endif -bool is_tcg_gen_code(uintptr_t pc_ptr); -# define GETPC_EXT() (is_tcg_gen_code(GETRA()) ? GETPC_LDST() : GETPC()) -#else -# define GETPC_EXT() GETPC() -#endif - -#if !defined(CONFIG_USER_ONLY) - -struct MemoryRegion *iotlb_to_region(hwaddr index); -uint64_t io_mem_read(struct MemoryRegion *mr, hwaddr addr, - unsigned size); -void io_mem_write(struct MemoryRegion *mr, hwaddr addr, - uint64_t value, unsigned size); - -void tlb_fill(CPUArchState *env1, target_ulong addr, int is_write, int mmu_idx, - uintptr_t retaddr); - -#include "softmmu_defs.h" - -#define ACCESS_TYPE (NB_MMU_MODES + 1) -#define MEMSUFFIX _code - -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" - -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#endif - -#if defined(CONFIG_USER_ONLY) -static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) -{ - return addr; -} -#else -/* cputlb.c */ -tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); -#endif - -typedef void (CPUDebugExcpHandler)(CPUArchState *env); - -void cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); - -/* vl.c */ -extern int singlestep; - -/* cpu-exec.c */ -extern volatile sig_atomic_t exit_request; - -/* Deterministic execution requires that IO only be performed on the last - instruction of a TB so that interrupts take effect immediately. */ -static inline int can_do_io(CPUArchState *env) -{ - if (!use_icount) { - return 1; - } - /* If not executing code then assume we are ok. */ - if (!env->current_tb) { - return 1; - } - return env->can_do_io != 0; -} - -#endif diff --git a/exec-memory.h b/exec-memory.h deleted file mode 100644 index ac1d07dfe4..0000000000 --- a/exec-memory.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Internal memory management interfaces - * - * Copyright 2011 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef EXEC_MEMORY_H -#define EXEC_MEMORY_H - -/* - * Internal interfaces between memory.c/exec.c/vl.c. Do not #include unless - * you're one of them. - */ - -#include "memory.h" - -#ifndef CONFIG_USER_ONLY - -/* Get the root memory region. This interface should only be used temporarily - * until a proper bus interface is available. - */ -MemoryRegion *get_system_memory(void); - -/* Get the root I/O port region. This interface should only be used - * temporarily until a proper bus interface is available. - */ -MemoryRegion *get_system_io(void); - -extern AddressSpace address_space_memory; -extern AddressSpace address_space_io; - -#endif - -#endif diff --git a/exec.c b/exec.c index 986084146c..17fc7cf854 100644 --- a/exec.c +++ b/exec.c @@ -34,9 +34,9 @@ #include "hw/xen.h" #include "qemu-timer.h" #include "qemu-config.h" -#include "memory.h" +#include "exec/memory.h" #include "dma.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) #include #else /* !CONFIG_USER_ONLY */ @@ -44,10 +44,10 @@ #include "trace.h" #endif -#include "cputlb.h" +#include "exec/cputlb.h" #include "translate-all.h" -#include "memory-internal.h" +#include "exec/memory-internal.h" //#define DEBUG_UNASSIGNED //#define DEBUG_SUBPAGE diff --git a/gdbstub.c b/gdbstub.c index d02ec75384..70ad79a748 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -32,7 +32,7 @@ #include "monitor.h" #include "qemu-char.h" #include "sysemu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #endif #define MAX_PACKET_LENGTH 4096 diff --git a/gdbstub.h b/gdbstub.h deleted file mode 100644 index 668de66000..0000000000 --- a/gdbstub.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GDBSTUB_H -#define GDBSTUB_H - -#define DEFAULT_GDBSTUB_PORT "1234" - -/* GDB breakpoint/watchpoint types */ -#define GDB_BREAKPOINT_SW 0 -#define GDB_BREAKPOINT_HW 1 -#define GDB_WATCHPOINT_WRITE 2 -#define GDB_WATCHPOINT_READ 3 -#define GDB_WATCHPOINT_ACCESS 4 - -#ifdef NEED_CPU_H -typedef void (*gdb_syscall_complete_cb)(CPUArchState *env, - target_ulong ret, target_ulong err); - -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); -int use_gdb_syscalls(void); -void gdb_set_stop_cpu(CPUArchState *env); -void gdb_exit(CPUArchState *, int); -#ifdef CONFIG_USER_ONLY -int gdb_queuesig (void); -int gdb_handlesig (CPUArchState *, int); -void gdb_signalled(CPUArchState *, int); -void gdbserver_fork(CPUArchState *); -#endif -/* Get or set a register. Returns the size of the register. */ -typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); -void gdb_register_coprocessor(CPUArchState *env, - gdb_reg_cb get_reg, gdb_reg_cb set_reg, - int num_regs, const char *xml, int g_pos); - -static inline int cpu_index(CPUArchState *env) -{ -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL) - return env->host_tid; -#else - return env->cpu_index + 1; -#endif -} - -#endif - -#ifdef CONFIG_USER_ONLY -int gdbserver_start(int); -#else -int gdbserver_start(const char *port); -#endif - -/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ -extern const char *const xml_builtin[][2]; - -#endif diff --git a/gen-icount.h b/gen-icount.h deleted file mode 100644 index 1541f0b1e4..0000000000 --- a/gen-icount.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GEN_ICOUNT_H -#define GEN_ICOUNT_H 1 - -#include "qemu-timer.h" - -/* Helpers for instruction counting code generation. */ - -static TCGArg *icount_arg; -static int icount_label; - -static inline void gen_icount_start(void) -{ - TCGv_i32 count; - - if (!use_icount) - return; - - icount_label = gen_new_label(); - count = tcg_temp_local_new_i32(); - tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32)); - /* This is a horrid hack to allow fixing up the value later. */ - icount_arg = tcg_ctx.gen_opparam_ptr + 1; - tcg_gen_subi_i32(count, count, 0xdeadbeef); - - tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label); - tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low)); - tcg_temp_free_i32(count); -} - -static void gen_icount_end(TranslationBlock *tb, int num_insns) -{ - if (use_icount) { - *icount_arg = num_insns; - gen_set_label(icount_label); - tcg_gen_exit_tb((tcg_target_long)tb + 2); - } -} - -static inline void gen_io_start(void) -{ - TCGv_i32 tmp = tcg_const_i32(1); - tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); - tcg_temp_free_i32(tmp); -} - -static inline void gen_io_end(void) -{ - TCGv_i32 tmp = tcg_const_i32(0); - tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); - tcg_temp_free_i32(tmp); -} - -#endif diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 755fa050f7..92af3a554c 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -30,7 +30,7 @@ #include "sysemu.h" #include "acpi.h" #include "kvm.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ich9.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 46f9843891..4f43f6e070 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -26,9 +26,9 @@ #include "acpi.h" #include "sysemu.h" #include "range.h" -#include "ioport.h" +#include "exec/ioport.h" #include "fw_cfg.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c index 9b16d96612..d61b2f483c 100644 --- a/hw/alpha_typhoon.c +++ b/hw/alpha_typhoon.c @@ -7,12 +7,12 @@ */ #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "hw.h" #include "devices.h" #include "sysemu.h" #include "alpha_sys.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost" diff --git a/hw/an5206.c b/hw/an5206.c index d887c0e7eb..dcfe34b3ae 100644 --- a/hw/an5206.c +++ b/hw/an5206.c @@ -11,7 +11,7 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define KERNEL_LOAD_ADDR 0x10000 #define AN5206_MBAR_ADDR 0x10000000 diff --git a/hw/apb_pci.c b/hw/apb_pci.c index fb7a07de37..144a7cc8d3 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -33,7 +33,7 @@ #include "pci/pci_bus.h" #include "apb_pci.h" #include "sysemu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* debug APB */ //#define DEBUG_APB diff --git a/hw/apic_internal.h b/hw/apic_internal.h index 79e2de2243..fea95654ca 100644 --- a/hw/apic_internal.h +++ b/hw/apic_internal.h @@ -20,7 +20,7 @@ #ifndef QEMU_APIC_INTERNAL_H #define QEMU_APIC_INTERNAL_H -#include "memory.h" +#include "exec/memory.h" #include "sysbus.h" #include "qemu-timer.h" diff --git a/hw/apm.h b/hw/apm.h index 5431b6d7c8..9abb47f99f 100644 --- a/hw/apm.h +++ b/hw/apm.h @@ -4,7 +4,7 @@ #include #include "qemu-common.h" #include "hw.h" -#include "memory.h" +#include "exec/memory.h" typedef void (*apm_ctrl_changed_t)(uint32_t val, void *arg); diff --git a/hw/arm-misc.h b/hw/arm-misc.h index d129678b26..cba7553039 100644 --- a/hw/arm-misc.h +++ b/hw/arm-misc.h @@ -11,7 +11,7 @@ #ifndef ARM_MISC_H #define ARM_MISC_H 1 -#include "memory.h" +#include "exec/memory.h" #include "hw/irq.h" /* The CPU is also modeled as an interrupt controller. */ diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c index 4963678bf1..270c307717 100644 --- a/hw/armv7m_nvic.c +++ b/hw/armv7m_nvic.c @@ -13,7 +13,7 @@ #include "sysbus.h" #include "qemu-timer.h" #include "arm-misc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "arm_gic_internal.h" typedef struct { diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c index 50ddbc920d..e537aecc78 100644 --- a/hw/axis_dev88.c +++ b/hw/axis_dev88.c @@ -31,7 +31,7 @@ #include "elf.h" #include "cris-boot.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define D(x) #define DNAND(x) diff --git a/hw/bonito.c b/hw/bonito.c index a1fc38c784..78e264ccc0 100644 --- a/hw/bonito.c +++ b/hw/bonito.c @@ -45,7 +45,7 @@ #include "mips.h" #include "pci/pci_host.h" #include "sysemu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_BONITO diff --git a/hw/collie.c b/hw/collie.c index 695982a99f..faf5ac9ac7 100644 --- a/hw/collie.c +++ b/hw/collie.c @@ -16,7 +16,7 @@ #include "arm-misc.h" #include "flash.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static struct arm_boot_info collie_binfo = { .loader_start = SA_SDCS0, diff --git a/hw/dummy_m68k.c b/hw/dummy_m68k.c index 20f790b1a6..7878cc3e15 100644 --- a/hw/dummy_m68k.c +++ b/hw/dummy_m68k.c @@ -10,7 +10,7 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define KERNEL_LOAD_ADDR 0x10000 diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c index 49221abc1a..089267fcc1 100644 --- a/hw/etraxfs_dma.c +++ b/hw/etraxfs_dma.c @@ -24,7 +24,7 @@ #include #include #include "hw.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "qemu-common.h" #include "sysemu.h" diff --git a/hw/exynos4210.h b/hw/exynos4210.h index 777f0f5b2f..bb9a1dddc8 100644 --- a/hw/exynos4210.h +++ b/hw/exynos4210.h @@ -27,7 +27,7 @@ #define EXYNOS4210_H_ #include "qemu-common.h" -#include "memory.h" +#include "exec/memory.h" #define EXYNOS4210_NCPUS 2 diff --git a/hw/exynos4210_fimd.c b/hw/exynos4210_fimd.c index 3ef0847271..cfca72ab67 100644 --- a/hw/exynos4210_fimd.c +++ b/hw/exynos4210_fimd.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "sysbus.h" #include "ui/console.h" #include "ui/pixel_ops.h" diff --git a/hw/exynos4_boards.c b/hw/exynos4_boards.c index c375f16479..5dd2961459 100644 --- a/hw/exynos4_boards.c +++ b/hw/exynos4_boards.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "net/net.h" #include "arm-misc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "exynos4210.h" #include "boards.h" diff --git a/hw/flash.h b/hw/flash.h index bda2158c13..920d7596e3 100644 --- a/hw/flash.h +++ b/hw/flash.h @@ -3,7 +3,7 @@ /* NOR flash devices */ -#include "memory.h" +#include "exec/memory.h" typedef struct pflash_t pflash_t; diff --git a/hw/framebuffer.h b/hw/framebuffer.h index 46e375b5ec..11f53edec0 100644 --- a/hw/framebuffer.h +++ b/hw/framebuffer.h @@ -1,7 +1,7 @@ #ifndef QEMU_FRAMEBUFFER_H #define QEMU_FRAMEBUFFER_H -#include "memory.h" +#include "exec/memory.h" /* Framebuffer device helper routines. */ diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c index 5aa49c6148..977a2c5e69 100644 --- a/hw/gt64xxx.c +++ b/hw/gt64xxx.c @@ -27,7 +27,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "pc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG diff --git a/hw/gumstix.c b/hw/gumstix.c index 545b92fd95..4acb32c2a9 100644 --- a/hw/gumstix.c +++ b/hw/gumstix.c @@ -41,7 +41,7 @@ #include "devices.h" #include "boards.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static const int sector_len = 128 * 1024; diff --git a/hw/highbank.c b/hw/highbank.c index 90f7cb5ef2..6f5f2a9d9d 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -26,7 +26,7 @@ #include "boards.h" #include "sysbus.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0x100 #define SMP_BOOT_REG 0x40 diff --git a/hw/hw.h b/hw/hw.h index 003d974866..7368470bb1 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -5,10 +5,10 @@ #include "qemu-common.h" #if !defined(CONFIG_USER_ONLY) && !defined(NEED_CPU_H) -#include "cpu-common.h" +#include "exec/cpu-common.h" #endif -#include "ioport.h" +#include "exec/ioport.h" #include "irq.h" #include "block/aio.h" #include "qemu-file.h" diff --git a/hw/ide.h b/hw/ide.h index 081c710d56..7e23cda8e0 100644 --- a/hw/ide.h +++ b/hw/ide.h @@ -3,7 +3,7 @@ #include "isa.h" #include "pci/pci.h" -#include "memory.h" +#include "exec/memory.h" #define MAX_IDE_DEVS 2 diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 2ea64bd316..f32a84761d 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -29,7 +29,7 @@ #include "monitor.h" #include "dma.h" -#include "cpu-common.h" +#include "exec/cpu-common.h" #include "internal.h" #include #include diff --git a/hw/ide/internal.h b/hw/ide/internal.h index bf7d313cf4..c5016f0cea 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -8,7 +8,7 @@ */ #include #include -#include "iorange.h" +#include "exec/iorange.h" #include "dma.h" #include "sysemu.h" #include "hw/block-common.h" diff --git a/hw/integratorcp.c b/hw/integratorcp.c index 2b59fea9f1..c995dc724f 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -12,7 +12,7 @@ #include "boards.h" #include "arm-misc.h" #include "net/net.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" typedef struct { diff --git a/hw/ioapic_internal.h b/hw/ioapic_internal.h index e04c9f3c12..c8447d7f3b 100644 --- a/hw/ioapic_internal.h +++ b/hw/ioapic_internal.h @@ -23,7 +23,7 @@ #define QEMU_IOAPIC_INTERNAL_H #include "hw.h" -#include "memory.h" +#include "exec/memory.h" #include "sysbus.h" #define MAX_IOAPICS 1 diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 144a88e272..8f40974166 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -21,7 +21,7 @@ #include "sysbus.h" #include "sysemu.h" #include "isa.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static ISABus *isabus; hwaddr isa_mem_base = 0; diff --git a/hw/isa.h b/hw/isa.h index 9d719fa3c8..62e89d3bcd 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -3,8 +3,8 @@ /* ISA bus */ -#include "ioport.h" -#include "memory.h" +#include "exec/ioport.h" +#include "exec/memory.h" #include "qdev.h" #define ISA_NUM_IRQS 16 diff --git a/hw/isa_mmio.c b/hw/isa_mmio.c index 14053960cb..487cf6a8fb 100644 --- a/hw/isa_mmio.c +++ b/hw/isa_mmio.c @@ -24,7 +24,7 @@ #include "hw.h" #include "isa.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static void isa_mmio_writeb (void *opaque, hwaddr addr, uint32_t val) diff --git a/hw/kzm.c b/hw/kzm.c index a27ecbba84..9f92d30928 100644 --- a/hw/kzm.c +++ b/hw/kzm.c @@ -14,7 +14,7 @@ */ #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw.h" #include "arm-misc.h" #include "devices.h" diff --git a/hw/leon3.c b/hw/leon3.c index ef83dffd85..e8d54e5d06 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -30,7 +30,7 @@ #include "loader.h" #include "elf.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "grlib.h" diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c index f59d3bfef8..81afdf675c 100644 --- a/hw/lm32_boards.c +++ b/hw/lm32_boards.c @@ -27,7 +27,7 @@ #include "elf.h" #include "lm32_hwsetup.h" #include "lm32.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { LM32CPU *cpu; diff --git a/hw/loader.c b/hw/loader.c index 52f0940778..03f0318d91 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -49,8 +49,8 @@ #include "uboot_image.h" #include "loader.h" #include "fw_cfg.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index 30505789f8..e225693721 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -43,7 +43,7 @@ #include "acpi_ich9.h" #include "pam.h" #include "pci/pci_bus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" static int ich9_lpc_sci_irq(ICH9LPCState *lpc); diff --git a/hw/m48t59.c b/hw/m48t59.c index 7da7e7c822..491d433ae7 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -27,7 +27,7 @@ #include "sysemu.h" #include "sysbus.h" #include "isa.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_NVRAM diff --git a/hw/mac_dbdma.h b/hw/mac_dbdma.h index e596837f46..691263eede 100644 --- a/hw/mac_dbdma.h +++ b/hw/mac_dbdma.h @@ -22,7 +22,7 @@ #ifndef HW_MAC_DBDMA_H #define HW_MAC_DBDMA_H 1 -#include "memory.h" +#include "exec/memory.h" typedef struct DBDMA_io DBDMA_io; diff --git a/hw/mainstone.c b/hw/mainstone.c index 58c8b0748e..80d6a9d54d 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -20,7 +20,7 @@ #include "flash.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* Device addresses */ #define MST_FPGA_PHYS 0x08000000 diff --git a/hw/mcf5206.c b/hw/mcf5206.c index 510d77047e..5edc931abd 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -10,7 +10,7 @@ #include "qemu-timer.h" #include "ptimer.h" #include "sysemu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* General purpose timer module. */ typedef struct { diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 6326624111..997b34847c 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -14,7 +14,7 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define SYS_FREQ 66000000 diff --git a/hw/mcf_fec.c b/hw/mcf_fec.c index b5fb18f67f..2423f64bf6 100644 --- a/hw/mcf_fec.c +++ b/hw/mcf_fec.c @@ -10,7 +10,7 @@ #include "mcf.h" /* For crc32 */ #include -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_FEC 1 diff --git a/hw/mcf_intc.c b/hw/mcf_intc.c index 6ef6dac931..3bed3a2e4c 100644 --- a/hw/mcf_intc.c +++ b/hw/mcf_intc.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { MemoryRegion iomem; diff --git a/hw/mcf_uart.c b/hw/mcf_uart.c index d1655f8f2c..2eca2c6ae9 100644 --- a/hw/mcf_uart.c +++ b/hw/mcf_uart.c @@ -8,7 +8,7 @@ #include "hw.h" #include "mcf.h" #include "qemu-char.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { MemoryRegion iomem; diff --git a/hw/milkymist.c b/hw/milkymist.c index c26ea4aed2..588522260b 100644 --- a/hw/milkymist.c +++ b/hw/milkymist.c @@ -28,7 +28,7 @@ #include "blockdev.h" #include "milkymist-hw.h" #include "lm32.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define BIOS_FILENAME "mmone-bios.bin" #define BIOS_OFFSET 0x00860000 diff --git a/hw/mips.h b/hw/mips.h index f7e9b7e2c1..291e85f6b9 100644 --- a/hw/mips.h +++ b/hw/mips.h @@ -2,7 +2,7 @@ #define HW_MIPS_H /* Definitions for mips board emulation. */ -#include "memory.h" +#include "exec/memory.h" /* gt64xxx.c */ PCIBus *gt64120_register(qemu_irq *pic); diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index b46f7fdcb1..34619b7e3e 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -42,7 +42,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define DEBUG_FULONG2E_INIT diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 8e5e8ef1af..0befc99210 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -41,7 +41,7 @@ #include "pcspk.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" enum jazz_model_e { diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 60f237987f..d65d1256fd 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -46,7 +46,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" /* SysBusDevice */ //#define DEBUG_BOARD_INIT diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index 78317426a7..ac7dfa9b74 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -36,7 +36,7 @@ #include "loader.h" #include "elf.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static struct _loaderparams { int ram_size; diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index ec99d7d6a6..05494b9b40 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -25,7 +25,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define MAX_IDE_BUS 2 diff --git a/hw/musicpal.c b/hw/musicpal.c index d7672e92a5..436b3f7c37 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -23,7 +23,7 @@ #include "ui/console.h" #include "i2c.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ui/pixel_ops.h" #define MP_MISC_BASE 0x80002000 diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c index 99477a412a..c2c00c215f 100644 --- a/hw/ne2000-isa.c +++ b/hw/ne2000-isa.c @@ -27,7 +27,7 @@ #include "qdev.h" #include "net/net.h" #include "ne2000.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct ISANE2000State { ISADevice dev; diff --git a/hw/nseries.c b/hw/nseries.c index dcd3dc97d0..83adb97211 100644 --- a/hw/nseries.c +++ b/hw/nseries.c @@ -33,7 +33,7 @@ #include "loader.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* Nokia N8x0 support */ struct n800_s { diff --git a/hw/omap.h b/hw/omap.h index 2b383ffc44..188cda8771 100644 --- a/hw/omap.h +++ b/hw/omap.h @@ -17,7 +17,7 @@ * with this program; if not, see . */ #ifndef hw_omap_h -#include "memory.h" +#include "exec/memory.h" # define hw_omap_h "omap.h" #include "hw/irq.h" diff --git a/hw/omap_gpmc.c b/hw/omap_gpmc.c index 1f7c5bc5f3..02ab0ab568 100644 --- a/hw/omap_gpmc.c +++ b/hw/omap_gpmc.c @@ -21,8 +21,8 @@ #include "hw.h" #include "flash.h" #include "omap.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" /* General-Purpose Memory Controller */ struct omap_gpmc_s { diff --git a/hw/omap_sx1.c b/hw/omap_sx1.c index 918a6f6a04..ca6eb9ddeb 100644 --- a/hw/omap_sx1.c +++ b/hw/omap_sx1.c @@ -32,7 +32,7 @@ #include "arm-misc.h" #include "flash.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /*****************************************************************************/ /* Siemens SX1 Cellphone V1 */ diff --git a/hw/omap_uart.c b/hw/omap_uart.c index 92f27021bb..159b2d1cdd 100644 --- a/hw/omap_uart.c +++ b/hw/omap_uart.c @@ -21,7 +21,7 @@ #include "hw.h" #include "omap.h" #include "serial.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* UARTs */ struct omap_uart_s { diff --git a/hw/onenand.c b/hw/onenand.c index 1803e4c264..7d255c563f 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -23,8 +23,8 @@ #include "flash.h" #include "irq.h" #include "blockdev.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" #include "qemu-error.h" diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c index a879fb0dd0..c12097e12b 100644 --- a/hw/openrisc_sim.c +++ b/hw/openrisc_sim.c @@ -24,7 +24,7 @@ #include "serial.h" #include "net/net.h" #include "loader.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" #include "sysbus.h" #include "qtest.h" diff --git a/hw/palm.c b/hw/palm.c index 5aaeb07460..e091bbcfc1 100644 --- a/hw/palm.c +++ b/hw/palm.c @@ -25,7 +25,7 @@ #include "arm-misc.h" #include "devices.h" #include "loader.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static uint32_t static_readb(void *opaque, hwaddr offset) { diff --git a/hw/pam.h b/hw/pam.h index 2d77ebe0d9..8e9e349b1d 100644 --- a/hw/pam.h +++ b/hw/pam.h @@ -51,7 +51,7 @@ */ #include "qemu-common.h" -#include "memory.h" +#include "exec/memory.h" #define SMRAM_C_BASE 0xa0000 #define SMRAM_C_END 0xc0000 diff --git a/hw/pc.c b/hw/pc.c index d1b102c879..2452fd4214 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -47,8 +47,8 @@ #include "blockdev.h" #include "hw/block-common.h" #include "ui/qemu-spice.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "arch_init.h" #include "bitmap.h" diff --git a/hw/pc.h b/hw/pc.h index 5e4d103813..a73e3e7b5b 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -2,12 +2,12 @@ #define HW_PC_H #include "qemu-common.h" -#include "memory.h" -#include "ioport.h" +#include "exec/memory.h" +#include "exec/ioport.h" #include "isa.h" #include "fdc.h" #include "net/net.h" -#include "memory.h" +#include "exec/memory.h" #include "ioapic.h" /* PC-style peripherals (also used by other machines). */ diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 7268dcd944..0d011348f2 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -41,8 +41,8 @@ #include "blockdev.h" #include "smbus.h" #include "xen.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "cpu.h" #ifdef CONFIG_XEN # include diff --git a/hw/pc_q35.c b/hw/pc_q35.c index 3429a9ae8f..2580d5ff34 100644 --- a/hw/pc_q35.c +++ b/hw/pc_q35.c @@ -36,7 +36,7 @@ #include "kvm.h" #include "kvm/clock.h" #include "q35.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ich9.h" #include "hw/ide/pci.h" #include "hw/ide/ahci.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 105fe9560e..fa0f08eb0a 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -33,7 +33,7 @@ #include "qmp-commands.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_PCI #ifdef DEBUG_PCI diff --git a/hw/pci/pci.h b/hw/pci/pci.h index 41e5ddd1c4..d6ef4f6574 100644 --- a/hw/pci/pci.h +++ b/hw/pci/pci.h @@ -4,7 +4,7 @@ #include "qemu-common.h" #include "hw/qdev.h" -#include "memory.h" +#include "exec/memory.h" #include "dma.h" /* PCI includes legacy ISA access. */ diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c index ab8d251de6..b2d942bce1 100644 --- a/hw/pci/pcie_host.c +++ b/hw/pci/pcie_host.c @@ -22,7 +22,7 @@ #include "hw/hw.h" #include "hw/pci/pci.h" #include "hw/pci/pcie_host.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* * PCI express mmcfig address diff --git a/hw/pci/pcie_host.h b/hw/pci/pcie_host.h index 150bef9736..1228e36cb2 100644 --- a/hw/pci/pcie_host.h +++ b/hw/pci/pcie_host.h @@ -22,7 +22,7 @@ #define PCIE_HOST_H #include "hw/pci/pci_host.h" -#include "memory.h" +#include "exec/memory.h" #define TYPE_PCIE_HOST_BRIDGE "pcie-host-bridge" #define PCIE_HOST_BRIDGE(obj) \ diff --git a/hw/pci/shpc.h b/hw/pci/shpc.h index 130b71df30..6374e68bdb 100644 --- a/hw/pci/shpc.h +++ b/hw/pci/shpc.h @@ -2,7 +2,7 @@ #define SHPC_H #include "qemu-common.h" -#include "memory.h" +#include "exec/memory.h" #include "vmstate.h" struct SHPCDevice { diff --git a/hw/pci_bridge_dev.c b/hw/pci_bridge_dev.c index dbb4b3b433..7818dcc350 100644 --- a/hw/pci_bridge_dev.c +++ b/hw/pci_bridge_dev.c @@ -24,7 +24,7 @@ #include "pci/msi.h" #include "pci/shpc.h" #include "pci/slotid_cap.h" -#include "memory.h" +#include "exec/memory.h" #include "pci/pci_bus.h" #define REDHAT_PCI_VENDOR_ID 0x1b36 diff --git a/hw/pcnet.h b/hw/pcnet.h index 96643117a0..9dee6f3e2c 100644 --- a/hw/pcnet.h +++ b/hw/pcnet.h @@ -7,7 +7,7 @@ #define PCNET_LOOPTEST_CRC 1 #define PCNET_LOOPTEST_NOCRC 2 -#include "memory.h" +#include "exec/memory.h" /* BUS CONFIGURATION REGISTERS */ #define BCR_MSRDA 0 diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c index df51a74450..4eab0f2d8b 100644 --- a/hw/petalogix_ml605_mmu.c +++ b/hw/petalogix_ml605_mmu.c @@ -35,7 +35,7 @@ #include "xilinx.h" #include "blockdev.h" #include "serial.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ssi.h" #include "microblaze_boot.h" diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c index 37b0d5595a..124a88eeda 100644 --- a/hw/petalogix_s3adsp1800_mmu.c +++ b/hw/petalogix_s3adsp1800_mmu.c @@ -32,7 +32,7 @@ #include "boards.h" #include "xilinx.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "microblaze_boot.h" #include "microblaze_pic_cpu.h" diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index a2f6360838..36af4647df 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -40,7 +40,7 @@ #include "flash.h" #include "block/block.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "host-utils.h" #include "sysbus.h" diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index beab67fc87..c689cc9f42 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -39,7 +39,7 @@ #include "flash.h" #include "qemu-timer.h" #include "block/block.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "host-utils.h" #include "sysbus.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 4690bd8b00..798e67cedf 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -33,7 +33,7 @@ #include "hw/loader.h" #include "elf.h" #include "hw/sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "host-utils.h" #include "hw/ppce500_pci.h" diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index b875e3b615..5a0e0260e6 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -32,7 +32,7 @@ #include "qemu-log.h" #include "loader.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define BIOS_FILENAME "ppc405_rom.bin" #define BIOS_SIZE (2048 * 1024) diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c index 0f458ef772..aabb2efb48 100644 --- a/hw/ppc405_uc.c +++ b/hw/ppc405_uc.c @@ -28,7 +28,7 @@ #include "qemu-timer.h" #include "sysemu.h" #include "qemu-log.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define DEBUG_OPBA #define DEBUG_SDRAM diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index 5193a0c4be..591d7b0088 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -22,7 +22,7 @@ #include "device_tree.h" #include "loader.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "serial.h" #include "ppc.h" #include "ppc405.h" diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c index bac8d8769a..3b9dc06716 100644 --- a/hw/ppc4xx_devs.c +++ b/hw/ppc4xx_devs.c @@ -25,7 +25,7 @@ #include "ppc.h" #include "ppc4xx.h" #include "qemu-log.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_MMIO //#define DEBUG_UNASSIGNED diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c index 3e8af11f08..ba2d669b83 100644 --- a/hw/ppc4xx_pci.c +++ b/hw/ppc4xx_pci.c @@ -24,7 +24,7 @@ #include "ppc4xx.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #undef DEBUG #ifdef DEBUG diff --git a/hw/ppc_mac.h b/hw/ppc_mac.h index 524b2368a4..89c7d66386 100644 --- a/hw/ppc_mac.h +++ b/hw/ppc_mac.h @@ -25,7 +25,7 @@ #if !defined(__PPC_MAC_H__) #define __PPC_MAC_H__ -#include "memory.h" +#include "exec/memory.h" /* SMP is not enabled, for now */ #define MAX_CPUS 1 diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 657f405f1b..b2d02eaff2 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -66,7 +66,7 @@ #include "kvm_ppc.h" #include "hw/usb.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" #define MAX_IDE_BUS 2 diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index a149306cc9..7a8a039d7e 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -42,7 +42,7 @@ #include "kvm.h" #include "kvm_ppc.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define MAX_IDE_BUS 2 #define CFG_ADDR 0xf0000510 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 25cc0490f9..aa46cc6f55 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -39,7 +39,7 @@ #include "mc146818rtc.h" #include "blockdev.h" #include "arch_init.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define HARD_DEBUG_PPC_IO //#define DEBUG_PPC_IO diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index 9bffbb9f87..feefc6596b 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -317,7 +317,7 @@ static const VMStateDescription vmstate_ppce500_pci = { } }; -#include "exec-memory.h" +#include "exec/address-spaces.h" static int e500_pcihost_bridge_initfn(PCIDevice *d) { diff --git a/hw/prep_pci.c b/hw/prep_pci.c index 5f22de647a..212a2ac4f1 100644 --- a/hw/prep_pci.c +++ b/hw/prep_pci.c @@ -26,7 +26,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "pc.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define TYPE_RAVEN_PCI_HOST_BRIDGE "raven-pcihost" diff --git a/hw/puv3.c b/hw/puv3.c index 9f8e294ad5..7814bc5051 100644 --- a/hw/puv3.c +++ b/hw/puv3.c @@ -12,7 +12,7 @@ #include "qemu-common.h" #include "ui/console.h" #include "elf.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysbus.h" #include "boards.h" #include "loader.h" diff --git a/hw/pxa.h b/hw/pxa.h index 49ac820ea2..c2577d1d94 100644 --- a/hw/pxa.h +++ b/hw/pxa.h @@ -9,7 +9,7 @@ #ifndef PXA_H # define PXA_H "pxa.h" -#include "memory.h" +#include "exec/memory.h" /* Interrupt numbers */ # define PXA2XX_PIC_SSP3 0 diff --git a/hw/qdev-addr.c b/hw/qdev-addr.c index 552ee21f82..3bfe101d79 100644 --- a/hw/qdev-addr.c +++ b/hw/qdev-addr.c @@ -1,6 +1,6 @@ #include "qdev.h" #include "qdev-addr.h" -#include "hwaddr.h" +#include "exec/hwaddr.h" #include "qapi/visitor.h" /* --- target physical address --- */ diff --git a/hw/r2d.c b/hw/r2d.c index b1c278f73f..d7a26bf398 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -37,7 +37,7 @@ #include "usb.h" #include "flash.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define FLASH_BASE 0x00000000 #define FLASH_SIZE 0x02000000 diff --git a/hw/realview.c b/hw/realview.c index 17d1ba2266..9c55bf29b7 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -17,7 +17,7 @@ #include "boards.h" #include "i2c.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0xe0000000 #define SMP_BOOTREG_ADDR 0x10000030 diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index b732bccef8..0a15625b73 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -29,7 +29,7 @@ #include "hw/virtio.h" #include "hw/sysbus.h" #include "kvm.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/s390-virtio-bus.h" #include "hw/s390x/sclp.h" diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 5c274fa03d..bc9b0aeb00 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -14,7 +14,7 @@ #include "cpu.h" #include "kvm.h" -#include "memory.h" +#include "exec/memory.h" #include "sclp.h" diff --git a/hw/serial.c b/hw/serial.c index 07a2a11931..3968c4fc46 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -26,7 +26,7 @@ #include "serial.h" #include "qemu-char.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/serial.h b/hw/serial.h index 2d7d614e09..5722f8a353 100644 --- a/hw/serial.h +++ b/hw/serial.h @@ -27,7 +27,7 @@ #include "hw.h" #include "sysemu.h" -#include "memory.h" +#include "exec/memory.h" #define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */ diff --git a/hw/sh7750.c b/hw/sh7750.c index 8bcf0df96f..08945750c4 100644 --- a/hw/sh7750.c +++ b/hw/sh7750.c @@ -30,7 +30,7 @@ #include "sh7750_regnames.h" #include "sh_intc.h" #include "cpu.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define NB_DEVICES 4 diff --git a/hw/sh_intc.h b/hw/sh_intc.h index 80c9430577..6f11beeddd 100644 --- a/hw/sh_intc.h +++ b/hw/sh_intc.h @@ -3,7 +3,7 @@ #include "qemu-common.h" #include "irq.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef unsigned char intc_enum; diff --git a/hw/sh_pci.c b/hw/sh_pci.c index 9ea08c8f8e..d5218420a3 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -26,7 +26,7 @@ #include "pci/pci.h" #include "pci/pci_host.h" #include "bswap.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct SHPCIState { SysBusDevice busdev; diff --git a/hw/sh_serial.c b/hw/sh_serial.c index 9da5d08fee..63723496f1 100644 --- a/hw/sh_serial.c +++ b/hw/sh_serial.c @@ -27,7 +27,7 @@ #include "hw.h" #include "sh.h" #include "qemu-char.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/sh_timer.c b/hw/sh_timer.c index c0365b1142..da6689f369 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -11,7 +11,7 @@ #include "hw.h" #include "sh.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ptimer.h" //#define DEBUG_TIMER diff --git a/hw/shix.c b/hw/shix.c index b56dd54f75..821196e84c 100644 --- a/hw/shix.c +++ b/hw/shix.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "boards.h" #include "loader.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define BIOS_FILENAME "shix_bios.bin" #define BIOS_ADDRESS 0xA0000000 diff --git a/hw/soc_dma.h b/hw/soc_dma.h index 6ca4166184..7379731afd 100644 --- a/hw/soc_dma.h +++ b/hw/soc_dma.h @@ -22,7 +22,7 @@ #define HW_SOC_DMA_H 1 -#include "memory.h" +#include "exec/memory.h" #include "hw/irq.h" struct soc_dma_s; diff --git a/hw/spapr.c b/hw/spapr.c index 395c4ac69b..d1252fc68c 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -47,7 +47,7 @@ #include "kvm_ppc.h" #include "pci/pci.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/usb.h" #include "qemu-config.h" diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c index 3011b251d3..fb968b250b 100644 --- a/hw/spapr_iommu.c +++ b/hw/spapr_iommu.c @@ -21,7 +21,7 @@ #include "qdev.h" #include "kvm_ppc.h" #include "dma.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "hw/spapr.h" diff --git a/hw/spapr_pci.c b/hw/spapr_pci.c index 786f6f4222..27b3ad3d60 100644 --- a/hw/spapr_pci.c +++ b/hw/spapr_pci.c @@ -29,7 +29,7 @@ #include "pci/pci_host.h" #include "hw/spapr.h" #include "hw/spapr_pci.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include #include "trace.h" diff --git a/hw/spitz.c b/hw/spitz.c index 1500161d44..48668a0f10 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -27,7 +27,7 @@ #include "boards.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #undef REG_FMT #define REG_FMT "0x%02lx" diff --git a/hw/stellaris.c b/hw/stellaris.c index f3eb4bbc01..368f8a5e73 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -15,7 +15,7 @@ #include "i2c.h" #include "net/net.h" #include "boards.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define GPIO_A 0 #define GPIO_B 1 diff --git a/hw/strongarm.h b/hw/strongarm.h index d30dd6ac5e..2893f94445 100644 --- a/hw/strongarm.h +++ b/hw/strongarm.h @@ -1,7 +1,7 @@ #ifndef _STRONGARM_H #define _STRONGARM_H -#include "memory.h" +#include "exec/memory.h" #define SA_CS0 0x00000000 #define SA_CS1 0x08000000 diff --git a/hw/sun4u.c b/hw/sun4u.c index d9e752fe83..000f6118e1 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -39,7 +39,7 @@ #include "loader.h" #include "elf.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" //#define DEBUG_IRQ //#define DEBUG_EBUS diff --git a/hw/sysbus.c b/hw/sysbus.c index ef8ffb6603..7ab250463c 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -19,7 +19,7 @@ #include "sysbus.h" #include "monitor.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent); static char *sysbus_get_fw_dev_path(DeviceState *dev); diff --git a/hw/sysbus.h b/hw/sysbus.h index e58baaae36..669cf87ae9 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -4,7 +4,7 @@ /* Devices attached directly to the main system bus. */ #include "qdev.h" -#include "memory.h" +#include "exec/memory.h" #define QDEV_MAX_MMIO 32 #define QDEV_MAX_PIO 32 diff --git a/hw/tosa.c b/hw/tosa.c index 3991a909b5..6fdbec53ee 100644 --- a/hw/tosa.c +++ b/hw/tosa.c @@ -23,7 +23,7 @@ #include "ssi.h" #include "blockdev.h" #include "sysbus.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define TOSA_RAM 0x04000000 #define TOSA_ROM 0x00800000 diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c index 24d3cad3a2..672d7a5598 100644 --- a/hw/usb/libhw.c +++ b/hw/usb/libhw.c @@ -20,7 +20,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "cpu-common.h" +#include "exec/cpu-common.h" #include "hw/usb.h" #include "dma.h" diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index 7a543b47d0..1f4d66934c 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -10,7 +10,7 @@ #include "sysbus.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef struct { SysBusDevice busdev; diff --git a/hw/versatilepb.c b/hw/versatilepb.c index af398d9cca..bd9c01564a 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -16,7 +16,7 @@ #include "i2c.h" #include "boards.h" #include "blockdev.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "flash.h" #define VERSATILE_FLASH_ADDR 0x34000000 diff --git a/hw/vexpress.c b/hw/vexpress.c index 5c9c08b991..e7b9e93852 100644 --- a/hw/vexpress.c +++ b/hw/vexpress.c @@ -28,7 +28,7 @@ #include "net/net.h" #include "sysemu.h" #include "boards.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "blockdev.h" #include "flash.h" diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 264e58a68b..096621cdbd 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -28,9 +28,9 @@ #include "config.h" #include "event_notifier.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "kvm.h" -#include "memory.h" +#include "exec/memory.h" #include "pci/msi.h" #include "pci/msix.h" #include "pci/pci.h" diff --git a/hw/vga_int.h b/hw/vga_int.h index 5efaee81d9..8d496ea9bf 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -26,7 +26,7 @@ #include #include "qapi/error.h" -#include "memory.h" +#include "exec/memory.h" #define ST01_V_RETRACE 0x08 #define ST01_DISP_ENABLE 0x01 diff --git a/hw/vhost.c b/hw/vhost.c index 16322a14f4..feaff64c15 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -18,7 +18,7 @@ #include "hw/hw.h" #include "range.h" #include -#include "exec-memory.h" +#include "exec/address-spaces.h" static void vhost_dev_sync_region(struct vhost_dev *dev, MemoryRegionSection *section, diff --git a/hw/vhost.h b/hw/vhost.h index 0c47229f91..6f6a906f4f 100644 --- a/hw/vhost.h +++ b/hw/vhost.h @@ -3,7 +3,7 @@ #include "hw/hw.h" #include "hw/virtio.h" -#include "memory.h" +#include "exec/memory.h" /* Generic structures common for any vhost based device. */ struct vhost_virtqueue { diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 1fdbc497cc..0f27c2b414 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -33,7 +33,7 @@ #include "loader.h" #include "elf.h" #include "qemu-log.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "ppc.h" #include "ppc4xx.h" diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index dd1a6506cf..97d3a932d9 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -21,7 +21,7 @@ #include "balloon.h" #include "virtio-balloon.h" #include "kvm.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #if defined(__linux__) #include diff --git a/hw/vt82c686.c b/hw/vt82c686.c index f963912112..edceb5a01d 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -24,7 +24,7 @@ #include "pm_smbus.h" #include "sysemu.h" #include "qemu-timer.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" typedef uint32_t pci_addr_t; #include "pci/pci_host.h" diff --git a/hw/xen_platform.c b/hw/xen_platform.c index 023499eb55..e7611bb353 100644 --- a/hw/xen_platform.c +++ b/hw/xen_platform.c @@ -32,7 +32,7 @@ #include "xen_common.h" #include "xen_backend.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include diff --git a/hw/xen_pt.c b/hw/xen_pt.c index c782cdb283..5c50d562d9 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -59,7 +59,7 @@ #include "xen_backend.h" #include "xen_pt.h" #include "range.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #define XEN_PT_NR_IRQS (256) static uint8_t xen_pt_mapped_machine_irq[XEN_PT_NR_IRQS] = {0}; diff --git a/hw/xilinx_zynq.c b/hw/xilinx_zynq.c index 67adc52725..156648a5d1 100644 --- a/hw/xilinx_zynq.c +++ b/hw/xilinx_zynq.c @@ -18,7 +18,7 @@ #include "sysbus.h" #include "arm-misc.h" #include "net/net.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include "sysemu.h" #include "boards.h" #include "flash.h" diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index 0399de777e..c6c880eba5 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -29,8 +29,8 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "serial.h" #include "net/net.h" #include "sysbus.h" diff --git a/hw/xtensa_sim.c b/hw/xtensa_sim.c index 0d633e4724..29b5f22a18 100644 --- a/hw/xtensa_sim.c +++ b/hw/xtensa_sim.c @@ -29,8 +29,8 @@ #include "boards.h" #include "loader.h" #include "elf.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" static uint64_t translate_phys_addr(void *env, uint64_t addr) { diff --git a/hw/z2.c b/hw/z2.c index d46186430f..ec35f3e444 100644 --- a/hw/z2.c +++ b/hw/z2.c @@ -23,7 +23,7 @@ #include "blockdev.h" #include "ui/console.h" #include "audio/audio.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #ifdef DEBUG_Z2 #define DPRINTF(fmt, ...) \ diff --git a/hwaddr.h b/hwaddr.h deleted file mode 100644 index 251cf9216f..0000000000 --- a/hwaddr.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Define hwaddr if it exists. */ - -#ifndef HWADDR_H -#define HWADDR_H - -#ifndef CONFIG_USER_ONLY - -#define HWADDR_BITS 64 -/* hwaddr is the type of a physical address (its size can - be different from 'target_ulong'). */ - -typedef uint64_t hwaddr; -#define HWADDR_MAX UINT64_MAX -#define TARGET_FMT_plx "%016" PRIx64 -#define HWADDR_PRId PRId64 -#define HWADDR_PRIi PRIi64 -#define HWADDR_PRIo PRIo64 -#define HWADDR_PRIu PRIu64 -#define HWADDR_PRIx PRIx64 -#define HWADDR_PRIX PRIX64 - -#endif - -#endif diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h new file mode 100644 index 0000000000..3d12cddeec --- /dev/null +++ b/include/exec/address-spaces.h @@ -0,0 +1,41 @@ +/* + * Internal memory management interfaces + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef EXEC_MEMORY_H +#define EXEC_MEMORY_H + +/* + * Internal interfaces between memory.c/exec.c/vl.c. Do not #include unless + * you're one of them. + */ + +#include "exec/memory.h" + +#ifndef CONFIG_USER_ONLY + +/* Get the root memory region. This interface should only be used temporarily + * until a proper bus interface is available. + */ +MemoryRegion *get_system_memory(void); + +/* Get the root I/O port region. This interface should only be used + * temporarily until a proper bus interface is available. + */ +MemoryRegion *get_system_io(void); + +extern AddressSpace address_space_memory; +extern AddressSpace address_space_io; + +#endif + +#endif diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h new file mode 100644 index 0000000000..bec04e2008 --- /dev/null +++ b/include/exec/cpu-all.h @@ -0,0 +1,522 @@ +/* + * defines common to all virtual CPUs + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef CPU_ALL_H +#define CPU_ALL_H + +#include "qemu-common.h" +#include "qemu-tls.h" +#include "exec/cpu-common.h" + +/* some important defines: + * + * WORDS_ALIGNED : if defined, the host cpu can only make word aligned + * memory accesses. + * + * HOST_WORDS_BIGENDIAN : if defined, the host cpu is big endian and + * otherwise little endian. + * + * (TARGET_WORDS_ALIGNED : same for target cpu (not supported yet)) + * + * TARGET_WORDS_BIGENDIAN : same for target cpu + */ + +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) +#define BSWAP_NEEDED +#endif + +#ifdef BSWAP_NEEDED + +static inline uint16_t tswap16(uint16_t s) +{ + return bswap16(s); +} + +static inline uint32_t tswap32(uint32_t s) +{ + return bswap32(s); +} + +static inline uint64_t tswap64(uint64_t s) +{ + return bswap64(s); +} + +static inline void tswap16s(uint16_t *s) +{ + *s = bswap16(*s); +} + +static inline void tswap32s(uint32_t *s) +{ + *s = bswap32(*s); +} + +static inline void tswap64s(uint64_t *s) +{ + *s = bswap64(*s); +} + +#else + +static inline uint16_t tswap16(uint16_t s) +{ + return s; +} + +static inline uint32_t tswap32(uint32_t s) +{ + return s; +} + +static inline uint64_t tswap64(uint64_t s) +{ + return s; +} + +static inline void tswap16s(uint16_t *s) +{ +} + +static inline void tswap32s(uint32_t *s) +{ +} + +static inline void tswap64s(uint64_t *s) +{ +} + +#endif + +#if TARGET_LONG_SIZE == 4 +#define tswapl(s) tswap32(s) +#define tswapls(s) tswap32s((uint32_t *)(s)) +#define bswaptls(s) bswap32s(s) +#else +#define tswapl(s) tswap64(s) +#define tswapls(s) tswap64s((uint64_t *)(s)) +#define bswaptls(s) bswap64s(s) +#endif + +/* CPU memory access without any memory or io remapping */ + +/* + * the generic syntax for the memory accesses is: + * + * load: ld{type}{sign}{size}{endian}_{access_type}(ptr) + * + * store: st{type}{size}{endian}_{access_type}(ptr, val) + * + * type is: + * (empty): integer access + * f : float access + * + * sign is: + * (empty): for floats or 32 bit size + * u : unsigned + * s : signed + * + * size is: + * b: 8 bits + * w: 16 bits + * l: 32 bits + * q: 64 bits + * + * endian is: + * (empty): target cpu endianness or 8 bit access + * r : reversed target cpu endianness (not implemented yet) + * be : big endian (not implemented yet) + * le : little endian (not implemented yet) + * + * access_type is: + * raw : host memory access + * user : user mode access using soft MMU + * kernel : kernel mode access using soft MMU + */ + +/* target-endianness CPU memory access functions */ +#if defined(TARGET_WORDS_BIGENDIAN) +#define lduw_p(p) lduw_be_p(p) +#define ldsw_p(p) ldsw_be_p(p) +#define ldl_p(p) ldl_be_p(p) +#define ldq_p(p) ldq_be_p(p) +#define ldfl_p(p) ldfl_be_p(p) +#define ldfq_p(p) ldfq_be_p(p) +#define stw_p(p, v) stw_be_p(p, v) +#define stl_p(p, v) stl_be_p(p, v) +#define stq_p(p, v) stq_be_p(p, v) +#define stfl_p(p, v) stfl_be_p(p, v) +#define stfq_p(p, v) stfq_be_p(p, v) +#else +#define lduw_p(p) lduw_le_p(p) +#define ldsw_p(p) ldsw_le_p(p) +#define ldl_p(p) ldl_le_p(p) +#define ldq_p(p) ldq_le_p(p) +#define ldfl_p(p) ldfl_le_p(p) +#define ldfq_p(p) ldfq_le_p(p) +#define stw_p(p, v) stw_le_p(p, v) +#define stl_p(p, v) stl_le_p(p, v) +#define stq_p(p, v) stq_le_p(p, v) +#define stfl_p(p, v) stfl_le_p(p, v) +#define stfq_p(p, v) stfq_le_p(p, v) +#endif + +/* MMU memory access macros */ + +#if defined(CONFIG_USER_ONLY) +#include +#include "exec/user/abitypes.h" + +/* On some host systems the guest address space is reserved on the host. + * This allows the guest address space to be offset to a convenient location. + */ +#if defined(CONFIG_USE_GUEST_BASE) +extern unsigned long guest_base; +extern int have_guest_base; +extern unsigned long reserved_va; +#define GUEST_BASE guest_base +#define RESERVED_VA reserved_va +#else +#define GUEST_BASE 0ul +#define RESERVED_VA 0ul +#endif + +/* All direct uses of g2h and h2g need to go away for usermode softmmu. */ +#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE)) + +#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS +#define h2g_valid(x) 1 +#else +#define h2g_valid(x) ({ \ + unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ + (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \ + (!RESERVED_VA || (__guest < RESERVED_VA)); \ +}) +#endif + +#define h2g(x) ({ \ + unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ + /* Check if given address fits target address space */ \ + assert(h2g_valid(x)); \ + (abi_ulong)__ret; \ +}) + +#define saddr(x) g2h(x) +#define laddr(x) g2h(x) + +#else /* !CONFIG_USER_ONLY */ +/* NOTE: we use double casts if pointers and target_ulong have + different sizes */ +#define saddr(x) (uint8_t *)(intptr_t)(x) +#define laddr(x) (uint8_t *)(intptr_t)(x) +#endif + +#define ldub_raw(p) ldub_p(laddr((p))) +#define ldsb_raw(p) ldsb_p(laddr((p))) +#define lduw_raw(p) lduw_p(laddr((p))) +#define ldsw_raw(p) ldsw_p(laddr((p))) +#define ldl_raw(p) ldl_p(laddr((p))) +#define ldq_raw(p) ldq_p(laddr((p))) +#define ldfl_raw(p) ldfl_p(laddr((p))) +#define ldfq_raw(p) ldfq_p(laddr((p))) +#define stb_raw(p, v) stb_p(saddr((p)), v) +#define stw_raw(p, v) stw_p(saddr((p)), v) +#define stl_raw(p, v) stl_p(saddr((p)), v) +#define stq_raw(p, v) stq_p(saddr((p)), v) +#define stfl_raw(p, v) stfl_p(saddr((p)), v) +#define stfq_raw(p, v) stfq_p(saddr((p)), v) + + +#if defined(CONFIG_USER_ONLY) + +/* if user mode, no other memory access functions */ +#define ldub(p) ldub_raw(p) +#define ldsb(p) ldsb_raw(p) +#define lduw(p) lduw_raw(p) +#define ldsw(p) ldsw_raw(p) +#define ldl(p) ldl_raw(p) +#define ldq(p) ldq_raw(p) +#define ldfl(p) ldfl_raw(p) +#define ldfq(p) ldfq_raw(p) +#define stb(p, v) stb_raw(p, v) +#define stw(p, v) stw_raw(p, v) +#define stl(p, v) stl_raw(p, v) +#define stq(p, v) stq_raw(p, v) +#define stfl(p, v) stfl_raw(p, v) +#define stfq(p, v) stfq_raw(p, v) + +#define cpu_ldub_code(env1, p) ldub_raw(p) +#define cpu_ldsb_code(env1, p) ldsb_raw(p) +#define cpu_lduw_code(env1, p) lduw_raw(p) +#define cpu_ldsw_code(env1, p) ldsw_raw(p) +#define cpu_ldl_code(env1, p) ldl_raw(p) +#define cpu_ldq_code(env1, p) ldq_raw(p) + +#define cpu_ldub_data(env, addr) ldub_raw(addr) +#define cpu_lduw_data(env, addr) lduw_raw(addr) +#define cpu_ldsw_data(env, addr) ldsw_raw(addr) +#define cpu_ldl_data(env, addr) ldl_raw(addr) +#define cpu_ldq_data(env, addr) ldq_raw(addr) + +#define cpu_stb_data(env, addr, data) stb_raw(addr, data) +#define cpu_stw_data(env, addr, data) stw_raw(addr, data) +#define cpu_stl_data(env, addr, data) stl_raw(addr, data) +#define cpu_stq_data(env, addr, data) stq_raw(addr, data) + +#define cpu_ldub_kernel(env, addr) ldub_raw(addr) +#define cpu_lduw_kernel(env, addr) lduw_raw(addr) +#define cpu_ldsw_kernel(env, addr) ldsw_raw(addr) +#define cpu_ldl_kernel(env, addr) ldl_raw(addr) +#define cpu_ldq_kernel(env, addr) ldq_raw(addr) + +#define cpu_stb_kernel(env, addr, data) stb_raw(addr, data) +#define cpu_stw_kernel(env, addr, data) stw_raw(addr, data) +#define cpu_stl_kernel(env, addr, data) stl_raw(addr, data) +#define cpu_stq_kernel(env, addr, data) stq_raw(addr, data) + +#define ldub_kernel(p) ldub_raw(p) +#define ldsb_kernel(p) ldsb_raw(p) +#define lduw_kernel(p) lduw_raw(p) +#define ldsw_kernel(p) ldsw_raw(p) +#define ldl_kernel(p) ldl_raw(p) +#define ldq_kernel(p) ldq_raw(p) +#define ldfl_kernel(p) ldfl_raw(p) +#define ldfq_kernel(p) ldfq_raw(p) +#define stb_kernel(p, v) stb_raw(p, v) +#define stw_kernel(p, v) stw_raw(p, v) +#define stl_kernel(p, v) stl_raw(p, v) +#define stq_kernel(p, v) stq_raw(p, v) +#define stfl_kernel(p, v) stfl_raw(p, v) +#define stfq_kernel(p, vt) stfq_raw(p, v) + +#define cpu_ldub_data(env, addr) ldub_raw(addr) +#define cpu_lduw_data(env, addr) lduw_raw(addr) +#define cpu_ldl_data(env, addr) ldl_raw(addr) + +#define cpu_stb_data(env, addr, data) stb_raw(addr, data) +#define cpu_stw_data(env, addr, data) stw_raw(addr, data) +#define cpu_stl_data(env, addr, data) stl_raw(addr, data) +#endif /* defined(CONFIG_USER_ONLY) */ + +/* page related stuff */ + +#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) +#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) + +/* ??? These should be the larger of uintptr_t and target_ulong. */ +extern uintptr_t qemu_real_host_page_size; +extern uintptr_t qemu_host_page_size; +extern uintptr_t qemu_host_page_mask; + +#define HOST_PAGE_ALIGN(addr) (((addr) + qemu_host_page_size - 1) & qemu_host_page_mask) + +/* same as PROT_xxx */ +#define PAGE_READ 0x0001 +#define PAGE_WRITE 0x0002 +#define PAGE_EXEC 0x0004 +#define PAGE_BITS (PAGE_READ | PAGE_WRITE | PAGE_EXEC) +#define PAGE_VALID 0x0008 +/* original state of the write flag (used when tracking self-modifying + code */ +#define PAGE_WRITE_ORG 0x0010 +#if defined(CONFIG_BSD) && defined(CONFIG_USER_ONLY) +/* FIXME: Code that sets/uses this is broken and needs to go away. */ +#define PAGE_RESERVED 0x0020 +#endif + +#if defined(CONFIG_USER_ONLY) +void page_dump(FILE *f); + +typedef int (*walk_memory_regions_fn)(void *, abi_ulong, + abi_ulong, unsigned long); +int walk_memory_regions(void *, walk_memory_regions_fn); + +int page_get_flags(target_ulong address); +void page_set_flags(target_ulong start, target_ulong end, int flags); +int page_check_range(target_ulong start, target_ulong len, int flags); +#endif + +CPUArchState *cpu_copy(CPUArchState *env); +CPUArchState *qemu_get_cpu(int cpu); + +#define CPU_DUMP_CODE 0x00010000 +#define CPU_DUMP_FPU 0x00020000 /* dump FPU register state, not just integer */ +/* dump info about TCG QEMU's condition code optimization state */ +#define CPU_DUMP_CCOP 0x00040000 + +void cpu_dump_state(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, + int flags); +void cpu_dump_statistics(CPUArchState *env, FILE *f, fprintf_function cpu_fprintf, + int flags); + +void QEMU_NORETURN cpu_abort(CPUArchState *env, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); +extern CPUArchState *first_cpu; +DECLARE_TLS(CPUArchState *,cpu_single_env); +#define cpu_single_env tls_var(cpu_single_env) + +/* Flags for use in ENV->INTERRUPT_PENDING. + + The numbers assigned here are non-sequential in order to preserve + binary compatibility with the vmstate dump. Bit 0 (0x0001) was + previously used for CPU_INTERRUPT_EXIT, and is cleared when loading + the vmstate dump. */ + +/* External hardware interrupt pending. This is typically used for + interrupts from devices. */ +#define CPU_INTERRUPT_HARD 0x0002 + +/* Exit the current TB. This is typically used when some system-level device + makes some change to the memory mapping. E.g. the a20 line change. */ +#define CPU_INTERRUPT_EXITTB 0x0004 + +/* Halt the CPU. */ +#define CPU_INTERRUPT_HALT 0x0020 + +/* Debug event pending. */ +#define CPU_INTERRUPT_DEBUG 0x0080 + +/* Several target-specific external hardware interrupts. Each target/cpu.h + should define proper names based on these defines. */ +#define CPU_INTERRUPT_TGT_EXT_0 0x0008 +#define CPU_INTERRUPT_TGT_EXT_1 0x0010 +#define CPU_INTERRUPT_TGT_EXT_2 0x0040 +#define CPU_INTERRUPT_TGT_EXT_3 0x0200 +#define CPU_INTERRUPT_TGT_EXT_4 0x1000 + +/* Several target-specific internal interrupts. These differ from the + preceding target-specific interrupts in that they are intended to + originate from within the cpu itself, typically in response to some + instruction being executed. These, therefore, are not masked while + single-stepping within the debugger. */ +#define CPU_INTERRUPT_TGT_INT_0 0x0100 +#define CPU_INTERRUPT_TGT_INT_1 0x0400 +#define CPU_INTERRUPT_TGT_INT_2 0x0800 +#define CPU_INTERRUPT_TGT_INT_3 0x2000 + +/* First unused bit: 0x4000. */ + +/* The set of all bits that should be masked when single-stepping. */ +#define CPU_INTERRUPT_SSTEP_MASK \ + (CPU_INTERRUPT_HARD \ + | CPU_INTERRUPT_TGT_EXT_0 \ + | CPU_INTERRUPT_TGT_EXT_1 \ + | CPU_INTERRUPT_TGT_EXT_2 \ + | CPU_INTERRUPT_TGT_EXT_3 \ + | CPU_INTERRUPT_TGT_EXT_4) + +#ifndef CONFIG_USER_ONLY +typedef void (*CPUInterruptHandler)(CPUArchState *, int); + +extern CPUInterruptHandler cpu_interrupt_handler; + +static inline void cpu_interrupt(CPUArchState *s, int mask) +{ + cpu_interrupt_handler(s, mask); +} +#else /* USER_ONLY */ +void cpu_interrupt(CPUArchState *env, int mask); +#endif /* USER_ONLY */ + +void cpu_reset_interrupt(CPUArchState *env, int mask); + +void cpu_exit(CPUArchState *s); + +/* Breakpoint/watchpoint flags */ +#define BP_MEM_READ 0x01 +#define BP_MEM_WRITE 0x02 +#define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE) +#define BP_STOP_BEFORE_ACCESS 0x04 +#define BP_WATCHPOINT_HIT 0x08 +#define BP_GDB 0x10 +#define BP_CPU 0x20 + +int cpu_breakpoint_insert(CPUArchState *env, target_ulong pc, int flags, + CPUBreakpoint **breakpoint); +int cpu_breakpoint_remove(CPUArchState *env, target_ulong pc, int flags); +void cpu_breakpoint_remove_by_ref(CPUArchState *env, CPUBreakpoint *breakpoint); +void cpu_breakpoint_remove_all(CPUArchState *env, int mask); +int cpu_watchpoint_insert(CPUArchState *env, target_ulong addr, target_ulong len, + int flags, CPUWatchpoint **watchpoint); +int cpu_watchpoint_remove(CPUArchState *env, target_ulong addr, + target_ulong len, int flags); +void cpu_watchpoint_remove_by_ref(CPUArchState *env, CPUWatchpoint *watchpoint); +void cpu_watchpoint_remove_all(CPUArchState *env, int mask); + +#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */ +#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */ +#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */ + +void cpu_single_step(CPUArchState *env, int enabled); + +#if !defined(CONFIG_USER_ONLY) + +/* Return the physical page corresponding to a virtual one. Use it + only for debugging because no protection checks are done. Return -1 + if no page found. */ +hwaddr cpu_get_phys_page_debug(CPUArchState *env, target_ulong addr); + +/* memory API */ + +extern int phys_ram_fd; +extern ram_addr_t ram_size; + +/* RAM is pre-allocated and passed into qemu_ram_alloc_from_ptr */ +#define RAM_PREALLOC_MASK (1 << 0) + +typedef struct RAMBlock { + struct MemoryRegion *mr; + uint8_t *host; + ram_addr_t offset; + ram_addr_t length; + uint32_t flags; + char idstr[256]; + QLIST_ENTRY(RAMBlock) next; +#if defined(__linux__) && !defined(TARGET_S390X) + int fd; +#endif +} RAMBlock; + +typedef struct RAMList { + uint8_t *phys_dirty; + QLIST_HEAD(, RAMBlock) blocks; +} RAMList; +extern RAMList ram_list; + +extern const char *mem_path; +extern int mem_prealloc; + +/* Flags stored in the low bits of the TLB virtual address. These are + defined so that fast path ram access is all zeros. */ +/* Zero if TLB entry is valid. */ +#define TLB_INVALID_MASK (1 << 3) +/* Set if TLB entry references a clean RAM page. The iotlb entry will + contain the page physical address. */ +#define TLB_NOTDIRTY (1 << 4) +/* Set if TLB entry is an IO callback. */ +#define TLB_MMIO (1 << 5) + +void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); +ram_addr_t last_ram_offset(void); +#endif /* !CONFIG_USER_ONLY */ + +int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, + uint8_t *buf, int len, int is_write); + +#endif /* CPU_ALL_H */ diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h new file mode 100644 index 0000000000..f83d6180f3 --- /dev/null +++ b/include/exec/cpu-common.h @@ -0,0 +1,112 @@ +#ifndef CPU_COMMON_H +#define CPU_COMMON_H 1 + +/* CPU interfaces that are target independent. */ + +#include "exec/hwaddr.h" + +#ifndef NEED_CPU_H +#include "exec/poison.h" +#endif + +#include "bswap.h" +#include "qemu-queue.h" + +#if !defined(CONFIG_USER_ONLY) + +enum device_endian { + DEVICE_NATIVE_ENDIAN, + DEVICE_BIG_ENDIAN, + DEVICE_LITTLE_ENDIAN, +}; + +/* address in the RAM (different from a physical address) */ +#if defined(CONFIG_XEN_BACKEND) +typedef uint64_t ram_addr_t; +# define RAM_ADDR_MAX UINT64_MAX +# define RAM_ADDR_FMT "%" PRIx64 +#else +typedef uintptr_t ram_addr_t; +# define RAM_ADDR_MAX UINTPTR_MAX +# define RAM_ADDR_FMT "%" PRIxPTR +#endif + +/* memory API */ + +typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value); +typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr); + +void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); +/* This should only be used for ram local to a device. */ +void *qemu_get_ram_ptr(ram_addr_t addr); +void qemu_put_ram_ptr(void *addr); +/* This should not be used by devices. */ +int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr); +ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); +void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev); + +void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, + int len, int is_write); +static inline void cpu_physical_memory_read(hwaddr addr, + void *buf, int len) +{ + cpu_physical_memory_rw(addr, buf, len, 0); +} +static inline void cpu_physical_memory_write(hwaddr addr, + const void *buf, int len) +{ + cpu_physical_memory_rw(addr, (void *)buf, len, 1); +} +void *cpu_physical_memory_map(hwaddr addr, + hwaddr *plen, + int is_write); +void cpu_physical_memory_unmap(void *buffer, hwaddr len, + int is_write, hwaddr access_len); +void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)); + +bool cpu_physical_memory_is_io(hwaddr phys_addr); + +/* Coalesced MMIO regions are areas where write operations can be reordered. + * This usually implies that write operations are side-effect free. This allows + * batching which can make a major impact on performance when using + * virtualization. + */ +void qemu_flush_coalesced_mmio_buffer(void); + +uint32_t ldub_phys(hwaddr addr); +uint32_t lduw_le_phys(hwaddr addr); +uint32_t lduw_be_phys(hwaddr addr); +uint32_t ldl_le_phys(hwaddr addr); +uint32_t ldl_be_phys(hwaddr addr); +uint64_t ldq_le_phys(hwaddr addr); +uint64_t ldq_be_phys(hwaddr addr); +void stb_phys(hwaddr addr, uint32_t val); +void stw_le_phys(hwaddr addr, uint32_t val); +void stw_be_phys(hwaddr addr, uint32_t val); +void stl_le_phys(hwaddr addr, uint32_t val); +void stl_be_phys(hwaddr addr, uint32_t val); +void stq_le_phys(hwaddr addr, uint64_t val); +void stq_be_phys(hwaddr addr, uint64_t val); + +#ifdef NEED_CPU_H +uint32_t lduw_phys(hwaddr addr); +uint32_t ldl_phys(hwaddr addr); +uint64_t ldq_phys(hwaddr addr); +void stl_phys_notdirty(hwaddr addr, uint32_t val); +void stq_phys_notdirty(hwaddr addr, uint64_t val); +void stw_phys(hwaddr addr, uint32_t val); +void stl_phys(hwaddr addr, uint32_t val); +void stq_phys(hwaddr addr, uint64_t val); +#endif + +void cpu_physical_memory_write_rom(hwaddr addr, + const uint8_t *buf, int len); + +extern struct MemoryRegion io_mem_ram; +extern struct MemoryRegion io_mem_rom; +extern struct MemoryRegion io_mem_unassigned; +extern struct MemoryRegion io_mem_notdirty; + +#endif + +#endif /* !CPU_COMMON_H */ diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h new file mode 100644 index 0000000000..8d2230e50e --- /dev/null +++ b/include/exec/cpu-defs.h @@ -0,0 +1,213 @@ +/* + * common defines for all CPUs + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef CPU_DEFS_H +#define CPU_DEFS_H + +#ifndef NEED_CPU_H +#error cpu.h included from common code +#endif + +#include "config.h" +#include +#include +#include +#include "osdep.h" +#include "qemu-queue.h" +#include "exec/hwaddr.h" + +#ifndef TARGET_LONG_BITS +#error TARGET_LONG_BITS must be defined before including this header +#endif + +#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) + +typedef int16_t target_short __attribute__ ((aligned(TARGET_SHORT_ALIGNMENT))); +typedef uint16_t target_ushort __attribute__((aligned(TARGET_SHORT_ALIGNMENT))); +typedef int32_t target_int __attribute__((aligned(TARGET_INT_ALIGNMENT))); +typedef uint32_t target_uint __attribute__((aligned(TARGET_INT_ALIGNMENT))); +typedef int64_t target_llong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); +typedef uint64_t target_ullong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); +/* target_ulong is the type of a virtual address */ +#if TARGET_LONG_SIZE == 4 +typedef int32_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +typedef uint32_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +#define TARGET_FMT_lx "%08x" +#define TARGET_FMT_ld "%d" +#define TARGET_FMT_lu "%u" +#elif TARGET_LONG_SIZE == 8 +typedef int64_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +#define TARGET_FMT_lx "%016" PRIx64 +#define TARGET_FMT_ld "%" PRId64 +#define TARGET_FMT_lu "%" PRIu64 +#else +#error TARGET_LONG_SIZE undefined +#endif + +#define EXCP_INTERRUPT 0x10000 /* async interruption */ +#define EXCP_HLT 0x10001 /* hlt instruction reached */ +#define EXCP_DEBUG 0x10002 /* cpu stopped after a breakpoint or singlestep */ +#define EXCP_HALTED 0x10003 /* cpu is halted (waiting for external event) */ + +#define TB_JMP_CACHE_BITS 12 +#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) + +/* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for + addresses on the same page. The top bits are the same. This allows + TLB invalidation to quickly clear a subset of the hash table. */ +#define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2) +#define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS) +#define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) +#define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE) + +#if !defined(CONFIG_USER_ONLY) +#define CPU_TLB_BITS 8 +#define CPU_TLB_SIZE (1 << CPU_TLB_BITS) + +#if HOST_LONG_BITS == 32 && TARGET_LONG_BITS == 32 +#define CPU_TLB_ENTRY_BITS 4 +#else +#define CPU_TLB_ENTRY_BITS 5 +#endif + +typedef struct CPUTLBEntry { + /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address + bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not + go directly to ram. + bit 3 : indicates that the entry is invalid + bit 2..0 : zero + */ + target_ulong addr_read; + target_ulong addr_write; + target_ulong addr_code; + /* Addend to virtual address to get host address. IO accesses + use the corresponding iotlb value. */ + uintptr_t addend; + /* padding to get a power of two size */ + uint8_t dummy[(1 << CPU_TLB_ENTRY_BITS) - + (sizeof(target_ulong) * 3 + + ((-sizeof(target_ulong) * 3) & (sizeof(uintptr_t) - 1)) + + sizeof(uintptr_t))]; +} CPUTLBEntry; + +extern int CPUTLBEntry_wrong_size[sizeof(CPUTLBEntry) == (1 << CPU_TLB_ENTRY_BITS) ? 1 : -1]; + +#define CPU_COMMON_TLB \ + /* The meaning of the MMU modes is defined in the target code. */ \ + CPUTLBEntry tlb_table[NB_MMU_MODES][CPU_TLB_SIZE]; \ + hwaddr iotlb[NB_MMU_MODES][CPU_TLB_SIZE]; \ + target_ulong tlb_flush_addr; \ + target_ulong tlb_flush_mask; + +#else + +#define CPU_COMMON_TLB + +#endif + + +#ifdef HOST_WORDS_BIGENDIAN +typedef struct icount_decr_u16 { + uint16_t high; + uint16_t low; +} icount_decr_u16; +#else +typedef struct icount_decr_u16 { + uint16_t low; + uint16_t high; +} icount_decr_u16; +#endif + +struct kvm_run; +struct KVMState; +struct qemu_work_item; + +typedef struct CPUBreakpoint { + target_ulong pc; + int flags; /* BP_* */ + QTAILQ_ENTRY(CPUBreakpoint) entry; +} CPUBreakpoint; + +typedef struct CPUWatchpoint { + target_ulong vaddr; + target_ulong len_mask; + int flags; /* BP_* */ + QTAILQ_ENTRY(CPUWatchpoint) entry; +} CPUWatchpoint; + +#define CPU_TEMP_BUF_NLONGS 128 +#define CPU_COMMON \ + struct TranslationBlock *current_tb; /* currently executing TB */ \ + /* soft mmu support */ \ + /* in order to avoid passing too many arguments to the MMIO \ + helpers, we store some rarely used information in the CPU \ + context) */ \ + uintptr_t mem_io_pc; /* host pc at which the memory was \ + accessed */ \ + target_ulong mem_io_vaddr; /* target virtual addr at which the \ + memory was accessed */ \ + uint32_t halted; /* Nonzero if the CPU is in suspend state */ \ + uint32_t interrupt_request; \ + volatile sig_atomic_t exit_request; \ + CPU_COMMON_TLB \ + struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE]; \ + /* buffer for temporaries in the code generator */ \ + long temp_buf[CPU_TEMP_BUF_NLONGS]; \ + \ + int64_t icount_extra; /* Instructions until next timer event. */ \ + /* Number of cycles left, with interrupt flag in high bit. \ + This allows a single read-compare-cbranch-write sequence to test \ + for both decrementer underflow and exceptions. */ \ + union { \ + uint32_t u32; \ + icount_decr_u16 u16; \ + } icount_decr; \ + uint32_t can_do_io; /* nonzero if memory mapped IO is safe. */ \ + \ + /* from this point: preserved by CPU reset */ \ + /* ice debug support */ \ + QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ + int singlestep_enabled; \ + \ + QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ + CPUWatchpoint *watchpoint_hit; \ + \ + struct GDBRegisterState *gdb_regs; \ + \ + /* Core interrupt code */ \ + jmp_buf jmp_env; \ + int exception_index; \ + \ + CPUArchState *next_cpu; /* next CPU sharing TB cache */ \ + int cpu_index; /* CPU index (informative) */ \ + uint32_t host_tid; /* host thread ID */ \ + int numa_node; /* NUMA node this cpu is belonging to */ \ + int nr_cores; /* number of cores within this CPU package */ \ + int nr_threads;/* number of threads within this CPU */ \ + int running; /* Nonzero if cpu is currently running(usermode). */ \ + /* user data */ \ + void *opaque; \ + \ + const char *cpu_model_str; \ + struct KVMState *kvm_state; \ + struct kvm_run *kvm_run; \ + int kvm_fd; \ + int kvm_vcpu_dirty; + +#endif diff --git a/include/exec/cputlb.h b/include/exec/cputlb.h new file mode 100644 index 0000000000..733c885a1f --- /dev/null +++ b/include/exec/cputlb.h @@ -0,0 +1,46 @@ +/* + * Common CPU TLB handling + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef CPUTLB_H +#define CPUTLB_H + +#if !defined(CONFIG_USER_ONLY) +/* cputlb.c */ +void tlb_protect_code(ram_addr_t ram_addr); +void tlb_unprotect_code_phys(CPUArchState *env, ram_addr_t ram_addr, + target_ulong vaddr); +void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start, + uintptr_t length); +MemoryRegionSection *phys_page_find(struct AddressSpaceDispatch *d, + hwaddr index); +void cpu_tlb_reset_dirty_all(ram_addr_t start1, ram_addr_t length); +void tlb_set_dirty(CPUArchState *env, target_ulong vaddr); +extern int tlb_flush_count; + +/* exec.c */ +void tb_flush_jmp_cache(CPUArchState *env, target_ulong addr); +hwaddr memory_region_section_get_iotlb(CPUArchState *env, + MemoryRegionSection *section, + target_ulong vaddr, + hwaddr paddr, + int prot, + target_ulong *address); +bool memory_region_is_unassigned(MemoryRegion *mr); + +#endif +#endif diff --git a/include/exec/def-helper.h b/include/exec/def-helper.h new file mode 100644 index 0000000000..022a9ceb6a --- /dev/null +++ b/include/exec/def-helper.h @@ -0,0 +1,275 @@ +/* Helper file for declaring TCG helper functions. + Should be included at the start and end of target-foo/helper.h. + + Targets should use DEF_HELPER_N and DEF_HELPER_FLAGS_N to declare helper + functions. Names should be specified without the helper_ prefix, and + the return and argument types specified. 3 basic types are understood + (i32, i64 and ptr). Additional aliases are provided for convenience and + to match the types used by the C helper implementation. + + The target helper.h should be included in all files that use/define + helper functions. THis will ensure that function prototypes are + consistent. In addition it should be included an extra two times for + helper.c, defining: + GEN_HELPER 1 to produce op generation functions (gen_helper_*) + GEN_HELPER 2 to do runtime registration helper functions. + */ + +#ifndef DEF_HELPER_H +#define DEF_HELPER_H 1 + +#define HELPER(name) glue(helper_, name) + +#define GET_TCGV_i32 GET_TCGV_I32 +#define GET_TCGV_i64 GET_TCGV_I64 +#define GET_TCGV_ptr GET_TCGV_PTR + +/* Some types that make sense in C, but not for TCG. */ +#define dh_alias_i32 i32 +#define dh_alias_s32 i32 +#define dh_alias_int i32 +#define dh_alias_i64 i64 +#define dh_alias_s64 i64 +#define dh_alias_f32 i32 +#define dh_alias_f64 i64 +#if TARGET_LONG_BITS == 32 +#define dh_alias_tl i32 +#else +#define dh_alias_tl i64 +#endif +#define dh_alias_ptr ptr +#define dh_alias_void void +#define dh_alias_noreturn noreturn +#define dh_alias_env ptr +#define dh_alias(t) glue(dh_alias_, t) + +#define dh_ctype_i32 uint32_t +#define dh_ctype_s32 int32_t +#define dh_ctype_int int +#define dh_ctype_i64 uint64_t +#define dh_ctype_s64 int64_t +#define dh_ctype_f32 float32 +#define dh_ctype_f64 float64 +#define dh_ctype_tl target_ulong +#define dh_ctype_ptr void * +#define dh_ctype_void void +#define dh_ctype_noreturn void QEMU_NORETURN +#define dh_ctype_env CPUArchState * +#define dh_ctype(t) dh_ctype_##t + +/* We can't use glue() here because it falls foul of C preprocessor + recursive expansion rules. */ +#define dh_retvar_decl0_void void +#define dh_retvar_decl0_noreturn void +#define dh_retvar_decl0_i32 TCGv_i32 retval +#define dh_retvar_decl0_i64 TCGv_i64 retval +#define dh_retvar_decl0_ptr TCGv_ptr retval +#define dh_retvar_decl0(t) glue(dh_retvar_decl0_, dh_alias(t)) + +#define dh_retvar_decl_void +#define dh_retvar_decl_noreturn +#define dh_retvar_decl_i32 TCGv_i32 retval, +#define dh_retvar_decl_i64 TCGv_i64 retval, +#define dh_retvar_decl_ptr TCGv_ptr retval, +#define dh_retvar_decl(t) glue(dh_retvar_decl_, dh_alias(t)) + +#define dh_retvar_void TCG_CALL_DUMMY_ARG +#define dh_retvar_noreturn TCG_CALL_DUMMY_ARG +#define dh_retvar_i32 GET_TCGV_i32(retval) +#define dh_retvar_i64 GET_TCGV_i64(retval) +#define dh_retvar_ptr GET_TCGV_ptr(retval) +#define dh_retvar(t) glue(dh_retvar_, dh_alias(t)) + +#define dh_is_64bit_void 0 +#define dh_is_64bit_noreturn 0 +#define dh_is_64bit_i32 0 +#define dh_is_64bit_i64 1 +#define dh_is_64bit_ptr (TCG_TARGET_REG_BITS == 64) +#define dh_is_64bit(t) glue(dh_is_64bit_, dh_alias(t)) + +#define dh_is_signed_void 0 +#define dh_is_signed_noreturn 0 +#define dh_is_signed_i32 0 +#define dh_is_signed_s32 1 +#define dh_is_signed_i64 0 +#define dh_is_signed_s64 1 +#define dh_is_signed_f32 0 +#define dh_is_signed_f64 0 +#define dh_is_signed_tl 0 +#define dh_is_signed_int 1 +/* ??? This is highly specific to the host cpu. There are even special + extension instructions that may be required, e.g. ia64's addp4. But + for now we don't support any 64-bit targets with 32-bit pointers. */ +#define dh_is_signed_ptr 0 +#define dh_is_signed_env dh_is_signed_ptr +#define dh_is_signed(t) dh_is_signed_##t + +#define dh_sizemask(t, n) \ + sizemask |= dh_is_64bit(t) << (n*2); \ + sizemask |= dh_is_signed(t) << (n*2+1) + +#define dh_arg(t, n) \ + args[n - 1] = glue(GET_TCGV_, dh_alias(t))(glue(arg, n)); \ + dh_sizemask(t, n) + +#define dh_arg_decl(t, n) glue(TCGv_, dh_alias(t)) glue(arg, n) + + +#define DEF_HELPER_0(name, ret) \ + DEF_HELPER_FLAGS_0(name, 0, ret) +#define DEF_HELPER_1(name, ret, t1) \ + DEF_HELPER_FLAGS_1(name, 0, ret, t1) +#define DEF_HELPER_2(name, ret, t1, t2) \ + DEF_HELPER_FLAGS_2(name, 0, ret, t1, t2) +#define DEF_HELPER_3(name, ret, t1, t2, t3) \ + DEF_HELPER_FLAGS_3(name, 0, ret, t1, t2, t3) +#define DEF_HELPER_4(name, ret, t1, t2, t3, t4) \ + DEF_HELPER_FLAGS_4(name, 0, ret, t1, t2, t3, t4) +#define DEF_HELPER_5(name, ret, t1, t2, t3, t4, t5) \ + DEF_HELPER_FLAGS_5(name, 0, ret, t1, t2, t3, t4, t5) + +/* MAX_OPC_PARAM_IARGS must be set to n if last entry is DEF_HELPER_FLAGS_n. */ + +#endif /* DEF_HELPER_H */ + +#ifndef GEN_HELPER +/* Function prototypes. */ + +#define DEF_HELPER_FLAGS_0(name, flags, ret) \ +dh_ctype(ret) HELPER(name) (void); + +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1)); + +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2)); + +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3)); + +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ + dh_ctype(t4)); + +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ +dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \ + dh_ctype(t4), dh_ctype(t5)); + +#undef GEN_HELPER +#define GEN_HELPER -1 + +#elif GEN_HELPER == 1 +/* Gen functions. */ + +#define DEF_HELPER_FLAGS_0(name, flags, ret) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl0(ret)) \ +{ \ + int sizemask; \ + sizemask = dh_is_64bit(ret); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 0, NULL); \ +} + +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1)) \ +{ \ + TCGArg args[1]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 1, args); \ +} + +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ + dh_arg_decl(t2, 2)) \ +{ \ + TCGArg args[2]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 2, args); \ +} + +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ + dh_arg_decl(t2, 2), dh_arg_decl(t3, 3)) \ +{ \ + TCGArg args[3]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + dh_arg(t3, 3); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 3, args); \ +} + +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) dh_arg_decl(t1, 1), \ + dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), dh_arg_decl(t4, 4)) \ +{ \ + TCGArg args[4]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + dh_arg(t3, 3); \ + dh_arg(t4, 4); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 4, args); \ +} + +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ +static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \ + dh_arg_decl(t1, 1), dh_arg_decl(t2, 2), dh_arg_decl(t3, 3), \ + dh_arg_decl(t4, 4), dh_arg_decl(t5, 5)) \ +{ \ + TCGArg args[5]; \ + int sizemask = 0; \ + dh_sizemask(ret, 0); \ + dh_arg(t1, 1); \ + dh_arg(t2, 2); \ + dh_arg(t3, 3); \ + dh_arg(t4, 4); \ + dh_arg(t5, 5); \ + tcg_gen_helperN(HELPER(name), flags, sizemask, dh_retvar(ret), 5, args); \ +} + +#undef GEN_HELPER +#define GEN_HELPER -1 + +#elif GEN_HELPER == 2 +/* Register helpers. */ + +#define DEF_HELPER_FLAGS_0(name, flags, ret) \ +tcg_register_helper(HELPER(name), #name); + +#define DEF_HELPER_FLAGS_1(name, flags, ret, t1) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_3(name, flags, ret, t1, t2, t3) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_4(name, flags, ret, t1, t2, t3, t4) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#define DEF_HELPER_FLAGS_5(name, flags, ret, t1, t2, t3, t4, t5) \ +DEF_HELPER_FLAGS_0(name, flags, ret) + +#undef GEN_HELPER +#define GEN_HELPER -1 + +#elif GEN_HELPER == -1 +/* Undefine macros. */ + +#undef DEF_HELPER_FLAGS_0 +#undef DEF_HELPER_FLAGS_1 +#undef DEF_HELPER_FLAGS_2 +#undef DEF_HELPER_FLAGS_3 +#undef DEF_HELPER_FLAGS_4 +#undef DEF_HELPER_FLAGS_5 +#undef GEN_HELPER + +#endif diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h new file mode 100644 index 0000000000..2ae8aae3d6 --- /dev/null +++ b/include/exec/exec-all.h @@ -0,0 +1,412 @@ +/* + * internal execution defines for qemu + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef _EXEC_ALL_H_ +#define _EXEC_ALL_H_ + +#include "qemu-common.h" + +/* allow to see translation results - the slowdown should be negligible, so we leave it */ +#define DEBUG_DISAS + +/* Page tracking code uses ram addresses in system mode, and virtual + addresses in userspace mode. Define tb_page_addr_t to be an appropriate + type. */ +#if defined(CONFIG_USER_ONLY) +typedef abi_ulong tb_page_addr_t; +#else +typedef ram_addr_t tb_page_addr_t; +#endif + +/* is_jmp field values */ +#define DISAS_NEXT 0 /* next instruction can be analyzed */ +#define DISAS_JUMP 1 /* only pc was modified dynamically */ +#define DISAS_UPDATE 2 /* cpu state was modified dynamically */ +#define DISAS_TB_JUMP 3 /* only pc was modified statically */ + +struct TranslationBlock; +typedef struct TranslationBlock TranslationBlock; + +/* XXX: make safe guess about sizes */ +#define MAX_OP_PER_INSTR 208 + +#if HOST_LONG_BITS == 32 +#define MAX_OPC_PARAM_PER_ARG 2 +#else +#define MAX_OPC_PARAM_PER_ARG 1 +#endif +#define MAX_OPC_PARAM_IARGS 5 +#define MAX_OPC_PARAM_OARGS 1 +#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) + +/* A Call op needs up to 4 + 2N parameters on 32-bit archs, + * and up to 4 + N parameters on 64-bit archs + * (N = number of input arguments + output arguments). */ +#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) +#define OPC_BUF_SIZE 640 +#define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR) + +/* Maximum size a TCG op can expand to. This is complicated because a + single op may require several host instructions and register reloads. + For now take a wild guess at 192 bytes, which should allow at least + a couple of fixup instructions per argument. */ +#define TCG_MAX_OP_SIZE 192 + +#define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) + +#include "qemu-log.h" + +void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); +void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); +void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb, + int pc_pos); + +void cpu_gen_init(void); +int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb, + int *gen_code_size_ptr); +bool cpu_restore_state(CPUArchState *env, uintptr_t searched_pc); + +void QEMU_NORETURN cpu_resume_from_signal(CPUArchState *env1, void *puc); +void QEMU_NORETURN cpu_io_recompile(CPUArchState *env, uintptr_t retaddr); +TranslationBlock *tb_gen_code(CPUArchState *env, + target_ulong pc, target_ulong cs_base, int flags, + int cflags); +void cpu_exec_init(CPUArchState *env); +void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1); +int page_unprotect(target_ulong address, uintptr_t pc, void *puc); +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access); +void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end, + int is_cpu_write_access); +#if !defined(CONFIG_USER_ONLY) +/* cputlb.c */ +void tlb_flush_page(CPUArchState *env, target_ulong addr); +void tlb_flush(CPUArchState *env, int flush_global); +void tlb_set_page(CPUArchState *env, target_ulong vaddr, + hwaddr paddr, int prot, + int mmu_idx, target_ulong size); +void tb_invalidate_phys_addr(hwaddr addr); +#else +static inline void tlb_flush_page(CPUArchState *env, target_ulong addr) +{ +} + +static inline void tlb_flush(CPUArchState *env, int flush_global) +{ +} +#endif + +#define CODE_GEN_ALIGN 16 /* must be >= of the size of a icache line */ + +#define CODE_GEN_PHYS_HASH_BITS 15 +#define CODE_GEN_PHYS_HASH_SIZE (1 << CODE_GEN_PHYS_HASH_BITS) + +/* estimated block size for TB allocation */ +/* XXX: use a per code average code fragment size and modulate it + according to the host CPU */ +#if defined(CONFIG_SOFTMMU) +#define CODE_GEN_AVG_BLOCK_SIZE 128 +#else +#define CODE_GEN_AVG_BLOCK_SIZE 64 +#endif + +#if defined(__arm__) || defined(_ARCH_PPC) \ + || defined(__x86_64__) || defined(__i386__) \ + || defined(__sparc__) \ + || defined(CONFIG_TCG_INTERPRETER) +#define USE_DIRECT_JUMP +#endif + +struct TranslationBlock { + target_ulong pc; /* simulated PC corresponding to this block (EIP + CS base) */ + target_ulong cs_base; /* CS base for this block */ + uint64_t flags; /* flags defining in which context the code was generated */ + uint16_t size; /* size of target code for this block (1 <= + size <= TARGET_PAGE_SIZE) */ + uint16_t cflags; /* compile flags */ +#define CF_COUNT_MASK 0x7fff +#define CF_LAST_IO 0x8000 /* Last insn may be an IO access. */ + + uint8_t *tc_ptr; /* pointer to the translated code */ + /* next matching tb for physical address. */ + struct TranslationBlock *phys_hash_next; + /* first and second physical page containing code. The lower bit + of the pointer tells the index in page_next[] */ + struct TranslationBlock *page_next[2]; + tb_page_addr_t page_addr[2]; + + /* the following data are used to directly call another TB from + the code of this one. */ + uint16_t tb_next_offset[2]; /* offset of original jump target */ +#ifdef USE_DIRECT_JUMP + uint16_t tb_jmp_offset[2]; /* offset of jump instruction */ +#else + uintptr_t tb_next[2]; /* address of jump generated code */ +#endif + /* list of TBs jumping to this one. This is a circular list using + the two least significant bits of the pointers to tell what is + the next pointer: 0 = jmp_next[0], 1 = jmp_next[1], 2 = + jmp_first */ + struct TranslationBlock *jmp_next[2]; + struct TranslationBlock *jmp_first; + uint32_t icount; +}; + +static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) +{ + target_ulong tmp; + tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); + return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; +} + +static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) +{ + target_ulong tmp; + tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); + return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) + | (tmp & TB_JMP_ADDR_MASK)); +} + +static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc) +{ + return (pc >> 2) & (CODE_GEN_PHYS_HASH_SIZE - 1); +} + +void tb_free(TranslationBlock *tb); +void tb_flush(CPUArchState *env); +void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); + +extern TranslationBlock *tb_phys_hash[CODE_GEN_PHYS_HASH_SIZE]; + +#if defined(USE_DIRECT_JUMP) + +#if defined(CONFIG_TCG_INTERPRETER) +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) +{ + /* patch the branch destination */ + *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); + /* no need to flush icache explicitly */ +} +#elif defined(_ARCH_PPC) +void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr); +#define tb_set_jmp_target1 ppc_tb_set_jmp_target +#elif defined(__i386__) || defined(__x86_64__) +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) +{ + /* patch the branch destination */ + *(uint32_t *)jmp_addr = addr - (jmp_addr + 4); + /* no need to flush icache explicitly */ +} +#elif defined(__arm__) +static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) +{ +#if !QEMU_GNUC_PREREQ(4, 1) + register unsigned long _beg __asm ("a1"); + register unsigned long _end __asm ("a2"); + register unsigned long _flg __asm ("a3"); +#endif + + /* we could use a ldr pc, [pc, #-4] kind of branch and avoid the flush */ + *(uint32_t *)jmp_addr = + (*(uint32_t *)jmp_addr & ~0xffffff) + | (((addr - (jmp_addr + 8)) >> 2) & 0xffffff); + +#if QEMU_GNUC_PREREQ(4, 1) + __builtin___clear_cache((char *) jmp_addr, (char *) jmp_addr + 4); +#else + /* flush icache */ + _beg = jmp_addr; + _end = jmp_addr + 4; + _flg = 0; + __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); +#endif +} +#elif defined(__sparc__) +void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr); +#else +#error tb_set_jmp_target1 is missing +#endif + +static inline void tb_set_jmp_target(TranslationBlock *tb, + int n, uintptr_t addr) +{ + uint16_t offset = tb->tb_jmp_offset[n]; + tb_set_jmp_target1((uintptr_t)(tb->tc_ptr + offset), addr); +} + +#else + +/* set the jump target */ +static inline void tb_set_jmp_target(TranslationBlock *tb, + int n, uintptr_t addr) +{ + tb->tb_next[n] = addr; +} + +#endif + +static inline void tb_add_jump(TranslationBlock *tb, int n, + TranslationBlock *tb_next) +{ + /* NOTE: this test is only needed for thread safety */ + if (!tb->jmp_next[n]) { + /* patch the native jump address */ + tb_set_jmp_target(tb, n, (uintptr_t)tb_next->tc_ptr); + + /* add in TB jmp circular list */ + tb->jmp_next[n] = tb_next->jmp_first; + tb_next->jmp_first = (TranslationBlock *)((uintptr_t)(tb) | (n)); + } +} + +#include "exec/spinlock.h" + +extern spinlock_t tb_lock; + +extern int tb_invalidated_flag; + +/* The return address may point to the start of the next instruction. + Subtracting one gets us the call instruction itself. */ +#if defined(CONFIG_TCG_INTERPRETER) +/* Softmmu, Alpha, MIPS, SH4 and SPARC user mode emulations call GETPC(). + For all others, GETPC remains undefined (which makes TCI a little faster. */ +# if defined(CONFIG_SOFTMMU) || \ + defined(TARGET_ALPHA) || defined(TARGET_MIPS) || \ + defined(TARGET_SH4) || defined(TARGET_SPARC) +extern uintptr_t tci_tb_ptr; +# define GETPC() tci_tb_ptr +# endif +#elif defined(__s390__) && !defined(__s390x__) +# define GETPC() \ + (((uintptr_t)__builtin_return_address(0) & 0x7fffffffUL) - 1) +#elif defined(__arm__) +/* Thumb return addresses have the low bit set, so we need to subtract two. + This is still safe in ARM mode because instructions are 4 bytes. */ +# define GETPC() ((uintptr_t)__builtin_return_address(0) - 2) +#else +# define GETPC() ((uintptr_t)__builtin_return_address(0) - 1) +#endif + +#if defined(CONFIG_QEMU_LDST_OPTIMIZATION) && defined(CONFIG_SOFTMMU) +/* qemu_ld/st optimization split code generation to fast and slow path, thus, + it needs special handling for an MMU helper which is called from the slow + path, to get the fast path's pc without any additional argument. + It uses a tricky solution which embeds the fast path pc into the slow path. + + Code flow in slow path: + (1) pre-process + (2) call MMU helper + (3) jump to (5) + (4) fast path information (implementation specific) + (5) post-process (e.g. stack adjust) + (6) jump to corresponding code of the next of fast path + */ +# if defined(__i386__) || defined(__x86_64__) +/* To avoid broken disassembling, long jmp is used for embedding fast path pc, + so that the destination is the next code of fast path, though this jmp is + never executed. + + call MMU helper + jmp POST_PROC (2byte) <- GETRA() + jmp NEXT_CODE (5byte) + POST_PROCESS ... <- GETRA() + 7 + */ +# define GETRA() ((uintptr_t)__builtin_return_address(0)) +# define GETPC_LDST() ((uintptr_t)(GETRA() + 7 + \ + *(int32_t *)((void *)GETRA() + 3) - 1)) +# elif defined (_ARCH_PPC) && !defined (_ARCH_PPC64) +# define GETRA() ((uintptr_t)__builtin_return_address(0)) +# define GETPC_LDST() ((uintptr_t) ((*(int32_t *)(GETRA() - 4)) - 1)) +# else +# error "CONFIG_QEMU_LDST_OPTIMIZATION needs GETPC_LDST() implementation!" +# endif +bool is_tcg_gen_code(uintptr_t pc_ptr); +# define GETPC_EXT() (is_tcg_gen_code(GETRA()) ? GETPC_LDST() : GETPC()) +#else +# define GETPC_EXT() GETPC() +#endif + +#if !defined(CONFIG_USER_ONLY) + +struct MemoryRegion *iotlb_to_region(hwaddr index); +uint64_t io_mem_read(struct MemoryRegion *mr, hwaddr addr, + unsigned size); +void io_mem_write(struct MemoryRegion *mr, hwaddr addr, + uint64_t value, unsigned size); + +void tlb_fill(CPUArchState *env1, target_ulong addr, int is_write, int mmu_idx, + uintptr_t retaddr); + +#include "exec/softmmu_defs.h" + +#define ACCESS_TYPE (NB_MMU_MODES + 1) +#define MEMSUFFIX _code + +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" + +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#endif + +#if defined(CONFIG_USER_ONLY) +static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr) +{ + return addr; +} +#else +/* cputlb.c */ +tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); +#endif + +typedef void (CPUDebugExcpHandler)(CPUArchState *env); + +void cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); + +/* vl.c */ +extern int singlestep; + +/* cpu-exec.c */ +extern volatile sig_atomic_t exit_request; + +/* Deterministic execution requires that IO only be performed on the last + instruction of a TB so that interrupts take effect immediately. */ +static inline int can_do_io(CPUArchState *env) +{ + if (!use_icount) { + return 1; + } + /* If not executing code then assume we are ok. */ + if (!env->current_tb) { + return 1; + } + return env->can_do_io != 0; +} + +#endif diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h new file mode 100644 index 0000000000..668de66000 --- /dev/null +++ b/include/exec/gdbstub.h @@ -0,0 +1,53 @@ +#ifndef GDBSTUB_H +#define GDBSTUB_H + +#define DEFAULT_GDBSTUB_PORT "1234" + +/* GDB breakpoint/watchpoint types */ +#define GDB_BREAKPOINT_SW 0 +#define GDB_BREAKPOINT_HW 1 +#define GDB_WATCHPOINT_WRITE 2 +#define GDB_WATCHPOINT_READ 3 +#define GDB_WATCHPOINT_ACCESS 4 + +#ifdef NEED_CPU_H +typedef void (*gdb_syscall_complete_cb)(CPUArchState *env, + target_ulong ret, target_ulong err); + +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); +int use_gdb_syscalls(void); +void gdb_set_stop_cpu(CPUArchState *env); +void gdb_exit(CPUArchState *, int); +#ifdef CONFIG_USER_ONLY +int gdb_queuesig (void); +int gdb_handlesig (CPUArchState *, int); +void gdb_signalled(CPUArchState *, int); +void gdbserver_fork(CPUArchState *); +#endif +/* Get or set a register. Returns the size of the register. */ +typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); +void gdb_register_coprocessor(CPUArchState *env, + gdb_reg_cb get_reg, gdb_reg_cb set_reg, + int num_regs, const char *xml, int g_pos); + +static inline int cpu_index(CPUArchState *env) +{ +#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL) + return env->host_tid; +#else + return env->cpu_index + 1; +#endif +} + +#endif + +#ifdef CONFIG_USER_ONLY +int gdbserver_start(int); +#else +int gdbserver_start(const char *port); +#endif + +/* in gdbstub-xml.c, generated by scripts/feature_to_c.sh */ +extern const char *const xml_builtin[][2]; + +#endif diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h new file mode 100644 index 0000000000..1541f0b1e4 --- /dev/null +++ b/include/exec/gen-icount.h @@ -0,0 +1,53 @@ +#ifndef GEN_ICOUNT_H +#define GEN_ICOUNT_H 1 + +#include "qemu-timer.h" + +/* Helpers for instruction counting code generation. */ + +static TCGArg *icount_arg; +static int icount_label; + +static inline void gen_icount_start(void) +{ + TCGv_i32 count; + + if (!use_icount) + return; + + icount_label = gen_new_label(); + count = tcg_temp_local_new_i32(); + tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32)); + /* This is a horrid hack to allow fixing up the value later. */ + icount_arg = tcg_ctx.gen_opparam_ptr + 1; + tcg_gen_subi_i32(count, count, 0xdeadbeef); + + tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label); + tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low)); + tcg_temp_free_i32(count); +} + +static void gen_icount_end(TranslationBlock *tb, int num_insns) +{ + if (use_icount) { + *icount_arg = num_insns; + gen_set_label(icount_label); + tcg_gen_exit_tb((tcg_target_long)tb + 2); + } +} + +static inline void gen_io_start(void) +{ + TCGv_i32 tmp = tcg_const_i32(1); + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); + tcg_temp_free_i32(tmp); +} + +static inline void gen_io_end(void) +{ + TCGv_i32 tmp = tcg_const_i32(0); + tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io)); + tcg_temp_free_i32(tmp); +} + +#endif diff --git a/include/exec/hwaddr.h b/include/exec/hwaddr.h new file mode 100644 index 0000000000..251cf9216f --- /dev/null +++ b/include/exec/hwaddr.h @@ -0,0 +1,24 @@ +/* Define hwaddr if it exists. */ + +#ifndef HWADDR_H +#define HWADDR_H + +#ifndef CONFIG_USER_ONLY + +#define HWADDR_BITS 64 +/* hwaddr is the type of a physical address (its size can + be different from 'target_ulong'). */ + +typedef uint64_t hwaddr; +#define HWADDR_MAX UINT64_MAX +#define TARGET_FMT_plx "%016" PRIx64 +#define HWADDR_PRId PRId64 +#define HWADDR_PRIi PRIi64 +#define HWADDR_PRIo PRIo64 +#define HWADDR_PRIu PRIu64 +#define HWADDR_PRIx PRIx64 +#define HWADDR_PRIX PRIX64 + +#endif + +#endif diff --git a/include/exec/ioport.h b/include/exec/ioport.h new file mode 100644 index 0000000000..fc28350a3c --- /dev/null +++ b/include/exec/ioport.h @@ -0,0 +1,78 @@ +/* + * defines ioport related functions + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/************************************************************************** + * IO ports API + */ + +#ifndef IOPORT_H +#define IOPORT_H + +#include "qemu-common.h" +#include "exec/iorange.h" + +typedef uint32_t pio_addr_t; +#define FMT_pioaddr PRIx32 + +#define MAX_IOPORTS (64 * 1024) +#define IOPORTS_MASK (MAX_IOPORTS - 1) + +/* These should really be in isa.h, but are here to make pc.h happy. */ +typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); +typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); +typedef void (IOPortDestructor)(void *opaque); + +void ioport_register(IORange *iorange); +int register_ioport_read(pio_addr_t start, int length, int size, + IOPortReadFunc *func, void *opaque); +int register_ioport_write(pio_addr_t start, int length, int size, + IOPortWriteFunc *func, void *opaque); +void isa_unassign_ioport(pio_addr_t start, int length); +bool isa_is_ioport_assigned(pio_addr_t start); + +void cpu_outb(pio_addr_t addr, uint8_t val); +void cpu_outw(pio_addr_t addr, uint16_t val); +void cpu_outl(pio_addr_t addr, uint32_t val); +uint8_t cpu_inb(pio_addr_t addr); +uint16_t cpu_inw(pio_addr_t addr); +uint32_t cpu_inl(pio_addr_t addr); + +struct MemoryRegion; +struct MemoryRegionPortio; + +typedef struct PortioList { + const struct MemoryRegionPortio *ports; + struct MemoryRegion *address_space; + unsigned nr; + struct MemoryRegion **regions; + struct MemoryRegion **aliases; + void *opaque; + const char *name; +} PortioList; + +void portio_list_init(PortioList *piolist, + const struct MemoryRegionPortio *callbacks, + void *opaque, const char *name); +void portio_list_destroy(PortioList *piolist); +void portio_list_add(PortioList *piolist, + struct MemoryRegion *address_space, + uint32_t addr); +void portio_list_del(PortioList *piolist); + +#endif /* IOPORT_H */ diff --git a/include/exec/iorange.h b/include/exec/iorange.h new file mode 100644 index 0000000000..cd980a8312 --- /dev/null +++ b/include/exec/iorange.h @@ -0,0 +1,31 @@ +#ifndef IORANGE_H +#define IORANGE_H + +#include + +typedef struct IORange IORange; +typedef struct IORangeOps IORangeOps; + +struct IORangeOps { + void (*read)(IORange *iorange, uint64_t offset, unsigned width, + uint64_t *data); + void (*write)(IORange *iorange, uint64_t offset, unsigned width, + uint64_t data); + void (*destructor)(IORange *iorange); +}; + +struct IORange { + const IORangeOps *ops; + uint64_t base; + uint64_t len; +}; + +static inline void iorange_init(IORange *iorange, const IORangeOps *ops, + uint64_t base, uint64_t len) +{ + iorange->ops = ops; + iorange->base = base; + iorange->len = len; +} + +#endif diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h new file mode 100644 index 0000000000..1da240039d --- /dev/null +++ b/include/exec/memory-internal.h @@ -0,0 +1,141 @@ +/* + * Declarations for obsolete exec.c functions + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + * + */ + +/* + * This header is for use by exec.c and memory.c ONLY. Do not include it. + * The functions declared here will be removed soon. + */ + +#ifndef MEMORY_INTERNAL_H +#define MEMORY_INTERNAL_H + +#ifndef CONFIG_USER_ONLY +#include "hw/xen.h" + +typedef struct PhysPageEntry PhysPageEntry; + +struct PhysPageEntry { + uint16_t is_leaf : 1; + /* index into phys_sections (is_leaf) or phys_map_nodes (!is_leaf) */ + uint16_t ptr : 15; +}; + +typedef struct AddressSpaceDispatch AddressSpaceDispatch; + +struct AddressSpaceDispatch { + /* This is a multi-level map on the physical address space. + * The bottom level has pointers to MemoryRegionSections. + */ + PhysPageEntry phys_map; + MemoryListener listener; +}; + +void address_space_init_dispatch(AddressSpace *as); +void address_space_destroy_dispatch(AddressSpace *as); + +ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, + MemoryRegion *mr); +ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); +void qemu_ram_free(ram_addr_t addr); +void qemu_ram_free_from_ptr(ram_addr_t addr); + +struct MemoryRegion; +struct MemoryRegionSection; + +void qemu_register_coalesced_mmio(hwaddr addr, ram_addr_t size); +void qemu_unregister_coalesced_mmio(hwaddr addr, ram_addr_t size); + +#define VGA_DIRTY_FLAG 0x01 +#define CODE_DIRTY_FLAG 0x02 +#define MIGRATION_DIRTY_FLAG 0x08 + +static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) +{ + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; +} + +/* read dirty bit (return 0 or 1) */ +static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) +{ + return cpu_physical_memory_get_dirty_flags(addr) == 0xff; +} + +static inline int cpu_physical_memory_get_dirty(ram_addr_t start, + ram_addr_t length, + int dirty_flags) +{ + int ret = 0; + ram_addr_t addr, end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; + } + return ret; +} + +static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, + int dirty_flags) +{ + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; +} + +static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) +{ + cpu_physical_memory_set_dirty_flags(addr, 0xff); +} + +static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, + int dirty_flags) +{ + int mask = ~dirty_flags; + + return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; +} + +static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, + ram_addr_t length, + int dirty_flags) +{ + ram_addr_t addr, end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + cpu_physical_memory_set_dirty_flags(addr, dirty_flags); + } + xen_modified_memory(addr, length); +} + +static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, + ram_addr_t length, + int dirty_flags) +{ + ram_addr_t addr, end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; + for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { + cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); + } +} + +void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, + int dirty_flags); + +extern const IORangeOps memory_region_iorange_ops; + +#endif + +#endif diff --git a/include/exec/memory.h b/include/exec/memory.h new file mode 100644 index 0000000000..b0c474584f --- /dev/null +++ b/include/exec/memory.h @@ -0,0 +1,882 @@ +/* + * Physical memory management API + * + * Copyright 2011 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef MEMORY_H +#define MEMORY_H + +#ifndef CONFIG_USER_ONLY + +#include +#include +#include "qemu-common.h" +#include "exec/cpu-common.h" +#include "exec/hwaddr.h" +#include "qemu-queue.h" +#include "exec/iorange.h" +#include "exec/ioport.h" +#include "int128.h" + +typedef struct MemoryRegionOps MemoryRegionOps; +typedef struct MemoryRegion MemoryRegion; +typedef struct MemoryRegionPortio MemoryRegionPortio; +typedef struct MemoryRegionMmio MemoryRegionMmio; + +/* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic + * registration. + */ +#define DIRTY_MEMORY_VGA 0 +#define DIRTY_MEMORY_CODE 1 +#define DIRTY_MEMORY_MIGRATION 3 + +struct MemoryRegionMmio { + CPUReadMemoryFunc *read[3]; + CPUWriteMemoryFunc *write[3]; +}; + +/* Internal use; thunks between old-style IORange and MemoryRegions. */ +typedef struct MemoryRegionIORange MemoryRegionIORange; +struct MemoryRegionIORange { + IORange iorange; + MemoryRegion *mr; + hwaddr offset; +}; + +/* + * Memory region callbacks + */ +struct MemoryRegionOps { + /* Read from the memory region. @addr is relative to @mr; @size is + * in bytes. */ + uint64_t (*read)(void *opaque, + hwaddr addr, + unsigned size); + /* Write to the memory region. @addr is relative to @mr; @size is + * in bytes. */ + void (*write)(void *opaque, + hwaddr addr, + uint64_t data, + unsigned size); + + enum device_endian endianness; + /* Guest-visible constraints: */ + struct { + /* If nonzero, specify bounds on access sizes beyond which a machine + * check is thrown. + */ + unsigned min_access_size; + unsigned max_access_size; + /* If true, unaligned accesses are supported. Otherwise unaligned + * accesses throw machine checks. + */ + bool unaligned; + /* + * If present, and returns #false, the transaction is not accepted + * by the device (and results in machine dependent behaviour such + * as a machine check exception). + */ + bool (*accepts)(void *opaque, hwaddr addr, + unsigned size, bool is_write); + } valid; + /* Internal implementation constraints: */ + struct { + /* If nonzero, specifies the minimum size implemented. Smaller sizes + * will be rounded upwards and a partial result will be returned. + */ + unsigned min_access_size; + /* If nonzero, specifies the maximum size implemented. Larger sizes + * will be done as a series of accesses with smaller sizes. + */ + unsigned max_access_size; + /* If true, unaligned accesses are supported. Otherwise all accesses + * are converted to (possibly multiple) naturally aligned accesses. + */ + bool unaligned; + } impl; + + /* If .read and .write are not present, old_portio may be used for + * backwards compatibility with old portio registration + */ + const MemoryRegionPortio *old_portio; + /* If .read and .write are not present, old_mmio may be used for + * backwards compatibility with old mmio registration + */ + const MemoryRegionMmio old_mmio; +}; + +typedef struct CoalescedMemoryRange CoalescedMemoryRange; +typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; + +struct MemoryRegion { + /* All fields are private - violators will be prosecuted */ + const MemoryRegionOps *ops; + void *opaque; + MemoryRegion *parent; + Int128 size; + hwaddr addr; + void (*destructor)(MemoryRegion *mr); + ram_addr_t ram_addr; + bool subpage; + bool terminates; + bool readable; + bool ram; + bool readonly; /* For RAM regions */ + bool enabled; + bool rom_device; + bool warning_printed; /* For reservations */ + bool flush_coalesced_mmio; + MemoryRegion *alias; + hwaddr alias_offset; + unsigned priority; + bool may_overlap; + QTAILQ_HEAD(subregions, MemoryRegion) subregions; + QTAILQ_ENTRY(MemoryRegion) subregions_link; + QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; + const char *name; + uint8_t dirty_log_mask; + unsigned ioeventfd_nb; + MemoryRegionIoeventfd *ioeventfds; +}; + +struct MemoryRegionPortio { + uint32_t offset; + uint32_t len; + unsigned size; + IOPortReadFunc *read; + IOPortWriteFunc *write; +}; + +#define PORTIO_END_OF_LIST() { } + +typedef struct AddressSpace AddressSpace; + +/** + * AddressSpace: describes a mapping of addresses to #MemoryRegion objects + */ +struct AddressSpace { + /* All fields are private. */ + const char *name; + MemoryRegion *root; + struct FlatView *current_map; + int ioeventfd_nb; + struct MemoryRegionIoeventfd *ioeventfds; + struct AddressSpaceDispatch *dispatch; + QTAILQ_ENTRY(AddressSpace) address_spaces_link; +}; + +typedef struct MemoryRegionSection MemoryRegionSection; + +/** + * MemoryRegionSection: describes a fragment of a #MemoryRegion + * + * @mr: the region, or %NULL if empty + * @address_space: the address space the region is mapped in + * @offset_within_region: the beginning of the section, relative to @mr's start + * @size: the size of the section; will not exceed @mr's boundaries + * @offset_within_address_space: the address of the first byte of the section + * relative to the region's address space + * @readonly: writes to this section are ignored + */ +struct MemoryRegionSection { + MemoryRegion *mr; + AddressSpace *address_space; + hwaddr offset_within_region; + uint64_t size; + hwaddr offset_within_address_space; + bool readonly; +}; + +typedef struct MemoryListener MemoryListener; + +/** + * MemoryListener: callbacks structure for updates to the physical memory map + * + * Allows a component to adjust to changes in the guest-visible memory map. + * Use with memory_listener_register() and memory_listener_unregister(). + */ +struct MemoryListener { + void (*begin)(MemoryListener *listener); + void (*commit)(MemoryListener *listener); + void (*region_add)(MemoryListener *listener, MemoryRegionSection *section); + void (*region_del)(MemoryListener *listener, MemoryRegionSection *section); + void (*region_nop)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_start)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_stop)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_sync)(MemoryListener *listener, MemoryRegionSection *section); + void (*log_global_start)(MemoryListener *listener); + void (*log_global_stop)(MemoryListener *listener); + void (*eventfd_add)(MemoryListener *listener, MemoryRegionSection *section, + bool match_data, uint64_t data, EventNotifier *e); + void (*eventfd_del)(MemoryListener *listener, MemoryRegionSection *section, + bool match_data, uint64_t data, EventNotifier *e); + void (*coalesced_mmio_add)(MemoryListener *listener, MemoryRegionSection *section, + hwaddr addr, hwaddr len); + void (*coalesced_mmio_del)(MemoryListener *listener, MemoryRegionSection *section, + hwaddr addr, hwaddr len); + /* Lower = earlier (during add), later (during del) */ + unsigned priority; + AddressSpace *address_space_filter; + QTAILQ_ENTRY(MemoryListener) link; +}; + +/** + * memory_region_init: Initialize a memory region + * + * The region typically acts as a container for other memory regions. Use + * memory_region_add_subregion() to add subregions. + * + * @mr: the #MemoryRegion to be initialized + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region; any subregions beyond this size will be clipped + */ +void memory_region_init(MemoryRegion *mr, + const char *name, + uint64_t size); +/** + * memory_region_init_io: Initialize an I/O memory region. + * + * Accesses into the region will cause the callbacks in @ops to be called. + * if @size is nonzero, subregions will be clipped to @size. + * + * @mr: the #MemoryRegion to be initialized. + * @ops: a structure containing read and write callbacks to be used when + * I/O is performed on the region. + * @opaque: passed to to the read and write callbacks of the @ops structure. + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region. + */ +void memory_region_init_io(MemoryRegion *mr, + const MemoryRegionOps *ops, + void *opaque, + const char *name, + uint64_t size); + +/** + * memory_region_init_ram: Initialize RAM memory region. Accesses into the + * region will modify memory directly. + * + * @mr: the #MemoryRegion to be initialized. + * @name: the name of the region. + * @size: size of the region. + */ +void memory_region_init_ram(MemoryRegion *mr, + const char *name, + uint64_t size); + +/** + * memory_region_init_ram_ptr: Initialize RAM memory region from a + * user-provided pointer. Accesses into the + * region will modify memory directly. + * + * @mr: the #MemoryRegion to be initialized. + * @name: the name of the region. + * @size: size of the region. + * @ptr: memory to be mapped; must contain at least @size bytes. + */ +void memory_region_init_ram_ptr(MemoryRegion *mr, + const char *name, + uint64_t size, + void *ptr); + +/** + * memory_region_init_alias: Initialize a memory region that aliases all or a + * part of another memory region. + * + * @mr: the #MemoryRegion to be initialized. + * @name: used for debugging; not visible to the user or ABI + * @orig: the region to be referenced; @mr will be equivalent to + * @orig between @offset and @offset + @size - 1. + * @offset: start of the section in @orig to be referenced. + * @size: size of the region. + */ +void memory_region_init_alias(MemoryRegion *mr, + const char *name, + MemoryRegion *orig, + hwaddr offset, + uint64_t size); + +/** + * memory_region_init_rom_device: Initialize a ROM memory region. Writes are + * handled via callbacks. + * + * @mr: the #MemoryRegion to be initialized. + * @ops: callbacks for write access handling. + * @name: the name of the region. + * @size: size of the region. + */ +void memory_region_init_rom_device(MemoryRegion *mr, + const MemoryRegionOps *ops, + void *opaque, + const char *name, + uint64_t size); + +/** + * memory_region_init_reservation: Initialize a memory region that reserves + * I/O space. + * + * A reservation region primariy serves debugging purposes. It claims I/O + * space that is not supposed to be handled by QEMU itself. Any access via + * the memory API will cause an abort(). + * + * @mr: the #MemoryRegion to be initialized + * @name: used for debugging; not visible to the user or ABI + * @size: size of the region. + */ +void memory_region_init_reservation(MemoryRegion *mr, + const char *name, + uint64_t size); +/** + * memory_region_destroy: Destroy a memory region and reclaim all resources. + * + * @mr: the region to be destroyed. May not currently be a subregion + * (see memory_region_add_subregion()) or referenced in an alias + * (see memory_region_init_alias()). + */ +void memory_region_destroy(MemoryRegion *mr); + +/** + * memory_region_size: get a memory region's size. + * + * @mr: the memory region being queried. + */ +uint64_t memory_region_size(MemoryRegion *mr); + +/** + * memory_region_is_ram: check whether a memory region is random access + * + * Returns %true is a memory region is random access. + * + * @mr: the memory region being queried + */ +bool memory_region_is_ram(MemoryRegion *mr); + +/** + * memory_region_is_romd: check whether a memory region is ROMD + * + * Returns %true is a memory region is ROMD and currently set to allow + * direct reads. + * + * @mr: the memory region being queried + */ +static inline bool memory_region_is_romd(MemoryRegion *mr) +{ + return mr->rom_device && mr->readable; +} + +/** + * memory_region_name: get a memory region's name + * + * Returns the string that was used to initialize the memory region. + * + * @mr: the memory region being queried + */ +const char *memory_region_name(MemoryRegion *mr); + +/** + * memory_region_is_logging: return whether a memory region is logging writes + * + * Returns %true if the memory region is logging writes + * + * @mr: the memory region being queried + */ +bool memory_region_is_logging(MemoryRegion *mr); + +/** + * memory_region_is_rom: check whether a memory region is ROM + * + * Returns %true is a memory region is read-only memory. + * + * @mr: the memory region being queried + */ +bool memory_region_is_rom(MemoryRegion *mr); + +/** + * memory_region_get_ram_ptr: Get a pointer into a RAM memory region. + * + * Returns a host pointer to a RAM memory region (created with + * memory_region_init_ram() or memory_region_init_ram_ptr()). Use with + * care. + * + * @mr: the memory region being queried. + */ +void *memory_region_get_ram_ptr(MemoryRegion *mr); + +/** + * memory_region_set_log: Turn dirty logging on or off for a region. + * + * Turns dirty logging on or off for a specified client (display, migration). + * Only meaningful for RAM regions. + * + * @mr: the memory region being updated. + * @log: whether dirty logging is to be enabled or disabled. + * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or + * %DIRTY_MEMORY_VGA. + */ +void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client); + +/** + * memory_region_get_dirty: Check whether a range of bytes is dirty + * for a specified client. + * + * Checks whether a range of bytes has been written to since the last + * call to memory_region_reset_dirty() with the same @client. Dirty logging + * must be enabled. + * + * @mr: the memory region being queried. + * @addr: the address (relative to the start of the region) being queried. + * @size: the size of the range being queried. + * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or + * %DIRTY_MEMORY_VGA. + */ +bool memory_region_get_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size, unsigned client); + +/** + * memory_region_set_dirty: Mark a range of bytes as dirty in a memory region. + * + * Marks a range of bytes as dirty, after it has been dirtied outside + * guest code. + * + * @mr: the memory region being dirtied. + * @addr: the address (relative to the start of the region) being dirtied. + * @size: size of the range being dirtied. + */ +void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size); + +/** + * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap with + * any external TLBs (e.g. kvm) + * + * Flushes dirty information from accelerators such as kvm and vhost-net + * and makes it available to users of the memory API. + * + * @mr: the region being flushed. + */ +void memory_region_sync_dirty_bitmap(MemoryRegion *mr); + +/** + * memory_region_reset_dirty: Mark a range of pages as clean, for a specified + * client. + * + * Marks a range of pages as no longer dirty. + * + * @mr: the region being updated. + * @addr: the start of the subrange being cleaned. + * @size: the size of the subrange being cleaned. + * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or + * %DIRTY_MEMORY_VGA. + */ +void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, + hwaddr size, unsigned client); + +/** + * memory_region_set_readonly: Turn a memory region read-only (or read-write) + * + * Allows a memory region to be marked as read-only (turning it into a ROM). + * only useful on RAM regions. + * + * @mr: the region being updated. + * @readonly: whether rhe region is to be ROM or RAM. + */ +void memory_region_set_readonly(MemoryRegion *mr, bool readonly); + +/** + * memory_region_rom_device_set_readable: enable/disable ROM readability + * + * Allows a ROM device (initialized with memory_region_init_rom_device() to + * to be marked as readable (default) or not readable. When it is readable, + * the device is mapped to guest memory. When not readable, reads are + * forwarded to the #MemoryRegion.read function. + * + * @mr: the memory region to be updated + * @readable: whether reads are satisified directly (%true) or via callbacks + * (%false) + */ +void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable); + +/** + * memory_region_set_coalescing: Enable memory coalescing for the region. + * + * Enabled writes to a region to be queued for later processing. MMIO ->write + * callbacks may be delayed until a non-coalesced MMIO is issued. + * Only useful for IO regions. Roughly similar to write-combining hardware. + * + * @mr: the memory region to be write coalesced + */ +void memory_region_set_coalescing(MemoryRegion *mr); + +/** + * memory_region_add_coalescing: Enable memory coalescing for a sub-range of + * a region. + * + * Like memory_region_set_coalescing(), but works on a sub-range of a region. + * Multiple calls can be issued coalesced disjoint ranges. + * + * @mr: the memory region to be updated. + * @offset: the start of the range within the region to be coalesced. + * @size: the size of the subrange to be coalesced. + */ +void memory_region_add_coalescing(MemoryRegion *mr, + hwaddr offset, + uint64_t size); + +/** + * memory_region_clear_coalescing: Disable MMIO coalescing for the region. + * + * Disables any coalescing caused by memory_region_set_coalescing() or + * memory_region_add_coalescing(). Roughly equivalent to uncacheble memory + * hardware. + * + * @mr: the memory region to be updated. + */ +void memory_region_clear_coalescing(MemoryRegion *mr); + +/** + * memory_region_set_flush_coalesced: Enforce memory coalescing flush before + * accesses. + * + * Ensure that pending coalesced MMIO request are flushed before the memory + * region is accessed. This property is automatically enabled for all regions + * passed to memory_region_set_coalescing() and memory_region_add_coalescing(). + * + * @mr: the memory region to be updated. + */ +void memory_region_set_flush_coalesced(MemoryRegion *mr); + +/** + * memory_region_clear_flush_coalesced: Disable memory coalescing flush before + * accesses. + * + * Clear the automatic coalesced MMIO flushing enabled via + * memory_region_set_flush_coalesced. Note that this service has no effect on + * memory regions that have MMIO coalescing enabled for themselves. For them, + * automatic flushing will stop once coalescing is disabled. + * + * @mr: the memory region to be updated. + */ +void memory_region_clear_flush_coalesced(MemoryRegion *mr); + +/** + * memory_region_add_eventfd: Request an eventfd to be triggered when a word + * is written to a location. + * + * Marks a word in an IO region (initialized with memory_region_init_io()) + * as a trigger for an eventfd event. The I/O callback will not be called. + * The caller must be prepared to handle failure (that is, take the required + * action if the callback _is_ called). + * + * @mr: the memory region being updated. + * @addr: the address within @mr that is to be monitored + * @size: the size of the access to trigger the eventfd + * @match_data: whether to match against @data, instead of just @addr + * @data: the data to match against the guest write + * @fd: the eventfd to be triggered when @addr, @size, and @data all match. + **/ +void memory_region_add_eventfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + bool match_data, + uint64_t data, + EventNotifier *e); + +/** + * memory_region_del_eventfd: Cancel an eventfd. + * + * Cancels an eventfd trigger requested by a previous + * memory_region_add_eventfd() call. + * + * @mr: the memory region being updated. + * @addr: the address within @mr that is to be monitored + * @size: the size of the access to trigger the eventfd + * @match_data: whether to match against @data, instead of just @addr + * @data: the data to match against the guest write + * @fd: the eventfd to be triggered when @addr, @size, and @data all match. + */ +void memory_region_del_eventfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + bool match_data, + uint64_t data, + EventNotifier *e); + +/** + * memory_region_add_subregion: Add a subregion to a container. + * + * Adds a subregion at @offset. The subregion may not overlap with other + * subregions (except for those explicitly marked as overlapping). A region + * may only be added once as a subregion (unless removed with + * memory_region_del_subregion()); use memory_region_init_alias() if you + * want a region to be a subregion in multiple locations. + * + * @mr: the region to contain the new subregion; must be a container + * initialized with memory_region_init(). + * @offset: the offset relative to @mr where @subregion is added. + * @subregion: the subregion to be added. + */ +void memory_region_add_subregion(MemoryRegion *mr, + hwaddr offset, + MemoryRegion *subregion); +/** + * memory_region_add_subregion_overlap: Add a subregion to a container + * with overlap. + * + * Adds a subregion at @offset. The subregion may overlap with other + * subregions. Conflicts are resolved by having a higher @priority hide a + * lower @priority. Subregions without priority are taken as @priority 0. + * A region may only be added once as a subregion (unless removed with + * memory_region_del_subregion()); use memory_region_init_alias() if you + * want a region to be a subregion in multiple locations. + * + * @mr: the region to contain the new subregion; must be a container + * initialized with memory_region_init(). + * @offset: the offset relative to @mr where @subregion is added. + * @subregion: the subregion to be added. + * @priority: used for resolving overlaps; highest priority wins. + */ +void memory_region_add_subregion_overlap(MemoryRegion *mr, + hwaddr offset, + MemoryRegion *subregion, + unsigned priority); + +/** + * memory_region_get_ram_addr: Get the ram address associated with a memory + * region + * + * DO NOT USE THIS FUNCTION. This is a temporary workaround while the Xen + * code is being reworked. + */ +ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr); + +/** + * memory_region_del_subregion: Remove a subregion. + * + * Removes a subregion from its container. + * + * @mr: the container to be updated. + * @subregion: the region being removed; must be a current subregion of @mr. + */ +void memory_region_del_subregion(MemoryRegion *mr, + MemoryRegion *subregion); + +/* + * memory_region_set_enabled: dynamically enable or disable a region + * + * Enables or disables a memory region. A disabled memory region + * ignores all accesses to itself and its subregions. It does not + * obscure sibling subregions with lower priority - it simply behaves as + * if it was removed from the hierarchy. + * + * Regions default to being enabled. + * + * @mr: the region to be updated + * @enabled: whether to enable or disable the region + */ +void memory_region_set_enabled(MemoryRegion *mr, bool enabled); + +/* + * memory_region_set_address: dynamically update the address of a region + * + * Dynamically updates the address of a region, relative to its parent. + * May be used on regions are currently part of a memory hierarchy. + * + * @mr: the region to be updated + * @addr: new address, relative to parent region + */ +void memory_region_set_address(MemoryRegion *mr, hwaddr addr); + +/* + * memory_region_set_alias_offset: dynamically update a memory alias's offset + * + * Dynamically updates the offset into the target region that an alias points + * to, as if the fourth argument to memory_region_init_alias() has changed. + * + * @mr: the #MemoryRegion to be updated; should be an alias. + * @offset: the new offset into the target memory region + */ +void memory_region_set_alias_offset(MemoryRegion *mr, + hwaddr offset); + +/** + * memory_region_find: locate a MemoryRegion in an address space + * + * Locates the first #MemoryRegion within an address space given by + * @address_space that overlaps the range given by @addr and @size. + * + * Returns a #MemoryRegionSection that describes a contiguous overlap. + * It will have the following characteristics: + * .@offset_within_address_space >= @addr + * .@offset_within_address_space + .@size <= @addr + @size + * .@size = 0 iff no overlap was found + * .@mr is non-%NULL iff an overlap was found + * + * @address_space: a top-level (i.e. parentless) region that contains + * the region to be found + * @addr: start of the area within @address_space to be searched + * @size: size of the area to be searched + */ +MemoryRegionSection memory_region_find(MemoryRegion *address_space, + hwaddr addr, uint64_t size); + +/** + * memory_region_section_addr: get offset within MemoryRegionSection + * + * Returns offset within MemoryRegionSection + * + * @section: the memory region section being queried + * @addr: address in address space + */ +static inline hwaddr +memory_region_section_addr(MemoryRegionSection *section, + hwaddr addr) +{ + addr -= section->offset_within_address_space; + addr += section->offset_within_region; + return addr; +} + +/** + * memory_global_sync_dirty_bitmap: synchronize the dirty log for all memory + * + * Synchronizes the dirty page log for an entire address space. + * @address_space: a top-level (i.e. parentless) region that contains the + * memory being synchronized + */ +void memory_global_sync_dirty_bitmap(MemoryRegion *address_space); + +/** + * memory_region_transaction_begin: Start a transaction. + * + * During a transaction, changes will be accumulated and made visible + * only when the transaction ends (is committed). + */ +void memory_region_transaction_begin(void); + +/** + * memory_region_transaction_commit: Commit a transaction and make changes + * visible to the guest. + */ +void memory_region_transaction_commit(void); + +/** + * memory_listener_register: register callbacks to be called when memory + * sections are mapped or unmapped into an address + * space + * + * @listener: an object containing the callbacks to be called + * @filter: if non-%NULL, only regions in this address space will be observed + */ +void memory_listener_register(MemoryListener *listener, AddressSpace *filter); + +/** + * memory_listener_unregister: undo the effect of memory_listener_register() + * + * @listener: an object containing the callbacks to be removed + */ +void memory_listener_unregister(MemoryListener *listener); + +/** + * memory_global_dirty_log_start: begin dirty logging for all regions + */ +void memory_global_dirty_log_start(void); + +/** + * memory_global_dirty_log_stop: end dirty logging for all regions + */ +void memory_global_dirty_log_stop(void); + +void mtree_info(fprintf_function mon_printf, void *f); + +/** + * address_space_init: initializes an address space + * + * @as: an uninitialized #AddressSpace + * @root: a #MemoryRegion that routes addesses for the address space + */ +void address_space_init(AddressSpace *as, MemoryRegion *root); + + +/** + * address_space_destroy: destroy an address space + * + * Releases all resources associated with an address space. After an address space + * is destroyed, its root memory region (given by address_space_init()) may be destroyed + * as well. + * + * @as: address space to be destroyed + */ +void address_space_destroy(AddressSpace *as); + +/** + * address_space_rw: read from or write to an address space. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + * @is_write: indicates the transfer direction + */ +void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, + int len, bool is_write); + +/** + * address_space_write: write to address space. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + */ +void address_space_write(AddressSpace *as, hwaddr addr, + const uint8_t *buf, int len); + +/** + * address_space_read: read from an address space. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @buf: buffer with the data transferred + */ +void address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len); + +/* address_space_map: map a physical memory region into a host virtual address + * + * May map a subset of the requested range, given by and returned in @plen. + * May return %NULL if resources needed to perform the mapping are exhausted. + * Use only for reads OR writes - not for read-modify-write operations. + * Use cpu_register_map_client() to know when retrying the map operation is + * likely to succeed. + * + * @as: #AddressSpace to be accessed + * @addr: address within that address space + * @plen: pointer to length of buffer; updated on return + * @is_write: indicates the transfer direction + */ +void *address_space_map(AddressSpace *as, hwaddr addr, + hwaddr *plen, bool is_write); + +/* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() + * + * Will also mark the memory as dirty if @is_write == %true. @access_len gives + * the amount of memory that was actually read or written by the caller. + * + * @as: #AddressSpace used + * @addr: address within that address space + * @len: buffer length as returned by address_space_map() + * @access_len: amount of data actually transferred + * @is_write: indicates the transfer direction + */ +void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, + int is_write, hwaddr access_len); + + +#endif + +#endif diff --git a/include/exec/poison.h b/include/exec/poison.h new file mode 100644 index 0000000000..7d7b23b1fc --- /dev/null +++ b/include/exec/poison.h @@ -0,0 +1,64 @@ +/* Poison identifiers that should not be used when building + target independent device code. */ + +#ifndef HW_POISON_H +#define HW_POISON_H +#ifdef __GNUC__ + +#pragma GCC poison TARGET_I386 +#pragma GCC poison TARGET_X86_64 +#pragma GCC poison TARGET_ALPHA +#pragma GCC poison TARGET_ARM +#pragma GCC poison TARGET_CRIS +#pragma GCC poison TARGET_LM32 +#pragma GCC poison TARGET_M68K +#pragma GCC poison TARGET_MIPS +#pragma GCC poison TARGET_MIPS64 +#pragma GCC poison TARGET_OPENRISC +#pragma GCC poison TARGET_PPC +#pragma GCC poison TARGET_PPCEMB +#pragma GCC poison TARGET_PPC64 +#pragma GCC poison TARGET_ABI32 +#pragma GCC poison TARGET_SH4 +#pragma GCC poison TARGET_SPARC +#pragma GCC poison TARGET_SPARC64 + +#pragma GCC poison TARGET_WORDS_BIGENDIAN +#pragma GCC poison BSWAP_NEEDED + +#pragma GCC poison TARGET_LONG_BITS +#pragma GCC poison TARGET_FMT_lx +#pragma GCC poison TARGET_FMT_ld + +#pragma GCC poison TARGET_PAGE_SIZE +#pragma GCC poison TARGET_PAGE_MASK +#pragma GCC poison TARGET_PAGE_BITS +#pragma GCC poison TARGET_PAGE_ALIGN + +#pragma GCC poison CPUArchState +#pragma GCC poison env + +#pragma GCC poison lduw_phys +#pragma GCC poison ldl_phys +#pragma GCC poison ldq_phys +#pragma GCC poison stl_phys_notdirty +#pragma GCC poison stq_phys_notdirty +#pragma GCC poison stw_phys +#pragma GCC poison stl_phys +#pragma GCC poison stq_phys + +#pragma GCC poison CPU_INTERRUPT_HARD +#pragma GCC poison CPU_INTERRUPT_EXITTB +#pragma GCC poison CPU_INTERRUPT_HALT +#pragma GCC poison CPU_INTERRUPT_DEBUG +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 +#pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_0 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_1 +#pragma GCC poison CPU_INTERRUPT_TGT_INT_2 + +#endif +#endif diff --git a/include/exec/softmmu-semi.h b/include/exec/softmmu-semi.h new file mode 100644 index 0000000000..93798b9614 --- /dev/null +++ b/include/exec/softmmu-semi.h @@ -0,0 +1,77 @@ +/* + * Helper routines to provide target memory access for semihosting + * syscalls in system emulation mode. + * + * Copyright (c) 2007 CodeSourcery. + * + * This code is licensed under the GPL + */ +#ifndef SOFTMMU_SEMI_H +#define SOFTMMU_SEMI_H 1 + +static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr) +{ + uint32_t val; + + cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0); + return tswap32(val); +} +static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr) +{ + uint8_t val; + + cpu_memory_rw_debug(env, addr, &val, 1, 0); + return val; +} + +#define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; }) +#define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; }) +#define get_user_ual(arg, p) get_user_u32(arg, p) + +static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val) +{ + val = tswap32(val); + cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1); +} +#define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; }) +#define put_user_ual(arg, p) put_user_u32(arg, p) + +static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len, + int copy) +{ + uint8_t *p; + /* TODO: Make this something that isn't fixed size. */ + p = malloc(len); + if (p && copy) + cpu_memory_rw_debug(env, addr, p, len, 0); + return p; +} +#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy) +static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr) +{ + char *p; + char *s; + uint8_t c; + /* TODO: Make this something that isn't fixed size. */ + s = p = malloc(1024); + if (!s) { + return NULL; + } + do { + cpu_memory_rw_debug(env, addr, &c, 1, 0); + addr++; + *(p++) = c; + } while (c); + return s; +} +#define lock_user_string(p) softmmu_lock_user_string(env, p) +static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr, + target_ulong len) +{ + if (len) + cpu_memory_rw_debug(env, addr, p, len, 1); + free(p); +} +#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) + +#endif diff --git a/include/exec/softmmu_defs.h b/include/exec/softmmu_defs.h new file mode 100644 index 0000000000..1f25e33ce4 --- /dev/null +++ b/include/exec/softmmu_defs.h @@ -0,0 +1,37 @@ +/* + * Software MMU support + * + * Declare helpers used by TCG for qemu_ld/st ops. + * + * Used by softmmu_exec.h, TCG targets and exec-all.h. + * + */ +#ifndef SOFTMMU_DEFS_H +#define SOFTMMU_DEFS_H + +uint8_t helper_ldb_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, + int mmu_idx); +uint16_t helper_ldw_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, + int mmu_idx); +uint32_t helper_ldl_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, + int mmu_idx); +uint64_t helper_ldq_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, + int mmu_idx); + +uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stb_cmmu(CPUArchState *env, target_ulong addr, uint8_t val, +int mmu_idx); +uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stw_cmmu(CPUArchState *env, target_ulong addr, uint16_t val, + int mmu_idx); +uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stl_cmmu(CPUArchState *env, target_ulong addr, uint32_t val, + int mmu_idx); +uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); +void helper_stq_cmmu(CPUArchState *env, target_ulong addr, uint64_t val, + int mmu_idx); +#endif diff --git a/include/exec/softmmu_exec.h b/include/exec/softmmu_exec.h new file mode 100644 index 0000000000..3e4e886a30 --- /dev/null +++ b/include/exec/softmmu_exec.h @@ -0,0 +1,163 @@ +/* + * Software MMU support + * + * Generate inline load/store functions for all MMU modes (typically + * at least _user and _kernel) as well as _data versions, for all data + * sizes. + * + * Used by target op helpers. + * + * MMU mode suffixes are defined in target cpu.h. + */ + +/* XXX: find something cleaner. + * Furthermore, this is false for 64 bits targets + */ +#define ldul_user ldl_user +#define ldul_kernel ldl_kernel +#define ldul_hypv ldl_hypv +#define ldul_executive ldl_executive +#define ldul_supervisor ldl_supervisor + +#include "exec/softmmu_defs.h" + +#define ACCESS_TYPE 0 +#define MEMSUFFIX MMU_MODE0_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#define ACCESS_TYPE 1 +#define MEMSUFFIX MMU_MODE1_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#if (NB_MMU_MODES >= 3) + +#define ACCESS_TYPE 2 +#define MEMSUFFIX MMU_MODE2_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 3) */ + +#if (NB_MMU_MODES >= 4) + +#define ACCESS_TYPE 3 +#define MEMSUFFIX MMU_MODE3_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ + +#if (NB_MMU_MODES >= 5) + +#define ACCESS_TYPE 4 +#define MEMSUFFIX MMU_MODE4_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 5) */ + +#if (NB_MMU_MODES >= 6) + +#define ACCESS_TYPE 5 +#define MEMSUFFIX MMU_MODE5_SUFFIX +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 6) */ + +#if (NB_MMU_MODES > 6) +#error "NB_MMU_MODES > 6 is not supported for now" +#endif /* (NB_MMU_MODES > 6) */ + +/* these access are slower, they must be as rare as possible */ +#define ACCESS_TYPE (NB_MMU_MODES) +#define MEMSUFFIX _data +#define DATA_SIZE 1 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 2 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 4 +#include "exec/softmmu_header.h" + +#define DATA_SIZE 8 +#include "exec/softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX + +#define ldub(p) ldub_data(p) +#define ldsb(p) ldsb_data(p) +#define lduw(p) lduw_data(p) +#define ldsw(p) ldsw_data(p) +#define ldl(p) ldl_data(p) +#define ldq(p) ldq_data(p) + +#define stb(p, v) stb_data(p, v) +#define stw(p, v) stw_data(p, v) +#define stl(p, v) stl_data(p, v) +#define stq(p, v) stq_data(p, v) diff --git a/include/exec/softmmu_header.h b/include/exec/softmmu_header.h new file mode 100644 index 0000000000..d8d9c81b05 --- /dev/null +++ b/include/exec/softmmu_header.h @@ -0,0 +1,213 @@ +/* + * Software MMU support + * + * Generate inline load/store functions for one MMU mode and data + * size. + * + * Generate a store function as well as signed and unsigned loads. For + * 32 and 64 bit cases, also generate floating point functions with + * the same size. + * + * Not used directly but included from softmmu_exec.h and exec-all.h. + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#if DATA_SIZE == 8 +#define SUFFIX q +#define USUFFIX q +#define DATA_TYPE uint64_t +#elif DATA_SIZE == 4 +#define SUFFIX l +#define USUFFIX l +#define DATA_TYPE uint32_t +#elif DATA_SIZE == 2 +#define SUFFIX w +#define USUFFIX uw +#define DATA_TYPE uint16_t +#define DATA_STYPE int16_t +#elif DATA_SIZE == 1 +#define SUFFIX b +#define USUFFIX ub +#define DATA_TYPE uint8_t +#define DATA_STYPE int8_t +#else +#error unsupported data size +#endif + +#if ACCESS_TYPE < (NB_MMU_MODES) + +#define CPU_MMU_INDEX ACCESS_TYPE +#define MMUSUFFIX _mmu + +#elif ACCESS_TYPE == (NB_MMU_MODES) + +#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define MMUSUFFIX _mmu + +#elif ACCESS_TYPE == (NB_MMU_MODES + 1) + +#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define MMUSUFFIX _cmmu + +#else +#error invalid ACCESS_TYPE +#endif + +#if DATA_SIZE == 8 +#define RES_TYPE uint64_t +#else +#define RES_TYPE uint32_t +#endif + +#if ACCESS_TYPE == (NB_MMU_MODES + 1) +#define ADDR_READ addr_code +#else +#define ADDR_READ addr_read +#endif + +/* generic load/store macros */ + +static inline RES_TYPE +glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) +{ + int page_index; + RES_TYPE res; + target_ulong addr; + int mmu_idx; + + addr = ptr; + page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + mmu_idx = CPU_MMU_INDEX; + if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { + res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx); + } else { + uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + res = glue(glue(ld, USUFFIX), _raw)(hostaddr); + } + return res; +} + +#if DATA_SIZE <= 2 +static inline int +glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) +{ + int res, page_index; + target_ulong addr; + int mmu_idx; + + addr = ptr; + page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + mmu_idx = CPU_MMU_INDEX; + if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { + res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX), + MMUSUFFIX)(env, addr, mmu_idx); + } else { + uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + res = glue(glue(lds, SUFFIX), _raw)(hostaddr); + } + return res; +} +#endif + +#if ACCESS_TYPE != (NB_MMU_MODES + 1) + +/* generic store macro */ + +static inline void +glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr, + RES_TYPE v) +{ + int page_index; + target_ulong addr; + int mmu_idx; + + addr = ptr; + page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + mmu_idx = CPU_MMU_INDEX; + if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != + (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { + glue(glue(helper_st, SUFFIX), MMUSUFFIX)(env, addr, v, mmu_idx); + } else { + uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; + glue(glue(st, SUFFIX), _raw)(hostaddr, v); + } +} + +#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ + +#if ACCESS_TYPE != (NB_MMU_MODES + 1) + +#if DATA_SIZE == 8 +static inline float64 glue(cpu_ldfq, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr) +{ + union { + float64 d; + uint64_t i; + } u; + u.i = glue(cpu_ldq, MEMSUFFIX)(env, ptr); + return u.d; +} + +static inline void glue(cpu_stfq, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr, float64 v) +{ + union { + float64 d; + uint64_t i; + } u; + u.d = v; + glue(cpu_stq, MEMSUFFIX)(env, ptr, u.i); +} +#endif /* DATA_SIZE == 8 */ + +#if DATA_SIZE == 4 +static inline float32 glue(cpu_ldfl, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = glue(cpu_ldl, MEMSUFFIX)(env, ptr); + return u.f; +} + +static inline void glue(cpu_stfl, MEMSUFFIX)(CPUArchState *env, + target_ulong ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + glue(cpu_stl, MEMSUFFIX)(env, ptr, u.i); +} +#endif /* DATA_SIZE == 4 */ + +#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ + +#undef RES_TYPE +#undef DATA_TYPE +#undef DATA_STYPE +#undef SUFFIX +#undef USUFFIX +#undef DATA_SIZE +#undef CPU_MMU_INDEX +#undef MMUSUFFIX +#undef ADDR_READ diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_template.h new file mode 100644 index 0000000000..15d4c519ee --- /dev/null +++ b/include/exec/softmmu_template.h @@ -0,0 +1,354 @@ +/* + * Software MMU support + * + * Generate helpers used by TCG for qemu_ld/st ops and code load + * functions. + * + * Included from target op helpers and exec.c. + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#include "qemu-timer.h" +#include "exec/memory.h" + +#define DATA_SIZE (1 << SHIFT) + +#if DATA_SIZE == 8 +#define SUFFIX q +#define USUFFIX q +#define DATA_TYPE uint64_t +#elif DATA_SIZE == 4 +#define SUFFIX l +#define USUFFIX l +#define DATA_TYPE uint32_t +#elif DATA_SIZE == 2 +#define SUFFIX w +#define USUFFIX uw +#define DATA_TYPE uint16_t +#elif DATA_SIZE == 1 +#define SUFFIX b +#define USUFFIX ub +#define DATA_TYPE uint8_t +#else +#error unsupported data size +#endif + +#ifdef SOFTMMU_CODE_ACCESS +#define READ_ACCESS_TYPE 2 +#define ADDR_READ addr_code +#else +#define READ_ACCESS_TYPE 0 +#define ADDR_READ addr_read +#endif + +static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + int mmu_idx, + uintptr_t retaddr); +static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, + hwaddr physaddr, + target_ulong addr, + uintptr_t retaddr) +{ + DATA_TYPE res; + MemoryRegion *mr = iotlb_to_region(physaddr); + + physaddr = (physaddr & TARGET_PAGE_MASK) + addr; + env->mem_io_pc = retaddr; + if (mr != &io_mem_ram && mr != &io_mem_rom + && mr != &io_mem_unassigned + && mr != &io_mem_notdirty + && !can_do_io(env)) { + cpu_io_recompile(env, retaddr); + } + + env->mem_io_vaddr = addr; +#if SHIFT <= 2 + res = io_mem_read(mr, physaddr, 1 << SHIFT); +#else +#ifdef TARGET_WORDS_BIGENDIAN + res = io_mem_read(mr, physaddr, 4) << 32; + res |= io_mem_read(mr, physaddr + 4, 4); +#else + res = io_mem_read(mr, physaddr, 4); + res |= io_mem_read(mr, physaddr + 4, 4) << 32; +#endif +#endif /* SHIFT > 2 */ + return res; +} + +/* handle all cases except unaligned access which span two pages */ +DATA_TYPE +glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_ulong addr, + int mmu_idx) +{ + DATA_TYPE res; + int index; + target_ulong tlb_addr; + hwaddr ioaddr; + uintptr_t retaddr; + + /* test if there is match for unaligned or IO access */ + /* XXX: could done more in memory macro in a non portable way */ + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + retaddr = GETPC_EXT(); + ioaddr = env->iotlb[mmu_idx][index]; + res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + /* slow unaligned access (it spans two pages or IO) */ + do_unaligned_access: + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); +#endif + res = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr, + mmu_idx, retaddr); + } else { + /* unaligned/aligned access in the same page */ + uintptr_t addend; +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) { + retaddr = GETPC_EXT(); + do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); + } +#endif + addend = env->tlb_table[mmu_idx][index].addend; + res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend)); + } + } else { + /* the page is not in the TLB : fill it */ + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) + do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); +#endif + tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); + goto redo; + } + return res; +} + +/* handle all unaligned cases */ +static DATA_TYPE +glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + int mmu_idx, + uintptr_t retaddr) +{ + DATA_TYPE res, res1, res2; + int index, shift; + hwaddr ioaddr; + target_ulong tlb_addr, addr1, addr2; + + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + ioaddr = env->iotlb[mmu_idx][index]; + res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + do_unaligned_access: + /* slow unaligned access (it spans two pages) */ + addr1 = addr & ~(DATA_SIZE - 1); + addr2 = addr1 + DATA_SIZE; + res1 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr1, + mmu_idx, retaddr); + res2 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr2, + mmu_idx, retaddr); + shift = (addr & (DATA_SIZE - 1)) * 8; +#ifdef TARGET_WORDS_BIGENDIAN + res = (res1 << shift) | (res2 >> ((DATA_SIZE * 8) - shift)); +#else + res = (res1 >> shift) | (res2 << ((DATA_SIZE * 8) - shift)); +#endif + res = (DATA_TYPE)res; + } else { + /* unaligned/aligned access in the same page */ + uintptr_t addend = env->tlb_table[mmu_idx][index].addend; + res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend)); + } + } else { + /* the page is not in the TLB : fill it */ + tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); + goto redo; + } + return res; +} + +#ifndef SOFTMMU_CODE_ACCESS + +static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + DATA_TYPE val, + int mmu_idx, + uintptr_t retaddr); + +static inline void glue(io_write, SUFFIX)(CPUArchState *env, + hwaddr physaddr, + DATA_TYPE val, + target_ulong addr, + uintptr_t retaddr) +{ + MemoryRegion *mr = iotlb_to_region(physaddr); + + physaddr = (physaddr & TARGET_PAGE_MASK) + addr; + if (mr != &io_mem_ram && mr != &io_mem_rom + && mr != &io_mem_unassigned + && mr != &io_mem_notdirty + && !can_do_io(env)) { + cpu_io_recompile(env, retaddr); + } + + env->mem_io_vaddr = addr; + env->mem_io_pc = retaddr; +#if SHIFT <= 2 + io_mem_write(mr, physaddr, val, 1 << SHIFT); +#else +#ifdef TARGET_WORDS_BIGENDIAN + io_mem_write(mr, physaddr, (val >> 32), 4); + io_mem_write(mr, physaddr + 4, (uint32_t)val, 4); +#else + io_mem_write(mr, physaddr, (uint32_t)val, 4); + io_mem_write(mr, physaddr + 4, val >> 32, 4); +#endif +#endif /* SHIFT > 2 */ +} + +void glue(glue(helper_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, DATA_TYPE val, + int mmu_idx) +{ + hwaddr ioaddr; + target_ulong tlb_addr; + uintptr_t retaddr; + int index; + + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + retaddr = GETPC_EXT(); + ioaddr = env->iotlb[mmu_idx][index]; + glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + do_unaligned_access: + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + do_unaligned_access(env, addr, 1, mmu_idx, retaddr); +#endif + glue(glue(slow_st, SUFFIX), MMUSUFFIX)(env, addr, val, + mmu_idx, retaddr); + } else { + /* aligned/unaligned access in the same page */ + uintptr_t addend; +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) { + retaddr = GETPC_EXT(); + do_unaligned_access(env, addr, 1, mmu_idx, retaddr); + } +#endif + addend = env->tlb_table[mmu_idx][index].addend; + glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend), val); + } + } else { + /* the page is not in the TLB : fill it */ + retaddr = GETPC_EXT(); +#ifdef ALIGNED_ONLY + if ((addr & (DATA_SIZE - 1)) != 0) + do_unaligned_access(env, addr, 1, mmu_idx, retaddr); +#endif + tlb_fill(env, addr, 1, mmu_idx, retaddr); + goto redo; + } +} + +/* handles all unaligned cases */ +static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, + target_ulong addr, + DATA_TYPE val, + int mmu_idx, + uintptr_t retaddr) +{ + hwaddr ioaddr; + target_ulong tlb_addr; + int index, i; + + index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + redo: + tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + if ((addr & (DATA_SIZE - 1)) != 0) + goto do_unaligned_access; + ioaddr = env->iotlb[mmu_idx][index]; + glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); + } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { + do_unaligned_access: + /* XXX: not efficient, but simple */ + /* Note: relies on the fact that tlb_fill() does not remove the + * previous page from the TLB cache. */ + for(i = DATA_SIZE - 1; i >= 0; i--) { +#ifdef TARGET_WORDS_BIGENDIAN + glue(slow_stb, MMUSUFFIX)(env, addr + i, + val >> (((DATA_SIZE - 1) * 8) - (i * 8)), + mmu_idx, retaddr); +#else + glue(slow_stb, MMUSUFFIX)(env, addr + i, + val >> (i * 8), + mmu_idx, retaddr); +#endif + } + } else { + /* aligned/unaligned access in the same page */ + uintptr_t addend = env->tlb_table[mmu_idx][index].addend; + glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) + (addr + addend), val); + } + } else { + /* the page is not in the TLB : fill it */ + tlb_fill(env, addr, 1, mmu_idx, retaddr); + goto redo; + } +} + +#endif /* !defined(SOFTMMU_CODE_ACCESS) */ + +#undef READ_ACCESS_TYPE +#undef SHIFT +#undef DATA_TYPE +#undef SUFFIX +#undef USUFFIX +#undef DATA_SIZE +#undef ADDR_READ diff --git a/include/exec/spinlock.h b/include/exec/spinlock.h new file mode 100644 index 0000000000..a72edda1d2 --- /dev/null +++ b/include/exec/spinlock.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +/* configure guarantees us that we have pthreads on any host except + * mingw32, which doesn't support any of the user-only targets. + * So we can simply assume we have pthread mutexes here. + */ +#if defined(CONFIG_USER_ONLY) + +#include +#define spin_lock pthread_mutex_lock +#define spin_unlock pthread_mutex_unlock +#define spinlock_t pthread_mutex_t +#define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER + +#else + +/* Empty implementations, on the theory that system mode emulation + * is single-threaded. This means that these functions should only + * be used from code run in the TCG cpu thread, and cannot protect + * data structures which might also be accessed from the IO thread + * or from signal handlers. + */ +typedef int spinlock_t; +#define SPIN_LOCK_UNLOCKED 0 + +static inline void spin_lock(spinlock_t *lock) +{ +} + +static inline void spin_unlock(spinlock_t *lock) +{ +} + +#endif diff --git a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h new file mode 100644 index 0000000000..fe7f6624f9 --- /dev/null +++ b/include/exec/user/abitypes.h @@ -0,0 +1,36 @@ +#ifndef QEMU_TYPES_H +#define QEMU_TYPES_H +#include "cpu.h" + +#ifdef TARGET_ABI32 +typedef uint32_t abi_ulong; +typedef int32_t abi_long; +#define TARGET_ABI_FMT_lx "%08x" +#define TARGET_ABI_FMT_ld "%d" +#define TARGET_ABI_FMT_lu "%u" +#define TARGET_ABI_BITS 32 + +static inline abi_ulong tswapal(abi_ulong v) +{ + return tswap32(v); +} + +#else +typedef target_ulong abi_ulong; +typedef target_long abi_long; +#define TARGET_ABI_FMT_lx TARGET_FMT_lx +#define TARGET_ABI_FMT_ld TARGET_FMT_ld +#define TARGET_ABI_FMT_lu TARGET_FMT_lu +#define TARGET_ABI_BITS TARGET_LONG_BITS +/* for consistency, define ABI32 too */ +#if TARGET_ABI_BITS == 32 +#define TARGET_ABI32 1 +#endif + +static inline abi_ulong tswapal(abi_ulong v) +{ + return tswapl(v); +} + +#endif +#endif diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h new file mode 100644 index 0000000000..87025c3b04 --- /dev/null +++ b/include/exec/user/thunk.h @@ -0,0 +1,189 @@ +/* + * Generic thunking code to convert data between host and target CPU + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef THUNK_H +#define THUNK_H + +#include +#include "cpu.h" + +/* types enums definitions */ + +typedef enum argtype { + TYPE_NULL, + TYPE_CHAR, + TYPE_SHORT, + TYPE_INT, + TYPE_LONG, + TYPE_ULONG, + TYPE_PTRVOID, /* pointer on unknown data */ + TYPE_LONGLONG, + TYPE_ULONGLONG, + TYPE_PTR, + TYPE_ARRAY, + TYPE_STRUCT, + TYPE_OLDDEVT, +} argtype; + +#define MK_PTR(type) TYPE_PTR, type +#define MK_ARRAY(type, size) TYPE_ARRAY, size, type +#define MK_STRUCT(id) TYPE_STRUCT, id + +#define THUNK_TARGET 0 +#define THUNK_HOST 1 + +typedef struct { + /* standard struct handling */ + const argtype *field_types; + int nb_fields; + int *field_offsets[2]; + /* special handling */ + void (*convert[2])(void *dst, const void *src); + int size[2]; + int align[2]; + const char *name; +} StructEntry; + +/* Translation table for bitmasks... */ +typedef struct bitmask_transtbl { + unsigned int x86_mask; + unsigned int x86_bits; + unsigned int alpha_mask; + unsigned int alpha_bits; +} bitmask_transtbl; + +void thunk_register_struct(int id, const char *name, const argtype *types); +void thunk_register_struct_direct(int id, const char *name, + const StructEntry *se1); +const argtype *thunk_convert(void *dst, const void *src, + const argtype *type_ptr, int to_host); +#ifndef NO_THUNK_TYPE_SIZE + +extern StructEntry struct_entries[]; + +int thunk_type_size_array(const argtype *type_ptr, int is_host); +int thunk_type_align_array(const argtype *type_ptr, int is_host); + +static inline int thunk_type_size(const argtype *type_ptr, int is_host) +{ + int type, size; + const StructEntry *se; + + type = *type_ptr; + switch(type) { + case TYPE_CHAR: + return 1; + case TYPE_SHORT: + return 2; + case TYPE_INT: + return 4; + case TYPE_LONGLONG: + case TYPE_ULONGLONG: + return 8; + case TYPE_LONG: + case TYPE_ULONG: + case TYPE_PTRVOID: + case TYPE_PTR: + if (is_host) { + return sizeof(void *); + } else { + return TARGET_ABI_BITS / 8; + } + break; + case TYPE_OLDDEVT: + if (is_host) { +#if defined(HOST_X86_64) + return 8; +#elif defined(HOST_ALPHA) || defined(HOST_IA64) || defined(HOST_MIPS) || \ + defined(HOST_PARISC) || defined(HOST_SPARC64) + return 4; +#elif defined(HOST_PPC) + return sizeof(void *); +#else + return 2; +#endif + } else { +#if defined(TARGET_X86_64) + return 8; +#elif defined(TARGET_ALPHA) || defined(TARGET_IA64) || defined(TARGET_MIPS) || \ + defined(TARGET_PARISC) || defined(TARGET_SPARC64) + return 4; +#elif defined(TARGET_PPC) + return TARGET_ABI_BITS / 8; +#else + return 2; +#endif + } + break; + case TYPE_ARRAY: + size = type_ptr[1]; + return size * thunk_type_size_array(type_ptr + 2, is_host); + case TYPE_STRUCT: + se = struct_entries + type_ptr[1]; + return se->size[is_host]; + default: + return -1; + } +} + +static inline int thunk_type_align(const argtype *type_ptr, int is_host) +{ + int type; + const StructEntry *se; + + type = *type_ptr; + switch(type) { + case TYPE_CHAR: + return 1; + case TYPE_SHORT: + return 2; + case TYPE_INT: + return 4; + case TYPE_LONGLONG: + case TYPE_ULONGLONG: + return 8; + case TYPE_LONG: + case TYPE_ULONG: + case TYPE_PTRVOID: + case TYPE_PTR: + if (is_host) { + return sizeof(void *); + } else { + return TARGET_ABI_BITS / 8; + } + break; + case TYPE_OLDDEVT: + return thunk_type_size(type_ptr, is_host); + case TYPE_ARRAY: + return thunk_type_align_array(type_ptr + 2, is_host); + case TYPE_STRUCT: + se = struct_entries + type_ptr[1]; + return se->align[is_host]; + default: + return -1; + } +} + +#endif /* NO_THUNK_TYPE_SIZE */ + +unsigned int target_to_host_bitmask(unsigned int x86_mask, + const bitmask_transtbl * trans_tbl); +unsigned int host_to_target_bitmask(unsigned int alpha_mask, + const bitmask_transtbl * trans_tbl); + +#endif diff --git a/ioport.c b/ioport.c index 6e4ca0dd91..a0ac2a0a41 100644 --- a/ioport.c +++ b/ioport.c @@ -25,9 +25,9 @@ * splitted out ioport related stuffs from vl.c. */ -#include "ioport.h" +#include "exec/ioport.h" #include "trace.h" -#include "memory.h" +#include "exec/memory.h" /***********************************************************/ /* IO Port */ diff --git a/ioport.h b/ioport.h deleted file mode 100644 index 23441cba08..0000000000 --- a/ioport.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * defines ioport related functions - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/************************************************************************** - * IO ports API - */ - -#ifndef IOPORT_H -#define IOPORT_H - -#include "qemu-common.h" -#include "iorange.h" - -typedef uint32_t pio_addr_t; -#define FMT_pioaddr PRIx32 - -#define MAX_IOPORTS (64 * 1024) -#define IOPORTS_MASK (MAX_IOPORTS - 1) - -/* These should really be in isa.h, but are here to make pc.h happy. */ -typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); -typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); -typedef void (IOPortDestructor)(void *opaque); - -void ioport_register(IORange *iorange); -int register_ioport_read(pio_addr_t start, int length, int size, - IOPortReadFunc *func, void *opaque); -int register_ioport_write(pio_addr_t start, int length, int size, - IOPortWriteFunc *func, void *opaque); -void isa_unassign_ioport(pio_addr_t start, int length); -bool isa_is_ioport_assigned(pio_addr_t start); - -void cpu_outb(pio_addr_t addr, uint8_t val); -void cpu_outw(pio_addr_t addr, uint16_t val); -void cpu_outl(pio_addr_t addr, uint32_t val); -uint8_t cpu_inb(pio_addr_t addr); -uint16_t cpu_inw(pio_addr_t addr); -uint32_t cpu_inl(pio_addr_t addr); - -struct MemoryRegion; -struct MemoryRegionPortio; - -typedef struct PortioList { - const struct MemoryRegionPortio *ports; - struct MemoryRegion *address_space; - unsigned nr; - struct MemoryRegion **regions; - struct MemoryRegion **aliases; - void *opaque; - const char *name; -} PortioList; - -void portio_list_init(PortioList *piolist, - const struct MemoryRegionPortio *callbacks, - void *opaque, const char *name); -void portio_list_destroy(PortioList *piolist); -void portio_list_add(PortioList *piolist, - struct MemoryRegion *address_space, - uint32_t addr); -void portio_list_del(PortioList *piolist); - -#endif /* IOPORT_H */ diff --git a/iorange.h b/iorange.h deleted file mode 100644 index cd980a8312..0000000000 --- a/iorange.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef IORANGE_H -#define IORANGE_H - -#include - -typedef struct IORange IORange; -typedef struct IORangeOps IORangeOps; - -struct IORangeOps { - void (*read)(IORange *iorange, uint64_t offset, unsigned width, - uint64_t *data); - void (*write)(IORange *iorange, uint64_t offset, unsigned width, - uint64_t data); - void (*destructor)(IORange *iorange); -}; - -struct IORange { - const IORangeOps *ops; - uint64_t base; - uint64_t len; -}; - -static inline void iorange_init(IORange *iorange, const IORangeOps *ops, - uint64_t base, uint64_t len) -{ - iorange->ops = ops; - iorange->base = base; - iorange->len = len; -} - -#endif diff --git a/kvm-all.c b/kvm-all.c index 759ef17ab0..c2588594e1 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -27,11 +27,11 @@ #include "sysemu.h" #include "hw/hw.h" #include "hw/pci/msi.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "kvm.h" #include "bswap.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #include "event_notifier.h" /* This check must be after config-host.h is included */ diff --git a/kvm-stub.c b/kvm-stub.c index d65fd04507..8de8ebd3d2 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -14,7 +14,7 @@ #include "hw/hw.h" #include "hw/pci/msi.h" #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "kvm.h" KVMState *kvm_state; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index ceddb3ce72..2af883bf74 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -11,13 +11,13 @@ #include #endif /* DEBUG_REMAP */ -#include "qemu-user-types.h" +#include "exec/user/abitypes.h" -#include "thunk.h" +#include "exec/user/thunk.h" #include "syscall_defs.h" #include "syscall.h" #include "target_signal.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "qemu-queue.h" #if defined(CONFIG_USE_NPTL) diff --git a/memory-internal.h b/memory-internal.h deleted file mode 100644 index 1da240039d..0000000000 --- a/memory-internal.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Declarations for obsolete exec.c functions - * - * Copyright 2011 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2 or - * later. See the COPYING file in the top-level directory. - * - */ - -/* - * This header is for use by exec.c and memory.c ONLY. Do not include it. - * The functions declared here will be removed soon. - */ - -#ifndef MEMORY_INTERNAL_H -#define MEMORY_INTERNAL_H - -#ifndef CONFIG_USER_ONLY -#include "hw/xen.h" - -typedef struct PhysPageEntry PhysPageEntry; - -struct PhysPageEntry { - uint16_t is_leaf : 1; - /* index into phys_sections (is_leaf) or phys_map_nodes (!is_leaf) */ - uint16_t ptr : 15; -}; - -typedef struct AddressSpaceDispatch AddressSpaceDispatch; - -struct AddressSpaceDispatch { - /* This is a multi-level map on the physical address space. - * The bottom level has pointers to MemoryRegionSections. - */ - PhysPageEntry phys_map; - MemoryListener listener; -}; - -void address_space_init_dispatch(AddressSpace *as); -void address_space_destroy_dispatch(AddressSpace *as); - -ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, - MemoryRegion *mr); -ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); -void qemu_ram_free(ram_addr_t addr); -void qemu_ram_free_from_ptr(ram_addr_t addr); - -struct MemoryRegion; -struct MemoryRegionSection; - -void qemu_register_coalesced_mmio(hwaddr addr, ram_addr_t size); -void qemu_unregister_coalesced_mmio(hwaddr addr, ram_addr_t size); - -#define VGA_DIRTY_FLAG 0x01 -#define CODE_DIRTY_FLAG 0x02 -#define MIGRATION_DIRTY_FLAG 0x08 - -static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) -{ - return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS]; -} - -/* read dirty bit (return 0 or 1) */ -static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) -{ - return cpu_physical_memory_get_dirty_flags(addr) == 0xff; -} - -static inline int cpu_physical_memory_get_dirty(ram_addr_t start, - ram_addr_t length, - int dirty_flags) -{ - int ret = 0; - ram_addr_t addr, end; - - end = TARGET_PAGE_ALIGN(start + length); - start &= TARGET_PAGE_MASK; - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - ret |= cpu_physical_memory_get_dirty_flags(addr) & dirty_flags; - } - return ret; -} - -static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, - int dirty_flags) -{ - return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; -} - -static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) -{ - cpu_physical_memory_set_dirty_flags(addr, 0xff); -} - -static inline int cpu_physical_memory_clear_dirty_flags(ram_addr_t addr, - int dirty_flags) -{ - int mask = ~dirty_flags; - - return ram_list.phys_dirty[addr >> TARGET_PAGE_BITS] &= mask; -} - -static inline void cpu_physical_memory_set_dirty_range(ram_addr_t start, - ram_addr_t length, - int dirty_flags) -{ - ram_addr_t addr, end; - - end = TARGET_PAGE_ALIGN(start + length); - start &= TARGET_PAGE_MASK; - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - cpu_physical_memory_set_dirty_flags(addr, dirty_flags); - } - xen_modified_memory(addr, length); -} - -static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, - ram_addr_t length, - int dirty_flags) -{ - ram_addr_t addr, end; - - end = TARGET_PAGE_ALIGN(start + length); - start &= TARGET_PAGE_MASK; - for (addr = start; addr < end; addr += TARGET_PAGE_SIZE) { - cpu_physical_memory_clear_dirty_flags(addr, dirty_flags); - } -} - -void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, - int dirty_flags); - -extern const IORangeOps memory_region_iorange_ops; - -#endif - -#endif diff --git a/memory.c b/memory.c index 741985385c..d40193d474 100644 --- a/memory.c +++ b/memory.c @@ -13,14 +13,14 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "memory.h" -#include "exec-memory.h" -#include "ioport.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" +#include "exec/ioport.h" #include "bitops.h" #include "kvm.h" #include -#include "memory-internal.h" +#include "exec/memory-internal.h" static unsigned memory_region_transaction_depth; static bool memory_region_update_pending; diff --git a/memory.h b/memory.h deleted file mode 100644 index 9462bfd3ad..0000000000 --- a/memory.h +++ /dev/null @@ -1,882 +0,0 @@ -/* - * Physical memory management API - * - * Copyright 2011 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef MEMORY_H -#define MEMORY_H - -#ifndef CONFIG_USER_ONLY - -#include -#include -#include "qemu-common.h" -#include "cpu-common.h" -#include "hwaddr.h" -#include "qemu-queue.h" -#include "iorange.h" -#include "ioport.h" -#include "int128.h" - -typedef struct MemoryRegionOps MemoryRegionOps; -typedef struct MemoryRegion MemoryRegion; -typedef struct MemoryRegionPortio MemoryRegionPortio; -typedef struct MemoryRegionMmio MemoryRegionMmio; - -/* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic - * registration. - */ -#define DIRTY_MEMORY_VGA 0 -#define DIRTY_MEMORY_CODE 1 -#define DIRTY_MEMORY_MIGRATION 3 - -struct MemoryRegionMmio { - CPUReadMemoryFunc *read[3]; - CPUWriteMemoryFunc *write[3]; -}; - -/* Internal use; thunks between old-style IORange and MemoryRegions. */ -typedef struct MemoryRegionIORange MemoryRegionIORange; -struct MemoryRegionIORange { - IORange iorange; - MemoryRegion *mr; - hwaddr offset; -}; - -/* - * Memory region callbacks - */ -struct MemoryRegionOps { - /* Read from the memory region. @addr is relative to @mr; @size is - * in bytes. */ - uint64_t (*read)(void *opaque, - hwaddr addr, - unsigned size); - /* Write to the memory region. @addr is relative to @mr; @size is - * in bytes. */ - void (*write)(void *opaque, - hwaddr addr, - uint64_t data, - unsigned size); - - enum device_endian endianness; - /* Guest-visible constraints: */ - struct { - /* If nonzero, specify bounds on access sizes beyond which a machine - * check is thrown. - */ - unsigned min_access_size; - unsigned max_access_size; - /* If true, unaligned accesses are supported. Otherwise unaligned - * accesses throw machine checks. - */ - bool unaligned; - /* - * If present, and returns #false, the transaction is not accepted - * by the device (and results in machine dependent behaviour such - * as a machine check exception). - */ - bool (*accepts)(void *opaque, hwaddr addr, - unsigned size, bool is_write); - } valid; - /* Internal implementation constraints: */ - struct { - /* If nonzero, specifies the minimum size implemented. Smaller sizes - * will be rounded upwards and a partial result will be returned. - */ - unsigned min_access_size; - /* If nonzero, specifies the maximum size implemented. Larger sizes - * will be done as a series of accesses with smaller sizes. - */ - unsigned max_access_size; - /* If true, unaligned accesses are supported. Otherwise all accesses - * are converted to (possibly multiple) naturally aligned accesses. - */ - bool unaligned; - } impl; - - /* If .read and .write are not present, old_portio may be used for - * backwards compatibility with old portio registration - */ - const MemoryRegionPortio *old_portio; - /* If .read and .write are not present, old_mmio may be used for - * backwards compatibility with old mmio registration - */ - const MemoryRegionMmio old_mmio; -}; - -typedef struct CoalescedMemoryRange CoalescedMemoryRange; -typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; - -struct MemoryRegion { - /* All fields are private - violators will be prosecuted */ - const MemoryRegionOps *ops; - void *opaque; - MemoryRegion *parent; - Int128 size; - hwaddr addr; - void (*destructor)(MemoryRegion *mr); - ram_addr_t ram_addr; - bool subpage; - bool terminates; - bool readable; - bool ram; - bool readonly; /* For RAM regions */ - bool enabled; - bool rom_device; - bool warning_printed; /* For reservations */ - bool flush_coalesced_mmio; - MemoryRegion *alias; - hwaddr alias_offset; - unsigned priority; - bool may_overlap; - QTAILQ_HEAD(subregions, MemoryRegion) subregions; - QTAILQ_ENTRY(MemoryRegion) subregions_link; - QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; - const char *name; - uint8_t dirty_log_mask; - unsigned ioeventfd_nb; - MemoryRegionIoeventfd *ioeventfds; -}; - -struct MemoryRegionPortio { - uint32_t offset; - uint32_t len; - unsigned size; - IOPortReadFunc *read; - IOPortWriteFunc *write; -}; - -#define PORTIO_END_OF_LIST() { } - -typedef struct AddressSpace AddressSpace; - -/** - * AddressSpace: describes a mapping of addresses to #MemoryRegion objects - */ -struct AddressSpace { - /* All fields are private. */ - const char *name; - MemoryRegion *root; - struct FlatView *current_map; - int ioeventfd_nb; - struct MemoryRegionIoeventfd *ioeventfds; - struct AddressSpaceDispatch *dispatch; - QTAILQ_ENTRY(AddressSpace) address_spaces_link; -}; - -typedef struct MemoryRegionSection MemoryRegionSection; - -/** - * MemoryRegionSection: describes a fragment of a #MemoryRegion - * - * @mr: the region, or %NULL if empty - * @address_space: the address space the region is mapped in - * @offset_within_region: the beginning of the section, relative to @mr's start - * @size: the size of the section; will not exceed @mr's boundaries - * @offset_within_address_space: the address of the first byte of the section - * relative to the region's address space - * @readonly: writes to this section are ignored - */ -struct MemoryRegionSection { - MemoryRegion *mr; - AddressSpace *address_space; - hwaddr offset_within_region; - uint64_t size; - hwaddr offset_within_address_space; - bool readonly; -}; - -typedef struct MemoryListener MemoryListener; - -/** - * MemoryListener: callbacks structure for updates to the physical memory map - * - * Allows a component to adjust to changes in the guest-visible memory map. - * Use with memory_listener_register() and memory_listener_unregister(). - */ -struct MemoryListener { - void (*begin)(MemoryListener *listener); - void (*commit)(MemoryListener *listener); - void (*region_add)(MemoryListener *listener, MemoryRegionSection *section); - void (*region_del)(MemoryListener *listener, MemoryRegionSection *section); - void (*region_nop)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_start)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_stop)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_sync)(MemoryListener *listener, MemoryRegionSection *section); - void (*log_global_start)(MemoryListener *listener); - void (*log_global_stop)(MemoryListener *listener); - void (*eventfd_add)(MemoryListener *listener, MemoryRegionSection *section, - bool match_data, uint64_t data, EventNotifier *e); - void (*eventfd_del)(MemoryListener *listener, MemoryRegionSection *section, - bool match_data, uint64_t data, EventNotifier *e); - void (*coalesced_mmio_add)(MemoryListener *listener, MemoryRegionSection *section, - hwaddr addr, hwaddr len); - void (*coalesced_mmio_del)(MemoryListener *listener, MemoryRegionSection *section, - hwaddr addr, hwaddr len); - /* Lower = earlier (during add), later (during del) */ - unsigned priority; - AddressSpace *address_space_filter; - QTAILQ_ENTRY(MemoryListener) link; -}; - -/** - * memory_region_init: Initialize a memory region - * - * The region typically acts as a container for other memory regions. Use - * memory_region_add_subregion() to add subregions. - * - * @mr: the #MemoryRegion to be initialized - * @name: used for debugging; not visible to the user or ABI - * @size: size of the region; any subregions beyond this size will be clipped - */ -void memory_region_init(MemoryRegion *mr, - const char *name, - uint64_t size); -/** - * memory_region_init_io: Initialize an I/O memory region. - * - * Accesses into the region will cause the callbacks in @ops to be called. - * if @size is nonzero, subregions will be clipped to @size. - * - * @mr: the #MemoryRegion to be initialized. - * @ops: a structure containing read and write callbacks to be used when - * I/O is performed on the region. - * @opaque: passed to to the read and write callbacks of the @ops structure. - * @name: used for debugging; not visible to the user or ABI - * @size: size of the region. - */ -void memory_region_init_io(MemoryRegion *mr, - const MemoryRegionOps *ops, - void *opaque, - const char *name, - uint64_t size); - -/** - * memory_region_init_ram: Initialize RAM memory region. Accesses into the - * region will modify memory directly. - * - * @mr: the #MemoryRegion to be initialized. - * @name: the name of the region. - * @size: size of the region. - */ -void memory_region_init_ram(MemoryRegion *mr, - const char *name, - uint64_t size); - -/** - * memory_region_init_ram_ptr: Initialize RAM memory region from a - * user-provided pointer. Accesses into the - * region will modify memory directly. - * - * @mr: the #MemoryRegion to be initialized. - * @name: the name of the region. - * @size: size of the region. - * @ptr: memory to be mapped; must contain at least @size bytes. - */ -void memory_region_init_ram_ptr(MemoryRegion *mr, - const char *name, - uint64_t size, - void *ptr); - -/** - * memory_region_init_alias: Initialize a memory region that aliases all or a - * part of another memory region. - * - * @mr: the #MemoryRegion to be initialized. - * @name: used for debugging; not visible to the user or ABI - * @orig: the region to be referenced; @mr will be equivalent to - * @orig between @offset and @offset + @size - 1. - * @offset: start of the section in @orig to be referenced. - * @size: size of the region. - */ -void memory_region_init_alias(MemoryRegion *mr, - const char *name, - MemoryRegion *orig, - hwaddr offset, - uint64_t size); - -/** - * memory_region_init_rom_device: Initialize a ROM memory region. Writes are - * handled via callbacks. - * - * @mr: the #MemoryRegion to be initialized. - * @ops: callbacks for write access handling. - * @name: the name of the region. - * @size: size of the region. - */ -void memory_region_init_rom_device(MemoryRegion *mr, - const MemoryRegionOps *ops, - void *opaque, - const char *name, - uint64_t size); - -/** - * memory_region_init_reservation: Initialize a memory region that reserves - * I/O space. - * - * A reservation region primariy serves debugging purposes. It claims I/O - * space that is not supposed to be handled by QEMU itself. Any access via - * the memory API will cause an abort(). - * - * @mr: the #MemoryRegion to be initialized - * @name: used for debugging; not visible to the user or ABI - * @size: size of the region. - */ -void memory_region_init_reservation(MemoryRegion *mr, - const char *name, - uint64_t size); -/** - * memory_region_destroy: Destroy a memory region and reclaim all resources. - * - * @mr: the region to be destroyed. May not currently be a subregion - * (see memory_region_add_subregion()) or referenced in an alias - * (see memory_region_init_alias()). - */ -void memory_region_destroy(MemoryRegion *mr); - -/** - * memory_region_size: get a memory region's size. - * - * @mr: the memory region being queried. - */ -uint64_t memory_region_size(MemoryRegion *mr); - -/** - * memory_region_is_ram: check whether a memory region is random access - * - * Returns %true is a memory region is random access. - * - * @mr: the memory region being queried - */ -bool memory_region_is_ram(MemoryRegion *mr); - -/** - * memory_region_is_romd: check whether a memory region is ROMD - * - * Returns %true is a memory region is ROMD and currently set to allow - * direct reads. - * - * @mr: the memory region being queried - */ -static inline bool memory_region_is_romd(MemoryRegion *mr) -{ - return mr->rom_device && mr->readable; -} - -/** - * memory_region_name: get a memory region's name - * - * Returns the string that was used to initialize the memory region. - * - * @mr: the memory region being queried - */ -const char *memory_region_name(MemoryRegion *mr); - -/** - * memory_region_is_logging: return whether a memory region is logging writes - * - * Returns %true if the memory region is logging writes - * - * @mr: the memory region being queried - */ -bool memory_region_is_logging(MemoryRegion *mr); - -/** - * memory_region_is_rom: check whether a memory region is ROM - * - * Returns %true is a memory region is read-only memory. - * - * @mr: the memory region being queried - */ -bool memory_region_is_rom(MemoryRegion *mr); - -/** - * memory_region_get_ram_ptr: Get a pointer into a RAM memory region. - * - * Returns a host pointer to a RAM memory region (created with - * memory_region_init_ram() or memory_region_init_ram_ptr()). Use with - * care. - * - * @mr: the memory region being queried. - */ -void *memory_region_get_ram_ptr(MemoryRegion *mr); - -/** - * memory_region_set_log: Turn dirty logging on or off for a region. - * - * Turns dirty logging on or off for a specified client (display, migration). - * Only meaningful for RAM regions. - * - * @mr: the memory region being updated. - * @log: whether dirty logging is to be enabled or disabled. - * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or - * %DIRTY_MEMORY_VGA. - */ -void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client); - -/** - * memory_region_get_dirty: Check whether a range of bytes is dirty - * for a specified client. - * - * Checks whether a range of bytes has been written to since the last - * call to memory_region_reset_dirty() with the same @client. Dirty logging - * must be enabled. - * - * @mr: the memory region being queried. - * @addr: the address (relative to the start of the region) being queried. - * @size: the size of the range being queried. - * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or - * %DIRTY_MEMORY_VGA. - */ -bool memory_region_get_dirty(MemoryRegion *mr, hwaddr addr, - hwaddr size, unsigned client); - -/** - * memory_region_set_dirty: Mark a range of bytes as dirty in a memory region. - * - * Marks a range of bytes as dirty, after it has been dirtied outside - * guest code. - * - * @mr: the memory region being dirtied. - * @addr: the address (relative to the start of the region) being dirtied. - * @size: size of the range being dirtied. - */ -void memory_region_set_dirty(MemoryRegion *mr, hwaddr addr, - hwaddr size); - -/** - * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap with - * any external TLBs (e.g. kvm) - * - * Flushes dirty information from accelerators such as kvm and vhost-net - * and makes it available to users of the memory API. - * - * @mr: the region being flushed. - */ -void memory_region_sync_dirty_bitmap(MemoryRegion *mr); - -/** - * memory_region_reset_dirty: Mark a range of pages as clean, for a specified - * client. - * - * Marks a range of pages as no longer dirty. - * - * @mr: the region being updated. - * @addr: the start of the subrange being cleaned. - * @size: the size of the subrange being cleaned. - * @client: the user of the logging information; %DIRTY_MEMORY_MIGRATION or - * %DIRTY_MEMORY_VGA. - */ -void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, - hwaddr size, unsigned client); - -/** - * memory_region_set_readonly: Turn a memory region read-only (or read-write) - * - * Allows a memory region to be marked as read-only (turning it into a ROM). - * only useful on RAM regions. - * - * @mr: the region being updated. - * @readonly: whether rhe region is to be ROM or RAM. - */ -void memory_region_set_readonly(MemoryRegion *mr, bool readonly); - -/** - * memory_region_rom_device_set_readable: enable/disable ROM readability - * - * Allows a ROM device (initialized with memory_region_init_rom_device() to - * to be marked as readable (default) or not readable. When it is readable, - * the device is mapped to guest memory. When not readable, reads are - * forwarded to the #MemoryRegion.read function. - * - * @mr: the memory region to be updated - * @readable: whether reads are satisified directly (%true) or via callbacks - * (%false) - */ -void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable); - -/** - * memory_region_set_coalescing: Enable memory coalescing for the region. - * - * Enabled writes to a region to be queued for later processing. MMIO ->write - * callbacks may be delayed until a non-coalesced MMIO is issued. - * Only useful for IO regions. Roughly similar to write-combining hardware. - * - * @mr: the memory region to be write coalesced - */ -void memory_region_set_coalescing(MemoryRegion *mr); - -/** - * memory_region_add_coalescing: Enable memory coalescing for a sub-range of - * a region. - * - * Like memory_region_set_coalescing(), but works on a sub-range of a region. - * Multiple calls can be issued coalesced disjoint ranges. - * - * @mr: the memory region to be updated. - * @offset: the start of the range within the region to be coalesced. - * @size: the size of the subrange to be coalesced. - */ -void memory_region_add_coalescing(MemoryRegion *mr, - hwaddr offset, - uint64_t size); - -/** - * memory_region_clear_coalescing: Disable MMIO coalescing for the region. - * - * Disables any coalescing caused by memory_region_set_coalescing() or - * memory_region_add_coalescing(). Roughly equivalent to uncacheble memory - * hardware. - * - * @mr: the memory region to be updated. - */ -void memory_region_clear_coalescing(MemoryRegion *mr); - -/** - * memory_region_set_flush_coalesced: Enforce memory coalescing flush before - * accesses. - * - * Ensure that pending coalesced MMIO request are flushed before the memory - * region is accessed. This property is automatically enabled for all regions - * passed to memory_region_set_coalescing() and memory_region_add_coalescing(). - * - * @mr: the memory region to be updated. - */ -void memory_region_set_flush_coalesced(MemoryRegion *mr); - -/** - * memory_region_clear_flush_coalesced: Disable memory coalescing flush before - * accesses. - * - * Clear the automatic coalesced MMIO flushing enabled via - * memory_region_set_flush_coalesced. Note that this service has no effect on - * memory regions that have MMIO coalescing enabled for themselves. For them, - * automatic flushing will stop once coalescing is disabled. - * - * @mr: the memory region to be updated. - */ -void memory_region_clear_flush_coalesced(MemoryRegion *mr); - -/** - * memory_region_add_eventfd: Request an eventfd to be triggered when a word - * is written to a location. - * - * Marks a word in an IO region (initialized with memory_region_init_io()) - * as a trigger for an eventfd event. The I/O callback will not be called. - * The caller must be prepared to handle failure (that is, take the required - * action if the callback _is_ called). - * - * @mr: the memory region being updated. - * @addr: the address within @mr that is to be monitored - * @size: the size of the access to trigger the eventfd - * @match_data: whether to match against @data, instead of just @addr - * @data: the data to match against the guest write - * @fd: the eventfd to be triggered when @addr, @size, and @data all match. - **/ -void memory_region_add_eventfd(MemoryRegion *mr, - hwaddr addr, - unsigned size, - bool match_data, - uint64_t data, - EventNotifier *e); - -/** - * memory_region_del_eventfd: Cancel an eventfd. - * - * Cancels an eventfd trigger requested by a previous - * memory_region_add_eventfd() call. - * - * @mr: the memory region being updated. - * @addr: the address within @mr that is to be monitored - * @size: the size of the access to trigger the eventfd - * @match_data: whether to match against @data, instead of just @addr - * @data: the data to match against the guest write - * @fd: the eventfd to be triggered when @addr, @size, and @data all match. - */ -void memory_region_del_eventfd(MemoryRegion *mr, - hwaddr addr, - unsigned size, - bool match_data, - uint64_t data, - EventNotifier *e); - -/** - * memory_region_add_subregion: Add a subregion to a container. - * - * Adds a subregion at @offset. The subregion may not overlap with other - * subregions (except for those explicitly marked as overlapping). A region - * may only be added once as a subregion (unless removed with - * memory_region_del_subregion()); use memory_region_init_alias() if you - * want a region to be a subregion in multiple locations. - * - * @mr: the region to contain the new subregion; must be a container - * initialized with memory_region_init(). - * @offset: the offset relative to @mr where @subregion is added. - * @subregion: the subregion to be added. - */ -void memory_region_add_subregion(MemoryRegion *mr, - hwaddr offset, - MemoryRegion *subregion); -/** - * memory_region_add_subregion_overlap: Add a subregion to a container - * with overlap. - * - * Adds a subregion at @offset. The subregion may overlap with other - * subregions. Conflicts are resolved by having a higher @priority hide a - * lower @priority. Subregions without priority are taken as @priority 0. - * A region may only be added once as a subregion (unless removed with - * memory_region_del_subregion()); use memory_region_init_alias() if you - * want a region to be a subregion in multiple locations. - * - * @mr: the region to contain the new subregion; must be a container - * initialized with memory_region_init(). - * @offset: the offset relative to @mr where @subregion is added. - * @subregion: the subregion to be added. - * @priority: used for resolving overlaps; highest priority wins. - */ -void memory_region_add_subregion_overlap(MemoryRegion *mr, - hwaddr offset, - MemoryRegion *subregion, - unsigned priority); - -/** - * memory_region_get_ram_addr: Get the ram address associated with a memory - * region - * - * DO NOT USE THIS FUNCTION. This is a temporary workaround while the Xen - * code is being reworked. - */ -ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr); - -/** - * memory_region_del_subregion: Remove a subregion. - * - * Removes a subregion from its container. - * - * @mr: the container to be updated. - * @subregion: the region being removed; must be a current subregion of @mr. - */ -void memory_region_del_subregion(MemoryRegion *mr, - MemoryRegion *subregion); - -/* - * memory_region_set_enabled: dynamically enable or disable a region - * - * Enables or disables a memory region. A disabled memory region - * ignores all accesses to itself and its subregions. It does not - * obscure sibling subregions with lower priority - it simply behaves as - * if it was removed from the hierarchy. - * - * Regions default to being enabled. - * - * @mr: the region to be updated - * @enabled: whether to enable or disable the region - */ -void memory_region_set_enabled(MemoryRegion *mr, bool enabled); - -/* - * memory_region_set_address: dynamically update the address of a region - * - * Dynamically updates the address of a region, relative to its parent. - * May be used on regions are currently part of a memory hierarchy. - * - * @mr: the region to be updated - * @addr: new address, relative to parent region - */ -void memory_region_set_address(MemoryRegion *mr, hwaddr addr); - -/* - * memory_region_set_alias_offset: dynamically update a memory alias's offset - * - * Dynamically updates the offset into the target region that an alias points - * to, as if the fourth argument to memory_region_init_alias() has changed. - * - * @mr: the #MemoryRegion to be updated; should be an alias. - * @offset: the new offset into the target memory region - */ -void memory_region_set_alias_offset(MemoryRegion *mr, - hwaddr offset); - -/** - * memory_region_find: locate a MemoryRegion in an address space - * - * Locates the first #MemoryRegion within an address space given by - * @address_space that overlaps the range given by @addr and @size. - * - * Returns a #MemoryRegionSection that describes a contiguous overlap. - * It will have the following characteristics: - * .@offset_within_address_space >= @addr - * .@offset_within_address_space + .@size <= @addr + @size - * .@size = 0 iff no overlap was found - * .@mr is non-%NULL iff an overlap was found - * - * @address_space: a top-level (i.e. parentless) region that contains - * the region to be found - * @addr: start of the area within @address_space to be searched - * @size: size of the area to be searched - */ -MemoryRegionSection memory_region_find(MemoryRegion *address_space, - hwaddr addr, uint64_t size); - -/** - * memory_region_section_addr: get offset within MemoryRegionSection - * - * Returns offset within MemoryRegionSection - * - * @section: the memory region section being queried - * @addr: address in address space - */ -static inline hwaddr -memory_region_section_addr(MemoryRegionSection *section, - hwaddr addr) -{ - addr -= section->offset_within_address_space; - addr += section->offset_within_region; - return addr; -} - -/** - * memory_global_sync_dirty_bitmap: synchronize the dirty log for all memory - * - * Synchronizes the dirty page log for an entire address space. - * @address_space: a top-level (i.e. parentless) region that contains the - * memory being synchronized - */ -void memory_global_sync_dirty_bitmap(MemoryRegion *address_space); - -/** - * memory_region_transaction_begin: Start a transaction. - * - * During a transaction, changes will be accumulated and made visible - * only when the transaction ends (is committed). - */ -void memory_region_transaction_begin(void); - -/** - * memory_region_transaction_commit: Commit a transaction and make changes - * visible to the guest. - */ -void memory_region_transaction_commit(void); - -/** - * memory_listener_register: register callbacks to be called when memory - * sections are mapped or unmapped into an address - * space - * - * @listener: an object containing the callbacks to be called - * @filter: if non-%NULL, only regions in this address space will be observed - */ -void memory_listener_register(MemoryListener *listener, AddressSpace *filter); - -/** - * memory_listener_unregister: undo the effect of memory_listener_register() - * - * @listener: an object containing the callbacks to be removed - */ -void memory_listener_unregister(MemoryListener *listener); - -/** - * memory_global_dirty_log_start: begin dirty logging for all regions - */ -void memory_global_dirty_log_start(void); - -/** - * memory_global_dirty_log_stop: end dirty logging for all regions - */ -void memory_global_dirty_log_stop(void); - -void mtree_info(fprintf_function mon_printf, void *f); - -/** - * address_space_init: initializes an address space - * - * @as: an uninitialized #AddressSpace - * @root: a #MemoryRegion that routes addesses for the address space - */ -void address_space_init(AddressSpace *as, MemoryRegion *root); - - -/** - * address_space_destroy: destroy an address space - * - * Releases all resources associated with an address space. After an address space - * is destroyed, its root memory region (given by address_space_init()) may be destroyed - * as well. - * - * @as: address space to be destroyed - */ -void address_space_destroy(AddressSpace *as); - -/** - * address_space_rw: read from or write to an address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - * @is_write: indicates the transfer direction - */ -void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, - int len, bool is_write); - -/** - * address_space_write: write to address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - */ -void address_space_write(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len); - -/** - * address_space_read: read from an address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - */ -void address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len); - -/* address_space_map: map a physical memory region into a host virtual address - * - * May map a subset of the requested range, given by and returned in @plen. - * May return %NULL if resources needed to perform the mapping are exhausted. - * Use only for reads OR writes - not for read-modify-write operations. - * Use cpu_register_map_client() to know when retrying the map operation is - * likely to succeed. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @plen: pointer to length of buffer; updated on return - * @is_write: indicates the transfer direction - */ -void *address_space_map(AddressSpace *as, hwaddr addr, - hwaddr *plen, bool is_write); - -/* address_space_unmap: Unmaps a memory region previously mapped by address_space_map() - * - * Will also mark the memory as dirty if @is_write == %true. @access_len gives - * the amount of memory that was actually read or written by the caller. - * - * @as: #AddressSpace used - * @addr: address within that address space - * @len: buffer length as returned by address_space_map() - * @access_len: amount of data actually transferred - * @is_write: indicates the transfer direction - */ -void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, - int is_write, hwaddr access_len); - - -#endif - -#endif diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c index 76be34d89f..5f5fb99c58 100644 --- a/memory_mapping-stub.c +++ b/memory_mapping-stub.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "memory_mapping.h" int qemu_get_guest_memory_mapping(MemoryMappingList *list) diff --git a/memory_mapping.c b/memory_mapping.c index a82e190cab..c829a9fa34 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "memory_mapping.h" static void memory_mapping_list_add_mapping_sorted(MemoryMappingList *list, diff --git a/monitor.c b/monitor.c index 7d5c8a622c..a3e010968e 100644 --- a/monitor.c +++ b/monitor.c @@ -30,7 +30,7 @@ #include "hw/pci/pci.h" #include "hw/watchdog.h" #include "hw/loader.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "net/net.h" #include "net/slirp.h" #include "qemu-char.h" @@ -63,7 +63,7 @@ #include "trace/simple.h" #endif #include "ui/qemu-spice.h" -#include "memory.h" +#include "exec/memory.h" #include "qmp-commands.h" #include "hmp.h" #include "qemu-thread.h" diff --git a/poison.h b/poison.h deleted file mode 100644 index 7d7b23b1fc..0000000000 --- a/poison.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Poison identifiers that should not be used when building - target independent device code. */ - -#ifndef HW_POISON_H -#define HW_POISON_H -#ifdef __GNUC__ - -#pragma GCC poison TARGET_I386 -#pragma GCC poison TARGET_X86_64 -#pragma GCC poison TARGET_ALPHA -#pragma GCC poison TARGET_ARM -#pragma GCC poison TARGET_CRIS -#pragma GCC poison TARGET_LM32 -#pragma GCC poison TARGET_M68K -#pragma GCC poison TARGET_MIPS -#pragma GCC poison TARGET_MIPS64 -#pragma GCC poison TARGET_OPENRISC -#pragma GCC poison TARGET_PPC -#pragma GCC poison TARGET_PPCEMB -#pragma GCC poison TARGET_PPC64 -#pragma GCC poison TARGET_ABI32 -#pragma GCC poison TARGET_SH4 -#pragma GCC poison TARGET_SPARC -#pragma GCC poison TARGET_SPARC64 - -#pragma GCC poison TARGET_WORDS_BIGENDIAN -#pragma GCC poison BSWAP_NEEDED - -#pragma GCC poison TARGET_LONG_BITS -#pragma GCC poison TARGET_FMT_lx -#pragma GCC poison TARGET_FMT_ld - -#pragma GCC poison TARGET_PAGE_SIZE -#pragma GCC poison TARGET_PAGE_MASK -#pragma GCC poison TARGET_PAGE_BITS -#pragma GCC poison TARGET_PAGE_ALIGN - -#pragma GCC poison CPUArchState -#pragma GCC poison env - -#pragma GCC poison lduw_phys -#pragma GCC poison ldl_phys -#pragma GCC poison ldq_phys -#pragma GCC poison stl_phys_notdirty -#pragma GCC poison stq_phys_notdirty -#pragma GCC poison stw_phys -#pragma GCC poison stl_phys -#pragma GCC poison stq_phys - -#pragma GCC poison CPU_INTERRUPT_HARD -#pragma GCC poison CPU_INTERRUPT_EXITTB -#pragma GCC poison CPU_INTERRUPT_HALT -#pragma GCC poison CPU_INTERRUPT_DEBUG -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_0 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_1 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_2 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_3 -#pragma GCC poison CPU_INTERRUPT_TGT_EXT_4 -#pragma GCC poison CPU_INTERRUPT_TGT_INT_0 -#pragma GCC poison CPU_INTERRUPT_TGT_INT_1 -#pragma GCC poison CPU_INTERRUPT_TGT_INT_2 - -#endif -#endif diff --git a/qemu-lock.h b/qemu-lock.h deleted file mode 100644 index a72edda1d2..0000000000 --- a/qemu-lock.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see - */ - -/* configure guarantees us that we have pthreads on any host except - * mingw32, which doesn't support any of the user-only targets. - * So we can simply assume we have pthread mutexes here. - */ -#if defined(CONFIG_USER_ONLY) - -#include -#define spin_lock pthread_mutex_lock -#define spin_unlock pthread_mutex_unlock -#define spinlock_t pthread_mutex_t -#define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER - -#else - -/* Empty implementations, on the theory that system mode emulation - * is single-threaded. This means that these functions should only - * be used from code run in the TCG cpu thread, and cannot protect - * data structures which might also be accessed from the IO thread - * or from signal handlers. - */ -typedef int spinlock_t; -#define SPIN_LOCK_UNLOCKED 0 - -static inline void spin_lock(spinlock_t *lock) -{ -} - -static inline void spin_unlock(spinlock_t *lock) -{ -} - -#endif diff --git a/qemu-user-types.h b/qemu-user-types.h deleted file mode 100644 index fe7f6624f9..0000000000 --- a/qemu-user-types.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef QEMU_TYPES_H -#define QEMU_TYPES_H -#include "cpu.h" - -#ifdef TARGET_ABI32 -typedef uint32_t abi_ulong; -typedef int32_t abi_long; -#define TARGET_ABI_FMT_lx "%08x" -#define TARGET_ABI_FMT_ld "%d" -#define TARGET_ABI_FMT_lu "%u" -#define TARGET_ABI_BITS 32 - -static inline abi_ulong tswapal(abi_ulong v) -{ - return tswap32(v); -} - -#else -typedef target_ulong abi_ulong; -typedef target_long abi_long; -#define TARGET_ABI_FMT_lx TARGET_FMT_lx -#define TARGET_ABI_FMT_ld TARGET_FMT_ld -#define TARGET_ABI_FMT_lu TARGET_FMT_lu -#define TARGET_ABI_BITS TARGET_LONG_BITS -/* for consistency, define ABI32 too */ -#if TARGET_ABI_BITS == 32 -#define TARGET_ABI32 1 -#endif - -static inline abi_ulong tswapal(abi_ulong v) -{ - return tswapl(v); -} - -#endif -#endif diff --git a/qtest.c b/qtest.c index fbfab4e1a7..ebe3963167 100644 --- a/qtest.c +++ b/qtest.c @@ -14,8 +14,8 @@ #include "qtest.h" #include "hw/qdev.h" #include "qemu-char.h" -#include "ioport.h" -#include "memory.h" +#include "exec/ioport.h" +#include "exec/memory.h" #include "hw/irq.h" #include "sysemu.h" #include "cpus.h" diff --git a/savevm.c b/savevm.c index ae8787868f..cb33501ecc 100644 --- a/savevm.c +++ b/savevm.c @@ -82,7 +82,7 @@ #include "qemu-queue.h" #include "qemu-timer.h" #include "cpus.h" -#include "memory.h" +#include "exec/memory.h" #include "qmp-commands.h" #include "trace.h" #include "bitops.h" diff --git a/scripts/feature_to_c.sh b/scripts/feature_to_c.sh index b62da8a0bd..888548e58b 100644 --- a/scripts/feature_to_c.sh +++ b/scripts/feature_to_c.sh @@ -38,7 +38,7 @@ for input; do ${AWK:-awk} 'BEGIN { n = 0 printf "#include \"config.h\"\n" printf "#include \"qemu-common.h\"\n" - printf "#include \"gdbstub.h\"\n" + printf "#include \"exec/gdbstub.h\"\n" print "static const char '$arrayname'[] = {" for (i = 0; i < 255; i++) _ord_[sprintf("%c", i)] = i diff --git a/softmmu-semi.h b/softmmu-semi.h deleted file mode 100644 index 93798b9614..0000000000 --- a/softmmu-semi.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Helper routines to provide target memory access for semihosting - * syscalls in system emulation mode. - * - * Copyright (c) 2007 CodeSourcery. - * - * This code is licensed under the GPL - */ -#ifndef SOFTMMU_SEMI_H -#define SOFTMMU_SEMI_H 1 - -static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr) -{ - uint32_t val; - - cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0); - return tswap32(val); -} -static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr) -{ - uint8_t val; - - cpu_memory_rw_debug(env, addr, &val, 1, 0); - return val; -} - -#define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; }) -#define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; }) -#define get_user_ual(arg, p) get_user_u32(arg, p) - -static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val) -{ - val = tswap32(val); - cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1); -} -#define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; }) -#define put_user_ual(arg, p) put_user_u32(arg, p) - -static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len, - int copy) -{ - uint8_t *p; - /* TODO: Make this something that isn't fixed size. */ - p = malloc(len); - if (p && copy) - cpu_memory_rw_debug(env, addr, p, len, 0); - return p; -} -#define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy) -static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr) -{ - char *p; - char *s; - uint8_t c; - /* TODO: Make this something that isn't fixed size. */ - s = p = malloc(1024); - if (!s) { - return NULL; - } - do { - cpu_memory_rw_debug(env, addr, &c, 1, 0); - addr++; - *(p++) = c; - } while (c); - return s; -} -#define lock_user_string(p) softmmu_lock_user_string(env, p) -static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr, - target_ulong len) -{ - if (len) - cpu_memory_rw_debug(env, addr, p, len, 1); - free(p); -} -#define unlock_user(s, args, len) softmmu_unlock_user(env, s, args, len) - -#endif diff --git a/softmmu_defs.h b/softmmu_defs.h deleted file mode 100644 index 1f25e33ce4..0000000000 --- a/softmmu_defs.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Software MMU support - * - * Declare helpers used by TCG for qemu_ld/st ops. - * - * Used by softmmu_exec.h, TCG targets and exec-all.h. - * - */ -#ifndef SOFTMMU_DEFS_H -#define SOFTMMU_DEFS_H - -uint8_t helper_ldb_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stb_mmu(CPUArchState *env, target_ulong addr, uint8_t val, - int mmu_idx); -uint16_t helper_ldw_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stw_mmu(CPUArchState *env, target_ulong addr, uint16_t val, - int mmu_idx); -uint32_t helper_ldl_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stl_mmu(CPUArchState *env, target_ulong addr, uint32_t val, - int mmu_idx); -uint64_t helper_ldq_mmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, - int mmu_idx); - -uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stb_cmmu(CPUArchState *env, target_ulong addr, uint8_t val, -int mmu_idx); -uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stw_cmmu(CPUArchState *env, target_ulong addr, uint16_t val, - int mmu_idx); -uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stl_cmmu(CPUArchState *env, target_ulong addr, uint32_t val, - int mmu_idx); -uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx); -void helper_stq_cmmu(CPUArchState *env, target_ulong addr, uint64_t val, - int mmu_idx); -#endif diff --git a/softmmu_exec.h b/softmmu_exec.h deleted file mode 100644 index 8c73985599..0000000000 --- a/softmmu_exec.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Software MMU support - * - * Generate inline load/store functions for all MMU modes (typically - * at least _user and _kernel) as well as _data versions, for all data - * sizes. - * - * Used by target op helpers. - * - * MMU mode suffixes are defined in target cpu.h. - */ - -/* XXX: find something cleaner. - * Furthermore, this is false for 64 bits targets - */ -#define ldul_user ldl_user -#define ldul_kernel ldl_kernel -#define ldul_hypv ldl_hypv -#define ldul_executive ldl_executive -#define ldul_supervisor ldl_supervisor - -#include "softmmu_defs.h" - -#define ACCESS_TYPE 0 -#define MEMSUFFIX MMU_MODE0_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#define ACCESS_TYPE 1 -#define MEMSUFFIX MMU_MODE1_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#if (NB_MMU_MODES >= 3) - -#define ACCESS_TYPE 2 -#define MEMSUFFIX MMU_MODE2_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 3) */ - -#if (NB_MMU_MODES >= 4) - -#define ACCESS_TYPE 3 -#define MEMSUFFIX MMU_MODE3_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 4) */ - -#if (NB_MMU_MODES >= 5) - -#define ACCESS_TYPE 4 -#define MEMSUFFIX MMU_MODE4_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 5) */ - -#if (NB_MMU_MODES >= 6) - -#define ACCESS_TYPE 5 -#define MEMSUFFIX MMU_MODE5_SUFFIX -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX -#endif /* (NB_MMU_MODES >= 6) */ - -#if (NB_MMU_MODES > 6) -#error "NB_MMU_MODES > 6 is not supported for now" -#endif /* (NB_MMU_MODES > 6) */ - -/* these access are slower, they must be as rare as possible */ -#define ACCESS_TYPE (NB_MMU_MODES) -#define MEMSUFFIX _data -#define DATA_SIZE 1 -#include "softmmu_header.h" - -#define DATA_SIZE 2 -#include "softmmu_header.h" - -#define DATA_SIZE 4 -#include "softmmu_header.h" - -#define DATA_SIZE 8 -#include "softmmu_header.h" -#undef ACCESS_TYPE -#undef MEMSUFFIX - -#define ldub(p) ldub_data(p) -#define ldsb(p) ldsb_data(p) -#define lduw(p) lduw_data(p) -#define ldsw(p) ldsw_data(p) -#define ldl(p) ldl_data(p) -#define ldq(p) ldq_data(p) - -#define stb(p, v) stb_data(p, v) -#define stw(p, v) stw_data(p, v) -#define stl(p, v) stl_data(p, v) -#define stq(p, v) stq_data(p, v) diff --git a/softmmu_header.h b/softmmu_header.h deleted file mode 100644 index d8d9c81b05..0000000000 --- a/softmmu_header.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Software MMU support - * - * Generate inline load/store functions for one MMU mode and data - * size. - * - * Generate a store function as well as signed and unsigned loads. For - * 32 and 64 bit cases, also generate floating point functions with - * the same size. - * - * Not used directly but included from softmmu_exec.h and exec-all.h. - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#if DATA_SIZE == 8 -#define SUFFIX q -#define USUFFIX q -#define DATA_TYPE uint64_t -#elif DATA_SIZE == 4 -#define SUFFIX l -#define USUFFIX l -#define DATA_TYPE uint32_t -#elif DATA_SIZE == 2 -#define SUFFIX w -#define USUFFIX uw -#define DATA_TYPE uint16_t -#define DATA_STYPE int16_t -#elif DATA_SIZE == 1 -#define SUFFIX b -#define USUFFIX ub -#define DATA_TYPE uint8_t -#define DATA_STYPE int8_t -#else -#error unsupported data size -#endif - -#if ACCESS_TYPE < (NB_MMU_MODES) - -#define CPU_MMU_INDEX ACCESS_TYPE -#define MMUSUFFIX _mmu - -#elif ACCESS_TYPE == (NB_MMU_MODES) - -#define CPU_MMU_INDEX (cpu_mmu_index(env)) -#define MMUSUFFIX _mmu - -#elif ACCESS_TYPE == (NB_MMU_MODES + 1) - -#define CPU_MMU_INDEX (cpu_mmu_index(env)) -#define MMUSUFFIX _cmmu - -#else -#error invalid ACCESS_TYPE -#endif - -#if DATA_SIZE == 8 -#define RES_TYPE uint64_t -#else -#define RES_TYPE uint32_t -#endif - -#if ACCESS_TYPE == (NB_MMU_MODES + 1) -#define ADDR_READ addr_code -#else -#define ADDR_READ addr_read -#endif - -/* generic load/store macros */ - -static inline RES_TYPE -glue(glue(cpu_ld, USUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) -{ - int page_index; - RES_TYPE res; - target_ulong addr; - int mmu_idx; - - addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { - res = glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(env, addr, mmu_idx); - } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; - res = glue(glue(ld, USUFFIX), _raw)(hostaddr); - } - return res; -} - -#if DATA_SIZE <= 2 -static inline int -glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr) -{ - int res, page_index; - target_ulong addr; - int mmu_idx; - - addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { - res = (DATA_STYPE)glue(glue(helper_ld, SUFFIX), - MMUSUFFIX)(env, addr, mmu_idx); - } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; - res = glue(glue(lds, SUFFIX), _raw)(hostaddr); - } - return res; -} -#endif - -#if ACCESS_TYPE != (NB_MMU_MODES + 1) - -/* generic store macro */ - -static inline void -glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr, - RES_TYPE v) -{ - int page_index; - target_ulong addr; - int mmu_idx; - - addr = ptr; - page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - mmu_idx = CPU_MMU_INDEX; - if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != - (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { - glue(glue(helper_st, SUFFIX), MMUSUFFIX)(env, addr, v, mmu_idx); - } else { - uintptr_t hostaddr = addr + env->tlb_table[mmu_idx][page_index].addend; - glue(glue(st, SUFFIX), _raw)(hostaddr, v); - } -} - -#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ - -#if ACCESS_TYPE != (NB_MMU_MODES + 1) - -#if DATA_SIZE == 8 -static inline float64 glue(cpu_ldfq, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr) -{ - union { - float64 d; - uint64_t i; - } u; - u.i = glue(cpu_ldq, MEMSUFFIX)(env, ptr); - return u.d; -} - -static inline void glue(cpu_stfq, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr, float64 v) -{ - union { - float64 d; - uint64_t i; - } u; - u.d = v; - glue(cpu_stq, MEMSUFFIX)(env, ptr, u.i); -} -#endif /* DATA_SIZE == 8 */ - -#if DATA_SIZE == 4 -static inline float32 glue(cpu_ldfl, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = glue(cpu_ldl, MEMSUFFIX)(env, ptr); - return u.f; -} - -static inline void glue(cpu_stfl, MEMSUFFIX)(CPUArchState *env, - target_ulong ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - glue(cpu_stl, MEMSUFFIX)(env, ptr, u.i); -} -#endif /* DATA_SIZE == 4 */ - -#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ - -#undef RES_TYPE -#undef DATA_TYPE -#undef DATA_STYPE -#undef SUFFIX -#undef USUFFIX -#undef DATA_SIZE -#undef CPU_MMU_INDEX -#undef MMUSUFFIX -#undef ADDR_READ diff --git a/softmmu_template.h b/softmmu_template.h deleted file mode 100644 index ce30d8bddc..0000000000 --- a/softmmu_template.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Software MMU support - * - * Generate helpers used by TCG for qemu_ld/st ops and code load - * functions. - * - * Included from target op helpers and exec.c. - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#include "qemu-timer.h" -#include "memory.h" - -#define DATA_SIZE (1 << SHIFT) - -#if DATA_SIZE == 8 -#define SUFFIX q -#define USUFFIX q -#define DATA_TYPE uint64_t -#elif DATA_SIZE == 4 -#define SUFFIX l -#define USUFFIX l -#define DATA_TYPE uint32_t -#elif DATA_SIZE == 2 -#define SUFFIX w -#define USUFFIX uw -#define DATA_TYPE uint16_t -#elif DATA_SIZE == 1 -#define SUFFIX b -#define USUFFIX ub -#define DATA_TYPE uint8_t -#else -#error unsupported data size -#endif - -#ifdef SOFTMMU_CODE_ACCESS -#define READ_ACCESS_TYPE 2 -#define ADDR_READ addr_code -#else -#define READ_ACCESS_TYPE 0 -#define ADDR_READ addr_read -#endif - -static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - int mmu_idx, - uintptr_t retaddr); -static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, - hwaddr physaddr, - target_ulong addr, - uintptr_t retaddr) -{ - DATA_TYPE res; - MemoryRegion *mr = iotlb_to_region(physaddr); - - physaddr = (physaddr & TARGET_PAGE_MASK) + addr; - env->mem_io_pc = retaddr; - if (mr != &io_mem_ram && mr != &io_mem_rom - && mr != &io_mem_unassigned - && mr != &io_mem_notdirty - && !can_do_io(env)) { - cpu_io_recompile(env, retaddr); - } - - env->mem_io_vaddr = addr; -#if SHIFT <= 2 - res = io_mem_read(mr, physaddr, 1 << SHIFT); -#else -#ifdef TARGET_WORDS_BIGENDIAN - res = io_mem_read(mr, physaddr, 4) << 32; - res |= io_mem_read(mr, physaddr + 4, 4); -#else - res = io_mem_read(mr, physaddr, 4); - res |= io_mem_read(mr, physaddr + 4, 4) << 32; -#endif -#endif /* SHIFT > 2 */ - return res; -} - -/* handle all cases except unaligned access which span two pages */ -DATA_TYPE -glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_ulong addr, - int mmu_idx) -{ - DATA_TYPE res; - int index; - target_ulong tlb_addr; - hwaddr ioaddr; - uintptr_t retaddr; - - /* test if there is match for unaligned or IO access */ - /* XXX: could done more in memory macro in a non portable way */ - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - retaddr = GETPC_EXT(); - ioaddr = env->iotlb[mmu_idx][index]; - res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - /* slow unaligned access (it spans two pages or IO) */ - do_unaligned_access: - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); -#endif - res = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr, - mmu_idx, retaddr); - } else { - /* unaligned/aligned access in the same page */ - uintptr_t addend; -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) { - retaddr = GETPC_EXT(); - do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); - } -#endif - addend = env->tlb_table[mmu_idx][index].addend; - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend)); - } - } else { - /* the page is not in the TLB : fill it */ - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) - do_unaligned_access(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); -#endif - tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); - goto redo; - } - return res; -} - -/* handle all unaligned cases */ -static DATA_TYPE -glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - int mmu_idx, - uintptr_t retaddr) -{ - DATA_TYPE res, res1, res2; - int index, shift; - hwaddr ioaddr; - target_ulong tlb_addr, addr1, addr2; - - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].ADDR_READ; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - ioaddr = env->iotlb[mmu_idx][index]; - res = glue(io_read, SUFFIX)(env, ioaddr, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - do_unaligned_access: - /* slow unaligned access (it spans two pages) */ - addr1 = addr & ~(DATA_SIZE - 1); - addr2 = addr1 + DATA_SIZE; - res1 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr1, - mmu_idx, retaddr); - res2 = glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(env, addr2, - mmu_idx, retaddr); - shift = (addr & (DATA_SIZE - 1)) * 8; -#ifdef TARGET_WORDS_BIGENDIAN - res = (res1 << shift) | (res2 >> ((DATA_SIZE * 8) - shift)); -#else - res = (res1 >> shift) | (res2 << ((DATA_SIZE * 8) - shift)); -#endif - res = (DATA_TYPE)res; - } else { - /* unaligned/aligned access in the same page */ - uintptr_t addend = env->tlb_table[mmu_idx][index].addend; - res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend)); - } - } else { - /* the page is not in the TLB : fill it */ - tlb_fill(env, addr, READ_ACCESS_TYPE, mmu_idx, retaddr); - goto redo; - } - return res; -} - -#ifndef SOFTMMU_CODE_ACCESS - -static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - DATA_TYPE val, - int mmu_idx, - uintptr_t retaddr); - -static inline void glue(io_write, SUFFIX)(CPUArchState *env, - hwaddr physaddr, - DATA_TYPE val, - target_ulong addr, - uintptr_t retaddr) -{ - MemoryRegion *mr = iotlb_to_region(physaddr); - - physaddr = (physaddr & TARGET_PAGE_MASK) + addr; - if (mr != &io_mem_ram && mr != &io_mem_rom - && mr != &io_mem_unassigned - && mr != &io_mem_notdirty - && !can_do_io(env)) { - cpu_io_recompile(env, retaddr); - } - - env->mem_io_vaddr = addr; - env->mem_io_pc = retaddr; -#if SHIFT <= 2 - io_mem_write(mr, physaddr, val, 1 << SHIFT); -#else -#ifdef TARGET_WORDS_BIGENDIAN - io_mem_write(mr, physaddr, (val >> 32), 4); - io_mem_write(mr, physaddr + 4, (uint32_t)val, 4); -#else - io_mem_write(mr, physaddr, (uint32_t)val, 4); - io_mem_write(mr, physaddr + 4, val >> 32, 4); -#endif -#endif /* SHIFT > 2 */ -} - -void glue(glue(helper_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, DATA_TYPE val, - int mmu_idx) -{ - hwaddr ioaddr; - target_ulong tlb_addr; - uintptr_t retaddr; - int index; - - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].addr_write; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - retaddr = GETPC_EXT(); - ioaddr = env->iotlb[mmu_idx][index]; - glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - do_unaligned_access: - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - do_unaligned_access(env, addr, 1, mmu_idx, retaddr); -#endif - glue(glue(slow_st, SUFFIX), MMUSUFFIX)(env, addr, val, - mmu_idx, retaddr); - } else { - /* aligned/unaligned access in the same page */ - uintptr_t addend; -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) { - retaddr = GETPC_EXT(); - do_unaligned_access(env, addr, 1, mmu_idx, retaddr); - } -#endif - addend = env->tlb_table[mmu_idx][index].addend; - glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend), val); - } - } else { - /* the page is not in the TLB : fill it */ - retaddr = GETPC_EXT(); -#ifdef ALIGNED_ONLY - if ((addr & (DATA_SIZE - 1)) != 0) - do_unaligned_access(env, addr, 1, mmu_idx, retaddr); -#endif - tlb_fill(env, addr, 1, mmu_idx, retaddr); - goto redo; - } -} - -/* handles all unaligned cases */ -static void glue(glue(slow_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, - target_ulong addr, - DATA_TYPE val, - int mmu_idx, - uintptr_t retaddr) -{ - hwaddr ioaddr; - target_ulong tlb_addr; - int index, i; - - index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); - redo: - tlb_addr = env->tlb_table[mmu_idx][index].addr_write; - if ((addr & TARGET_PAGE_MASK) == (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - if ((addr & (DATA_SIZE - 1)) != 0) - goto do_unaligned_access; - ioaddr = env->iotlb[mmu_idx][index]; - glue(io_write, SUFFIX)(env, ioaddr, val, addr, retaddr); - } else if (((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1) >= TARGET_PAGE_SIZE) { - do_unaligned_access: - /* XXX: not efficient, but simple */ - /* Note: relies on the fact that tlb_fill() does not remove the - * previous page from the TLB cache. */ - for(i = DATA_SIZE - 1; i >= 0; i--) { -#ifdef TARGET_WORDS_BIGENDIAN - glue(slow_stb, MMUSUFFIX)(env, addr + i, - val >> (((DATA_SIZE - 1) * 8) - (i * 8)), - mmu_idx, retaddr); -#else - glue(slow_stb, MMUSUFFIX)(env, addr + i, - val >> (i * 8), - mmu_idx, retaddr); -#endif - } - } else { - /* aligned/unaligned access in the same page */ - uintptr_t addend = env->tlb_table[mmu_idx][index].addend; - glue(glue(st, SUFFIX), _raw)((uint8_t *)(intptr_t) - (addr + addend), val); - } - } else { - /* the page is not in the TLB : fill it */ - tlb_fill(env, addr, 1, mmu_idx, retaddr); - goto redo; - } -} - -#endif /* !defined(SOFTMMU_CODE_ACCESS) */ - -#undef READ_ACCESS_TYPE -#undef SHIFT -#undef DATA_TYPE -#undef SUFFIX -#undef USUFFIX -#undef DATA_SIZE -#undef ADDR_READ diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index 9939d61ca8..137703f6d7 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -27,7 +27,7 @@ #define CPUArchState struct CPUAlphaState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -295,7 +295,7 @@ struct CPUAlphaState { #define cpu_gen_code cpu_alpha_gen_code #define cpu_signal_handler cpu_alpha_signal_handler -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "cpu-qom.h" enum { @@ -520,7 +520,7 @@ static inline bool cpu_has_work(CPUState *cpu) | CPU_INTERRUPT_MCHK); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUAlphaState *env, TranslationBlock *tb) { diff --git a/target-alpha/helper.h b/target-alpha/helper.h index dd55f89aad..eac3041b87 100644 --- a/target-alpha/helper.h +++ b/target-alpha/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_3(excp, noreturn, env, int, int) DEF_HELPER_FLAGS_1(load_pcc, TCG_CALL_NO_RWG_SE, i64, env) @@ -119,4 +119,4 @@ DEF_HELPER_FLAGS_0(get_time, TCG_CALL_NO_RWG, i64) DEF_HELPER_FLAGS_2(set_alarm, TCG_CALL_NO_RWG, void, env, i64) #endif -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-alpha/mem_helper.c b/target-alpha/mem_helper.c index 64b33f6518..3d2cd61358 100644 --- a/target-alpha/mem_helper.c +++ b/target-alpha/mem_helper.c @@ -117,22 +117,22 @@ void cpu_unassigned_access(CPUAlphaState *env, hwaddr addr, dynamic_excp(env, 0, EXCP_MCHK, 0); } -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define ALIGNED_ONLY #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-alpha/translate.c b/target-alpha/translate.c index f57c8fd91f..2d0d891128 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -88,7 +88,7 @@ static TCGv cpu_usp; /* register names */ static char cpu_reg_names[10*4+21*5 + 10*5+21*6]; -#include "gen-icount.h" +#include "exec/gen-icount.h" static void alpha_translate_init(void) { diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c index 7743d67010..847318d1f4 100644 --- a/target-arm/arm-semi.c +++ b/target-arm/arm-semi.c @@ -33,7 +33,7 @@ #define ARM_ANGEL_HEAP_SIZE (128 * 1024 * 1024) #else #include "qemu-common.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "hw/arm-misc.h" #endif @@ -113,7 +113,7 @@ static inline uint32_t set_swi_errno(CPUARMState *env, uint32_t code) return code; } -#include "softmmu-semi.h" +#include "exec/softmmu-semi.h" #endif static target_ulong arm_semi_syscall_len; diff --git a/target-arm/cpu.h b/target-arm/cpu.h index e4ff918fa4..7f87efa7d9 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -27,7 +27,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -659,7 +659,7 @@ static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" /* Bit usage in the TB flags field: */ #define ARM_TBFLAG_THUMB_SHIFT 0 @@ -726,7 +726,7 @@ static inline bool cpu_has_work(CPUState *cpu) (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUARMState *env, TranslationBlock *tb) { diff --git a/target-arm/helper.c b/target-arm/helper.c index ab8b734933..1f7a3c04c3 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1,5 +1,5 @@ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "helper.h" #include "host-utils.h" #include "sysemu.h" diff --git a/target-arm/helper.h b/target-arm/helper.h index 3d23ceb257..8544f82a94 100644 --- a/target-arm/helper.h +++ b/target-arm/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_FLAGS_1(clz, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_FLAGS_1(sxtb16, TCG_CALL_NO_RWG_SE, i32, i32) @@ -463,4 +463,4 @@ DEF_HELPER_3(neon_qzip8, void, env, i32, i32) DEF_HELPER_3(neon_qzip16, void, env, i32, i32) DEF_HELPER_3(neon_qzip32, void, env, i32, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-arm/iwmmxt_helper.c b/target-arm/iwmmxt_helper.c index 1dd8d1a3af..7953b53f7e 100644 --- a/target-arm/iwmmxt_helper.c +++ b/target-arm/iwmmxt_helper.c @@ -23,7 +23,7 @@ #include #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "helper.h" /* iwMMXt macros extracted from GNU gdb. */ diff --git a/target-arm/neon_helper.c b/target-arm/neon_helper.c index 89280b6eeb..b028cc2c93 100644 --- a/target-arm/neon_helper.c +++ b/target-arm/neon_helper.c @@ -10,7 +10,7 @@ #include #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "helper.h" #define SIGNBIT (uint32_t)0x80000000 diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 1fcc975945..99610d7734 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -52,21 +52,21 @@ uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def, #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-arm/translate.c b/target-arm/translate.c index 10c548d5ba..988b5428d4 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -98,7 +98,7 @@ static TCGv_i32 cpu_exclusive_info; static TCGv cpu_F0s, cpu_F1s; static TCGv_i64 cpu_F0d, cpu_F1d; -#include "gen-icount.h" +#include "exec/gen-icount.h" static const char *regnames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", diff --git a/target-cris/cpu.h b/target-cris/cpu.h index 2c27506d0d..63e6234f11 100644 --- a/target-cris/cpu.h +++ b/target-cris/cpu.h @@ -27,7 +27,7 @@ #define CPUArchState struct CPUCRISState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #define TARGET_HAS_ICE 1 @@ -270,7 +270,7 @@ static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls) #define SFR_RW_MM_TLB_LO env->pregs[PR_SRS]][5 #define SFR_RW_MM_TLB_HI env->pregs[PR_SRS]][6 -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUCRISState *env, target_ulong *pc, target_ulong *cs_base, int *flags) @@ -292,7 +292,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUCRISState *env, TranslationBlock *tb) { diff --git a/target-cris/helper.h b/target-cris/helper.h index fe12083a16..8e8365cf69 100644 --- a/target-cris/helper.h +++ b/target-cris/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_2(tlb_flush_pid, void, env, i32) @@ -26,4 +26,4 @@ DEF_HELPER_FLAGS_3(evaluate_flags_move_2, TCG_CALL_NO_SE, i32, env, i32, i32) DEF_HELPER_1(evaluate_flags, void, env) DEF_HELPER_1(top_evaluate_flags, void, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c index 31db42494d..cd0e17e099 100644 --- a/target-cris/op_helper.c +++ b/target-cris/op_helper.c @@ -35,21 +35,21 @@ #endif #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* Try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-cris/translate.c b/target-cris/translate.c index 2a92727843..09e6011ea4 100644 --- a/target-cris/translate.c +++ b/target-cris/translate.c @@ -70,7 +70,7 @@ static TCGv env_btaken; static TCGv env_btarget; static TCGv env_pc; -#include "gen-icount.h" +#include "exec/gen-icount.h" /* This is the state at translation time. */ typedef struct DisasContext { diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c index 4240278edd..50d866f4c6 100644 --- a/target-i386/arch_dump.c +++ b/target-i386/arch_dump.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "dump.h" #include "elf.h" diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c index 41f9d1c3e3..6dfb0f3f56 100644 --- a/target-i386/arch_memory_mapping.c +++ b/target-i386/arch_memory_mapping.c @@ -12,7 +12,7 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "memory_mapping.h" /* PAE Paging or IA-32e Paging */ diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 386c4f6d98..f3f50a0499 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -44,7 +44,7 @@ #define CPUArchState struct CPUX86State -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -1117,7 +1117,7 @@ static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "svm.h" #if !defined(CONFIG_USER_ONLY) @@ -1137,7 +1137,7 @@ static inline bool cpu_has_work(CPUState *cpu) CPU_INTERRUPT_MCE)); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUX86State *env, TranslationBlock *tb) { diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c index dfc34a6253..44f3d27944 100644 --- a/target-i386/fpu_helper.c +++ b/target-i386/fpu_helper.c @@ -22,7 +22,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ #define FPU_RC_MASK 0xc00 diff --git a/target-i386/helper.h b/target-i386/helper.h index 970fcd98ff..9ed720d0ed 100644 --- a/target-i386/helper.h +++ b/target-i386/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_FLAGS_2(cc_compute_all, TCG_CALL_NO_SE, i32, env, int) DEF_HELPER_FLAGS_2(cc_compute_c, TCG_CALL_NO_SE, i32, env, int) @@ -220,4 +220,4 @@ DEF_HELPER_3(rclq, tl, env, tl, tl) DEF_HELPER_3(rcrq, tl, env, tl, tl) #endif -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-i386/ioport-user.c b/target-i386/ioport-user.c index 03fac22d22..f7636e0a87 100644 --- a/target-i386/ioport-user.c +++ b/target-i386/ioport-user.c @@ -21,7 +21,7 @@ #include "qemu.h" #include "qemu-common.h" -#include "ioport.h" +#include "exec/ioport.h" void cpu_outb(pio_addr_t addr, uint8_t val) { diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 824930c749..f7c95d5424 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -25,12 +25,12 @@ #include "kvm.h" #include "kvm_i386.h" #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "host-utils.h" #include "qemu-config.h" #include "hw/pc.h" #include "hw/apic.h" -#include "ioport.h" +#include "exec/ioport.h" #include "hyperv.h" #include "hw/pci/pci.h" diff --git a/target-i386/mem_helper.c b/target-i386/mem_helper.c index d0be77b1ed..6cf9ba076e 100644 --- a/target-i386/mem_helper.c +++ b/target-i386/mem_helper.c @@ -21,7 +21,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ /* broken thread support */ @@ -114,16 +114,16 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #endif diff --git a/target-i386/misc_helper.c b/target-i386/misc_helper.c index a02037963f..db3126b79b 100644 --- a/target-i386/misc_helper.c +++ b/target-i386/misc_helper.c @@ -18,11 +18,11 @@ */ #include "cpu.h" -#include "ioport.h" +#include "exec/ioport.h" #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ /* check if Port I/O is allowed in TSS */ diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index ff9337441b..be795d71eb 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -25,7 +25,7 @@ //#define DEBUG_PCALL #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ #ifdef DEBUG_PCALL diff --git a/target-i386/svm_helper.c b/target-i386/svm_helper.c index a238d95a55..3f246e9073 100644 --- a/target-i386/svm_helper.c +++ b/target-i386/svm_helper.c @@ -18,11 +18,11 @@ */ #include "cpu.h" -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ /* Secure Virtual Machine helpers */ diff --git a/target-i386/translate.c b/target-i386/translate.c index 026201e98e..32d21f52d0 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -65,7 +65,7 @@ static TCGv cpu_tmp5; static uint8_t gen_opc_cc_op[OPC_BUF_SIZE]; -#include "gen-icount.h" +#include "exec/gen-icount.h" #ifdef TARGET_X86_64 static int x86_64_hregs; diff --git a/target-lm32/cpu.h b/target-lm32/cpu.h index 7243b4f7c7..4e202db32c 100644 --- a/target-lm32/cpu.h +++ b/target-lm32/cpu.h @@ -26,7 +26,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" struct CPULM32State; typedef struct CPULM32State CPULM32State; @@ -238,7 +238,7 @@ static inline int cpu_interrupts_enabled(CPULM32State *env) return env->ie & IE_IE; } -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline target_ulong cpu_get_pc(CPULM32State *env) { @@ -260,7 +260,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & CPU_INTERRUPT_HARD; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPULM32State *env, TranslationBlock *tb) { diff --git a/target-lm32/helper.h b/target-lm32/helper.h index 07f5670172..3ea15a6e80 100644 --- a/target-lm32/helper.h +++ b/target-lm32/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_1(hlt, void, env) @@ -11,4 +11,4 @@ DEF_HELPER_1(rcsr_ip, i32, env) DEF_HELPER_1(rcsr_jtx, i32, env) DEF_HELPER_1(rcsr_jrx, i32, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c index 97b9625c1a..27b3cef25c 100644 --- a/target-lm32/op_helper.c +++ b/target-lm32/op_helper.c @@ -9,13 +9,13 @@ #if !defined(CONFIG_USER_ONLY) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void helper_raise_exception(CPULM32State *env, uint32_t index) { diff --git a/target-lm32/translate.c b/target-lm32/translate.c index 9683b9a4b5..6b87340174 100644 --- a/target-lm32/translate.c +++ b/target-lm32/translate.c @@ -53,7 +53,7 @@ static TCGv cpu_deba; static TCGv cpu_bp[4]; static TCGv cpu_wp[4]; -#include "gen-icount.h" +#include "exec/gen-icount.h" enum { OP_FMT_RI, diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index f4fcdeee7a..b37af1fffd 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -26,7 +26,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -242,7 +242,7 @@ static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc, target_ulong *cs_base, int *flags) @@ -261,7 +261,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & CPU_INTERRUPT_HARD; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUM68KState *env, TranslationBlock *tb) { diff --git a/target-m68k/helper.c b/target-m68k/helper.c index a5d0100473..a9a277865f 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "helpers.h" diff --git a/target-m68k/helpers.h b/target-m68k/helpers.h index 8112b44a58..2b024502ba 100644 --- a/target-m68k/helpers.h +++ b/target-m68k/helpers.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_1(bitrev, i32, i32) DEF_HELPER_1(ff1, i32, i32) @@ -51,4 +51,4 @@ DEF_HELPER_3(set_mac_extu, void, env, i32, i32) DEF_HELPER_2(flush_flags, void, env, i32) DEF_HELPER_2(raise_exception, void, env, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-m68k/m68k-semi.c b/target-m68k/m68k-semi.c index 9f7a24cdb4..e6c7dd2f9b 100644 --- a/target-m68k/m68k-semi.c +++ b/target-m68k/m68k-semi.c @@ -33,8 +33,8 @@ #define SEMIHOSTING_HEAP_SIZE (128 * 1024 * 1024) #else #include "qemu-common.h" -#include "gdbstub.h" -#include "softmmu-semi.h" +#include "exec/gdbstub.h" +#include "exec/softmmu-semi.h" #endif #include "sysemu.h" diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c index b97ba5e28f..16df24c0ca 100644 --- a/target-m68k/op_helper.c +++ b/target-m68k/op_helper.c @@ -34,21 +34,21 @@ void do_interrupt_m68k_hardirq(CPUM68KState *env) extern int semihosting_enabled; -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* Try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-m68k/translate.c b/target-m68k/translate.c index d955c7a409..1c9b5ec8d4 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -61,7 +61,7 @@ static TCGv NULL_QREG; /* Used to distinguish stores from bad addressing modes. */ static TCGv store_dummy; -#include "gen-icount.h" +#include "exec/gen-icount.h" void m68k_tcg_init(void) { diff --git a/target-microblaze/cpu.h b/target-microblaze/cpu.h index 585bbd6dbc..5358941ae4 100644 --- a/target-microblaze/cpu.h +++ b/target-microblaze/cpu.h @@ -26,7 +26,7 @@ #define CPUArchState struct CPUMBState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" struct CPUMBState; typedef struct CPUMBState CPUMBState; @@ -353,7 +353,7 @@ static inline int cpu_interrupts_enabled(CPUMBState *env) return env->sregs[SR_MSR] & MSR_IE; } -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline target_ulong cpu_get_pc(CPUMBState *env) { @@ -381,7 +381,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUMBState *env, TranslationBlock *tb) { diff --git a/target-microblaze/helper.h b/target-microblaze/helper.h index a667122e91..4e51429498 100644 --- a/target-microblaze/helper.h +++ b/target-microblaze/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(raise_exception, void, env, i32) DEF_HELPER_1(debug, void, env) @@ -38,4 +38,4 @@ DEF_HELPER_2(stackprot, void, env, i32) DEF_HELPER_2(get, i32, i32, i32) DEF_HELPER_3(put, void, i32, i32, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 7593517094..343dcc15e7 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -26,17 +26,17 @@ #define D(x) #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* Try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index 5946a5ba5c..58ce71267d 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -50,7 +50,7 @@ static TCGv env_btaken; static TCGv env_btarget; static TCGv env_iflags; -#include "gen-icount.h" +#include "exec/gen-icount.h" /* This is the state at translation time. */ typedef struct DisasContext { diff --git a/target-mips/cpu.h b/target-mips/cpu.h index aebb2d5b79..183ba9fbd8 100644 --- a/target-mips/cpu.h +++ b/target-mips/cpu.h @@ -12,7 +12,7 @@ #include "config.h" #include "qemu-common.h" #include "mips-defs.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" struct CPUMIPSState; @@ -560,7 +560,7 @@ static inline int cpu_mips_hw_interrupts_pending(CPUMIPSState *env) return r; } -#include "cpu-all.h" +#include "exec/cpu-all.h" /* Memory access type : * may be needed for precise access rights control and precise exceptions. @@ -738,7 +738,7 @@ static inline bool cpu_has_work(CPUState *cpu) return has_work; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUMIPSState *env, TranslationBlock *tb) { diff --git a/target-mips/helper.h b/target-mips/helper.h index acf9ebd759..9ea60ec1bb 100644 --- a/target-mips/helper.h +++ b/target-mips/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_3(raise_exception_err, noreturn, env, i32, int) DEF_HELPER_2(raise_exception, noreturn, env, i32) @@ -707,4 +707,4 @@ DEF_HELPER_FLAGS_2(rddsp, 0, tl, tl, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 2972ae3f0a..157f59e6bf 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -23,7 +23,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ #ifndef CONFIG_USER_ONLY @@ -2116,16 +2116,16 @@ static void QEMU_NORETURN do_unaligned_access(CPUMIPSState *env, #define ALIGNED_ONLY #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" static void do_unaligned_access(CPUMIPSState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr) diff --git a/target-mips/translate.c b/target-mips/translate.c index 44e7617395..e81ff38476 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -1017,7 +1017,7 @@ static TCGv_i64 fpu_f64[32]; static uint32_t gen_opc_hflags[OPC_BUF_SIZE]; static target_ulong gen_opc_btarget[OPC_BUF_SIZE]; -#include "gen-icount.h" +#include "exec/gen-icount.h" #define gen_helper_0e0i(name, arg) do { \ TCGv_i32 helper_tmp = tcg_const_i32(arg); \ diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h index c7b1750153..8dc56c2873 100644 --- a/target-openrisc/cpu.h +++ b/target-openrisc/cpu.h @@ -30,7 +30,7 @@ struct OpenRISCCPU; #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" #include "qemu/cpu.h" #include "qapi/error.h" @@ -398,7 +398,7 @@ static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env, target_ulong *pc, @@ -427,7 +427,7 @@ static inline bool cpu_has_work(CPUState *cpu) CPU_INTERRUPT_TIMER); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline target_ulong cpu_get_pc(CPUOpenRISCState *env) { diff --git a/target-openrisc/helper.h b/target-openrisc/helper.h index 404d46447f..2af97901ce 100644 --- a/target-openrisc/helper.h +++ b/target-openrisc/helper.h @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ -#include "def-helper.h" +#include "exec/def-helper.h" /* exception */ DEF_HELPER_FLAGS_2(exception, 0, void, env, i32) @@ -67,4 +67,4 @@ DEF_HELPER_FLAGS_1(rfe, 0, void, env) DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) DEF_HELPER_FLAGS_4(mfspr, 0, tl, env, tl, tl, tl) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c index 642da7de49..226ce43513 100644 --- a/target-openrisc/interrupt.c +++ b/target-openrisc/interrupt.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" diff --git a/target-openrisc/mmu.c b/target-openrisc/mmu.c index f2a6523cfb..4eee44434f 100644 --- a/target-openrisc/mmu.c +++ b/target-openrisc/mmu.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" diff --git a/target-openrisc/mmu_helper.c b/target-openrisc/mmu_helper.c index d2edebcb49..e46b092984 100644 --- a/target-openrisc/mmu_helper.c +++ b/target-openrisc/mmu_helper.c @@ -21,20 +21,20 @@ #include "cpu.h" #ifndef CONFIG_USER_ONLY -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void tlb_fill(CPUOpenRISCState *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c index 2cb9d69826..5883347fa7 100644 --- a/target-openrisc/translate.c +++ b/target-openrisc/translate.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" #include "qemu-common.h" @@ -61,7 +61,7 @@ static TCGv_i32 fpcsr; static TCGv machi, maclo; static TCGv fpmaddhi, fpmaddlo; static TCGv_i32 env_flags; -#include "gen-icount.h" +#include "exec/gen-icount.h" void openrisc_translate_init(void) { diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 742d4f8ae3..610bcd544b 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -73,7 +73,7 @@ #define CPUArchState struct CPUPPCState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -1251,7 +1251,7 @@ static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" /*****************************************************************************/ /* CRF definitions */ @@ -2224,7 +2224,7 @@ static inline bool cpu_has_work(CPUState *cpu) return msr_ee && (env->interrupt_request & CPU_INTERRUPT_HARD); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUPPCState *env, TranslationBlock *tb) { diff --git a/target-ppc/helper.h b/target-ppc/helper.h index e588370e29..d2e9a55f28 100644 --- a/target-ppc/helper.h +++ b/target-ppc/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_3(raise_exception_err, void, env, i32, i32) DEF_HELPER_2(raise_exception, void, env, i32) @@ -414,4 +414,4 @@ DEF_HELPER_3(store_601_batl, void, env, i32, tl) DEF_HELPER_3(store_601_batu, void, env, i32, tl) #endif -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index baad6eb75b..83f98729a2 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -9,7 +9,7 @@ #ifndef __KVM_PPC_H__ #define __KVM_PPC_H__ -#include "memory.h" +#include "exec/memory.h" void kvmppc_init(void); diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c index 04c01445f9..2d7a349c32 100644 --- a/target-ppc/mem_helper.c +++ b/target-ppc/mem_helper.c @@ -23,7 +23,7 @@ #include "helper_regs.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* !defined(CONFIG_USER_ONLY) */ //#define DEBUG_OP @@ -257,16 +257,16 @@ STVE(stvewx, cpu_stl_data, bswap32, u32) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 8a53105f89..a74d76b5a6 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -71,7 +71,7 @@ static TCGv cpu_reserve; static TCGv cpu_fpscr; static TCGv_i32 cpu_access_type; -#include "gen-icount.h" +#include "exec/gen-icount.h" void ppc_translate_init(void) { diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 984ca9fc63..cca63abf5d 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -24,7 +24,7 @@ */ #include "disas/bfd.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include #include "kvm_ppc.h" #include "arch_init.h" diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index 0f9a1f7340..acb8c73174 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -28,13 +28,13 @@ #define CPUArchState struct CPUS390XState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #define TARGET_PAGE_BITS 12 #define TARGET_PHYS_ADDR_SPACE_BITS 64 #define TARGET_VIRT_ADDR_SPACE_BITS 64 -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "softfloat.h" @@ -350,7 +350,7 @@ static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls) #define cpu_gen_code cpu_s390x_gen_code #define cpu_signal_handler cpu_s390x_signal_handler -#include "exec-all.h" +#include "exec/exec-all.h" #ifdef CONFIG_USER_ONLY diff --git a/target-s390x/fpu_helper.c b/target-s390x/fpu_helper.c index ee9420d446..173f820428 100644 --- a/target-s390x/fpu_helper.c +++ b/target-s390x/fpu_helper.c @@ -22,7 +22,7 @@ #include "helper.h" #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #endif /* #define DEBUG_HELPER */ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index b7b812a7e6..6e9b209713 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "qemu-timer.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" diff --git a/target-s390x/helper.h b/target-s390x/helper.h index ac44eabd53..c4926c52ad 100644 --- a/target-s390x/helper.h +++ b/target-s390x/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(exception, void, env, i32) DEF_HELPER_4(nc, i32, env, i32, i64, i64) @@ -149,4 +149,4 @@ DEF_HELPER_3(cksm, void, env, i32, i32) DEF_HELPER_FLAGS_5(calc_cc, TCG_CALL_NO_RWG_SE, i32, env, i32, i64, i64, i64) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index 91b25e309d..bed21e6e1c 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -24,21 +24,21 @@ /*****************************************************************************/ /* Softmmu support */ #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" /* try to fill the TLB and return an exception if error. If retaddr is NULL, it means that the function was called in C code (i.e. not diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index 38d8f2a627..a3336e16b0 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "memory.h" +#include "exec/memory.h" #include "host-utils.h" #include "helper.h" #include @@ -30,7 +30,7 @@ #endif #if !defined(CONFIG_USER_ONLY) -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #include "sysemu.h" #endif diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 6e144a67a2..28e61c54b8 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -37,7 +37,7 @@ /* global register indexes */ static TCGv_ptr cpu_env; -#include "gen-icount.h" +#include "exec/gen-icount.h" #include "helper.h" #define GEN_HELPER 1 #include "helper.h" diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h index 9a0e72b1fb..7c50c798b8 100644 --- a/target-sh4/cpu.h +++ b/target-sh4/cpu.h @@ -39,7 +39,7 @@ #define CPUArchState struct CPUSH4State -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -264,7 +264,7 @@ static inline void cpu_clone_regs(CPUSH4State *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" /* Memory access type */ enum { @@ -378,7 +378,7 @@ static inline bool cpu_has_work(CPUState *cpu) return env->interrupt_request & CPU_INTERRUPT_HARD; } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUSH4State *env, TranslationBlock *tb) { diff --git a/target-sh4/helper.h b/target-sh4/helper.h index 304b77ba3f..7162448497 100644 --- a/target-sh4/helper.h +++ b/target-sh4/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_1(ldtlb, void, env) DEF_HELPER_1(raise_illegal_instruction, noreturn, env) @@ -47,4 +47,4 @@ DEF_HELPER_2(ftrc_DT, i32, env, f64) DEF_HELPER_3(fipr, void, env, i32, i32) DEF_HELPER_2(ftrv, void, env, i32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c index e8e87f5152..09e3d23aff 100644 --- a/target-sh4/op_helper.c +++ b/target-sh4/op_helper.c @@ -22,21 +22,21 @@ #include "helper.h" #ifndef CONFIG_USER_ONLY -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void tlb_fill(CPUSH4State *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) diff --git a/target-sh4/translate.c b/target-sh4/translate.c index 41d53e5c51..260aaab559 100644 --- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -69,7 +69,7 @@ static TCGv cpu_flags, cpu_delayed_pc; static uint32_t gen_opc_hflags[OPC_BUF_SIZE]; -#include "gen-icount.h" +#include "exec/gen-icount.h" static void sh4_translate_init(void) { diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 013ecbd063..0ed511a399 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -25,7 +25,7 @@ #define CPUArchState struct CPUSPARCState -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" @@ -701,7 +701,7 @@ static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp) } #endif -#include "cpu-all.h" +#include "exec/cpu-all.h" #ifdef TARGET_SPARC64 /* sun4u.c */ @@ -767,7 +767,7 @@ static inline bool cpu_has_work(CPUState *cpu) cpu_interrupts_enabled(env1); } -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUSPARCState *env, TranslationBlock *tb) { diff --git a/target-sparc/helper.h b/target-sparc/helper.h index 098c482216..cfcdab1ea4 100644 --- a/target-sparc/helper.h +++ b/target-sparc/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" #ifndef TARGET_SPARC64 DEF_HELPER_1(rett, void, env) @@ -173,4 +173,4 @@ VIS_CMPHELPER(cmpne); DEF_HELPER_1(compute_psr, void, env); DEF_HELPER_1(compute_C_icc, i32, env); -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-sparc/ldst_helper.c b/target-sparc/ldst_helper.c index 8d815e5038..cf1bddf2db 100644 --- a/target-sparc/ldst_helper.c +++ b/target-sparc/ldst_helper.c @@ -68,21 +68,21 @@ static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr); -#include "softmmu_exec.h" +#include "exec/softmmu_exec.h" #define MMUSUFFIX _mmu #define ALIGNED_ONLY #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #endif #if defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) diff --git a/target-sparc/mmu_helper.c b/target-sparc/mmu_helper.c index 2c89b20b68..a9649ae064 100644 --- a/target-sparc/mmu_helper.c +++ b/target-sparc/mmu_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" /* Sparc MMU emulation */ diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 88802b8486..ca75e1aa48 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -64,7 +64,7 @@ static TCGv_i64 cpu_fpr[TARGET_DPREGS]; static target_ulong gen_opc_npc[OPC_BUF_SIZE]; static target_ulong gen_opc_jump_pc[2]; -#include "gen-icount.h" +#include "exec/gen-icount.h" typedef struct DisasContext { target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */ diff --git a/target-unicore32/cpu.h b/target-unicore32/cpu.h index 676c5d9d99..cd8f730756 100644 --- a/target-unicore32/cpu.h +++ b/target-unicore32/cpu.h @@ -23,7 +23,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "softfloat.h" #define NB_MMU_MODES 2 @@ -157,9 +157,9 @@ static inline void cpu_set_tls(CPUUniCore32State *env, target_ulong newtls) env->regs[16] = newtls; } -#include "cpu-all.h" +#include "exec/cpu-all.h" #include "cpu-qom.h" -#include "exec-all.h" +#include "exec/exec-all.h" static inline void cpu_pc_from_tb(CPUUniCore32State *env, TranslationBlock *tb) { diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 4b6856137d..2adbd1675d 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -10,7 +10,7 @@ */ #include "cpu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "helper.h" #include "host-utils.h" #include "ui/console.h" diff --git a/target-unicore32/helper.h b/target-unicore32/helper.h index a4b81494aa..e85ce6c201 100644 --- a/target-unicore32/helper.h +++ b/target-unicore32/helper.h @@ -6,7 +6,7 @@ * published by the Free Software Foundation, or (at your option) any * later version. See the COPYING file in the top-level directory. */ -#include "def-helper.h" +#include "exec/def-helper.h" #ifndef CONFIG_USER_ONLY DEF_HELPER_4(cp0_set, void, env, i32, i32, i32) @@ -65,4 +65,4 @@ DEF_HELPER_2(ucf64_si2df, f64, f32, env) DEF_HELPER_2(ucf64_sf2si, f32, f32, env) DEF_HELPER_2(ucf64_df2si, f32, f64, env) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-unicore32/op_helper.c b/target-unicore32/op_helper.c index b8172ba682..6443ffec1c 100644 --- a/target-unicore32/op_helper.c +++ b/target-unicore32/op_helper.c @@ -242,16 +242,16 @@ uint32_t HELPER(ror_cc)(CPUUniCore32State *env, uint32_t x, uint32_t i) #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" void tlb_fill(CPUUniCore32State *env, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 8c49f4d701..218e95eaca 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -55,7 +55,7 @@ static TCGv_i32 cpu_R[32]; static TCGv cpu_F0s, cpu_F1s; static TCGv_i64 cpu_F0d, cpu_F1d; -#include "gen-icount.h" +#include "exec/gen-icount.h" static const char *regnames[] = { "r00", "r01", "r02", "r03", "r04", "r05", "r06", "r07", diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index 804fdef56a..d1a594cda2 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "host-utils.h" #include "core-dc232b/core-isa.h" diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index d643f41d37..ead6b3b128 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "qemu-common.h" #include "host-utils.h" diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index e36b0de9d5..a387aeeca5 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "host-utils.h" #include "core-fsf/core-isa.h" diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h index 08fd5bc395..5acf78c692 100644 --- a/target-xtensa/cpu.h +++ b/target-xtensa/cpu.h @@ -35,7 +35,7 @@ #include "config.h" #include "qemu-common.h" -#include "cpu-defs.h" +#include "exec/cpu-defs.h" #include "fpu/softfloat.h" #define TARGET_HAS_ICE 1 @@ -512,8 +512,8 @@ static inline void cpu_get_tb_cpu_state(CPUXtensaState *env, target_ulong *pc, } } -#include "cpu-all.h" -#include "exec-all.h" +#include "exec/cpu-all.h" +#include "exec/exec-all.h" static inline int cpu_has_work(CPUState *cpu) { diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index bf05575eb5..3d7a399008 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -26,8 +26,8 @@ */ #include "cpu.h" -#include "exec-all.h" -#include "gdbstub.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" #include "host-utils.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" diff --git a/target-xtensa/helper.h b/target-xtensa/helper.h index 5b4cd2700f..38d7157f34 100644 --- a/target-xtensa/helper.h +++ b/target-xtensa/helper.h @@ -1,4 +1,4 @@ -#include "def-helper.h" +#include "exec/def-helper.h" DEF_HELPER_2(exception, noreturn, env, i32) DEF_HELPER_3(exception_cause, noreturn, env, i32, i32) @@ -58,4 +58,4 @@ DEF_HELPER_4(ult_s, void, env, i32, f32, f32) DEF_HELPER_4(ole_s, void, env, i32, f32, f32) DEF_HELPER_4(ule_s, void, env, i32, f32, f32) -#include "def-helper.h" +#include "exec/def-helper.h" diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c index 84f0449f79..a93abcb1dd 100644 --- a/target-xtensa/op_helper.c +++ b/target-xtensa/op_helper.c @@ -36,16 +36,16 @@ static void do_unaligned_access(CPUXtensaState *env, #define MMUSUFFIX _mmu #define SHIFT 0 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 1 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 2 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" #define SHIFT 3 -#include "softmmu_template.h" +#include "exec/softmmu_template.h" static void do_unaligned_access(CPUXtensaState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr) diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index 4e81cbd9ec..3c2d1853d6 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -31,7 +31,7 @@ #include #include "cpu.h" -#include "exec-all.h" +#include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" #include "qemu-log.h" @@ -76,7 +76,7 @@ static TCGv_i32 cpu_FR[16]; static TCGv_i32 cpu_SR[256]; static TCGv_i32 cpu_UR[256]; -#include "gen-icount.h" +#include "exec/gen-icount.h" typedef struct XtensaReg { const char *name; diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 47612fe260..c3ac85e054 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -992,7 +992,7 @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, int label_index) #ifdef CONFIG_SOFTMMU -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/hppa/tcg-target.c b/tcg/hppa/tcg-target.c index de500ae181..5b27cf6f12 100644 --- a/tcg/hppa/tcg-target.c +++ b/tcg/hppa/tcg-target.c @@ -906,7 +906,7 @@ static void tcg_out_movcond(TCGContext *s, int cond, TCGArg ret, } #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 6f3ad3ceab..ae8274652a 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -982,7 +982,7 @@ static void tcg_out_jmp(TCGContext *s, tcg_target_long dest) #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/ia64/tcg-target.c b/tcg/ia64/tcg-target.c index 06570bea38..2373d9ef79 100644 --- a/tcg/ia64/tcg-target.c +++ b/tcg/ia64/tcg-target.c @@ -1491,7 +1491,7 @@ static inline void tcg_out_movcond(TCGContext *s, TCGCond cond, TCGArg ret, #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* Load and compare a TLB entry, and return the result in (p6, p7). R2 is loaded with the address of the addend TLB entry. diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index ae2b274d85..bd8c858989 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -920,7 +920,7 @@ static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c index d72d396270..29ca934e66 100644 --- a/tcg/ppc/tcg-target.c +++ b/tcg/ppc/tcg-target.c @@ -549,7 +549,7 @@ static void add_qemu_ldst_label (TCGContext *s, label->label_ptr[0] = label_ptr; } -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c index 5403fc1f91..833fe0c10b 100644 --- a/tcg/ppc64/tcg-target.c +++ b/tcg/ppc64/tcg-target.c @@ -546,7 +546,7 @@ static void tcg_out_ldsta (TCGContext *s, int ret, int addr, #if defined (CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index fd9286f52d..e12a15221a 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -299,7 +299,7 @@ static const uint8_t tcg_cond_to_ltr_cond[] = { #ifdef CONFIG_SOFTMMU -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index f146647874..03db514a1d 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -831,7 +831,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) #if defined(CONFIG_SOFTMMU) -#include "../../softmmu_defs.h" +#include "exec/softmmu_defs.h" /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, int mmu_idx) */ diff --git a/tci.c b/tci.c index 54cf1d9524..2b2c11f259 100644 --- a/tci.c +++ b/tci.c @@ -25,7 +25,7 @@ #endif #include "qemu-common.h" -#include "exec-all.h" /* MAX_OPC_PARAM_IARGS */ +#include "exec/exec-all.h" /* MAX_OPC_PARAM_IARGS */ #include "tcg-op.h" /* Marker for missing code. */ diff --git a/thunk.c b/thunk.c index 8ebbbb46b6..3cca047509 100644 --- a/thunk.c +++ b/thunk.c @@ -21,7 +21,7 @@ #include #include "qemu.h" -#include "thunk.h" +#include "exec/user/thunk.h" //#define DEBUG diff --git a/thunk.h b/thunk.h deleted file mode 100644 index 87025c3b04..0000000000 --- a/thunk.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Generic thunking code to convert data between host and target CPU - * - * Copyright (c) 2003 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef THUNK_H -#define THUNK_H - -#include -#include "cpu.h" - -/* types enums definitions */ - -typedef enum argtype { - TYPE_NULL, - TYPE_CHAR, - TYPE_SHORT, - TYPE_INT, - TYPE_LONG, - TYPE_ULONG, - TYPE_PTRVOID, /* pointer on unknown data */ - TYPE_LONGLONG, - TYPE_ULONGLONG, - TYPE_PTR, - TYPE_ARRAY, - TYPE_STRUCT, - TYPE_OLDDEVT, -} argtype; - -#define MK_PTR(type) TYPE_PTR, type -#define MK_ARRAY(type, size) TYPE_ARRAY, size, type -#define MK_STRUCT(id) TYPE_STRUCT, id - -#define THUNK_TARGET 0 -#define THUNK_HOST 1 - -typedef struct { - /* standard struct handling */ - const argtype *field_types; - int nb_fields; - int *field_offsets[2]; - /* special handling */ - void (*convert[2])(void *dst, const void *src); - int size[2]; - int align[2]; - const char *name; -} StructEntry; - -/* Translation table for bitmasks... */ -typedef struct bitmask_transtbl { - unsigned int x86_mask; - unsigned int x86_bits; - unsigned int alpha_mask; - unsigned int alpha_bits; -} bitmask_transtbl; - -void thunk_register_struct(int id, const char *name, const argtype *types); -void thunk_register_struct_direct(int id, const char *name, - const StructEntry *se1); -const argtype *thunk_convert(void *dst, const void *src, - const argtype *type_ptr, int to_host); -#ifndef NO_THUNK_TYPE_SIZE - -extern StructEntry struct_entries[]; - -int thunk_type_size_array(const argtype *type_ptr, int is_host); -int thunk_type_align_array(const argtype *type_ptr, int is_host); - -static inline int thunk_type_size(const argtype *type_ptr, int is_host) -{ - int type, size; - const StructEntry *se; - - type = *type_ptr; - switch(type) { - case TYPE_CHAR: - return 1; - case TYPE_SHORT: - return 2; - case TYPE_INT: - return 4; - case TYPE_LONGLONG: - case TYPE_ULONGLONG: - return 8; - case TYPE_LONG: - case TYPE_ULONG: - case TYPE_PTRVOID: - case TYPE_PTR: - if (is_host) { - return sizeof(void *); - } else { - return TARGET_ABI_BITS / 8; - } - break; - case TYPE_OLDDEVT: - if (is_host) { -#if defined(HOST_X86_64) - return 8; -#elif defined(HOST_ALPHA) || defined(HOST_IA64) || defined(HOST_MIPS) || \ - defined(HOST_PARISC) || defined(HOST_SPARC64) - return 4; -#elif defined(HOST_PPC) - return sizeof(void *); -#else - return 2; -#endif - } else { -#if defined(TARGET_X86_64) - return 8; -#elif defined(TARGET_ALPHA) || defined(TARGET_IA64) || defined(TARGET_MIPS) || \ - defined(TARGET_PARISC) || defined(TARGET_SPARC64) - return 4; -#elif defined(TARGET_PPC) - return TARGET_ABI_BITS / 8; -#else - return 2; -#endif - } - break; - case TYPE_ARRAY: - size = type_ptr[1]; - return size * thunk_type_size_array(type_ptr + 2, is_host); - case TYPE_STRUCT: - se = struct_entries + type_ptr[1]; - return se->size[is_host]; - default: - return -1; - } -} - -static inline int thunk_type_align(const argtype *type_ptr, int is_host) -{ - int type; - const StructEntry *se; - - type = *type_ptr; - switch(type) { - case TYPE_CHAR: - return 1; - case TYPE_SHORT: - return 2; - case TYPE_INT: - return 4; - case TYPE_LONGLONG: - case TYPE_ULONGLONG: - return 8; - case TYPE_LONG: - case TYPE_ULONG: - case TYPE_PTRVOID: - case TYPE_PTR: - if (is_host) { - return sizeof(void *); - } else { - return TARGET_ABI_BITS / 8; - } - break; - case TYPE_OLDDEVT: - return thunk_type_size(type_ptr, is_host); - case TYPE_ARRAY: - return thunk_type_align_array(type_ptr + 2, is_host); - case TYPE_STRUCT: - se = struct_entries + type_ptr[1]; - return se->align[is_host]; - default: - return -1; - } -} - -#endif /* NO_THUNK_TYPE_SIZE */ - -unsigned int target_to_host_bitmask(unsigned int x86_mask, - const bitmask_transtbl * trans_tbl); -unsigned int host_to_target_bitmask(unsigned int alpha_mask, - const bitmask_transtbl * trans_tbl); - -#endif diff --git a/translate-all.c b/translate-all.c index bbe06db6eb..e0cdad38c7 100644 --- a/translate-all.c +++ b/translate-all.c @@ -36,8 +36,8 @@ #include "disas/disas.h" #include "tcg.h" #include "qemu-timer.h" -#include "memory.h" -#include "exec-memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) #include "qemu.h" #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) @@ -57,7 +57,7 @@ #endif #endif -#include "cputlb.h" +#include "exec/cputlb.h" #include "translate-all.h" //#define DEBUG_TB_INVALIDATE diff --git a/vl.c b/vl.c index 975767a44b..015f0a4757 100644 --- a/vl.c +++ b/vl.c @@ -132,7 +132,7 @@ int main(int argc, char **argv) #include "monitor.h" #include "ui/console.h" #include "sysemu.h" -#include "gdbstub.h" +#include "exec/gdbstub.h" #include "qemu-timer.h" #include "qemu-char.h" #include "cache-utils.h" diff --git a/xen-all.c b/xen-all.c index e3a51ccc81..95d383f41f 100644 --- a/xen-all.c +++ b/xen-all.c @@ -19,7 +19,7 @@ #include "range.h" #include "xen-mapcache.h" #include "trace.h" -#include "exec-memory.h" +#include "exec/address-spaces.h" #include #include diff --git a/xen-stub.c b/xen-stub.c index 921439263a..1ee841137e 100644 --- a/xen-stub.c +++ b/xen-stub.c @@ -10,7 +10,7 @@ #include "qemu-common.h" #include "hw/xen.h" -#include "memory.h" +#include "exec/memory.h" #include "qmp-commands.h" void xenstore_store_pv_console_info(int i, CharDriverState *chr) -- cgit v1.2.3-55-g7522 From 83c9089e73b81c69dc1ecdf859fa84d2c500fb5f Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:19:49 +0100 Subject: monitor: move include files to include/monitor/ Signed-off-by: Paolo Bonzini --- arch_init.c | 2 +- audio/audio.c | 2 +- audio/wavcapture.c | 2 +- balloon.c | 2 +- balloon.h | 2 +- block.c | 2 +- blockdev-nbd.c | 2 +- blockdev.c | 2 +- blockjob.c | 2 +- cpus.c | 2 +- disas.c | 2 +- dump.c | 2 +- gdbstub.c | 2 +- hmp.c | 2 +- hw/acpi.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/device-hotplug.c | 2 +- hw/i8259.c | 2 +- hw/ide/ahci.c | 2 +- hw/isa-bus.c | 2 +- hw/kvm/pci-assign.c | 2 +- hw/lm32_pic.c | 2 +- hw/loader.c | 2 +- hw/pc.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci-stub.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pcie_aer.c | 2 +- hw/qdev-monitor.c | 2 +- hw/qdev-monitor.h | 2 +- hw/qxl.c | 2 +- hw/s390-virtio-bus.c | 2 +- hw/s390-virtio.c | 2 +- hw/s390x/event-facility.c | 2 +- hw/slavio_intctl.c | 2 +- hw/spapr_vio.c | 2 +- hw/sun4c_intctl.c | 2 +- hw/sysbus.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/host-bsd.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/host-stub.c | 2 +- hw/usb/redirect.c | 2 +- hw/virtio-serial-bus.c | 2 +- hw/watchdog.c | 2 +- include/block/block_int.h | 2 +- include/monitor/monitor.h | 101 ++++++++++++++++++++++++++++++++++++++++++ include/monitor/readline.h | 55 +++++++++++++++++++++++ include/ui/console.h | 2 +- include/ui/qemu-spice.h | 4 +- migration-fd.c | 2 +- migration.c | 2 +- monitor.c | 4 +- monitor.h | 101 ------------------------------------------ net/hub.c | 2 +- net/net.c | 2 +- net/slirp.c | 2 +- net/socket.c | 2 +- net/tap.c | 2 +- osdep.c | 2 +- qemu-char.c | 2 +- qemu-error.c | 2 +- qemu-sockets.c | 2 +- qemu-timer.c | 2 +- qemu-tool.c | 2 +- qemu-user.c | 2 +- qerror.c | 2 +- readline.c | 4 +- readline.h | 55 ----------------------- savevm.c | 2 +- slirp/misc.c | 4 +- stubs/fdset-add-fd.c | 2 +- stubs/fdset-find-fd.c | 2 +- stubs/fdset-get-fd.c | 2 +- stubs/fdset-remove-fd.c | 2 +- stubs/get-fd.c | 2 +- target-i386/helper.c | 2 +- ui/input.c | 2 +- ui/spice-core.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.h | 2 +- vl.c | 2 +- 86 files changed, 242 insertions(+), 242 deletions(-) create mode 100644 include/monitor/monitor.h create mode 100644 include/monitor/readline.h delete mode 100644 monitor.h delete mode 100644 readline.h (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index e15cedad04..93d1e52f4a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -29,7 +29,7 @@ #include #endif #include "config.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "bitops.h" #include "bitmap.h" diff --git a/audio/audio.c b/audio/audio.c index 1c7738930b..a0cc727020 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -23,7 +23,7 @@ */ #include "hw/hw.h" #include "audio.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "sysemu.h" diff --git a/audio/wavcapture.c b/audio/wavcapture.c index 4f785f5f49..9d94623225 100644 --- a/audio/wavcapture.c +++ b/audio/wavcapture.c @@ -1,5 +1,5 @@ #include "hw/hw.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "audio.h" typedef struct { diff --git a/balloon.c b/balloon.c index c24458b5f9..d1de4352b4 100644 --- a/balloon.c +++ b/balloon.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "monitor.h" +#include "monitor/monitor.h" #include "exec/cpu-common.h" #include "kvm.h" #include "balloon.h" diff --git a/balloon.h b/balloon.h index b803a00741..bd9d39505d 100644 --- a/balloon.h +++ b/balloon.h @@ -14,7 +14,7 @@ #ifndef _QEMU_BALLOON_H #define _QEMU_BALLOON_H -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi-types.h" typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); diff --git a/block.c b/block.c index 5eab9e2519..0e7f18c6d3 100644 --- a/block.c +++ b/block.c @@ -24,7 +24,7 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "module.h" diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 81aa1d34ef..596b47499d 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -11,7 +11,7 @@ #include "blockdev.h" #include "hw/block-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "sysemu.h" #include "qmp-commands.h" diff --git a/blockdev.c b/blockdev.c index ff6b333f69..a2308fa718 100644 --- a/blockdev.c +++ b/blockdev.c @@ -10,7 +10,7 @@ #include "blockdev.h" #include "hw/block-common.h" #include "block/blockjob.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qerror.h" #include "qemu-option.h" #include "qemu-config.h" diff --git a/blockjob.c b/blockjob.c index 004480d714..4bc60c7378 100644 --- a/blockjob.c +++ b/blockjob.c @@ -26,7 +26,7 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "block/block.h" #include "block/blockjob.h" #include "block/block_int.h" diff --git a/cpus.c b/cpus.c index 8926873ad1..3a66401e0d 100644 --- a/cpus.c +++ b/cpus.c @@ -25,7 +25,7 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "exec/gdbstub.h" #include "dma.h" diff --git a/disas.c b/disas.c index 8157b96fc1..a46faeed80 100644 --- a/disas.c +++ b/disas.c @@ -374,7 +374,7 @@ const char *lookup_symbol(target_ulong orig_addr) #if !defined(CONFIG_USER_ONLY) -#include "monitor.h" +#include "monitor/monitor.h" static int monitor_disas_is_physical; diff --git a/dump.c b/dump.c index e70e0f3b21..871ee1727a 100644 --- a/dump.c +++ b/dump.c @@ -16,7 +16,7 @@ #include "cpu.h" #include "exec/cpu-all.h" #include "exec/hwaddr.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "kvm.h" #include "dump.h" #include "sysemu.h" diff --git a/gdbstub.c b/gdbstub.c index 70ad79a748..9395c829a2 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -29,7 +29,7 @@ #include "qemu.h" #else -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-char.h" #include "sysemu.h" #include "exec/gdbstub.h" diff --git a/hmp.c b/hmp.c index f235134bb6..a76a8f06ea 100644 --- a/hmp.c +++ b/hmp.c @@ -20,7 +20,7 @@ #include "qemu-timer.h" #include "qmp-commands.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" static void hmp_handle_error(Monitor *mon, Error **errp) diff --git a/hw/acpi.c b/hw/acpi.c index ae29a59077..fe9b76a9b0 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -22,7 +22,7 @@ #include "hw.h" #include "pc.h" #include "acpi.h" -#include "monitor.h" +#include "monitor/monitor.h" struct acpi_table_header { uint16_t _length; /* our length, not actual part of the hdr */ diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index f4a6da4283..845a764446 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -33,7 +33,7 @@ #include "qemu-thread.h" #include "qemu-char.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" #define DPRINTF(card, lvl, fmt, ...) \ diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index bd6c77777d..f5b4794e90 100644 --- a/hw/ccid-card-passthru.c +++ b/hw/ccid-card-passthru.c @@ -10,7 +10,7 @@ #include "qemu-char.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" #include "libcacard/vscard_common.h" diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 336ffc2274..809a598e3a 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -27,7 +27,7 @@ #include "blockdev.h" #include "qemu-config.h" #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" DriveInfo *add_init_drive(const char *optstr) { diff --git a/hw/i8259.c b/hw/i8259.c index af0ba4d7c6..5e935e7f99 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "i8259_internal.h" diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index f32a84761d..d38c6e4574 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -27,7 +27,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #include "dma.h" #include "exec/cpu-common.h" #include "internal.h" diff --git a/hw/isa-bus.c b/hw/isa-bus.c index 8f40974166..a2be67df56 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "hw.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "sysemu.h" #include "isa.h" diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 2629775589..ff0dc0dfd4 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -31,7 +31,7 @@ #include "qemu-error.h" #include "ui/console.h" #include "hw/loader.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "range.h" #include "sysemu.h" #include "hw/pci/pci.h" diff --git a/hw/lm32_pic.c b/hw/lm32_pic.c index 32f65db7f1..42d5602cf0 100644 --- a/hw/lm32_pic.c +++ b/hw/lm32_pic.c @@ -21,7 +21,7 @@ #include "hw.h" #include "pc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "trace.h" #include "lm32_pic.h" diff --git a/hw/loader.c b/hw/loader.c index 03f0318d91..f5ef575b52 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -44,7 +44,7 @@ #include "hw.h" #include "disas/disas.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "uboot_image.h" #include "loader.h" diff --git a/hw/pc.c b/hw/pc.c index 2452fd4214..7aaff0f2fd 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -28,7 +28,7 @@ #include "fdc.h" #include "ide.h" #include "pci/pci.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "fw_cfg.h" #include "hpet_emul.h" #include "smbios.h" diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 5ba7558ecd..e5e8a7ab58 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -27,7 +27,7 @@ #include "hw/pci/pci.h" #include "net/net.h" #include "hw/pc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/scsi.h" #include "hw/virtio-blk.h" #include "qemu-config.h" diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index b5c43a935b..5891dc959d 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -19,7 +19,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/pci/pci.h" #include "qmp-commands.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fa0f08eb0a..e062f66088 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -25,7 +25,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "net/net.h" #include "sysemu.h" #include "hw/loader.h" diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index b6f4f8510f..f7f3633f5b 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -20,7 +20,7 @@ #include "sysemu.h" #include "qapi/qmp/types.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pcie.h" #include "hw/pci/msix.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 5aaf74b98a..207282c4a4 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -18,7 +18,7 @@ */ #include "qdev.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qmp-commands.h" #include "arch_init.h" #include "qemu-config.h" diff --git a/hw/qdev-monitor.h b/hw/qdev-monitor.h index 220ceba4c5..fae1b1ec84 100644 --- a/hw/qdev-monitor.h +++ b/hw/qdev-monitor.h @@ -2,7 +2,7 @@ #define QEMU_QDEV_MONITOR_H #include "qdev-core.h" -#include "monitor.h" +#include "monitor/monitor.h" /*** monitor commands ***/ diff --git a/hw/qxl.c b/hw/qxl.c index 96887c4aad..ad0214827e 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -23,7 +23,7 @@ #include "qemu-common.h" #include "qemu-timer.h" #include "qemu-queue.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index f7e1939288..769015c136 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -21,7 +21,7 @@ #include "block/block.h" #include "sysemu.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/virtio.h" diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 0a15625b73..7dfe87ade3 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -23,7 +23,7 @@ #include "sysemu.h" #include "net/net.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/virtio.h" diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index bc9cea9e1b..748118d0f0 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -15,7 +15,7 @@ * */ -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "sclp.h" diff --git a/hw/slavio_intctl.c b/hw/slavio_intctl.c index 6aafa8b233..a44ce95c1f 100644 --- a/hw/slavio_intctl.c +++ b/hw/slavio_intctl.c @@ -23,7 +23,7 @@ */ #include "sun4m.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index 1f19fedd0e..fdf8db9158 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -22,7 +22,7 @@ #include "hw.h" #include "sysemu.h" #include "boards.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/sysbus.h" diff --git a/hw/sun4c_intctl.c b/hw/sun4c_intctl.c index 702e9f5444..b78d54f232 100644 --- a/hw/sun4c_intctl.c +++ b/hw/sun4c_intctl.c @@ -24,7 +24,7 @@ #include "hw.h" #include "sun4m.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysbus.h" //#define DEBUG_IRQ_COUNT diff --git a/hw/sysbus.c b/hw/sysbus.c index 7ab250463c..49a41775f8 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -18,7 +18,7 @@ */ #include "sysbus.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "exec/address-spaces.h" static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 8264c240ee..74728c94e5 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -2,7 +2,7 @@ #include "hw/usb.h" #include "hw/qdev.h" #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent); diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index de955b709f..3862c9b6c9 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -38,7 +38,7 @@ #include "qemu-error.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/ccid.h" diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index de56fea610..0d7597b4d1 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -14,7 +14,7 @@ #include "hw/usb/desc.h" #include "hw/scsi.h" #include "ui/console.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "blockdev.h" diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 837c63be85..740f7309fb 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -20,7 +20,7 @@ #include "hw/hw.h" #include "qemu-timer.h" #include "hw/usb.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" #include "dma.h" #include "sysemu.h" diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index dae0009378..340c21aeb4 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/usb.h" /* usb.h declares these */ diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index bdafb6bc87..5a56e99891 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -32,7 +32,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/usb/host-stub.c b/hw/usb/host-stub.c index e8da3221f6..58423a0f5c 100644 --- a/hw/usb/host-stub.c +++ b/hw/usb/host-stub.c @@ -33,7 +33,7 @@ #include "qemu-common.h" #include "ui/console.h" #include "hw/usb.h" -#include "monitor.h" +#include "monitor/monitor.h" void usb_host_info(Monitor *mon) { diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 9e7f6453f7..3621076020 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -27,7 +27,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "iov.h" diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 155da58dcd..5559518a93 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -19,7 +19,7 @@ */ #include "iov.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-queue.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/watchdog.c b/hw/watchdog.c index f878bec860..623b299f71 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -24,7 +24,7 @@ #include "qemu-config.h" #include "qemu-queue.h" #include "qapi/qmp/types.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "hw/watchdog.h" diff --git a/include/block/block_int.h b/include/block/block_int.h index d06de2637b..14c57afd54 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -31,7 +31,7 @@ #include "qemu-timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" -#include "monitor.h" +#include "monitor/monitor.h" #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h new file mode 100644 index 0000000000..87fb49c092 --- /dev/null +++ b/include/monitor/monitor.h @@ -0,0 +1,101 @@ +#ifndef MONITOR_H +#define MONITOR_H + +#include "qemu-common.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/qdict.h" +#include "block/block.h" +#include "monitor/readline.h" + +extern Monitor *cur_mon; +extern Monitor *default_mon; + +/* flags for monitor_init */ +#define MONITOR_IS_DEFAULT 0x01 +#define MONITOR_USE_READLINE 0x02 +#define MONITOR_USE_CONTROL 0x04 +#define MONITOR_USE_PRETTY 0x08 + +/* flags for monitor commands */ +#define MONITOR_CMD_ASYNC 0x0001 + +/* QMP events */ +typedef enum MonitorEvent { + QEVENT_SHUTDOWN, + QEVENT_RESET, + QEVENT_POWERDOWN, + QEVENT_STOP, + QEVENT_RESUME, + QEVENT_VNC_CONNECTED, + QEVENT_VNC_INITIALIZED, + QEVENT_VNC_DISCONNECTED, + QEVENT_BLOCK_IO_ERROR, + QEVENT_RTC_CHANGE, + QEVENT_WATCHDOG, + QEVENT_SPICE_CONNECTED, + QEVENT_SPICE_INITIALIZED, + QEVENT_SPICE_DISCONNECTED, + QEVENT_BLOCK_JOB_COMPLETED, + QEVENT_BLOCK_JOB_CANCELLED, + QEVENT_BLOCK_JOB_ERROR, + QEVENT_BLOCK_JOB_READY, + QEVENT_DEVICE_TRAY_MOVED, + QEVENT_SUSPEND, + QEVENT_SUSPEND_DISK, + QEVENT_WAKEUP, + QEVENT_BALLOON_CHANGE, + QEVENT_SPICE_MIGRATE_COMPLETED, + + /* Add to 'monitor_event_names' array in monitor.c when + * defining new events here */ + + QEVENT_MAX, +} MonitorEvent; + +int monitor_cur_is_qmp(void); + +void monitor_protocol_event(MonitorEvent event, QObject *data); +void monitor_init(CharDriverState *chr, int flags); + +int monitor_suspend(Monitor *mon); +void monitor_resume(Monitor *mon); + +int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, + BlockDriverCompletionFunc *completion_cb, + void *opaque); +int monitor_read_block_device_key(Monitor *mon, const char *device, + BlockDriverCompletionFunc *completion_cb, + void *opaque); + +int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); +int monitor_handle_fd_param(Monitor *mon, const char *fdname); + +void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); +void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +void monitor_print_filename(Monitor *mon, const char *filename); +void monitor_flush(Monitor *mon); +int monitor_set_cpu(int cpu_index); +int monitor_get_cpu_index(void); + +typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); + +void monitor_set_error(Monitor *mon, QError *qerror); +void monitor_read_command(Monitor *mon, int show_prompt); +ReadLineState *monitor_get_rs(Monitor *mon); +int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, + void *opaque); + +int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); + +int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); + +AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, + bool has_opaque, const char *opaque, + Error **errp); +int monitor_fdset_get_fd(int64_t fdset_id, int flags); +int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); +int monitor_fdset_dup_fd_remove(int dup_fd); +int monitor_fdset_dup_fd_find(int dup_fd); + +#endif /* !MONITOR_H */ diff --git a/include/monitor/readline.h b/include/monitor/readline.h new file mode 100644 index 0000000000..fc9806ecf1 --- /dev/null +++ b/include/monitor/readline.h @@ -0,0 +1,55 @@ +#ifndef READLINE_H +#define READLINE_H + +#include "qemu-common.h" + +#define READLINE_CMD_BUF_SIZE 4095 +#define READLINE_MAX_CMDS 64 +#define READLINE_MAX_COMPLETIONS 256 + +typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); +typedef void ReadLineCompletionFunc(const char *cmdline); + +typedef struct ReadLineState { + char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int cmd_buf_index; + int cmd_buf_size; + + char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; + int last_cmd_buf_index; + int last_cmd_buf_size; + + int esc_state; + int esc_param; + + char *history[READLINE_MAX_CMDS]; + int hist_entry; + + ReadLineCompletionFunc *completion_finder; + char *completions[READLINE_MAX_COMPLETIONS]; + int nb_completions; + int completion_index; + + ReadLineFunc *readline_func; + void *readline_opaque; + int read_password; + char prompt[256]; + Monitor *mon; +} ReadLineState; + +void readline_add_completion(ReadLineState *rs, const char *str); +void readline_set_completion_index(ReadLineState *rs, int completion_index); + +const char *readline_get_history(ReadLineState *rs, unsigned int index); + +void readline_handle_byte(ReadLineState *rs, int ch); + +void readline_start(ReadLineState *rs, const char *prompt, int read_password, + ReadLineFunc *readline_func, void *opaque); +void readline_restart(ReadLineState *rs); +void readline_show_prompt(ReadLineState *rs); + +ReadLineState *readline_init(Monitor *mon, + ReadLineCompletionFunc *completion_finder); + +#endif /* !READLINE_H */ diff --git a/include/ui/console.h b/include/ui/console.h index eff5cc92d6..3db6635b0a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -4,7 +4,7 @@ #include "ui/qemu-pixman.h" #include "qapi/qmp/qdict.h" #include "notify.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "trace.h" #include "qapi-types.h" #include "qapi/error.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 5857b8a92e..3e08be06bf 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -24,7 +24,7 @@ #include "qemu-option.h" #include "qemu-config.h" -#include "monitor.h" +#include "monitor/monitor.h" extern int using_spice; @@ -47,7 +47,7 @@ void do_info_spice(Monitor *mon, QObject **ret_data); CharDriverState *qemu_chr_open_spice(QemuOpts *opts); #else /* CONFIG_SPICE */ -#include "monitor.h" +#include "monitor/monitor.h" #define using_spice 0 static inline int qemu_spice_set_passwd(const char *passwd, diff --git a/migration-fd.c b/migration-fd.c index e86228823f..73a1dfcc93 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -16,7 +16,7 @@ #include "qemu-common.h" #include "qemu_socket.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" #include "qemu_socket.h" diff --git a/migration.c b/migration.c index 1fce152548..27a272eace 100644 --- a/migration.c +++ b/migration.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" diff --git a/monitor.c b/monitor.c index a3e010968e..94c6bb6672 100644 --- a/monitor.c +++ b/monitor.c @@ -36,8 +36,8 @@ #include "qemu-char.h" #include "ui/qemu-spice.h" #include "sysemu.h" -#include "monitor.h" -#include "readline.h" +#include "monitor/monitor.h" +#include "monitor/readline.h" #include "ui/console.h" #include "blockdev.h" #include "audio/audio.h" diff --git a/monitor.h b/monitor.h deleted file mode 100644 index 9e96e83f5f..0000000000 --- a/monitor.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef MONITOR_H -#define MONITOR_H - -#include "qemu-common.h" -#include "qapi/qmp/qerror.h" -#include "qapi/qmp/qdict.h" -#include "block/block.h" -#include "readline.h" - -extern Monitor *cur_mon; -extern Monitor *default_mon; - -/* flags for monitor_init */ -#define MONITOR_IS_DEFAULT 0x01 -#define MONITOR_USE_READLINE 0x02 -#define MONITOR_USE_CONTROL 0x04 -#define MONITOR_USE_PRETTY 0x08 - -/* flags for monitor commands */ -#define MONITOR_CMD_ASYNC 0x0001 - -/* QMP events */ -typedef enum MonitorEvent { - QEVENT_SHUTDOWN, - QEVENT_RESET, - QEVENT_POWERDOWN, - QEVENT_STOP, - QEVENT_RESUME, - QEVENT_VNC_CONNECTED, - QEVENT_VNC_INITIALIZED, - QEVENT_VNC_DISCONNECTED, - QEVENT_BLOCK_IO_ERROR, - QEVENT_RTC_CHANGE, - QEVENT_WATCHDOG, - QEVENT_SPICE_CONNECTED, - QEVENT_SPICE_INITIALIZED, - QEVENT_SPICE_DISCONNECTED, - QEVENT_BLOCK_JOB_COMPLETED, - QEVENT_BLOCK_JOB_CANCELLED, - QEVENT_BLOCK_JOB_ERROR, - QEVENT_BLOCK_JOB_READY, - QEVENT_DEVICE_TRAY_MOVED, - QEVENT_SUSPEND, - QEVENT_SUSPEND_DISK, - QEVENT_WAKEUP, - QEVENT_BALLOON_CHANGE, - QEVENT_SPICE_MIGRATE_COMPLETED, - - /* Add to 'monitor_event_names' array in monitor.c when - * defining new events here */ - - QEVENT_MAX, -} MonitorEvent; - -int monitor_cur_is_qmp(void); - -void monitor_protocol_event(MonitorEvent event, QObject *data); -void monitor_init(CharDriverState *chr, int flags); - -int monitor_suspend(Monitor *mon); -void monitor_resume(Monitor *mon); - -int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, - BlockDriverCompletionFunc *completion_cb, - void *opaque); -int monitor_read_block_device_key(Monitor *mon, const char *device, - BlockDriverCompletionFunc *completion_cb, - void *opaque); - -int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); -int monitor_handle_fd_param(Monitor *mon, const char *fdname); - -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) - GCC_FMT_ATTR(2, 0); -void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -void monitor_print_filename(Monitor *mon, const char *filename); -void monitor_flush(Monitor *mon); -int monitor_set_cpu(int cpu_index); -int monitor_get_cpu_index(void); - -typedef void (MonitorCompletion)(void *opaque, QObject *ret_data); - -void monitor_set_error(Monitor *mon, QError *qerror); -void monitor_read_command(Monitor *mon, int show_prompt); -ReadLineState *monitor_get_rs(Monitor *mon); -int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, - void *opaque); - -int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); - -int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); - -AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset_id, int64_t fdset_id, - bool has_opaque, const char *opaque, - Error **errp); -int monitor_fdset_get_fd(int64_t fdset_id, int flags); -int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); -int monitor_fdset_dup_fd_remove(int dup_fd); -int monitor_fdset_dup_fd_find(int dup_fd); - -#endif /* !MONITOR_H */ diff --git a/net/hub.c b/net/hub.c index 8508ecf380..81a73b54a7 100644 --- a/net/hub.c +++ b/net/hub.c @@ -12,7 +12,7 @@ * */ -#include "monitor.h" +#include "monitor/monitor.h" #include "net/net.h" #include "clients.h" #include "hub.h" diff --git a/net/net.c b/net/net.c index ead7e96fe1..e4d85a9cfa 100644 --- a/net/net.c +++ b/net/net.c @@ -29,7 +29,7 @@ #include "net/slirp.h" #include "util.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-common.h" #include "qemu_socket.h" #include "qemu-config.h" diff --git a/net/slirp.c b/net/slirp.c index 5a11ac5859..c37a5ef959 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -32,7 +32,7 @@ #include "net/net.h" #include "clients.h" #include "hub.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu_socket.h" #include "slirp/libslirp.h" #include "qemu-char.h" diff --git a/net/socket.c b/net/socket.c index 8430f1a161..bc2b951832 100644 --- a/net/socket.c +++ b/net/socket.c @@ -25,7 +25,7 @@ #include "net/net.h" #include "clients.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-common.h" #include "qemu-error.h" #include "qemu-option.h" diff --git a/net/tap.c b/net/tap.c index f8cabc4f86..9a677e9864 100644 --- a/net/tap.c +++ b/net/tap.c @@ -35,7 +35,7 @@ #include "net/net.h" #include "clients.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "qemu-common.h" #include "qemu-error.h" diff --git a/osdep.c b/osdep.c index 3a63d26e75..807e90cf97 100644 --- a/osdep.c +++ b/osdep.c @@ -48,7 +48,7 @@ extern int madvise(caddr_t, size_t, int); #include "qemu-common.h" #include "trace.h" #include "qemu_socket.h" -#include "monitor.h" +#include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/qemu-char.c b/qemu-char.c index bc53d09a9b..16021c5a43 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "qemu-timer.h" diff --git a/qemu-error.c b/qemu-error.c index 7cd5ffe1e9..08a36f480c 100644 --- a/qemu-error.c +++ b/qemu-error.c @@ -11,7 +11,7 @@ */ #include -#include "monitor.h" +#include "monitor/monitor.h" /* * Print to current monitor if we have one, else to stderr. diff --git a/qemu-sockets.c b/qemu-sockets.c index c52a40a411..cea0a4b8ac 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -22,7 +22,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu_socket.h" #include "qemu-common.h" /* for qemu_isdigit */ #include "main-loop.h" diff --git a/qemu-timer.c b/qemu-timer.c index 5a99403fda..8e0dccc087 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -23,7 +23,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "hw/hw.h" diff --git a/qemu-tool.c b/qemu-tool.c index b46631e422..40453fdd99 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "qemu-timer.h" #include "qemu-log.h" #include "migration.h" diff --git a/qemu-user.c b/qemu-user.c index 08ccb0fe8e..f8b450c03d 100644 --- a/qemu-user.c +++ b/qemu-user.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" Monitor *cur_mon; diff --git a/qerror.c b/qerror.c index 8c78104277..3aee1cf6a6 100644 --- a/qerror.c +++ b/qerror.c @@ -10,7 +10,7 @@ * See the COPYING.LIB file in the top-level directory. */ -#include "monitor.h" +#include "monitor/monitor.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qerror.h" #include "qemu-common.h" diff --git a/readline.c b/readline.c index 540cd8a025..5fc9643c2b 100644 --- a/readline.c +++ b/readline.c @@ -21,8 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "readline.h" -#include "monitor.h" +#include "monitor/readline.h" +#include "monitor/monitor.h" #define IS_NORM 0 #define IS_ESC 1 diff --git a/readline.h b/readline.h deleted file mode 100644 index fc9806ecf1..0000000000 --- a/readline.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef READLINE_H -#define READLINE_H - -#include "qemu-common.h" - -#define READLINE_CMD_BUF_SIZE 4095 -#define READLINE_MAX_CMDS 64 -#define READLINE_MAX_COMPLETIONS 256 - -typedef void ReadLineFunc(Monitor *mon, const char *str, void *opaque); -typedef void ReadLineCompletionFunc(const char *cmdline); - -typedef struct ReadLineState { - char cmd_buf[READLINE_CMD_BUF_SIZE + 1]; - int cmd_buf_index; - int cmd_buf_size; - - char last_cmd_buf[READLINE_CMD_BUF_SIZE + 1]; - int last_cmd_buf_index; - int last_cmd_buf_size; - - int esc_state; - int esc_param; - - char *history[READLINE_MAX_CMDS]; - int hist_entry; - - ReadLineCompletionFunc *completion_finder; - char *completions[READLINE_MAX_COMPLETIONS]; - int nb_completions; - int completion_index; - - ReadLineFunc *readline_func; - void *readline_opaque; - int read_password; - char prompt[256]; - Monitor *mon; -} ReadLineState; - -void readline_add_completion(ReadLineState *rs, const char *str); -void readline_set_completion_index(ReadLineState *rs, int completion_index); - -const char *readline_get_history(ReadLineState *rs, unsigned int index); - -void readline_handle_byte(ReadLineState *rs, int ch); - -void readline_start(ReadLineState *rs, const char *prompt, int read_password, - ReadLineFunc *readline_func, void *opaque); -void readline_restart(ReadLineState *rs); -void readline_show_prompt(ReadLineState *rs); - -ReadLineState *readline_init(Monitor *mon, - ReadLineCompletionFunc *completion_finder); - -#endif /* !READLINE_H */ diff --git a/savevm.c b/savevm.c index cb33501ecc..bf341bb25f 100644 --- a/savevm.c +++ b/savevm.c @@ -73,7 +73,7 @@ #include "hw/hw.h" #include "hw/qdev.h" #include "net/net.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "sysemu.h" #include "qemu-timer.h" #include "audio/audio.h" diff --git a/slirp/misc.c b/slirp/misc.c index 664532a663..d4df972d13 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -8,7 +8,7 @@ #include #include -#include "monitor.h" +#include "monitor/monitor.h" #ifdef DEBUG int slirp_debug = DBG_CALL|DBG_MISC|DBG_ERROR; @@ -242,7 +242,7 @@ strdup(str) } #endif -#include "monitor.h" +#include "monitor/monitor.h" void lprint(const char *format, ...) { diff --git a/stubs/fdset-add-fd.c b/stubs/fdset-add-fd.c index 09fe2a839a..ee1643708c 100644 --- a/stubs/fdset-add-fd.c +++ b/stubs/fdset-add-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd) { diff --git a/stubs/fdset-find-fd.c b/stubs/fdset-find-fd.c index f82baa066c..4f18344bad 100644 --- a/stubs/fdset-find-fd.c +++ b/stubs/fdset-find-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_find(int dup_fd) { diff --git a/stubs/fdset-get-fd.c b/stubs/fdset-get-fd.c index 4106cf90f0..7112c155e3 100644 --- a/stubs/fdset-get-fd.c +++ b/stubs/fdset-get-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_get_fd(int64_t fdset_id, int flags) { diff --git a/stubs/fdset-remove-fd.c b/stubs/fdset-remove-fd.c index 861b31247e..b3886d9f45 100644 --- a/stubs/fdset-remove-fd.c +++ b/stubs/fdset-remove-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_fdset_dup_fd_remove(int dupfd) { diff --git a/stubs/get-fd.c b/stubs/get-fd.c index 3561ab60e2..9f2c65cf0a 100644 --- a/stubs/get-fd.c +++ b/stubs/get-fd.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "monitor.h" +#include "monitor/monitor.h" int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { diff --git a/target-i386/helper.c b/target-i386/helper.c index 00341c5233..bd47b8e58e 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -21,7 +21,7 @@ #include "kvm.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #endif //#define DEBUG_MMU diff --git a/ui/input.c b/ui/input.c index 65950af9af..05f6c0c849 100644 --- a/ui/input.c +++ b/ui/input.c @@ -23,7 +23,7 @@ */ #include "sysemu.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "qapi/error.h" #include "qmp-commands.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index 0550805b38..379677554e 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -35,7 +35,7 @@ #include "qapi/qmp/qjson.h" #include "notify.h" #include "migration.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "hw/hw.h" #include "ui/spice-display.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index 681fe32fed..56ebf80805 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -19,7 +19,7 @@ #include "ui/qemu-spice.h" #include "qemu-timer.h" #include "qemu-queue.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "trace.h" diff --git a/ui/vnc.h b/ui/vnc.h index 7ec183372a..e5c043ff45 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -31,7 +31,7 @@ #include "qemu-queue.h" #include "qemu-thread.h" #include "ui/console.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "audio/audio.h" #include "bitmap.h" #include diff --git a/vl.c b/vl.c index 015f0a4757..9adaf28e64 100644 --- a/vl.c +++ b/vl.c @@ -129,7 +129,7 @@ int main(int argc, char **argv) #include "bt-host.h" #include "net/net.h" #include "net/slirp.h" -#include "monitor.h" +#include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" #include "exec/gdbstub.h" -- cgit v1.2.3-55-g7522 From caf71f86a3de97394bcc5b06549012b7dc65fe60 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:19:50 +0100 Subject: migration: move include files to include/migration/ Signed-off-by: Paolo Bonzini --- arch_init.c | 4 +- block-migration.c | 4 +- block-migration.h | 23 -- block/qcow.c | 2 +- block/qed.c | 2 +- block/vdi.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- block/vvfat.c | 2 +- buffered_file.h | 2 +- hw/9pfs/virtio-9p.c | 2 +- hw/hid.h | 2 +- hw/hw.h | 4 +- hw/ivshmem.c | 2 +- hw/pci/shpc.h | 2 +- hw/ptimer.h | 2 +- include/migration/block.h | 23 ++ include/migration/migration.h | 131 +++++++++ include/migration/page_cache.h | 79 +++++ include/migration/qemu-file.h | 241 ++++++++++++++++ include/migration/vmstate.h | 639 +++++++++++++++++++++++++++++++++++++++++ include/net/net.h | 2 +- include/qemu/page_cache.h | 79 ----- migration-exec.c | 2 +- migration-fd.c | 2 +- migration-tcp.c | 2 +- migration-unix.c | 2 +- migration.c | 4 +- migration.h | 131 --------- monitor.c | 2 +- page_cache.c | 2 +- qemu-file.h | 241 ---------------- qemu-tool.c | 2 +- savevm.c | 2 +- ui/spice-core.c | 2 +- vl.c | 4 +- vmstate.h | 639 ----------------------------------------- 37 files changed, 1145 insertions(+), 1145 deletions(-) delete mode 100644 block-migration.h create mode 100644 include/migration/block.h create mode 100644 include/migration/migration.h create mode 100644 include/migration/page_cache.h create mode 100644 include/migration/qemu-file.h create mode 100644 include/migration/vmstate.h delete mode 100644 include/qemu/page_cache.h delete mode 100644 migration.h delete mode 100644 qemu-file.h delete mode 100644 vmstate.h (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 93d1e52f4a..f627253a20 100644 --- a/arch_init.c +++ b/arch_init.c @@ -39,12 +39,12 @@ #include "hw/pci/pci.h" #include "hw/audiodev.h" #include "kvm.h" -#include "migration.h" +#include "migration/migration.h" #include "exec/gdbstub.h" #include "hw/smbios.h" #include "exec/address-spaces.h" #include "hw/pcspk.h" -#include "qemu/page_cache.h" +#include "migration/page_cache.h" #include "qemu-config.h" #include "qmp-commands.h" #include "trace.h" diff --git a/block-migration.c b/block-migration.c index c15de9f750..2d2dcbda94 100644 --- a/block-migration.c +++ b/block-migration.c @@ -18,8 +18,8 @@ #include "hw/hw.h" #include "qemu-queue.h" #include "qemu-timer.h" -#include "block-migration.h" -#include "migration.h" +#include "migration/block.h" +#include "migration/migration.h" #include "blockdev.h" #include diff --git a/block-migration.h b/block-migration.h deleted file mode 100644 index ffa8ac0bdd..0000000000 --- a/block-migration.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * QEMU live block migration - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Liran Schour - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef BLOCK_MIGRATION_H -#define BLOCK_MIGRATION_H - -void blk_mig_init(void); -int blk_mig_active(void); -uint64_t blk_mig_bytes_transferred(void); -uint64_t blk_mig_bytes_remaining(void); -uint64_t blk_mig_bytes_total(void); - -#endif /* BLOCK_MIGRATION_H */ diff --git a/block/qcow.c b/block/qcow.c index d13bd400f0..f36671196e 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -26,7 +26,7 @@ #include "module.h" #include #include "block/aes.h" -#include "migration.h" +#include "migration/migration.h" /**************************************************************/ /* QEMU COW block driver with compression and encryption support */ diff --git a/block/qed.c b/block/qed.c index ca1fafb47e..10d0827482 100644 --- a/block/qed.c +++ b/block/qed.c @@ -16,7 +16,7 @@ #include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" -#include "migration.h" +#include "migration/migration.h" static void qed_aio_cancel(BlockDriverAIOCB *blockacb) { diff --git a/block/vdi.c b/block/vdi.c index dab9cac76e..b1d199a2e5 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -52,7 +52,7 @@ #include "qemu-common.h" #include "block/block_int.h" #include "module.h" -#include "migration.h" +#include "migration/migration.h" #if defined(CONFIG_UUID) #include diff --git a/block/vmdk.c b/block/vmdk.c index 68e50e1a3e..77a1a67c61 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -26,7 +26,7 @@ #include "qemu-common.h" #include "block/block_int.h" #include "module.h" -#include "migration.h" +#include "migration/migration.h" #include #define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D') diff --git a/block/vpc.c b/block/vpc.c index aabd71201c..47b5518aee 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/block_int.h" #include "module.h" -#include "migration.h" +#include "migration/migration.h" #if defined(CONFIG_UUID) #include #endif diff --git a/block/vvfat.c b/block/vvfat.c index fbabafca76..a63c3ea7cd 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -27,7 +27,7 @@ #include "qemu-common.h" #include "block/block_int.h" #include "module.h" -#include "migration.h" +#include "migration/migration.h" #ifndef S_IWGRP #define S_IWGRP 0 diff --git a/buffered_file.h b/buffered_file.h index ef010febfe..86a7075246 100644 --- a/buffered_file.h +++ b/buffered_file.h @@ -15,7 +15,7 @@ #define QEMU_BUFFERED_FILE_H #include "hw/hw.h" -#include "migration.h" +#include "migration/migration.h" QEMUFile *qemu_fopen_ops_buffered(MigrationState *migration_state); diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 8b9cdc96ed..ede20ce80e 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -20,7 +20,7 @@ #include "virtio-9p-xattr.h" #include "virtio-9p-coth.h" #include "trace.h" -#include "migration.h" +#include "migration/migration.h" int open_fd_hw; int total_open_fd; diff --git a/hw/hid.h b/hw/hid.h index 5315cf7a31..100b121663 100644 --- a/hw/hid.h +++ b/hw/hid.h @@ -1,7 +1,7 @@ #ifndef QEMU_HID_H #define QEMU_HID_H -#include "vmstate.h" +#include "migration/vmstate.h" #define HID_MOUSE 1 #define HID_TABLET 2 diff --git a/hw/hw.h b/hw/hw.h index 7368470bb1..883ddb60f9 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -11,8 +11,8 @@ #include "exec/ioport.h" #include "irq.h" #include "block/aio.h" -#include "qemu-file.h" -#include "vmstate.h" +#include "migration/qemu-file.h" +#include "migration/vmstate.h" #include "qemu-log.h" #ifdef NEED_CPU_H diff --git a/hw/ivshmem.c b/hw/ivshmem.c index d15760b314..d5b91dd24e 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -21,7 +21,7 @@ #include "pci/pci.h" #include "pci/msix.h" #include "kvm.h" -#include "migration.h" +#include "migration/migration.h" #include "qapi/qmp/qerror.h" #include "event_notifier.h" #include "qemu-char.h" diff --git a/hw/pci/shpc.h b/hw/pci/shpc.h index 6374e68bdb..467911a558 100644 --- a/hw/pci/shpc.h +++ b/hw/pci/shpc.h @@ -3,7 +3,7 @@ #include "qemu-common.h" #include "exec/memory.h" -#include "vmstate.h" +#include "migration/vmstate.h" struct SHPCDevice { /* Capability offset in device's config space */ diff --git a/hw/ptimer.h b/hw/ptimer.h index 6638f61322..9d172f7764 100644 --- a/hw/ptimer.h +++ b/hw/ptimer.h @@ -10,7 +10,7 @@ #include "qemu-common.h" #include "qemu-timer.h" -#include "vmstate.h" +#include "migration/vmstate.h" /* ptimer.c */ typedef struct ptimer_state ptimer_state; diff --git a/include/migration/block.h b/include/migration/block.h new file mode 100644 index 0000000000..ffa8ac0bdd --- /dev/null +++ b/include/migration/block.h @@ -0,0 +1,23 @@ +/* + * QEMU live block migration + * + * Copyright IBM, Corp. 2009 + * + * Authors: + * Liran Schour + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef BLOCK_MIGRATION_H +#define BLOCK_MIGRATION_H + +void blk_mig_init(void); +int blk_mig_active(void); +uint64_t blk_mig_bytes_transferred(void); +uint64_t blk_mig_bytes_remaining(void); +uint64_t blk_mig_bytes_total(void); + +#endif /* BLOCK_MIGRATION_H */ diff --git a/include/migration/migration.h b/include/migration/migration.h new file mode 100644 index 0000000000..a95f761e4c --- /dev/null +++ b/include/migration/migration.h @@ -0,0 +1,131 @@ +/* + * QEMU live migration + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_MIGRATION_H +#define QEMU_MIGRATION_H + +#include "qapi/qmp/qdict.h" +#include "qemu-common.h" +#include "notify.h" +#include "qapi/error.h" +#include "migration/vmstate.h" +#include "qapi-types.h" + +struct MigrationParams { + bool blk; + bool shared; +}; + +typedef struct MigrationState MigrationState; + +struct MigrationState +{ + int64_t bandwidth_limit; + QEMUFile *file; + int fd; + int state; + int (*get_error)(MigrationState *s); + int (*close)(MigrationState *s); + int (*write)(MigrationState *s, const void *buff, size_t size); + void *opaque; + MigrationParams params; + int64_t total_time; + int64_t downtime; + int64_t expected_downtime; + int64_t dirty_pages_rate; + bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; + int64_t xbzrle_cache_size; +}; + +void process_incoming_migration(QEMUFile *f); + +void qemu_start_incoming_migration(const char *uri, Error **errp); + +uint64_t migrate_max_downtime(void); + +void do_info_migrate_print(Monitor *mon, const QObject *data); + +void do_info_migrate(Monitor *mon, QObject **ret_data); + +void exec_start_incoming_migration(const char *host_port, Error **errp); + +void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); + +void tcp_start_incoming_migration(const char *host_port, Error **errp); + +void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); + +void unix_start_incoming_migration(const char *path, Error **errp); + +void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp); + +void fd_start_incoming_migration(const char *path, Error **errp); + +void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); + +void migrate_fd_error(MigrationState *s); + +void migrate_fd_connect(MigrationState *s); + +ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, + size_t size); +void migrate_fd_put_ready(MigrationState *s); +int migrate_fd_wait_for_unfreeze(MigrationState *s); +int migrate_fd_close(MigrationState *s); + +void add_migration_state_change_notifier(Notifier *notify); +void remove_migration_state_change_notifier(Notifier *notify); +bool migration_is_active(MigrationState *); +bool migration_has_finished(MigrationState *); +bool migration_has_failed(MigrationState *); +MigrationState *migrate_get_current(void); + +uint64_t ram_bytes_remaining(void); +uint64_t ram_bytes_transferred(void); +uint64_t ram_bytes_total(void); + +extern SaveVMHandlers savevm_ram_handlers; + +uint64_t dup_mig_bytes_transferred(void); +uint64_t dup_mig_pages_transferred(void); +uint64_t norm_mig_bytes_transferred(void); +uint64_t norm_mig_pages_transferred(void); +uint64_t xbzrle_mig_bytes_transferred(void); +uint64_t xbzrle_mig_pages_transferred(void); +uint64_t xbzrle_mig_pages_overflow(void); +uint64_t xbzrle_mig_pages_cache_miss(void); + +/** + * @migrate_add_blocker - prevent migration from proceeding + * + * @reason - an error to be returned whenever migration is attempted + */ +void migrate_add_blocker(Error *reason); + +/** + * @migrate_del_blocker - remove a blocking error from migration + * + * @reason - the error blocking migration + */ +void migrate_del_blocker(Error *reason); + +int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, + uint8_t *dst, int dlen); +int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen); + +int migrate_use_xbzrle(void); +int64_t migrate_xbzrle_cache_size(void); + +int64_t xbzrle_cache_resize(int64_t new_size); + +#endif diff --git a/include/migration/page_cache.h b/include/migration/page_cache.h new file mode 100644 index 0000000000..3839ac7726 --- /dev/null +++ b/include/migration/page_cache.h @@ -0,0 +1,79 @@ +/* + * Page cache for QEMU + * The cache is base on a hash of the page address + * + * Copyright 2012 Red Hat, Inc. and/or its affiliates + * + * Authors: + * Orit Wasserman + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef PAGE_CACHE_H +#define PAGE_CACHE_H + +/* Page cache for storing guest pages */ +typedef struct PageCache PageCache; + +/** + * cache_init: Initialize the page cache + * + * + * Returns new allocated cache or NULL on error + * + * @cache pointer to the PageCache struct + * @num_pages: cache maximal number of cached pages + * @page_size: cache page size + */ +PageCache *cache_init(int64_t num_pages, unsigned int page_size); + +/** + * cache_fini: free all cache resources + * @cache pointer to the PageCache struct + */ +void cache_fini(PageCache *cache); + +/** + * cache_is_cached: Checks to see if the page is cached + * + * Returns %true if page is cached + * + * @cache pointer to the PageCache struct + * @addr: page addr + */ +bool cache_is_cached(const PageCache *cache, uint64_t addr); + +/** + * get_cached_data: Get the data cached for an addr + * + * Returns pointer to the data cached or NULL if not cached + * + * @cache pointer to the PageCache struct + * @addr: page addr + */ +uint8_t *get_cached_data(const PageCache *cache, uint64_t addr); + +/** + * cache_insert: insert the page into the cache. the previous value will be overwritten + * + * @cache pointer to the PageCache struct + * @addr: page address + * @pdata: pointer to the page + */ +void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata); + +/** + * cache_resize: resize the page cache. In case of size reduction the extra + * pages will be freed + * + * Returns -1 on error new cache size on success + * + * @cache pointer to the PageCache struct + * @num_pages: new page cache size (in pages) + */ +int64_t cache_resize(PageCache *cache, int64_t num_pages); + +#endif diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h new file mode 100644 index 0000000000..d64bdbb19b --- /dev/null +++ b/include/migration/qemu-file.h @@ -0,0 +1,241 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef QEMU_FILE_H +#define QEMU_FILE_H 1 + +/* This function writes a chunk of data to a file at the given position. + * The pos argument can be ignored if the file is only being used for + * streaming. The handler should try to write all of the data it can. + */ +typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, + int64_t pos, int size); + +/* Read a chunk of data from a file at the given position. The pos argument + * can be ignored if the file is only be used for streaming. The number of + * bytes actually read should be returned. + */ +typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, + int64_t pos, int size); + +/* Close a file + * + * Return negative error number on error, 0 or positive value on success. + * + * The meaning of return value on success depends on the specific back-end being + * used. + */ +typedef int (QEMUFileCloseFunc)(void *opaque); + +/* Called to return the OS file descriptor associated to the QEMUFile. + */ +typedef int (QEMUFileGetFD)(void *opaque); + +/* Called to determine if the file has exceeded its bandwidth allocation. The + * bandwidth capping is a soft limit, not a hard limit. + */ +typedef int (QEMUFileRateLimit)(void *opaque); + +/* Called to change the current bandwidth allocation. This function must return + * the new actual bandwidth. It should be new_rate if everything goes ok, and + * the old rate otherwise + */ +typedef int64_t (QEMUFileSetRateLimit)(void *opaque, int64_t new_rate); +typedef int64_t (QEMUFileGetRateLimit)(void *opaque); + +typedef struct QEMUFileOps { + QEMUFilePutBufferFunc *put_buffer; + QEMUFileGetBufferFunc *get_buffer; + QEMUFileCloseFunc *close; + QEMUFileGetFD *get_fd; + QEMUFileRateLimit *rate_limit; + QEMUFileSetRateLimit *set_rate_limit; + QEMUFileGetRateLimit *get_rate_limit; +} QEMUFileOps; + +QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); +QEMUFile *qemu_fopen(const char *filename, const char *mode); +QEMUFile *qemu_fdopen(int fd, const char *mode); +QEMUFile *qemu_fopen_socket(int fd); +QEMUFile *qemu_popen(FILE *popen_file, const char *mode); +QEMUFile *qemu_popen_cmd(const char *command, const char *mode); +int qemu_get_fd(QEMUFile *f); +int qemu_fclose(QEMUFile *f); +void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); +void qemu_put_byte(QEMUFile *f, int v); + +static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) +{ + qemu_put_byte(f, (int)v); +} + +#define qemu_put_sbyte qemu_put_byte + +void qemu_put_be16(QEMUFile *f, unsigned int v); +void qemu_put_be32(QEMUFile *f, unsigned int v); +void qemu_put_be64(QEMUFile *f, uint64_t v); +int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); +int qemu_get_byte(QEMUFile *f); + +static inline unsigned int qemu_get_ubyte(QEMUFile *f) +{ + return (unsigned int)qemu_get_byte(f); +} + +#define qemu_get_sbyte qemu_get_byte + +unsigned int qemu_get_be16(QEMUFile *f); +unsigned int qemu_get_be32(QEMUFile *f); +uint64_t qemu_get_be64(QEMUFile *f); + +int qemu_file_rate_limit(QEMUFile *f); +int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); +int64_t qemu_file_get_rate_limit(QEMUFile *f); +int qemu_file_get_error(QEMUFile *f); + +/* Try to send any outstanding data. This function is useful when output is + * halted due to rate limiting or EAGAIN errors occur as it can be used to + * resume output. */ +int qemu_file_put_notify(QEMUFile *f); + +static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) +{ + qemu_put_be64(f, *pv); +} + +static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) +{ + qemu_put_be32(f, *pv); +} + +static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) +{ + qemu_put_be16(f, *pv); +} + +static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) +{ + qemu_put_byte(f, *pv); +} + +static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) +{ + *pv = qemu_get_be64(f); +} + +static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) +{ + *pv = qemu_get_be32(f); +} + +static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) +{ + *pv = qemu_get_be16(f); +} + +static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) +{ + *pv = qemu_get_byte(f); +} + +// Signed versions for type safety +static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) +{ + qemu_put_buffer(f, (const uint8_t *)buf, size); +} + +static inline void qemu_put_sbe16(QEMUFile *f, int v) +{ + qemu_put_be16(f, (unsigned int)v); +} + +static inline void qemu_put_sbe32(QEMUFile *f, int v) +{ + qemu_put_be32(f, (unsigned int)v); +} + +static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) +{ + qemu_put_be64(f, (uint64_t)v); +} + +static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) +{ + return qemu_get_buffer(f, (uint8_t *)buf, size); +} + +static inline int qemu_get_sbe16(QEMUFile *f) +{ + return (int)qemu_get_be16(f); +} + +static inline int qemu_get_sbe32(QEMUFile *f) +{ + return (int)qemu_get_be32(f); +} + +static inline int64_t qemu_get_sbe64(QEMUFile *f) +{ + return (int64_t)qemu_get_be64(f); +} + +static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) +{ + qemu_put_8s(f, (const uint8_t *)pv); +} + +static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) +{ + qemu_put_be16s(f, (const uint16_t *)pv); +} + +static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) +{ + qemu_put_be32s(f, (const uint32_t *)pv); +} + +static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) +{ + qemu_put_be64s(f, (const uint64_t *)pv); +} + +static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) +{ + qemu_get_8s(f, (uint8_t *)pv); +} + +static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) +{ + qemu_get_be16s(f, (uint16_t *)pv); +} + +static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) +{ + qemu_get_be32s(f, (uint32_t *)pv); +} + +static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) +{ + qemu_get_be64s(f, (uint64_t *)pv); +} +#endif diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h new file mode 100644 index 0000000000..623af0a29a --- /dev/null +++ b/include/migration/vmstate.h @@ -0,0 +1,639 @@ +/* + * QEMU migration/snapshot declarations + * + * Copyright (c) 2009-2011 Red Hat, Inc. + * + * Original author: Juan Quintela + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef QEMU_VMSTATE_H +#define QEMU_VMSTATE_H 1 + +typedef void SaveStateHandler(QEMUFile *f, void *opaque); +typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); + +typedef struct SaveVMHandlers { + void (*set_params)(const MigrationParams *params, void * opaque); + SaveStateHandler *save_state; + int (*save_live_setup)(QEMUFile *f, void *opaque); + int (*save_live_iterate)(QEMUFile *f, void *opaque); + int (*save_live_complete)(QEMUFile *f, void *opaque); + void (*cancel)(void *opaque); + LoadStateHandler *load_state; + bool (*is_active)(void *opaque); +} SaveVMHandlers; + +int register_savevm(DeviceState *dev, + const char *idstr, + int instance_id, + int version_id, + SaveStateHandler *save_state, + LoadStateHandler *load_state, + void *opaque); + +int register_savevm_live(DeviceState *dev, + const char *idstr, + int instance_id, + int version_id, + SaveVMHandlers *ops, + void *opaque); + +void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); +void register_device_unmigratable(DeviceState *dev, const char *idstr, + void *opaque); + + +typedef struct VMStateInfo VMStateInfo; +typedef struct VMStateDescription VMStateDescription; + +struct VMStateInfo { + const char *name; + int (*get)(QEMUFile *f, void *pv, size_t size); + void (*put)(QEMUFile *f, void *pv, size_t size); +}; + +enum VMStateFlags { + VMS_SINGLE = 0x001, + VMS_POINTER = 0x002, + VMS_ARRAY = 0x004, + VMS_STRUCT = 0x008, + VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ + VMS_BUFFER = 0x020, /* static sized buffer */ + VMS_ARRAY_OF_POINTER = 0x040, + VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ + VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ + VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ + VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ + VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ +}; + +typedef struct { + const char *name; + size_t offset; + size_t size; + size_t start; + int num; + size_t num_offset; + size_t size_offset; + const VMStateInfo *info; + enum VMStateFlags flags; + const VMStateDescription *vmsd; + int version_id; + bool (*field_exists)(void *opaque, int version_id); +} VMStateField; + +typedef struct VMStateSubsection { + const VMStateDescription *vmsd; + bool (*needed)(void *opaque); +} VMStateSubsection; + +struct VMStateDescription { + const char *name; + int unmigratable; + int version_id; + int minimum_version_id; + int minimum_version_id_old; + LoadStateHandler *load_state_old; + int (*pre_load)(void *opaque); + int (*post_load)(void *opaque, int version_id); + void (*pre_save)(void *opaque); + VMStateField *fields; + const VMStateSubsection *subsections; +}; + +extern const VMStateInfo vmstate_info_bool; + +extern const VMStateInfo vmstate_info_int8; +extern const VMStateInfo vmstate_info_int16; +extern const VMStateInfo vmstate_info_int32; +extern const VMStateInfo vmstate_info_int64; + +extern const VMStateInfo vmstate_info_uint8_equal; +extern const VMStateInfo vmstate_info_uint16_equal; +extern const VMStateInfo vmstate_info_int32_equal; +extern const VMStateInfo vmstate_info_uint32_equal; +extern const VMStateInfo vmstate_info_int32_le; + +extern const VMStateInfo vmstate_info_uint8; +extern const VMStateInfo vmstate_info_uint16; +extern const VMStateInfo vmstate_info_uint32; +extern const VMStateInfo vmstate_info_uint64; + +extern const VMStateInfo vmstate_info_timer; +extern const VMStateInfo vmstate_info_buffer; +extern const VMStateInfo vmstate_info_unused_buffer; +extern const VMStateInfo vmstate_info_bitmap; + +#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) +#define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) + +#define vmstate_offset_value(_state, _field, _type) \ + (offsetof(_state, _field) + \ + type_check(_type, typeof_field(_state, _field))) + +#define vmstate_offset_pointer(_state, _field, _type) \ + (offsetof(_state, _field) + \ + type_check_pointer(_type, typeof_field(_state, _field))) + +#define vmstate_offset_array(_state, _field, _type, _num) \ + (offsetof(_state, _field) + \ + type_check_array(_type, typeof_field(_state, _field), _num)) + +#define vmstate_offset_sub_array(_state, _field, _type, _start) \ + (offsetof(_state, _field[_start])) + +#define vmstate_offset_buffer(_state, _field) \ + vmstate_offset_array(_state, _field, uint8_t, \ + sizeof(typeof_field(_state, _field))) + +#define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size = sizeof(_type), \ + .info = &(_info), \ + .flags = VMS_SINGLE, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} + +#define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_SINGLE|VMS_POINTER, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} + +#define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \ + .name = (stringify(_field)), \ + .info = &(_info), \ + .field_exists = (_test), \ + .size = sizeof(_type), \ + .flags = VMS_SINGLE|VMS_POINTER, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} + +#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY, \ + .offset = vmstate_offset_array(_state, _field, _type, _num), \ +} + +#define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ + .name = (stringify(_field)), \ + .field_exists = (_test), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY, \ + .offset = vmstate_offset_array(_state, _field, _type, _num),\ +} + +#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY, \ + .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ +} + +#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\ + .name = (stringify(_field)), \ + .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_INT32, \ + .offset = offsetof(_state, _field), \ +} + +#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_INT32|VMS_POINTER, \ + .offset = vmstate_offset_pointer(_state, _field, _type), \ +} + +#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_UINT32|VMS_POINTER, \ + .offset = vmstate_offset_pointer(_state, _field, _type), \ +} + +#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_VARRAY_UINT16, \ + .offset = offsetof(_state, _field), \ +} + +#define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} + +#define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .field_exists = (_test), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_POINTER, \ + .offset = vmstate_offset_value(_state, _field, _type), \ +} + +#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ + .offset = vmstate_offset_array(_state, _field, _type, _num), \ +} + +#define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .num = (_num), \ + .field_exists = (_test), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_ARRAY, \ + .offset = vmstate_offset_array(_state, _field, _type, _num),\ +} + +#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \ + .offset = offsetof(_state, _field), \ +} + +#define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .version_id = 0, \ + .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ + .size = sizeof(_type), \ + .vmsd = &(_vmsd), \ + .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ + .offset = vmstate_offset_pointer(_state, _field, _type), \ +} + +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .version_id = 0, \ + .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ + .size = sizeof(_type), \ + .vmsd = &(_vmsd), \ + .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ + .offset = vmstate_offset_pointer(_state, _field, _type), \ +} + +#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_VARRAY_INT32, \ + .offset = offsetof(_state, _field), \ +} + +#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \ + .offset = offsetof(_state, _field), \ +} + +#define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size = (_size - _start), \ + .info = &vmstate_info_buffer, \ + .flags = VMS_BUFFER, \ + .offset = vmstate_offset_buffer(_state, _field) + _start, \ +} + +#define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ + .size = (_multiply), \ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_MULTIPLY, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} + +#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_POINTER, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} + +#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .field_exists = (_test), \ + .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ + .info = &vmstate_info_buffer, \ + .flags = VMS_VBUFFER|VMS_POINTER, \ + .offset = offsetof(_state, _field), \ + .start = (_start), \ +} + +#define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .size = (_size), \ + .info = &(_info), \ + .flags = VMS_BUFFER, \ + .offset = offsetof(_state, _field), \ +} + +#define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \ + .name = "unused", \ + .field_exists = (_test), \ + .version_id = (_version), \ + .size = (_size), \ + .info = &vmstate_info_unused_buffer, \ + .flags = VMS_BUFFER, \ +} + +/* _field_size should be a int32_t field in the _state struct giving the + * size of the bitmap _field in bits. + */ +#define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ + .info = &vmstate_info_bitmap, \ + .flags = VMS_VBUFFER|VMS_POINTER, \ + .offset = offsetof(_state, _field), \ +} + +/* _f : field name + _f_n : num of elements field_name + _n : num of elements + _s : struct state name + _v : version +*/ + +#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \ + VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type) + +#define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \ + VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type) + +#define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \ + VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) + +#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \ + VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \ + _vmsd, _type) + +#define VMSTATE_BOOL_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool) + +#define VMSTATE_INT8_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) +#define VMSTATE_INT16_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t) +#define VMSTATE_INT32_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t) +#define VMSTATE_INT64_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t) + +#define VMSTATE_UINT8_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t) +#define VMSTATE_UINT16_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t) +#define VMSTATE_UINT32_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t) +#define VMSTATE_UINT64_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) + +#define VMSTATE_BOOL(_f, _s) \ + VMSTATE_BOOL_V(_f, _s, 0) + +#define VMSTATE_INT8(_f, _s) \ + VMSTATE_INT8_V(_f, _s, 0) +#define VMSTATE_INT16(_f, _s) \ + VMSTATE_INT16_V(_f, _s, 0) +#define VMSTATE_INT32(_f, _s) \ + VMSTATE_INT32_V(_f, _s, 0) +#define VMSTATE_INT64(_f, _s) \ + VMSTATE_INT64_V(_f, _s, 0) + +#define VMSTATE_UINT8(_f, _s) \ + VMSTATE_UINT8_V(_f, _s, 0) +#define VMSTATE_UINT16(_f, _s) \ + VMSTATE_UINT16_V(_f, _s, 0) +#define VMSTATE_UINT32(_f, _s) \ + VMSTATE_UINT32_V(_f, _s, 0) +#define VMSTATE_UINT64(_f, _s) \ + VMSTATE_UINT64_V(_f, _s, 0) + +#define VMSTATE_UINT8_EQUAL(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) + +#define VMSTATE_UINT16_EQUAL(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t) + +#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) + +#define VMSTATE_INT32_EQUAL(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) + +#define VMSTATE_UINT32_EQUAL(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t) + +#define VMSTATE_INT32_LE(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) + +#define VMSTATE_UINT8_TEST(_f, _s, _t) \ + VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t) + +#define VMSTATE_UINT16_TEST(_f, _s, _t) \ + VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t) + +#define VMSTATE_UINT32_TEST(_f, _s, _t) \ + VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t) + +#define VMSTATE_TIMER_TEST(_f, _s, _test) \ + VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *) + +#define VMSTATE_TIMER_V(_f, _s, _v) \ + VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) + +#define VMSTATE_TIMER(_f, _s) \ + VMSTATE_TIMER_V(_f, _s, 0) + +#define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ + VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) + +#define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool) + +#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ + VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) + +#define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ + VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) + +#define VMSTATE_UINT8_ARRAY(_f, _s, _n) \ + VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) + +#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ + VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t) + +#define VMSTATE_UINT64_ARRAY(_f, _s, _n) \ + VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) + +#define VMSTATE_INT16_ARRAY(_f, _s, _n) \ + VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) + +#define VMSTATE_INT32_ARRAY(_f, _s, _n) \ + VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ + VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) + +#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ + VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t) + +#define VMSTATE_INT64_ARRAY(_f, _s, _n) \ + VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0) + +#define VMSTATE_BUFFER_V(_f, _s, _v) \ + VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f))) + +#define VMSTATE_BUFFER(_f, _s) \ + VMSTATE_BUFFER_V(_f, _s, 0) + +#define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \ + VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size) + +#define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \ + VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f))) + +#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \ + VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size) + +#define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \ + VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size) + +#define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \ + VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size) + +#define VMSTATE_BUFFER_TEST(_f, _s, _test) \ + VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f))) + +#define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \ + VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size) + +#define VMSTATE_UNUSED_V(_v, _size) \ + VMSTATE_UNUSED_BUFFER(NULL, _v, _size) + +#define VMSTATE_UNUSED(_size) \ + VMSTATE_UNUSED_V(0, _size) + +#define VMSTATE_UNUSED_TEST(_test, _size) \ + VMSTATE_UNUSED_BUFFER(_test, 0, _size) + +#define VMSTATE_END_OF_LIST() \ + {} + +int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque, int version_id); +void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, + void *opaque); +int vmstate_register(DeviceState *dev, int instance_id, + const VMStateDescription *vmsd, void *base); +int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, + const VMStateDescription *vmsd, + void *base, int alias_id, + int required_for_version); +void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd, + void *opaque); + +struct MemoryRegion; +void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev); +void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); +void vmstate_register_ram_global(struct MemoryRegion *memory); + +#endif diff --git a/include/net/net.h b/include/net/net.h index 26dd0cf29c..41d3729867 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -6,7 +6,7 @@ #include "qapi/qmp/qdict.h" #include "qemu-option.h" #include "net/queue.h" -#include "vmstate.h" +#include "migration/vmstate.h" #include "qapi-types.h" struct MACAddr { diff --git a/include/qemu/page_cache.h b/include/qemu/page_cache.h deleted file mode 100644 index 3839ac7726..0000000000 --- a/include/qemu/page_cache.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Page cache for QEMU - * The cache is base on a hash of the page address - * - * Copyright 2012 Red Hat, Inc. and/or its affiliates - * - * Authors: - * Orit Wasserman - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef PAGE_CACHE_H -#define PAGE_CACHE_H - -/* Page cache for storing guest pages */ -typedef struct PageCache PageCache; - -/** - * cache_init: Initialize the page cache - * - * - * Returns new allocated cache or NULL on error - * - * @cache pointer to the PageCache struct - * @num_pages: cache maximal number of cached pages - * @page_size: cache page size - */ -PageCache *cache_init(int64_t num_pages, unsigned int page_size); - -/** - * cache_fini: free all cache resources - * @cache pointer to the PageCache struct - */ -void cache_fini(PageCache *cache); - -/** - * cache_is_cached: Checks to see if the page is cached - * - * Returns %true if page is cached - * - * @cache pointer to the PageCache struct - * @addr: page addr - */ -bool cache_is_cached(const PageCache *cache, uint64_t addr); - -/** - * get_cached_data: Get the data cached for an addr - * - * Returns pointer to the data cached or NULL if not cached - * - * @cache pointer to the PageCache struct - * @addr: page addr - */ -uint8_t *get_cached_data(const PageCache *cache, uint64_t addr); - -/** - * cache_insert: insert the page into the cache. the previous value will be overwritten - * - * @cache pointer to the PageCache struct - * @addr: page address - * @pdata: pointer to the page - */ -void cache_insert(PageCache *cache, uint64_t addr, uint8_t *pdata); - -/** - * cache_resize: resize the page cache. In case of size reduction the extra - * pages will be freed - * - * Returns -1 on error new cache size on success - * - * @cache pointer to the PageCache struct - * @num_pages: new page cache size (in pages) - */ -int64_t cache_resize(PageCache *cache, int64_t num_pages); - -#endif diff --git a/migration-exec.c b/migration-exec.c index 3e55b7792d..784486d2fc 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -17,7 +17,7 @@ #include "qemu-common.h" #include "qemu_socket.h" -#include "migration.h" +#include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" #include diff --git a/migration-fd.c b/migration-fd.c index 73a1dfcc93..ab5abe2aa5 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "qemu_socket.h" -#include "migration.h" +#include "migration/migration.h" #include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-tcp.c b/migration-tcp.c index 07f51f2aef..a36e637ffd 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "qemu_socket.h" -#include "migration.h" +#include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-unix.c b/migration-unix.c index 1b9c461083..9debc952da 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "qemu_socket.h" -#include "migration.h" +#include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration.c b/migration.c index 27a272eace..0456983bad 100644 --- a/migration.c +++ b/migration.c @@ -14,13 +14,13 @@ */ #include "qemu-common.h" -#include "migration.h" +#include "migration/migration.h" #include "monitor/monitor.h" #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" #include "qemu_socket.h" -#include "block-migration.h" +#include "migration/block.h" #include "qmp-commands.h" //#define DEBUG_MIGRATION diff --git a/migration.h b/migration.h deleted file mode 100644 index af444d444b..0000000000 --- a/migration.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * QEMU live migration - * - * Copyright IBM, Corp. 2008 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_MIGRATION_H -#define QEMU_MIGRATION_H - -#include "qapi/qmp/qdict.h" -#include "qemu-common.h" -#include "notify.h" -#include "qapi/error.h" -#include "vmstate.h" -#include "qapi-types.h" - -struct MigrationParams { - bool blk; - bool shared; -}; - -typedef struct MigrationState MigrationState; - -struct MigrationState -{ - int64_t bandwidth_limit; - QEMUFile *file; - int fd; - int state; - int (*get_error)(MigrationState *s); - int (*close)(MigrationState *s); - int (*write)(MigrationState *s, const void *buff, size_t size); - void *opaque; - MigrationParams params; - int64_t total_time; - int64_t downtime; - int64_t expected_downtime; - int64_t dirty_pages_rate; - bool enabled_capabilities[MIGRATION_CAPABILITY_MAX]; - int64_t xbzrle_cache_size; -}; - -void process_incoming_migration(QEMUFile *f); - -void qemu_start_incoming_migration(const char *uri, Error **errp); - -uint64_t migrate_max_downtime(void); - -void do_info_migrate_print(Monitor *mon, const QObject *data); - -void do_info_migrate(Monitor *mon, QObject **ret_data); - -void exec_start_incoming_migration(const char *host_port, Error **errp); - -void exec_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); - -void tcp_start_incoming_migration(const char *host_port, Error **errp); - -void tcp_start_outgoing_migration(MigrationState *s, const char *host_port, Error **errp); - -void unix_start_incoming_migration(const char *path, Error **errp); - -void unix_start_outgoing_migration(MigrationState *s, const char *path, Error **errp); - -void fd_start_incoming_migration(const char *path, Error **errp); - -void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); - -void migrate_fd_error(MigrationState *s); - -void migrate_fd_connect(MigrationState *s); - -ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, - size_t size); -void migrate_fd_put_ready(MigrationState *s); -int migrate_fd_wait_for_unfreeze(MigrationState *s); -int migrate_fd_close(MigrationState *s); - -void add_migration_state_change_notifier(Notifier *notify); -void remove_migration_state_change_notifier(Notifier *notify); -bool migration_is_active(MigrationState *); -bool migration_has_finished(MigrationState *); -bool migration_has_failed(MigrationState *); -MigrationState *migrate_get_current(void); - -uint64_t ram_bytes_remaining(void); -uint64_t ram_bytes_transferred(void); -uint64_t ram_bytes_total(void); - -extern SaveVMHandlers savevm_ram_handlers; - -uint64_t dup_mig_bytes_transferred(void); -uint64_t dup_mig_pages_transferred(void); -uint64_t norm_mig_bytes_transferred(void); -uint64_t norm_mig_pages_transferred(void); -uint64_t xbzrle_mig_bytes_transferred(void); -uint64_t xbzrle_mig_pages_transferred(void); -uint64_t xbzrle_mig_pages_overflow(void); -uint64_t xbzrle_mig_pages_cache_miss(void); - -/** - * @migrate_add_blocker - prevent migration from proceeding - * - * @reason - an error to be returned whenever migration is attempted - */ -void migrate_add_blocker(Error *reason); - -/** - * @migrate_del_blocker - remove a blocking error from migration - * - * @reason - the error blocking migration - */ -void migrate_del_blocker(Error *reason); - -int xbzrle_encode_buffer(uint8_t *old_buf, uint8_t *new_buf, int slen, - uint8_t *dst, int dlen); -int xbzrle_decode_buffer(uint8_t *src, int slen, uint8_t *dst, int dlen); - -int migrate_use_xbzrle(void); -int64_t migrate_xbzrle_cache_size(void); - -int64_t xbzrle_cache_resize(int64_t new_size); - -#endif diff --git a/monitor.c b/monitor.c index 94c6bb6672..46fdc008f4 100644 --- a/monitor.c +++ b/monitor.c @@ -44,7 +44,7 @@ #include "disas/disas.h" #include "balloon.h" #include "qemu-timer.h" -#include "migration.h" +#include "migration/migration.h" #include "kvm.h" #include "acl.h" #include "qapi/qmp/qint.h" diff --git a/page_cache.c b/page_cache.c index 0294f7e9f6..ba5640bd73 100644 --- a/page_cache.c +++ b/page_cache.c @@ -24,7 +24,7 @@ #include #include "qemu-common.h" -#include "qemu/page_cache.h" +#include "migration/page_cache.h" #ifdef DEBUG_CACHE #define DPRINTF(fmt, ...) \ diff --git a/qemu-file.h b/qemu-file.h deleted file mode 100644 index d64bdbb19b..0000000000 --- a/qemu-file.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef QEMU_FILE_H -#define QEMU_FILE_H 1 - -/* This function writes a chunk of data to a file at the given position. - * The pos argument can be ignored if the file is only being used for - * streaming. The handler should try to write all of the data it can. - */ -typedef int (QEMUFilePutBufferFunc)(void *opaque, const uint8_t *buf, - int64_t pos, int size); - -/* Read a chunk of data from a file at the given position. The pos argument - * can be ignored if the file is only be used for streaming. The number of - * bytes actually read should be returned. - */ -typedef int (QEMUFileGetBufferFunc)(void *opaque, uint8_t *buf, - int64_t pos, int size); - -/* Close a file - * - * Return negative error number on error, 0 or positive value on success. - * - * The meaning of return value on success depends on the specific back-end being - * used. - */ -typedef int (QEMUFileCloseFunc)(void *opaque); - -/* Called to return the OS file descriptor associated to the QEMUFile. - */ -typedef int (QEMUFileGetFD)(void *opaque); - -/* Called to determine if the file has exceeded its bandwidth allocation. The - * bandwidth capping is a soft limit, not a hard limit. - */ -typedef int (QEMUFileRateLimit)(void *opaque); - -/* Called to change the current bandwidth allocation. This function must return - * the new actual bandwidth. It should be new_rate if everything goes ok, and - * the old rate otherwise - */ -typedef int64_t (QEMUFileSetRateLimit)(void *opaque, int64_t new_rate); -typedef int64_t (QEMUFileGetRateLimit)(void *opaque); - -typedef struct QEMUFileOps { - QEMUFilePutBufferFunc *put_buffer; - QEMUFileGetBufferFunc *get_buffer; - QEMUFileCloseFunc *close; - QEMUFileGetFD *get_fd; - QEMUFileRateLimit *rate_limit; - QEMUFileSetRateLimit *set_rate_limit; - QEMUFileGetRateLimit *get_rate_limit; -} QEMUFileOps; - -QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); -QEMUFile *qemu_fopen(const char *filename, const char *mode); -QEMUFile *qemu_fdopen(int fd, const char *mode); -QEMUFile *qemu_fopen_socket(int fd); -QEMUFile *qemu_popen(FILE *popen_file, const char *mode); -QEMUFile *qemu_popen_cmd(const char *command, const char *mode); -int qemu_get_fd(QEMUFile *f); -int qemu_fclose(QEMUFile *f); -void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); -void qemu_put_byte(QEMUFile *f, int v); - -static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v) -{ - qemu_put_byte(f, (int)v); -} - -#define qemu_put_sbyte qemu_put_byte - -void qemu_put_be16(QEMUFile *f, unsigned int v); -void qemu_put_be32(QEMUFile *f, unsigned int v); -void qemu_put_be64(QEMUFile *f, uint64_t v); -int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); -int qemu_get_byte(QEMUFile *f); - -static inline unsigned int qemu_get_ubyte(QEMUFile *f) -{ - return (unsigned int)qemu_get_byte(f); -} - -#define qemu_get_sbyte qemu_get_byte - -unsigned int qemu_get_be16(QEMUFile *f); -unsigned int qemu_get_be32(QEMUFile *f); -uint64_t qemu_get_be64(QEMUFile *f); - -int qemu_file_rate_limit(QEMUFile *f); -int64_t qemu_file_set_rate_limit(QEMUFile *f, int64_t new_rate); -int64_t qemu_file_get_rate_limit(QEMUFile *f); -int qemu_file_get_error(QEMUFile *f); - -/* Try to send any outstanding data. This function is useful when output is - * halted due to rate limiting or EAGAIN errors occur as it can be used to - * resume output. */ -int qemu_file_put_notify(QEMUFile *f); - -static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) -{ - qemu_put_be64(f, *pv); -} - -static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) -{ - qemu_put_be32(f, *pv); -} - -static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) -{ - qemu_put_be16(f, *pv); -} - -static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) -{ - qemu_put_byte(f, *pv); -} - -static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) -{ - *pv = qemu_get_be64(f); -} - -static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) -{ - *pv = qemu_get_be32(f); -} - -static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) -{ - *pv = qemu_get_be16(f); -} - -static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) -{ - *pv = qemu_get_byte(f); -} - -// Signed versions for type safety -static inline void qemu_put_sbuffer(QEMUFile *f, const int8_t *buf, int size) -{ - qemu_put_buffer(f, (const uint8_t *)buf, size); -} - -static inline void qemu_put_sbe16(QEMUFile *f, int v) -{ - qemu_put_be16(f, (unsigned int)v); -} - -static inline void qemu_put_sbe32(QEMUFile *f, int v) -{ - qemu_put_be32(f, (unsigned int)v); -} - -static inline void qemu_put_sbe64(QEMUFile *f, int64_t v) -{ - qemu_put_be64(f, (uint64_t)v); -} - -static inline size_t qemu_get_sbuffer(QEMUFile *f, int8_t *buf, int size) -{ - return qemu_get_buffer(f, (uint8_t *)buf, size); -} - -static inline int qemu_get_sbe16(QEMUFile *f) -{ - return (int)qemu_get_be16(f); -} - -static inline int qemu_get_sbe32(QEMUFile *f) -{ - return (int)qemu_get_be32(f); -} - -static inline int64_t qemu_get_sbe64(QEMUFile *f) -{ - return (int64_t)qemu_get_be64(f); -} - -static inline void qemu_put_s8s(QEMUFile *f, const int8_t *pv) -{ - qemu_put_8s(f, (const uint8_t *)pv); -} - -static inline void qemu_put_sbe16s(QEMUFile *f, const int16_t *pv) -{ - qemu_put_be16s(f, (const uint16_t *)pv); -} - -static inline void qemu_put_sbe32s(QEMUFile *f, const int32_t *pv) -{ - qemu_put_be32s(f, (const uint32_t *)pv); -} - -static inline void qemu_put_sbe64s(QEMUFile *f, const int64_t *pv) -{ - qemu_put_be64s(f, (const uint64_t *)pv); -} - -static inline void qemu_get_s8s(QEMUFile *f, int8_t *pv) -{ - qemu_get_8s(f, (uint8_t *)pv); -} - -static inline void qemu_get_sbe16s(QEMUFile *f, int16_t *pv) -{ - qemu_get_be16s(f, (uint16_t *)pv); -} - -static inline void qemu_get_sbe32s(QEMUFile *f, int32_t *pv) -{ - qemu_get_be32s(f, (uint32_t *)pv); -} - -static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) -{ - qemu_get_be64s(f, (uint64_t *)pv); -} -#endif diff --git a/qemu-tool.c b/qemu-tool.c index 40453fdd99..d1f46222ee 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -17,7 +17,7 @@ #include "monitor/monitor.h" #include "qemu-timer.h" #include "qemu-log.h" -#include "migration.h" +#include "migration/migration.h" #include "main-loop.h" #include "sysemu.h" #include "qemu_socket.h" diff --git a/savevm.c b/savevm.c index bf341bb25f..a5205a09c3 100644 --- a/savevm.c +++ b/savevm.c @@ -77,7 +77,7 @@ #include "sysemu.h" #include "qemu-timer.h" #include "audio/audio.h" -#include "migration.h" +#include "migration/migration.h" #include "qemu_socket.h" #include "qemu-queue.h" #include "qemu-timer.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index 379677554e..962475de6b 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -34,7 +34,7 @@ #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" #include "notify.h" -#include "migration.h" +#include "migration/migration.h" #include "monitor/monitor.h" #include "hw/hw.h" #include "ui/spice-display.h" diff --git a/vl.c b/vl.c index 9adaf28e64..2debde0a4a 100644 --- a/vl.c +++ b/vl.c @@ -138,10 +138,10 @@ int main(int argc, char **argv) #include "cache-utils.h" #include "blockdev.h" #include "hw/block-common.h" -#include "block-migration.h" +#include "migration/block.h" #include "dma.h" #include "audio/audio.h" -#include "migration.h" +#include "migration/migration.h" #include "kvm.h" #include "qapi/qmp/qjson.h" #include "qemu-option.h" diff --git a/vmstate.h b/vmstate.h deleted file mode 100644 index 623af0a29a..0000000000 --- a/vmstate.h +++ /dev/null @@ -1,639 +0,0 @@ -/* - * QEMU migration/snapshot declarations - * - * Copyright (c) 2009-2011 Red Hat, Inc. - * - * Original author: Juan Quintela - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef QEMU_VMSTATE_H -#define QEMU_VMSTATE_H 1 - -typedef void SaveStateHandler(QEMUFile *f, void *opaque); -typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); - -typedef struct SaveVMHandlers { - void (*set_params)(const MigrationParams *params, void * opaque); - SaveStateHandler *save_state; - int (*save_live_setup)(QEMUFile *f, void *opaque); - int (*save_live_iterate)(QEMUFile *f, void *opaque); - int (*save_live_complete)(QEMUFile *f, void *opaque); - void (*cancel)(void *opaque); - LoadStateHandler *load_state; - bool (*is_active)(void *opaque); -} SaveVMHandlers; - -int register_savevm(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveStateHandler *save_state, - LoadStateHandler *load_state, - void *opaque); - -int register_savevm_live(DeviceState *dev, - const char *idstr, - int instance_id, - int version_id, - SaveVMHandlers *ops, - void *opaque); - -void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque); -void register_device_unmigratable(DeviceState *dev, const char *idstr, - void *opaque); - - -typedef struct VMStateInfo VMStateInfo; -typedef struct VMStateDescription VMStateDescription; - -struct VMStateInfo { - const char *name; - int (*get)(QEMUFile *f, void *pv, size_t size); - void (*put)(QEMUFile *f, void *pv, size_t size); -}; - -enum VMStateFlags { - VMS_SINGLE = 0x001, - VMS_POINTER = 0x002, - VMS_ARRAY = 0x004, - VMS_STRUCT = 0x008, - VMS_VARRAY_INT32 = 0x010, /* Array with size in int32_t field*/ - VMS_BUFFER = 0x020, /* static sized buffer */ - VMS_ARRAY_OF_POINTER = 0x040, - VMS_VARRAY_UINT16 = 0x080, /* Array with size in uint16_t field */ - VMS_VBUFFER = 0x100, /* Buffer with size in int32_t field */ - VMS_MULTIPLY = 0x200, /* multiply "size" field by field_size */ - VMS_VARRAY_UINT8 = 0x400, /* Array with size in uint8_t field*/ - VMS_VARRAY_UINT32 = 0x800, /* Array with size in uint32_t field*/ -}; - -typedef struct { - const char *name; - size_t offset; - size_t size; - size_t start; - int num; - size_t num_offset; - size_t size_offset; - const VMStateInfo *info; - enum VMStateFlags flags; - const VMStateDescription *vmsd; - int version_id; - bool (*field_exists)(void *opaque, int version_id); -} VMStateField; - -typedef struct VMStateSubsection { - const VMStateDescription *vmsd; - bool (*needed)(void *opaque); -} VMStateSubsection; - -struct VMStateDescription { - const char *name; - int unmigratable; - int version_id; - int minimum_version_id; - int minimum_version_id_old; - LoadStateHandler *load_state_old; - int (*pre_load)(void *opaque); - int (*post_load)(void *opaque, int version_id); - void (*pre_save)(void *opaque); - VMStateField *fields; - const VMStateSubsection *subsections; -}; - -extern const VMStateInfo vmstate_info_bool; - -extern const VMStateInfo vmstate_info_int8; -extern const VMStateInfo vmstate_info_int16; -extern const VMStateInfo vmstate_info_int32; -extern const VMStateInfo vmstate_info_int64; - -extern const VMStateInfo vmstate_info_uint8_equal; -extern const VMStateInfo vmstate_info_uint16_equal; -extern const VMStateInfo vmstate_info_int32_equal; -extern const VMStateInfo vmstate_info_uint32_equal; -extern const VMStateInfo vmstate_info_int32_le; - -extern const VMStateInfo vmstate_info_uint8; -extern const VMStateInfo vmstate_info_uint16; -extern const VMStateInfo vmstate_info_uint32; -extern const VMStateInfo vmstate_info_uint64; - -extern const VMStateInfo vmstate_info_timer; -extern const VMStateInfo vmstate_info_buffer; -extern const VMStateInfo vmstate_info_unused_buffer; -extern const VMStateInfo vmstate_info_bitmap; - -#define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0) -#define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0) - -#define vmstate_offset_value(_state, _field, _type) \ - (offsetof(_state, _field) + \ - type_check(_type, typeof_field(_state, _field))) - -#define vmstate_offset_pointer(_state, _field, _type) \ - (offsetof(_state, _field) + \ - type_check_pointer(_type, typeof_field(_state, _field))) - -#define vmstate_offset_array(_state, _field, _type, _num) \ - (offsetof(_state, _field) + \ - type_check_array(_type, typeof_field(_state, _field), _num)) - -#define vmstate_offset_sub_array(_state, _field, _type, _start) \ - (offsetof(_state, _field[_start])) - -#define vmstate_offset_buffer(_state, _field) \ - vmstate_offset_array(_state, _field, uint8_t, \ - sizeof(typeof_field(_state, _field))) - -#define VMSTATE_SINGLE_TEST(_field, _state, _test, _version, _info, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size = sizeof(_type), \ - .info = &(_info), \ - .flags = VMS_SINGLE, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_SINGLE|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_POINTER_TEST(_field, _state, _test, _info, _type) { \ - .name = (stringify(_field)), \ - .info = &(_info), \ - .field_exists = (_test), \ - .size = sizeof(_type), \ - .flags = VMS_SINGLE|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_ARRAY(_field, _state, _num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num), \ -} - -#define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ - .name = (stringify(_field)), \ - .field_exists = (_test), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num),\ -} - -#define VMSTATE_SUB_ARRAY(_field, _state, _start, _num, _version, _info, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY, \ - .offset = vmstate_offset_sub_array(_state, _field, _type, _start), \ -} - -#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _type) {\ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_INT32, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_INT32|VMS_POINTER, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_UINT32|VMS_POINTER, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_VARRAY_UINT16, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STRUCT_TEST(_field, _state, _test, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_POINTER_TEST(_field, _state, _test, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .field_exists = (_test), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_POINTER, \ - .offset = vmstate_offset_value(_state, _field, _type), \ -} - -#define VMSTATE_ARRAY_OF_POINTER(_field, _state, _num, _version, _info, _type) {\ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .num = (_num), \ - .info = &(_info), \ - .size = sizeof(_type), \ - .flags = VMS_ARRAY|VMS_ARRAY_OF_POINTER, \ - .offset = vmstate_offset_array(_state, _field, _type, _num), \ -} - -#define VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, _test, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num = (_num), \ - .field_exists = (_test), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_ARRAY, \ - .offset = vmstate_offset_array(_state, _field, _type, _num),\ -} - -#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint8_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_UINT8, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = 0, \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .size = sizeof(_type), \ - .vmsd = &(_vmsd), \ - .flags = VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .version_id = 0, \ - .num_offset = vmstate_offset_value(_state, _field_num, uint16_t),\ - .size = sizeof(_type), \ - .vmsd = &(_vmsd), \ - .flags = VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ - .offset = vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_INT32, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \ - .name = (stringify(_field)), \ - .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \ - .version_id = (_version), \ - .vmsd = &(_vmsd), \ - .size = sizeof(_type), \ - .flags = VMS_STRUCT|VMS_VARRAY_UINT32, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size = (_size - _start), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_BUFFER, \ - .offset = vmstate_offset_buffer(_state, _field) + _start, \ -} - -#define VMSTATE_BUFFER_MULTIPLY(_field, _state, _version, _test, _start, _field_size, _multiply) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ - .size = (_multiply), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_VBUFFER|VMS_MULTIPLY, \ - .offset = offsetof(_state, _field), \ - .start = (_start), \ -} - -#define VMSTATE_VBUFFER(_field, _state, _version, _test, _start, _field_size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ - .info = &vmstate_info_buffer, \ - .flags = VMS_VBUFFER|VMS_POINTER, \ - .offset = offsetof(_state, _field), \ - .start = (_start), \ -} - -#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _start, _field_size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .field_exists = (_test), \ - .size_offset = vmstate_offset_value(_state, _field_size, uint32_t),\ - .info = &vmstate_info_buffer, \ - .flags = VMS_VBUFFER|VMS_POINTER, \ - .offset = offsetof(_state, _field), \ - .start = (_start), \ -} - -#define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .size = (_size), \ - .info = &(_info), \ - .flags = VMS_BUFFER, \ - .offset = offsetof(_state, _field), \ -} - -#define VMSTATE_UNUSED_BUFFER(_test, _version, _size) { \ - .name = "unused", \ - .field_exists = (_test), \ - .version_id = (_version), \ - .size = (_size), \ - .info = &vmstate_info_unused_buffer, \ - .flags = VMS_BUFFER, \ -} - -/* _field_size should be a int32_t field in the _state struct giving the - * size of the bitmap _field in bits. - */ -#define VMSTATE_BITMAP(_field, _state, _version, _field_size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .size_offset = vmstate_offset_value(_state, _field_size, int32_t),\ - .info = &vmstate_info_bitmap, \ - .flags = VMS_VBUFFER|VMS_POINTER, \ - .offset = offsetof(_state, _field), \ -} - -/* _f : field name - _f_n : num of elements field_name - _n : num of elements - _s : struct state name - _v : version -*/ - -#define VMSTATE_SINGLE(_field, _state, _version, _info, _type) \ - VMSTATE_SINGLE_TEST(_field, _state, NULL, _version, _info, _type) - -#define VMSTATE_STRUCT(_field, _state, _version, _vmsd, _type) \ - VMSTATE_STRUCT_TEST(_field, _state, NULL, _version, _vmsd, _type) - -#define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \ - VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) - -#define VMSTATE_STRUCT_ARRAY(_field, _state, _num, _version, _vmsd, _type) \ - VMSTATE_STRUCT_ARRAY_TEST(_field, _state, _num, NULL, _version, \ - _vmsd, _type) - -#define VMSTATE_BOOL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool) - -#define VMSTATE_INT8_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) -#define VMSTATE_INT16_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int16, int16_t) -#define VMSTATE_INT32_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int32, int32_t) -#define VMSTATE_INT64_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int64, int64_t) - -#define VMSTATE_UINT8_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint8, uint8_t) -#define VMSTATE_UINT16_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16, uint16_t) -#define VMSTATE_UINT32_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint32, uint32_t) -#define VMSTATE_UINT64_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) - -#define VMSTATE_BOOL(_f, _s) \ - VMSTATE_BOOL_V(_f, _s, 0) - -#define VMSTATE_INT8(_f, _s) \ - VMSTATE_INT8_V(_f, _s, 0) -#define VMSTATE_INT16(_f, _s) \ - VMSTATE_INT16_V(_f, _s, 0) -#define VMSTATE_INT32(_f, _s) \ - VMSTATE_INT32_V(_f, _s, 0) -#define VMSTATE_INT64(_f, _s) \ - VMSTATE_INT64_V(_f, _s, 0) - -#define VMSTATE_UINT8(_f, _s) \ - VMSTATE_UINT8_V(_f, _s, 0) -#define VMSTATE_UINT16(_f, _s) \ - VMSTATE_UINT16_V(_f, _s, 0) -#define VMSTATE_UINT32(_f, _s) \ - VMSTATE_UINT32_V(_f, _s, 0) -#define VMSTATE_UINT64(_f, _s) \ - VMSTATE_UINT64_V(_f, _s, 0) - -#define VMSTATE_UINT8_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) - -#define VMSTATE_UINT16_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint16_equal, uint16_t) - -#define VMSTATE_UINT16_EQUAL_V(_f, _s, _v) \ - VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint16_equal, uint16_t) - -#define VMSTATE_INT32_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) - -#define VMSTATE_UINT32_EQUAL(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t) - -#define VMSTATE_INT32_LE(_f, _s) \ - VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) - -#define VMSTATE_UINT8_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint8, uint8_t) - -#define VMSTATE_UINT16_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint16, uint16_t) - -#define VMSTATE_UINT32_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint32, uint32_t) - -#define VMSTATE_TIMER_TEST(_f, _s, _test) \ - VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *) - -#define VMSTATE_TIMER_V(_f, _s, _v) \ - VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) - -#define VMSTATE_TIMER(_f, _s) \ - VMSTATE_TIMER_V(_f, _s, 0) - -#define VMSTATE_TIMER_ARRAY(_f, _s, _n) \ - VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer *) - -#define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool) - -#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ - VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) - -#define VMSTATE_UINT16_ARRAY(_f, _s, _n) \ - VMSTATE_UINT16_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT8_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint8, uint8_t) - -#define VMSTATE_UINT8_ARRAY(_f, _s, _n) \ - VMSTATE_UINT8_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint32, uint32_t) - -#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ - VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint64, uint64_t) - -#define VMSTATE_UINT64_ARRAY(_f, _s, _n) \ - VMSTATE_UINT64_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_INT16_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int16, int16_t) - -#define VMSTATE_INT16_ARRAY(_f, _s, _n) \ - VMSTATE_INT16_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_INT32_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int32, int32_t) - -#define VMSTATE_INT32_ARRAY(_f, _s, _n) \ - VMSTATE_INT32_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_UINT32_SUB_ARRAY(_f, _s, _start, _num) \ - VMSTATE_SUB_ARRAY(_f, _s, _start, _num, 0, vmstate_info_uint32, uint32_t) - -#define VMSTATE_UINT32_ARRAY(_f, _s, _n) \ - VMSTATE_UINT32_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_INT64_ARRAY_V(_f, _s, _n, _v) \ - VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_int64, int64_t) - -#define VMSTATE_INT64_ARRAY(_f, _s, _n) \ - VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0) - -#define VMSTATE_BUFFER_V(_f, _s, _v) \ - VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f))) - -#define VMSTATE_BUFFER(_f, _s) \ - VMSTATE_BUFFER_V(_f, _s, 0) - -#define VMSTATE_PARTIAL_BUFFER(_f, _s, _size) \ - VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, 0, _size) - -#define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \ - VMSTATE_STATIC_BUFFER(_f, _s, 0, NULL, _start, sizeof(typeof_field(_s, _f))) - -#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \ - VMSTATE_VBUFFER(_f, _s, 0, NULL, 0, _size) - -#define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) \ - VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, 0, _size) - -#define VMSTATE_SUB_VBUFFER(_f, _s, _start, _size) \ - VMSTATE_VBUFFER(_f, _s, 0, NULL, _start, _size) - -#define VMSTATE_BUFFER_TEST(_f, _s, _test) \ - VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f))) - -#define VMSTATE_BUFFER_UNSAFE(_field, _state, _version, _size) \ - VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size) - -#define VMSTATE_UNUSED_V(_v, _size) \ - VMSTATE_UNUSED_BUFFER(NULL, _v, _size) - -#define VMSTATE_UNUSED(_size) \ - VMSTATE_UNUSED_V(0, _size) - -#define VMSTATE_UNUSED_TEST(_test, _size) \ - VMSTATE_UNUSED_BUFFER(_test, 0, _size) - -#define VMSTATE_END_OF_LIST() \ - {} - -int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, int version_id); -void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque); -int vmstate_register(DeviceState *dev, int instance_id, - const VMStateDescription *vmsd, void *base); -int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, - const VMStateDescription *vmsd, - void *base, int alias_id, - int required_for_version); -void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd, - void *opaque); - -struct MemoryRegion; -void vmstate_register_ram(struct MemoryRegion *memory, DeviceState *dev); -void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); -void vmstate_register_ram_global(struct MemoryRegion *memory); - -#endif -- cgit v1.2.3-55-g7522 From 1de7afc984b49af164e2619e6850b9732b173b34 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:20:00 +0100 Subject: misc: move include files to include/qemu/ Signed-off-by: Paolo Bonzini --- acl.c | 2 +- acl.h | 74 ----- aio-posix.c | 4 +- aio-win32.c | 4 +- arch_init.c | 6 +- async.c | 2 +- audio/alsaaudio.c | 2 +- audio/audio.c | 2 +- audio/audio.h | 2 +- audio/noaudio.c | 2 +- audio/ossaudio.c | 4 +- audio/spiceaudio.c | 2 +- audio/wavaudio.c | 2 +- backends/rng-random.c | 2 +- bitmap.c | 4 +- bitmap.h | 222 ------------- bitops.c | 2 +- bitops.h | 362 -------------------- block-migration.c | 4 +- block.c | 6 +- block/blkdebug.c | 4 +- block/blkverify.c | 2 +- block/bochs.c | 2 +- block/cloop.c | 2 +- block/cow.c | 2 +- block/dmg.c | 4 +- block/gluster.c | 4 +- block/iscsi.c | 4 +- block/linux-aio.c | 4 +- block/nbd.c | 6 +- block/parallels.c | 2 +- block/qcow.c | 2 +- block/qcow2.c | 4 +- block/qed-table.c | 2 +- block/qed.c | 2 +- block/raw-posix.c | 8 +- block/raw-win32.c | 6 +- block/raw.c | 2 +- block/rbd.c | 2 +- block/sheepdog.c | 6 +- block/vdi.c | 2 +- block/vmdk.c | 2 +- block/vpc.c | 2 +- block/vvfat.c | 2 +- block/win32-aio.c | 6 +- blockdev-nbd.c | 2 +- blockdev.c | 4 +- blockdev.h | 2 +- blockjob.c | 2 +- bsd-user/main.c | 4 +- bsd-user/qemu.h | 2 +- bswap.h | 713 ---------------------------------------- bt-host.c | 2 +- bt-vhci.c | 2 +- buffered_file.c | 2 +- cache-utils.c | 2 +- cache-utils.h | 44 --- cmd.c | 2 +- compatfd.c | 2 +- compatfd.h | 44 --- compiler.h | 58 ---- cpu-exec.c | 2 +- cpus.c | 8 +- cutils.c | 6 +- device_tree.c | 4 +- dma-helpers.c | 4 +- envlist.c | 4 +- envlist.h | 22 -- event_notifier-posix.c | 4 +- event_notifier-win32.c | 4 +- event_notifier.h | 46 --- exec.c | 6 +- fpu/softfloat.h | 2 +- fsdev/qemu-fsdev-dummy.c | 4 +- fsdev/qemu-fsdev.c | 6 +- fsdev/qemu-fsdev.h | 2 +- fsdev/virtfs-proxy-helper.c | 4 +- fsdev/virtio-9p-marshal.c | 4 +- gdbstub.c | 2 +- hmp.c | 6 +- host-utils.c | 2 +- host-utils.h | 240 -------------- hw/9pfs/codir.c | 2 +- hw/9pfs/cofile.c | 2 +- hw/9pfs/cofs.c | 2 +- hw/9pfs/coxattr.c | 2 +- hw/9pfs/virtio-9p-coth.c | 2 +- hw/9pfs/virtio-9p-coth.h | 2 +- hw/9pfs/virtio-9p-device.c | 2 +- hw/9pfs/virtio-9p-handle.c | 2 +- hw/9pfs/virtio-9p-local.c | 2 +- hw/9pfs/virtio-9p-posix-acl.c | 2 +- hw/9pfs/virtio-9p-xattr.h | 2 +- hw/9pfs/virtio-9p.c | 2 +- hw/9pfs/virtio-9p.h | 2 +- hw/acpi.h | 2 +- hw/acpi_ich9.c | 2 +- hw/acpi_piix4.c | 2 +- hw/adlib.c | 2 +- hw/alpha_pci.c | 2 +- hw/apic.c | 4 +- hw/apic_internal.h | 2 +- hw/applesmc.c | 2 +- hw/arm11mpcore.c | 2 +- hw/arm_boot.c | 2 +- hw/arm_mptimer.c | 2 +- hw/arm_sysctl.c | 2 +- hw/arm_timer.c | 2 +- hw/armv7m_nvic.c | 2 +- hw/baum.c | 2 +- hw/block-common.c | 2 +- hw/bt-hci-csr.c | 2 +- hw/bt-hci.c | 2 +- hw/bt-hid.c | 2 +- hw/bt-l2cap.c | 2 +- hw/cadence_ttc.c | 2 +- hw/cadence_uart.c | 2 +- hw/ccid-card-emulated.c | 2 +- hw/ccid-card-passthru.c | 2 +- hw/cs4231a.c | 2 +- hw/cuda.c | 2 +- hw/device-hotplug.c | 2 +- hw/dma.c | 2 +- hw/dp8393x.c | 2 +- hw/esp-pci.c | 2 +- hw/esp.c | 2 +- hw/etraxfs_ser.c | 2 +- hw/etraxfs_timer.c | 2 +- hw/exynos4210_fimd.c | 2 +- hw/exynos4210_i2c.c | 2 +- hw/exynos4210_mct.c | 2 +- hw/exynos4210_pwm.c | 2 +- hw/exynos4210_rtc.c | 4 +- hw/fdc.c | 6 +- hw/fw_cfg.c | 4 +- hw/grlib_gptimer.c | 2 +- hw/hid.c | 2 +- hw/hpet.c | 2 +- hw/hw.h | 2 +- hw/i8254.c | 2 +- hw/i8254_common.c | 2 +- hw/i8259.c | 2 +- hw/ich9.h | 2 +- hw/ide/core.c | 4 +- hw/ide/qdev.c | 2 +- hw/imx_avic.c | 2 +- hw/imx_timer.c | 2 +- hw/intel-hda.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/i8254.c | 2 +- hw/kvm/pci-assign.c | 4 +- hw/lance.c | 4 +- hw/leon3.c | 2 +- hw/lm32_sys.c | 6 +- hw/lm32_timer.c | 4 +- hw/lm32_uart.c | 2 +- hw/lm832x.c | 2 +- hw/lpc_ich9.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.c | 2 +- hw/mc146818rtc.c | 2 +- hw/mcf5206.c | 2 +- hw/mcf5208.c | 2 +- hw/megasas.c | 2 +- hw/microblaze_boot.c | 4 +- hw/milkymist-ac97.c | 2 +- hw/milkymist-hpdmc.c | 2 +- hw/milkymist-memcard.c | 2 +- hw/milkymist-minimac2.c | 2 +- hw/milkymist-pfpu.c | 4 +- hw/milkymist-softusb.c | 2 +- hw/milkymist-sysctl.c | 4 +- hw/milkymist-tmu2.c | 2 +- hw/milkymist-uart.c | 2 +- hw/milkymist-vgafb.c | 2 +- hw/mips_fulong2e.c | 2 +- hw/mips_malta.c | 2 +- hw/mips_r4k.c | 2 +- hw/mips_timer.c | 2 +- hw/musicpal.c | 2 +- hw/nand.c | 2 +- hw/omap1.c | 2 +- hw/omap2.c | 2 +- hw/omap_dma.c | 2 +- hw/omap_gptimer.c | 2 +- hw/omap_synctimer.c | 2 +- hw/onenand.c | 2 +- hw/openrisc_timer.c | 2 +- hw/pc.c | 2 +- hw/pci/msi.c | 2 +- hw/pci/msix.c | 2 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pci_bridge.c | 2 +- hw/pci/pcie.c | 2 +- hw/pci/shpc.c | 4 +- hw/pcnet-pci.c | 2 +- hw/pcnet.c | 4 +- hw/pcspk.c | 2 +- hw/pflash_cfi01.c | 4 +- hw/pflash_cfi02.c | 4 +- hw/piix_pci.c | 2 +- hw/pl031.c | 2 +- hw/ppc.c | 4 +- hw/ppc/e500.c | 4 +- hw/ppc405_boards.c | 2 +- hw/ppc405_uc.c | 4 +- hw/ppc4xx_devs.c | 2 +- hw/ppc_booke.c | 4 +- hw/ppc_prep.c | 2 +- hw/ppce500_pci.c | 2 +- hw/ptimer.c | 4 +- hw/ptimer.h | 2 +- hw/pxa2xx_timer.c | 2 +- hw/q35.h | 2 +- hw/qdev-core.h | 6 +- hw/qdev-monitor.c | 2 +- hw/qxl-logger.c | 2 +- hw/qxl.c | 4 +- hw/qxl.h | 2 +- hw/rc4030.c | 2 +- hw/rtl8139.c | 4 +- hw/s390x/event-facility.h | 2 +- hw/s390x/sclpconsole.c | 2 +- hw/sb16.c | 4 +- hw/scsi-bus.c | 2 +- hw/scsi-disk.c | 2 +- hw/scsi-generic.c | 2 +- hw/sd.c | 2 +- hw/serial.c | 2 +- hw/sh_pci.c | 2 +- hw/sh_timer.c | 2 +- hw/slavio_timer.c | 2 +- hw/sm501.c | 2 +- hw/soc_dma.c | 2 +- hw/spapr.c | 2 +- hw/spitz.c | 2 +- hw/stellaris.c | 2 +- hw/strongarm.c | 2 +- hw/sun4m.c | 2 +- hw/sun4u.c | 2 +- hw/tsc2005.c | 2 +- hw/tsc210x.c | 2 +- hw/tusb6010.c | 2 +- hw/twl92230.c | 2 +- hw/usb.h | 2 +- hw/usb/combined-packet.c | 2 +- hw/usb/core.c | 2 +- hw/usb/dev-hid.c | 2 +- hw/usb/dev-network.c | 6 +- hw/usb/dev-serial.c | 2 +- hw/usb/dev-smartcard-reader.c | 2 +- hw/usb/dev-storage.c | 4 +- hw/usb/dev-uas.c | 4 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/hcd-musb.c | 2 +- hw/usb/hcd-ohci.c | 2 +- hw/usb/hcd-uhci.c | 4 +- hw/usb/hcd-xhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/redirect.c | 4 +- hw/vfio_pci.c | 8 +- hw/vga-isa-mm.c | 2 +- hw/vga-isa.c | 2 +- hw/vga-pci.c | 2 +- hw/vga.c | 2 +- hw/vhost.c | 2 +- hw/vhost_net.c | 2 +- hw/virtex_ml507.c | 2 +- hw/virtio-balloon.c | 2 +- hw/virtio-blk.c | 2 +- hw/virtio-console.c | 2 +- hw/virtio-net.c | 6 +- hw/virtio-pci.c | 4 +- hw/virtio-rng.c | 2 +- hw/virtio-serial-bus.c | 4 +- hw/virtio.c | 4 +- hw/virtio.h | 2 +- hw/vt82c686.c | 2 +- hw/watchdog.c | 6 +- hw/watchdog.h | 2 +- hw/wdt_i6300esb.c | 2 +- hw/wdt_ib700.c | 2 +- hw/xen_backend.c | 2 +- hw/xen_common.h | 2 +- hw/xen_domainbuild.c | 4 +- hw/xen_pt.c | 2 +- hw/xen_pt_config_init.c | 2 +- hw/xgmac.c | 2 +- hw/xilinx_axidma.c | 4 +- hw/xilinx_axienet.c | 2 +- hw/xilinx_spi.c | 2 +- hw/xilinx_spips.c | 4 +- hw/xilinx_timer.c | 2 +- hw/xtensa_pic.c | 4 +- hw/zynq_slcr.c | 2 +- include/block/aio.h | 4 +- include/block/block.h | 2 +- include/block/block_int.h | 6 +- include/block/coroutine.h | 4 +- include/block/coroutine_int.h | 2 +- include/block/thread-pool.h | 4 +- include/exec/cpu-all.h | 2 +- include/exec/cpu-common.h | 4 +- include/exec/cpu-defs.h | 4 +- include/exec/exec-all.h | 2 +- include/exec/gen-icount.h | 2 +- include/exec/memory.h | 4 +- include/exec/softmmu_template.h | 2 +- include/migration/migration.h | 2 +- include/net/net.h | 4 +- include/net/slirp.h | 2 +- include/qapi/error.h | 2 +- include/qapi/opts-visitor.h | 2 +- include/qapi/qmp/qdict.h | 2 +- include/qapi/qmp/qerror.h | 2 +- include/qapi/qmp/qjson.h | 2 +- include/qapi/qmp/qlist.h | 4 +- include/qemu/acl.h | 74 +++++ include/qemu/atomic.h | 67 ++++ include/qemu/bitmap.h | 222 +++++++++++++ include/qemu/bitops.h | 362 ++++++++++++++++++++ include/qemu/bswap.h | 713 ++++++++++++++++++++++++++++++++++++++++ include/qemu/cache-utils.h | 44 +++ include/qemu/compatfd.h | 44 +++ include/qemu/compiler.h | 58 ++++ include/qemu/config-file.h | 30 ++ include/qemu/envlist.h | 22 ++ include/qemu/error-report.h | 43 +++ include/qemu/event_notifier.h | 46 +++ include/qemu/host-utils.h | 240 ++++++++++++++ include/qemu/int128.h | 116 +++++++ include/qemu/iov.h | 102 ++++++ include/qemu/log.h | 160 +++++++++ include/qemu/main-loop.h | 306 +++++++++++++++++ include/qemu/module.h | 40 +++ include/qemu/notify.h | 43 +++ include/qemu/option.h | 158 +++++++++ include/qemu/option_int.h | 54 +++ include/qemu/osdep.h | 178 ++++++++++ include/qemu/queue.h | 414 +++++++++++++++++++++++ include/qemu/range.h | 29 ++ include/qemu/sockets.h | 77 +++++ include/qemu/thread-posix.h | 28 ++ include/qemu/thread-win32.h | 29 ++ include/qemu/thread.h | 56 ++++ include/qemu/timer.h | 310 +++++++++++++++++ include/qemu/tls.h | 52 +++ include/qemu/typedefs.h | 61 ++++ include/qemu/uri.h | 113 +++++++ include/qemu/xattr.h | 30 ++ include/qom/cpu.h | 2 +- include/qom/object.h | 2 +- include/ui/console.h | 2 +- include/ui/qemu-spice.h | 4 +- include/ui/spice-display.h | 2 +- int128.h | 116 ------- iohandler.c | 4 +- iov.c | 2 +- iov.h | 102 ------ kvm-all.c | 10 +- kvm.h | 2 +- libcacard/event.c | 2 +- libcacard/vreader.c | 2 +- libcacard/vscclient.c | 4 +- libfdt_env.h | 2 +- linux-user/main.c | 6 +- linux-user/qemu.h | 4 +- linux-user/syscall.c | 2 +- main-loop.c | 6 +- main-loop.h | 306 ----------------- memory.c | 2 +- memory_mapping.h | 2 +- migration-exec.c | 2 +- migration-fd.c | 4 +- migration-tcp.c | 2 +- migration-unix.c | 2 +- migration.c | 2 +- module.c | 4 +- module.h | 40 --- monitor.c | 8 +- nbd.c | 4 +- net/dump.c | 6 +- net/hub.c | 2 +- net/net.c | 6 +- net/queue.c | 2 +- net/slirp.c | 2 +- net/socket.c | 8 +- net/tap-bsd.c | 2 +- net/tap-linux.c | 2 +- net/tap-solaris.c | 2 +- net/tap-win32.c | 2 +- net/tap.c | 2 +- net/vde.c | 2 +- notify.c | 2 +- notify.h | 43 --- osdep.c | 2 +- osdep.h | 178 ---------- oslib-posix.c | 2 +- oslib-win32.c | 4 +- qapi/opts-visitor.c | 4 +- qapi/qapi-dealloc-visitor.c | 2 +- qapi/qmp-input-visitor.c | 2 +- qapi/qmp-output-visitor.c | 2 +- qdict.c | 2 +- qemu-barrier.h | 67 ---- qemu-bridge-helper.c | 2 +- qemu-char.c | 4 +- qemu-char.h | 8 +- qemu-common.h | 10 +- qemu-config.c | 6 +- qemu-config.h | 30 -- qemu-coroutine-io.c | 4 +- qemu-coroutine-lock.c | 2 +- qemu-coroutine-sleep.c | 2 +- qemu-error.h | 43 --- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-log.c | 2 +- qemu-log.h | 160 --------- qemu-option-internal.h | 54 --- qemu-option.c | 4 +- qemu-option.h | 158 --------- qemu-progress.c | 2 +- qemu-queue.h | 414 ----------------------- qemu-seccomp.h | 2 +- qemu-sockets.c | 4 +- qemu-thread-posix.c | 2 +- qemu-thread-posix.h | 28 -- qemu-thread-win32.c | 2 +- qemu-thread-win32.h | 29 -- qemu-thread.h | 56 ---- qemu-timer-common.c | 2 +- qemu-timer.c | 4 +- qemu-timer.h | 310 ----------------- qemu-tls.h | 52 --- qemu-tool.c | 8 +- qemu-types.h | 61 ---- qemu-xattr.h | 30 -- qemu_socket.h | 77 ----- qga/channel-posix.c | 4 +- qga/commands-posix.c | 4 +- qga/main.c | 2 +- qlist.c | 2 +- qom/container.c | 2 +- range.h | 29 -- savevm.c | 10 +- scripts/qapi-commands.py | 2 +- slirp/if.c | 2 +- slirp/ip_input.c | 2 +- slirp/sbuf.c | 2 +- slirp/slirp.c | 2 +- slirp/slirp.h | 4 +- spice-qemu-char.c | 2 +- stubs/fd-register.c | 2 +- stubs/set-fd-handler.c | 2 +- sysemu.h | 12 +- target-alpha/int_helper.c | 2 +- target-alpha/sys_helper.c | 2 +- target-alpha/translate.c | 2 +- target-arm/helper.c | 4 +- target-arm/translate.c | 2 +- target-cris/helper.c | 2 +- target-cris/op_helper.c | 2 +- target-i386/cpu.c | 4 +- target-i386/excp_helper.c | 2 +- target-i386/int_helper.c | 2 +- target-i386/kvm.c | 4 +- target-i386/seg_helper.c | 2 +- target-lm32/helper.c | 2 +- target-lm32/op_helper.c | 2 +- target-m68k/translate.c | 2 +- target-microblaze/helper.c | 2 +- target-microblaze/op_helper.c | 2 +- target-mips/op_helper.c | 2 +- target-openrisc/int_helper.c | 2 +- target-openrisc/interrupt.c | 2 +- target-openrisc/mmu.c | 2 +- target-openrisc/translate.c | 4 +- target-ppc/int_helper.c | 2 +- target-ppc/kvm.c | 2 +- target-ppc/kvm_ppc.c | 2 +- target-ppc/mem_helper.c | 2 +- target-ppc/translate.c | 2 +- target-s390x/cpu.c | 2 +- target-s390x/helper.c | 2 +- target-s390x/int_helper.c | 2 +- target-s390x/kvm.c | 2 +- target-s390x/misc_helper.c | 4 +- target-s390x/translate.c | 2 +- target-sparc/cpu.h | 2 +- target-sparc/helper.c | 2 +- target-sparc/machine.c | 2 +- target-unicore32/helper.c | 2 +- target-unicore32/translate.c | 2 +- target-xtensa/core-dc232b.c | 2 +- target-xtensa/core-dc233c.c | 2 +- target-xtensa/core-fsf.c | 2 +- target-xtensa/helper.c | 2 +- target-xtensa/op_helper.c | 2 +- target-xtensa/translate.c | 2 +- target-xtensa/xtensa-semi.c | 2 +- tcg/tcg.c | 6 +- tests/libqtest.c | 4 +- tests/tcg/test-i386-fprem.c | 4 +- tests/tcg/test-i386.c | 2 +- tests/test-iov.c | 4 +- tests/test-qmp-commands.c | 2 +- thread-pool.c | 8 +- trace/simple.c | 2 +- translate-all.c | 2 +- ui/console.c | 2 +- ui/sdl_zoom.c | 2 +- ui/spice-core.c | 10 +- ui/spice-display.c | 4 +- ui/vnc-auth-sasl.h | 2 +- ui/vnc-enc-tight.c | 2 +- ui/vnc-jobs.c | 2 +- ui/vnc-palette.h | 2 +- ui/vnc-tls.c | 2 +- ui/vnc-tls.h | 2 +- ui/vnc.c | 8 +- ui/vnc.h | 6 +- uri.c | 2 +- uri.h | 113 ------- vl.c | 18 +- xen-all.c | 2 +- xen-mapcache.c | 2 +- 529 files changed, 4978 insertions(+), 4978 deletions(-) delete mode 100644 acl.h delete mode 100644 bitmap.h delete mode 100644 bitops.h delete mode 100644 bswap.h delete mode 100644 cache-utils.h delete mode 100644 compatfd.h delete mode 100644 compiler.h delete mode 100644 envlist.h delete mode 100644 event_notifier.h delete mode 100644 host-utils.h create mode 100644 include/qemu/acl.h create mode 100644 include/qemu/atomic.h create mode 100644 include/qemu/bitmap.h create mode 100644 include/qemu/bitops.h create mode 100644 include/qemu/bswap.h create mode 100644 include/qemu/cache-utils.h create mode 100644 include/qemu/compatfd.h create mode 100644 include/qemu/compiler.h create mode 100644 include/qemu/config-file.h create mode 100644 include/qemu/envlist.h create mode 100644 include/qemu/error-report.h create mode 100644 include/qemu/event_notifier.h create mode 100644 include/qemu/host-utils.h create mode 100644 include/qemu/int128.h create mode 100644 include/qemu/iov.h create mode 100644 include/qemu/log.h create mode 100644 include/qemu/main-loop.h create mode 100644 include/qemu/module.h create mode 100644 include/qemu/notify.h create mode 100644 include/qemu/option.h create mode 100644 include/qemu/option_int.h create mode 100644 include/qemu/osdep.h create mode 100644 include/qemu/queue.h create mode 100644 include/qemu/range.h create mode 100644 include/qemu/sockets.h create mode 100644 include/qemu/thread-posix.h create mode 100644 include/qemu/thread-win32.h create mode 100644 include/qemu/thread.h create mode 100644 include/qemu/timer.h create mode 100644 include/qemu/tls.h create mode 100644 include/qemu/typedefs.h create mode 100644 include/qemu/uri.h create mode 100644 include/qemu/xattr.h delete mode 100644 int128.h delete mode 100644 iov.h delete mode 100644 main-loop.h delete mode 100644 module.h delete mode 100644 notify.h delete mode 100644 osdep.h delete mode 100644 qemu-barrier.h delete mode 100644 qemu-config.h delete mode 100644 qemu-error.h delete mode 100644 qemu-log.h delete mode 100644 qemu-option-internal.h delete mode 100644 qemu-option.h delete mode 100644 qemu-queue.h delete mode 100644 qemu-thread-posix.h delete mode 100644 qemu-thread-win32.h delete mode 100644 qemu-thread.h delete mode 100644 qemu-timer.h delete mode 100644 qemu-tls.h delete mode 100644 qemu-types.h delete mode 100644 qemu-xattr.h delete mode 100644 qemu_socket.h delete mode 100644 range.h delete mode 100644 uri.h (limited to 'arch_init.c') diff --git a/acl.c b/acl.c index e840b9b633..81ac25599b 100644 --- a/acl.c +++ b/acl.c @@ -24,7 +24,7 @@ #include "qemu-common.h" -#include "acl.h" +#include "qemu/acl.h" #ifdef CONFIG_FNMATCH #include diff --git a/acl.h b/acl.h deleted file mode 100644 index 0ef780401f..0000000000 --- a/acl.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * QEMU access control list management - * - * Copyright (C) 2009 Red Hat, Inc - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef __QEMU_ACL_H__ -#define __QEMU_ACL_H__ - -#include "qemu-queue.h" - -typedef struct qemu_acl_entry qemu_acl_entry; -typedef struct qemu_acl qemu_acl; - -struct qemu_acl_entry { - char *match; - int deny; - - QTAILQ_ENTRY(qemu_acl_entry) next; -}; - -struct qemu_acl { - char *aclname; - unsigned int nentries; - QTAILQ_HEAD(,qemu_acl_entry) entries; - int defaultDeny; -}; - -qemu_acl *qemu_acl_init(const char *aclname); - -qemu_acl *qemu_acl_find(const char *aclname); - -int qemu_acl_party_is_allowed(qemu_acl *acl, - const char *party); - -void qemu_acl_reset(qemu_acl *acl); - -int qemu_acl_append(qemu_acl *acl, - int deny, - const char *match); -int qemu_acl_insert(qemu_acl *acl, - int deny, - const char *match, - int index); -int qemu_acl_remove(qemu_acl *acl, - const char *match); - -#endif /* __QEMU_ACL_H__ */ - -/* - * Local variables: - * c-indent-level: 4 - * c-basic-offset: 4 - * tab-width: 8 - * End: - */ diff --git a/aio-posix.c b/aio-posix.c index d1e1bc2c75..88d09e1cfb 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -15,8 +15,8 @@ #include "qemu-common.h" #include "block/block.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" struct AioHandler { diff --git a/aio-win32.c b/aio-win32.c index 9a26f9c3d9..f5ea027f8c 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -17,8 +17,8 @@ #include "qemu-common.h" #include "block/block.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" struct AioHandler { EventNotifier *e; diff --git a/arch_init.c b/arch_init.c index f627253a20..9dacf5689b 100644 --- a/arch_init.c +++ b/arch_init.c @@ -31,8 +31,8 @@ #include "config.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "bitops.h" -#include "bitmap.h" +#include "qemu/bitops.h" +#include "qemu/bitmap.h" #include "arch_init.h" #include "audio/audio.h" #include "hw/pc.h" @@ -45,7 +45,7 @@ #include "exec/address-spaces.h" #include "hw/pcspk.h" #include "migration/page_cache.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "qmp-commands.h" #include "trace.h" diff --git a/async.c b/async.c index 6df4caf68a..72d268ae35 100644 --- a/async.c +++ b/async.c @@ -24,7 +24,7 @@ #include "qemu-common.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /***********************************************************/ /* bottom halves (can be seen as timers which expire ASAP) */ diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index cd553c2a7b..e4e5442631 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -23,7 +23,7 @@ */ #include #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "audio.h" #if QEMU_GNUC_PREREQ(4, 3) diff --git a/audio/audio.c b/audio/audio.c index a0cc727020..eb2222c10f 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -24,7 +24,7 @@ #include "hw/hw.h" #include "audio.h" #include "monitor/monitor.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #define AUDIO_CAP "audio" diff --git a/audio/audio.h b/audio/audio.h index a70fda97e3..e7ea39777e 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -25,7 +25,7 @@ #define QEMU_AUDIO_H #include "config-host.h" -#include "qemu-queue.h" +#include "qemu/queue.h" typedef void (*audio_callback_fn) (void *opaque, int avail); diff --git a/audio/noaudio.c b/audio/noaudio.c index 54958f8623..9f23aa2cb3 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define AUDIO_CAP "noaudio" #include "audio_int.h" diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 8249a00449..00be9c91e3 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -31,8 +31,8 @@ #include #endif #include "qemu-common.h" -#include "main-loop.h" -#include "host-utils.h" +#include "qemu/main-loop.h" +#include "qemu/host-utils.h" #include "audio.h" #define AUDIO_CAP "oss" diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c index 6f15591a74..bc24557de4 100644 --- a/audio/spiceaudio.c +++ b/audio/spiceaudio.c @@ -18,7 +18,7 @@ */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/qemu-spice.h" #define AUDIO_CAP "spice" diff --git a/audio/wavaudio.c b/audio/wavaudio.c index a449b5127e..950fa8f19c 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audio.h" #define AUDIO_CAP "wav" diff --git a/backends/rng-random.c b/backends/rng-random.c index c201953f29..d479ce8c56 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -13,7 +13,7 @@ #include "qemu/rng-random.h" #include "qemu/rng.h" #include "qapi/qmp/qerror.h" -#include "main-loop.h" +#include "qemu/main-loop.h" struct RndRandom { diff --git a/bitmap.c b/bitmap.c index a62c8ba681..687841dcec 100644 --- a/bitmap.c +++ b/bitmap.c @@ -9,8 +9,8 @@ * Version 2. */ -#include "bitops.h" -#include "bitmap.h" +#include "qemu/bitops.h" +#include "qemu/bitmap.h" /* * bitmaps provide an array of bits, implemented using an an diff --git a/bitmap.h b/bitmap.h deleted file mode 100644 index 08755eba11..0000000000 --- a/bitmap.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Bitmap Module - * - * Copyright (C) 2010 Corentin Chary - * - * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef BITMAP_H -#define BITMAP_H - -#include "qemu-common.h" -#include "bitops.h" - -/* - * The available bitmap operations and their rough meaning in the - * case that the bitmap is a single unsigned long are thus: - * - * Note that nbits should be always a compile time evaluable constant. - * Otherwise many inlines will generate horrible code. - * - * bitmap_zero(dst, nbits) *dst = 0UL - * bitmap_fill(dst, nbits) *dst = ~0UL - * bitmap_copy(dst, src, nbits) *dst = *src - * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 - * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 - * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 - * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) - * bitmap_complement(dst, src, nbits) *dst = ~(*src) - * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? - * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? - * bitmap_empty(src, nbits) Are all bits zero in *src? - * bitmap_full(src, nbits) Are all bits set in *src? - * bitmap_set(dst, pos, nbits) Set specified bit area - * bitmap_clear(dst, pos, nbits) Clear specified bit area - * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area - */ - -/* - * Also the following operations apply to bitmaps. - * - * set_bit(bit, addr) *addr |= bit - * clear_bit(bit, addr) *addr &= ~bit - * change_bit(bit, addr) *addr ^= bit - * test_bit(bit, addr) Is bit set in *addr? - * test_and_set_bit(bit, addr) Set bit and return old value - * test_and_clear_bit(bit, addr) Clear bit and return old value - * test_and_change_bit(bit, addr) Change bit and return old value - * find_first_zero_bit(addr, nbits) Position first zero bit in *addr - * find_first_bit(addr, nbits) Position first set bit in *addr - * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit - * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit - */ - -#define BITMAP_LAST_WORD_MASK(nbits) \ - ( \ - ((nbits) % BITS_PER_LONG) ? \ - (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ - ) - -#define DECLARE_BITMAP(name,bits) \ - unsigned long name[BITS_TO_LONGS(bits)] - -#define small_nbits(nbits) \ - ((nbits) <= BITS_PER_LONG) - -int slow_bitmap_empty(const unsigned long *bitmap, int bits); -int slow_bitmap_full(const unsigned long *bitmap, int bits); -int slow_bitmap_equal(const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, - int bits); -void slow_bitmap_shift_right(unsigned long *dst, - const unsigned long *src, int shift, int bits); -void slow_bitmap_shift_left(unsigned long *dst, - const unsigned long *src, int shift, int bits); -int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); -int slow_bitmap_intersects(const unsigned long *bitmap1, - const unsigned long *bitmap2, int bits); - -static inline unsigned long *bitmap_new(int nbits) -{ - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - return g_malloc0(len); -} - -static inline void bitmap_zero(unsigned long *dst, int nbits) -{ - if (small_nbits(nbits)) { - *dst = 0UL; - } else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0, len); - } -} - -static inline void bitmap_fill(unsigned long *dst, int nbits) -{ - size_t nlongs = BITS_TO_LONGS(nbits); - if (!small_nbits(nbits)) { - int len = (nlongs - 1) * sizeof(unsigned long); - memset(dst, 0xff, len); - } - dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); -} - -static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, - int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src; - } else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memcpy(dst, src, len); - } -} - -static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return (*dst = *src1 & *src2) != 0; - } - return slow_bitmap_and(dst, src1, src2, nbits); -} - -static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src1 | *src2; - } else { - slow_bitmap_or(dst, src1, src2, nbits); - } -} - -static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - *dst = *src1 ^ *src2; - } else { - slow_bitmap_xor(dst, src1, src2, nbits); - } -} - -static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return (*dst = *src1 & ~(*src2)) != 0; - } - return slow_bitmap_andnot(dst, src1, src2, nbits); -} - -static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, - int nbits) -{ - if (small_nbits(nbits)) { - *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); - } else { - slow_bitmap_complement(dst, src, nbits); - } -} - -static inline int bitmap_equal(const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_equal(src1, src2, nbits); - } -} - -static inline int bitmap_empty(const unsigned long *src, int nbits) -{ - if (small_nbits(nbits)) { - return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_empty(src, nbits); - } -} - -static inline int bitmap_full(const unsigned long *src, int nbits) -{ - if (small_nbits(nbits)) { - return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); - } else { - return slow_bitmap_full(src, nbits); - } -} - -static inline int bitmap_intersects(const unsigned long *src1, - const unsigned long *src2, int nbits) -{ - if (small_nbits(nbits)) { - return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; - } else { - return slow_bitmap_intersects(src1, src2, nbits); - } -} - -void bitmap_set(unsigned long *map, int i, int len); -void bitmap_clear(unsigned long *map, int start, int nr); -unsigned long bitmap_find_next_zero_area(unsigned long *map, - unsigned long size, - unsigned long start, - unsigned int nr, - unsigned long align_mask); - -#endif /* BITMAP_H */ diff --git a/bitops.c b/bitops.c index d9de71f7e8..4c3a836a01 100644 --- a/bitops.c +++ b/bitops.c @@ -11,7 +11,7 @@ * 2 of the License, or (at your option) any later version. */ -#include "bitops.h" +#include "qemu/bitops.h" #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) diff --git a/bitops.h b/bitops.h deleted file mode 100644 index 74e14e5724..0000000000 --- a/bitops.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * Bitops Module - * - * Copyright (C) 2010 Corentin Chary - * - * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef BITOPS_H -#define BITOPS_H - -#include "qemu-common.h" - -#define BITS_PER_BYTE CHAR_BIT -#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) - -#define BIT(nr) (1UL << (nr)) -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) - -/** - * bitops_ffs - find first bit in word. - * @word: The word to search - * - * Undefined if no bit exists, so code should check against 0 first. - */ -static unsigned long bitops_ffsl(unsigned long word) -{ - int num = 0; - -#if LONG_MAX > 0x7FFFFFFF - if ((word & 0xffffffff) == 0) { - num += 32; - word >>= 32; - } -#endif - if ((word & 0xffff) == 0) { - num += 16; - word >>= 16; - } - if ((word & 0xff) == 0) { - num += 8; - word >>= 8; - } - if ((word & 0xf) == 0) { - num += 4; - word >>= 4; - } - if ((word & 0x3) == 0) { - num += 2; - word >>= 2; - } - if ((word & 0x1) == 0) { - num += 1; - } - return num; -} - -/** - * bitops_fls - find last (most-significant) set bit in a long word - * @word: the word to search - * - * Undefined if no set bit exists, so code should check against 0 first. - */ -static inline unsigned long bitops_flsl(unsigned long word) -{ - int num = BITS_PER_LONG - 1; - -#if LONG_MAX > 0x7FFFFFFF - if (!(word & (~0ul << 32))) { - num -= 32; - word <<= 32; - } -#endif - if (!(word & (~0ul << (BITS_PER_LONG-16)))) { - num -= 16; - word <<= 16; - } - if (!(word & (~0ul << (BITS_PER_LONG-8)))) { - num -= 8; - word <<= 8; - } - if (!(word & (~0ul << (BITS_PER_LONG-4)))) { - num -= 4; - word <<= 4; - } - if (!(word & (~0ul << (BITS_PER_LONG-2)))) { - num -= 2; - - word <<= 2; - } - if (!(word & (~0ul << (BITS_PER_LONG-1)))) - num -= 1; - return num; -} - -/** - * ffz - find first zero in word. - * @word: The word to search - * - * Undefined if no zero exists, so code should check against ~0UL first. - */ -static inline unsigned long ffz(unsigned long word) -{ - return bitops_ffsl(~word); -} - -/** - * set_bit - Set a bit in memory - * @nr: the bit to set - * @addr: the address to start counting from - */ -static inline void set_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p |= mask; -} - -/** - * clear_bit - Clears a bit in memory - * @nr: Bit to clear - * @addr: Address to start counting from - */ -static inline void clear_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p &= ~mask; -} - -/** - * change_bit - Toggle a bit in memory - * @nr: Bit to change - * @addr: Address to start counting from - */ -static inline void change_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - - *p ^= mask; -} - -/** - * test_and_set_bit - Set a bit and return its old value - * @nr: Bit to set - * @addr: Address to count from - */ -static inline int test_and_set_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old | mask; - return (old & mask) != 0; -} - -/** - * test_and_clear_bit - Clear a bit and return its old value - * @nr: Bit to clear - * @addr: Address to count from - */ -static inline int test_and_clear_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old & ~mask; - return (old & mask) != 0; -} - -/** - * test_and_change_bit - Change a bit and return its old value - * @nr: Bit to change - * @addr: Address to count from - */ -static inline int test_and_change_bit(int nr, unsigned long *addr) -{ - unsigned long mask = BIT_MASK(nr); - unsigned long *p = addr + BIT_WORD(nr); - unsigned long old = *p; - - *p = old ^ mask; - return (old & mask) != 0; -} - -/** - * test_bit - Determine whether a bit is set - * @nr: bit number to test - * @addr: Address to start counting from - */ -static inline int test_bit(int nr, const unsigned long *addr) -{ - return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); -} - -/** - * find_last_bit - find the last set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first set bit, or size. - */ -unsigned long find_last_bit(const unsigned long *addr, - unsigned long size); - -/** - * find_next_bit - find the next set bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The bitmap size in bits - */ -unsigned long find_next_bit(const unsigned long *addr, - unsigned long size, unsigned long offset); - -/** - * find_next_zero_bit - find the next cleared bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The bitmap size in bits - */ - -unsigned long find_next_zero_bit(const unsigned long *addr, - unsigned long size, - unsigned long offset); - -/** - * find_first_bit - find the first set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first set bit. - */ -static inline unsigned long find_first_bit(const unsigned long *addr, - unsigned long size) -{ - return find_next_bit(addr, size, 0); -} - -/** - * find_first_zero_bit - find the first cleared bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit number of the first cleared bit. - */ -static inline unsigned long find_first_zero_bit(const unsigned long *addr, - unsigned long size) -{ - return find_next_zero_bit(addr, size, 0); -} - -static inline unsigned long hweight_long(unsigned long w) -{ - unsigned long count; - - for (count = 0; w; w >>= 1) { - count += w & 1; - } - return count; -} - -/** - * extract32: - * @value: the value to extract the bit field from - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * - * Extract from the 32 bit input @value the bit field specified by the - * @start and @length parameters, and return it. The bit field must - * lie entirely within the 32 bit word. It is valid to request that - * all 32 bits are returned (ie @length 32 and @start 0). - * - * Returns: the value of the bit field extracted from the input value. - */ -static inline uint32_t extract32(uint32_t value, int start, int length) -{ - assert(start >= 0 && length > 0 && length <= 32 - start); - return (value >> start) & (~0U >> (32 - length)); -} - -/** - * extract64: - * @value: the value to extract the bit field from - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * - * Extract from the 64 bit input @value the bit field specified by the - * @start and @length parameters, and return it. The bit field must - * lie entirely within the 64 bit word. It is valid to request that - * all 64 bits are returned (ie @length 64 and @start 0). - * - * Returns: the value of the bit field extracted from the input value. - */ -static inline uint64_t extract64(uint64_t value, int start, int length) -{ - assert(start >= 0 && length > 0 && length <= 64 - start); - return (value >> start) & (~0ULL >> (64 - length)); -} - -/** - * deposit32: - * @value: initial value to insert bit field into - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * @fieldval: the value to insert into the bit field - * - * Deposit @fieldval into the 32 bit @value at the bit field specified - * by the @start and @length parameters, and return the modified - * @value. Bits of @value outside the bit field are not modified. - * Bits of @fieldval above the least significant @length bits are - * ignored. The bit field must lie entirely within the 32 bit word. - * It is valid to request that all 32 bits are modified (ie @length - * 32 and @start 0). - * - * Returns: the modified @value. - */ -static inline uint32_t deposit32(uint32_t value, int start, int length, - uint32_t fieldval) -{ - uint32_t mask; - assert(start >= 0 && length > 0 && length <= 32 - start); - mask = (~0U >> (32 - length)) << start; - return (value & ~mask) | ((fieldval << start) & mask); -} - -/** - * deposit64: - * @value: initial value to insert bit field into - * @start: the lowest bit in the bit field (numbered from 0) - * @length: the length of the bit field - * @fieldval: the value to insert into the bit field - * - * Deposit @fieldval into the 64 bit @value at the bit field specified - * by the @start and @length parameters, and return the modified - * @value. Bits of @value outside the bit field are not modified. - * Bits of @fieldval above the least significant @length bits are - * ignored. The bit field must lie entirely within the 64 bit word. - * It is valid to request that all 64 bits are modified (ie @length - * 64 and @start 0). - * - * Returns: the modified @value. - */ -static inline uint64_t deposit64(uint64_t value, int start, int length, - uint64_t fieldval) -{ - uint64_t mask; - assert(start >= 0 && length > 0 && length <= 64 - start); - mask = (~0ULL >> (64 - length)) << start; - return (value & ~mask) | ((fieldval << start) & mask); -} - -#endif diff --git a/block-migration.c b/block-migration.c index 2d2dcbda94..4e865a6781 100644 --- a/block-migration.c +++ b/block-migration.c @@ -16,8 +16,8 @@ #include "qemu-common.h" #include "block/block_int.h" #include "hw/hw.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "migration/block.h" #include "migration/migration.h" #include "blockdev.h" diff --git a/block.c b/block.c index 0e7f18c6d3..1af4b99ee8 100644 --- a/block.c +++ b/block.c @@ -27,13 +27,13 @@ #include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp/qjson.h" #include "sysemu.h" -#include "notify.h" +#include "qemu/notify.h" #include "block/coroutine.h" #include "qmp-commands.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_BSD #include diff --git a/block/blkdebug.c b/block/blkdebug.c index cd2866e7bd..6f7463772b 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -23,9 +23,9 @@ */ #include "qemu-common.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" typedef struct BDRVBlkdebugState { int state; diff --git a/block/blkverify.c b/block/blkverify.c index cde5098e5a..a7dd45909b 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -8,7 +8,7 @@ */ #include -#include "qemu_socket.h" /* for EINPROGRESS on Windows */ +#include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "block/block_int.h" typedef struct { diff --git a/block/bochs.c b/block/bochs.c index 2cc7524782..1b1d9cdbe5 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -24,7 +24,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ diff --git a/block/cloop.c b/block/cloop.c index da29ff379c..5a0d0d805f 100644 --- a/block/cloop.c +++ b/block/cloop.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include typedef struct BDRVCloopState { diff --git a/block/cow.c b/block/cow.c index 1438ae1e3b..a33ce950d4 100644 --- a/block/cow.c +++ b/block/cow.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ /* COW block driver using file system holes */ diff --git a/block/dmg.c b/block/dmg.c index 6ee505a9f5..ac397dc8f7 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -23,8 +23,8 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "bswap.h" -#include "module.h" +#include "qemu/bswap.h" +#include "qemu/module.h" #include typedef struct BDRVDMGState { diff --git a/block/gluster.c b/block/gluster.c index 4cb4e60227..0f2c32a3fa 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -17,8 +17,8 @@ */ #include #include "block/block_int.h" -#include "qemu_socket.h" -#include "uri.h" +#include "qemu/sockets.h" +#include "qemu/uri.h" typedef struct GlusterAIOCB { BlockDriverAIOCB common; diff --git a/block/iscsi.c b/block/iscsi.c index 77e619a1fd..041ee07de3 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -27,8 +27,8 @@ #include #include #include "qemu-common.h" -#include "qemu-config.h" -#include "qemu-error.h" +#include "qemu/config-file.h" +#include "qemu/error-report.h" #include "block/block_int.h" #include "trace.h" #include "hw/scsi-defs.h" diff --git a/block/linux-aio.c b/block/linux-aio.c index 28e5a04e12..ee0f8d10c9 100644 --- a/block/linux-aio.c +++ b/block/linux-aio.c @@ -9,9 +9,9 @@ */ #include "qemu-common.h" #include "block/aio.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/raw-aio.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include diff --git a/block/nbd.c b/block/nbd.c index 38d6b90ab2..a5812948d2 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -28,10 +28,10 @@ #include "qemu-common.h" #include "block/nbd.h" -#include "uri.h" +#include "qemu/uri.h" #include "block/block_int.h" -#include "module.h" -#include "qemu_socket.h" +#include "qemu/module.h" +#include "qemu/sockets.h" #include #include diff --git a/block/parallels.c b/block/parallels.c index ae88cd6359..377375046f 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" /**************************************************************/ diff --git a/block/qcow.c b/block/qcow.c index f36671196e..4276610afd 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include #include "block/aes.h" #include "migration/migration.h" diff --git a/block/qcow2.c b/block/qcow2.c index 205d910a52..d603f98a9c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -23,11 +23,11 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include #include "block/aes.h" #include "block/qcow2.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/qmp/qerror.h" #include "trace.h" diff --git a/block/qed-table.c b/block/qed-table.c index de845ec3d0..76d2dcccf8 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -13,7 +13,7 @@ */ #include "trace.h" -#include "qemu_socket.h" /* for EINPROGRESS on Windows */ +#include "qemu/sockets.h" /* for EINPROGRESS on Windows */ #include "qed.h" typedef struct { diff --git a/block/qed.c b/block/qed.c index 10d0827482..cf85d8f2b4 100644 --- a/block/qed.c +++ b/block/qed.c @@ -12,7 +12,7 @@ * */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "trace.h" #include "qed.h" #include "qapi/qmp/qerror.h" diff --git a/block/raw-posix.c b/block/raw-posix.c index 4e73885269..91159c7887 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "trace.h" #include "block/thread-pool.h" -#include "iov.h" +#include "qemu/iov.h" #include "raw-aio.h" #if defined(__APPLE__) && (__MACH__) diff --git a/block/raw-win32.c b/block/raw-win32.c index 9269fe84c0..f58334be08 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "raw-aio.h" #include "trace.h" #include "block/thread-pool.h" -#include "iov.h" +#include "qemu/iov.h" #include #include diff --git a/block/raw.c b/block/raw.c index 6aec93dadb..75812db3c2 100644 --- a/block/raw.c +++ b/block/raw.c @@ -1,7 +1,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" static int raw_open(BlockDriverState *bs, int flags) { diff --git a/block/rbd.c b/block/rbd.c index 8def2f174c..8cd10a7b59 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -14,7 +14,7 @@ #include #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "block/block_int.h" #include diff --git a/block/sheepdog.c b/block/sheepdog.c index da70df2d00..13dc023fdb 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -13,10 +13,10 @@ */ #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu_socket.h" +#include "qemu/error-report.h" +#include "qemu/sockets.h" #include "block/block_int.h" -#include "bitops.h" +#include "qemu/bitops.h" #define SD_PROTO_VER 0x01 diff --git a/block/vdi.c b/block/vdi.c index b1d199a2e5..7b6231941b 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -51,7 +51,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #if defined(CONFIG_UUID) diff --git a/block/vmdk.c b/block/vmdk.c index 77a1a67c61..19298c2a3e 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #include diff --git a/block/vpc.c b/block/vpc.c index 47b5518aee..7948609e50 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -24,7 +24,7 @@ */ #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #if defined(CONFIG_UUID) #include diff --git a/block/vvfat.c b/block/vvfat.c index a63c3ea7cd..83706ce556 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -26,7 +26,7 @@ #include #include "qemu-common.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "migration/migration.h" #ifndef S_IWGRP diff --git a/block/win32-aio.c b/block/win32-aio.c index 606e4d6925..46a5db78cc 100644 --- a/block/win32-aio.c +++ b/block/win32-aio.c @@ -22,13 +22,13 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block_int.h" -#include "module.h" +#include "qemu/module.h" #include "qemu-common.h" #include "block/aio.h" #include "raw-aio.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include #include diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 596b47499d..95b621699a 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -17,7 +17,7 @@ #include "qmp-commands.h" #include "trace.h" #include "block/nbd.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" static int server_fd = -1; diff --git a/blockdev.c b/blockdev.c index a2308fa718..3ebff44310 100644 --- a/blockdev.c +++ b/blockdev.c @@ -12,8 +12,8 @@ #include "block/blockjob.h" #include "monitor/monitor.h" #include "qapi/qmp/qerror.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qapi/qmp/types.h" #include "sysemu.h" #include "block/block_int.h" diff --git a/blockdev.h b/blockdev.h index 4134864758..1fe533299e 100644 --- a/blockdev.h +++ b/blockdev.h @@ -12,7 +12,7 @@ #include "block/block.h" #include "qapi/error.h" -#include "qemu-queue.h" +#include "qemu/queue.h" void blockdev_mark_auto_del(BlockDriverState *bs); void blockdev_auto_del(BlockDriverState *bs); diff --git a/blockjob.c b/blockjob.c index 4bc60c7378..ca80df1d0e 100644 --- a/blockjob.c +++ b/blockjob.c @@ -33,7 +33,7 @@ #include "qapi/qmp/qjson.h" #include "block/coroutine.h" #include "qmp-commands.h" -#include "qemu-timer.h" +#include "qemu/timer.h" void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, diff --git a/bsd-user/main.c b/bsd-user/main.c index 095ae8eaaa..1dc033046b 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -31,8 +31,8 @@ /* For tb_lock */ #include "cpu.h" #include "tcg.h" -#include "qemu-timer.h" -#include "envlist.h" +#include "qemu/timer.h" +#include "qemu/envlist.h" #define DEBUG_LOGFILE "/tmp/qemu.log" diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c64c3ccca3..a826086dab 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -146,7 +146,7 @@ int get_osversion(void); void fork_start(void); void fork_end(int child); -#include "qemu-log.h" +#include "qemu/log.h" /* strace.c */ void diff --git a/bswap.h b/bswap.h deleted file mode 100644 index cc7f84d30f..0000000000 --- a/bswap.h +++ /dev/null @@ -1,713 +0,0 @@ -#ifndef BSWAP_H -#define BSWAP_H - -#include "config-host.h" - -#include -#include "softfloat.h" - -#ifdef CONFIG_MACHINE_BSWAP_H -#include -#include -#include -#else - -#ifdef CONFIG_BYTESWAP_H -#include -#else - -#define bswap_16(x) \ -({ \ - uint16_t __x = (x); \ - ((uint16_t)( \ - (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ - (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ -}) - -#define bswap_32(x) \ -({ \ - uint32_t __x = (x); \ - ((uint32_t)( \ - (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ - (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ - (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ -}) - -#define bswap_64(x) \ -({ \ - uint64_t __x = (x); \ - ((uint64_t)( \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ - (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ -}) - -#endif /* !CONFIG_BYTESWAP_H */ - -static inline uint16_t bswap16(uint16_t x) -{ - return bswap_16(x); -} - -static inline uint32_t bswap32(uint32_t x) -{ - return bswap_32(x); -} - -static inline uint64_t bswap64(uint64_t x) -{ - return bswap_64(x); -} - -#endif /* ! CONFIG_MACHINE_BSWAP_H */ - -static inline void bswap16s(uint16_t *s) -{ - *s = bswap16(*s); -} - -static inline void bswap32s(uint32_t *s) -{ - *s = bswap32(*s); -} - -static inline void bswap64s(uint64_t *s) -{ - *s = bswap64(*s); -} - -#if defined(HOST_WORDS_BIGENDIAN) -#define be_bswap(v, size) (v) -#define le_bswap(v, size) bswap ## size(v) -#define be_bswaps(v, size) -#define le_bswaps(p, size) *p = bswap ## size(*p); -#else -#define le_bswap(v, size) (v) -#define be_bswap(v, size) bswap ## size(v) -#define le_bswaps(v, size) -#define be_bswaps(p, size) *p = bswap ## size(*p); -#endif - -#define CPU_CONVERT(endian, size, type)\ -static inline type endian ## size ## _to_cpu(type v)\ -{\ - return endian ## _bswap(v, size);\ -}\ -\ -static inline type cpu_to_ ## endian ## size(type v)\ -{\ - return endian ## _bswap(v, size);\ -}\ -\ -static inline void endian ## size ## _to_cpus(type *p)\ -{\ - endian ## _bswaps(p, size)\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## s(type *p)\ -{\ - endian ## _bswaps(p, size)\ -}\ -\ -static inline type endian ## size ## _to_cpup(const type *p)\ -{\ - return endian ## size ## _to_cpu(*p);\ -}\ -\ -static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ -{\ - *p = cpu_to_ ## endian ## size(v);\ -} - -CPU_CONVERT(be, 16, uint16_t) -CPU_CONVERT(be, 32, uint32_t) -CPU_CONVERT(be, 64, uint64_t) - -CPU_CONVERT(le, 16, uint16_t) -CPU_CONVERT(le, 32, uint32_t) -CPU_CONVERT(le, 64, uint64_t) - -/* unaligned versions (optimized for frequent unaligned accesses)*/ - -#if defined(__i386__) || defined(_ARCH_PPC) - -#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v) -#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v) -#define le16_to_cpupu(p) le16_to_cpup(p) -#define le32_to_cpupu(p) le32_to_cpup(p) -#define be32_to_cpupu(p) be32_to_cpup(p) - -#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) -#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) -#define cpu_to_be64wu(p, v) cpu_to_be64w(p, v) - -#else - -static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v & 0xff; - p1[1] = v >> 8; -} - -static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v & 0xff; - p1[1] = v >> 8; - p1[2] = v >> 16; - p1[3] = v >> 24; -} - -static inline uint16_t le16_to_cpupu(const uint16_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[0] | (p1[1] << 8); -} - -static inline uint32_t le32_to_cpupu(const uint32_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); -} - -static inline uint32_t be32_to_cpupu(const uint32_t *p) -{ - const uint8_t *p1 = (const uint8_t *)p; - return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24); -} - -static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 8; - p1[1] = v & 0xff; -} - -static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 24; - p1[1] = v >> 16; - p1[2] = v >> 8; - p1[3] = v & 0xff; -} - -static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) -{ - uint8_t *p1 = (uint8_t *)p; - - p1[0] = v >> 56; - p1[1] = v >> 48; - p1[2] = v >> 40; - p1[3] = v >> 32; - p1[4] = v >> 24; - p1[5] = v >> 16; - p1[6] = v >> 8; - p1[7] = v & 0xff; -} - -#endif - -#ifdef HOST_WORDS_BIGENDIAN -#define cpu_to_32wu cpu_to_be32wu -#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v) -#else -#define cpu_to_32wu cpu_to_le32wu -#define leul_to_cpu(v) (v) -#endif - -#undef le_bswap -#undef be_bswap -#undef le_bswaps -#undef be_bswaps - -/* len must be one of 1, 2, 4 */ -static inline uint32_t qemu_bswap_len(uint32_t value, int len) -{ - return bswap32(value) >> (32 - 8 * len); -} - -typedef union { - float32 f; - uint32_t l; -} CPU_FloatU; - -typedef union { - float64 d; -#if defined(HOST_WORDS_BIGENDIAN) - struct { - uint32_t upper; - uint32_t lower; - } l; -#else - struct { - uint32_t lower; - uint32_t upper; - } l; -#endif - uint64_t ll; -} CPU_DoubleU; - -typedef union { - floatx80 d; - struct { - uint64_t lower; - uint16_t upper; - } l; -} CPU_LDoubleU; - -typedef union { - float128 q; -#if defined(HOST_WORDS_BIGENDIAN) - struct { - uint32_t upmost; - uint32_t upper; - uint32_t lower; - uint32_t lowest; - } l; - struct { - uint64_t upper; - uint64_t lower; - } ll; -#else - struct { - uint32_t lowest; - uint32_t lower; - uint32_t upper; - uint32_t upmost; - } l; - struct { - uint64_t lower; - uint64_t upper; - } ll; -#endif -} CPU_QuadU; - -/* unaligned/endian-independent pointer access */ - -/* - * the generic syntax is: - * - * load: ld{type}{sign}{size}{endian}_p(ptr) - * - * store: st{type}{size}{endian}_p(ptr, val) - * - * Note there are small differences with the softmmu access API! - * - * type is: - * (empty): integer access - * f : float access - * - * sign is: - * (empty): for floats or 32 bit size - * u : unsigned - * s : signed - * - * size is: - * b: 8 bits - * w: 16 bits - * l: 32 bits - * q: 64 bits - * - * endian is: - * (empty): 8 bit access - * be : big endian - * le : little endian - */ -static inline int ldub_p(const void *ptr) -{ - return *(uint8_t *)ptr; -} - -static inline int ldsb_p(const void *ptr) -{ - return *(int8_t *)ptr; -} - -static inline void stb_p(void *ptr, int v) -{ - *(uint8_t *)ptr = v; -} - -/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the - kernel handles unaligned load/stores may give better results, but - it is a system wide setting : bad */ -#if defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) - -/* conservative code for little endian unaligned accesses */ -static inline int lduw_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return val; -#else - const uint8_t *p = ptr; - return p[0] | (p[1] << 8); -#endif -} - -static inline int ldsw_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return (int16_t)val; -#else - const uint8_t *p = ptr; - return (int16_t)(p[0] | (p[1] << 8)); -#endif -} - -static inline int ldl_le_p(const void *ptr) -{ -#ifdef _ARCH_PPC - int val; - __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); - return val; -#else - const uint8_t *p = ptr; - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); -#endif -} - -static inline uint64_t ldq_le_p(const void *ptr) -{ - const uint8_t *p = ptr; - uint32_t v1, v2; - v1 = ldl_le_p(p); - v2 = ldl_le_p(p + 4); - return v1 | ((uint64_t)v2 << 32); -} - -static inline void stw_le_p(void *ptr, int v) -{ -#ifdef _ARCH_PPC - __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); -#else - uint8_t *p = ptr; - p[0] = v; - p[1] = v >> 8; -#endif -} - -static inline void stl_le_p(void *ptr, int v) -{ -#ifdef _ARCH_PPC - __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); -#else - uint8_t *p = ptr; - p[0] = v; - p[1] = v >> 8; - p[2] = v >> 16; - p[3] = v >> 24; -#endif -} - -static inline void stq_le_p(void *ptr, uint64_t v) -{ - uint8_t *p = ptr; - stl_le_p(p, (uint32_t)v); - stl_le_p(p + 4, v >> 32); -} - -/* float access */ - -static inline float32 ldfl_le_p(const void *ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = ldl_le_p(ptr); - return u.f; -} - -static inline void stfl_le_p(void *ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - stl_le_p(ptr, u.i); -} - -static inline float64 ldfq_le_p(const void *ptr) -{ - CPU_DoubleU u; - u.l.lower = ldl_le_p(ptr); - u.l.upper = ldl_le_p(ptr + 4); - return u.d; -} - -static inline void stfq_le_p(void *ptr, float64 v) -{ - CPU_DoubleU u; - u.d = v; - stl_le_p(ptr, u.l.lower); - stl_le_p(ptr + 4, u.l.upper); -} - -#else - -static inline int lduw_le_p(const void *ptr) -{ - return *(uint16_t *)ptr; -} - -static inline int ldsw_le_p(const void *ptr) -{ - return *(int16_t *)ptr; -} - -static inline int ldl_le_p(const void *ptr) -{ - return *(uint32_t *)ptr; -} - -static inline uint64_t ldq_le_p(const void *ptr) -{ - return *(uint64_t *)ptr; -} - -static inline void stw_le_p(void *ptr, int v) -{ - *(uint16_t *)ptr = v; -} - -static inline void stl_le_p(void *ptr, int v) -{ - *(uint32_t *)ptr = v; -} - -static inline void stq_le_p(void *ptr, uint64_t v) -{ - *(uint64_t *)ptr = v; -} - -/* float access */ - -static inline float32 ldfl_le_p(const void *ptr) -{ - return *(float32 *)ptr; -} - -static inline float64 ldfq_le_p(const void *ptr) -{ - return *(float64 *)ptr; -} - -static inline void stfl_le_p(void *ptr, float32 v) -{ - *(float32 *)ptr = v; -} - -static inline void stfq_le_p(void *ptr, float64 v) -{ - *(float64 *)ptr = v; -} -#endif - -#if !defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) - -static inline int lduw_be_p(const void *ptr) -{ -#if defined(__i386__) - int val; - asm volatile ("movzwl %1, %0\n" - "xchgb %b0, %h0\n" - : "=q" (val) - : "m" (*(uint16_t *)ptr)); - return val; -#else - const uint8_t *b = ptr; - return ((b[0] << 8) | b[1]); -#endif -} - -static inline int ldsw_be_p(const void *ptr) -{ -#if defined(__i386__) - int val; - asm volatile ("movzwl %1, %0\n" - "xchgb %b0, %h0\n" - : "=q" (val) - : "m" (*(uint16_t *)ptr)); - return (int16_t)val; -#else - const uint8_t *b = ptr; - return (int16_t)((b[0] << 8) | b[1]); -#endif -} - -static inline int ldl_be_p(const void *ptr) -{ -#if defined(__i386__) || defined(__x86_64__) - int val; - asm volatile ("movl %1, %0\n" - "bswap %0\n" - : "=r" (val) - : "m" (*(uint32_t *)ptr)); - return val; -#else - const uint8_t *b = ptr; - return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; -#endif -} - -static inline uint64_t ldq_be_p(const void *ptr) -{ - uint32_t a,b; - a = ldl_be_p(ptr); - b = ldl_be_p((uint8_t *)ptr + 4); - return (((uint64_t)a<<32)|b); -} - -static inline void stw_be_p(void *ptr, int v) -{ -#if defined(__i386__) - asm volatile ("xchgb %b0, %h0\n" - "movw %w0, %1\n" - : "=q" (v) - : "m" (*(uint16_t *)ptr), "0" (v)); -#else - uint8_t *d = (uint8_t *) ptr; - d[0] = v >> 8; - d[1] = v; -#endif -} - -static inline void stl_be_p(void *ptr, int v) -{ -#if defined(__i386__) || defined(__x86_64__) - asm volatile ("bswap %0\n" - "movl %0, %1\n" - : "=r" (v) - : "m" (*(uint32_t *)ptr), "0" (v)); -#else - uint8_t *d = (uint8_t *) ptr; - d[0] = v >> 24; - d[1] = v >> 16; - d[2] = v >> 8; - d[3] = v; -#endif -} - -static inline void stq_be_p(void *ptr, uint64_t v) -{ - stl_be_p(ptr, v >> 32); - stl_be_p((uint8_t *)ptr + 4, v); -} - -/* float access */ - -static inline float32 ldfl_be_p(const void *ptr) -{ - union { - float32 f; - uint32_t i; - } u; - u.i = ldl_be_p(ptr); - return u.f; -} - -static inline void stfl_be_p(void *ptr, float32 v) -{ - union { - float32 f; - uint32_t i; - } u; - u.f = v; - stl_be_p(ptr, u.i); -} - -static inline float64 ldfq_be_p(const void *ptr) -{ - CPU_DoubleU u; - u.l.upper = ldl_be_p(ptr); - u.l.lower = ldl_be_p((uint8_t *)ptr + 4); - return u.d; -} - -static inline void stfq_be_p(void *ptr, float64 v) -{ - CPU_DoubleU u; - u.d = v; - stl_be_p(ptr, u.l.upper); - stl_be_p((uint8_t *)ptr + 4, u.l.lower); -} - -#else - -static inline int lduw_be_p(const void *ptr) -{ - return *(uint16_t *)ptr; -} - -static inline int ldsw_be_p(const void *ptr) -{ - return *(int16_t *)ptr; -} - -static inline int ldl_be_p(const void *ptr) -{ - return *(uint32_t *)ptr; -} - -static inline uint64_t ldq_be_p(const void *ptr) -{ - return *(uint64_t *)ptr; -} - -static inline void stw_be_p(void *ptr, int v) -{ - *(uint16_t *)ptr = v; -} - -static inline void stl_be_p(void *ptr, int v) -{ - *(uint32_t *)ptr = v; -} - -static inline void stq_be_p(void *ptr, uint64_t v) -{ - *(uint64_t *)ptr = v; -} - -/* float access */ - -static inline float32 ldfl_be_p(const void *ptr) -{ - return *(float32 *)ptr; -} - -static inline float64 ldfq_be_p(const void *ptr) -{ - return *(float64 *)ptr; -} - -static inline void stfl_be_p(void *ptr, float32 v) -{ - *(float32 *)ptr = v; -} - -static inline void stfq_be_p(void *ptr, float64 v) -{ - *(float64 *)ptr = v; -} - -#endif - -#endif /* BSWAP_H */ diff --git a/bt-host.c b/bt-host.c index 65aaca337c..4f5f9f93c5 100644 --- a/bt-host.c +++ b/bt-host.c @@ -19,7 +19,7 @@ #include "qemu-common.h" #include "bt-host.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef _WIN32 # include diff --git a/bt-vhci.c b/bt-vhci.c index 13c0e53729..f5d856a809 100644 --- a/bt-vhci.c +++ b/bt-vhci.c @@ -20,7 +20,7 @@ #include "qemu-common.h" #include "bt-host.h" #include "hw/bt.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #define VHCI_DEV "/dev/vhci" #define VHCI_UDEV "/dev/hci_vhci" diff --git a/buffered_file.c b/buffered_file.c index f13443ee91..27627a1b71 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -15,7 +15,7 @@ #include "qemu-common.h" #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "buffered_file.h" //#define DEBUG_BUFFERED_FILE diff --git a/cache-utils.c b/cache-utils.c index 2db5af2db1..b94013a8cb 100644 --- a/cache-utils.c +++ b/cache-utils.c @@ -1,4 +1,4 @@ -#include "cache-utils.h" +#include "qemu/cache-utils.h" #if defined(_ARCH_PPC) struct qemu_cache_conf qemu_cache_conf = { diff --git a/cache-utils.h b/cache-utils.h deleted file mode 100644 index 2c57f78fc1..0000000000 --- a/cache-utils.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef QEMU_CACHE_UTILS_H -#define QEMU_CACHE_UTILS_H - -#if defined(_ARCH_PPC) - -#include /* uintptr_t */ - -struct qemu_cache_conf { - unsigned long dcache_bsize; - unsigned long icache_bsize; -}; - -extern struct qemu_cache_conf qemu_cache_conf; - -void qemu_cache_utils_init(char **envp); - -/* mildly adjusted code from tcg-dyngen.c */ -static inline void flush_icache_range(uintptr_t start, uintptr_t stop) -{ - unsigned long p, start1, stop1; - unsigned long dsize = qemu_cache_conf.dcache_bsize; - unsigned long isize = qemu_cache_conf.icache_bsize; - - start1 = start & ~(dsize - 1); - stop1 = (stop + dsize - 1) & ~(dsize - 1); - for (p = start1; p < stop1; p += dsize) { - asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - - start &= start & ~(isize - 1); - stop1 = (stop + isize - 1) & ~(isize - 1); - for (p = start1; p < stop1; p += isize) { - asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); - } - asm volatile ("sync" : : : "memory"); - asm volatile ("isync" : : : "memory"); -} - -#else -#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) -#endif - -#endif /* QEMU_CACHE_UTILS_H */ diff --git a/cmd.c b/cmd.c index 01a8c3a299..10a8688b2d 100644 --- a/cmd.c +++ b/cmd.c @@ -25,7 +25,7 @@ #include "cmd.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #define _(x) x /* not gettext support yet */ diff --git a/compatfd.c b/compatfd.c index 42f81cafe4..9cf3f2834d 100644 --- a/compatfd.c +++ b/compatfd.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "compatfd.h" +#include "qemu/compatfd.h" #include #include diff --git a/compatfd.h b/compatfd.h deleted file mode 100644 index 6b04877b97..0000000000 --- a/compatfd.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * signalfd/eventfd compatibility - * - * Copyright IBM, Corp. 2008 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_COMPATFD_H -#define QEMU_COMPATFD_H - -#include - -struct qemu_signalfd_siginfo { - uint32_t ssi_signo; /* Signal number */ - int32_t ssi_errno; /* Error number (unused) */ - int32_t ssi_code; /* Signal code */ - uint32_t ssi_pid; /* PID of sender */ - uint32_t ssi_uid; /* Real UID of sender */ - int32_t ssi_fd; /* File descriptor (SIGIO) */ - uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */ - uint32_t ssi_band; /* Band event (SIGIO) */ - uint32_t ssi_overrun; /* POSIX timer overrun count */ - uint32_t ssi_trapno; /* Trap number that caused signal */ - int32_t ssi_status; /* Exit status or signal (SIGCHLD) */ - int32_t ssi_int; /* Integer sent by sigqueue(2) */ - uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */ - uint64_t ssi_utime; /* User CPU time consumed (SIGCHLD) */ - uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ - uint64_t ssi_addr; /* Address that generated signal - (for hardware-generated signals) */ - uint8_t pad[48]; /* Pad size to 128 bytes (allow for - additional fields in the future) */ -}; - -int qemu_signalfd(const sigset_t *mask); -bool qemu_signalfd_available(void); - -#endif diff --git a/compiler.h b/compiler.h deleted file mode 100644 index 2f7998b6c1..0000000000 --- a/compiler.h +++ /dev/null @@ -1,58 +0,0 @@ -/* public domain */ - -#ifndef COMPILER_H -#define COMPILER_H - -#include "config-host.h" - -/*---------------------------------------------------------------------------- -| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. -| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. -*----------------------------------------------------------------------------*/ -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define QEMU_GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -# define QEMU_GNUC_PREREQ(maj, min) 0 -#endif - -#define QEMU_NORETURN __attribute__ ((__noreturn__)) - -#if QEMU_GNUC_PREREQ(3, 4) -#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define QEMU_WARN_UNUSED_RESULT -#endif - -#if defined(_WIN32) -# define QEMU_PACKED __attribute__((gcc_struct, packed)) -#else -# define QEMU_PACKED __attribute__((packed)) -#endif - -#define cat(x,y) x ## y -#define cat2(x,y) cat(x,y) -#define QEMU_BUILD_BUG_ON(x) \ - typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1]; - -#if defined __GNUC__ -# if !QEMU_GNUC_PREREQ(4, 4) - /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ -# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) -# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) -# else - /* Use gnu_printf when supported (qemu uses standard format strings). */ -# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) -# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) -# if defined(_WIN32) - /* Map __printf__ to __gnu_printf__ because we want standard format strings - * even when MinGW or GLib include files use __printf__. */ -# define __printf__ __gnu_printf__ -# endif -# endif -#else -#define GCC_ATTR /**/ -#define GCC_FMT_ATTR(n, m) -#endif - -#endif /* COMPILER_H */ diff --git a/cpu-exec.c b/cpu-exec.c index b5a32b84e4..54e62ed551 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg.h" -#include "qemu-barrier.h" +#include "qemu/atomic.h" #include "qtest.h" int tb_invalidated_flag; diff --git a/cpus.c b/cpus.c index 3a66401e0d..036418d62c 100644 --- a/cpus.c +++ b/cpus.c @@ -32,14 +32,14 @@ #include "kvm.h" #include "qmp-commands.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "cpus.h" #include "qtest.h" -#include "main-loop.h" -#include "bitmap.h" +#include "qemu/main-loop.h" +#include "qemu/bitmap.h" #ifndef _WIN32 -#include "compatfd.h" +#include "qemu/compatfd.h" #endif #ifdef CONFIG_LINUX diff --git a/cutils.c b/cutils.c index 4f0692f78e..d06590b330 100644 --- a/cutils.c +++ b/cutils.c @@ -22,11 +22,11 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include -#include "qemu_socket.h" -#include "iov.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" void strpadcpy(char *buf, int buf_size, const char *str, char pad) { diff --git a/device_tree.c b/device_tree.c index a9236133c7..c3e1ba4904 100644 --- a/device_tree.c +++ b/device_tree.c @@ -22,8 +22,8 @@ #include "qemu-common.h" #include "device_tree.h" #include "hw/loader.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include diff --git a/dma-helpers.c b/dma-helpers.c index 4f5fb649e7..e6a6dd82fd 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -9,8 +9,8 @@ #include "dma.h" #include "trace.h" -#include "range.h" -#include "qemu-thread.h" +#include "qemu/range.h" +#include "qemu/thread.h" /* #define DEBUG_IOMMU */ diff --git a/envlist.c b/envlist.c index f2303cdd79..ff99fc44e9 100644 --- a/envlist.c +++ b/envlist.c @@ -4,8 +4,8 @@ #include #include -#include "qemu-queue.h" -#include "envlist.h" +#include "qemu/queue.h" +#include "qemu/envlist.h" struct envlist_entry { const char *ev_var; /* actual env value */ diff --git a/envlist.h b/envlist.h deleted file mode 100644 index b9addcc11f..0000000000 --- a/envlist.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ENVLIST_H -#define ENVLIST_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct envlist envlist_t; - -envlist_t *envlist_create(void); -void envlist_free(envlist_t *); -int envlist_setenv(envlist_t *, const char *); -int envlist_unsetenv(envlist_t *, const char *); -int envlist_parse_set(envlist_t *, const char *); -int envlist_parse_unset(envlist_t *, const char *); -char **envlist_to_environ(const envlist_t *, size_t *); - -#ifdef __cplusplus -} -#endif - -#endif /* ENVLIST_H */ diff --git a/event_notifier-posix.c b/event_notifier-posix.c index f0bd839acd..a53b95688d 100644 --- a/event_notifier-posix.c +++ b/event_notifier-posix.c @@ -11,9 +11,9 @@ */ #include "qemu-common.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "qemu-char.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifdef CONFIG_EVENTFD #include diff --git a/event_notifier-win32.c b/event_notifier-win32.c index 4ed21c2a7c..6dbb530cfa 100644 --- a/event_notifier-win32.c +++ b/event_notifier-win32.c @@ -11,8 +11,8 @@ */ #include "qemu-common.h" -#include "event_notifier.h" -#include "main-loop.h" +#include "qemu/event_notifier.h" +#include "qemu/main-loop.h" int event_notifier_init(EventNotifier *e, int active) { diff --git a/event_notifier.h b/event_notifier.h deleted file mode 100644 index 88b57af7ce..0000000000 --- a/event_notifier.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * event notifier support - * - * Copyright Red Hat, Inc. 2010 - * - * Authors: - * Michael S. Tsirkin - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_EVENT_NOTIFIER_H -#define QEMU_EVENT_NOTIFIER_H - -#include "qemu-common.h" - -#ifdef _WIN32 -#include -#endif - -struct EventNotifier { -#ifdef _WIN32 - HANDLE event; -#else - int rfd; - int wfd; -#endif -}; - -typedef void EventNotifierHandler(EventNotifier *); - -int event_notifier_init(EventNotifier *, int active); -void event_notifier_cleanup(EventNotifier *); -int event_notifier_set(EventNotifier *); -int event_notifier_test_and_clear(EventNotifier *); -int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); - -#ifdef CONFIG_POSIX -void event_notifier_init_fd(EventNotifier *, int fd); -int event_notifier_get_fd(EventNotifier *); -#else -HANDLE event_notifier_get_handle(EventNotifier *); -#endif - -#endif diff --git a/exec.c b/exec.c index 17fc7cf854..917bec0ecd 100644 --- a/exec.c +++ b/exec.c @@ -29,11 +29,11 @@ #include "tcg.h" #include "hw/hw.h" #include "hw/qdev.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "kvm.h" #include "hw/xen.h" -#include "qemu-timer.h" -#include "qemu-config.h" +#include "qemu/timer.h" +#include "qemu/config-file.h" #include "exec/memory.h" #include "dma.h" #include "exec/address-spaces.h" diff --git a/fpu/softfloat.h b/fpu/softfloat.h index d8999b311a..0946f0739d 100644 --- a/fpu/softfloat.h +++ b/fpu/softfloat.h @@ -44,7 +44,7 @@ these four paragraphs for those parts of this code that are retained. #include #include "config-host.h" -#include "osdep.h" +#include "qemu/osdep.h" /*---------------------------------------------------------------------------- | Each of the following `typedef's defines the most convenient type that holds diff --git a/fsdev/qemu-fsdev-dummy.c b/fsdev/qemu-fsdev-dummy.c index 300f2758be..4bcf38fe4b 100644 --- a/fsdev/qemu-fsdev-dummy.c +++ b/fsdev/qemu-fsdev-dummy.c @@ -13,8 +13,8 @@ #include #include #include "qemu-fsdev.h" -#include "qemu-config.h" -#include "module.h" +#include "qemu/config-file.h" +#include "qemu/module.h" int qemu_fsdev_add(QemuOpts *opts) { diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index e20202a4bf..4cc04d4fde 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -13,10 +13,10 @@ #include #include #include "qemu-fsdev.h" -#include "qemu-queue.h" -#include "osdep.h" +#include "qemu/queue.h" +#include "qemu/osdep.h" #include "qemu-common.h" -#include "qemu-config.h" +#include "qemu/config-file.h" static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries = QTAILQ_HEAD_INITIALIZER(fsdriver_entries); diff --git a/fsdev/qemu-fsdev.h b/fsdev/qemu-fsdev.h index 1af1f545d8..9fa45bf510 100644 --- a/fsdev/qemu-fsdev.h +++ b/fsdev/qemu-fsdev.h @@ -12,7 +12,7 @@ */ #ifndef QEMU_FSDEV_H #define QEMU_FSDEV_H -#include "qemu-option.h" +#include "qemu/option.h" #include "file-op-9p.h" diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index df2a9392b1..6b9afd32d5 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -21,8 +21,8 @@ #include #endif #include "qemu-common.h" -#include "qemu_socket.h" -#include "qemu-xattr.h" +#include "qemu/sockets.h" +#include "qemu/xattr.h" #include "virtio-9p-marshal.h" #include "hw/9pfs/virtio-9p-proxy.h" #include "fsdev/virtio-9p-marshal.h" diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c index bf980bfa38..20f308b760 100644 --- a/fsdev/virtio-9p-marshal.c +++ b/fsdev/virtio-9p-marshal.c @@ -22,9 +22,9 @@ #include #include -#include "compiler.h" +#include "qemu/compiler.h" #include "virtio-9p-marshal.h" -#include "bswap.h" +#include "qemu/bswap.h" void v9fs_string_free(V9fsString *str) { diff --git a/gdbstub.c b/gdbstub.c index 9395c829a2..4b178a608f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -38,7 +38,7 @@ #define MAX_PACKET_LENGTH 4096 #include "cpu.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "kvm.h" #ifndef TARGET_CPU_MEMORY_RW_DEBUG diff --git a/hmp.c b/hmp.c index a76a8f06ea..3d056b0e38 100644 --- a/hmp.c +++ b/hmp.c @@ -16,10 +16,10 @@ #include "hmp.h" #include "net/net.h" #include "qemu-char.h" -#include "qemu-option.h" -#include "qemu-timer.h" +#include "qemu/option.h" +#include "qemu/timer.h" #include "qmp-commands.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" #include "ui/console.h" diff --git a/host-utils.c b/host-utils.c index dc9612387b..5e3915abba 100644 --- a/host-utils.c +++ b/host-utils.c @@ -25,7 +25,7 @@ #include #include -#include "host-utils.h" +#include "qemu/host-utils.h" //#define DEBUG_MULDIV diff --git a/host-utils.h b/host-utils.h deleted file mode 100644 index a5f8464fb2..0000000000 --- a/host-utils.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Utility compute operations used by translated code. - * - * Copyright (c) 2007 Thiemo Seufer - * Copyright (c) 2007 Jocelyn Mayer - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#ifndef HOST_UTILS_H -#define HOST_UTILS_H 1 - -#include "compiler.h" /* QEMU_GNUC_PREREQ */ - -#if defined(__x86_64__) -#define __HAVE_FAST_MULU64__ -static inline void mulu64(uint64_t *plow, uint64_t *phigh, - uint64_t a, uint64_t b) -{ - __asm__ ("mul %0\n\t" - : "=d" (*phigh), "=a" (*plow) - : "a" (a), "0" (b)); -} -#define __HAVE_FAST_MULS64__ -static inline void muls64(uint64_t *plow, uint64_t *phigh, - int64_t a, int64_t b) -{ - __asm__ ("imul %0\n\t" - : "=d" (*phigh), "=a" (*plow) - : "a" (a), "0" (b)); -} -#else -void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); -void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); -#endif - -/* Binary search for leading zeros. */ - -static inline int clz32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_clz(val); - else - return 32; -#else - int cnt = 0; - - if (!(val & 0xFFFF0000U)) { - cnt += 16; - val <<= 16; - } - if (!(val & 0xFF000000U)) { - cnt += 8; - val <<= 8; - } - if (!(val & 0xF0000000U)) { - cnt += 4; - val <<= 4; - } - if (!(val & 0xC0000000U)) { - cnt += 2; - val <<= 2; - } - if (!(val & 0x80000000U)) { - cnt++; - val <<= 1; - } - if (!(val & 0x80000000U)) { - cnt++; - } - return cnt; -#endif -} - -static inline int clo32(uint32_t val) -{ - return clz32(~val); -} - -static inline int clz64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_clzll(val); - else - return 64; -#else - int cnt = 0; - - if (!(val >> 32)) { - cnt += 32; - } else { - val >>= 32; - } - - return cnt + clz32(val); -#endif -} - -static inline int clo64(uint64_t val) -{ - return clz64(~val); -} - -static inline int ctz32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_ctz(val); - else - return 32; -#else - int cnt; - - cnt = 0; - if (!(val & 0x0000FFFFUL)) { - cnt += 16; - val >>= 16; - } - if (!(val & 0x000000FFUL)) { - cnt += 8; - val >>= 8; - } - if (!(val & 0x0000000FUL)) { - cnt += 4; - val >>= 4; - } - if (!(val & 0x00000003UL)) { - cnt += 2; - val >>= 2; - } - if (!(val & 0x00000001UL)) { - cnt++; - val >>= 1; - } - if (!(val & 0x00000001UL)) { - cnt++; - } - - return cnt; -#endif -} - -static inline int cto32(uint32_t val) -{ - return ctz32(~val); -} - -static inline int ctz64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - if (val) - return __builtin_ctzll(val); - else - return 64; -#else - int cnt; - - cnt = 0; - if (!((uint32_t)val)) { - cnt += 32; - val >>= 32; - } - - return cnt + ctz32(val); -#endif -} - -static inline int cto64(uint64_t val) -{ - return ctz64(~val); -} - -static inline int ctpop8(uint8_t val) -{ - val = (val & 0x55) + ((val >> 1) & 0x55); - val = (val & 0x33) + ((val >> 2) & 0x33); - val = (val & 0x0f) + ((val >> 4) & 0x0f); - - return val; -} - -static inline int ctpop16(uint16_t val) -{ - val = (val & 0x5555) + ((val >> 1) & 0x5555); - val = (val & 0x3333) + ((val >> 2) & 0x3333); - val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); - val = (val & 0x00ff) + ((val >> 8) & 0x00ff); - - return val; -} - -static inline int ctpop32(uint32_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - return __builtin_popcount(val); -#else - val = (val & 0x55555555) + ((val >> 1) & 0x55555555); - val = (val & 0x33333333) + ((val >> 2) & 0x33333333); - val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); - val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); - val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); - - return val; -#endif -} - -static inline int ctpop64(uint64_t val) -{ -#if QEMU_GNUC_PREREQ(3, 4) - return __builtin_popcountll(val); -#else - val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); - val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); - val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); - val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); - val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); - val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); - - return val; -#endif -} - -#endif diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c index cd137330b9..65ad3298be 100644 --- a/hw/9pfs/codir.c +++ b/hw/9pfs/codir.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c index 6d6dac7abf..2efebf3571 100644 --- a/hw/9pfs/cofile.c +++ b/hw/9pfs/cofile.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 4b9ba30157..3891050748 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/coxattr.c b/hw/9pfs/coxattr.c index 08365a697e..18ee08df0f 100644 --- a/hw/9pfs/coxattr.c +++ b/hw/9pfs/coxattr.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/virtio-9p-coth.c b/hw/9pfs/virtio-9p-coth.c index 958725e5cc..ae6cde8005 100644 --- a/hw/9pfs/virtio-9p-coth.c +++ b/hw/9pfs/virtio-9p-coth.c @@ -13,7 +13,7 @@ */ #include "fsdev/qemu-fsdev.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p-coth.h" diff --git a/hw/9pfs/virtio-9p-coth.h b/hw/9pfs/virtio-9p-coth.h index 8c48a16c10..86d5ed4169 100644 --- a/hw/9pfs/virtio-9p-coth.h +++ b/hw/9pfs/virtio-9p-coth.h @@ -15,7 +15,7 @@ #ifndef _QEMU_VIRTIO_9P_COTH_H #define _QEMU_VIRTIO_9P_COTH_H -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "virtio-9p.h" #include diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index b8220abae7..6761bce9dc 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -13,7 +13,7 @@ #include "hw/virtio.h" #include "hw/pc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c index f96d17a974..e30fdb6730 100644 --- a/hw/9pfs/virtio-9p-handle.c +++ b/hw/9pfs/virtio-9p-handle.c @@ -19,7 +19,7 @@ #include #include #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include #include #ifdef CONFIG_LINUX_MAGIC_H diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 33a41d2e18..113602144c 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -19,7 +19,7 @@ #include #include #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include #include #ifdef CONFIG_LINUX_MAGIC_H diff --git a/hw/9pfs/virtio-9p-posix-acl.c b/hw/9pfs/virtio-9p-posix-acl.c index c064017b1f..08bb0e8bca 100644 --- a/hw/9pfs/virtio-9p-posix-acl.c +++ b/hw/9pfs/virtio-9p-posix-acl.c @@ -12,7 +12,7 @@ */ #include -#include "qemu-xattr.h" +#include "qemu/xattr.h" #include "hw/virtio.h" #include "virtio-9p.h" #include "fsdev/file-op-9p.h" diff --git a/hw/9pfs/virtio-9p-xattr.h b/hw/9pfs/virtio-9p-xattr.h index 9437280c99..41cc6cbc7b 100644 --- a/hw/9pfs/virtio-9p-xattr.h +++ b/hw/9pfs/virtio-9p-xattr.h @@ -13,7 +13,7 @@ #ifndef _QEMU_VIRTIO_9P_XATTR_H #define _QEMU_VIRTIO_9P_XATTR_H -#include "qemu-xattr.h" +#include "qemu/xattr.h" typedef struct xattr_operations { diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index ede20ce80e..0aaf0d2de0 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -13,7 +13,7 @@ #include "hw/virtio.h" #include "hw/pc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "hw/virtio-pci.h" #include "virtio-9p.h" #include "fsdev/qemu-fsdev.h" diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 2c0c3baad4..406fe522db 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -9,7 +9,7 @@ #include "hw/virtio.h" #include "fsdev/file-op-9p.h" #include "fsdev/virtio-9p-marshal.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "block/coroutine.h" diff --git a/hw/acpi.h b/hw/acpi.h index afda153d09..c3628d070d 100644 --- a/hw/acpi.h +++ b/hw/acpi.h @@ -127,7 +127,7 @@ void acpi_pm_tmr_init(ACPIREGS *ar, acpi_update_sci_fn update_sci, MemoryRegion *parent); void acpi_pm_tmr_reset(ACPIREGS *ar); -#include "qemu-timer.h" +#include "qemu/timer.h" static inline int64_t acpi_pm_tmr_get_clock(void) { return muldiv64(qemu_get_clock_ns(vm_clock), PM_TIMER_FREQUENCY, diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 92af3a554c..8d1a689a36 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -26,7 +26,7 @@ #include "hw.h" #include "pc.h" #include "pci/pci.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "acpi.h" #include "kvm.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index 4f43f6e070..ebd015dc02 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -25,7 +25,7 @@ #include "pci/pci.h" #include "acpi.h" #include "sysemu.h" -#include "range.h" +#include "qemu/range.h" #include "exec/ioport.h" #include "fw_cfg.h" #include "exec/address-spaces.h" diff --git a/hw/adlib.c b/hw/adlib.c index d39cd97384..07c69fc967 100644 --- a/hw/adlib.c +++ b/hw/adlib.c @@ -32,7 +32,7 @@ #define ADLIB_KILL_TIMERS 1 #ifdef DEBUG -#include "qemu-timer.h" +#include "qemu/timer.h" #endif #define dolog(...) AUD_log ("adlib", __VA_ARGS__) diff --git a/hw/alpha_pci.c b/hw/alpha_pci.c index 7e7b1d27d2..78d93e55ec 100644 --- a/hw/alpha_pci.c +++ b/hw/alpha_pci.c @@ -8,7 +8,7 @@ #include "config.h" #include "alpha_sys.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" diff --git a/hw/apic.c b/hw/apic.c index d66a476aac..81b82f694c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -16,12 +16,12 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see */ -#include "qemu-thread.h" +#include "qemu/thread.h" #include "apic_internal.h" #include "apic.h" #include "ioapic.h" #include "pci/msi.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "trace.h" #include "pc.h" #include "apic-msidef.h" diff --git a/hw/apic_internal.h b/hw/apic_internal.h index fea95654ca..dcbbfd41cb 100644 --- a/hw/apic_internal.h +++ b/hw/apic_internal.h @@ -22,7 +22,7 @@ #include "exec/memory.h" #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* APIC Local Vector Table */ #define APIC_LVT_TIMER 0 diff --git a/hw/applesmc.c b/hw/applesmc.c index 91e7cb3d5c..c564b60c0a 100644 --- a/hw/applesmc.c +++ b/hw/applesmc.c @@ -33,7 +33,7 @@ #include "hw.h" #include "isa.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* #define DEBUG_SMC */ diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c index 640ed20a61..093331124a 100644 --- a/hw/arm11mpcore.c +++ b/hw/arm11mpcore.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* MPCore private memory region. */ diff --git a/hw/arm_boot.c b/hw/arm_boot.c index 63ff559cf7..bb9889fbef 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -15,7 +15,7 @@ #include "loader.h" #include "elf.h" #include "device_tree.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #define KERNEL_ARGS_ADDR 0x100 #define KERNEL_LOAD_ADDR 0x00010000 diff --git a/hw/arm_mptimer.c b/hw/arm_mptimer.c index 6790832236..1febaeb7b1 100644 --- a/hw/arm_mptimer.c +++ b/hw/arm_mptimer.c @@ -20,7 +20,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* This device implements the per-cpu private timer and watchdog block * which is used in both the ARM11MPCore and Cortex-A9MP. diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c index 58eb98216d..0884f6275c 100644 --- a/hw/arm_sysctl.c +++ b/hw/arm_sysctl.c @@ -8,7 +8,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "primecell.h" #include "sysemu.h" diff --git a/hw/arm_timer.c b/hw/arm_timer.c index af339d3d19..37e28e993c 100644 --- a/hw/arm_timer.c +++ b/hw/arm_timer.c @@ -8,7 +8,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "qdev.h" #include "ptimer.h" diff --git a/hw/armv7m_nvic.c b/hw/armv7m_nvic.c index 270c307717..0907e42c0c 100644 --- a/hw/armv7m_nvic.c +++ b/hw/armv7m_nvic.c @@ -11,7 +11,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "arm-misc.h" #include "exec/address-spaces.h" #include "arm_gic_internal.h" diff --git a/hw/baum.c b/hw/baum.c index 3e94f84e51..97d13ea344 100644 --- a/hw/baum.c +++ b/hw/baum.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "baum.h" #include diff --git a/hw/block-common.c b/hw/block-common.c index f0196d78dc..c24208e560 100644 --- a/hw/block-common.c +++ b/hw/block-common.c @@ -9,7 +9,7 @@ #include "blockdev.h" #include "hw/block-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" void blkconf_serial(BlockConf *conf, char **serial) { diff --git a/hw/bt-hci-csr.c b/hw/bt-hci-csr.c index 0faabbb585..e1dcb6d099 100644 --- a/hw/bt-hci-csr.c +++ b/hw/bt-hci-csr.c @@ -20,7 +20,7 @@ #include "qemu-common.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "irq.h" #include "bt-host.h" #include "bt.h" diff --git a/hw/bt-hci.c b/hw/bt-hci.c index d2ad57faa9..da096d8c37 100644 --- a/hw/bt-hci.c +++ b/hw/bt-hci.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "bt-host.h" #include "bt.h" diff --git a/hw/bt-hid.c b/hw/bt-hid.c index 0ec0c013b0..cfa7c145b8 100644 --- a/hw/bt-hid.c +++ b/hw/bt-hid.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "hid.h" #include "bt.h" diff --git a/hw/bt-l2cap.c b/hw/bt-l2cap.c index cb43ee7733..ba061c0da3 100644 --- a/hw/bt-l2cap.c +++ b/hw/bt-l2cap.c @@ -18,7 +18,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "bt.h" #define L2CAP_CID_MAX 0x100 /* Between 0x40 and 0x10000 */ diff --git a/hw/cadence_ttc.c b/hw/cadence_ttc.c index ec78a52180..9e1cb1f152 100644 --- a/hw/cadence_ttc.c +++ b/hw/cadence_ttc.c @@ -17,7 +17,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CADENCE_TTC_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/cadence_uart.c b/hw/cadence_uart.c index 686e6172d0..f34acc8c46 100644 --- a/hw/cadence_uart.c +++ b/hw/cadence_uart.c @@ -18,7 +18,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CADENCE_UART_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index 845a764446..e508380482 100644 --- a/hw/ccid-card-emulated.c +++ b/hw/ccid-card-emulated.c @@ -31,7 +31,7 @@ #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "qemu-char.h" #include "monitor/monitor.h" #include "hw/ccid.h" diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index f5b4794e90..48e4228b9d 100644 --- a/hw/ccid-card-passthru.c +++ b/hw/ccid-card-passthru.c @@ -9,7 +9,7 @@ */ #include "qemu-char.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" #include "hw/ccid.h" #include "libcacard/vscard_common.h" diff --git a/hw/cs4231a.c b/hw/cs4231a.c index 0257fd8d2a..9d528c43b0 100644 --- a/hw/cs4231a.c +++ b/hw/cs4231a.c @@ -26,7 +26,7 @@ #include "audio/audio.h" #include "isa.h" #include "qdev.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* Missing features: diff --git a/hw/cuda.c b/hw/cuda.c index f1f408b839..cf83956e1a 100644 --- a/hw/cuda.c +++ b/hw/cuda.c @@ -25,7 +25,7 @@ #include "hw.h" #include "ppc_mac.h" #include "adb.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" /* XXX: implement all timer modes */ diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 809a598e3a..34543786e5 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -25,7 +25,7 @@ #include "hw.h" #include "boards.h" #include "blockdev.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "sysemu.h" #include "monitor/monitor.h" diff --git a/hw/dma.c b/hw/dma.c index 364f54d2d7..0634baa552 100644 --- a/hw/dma.c +++ b/hw/dma.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "isa.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* #define DEBUG_DMA */ diff --git a/hw/dp8393x.c b/hw/dp8393x.c index d59b6118ad..b5014501df 100644 --- a/hw/dp8393x.c +++ b/hw/dp8393x.c @@ -18,7 +18,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "net/net.h" #include "mips.h" diff --git a/hw/esp-pci.c b/hw/esp-pci.c index d433473d6a..c949e6e0d9 100644 --- a/hw/esp-pci.c +++ b/hw/esp-pci.c @@ -27,7 +27,7 @@ #include "eeprom93xx.h" #include "esp.h" #include "trace.h" -#include "qemu-log.h" +#include "qemu/log.h" #define TYPE_AM53C974_DEVICE "am53c974" diff --git a/hw/esp.c b/hw/esp.c index 6d01624a49..0e4e430880 100644 --- a/hw/esp.c +++ b/hw/esp.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "esp.h" #include "trace.h" -#include "qemu-log.h" +#include "qemu/log.h" /* * On Sparc32, this is the ESP (NCR53C90) part of chip STP2000 (Master I/O), diff --git a/hw/etraxfs_ser.c b/hw/etraxfs_ser.c index ee0d72bf87..59cb7d2172 100644 --- a/hw/etraxfs_ser.c +++ b/hw/etraxfs_ser.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #define D(x) diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c index f5601dc7a5..cc8b327715 100644 --- a/hw/etraxfs_timer.c +++ b/hw/etraxfs_timer.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #define D(x) diff --git a/hw/exynos4210_fimd.c b/hw/exynos4210_fimd.c index cfca72ab67..5c29b5d01d 100644 --- a/hw/exynos4210_fimd.c +++ b/hw/exynos4210_fimd.c @@ -27,7 +27,7 @@ #include "sysbus.h" #include "ui/console.h" #include "ui/pixel_ops.h" -#include "bswap.h" +#include "qemu/bswap.h" /* Debug messages configuration */ #define EXYNOS4210_FIMD_DEBUG 0 diff --git a/hw/exynos4210_i2c.c b/hw/exynos4210_i2c.c index 1e11d9b48c..cefd736092 100644 --- a/hw/exynos4210_i2c.c +++ b/hw/exynos4210_i2c.c @@ -20,7 +20,7 @@ * */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "i2c.h" diff --git a/hw/exynos4210_mct.c b/hw/exynos4210_mct.c index 37dbda92df..41cd142227 100644 --- a/hw/exynos4210_mct.c +++ b/hw/exynos4210_mct.c @@ -53,7 +53,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" diff --git a/hw/exynos4210_pwm.c b/hw/exynos4210_pwm.c index 5e2872f8f7..3a3eb8c27a 100644 --- a/hw/exynos4210_pwm.c +++ b/hw/exynos4210_pwm.c @@ -21,7 +21,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" diff --git a/hw/exynos4210_rtc.c b/hw/exynos4210_rtc.c index c4fbd49461..6ebc9b1790 100644 --- a/hw/exynos4210_rtc.c +++ b/hw/exynos4210_rtc.c @@ -26,12 +26,12 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-common.h" #include "ptimer.h" #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "exynos4210.h" diff --git a/hw/fdc.c b/hw/fdc.c index 29b5449ff8..b67d3a574b 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -29,14 +29,14 @@ #include "hw.h" #include "fdc.h" -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "isa.h" #include "sysbus.h" #include "qdev-addr.h" #include "blockdev.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" /********************************************************/ /* debug Floppy devices */ diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 7b0e50f70d..2a00163a04 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -26,8 +26,8 @@ #include "isa.h" #include "fw_cfg.h" #include "sysbus.h" -#include "qemu-error.h" -#include "qemu-config.h" +#include "qemu/error-report.h" +#include "qemu/config-file.h" /* debug firmware config */ //#define DEBUG_FW_CFG diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c index 2fdccfba06..252ba893e3 100644 --- a/hw/grlib_gptimer.c +++ b/hw/grlib_gptimer.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "trace.h" diff --git a/hw/hid.c b/hw/hid.c index 7935998e83..0fee3b6ddd 100644 --- a/hw/hid.c +++ b/hw/hid.c @@ -24,7 +24,7 @@ */ #include "hw.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hid.h" #define HID_USAGE_ERROR_ROLLOVER 0x01 diff --git a/hw/hpet.c b/hw/hpet.c index 49e1b631b5..78c0662dfc 100644 --- a/hw/hpet.c +++ b/hw/hpet.c @@ -27,7 +27,7 @@ #include "hw.h" #include "pc.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hpet_emul.h" #include "sysbus.h" #include "mc146818rtc.h" diff --git a/hw/hw.h b/hw/hw.h index 883ddb60f9..dfced97bbc 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -13,7 +13,7 @@ #include "block/aio.h" #include "migration/qemu-file.h" #include "migration/vmstate.h" -#include "qemu-log.h" +#include "qemu/log.h" #ifdef NEED_CPU_H #if TARGET_LONG_BITS == 64 diff --git a/hw/i8254.c b/hw/i8254.c index bea5f92fd2..7c2aa6238d 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -24,7 +24,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "i8254_internal.h" diff --git a/hw/i8254_common.c b/hw/i8254_common.c index a03d7cd458..08ab8d14bd 100644 --- a/hw/i8254_common.c +++ b/hw/i8254_common.c @@ -25,7 +25,7 @@ #include "hw.h" #include "pc.h" #include "isa.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "i8254_internal.h" diff --git a/hw/i8259.c b/hw/i8259.c index 5e935e7f99..8fc6339250 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -25,7 +25,7 @@ #include "pc.h" #include "isa.h" #include "monitor/monitor.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8259_internal.h" /* debug PIC */ diff --git a/hw/ich9.h b/hw/ich9.h index 5c73f94caf..b8d8e6d3df 100644 --- a/hw/ich9.h +++ b/hw/ich9.h @@ -2,7 +2,7 @@ #define HW_ICH9_H #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/ide/core.c b/hw/ide/core.c index 0e5bc7fe3b..bf65cb407e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -26,8 +26,8 @@ #include #include #include -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "sysemu.h" #include "dma.h" #include "hw/block-common.h" diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index f2e4ea4207..c85e1ac018 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -18,7 +18,7 @@ */ #include #include "dma.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include "blockdev.h" #include "hw/block-common.h" diff --git a/hw/imx_avic.c b/hw/imx_avic.c index 810979366d..f1f066cf9c 100644 --- a/hw/imx_avic.c +++ b/hw/imx_avic.c @@ -16,7 +16,7 @@ #include "hw.h" #include "sysbus.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define DEBUG_INT 1 #undef DEBUG_INT /* comment out for debugging */ diff --git a/hw/imx_timer.c b/hw/imx_timer.c index 33f33fb41e..e924c747c5 100644 --- a/hw/imx_timer.c +++ b/hw/imx_timer.c @@ -12,7 +12,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysbus.h" #include "imx.h" diff --git a/hw/intel-hda.c b/hw/intel-hda.c index c21bf7204a..7ef3a15e08 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -20,7 +20,7 @@ #include "hw.h" #include "pci/pci.h" #include "pci/msi.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audiodev.h" #include "intel-hda.h" #include "intel-hda-defs.h" diff --git a/hw/ivshmem.c b/hw/ivshmem.c index d5b91dd24e..af34f3b582 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -23,7 +23,7 @@ #include "kvm.h" #include "migration/migration.h" #include "qapi/qmp/qerror.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "qemu-char.h" #include diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index 53d13e3123..8ee1c352cf 100644 --- a/hw/kvm/i8254.c +++ b/hw/kvm/i8254.c @@ -22,7 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "hw/i8254.h" #include "hw/i8254_internal.h" diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index ff0dc0dfd4..2f06c27e83 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -28,11 +28,11 @@ #include #include "hw/hw.h" #include "hw/pc.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "ui/console.h" #include "hw/loader.h" #include "monitor/monitor.h" -#include "range.h" +#include "qemu/range.h" #include "sysemu.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" diff --git a/hw/lance.c b/hw/lance.c index a384676158..b7265c0fed 100644 --- a/hw/lance.c +++ b/hw/lance.c @@ -37,8 +37,8 @@ #include "sysbus.h" #include "net/net.h" -#include "qemu-timer.h" -#include "qemu_socket.h" +#include "qemu/timer.h" +#include "qemu/sockets.h" #include "sun4m.h" #include "pcnet.h" #include "trace.h" diff --git a/hw/leon3.c b/hw/leon3.c index e8d54e5d06..776ab97a78 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "qemu-char.h" #include "sysemu.h" diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c index a7887d14f6..b3350890cb 100644 --- a/hw/lm32_sys.c +++ b/hw/lm32_sys.c @@ -31,10 +31,10 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-log.h" -#include "qemu-error.h" +#include "qemu/log.h" +#include "qemu/error-report.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" enum { R_CTRL = 0, diff --git a/hw/lm32_timer.c b/hw/lm32_timer.c index a8be9cc168..bd4c346386 100644 --- a/hw/lm32_timer.c +++ b/hw/lm32_timer.c @@ -24,9 +24,9 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define DEFAULT_FREQUENCY (50*1000000) diff --git a/hw/lm32_uart.c b/hw/lm32_uart.c index adb9287568..bf2f507523 100644 --- a/hw/lm32_uart.c +++ b/hw/lm32_uart.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_RXTX = 0, diff --git a/hw/lm832x.c b/hw/lm832x.c index b14a089b32..3649e3d249 100644 --- a/hw/lm832x.c +++ b/hw/lm832x.c @@ -20,7 +20,7 @@ #include "hw.h" #include "i2c.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" typedef struct { diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index e225693721..76217a74fc 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -29,7 +29,7 @@ */ #include "qemu-common.h" #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/m48t59.c b/hw/m48t59.c index 491d433ae7..301b10ce79 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "nvram.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "sysbus.h" #include "isa.h" diff --git a/hw/mac_dbdma.c b/hw/mac_dbdma.c index 41eee50a35..b894ab21aa 100644 --- a/hw/mac_dbdma.c +++ b/hw/mac_dbdma.c @@ -39,7 +39,7 @@ #include "hw.h" #include "isa.h" #include "mac_dbdma.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* debug DBDMA */ //#define DEBUG_DBDMA diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index 2a1278f393..fba75029df 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "mc146818rtc.h" #include "qapi/visitor.h" diff --git a/hw/mcf5206.c b/hw/mcf5206.c index 5edc931abd..fbc806ac18 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysemu.h" #include "exec/address-spaces.h" diff --git a/hw/mcf5208.c b/hw/mcf5208.c index 997b34847c..fea8a69262 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -7,7 +7,7 @@ */ #include "hw.h" #include "mcf.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysemu.h" #include "net/net.h" diff --git a/hw/megasas.c b/hw/megasas.c index f4fbe9790a..e80c0d1c25 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -22,7 +22,7 @@ #include "pci/pci.h" #include "dma.h" #include "pci/msix.h" -#include "iov.h" +#include "qemu/iov.h" #include "scsi.h" #include "scsi-defs.h" #include "trace.h" diff --git a/hw/microblaze_boot.c b/hw/microblaze_boot.c index 02c349c189..76d33021c0 100644 --- a/hw/microblaze_boot.c +++ b/hw/microblaze_boot.c @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qemu-common.h" #include "device_tree.h" #include "loader.h" diff --git a/hw/milkymist-ac97.c b/hw/milkymist-ac97.c index d87656c9ac..f46af1c509 100644 --- a/hw/milkymist-ac97.c +++ b/hw/milkymist-ac97.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "audio/audio.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_AC97_CTRL = 0, diff --git a/hw/milkymist-hpdmc.c b/hw/milkymist-hpdmc.c index 5d120a497f..fd54d3129a 100644 --- a/hw/milkymist-hpdmc.c +++ b/hw/milkymist-hpdmc.c @@ -24,7 +24,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_SYSTEM = 0, diff --git a/hw/milkymist-memcard.c b/hw/milkymist-memcard.c index ca5df56290..5dc30ace60 100644 --- a/hw/milkymist-memcard.c +++ b/hw/milkymist-memcard.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "sysemu.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "blockdev.h" #include "sd.h" diff --git a/hw/milkymist-minimac2.c b/hw/milkymist-minimac2.c index 926f7f9a8b..4e92ac3dcb 100644 --- a/hw/milkymist-minimac2.c +++ b/hw/milkymist-minimac2.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "trace.h" #include "net/net.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qdev-addr.h" #include diff --git a/hw/milkymist-pfpu.c b/hw/milkymist-pfpu.c index 450bab921f..0521829202 100644 --- a/hw/milkymist-pfpu.c +++ b/hw/milkymist-pfpu.c @@ -25,8 +25,8 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-log.h" -#include "qemu-error.h" +#include "qemu/log.h" +#include "qemu/error-report.h" #include /* #define TRACE_EXEC */ diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c index 0743668d18..b7beb4bedb 100644 --- a/hw/milkymist-softusb.c +++ b/hw/milkymist-softusb.c @@ -26,7 +26,7 @@ #include "trace.h" #include "ui/console.h" #include "hid.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_CTRL = 0, diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c index f951ef9ca8..519462afcc 100644 --- a/hw/milkymist-sysctl.c +++ b/hw/milkymist-sysctl.c @@ -25,9 +25,9 @@ #include "sysbus.h" #include "sysemu.h" #include "trace.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { CTRL_ENABLE = (1<<0), diff --git a/hw/milkymist-tmu2.c b/hw/milkymist-tmu2.c index 3f9a684eda..a11772aebe 100644 --- a/hw/milkymist-tmu2.c +++ b/hw/milkymist-tmu2.c @@ -27,7 +27,7 @@ #include "hw.h" #include "sysbus.h" #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c index aefa8c7f1c..ef5518e5c2 100644 --- a/hw/milkymist-uart.c +++ b/hw/milkymist-uart.c @@ -25,7 +25,7 @@ #include "sysbus.h" #include "trace.h" #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" enum { R_RXTX = 0, diff --git a/hw/milkymist-vgafb.c b/hw/milkymist-vgafb.c index c3471315d3..561285154f 100644 --- a/hw/milkymist-vgafb.c +++ b/hw/milkymist-vgafb.c @@ -28,7 +28,7 @@ #include "ui/console.h" #include "framebuffer.h" #include "ui/pixel_ops.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define BITS 8 #include "milkymist-vgafb_template.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 34619b7e3e..60dd8c69bb 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -33,7 +33,7 @@ #include "qemu-char.h" #include "sysemu.h" #include "audio/audio.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "mips-bios.h" #include "ide.h" diff --git a/hw/mips_malta.c b/hw/mips_malta.c index d65d1256fd..04c7a2612c 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -38,7 +38,7 @@ #include "sysemu.h" #include "arch_init.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "mips-bios.h" #include "ide.h" #include "loader.h" diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 05494b9b40..511e1e41c0 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -17,7 +17,7 @@ #include "sysemu.h" #include "boards.h" #include "flash.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "mips-bios.h" #include "ide.h" #include "loader.h" diff --git a/hw/mips_timer.c b/hw/mips_timer.c index 7aa9004a0e..83c400c158 100644 --- a/hw/mips_timer.c +++ b/hw/mips_timer.c @@ -22,7 +22,7 @@ #include "hw.h" #include "mips_cpudevs.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define TIMER_FREQ 100 * 1000 * 1000 diff --git a/hw/musicpal.c b/hw/musicpal.c index 436b3f7c37..5a7bf8bee1 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -16,7 +16,7 @@ #include "sysemu.h" #include "boards.h" #include "serial.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "block/block.h" #include "flash.h" diff --git a/hw/nand.c b/hw/nand.c index 01f3adaee1..a73205d866 100644 --- a/hw/nand.c +++ b/hw/nand.c @@ -22,7 +22,7 @@ # include "flash.h" # include "blockdev.h" # include "sysbus.h" -#include "qemu-error.h" +#include "qemu/error-report.h" # define NAND_CMD_READ0 0x00 # define NAND_CMD_READ1 0x01 diff --git a/hw/omap1.c b/hw/omap1.c index 4d5815eb08..50c4570f31 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -22,7 +22,7 @@ #include "sysemu.h" #include "soc_dma.h" #include "blockdev.h" -#include "range.h" +#include "qemu/range.h" #include "sysbus.h" /* Should signal the TCMI/GPMC */ diff --git a/hw/omap2.c b/hw/omap2.c index 96aba71052..7ccee69661 100644 --- a/hw/omap2.c +++ b/hw/omap2.c @@ -23,7 +23,7 @@ #include "arm-misc.h" #include "omap.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "flash.h" #include "soc_dma.h" diff --git a/hw/omap_dma.c b/hw/omap_dma.c index e619c7b7de..aec5874311 100644 --- a/hw/omap_dma.c +++ b/hw/omap_dma.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" #include "irq.h" #include "soc_dma.h" diff --git a/hw/omap_gptimer.c b/hw/omap_gptimer.c index e39da74067..a5db710dcb 100644 --- a/hw/omap_gptimer.c +++ b/hw/omap_gptimer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" /* GP timers */ diff --git a/hw/omap_synctimer.c b/hw/omap_synctimer.c index 7031a88531..945711eff5 100644 --- a/hw/omap_synctimer.c +++ b/hw/omap_synctimer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "omap.h" struct omap_synctimer_s { MemoryRegion iomem; diff --git a/hw/onenand.c b/hw/onenand.c index 7d255c563f..2e26e3a05d 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -26,7 +26,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "sysbus.h" -#include "qemu-error.h" +#include "qemu/error-report.h" /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */ #define PAGE_SHIFT 11 diff --git a/hw/openrisc_timer.c b/hw/openrisc_timer.c index 7916e61d24..d965be77de 100644 --- a/hw/openrisc_timer.c +++ b/hw/openrisc_timer.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define TIMER_FREQ (20 * 1000 * 1000) /* 20MHz */ diff --git a/hw/pc.c b/hw/pc.c index 7aaff0f2fd..0a92ea6bed 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -50,7 +50,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "arch_init.h" -#include "bitmap.h" +#include "qemu/bitmap.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ diff --git a/hw/pci/msi.c b/hw/pci/msi.c index 680e4637d7..2a04d18884 100644 --- a/hw/pci/msi.c +++ b/hw/pci/msi.c @@ -19,7 +19,7 @@ */ #include "hw/pci/msi.h" -#include "range.h" +#include "qemu/range.h" /* Eventually those constants should go to Linux pci_regs.h */ #define PCI_MSI_PENDING_32 0x10 diff --git a/hw/pci/msix.c b/hw/pci/msix.c index a6a401e286..073e22c315 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -18,7 +18,7 @@ #include "hw/pci/msi.h" #include "hw/pci/msix.h" #include "hw/pci/pci.h" -#include "range.h" +#include "qemu/range.h" #define MSIX_CAP_LENGTH 12 diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index e5e8a7ab58..2bc02e344f 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -30,7 +30,7 @@ #include "monitor/monitor.h" #include "hw/scsi.h" #include "hw/virtio-blk.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "blockdev.h" #include "qapi/error.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e062f66088..c9ed95be89 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -29,7 +29,7 @@ #include "net/net.h" #include "sysemu.h" #include "hw/loader.h" -#include "range.h" +#include "qemu/range.h" #include "qmp-commands.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 131091408d..995842a72d 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -31,7 +31,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" -#include "range.h" +#include "qemu/range.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8 diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b60a6faaf3..6c916d15ec 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -25,7 +25,7 @@ #include "hw/pci/msi.h" #include "hw/pci/pci_bus.h" #include "hw/pci/pcie_regs.h" -#include "range.h" +#include "qemu/range.h" //#define DEBUG_PCIE #ifdef DEBUG_PCIE diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c index 18b1512b43..f07266da66 100644 --- a/hw/pci/shpc.c +++ b/hw/pci/shpc.c @@ -1,7 +1,7 @@ #include #include -#include "range.h" -#include "range.h" +#include "qemu/range.h" +#include "qemu/range.h" #include "hw/pci/shpc.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h" diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c index c6768bcbdc..5e8eed3af8 100644 --- a/hw/pcnet-pci.c +++ b/hw/pcnet-pci.c @@ -30,7 +30,7 @@ #include "pci/pci.h" #include "net/net.h" #include "loader.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "dma.h" #include "pcnet.h" diff --git a/hw/pcnet.c b/hw/pcnet.c index 5b03edecdd..87736542e4 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -37,8 +37,8 @@ #include "qdev.h" #include "net/net.h" -#include "qemu-timer.h" -#include "qemu_socket.h" +#include "qemu/timer.h" +#include "qemu/sockets.h" #include "sysemu.h" #include "pcnet.h" diff --git a/hw/pcspk.c b/hw/pcspk.c index ad6491b0f4..6d55ebe82f 100644 --- a/hw/pcspk.c +++ b/hw/pcspk.c @@ -26,7 +26,7 @@ #include "pc.h" #include "isa.h" #include "audio/audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i8254.h" #include "pcspk.h" diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 36af4647df..59982dcd6f 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -39,9 +39,9 @@ #include "hw.h" #include "flash.h" #include "block/block.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysbus.h" #define PFLASH_BUG(fmt, ...) \ diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index c689cc9f42..6924f064c2 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -37,10 +37,10 @@ #include "hw.h" #include "flash.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "block/block.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysbus.h" //#define PFLASH_DEBUG diff --git a/hw/piix_pci.c b/hw/piix_pci.c index b5ea68bc61..3d79c73fda 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -28,7 +28,7 @@ #include "pci/pci_host.h" #include "isa.h" #include "sysbus.h" -#include "range.h" +#include "qemu/range.h" #include "xen.h" #include "pam.h" diff --git a/hw/pl031.c b/hw/pl031.c index 8bf0183289..834a20c917 100644 --- a/hw/pl031.c +++ b/hw/pl031.c @@ -12,7 +12,7 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" //#define DEBUG_PL031 diff --git a/hw/ppc.c b/hw/ppc.c index 11fd199eaa..f066367609 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -23,10 +23,10 @@ */ #include "hw.h" #include "ppc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "nvram.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 798e67cedf..3593f7c0e2 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -19,7 +19,7 @@ #include "e500.h" #include "e500-ccsr.h" #include "net/net.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include "hw/hw.h" #include "hw/serial.h" #include "hw/pci/pci.h" @@ -34,7 +34,7 @@ #include "elf.h" #include "hw/sysbus.h" #include "exec/address-spaces.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "hw/ppce500_pci.h" #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index 5a0e0260e6..31bcc4bb95 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -29,7 +29,7 @@ #include "sysemu.h" #include "block/block.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" #include "blockdev.h" #include "exec/address-spaces.h" diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c index aabb2efb48..b1ed8837d6 100644 --- a/hw/ppc405_uc.c +++ b/hw/ppc405_uc.c @@ -25,9 +25,9 @@ #include "ppc.h" #include "ppc405.h" #include "serial.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" #define DEBUG_OPBA diff --git a/hw/ppc4xx_devs.c b/hw/ppc4xx_devs.c index 3b9dc06716..d1fb1576b0 100644 --- a/hw/ppc4xx_devs.c +++ b/hw/ppc4xx_devs.c @@ -24,7 +24,7 @@ #include "hw.h" #include "ppc.h" #include "ppc4xx.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" //#define DEBUG_MMIO diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c index d51e7fad67..a7182be0d3 100644 --- a/hw/ppc_booke.c +++ b/hw/ppc_booke.c @@ -23,10 +23,10 @@ */ #include "hw.h" #include "ppc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "nvram.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "loader.h" diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index aa46cc6f55..072535294e 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -33,7 +33,7 @@ #include "pci/pci_host.h" #include "ppc.h" #include "boards.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "ide.h" #include "loader.h" #include "mc146818rtc.h" diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index feefc6596b..1e1ade3d2e 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -18,7 +18,7 @@ #include "hw/ppc/e500-ccsr.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "ppce500_pci.h" #ifdef DEBUG_PCI diff --git a/hw/ptimer.c b/hw/ptimer.c index bc0b3f802f..24af6a2afe 100644 --- a/hw/ptimer.c +++ b/hw/ptimer.c @@ -6,9 +6,9 @@ * This code is licensed under the GNU LGPL. */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "host-utils.h" +#include "qemu/host-utils.h" struct ptimer_state { diff --git a/hw/ptimer.h b/hw/ptimer.h index 9d172f7764..28fcaf17f8 100644 --- a/hw/ptimer.h +++ b/hw/ptimer.h @@ -9,7 +9,7 @@ #define PTIMER_H #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "migration/vmstate.h" /* ptimer.c */ diff --git a/hw/pxa2xx_timer.c b/hw/pxa2xx_timer.c index 8242d26c37..1481c6d3e1 100644 --- a/hw/pxa2xx_timer.c +++ b/hw/pxa2xx_timer.c @@ -8,7 +8,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "pxa.h" #include "sysbus.h" diff --git a/hw/q35.h b/hw/q35.h index 2f951c8a94..246c12cb04 100644 --- a/hw/q35.h +++ b/hw/q35.h @@ -23,7 +23,7 @@ #define HW_Q35_H #include "hw.h" -#include "range.h" +#include "qemu/range.h" #include "isa.h" #include "sysbus.h" #include "pc.h" diff --git a/hw/qdev-core.h b/hw/qdev-core.h index 93a3a2a7bc..fdf14ec4a6 100644 --- a/hw/qdev-core.h +++ b/hw/qdev-core.h @@ -1,9 +1,9 @@ #ifndef QDEV_CORE_H #define QDEV_CORE_H -#include "qemu-queue.h" -#include "qemu-option.h" -#include "qemu-types.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "qemu/typedefs.h" #include "qom/object.h" #include "hw/irq.h" #include "qapi/error.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 207282c4a4..1c6712e6de 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -21,7 +21,7 @@ #include "monitor/monitor.h" #include "qmp-commands.h" #include "arch_init.h" -#include "qemu-config.h" +#include "qemu/config-file.h" /* * Aliases were a bad idea from the start. Let's keep them diff --git a/hw/qxl-logger.c b/hw/qxl-logger.c index fe2878c836..3cd85d9b97 100644 --- a/hw/qxl-logger.c +++ b/hw/qxl-logger.c @@ -19,7 +19,7 @@ * along with this program; if not, see . */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qxl.h" static const char *qxl_type[] = { diff --git a/hw/qxl.c b/hw/qxl.c index ad0214827e..b88a39cc93 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -21,8 +21,8 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/qxl.h b/hw/qxl.h index 9130261524..f867a1d0ac 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -7,7 +7,7 @@ #include "hw.h" #include "pci/pci.h" #include "vga_int.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "ui/qemu-spice.h" #include "ui/spice-display.h" diff --git a/hw/rc4030.c b/hw/rc4030.c index e0024c87e8..a0358a319c 100644 --- a/hw/rc4030.c +++ b/hw/rc4030.c @@ -24,7 +24,7 @@ #include "hw.h" #include "mips.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /********************************************************/ /* debug rc4030 */ diff --git a/hw/rtl8139.c b/hw/rtl8139.c index e024520b8b..19c31a02c6 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -54,11 +54,11 @@ #include "hw.h" #include "pci/pci.h" #include "dma.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "net/net.h" #include "loader.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" /* debug RTL8139 card */ //#define DEBUG_RTL8139 1 diff --git a/hw/s390x/event-facility.h b/hw/s390x/event-facility.h index 30af0a76a7..791ab2a6de 100644 --- a/hw/s390x/event-facility.h +++ b/hw/s390x/event-facility.h @@ -16,7 +16,7 @@ #define HW_S390_SCLP_EVENT_FACILITY_H #include -#include "qemu-thread.h" +#include "qemu/thread.h" /* SCLP event types */ #define SCLP_EVENT_ASCII_CONSOLE_DATA 0x1a diff --git a/hw/s390x/sclpconsole.c b/hw/s390x/sclpconsole.c index 9ad297c999..ca78d6796a 100644 --- a/hw/s390x/sclpconsole.c +++ b/hw/s390x/sclpconsole.c @@ -13,7 +13,7 @@ */ #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "sclp.h" #include "event-facility.h" diff --git a/hw/sb16.c b/hw/sb16.c index 523ab0d5fd..bb460ccb60 100644 --- a/hw/sb16.c +++ b/hw/sb16.c @@ -26,8 +26,8 @@ #include "audio/audio.h" #include "isa.h" #include "qdev.h" -#include "qemu-timer.h" -#include "host-utils.h" +#include "qemu/timer.h" +#include "qemu/host-utils.h" #define dolog(...) AUD_log ("sb16", __VA_ARGS__) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index dfb2631210..5dc9f512b5 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1,5 +1,5 @@ #include "hw.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" #include "qdev.h" diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 49b5686a92..c65da4a9c9 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -29,7 +29,7 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0) #endif #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" #include "sysemu.h" diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index d9045341ba..faeb61ee2c 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "scsi.h" #include "blockdev.h" diff --git a/hw/sd.c b/hw/sd.c index 2e54eea981..428bd78e32 100644 --- a/hw/sd.c +++ b/hw/sd.c @@ -32,7 +32,7 @@ #include "hw.h" #include "block/block.h" #include "sd.h" -#include "bitmap.h" +#include "qemu/bitmap.h" //#define DEBUG_SD 1 diff --git a/hw/serial.c b/hw/serial.c index 3968c4fc46..2cbb5447a7 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -25,7 +25,7 @@ #include "serial.h" #include "qemu-char.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" //#define DEBUG_SERIAL diff --git a/hw/sh_pci.c b/hw/sh_pci.c index d5218420a3..018b1c198b 100644 --- a/hw/sh_pci.c +++ b/hw/sh_pci.c @@ -25,7 +25,7 @@ #include "sh.h" #include "pci/pci.h" #include "pci/pci_host.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "exec/address-spaces.h" typedef struct SHPCIState { diff --git a/hw/sh_timer.c b/hw/sh_timer.c index da6689f369..64ea23fce6 100644 --- a/hw/sh_timer.c +++ b/hw/sh_timer.c @@ -10,7 +10,7 @@ #include "hw.h" #include "sh.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" #include "ptimer.h" diff --git a/hw/slavio_timer.c b/hw/slavio_timer.c index c07ceb1de0..584629f1a5 100644 --- a/hw/slavio_timer.c +++ b/hw/slavio_timer.c @@ -23,7 +23,7 @@ */ #include "sun4m.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/sm501.c b/hw/sm501.c index 714aca0492..dd186aa7f2 100644 --- a/hw/sm501.c +++ b/hw/sm501.c @@ -29,7 +29,7 @@ #include "devices.h" #include "sysbus.h" #include "qdev-addr.h" -#include "range.h" +#include "qemu/range.h" #include "ui/pixel_ops.h" /* diff --git a/hw/soc_dma.c b/hw/soc_dma.c index 50d5f84b4e..64e8ee1d13 100644 --- a/hw/soc_dma.c +++ b/hw/soc_dma.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "soc_dma.h" static void transfer_mem2mem(struct soc_dma_ch_s *ch) diff --git a/hw/spapr.c b/hw/spapr.c index d1252fc68c..1abfde2a05 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -49,7 +49,7 @@ #include "exec/address-spaces.h" #include "hw/usb.h" -#include "qemu-config.h" +#include "qemu/config-file.h" #include diff --git a/hw/spitz.c b/hw/spitz.c index 48668a0f10..1259e32974 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -18,7 +18,7 @@ #include "i2c.h" #include "ssi.h" #include "flash.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "devices.h" #include "sharpsl.h" #include "ui/console.h" diff --git a/hw/stellaris.c b/hw/stellaris.c index 368f8a5e73..26da3c7f60 100644 --- a/hw/stellaris.c +++ b/hw/stellaris.c @@ -11,7 +11,7 @@ #include "ssi.h" #include "arm-misc.h" #include "devices.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i2c.h" #include "net/net.h" #include "boards.h" diff --git a/hw/strongarm.c b/hw/strongarm.c index 44bec34e07..f776fee3bc 100644 --- a/hw/strongarm.c +++ b/hw/strongarm.c @@ -28,7 +28,7 @@ */ #include "sysbus.h" #include "strongarm.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "arm-misc.h" #include "qemu-char.h" #include "sysemu.h" diff --git a/hw/sun4m.c b/hw/sun4m.c index 9a784dfd04..4245854949 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sun4m.h" #include "nvram.h" #include "sparc32_dma.h" diff --git a/hw/sun4u.c b/hw/sun4u.c index 000f6118e1..8bca4fdff9 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -29,7 +29,7 @@ #include "nvram.h" #include "fdc.h" #include "net/net.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "boards.h" #include "firmware_abi.h" diff --git a/hw/tsc2005.c b/hw/tsc2005.c index e2326283c0..740ff86aa8 100644 --- a/hw/tsc2005.c +++ b/hw/tsc2005.c @@ -19,7 +19,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "devices.h" diff --git a/hw/tsc210x.c b/hw/tsc210x.c index 2b3535d4fc..2076c355d2 100644 --- a/hw/tsc210x.c +++ b/hw/tsc210x.c @@ -21,7 +21,7 @@ #include "hw.h" #include "audio/audio.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ui/console.h" #include "omap.h" /* For I2SCodec and uWireSlave */ #include "devices.h" diff --git a/hw/tusb6010.c b/hw/tusb6010.c index 325200bd34..990d50619d 100644 --- a/hw/tusb6010.c +++ b/hw/tusb6010.c @@ -19,7 +19,7 @@ * with this program; if not, see . */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "usb.h" #include "omap.h" #include "irq.h" diff --git a/hw/twl92230.c b/hw/twl92230.c index ce699bdbdd..3210b9ef4e 100644 --- a/hw/twl92230.c +++ b/hw/twl92230.c @@ -20,7 +20,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "i2c.h" #include "sysemu.h" #include "ui/console.h" diff --git a/hw/usb.h b/hw/usb.h index efae65dcad..81e265c4fd 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -26,7 +26,7 @@ */ #include "qdev.h" -#include "qemu-queue.h" +#include "qemu/queue.h" /* Constants related to the USB / PCI interaction */ #define USB_SBRN 0x60 /* Serial Bus Release Number Register */ diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c index 4a0c299457..13f6602ad2 100644 --- a/hw/usb/combined-packet.c +++ b/hw/usb/combined-packet.c @@ -21,7 +21,7 @@ */ #include "qemu-common.h" #include "hw/usb.h" -#include "iov.h" +#include "qemu/iov.h" #include "trace.h" static void usb_combined_packet_add(USBCombinedPacket *combined, USBPacket *p) diff --git a/hw/usb/core.c b/hw/usb/core.c index 8e360d3ec0..e315fc1021 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -25,7 +25,7 @@ */ #include "qemu-common.h" #include "hw/usb.h" -#include "iov.h" +#include "qemu/iov.h" #include "trace.h" void usb_attach(USBPort *port) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 6953f2e710..ce38fef9f6 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -26,7 +26,7 @@ #include "ui/console.h" #include "hw/usb.h" #include "hw/usb/desc.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/hid.h" /* HID interface requests */ diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index bf289ff5a6..e8ada9f02c 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -27,10 +27,10 @@ #include "hw/usb.h" #include "hw/usb/desc.h" #include "net/net.h" -#include "qemu-queue.h" -#include "qemu-config.h" +#include "qemu/queue.h" +#include "qemu/config-file.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" /*#define TRAFFIC_DEBUG*/ /* Thanks to NetChip Technologies for donating this product ID. diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 99b19df1d1..2ff4fe247a 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -9,7 +9,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "qemu-char.h" diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 3862c9b6c9..f26bb341f7 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -35,7 +35,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "monitor/monitor.h" diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 0d7597b4d1..6d27bac94f 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -8,8 +8,8 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/usb.h" #include "hw/usb/desc.h" #include "hw/scsi.h" diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index a21b2ba627..9a0088928f 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -10,8 +10,8 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "trace.h" #include "hw/usb.h" diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 8b043966f6..ee77d41db5 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -17,7 +17,7 @@ #include "hw/usb/hcd-ehci.h" #include "hw/pci/pci.h" -#include "range.h" +#include "qemu/range.h" typedef struct EHCIPCIState { PCIDevice pcidev; diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 740f7309fb..5bc80031bf 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -18,7 +18,7 @@ #define HW_USB_EHCI_H 1 #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "monitor/monitor.h" #include "trace.h" diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index c707f7a2bb..64e9e834bf 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -21,7 +21,7 @@ * Only host-mode and non-DMA accesses are currently supported. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/irq.h" #include "hw/hw.h" diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 4faf8e1aed..052c4a3037 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -27,7 +27,7 @@ */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/pci/pci.h" #include "hw/sysbus.h" diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index 04c944613c..c9b8a31465 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -28,8 +28,8 @@ #include "hw/hw.h" #include "hw/usb.h" #include "hw/pci/pci.h" -#include "qemu-timer.h" -#include "iov.h" +#include "qemu/timer.h" +#include "qemu/iov.h" #include "dma.h" #include "trace.h" diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 220c3b536a..e2de71ef1a 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -19,7 +19,7 @@ * License along with this library; if not, see . */ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "hw/usb.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index 5a56e99891..9a8c26ceaf 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -31,7 +31,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "monitor/monitor.h" #include "sysemu.h" #include "trace.h" diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 3621076020..31e5f27595 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -26,10 +26,10 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "iov.h" +#include "qemu/iov.h" #include #include diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 096621cdbd..9f204bc113 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -27,7 +27,7 @@ #include #include "config.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "exec/address-spaces.h" #include "kvm.h" #include "exec/memory.h" @@ -35,9 +35,9 @@ #include "pci/msix.h" #include "pci/pci.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-queue.h" -#include "range.h" +#include "qemu/error-report.h" +#include "qemu/queue.h" +#include "qemu/range.h" /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO diff --git a/hw/vga-isa-mm.c b/hw/vga-isa-mm.c index 008703ff57..311c966f77 100644 --- a/hw/vga-isa-mm.c +++ b/hw/vga-isa-mm.c @@ -26,7 +26,7 @@ #include "pc.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #define VGA_RAM_SIZE (8192 * 1024) diff --git a/hw/vga-isa.c b/hw/vga-isa.c index d1d5b11828..cbe7b05a7e 100644 --- a/hw/vga-isa.c +++ b/hw/vga-isa.c @@ -28,7 +28,7 @@ #include "pc.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "loader.h" typedef struct ISAVGAState { diff --git a/hw/vga-pci.c b/hw/vga-pci.c index fe3a3d4899..87c7c0648d 100644 --- a/hw/vga-pci.c +++ b/hw/vga-pci.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "loader.h" #define PCI_VGA_IOPORT_OFFSET 0x400 diff --git a/hw/vga.c b/hw/vga.c index 4007116859..e2ba7f208c 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -28,7 +28,7 @@ #include "pci/pci.h" #include "vga_int.h" #include "ui/pixel_ops.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "xen.h" #include "trace.h" diff --git a/hw/vhost.c b/hw/vhost.c index feaff64c15..4e1cb47418 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -16,7 +16,7 @@ #include #include "vhost.h" #include "hw/hw.h" -#include "range.h" +#include "qemu/range.h" #include #include "exec/address-spaces.h" diff --git a/hw/vhost_net.c b/hw/vhost_net.c index 93ad89a11c..ae2785d83f 100644 --- a/hw/vhost_net.c +++ b/hw/vhost_net.c @@ -18,7 +18,7 @@ #include "virtio-net.h" #include "vhost_net.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "config.h" diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 0f27c2b414..5134e2f477 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -32,7 +32,7 @@ #include "device_tree.h" #include "loader.h" #include "elf.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "exec/address-spaces.h" #include "ppc.h" diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 97d3a932d9..2eb709b422 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -13,7 +13,7 @@ * */ -#include "iov.h" +#include "qemu/iov.h" #include "qemu-common.h" #include "virtio.h" #include "pc.h" diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index e25cc96477..208caa2642 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "trace.h" #include "hw/block-common.h" #include "blockdev.h" diff --git a/hw/virtio-console.c b/hw/virtio-console.c index cffee3d470..df0951e973 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -11,7 +11,7 @@ */ #include "qemu-char.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "trace.h" #include "virtio-serial.h" diff --git a/hw/virtio-net.c b/hw/virtio-net.c index dc7c6d6b56..5d03b31c1b 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -11,13 +11,13 @@ * */ -#include "iov.h" +#include "qemu/iov.h" #include "virtio.h" #include "net/net.h" #include "net/checksum.h" #include "net/tap.h" -#include "qemu-error.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/timer.h" #include "virtio-net.h" #include "vhost_net.h" diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index a2355dc867..f58917f75f 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -23,14 +23,14 @@ #include "virtio-serial.h" #include "virtio-scsi.h" #include "pci/pci.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "pci/msi.h" #include "pci/msix.h" #include "loader.h" #include "kvm.h" #include "blockdev.h" #include "virtio-pci.h" -#include "range.h" +#include "qemu/range.h" /* from Linux's linux/virtio_pci.h */ diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c index a73ef8e334..e063127df6 100644 --- a/hw/virtio-rng.c +++ b/hw/virtio-rng.c @@ -9,7 +9,7 @@ * top-level directory. */ -#include "iov.h" +#include "qemu/iov.h" #include "qdev.h" #include "virtio.h" #include "virtio-rng.h" diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 5559518a93..fc5cb32277 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -18,9 +18,9 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "iov.h" +#include "qemu/iov.h" #include "monitor/monitor.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "sysbus.h" #include "trace.h" #include "virtio-serial.h" diff --git a/hw/virtio.c b/hw/virtio.c index f40a8c5571..0455a9e8f3 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -14,9 +14,9 @@ #include #include "trace.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "virtio.h" -#include "qemu-barrier.h" +#include "qemu/atomic.h" /* The alignment to use between consumer and producer parts of vring. * x86 pagesize again. */ diff --git a/hw/virtio.h b/hw/virtio.h index cdcb490733..511a16992e 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -18,7 +18,7 @@ #include "net/net.h" #include "qdev.h" #include "sysemu.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #ifdef CONFIG_LINUX #include "9p.h" #endif diff --git a/hw/vt82c686.c b/hw/vt82c686.c index edceb5a01d..a18aaed217 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -23,7 +23,7 @@ #include "acpi.h" #include "pm_smbus.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/address-spaces.h" typedef uint32_t pci_addr_t; diff --git a/hw/watchdog.c b/hw/watchdog.c index 623b299f71..5b04215374 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -20,9 +20,9 @@ */ #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-config.h" -#include "qemu-queue.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "qemu/queue.h" #include "qapi/qmp/types.h" #include "monitor/monitor.h" #include "sysemu.h" diff --git a/hw/watchdog.h b/hw/watchdog.h index c12a29311a..3e9a970686 100644 --- a/hw/watchdog.h +++ b/hw/watchdog.h @@ -22,7 +22,7 @@ #ifndef QEMU_WATCHDOG_H #define QEMU_WATCHDOG_H -#include "qemu-queue.h" +#include "qemu/queue.h" struct WatchdogTimerModel { QLIST_ENTRY(WatchdogTimerModel) entry; diff --git a/hw/wdt_i6300esb.c b/hw/wdt_i6300esb.c index 181774220d..54f0665135 100644 --- a/hw/wdt_i6300esb.c +++ b/hw/wdt_i6300esb.c @@ -22,7 +22,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "watchdog.h" #include "hw.h" #include "pci/pci.h" diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c index 7f6c21d809..4475f7b862 100644 --- a/hw/wdt_ib700.c +++ b/hw/wdt_ib700.c @@ -20,7 +20,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "watchdog.h" #include "hw.h" #include "isa.h" diff --git a/hw/xen_backend.c b/hw/xen_backend.c index f83a1e1d09..270584fc10 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -36,7 +36,7 @@ #include "hw.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "xen_backend.h" #include diff --git a/hw/xen_common.h b/hw/xen_common.h index 727757afb4..95bc9a7825 100644 --- a/hw/xen_common.h +++ b/hw/xen_common.h @@ -16,7 +16,7 @@ #include "hw.h" #include "xen.h" -#include "qemu-queue.h" +#include "qemu/queue.h" /* * We don't support Xen prior to 3.3.0. diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c index db1497469a..a4272f0680 100644 --- a/hw/xen_domainbuild.c +++ b/hw/xen_domainbuild.c @@ -1,8 +1,8 @@ #include #include "xen_backend.h" #include "xen_domainbuild.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include diff --git a/hw/xen_pt.c b/hw/xen_pt.c index 5c50d562d9..9ebd028f2e 100644 --- a/hw/xen_pt.c +++ b/hw/xen_pt.c @@ -58,7 +58,7 @@ #include "xen.h" #include "xen_backend.h" #include "xen_pt.h" -#include "range.h" +#include "qemu/range.h" #include "exec/address-spaces.h" #define XEN_PT_NR_IRQS (256) diff --git a/hw/xen_pt_config_init.c b/hw/xen_pt_config_init.c index 0a5f82cb80..54a179af90 100644 --- a/hw/xen_pt_config_init.c +++ b/hw/xen_pt_config_init.c @@ -12,7 +12,7 @@ * This file implements direct PCI assignment to a HVM guest */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "xen_backend.h" #include "xen_pt.h" diff --git a/hw/xgmac.c b/hw/xgmac.c index d0d510ed6a..acc3d37648 100644 --- a/hw/xgmac.c +++ b/hw/xgmac.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "qemu-char.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "net/net.h" #include "net/checksum.h" diff --git a/hw/xilinx_axidma.c b/hw/xilinx_axidma.c index 2fd6068428..ce02764b3f 100644 --- a/hw/xilinx_axidma.c +++ b/hw/xilinx_axidma.c @@ -23,9 +23,9 @@ */ #include "sysbus.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "qdev-addr.h" #include "stream.h" diff --git a/hw/xilinx_axienet.c b/hw/xilinx_axienet.c index 35979e65c9..09e49b0aee 100644 --- a/hw/xilinx_axienet.c +++ b/hw/xilinx_axienet.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "net/net.h" #include "net/checksum.h" diff --git a/hw/xilinx_spi.c b/hw/xilinx_spi.c index 039027442c..4eed1828e3 100644 --- a/hw/xilinx_spi.c +++ b/hw/xilinx_spi.c @@ -26,7 +26,7 @@ #include "sysbus.h" #include "sysemu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "fifo.h" #include "ssi.h" diff --git a/hw/xilinx_spips.c b/hw/xilinx_spips.c index ee7656d7d8..ebe375e56f 100644 --- a/hw/xilinx_spips.c +++ b/hw/xilinx_spips.c @@ -25,10 +25,10 @@ #include "sysbus.h" #include "sysemu.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "fifo.h" #include "ssi.h" -#include "bitops.h" +#include "qemu/bitops.h" #ifdef XILINX_SPIPS_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/hw/xilinx_timer.c b/hw/xilinx_timer.c index 2b01dc2869..69294bb83c 100644 --- a/hw/xilinx_timer.c +++ b/hw/xilinx_timer.c @@ -24,7 +24,7 @@ #include "sysbus.h" #include "ptimer.h" -#include "qemu-log.h" +#include "qemu/log.h" #define D(x) diff --git a/hw/xtensa_pic.c b/hw/xtensa_pic.c index 1ec70cd969..97d36be272 100644 --- a/hw/xtensa_pic.c +++ b/hw/xtensa_pic.c @@ -26,8 +26,8 @@ */ #include "hw.h" -#include "qemu-log.h" -#include "qemu-timer.h" +#include "qemu/log.h" +#include "qemu/timer.h" void xtensa_advance_ccount(CPUXtensaState *env, uint32_t d) { diff --git a/hw/zynq_slcr.c b/hw/zynq_slcr.c index dde4306195..c7ce51f4a6 100644 --- a/hw/zynq_slcr.c +++ b/hw/zynq_slcr.c @@ -15,7 +15,7 @@ */ #include "hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysbus.h" #include "sysemu.h" diff --git a/include/block/aio.h b/include/block/aio.h index 31884a8f16..0933f05878 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -15,8 +15,8 @@ #define QEMU_AIO_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "event_notifier.h" +#include "qemu/queue.h" +#include "qemu/event_notifier.h" typedef struct BlockDriverAIOCB BlockDriverAIOCB; typedef void BlockDriverCompletionFunc(void *opaque, int ret); diff --git a/include/block/block.h b/include/block/block.h index d49ce4dbc5..b81d200b03 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -3,7 +3,7 @@ #include "block/aio.h" #include "qemu-common.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "block/coroutine.h" #include "qapi/qmp/qobject.h" #include "qapi-types.h" diff --git a/include/block/block_int.h b/include/block/block_int.h index 14c57afd54..f83ffb8a08 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -25,10 +25,10 @@ #define BLOCK_INT_H #include "block/block.h" -#include "qemu-option.h" -#include "qemu-queue.h" +#include "qemu/option.h" +#include "qemu/queue.h" #include "block/coroutine.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qapi-types.h" #include "qapi/qmp/qerror.h" #include "monitor/monitor.h" diff --git a/include/block/coroutine.h b/include/block/coroutine.h index 34c15d4116..c31fae3f3c 100644 --- a/include/block/coroutine.h +++ b/include/block/coroutine.h @@ -16,8 +16,8 @@ #define QEMU_COROUTINE_H #include -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/queue.h" +#include "qemu/timer.h" /** * Coroutines are a mechanism for stack switching and can be used for diff --git a/include/block/coroutine_int.h b/include/block/coroutine_int.h index 282a3ceda6..17eb71e723 100644 --- a/include/block/coroutine_int.h +++ b/include/block/coroutine_int.h @@ -25,7 +25,7 @@ #ifndef QEMU_COROUTINE_INT_H #define QEMU_COROUTINE_INT_H -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/coroutine.h" typedef enum { diff --git a/include/block/thread-pool.h b/include/block/thread-pool.h index a87b287081..200703e35f 100644 --- a/include/block/thread-pool.h +++ b/include/block/thread-pool.h @@ -19,8 +19,8 @@ #define QEMU_THREAD_POOL_H 1 #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" +#include "qemu/queue.h" +#include "qemu/thread.h" #include "block/coroutine.h" #include "block/block_int.h" diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index bec04e2008..c12e35f54d 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -20,7 +20,7 @@ #define CPU_ALL_H #include "qemu-common.h" -#include "qemu-tls.h" +#include "qemu/tls.h" #include "exec/cpu-common.h" /* some important defines: diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index f83d6180f3..4d4f8d4e98 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -9,8 +9,8 @@ #include "exec/poison.h" #endif -#include "bswap.h" -#include "qemu-queue.h" +#include "qemu/bswap.h" +#include "qemu/queue.h" #if !defined(CONFIG_USER_ONLY) diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index 8d2230e50e..aea0ece051 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -27,8 +27,8 @@ #include #include #include -#include "osdep.h" -#include "qemu-queue.h" +#include "qemu/osdep.h" +#include "qemu/queue.h" #include "exec/hwaddr.h" #ifndef TARGET_LONG_BITS diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 2ae8aae3d6..46dca74fda 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -70,7 +70,7 @@ typedef struct TranslationBlock TranslationBlock; #define OPPARAM_BUF_SIZE (OPC_BUF_SIZE * MAX_OPC_PARAM) -#include "qemu-log.h" +#include "qemu/log.h" void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb); void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb); diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index 1541f0b1e4..8043b3ba26 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -1,7 +1,7 @@ #ifndef GEN_ICOUNT_H #define GEN_ICOUNT_H 1 -#include "qemu-timer.h" +#include "qemu/timer.h" /* Helpers for instruction counting code generation. */ diff --git a/include/exec/memory.h b/include/exec/memory.h index b0c474584f..aada969628 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -21,10 +21,10 @@ #include "qemu-common.h" #include "exec/cpu-common.h" #include "exec/hwaddr.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "exec/iorange.h" #include "exec/ioport.h" -#include "int128.h" +#include "qemu/int128.h" typedef struct MemoryRegionOps MemoryRegionOps; typedef struct MemoryRegion MemoryRegion; diff --git a/include/exec/softmmu_template.h b/include/exec/softmmu_template.h index 15d4c519ee..b219191abd 100644 --- a/include/exec/softmmu_template.h +++ b/include/exec/softmmu_template.h @@ -21,7 +21,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/memory.h" #define DATA_SIZE (1 << SHIFT) diff --git a/include/migration/migration.h b/include/migration/migration.h index a95f761e4c..8b7af61e7e 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -16,7 +16,7 @@ #include "qapi/qmp/qdict.h" #include "qemu-common.h" -#include "notify.h" +#include "qemu/notify.h" #include "qapi/error.h" #include "migration/vmstate.h" #include "qapi-types.h" diff --git a/include/net/net.h b/include/net/net.h index 41d3729867..de42dd76da 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -1,10 +1,10 @@ #ifndef QEMU_NET_H #define QEMU_NET_H -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/qdict.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "net/queue.h" #include "migration/vmstate.h" #include "qapi-types.h" diff --git a/include/net/slirp.h b/include/net/slirp.h index ac9d44964f..54b655c272 100644 --- a/include/net/slirp.h +++ b/include/net/slirp.h @@ -26,7 +26,7 @@ #include "qemu-common.h" #include "qapi/qmp/qdict.h" -#include "qemu-option.h" +#include "qemu/option.h" #include "qapi-types.h" #ifdef CONFIG_SLIRP diff --git a/include/qapi/error.h b/include/qapi/error.h index 4d52e7369e..5cd2f0c302 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -12,7 +12,7 @@ #ifndef ERROR_H #define ERROR_H -#include "compiler.h" +#include "qemu/compiler.h" #include "qapi-types.h" #include diff --git a/include/qapi/opts-visitor.h b/include/qapi/opts-visitor.h index 31fa4c5628..5939eeebc7 100644 --- a/include/qapi/opts-visitor.h +++ b/include/qapi/opts-visitor.h @@ -14,7 +14,7 @@ #define OPTS_VISITOR_H #include "qapi/visitor.h" -#include "qemu-option.h" +#include "qemu/option.h" typedef struct OptsVisitor OptsVisitor; diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index c815981d30..6d9a4be3a5 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -15,7 +15,7 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include #define QDICT_BUCKET_MAX 512 diff --git a/include/qapi/qmp/qerror.h b/include/qapi/qmp/qerror.h index d912297590..6c0a18dfc4 100644 --- a/include/qapi/qmp/qerror.h +++ b/include/qapi/qmp/qerror.h @@ -14,7 +14,7 @@ #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "qapi-types.h" #include diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h index 0473374bf2..73351ed6d6 100644 --- a/include/qapi/qmp/qjson.h +++ b/include/qapi/qmp/qjson.h @@ -15,7 +15,7 @@ #define QJSON_H #include -#include "compiler.h" +#include "qemu/compiler.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index ffa0846d48..382f04c3c4 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -14,8 +14,8 @@ #define QLIST_H #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" -#include "qemu-queue.h" +#include "qemu/queue.h" +#include "qemu/queue.h" typedef struct QListEntry { QObject *value; diff --git a/include/qemu/acl.h b/include/qemu/acl.h new file mode 100644 index 0000000000..116487e282 --- /dev/null +++ b/include/qemu/acl.h @@ -0,0 +1,74 @@ +/* + * QEMU access control list management + * + * Copyright (C) 2009 Red Hat, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef __QEMU_ACL_H__ +#define __QEMU_ACL_H__ + +#include "qemu/queue.h" + +typedef struct qemu_acl_entry qemu_acl_entry; +typedef struct qemu_acl qemu_acl; + +struct qemu_acl_entry { + char *match; + int deny; + + QTAILQ_ENTRY(qemu_acl_entry) next; +}; + +struct qemu_acl { + char *aclname; + unsigned int nentries; + QTAILQ_HEAD(,qemu_acl_entry) entries; + int defaultDeny; +}; + +qemu_acl *qemu_acl_init(const char *aclname); + +qemu_acl *qemu_acl_find(const char *aclname); + +int qemu_acl_party_is_allowed(qemu_acl *acl, + const char *party); + +void qemu_acl_reset(qemu_acl *acl); + +int qemu_acl_append(qemu_acl *acl, + int deny, + const char *match); +int qemu_acl_insert(qemu_acl *acl, + int deny, + const char *match, + int index); +int qemu_acl_remove(qemu_acl *acl, + const char *match); + +#endif /* __QEMU_ACL_H__ */ + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * tab-width: 8 + * End: + */ diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h new file mode 100644 index 0000000000..96a194bbee --- /dev/null +++ b/include/qemu/atomic.h @@ -0,0 +1,67 @@ +#ifndef __QEMU_BARRIER_H +#define __QEMU_BARRIER_H 1 + +/* Compiler barrier */ +#define barrier() asm volatile("" ::: "memory") + +#if defined(__i386__) + +#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ + +/* + * Because of the strongly ordered x86 storage model, wmb() and rmb() are nops + * on x86(well, a compiler barrier only). Well, at least as long as + * qemu doesn't do accesses to write-combining memory or non-temporal + * load/stores from C code. + */ +#define smp_wmb() barrier() +#define smp_rmb() barrier() +/* + * We use GCC builtin if it's available, as that can use + * mfence on 32 bit as well, e.g. if built with -march=pentium-m. + * However, on i386, there seem to be known bugs as recently as 4.3. + * */ +#if QEMU_GNUC_PREREQ(4, 4) +#define smp_mb() __sync_synchronize() +#else +#define smp_mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") +#endif + +#elif defined(__x86_64__) + +#define smp_wmb() barrier() +#define smp_rmb() barrier() +#define smp_mb() asm volatile("mfence" ::: "memory") + +#elif defined(_ARCH_PPC) + +/* + * We use an eieio() for wmb() on powerpc. This assumes we don't + * need to order cacheable and non-cacheable stores with respect to + * each other + */ +#define smp_wmb() asm volatile("eieio" ::: "memory") + +#if defined(__powerpc64__) +#define smp_rmb() asm volatile("lwsync" ::: "memory") +#else +#define smp_rmb() asm volatile("sync" ::: "memory") +#endif + +#define smp_mb() asm volatile("sync" ::: "memory") + +#else + +/* + * For (host) platforms we don't have explicit barrier definitions + * for, we use the gcc __sync_synchronize() primitive to generate a + * full barrier. This should be safe on all platforms, though it may + * be overkill for wmb() and rmb(). + */ +#define smp_wmb() __sync_synchronize() +#define smp_mb() __sync_synchronize() +#define smp_rmb() __sync_synchronize() + +#endif + +#endif diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h new file mode 100644 index 0000000000..308bbb71e9 --- /dev/null +++ b/include/qemu/bitmap.h @@ -0,0 +1,222 @@ +/* + * Bitmap Module + * + * Copyright (C) 2010 Corentin Chary + * + * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef BITMAP_H +#define BITMAP_H + +#include "qemu-common.h" +#include "qemu/bitops.h" + +/* + * The available bitmap operations and their rough meaning in the + * case that the bitmap is a single unsigned long are thus: + * + * Note that nbits should be always a compile time evaluable constant. + * Otherwise many inlines will generate horrible code. + * + * bitmap_zero(dst, nbits) *dst = 0UL + * bitmap_fill(dst, nbits) *dst = ~0UL + * bitmap_copy(dst, src, nbits) *dst = *src + * bitmap_and(dst, src1, src2, nbits) *dst = *src1 & *src2 + * bitmap_or(dst, src1, src2, nbits) *dst = *src1 | *src2 + * bitmap_xor(dst, src1, src2, nbits) *dst = *src1 ^ *src2 + * bitmap_andnot(dst, src1, src2, nbits) *dst = *src1 & ~(*src2) + * bitmap_complement(dst, src, nbits) *dst = ~(*src) + * bitmap_equal(src1, src2, nbits) Are *src1 and *src2 equal? + * bitmap_intersects(src1, src2, nbits) Do *src1 and *src2 overlap? + * bitmap_empty(src, nbits) Are all bits zero in *src? + * bitmap_full(src, nbits) Are all bits set in *src? + * bitmap_set(dst, pos, nbits) Set specified bit area + * bitmap_clear(dst, pos, nbits) Clear specified bit area + * bitmap_find_next_zero_area(buf, len, pos, n, mask) Find bit free area + */ + +/* + * Also the following operations apply to bitmaps. + * + * set_bit(bit, addr) *addr |= bit + * clear_bit(bit, addr) *addr &= ~bit + * change_bit(bit, addr) *addr ^= bit + * test_bit(bit, addr) Is bit set in *addr? + * test_and_set_bit(bit, addr) Set bit and return old value + * test_and_clear_bit(bit, addr) Clear bit and return old value + * test_and_change_bit(bit, addr) Change bit and return old value + * find_first_zero_bit(addr, nbits) Position first zero bit in *addr + * find_first_bit(addr, nbits) Position first set bit in *addr + * find_next_zero_bit(addr, nbits, bit) Position next zero bit in *addr >= bit + * find_next_bit(addr, nbits, bit) Position next set bit in *addr >= bit + */ + +#define BITMAP_LAST_WORD_MASK(nbits) \ + ( \ + ((nbits) % BITS_PER_LONG) ? \ + (1UL<<((nbits) % BITS_PER_LONG))-1 : ~0UL \ + ) + +#define DECLARE_BITMAP(name,bits) \ + unsigned long name[BITS_TO_LONGS(bits)] + +#define small_nbits(nbits) \ + ((nbits) <= BITS_PER_LONG) + +int slow_bitmap_empty(const unsigned long *bitmap, int bits); +int slow_bitmap_full(const unsigned long *bitmap, int bits); +int slow_bitmap_equal(const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_complement(unsigned long *dst, const unsigned long *src, + int bits); +void slow_bitmap_shift_right(unsigned long *dst, + const unsigned long *src, int shift, int bits); +void slow_bitmap_shift_left(unsigned long *dst, + const unsigned long *src, int shift, int bits); +int slow_bitmap_and(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_or(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +void slow_bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int slow_bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); +int slow_bitmap_intersects(const unsigned long *bitmap1, + const unsigned long *bitmap2, int bits); + +static inline unsigned long *bitmap_new(int nbits) +{ + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + return g_malloc0(len); +} + +static inline void bitmap_zero(unsigned long *dst, int nbits) +{ + if (small_nbits(nbits)) { + *dst = 0UL; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + memset(dst, 0, len); + } +} + +static inline void bitmap_fill(unsigned long *dst, int nbits) +{ + size_t nlongs = BITS_TO_LONGS(nbits); + if (!small_nbits(nbits)) { + int len = (nlongs - 1) * sizeof(unsigned long); + memset(dst, 0xff, len); + } + dst[nlongs - 1] = BITMAP_LAST_WORD_MASK(nbits); +} + +static inline void bitmap_copy(unsigned long *dst, const unsigned long *src, + int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + memcpy(dst, src, len); + } +} + +static inline int bitmap_and(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return (*dst = *src1 & *src2) != 0; + } + return slow_bitmap_and(dst, src1, src2, nbits); +} + +static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src1 | *src2; + } else { + slow_bitmap_or(dst, src1, src2, nbits); + } +} + +static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + *dst = *src1 ^ *src2; + } else { + slow_bitmap_xor(dst, src1, src2, nbits); + } +} + +static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return (*dst = *src1 & ~(*src2)) != 0; + } + return slow_bitmap_andnot(dst, src1, src2, nbits); +} + +static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, + int nbits) +{ + if (small_nbits(nbits)) { + *dst = ~(*src) & BITMAP_LAST_WORD_MASK(nbits); + } else { + slow_bitmap_complement(dst, src, nbits); + } +} + +static inline int bitmap_equal(const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_equal(src1, src2, nbits); + } +} + +static inline int bitmap_empty(const unsigned long *src, int nbits) +{ + if (small_nbits(nbits)) { + return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_empty(src, nbits); + } +} + +static inline int bitmap_full(const unsigned long *src, int nbits) +{ + if (small_nbits(nbits)) { + return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); + } else { + return slow_bitmap_full(src, nbits); + } +} + +static inline int bitmap_intersects(const unsigned long *src1, + const unsigned long *src2, int nbits) +{ + if (small_nbits(nbits)) { + return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0; + } else { + return slow_bitmap_intersects(src1, src2, nbits); + } +} + +void bitmap_set(unsigned long *map, int i, int len); +void bitmap_clear(unsigned long *map, int start, int nr); +unsigned long bitmap_find_next_zero_area(unsigned long *map, + unsigned long size, + unsigned long start, + unsigned int nr, + unsigned long align_mask); + +#endif /* BITMAP_H */ diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h new file mode 100644 index 0000000000..74e14e5724 --- /dev/null +++ b/include/qemu/bitops.h @@ -0,0 +1,362 @@ +/* + * Bitops Module + * + * Copyright (C) 2010 Corentin Chary + * + * Mostly inspired by (stolen from) linux/bitmap.h and linux/bitops.h + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef BITOPS_H +#define BITOPS_H + +#include "qemu-common.h" + +#define BITS_PER_BYTE CHAR_BIT +#define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) + +#define BIT(nr) (1UL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) + +/** + * bitops_ffs - find first bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static unsigned long bitops_ffsl(unsigned long word) +{ + int num = 0; + +#if LONG_MAX > 0x7FFFFFFF + if ((word & 0xffffffff) == 0) { + num += 32; + word >>= 32; + } +#endif + if ((word & 0xffff) == 0) { + num += 16; + word >>= 16; + } + if ((word & 0xff) == 0) { + num += 8; + word >>= 8; + } + if ((word & 0xf) == 0) { + num += 4; + word >>= 4; + } + if ((word & 0x3) == 0) { + num += 2; + word >>= 2; + } + if ((word & 0x1) == 0) { + num += 1; + } + return num; +} + +/** + * bitops_fls - find last (most-significant) set bit in a long word + * @word: the word to search + * + * Undefined if no set bit exists, so code should check against 0 first. + */ +static inline unsigned long bitops_flsl(unsigned long word) +{ + int num = BITS_PER_LONG - 1; + +#if LONG_MAX > 0x7FFFFFFF + if (!(word & (~0ul << 32))) { + num -= 32; + word <<= 32; + } +#endif + if (!(word & (~0ul << (BITS_PER_LONG-16)))) { + num -= 16; + word <<= 16; + } + if (!(word & (~0ul << (BITS_PER_LONG-8)))) { + num -= 8; + word <<= 8; + } + if (!(word & (~0ul << (BITS_PER_LONG-4)))) { + num -= 4; + word <<= 4; + } + if (!(word & (~0ul << (BITS_PER_LONG-2)))) { + num -= 2; + + word <<= 2; + } + if (!(word & (~0ul << (BITS_PER_LONG-1)))) + num -= 1; + return num; +} + +/** + * ffz - find first zero in word. + * @word: The word to search + * + * Undefined if no zero exists, so code should check against ~0UL first. + */ +static inline unsigned long ffz(unsigned long word) +{ + return bitops_ffsl(~word); +} + +/** + * set_bit - Set a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + */ +static inline void set_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p |= mask; +} + +/** + * clear_bit - Clears a bit in memory + * @nr: Bit to clear + * @addr: Address to start counting from + */ +static inline void clear_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p &= ~mask; +} + +/** + * change_bit - Toggle a bit in memory + * @nr: Bit to change + * @addr: Address to start counting from + */ +static inline void change_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + + *p ^= mask; +} + +/** + * test_and_set_bit - Set a bit and return its old value + * @nr: Bit to set + * @addr: Address to count from + */ +static inline int test_and_set_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old | mask; + return (old & mask) != 0; +} + +/** + * test_and_clear_bit - Clear a bit and return its old value + * @nr: Bit to clear + * @addr: Address to count from + */ +static inline int test_and_clear_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old & ~mask; + return (old & mask) != 0; +} + +/** + * test_and_change_bit - Change a bit and return its old value + * @nr: Bit to change + * @addr: Address to count from + */ +static inline int test_and_change_bit(int nr, unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = addr + BIT_WORD(nr); + unsigned long old = *p; + + *p = old ^ mask; + return (old & mask) != 0; +} + +/** + * test_bit - Determine whether a bit is set + * @nr: bit number to test + * @addr: Address to start counting from + */ +static inline int test_bit(int nr, const unsigned long *addr) +{ + return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); +} + +/** + * find_last_bit - find the last set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit, or size. + */ +unsigned long find_last_bit(const unsigned long *addr, + unsigned long size); + +/** + * find_next_bit - find the next set bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ +unsigned long find_next_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); + +/** + * find_next_zero_bit - find the next cleared bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ + +unsigned long find_next_zero_bit(const unsigned long *addr, + unsigned long size, + unsigned long offset); + +/** + * find_first_bit - find the first set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit. + */ +static inline unsigned long find_first_bit(const unsigned long *addr, + unsigned long size) +{ + return find_next_bit(addr, size, 0); +} + +/** + * find_first_zero_bit - find the first cleared bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first cleared bit. + */ +static inline unsigned long find_first_zero_bit(const unsigned long *addr, + unsigned long size) +{ + return find_next_zero_bit(addr, size, 0); +} + +static inline unsigned long hweight_long(unsigned long w) +{ + unsigned long count; + + for (count = 0; w; w >>= 1) { + count += w & 1; + } + return count; +} + +/** + * extract32: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 32 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 32 bit word. It is valid to request that + * all 32 bits are returned (ie @length 32 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint32_t extract32(uint32_t value, int start, int length) +{ + assert(start >= 0 && length > 0 && length <= 32 - start); + return (value >> start) & (~0U >> (32 - length)); +} + +/** + * extract64: + * @value: the value to extract the bit field from + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * + * Extract from the 64 bit input @value the bit field specified by the + * @start and @length parameters, and return it. The bit field must + * lie entirely within the 64 bit word. It is valid to request that + * all 64 bits are returned (ie @length 64 and @start 0). + * + * Returns: the value of the bit field extracted from the input value. + */ +static inline uint64_t extract64(uint64_t value, int start, int length) +{ + assert(start >= 0 && length > 0 && length <= 64 - start); + return (value >> start) & (~0ULL >> (64 - length)); +} + +/** + * deposit32: + * @value: initial value to insert bit field into + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * @fieldval: the value to insert into the bit field + * + * Deposit @fieldval into the 32 bit @value at the bit field specified + * by the @start and @length parameters, and return the modified + * @value. Bits of @value outside the bit field are not modified. + * Bits of @fieldval above the least significant @length bits are + * ignored. The bit field must lie entirely within the 32 bit word. + * It is valid to request that all 32 bits are modified (ie @length + * 32 and @start 0). + * + * Returns: the modified @value. + */ +static inline uint32_t deposit32(uint32_t value, int start, int length, + uint32_t fieldval) +{ + uint32_t mask; + assert(start >= 0 && length > 0 && length <= 32 - start); + mask = (~0U >> (32 - length)) << start; + return (value & ~mask) | ((fieldval << start) & mask); +} + +/** + * deposit64: + * @value: initial value to insert bit field into + * @start: the lowest bit in the bit field (numbered from 0) + * @length: the length of the bit field + * @fieldval: the value to insert into the bit field + * + * Deposit @fieldval into the 64 bit @value at the bit field specified + * by the @start and @length parameters, and return the modified + * @value. Bits of @value outside the bit field are not modified. + * Bits of @fieldval above the least significant @length bits are + * ignored. The bit field must lie entirely within the 64 bit word. + * It is valid to request that all 64 bits are modified (ie @length + * 64 and @start 0). + * + * Returns: the modified @value. + */ +static inline uint64_t deposit64(uint64_t value, int start, int length, + uint64_t fieldval) +{ + uint64_t mask; + assert(start >= 0 && length > 0 && length <= 64 - start); + mask = (~0ULL >> (64 - length)) << start; + return (value & ~mask) | ((fieldval << start) & mask); +} + +#endif diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h new file mode 100644 index 0000000000..cc7f84d30f --- /dev/null +++ b/include/qemu/bswap.h @@ -0,0 +1,713 @@ +#ifndef BSWAP_H +#define BSWAP_H + +#include "config-host.h" + +#include +#include "softfloat.h" + +#ifdef CONFIG_MACHINE_BSWAP_H +#include +#include +#include +#else + +#ifdef CONFIG_BYTESWAP_H +#include +#else + +#define bswap_16(x) \ +({ \ + uint16_t __x = (x); \ + ((uint16_t)( \ + (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ +}) + +#define bswap_32(x) \ +({ \ + uint32_t __x = (x); \ + ((uint32_t)( \ + (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ +}) + +#define bswap_64(x) \ +({ \ + uint64_t __x = (x); \ + ((uint64_t)( \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ +}) + +#endif /* !CONFIG_BYTESWAP_H */ + +static inline uint16_t bswap16(uint16_t x) +{ + return bswap_16(x); +} + +static inline uint32_t bswap32(uint32_t x) +{ + return bswap_32(x); +} + +static inline uint64_t bswap64(uint64_t x) +{ + return bswap_64(x); +} + +#endif /* ! CONFIG_MACHINE_BSWAP_H */ + +static inline void bswap16s(uint16_t *s) +{ + *s = bswap16(*s); +} + +static inline void bswap32s(uint32_t *s) +{ + *s = bswap32(*s); +} + +static inline void bswap64s(uint64_t *s) +{ + *s = bswap64(*s); +} + +#if defined(HOST_WORDS_BIGENDIAN) +#define be_bswap(v, size) (v) +#define le_bswap(v, size) bswap ## size(v) +#define be_bswaps(v, size) +#define le_bswaps(p, size) *p = bswap ## size(*p); +#else +#define le_bswap(v, size) (v) +#define be_bswap(v, size) bswap ## size(v) +#define le_bswaps(v, size) +#define be_bswaps(p, size) *p = bswap ## size(*p); +#endif + +#define CPU_CONVERT(endian, size, type)\ +static inline type endian ## size ## _to_cpu(type v)\ +{\ + return endian ## _bswap(v, size);\ +}\ +\ +static inline type cpu_to_ ## endian ## size(type v)\ +{\ + return endian ## _bswap(v, size);\ +}\ +\ +static inline void endian ## size ## _to_cpus(type *p)\ +{\ + endian ## _bswaps(p, size)\ +}\ +\ +static inline void cpu_to_ ## endian ## size ## s(type *p)\ +{\ + endian ## _bswaps(p, size)\ +}\ +\ +static inline type endian ## size ## _to_cpup(const type *p)\ +{\ + return endian ## size ## _to_cpu(*p);\ +}\ +\ +static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\ +{\ + *p = cpu_to_ ## endian ## size(v);\ +} + +CPU_CONVERT(be, 16, uint16_t) +CPU_CONVERT(be, 32, uint32_t) +CPU_CONVERT(be, 64, uint64_t) + +CPU_CONVERT(le, 16, uint16_t) +CPU_CONVERT(le, 32, uint32_t) +CPU_CONVERT(le, 64, uint64_t) + +/* unaligned versions (optimized for frequent unaligned accesses)*/ + +#if defined(__i386__) || defined(_ARCH_PPC) + +#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v) +#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v) +#define le16_to_cpupu(p) le16_to_cpup(p) +#define le32_to_cpupu(p) le32_to_cpup(p) +#define be32_to_cpupu(p) be32_to_cpup(p) + +#define cpu_to_be16wu(p, v) cpu_to_be16w(p, v) +#define cpu_to_be32wu(p, v) cpu_to_be32w(p, v) +#define cpu_to_be64wu(p, v) cpu_to_be64w(p, v) + +#else + +static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v & 0xff; + p1[1] = v >> 8; +} + +static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v & 0xff; + p1[1] = v >> 8; + p1[2] = v >> 16; + p1[3] = v >> 24; +} + +static inline uint16_t le16_to_cpupu(const uint16_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[0] | (p1[1] << 8); +} + +static inline uint32_t le32_to_cpupu(const uint32_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24); +} + +static inline uint32_t be32_to_cpupu(const uint32_t *p) +{ + const uint8_t *p1 = (const uint8_t *)p; + return p1[3] | (p1[2] << 8) | (p1[1] << 16) | (p1[0] << 24); +} + +static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 8; + p1[1] = v & 0xff; +} + +static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 24; + p1[1] = v >> 16; + p1[2] = v >> 8; + p1[3] = v & 0xff; +} + +static inline void cpu_to_be64wu(uint64_t *p, uint64_t v) +{ + uint8_t *p1 = (uint8_t *)p; + + p1[0] = v >> 56; + p1[1] = v >> 48; + p1[2] = v >> 40; + p1[3] = v >> 32; + p1[4] = v >> 24; + p1[5] = v >> 16; + p1[6] = v >> 8; + p1[7] = v & 0xff; +} + +#endif + +#ifdef HOST_WORDS_BIGENDIAN +#define cpu_to_32wu cpu_to_be32wu +#define leul_to_cpu(v) glue(glue(le,HOST_LONG_BITS),_to_cpu)(v) +#else +#define cpu_to_32wu cpu_to_le32wu +#define leul_to_cpu(v) (v) +#endif + +#undef le_bswap +#undef be_bswap +#undef le_bswaps +#undef be_bswaps + +/* len must be one of 1, 2, 4 */ +static inline uint32_t qemu_bswap_len(uint32_t value, int len) +{ + return bswap32(value) >> (32 - 8 * len); +} + +typedef union { + float32 f; + uint32_t l; +} CPU_FloatU; + +typedef union { + float64 d; +#if defined(HOST_WORDS_BIGENDIAN) + struct { + uint32_t upper; + uint32_t lower; + } l; +#else + struct { + uint32_t lower; + uint32_t upper; + } l; +#endif + uint64_t ll; +} CPU_DoubleU; + +typedef union { + floatx80 d; + struct { + uint64_t lower; + uint16_t upper; + } l; +} CPU_LDoubleU; + +typedef union { + float128 q; +#if defined(HOST_WORDS_BIGENDIAN) + struct { + uint32_t upmost; + uint32_t upper; + uint32_t lower; + uint32_t lowest; + } l; + struct { + uint64_t upper; + uint64_t lower; + } ll; +#else + struct { + uint32_t lowest; + uint32_t lower; + uint32_t upper; + uint32_t upmost; + } l; + struct { + uint64_t lower; + uint64_t upper; + } ll; +#endif +} CPU_QuadU; + +/* unaligned/endian-independent pointer access */ + +/* + * the generic syntax is: + * + * load: ld{type}{sign}{size}{endian}_p(ptr) + * + * store: st{type}{size}{endian}_p(ptr, val) + * + * Note there are small differences with the softmmu access API! + * + * type is: + * (empty): integer access + * f : float access + * + * sign is: + * (empty): for floats or 32 bit size + * u : unsigned + * s : signed + * + * size is: + * b: 8 bits + * w: 16 bits + * l: 32 bits + * q: 64 bits + * + * endian is: + * (empty): 8 bit access + * be : big endian + * le : little endian + */ +static inline int ldub_p(const void *ptr) +{ + return *(uint8_t *)ptr; +} + +static inline int ldsb_p(const void *ptr) +{ + return *(int8_t *)ptr; +} + +static inline void stb_p(void *ptr, int v) +{ + *(uint8_t *)ptr = v; +} + +/* NOTE: on arm, putting 2 in /proc/sys/debug/alignment so that the + kernel handles unaligned load/stores may give better results, but + it is a system wide setting : bad */ +#if defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) + +/* conservative code for little endian unaligned accesses */ +static inline int lduw_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return val; +#else + const uint8_t *p = ptr; + return p[0] | (p[1] << 8); +#endif +} + +static inline int ldsw_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return (int16_t)val; +#else + const uint8_t *p = ptr; + return (int16_t)(p[0] | (p[1] << 8)); +#endif +} + +static inline int ldl_le_p(const void *ptr) +{ +#ifdef _ARCH_PPC + int val; + __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (ptr)); + return val; +#else + const uint8_t *p = ptr; + return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); +#endif +} + +static inline uint64_t ldq_le_p(const void *ptr) +{ + const uint8_t *p = ptr; + uint32_t v1, v2; + v1 = ldl_le_p(p); + v2 = ldl_le_p(p + 4); + return v1 | ((uint64_t)v2 << 32); +} + +static inline void stw_le_p(void *ptr, int v) +{ +#ifdef _ARCH_PPC + __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*(uint16_t *)ptr) : "r" (v), "r" (ptr)); +#else + uint8_t *p = ptr; + p[0] = v; + p[1] = v >> 8; +#endif +} + +static inline void stl_le_p(void *ptr, int v) +{ +#ifdef _ARCH_PPC + __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*(uint32_t *)ptr) : "r" (v), "r" (ptr)); +#else + uint8_t *p = ptr; + p[0] = v; + p[1] = v >> 8; + p[2] = v >> 16; + p[3] = v >> 24; +#endif +} + +static inline void stq_le_p(void *ptr, uint64_t v) +{ + uint8_t *p = ptr; + stl_le_p(p, (uint32_t)v); + stl_le_p(p + 4, v >> 32); +} + +/* float access */ + +static inline float32 ldfl_le_p(const void *ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = ldl_le_p(ptr); + return u.f; +} + +static inline void stfl_le_p(void *ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + stl_le_p(ptr, u.i); +} + +static inline float64 ldfq_le_p(const void *ptr) +{ + CPU_DoubleU u; + u.l.lower = ldl_le_p(ptr); + u.l.upper = ldl_le_p(ptr + 4); + return u.d; +} + +static inline void stfq_le_p(void *ptr, float64 v) +{ + CPU_DoubleU u; + u.d = v; + stl_le_p(ptr, u.l.lower); + stl_le_p(ptr + 4, u.l.upper); +} + +#else + +static inline int lduw_le_p(const void *ptr) +{ + return *(uint16_t *)ptr; +} + +static inline int ldsw_le_p(const void *ptr) +{ + return *(int16_t *)ptr; +} + +static inline int ldl_le_p(const void *ptr) +{ + return *(uint32_t *)ptr; +} + +static inline uint64_t ldq_le_p(const void *ptr) +{ + return *(uint64_t *)ptr; +} + +static inline void stw_le_p(void *ptr, int v) +{ + *(uint16_t *)ptr = v; +} + +static inline void stl_le_p(void *ptr, int v) +{ + *(uint32_t *)ptr = v; +} + +static inline void stq_le_p(void *ptr, uint64_t v) +{ + *(uint64_t *)ptr = v; +} + +/* float access */ + +static inline float32 ldfl_le_p(const void *ptr) +{ + return *(float32 *)ptr; +} + +static inline float64 ldfq_le_p(const void *ptr) +{ + return *(float64 *)ptr; +} + +static inline void stfl_le_p(void *ptr, float32 v) +{ + *(float32 *)ptr = v; +} + +static inline void stfq_le_p(void *ptr, float64 v) +{ + *(float64 *)ptr = v; +} +#endif + +#if !defined(HOST_WORDS_BIGENDIAN) || defined(WORDS_ALIGNED) + +static inline int lduw_be_p(const void *ptr) +{ +#if defined(__i386__) + int val; + asm volatile ("movzwl %1, %0\n" + "xchgb %b0, %h0\n" + : "=q" (val) + : "m" (*(uint16_t *)ptr)); + return val; +#else + const uint8_t *b = ptr; + return ((b[0] << 8) | b[1]); +#endif +} + +static inline int ldsw_be_p(const void *ptr) +{ +#if defined(__i386__) + int val; + asm volatile ("movzwl %1, %0\n" + "xchgb %b0, %h0\n" + : "=q" (val) + : "m" (*(uint16_t *)ptr)); + return (int16_t)val; +#else + const uint8_t *b = ptr; + return (int16_t)((b[0] << 8) | b[1]); +#endif +} + +static inline int ldl_be_p(const void *ptr) +{ +#if defined(__i386__) || defined(__x86_64__) + int val; + asm volatile ("movl %1, %0\n" + "bswap %0\n" + : "=r" (val) + : "m" (*(uint32_t *)ptr)); + return val; +#else + const uint8_t *b = ptr; + return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]; +#endif +} + +static inline uint64_t ldq_be_p(const void *ptr) +{ + uint32_t a,b; + a = ldl_be_p(ptr); + b = ldl_be_p((uint8_t *)ptr + 4); + return (((uint64_t)a<<32)|b); +} + +static inline void stw_be_p(void *ptr, int v) +{ +#if defined(__i386__) + asm volatile ("xchgb %b0, %h0\n" + "movw %w0, %1\n" + : "=q" (v) + : "m" (*(uint16_t *)ptr), "0" (v)); +#else + uint8_t *d = (uint8_t *) ptr; + d[0] = v >> 8; + d[1] = v; +#endif +} + +static inline void stl_be_p(void *ptr, int v) +{ +#if defined(__i386__) || defined(__x86_64__) + asm volatile ("bswap %0\n" + "movl %0, %1\n" + : "=r" (v) + : "m" (*(uint32_t *)ptr), "0" (v)); +#else + uint8_t *d = (uint8_t *) ptr; + d[0] = v >> 24; + d[1] = v >> 16; + d[2] = v >> 8; + d[3] = v; +#endif +} + +static inline void stq_be_p(void *ptr, uint64_t v) +{ + stl_be_p(ptr, v >> 32); + stl_be_p((uint8_t *)ptr + 4, v); +} + +/* float access */ + +static inline float32 ldfl_be_p(const void *ptr) +{ + union { + float32 f; + uint32_t i; + } u; + u.i = ldl_be_p(ptr); + return u.f; +} + +static inline void stfl_be_p(void *ptr, float32 v) +{ + union { + float32 f; + uint32_t i; + } u; + u.f = v; + stl_be_p(ptr, u.i); +} + +static inline float64 ldfq_be_p(const void *ptr) +{ + CPU_DoubleU u; + u.l.upper = ldl_be_p(ptr); + u.l.lower = ldl_be_p((uint8_t *)ptr + 4); + return u.d; +} + +static inline void stfq_be_p(void *ptr, float64 v) +{ + CPU_DoubleU u; + u.d = v; + stl_be_p(ptr, u.l.upper); + stl_be_p((uint8_t *)ptr + 4, u.l.lower); +} + +#else + +static inline int lduw_be_p(const void *ptr) +{ + return *(uint16_t *)ptr; +} + +static inline int ldsw_be_p(const void *ptr) +{ + return *(int16_t *)ptr; +} + +static inline int ldl_be_p(const void *ptr) +{ + return *(uint32_t *)ptr; +} + +static inline uint64_t ldq_be_p(const void *ptr) +{ + return *(uint64_t *)ptr; +} + +static inline void stw_be_p(void *ptr, int v) +{ + *(uint16_t *)ptr = v; +} + +static inline void stl_be_p(void *ptr, int v) +{ + *(uint32_t *)ptr = v; +} + +static inline void stq_be_p(void *ptr, uint64_t v) +{ + *(uint64_t *)ptr = v; +} + +/* float access */ + +static inline float32 ldfl_be_p(const void *ptr) +{ + return *(float32 *)ptr; +} + +static inline float64 ldfq_be_p(const void *ptr) +{ + return *(float64 *)ptr; +} + +static inline void stfl_be_p(void *ptr, float32 v) +{ + *(float32 *)ptr = v; +} + +static inline void stfq_be_p(void *ptr, float64 v) +{ + *(float64 *)ptr = v; +} + +#endif + +#endif /* BSWAP_H */ diff --git a/include/qemu/cache-utils.h b/include/qemu/cache-utils.h new file mode 100644 index 0000000000..2c57f78fc1 --- /dev/null +++ b/include/qemu/cache-utils.h @@ -0,0 +1,44 @@ +#ifndef QEMU_CACHE_UTILS_H +#define QEMU_CACHE_UTILS_H + +#if defined(_ARCH_PPC) + +#include /* uintptr_t */ + +struct qemu_cache_conf { + unsigned long dcache_bsize; + unsigned long icache_bsize; +}; + +extern struct qemu_cache_conf qemu_cache_conf; + +void qemu_cache_utils_init(char **envp); + +/* mildly adjusted code from tcg-dyngen.c */ +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + unsigned long p, start1, stop1; + unsigned long dsize = qemu_cache_conf.dcache_bsize; + unsigned long isize = qemu_cache_conf.icache_bsize; + + start1 = start & ~(dsize - 1); + stop1 = (stop + dsize - 1) & ~(dsize - 1); + for (p = start1; p < stop1; p += dsize) { + asm volatile ("dcbst 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + + start &= start & ~(isize - 1); + stop1 = (stop + isize - 1) & ~(isize - 1); + for (p = start1; p < stop1; p += isize) { + asm volatile ("icbi 0,%0" : : "r"(p) : "memory"); + } + asm volatile ("sync" : : : "memory"); + asm volatile ("isync" : : : "memory"); +} + +#else +#define qemu_cache_utils_init(envp) do { (void) (envp); } while (0) +#endif + +#endif /* QEMU_CACHE_UTILS_H */ diff --git a/include/qemu/compatfd.h b/include/qemu/compatfd.h new file mode 100644 index 0000000000..6b04877b97 --- /dev/null +++ b/include/qemu/compatfd.h @@ -0,0 +1,44 @@ +/* + * signalfd/eventfd compatibility + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_COMPATFD_H +#define QEMU_COMPATFD_H + +#include + +struct qemu_signalfd_siginfo { + uint32_t ssi_signo; /* Signal number */ + int32_t ssi_errno; /* Error number (unused) */ + int32_t ssi_code; /* Signal code */ + uint32_t ssi_pid; /* PID of sender */ + uint32_t ssi_uid; /* Real UID of sender */ + int32_t ssi_fd; /* File descriptor (SIGIO) */ + uint32_t ssi_tid; /* Kernel timer ID (POSIX timers) */ + uint32_t ssi_band; /* Band event (SIGIO) */ + uint32_t ssi_overrun; /* POSIX timer overrun count */ + uint32_t ssi_trapno; /* Trap number that caused signal */ + int32_t ssi_status; /* Exit status or signal (SIGCHLD) */ + int32_t ssi_int; /* Integer sent by sigqueue(2) */ + uint64_t ssi_ptr; /* Pointer sent by sigqueue(2) */ + uint64_t ssi_utime; /* User CPU time consumed (SIGCHLD) */ + uint64_t ssi_stime; /* System CPU time consumed (SIGCHLD) */ + uint64_t ssi_addr; /* Address that generated signal + (for hardware-generated signals) */ + uint8_t pad[48]; /* Pad size to 128 bytes (allow for + additional fields in the future) */ +}; + +int qemu_signalfd(const sigset_t *mask); +bool qemu_signalfd_available(void); + +#endif diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h new file mode 100644 index 0000000000..2f7998b6c1 --- /dev/null +++ b/include/qemu/compiler.h @@ -0,0 +1,58 @@ +/* public domain */ + +#ifndef COMPILER_H +#define COMPILER_H + +#include "config-host.h" + +/*---------------------------------------------------------------------------- +| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. +| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. +*----------------------------------------------------------------------------*/ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define QEMU_GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define QEMU_GNUC_PREREQ(maj, min) 0 +#endif + +#define QEMU_NORETURN __attribute__ ((__noreturn__)) + +#if QEMU_GNUC_PREREQ(3, 4) +#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define QEMU_WARN_UNUSED_RESULT +#endif + +#if defined(_WIN32) +# define QEMU_PACKED __attribute__((gcc_struct, packed)) +#else +# define QEMU_PACKED __attribute__((packed)) +#endif + +#define cat(x,y) x ## y +#define cat2(x,y) cat(x,y) +#define QEMU_BUILD_BUG_ON(x) \ + typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1]; + +#if defined __GNUC__ +# if !QEMU_GNUC_PREREQ(4, 4) + /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ +# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) +# else + /* Use gnu_printf when supported (qemu uses standard format strings). */ +# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) +# if defined(_WIN32) + /* Map __printf__ to __gnu_printf__ because we want standard format strings + * even when MinGW or GLib include files use __printf__. */ +# define __printf__ __gnu_printf__ +# endif +# endif +#else +#define GCC_ATTR /**/ +#define GCC_FMT_ATTR(n, m) +#endif + +#endif /* COMPILER_H */ diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h new file mode 100644 index 0000000000..486c77cad4 --- /dev/null +++ b/include/qemu/config-file.h @@ -0,0 +1,30 @@ +#ifndef QEMU_CONFIG_H +#define QEMU_CONFIG_H + +#include +#include "qemu/option.h" +#include "qapi/error.h" +#include "qemu/option.h" + +extern QemuOptsList qemu_fsdev_opts; +extern QemuOptsList qemu_virtfs_opts; +extern QemuOptsList qemu_spice_opts; +extern QemuOptsList qemu_sandbox_opts; + +QemuOptsList *qemu_find_opts(const char *group); +QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); +void qemu_add_opts(QemuOptsList *list); +int qemu_set_option(const char *str); +int qemu_global_option(const char *str); +void qemu_add_globals(void); + +void qemu_config_write(FILE *fp); +int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); + +int qemu_read_config_file(const char *filename); + +/* Read default QEMU config files + */ +int qemu_read_default_config_files(bool userconfig); + +#endif /* QEMU_CONFIG_H */ diff --git a/include/qemu/envlist.h b/include/qemu/envlist.h new file mode 100644 index 0000000000..b9addcc11f --- /dev/null +++ b/include/qemu/envlist.h @@ -0,0 +1,22 @@ +#ifndef ENVLIST_H +#define ENVLIST_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct envlist envlist_t; + +envlist_t *envlist_create(void); +void envlist_free(envlist_t *); +int envlist_setenv(envlist_t *, const char *); +int envlist_unsetenv(envlist_t *, const char *); +int envlist_parse_set(envlist_t *, const char *); +int envlist_parse_unset(envlist_t *, const char *); +char **envlist_to_environ(const envlist_t *, size_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* ENVLIST_H */ diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h new file mode 100644 index 0000000000..c902cc10de --- /dev/null +++ b/include/qemu/error-report.h @@ -0,0 +1,43 @@ +/* + * Error reporting + * + * Copyright (C) 2010 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_ERROR_H +#define QEMU_ERROR_H + +#include + +typedef struct Location { + /* all members are private to qemu-error.c */ + enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; + int num; + const void *ptr; + struct Location *prev; +} Location; + +Location *loc_push_restore(Location *loc); +Location *loc_push_none(Location *loc); +Location *loc_pop(Location *loc); +Location *loc_save(Location *loc); +void loc_restore(Location *loc); +void loc_set_none(void); +void loc_set_cmdline(char **argv, int idx, int cnt); +void loc_set_file(const char *fname, int lno); + +void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_print_loc(void); +void error_set_progname(const char *argv0); +void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +const char *error_get_progname(void); + +#endif diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h new file mode 100644 index 0000000000..88b57af7ce --- /dev/null +++ b/include/qemu/event_notifier.h @@ -0,0 +1,46 @@ +/* + * event notifier support + * + * Copyright Red Hat, Inc. 2010 + * + * Authors: + * Michael S. Tsirkin + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_EVENT_NOTIFIER_H +#define QEMU_EVENT_NOTIFIER_H + +#include "qemu-common.h" + +#ifdef _WIN32 +#include +#endif + +struct EventNotifier { +#ifdef _WIN32 + HANDLE event; +#else + int rfd; + int wfd; +#endif +}; + +typedef void EventNotifierHandler(EventNotifier *); + +int event_notifier_init(EventNotifier *, int active); +void event_notifier_cleanup(EventNotifier *); +int event_notifier_set(EventNotifier *); +int event_notifier_test_and_clear(EventNotifier *); +int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *); + +#ifdef CONFIG_POSIX +void event_notifier_init_fd(EventNotifier *, int fd); +int event_notifier_get_fd(EventNotifier *); +#else +HANDLE event_notifier_get_handle(EventNotifier *); +#endif + +#endif diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h new file mode 100644 index 0000000000..81c9a754ae --- /dev/null +++ b/include/qemu/host-utils.h @@ -0,0 +1,240 @@ +/* + * Utility compute operations used by translated code. + * + * Copyright (c) 2007 Thiemo Seufer + * Copyright (c) 2007 Jocelyn Mayer + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#ifndef HOST_UTILS_H +#define HOST_UTILS_H 1 + +#include "qemu/compiler.h" /* QEMU_GNUC_PREREQ */ + +#if defined(__x86_64__) +#define __HAVE_FAST_MULU64__ +static inline void mulu64(uint64_t *plow, uint64_t *phigh, + uint64_t a, uint64_t b) +{ + __asm__ ("mul %0\n\t" + : "=d" (*phigh), "=a" (*plow) + : "a" (a), "0" (b)); +} +#define __HAVE_FAST_MULS64__ +static inline void muls64(uint64_t *plow, uint64_t *phigh, + int64_t a, int64_t b) +{ + __asm__ ("imul %0\n\t" + : "=d" (*phigh), "=a" (*plow) + : "a" (a), "0" (b)); +} +#else +void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); +void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); +#endif + +/* Binary search for leading zeros. */ + +static inline int clz32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_clz(val); + else + return 32; +#else + int cnt = 0; + + if (!(val & 0xFFFF0000U)) { + cnt += 16; + val <<= 16; + } + if (!(val & 0xFF000000U)) { + cnt += 8; + val <<= 8; + } + if (!(val & 0xF0000000U)) { + cnt += 4; + val <<= 4; + } + if (!(val & 0xC0000000U)) { + cnt += 2; + val <<= 2; + } + if (!(val & 0x80000000U)) { + cnt++; + val <<= 1; + } + if (!(val & 0x80000000U)) { + cnt++; + } + return cnt; +#endif +} + +static inline int clo32(uint32_t val) +{ + return clz32(~val); +} + +static inline int clz64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_clzll(val); + else + return 64; +#else + int cnt = 0; + + if (!(val >> 32)) { + cnt += 32; + } else { + val >>= 32; + } + + return cnt + clz32(val); +#endif +} + +static inline int clo64(uint64_t val) +{ + return clz64(~val); +} + +static inline int ctz32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_ctz(val); + else + return 32; +#else + int cnt; + + cnt = 0; + if (!(val & 0x0000FFFFUL)) { + cnt += 16; + val >>= 16; + } + if (!(val & 0x000000FFUL)) { + cnt += 8; + val >>= 8; + } + if (!(val & 0x0000000FUL)) { + cnt += 4; + val >>= 4; + } + if (!(val & 0x00000003UL)) { + cnt += 2; + val >>= 2; + } + if (!(val & 0x00000001UL)) { + cnt++; + val >>= 1; + } + if (!(val & 0x00000001UL)) { + cnt++; + } + + return cnt; +#endif +} + +static inline int cto32(uint32_t val) +{ + return ctz32(~val); +} + +static inline int ctz64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + if (val) + return __builtin_ctzll(val); + else + return 64; +#else + int cnt; + + cnt = 0; + if (!((uint32_t)val)) { + cnt += 32; + val >>= 32; + } + + return cnt + ctz32(val); +#endif +} + +static inline int cto64(uint64_t val) +{ + return ctz64(~val); +} + +static inline int ctpop8(uint8_t val) +{ + val = (val & 0x55) + ((val >> 1) & 0x55); + val = (val & 0x33) + ((val >> 2) & 0x33); + val = (val & 0x0f) + ((val >> 4) & 0x0f); + + return val; +} + +static inline int ctpop16(uint16_t val) +{ + val = (val & 0x5555) + ((val >> 1) & 0x5555); + val = (val & 0x3333) + ((val >> 2) & 0x3333); + val = (val & 0x0f0f) + ((val >> 4) & 0x0f0f); + val = (val & 0x00ff) + ((val >> 8) & 0x00ff); + + return val; +} + +static inline int ctpop32(uint32_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + return __builtin_popcount(val); +#else + val = (val & 0x55555555) + ((val >> 1) & 0x55555555); + val = (val & 0x33333333) + ((val >> 2) & 0x33333333); + val = (val & 0x0f0f0f0f) + ((val >> 4) & 0x0f0f0f0f); + val = (val & 0x00ff00ff) + ((val >> 8) & 0x00ff00ff); + val = (val & 0x0000ffff) + ((val >> 16) & 0x0000ffff); + + return val; +#endif +} + +static inline int ctpop64(uint64_t val) +{ +#if QEMU_GNUC_PREREQ(3, 4) + return __builtin_popcountll(val); +#else + val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL); + val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL); + val = (val & 0x0f0f0f0f0f0f0f0fULL) + ((val >> 4) & 0x0f0f0f0f0f0f0f0fULL); + val = (val & 0x00ff00ff00ff00ffULL) + ((val >> 8) & 0x00ff00ff00ff00ffULL); + val = (val & 0x0000ffff0000ffffULL) + ((val >> 16) & 0x0000ffff0000ffffULL); + val = (val & 0x00000000ffffffffULL) + ((val >> 32) & 0x00000000ffffffffULL); + + return val; +#endif +} + +#endif diff --git a/include/qemu/int128.h b/include/qemu/int128.h new file mode 100644 index 0000000000..b3864b6cd4 --- /dev/null +++ b/include/qemu/int128.h @@ -0,0 +1,116 @@ +#ifndef INT128_H +#define INT128_H + +typedef struct Int128 Int128; + +struct Int128 { + uint64_t lo; + int64_t hi; +}; + +static inline Int128 int128_make64(uint64_t a) +{ + return (Int128) { a, 0 }; +} + +static inline uint64_t int128_get64(Int128 a) +{ + assert(!a.hi); + return a.lo; +} + +static inline Int128 int128_zero(void) +{ + return int128_make64(0); +} + +static inline Int128 int128_one(void) +{ + return int128_make64(1); +} + +static inline Int128 int128_2_64(void) +{ + return (Int128) { 0, 1 }; +} + +static inline Int128 int128_add(Int128 a, Int128 b) +{ + Int128 r = { a.lo + b.lo, a.hi + b.hi }; + r.hi += (r.lo < a.lo) || (r.lo < b.lo); + return r; +} + +static inline Int128 int128_neg(Int128 a) +{ + a.lo = ~a.lo; + a.hi = ~a.hi; + return int128_add(a, int128_one()); +} + +static inline Int128 int128_sub(Int128 a, Int128 b) +{ + return int128_add(a, int128_neg(b)); +} + +static inline bool int128_nonneg(Int128 a) +{ + return a.hi >= 0; +} + +static inline bool int128_eq(Int128 a, Int128 b) +{ + return a.lo == b.lo && a.hi == b.hi; +} + +static inline bool int128_ne(Int128 a, Int128 b) +{ + return !int128_eq(a, b); +} + +static inline bool int128_ge(Int128 a, Int128 b) +{ + return int128_nonneg(int128_sub(a, b)); +} + +static inline bool int128_lt(Int128 a, Int128 b) +{ + return !int128_ge(a, b); +} + +static inline bool int128_le(Int128 a, Int128 b) +{ + return int128_ge(b, a); +} + +static inline bool int128_gt(Int128 a, Int128 b) +{ + return !int128_le(a, b); +} + +static inline bool int128_nz(Int128 a) +{ + return a.lo || a.hi; +} + +static inline Int128 int128_min(Int128 a, Int128 b) +{ + return int128_le(a, b) ? a : b; +} + +static inline Int128 int128_max(Int128 a, Int128 b) +{ + return int128_ge(a, b) ? a : b; +} + +static inline void int128_addto(Int128 *a, Int128 b) +{ + *a = int128_add(*a, b); +} + +static inline void int128_subfrom(Int128 *a, Int128 b) +{ + *a = int128_sub(*a, b); +} + +#endif diff --git a/include/qemu/iov.h b/include/qemu/iov.h new file mode 100644 index 0000000000..d06f8b9ce3 --- /dev/null +++ b/include/qemu/iov.h @@ -0,0 +1,102 @@ +/* + * Helpers for using (partial) iovecs. + * + * Copyright (C) 2010 Red Hat, Inc. + * + * Author(s): + * Amit Shah + * Michael Tokarev + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#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. + */ +size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); + +/** + * Copy from single continuous buffer to scatter-gather vector of buffers + * (iovec) and back like memcpy() between two continuous memory regions. + * Data in single continuous buffer starting at address `buf' and + * `bytes' bytes long will be copied to/from an iovec `iov' with + * `iov_cnt' number of elements, starting at byte position `offset' + * within the iovec. If the iovec does not contain enough space, + * only part of data will be copied, up to the end of the iovec. + * Number of bytes actually copied will be returned, which is + * min(bytes, iov_size(iov)-offset) + * `Offset' must point to the inside of iovec. + * It is okay to use very large value for `bytes' since we're + * limited by the size of the iovec anyway, provided that the + * buffer pointed to by buf has enough space. One possible + * such "large" value is -1 (sinice size_t is unsigned), + * so specifying `-1' as `bytes' means 'up to the end of iovec'. + */ +size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, + size_t offset, const void *buf, size_t bytes); +size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, void *buf, size_t bytes); + +/** + * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, + * starting at byte offset `start', to value `fillc', repeating it + * `bytes' number of times. `Offset' must point to the inside of iovec. + * If `bytes' is large enough, only last bytes portion of iovec, + * up to the end of it, will be filled with the specified value. + * Function return actual number of bytes processed, which is + * min(size, iov_size(iov) - offset). + * Again, it is okay to use large value for `bytes' to mean "up to the end". + */ +size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, int fillc, size_t bytes); + +/* + * Send/recv data from/to iovec buffers directly + * + * `offset' bytes in the beginning of iovec buffer are skipped and + * next `bytes' bytes are used, which must be within data of iovec. + * + * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); + * + * is logically equivalent to + * + * char *buf = malloc(bytes); + * iov_to_buf(iov, iovcnt, offset, buf, bytes); + * r = send(sockfd, buf, bytes, 0); + * free(buf); + * + * For iov_send_recv() _whole_ area being sent or received + * should be within the iovec, not only beginning of it. + */ +ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, + size_t offset, size_t bytes, bool do_send); +#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ + iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) +#define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ + iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) + +/** + * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements + * in file `fp', prefixing each line with `prefix' and processing not more + * than `limit' data bytes. + */ +void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, + FILE *fp, const char *prefix, size_t limit); + +/* + * Partial copy of vector from iov to dst_iov (data is not copied). + * dst_iov overlaps iov at a specified offset. + * size of dst_iov is at most bytes. dst vector count is returned. + */ +unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, + const struct iovec *iov, unsigned int iov_cnt, + size_t offset, size_t bytes); + +#endif diff --git a/include/qemu/log.h b/include/qemu/log.h new file mode 100644 index 0000000000..58f69cb494 --- /dev/null +++ b/include/qemu/log.h @@ -0,0 +1,160 @@ +#ifndef QEMU_LOG_H +#define QEMU_LOG_H + +#include +#ifdef NEED_CPU_H +#include "disas/disas.h" +#endif + +/* Private global variables, don't use */ +extern FILE *qemu_logfile; +extern int qemu_loglevel; + +/* + * The new API: + * + */ + +/* Log settings checking macros: */ + +/* Returns true if qemu_log() will really write somewhere + */ +static inline bool qemu_log_enabled(void) +{ + return qemu_logfile != NULL; +} + +#define CPU_LOG_TB_OUT_ASM (1 << 0) +#define CPU_LOG_TB_IN_ASM (1 << 1) +#define CPU_LOG_TB_OP (1 << 2) +#define CPU_LOG_TB_OP_OPT (1 << 3) +#define CPU_LOG_INT (1 << 4) +#define CPU_LOG_EXEC (1 << 5) +#define CPU_LOG_PCALL (1 << 6) +#define CPU_LOG_IOPORT (1 << 7) +#define CPU_LOG_TB_CPU (1 << 8) +#define CPU_LOG_RESET (1 << 9) +#define LOG_UNIMP (1 << 10) +#define LOG_GUEST_ERROR (1 << 11) + +/* Returns true if a bit is set in the current loglevel mask + */ +static inline bool qemu_loglevel_mask(int mask) +{ + return (qemu_loglevel & mask) != 0; +} + +/* Logging functions: */ + +/* main logging function + */ +void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); + +/* vfprintf-like logging function + */ +static inline void GCC_FMT_ATTR(1, 0) +qemu_log_vprintf(const char *fmt, va_list va) +{ + if (qemu_logfile) { + vfprintf(qemu_logfile, fmt, va); + } +} + +/* log only if a bit is set on the current loglevel mask + */ +void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); + + +/* Special cases: */ + +#ifdef NEED_CPU_H +/* cpu_dump_state() logging functions: */ +static inline void log_cpu_state(CPUArchState *env1, int flags) +{ + if (qemu_log_enabled()) { + cpu_dump_state(env1, qemu_logfile, fprintf, flags); + } +} + +static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags) +{ + if (qemu_loglevel & mask) { + log_cpu_state(env1, flags); + } +} + +/* disas() and target_disas() to qemu_logfile: */ +static inline void log_target_disas(CPUArchState *env, target_ulong start, + target_ulong len, int flags) +{ + target_disas(qemu_logfile, env, start, len, flags); +} + +static inline void log_disas(void *code, unsigned long size) +{ + disas(qemu_logfile, code, size); +} + +#if defined(CONFIG_USER_ONLY) +/* page_dump() output to the log file: */ +static inline void log_page_dump(void) +{ + page_dump(qemu_logfile); +} +#endif +#endif + + +/* Maintenance: */ + +/* fflush() the log file */ +static inline void qemu_log_flush(void) +{ + fflush(qemu_logfile); +} + +/* Close the log file */ +static inline void qemu_log_close(void) +{ + fclose(qemu_logfile); + qemu_logfile = NULL; +} + +/* Set up a new log file */ +static inline void qemu_log_set_file(FILE *f) +{ + qemu_logfile = f; +} + +/* Set up a new log file, only if none is set */ +static inline void qemu_log_try_set_file(FILE *f) +{ + if (!qemu_logfile) { + qemu_logfile = f; + } +} + +/* define log items */ +typedef struct CPULogItem { + int mask; + const char *name; + const char *help; +} CPULogItem; + +extern const CPULogItem cpu_log_items[]; + +void qemu_set_log(int log_flags, bool use_own_buffers); + +static inline void cpu_set_log(int log_flags) +{ +#ifdef CONFIG_USER_ONLY + qemu_set_log(log_flags, true); +#else + qemu_set_log(log_flags, false); +#endif +} + +void cpu_set_log_filename(const char *filename); +int cpu_str_to_log_mask(const char *str); + +#endif diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h new file mode 100644 index 0000000000..e8059c3d0a --- /dev/null +++ b/include/qemu/main-loop.h @@ -0,0 +1,306 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_MAIN_LOOP_H +#define QEMU_MAIN_LOOP_H 1 + +#include "block/aio.h" + +#define SIG_IPI SIGUSR1 + +/** + * qemu_init_main_loop: Set up the process so that it can run the main loop. + * + * This includes setting up signal handlers. It should be called before + * any other threads are created. In addition, threads other than the + * main one should block signals that are trapped by the main loop. + * For simplicity, you can consider these signals to be safe: SIGUSR1, + * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time + * signals if available. Remember that Windows in practice does not have + * signals, though. + * + * In the case of QEMU tools, this will also start/initialize timers. + */ +int qemu_init_main_loop(void); + +/** + * main_loop_wait: Run one iteration of the main loop. + * + * If @nonblocking is true, poll for events, otherwise suspend until + * one actually occurs. The main loop usually consists of a loop that + * repeatedly calls main_loop_wait(false). + * + * Main loop services include file descriptor callbacks, bottom halves + * and timers (defined in qemu-timer.h). Bottom halves are similar to timers + * that execute immediately, but have a lower overhead and scheduling them + * is wait-free, thread-safe and signal-safe. + * + * It is sometimes useful to put a whole program in a coroutine. In this + * case, the coroutine actually should be started from within the main loop, + * so that the main loop can run whenever the coroutine yields. To do this, + * you can use a bottom half to enter the coroutine as soon as the main loop + * starts: + * + * void enter_co_bh(void *opaque) { + * QEMUCoroutine *co = opaque; + * qemu_coroutine_enter(co, NULL); + * } + * + * ... + * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); + * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); + * qemu_bh_schedule(start_bh); + * while (...) { + * main_loop_wait(false); + * } + * + * (In the future we may provide a wrapper for this). + * + * @nonblocking: Whether the caller should block until an event occurs. + */ +int main_loop_wait(int nonblocking); + +/** + * qemu_notify_event: Force processing of pending events. + * + * Similar to signaling a condition variable, qemu_notify_event forces + * main_loop_wait to look at pending events and exit. The caller of + * main_loop_wait will usually call it again very soon, so qemu_notify_event + * also has the side effect of recalculating the sets of file descriptors + * that the main loop waits for. + * + * Calling qemu_notify_event is rarely necessary, because main loop + * services (bottom halves and timers) call it themselves. One notable + * exception occurs when using qemu_set_fd_handler2 (see below). + */ +void qemu_notify_event(void); + +#ifdef _WIN32 +/* return TRUE if no sleep should be done afterwards */ +typedef int PollingFunc(void *opaque); + +/** + * qemu_add_polling_cb: Register a Windows-specific polling callback + * + * Currently, under Windows some events are polled rather than waited for. + * Polling callbacks do not ensure that @func is called timely, because + * the main loop might wait for an arbitrarily long time. If possible, + * you should instead create a separate thread that does a blocking poll + * and set a Win32 event object. The event can then be passed to + * qemu_add_wait_object. + * + * Polling callbacks really have nothing Windows specific in them, but + * as they are a hack and are currently not necessary under POSIX systems, + * they are only available when QEMU is running under Windows. + * + * @func: The function that does the polling, and returns 1 to force + * immediate completion of main_loop_wait. + * @opaque: A pointer-size value that is passed to @func. + */ +int qemu_add_polling_cb(PollingFunc *func, void *opaque); + +/** + * qemu_del_polling_cb: Unregister a Windows-specific polling callback + * + * This function removes a callback that was registered with + * qemu_add_polling_cb. + * + * @func: The function that was passed to qemu_add_polling_cb. + * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. + */ +void qemu_del_polling_cb(PollingFunc *func, void *opaque); + +/* Wait objects handling */ +typedef void WaitObjectFunc(void *opaque); + +/** + * qemu_add_wait_object: Register a callback for a Windows handle + * + * Under Windows, the iohandler mechanism can only be used with sockets. + * QEMU must use the WaitForMultipleObjects API to wait on other handles. + * This function registers a #HANDLE with QEMU, so that it will be included + * in the main loop's calls to WaitForMultipleObjects. When the handle + * is in a signaled state, QEMU will call @func. + * + * @handle: The Windows handle to be observed. + * @func: A function to be called when @handle is in a signaled state. + * @opaque: A pointer-size value that is passed to @func. + */ +int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); + +/** + * qemu_del_wait_object: Unregister a callback for a Windows handle + * + * This function removes a callback that was registered with + * qemu_add_wait_object. + * + * @func: The function that was passed to qemu_add_wait_object. + * @opaque: A pointer-size value that was passed to qemu_add_wait_object. + */ +void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); +#endif + +/* async I/O support */ + +typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); +typedef int IOCanReadHandler(void *opaque); + +/** + * qemu_set_fd_handler2: Register a file descriptor with the main loop + * + * This function tells the main loop to wake up whenever one of the + * following conditions is true: + * + * 1) if @fd_write is not %NULL, when the file descriptor is writable; + * + * 2) if @fd_read is not %NULL, when the file descriptor is readable. + * + * @fd_read_poll can be used to disable the @fd_read callback temporarily. + * This is useful to avoid calling qemu_set_fd_handler2 every time the + * client becomes interested in reading (or dually, stops being interested). + * A typical example is when @fd is a listening socket and you want to bound + * the number of active clients. Remember to call qemu_notify_event whenever + * the condition may change from %false to %true. + * + * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. + * If @fd_read does not read from @fd, or @fd_write does not write to @fd + * until its buffers are full, they will be called again on the next + * iteration. + * + * @fd: The file descriptor to be observed. Under Windows it must be + * a #SOCKET. + * + * @fd_read_poll: A function that returns 1 if the @fd_read callback + * should be fired. If the function returns 0, the main loop will not + * end its iteration even if @fd becomes readable. + * + * @fd_read: A level-triggered callback that is fired if @fd is readable + * at the beginning of a main loop iteration, or if it becomes readable + * during one. + * + * @fd_write: A level-triggered callback that is fired when @fd is writable + * at the beginning of a main loop iteration, or if it becomes writable + * during one. + * + * @opaque: A pointer-sized value that is passed to @fd_read_poll, + * @fd_read and @fd_write. + */ +int qemu_set_fd_handler2(int fd, + IOCanReadHandler *fd_read_poll, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); + +/** + * qemu_set_fd_handler: Register a file descriptor with the main loop + * + * This function tells the main loop to wake up whenever one of the + * following conditions is true: + * + * 1) if @fd_write is not %NULL, when the file descriptor is writable; + * + * 2) if @fd_read is not %NULL, when the file descriptor is readable. + * + * The callbacks that are set up by qemu_set_fd_handler are level-triggered. + * If @fd_read does not read from @fd, or @fd_write does not write to @fd + * until its buffers are full, they will be called again on the next + * iteration. + * + * @fd: The file descriptor to be observed. Under Windows it must be + * a #SOCKET. + * + * @fd_read: A level-triggered callback that is fired if @fd is readable + * at the beginning of a main loop iteration, or if it becomes readable + * during one. + * + * @fd_write: A level-triggered callback that is fired when @fd is writable + * at the beginning of a main loop iteration, or if it becomes writable + * during one. + * + * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. + */ +int qemu_set_fd_handler(int fd, + IOHandler *fd_read, + IOHandler *fd_write, + void *opaque); + +#ifdef CONFIG_POSIX +/** + * qemu_add_child_watch: Register a child process for reaping. + * + * Under POSIX systems, a parent process must read the exit status of + * its child processes using waitpid, or the operating system will not + * free some of the resources attached to that process. + * + * This function directs the QEMU main loop to observe a child process + * and call waitpid as soon as it exits; the watch is then removed + * automatically. It is useful whenever QEMU forks a child process + * but will find out about its termination by other means such as a + * "broken pipe". + * + * @pid: The pid that QEMU should observe. + */ +int qemu_add_child_watch(pid_t pid); +#endif + +/** + * qemu_mutex_lock_iothread: Lock the main loop mutex. + * + * This function locks the main loop mutex. The mutex is taken by + * qemu_init_main_loop and always taken except while waiting on + * external events (such as with select). The mutex should be taken + * by threads other than the main loop thread when calling + * qemu_bh_new(), qemu_set_fd_handler() and basically all other + * functions documented in this file. + * + * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread + * is a no-op there. + */ +void qemu_mutex_lock_iothread(void); + +/** + * qemu_mutex_unlock_iothread: Unlock the main loop mutex. + * + * This function unlocks the main loop mutex. The mutex is taken by + * qemu_init_main_loop and always taken except while waiting on + * external events (such as with select). The mutex should be unlocked + * as soon as possible by threads other than the main loop thread, + * because it prevents the main loop from processing callbacks, + * including timers and bottom halves. + * + * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread + * is a no-op there. + */ +void qemu_mutex_unlock_iothread(void); + +/* internal interfaces */ + +void qemu_fd_register(int fd); +void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); +void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); + +QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); +void qemu_bh_schedule_idle(QEMUBH *bh); + +#endif diff --git a/include/qemu/module.h b/include/qemu/module.h new file mode 100644 index 0000000000..c4ccd57166 --- /dev/null +++ b/include/qemu/module.h @@ -0,0 +1,40 @@ +/* + * QEMU Module Infrastructure + * + * Copyright IBM, Corp. 2009 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_MODULE_H +#define QEMU_MODULE_H + +/* This should not be used directly. Use block_init etc. instead. */ +#define module_init(function, type) \ +static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ + register_module_init(function, type); \ +} + +typedef enum { + MODULE_INIT_BLOCK, + MODULE_INIT_MACHINE, + MODULE_INIT_QAPI, + MODULE_INIT_QOM, + MODULE_INIT_MAX +} module_init_type; + +#define block_init(function) module_init(function, MODULE_INIT_BLOCK) +#define machine_init(function) module_init(function, MODULE_INIT_MACHINE) +#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) +#define type_init(function) module_init(function, MODULE_INIT_QOM) + +void register_module_init(void (*fn)(void), module_init_type type); + +void module_call_init(module_init_type type); + +#endif diff --git a/include/qemu/notify.h b/include/qemu/notify.h new file mode 100644 index 0000000000..4e2e7f0ec4 --- /dev/null +++ b/include/qemu/notify.h @@ -0,0 +1,43 @@ +/* + * Notifier lists + * + * Copyright IBM, Corp. 2010 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_NOTIFY_H +#define QEMU_NOTIFY_H + +#include "qemu/queue.h" + +typedef struct Notifier Notifier; + +struct Notifier +{ + void (*notify)(Notifier *notifier, void *data); + QLIST_ENTRY(Notifier) node; +}; + +typedef struct NotifierList +{ + QLIST_HEAD(, Notifier) notifiers; +} NotifierList; + +#define NOTIFIER_LIST_INITIALIZER(head) \ + { QLIST_HEAD_INITIALIZER((head).notifiers) } + +void notifier_list_init(NotifierList *list); + +void notifier_list_add(NotifierList *list, Notifier *notifier); + +void notifier_remove(Notifier *notifier); + +void notifier_list_notify(NotifierList *list, void *data); + +#endif diff --git a/include/qemu/option.h b/include/qemu/option.h new file mode 100644 index 0000000000..ba197cddcf --- /dev/null +++ b/include/qemu/option.h @@ -0,0 +1,158 @@ +/* + * Commandline option parsing functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OPTIONS_H +#define QEMU_OPTIONS_H + +#include +#include "qemu/queue.h" +#include "qapi/error.h" +#include "qapi/qmp/qdict.h" + +enum QEMUOptionParType { + OPT_FLAG, + OPT_NUMBER, + OPT_SIZE, + OPT_STRING, +}; + +typedef struct QEMUOptionParameter { + const char *name; + enum QEMUOptionParType type; + union { + uint64_t n; + char* s; + } value; + const char *help; +} QEMUOptionParameter; + + +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); +int get_next_param_value(char *buf, int buf_size, + const char *tag, const char **pstr); +int get_param_value(char *buf, int buf_size, + const char *tag, const char *str); +int check_params(char *buf, int buf_size, + const char * const *params, const char *str); + + +/* + * The following functions take a parameter list as input. This is a pointer to + * the first element of a QEMUOptionParameter array which is terminated by an + * entry with entry->name == NULL. + */ + +QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, + const char *name); +int set_option_parameter(QEMUOptionParameter *list, const char *name, + const char *value); +int set_option_parameter_int(QEMUOptionParameter *list, const char *name, + uint64_t value); +QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, + QEMUOptionParameter *list); +QEMUOptionParameter *parse_option_parameters(const char *param, + QEMUOptionParameter *list, QEMUOptionParameter *dest); +void free_option_parameters(QEMUOptionParameter *list); +void print_option_parameters(QEMUOptionParameter *list); +void print_option_help(QEMUOptionParameter *list); + +/* ------------------------------------------------------------------ */ + +typedef struct QemuOpt QemuOpt; +typedef struct QemuOpts QemuOpts; +typedef struct QemuOptsList QemuOptsList; + +enum QemuOptType { + QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ + QEMU_OPT_BOOL, /* on/off */ + QEMU_OPT_NUMBER, /* simple number */ + QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ +}; + +typedef struct QemuOptDesc { + const char *name; + enum QemuOptType type; + const char *help; +} QemuOptDesc; + +struct QemuOptsList { + const char *name; + const char *implied_opt_name; + bool merge_lists; /* Merge multiple uses of option into a single list? */ + QTAILQ_HEAD(, QemuOpts) head; + QemuOptDesc desc[]; +}; + +const char *qemu_opt_get(QemuOpts *opts, const char *name); +/** + * qemu_opt_has_help_opt: + * @opts: options to search for a help request + * + * Check whether the options specified by @opts include one of the + * standard strings which indicate that the user is asking for a + * list of the valid values for a command line option (as defined + * by is_help_option()). + * + * Returns: true if @opts includes 'help' or equivalent. + */ +bool qemu_opt_has_help_opt(QemuOpts *opts); +bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); +uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); +uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); +int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); +void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, + Error **errp); +int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); +int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); +typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); +int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, + int abort_on_failure); + +QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); +QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, + int fail_if_exists, Error **errp); +QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); +void qemu_opts_reset(QemuOptsList *list); +void qemu_opts_loc_restore(QemuOpts *opts); +int qemu_opts_set(QemuOptsList *list, const char *id, + const char *name, const char *value); +const char *qemu_opts_id(QemuOpts *opts); +void qemu_opts_del(QemuOpts *opts); +void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); +int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); +QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); +void qemu_opts_set_defaults(QemuOptsList *list, const char *params, + int permit_abbrev); +QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, + Error **errp); +QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); + +typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); +int qemu_opts_print(QemuOpts *opts, void *dummy); +int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, + int abort_on_failure); + +#endif diff --git a/include/qemu/option_int.h b/include/qemu/option_int.h new file mode 100644 index 0000000000..8212fa4a48 --- /dev/null +++ b/include/qemu/option_int.h @@ -0,0 +1,54 @@ +/* + * Commandline option parsing functions + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2009 Kevin Wolf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OPTIONS_INTERNAL_H +#define QEMU_OPTIONS_INTERNAL_H + +#include "qemu/option.h" +#include "qemu/error-report.h" + +struct QemuOpt { + const char *name; + const char *str; + + const QemuOptDesc *desc; + union { + bool boolean; + uint64_t uint; + } value; + + QemuOpts *opts; + QTAILQ_ENTRY(QemuOpt) next; +}; + +struct QemuOpts { + char *id; + QemuOptsList *list; + Location loc; + QTAILQ_HEAD(QemuOptHead, QemuOpt) head; + QTAILQ_ENTRY(QemuOpts) next; +}; + +#endif diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h new file mode 100644 index 0000000000..87d3b9cfa8 --- /dev/null +++ b/include/qemu/osdep.h @@ -0,0 +1,178 @@ +#ifndef QEMU_OSDEP_H +#define QEMU_OSDEP_H + +#include +#include +#include +#ifdef __OpenBSD__ +#include +#include +#endif + +#include + +#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 +/* [u]int_fast*_t not in */ +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef signed int int_fast16_t; +#endif + +#ifndef glue +#define xglue(x, y) x ## y +#define glue(x, y) xglue(x, y) +#define stringify(s) tostring(s) +#define tostring(s) #s +#endif + +#ifndef likely +#if __GNUC__ < 3 +#define __builtin_expect(x, n) (x) +#endif + +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#ifndef container_of +#define container_of(ptr, type, member) ({ \ + const typeof(((type *) 0)->member) *__mptr = (ptr); \ + (type *) ((char *) __mptr - offsetof(type, member));}) +#endif + +/* Convert from a base type to a parent type, with compile time checking. */ +#ifdef __GNUC__ +#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ + char __attribute__((unused)) offset_must_be_zero[ \ + -offsetof(type, field)]; \ + container_of(dev, type, field);})) +#else +#define DO_UPCAST(type, field, dev) container_of(dev, type, field) +#endif + +#define typeof_field(type, field) typeof(((type *)0)->field) +#define type_check(t1,t2) ((t1*)0 - (t2*)0) + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef DIV_ROUND_UP +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#endif + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +#ifndef always_inline +#if !((__GNUC__ < 3) || defined(__APPLE__)) +#ifdef __OPTIMIZE__ +#undef inline +#define inline __attribute__ (( always_inline )) __inline__ +#endif +#endif +#else +#undef inline +#define inline always_inline +#endif + +#define qemu_printf printf + +int qemu_daemon(int nochdir, int noclose); +void *qemu_memalign(size_t alignment, size_t size); +void *qemu_vmalloc(size_t size); +void qemu_vfree(void *ptr); + +#define QEMU_MADV_INVALID -1 + +#if defined(CONFIG_MADVISE) + +#define QEMU_MADV_WILLNEED MADV_WILLNEED +#define QEMU_MADV_DONTNEED MADV_DONTNEED +#ifdef MADV_DONTFORK +#define QEMU_MADV_DONTFORK MADV_DONTFORK +#else +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#endif +#ifdef MADV_MERGEABLE +#define QEMU_MADV_MERGEABLE MADV_MERGEABLE +#else +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#endif +#ifdef MADV_DONTDUMP +#define QEMU_MADV_DONTDUMP MADV_DONTDUMP +#else +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#endif +#ifdef MADV_HUGEPAGE +#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE +#else +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID +#endif + +#elif defined(CONFIG_POSIX_MADVISE) + +#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED +#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID + +#else /* no-op */ + +#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID +#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID +#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID +#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID +#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID +#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID + +#endif + +int qemu_madvise(void *addr, size_t len, int advice); + +int qemu_open(const char *name, int flags, ...); +int qemu_close(int fd); + +#if defined(__HAIKU__) && defined(__i386__) +#define FMT_pid "%ld" +#elif defined(WIN64) +#define FMT_pid "%" PRId64 +#else +#define FMT_pid "%d" +#endif + +int qemu_create_pidfile(const char *filename); +int qemu_get_thread_id(void); + +#ifdef _WIN32 +static inline void qemu_timersub(const struct timeval *val1, + const struct timeval *val2, + struct timeval *res) +{ + res->tv_sec = val1->tv_sec - val2->tv_sec; + if (val1->tv_usec < val2->tv_usec) { + res->tv_sec--; + res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000; + } else { + res->tv_usec = val1->tv_usec - val2->tv_usec; + } +} +#else +#define qemu_timersub timersub +#endif + +void qemu_set_cloexec(int fd); + +void qemu_set_version(const char *); +const char *qemu_get_version(void); + +void fips_set_state(bool requested); +bool fips_get_state(void); + +#endif diff --git a/include/qemu/queue.h b/include/qemu/queue.h new file mode 100644 index 0000000000..d433b9017c --- /dev/null +++ b/include/qemu/queue.h @@ -0,0 +1,414 @@ +/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ + +/* + * QEMU version: Copy from netbsd, removed debug code, removed some of + * the implementations. Left in singly-linked lists, lists, simple + * queues, and tail queues. + */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef QEMU_SYS_QUEUE_H_ +#define QEMU_SYS_QUEUE_H_ + +/* + * This file defines four types of data structures: singly-linked lists, + * lists, simple queues, and tail queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +#include "qemu/atomic.h" /* for smp_wmb() */ + +/* + * List definitions. + */ +#define QLIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define QLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define QLIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#define QLIST_INIT(head) do { \ + (head)->lh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ + (elm)->field.le_prev = &(head)->lh_first; \ + (elm)->field.le_next = (head)->lh_first; \ + smp_wmb(); /* fill elm before linking it */ \ + if ((head)->lh_first != NULL) { \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ + } \ + (head)->lh_first = (elm); \ + smp_wmb(); \ +} while (/* CONSTCOND*/0) + +#define QLIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define QLIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var); \ + (var) = ((var)->field.le_next)) + +#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->lh_first); \ + (var) && ((next_var) = ((var)->field.le_next), 1); \ + (var) = (next_var)) + +/* + * List access methods. + */ +#define QLIST_EMPTY(head) ((head)->lh_first == NULL) +#define QLIST_FIRST(head) ((head)->lh_first) +#define QLIST_NEXT(elm, field) ((elm)->field.le_next) + + +/* + * Singly-linked List definitions. + */ +#define QSLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define QSLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define QSLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define QSLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ + (slistelm)->field.sle_next = \ + QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ +} while (/*CONSTCOND*/0) + +#define QSLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) + +#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = QSLIST_FIRST((head)); \ + (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List access methods. + */ +#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) +#define QSLIST_FIRST(head) ((head)->slh_first) +#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) + + +/* + * Simple queue definitions. + */ +#define QSIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define QSIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define QSIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define QSIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + QSIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var); \ + (var) = ((var)->field.sqe_next)) + +#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) && ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +#define QSIMPLEQ_CONCAT(head1, head2) do { \ + if (!QSIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + QSIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define QSIMPLEQ_LAST(head, type, field) \ + (QSIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +/* + * Simple queue access methods. + */ +#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) +#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) +#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + + +/* + * Tail queue definitions. + */ +#define Q_TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) + +#define QTAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define Q_TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) + +/* + * Tail queue functions. + */ +#define QTAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define QTAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ + for ((var) = ((head)->tqh_first); \ + (var) && ((next_var) = ((var)->field.tqe_next), 1); \ + (var) = (next_var)) + +#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + (var); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +/* + * Tail queue access methods. + */ +#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define QTAILQ_FIRST(head) ((head)->tqh_first) +#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define QTAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define QTAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + +#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/include/qemu/range.h b/include/qemu/range.h new file mode 100644 index 0000000000..350237212b --- /dev/null +++ b/include/qemu/range.h @@ -0,0 +1,29 @@ +#ifndef QEMU_RANGE_H +#define QEMU_RANGE_H + +/* Get last byte of a range from offset + length. + * Undefined for ranges that wrap around 0. */ +static inline uint64_t range_get_last(uint64_t offset, uint64_t len) +{ + return offset + len - 1; +} + +/* Check whether a given range covers a given byte. */ +static inline int range_covers_byte(uint64_t offset, uint64_t len, + uint64_t byte) +{ + return offset <= byte && byte <= range_get_last(offset, len); +} + +/* Check whether 2 given ranges overlap. + * Undefined if ranges that wrap around 0. */ +static inline int ranges_overlap(uint64_t first1, uint64_t len1, + uint64_t first2, uint64_t len2) +{ + uint64_t last1 = range_get_last(first1, len1); + uint64_t last2 = range_get_last(first2, len2); + + return !(last2 < first1 || last1 < first2); +} + +#endif diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h new file mode 100644 index 0000000000..803ae1798c --- /dev/null +++ b/include/qemu/sockets.h @@ -0,0 +1,77 @@ +/* headers to use the BSD sockets */ +#ifndef QEMU_SOCKET_H +#define QEMU_SOCKET_H + +#ifdef _WIN32 +#include +#include +#include + +#define socket_error() WSAGetLastError() + +int inet_aton(const char *cp, struct in_addr *ia); + +#else + +#include +#include +#include +#include +#include +#include +#include + +#define socket_error() errno +#define closesocket(s) close(s) + +#endif /* !_WIN32 */ + +#include "qemu/option.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" + +/* misc helpers */ +int qemu_socket(int domain, int type, int protocol); +int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int socket_set_cork(int fd, int v); +void socket_set_block(int fd); +void socket_set_nonblock(int fd); +int send_all(int fd, const void *buf, int len1); + +/* callback function for nonblocking connect + * valid fd on success, negative error code on failure + */ +typedef void NonBlockingConnectHandler(int fd, void *opaque); + +int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); +int inet_listen(const char *str, char *ostr, int olen, + int socktype, int port_offset, Error **errp); +int inet_connect_opts(QemuOpts *opts, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int inet_connect(const char *str, Error **errp); +int inet_nonblocking_connect(const char *str, + NonBlockingConnectHandler *callback, + void *opaque, Error **errp); + +int inet_dgram_opts(QemuOpts *opts, Error **errp); +const char *inet_strfamily(int family); + +int unix_listen_opts(QemuOpts *opts, Error **errp); +int unix_listen(const char *path, char *ostr, int olen, Error **errp); +int unix_connect_opts(QemuOpts *opts, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int unix_connect(const char *path, Error **errp); +int unix_nonblocking_connect(const char *str, + NonBlockingConnectHandler *callback, + void *opaque, Error **errp); + +SocketAddress *socket_parse(const char *str, Error **errp); +int socket_connect(SocketAddress *addr, Error **errp, + NonBlockingConnectHandler *callback, void *opaque); +int socket_listen(SocketAddress *addr, Error **errp); + +/* Old, ipv4 only bits. Don't use for new code. */ +int parse_host_port(struct sockaddr_in *saddr, const char *str); +int socket_init(void); + +#endif /* QEMU_SOCKET_H */ diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h new file mode 100644 index 0000000000..380bae209b --- /dev/null +++ b/include/qemu/thread-posix.h @@ -0,0 +1,28 @@ +#ifndef __QEMU_THREAD_POSIX_H +#define __QEMU_THREAD_POSIX_H 1 +#include "pthread.h" +#include + +struct QemuMutex { + pthread_mutex_t lock; +}; + +struct QemuCond { + pthread_cond_t cond; +}; + +struct QemuSemaphore { +#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) + pthread_mutex_t lock; + pthread_cond_t cond; + int count; +#else + sem_t sem; +#endif +}; + +struct QemuThread { + pthread_t thread; +}; + +#endif diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h new file mode 100644 index 0000000000..13adb958f0 --- /dev/null +++ b/include/qemu/thread-win32.h @@ -0,0 +1,29 @@ +#ifndef __QEMU_THREAD_WIN32_H +#define __QEMU_THREAD_WIN32_H 1 +#include "windows.h" + +struct QemuMutex { + CRITICAL_SECTION lock; + LONG owner; +}; + +struct QemuCond { + LONG waiters, target; + HANDLE sema; + HANDLE continue_event; +}; + +struct QemuSemaphore { + HANDLE sema; +}; + +typedef struct QemuThreadData QemuThreadData; +struct QemuThread { + QemuThreadData *data; + unsigned tid; +}; + +/* Only valid for joinable threads. */ +HANDLE qemu_thread_get_handle(QemuThread *thread); + +#endif diff --git a/include/qemu/thread.h b/include/qemu/thread.h new file mode 100644 index 0000000000..c02404b9fb --- /dev/null +++ b/include/qemu/thread.h @@ -0,0 +1,56 @@ +#ifndef __QEMU_THREAD_H +#define __QEMU_THREAD_H 1 + +#include +#include + +typedef struct QemuMutex QemuMutex; +typedef struct QemuCond QemuCond; +typedef struct QemuSemaphore QemuSemaphore; +typedef struct QemuThread QemuThread; + +#ifdef _WIN32 +#include "qemu/thread-win32.h" +#else +#include "qemu/thread-posix.h" +#endif + +#define QEMU_THREAD_JOINABLE 0 +#define QEMU_THREAD_DETACHED 1 + +void qemu_mutex_init(QemuMutex *mutex); +void qemu_mutex_destroy(QemuMutex *mutex); +void qemu_mutex_lock(QemuMutex *mutex); +int qemu_mutex_trylock(QemuMutex *mutex); +void qemu_mutex_unlock(QemuMutex *mutex); + +#define rcu_read_lock() do { } while (0) +#define rcu_read_unlock() do { } while (0) + +void qemu_cond_init(QemuCond *cond); +void qemu_cond_destroy(QemuCond *cond); + +/* + * IMPORTANT: The implementation does not guarantee that pthread_cond_signal + * and pthread_cond_broadcast can be called except while the same mutex is + * held as in the corresponding pthread_cond_wait calls! + */ +void qemu_cond_signal(QemuCond *cond); +void qemu_cond_broadcast(QemuCond *cond); +void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); + +void qemu_sem_init(QemuSemaphore *sem, int init); +void qemu_sem_post(QemuSemaphore *sem); +void qemu_sem_wait(QemuSemaphore *sem); +int qemu_sem_timedwait(QemuSemaphore *sem, int ms); +void qemu_sem_destroy(QemuSemaphore *sem); + +void qemu_thread_create(QemuThread *thread, + void *(*start_routine)(void *), + void *arg, int mode); +void *qemu_thread_join(QemuThread *thread); +void qemu_thread_get_self(QemuThread *thread); +bool qemu_thread_is_self(QemuThread *thread); +void qemu_thread_exit(void *retval); + +#endif diff --git a/include/qemu/timer.h b/include/qemu/timer.h new file mode 100644 index 0000000000..1766b2d6c7 --- /dev/null +++ b/include/qemu/timer.h @@ -0,0 +1,310 @@ +#ifndef QEMU_TIMER_H +#define QEMU_TIMER_H + +#include "qemu-common.h" +#include "qemu/main-loop.h" +#include "qemu/notify.h" + +#ifdef __FreeBSD__ +#include +#endif + +/* timers */ + +#define SCALE_MS 1000000 +#define SCALE_US 1000 +#define SCALE_NS 1 + +typedef struct QEMUClock QEMUClock; +typedef void QEMUTimerCB(void *opaque); + +/* The real time clock should be used only for stuff which does not + change the virtual machine state, as it is run even if the virtual + machine is stopped. The real time clock has a frequency of 1000 + Hz. */ +extern QEMUClock *rt_clock; + +/* The virtual clock is only run during the emulation. It is stopped + when the virtual machine is stopped. Virtual timers use a high + precision clock, usually cpu cycles (use ticks_per_sec). */ +extern QEMUClock *vm_clock; + +/* The host clock should be use for device models that emulate accurate + real time sources. It will continue to run when the virtual machine + is suspended, and it will reflect system time changes the host may + undergo (e.g. due to NTP). The host clock has the same precision as + the virtual clock. */ +extern QEMUClock *host_clock; + +int64_t qemu_get_clock_ns(QEMUClock *clock); +int64_t qemu_clock_has_timers(QEMUClock *clock); +int64_t qemu_clock_expired(QEMUClock *clock); +int64_t qemu_clock_deadline(QEMUClock *clock); +void qemu_clock_enable(QEMUClock *clock, bool enabled); +void qemu_clock_warp(QEMUClock *clock); + +void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); +void qemu_unregister_clock_reset_notifier(QEMUClock *clock, + Notifier *notifier); + +QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, + QEMUTimerCB *cb, void *opaque); +void qemu_free_timer(QEMUTimer *ts); +void qemu_del_timer(QEMUTimer *ts); +void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); +void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); +bool qemu_timer_pending(QEMUTimer *ts); +bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); +uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); + +void qemu_run_timers(QEMUClock *clock); +void qemu_run_all_timers(void); +void configure_alarms(char const *opt); +void init_clocks(void); +int init_timer_alarm(void); + +int64_t cpu_get_ticks(void); +void cpu_enable_ticks(void); +void cpu_disable_ticks(void); + +static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, + void *opaque) +{ + return qemu_new_timer(clock, SCALE_NS, cb, opaque); +} + +static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, + void *opaque) +{ + return qemu_new_timer(clock, SCALE_MS, cb, opaque); +} + +static inline int64_t qemu_get_clock_ms(QEMUClock *clock) +{ + return qemu_get_clock_ns(clock) / SCALE_MS; +} + +static inline int64_t get_ticks_per_sec(void) +{ + return 1000000000LL; +} + +/* real time host monotonic timer */ +static inline int64_t get_clock_realtime(void) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); +} + +/* Warning: don't insert tracepoints into these functions, they are + also used by simpletrace backend and tracepoints would cause + an infinite recursion! */ +#ifdef _WIN32 +extern int64_t clock_freq; + +static inline int64_t get_clock(void) +{ + LARGE_INTEGER ti; + QueryPerformanceCounter(&ti); + return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); +} + +#else + +extern int use_rt_clock; + +static inline int64_t get_clock(void) +{ +#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ + || defined(__DragonFly__) || defined(__FreeBSD_kernel__) + if (use_rt_clock) { + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ts.tv_sec * 1000000000LL + ts.tv_nsec; + } else +#endif + { + /* XXX: using gettimeofday leads to problems if the date + changes, so it should be avoided. */ + return get_clock_realtime(); + } +} +#endif + +void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); +void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); + +/* icount */ +int64_t cpu_get_icount(void); +int64_t cpu_get_clock(void); + +/*******************************************/ +/* host CPU ticks (if available) */ + +#if defined(_ARCH_PPC) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t retval; +#ifdef _ARCH_PPC64 + /* This reads timebase in one 64bit go and includes Cell workaround from: + http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html + */ + __asm__ __volatile__ ("mftb %0\n\t" + "cmpwi %0,0\n\t" + "beq- $-8" + : "=r" (retval)); +#else + /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ + unsigned long junk; + __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ + "mfspr %L0,268\n\t" /* mftb */ + "mfspr %0,269\n\t" /* mftbu */ + "cmpw %0,%1\n\t" + "bne $-16" + : "=r" (retval), "=r" (junk)); +#endif + return retval; +} + +#elif defined(__i386__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("rdtsc" : "=A" (val)); + return val; +} + +#elif defined(__x86_64__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint32_t low,high; + int64_t val; + asm volatile("rdtsc" : "=a" (low), "=d" (high)); + val = high; + val <<= 32; + val |= low; + return val; +} + +#elif defined(__hppa__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int val; + asm volatile ("mfctl %%cr16, %0" : "=r"(val)); + return val; +} + +#elif defined(__ia64) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); + return val; +} + +#elif defined(__s390__) + +static inline int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); + return val; +} + +#elif defined(__sparc__) + +static inline int64_t cpu_get_real_ticks (void) +{ +#if defined(_LP64) + uint64_t rval; + asm volatile("rd %%tick,%0" : "=r"(rval)); + return rval; +#else + /* We need an %o or %g register for this. For recent enough gcc + there is an "h" constraint for that. Don't bother with that. */ + union { + uint64_t i64; + struct { + uint32_t high; + uint32_t low; + } i32; + } rval; + asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" + : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); + return rval.i64; +#endif +} + +#elif defined(__mips__) && \ + ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) +/* + * binutils wants to use rdhwr only on mips32r2 + * but as linux kernel emulate it, it's fine + * to use it. + * + */ +#define MIPS_RDHWR(rd, value) { \ + __asm__ __volatile__ (".set push\n\t" \ + ".set mips32r2\n\t" \ + "rdhwr %0, "rd"\n\t" \ + ".set pop" \ + : "=r" (value)); \ + } + +static inline int64_t cpu_get_real_ticks(void) +{ + /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ + uint32_t count; + static uint32_t cyc_per_count = 0; + + if (!cyc_per_count) { + MIPS_RDHWR("$3", cyc_per_count); + } + + MIPS_RDHWR("$2", count); + return (int64_t)(count * cyc_per_count); +} + +#elif defined(__alpha__) + +static inline int64_t cpu_get_real_ticks(void) +{ + uint64_t cc; + uint32_t cur, ofs; + + asm volatile("rpcc %0" : "=r"(cc)); + cur = cc; + ofs = cc >> 32; + return cur - ofs; +} + +#else +/* The host CPU doesn't have an easily accessible cycle counter. + Just return a monotonically increasing value. This will be + totally wrong, but hopefully better than nothing. */ +static inline int64_t cpu_get_real_ticks (void) +{ + static int64_t ticks = 0; + return ticks++; +} +#endif + +#ifdef CONFIG_PROFILER +static inline int64_t profile_getclock(void) +{ + return cpu_get_real_ticks(); +} + +extern int64_t qemu_time, qemu_time_start; +extern int64_t tlb_flush_time; +extern int64_t dev_time; +#endif + +#endif diff --git a/include/qemu/tls.h b/include/qemu/tls.h new file mode 100644 index 0000000000..b92ea9d7da --- /dev/null +++ b/include/qemu/tls.h @@ -0,0 +1,52 @@ +/* + * Abstraction layer for defining and using TLS variables + * + * Copyright (c) 2011 Red Hat, Inc + * Copyright (c) 2011 Linaro Limited + * + * Authors: + * Paolo Bonzini + * Peter Maydell + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#ifndef QEMU_TLS_H +#define QEMU_TLS_H + +/* Per-thread variables. Note that we only have implementations + * which are really thread-local on Linux; the dummy implementations + * define plain global variables. + * + * This means that for the moment use should be restricted to + * per-VCPU variables, which are OK because: + * - the only -user mode supporting multiple VCPU threads is linux-user + * - TCG system mode is single-threaded regarding VCPUs + * - KVM system mode is multi-threaded but limited to Linux + * + * TODO: proper implementations via Win32 .tls sections and + * POSIX pthread_getspecific. + */ +#ifdef __linux__ +#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) +#define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x +#define tls_var(x) tls__##x +#else +/* Dummy implementations which define plain global variables */ +#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) +#define DEFINE_TLS(type, x) __typeof__(type) tls__##x +#define tls_var(x) tls__##x +#endif + +#endif diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h new file mode 100644 index 0000000000..fd532a268d --- /dev/null +++ b/include/qemu/typedefs.h @@ -0,0 +1,61 @@ +#ifndef QEMU_TYPEDEFS_H +#define QEMU_TYPEDEFS_H + +/* A load of opaque types so that device init declarations don't have to + pull in all the real definitions. */ +typedef struct QEMUTimer QEMUTimer; +typedef struct QEMUFile QEMUFile; +typedef struct QEMUBH QEMUBH; + +struct Monitor; +typedef struct Monitor Monitor; +typedef struct MigrationParams MigrationParams; + +typedef struct Property Property; +typedef struct PropertyInfo PropertyInfo; +typedef struct CompatProperty CompatProperty; +typedef struct DeviceState DeviceState; +typedef struct BusState BusState; +typedef struct BusClass BusClass; + +typedef struct NICInfo NICInfo; +typedef struct HCIInfo HCIInfo; +typedef struct AudioState AudioState; +typedef struct BlockDriverState BlockDriverState; +typedef struct DriveInfo DriveInfo; +typedef struct DisplayState DisplayState; +typedef struct DisplayChangeListener DisplayChangeListener; +typedef struct DisplaySurface DisplaySurface; +typedef struct PixelFormat PixelFormat; +typedef struct QemuConsole QemuConsole; +typedef struct CharDriverState CharDriverState; +typedef struct MACAddr MACAddr; +typedef struct NetClientState NetClientState; +typedef struct i2c_bus i2c_bus; +typedef struct ISABus ISABus; +typedef struct ISADevice ISADevice; +typedef struct SMBusDevice SMBusDevice; +typedef struct PCIHostState PCIHostState; +typedef struct PCIExpressHost PCIExpressHost; +typedef struct PCIBus PCIBus; +typedef struct PCIDevice PCIDevice; +typedef struct PCIExpressDevice PCIExpressDevice; +typedef struct PCIBridge PCIBridge; +typedef struct PCIEAERMsg PCIEAERMsg; +typedef struct PCIEAERLog PCIEAERLog; +typedef struct PCIEAERErr PCIEAERErr; +typedef struct PCIEPort PCIEPort; +typedef struct PCIESlot PCIESlot; +typedef struct MSIMessage MSIMessage; +typedef struct SerialState SerialState; +typedef struct PCMCIACardState PCMCIACardState; +typedef struct MouseTransformInfo MouseTransformInfo; +typedef struct uWireSlave uWireSlave; +typedef struct I2SCodec I2SCodec; +typedef struct SSIBus SSIBus; +typedef struct EventNotifier EventNotifier; +typedef struct VirtIODevice VirtIODevice; +typedef struct QEMUSGList QEMUSGList; +typedef struct SHPCDevice SHPCDevice; + +#endif /* QEMU_TYPEDEFS_H */ diff --git a/include/qemu/uri.h b/include/qemu/uri.h new file mode 100644 index 0000000000..de99b3bd4b --- /dev/null +++ b/include/qemu/uri.h @@ -0,0 +1,113 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Daniel Veillard shall not + * be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from him. + * + * Author: Daniel Veillard + ** + * Copyright (C) 2007 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Authors: + * Richard W.M. Jones + * + * Utility functions to help parse and assemble query strings. + */ + +#ifndef QEMU_URI_H +#define QEMU_URI_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * URI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + */ +typedef struct URI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ + char *query; /* the query string (as it appears in the URI) */ +} URI; + +URI *uri_new(void); +char *uri_resolve(const char *URI, const char *base); +char *uri_resolve_relative(const char *URI, const char *base); +URI *uri_parse(const char *str); +URI *uri_parse_raw(const char *str, int raw); +int uri_parse_into(URI *uri, const char *str); +char *uri_to_string(URI *uri); +char *uri_string_escape(const char *str, const char *list); +char *uri_string_unescape(const char *str, int len, char *target); +void uri_free(URI *uri); + +/* Single web service query parameter 'name=value'. */ +typedef struct QueryParam { + char *name; /* Name (unescaped). */ + char *value; /* Value (unescaped). */ + int ignore; /* Ignore this field in qparam_get_query */ +} QueryParam; + +/* Set of parameters. */ +typedef struct QueryParams { + int n; /* number of parameters used */ + int alloc; /* allocated space */ + QueryParam *p; /* array of parameters */ +} QueryParams; + +struct QueryParams *query_params_new (int init_alloc); +int query_param_append (QueryParams *ps, const char *name, const char *value); +extern char *query_param_to_string (const QueryParams *ps); +extern QueryParams *query_params_parse (const char *query); +extern void query_params_free (QueryParams *ps); + +#ifdef __cplusplus +} +#endif +#endif /* QEMU_URI_H */ diff --git a/include/qemu/xattr.h b/include/qemu/xattr.h new file mode 100644 index 0000000000..f910d96eaf --- /dev/null +++ b/include/qemu/xattr.h @@ -0,0 +1,30 @@ +/* + * Host xattr.h abstraction + * + * Copyright 2011 Red Hat Inc. and/or its affiliates + * + * Authors: + * Avi Kivity + * + * This work is licensed under the terms of the GNU GPL, version 2, or any + * later version. See the COPYING file in the top-level directory. + * + */ +#ifndef QEMU_XATTR_H +#define QEMU_XATTR_H + +/* + * Modern distributions (e.g. Fedora 15, have no libattr.so, place attr.h + * in /usr/include/sys, and don't have ENOATTR. + */ + +#include "config-host.h" + +#ifdef CONFIG_LIBATTR +# include +#else +# define ENOATTR ENODATA +# include +#endif + +#endif diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9682dd59ed..9e9d044bdf 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -21,7 +21,7 @@ #define QEMU_CPU_H #include "qom/object.h" -#include "qemu-thread.h" +#include "qemu/thread.h" /** * SECTION:cpu diff --git a/include/qom/object.h b/include/qom/object.h index ed1f47f050..abe9691cb7 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -17,7 +17,7 @@ #include #include #include -#include "qemu-queue.h" +#include "qemu/queue.h" struct Visitor; struct Error; diff --git a/include/ui/console.h b/include/ui/console.h index 3db6635b0a..fc23baa06b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -3,7 +3,7 @@ #include "ui/qemu-pixman.h" #include "qapi/qmp/qdict.h" -#include "notify.h" +#include "qemu/notify.h" #include "monitor/monitor.h" #include "trace.h" #include "qapi-types.h" diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 3e08be06bf..73422adeee 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -22,8 +22,8 @@ #include -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "monitor/monitor.h" extern int using_spice; diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 928e0a1bae..a0d1a50487 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -19,7 +19,7 @@ #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" #include "ui/qemu-pixman.h" #include "sysemu.h" diff --git a/int128.h b/int128.h deleted file mode 100644 index b3864b6cd4..0000000000 --- a/int128.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef INT128_H -#define INT128_H - -typedef struct Int128 Int128; - -struct Int128 { - uint64_t lo; - int64_t hi; -}; - -static inline Int128 int128_make64(uint64_t a) -{ - return (Int128) { a, 0 }; -} - -static inline uint64_t int128_get64(Int128 a) -{ - assert(!a.hi); - return a.lo; -} - -static inline Int128 int128_zero(void) -{ - return int128_make64(0); -} - -static inline Int128 int128_one(void) -{ - return int128_make64(1); -} - -static inline Int128 int128_2_64(void) -{ - return (Int128) { 0, 1 }; -} - -static inline Int128 int128_add(Int128 a, Int128 b) -{ - Int128 r = { a.lo + b.lo, a.hi + b.hi }; - r.hi += (r.lo < a.lo) || (r.lo < b.lo); - return r; -} - -static inline Int128 int128_neg(Int128 a) -{ - a.lo = ~a.lo; - a.hi = ~a.hi; - return int128_add(a, int128_one()); -} - -static inline Int128 int128_sub(Int128 a, Int128 b) -{ - return int128_add(a, int128_neg(b)); -} - -static inline bool int128_nonneg(Int128 a) -{ - return a.hi >= 0; -} - -static inline bool int128_eq(Int128 a, Int128 b) -{ - return a.lo == b.lo && a.hi == b.hi; -} - -static inline bool int128_ne(Int128 a, Int128 b) -{ - return !int128_eq(a, b); -} - -static inline bool int128_ge(Int128 a, Int128 b) -{ - return int128_nonneg(int128_sub(a, b)); -} - -static inline bool int128_lt(Int128 a, Int128 b) -{ - return !int128_ge(a, b); -} - -static inline bool int128_le(Int128 a, Int128 b) -{ - return int128_ge(b, a); -} - -static inline bool int128_gt(Int128 a, Int128 b) -{ - return !int128_le(a, b); -} - -static inline bool int128_nz(Int128 a) -{ - return a.lo || a.hi; -} - -static inline Int128 int128_min(Int128 a, Int128 b) -{ - return int128_le(a, b) ? a : b; -} - -static inline Int128 int128_max(Int128 a, Int128 b) -{ - return int128_ge(a, b) ? a : b; -} - -static inline void int128_addto(Int128 *a, Int128 b) -{ - *a = int128_add(*a, b); -} - -static inline void int128_subfrom(Int128 *a, Int128 b) -{ - *a = int128_sub(*a, b); -} - -#endif diff --git a/iohandler.c b/iohandler.c index cf8276dffc..2523adc11d 100644 --- a/iohandler.c +++ b/iohandler.c @@ -24,9 +24,9 @@ #include "config-host.h" #include "qemu-common.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/aio.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef _WIN32 #include diff --git a/iov.c b/iov.c index a81eedcedb..419e419969 100644 --- a/iov.c +++ b/iov.c @@ -16,7 +16,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "iov.h" +#include "qemu/iov.h" #ifdef _WIN32 # include diff --git a/iov.h b/iov.h deleted file mode 100644 index d06f8b9ce3..0000000000 --- a/iov.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Helpers for using (partial) iovecs. - * - * Copyright (C) 2010 Red Hat, Inc. - * - * Author(s): - * Amit Shah - * Michael Tokarev - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#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. - */ -size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt); - -/** - * Copy from single continuous buffer to scatter-gather vector of buffers - * (iovec) and back like memcpy() between two continuous memory regions. - * Data in single continuous buffer starting at address `buf' and - * `bytes' bytes long will be copied to/from an iovec `iov' with - * `iov_cnt' number of elements, starting at byte position `offset' - * within the iovec. If the iovec does not contain enough space, - * only part of data will be copied, up to the end of the iovec. - * Number of bytes actually copied will be returned, which is - * min(bytes, iov_size(iov)-offset) - * `Offset' must point to the inside of iovec. - * It is okay to use very large value for `bytes' since we're - * limited by the size of the iovec anyway, provided that the - * buffer pointed to by buf has enough space. One possible - * such "large" value is -1 (sinice size_t is unsigned), - * so specifying `-1' as `bytes' means 'up to the end of iovec'. - */ -size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, - size_t offset, const void *buf, size_t bytes); -size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, - size_t offset, void *buf, size_t bytes); - -/** - * Set data bytes pointed out by iovec `iov' of size `iov_cnt' elements, - * starting at byte offset `start', to value `fillc', repeating it - * `bytes' number of times. `Offset' must point to the inside of iovec. - * If `bytes' is large enough, only last bytes portion of iovec, - * up to the end of it, will be filled with the specified value. - * Function return actual number of bytes processed, which is - * min(size, iov_size(iov) - offset). - * Again, it is okay to use large value for `bytes' to mean "up to the end". - */ -size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, - size_t offset, int fillc, size_t bytes); - -/* - * Send/recv data from/to iovec buffers directly - * - * `offset' bytes in the beginning of iovec buffer are skipped and - * next `bytes' bytes are used, which must be within data of iovec. - * - * r = iov_send_recv(sockfd, iov, iovcnt, offset, bytes, true); - * - * is logically equivalent to - * - * char *buf = malloc(bytes); - * iov_to_buf(iov, iovcnt, offset, buf, bytes); - * r = send(sockfd, buf, bytes, 0); - * free(buf); - * - * For iov_send_recv() _whole_ area being sent or received - * should be within the iovec, not only beginning of it. - */ -ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, - size_t offset, size_t bytes, bool do_send); -#define iov_recv(sockfd, iov, iov_cnt, offset, bytes) \ - iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, false) -#define iov_send(sockfd, iov, iov_cnt, offset, bytes) \ - iov_send_recv(sockfd, iov, iov_cnt, offset, bytes, true) - -/** - * Produce a text hexdump of iovec `iov' with `iov_cnt' number of elements - * in file `fp', prefixing each line with `prefix' and processing not more - * than `limit' data bytes. - */ -void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, - FILE *fp, const char *prefix, size_t limit); - -/* - * Partial copy of vector from iov to dst_iov (data is not copied). - * dst_iov overlaps iov at a specified offset. - * size of dst_iov is at most bytes. dst vector count is returned. - */ -unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, - const struct iovec *iov, unsigned int iov_cnt, - size_t offset, size_t bytes); - -#endif diff --git a/kvm-all.c b/kvm-all.c index c2588594e1..41ea3aa6ee 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -21,18 +21,18 @@ #include #include "qemu-common.h" -#include "qemu-barrier.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/atomic.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "sysemu.h" #include "hw/hw.h" #include "hw/pci/msi.h" #include "exec/gdbstub.h" #include "kvm.h" -#include "bswap.h" +#include "qemu/bswap.h" #include "exec/memory.h" #include "exec/address-spaces.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD diff --git a/kvm.h b/kvm.h index 72d866a966..131d2bdc15 100644 --- a/kvm.h +++ b/kvm.h @@ -16,7 +16,7 @@ #include #include "config-host.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #ifdef CONFIG_KVM #include diff --git a/libcacard/event.c b/libcacard/event.c index 61923761c9..2d7500fac0 100644 --- a/libcacard/event.c +++ b/libcacard/event.c @@ -6,7 +6,7 @@ */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "vcard.h" #include "vreader.h" diff --git a/libcacard/vreader.c b/libcacard/vreader.c index 96d2407e78..313349b656 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -6,7 +6,7 @@ */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include "vcard.h" #include "vcard_emul.h" diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c index b64c93dd69..2fce52bed5 100644 --- a/libcacard/vscclient.c +++ b/libcacard/vscclient.c @@ -13,8 +13,8 @@ #include #include "qemu-common.h" -#include "qemu-thread.h" -#include "qemu_socket.h" +#include "qemu/thread.h" +#include "qemu/sockets.h" #include "vscard_common.h" diff --git a/libfdt_env.h b/libfdt_env.h index 90d7f3b162..7938d73fae 100644 --- a/libfdt_env.h +++ b/libfdt_env.h @@ -19,7 +19,7 @@ #ifndef _LIBFDT_ENV_H #define _LIBFDT_ENV_H -#include "bswap.h" +#include "qemu/bswap.h" #ifdef HOST_WORDS_BIGENDIAN #define fdt32_to_cpu(x) (x) diff --git a/linux-user/main.c b/linux-user/main.c index 25e35cd3dc..f6c4c8d7a3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -28,11 +28,11 @@ #include "qemu.h" #include "qemu-common.h" -#include "cache-utils.h" +#include "qemu/cache-utils.h" #include "cpu.h" #include "tcg.h" -#include "qemu-timer.h" -#include "envlist.h" +#include "qemu/timer.h" +#include "qemu/envlist.h" #include "elf.h" #define DEBUG_LOGFILE "/tmp/qemu.log" diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 2af883bf74..8a3538c631 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -18,7 +18,7 @@ #include "syscall.h" #include "target_signal.h" #include "exec/gdbstub.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #if defined(CONFIG_USE_NPTL) #define THREAD __thread @@ -217,7 +217,7 @@ unsigned long init_guest_space(unsigned long host_start, unsigned long guest_start, bool fixed); -#include "qemu-log.h" +#include "qemu/log.h" /* syscall.c */ int host_to_target_waitstatus(int status); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 31d5276465..7c304e92de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -72,7 +72,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #endif #ifdef CONFIG_ATTR -#include "qemu-xattr.h" +#include "qemu/xattr.h" #endif #define termios host_termios diff --git a/main-loop.c b/main-loop.c index f9006118ad..54f38ae1ae 100644 --- a/main-loop.c +++ b/main-loop.c @@ -23,14 +23,14 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "slirp/slirp.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "block/aio.h" #ifndef _WIN32 -#include "compatfd.h" +#include "qemu/compatfd.h" /* If we have signalfd, we mask out the signals we want to handle and then * use signalfd to listen for them. We rely on whatever the current signal diff --git a/main-loop.h b/main-loop.h deleted file mode 100644 index e8059c3d0a..0000000000 --- a/main-loop.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * QEMU System Emulator - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_MAIN_LOOP_H -#define QEMU_MAIN_LOOP_H 1 - -#include "block/aio.h" - -#define SIG_IPI SIGUSR1 - -/** - * qemu_init_main_loop: Set up the process so that it can run the main loop. - * - * This includes setting up signal handlers. It should be called before - * any other threads are created. In addition, threads other than the - * main one should block signals that are trapped by the main loop. - * For simplicity, you can consider these signals to be safe: SIGUSR1, - * SIGUSR2, thread signals (SIGFPE, SIGILL, SIGSEGV, SIGBUS) and real-time - * signals if available. Remember that Windows in practice does not have - * signals, though. - * - * In the case of QEMU tools, this will also start/initialize timers. - */ -int qemu_init_main_loop(void); - -/** - * main_loop_wait: Run one iteration of the main loop. - * - * If @nonblocking is true, poll for events, otherwise suspend until - * one actually occurs. The main loop usually consists of a loop that - * repeatedly calls main_loop_wait(false). - * - * Main loop services include file descriptor callbacks, bottom halves - * and timers (defined in qemu-timer.h). Bottom halves are similar to timers - * that execute immediately, but have a lower overhead and scheduling them - * is wait-free, thread-safe and signal-safe. - * - * It is sometimes useful to put a whole program in a coroutine. In this - * case, the coroutine actually should be started from within the main loop, - * so that the main loop can run whenever the coroutine yields. To do this, - * you can use a bottom half to enter the coroutine as soon as the main loop - * starts: - * - * void enter_co_bh(void *opaque) { - * QEMUCoroutine *co = opaque; - * qemu_coroutine_enter(co, NULL); - * } - * - * ... - * QEMUCoroutine *co = qemu_coroutine_create(coroutine_entry); - * QEMUBH *start_bh = qemu_bh_new(enter_co_bh, co); - * qemu_bh_schedule(start_bh); - * while (...) { - * main_loop_wait(false); - * } - * - * (In the future we may provide a wrapper for this). - * - * @nonblocking: Whether the caller should block until an event occurs. - */ -int main_loop_wait(int nonblocking); - -/** - * qemu_notify_event: Force processing of pending events. - * - * Similar to signaling a condition variable, qemu_notify_event forces - * main_loop_wait to look at pending events and exit. The caller of - * main_loop_wait will usually call it again very soon, so qemu_notify_event - * also has the side effect of recalculating the sets of file descriptors - * that the main loop waits for. - * - * Calling qemu_notify_event is rarely necessary, because main loop - * services (bottom halves and timers) call it themselves. One notable - * exception occurs when using qemu_set_fd_handler2 (see below). - */ -void qemu_notify_event(void); - -#ifdef _WIN32 -/* return TRUE if no sleep should be done afterwards */ -typedef int PollingFunc(void *opaque); - -/** - * qemu_add_polling_cb: Register a Windows-specific polling callback - * - * Currently, under Windows some events are polled rather than waited for. - * Polling callbacks do not ensure that @func is called timely, because - * the main loop might wait for an arbitrarily long time. If possible, - * you should instead create a separate thread that does a blocking poll - * and set a Win32 event object. The event can then be passed to - * qemu_add_wait_object. - * - * Polling callbacks really have nothing Windows specific in them, but - * as they are a hack and are currently not necessary under POSIX systems, - * they are only available when QEMU is running under Windows. - * - * @func: The function that does the polling, and returns 1 to force - * immediate completion of main_loop_wait. - * @opaque: A pointer-size value that is passed to @func. - */ -int qemu_add_polling_cb(PollingFunc *func, void *opaque); - -/** - * qemu_del_polling_cb: Unregister a Windows-specific polling callback - * - * This function removes a callback that was registered with - * qemu_add_polling_cb. - * - * @func: The function that was passed to qemu_add_polling_cb. - * @opaque: A pointer-size value that was passed to qemu_add_polling_cb. - */ -void qemu_del_polling_cb(PollingFunc *func, void *opaque); - -/* Wait objects handling */ -typedef void WaitObjectFunc(void *opaque); - -/** - * qemu_add_wait_object: Register a callback for a Windows handle - * - * Under Windows, the iohandler mechanism can only be used with sockets. - * QEMU must use the WaitForMultipleObjects API to wait on other handles. - * This function registers a #HANDLE with QEMU, so that it will be included - * in the main loop's calls to WaitForMultipleObjects. When the handle - * is in a signaled state, QEMU will call @func. - * - * @handle: The Windows handle to be observed. - * @func: A function to be called when @handle is in a signaled state. - * @opaque: A pointer-size value that is passed to @func. - */ -int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); - -/** - * qemu_del_wait_object: Unregister a callback for a Windows handle - * - * This function removes a callback that was registered with - * qemu_add_wait_object. - * - * @func: The function that was passed to qemu_add_wait_object. - * @opaque: A pointer-size value that was passed to qemu_add_wait_object. - */ -void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); -#endif - -/* async I/O support */ - -typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); -typedef int IOCanReadHandler(void *opaque); - -/** - * qemu_set_fd_handler2: Register a file descriptor with the main loop - * - * This function tells the main loop to wake up whenever one of the - * following conditions is true: - * - * 1) if @fd_write is not %NULL, when the file descriptor is writable; - * - * 2) if @fd_read is not %NULL, when the file descriptor is readable. - * - * @fd_read_poll can be used to disable the @fd_read callback temporarily. - * This is useful to avoid calling qemu_set_fd_handler2 every time the - * client becomes interested in reading (or dually, stops being interested). - * A typical example is when @fd is a listening socket and you want to bound - * the number of active clients. Remember to call qemu_notify_event whenever - * the condition may change from %false to %true. - * - * The callbacks that are set up by qemu_set_fd_handler2 are level-triggered. - * If @fd_read does not read from @fd, or @fd_write does not write to @fd - * until its buffers are full, they will be called again on the next - * iteration. - * - * @fd: The file descriptor to be observed. Under Windows it must be - * a #SOCKET. - * - * @fd_read_poll: A function that returns 1 if the @fd_read callback - * should be fired. If the function returns 0, the main loop will not - * end its iteration even if @fd becomes readable. - * - * @fd_read: A level-triggered callback that is fired if @fd is readable - * at the beginning of a main loop iteration, or if it becomes readable - * during one. - * - * @fd_write: A level-triggered callback that is fired when @fd is writable - * at the beginning of a main loop iteration, or if it becomes writable - * during one. - * - * @opaque: A pointer-sized value that is passed to @fd_read_poll, - * @fd_read and @fd_write. - */ -int qemu_set_fd_handler2(int fd, - IOCanReadHandler *fd_read_poll, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque); - -/** - * qemu_set_fd_handler: Register a file descriptor with the main loop - * - * This function tells the main loop to wake up whenever one of the - * following conditions is true: - * - * 1) if @fd_write is not %NULL, when the file descriptor is writable; - * - * 2) if @fd_read is not %NULL, when the file descriptor is readable. - * - * The callbacks that are set up by qemu_set_fd_handler are level-triggered. - * If @fd_read does not read from @fd, or @fd_write does not write to @fd - * until its buffers are full, they will be called again on the next - * iteration. - * - * @fd: The file descriptor to be observed. Under Windows it must be - * a #SOCKET. - * - * @fd_read: A level-triggered callback that is fired if @fd is readable - * at the beginning of a main loop iteration, or if it becomes readable - * during one. - * - * @fd_write: A level-triggered callback that is fired when @fd is writable - * at the beginning of a main loop iteration, or if it becomes writable - * during one. - * - * @opaque: A pointer-sized value that is passed to @fd_read and @fd_write. - */ -int qemu_set_fd_handler(int fd, - IOHandler *fd_read, - IOHandler *fd_write, - void *opaque); - -#ifdef CONFIG_POSIX -/** - * qemu_add_child_watch: Register a child process for reaping. - * - * Under POSIX systems, a parent process must read the exit status of - * its child processes using waitpid, or the operating system will not - * free some of the resources attached to that process. - * - * This function directs the QEMU main loop to observe a child process - * and call waitpid as soon as it exits; the watch is then removed - * automatically. It is useful whenever QEMU forks a child process - * but will find out about its termination by other means such as a - * "broken pipe". - * - * @pid: The pid that QEMU should observe. - */ -int qemu_add_child_watch(pid_t pid); -#endif - -/** - * qemu_mutex_lock_iothread: Lock the main loop mutex. - * - * This function locks the main loop mutex. The mutex is taken by - * qemu_init_main_loop and always taken except while waiting on - * external events (such as with select). The mutex should be taken - * by threads other than the main loop thread when calling - * qemu_bh_new(), qemu_set_fd_handler() and basically all other - * functions documented in this file. - * - * NOTE: tools currently are single-threaded and qemu_mutex_lock_iothread - * is a no-op there. - */ -void qemu_mutex_lock_iothread(void); - -/** - * qemu_mutex_unlock_iothread: Unlock the main loop mutex. - * - * This function unlocks the main loop mutex. The mutex is taken by - * qemu_init_main_loop and always taken except while waiting on - * external events (such as with select). The mutex should be unlocked - * as soon as possible by threads other than the main loop thread, - * because it prevents the main loop from processing callbacks, - * including timers and bottom halves. - * - * NOTE: tools currently are single-threaded and qemu_mutex_unlock_iothread - * is a no-op there. - */ -void qemu_mutex_unlock_iothread(void); - -/* internal interfaces */ - -void qemu_fd_register(int fd); -void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds); -void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc); - -QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); -void qemu_bh_schedule_idle(QEMUBH *bh); - -#endif diff --git a/memory.c b/memory.c index d40193d474..d44200335b 100644 --- a/memory.c +++ b/memory.c @@ -16,7 +16,7 @@ #include "exec/memory.h" #include "exec/address-spaces.h" #include "exec/ioport.h" -#include "bitops.h" +#include "qemu/bitops.h" #include "kvm.h" #include diff --git a/memory_mapping.h b/memory_mapping.h index d5ba46c7e7..1256125963 100644 --- a/memory_mapping.h +++ b/memory_mapping.h @@ -14,7 +14,7 @@ #ifndef MEMORY_MAPPING_H #define MEMORY_MAPPING_H -#include "qemu-queue.h" +#include "qemu/queue.h" /* The physical and virtual address in the memory mapping are contiguous. */ typedef struct MemoryMapping { diff --git a/migration-exec.c b/migration-exec.c index 784486d2fc..68f36f41f1 100644 --- a/migration-exec.c +++ b/migration-exec.c @@ -16,7 +16,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-fd.c b/migration-fd.c index ab5abe2aa5..ea121bc0d6 100644 --- a/migration-fd.c +++ b/migration-fd.c @@ -14,12 +14,12 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "buffered_file.h" #include "block/block.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" //#define DEBUG_MIGRATION_FD diff --git a/migration-tcp.c b/migration-tcp.c index a36e637ffd..3c4c315052 100644 --- a/migration-tcp.c +++ b/migration-tcp.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration-unix.c b/migration-unix.c index 9debc952da..d5f986853f 100644 --- a/migration-unix.c +++ b/migration-unix.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/migration.h" #include "buffered_file.h" #include "block/block.h" diff --git a/migration.c b/migration.c index 0456983bad..8c5c5670d8 100644 --- a/migration.c +++ b/migration.c @@ -19,7 +19,7 @@ #include "buffered_file.h" #include "sysemu.h" #include "block/block.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "migration/block.h" #include "qmp-commands.h" diff --git a/module.c b/module.c index c3a6da7a86..7acc33d076 100644 --- a/module.c +++ b/module.c @@ -14,8 +14,8 @@ */ #include "qemu-common.h" -#include "qemu-queue.h" -#include "module.h" +#include "qemu/queue.h" +#include "qemu/module.h" typedef struct ModuleEntry { diff --git a/module.h b/module.h deleted file mode 100644 index c4ccd57166..0000000000 --- a/module.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * QEMU Module Infrastructure - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_MODULE_H -#define QEMU_MODULE_H - -/* This should not be used directly. Use block_init etc. instead. */ -#define module_init(function, type) \ -static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \ - register_module_init(function, type); \ -} - -typedef enum { - MODULE_INIT_BLOCK, - MODULE_INIT_MACHINE, - MODULE_INIT_QAPI, - MODULE_INIT_QOM, - MODULE_INIT_MAX -} module_init_type; - -#define block_init(function) module_init(function, MODULE_INIT_BLOCK) -#define machine_init(function) module_init(function, MODULE_INIT_MACHINE) -#define qapi_init(function) module_init(function, MODULE_INIT_QAPI) -#define type_init(function) module_init(function, MODULE_INIT_QOM) - -void register_module_init(void (*fn)(void), module_init_type type); - -void module_call_init(module_init_type type); - -#endif diff --git a/monitor.c b/monitor.c index 46fdc008f4..878b2317af 100644 --- a/monitor.c +++ b/monitor.c @@ -43,10 +43,10 @@ #include "audio/audio.h" #include "disas/disas.h" #include "balloon.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "migration/migration.h" #include "kvm.h" -#include "acl.h" +#include "qemu/acl.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" #include "qapi/qmp/qlist.h" @@ -55,7 +55,7 @@ #include "qapi/qmp/qjson.h" #include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-parser.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "cpu.h" #include "trace.h" #include "trace/control.h" @@ -66,7 +66,7 @@ #include "exec/memory.h" #include "qmp-commands.h" #include "hmp.h" -#include "qemu-thread.h" +#include "qemu/thread.h" /* for pic/irq_info */ #if defined(TARGET_SPARC) diff --git a/nbd.c b/nbd.c index 04ff0a1d44..0698a023ad 100644 --- a/nbd.c +++ b/nbd.c @@ -36,8 +36,8 @@ #include #endif -#include "qemu_socket.h" -#include "qemu-queue.h" +#include "qemu/sockets.h" +#include "qemu/queue.h" //#define DEBUG_NBD diff --git a/net/dump.c b/net/dump.c index e0a5d74644..4119721720 100644 --- a/net/dump.c +++ b/net/dump.c @@ -24,9 +24,9 @@ #include "clients.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-log.h" -#include "qemu-timer.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "qemu/timer.h" #include "hub.h" typedef struct DumpState { diff --git a/net/hub.c b/net/hub.c index 81a73b54a7..5adfce444b 100644 --- a/net/hub.c +++ b/net/hub.c @@ -16,7 +16,7 @@ #include "net/net.h" #include "clients.h" #include "hub.h" -#include "iov.h" +#include "qemu/iov.h" /* * A hub broadcasts incoming packets to all its ports except the source port. diff --git a/net/net.c b/net/net.c index e4d85a9cfa..dbf3e1b003 100644 --- a/net/net.c +++ b/net/net.c @@ -31,11 +31,11 @@ #include "monitor/monitor.h" #include "qemu-common.h" -#include "qemu_socket.h" -#include "qemu-config.h" +#include "qemu/sockets.h" +#include "qemu/config-file.h" #include "qmp-commands.h" #include "hw/qdev.h" -#include "iov.h" +#include "qemu/iov.h" #include "qapi-visit.h" #include "qapi/opts-visitor.h" #include "qapi/dealloc-visitor.h" diff --git a/net/queue.c b/net/queue.c index 542c549b1a..6eaf5b63c0 100644 --- a/net/queue.c +++ b/net/queue.c @@ -22,7 +22,7 @@ */ #include "net/queue.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "net/net.h" /* The delivery handler may only return zero if it will call diff --git a/net/slirp.c b/net/slirp.c index c37a5ef959..87bdc9d031 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -33,7 +33,7 @@ #include "clients.h" #include "hub.h" #include "monitor/monitor.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include "qemu-char.h" diff --git a/net/socket.c b/net/socket.c index bc2b951832..396dc8c0b1 100644 --- a/net/socket.c +++ b/net/socket.c @@ -27,10 +27,10 @@ #include "clients.h" #include "monitor/monitor.h" #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-option.h" -#include "qemu_socket.h" -#include "iov.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" typedef struct NetSocketState { NetClientState nc; diff --git a/net/tap-bsd.c b/net/tap-bsd.c index a1c55ad3de..b48182f678 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -25,7 +25,7 @@ #include "tap_int.h" #include "qemu-common.h" #include "sysemu.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #ifdef __NetBSD__ #include diff --git a/net/tap-linux.c b/net/tap-linux.c index 3de7b3b6ce..dd4b915243 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -32,7 +32,7 @@ #include "sysemu.h" #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #define PATH_NET_TUN "/dev/net/tun" diff --git a/net/tap-solaris.c b/net/tap-solaris.c index f228fffb6d..3d5fee5542 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -38,7 +38,7 @@ #include #include #include -#include "qemu-error.h" +#include "qemu/error-report.h" ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) { diff --git a/net/tap-win32.c b/net/tap-win32.c index e37d8ee458..1ddd6fa6e6 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -32,7 +32,7 @@ #include "clients.h" /* net_init_tap */ #include "net/net.h" #include "sysemu.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include #include #include diff --git a/net/tap.c b/net/tap.c index 9a677e9864..d34ff13398 100644 --- a/net/tap.c +++ b/net/tap.c @@ -38,7 +38,7 @@ #include "monitor/monitor.h" #include "sysemu.h" #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "net/tap.h" diff --git a/net/vde.c b/net/vde.c index 52d4f19fba..754a141543 100644 --- a/net/vde.c +++ b/net/vde.c @@ -28,7 +28,7 @@ #include "net/net.h" #include "clients.h" #include "qemu-common.h" -#include "qemu-option.h" +#include "qemu/option.h" typedef struct VDEState { NetClientState nc; diff --git a/notify.c b/notify.c index 12282a6745..7b7692acb2 100644 --- a/notify.c +++ b/notify.c @@ -14,7 +14,7 @@ */ #include "qemu-common.h" -#include "notify.h" +#include "qemu/notify.h" void notifier_list_init(NotifierList *list) { diff --git a/notify.h b/notify.h deleted file mode 100644 index 03cf26c0b6..0000000000 --- a/notify.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Notifier lists - * - * Copyright IBM, Corp. 2010 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_NOTIFY_H -#define QEMU_NOTIFY_H - -#include "qemu-queue.h" - -typedef struct Notifier Notifier; - -struct Notifier -{ - void (*notify)(Notifier *notifier, void *data); - QLIST_ENTRY(Notifier) node; -}; - -typedef struct NotifierList -{ - QLIST_HEAD(, Notifier) notifiers; -} NotifierList; - -#define NOTIFIER_LIST_INITIALIZER(head) \ - { QLIST_HEAD_INITIALIZER((head).notifiers) } - -void notifier_list_init(NotifierList *list); - -void notifier_list_add(NotifierList *list, Notifier *notifier); - -void notifier_remove(Notifier *notifier); - -void notifier_list_notify(NotifierList *list, void *data); - -#endif diff --git a/osdep.c b/osdep.c index 807e90cf97..5b51a0322e 100644 --- a/osdep.c +++ b/osdep.c @@ -47,7 +47,7 @@ extern int madvise(caddr_t, size_t, int); #include "qemu-common.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "monitor/monitor.h" static bool fips_enabled = false; diff --git a/osdep.h b/osdep.h deleted file mode 100644 index 87d3b9cfa8..0000000000 --- a/osdep.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef QEMU_OSDEP_H -#define QEMU_OSDEP_H - -#include -#include -#include -#ifdef __OpenBSD__ -#include -#include -#endif - -#include - -#if defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10 -/* [u]int_fast*_t not in */ -typedef unsigned char uint_fast8_t; -typedef unsigned int uint_fast16_t; -typedef signed int int_fast16_t; -#endif - -#ifndef glue -#define xglue(x, y) x ## y -#define glue(x, y) xglue(x, y) -#define stringify(s) tostring(s) -#define tostring(s) #s -#endif - -#ifndef likely -#if __GNUC__ < 3 -#define __builtin_expect(x, n) (x) -#endif - -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif - -#ifndef container_of -#define container_of(ptr, type, member) ({ \ - const typeof(((type *) 0)->member) *__mptr = (ptr); \ - (type *) ((char *) __mptr - offsetof(type, member));}) -#endif - -/* Convert from a base type to a parent type, with compile time checking. */ -#ifdef __GNUC__ -#define DO_UPCAST(type, field, dev) ( __extension__ ( { \ - char __attribute__((unused)) offset_must_be_zero[ \ - -offsetof(type, field)]; \ - container_of(dev, type, field);})) -#else -#define DO_UPCAST(type, field, dev) container_of(dev, type, field) -#endif - -#define typeof_field(type, field) typeof(((type *)0)->field) -#define type_check(t1,t2) ((t1*)0 - (t2*)0) - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef DIV_ROUND_UP -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#ifndef always_inline -#if !((__GNUC__ < 3) || defined(__APPLE__)) -#ifdef __OPTIMIZE__ -#undef inline -#define inline __attribute__ (( always_inline )) __inline__ -#endif -#endif -#else -#undef inline -#define inline always_inline -#endif - -#define qemu_printf printf - -int qemu_daemon(int nochdir, int noclose); -void *qemu_memalign(size_t alignment, size_t size); -void *qemu_vmalloc(size_t size); -void qemu_vfree(void *ptr); - -#define QEMU_MADV_INVALID -1 - -#if defined(CONFIG_MADVISE) - -#define QEMU_MADV_WILLNEED MADV_WILLNEED -#define QEMU_MADV_DONTNEED MADV_DONTNEED -#ifdef MADV_DONTFORK -#define QEMU_MADV_DONTFORK MADV_DONTFORK -#else -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#endif -#ifdef MADV_MERGEABLE -#define QEMU_MADV_MERGEABLE MADV_MERGEABLE -#else -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#endif -#ifdef MADV_DONTDUMP -#define QEMU_MADV_DONTDUMP MADV_DONTDUMP -#else -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#endif -#ifdef MADV_HUGEPAGE -#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE -#else -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID -#endif - -#elif defined(CONFIG_POSIX_MADVISE) - -#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED -#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID - -#else /* no-op */ - -#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID -#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID -#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID -#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID -#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID -#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID - -#endif - -int qemu_madvise(void *addr, size_t len, int advice); - -int qemu_open(const char *name, int flags, ...); -int qemu_close(int fd); - -#if defined(__HAIKU__) && defined(__i386__) -#define FMT_pid "%ld" -#elif defined(WIN64) -#define FMT_pid "%" PRId64 -#else -#define FMT_pid "%d" -#endif - -int qemu_create_pidfile(const char *filename); -int qemu_get_thread_id(void); - -#ifdef _WIN32 -static inline void qemu_timersub(const struct timeval *val1, - const struct timeval *val2, - struct timeval *res) -{ - res->tv_sec = val1->tv_sec - val2->tv_sec; - if (val1->tv_usec < val2->tv_usec) { - res->tv_sec--; - res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000; - } else { - res->tv_usec = val1->tv_usec - val2->tv_usec; - } -} -#else -#define qemu_timersub timersub -#endif - -void qemu_set_cloexec(int fd); - -void qemu_set_version(const char *); -const char *qemu_get_version(void); - -void fips_set_state(bool requested); -bool fips_get_state(void); - -#endif diff --git a/oslib-posix.c b/oslib-posix.c index 9db9c3d8af..a737d6e0e3 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -51,7 +51,7 @@ extern int daemon(int, int); #include "config-host.h" #include "sysemu.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #if defined(CONFIG_VALGRIND) static int running_on_valgrind = -1; diff --git a/oslib-win32.c b/oslib-win32.c index 51b33e8b20..7f0dd07e5f 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -28,9 +28,9 @@ #include #include "config-host.h" #include "sysemu.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "trace.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" void *qemu_oom_check(void *ptr) { diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index f8149ce455..174bd8bdb0 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -13,8 +13,8 @@ #include "qemu-common.h" #include "qapi/qmp/qerror.h" #include "qapi/opts-visitor.h" -#include "qemu-queue.h" -#include "qemu-option-internal.h" +#include "qemu/queue.h" +#include "qemu/option_int.h" #include "qapi/visitor-impl.h" diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index 98f2a58efd..1334de33cc 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -12,7 +12,7 @@ */ #include "qapi/dealloc-visitor.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/visitor-impl.h" diff --git a/qapi/qmp-input-visitor.c b/qapi/qmp-input-visitor.c index 8087909036..67fb127050 100644 --- a/qapi/qmp-input-visitor.c +++ b/qapi/qmp-input-visitor.c @@ -13,7 +13,7 @@ #include "qapi/qmp-input-visitor.h" #include "qapi/visitor-impl.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qerror.h" diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index 8015e3f88d..74a5684ed3 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -13,7 +13,7 @@ #include "qapi/qmp-output-visitor.h" #include "qapi/visitor-impl.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" #include "qapi/qmp/types.h" #include "qapi/qmp/qerror.h" diff --git a/qdict.c b/qdict.c index fa7a62cff4..7543ccc10f 100644 --- a/qdict.c +++ b/qdict.c @@ -16,7 +16,7 @@ #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" static void qdict_destroy_obj(QObject *obj); diff --git a/qemu-barrier.h b/qemu-barrier.h deleted file mode 100644 index faa83d265e..0000000000 --- a/qemu-barrier.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __QEMU_BARRIER_H -#define __QEMU_BARRIER_H 1 - -/* Compiler barrier */ -#define barrier() asm volatile("" ::: "memory") - -#if defined(__i386__) - -#include "compiler.h" /* QEMU_GNUC_PREREQ */ - -/* - * Because of the strongly ordered x86 storage model, wmb() and rmb() are nops - * on x86(well, a compiler barrier only). Well, at least as long as - * qemu doesn't do accesses to write-combining memory or non-temporal - * load/stores from C code. - */ -#define smp_wmb() barrier() -#define smp_rmb() barrier() -/* - * We use GCC builtin if it's available, as that can use - * mfence on 32 bit as well, e.g. if built with -march=pentium-m. - * However, on i386, there seem to be known bugs as recently as 4.3. - * */ -#if QEMU_GNUC_PREREQ(4, 4) -#define smp_mb() __sync_synchronize() -#else -#define smp_mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory") -#endif - -#elif defined(__x86_64__) - -#define smp_wmb() barrier() -#define smp_rmb() barrier() -#define smp_mb() asm volatile("mfence" ::: "memory") - -#elif defined(_ARCH_PPC) - -/* - * We use an eieio() for wmb() on powerpc. This assumes we don't - * need to order cacheable and non-cacheable stores with respect to - * each other - */ -#define smp_wmb() asm volatile("eieio" ::: "memory") - -#if defined(__powerpc64__) -#define smp_rmb() asm volatile("lwsync" ::: "memory") -#else -#define smp_rmb() asm volatile("sync" ::: "memory") -#endif - -#define smp_mb() asm volatile("sync" ::: "memory") - -#else - -/* - * For (host) platforms we don't have explicit barrier definitions - * for, we use the gcc __sync_synchronize() primitive to generate a - * full barrier. This should be safe on all platforms, though it may - * be overkill for wmb() and rmb(). - */ -#define smp_wmb() __sync_synchronize() -#define smp_mb() __sync_synchronize() -#define smp_rmb() __sync_synchronize() - -#endif - -#endif diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c index 652eec99fd..287bfd5e38 100644 --- a/qemu-bridge-helper.c +++ b/qemu-bridge-helper.c @@ -39,7 +39,7 @@ #include #endif -#include "qemu-queue.h" +#include "qemu/queue.h" #include "net/tap-linux.h" diff --git a/qemu-char.c b/qemu-char.c index 16021c5a43..5a8d8f75a4 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -25,7 +25,7 @@ #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "hw/usb.h" #include "hw/baum.h" @@ -94,7 +94,7 @@ #endif #endif -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "ui/qemu-spice.h" #define READ_BUF_LEN 4096 diff --git a/qemu-char.h b/qemu-char.h index 5ff1b2ba91..baa5d035fd 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -2,13 +2,13 @@ #define QEMU_CHAR_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/queue.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "block/aio.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qstring.h" -#include "main-loop.h" +#include "qemu/main-loop.h" /* character device */ diff --git a/qemu-common.h b/qemu-common.h index e67478607b..40cd198fc1 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -12,9 +12,9 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H -#include "compiler.h" +#include "qemu/compiler.h" #include "config-host.h" -#include "qemu-types.h" +#include "qemu/typedefs.h" #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) #define WORDS_ALIGNED @@ -122,8 +122,8 @@ extern int use_icount; /* FIXME: Remove NEED_CPU_H. */ #ifndef NEED_CPU_H -#include "osdep.h" -#include "bswap.h" +#include "qemu/osdep.h" +#include "qemu/bswap.h" #else @@ -408,7 +408,7 @@ static inline bool is_power_of_2(uint64_t value) /* round down to the nearest power of 2*/ int64_t pow2floor(int64_t value); -#include "module.h" +#include "qemu/module.h" /* * Implementation of ULEB128 (http://en.wikipedia.org/wiki/LEB128) diff --git a/qemu-config.c b/qemu-config.c index ceec6bd155..2188c3e5ec 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -1,7 +1,7 @@ #include "qemu-common.h" -#include "qemu-error.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "hw/qdev.h" #include "qapi/error.h" diff --git a/qemu-config.h b/qemu-config.h deleted file mode 100644 index 584491a29b..0000000000 --- a/qemu-config.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QEMU_CONFIG_H -#define QEMU_CONFIG_H - -#include -#include "qemu-option.h" -#include "qapi/error.h" -#include "qemu-option.h" - -extern QemuOptsList qemu_fsdev_opts; -extern QemuOptsList qemu_virtfs_opts; -extern QemuOptsList qemu_spice_opts; -extern QemuOptsList qemu_sandbox_opts; - -QemuOptsList *qemu_find_opts(const char *group); -QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); -void qemu_add_opts(QemuOptsList *list); -int qemu_set_option(const char *str); -int qemu_global_option(const char *str); -void qemu_add_globals(void); - -void qemu_config_write(FILE *fp); -int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname); - -int qemu_read_config_file(const char *filename); - -/* Read default QEMU config files - */ -int qemu_read_default_config_files(bool userconfig); - -#endif /* QEMU_CONFIG_H */ diff --git a/qemu-coroutine-io.c b/qemu-coroutine-io.c index 5fae9c7d47..e8ad1a4011 100644 --- a/qemu-coroutine-io.c +++ b/qemu-coroutine-io.c @@ -23,9 +23,9 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "block/coroutine.h" -#include "iov.h" +#include "qemu/iov.h" ssize_t coroutine_fn qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt, diff --git a/qemu-coroutine-lock.c b/qemu-coroutine-lock.c index c3939ac6ef..97ef01c796 100644 --- a/qemu-coroutine-lock.c +++ b/qemu-coroutine-lock.c @@ -25,7 +25,7 @@ #include "qemu-common.h" #include "block/coroutine.h" #include "block/coroutine_int.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "block/aio.h" #include "trace.h" diff --git a/qemu-coroutine-sleep.c b/qemu-coroutine-sleep.c index 26e6dac2eb..169ce5ccc9 100644 --- a/qemu-coroutine-sleep.c +++ b/qemu-coroutine-sleep.c @@ -12,7 +12,7 @@ */ #include "block/coroutine.h" -#include "qemu-timer.h" +#include "qemu/timer.h" typedef struct CoSleepCB { QEMUTimer *ts; diff --git a/qemu-error.h b/qemu-error.h deleted file mode 100644 index c902cc10de..0000000000 --- a/qemu-error.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Error reporting - * - * Copyright (C) 2010 Red Hat Inc. - * - * Authors: - * Markus Armbruster , - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_ERROR_H -#define QEMU_ERROR_H - -#include - -typedef struct Location { - /* all members are private to qemu-error.c */ - enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind; - int num; - const void *ptr; - struct Location *prev; -} Location; - -Location *loc_push_restore(Location *loc); -Location *loc_push_none(Location *loc); -Location *loc_pop(Location *loc); -Location *loc_save(Location *loc); -void loc_restore(Location *loc); -void loc_set_none(void); -void loc_set_cmdline(char **argv, int idx, int cnt); -void loc_set_file(const char *fname, int lno); - -void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); -void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_print_loc(void); -void error_set_progname(const char *argv0); -void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -const char *error_get_progname(void); - -#endif diff --git a/qemu-img.c b/qemu-img.c index 2e5ca5c964..4c8e2f3849 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -25,9 +25,9 @@ #include "qapi/qmp-output-visitor.h" #include "qapi/qmp/qjson.h" #include "qemu-common.h" -#include "qemu-option.h" -#include "qemu-error.h" -#include "osdep.h" +#include "qemu/option.h" +#include "qemu/error-report.h" +#include "qemu/osdep.h" #include "sysemu.h" #include "block/block_int.h" #include diff --git a/qemu-io.c b/qemu-io.c index e0e47423d7..61880932b3 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -15,7 +15,7 @@ #include #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "block/block_int.h" #include "cmd.h" #include "trace/control.h" diff --git a/qemu-log.c b/qemu-log.c index a4c3d1f2e3..b655b305ea 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -18,7 +18,7 @@ */ #include "qemu-common.h" -#include "qemu-log.h" +#include "qemu/log.h" #ifdef WIN32 static const char *logfilename = "qemu.log"; diff --git a/qemu-log.h b/qemu-log.h deleted file mode 100644 index 58f69cb494..0000000000 --- a/qemu-log.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef QEMU_LOG_H -#define QEMU_LOG_H - -#include -#ifdef NEED_CPU_H -#include "disas/disas.h" -#endif - -/* Private global variables, don't use */ -extern FILE *qemu_logfile; -extern int qemu_loglevel; - -/* - * The new API: - * - */ - -/* Log settings checking macros: */ - -/* Returns true if qemu_log() will really write somewhere - */ -static inline bool qemu_log_enabled(void) -{ - return qemu_logfile != NULL; -} - -#define CPU_LOG_TB_OUT_ASM (1 << 0) -#define CPU_LOG_TB_IN_ASM (1 << 1) -#define CPU_LOG_TB_OP (1 << 2) -#define CPU_LOG_TB_OP_OPT (1 << 3) -#define CPU_LOG_INT (1 << 4) -#define CPU_LOG_EXEC (1 << 5) -#define CPU_LOG_PCALL (1 << 6) -#define CPU_LOG_IOPORT (1 << 7) -#define CPU_LOG_TB_CPU (1 << 8) -#define CPU_LOG_RESET (1 << 9) -#define LOG_UNIMP (1 << 10) -#define LOG_GUEST_ERROR (1 << 11) - -/* Returns true if a bit is set in the current loglevel mask - */ -static inline bool qemu_loglevel_mask(int mask) -{ - return (qemu_loglevel & mask) != 0; -} - -/* Logging functions: */ - -/* main logging function - */ -void GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); - -/* vfprintf-like logging function - */ -static inline void GCC_FMT_ATTR(1, 0) -qemu_log_vprintf(const char *fmt, va_list va) -{ - if (qemu_logfile) { - vfprintf(qemu_logfile, fmt, va); - } -} - -/* log only if a bit is set on the current loglevel mask - */ -void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...); - - -/* Special cases: */ - -#ifdef NEED_CPU_H -/* cpu_dump_state() logging functions: */ -static inline void log_cpu_state(CPUArchState *env1, int flags) -{ - if (qemu_log_enabled()) { - cpu_dump_state(env1, qemu_logfile, fprintf, flags); - } -} - -static inline void log_cpu_state_mask(int mask, CPUArchState *env1, int flags) -{ - if (qemu_loglevel & mask) { - log_cpu_state(env1, flags); - } -} - -/* disas() and target_disas() to qemu_logfile: */ -static inline void log_target_disas(CPUArchState *env, target_ulong start, - target_ulong len, int flags) -{ - target_disas(qemu_logfile, env, start, len, flags); -} - -static inline void log_disas(void *code, unsigned long size) -{ - disas(qemu_logfile, code, size); -} - -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(void) -{ - page_dump(qemu_logfile); -} -#endif -#endif - - -/* Maintenance: */ - -/* fflush() the log file */ -static inline void qemu_log_flush(void) -{ - fflush(qemu_logfile); -} - -/* Close the log file */ -static inline void qemu_log_close(void) -{ - fclose(qemu_logfile); - qemu_logfile = NULL; -} - -/* Set up a new log file */ -static inline void qemu_log_set_file(FILE *f) -{ - qemu_logfile = f; -} - -/* Set up a new log file, only if none is set */ -static inline void qemu_log_try_set_file(FILE *f) -{ - if (!qemu_logfile) { - qemu_logfile = f; - } -} - -/* define log items */ -typedef struct CPULogItem { - int mask; - const char *name; - const char *help; -} CPULogItem; - -extern const CPULogItem cpu_log_items[]; - -void qemu_set_log(int log_flags, bool use_own_buffers); - -static inline void cpu_set_log(int log_flags) -{ -#ifdef CONFIG_USER_ONLY - qemu_set_log(log_flags, true); -#else - qemu_set_log(log_flags, false); -#endif -} - -void cpu_set_log_filename(const char *filename); -int cpu_str_to_log_mask(const char *str); - -#endif diff --git a/qemu-option-internal.h b/qemu-option-internal.h deleted file mode 100644 index 77899b082d..0000000000 --- a/qemu-option-internal.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Commandline option parsing functions - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Kevin Wolf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OPTIONS_INTERNAL_H -#define QEMU_OPTIONS_INTERNAL_H - -#include "qemu-option.h" -#include "qemu-error.h" - -struct QemuOpt { - const char *name; - const char *str; - - const QemuOptDesc *desc; - union { - bool boolean; - uint64_t uint; - } value; - - QemuOpts *opts; - QTAILQ_ENTRY(QemuOpt) next; -}; - -struct QemuOpts { - char *id; - QemuOptsList *list; - Location loc; - QTAILQ_HEAD(QemuOptHead, QemuOpt) head; - QTAILQ_ENTRY(QemuOpts) next; -}; - -#endif diff --git a/qemu-option.c b/qemu-option.c index ebd3537063..f532b765a0 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -27,11 +27,11 @@ #include #include "qemu-common.h" -#include "qemu-error.h" +#include "qemu/error-report.h" #include "qapi/qmp/types.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" -#include "qemu-option-internal.h" +#include "qemu/option_int.h" /* * Extracts the name of an option from the parameter string (p points at the diff --git a/qemu-option.h b/qemu-option.h deleted file mode 100644 index ca0dc041dd..0000000000 --- a/qemu-option.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Commandline option parsing functions - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2009 Kevin Wolf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OPTIONS_H -#define QEMU_OPTIONS_H - -#include -#include "qemu-queue.h" -#include "qapi/error.h" -#include "qapi/qmp/qdict.h" - -enum QEMUOptionParType { - OPT_FLAG, - OPT_NUMBER, - OPT_SIZE, - OPT_STRING, -}; - -typedef struct QEMUOptionParameter { - const char *name; - enum QEMUOptionParType type; - union { - uint64_t n; - char* s; - } value; - const char *help; -} QEMUOptionParameter; - - -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); -int get_next_param_value(char *buf, int buf_size, - const char *tag, const char **pstr); -int get_param_value(char *buf, int buf_size, - const char *tag, const char *str); -int check_params(char *buf, int buf_size, - const char * const *params, const char *str); - - -/* - * The following functions take a parameter list as input. This is a pointer to - * the first element of a QEMUOptionParameter array which is terminated by an - * entry with entry->name == NULL. - */ - -QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list, - const char *name); -int set_option_parameter(QEMUOptionParameter *list, const char *name, - const char *value); -int set_option_parameter_int(QEMUOptionParameter *list, const char *name, - uint64_t value); -QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest, - QEMUOptionParameter *list); -QEMUOptionParameter *parse_option_parameters(const char *param, - QEMUOptionParameter *list, QEMUOptionParameter *dest); -void free_option_parameters(QEMUOptionParameter *list); -void print_option_parameters(QEMUOptionParameter *list); -void print_option_help(QEMUOptionParameter *list); - -/* ------------------------------------------------------------------ */ - -typedef struct QemuOpt QemuOpt; -typedef struct QemuOpts QemuOpts; -typedef struct QemuOptsList QemuOptsList; - -enum QemuOptType { - QEMU_OPT_STRING = 0, /* no parsing (use string as-is) */ - QEMU_OPT_BOOL, /* on/off */ - QEMU_OPT_NUMBER, /* simple number */ - QEMU_OPT_SIZE, /* size, accepts (K)ilo, (M)ega, (G)iga, (T)era postfix */ -}; - -typedef struct QemuOptDesc { - const char *name; - enum QemuOptType type; - const char *help; -} QemuOptDesc; - -struct QemuOptsList { - const char *name; - const char *implied_opt_name; - bool merge_lists; /* Merge multiple uses of option into a single list? */ - QTAILQ_HEAD(, QemuOpts) head; - QemuOptDesc desc[]; -}; - -const char *qemu_opt_get(QemuOpts *opts, const char *name); -/** - * qemu_opt_has_help_opt: - * @opts: options to search for a help request - * - * Check whether the options specified by @opts include one of the - * standard strings which indicate that the user is asking for a - * list of the valid values for a command line option (as defined - * by is_help_option()). - * - * Returns: true if @opts includes 'help' or equivalent. - */ -bool qemu_opt_has_help_opt(QemuOpts *opts); -bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval); -uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval); -uint64_t qemu_opt_get_size(QemuOpts *opts, const char *name, uint64_t defval); -int qemu_opt_set(QemuOpts *opts, const char *name, const char *value); -void qemu_opt_set_err(QemuOpts *opts, const char *name, const char *value, - Error **errp); -int qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val); -int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val); -typedef int (*qemu_opt_loopfunc)(const char *name, const char *value, void *opaque); -int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, - int abort_on_failure); - -QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); -QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, - int fail_if_exists, Error **errp); -QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); -void qemu_opts_reset(QemuOptsList *list); -void qemu_opts_loc_restore(QemuOpts *opts); -int qemu_opts_set(QemuOptsList *list, const char *id, - const char *name, const char *value); -const char *qemu_opts_id(QemuOpts *opts); -void qemu_opts_del(QemuOpts *opts); -void qemu_opts_validate(QemuOpts *opts, const QemuOptDesc *desc, Error **errp); -int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname); -QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, int permit_abbrev); -void qemu_opts_set_defaults(QemuOptsList *list, const char *params, - int permit_abbrev); -QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, - Error **errp); -QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict); - -typedef int (*qemu_opts_loopfunc)(QemuOpts *opts, void *opaque); -int qemu_opts_print(QemuOpts *opts, void *dummy); -int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, - int abort_on_failure); - -#endif diff --git a/qemu-progress.c b/qemu-progress.c index 5f1b8dfb97..08d67949a1 100644 --- a/qemu-progress.c +++ b/qemu-progress.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "sysemu.h" #include diff --git a/qemu-queue.h b/qemu-queue.h deleted file mode 100644 index 9288cd8e82..0000000000 --- a/qemu-queue.h +++ /dev/null @@ -1,414 +0,0 @@ -/* $NetBSD: queue.h,v 1.52 2009/04/20 09:56:08 mschuett Exp $ */ - -/* - * QEMU version: Copy from netbsd, removed debug code, removed some of - * the implementations. Left in singly-linked lists, lists, simple - * queues, and tail queues. - */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)queue.h 8.5 (Berkeley) 8/20/94 - */ - -#ifndef QEMU_SYS_QUEUE_H_ -#define QEMU_SYS_QUEUE_H_ - -/* - * This file defines four types of data structures: singly-linked lists, - * lists, simple queues, and tail queues. - * - * A singly-linked list is headed by a single forward pointer. The - * elements are singly linked for minimum space and pointer manipulation - * overhead at the expense of O(n) removal for arbitrary elements. New - * elements can be added to the list after an existing element or at the - * head of the list. Elements being removed from the head of the list - * should use the explicit macro for this purpose for optimum - * efficiency. A singly-linked list may only be traversed in the forward - * direction. Singly-linked lists are ideal for applications with large - * datasets and few or no removals or for implementing a LIFO queue. - * - * A list is headed by a single forward pointer (or an array of forward - * pointers for a hash table header). The elements are doubly linked - * so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before - * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. - * - * A simple queue is headed by a pair of pointers, one the head of the - * list and the other to the tail of the list. The elements are singly - * linked to save space, so elements can only be removed from the - * head of the list. New elements can be added to the list after - * an existing element, at the head of the list, or at the end of the - * list. A simple queue may only be traversed in the forward direction. - * - * A tail queue is headed by a pair of pointers, one to the head of the - * list and the other to the tail of the list. The elements are doubly - * linked so that an arbitrary element can be removed without a need to - * traverse the list. New elements can be added to the list before or - * after an existing element, at the head of the list, or at the end of - * the list. A tail queue may be traversed in either direction. - * - * For details on the use of these macros, see the queue(3) manual page. - */ - -#include "qemu-barrier.h" /* for smp_wmb() */ - -/* - * List definitions. - */ -#define QLIST_HEAD(name, type) \ -struct name { \ - struct type *lh_first; /* first element */ \ -} - -#define QLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define QLIST_ENTRY(type) \ -struct { \ - struct type *le_next; /* next element */ \ - struct type **le_prev; /* address of previous next element */ \ -} - -/* - * List functions. - */ -#define QLIST_INIT(head) do { \ - (head)->lh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ - (listelm)->field.le_next->field.le_prev = \ - &(elm)->field.le_next; \ - (listelm)->field.le_next = (elm); \ - (elm)->field.le_prev = &(listelm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.le_prev = (listelm)->field.le_prev; \ - (elm)->field.le_next = (listelm); \ - *(listelm)->field.le_prev = (elm); \ - (listelm)->field.le_prev = &(elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.le_next = (head)->lh_first) != NULL) \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ - (head)->lh_first = (elm); \ - (elm)->field.le_prev = &(head)->lh_first; \ -} while (/*CONSTCOND*/0) - -#define QLIST_INSERT_HEAD_RCU(head, elm, field) do { \ - (elm)->field.le_prev = &(head)->lh_first; \ - (elm)->field.le_next = (head)->lh_first; \ - smp_wmb(); /* fill elm before linking it */ \ - if ((head)->lh_first != NULL) { \ - (head)->lh_first->field.le_prev = &(elm)->field.le_next; \ - } \ - (head)->lh_first = (elm); \ - smp_wmb(); \ -} while (/* CONSTCOND*/0) - -#define QLIST_REMOVE(elm, field) do { \ - if ((elm)->field.le_next != NULL) \ - (elm)->field.le_next->field.le_prev = \ - (elm)->field.le_prev; \ - *(elm)->field.le_prev = (elm)->field.le_next; \ -} while (/*CONSTCOND*/0) - -#define QLIST_FOREACH(var, head, field) \ - for ((var) = ((head)->lh_first); \ - (var); \ - (var) = ((var)->field.le_next)) - -#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ - for ((var) = ((head)->lh_first); \ - (var) && ((next_var) = ((var)->field.le_next), 1); \ - (var) = (next_var)) - -/* - * List access methods. - */ -#define QLIST_EMPTY(head) ((head)->lh_first == NULL) -#define QLIST_FIRST(head) ((head)->lh_first) -#define QLIST_NEXT(elm, field) ((elm)->field.le_next) - - -/* - * Singly-linked List definitions. - */ -#define QSLIST_HEAD(name, type) \ -struct name { \ - struct type *slh_first; /* first element */ \ -} - -#define QSLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define QSLIST_ENTRY(type) \ -struct { \ - struct type *sle_next; /* next element */ \ -} - -/* - * Singly-linked List functions. - */ -#define QSLIST_INIT(head) do { \ - (head)->slh_first = NULL; \ -} while (/*CONSTCOND*/0) - -#define QSLIST_INSERT_AFTER(slistelm, elm, field) do { \ - (elm)->field.sle_next = (slistelm)->field.sle_next; \ - (slistelm)->field.sle_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_INSERT_HEAD(head, elm, field) do { \ - (elm)->field.sle_next = (head)->slh_first; \ - (head)->slh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_REMOVE_HEAD(head, field) do { \ - (head)->slh_first = (head)->slh_first->field.sle_next; \ -} while (/*CONSTCOND*/0) - -#define QSLIST_REMOVE_AFTER(slistelm, field) do { \ - (slistelm)->field.sle_next = \ - QSLIST_NEXT(QSLIST_NEXT((slistelm), field), field); \ -} while (/*CONSTCOND*/0) - -#define QSLIST_FOREACH(var, head, field) \ - for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) - -#define QSLIST_FOREACH_SAFE(var, head, field, tvar) \ - for ((var) = QSLIST_FIRST((head)); \ - (var) && ((tvar) = QSLIST_NEXT((var), field), 1); \ - (var) = (tvar)) - -/* - * Singly-linked List access methods. - */ -#define QSLIST_EMPTY(head) ((head)->slh_first == NULL) -#define QSLIST_FIRST(head) ((head)->slh_first) -#define QSLIST_NEXT(elm, field) ((elm)->field.sle_next) - - -/* - * Simple queue definitions. - */ -#define QSIMPLEQ_HEAD(name, type) \ -struct name { \ - struct type *sqh_first; /* first element */ \ - struct type **sqh_last; /* addr of last next element */ \ -} - -#define QSIMPLEQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).sqh_first } - -#define QSIMPLEQ_ENTRY(type) \ -struct { \ - struct type *sqe_next; /* next element */ \ -} - -/* - * Simple queue functions. - */ -#define QSIMPLEQ_INIT(head) do { \ - (head)->sqh_first = NULL; \ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (head)->sqh_first = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.sqe_next = NULL; \ - *(head)->sqh_last = (elm); \ - (head)->sqh_last = &(elm)->field.sqe_next; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL) \ - (head)->sqh_last = &(elm)->field.sqe_next; \ - (listelm)->field.sqe_next = (elm); \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_REMOVE_HEAD(head, field) do { \ - if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL)\ - (head)->sqh_last = &(head)->sqh_first; \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_REMOVE(head, elm, type, field) do { \ - if ((head)->sqh_first == (elm)) { \ - QSIMPLEQ_REMOVE_HEAD((head), field); \ - } else { \ - struct type *curelm = (head)->sqh_first; \ - while (curelm->field.sqe_next != (elm)) \ - curelm = curelm->field.sqe_next; \ - if ((curelm->field.sqe_next = \ - curelm->field.sqe_next->field.sqe_next) == NULL) \ - (head)->sqh_last = &(curelm)->field.sqe_next; \ - } \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_FOREACH(var, head, field) \ - for ((var) = ((head)->sqh_first); \ - (var); \ - (var) = ((var)->field.sqe_next)) - -#define QSIMPLEQ_FOREACH_SAFE(var, head, field, next) \ - for ((var) = ((head)->sqh_first); \ - (var) && ((next = ((var)->field.sqe_next)), 1); \ - (var) = (next)) - -#define QSIMPLEQ_CONCAT(head1, head2) do { \ - if (!QSIMPLEQ_EMPTY((head2))) { \ - *(head1)->sqh_last = (head2)->sqh_first; \ - (head1)->sqh_last = (head2)->sqh_last; \ - QSIMPLEQ_INIT((head2)); \ - } \ -} while (/*CONSTCOND*/0) - -#define QSIMPLEQ_LAST(head, type, field) \ - (QSIMPLEQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->sqh_last) - offsetof(struct type, field)))) - -/* - * Simple queue access methods. - */ -#define QSIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) -#define QSIMPLEQ_FIRST(head) ((head)->sqh_first) -#define QSIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) - - -/* - * Tail queue definitions. - */ -#define Q_TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last; /* addr of last next element */ \ -} -#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) - -#define QTAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).tqh_first } - -#define Q_TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ -} -#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) - -/* - * Tail queue functions. - */ -#define QTAILQ_INIT(head) do { \ - (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ - (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ - else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ - (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_REMOVE(head, elm, field) do { \ - if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ - else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ -} while (/*CONSTCOND*/0) - -#define QTAILQ_FOREACH(var, head, field) \ - for ((var) = ((head)->tqh_first); \ - (var); \ - (var) = ((var)->field.tqe_next)) - -#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ - for ((var) = ((head)->tqh_first); \ - (var) && ((next_var) = ((var)->field.tqe_next), 1); \ - (var) = (next_var)) - -#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ - (var); \ - (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) - -/* - * Tail queue access methods. - */ -#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define QTAILQ_FIRST(head) ((head)->tqh_first) -#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) - -#define QTAILQ_LAST(head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define QTAILQ_PREV(elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) - -#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/qemu-seccomp.h b/qemu-seccomp.h index b2fc3f8c3c..1189fa241d 100644 --- a/qemu-seccomp.h +++ b/qemu-seccomp.h @@ -16,7 +16,7 @@ #define QEMU_SECCOMP_H #include -#include "osdep.h" +#include "qemu/osdep.h" int seccomp_start(void); #endif diff --git a/qemu-sockets.c b/qemu-sockets.c index cea0a4b8ac..3537bf3d45 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -23,9 +23,9 @@ #include #include "monitor/monitor.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "qemu-common.h" /* for qemu_isdigit */ -#include "main-loop.h" +#include "qemu/main-loop.h" #ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index 4ef9c7b3f8..7be292ed68 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -20,7 +20,7 @@ #include #include #include -#include "qemu-thread.h" +#include "qemu/thread.h" static void error_exit(int err, const char *msg) { diff --git a/qemu-thread-posix.h b/qemu-thread-posix.h deleted file mode 100644 index 380bae209b..0000000000 --- a/qemu-thread-posix.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __QEMU_THREAD_POSIX_H -#define __QEMU_THREAD_POSIX_H 1 -#include "pthread.h" -#include - -struct QemuMutex { - pthread_mutex_t lock; -}; - -struct QemuCond { - pthread_cond_t cond; -}; - -struct QemuSemaphore { -#if defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) - pthread_mutex_t lock; - pthread_cond_t cond; - int count; -#else - sem_t sem; -#endif -}; - -struct QemuThread { - pthread_t thread; -}; - -#endif diff --git a/qemu-thread-win32.c b/qemu-thread-win32.c index 4b3db60f5c..8037b39045 100644 --- a/qemu-thread-win32.c +++ b/qemu-thread-win32.c @@ -11,7 +11,7 @@ * */ #include "qemu-common.h" -#include "qemu-thread.h" +#include "qemu/thread.h" #include #include #include diff --git a/qemu-thread-win32.h b/qemu-thread-win32.h deleted file mode 100644 index 13adb958f0..0000000000 --- a/qemu-thread-win32.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __QEMU_THREAD_WIN32_H -#define __QEMU_THREAD_WIN32_H 1 -#include "windows.h" - -struct QemuMutex { - CRITICAL_SECTION lock; - LONG owner; -}; - -struct QemuCond { - LONG waiters, target; - HANDLE sema; - HANDLE continue_event; -}; - -struct QemuSemaphore { - HANDLE sema; -}; - -typedef struct QemuThreadData QemuThreadData; -struct QemuThread { - QemuThreadData *data; - unsigned tid; -}; - -/* Only valid for joinable threads. */ -HANDLE qemu_thread_get_handle(QemuThread *thread); - -#endif diff --git a/qemu-thread.h b/qemu-thread.h deleted file mode 100644 index 3ee2f6b1f9..0000000000 --- a/qemu-thread.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __QEMU_THREAD_H -#define __QEMU_THREAD_H 1 - -#include -#include - -typedef struct QemuMutex QemuMutex; -typedef struct QemuCond QemuCond; -typedef struct QemuSemaphore QemuSemaphore; -typedef struct QemuThread QemuThread; - -#ifdef _WIN32 -#include "qemu-thread-win32.h" -#else -#include "qemu-thread-posix.h" -#endif - -#define QEMU_THREAD_JOINABLE 0 -#define QEMU_THREAD_DETACHED 1 - -void qemu_mutex_init(QemuMutex *mutex); -void qemu_mutex_destroy(QemuMutex *mutex); -void qemu_mutex_lock(QemuMutex *mutex); -int qemu_mutex_trylock(QemuMutex *mutex); -void qemu_mutex_unlock(QemuMutex *mutex); - -#define rcu_read_lock() do { } while (0) -#define rcu_read_unlock() do { } while (0) - -void qemu_cond_init(QemuCond *cond); -void qemu_cond_destroy(QemuCond *cond); - -/* - * IMPORTANT: The implementation does not guarantee that pthread_cond_signal - * and pthread_cond_broadcast can be called except while the same mutex is - * held as in the corresponding pthread_cond_wait calls! - */ -void qemu_cond_signal(QemuCond *cond); -void qemu_cond_broadcast(QemuCond *cond); -void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex); - -void qemu_sem_init(QemuSemaphore *sem, int init); -void qemu_sem_post(QemuSemaphore *sem); -void qemu_sem_wait(QemuSemaphore *sem); -int qemu_sem_timedwait(QemuSemaphore *sem, int ms); -void qemu_sem_destroy(QemuSemaphore *sem); - -void qemu_thread_create(QemuThread *thread, - void *(*start_routine)(void *), - void *arg, int mode); -void *qemu_thread_join(QemuThread *thread); -void qemu_thread_get_self(QemuThread *thread); -bool qemu_thread_is_self(QemuThread *thread); -void qemu_thread_exit(void *retval); - -#endif diff --git a/qemu-timer-common.c b/qemu-timer-common.c index 755e300bc9..16f5e758b2 100644 --- a/qemu-timer-common.c +++ b/qemu-timer-common.c @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-timer.h" +#include "qemu/timer.h" /***********************************************************/ /* real time host monotonic timer */ diff --git a/qemu-timer.c b/qemu-timer.c index 8e0dccc087..80b3f2eb31 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -28,7 +28,7 @@ #include "hw/hw.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_POSIX #include #endif @@ -477,7 +477,7 @@ static void host_alarm_handler(int host_signum) #if defined(__linux__) -#include "compatfd.h" +#include "qemu/compatfd.h" static int dynticks_start_timer(struct qemu_alarm_timer *t) { diff --git a/qemu-timer.h b/qemu-timer.h deleted file mode 100644 index da7e97cd5a..0000000000 --- a/qemu-timer.h +++ /dev/null @@ -1,310 +0,0 @@ -#ifndef QEMU_TIMER_H -#define QEMU_TIMER_H - -#include "qemu-common.h" -#include "main-loop.h" -#include "notify.h" - -#ifdef __FreeBSD__ -#include -#endif - -/* timers */ - -#define SCALE_MS 1000000 -#define SCALE_US 1000 -#define SCALE_NS 1 - -typedef struct QEMUClock QEMUClock; -typedef void QEMUTimerCB(void *opaque); - -/* The real time clock should be used only for stuff which does not - change the virtual machine state, as it is run even if the virtual - machine is stopped. The real time clock has a frequency of 1000 - Hz. */ -extern QEMUClock *rt_clock; - -/* The virtual clock is only run during the emulation. It is stopped - when the virtual machine is stopped. Virtual timers use a high - precision clock, usually cpu cycles (use ticks_per_sec). */ -extern QEMUClock *vm_clock; - -/* The host clock should be use for device models that emulate accurate - real time sources. It will continue to run when the virtual machine - is suspended, and it will reflect system time changes the host may - undergo (e.g. due to NTP). The host clock has the same precision as - the virtual clock. */ -extern QEMUClock *host_clock; - -int64_t qemu_get_clock_ns(QEMUClock *clock); -int64_t qemu_clock_has_timers(QEMUClock *clock); -int64_t qemu_clock_expired(QEMUClock *clock); -int64_t qemu_clock_deadline(QEMUClock *clock); -void qemu_clock_enable(QEMUClock *clock, bool enabled); -void qemu_clock_warp(QEMUClock *clock); - -void qemu_register_clock_reset_notifier(QEMUClock *clock, Notifier *notifier); -void qemu_unregister_clock_reset_notifier(QEMUClock *clock, - Notifier *notifier); - -QEMUTimer *qemu_new_timer(QEMUClock *clock, int scale, - QEMUTimerCB *cb, void *opaque); -void qemu_free_timer(QEMUTimer *ts); -void qemu_del_timer(QEMUTimer *ts); -void qemu_mod_timer_ns(QEMUTimer *ts, int64_t expire_time); -void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); -bool qemu_timer_pending(QEMUTimer *ts); -bool qemu_timer_expired(QEMUTimer *timer_head, int64_t current_time); -uint64_t qemu_timer_expire_time_ns(QEMUTimer *ts); - -void qemu_run_timers(QEMUClock *clock); -void qemu_run_all_timers(void); -void configure_alarms(char const *opt); -void init_clocks(void); -int init_timer_alarm(void); - -int64_t cpu_get_ticks(void); -void cpu_enable_ticks(void); -void cpu_disable_ticks(void); - -static inline QEMUTimer *qemu_new_timer_ns(QEMUClock *clock, QEMUTimerCB *cb, - void *opaque) -{ - return qemu_new_timer(clock, SCALE_NS, cb, opaque); -} - -static inline QEMUTimer *qemu_new_timer_ms(QEMUClock *clock, QEMUTimerCB *cb, - void *opaque) -{ - return qemu_new_timer(clock, SCALE_MS, cb, opaque); -} - -static inline int64_t qemu_get_clock_ms(QEMUClock *clock) -{ - return qemu_get_clock_ns(clock) / SCALE_MS; -} - -static inline int64_t get_ticks_per_sec(void) -{ - return 1000000000LL; -} - -/* real time host monotonic timer */ -static inline int64_t get_clock_realtime(void) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - return tv.tv_sec * 1000000000LL + (tv.tv_usec * 1000); -} - -/* Warning: don't insert tracepoints into these functions, they are - also used by simpletrace backend and tracepoints would cause - an infinite recursion! */ -#ifdef _WIN32 -extern int64_t clock_freq; - -static inline int64_t get_clock(void) -{ - LARGE_INTEGER ti; - QueryPerformanceCounter(&ti); - return muldiv64(ti.QuadPart, get_ticks_per_sec(), clock_freq); -} - -#else - -extern int use_rt_clock; - -static inline int64_t get_clock(void) -{ -#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ - || defined(__DragonFly__) || defined(__FreeBSD_kernel__) - if (use_rt_clock) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec * 1000000000LL + ts.tv_nsec; - } else -#endif - { - /* XXX: using gettimeofday leads to problems if the date - changes, so it should be avoided. */ - return get_clock_realtime(); - } -} -#endif - -void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); -void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); - -/* icount */ -int64_t cpu_get_icount(void); -int64_t cpu_get_clock(void); - -/*******************************************/ -/* host CPU ticks (if available) */ - -#if defined(_ARCH_PPC) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t retval; -#ifdef _ARCH_PPC64 - /* This reads timebase in one 64bit go and includes Cell workaround from: - http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html - */ - __asm__ __volatile__ ("mftb %0\n\t" - "cmpwi %0,0\n\t" - "beq- $-8" - : "=r" (retval)); -#else - /* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ - unsigned long junk; - __asm__ __volatile__ ("mfspr %1,269\n\t" /* mftbu */ - "mfspr %L0,268\n\t" /* mftb */ - "mfspr %0,269\n\t" /* mftbu */ - "cmpw %0,%1\n\t" - "bne $-16" - : "=r" (retval), "=r" (junk)); -#endif - return retval; -} - -#elif defined(__i386__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile ("rdtsc" : "=A" (val)); - return val; -} - -#elif defined(__x86_64__) - -static inline int64_t cpu_get_real_ticks(void) -{ - uint32_t low,high; - int64_t val; - asm volatile("rdtsc" : "=a" (low), "=d" (high)); - val = high; - val <<= 32; - val |= low; - return val; -} - -#elif defined(__hppa__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int val; - asm volatile ("mfctl %%cr16, %0" : "=r"(val)); - return val; -} - -#elif defined(__ia64) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); - return val; -} - -#elif defined(__s390__) - -static inline int64_t cpu_get_real_ticks(void) -{ - int64_t val; - asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); - return val; -} - -#elif defined(__sparc__) - -static inline int64_t cpu_get_real_ticks (void) -{ -#if defined(_LP64) - uint64_t rval; - asm volatile("rd %%tick,%0" : "=r"(rval)); - return rval; -#else - /* We need an %o or %g register for this. For recent enough gcc - there is an "h" constraint for that. Don't bother with that. */ - union { - uint64_t i64; - struct { - uint32_t high; - uint32_t low; - } i32; - } rval; - asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1" - : "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1"); - return rval.i64; -#endif -} - -#elif defined(__mips__) && \ - ((defined(__mips_isa_rev) && __mips_isa_rev >= 2) || defined(__linux__)) -/* - * binutils wants to use rdhwr only on mips32r2 - * but as linux kernel emulate it, it's fine - * to use it. - * - */ -#define MIPS_RDHWR(rd, value) { \ - __asm__ __volatile__ (".set push\n\t" \ - ".set mips32r2\n\t" \ - "rdhwr %0, "rd"\n\t" \ - ".set pop" \ - : "=r" (value)); \ - } - -static inline int64_t cpu_get_real_ticks(void) -{ - /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ - uint32_t count; - static uint32_t cyc_per_count = 0; - - if (!cyc_per_count) { - MIPS_RDHWR("$3", cyc_per_count); - } - - MIPS_RDHWR("$2", count); - return (int64_t)(count * cyc_per_count); -} - -#elif defined(__alpha__) - -static inline int64_t cpu_get_real_ticks(void) -{ - uint64_t cc; - uint32_t cur, ofs; - - asm volatile("rpcc %0" : "=r"(cc)); - cur = cc; - ofs = cc >> 32; - return cur - ofs; -} - -#else -/* The host CPU doesn't have an easily accessible cycle counter. - Just return a monotonically increasing value. This will be - totally wrong, but hopefully better than nothing. */ -static inline int64_t cpu_get_real_ticks (void) -{ - static int64_t ticks = 0; - return ticks++; -} -#endif - -#ifdef CONFIG_PROFILER -static inline int64_t profile_getclock(void) -{ - return cpu_get_real_ticks(); -} - -extern int64_t qemu_time, qemu_time_start; -extern int64_t tlb_flush_time; -extern int64_t dev_time; -#endif - -#endif diff --git a/qemu-tls.h b/qemu-tls.h deleted file mode 100644 index b92ea9d7da..0000000000 --- a/qemu-tls.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Abstraction layer for defining and using TLS variables - * - * Copyright (c) 2011 Red Hat, Inc - * Copyright (c) 2011 Linaro Limited - * - * Authors: - * Paolo Bonzini - * Peter Maydell - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - */ - -#ifndef QEMU_TLS_H -#define QEMU_TLS_H - -/* Per-thread variables. Note that we only have implementations - * which are really thread-local on Linux; the dummy implementations - * define plain global variables. - * - * This means that for the moment use should be restricted to - * per-VCPU variables, which are OK because: - * - the only -user mode supporting multiple VCPU threads is linux-user - * - TCG system mode is single-threaded regarding VCPUs - * - KVM system mode is multi-threaded but limited to Linux - * - * TODO: proper implementations via Win32 .tls sections and - * POSIX pthread_getspecific. - */ -#ifdef __linux__ -#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) -#define DEFINE_TLS(type, x) __thread __typeof__(type) tls__##x -#define tls_var(x) tls__##x -#else -/* Dummy implementations which define plain global variables */ -#define DECLARE_TLS(type, x) extern DEFINE_TLS(type, x) -#define DEFINE_TLS(type, x) __typeof__(type) tls__##x -#define tls_var(x) tls__##x -#endif - -#endif diff --git a/qemu-tool.c b/qemu-tool.c index d1f46222ee..8ac45ff39b 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -15,12 +15,12 @@ #include "qemu-common.h" #include "monitor/monitor.h" -#include "qemu-timer.h" -#include "qemu-log.h" +#include "qemu/timer.h" +#include "qemu/log.h" #include "migration/migration.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #include "sysemu.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include diff --git a/qemu-types.h b/qemu-types.h deleted file mode 100644 index fd532a268d..0000000000 --- a/qemu-types.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef QEMU_TYPEDEFS_H -#define QEMU_TYPEDEFS_H - -/* A load of opaque types so that device init declarations don't have to - pull in all the real definitions. */ -typedef struct QEMUTimer QEMUTimer; -typedef struct QEMUFile QEMUFile; -typedef struct QEMUBH QEMUBH; - -struct Monitor; -typedef struct Monitor Monitor; -typedef struct MigrationParams MigrationParams; - -typedef struct Property Property; -typedef struct PropertyInfo PropertyInfo; -typedef struct CompatProperty CompatProperty; -typedef struct DeviceState DeviceState; -typedef struct BusState BusState; -typedef struct BusClass BusClass; - -typedef struct NICInfo NICInfo; -typedef struct HCIInfo HCIInfo; -typedef struct AudioState AudioState; -typedef struct BlockDriverState BlockDriverState; -typedef struct DriveInfo DriveInfo; -typedef struct DisplayState DisplayState; -typedef struct DisplayChangeListener DisplayChangeListener; -typedef struct DisplaySurface DisplaySurface; -typedef struct PixelFormat PixelFormat; -typedef struct QemuConsole QemuConsole; -typedef struct CharDriverState CharDriverState; -typedef struct MACAddr MACAddr; -typedef struct NetClientState NetClientState; -typedef struct i2c_bus i2c_bus; -typedef struct ISABus ISABus; -typedef struct ISADevice ISADevice; -typedef struct SMBusDevice SMBusDevice; -typedef struct PCIHostState PCIHostState; -typedef struct PCIExpressHost PCIExpressHost; -typedef struct PCIBus PCIBus; -typedef struct PCIDevice PCIDevice; -typedef struct PCIExpressDevice PCIExpressDevice; -typedef struct PCIBridge PCIBridge; -typedef struct PCIEAERMsg PCIEAERMsg; -typedef struct PCIEAERLog PCIEAERLog; -typedef struct PCIEAERErr PCIEAERErr; -typedef struct PCIEPort PCIEPort; -typedef struct PCIESlot PCIESlot; -typedef struct MSIMessage MSIMessage; -typedef struct SerialState SerialState; -typedef struct PCMCIACardState PCMCIACardState; -typedef struct MouseTransformInfo MouseTransformInfo; -typedef struct uWireSlave uWireSlave; -typedef struct I2SCodec I2SCodec; -typedef struct SSIBus SSIBus; -typedef struct EventNotifier EventNotifier; -typedef struct VirtIODevice VirtIODevice; -typedef struct QEMUSGList QEMUSGList; -typedef struct SHPCDevice SHPCDevice; - -#endif /* QEMU_TYPEDEFS_H */ diff --git a/qemu-xattr.h b/qemu-xattr.h deleted file mode 100644 index f910d96eaf..0000000000 --- a/qemu-xattr.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Host xattr.h abstraction - * - * Copyright 2011 Red Hat Inc. and/or its affiliates - * - * Authors: - * Avi Kivity - * - * This work is licensed under the terms of the GNU GPL, version 2, or any - * later version. See the COPYING file in the top-level directory. - * - */ -#ifndef QEMU_XATTR_H -#define QEMU_XATTR_H - -/* - * Modern distributions (e.g. Fedora 15, have no libattr.so, place attr.h - * in /usr/include/sys, and don't have ENOATTR. - */ - -#include "config-host.h" - -#ifdef CONFIG_LIBATTR -# include -#else -# define ENOATTR ENODATA -# include -#endif - -#endif diff --git a/qemu_socket.h b/qemu_socket.h deleted file mode 100644 index 42899fe138..0000000000 --- a/qemu_socket.h +++ /dev/null @@ -1,77 +0,0 @@ -/* headers to use the BSD sockets */ -#ifndef QEMU_SOCKET_H -#define QEMU_SOCKET_H - -#ifdef _WIN32 -#include -#include -#include - -#define socket_error() WSAGetLastError() - -int inet_aton(const char *cp, struct in_addr *ia); - -#else - -#include -#include -#include -#include -#include -#include -#include - -#define socket_error() errno -#define closesocket(s) close(s) - -#endif /* !_WIN32 */ - -#include "qemu-option.h" -#include "qapi/error.h" -#include "qapi/qmp/qerror.h" - -/* misc helpers */ -int qemu_socket(int domain, int type, int protocol); -int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); -int socket_set_cork(int fd, int v); -void socket_set_block(int fd); -void socket_set_nonblock(int fd); -int send_all(int fd, const void *buf, int len1); - -/* callback function for nonblocking connect - * valid fd on success, negative error code on failure - */ -typedef void NonBlockingConnectHandler(int fd, void *opaque); - -int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp); -int inet_listen(const char *str, char *ostr, int olen, - int socktype, int port_offset, Error **errp); -int inet_connect_opts(QemuOpts *opts, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int inet_connect(const char *str, Error **errp); -int inet_nonblocking_connect(const char *str, - NonBlockingConnectHandler *callback, - void *opaque, Error **errp); - -int inet_dgram_opts(QemuOpts *opts, Error **errp); -const char *inet_strfamily(int family); - -int unix_listen_opts(QemuOpts *opts, Error **errp); -int unix_listen(const char *path, char *ostr, int olen, Error **errp); -int unix_connect_opts(QemuOpts *opts, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int unix_connect(const char *path, Error **errp); -int unix_nonblocking_connect(const char *str, - NonBlockingConnectHandler *callback, - void *opaque, Error **errp); - -SocketAddress *socket_parse(const char *str, Error **errp); -int socket_connect(SocketAddress *addr, Error **errp, - NonBlockingConnectHandler *callback, void *opaque); -int socket_listen(SocketAddress *addr, Error **errp); - -/* Old, ipv4 only bits. Don't use for new code. */ -int parse_host_port(struct sockaddr_in *saddr, const char *str); -int socket_init(void); - -#endif /* QEMU_SOCKET_H */ diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 769a559456..d4fd628907 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -4,8 +4,8 @@ #include #include #include -#include "osdep.h" -#include "qemu_socket.h" +#include "qemu/osdep.h" +#include "qemu/sockets.h" #include "qga/channel.h" #ifdef CONFIG_SOLARIS diff --git a/qga/commands-posix.c b/qga/commands-posix.c index cedf2ccf28..a657201e7a 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -18,8 +18,8 @@ #include "qga/guest-agent-core.h" #include "qga-qmp-commands.h" #include "qapi/qmp/qerror.h" -#include "qemu-queue.h" -#include "host-utils.h" +#include "qemu/queue.h" +#include "qemu/host-utils.h" #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ diff --git a/qga/main.c b/qga/main.c index ead58cc11f..ba5fa1c778 100644 --- a/qga/main.c +++ b/qga/main.c @@ -25,7 +25,7 @@ #include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" #include "qga/guest-agent-core.h" -#include "module.h" +#include "qemu/module.h" #include "signal.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/dispatch.h" diff --git a/qlist.c b/qlist.c index c5ac2115af..1ced0de58e 100644 --- a/qlist.c +++ b/qlist.c @@ -12,7 +12,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qobject.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "qemu-common.h" static void qlist_destroy_obj(QObject *obj); diff --git a/qom/container.c b/qom/container.c index ceb0f0186d..5270a5ee9c 100644 --- a/qom/container.c +++ b/qom/container.c @@ -11,7 +11,7 @@ */ #include "qom/object.h" -#include "module.h" +#include "qemu/module.h" #include static TypeInfo container_info = { diff --git a/range.h b/range.h deleted file mode 100644 index 350237212b..0000000000 --- a/range.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef QEMU_RANGE_H -#define QEMU_RANGE_H - -/* Get last byte of a range from offset + length. - * Undefined for ranges that wrap around 0. */ -static inline uint64_t range_get_last(uint64_t offset, uint64_t len) -{ - return offset + len - 1; -} - -/* Check whether a given range covers a given byte. */ -static inline int range_covers_byte(uint64_t offset, uint64_t len, - uint64_t byte) -{ - return offset <= byte && byte <= range_get_last(offset, len); -} - -/* Check whether 2 given ranges overlap. - * Undefined if ranges that wrap around 0. */ -static inline int ranges_overlap(uint64_t first1, uint64_t len1, - uint64_t first2, uint64_t len2) -{ - uint64_t last1 = range_get_last(first1, len1); - uint64_t last2 = range_get_last(first2, len2); - - return !(last2 < first1 || last1 < first2); -} - -#endif diff --git a/savevm.c b/savevm.c index a5205a09c3..ea01e9baf6 100644 --- a/savevm.c +++ b/savevm.c @@ -75,17 +75,17 @@ #include "net/net.h" #include "monitor/monitor.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "audio/audio.h" #include "migration/migration.h" -#include "qemu_socket.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/sockets.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "cpus.h" #include "exec/memory.h" #include "qmp-commands.h" #include "trace.h" -#include "bitops.h" +#include "qemu/bitops.h" #define SELF_ANNOUNCE_ROUNDS 5 diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py index eccc28daee..e06332bd55 100644 --- a/scripts/qapi-commands.py +++ b/scripts/qapi-commands.py @@ -367,7 +367,7 @@ def gen_command_def_prologue(prefix="", proxy=False): */ #include "qemu-common.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/types.h" #include "qapi/qmp/dispatch.h" diff --git a/slirp/if.c b/slirp/if.c index 533295dd07..dcd5fafe5d 100644 --- a/slirp/if.c +++ b/slirp/if.c @@ -6,7 +6,7 @@ */ #include -#include "qemu-timer.h" +#include "qemu/timer.h" static void ifs_insque(struct mbuf *ifm, struct mbuf *ifmhead) diff --git a/slirp/ip_input.c b/slirp/ip_input.c index 6f4cff8fdd..880bdfd3cc 100644 --- a/slirp/ip_input.c +++ b/slirp/ip_input.c @@ -39,7 +39,7 @@ */ #include -#include +#include #include "ip_icmp.h" static struct ip *ip_reass(Slirp *slirp, struct ip *ip, struct ipq *fp); diff --git a/slirp/sbuf.c b/slirp/sbuf.c index 637f8fea3d..08ec2b4f44 100644 --- a/slirp/sbuf.c +++ b/slirp/sbuf.c @@ -6,7 +6,7 @@ */ #include -#include +#include static void sbappendsb(struct sbuf *sb, struct mbuf *m); diff --git a/slirp/slirp.c b/slirp/slirp.c index 3395d509a2..4b51a67e7d 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" #include "slirp.h" #include "hw/hw.h" diff --git a/slirp/slirp.h b/slirp/slirp.h index 0107b07e66..dfc3e3a2b8 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -133,8 +133,8 @@ void free(void *ptr); #include "debug.h" -#include "qemu-queue.h" -#include "qemu_socket.h" +#include "qemu/queue.h" +#include "qemu/sockets.h" #include "libslirp.h" #include "ip.h" diff --git a/spice-qemu-char.c b/spice-qemu-char.c index 5f95c937f3..41b1657ccd 100644 --- a/spice-qemu-char.c +++ b/spice-qemu-char.c @@ -5,7 +5,7 @@ #include #include -#include "osdep.h" +#include "qemu/osdep.h" #define dprintf(_scd, _level, _fmt, ...) \ do { \ diff --git a/stubs/fd-register.c b/stubs/fd-register.c index 813b6dd7c0..d0c34fd2a3 100644 --- a/stubs/fd-register.c +++ b/stubs/fd-register.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" void qemu_fd_register(int fd) { diff --git a/stubs/set-fd-handler.c b/stubs/set-fd-handler.c index 4807b5dc22..fc874d33fe 100644 --- a/stubs/set-fd-handler.c +++ b/stubs/set-fd-handler.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "main-loop.h" +#include "qemu/main-loop.h" int qemu_set_fd_handler2(int fd, IOCanReadHandler *fd_read_poll, diff --git a/sysemu.h b/sysemu.h index 1b6add2dc3..8eaa4707a0 100644 --- a/sysemu.h +++ b/sysemu.h @@ -2,13 +2,13 @@ #define SYSEMU_H /* Misc. things related to the system emulator. */ -#include "qemu-types.h" -#include "qemu-option.h" -#include "qemu-queue.h" -#include "qemu-timer.h" +#include "qemu/typedefs.h" +#include "qemu/option.h" +#include "qemu/queue.h" +#include "qemu/timer.h" #include "qapi-types.h" -#include "notify.h" -#include "main-loop.h" +#include "qemu/notify.h" +#include "qemu/main-loop.h" /* vl.c */ diff --git a/target-alpha/int_helper.c b/target-alpha/int_helper.c index 1d832f0b57..c9b42b6ed4 100644 --- a/target-alpha/int_helper.c +++ b/target-alpha/int_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" uint64_t helper_umulh(uint64_t op1, uint64_t op2) diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c index 40ca49c883..2bc2b02815 100644 --- a/target-alpha/sys_helper.c +++ b/target-alpha/sys_helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "helper.h" #include "sysemu.h" -#include "qemu-timer.h" +#include "qemu/timer.h" uint64_t helper_load_pcc(CPUAlphaState *env) diff --git a/target-alpha/translate.c b/target-alpha/translate.c index 2d0d891128..c94126737f 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "disas/disas.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "tcg-op.h" #include "helper.h" diff --git a/target-arm/helper.c b/target-arm/helper.c index 1f7a3c04c3..eef2acd18a 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1,9 +1,9 @@ #include "cpu.h" #include "exec/gdbstub.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "sysemu.h" -#include "bitops.h" +#include "qemu/bitops.h" #ifndef CONFIG_USER_ONLY static inline int get_phys_addr(CPUARMState *env, uint32_t address, diff --git a/target-arm/translate.c b/target-arm/translate.c index 988b5428d4..724e00f7cf 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -27,7 +27,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-cris/helper.c b/target-cris/helper.c index 324fe052f5..8407a6d880 100644 --- a/target-cris/helper.c +++ b/target-cris/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "mmu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" //#define CRIS_HELPER_DEBUG diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c index cd0e17e099..79bff38663 100644 --- a/target-cris/op_helper.c +++ b/target-cris/op_helper.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "mmu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" //#define CRIS_OP_HELPER_DEBUG diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 150c4dfb0c..8abc5561e9 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -24,8 +24,8 @@ #include "cpu.h" #include "kvm.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c index aaa5ca2090..64c8346d3b 100644 --- a/target-i386/excp_helper.c +++ b/target-i386/excp_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" #include "helper.h" diff --git a/target-i386/int_helper.c b/target-i386/int_helper.c index f39747e806..84b812dcca 100644 --- a/target-i386/int_helper.c +++ b/target-i386/int_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" //#define DEBUG_MULDIV diff --git a/target-i386/kvm.c b/target-i386/kvm.c index f7c95d5424..340ed3f33e 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -26,8 +26,8 @@ #include "kvm_i386.h" #include "cpu.h" #include "exec/gdbstub.h" -#include "host-utils.h" -#include "qemu-config.h" +#include "qemu/host-utils.h" +#include "qemu/config-file.h" #include "hw/pc.h" #include "hw/apic.h" #include "exec/ioport.h" diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index be795d71eb..c2a99ee9bc 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" //#define DEBUG_PCALL diff --git a/target-lm32/helper.c b/target-lm32/helper.c index 0ed7cfda18..d76ea3fe09 100644 --- a/target-lm32/helper.c +++ b/target-lm32/helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" int cpu_lm32_handle_mmu_fault(CPULM32State *env, target_ulong address, int rw, int mmu_idx) diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c index 27b3cef25c..53410b176e 100644 --- a/target-lm32/op_helper.c +++ b/target-lm32/op_helper.c @@ -1,7 +1,7 @@ #include #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "hw/lm32_pic.h" #include "hw/lm32_juart.h" diff --git a/target-m68k/translate.c b/target-m68k/translate.c index 1c9b5ec8d4..e763195f86 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helpers.h" #define GEN_HELPER 1 diff --git a/target-microblaze/helper.c b/target-microblaze/helper.c index 530e0b5fb0..97aedc52bb 100644 --- a/target-microblaze/helper.c +++ b/target-microblaze/helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define D(x) #define DMMU(x) diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 343dcc15e7..1c62f3c68f 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -21,7 +21,7 @@ #include #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #define D(x) diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index 157f59e6bf..e85edce6fa 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -18,7 +18,7 @@ */ #include #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" diff --git a/target-openrisc/int_helper.c b/target-openrisc/int_helper.c index 2fdfd27712..20f9837e6a 100644 --- a/target-openrisc/int_helper.c +++ b/target-openrisc/int_helper.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "helper.h" #include "exception.h" -#include "host-utils.h" +#include "qemu/host-utils.h" target_ulong HELPER(ff1)(target_ulong x) { diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c index 226ce43513..7f2c025da2 100644 --- a/target-openrisc/interrupt.c +++ b/target-openrisc/interrupt.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif diff --git a/target-openrisc/mmu.c b/target-openrisc/mmu.c index 4eee44434f..836465259a 100644 --- a/target-openrisc/mmu.c +++ b/target-openrisc/mmu.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "qemu-common.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c index 5883347fa7..1e1b30cdcb 100644 --- a/target-openrisc/translate.c +++ b/target-openrisc/translate.c @@ -23,9 +23,9 @@ #include "disas/disas.h" #include "tcg-op.h" #include "qemu-common.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "config.h" -#include "bitops.h" +#include "qemu/bitops.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c index f39b4f682a..783079d995 100644 --- a/target-ppc/int_helper.c +++ b/target-ppc/int_helper.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "helper_regs.h" diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 3f5df5772f..2546c577f6 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -23,7 +23,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "kvm.h" #include "kvm_ppc.h" diff --git a/target-ppc/kvm_ppc.c b/target-ppc/kvm_ppc.c index a2e49cd423..2de59fd43b 100644 --- a/target-ppc/kvm_ppc.c +++ b/target-ppc/kvm_ppc.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "kvm_ppc.h" #include "device_tree.h" diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c index 2d7a349c32..902b1cd823 100644 --- a/target-ppc/mem_helper.c +++ b/target-ppc/mem_helper.c @@ -17,7 +17,7 @@ * License along with this library; if not, see . */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "helper_regs.h" diff --git a/target-ppc/translate.c b/target-ppc/translate.c index a74d76b5a6..798b7acfc9 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -21,7 +21,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index 619b202b92..249f063d94 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -22,7 +22,7 @@ #include "cpu.h" #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" /* CPUClass::reset() */ diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 6e9b209713..8e135457a3 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "exec/gdbstub.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifndef CONFIG_USER_ONLY #include "sysemu.h" #endif diff --git a/target-s390x/int_helper.c b/target-s390x/int_helper.c index f202a7e1da..b683709860 100644 --- a/target-s390x/int_helper.c +++ b/target-s390x/int_helper.c @@ -19,7 +19,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" /* #define DEBUG_HELPER */ diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 94de764264..dc70699919 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -25,7 +25,7 @@ #include #include "qemu-common.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "sysemu.h" #include "kvm.h" #include "cpu.h" diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index a3336e16b0..2e73d30756 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -20,11 +20,11 @@ #include "cpu.h" #include "exec/memory.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include #include "kvm.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #ifdef CONFIG_KVM #include #endif diff --git a/target-s390x/translate.c b/target-s390x/translate.c index 28e61c54b8..9e34741311 100644 --- a/target-s390x/translate.c +++ b/target-s390x/translate.c @@ -32,7 +32,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" /* global register indexes */ static TCGv_ptr cpu_env; diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 0ed511a399..04b6659909 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -3,7 +3,7 @@ #include "config.h" #include "qemu-common.h" -#include "bswap.h" +#include "qemu/bswap.h" #if !defined(TARGET_SPARC64) #define TARGET_LONG_BITS 32 diff --git a/target-sparc/helper.c b/target-sparc/helper.c index 3c8e865eef..e0d78f3852 100644 --- a/target-sparc/helper.c +++ b/target-sparc/helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "helper.h" #include "sysemu.h" diff --git a/target-sparc/machine.c b/target-sparc/machine.c index eb4d87f158..a353dabdd9 100644 --- a/target-sparc/machine.c +++ b/target-sparc/machine.c @@ -1,6 +1,6 @@ #include "hw/hw.h" #include "hw/boards.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "cpu.h" diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c index 2adbd1675d..ff4f628404 100644 --- a/target-unicore32/helper.c +++ b/target-unicore32/helper.c @@ -12,7 +12,7 @@ #include "cpu.h" #include "exec/gdbstub.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "ui/console.h" #undef DEBUG_UC32 diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 218e95eaca..f4498bcb14 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -17,7 +17,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/target-xtensa/core-dc232b.c b/target-xtensa/core-dc232b.c index d1a594cda2..0bfcf2414c 100644 --- a/target-xtensa/core-dc232b.c +++ b/target-xtensa/core-dc232b.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-dc232b/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/core-dc233c.c b/target-xtensa/core-dc233c.c index ead6b3b128..11acbf3580 100644 --- a/target-xtensa/core-dc233c.c +++ b/target-xtensa/core-dc233c.c @@ -29,7 +29,7 @@ #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "qemu-common.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-dc233c/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/core-fsf.c b/target-xtensa/core-fsf.c index a387aeeca5..d4660edde9 100644 --- a/target-xtensa/core-fsf.c +++ b/target-xtensa/core-fsf.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #include "core-fsf/core-isa.h" #include "overlay_tool.h" diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index 3d7a399008..94c03a1d3c 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -28,7 +28,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" -#include "host-utils.h" +#include "qemu/host-utils.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" #endif diff --git a/target-xtensa/op_helper.c b/target-xtensa/op_helper.c index a93abcb1dd..3813a72626 100644 --- a/target-xtensa/op_helper.c +++ b/target-xtensa/op_helper.c @@ -27,7 +27,7 @@ #include "cpu.h" #include "helper.h" -#include "host-utils.h" +#include "qemu/host-utils.h" static void do_unaligned_access(CPUXtensaState *env, target_ulong addr, int is_write, int is_user, uintptr_t retaddr); diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index 3c2d1853d6..f61a497d21 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -34,7 +34,7 @@ #include "exec/exec-all.h" #include "disas/disas.h" #include "tcg-op.h" -#include "qemu-log.h" +#include "qemu/log.h" #include "sysemu.h" #include "helper.h" diff --git a/target-xtensa/xtensa-semi.c b/target-xtensa/xtensa-semi.c index 851ff546f0..5fe0361c02 100644 --- a/target-xtensa/xtensa-semi.c +++ b/target-xtensa/xtensa-semi.c @@ -31,7 +31,7 @@ #include #include "cpu.h" #include "helper.h" -#include "qemu-log.h" +#include "qemu/log.h" enum { TARGET_SYS_exit = 1, diff --git a/tcg/tcg.c b/tcg/tcg.c index cb193f2683..ede51a3960 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -37,9 +37,9 @@ #endif #include "qemu-common.h" -#include "cache-utils.h" -#include "host-utils.h" -#include "qemu-timer.h" +#include "qemu/cache-utils.h" +#include "qemu/host-utils.h" +#include "qemu/timer.h" /* Note: the long term plan is to reduce the dependancies on the QEMU CPU definitions. Currently they are used for qemu_ld/st diff --git a/tests/libqtest.c b/tests/libqtest.c index 71b84c12dd..913fa0535c 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -26,8 +26,8 @@ #include #include -#include "compiler.h" -#include "osdep.h" +#include "qemu/compiler.h" +#include "qemu/osdep.h" #define MAX_IRQ 256 diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c index 8c7a4d1ff4..e91fb1ae93 100644 --- a/tests/tcg/test-i386-fprem.c +++ b/tests/tcg/test-i386-fprem.c @@ -22,8 +22,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ -#include "compiler.h" -#include "osdep.h" +#include "qemu/compiler.h" +#include "qemu/osdep.h" #include #include diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c index 40392ac51d..6dc730d882 100644 --- a/tests/tcg/test-i386.c +++ b/tests/tcg/test-i386.c @@ -17,7 +17,7 @@ * along with this program; if not, see . */ #define _GNU_SOURCE -#include "compiler.h" +#include "qemu/compiler.h" #include #include #include diff --git a/tests/test-iov.c b/tests/test-iov.c index cbe7a8955c..a480bc8725 100644 --- a/tests/test-iov.c +++ b/tests/test-iov.c @@ -1,7 +1,7 @@ #include #include "qemu-common.h" -#include "iov.h" -#include "qemu_socket.h" +#include "qemu/iov.h" +#include "qemu/sockets.h" /* create a randomly-sized iovec with random vectors */ static void iov_random(struct iovec **iovp, unsigned *iov_cntp) diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 61b533a071..5a3e82a854 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -3,7 +3,7 @@ #include "qapi/qmp/types.h" #include "test-qmp-commands.h" #include "qapi/qmp/dispatch.h" -#include "module.h" +#include "qemu/module.h" #include "qapi/qmp-input-visitor.h" #include "tests/test-qapi-types.h" #include "tests/test-qapi-visit.h" diff --git a/thread-pool.c b/thread-pool.c index 4c73a7db97..e3ca64d790 100644 --- a/thread-pool.c +++ b/thread-pool.c @@ -15,13 +15,13 @@ * GNU GPL, version 2 or (at your option) any later version. */ #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" -#include "osdep.h" +#include "qemu/queue.h" +#include "qemu/thread.h" +#include "qemu/osdep.h" #include "block/coroutine.h" #include "trace.h" #include "block/block_int.h" -#include "event_notifier.h" +#include "qemu/event_notifier.h" #include "block/thread-pool.h" static void do_spawn_thread(void); diff --git a/trace/simple.c b/trace/simple.c index d83681b227..ce17d64bd7 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -16,7 +16,7 @@ #include #include #endif -#include "qemu-timer.h" +#include "qemu/timer.h" #include "trace.h" #include "trace/control.h" diff --git a/translate-all.c b/translate-all.c index e0cdad38c7..b621748ec0 100644 --- a/translate-all.c +++ b/translate-all.c @@ -35,7 +35,7 @@ #include "cpu.h" #include "disas/disas.h" #include "tcg.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "exec/memory.h" #include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) diff --git a/ui/console.c b/ui/console.c index 60bfb72ac2..a4bff8ce8a 100644 --- a/ui/console.c +++ b/ui/console.c @@ -23,7 +23,7 @@ */ #include "qemu-common.h" #include "ui/console.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qmp-commands.h" #include "qemu-char.h" diff --git a/ui/sdl_zoom.c b/ui/sdl_zoom.c index a986c7c14c..122027cb36 100644 --- a/ui/sdl_zoom.c +++ b/ui/sdl_zoom.c @@ -12,7 +12,7 @@ */ #include "sdl_zoom.h" -#include "osdep.h" +#include "qemu/osdep.h" #include #include diff --git a/ui/spice-core.c b/ui/spice-core.c index 962475de6b..8727bf49ca 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -23,17 +23,17 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" -#include "qemu-thread.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/thread.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "qemu-x509.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "qmp-commands.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" -#include "notify.h" +#include "qemu/notify.h" #include "migration/migration.h" #include "monitor/monitor.h" #include "hw/hw.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index 56ebf80805..a19b3d95fb 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -17,8 +17,8 @@ #include "qemu-common.h" #include "ui/qemu-spice.h" -#include "qemu-timer.h" -#include "qemu-queue.h" +#include "qemu/timer.h" +#include "qemu/queue.h" #include "monitor/monitor.h" #include "ui/console.h" #include "sysemu.h" diff --git a/ui/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h index ee243a9d64..8091d689cb 100644 --- a/ui/vnc-auth-sasl.h +++ b/ui/vnc-auth-sasl.h @@ -32,7 +32,7 @@ typedef struct VncStateSASL VncStateSASL; typedef struct VncDisplaySASL VncDisplaySASL; -#include "acl.h" +#include "qemu/acl.h" struct VncStateSASL { sasl_conn_t *conn; diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 09199ef584..4ddea7d4f5 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -44,7 +44,7 @@ #include #endif -#include "bswap.h" +#include "qemu/bswap.h" #include "qapi/qmp/qint.h" #include "vnc.h" #include "vnc-enc-tight.h" diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index 57c091683b..0bfc0c5485 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -28,7 +28,7 @@ #include "vnc.h" #include "vnc-jobs.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" /* * Locking: diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h index bfc7fe642e..d02f0236c1 100644 --- a/ui/vnc-palette.h +++ b/ui/vnc-palette.h @@ -30,7 +30,7 @@ #define VNC_PALETTE_H #include "qapi/qmp/qlist.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include #include diff --git a/ui/vnc-tls.c b/ui/vnc-tls.c index a7f7d07ac8..56292636d7 100644 --- a/ui/vnc-tls.c +++ b/ui/vnc-tls.c @@ -26,7 +26,7 @@ #include "qemu-x509.h" #include "vnc.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #if defined(_VNC_DEBUG) && _VNC_DEBUG >= 2 /* Very verbose, so only enabled for _VNC_DEBUG >= 2 */ diff --git a/ui/vnc-tls.h b/ui/vnc-tls.h index 2b93633896..36a2227fec 100644 --- a/ui/vnc-tls.h +++ b/ui/vnc-tls.h @@ -31,7 +31,7 @@ #include #include -#include "acl.h" +#include "qemu/acl.h" enum { VNC_WIREMODE_CLEAR, diff --git a/ui/vnc.c b/ui/vnc.c index dad2ddee29..d9e5315e79 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -27,12 +27,12 @@ #include "vnc.h" #include "vnc-jobs.h" #include "sysemu.h" -#include "qemu_socket.h" -#include "qemu-timer.h" -#include "acl.h" +#include "qemu/sockets.h" +#include "qemu/timer.h" +#include "qemu/acl.h" #include "qapi/qmp/types.h" #include "qmp-commands.h" -#include "osdep.h" +#include "qemu/osdep.h" #define VNC_REFRESH_INTERVAL_BASE 30 #define VNC_REFRESH_INTERVAL_INC 50 diff --git a/ui/vnc.h b/ui/vnc.h index e5c043ff45..8b40f09117 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -28,12 +28,12 @@ #define __QEMU_VNC_H #include "qemu-common.h" -#include "qemu-queue.h" -#include "qemu-thread.h" +#include "qemu/queue.h" +#include "qemu/thread.h" #include "ui/console.h" #include "monitor/monitor.h" #include "audio/audio.h" -#include "bitmap.h" +#include "qemu/bitmap.h" #include #include diff --git a/uri.c b/uri.c index 138547b821..4238729b83 100644 --- a/uri.c +++ b/uri.c @@ -55,7 +55,7 @@ #include #include -#include "uri.h" +#include "qemu/uri.h" static void uri_clean(URI *uri); diff --git a/uri.h b/uri.h deleted file mode 100644 index de99b3bd4b..0000000000 --- a/uri.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Summary: library of generic URI related routines - * Description: library of generic URI related routines - * Implements RFC 2396 - * - * Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Daniel Veillard shall not - * be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from him. - * - * Author: Daniel Veillard - ** - * Copyright (C) 2007 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: - * Richard W.M. Jones - * - * Utility functions to help parse and assemble query strings. - */ - -#ifndef QEMU_URI_H -#define QEMU_URI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * URI: - * - * A parsed URI reference. This is a struct containing the various fields - * as described in RFC 2396 but separated for further processing. - */ -typedef struct URI { - char *scheme; /* the URI scheme */ - char *opaque; /* opaque part */ - char *authority; /* the authority part */ - char *server; /* the server part */ - char *user; /* the user part */ - int port; /* the port number */ - char *path; /* the path string */ - char *fragment; /* the fragment identifier */ - int cleanup; /* parsing potentially unclean URI */ - char *query; /* the query string (as it appears in the URI) */ -} URI; - -URI *uri_new(void); -char *uri_resolve(const char *URI, const char *base); -char *uri_resolve_relative(const char *URI, const char *base); -URI *uri_parse(const char *str); -URI *uri_parse_raw(const char *str, int raw); -int uri_parse_into(URI *uri, const char *str); -char *uri_to_string(URI *uri); -char *uri_string_escape(const char *str, const char *list); -char *uri_string_unescape(const char *str, int len, char *target); -void uri_free(URI *uri); - -/* Single web service query parameter 'name=value'. */ -typedef struct QueryParam { - char *name; /* Name (unescaped). */ - char *value; /* Value (unescaped). */ - int ignore; /* Ignore this field in qparam_get_query */ -} QueryParam; - -/* Set of parameters. */ -typedef struct QueryParams { - int n; /* number of parameters used */ - int alloc; /* allocated space */ - QueryParam *p; /* array of parameters */ -} QueryParams; - -struct QueryParams *query_params_new (int init_alloc); -int query_param_append (QueryParams *ps, const char *name, const char *value); -extern char *query_param_to_string (const QueryParams *ps); -extern QueryParams *query_params_parse (const char *query); -extern void query_params_free (QueryParams *ps); - -#ifdef __cplusplus -} -#endif -#endif /* QEMU_URI_H */ diff --git a/vl.c b/vl.c index 2debde0a4a..9b80e7abc4 100644 --- a/vl.c +++ b/vl.c @@ -28,7 +28,7 @@ #include #include #include -#include "bitmap.h" +#include "qemu/bitmap.h" /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" @@ -133,9 +133,9 @@ int main(int argc, char **argv) #include "ui/console.h" #include "sysemu.h" #include "exec/gdbstub.h" -#include "qemu-timer.h" +#include "qemu/timer.h" #include "qemu-char.h" -#include "cache-utils.h" +#include "qemu/cache-utils.h" #include "blockdev.h" #include "hw/block-common.h" #include "migration/block.h" @@ -144,11 +144,11 @@ int main(int argc, char **argv) #include "migration/migration.h" #include "kvm.h" #include "qapi/qmp/qjson.h" -#include "qemu-option.h" -#include "qemu-config.h" +#include "qemu/option.h" +#include "qemu/config-file.h" #include "qemu-options.h" #include "qmp-commands.h" -#include "main-loop.h" +#include "qemu/main-loop.h" #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif @@ -156,16 +156,16 @@ int main(int argc, char **argv) #include "disas/disas.h" -#include "qemu_socket.h" +#include "qemu/sockets.h" #include "slirp/libslirp.h" #include "trace.h" #include "trace/control.h" -#include "qemu-queue.h" +#include "qemu/queue.h" #include "cpus.h" #include "arch_init.h" -#include "osdep.h" +#include "qemu/osdep.h" #include "ui/qemu-spice.h" #include "qapi/string-input-visitor.h" diff --git a/xen-all.c b/xen-all.c index 95d383f41f..6965626db8 100644 --- a/xen-all.c +++ b/xen-all.c @@ -16,7 +16,7 @@ #include "hw/xen_backend.h" #include "qmp-commands.h" -#include "range.h" +#include "qemu/range.h" #include "xen-mapcache.h" #include "trace.h" #include "exec/address-spaces.h" diff --git a/xen-mapcache.c b/xen-mapcache.c index 31c06dc950..8f4648cc32 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -14,7 +14,7 @@ #include "hw/xen_backend.h" #include "blockdev.h" -#include "bitmap.h" +#include "qemu/bitmap.h" #include #include -- cgit v1.2.3-55-g7522 From 9c17d615a66ebd655871bf891ec0fe901ad8b332 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Dec 2012 18:20:04 +0100 Subject: softmmu: move include files to include/sysemu/ Signed-off-by: Paolo Bonzini --- arch_init.c | 6 +- arch_init.h | 39 ------ audio/audio.c | 2 +- audio/winwaveaudio.c | 2 +- balloon.c | 4 +- balloon.h | 29 ---- block-migration.c | 2 +- block.c | 2 +- block/vdi.c | 2 +- blockdev-nbd.c | 4 +- blockdev.c | 6 +- blockdev.h | 69 ---------- cpu-exec.c | 2 +- cpus.c | 10 +- cpus.h | 24 ---- device_tree.c | 2 +- device_tree.h | 54 -------- dma-helpers.c | 2 +- dma.h | 282 -------------------------------------- dump-stub.c | 2 +- dump.c | 8 +- dump.h | 35 ----- exec.c | 6 +- gdbstub.c | 4 +- hw/ac97.c | 2 +- hw/acpi.c | 2 +- hw/acpi_ich9.c | 4 +- hw/acpi_piix4.c | 2 +- hw/alpha_dp264.c | 2 +- hw/alpha_pci.c | 2 +- hw/alpha_typhoon.c | 2 +- hw/apb_pci.c | 2 +- hw/apic_common.c | 2 +- hw/arm_boot.c | 4 +- hw/arm_sysctl.c | 2 +- hw/axis_dev88.c | 2 +- hw/block-common.c | 2 +- hw/boards.h | 2 +- hw/bonito.c | 2 +- hw/cbus.c | 2 +- hw/collie.c | 2 +- hw/cuda.c | 2 +- hw/device-hotplug.c | 4 +- hw/e1000.c | 4 +- hw/eepro100.c | 4 +- hw/es1370.c | 2 +- hw/etraxfs_dma.c | 2 +- hw/etraxfs_timer.c | 2 +- hw/exynos4210.c | 2 +- hw/exynos4210_rtc.c | 2 +- hw/exynos4210_uart.c | 2 +- hw/exynos4_boards.c | 2 +- hw/fdc.c | 4 +- hw/fw_cfg.c | 2 +- hw/gumstix.c | 2 +- hw/highbank.c | 4 +- hw/ide/ahci.c | 2 +- hw/ide/cmd646.c | 4 +- hw/ide/core.c | 6 +- hw/ide/ich.c | 2 +- hw/ide/internal.h | 4 +- hw/ide/isa.c | 2 +- hw/ide/macio.c | 2 +- hw/ide/microdrive.c | 2 +- hw/ide/mmio.c | 2 +- hw/ide/pci.c | 2 +- hw/ide/piix.c | 6 +- hw/ide/qdev.c | 6 +- hw/ide/via.c | 4 +- hw/imx_ccm.c | 2 +- hw/imx_serial.c | 2 +- hw/integratorcp.c | 2 +- hw/intel-hda.c | 2 +- hw/isa-bus.c | 2 +- hw/ivshmem.c | 2 +- hw/kvm/apic.c | 2 +- hw/kvm/clock.c | 4 +- hw/kvm/i8254.c | 4 +- hw/kvm/i8259.c | 2 +- hw/kvm/ioapic.c | 2 +- hw/kvm/pci-assign.c | 2 +- hw/kvmvapic.c | 6 +- hw/kzm.c | 2 +- hw/lan9118.c | 2 +- hw/leon3.c | 2 +- hw/lm32_boards.c | 2 +- hw/lm32_sys.c | 2 +- hw/loader.c | 2 +- hw/lpc_ich9.c | 2 +- hw/lsi53c895a.c | 2 +- hw/m25p80.c | 2 +- hw/m48t59.c | 2 +- hw/mac_nvram.c | 2 +- hw/mainstone.c | 2 +- hw/mc146818rtc.c | 2 +- hw/mcf5206.c | 2 +- hw/mcf5208.c | 2 +- hw/megasas.c | 2 +- hw/microblaze_boot.c | 2 +- hw/milkymist-memcard.c | 4 +- hw/milkymist-sysctl.c | 2 +- hw/milkymist.c | 4 +- hw/mips_fulong2e.c | 4 +- hw/mips_jazz.c | 6 +- hw/mips_malta.c | 6 +- hw/mips_mipssim.c | 2 +- hw/mips_r4k.c | 4 +- hw/mpc8544_guts.c | 2 +- hw/multiboot.c | 2 +- hw/musicpal.c | 4 +- hw/nand.c | 2 +- hw/ne2000.c | 2 +- hw/nseries.c | 4 +- hw/omap1.c | 4 +- hw/omap2.c | 4 +- hw/omap_sx1.c | 2 +- hw/onenand.c | 2 +- hw/opencores_eth.c | 2 +- hw/openrisc_sim.c | 4 +- hw/palm.c | 2 +- hw/pam.c | 2 +- hw/parallel.c | 2 +- hw/pc.c | 8 +- hw/pc_piix.c | 8 +- hw/pc_q35.c | 4 +- hw/pc_sysfw.c | 6 +- hw/pci/pci-hotplug.c | 2 +- hw/pci/pci-stub.c | 2 +- hw/pci/pci.c | 2 +- hw/pci/pci.h | 2 +- hw/pci/pcie_aer.c | 2 +- hw/pckbd.c | 2 +- hw/pcnet-pci.c | 2 +- hw/pcnet.c | 2 +- hw/petalogix_ml605_mmu.c | 4 +- hw/petalogix_s3adsp1800_mmu.c | 4 +- hw/pl031.c | 2 +- hw/pl181.c | 2 +- hw/ppc.c | 4 +- hw/ppc/e500.c | 6 +- hw/ppc/e500plat.c | 4 +- hw/ppc/mpc8544ds.c | 2 +- hw/ppc405_boards.c | 4 +- hw/ppc405_uc.c | 2 +- hw/ppc440_bamboo.c | 6 +- hw/ppc_booke.c | 2 +- hw/ppc_newworld.c | 6 +- hw/ppc_oldworld.c | 6 +- hw/ppc_prep.c | 6 +- hw/ppce500_spin.c | 4 +- hw/ps2.c | 2 +- hw/pxa2xx.c | 4 +- hw/pxa2xx_lcd.c | 2 +- hw/pxa2xx_timer.c | 2 +- hw/qdev-monitor.c | 2 +- hw/qdev-properties.c | 2 +- hw/qdev.c | 2 +- hw/qxl.c | 2 +- hw/r2d.c | 4 +- hw/realview.c | 4 +- hw/rtl8139.c | 4 +- hw/s390-virtio-bus.c | 4 +- hw/s390-virtio.c | 6 +- hw/s390x/event-facility.c | 2 +- hw/s390x/sclp.c | 2 +- hw/s390x/sclpquiesce.c | 2 +- hw/scsi-bus.c | 4 +- hw/scsi-disk.c | 6 +- hw/scsi-generic.c | 2 +- hw/scsi.h | 2 +- hw/serial.h | 2 +- hw/sga.c | 2 +- hw/sh7750.c | 2 +- hw/shix.c | 2 +- hw/slavio_misc.c | 2 +- hw/smbios.c | 2 +- hw/smbus_ich9.c | 2 +- hw/spapr.c | 10 +- hw/spapr.h | 2 +- hw/spapr_events.c | 4 +- hw/spapr_hcall.c | 4 +- hw/spapr_iommu.c | 4 +- hw/spapr_nvram.c | 2 +- hw/spapr_rtas.c | 4 +- hw/spapr_vio.c | 6 +- hw/spapr_vio.h | 2 +- hw/spitz.c | 4 +- hw/ssi-sd.c | 2 +- hw/strongarm.c | 2 +- hw/sun4m.c | 4 +- hw/sun4u.c | 4 +- hw/tc6393xb.c | 2 +- hw/tosa.c | 2 +- hw/twl92230.c | 2 +- hw/usb/bus.c | 2 +- hw/usb/dev-network.c | 2 +- hw/usb/dev-storage.c | 4 +- hw/usb/hcd-ehci.h | 4 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/host-linux.c | 2 +- hw/usb/libhw.c | 2 +- hw/usb/redirect.c | 2 +- hw/versatilepb.c | 4 +- hw/vexpress.c | 4 +- hw/vfio_pci.c | 2 +- hw/virtex_ml507.c | 6 +- hw/virtio-balloon.c | 4 +- hw/virtio-blk.c | 2 +- hw/virtio-pci.c | 4 +- hw/virtio.h | 2 +- hw/vmport.c | 2 +- hw/vt82c686.c | 2 +- hw/watchdog.c | 2 +- hw/xen_backend.h | 2 +- hw/xen_devconfig.c | 2 +- hw/xen_disk.c | 2 +- hw/xen_machine_pv.c | 2 +- hw/xilinx_spi.c | 2 +- hw/xilinx_spips.c | 2 +- hw/xilinx_zynq.c | 4 +- hw/xtensa_lx60.c | 4 +- hw/xtensa_sim.c | 2 +- hw/z2.c | 4 +- hw/zynq_slcr.c | 2 +- include/sysemu/arch_init.h | 39 ++++++ include/sysemu/balloon.h | 29 ++++ include/sysemu/blockdev.h | 69 ++++++++++ include/sysemu/cpus.h | 24 ++++ include/sysemu/device_tree.h | 54 ++++++++ include/sysemu/dma.h | 282 ++++++++++++++++++++++++++++++++++++++ include/sysemu/dump.h | 35 +++++ include/sysemu/kvm.h | 280 +++++++++++++++++++++++++++++++++++++ include/sysemu/memory_mapping.h | 64 +++++++++ include/sysemu/os-posix.h | 51 +++++++ include/sysemu/os-win32.h | 99 +++++++++++++ include/sysemu/qtest.h | 53 +++++++ include/sysemu/seccomp.h | 22 +++ include/sysemu/sysemu.h | 185 +++++++++++++++++++++++++ include/sysemu/xen-mapcache.h | 56 ++++++++ include/ui/spice-display.h | 2 +- kvm-all.c | 4 +- kvm-stub.c | 2 +- kvm.h | 280 ------------------------------------- memory.c | 2 +- memory_mapping-stub.c | 2 +- memory_mapping.c | 2 +- memory_mapping.h | 64 --------- migration.c | 2 +- monitor.c | 8 +- net/tap-bsd.c | 2 +- net/tap-linux.c | 2 +- net/tap-solaris.c | 2 +- net/tap-win32.c | 2 +- net/tap.c | 2 +- os-posix.c | 2 +- os-win32.c | 2 +- oslib-posix.c | 2 +- oslib-win32.c | 2 +- qemu-char.c | 2 +- qemu-common.h | 4 +- qemu-img.c | 2 +- qemu-os-posix.h | 51 ------- qemu-os-win32.h | 99 ------------- qemu-progress.c | 2 +- qemu-seccomp.c | 2 +- qemu-seccomp.h | 22 --- qemu-timer.c | 2 +- qemu-tool.c | 2 +- qmp.c | 8 +- qtest.c | 6 +- qtest.h | 53 ------- savevm.c | 4 +- stubs/arch-query-cpu-def.c | 2 +- sysemu.h | 185 ------------------------- target-alpha/sys_helper.c | 2 +- target-arm/cpu.c | 2 +- target-arm/helper.c | 2 +- target-i386/arch_dump.c | 2 +- target-i386/arch_memory_mapping.c | 2 +- target-i386/cpu.c | 6 +- target-i386/excp_helper.c | 2 +- target-i386/helper.c | 4 +- target-i386/kvm.c | 4 +- target-i386/kvm_i386.h | 2 +- target-i386/machine.c | 2 +- target-m68k/m68k-semi.c | 2 +- target-ppc/helper.c | 4 +- target-ppc/kvm.c | 8 +- target-ppc/kvm_ppc.c | 2 +- target-ppc/machine.c | 2 +- target-ppc/mmu_helper.c | 2 +- target-ppc/translate_init.c | 4 +- target-s390x/helper.c | 2 +- target-s390x/interrupt.c | 2 +- target-s390x/kvm.c | 6 +- target-s390x/misc_helper.c | 4 +- target-sparc/helper.c | 2 +- target-sparc/int32_helper.c | 2 +- target-xtensa/translate.c | 2 +- ui/cocoa.m | 2 +- ui/curses.c | 2 +- ui/input.c | 2 +- ui/keymaps.c | 2 +- ui/sdl.c | 2 +- ui/spice-core.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.c | 2 +- vl.c | 16 +-- xen-all.c | 2 +- xen-mapcache.c | 4 +- xen-mapcache.h | 56 -------- 311 files changed, 1762 insertions(+), 1762 deletions(-) delete mode 100644 arch_init.h delete mode 100644 balloon.h delete mode 100644 blockdev.h delete mode 100644 cpus.h delete mode 100644 device_tree.h delete mode 100644 dma.h delete mode 100644 dump.h create mode 100644 include/sysemu/arch_init.h create mode 100644 include/sysemu/balloon.h create mode 100644 include/sysemu/blockdev.h create mode 100644 include/sysemu/cpus.h create mode 100644 include/sysemu/device_tree.h create mode 100644 include/sysemu/dma.h create mode 100644 include/sysemu/dump.h create mode 100644 include/sysemu/kvm.h create mode 100644 include/sysemu/memory_mapping.h create mode 100644 include/sysemu/os-posix.h create mode 100644 include/sysemu/os-win32.h create mode 100644 include/sysemu/qtest.h create mode 100644 include/sysemu/seccomp.h create mode 100644 include/sysemu/sysemu.h create mode 100644 include/sysemu/xen-mapcache.h delete mode 100644 kvm.h delete mode 100644 memory_mapping.h delete mode 100644 qemu-os-posix.h delete mode 100644 qemu-os-win32.h delete mode 100644 qemu-seccomp.h delete mode 100644 qtest.h delete mode 100644 sysemu.h delete mode 100644 xen-mapcache.h (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 9dacf5689b..a8b65416da 100644 --- a/arch_init.c +++ b/arch_init.c @@ -30,15 +30,15 @@ #endif #include "config.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/bitops.h" #include "qemu/bitmap.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" #include "audio/audio.h" #include "hw/pc.h" #include "hw/pci/pci.h" #include "hw/audiodev.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "migration/migration.h" #include "exec/gdbstub.h" #include "hw/smbios.h" diff --git a/arch_init.h b/arch_init.h deleted file mode 100644 index 5fc780c63d..0000000000 --- a/arch_init.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef QEMU_ARCH_INIT_H -#define QEMU_ARCH_INIT_H - -#include "qmp-commands.h" - -enum { - QEMU_ARCH_ALL = -1, - QEMU_ARCH_ALPHA = 1, - QEMU_ARCH_ARM = 2, - QEMU_ARCH_CRIS = 4, - QEMU_ARCH_I386 = 8, - QEMU_ARCH_M68K = 16, - QEMU_ARCH_LM32 = 32, - QEMU_ARCH_MICROBLAZE = 64, - QEMU_ARCH_MIPS = 128, - QEMU_ARCH_PPC = 256, - QEMU_ARCH_S390X = 512, - QEMU_ARCH_SH4 = 1024, - QEMU_ARCH_SPARC = 2048, - QEMU_ARCH_XTENSA = 4096, - QEMU_ARCH_OPENRISC = 8192, - QEMU_ARCH_UNICORE32 = 0x4000, -}; - -extern const uint32_t arch_type; - -void select_soundhw(const char *optarg); -void do_acpitable_option(const char *optarg); -void do_smbios_option(const char *optarg); -void cpudef_init(void); -int audio_available(void); -void audio_init(ISABus *isa_bus, PCIBus *pci_bus); -int tcg_available(void); -int kvm_available(void); -int xen_available(void); - -CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); - -#endif diff --git a/audio/audio.c b/audio/audio.c index eb2222c10f..1510b598a6 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -25,7 +25,7 @@ #include "audio.h" #include "monitor/monitor.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define AUDIO_CAP "audio" #include "audio_int.h" diff --git a/audio/winwaveaudio.c b/audio/winwaveaudio.c index 72babbf184..8dbd145ca1 100644 --- a/audio/winwaveaudio.c +++ b/audio/winwaveaudio.c @@ -1,7 +1,7 @@ /* public domain */ #include "qemu-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "audio.h" #define AUDIO_CAP "winwave" diff --git a/balloon.c b/balloon.c index d1de4352b4..e321f2c688 100644 --- a/balloon.c +++ b/balloon.c @@ -26,8 +26,8 @@ #include "monitor/monitor.h" #include "exec/cpu-common.h" -#include "kvm.h" -#include "balloon.h" +#include "sysemu/kvm.h" +#include "sysemu/balloon.h" #include "trace.h" #include "qmp-commands.h" #include "qapi/qmp/qjson.h" diff --git a/balloon.h b/balloon.h deleted file mode 100644 index bd9d39505d..0000000000 --- a/balloon.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Balloon - * - * Copyright IBM, Corp. 2008 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef _QEMU_BALLOON_H -#define _QEMU_BALLOON_H - -#include "monitor/monitor.h" -#include "qapi-types.h" - -typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); -typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info); - -int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, - QEMUBalloonStatus *stat_func, void *opaque); -void qemu_remove_balloon_handler(void *opaque); - -void qemu_balloon_changed(int64_t actual); - -#endif diff --git a/block-migration.c b/block-migration.c index 4e865a6781..ca4ba3fffb 100644 --- a/block-migration.c +++ b/block-migration.c @@ -20,7 +20,7 @@ #include "qemu/timer.h" #include "migration/block.h" #include "migration/migration.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include #define BLOCK_SIZE (BDRV_SECTORS_PER_DIRTY_CHUNK << BDRV_SECTOR_BITS) diff --git a/block.c b/block.c index 1af4b99ee8..4e28c55bc7 100644 --- a/block.c +++ b/block.c @@ -29,7 +29,7 @@ #include "block/blockjob.h" #include "qemu/module.h" #include "qapi/qmp/qjson.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/notify.h" #include "block/coroutine.h" #include "qmp-commands.h" diff --git a/block/vdi.c b/block/vdi.c index 7b6231941b..021abaa227 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -58,7 +58,7 @@ #include #else /* TODO: move uuid emulation to some central place in QEMU. */ -#include "sysemu.h" /* UUID_FMT */ +#include "sysemu/sysemu.h" /* UUID_FMT */ typedef unsigned char uuid_t[16]; #endif diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 95b621699a..dc4e9a2462 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -9,11 +9,11 @@ * later. See the COPYING file in the top-level directory. */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" #include "monitor/monitor.h" #include "qapi/qmp/qerror.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qmp-commands.h" #include "trace.h" #include "block/nbd.h" diff --git a/blockdev.c b/blockdev.c index 3ebff44310..d724e2dc5b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -7,7 +7,7 @@ * later. See the COPYING file in the top-level directory. */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" #include "block/blockjob.h" #include "monitor/monitor.h" @@ -15,11 +15,11 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qapi/qmp/types.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "block/block_int.h" #include "qmp-commands.h" #include "trace.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives); diff --git a/blockdev.h b/blockdev.h deleted file mode 100644 index 1fe533299e..0000000000 --- a/blockdev.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * QEMU host block devices - * - * Copyright (c) 2003-2008 Fabrice Bellard - * - * This work is licensed under the terms of the GNU GPL, version 2 or - * later. See the COPYING file in the top-level directory. - */ - -#ifndef BLOCKDEV_H -#define BLOCKDEV_H - -#include "block/block.h" -#include "qapi/error.h" -#include "qemu/queue.h" - -void blockdev_mark_auto_del(BlockDriverState *bs); -void blockdev_auto_del(BlockDriverState *bs); - -typedef enum { - IF_DEFAULT = -1, /* for use with drive_add() only */ - /* - * IF_IDE must be zero, because we want QEMUMachine member - * block_default_type to default-initialize to IF_IDE - */ - IF_IDE = 0, - IF_NONE, - IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, - IF_COUNT -} BlockInterfaceType; - -struct DriveInfo { - BlockDriverState *bdrv; - char *id; - const char *devaddr; - BlockInterfaceType type; - int bus; - int unit; - int auto_del; /* see blockdev_mark_auto_del() */ - int media_cd; - int cyls, heads, secs, trans; - QemuOpts *opts; - const char *serial; - QTAILQ_ENTRY(DriveInfo) next; - int refcount; -}; - -DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); -DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); -int drive_get_max_bus(BlockInterfaceType type); -DriveInfo *drive_get_next(BlockInterfaceType type); -void drive_get_ref(DriveInfo *dinfo); -void drive_put_ref(DriveInfo *dinfo); -DriveInfo *drive_get_by_blockdev(BlockDriverState *bs); - -QemuOpts *drive_def(const char *optstr); -QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, - const char *optstr); -DriveInfo *drive_init(QemuOpts *arg, BlockInterfaceType block_default_type); - -/* device-hotplug */ - -DriveInfo *add_init_drive(const char *opts); - -void qmp_change_blockdev(const char *device, const char *filename, - bool has_format, const char *format, Error **errp); -void do_commit(Monitor *mon, const QDict *qdict); -int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); -#endif diff --git a/cpu-exec.c b/cpu-exec.c index 54e62ed551..19ebb4a924 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -21,7 +21,7 @@ #include "disas/disas.h" #include "tcg.h" #include "qemu/atomic.h" -#include "qtest.h" +#include "sysemu/qtest.h" int tb_invalidated_flag; diff --git a/cpus.c b/cpus.c index 036418d62c..4a7782a541 100644 --- a/cpus.c +++ b/cpus.c @@ -26,15 +26,15 @@ #include "config-host.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/gdbstub.h" -#include "dma.h" -#include "kvm.h" +#include "sysemu/dma.h" +#include "sysemu/kvm.h" #include "qmp-commands.h" #include "qemu/thread.h" -#include "cpus.h" -#include "qtest.h" +#include "sysemu/cpus.h" +#include "sysemu/qtest.h" #include "qemu/main-loop.h" #include "qemu/bitmap.h" diff --git a/cpus.h b/cpus.h deleted file mode 100644 index 81bd81773f..0000000000 --- a/cpus.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef QEMU_CPUS_H -#define QEMU_CPUS_H - -/* cpus.c */ -void qemu_init_cpu_loop(void); -void resume_all_vcpus(void); -void pause_all_vcpus(void); -void cpu_stop_current(void); - -void cpu_synchronize_all_states(void); -void cpu_synchronize_all_post_reset(void); -void cpu_synchronize_all_post_init(void); - -void qtest_clock_warp(int64_t dest); - -/* vl.c */ -extern int smp_cores; -extern int smp_threads; -void set_numa_modes(void); -void set_cpu_log(const char *optarg); -void set_cpu_log_filename(const char *optarg); -void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg); - -#endif diff --git a/device_tree.c b/device_tree.c index c3e1ba4904..56af24b397 100644 --- a/device_tree.c +++ b/device_tree.c @@ -20,7 +20,7 @@ #include "config.h" #include "qemu-common.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "hw/loader.h" #include "qemu/option.h" #include "qemu/config-file.h" diff --git a/device_tree.h b/device_tree.h deleted file mode 100644 index f0b3f35e03..0000000000 --- a/device_tree.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Header with function prototypes to help device tree manipulation using - * libfdt. It also provides functions to read entries from device tree proc - * interface. - * - * Copyright 2008 IBM Corporation. - * Authors: Jerone Young - * Hollis Blanchard - * - * This work is licensed under the GNU GPL license version 2 or later. - * - */ - -#ifndef __DEVICE_TREE_H__ -#define __DEVICE_TREE_H__ - -void *create_device_tree(int *sizep); -void *load_device_tree(const char *filename_path, int *sizep); - -int qemu_devtree_setprop(void *fdt, const char *node_path, - const char *property, const void *val_array, int size); -int qemu_devtree_setprop_cell(void *fdt, const char *node_path, - const char *property, uint32_t val); -int qemu_devtree_setprop_u64(void *fdt, const char *node_path, - const char *property, uint64_t val); -int qemu_devtree_setprop_string(void *fdt, const char *node_path, - const char *property, const char *string); -int qemu_devtree_setprop_phandle(void *fdt, const char *node_path, - const char *property, - const char *target_node_path); -const void *qemu_devtree_getprop(void *fdt, const char *node_path, - const char *property, int *lenp); -uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path, - const char *property); -uint32_t qemu_devtree_get_phandle(void *fdt, const char *path); -uint32_t qemu_devtree_alloc_phandle(void *fdt); -int qemu_devtree_nop_node(void *fdt, const char *node_path); -int qemu_devtree_add_subnode(void *fdt, const char *name); - -#define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \ - do { \ - uint32_t qdt_tmp[] = { __VA_ARGS__ }; \ - int i; \ - \ - for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \ - qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \ - } \ - qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \ - sizeof(qdt_tmp)); \ - } while (0) - -void qemu_devtree_dumpdtb(void *fdt, int size); - -#endif /* __DEVICE_TREE_H__ */ diff --git a/dma-helpers.c b/dma-helpers.c index e6a6dd82fd..272632f367 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -7,7 +7,7 @@ * (GNU GPL), version 2 or later. */ -#include "dma.h" +#include "sysemu/dma.h" #include "trace.h" #include "qemu/range.h" #include "qemu/thread.h" diff --git a/dma.h b/dma.h deleted file mode 100644 index fd68f74c5b..0000000000 --- a/dma.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * DMA helper functions - * - * Copyright (c) 2009 Red Hat - * - * This work is licensed under the terms of the GNU General Public License - * (GNU GPL), version 2 or later. - */ - -#ifndef DMA_H -#define DMA_H - -#include -#include "exec/memory.h" -#include "hw/hw.h" -#include "block/block.h" -#include "kvm.h" - -typedef struct DMAContext DMAContext; -typedef struct ScatterGatherEntry ScatterGatherEntry; - -typedef enum { - DMA_DIRECTION_TO_DEVICE = 0, - DMA_DIRECTION_FROM_DEVICE = 1, -} DMADirection; - -struct QEMUSGList { - ScatterGatherEntry *sg; - int nsg; - int nalloc; - size_t size; - DMAContext *dma; -}; - -#ifndef CONFIG_USER_ONLY - -/* - * When an IOMMU is present, bus addresses become distinct from - * CPU/memory physical addresses and may be a different size. Because - * the IOVA size depends more on the bus than on the platform, we more - * or less have to treat these as 64-bit always to cover all (or at - * least most) cases. - */ -typedef uint64_t dma_addr_t; - -#define DMA_ADDR_BITS 64 -#define DMA_ADDR_FMT "%" PRIx64 - -typedef int DMATranslateFunc(DMAContext *dma, - dma_addr_t addr, - hwaddr *paddr, - hwaddr *len, - DMADirection dir); -typedef void* DMAMapFunc(DMAContext *dma, - dma_addr_t addr, - dma_addr_t *len, - DMADirection dir); -typedef void DMAUnmapFunc(DMAContext *dma, - void *buffer, - dma_addr_t len, - DMADirection dir, - dma_addr_t access_len); - -struct DMAContext { - AddressSpace *as; - DMATranslateFunc *translate; - DMAMapFunc *map; - DMAUnmapFunc *unmap; -}; - -/* A global DMA context corresponding to the address_space_memory - * AddressSpace, for sysbus devices which do DMA. - */ -extern DMAContext dma_context_memory; - -static inline void dma_barrier(DMAContext *dma, DMADirection dir) -{ - /* - * This is called before DMA read and write operations - * unless the _relaxed form is used and is responsible - * for providing some sane ordering of accesses vs - * concurrently running VCPUs. - * - * Users of map(), unmap() or lower level st/ld_* - * operations are responsible for providing their own - * ordering via barriers. - * - * This primitive implementation does a simple smp_mb() - * before each operation which provides pretty much full - * ordering. - * - * A smarter implementation can be devised if needed to - * use lighter barriers based on the direction of the - * transfer, the DMA context, etc... - */ - if (kvm_enabled()) { - smp_mb(); - } -} - -static inline bool dma_has_iommu(DMAContext *dma) -{ - return dma && dma->translate; -} - -/* Checks that the given range of addresses is valid for DMA. This is - * useful for certain cases, but usually you should just use - * dma_memory_{read,write}() and check for errors */ -bool iommu_dma_memory_valid(DMAContext *dma, dma_addr_t addr, dma_addr_t len, - DMADirection dir); -static inline bool dma_memory_valid(DMAContext *dma, - dma_addr_t addr, dma_addr_t len, - DMADirection dir) -{ - if (!dma_has_iommu(dma)) { - return true; - } else { - return iommu_dma_memory_valid(dma, addr, len, dir); - } -} - -int iommu_dma_memory_rw(DMAContext *dma, dma_addr_t addr, - void *buf, dma_addr_t len, DMADirection dir); -static inline int dma_memory_rw_relaxed(DMAContext *dma, dma_addr_t addr, - void *buf, dma_addr_t len, - DMADirection dir) -{ - if (!dma_has_iommu(dma)) { - /* Fast-path for no IOMMU */ - address_space_rw(dma->as, addr, buf, len, dir == DMA_DIRECTION_FROM_DEVICE); - return 0; - } else { - return iommu_dma_memory_rw(dma, addr, buf, len, dir); - } -} - -static inline int dma_memory_read_relaxed(DMAContext *dma, dma_addr_t addr, - void *buf, dma_addr_t len) -{ - return dma_memory_rw_relaxed(dma, addr, buf, len, DMA_DIRECTION_TO_DEVICE); -} - -static inline int dma_memory_write_relaxed(DMAContext *dma, dma_addr_t addr, - const void *buf, dma_addr_t len) -{ - return dma_memory_rw_relaxed(dma, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE); -} - -static inline int dma_memory_rw(DMAContext *dma, dma_addr_t addr, - void *buf, dma_addr_t len, - DMADirection dir) -{ - dma_barrier(dma, dir); - - return dma_memory_rw_relaxed(dma, addr, buf, len, dir); -} - -static inline int dma_memory_read(DMAContext *dma, dma_addr_t addr, - void *buf, dma_addr_t len) -{ - return dma_memory_rw(dma, addr, buf, len, DMA_DIRECTION_TO_DEVICE); -} - -static inline int dma_memory_write(DMAContext *dma, dma_addr_t addr, - const void *buf, dma_addr_t len) -{ - return dma_memory_rw(dma, addr, (void *)buf, len, - DMA_DIRECTION_FROM_DEVICE); -} - -int iommu_dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c, - dma_addr_t len); - -int dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c, dma_addr_t len); - -void *iommu_dma_memory_map(DMAContext *dma, - dma_addr_t addr, dma_addr_t *len, - DMADirection dir); -static inline void *dma_memory_map(DMAContext *dma, - dma_addr_t addr, dma_addr_t *len, - DMADirection dir) -{ - if (!dma_has_iommu(dma)) { - hwaddr xlen = *len; - void *p; - - p = address_space_map(dma->as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE); - *len = xlen; - return p; - } else { - return iommu_dma_memory_map(dma, addr, len, dir); - } -} - -void iommu_dma_memory_unmap(DMAContext *dma, - void *buffer, dma_addr_t len, - DMADirection dir, dma_addr_t access_len); -static inline void dma_memory_unmap(DMAContext *dma, - void *buffer, dma_addr_t len, - DMADirection dir, dma_addr_t access_len) -{ - if (!dma_has_iommu(dma)) { - address_space_unmap(dma->as, buffer, (hwaddr)len, - dir == DMA_DIRECTION_FROM_DEVICE, access_len); - } else { - iommu_dma_memory_unmap(dma, buffer, len, dir, access_len); - } -} - -#define DEFINE_LDST_DMA(_lname, _sname, _bits, _end) \ - static inline uint##_bits##_t ld##_lname##_##_end##_dma(DMAContext *dma, \ - dma_addr_t addr) \ - { \ - uint##_bits##_t val; \ - dma_memory_read(dma, addr, &val, (_bits) / 8); \ - return _end##_bits##_to_cpu(val); \ - } \ - static inline void st##_sname##_##_end##_dma(DMAContext *dma, \ - dma_addr_t addr, \ - uint##_bits##_t val) \ - { \ - val = cpu_to_##_end##_bits(val); \ - dma_memory_write(dma, addr, &val, (_bits) / 8); \ - } - -static inline uint8_t ldub_dma(DMAContext *dma, dma_addr_t addr) -{ - uint8_t val; - - dma_memory_read(dma, addr, &val, 1); - return val; -} - -static inline void stb_dma(DMAContext *dma, dma_addr_t addr, uint8_t val) -{ - dma_memory_write(dma, addr, &val, 1); -} - -DEFINE_LDST_DMA(uw, w, 16, le); -DEFINE_LDST_DMA(l, l, 32, le); -DEFINE_LDST_DMA(q, q, 64, le); -DEFINE_LDST_DMA(uw, w, 16, be); -DEFINE_LDST_DMA(l, l, 32, be); -DEFINE_LDST_DMA(q, q, 64, be); - -#undef DEFINE_LDST_DMA - -void dma_context_init(DMAContext *dma, AddressSpace *as, DMATranslateFunc translate, - DMAMapFunc map, DMAUnmapFunc unmap); - -struct ScatterGatherEntry { - dma_addr_t base; - dma_addr_t len; -}; - -void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint, DMAContext *dma); -void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len); -void qemu_sglist_destroy(QEMUSGList *qsg); -#endif - -typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num, - QEMUIOVector *iov, int nb_sectors, - BlockDriverCompletionFunc *cb, void *opaque); - -BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs, - QEMUSGList *sg, uint64_t sector_num, - DMAIOFunc *io_func, BlockDriverCompletionFunc *cb, - void *opaque, DMADirection dir); -BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs, - QEMUSGList *sg, uint64_t sector, - BlockDriverCompletionFunc *cb, void *opaque); -BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, - QEMUSGList *sg, uint64_t sector, - BlockDriverCompletionFunc *cb, void *opaque); -uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg); -uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); - -void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, - QEMUSGList *sg, enum BlockAcctType type); - -#endif diff --git a/dump-stub.c b/dump-stub.c index 0842e6f916..a9d0b3c67b 100644 --- a/dump-stub.c +++ b/dump-stub.c @@ -12,7 +12,7 @@ */ #include "qemu-common.h" -#include "dump.h" +#include "sysemu/dump.h" #include "qapi/qmp/qerror.h" #include "qmp-commands.h" diff --git a/dump.c b/dump.c index 871ee1727a..a26b1a5e1a 100644 --- a/dump.c +++ b/dump.c @@ -17,10 +17,10 @@ #include "exec/cpu-all.h" #include "exec/hwaddr.h" #include "monitor/monitor.h" -#include "kvm.h" -#include "dump.h" -#include "sysemu.h" -#include "memory_mapping.h" +#include "sysemu/kvm.h" +#include "sysemu/dump.h" +#include "sysemu/sysemu.h" +#include "sysemu/memory_mapping.h" #include "qapi/error.h" #include "qmp-commands.h" #include "exec/gdbstub.h" diff --git a/dump.h b/dump.h deleted file mode 100644 index e25b7cfb73..0000000000 --- a/dump.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * QEMU dump - * - * Copyright Fujitsu, Corp. 2011, 2012 - * - * Authors: - * Wen Congyang - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef DUMP_H -#define DUMP_H - -typedef struct ArchDumpInfo { - int d_machine; /* Architecture */ - int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */ - int d_class; /* ELFCLASS32 or ELFCLASS64 */ -} ArchDumpInfo; - -typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque); -int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, - int cpuid, void *opaque); -int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env, - int cpuid, void *opaque); -int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, - void *opaque); -int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, - void *opaque); -int cpu_get_dump_info(ArchDumpInfo *info); -ssize_t cpu_get_note_size(int class, int machine, int nr_cpus); - -#endif diff --git a/exec.c b/exec.c index 917bec0ecd..28abd7e710 100644 --- a/exec.c +++ b/exec.c @@ -30,17 +30,17 @@ #include "hw/hw.h" #include "hw/qdev.h" #include "qemu/osdep.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "hw/xen.h" #include "qemu/timer.h" #include "qemu/config-file.h" #include "exec/memory.h" -#include "dma.h" +#include "sysemu/dma.h" #include "exec/address-spaces.h" #if defined(CONFIG_USER_ONLY) #include #else /* !CONFIG_USER_ONLY */ -#include "xen-mapcache.h" +#include "sysemu/xen-mapcache.h" #include "trace.h" #endif diff --git a/gdbstub.c b/gdbstub.c index 4b178a608f..2fca1a7ebf 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -31,7 +31,7 @@ #else #include "monitor/monitor.h" #include "qemu-char.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/gdbstub.h" #endif @@ -39,7 +39,7 @@ #include "cpu.h" #include "qemu/sockets.h" -#include "kvm.h" +#include "sysemu/kvm.h" #ifndef TARGET_CPU_MEMORY_RW_DEBUG static inline int target_memory_rw_debug(CPUArchState *env, target_ulong addr, diff --git a/hw/ac97.c b/hw/ac97.c index 3e659b38df..5cd19c1d02 100644 --- a/hw/ac97.c +++ b/hw/ac97.c @@ -21,7 +21,7 @@ #include "audiodev.h" #include "audio/audio.h" #include "pci/pci.h" -#include "dma.h" +#include "sysemu/dma.h" enum { AC97_Reset = 0x00, diff --git a/hw/acpi.c b/hw/acpi.c index fe9b76a9b0..97617c4ef5 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -18,7 +18,7 @@ * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw.h" #include "pc.h" #include "acpi.h" diff --git a/hw/acpi_ich9.c b/hw/acpi_ich9.c index 8d1a689a36..37a50e6d7b 100644 --- a/hw/acpi_ich9.c +++ b/hw/acpi_ich9.c @@ -27,9 +27,9 @@ #include "pc.h" #include "pci/pci.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "acpi.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "exec/address-spaces.h" #include "ich9.h" diff --git a/hw/acpi_piix4.c b/hw/acpi_piix4.c index ebd015dc02..f53b969aa6 100644 --- a/hw/acpi_piix4.c +++ b/hw/acpi_piix4.c @@ -24,7 +24,7 @@ #include "pm_smbus.h" #include "pci/pci.h" #include "acpi.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/range.h" #include "exec/ioport.h" #include "fw_cfg.h" diff --git a/hw/alpha_dp264.c b/hw/alpha_dp264.c index 76d8ae8a84..e7e52c1f1c 100644 --- a/hw/alpha_dp264.c +++ b/hw/alpha_dp264.c @@ -11,7 +11,7 @@ #include "loader.h" #include "boards.h" #include "alpha_sys.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "mc146818rtc.h" #include "ide.h" #include "i8254.h" diff --git a/hw/alpha_pci.c b/hw/alpha_pci.c index 78d93e55ec..7327d488fd 100644 --- a/hw/alpha_pci.c +++ b/hw/alpha_pci.c @@ -9,7 +9,7 @@ #include "config.h" #include "alpha_sys.h" #include "qemu/log.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* PCI IO reads/writes, to byte-word addressable memory. */ diff --git a/hw/alpha_typhoon.c b/hw/alpha_typhoon.c index d61b2f483c..9f233d99f5 100644 --- a/hw/alpha_typhoon.c +++ b/hw/alpha_typhoon.c @@ -10,7 +10,7 @@ #include "exec/exec-all.h" #include "hw.h" #include "devices.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "alpha_sys.h" #include "exec/address-spaces.h" diff --git a/hw/apb_pci.c b/hw/apb_pci.c index 144a7cc8d3..c22e2b0fc3 100644 --- a/hw/apb_pci.c +++ b/hw/apb_pci.c @@ -32,7 +32,7 @@ #include "pci/pci_bridge.h" #include "pci/pci_bus.h" #include "apb_pci.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/address-spaces.h" /* debug APB */ diff --git a/hw/apic_common.c b/hw/apic_common.c index 5f542764eb..0658be93c1 100644 --- a/hw/apic_common.c +++ b/hw/apic_common.c @@ -20,7 +20,7 @@ #include "apic.h" #include "apic_internal.h" #include "trace.h" -#include "kvm.h" +#include "sysemu/kvm.h" static int apic_irq_delivered; bool apic_report_tpr_access; diff --git a/hw/arm_boot.c b/hw/arm_boot.c index bb9889fbef..115f583876 100644 --- a/hw/arm_boot.c +++ b/hw/arm_boot.c @@ -10,11 +10,11 @@ #include "config.h" #include "hw.h" #include "arm-misc.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "loader.h" #include "elf.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "qemu/config-file.h" #define KERNEL_ARGS_ADDR 0x100 diff --git a/hw/arm_sysctl.c b/hw/arm_sysctl.c index 0884f6275c..b733617aa0 100644 --- a/hw/arm_sysctl.c +++ b/hw/arm_sysctl.c @@ -11,7 +11,7 @@ #include "qemu/timer.h" #include "sysbus.h" #include "primecell.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define LOCK_VALUE 0xa05f diff --git a/hw/axis_dev88.c b/hw/axis_dev88.c index e537aecc78..2ca606b835 100644 --- a/hw/axis_dev88.c +++ b/hw/axis_dev88.c @@ -30,7 +30,7 @@ #include "loader.h" #include "elf.h" #include "cris-boot.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define D(x) diff --git a/hw/block-common.c b/hw/block-common.c index c24208e560..0f1b64ec95 100644 --- a/hw/block-common.c +++ b/hw/block-common.c @@ -7,7 +7,7 @@ * later. See the COPYING file in the top-level directory. */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" #include "qemu/error-report.h" diff --git a/hw/boards.h b/hw/boards.h index c66fa16a9d..4540e952f7 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -3,7 +3,7 @@ #ifndef HW_BOARDS_H #define HW_BOARDS_H -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qdev.h" typedef struct QEMUMachineInitArgs { diff --git a/hw/bonito.c b/hw/bonito.c index 78e264ccc0..0498c9be79 100644 --- a/hw/bonito.c +++ b/hw/bonito.c @@ -44,7 +44,7 @@ #include "pc.h" #include "mips.h" #include "pci/pci_host.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/address-spaces.h" //#define DEBUG_BONITO diff --git a/hw/cbus.c b/hw/cbus.c index 7216899a09..6fd3905448 100644 --- a/hw/cbus.c +++ b/hw/cbus.c @@ -23,7 +23,7 @@ #include "qemu-common.h" #include "irq.h" #include "devices.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" //#define DEBUG diff --git a/hw/collie.c b/hw/collie.c index faf5ac9ac7..804d61a421 100644 --- a/hw/collie.c +++ b/hw/collie.c @@ -15,7 +15,7 @@ #include "strongarm.h" #include "arm-misc.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" static struct arm_boot_info collie_binfo = { diff --git a/hw/cuda.c b/hw/cuda.c index cf83956e1a..d59e0aeaa9 100644 --- a/hw/cuda.c +++ b/hw/cuda.c @@ -26,7 +26,7 @@ #include "ppc_mac.h" #include "adb.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* XXX: implement all timer modes */ diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 34543786e5..88da145a89 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -24,9 +24,9 @@ #include "hw.h" #include "boards.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qemu/config-file.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" DriveInfo *add_init_drive(const char *optstr) diff --git a/hw/e1000.c b/hw/e1000.c index aeee3e61f4..92fb00a89f 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -30,8 +30,8 @@ #include "net/net.h" #include "net/checksum.h" #include "loader.h" -#include "sysemu.h" -#include "dma.h" +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" #include "e1000_hw.h" diff --git a/hw/eepro100.c b/hw/eepro100.c index 9e2be4ea0d..6bbefb505f 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -45,8 +45,8 @@ #include "pci/pci.h" #include "net/net.h" #include "eeprom93xx.h" -#include "sysemu.h" -#include "dma.h" +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" /* QEMU sends frames smaller than 60 bytes to ethernet nics. * Such frames are rejected by real nics and their emulations. diff --git a/hw/es1370.c b/hw/es1370.c index 65365788e1..59c3f2329e 100644 --- a/hw/es1370.c +++ b/hw/es1370.c @@ -30,7 +30,7 @@ #include "audiodev.h" #include "audio/audio.h" #include "pci/pci.h" -#include "dma.h" +#include "sysemu/dma.h" /* Missing stuff: SCTRL_P[12](END|ST)INC diff --git a/hw/etraxfs_dma.c b/hw/etraxfs_dma.c index 089267fcc1..d41500316f 100644 --- a/hw/etraxfs_dma.c +++ b/hw/etraxfs_dma.c @@ -26,7 +26,7 @@ #include "hw.h" #include "exec/address-spaces.h" #include "qemu-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "etraxfs_dma.h" diff --git a/hw/etraxfs_timer.c b/hw/etraxfs_timer.c index cc8b327715..e9273cd95d 100644 --- a/hw/etraxfs_timer.c +++ b/hw/etraxfs_timer.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" #include "ptimer.h" diff --git a/hw/exynos4210.c b/hw/exynos4210.c index 22148cd946..a7b84d61a0 100644 --- a/hw/exynos4210.c +++ b/hw/exynos4210.c @@ -22,7 +22,7 @@ */ #include "boards.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" #include "arm-misc.h" #include "loader.h" diff --git a/hw/exynos4210_rtc.c b/hw/exynos4210_rtc.c index 6ebc9b1790..5694a6207b 100644 --- a/hw/exynos4210_rtc.c +++ b/hw/exynos4210_rtc.c @@ -32,7 +32,7 @@ #include "hw.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exynos4210.h" diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c index 20dcd9fb57..8950891a00 100644 --- a/hw/exynos4210_uart.c +++ b/hw/exynos4210_uart.c @@ -20,7 +20,7 @@ */ #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-char.h" #include "exynos4210.h" diff --git a/hw/exynos4_boards.c b/hw/exynos4_boards.c index 5dd2961459..b26796847b 100644 --- a/hw/exynos4_boards.c +++ b/hw/exynos4_boards.c @@ -21,7 +21,7 @@ * */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" #include "net/net.h" #include "arm-misc.h" diff --git a/hw/fdc.c b/hw/fdc.c index b67d3a574b..ddc0cc3819 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -34,8 +34,8 @@ #include "isa.h" #include "sysbus.h" #include "qdev-addr.h" -#include "blockdev.h" -#include "sysemu.h" +#include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" #include "qemu/log.h" /********************************************************/ diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c index 2a00163a04..26f7125fe2 100644 --- a/hw/fw_cfg.c +++ b/hw/fw_cfg.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ #include "hw.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "isa.h" #include "fw_cfg.h" #include "sysbus.h" diff --git a/hw/gumstix.c b/hw/gumstix.c index 4acb32c2a9..6fb068386c 100644 --- a/hw/gumstix.c +++ b/hw/gumstix.c @@ -40,7 +40,7 @@ #include "flash.h" #include "devices.h" #include "boards.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" static const int sector_len = 128 * 1024; diff --git a/hw/highbank.c b/hw/highbank.c index 6f5f2a9d9d..6005622f3a 100644 --- a/hw/highbank.c +++ b/hw/highbank.c @@ -22,10 +22,10 @@ #include "devices.h" #include "loader.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "sysbus.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0x100 diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index d38c6e4574..d0724499c7 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -28,7 +28,7 @@ #include #include "monitor/monitor.h" -#include "dma.h" +#include "sysemu/dma.h" #include "exec/cpu-common.h" #include "internal.h" #include diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index f6d15b9f2a..ee855b670f 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -27,8 +27,8 @@ #include #include #include "block/block.h" -#include "sysemu.h" -#include "dma.h" +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/core.c b/hw/ide/core.c index bf65cb407e..6f1938a0a8 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -28,10 +28,10 @@ #include #include "qemu/error-report.h" #include "qemu/timer.h" -#include "sysemu.h" -#include "dma.h" +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" #include "hw/block-common.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include diff --git a/hw/ide/ich.c b/hw/ide/ich.c index 3457b98cc1..de39b3067a 100644 --- a/hw/ide/ich.c +++ b/hw/ide/ich.c @@ -66,7 +66,7 @@ #include #include #include "block/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include #include diff --git a/hw/ide/internal.h b/hw/ide/internal.h index c5016f0cea..d80360e85b 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -9,8 +9,8 @@ #include #include #include "exec/iorange.h" -#include "dma.h" -#include "sysemu.h" +#include "sysemu/dma.h" +#include "sysemu/sysemu.h" #include "hw/block-common.h" #include "hw/scsi-defs.h" diff --git a/hw/ide/isa.c b/hw/ide/isa.c index 39df87c608..aa0e7fa22d 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -26,7 +26,7 @@ #include #include #include "block/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 87cbb0c31e..d8f9b4bce1 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -26,7 +26,7 @@ #include #include #include "block/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c index 6cce5230c5..642774ef98 100644 --- a/hw/ide/microdrive.c +++ b/hw/ide/microdrive.c @@ -26,7 +26,7 @@ #include #include #include "block/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/mmio.c b/hw/ide/mmio.c index 40443513be..eb59976eda 100644 --- a/hw/ide/mmio.c +++ b/hw/ide/mmio.c @@ -24,7 +24,7 @@ */ #include #include "block/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 8821d5cceb..e6226e3197 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -27,7 +27,7 @@ #include #include #include "block/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/piix.c b/hw/ide/piix.c index 5cf39cf8f0..df95aec195 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -27,9 +27,9 @@ #include #include #include -#include "blockdev.h" -#include "sysemu.h" -#include "dma.h" +#include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" #include diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index c85e1ac018..d2fe77398f 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -17,12 +17,12 @@ * License along with this library; if not, see . */ #include -#include "dma.h" +#include "sysemu/dma.h" #include "qemu/error-report.h" #include -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* --------------------------------- */ diff --git a/hw/ide/via.c b/hw/ide/via.c index 880f61cc8e..14acb3ac04 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -28,8 +28,8 @@ #include #include #include "block/block.h" -#include "sysemu.h" -#include "dma.h" +#include "sysemu/sysemu.h" +#include "sysemu/dma.h" #include diff --git a/hw/imx_ccm.c b/hw/imx_ccm.c index f2e623cd29..46962e4df9 100644 --- a/hw/imx_ccm.c +++ b/hw/imx_ccm.c @@ -12,7 +12,7 @@ #include "hw.h" #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "imx.h" #define CKIH_FREQ 26000000 /* 26MHz crystal input */ diff --git a/hw/imx_serial.c b/hw/imx_serial.c index dcd125fd25..e56e3ea726 100644 --- a/hw/imx_serial.c +++ b/hw/imx_serial.c @@ -19,7 +19,7 @@ #include "hw.h" #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-char.h" #include "imx.h" diff --git a/hw/integratorcp.c b/hw/integratorcp.c index c995dc724f..47fc9cb944 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -13,7 +13,7 @@ #include "arm-misc.h" #include "net/net.h" #include "exec/address-spaces.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" typedef struct { SysBusDevice busdev; diff --git a/hw/intel-hda.c b/hw/intel-hda.c index 7ef3a15e08..98ff93679d 100644 --- a/hw/intel-hda.c +++ b/hw/intel-hda.c @@ -24,7 +24,7 @@ #include "audiodev.h" #include "intel-hda.h" #include "intel-hda-defs.h" -#include "dma.h" +#include "sysemu/dma.h" /* --------------------------------------------------------------------- */ /* hda bus */ diff --git a/hw/isa-bus.c b/hw/isa-bus.c index a2be67df56..86b0bbd3d1 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -19,7 +19,7 @@ #include "hw.h" #include "monitor/monitor.h" #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "isa.h" #include "exec/address-spaces.h" diff --git a/hw/ivshmem.c b/hw/ivshmem.c index af34f3b582..567c9a76a7 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -20,7 +20,7 @@ #include "pc.h" #include "pci/pci.h" #include "pci/msix.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "migration/migration.h" #include "qapi/qmp/qerror.h" #include "qemu/event_notifier.h" diff --git a/hw/kvm/apic.c b/hw/kvm/apic.c index beb418de8d..dad2f21c18 100644 --- a/hw/kvm/apic.c +++ b/hw/kvm/apic.c @@ -11,7 +11,7 @@ */ #include "hw/apic_internal.h" #include "hw/pci/msi.h" -#include "kvm.h" +#include "sysemu/kvm.h" static inline void kvm_apic_set_reg(struct kvm_lapic_state *kapic, int reg_id, uint32_t val) diff --git a/hw/kvm/clock.c b/hw/kvm/clock.c index 824b978397..6fcca95ada 100644 --- a/hw/kvm/clock.c +++ b/hw/kvm/clock.c @@ -14,8 +14,8 @@ */ #include "qemu-common.h" -#include "sysemu.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "hw/sysbus.h" #include "hw/kvm/clock.h" diff --git a/hw/kvm/i8254.c b/hw/kvm/i8254.c index 8ee1c352cf..57faf64ab2 100644 --- a/hw/kvm/i8254.c +++ b/hw/kvm/i8254.c @@ -23,10 +23,10 @@ * THE SOFTWARE. */ #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw/i8254.h" #include "hw/i8254_internal.h" -#include "kvm.h" +#include "sysemu/kvm.h" #define KVM_PIT_REINJECT_BIT 0 diff --git a/hw/kvm/i8259.c b/hw/kvm/i8259.c index 1e24cd4f36..70e1d185de 100644 --- a/hw/kvm/i8259.c +++ b/hw/kvm/i8259.c @@ -11,7 +11,7 @@ */ #include "hw/i8259_internal.h" #include "hw/apic_internal.h" -#include "kvm.h" +#include "sysemu/kvm.h" static void kvm_pic_get(PICCommonState *s) { diff --git a/hw/kvm/ioapic.c b/hw/kvm/ioapic.c index f95c157591..30db6230b4 100644 --- a/hw/kvm/ioapic.c +++ b/hw/kvm/ioapic.c @@ -13,7 +13,7 @@ #include "hw/pc.h" #include "hw/ioapic_internal.h" #include "hw/apic_internal.h" -#include "kvm.h" +#include "sysemu/kvm.h" /* PC Utility function */ void kvm_pc_setup_irq_routing(bool pci_enabled) diff --git a/hw/kvm/pci-assign.c b/hw/kvm/pci-assign.c index 2f06c27e83..410b6c6eeb 100644 --- a/hw/kvm/pci-assign.c +++ b/hw/kvm/pci-assign.c @@ -33,7 +33,7 @@ #include "hw/loader.h" #include "monitor/monitor.h" #include "qemu/range.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw/pci/pci.h" #include "hw/pci/msi.h" #include "kvm_i386.h" diff --git a/hw/kvmvapic.c b/hw/kvmvapic.c index 60c8fc46aa..81f4bcfdf6 100644 --- a/hw/kvmvapic.c +++ b/hw/kvmvapic.c @@ -8,9 +8,9 @@ * (at your option) any later version. See the COPYING file in the * top-level directory. */ -#include "sysemu.h" -#include "cpus.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/cpus.h" +#include "sysemu/kvm.h" #include "apic_internal.h" #define APIC_DEFAULT_ADDRESS 0xfee00000 diff --git a/hw/kzm.c b/hw/kzm.c index 9f92d30928..fd00af921e 100644 --- a/hw/kzm.c +++ b/hw/kzm.c @@ -19,7 +19,7 @@ #include "arm-misc.h" #include "devices.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "serial.h" #include "imx.h" diff --git a/hw/lan9118.c b/hw/lan9118.c index 4c72d0d98e..5adf91199b 100644 --- a/hw/lan9118.c +++ b/hw/lan9118.c @@ -13,7 +13,7 @@ #include "sysbus.h" #include "net/net.h" #include "devices.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "ptimer.h" /* For crc32 */ #include diff --git a/hw/leon3.c b/hw/leon3.c index 776ab97a78..d1d4541867 100644 --- a/hw/leon3.c +++ b/hw/leon3.c @@ -25,7 +25,7 @@ #include "qemu/timer.h" #include "ptimer.h" #include "qemu-char.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "loader.h" #include "elf.h" diff --git a/hw/lm32_boards.c b/hw/lm32_boards.c index 81afdf675c..42e8b6b52a 100644 --- a/hw/lm32_boards.c +++ b/hw/lm32_boards.c @@ -23,7 +23,7 @@ #include "devices.h" #include "boards.h" #include "loader.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "elf.h" #include "lm32_hwsetup.h" #include "lm32.h" diff --git a/hw/lm32_sys.c b/hw/lm32_sys.c index b3350890cb..e3a9db9748 100644 --- a/hw/lm32_sys.c +++ b/hw/lm32_sys.c @@ -33,7 +33,7 @@ #include "trace.h" #include "qemu/log.h" #include "qemu/error-report.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/log.h" enum { diff --git a/hw/loader.c b/hw/loader.c index f5ef575b52..3f59fcd14a 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -45,7 +45,7 @@ #include "hw.h" #include "disas/disas.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "uboot_image.h" #include "loader.h" #include "fw_cfg.h" diff --git a/hw/lpc_ich9.c b/hw/lpc_ich9.c index 76217a74fc..a068715c04 100644 --- a/hw/lpc_ich9.c +++ b/hw/lpc_ich9.c @@ -44,7 +44,7 @@ #include "pam.h" #include "pci/pci_bus.h" #include "exec/address-spaces.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" static int ich9_lpc_sci_irq(ICH9LPCState *lpc); diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 4aac9a0cff..0aafb00b58 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -15,7 +15,7 @@ #include "hw.h" #include "pci/pci.h" #include "scsi.h" -#include "dma.h" +#include "sysemu/dma.h" //#define DEBUG_LSI //#define DEBUG_LSI_REG diff --git a/hw/m25p80.c b/hw/m25p80.c index 3895e73957..d39265632b 100644 --- a/hw/m25p80.c +++ b/hw/m25p80.c @@ -22,7 +22,7 @@ */ #include "hw.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "ssi.h" #include "devices.h" diff --git a/hw/m48t59.c b/hw/m48t59.c index 301b10ce79..393c5c049a 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -24,7 +24,7 @@ #include "hw.h" #include "nvram.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" #include "isa.h" #include "exec/address-spaces.h" diff --git a/hw/mac_nvram.c b/hw/mac_nvram.c index a0d14dd3c5..71093c2b10 100644 --- a/hw/mac_nvram.c +++ b/hw/mac_nvram.c @@ -24,7 +24,7 @@ */ #include "hw.h" #include "firmware_abi.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "ppc_mac.h" /* debug NVR */ diff --git a/hw/mainstone.c b/hw/mainstone.c index 80d6a9d54d..a5ddbeff9d 100644 --- a/hw/mainstone.c +++ b/hw/mainstone.c @@ -18,7 +18,7 @@ #include "devices.h" #include "boards.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "exec/address-spaces.h" diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index fba75029df..2ddd7de09e 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -23,7 +23,7 @@ */ #include "hw.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "mc146818rtc.h" #include "qapi/visitor.h" diff --git a/hw/mcf5206.c b/hw/mcf5206.c index fbc806ac18..fe7a48864f 100644 --- a/hw/mcf5206.c +++ b/hw/mcf5206.c @@ -9,7 +9,7 @@ #include "mcf.h" #include "qemu/timer.h" #include "ptimer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/address-spaces.h" /* General purpose timer module. */ diff --git a/hw/mcf5208.c b/hw/mcf5208.c index fea8a69262..c1816cc9d1 100644 --- a/hw/mcf5208.c +++ b/hw/mcf5208.c @@ -9,7 +9,7 @@ #include "mcf.h" #include "qemu/timer.h" #include "ptimer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "net/net.h" #include "boards.h" #include "loader.h" diff --git a/hw/megasas.c b/hw/megasas.c index e80c0d1c25..eb191f5e12 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -20,7 +20,7 @@ #include "hw.h" #include "pci/pci.h" -#include "dma.h" +#include "sysemu/dma.h" #include "pci/msix.h" #include "qemu/iov.h" #include "scsi.h" diff --git a/hw/microblaze_boot.c b/hw/microblaze_boot.c index 76d33021c0..3ec5c0f7dd 100644 --- a/hw/microblaze_boot.c +++ b/hw/microblaze_boot.c @@ -27,7 +27,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qemu-common.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "loader.h" #include "elf.h" diff --git a/hw/milkymist-memcard.c b/hw/milkymist-memcard.c index 5dc30ace60..f80befc53a 100644 --- a/hw/milkymist-memcard.c +++ b/hw/milkymist-memcard.c @@ -23,10 +23,10 @@ #include "hw.h" #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "qemu/error-report.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sd.h" enum { diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c index 519462afcc..796e795f04 100644 --- a/hw/milkymist-sysctl.c +++ b/hw/milkymist-sysctl.c @@ -23,7 +23,7 @@ #include "hw.h" #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "qemu/timer.h" #include "ptimer.h" diff --git a/hw/milkymist.c b/hw/milkymist.c index 588522260b..0c23b672f3 100644 --- a/hw/milkymist.c +++ b/hw/milkymist.c @@ -20,12 +20,12 @@ #include "sysbus.h" #include "hw.h" #include "flash.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "devices.h" #include "boards.h" #include "loader.h" #include "elf.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "milkymist-hw.h" #include "lm32.h" #include "exec/address-spaces.h" diff --git a/hw/mips_fulong2e.c b/hw/mips_fulong2e.c index 60dd8c69bb..e7eeda319e 100644 --- a/hw/mips_fulong2e.c +++ b/hw/mips_fulong2e.c @@ -31,7 +31,7 @@ #include "mips_cpudevs.h" #include "pci/pci.h" #include "qemu-char.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "audio/audio.h" #include "qemu/log.h" #include "loader.h" @@ -41,7 +41,7 @@ #include "vt82c686.h" #include "mc146818rtc.h" #include "i8254.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define DEBUG_FULONG2E_INIT diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c index 0befc99210..63df2a734b 100644 --- a/hw/mips_jazz.c +++ b/hw/mips_jazz.c @@ -29,8 +29,8 @@ #include "serial.h" #include "isa.h" #include "fdc.h" -#include "sysemu.h" -#include "arch_init.h" +#include "sysemu/sysemu.h" +#include "sysemu/arch_init.h" #include "boards.h" #include "net/net.h" #include "esp.h" @@ -39,7 +39,7 @@ #include "mc146818rtc.h" #include "i8254.h" #include "pcspk.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "exec/address-spaces.h" diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 04c7a2612c..bd31ced29d 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -35,8 +35,8 @@ #include "mips_cpudevs.h" #include "pci/pci.h" #include "qemu-char.h" -#include "sysemu.h" -#include "arch_init.h" +#include "sysemu/sysemu.h" +#include "sysemu/arch_init.h" #include "boards.h" #include "qemu/log.h" #include "mips-bios.h" @@ -45,7 +45,7 @@ #include "elf.h" #include "mc146818rtc.h" #include "i8254.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "sysbus.h" /* SysBusDevice */ diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c index ac7dfa9b74..67066c0ca1 100644 --- a/hw/mips_mipssim.c +++ b/hw/mips_mipssim.c @@ -30,7 +30,7 @@ #include "serial.h" #include "isa.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "mips-bios.h" #include "loader.h" diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c index 511e1e41c0..59c43e591c 100644 --- a/hw/mips_r4k.c +++ b/hw/mips_r4k.c @@ -14,7 +14,7 @@ #include "serial.h" #include "isa.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "flash.h" #include "qemu/log.h" @@ -24,7 +24,7 @@ #include "elf.h" #include "mc146818rtc.h" #include "i8254.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define MAX_IDE_BUS 2 diff --git a/hw/mpc8544_guts.c b/hw/mpc8544_guts.c index 873cb8cbfc..84522e9722 100644 --- a/hw/mpc8544_guts.c +++ b/hw/mpc8544_guts.c @@ -18,7 +18,7 @@ */ #include "hw.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" #define MPC8544_GUTS_MMIO_SIZE 0x1000 diff --git a/hw/multiboot.c b/hw/multiboot.c index 09ec5b2539..c4ec2e34a7 100644 --- a/hw/multiboot.c +++ b/hw/multiboot.c @@ -27,7 +27,7 @@ #include "multiboot.h" #include "loader.h" #include "elf.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* Show multiboot debug output */ //#define DEBUG_MULTIBOOT diff --git a/hw/musicpal.c b/hw/musicpal.c index 5a7bf8bee1..77a585eee6 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -13,7 +13,7 @@ #include "arm-misc.h" #include "devices.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "serial.h" #include "qemu/timer.h" @@ -22,7 +22,7 @@ #include "flash.h" #include "ui/console.h" #include "i2c.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "ui/pixel_ops.h" diff --git a/hw/nand.c b/hw/nand.c index a73205d866..16950c5ec4 100644 --- a/hw/nand.c +++ b/hw/nand.c @@ -20,7 +20,7 @@ # include "hw.h" # include "flash.h" -# include "blockdev.h" +# include "sysemu/blockdev.h" # include "sysbus.h" #include "qemu/error-report.h" diff --git a/hw/ne2000.c b/hw/ne2000.c index 2001264e14..00efa74a0f 100644 --- a/hw/ne2000.c +++ b/hw/ne2000.c @@ -26,7 +26,7 @@ #include "net/net.h" #include "ne2000.h" #include "loader.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* debug NE2000 card */ //#define DEBUG_NE2000 diff --git a/hw/nseries.c b/hw/nseries.c index 83adb97211..d96b750ccd 100644 --- a/hw/nseries.c +++ b/hw/nseries.c @@ -19,7 +19,7 @@ */ #include "qemu-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "omap.h" #include "arm-misc.h" #include "irq.h" @@ -31,7 +31,7 @@ #include "hw.h" #include "bt.h" #include "loader.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "exec/address-spaces.h" diff --git a/hw/omap1.c b/hw/omap1.c index 50c4570f31..8536e96687 100644 --- a/hw/omap1.c +++ b/hw/omap1.c @@ -19,9 +19,9 @@ #include "hw.h" #include "arm-misc.h" #include "omap.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "soc_dma.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qemu/range.h" #include "sysbus.h" diff --git a/hw/omap2.c b/hw/omap2.c index 7ccee69661..dc6867c962 100644 --- a/hw/omap2.c +++ b/hw/omap2.c @@ -18,11 +18,11 @@ * with this program; if not, see . */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw.h" #include "arm-misc.h" #include "omap.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" #include "qemu-char.h" #include "flash.h" diff --git a/hw/omap_sx1.c b/hw/omap_sx1.c index ca6eb9ddeb..0f03121505 100644 --- a/hw/omap_sx1.c +++ b/hw/omap_sx1.c @@ -31,7 +31,7 @@ #include "boards.h" #include "arm-misc.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" /*****************************************************************************/ diff --git a/hw/onenand.c b/hw/onenand.c index 2e26e3a05d..26bf991d6d 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -22,7 +22,7 @@ #include "hw.h" #include "flash.h" #include "irq.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/memory.h" #include "exec/address-spaces.h" #include "sysbus.h" diff --git a/hw/opencores_eth.c b/hw/opencores_eth.c index fd2f0f61c3..a0dfdce1f9 100644 --- a/hw/opencores_eth.c +++ b/hw/opencores_eth.c @@ -34,7 +34,7 @@ #include "hw.h" #include "sysbus.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" /* RECSMALL is not used because it breaks tap networking in linux: diff --git a/hw/openrisc_sim.c b/hw/openrisc_sim.c index c12097e12b..d2b2379ae2 100644 --- a/hw/openrisc_sim.c +++ b/hw/openrisc_sim.c @@ -25,9 +25,9 @@ #include "net/net.h" #include "loader.h" #include "exec/address-spaces.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" -#include "qtest.h" +#include "sysemu/qtest.h" #define KERNEL_LOAD_ADDR 0x100 diff --git a/hw/palm.c b/hw/palm.c index e091bbcfc1..5219e37394 100644 --- a/hw/palm.c +++ b/hw/palm.c @@ -18,7 +18,7 @@ */ #include "hw.h" #include "audio/audio.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "ui/console.h" #include "omap.h" #include "boards.h" diff --git a/hw/pam.c b/hw/pam.c index a95e2cfb07..1d72e88e62 100644 --- a/hw/pam.c +++ b/hw/pam.c @@ -26,7 +26,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "pam.h" void smram_update(MemoryRegion *smram_region, uint8_t smram, diff --git a/hw/parallel.c b/hw/parallel.c index c4705bc89d..56b3760e8c 100644 --- a/hw/parallel.c +++ b/hw/parallel.c @@ -26,7 +26,7 @@ #include "qemu-char.h" #include "isa.h" #include "pc.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" //#define DEBUG_PARALLEL diff --git a/hw/pc.c b/hw/pc.c index 0a92ea6bed..71902e210b 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -40,16 +40,16 @@ #include "pcspk.h" #include "pci/msi.h" #include "sysbus.h" -#include "sysemu.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "kvm_i386.h" #include "xen.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" #include "ui/qemu-spice.h" #include "exec/memory.h" #include "exec/address-spaces.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" #include "qemu/bitmap.h" /* debug PC/ISA interrupts */ diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 0d011348f2..99747a774c 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -33,12 +33,12 @@ #include "net/net.h" #include "boards.h" #include "ide.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm/clock.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" -#include "arch_init.h" -#include "blockdev.h" +#include "sysemu/arch_init.h" +#include "sysemu/blockdev.h" #include "smbus.h" #include "xen.h" #include "exec/memory.h" diff --git a/hw/pc_q35.c b/hw/pc_q35.c index 2580d5ff34..c7262d6315 100644 --- a/hw/pc_q35.c +++ b/hw/pc_q35.c @@ -28,12 +28,12 @@ * THE SOFTWARE. */ #include "hw.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" #include "smbus.h" #include "boards.h" #include "mc146818rtc.h" #include "xen.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm/clock.h" #include "q35.h" #include "exec/address-spaces.h" diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c index d7ea3a5595..87e1fa961b 100644 --- a/hw/pc_sysfw.c +++ b/hw/pc_sysfw.c @@ -23,15 +23,15 @@ * THE SOFTWARE. */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "hw.h" #include "pc.h" #include "hw/boards.h" #include "loader.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "flash.h" -#include "kvm.h" +#include "sysemu/kvm.h" #define BIOS_FILENAME "bios.bin" diff --git a/hw/pci/pci-hotplug.c b/hw/pci/pci-hotplug.c index 2bc02e344f..f38df30540 100644 --- a/hw/pci/pci-hotplug.c +++ b/hw/pci/pci-hotplug.c @@ -31,7 +31,7 @@ #include "hw/scsi.h" #include "hw/virtio-blk.h" #include "qemu/config-file.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qapi/error.h" #if defined(TARGET_I386) diff --git a/hw/pci/pci-stub.c b/hw/pci/pci-stub.c index 5891dc959d..1dda89b593 100644 --- a/hw/pci/pci-stub.c +++ b/hw/pci/pci-stub.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "hw/pci/pci.h" #include "qmp-commands.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c9ed95be89..94840c4af7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -27,7 +27,7 @@ #include "hw/pci/pci_bus.h" #include "monitor/monitor.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw/loader.h" #include "qemu/range.h" #include "qmp-commands.h" diff --git a/hw/pci/pci.h b/hw/pci/pci.h index d6ef4f6574..3152050856 100644 --- a/hw/pci/pci.h +++ b/hw/pci/pci.h @@ -5,7 +5,7 @@ #include "hw/qdev.h" #include "exec/memory.h" -#include "dma.h" +#include "sysemu/dma.h" /* PCI includes legacy ISA access. */ #include "hw/isa.h" diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c index f7f3633f5b..1ce72ce944 100644 --- a/hw/pci/pcie_aer.c +++ b/hw/pci/pcie_aer.c @@ -18,7 +18,7 @@ * with this program; if not, see . */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qapi/qmp/types.h" #include "monitor/monitor.h" #include "hw/pci/pci_bridge.h" diff --git a/hw/pckbd.c b/hw/pckbd.c index 5bb3e0abf3..6db7bbcc06 100644 --- a/hw/pckbd.c +++ b/hw/pckbd.c @@ -25,7 +25,7 @@ #include "isa.h" #include "pc.h" #include "ps2.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* debug PC keyboard */ //#define DEBUG_KBD diff --git a/hw/pcnet-pci.c b/hw/pcnet-pci.c index 5e8eed3af8..40a0e6eda4 100644 --- a/hw/pcnet-pci.c +++ b/hw/pcnet-pci.c @@ -31,7 +31,7 @@ #include "net/net.h" #include "loader.h" #include "qemu/timer.h" -#include "dma.h" +#include "sysemu/dma.h" #include "pcnet.h" diff --git a/hw/pcnet.c b/hw/pcnet.c index 87736542e4..30f100007a 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -39,7 +39,7 @@ #include "net/net.h" #include "qemu/timer.h" #include "qemu/sockets.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "pcnet.h" diff --git a/hw/petalogix_ml605_mmu.c b/hw/petalogix_ml605_mmu.c index 4eab0f2d8b..1cfdb2f302 100644 --- a/hw/petalogix_ml605_mmu.c +++ b/hw/petalogix_ml605_mmu.c @@ -29,11 +29,11 @@ #include "hw.h" #include "net/net.h" #include "flash.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "devices.h" #include "boards.h" #include "xilinx.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "serial.h" #include "exec/address-spaces.h" #include "ssi.h" diff --git a/hw/petalogix_s3adsp1800_mmu.c b/hw/petalogix_s3adsp1800_mmu.c index 124a88eeda..27ecfe7752 100644 --- a/hw/petalogix_s3adsp1800_mmu.c +++ b/hw/petalogix_s3adsp1800_mmu.c @@ -27,11 +27,11 @@ #include "hw.h" #include "net/net.h" #include "flash.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "devices.h" #include "boards.h" #include "xilinx.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "microblaze_boot.h" diff --git a/hw/pl031.c b/hw/pl031.c index 834a20c917..3a23ecde48 100644 --- a/hw/pl031.c +++ b/hw/pl031.c @@ -13,7 +13,7 @@ #include "sysbus.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" //#define DEBUG_PL031 diff --git a/hw/pl181.c b/hw/pl181.c index 8a2895ce1b..cbddb741ce 100644 --- a/hw/pl181.c +++ b/hw/pl181.c @@ -7,7 +7,7 @@ * This code is licensed under the GPL. */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "sd.h" diff --git a/hw/ppc.c b/hw/ppc.c index f066367609..1559982625 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -24,11 +24,11 @@ #include "hw.h" #include "ppc.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "nvram.h" #include "qemu/log.h" #include "loader.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" //#define PPC_DEBUG_IRQ diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 3593f7c0e2..aa54fd84d7 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -24,10 +24,10 @@ #include "hw/serial.h" #include "hw/pci/pci.h" #include "hw/boards.h" -#include "sysemu.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "hw/openpic.h" #include "hw/ppc.h" #include "hw/loader.h" diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 2992bd9794..4deb02ac38 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -13,8 +13,8 @@ #include "qemu-common.h" #include "e500.h" #include "../boards.h" -#include "device_tree.h" -#include "hw/pci.h" +#include "sysemu/device_tree.h" +#include "hw/pci/pci.h" static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt) { diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c index 7e1761d20c..f9ae20f5a3 100644 --- a/hw/ppc/mpc8544ds.c +++ b/hw/ppc/mpc8544ds.c @@ -13,7 +13,7 @@ #include "qemu-common.h" #include "e500.h" #include "../boards.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" static void mpc8544ds_fixup_devtree(PPCE500Params *params, void *fdt) { diff --git a/hw/ppc405_boards.c b/hw/ppc405_boards.c index 31bcc4bb95..8f7f0d07d1 100644 --- a/hw/ppc405_boards.c +++ b/hw/ppc405_boards.c @@ -26,12 +26,12 @@ #include "ppc405.h" #include "nvram.h" #include "flash.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "block/block.h" #include "boards.h" #include "qemu/log.h" #include "loader.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define BIOS_FILENAME "ppc405_rom.bin" diff --git a/hw/ppc405_uc.c b/hw/ppc405_uc.c index b1ed8837d6..7e56ecb4af 100644 --- a/hw/ppc405_uc.c +++ b/hw/ppc405_uc.c @@ -26,7 +26,7 @@ #include "ppc405.h" #include "serial.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/log.h" #include "exec/address-spaces.h" diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c index 591d7b0088..4f1b734c22 100644 --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -17,16 +17,16 @@ #include "hw.h" #include "pci/pci.h" #include "boards.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "loader.h" #include "elf.h" #include "exec/address-spaces.h" #include "serial.h" #include "ppc.h" #include "ppc405.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" diff --git a/hw/ppc_booke.c b/hw/ppc_booke.c index a7182be0d3..5c89fc313d 100644 --- a/hw/ppc_booke.c +++ b/hw/ppc_booke.c @@ -24,7 +24,7 @@ #include "hw.h" #include "ppc.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "nvram.h" #include "qemu/log.h" #include "loader.h" diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index b2d02eaff2..fabcc08b40 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -54,7 +54,7 @@ #include "nvram.h" #include "pci/pci.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "fw_cfg.h" #include "escc.h" @@ -62,10 +62,10 @@ #include "ide.h" #include "loader.h" #include "elf.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" #include "hw/usb.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "sysbus.h" diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 7a8a039d7e..fff5129ca9 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -29,7 +29,7 @@ #include "adb.h" #include "mac_dbdma.h" #include "nvram.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "net/net.h" #include "isa.h" #include "pci/pci.h" @@ -39,9 +39,9 @@ #include "ide.h" #include "loader.h" #include "elf.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define MAX_IDE_BUS 2 diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c index 072535294e..9c78c863e8 100644 --- a/hw/ppc_prep.c +++ b/hw/ppc_prep.c @@ -27,7 +27,7 @@ #include "serial.h" #include "fdc.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "isa.h" #include "pci/pci.h" #include "pci/pci_host.h" @@ -37,8 +37,8 @@ #include "ide.h" #include "loader.h" #include "mc146818rtc.h" -#include "blockdev.h" -#include "arch_init.h" +#include "sysemu/blockdev.h" +#include "sysemu/arch_init.h" #include "exec/address-spaces.h" //#define HARD_DEBUG_PPC_IO diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c index c1a155bd31..177aa2d122 100644 --- a/hw/ppce500_spin.c +++ b/hw/ppce500_spin.c @@ -28,9 +28,9 @@ */ #include "hw.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" -#include "kvm.h" +#include "sysemu/kvm.h" #define MAX_CPUS 32 diff --git a/hw/ps2.c b/hw/ps2.c index ba80089aba..15cfd5bb76 100644 --- a/hw/ps2.c +++ b/hw/ps2.c @@ -24,7 +24,7 @@ #include "hw.h" #include "ps2.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" /* debug PC keyboard */ //#define DEBUG_KBD diff --git a/hw/pxa2xx.c b/hw/pxa2xx.c index e616979207..936e9f87cd 100644 --- a/hw/pxa2xx.c +++ b/hw/pxa2xx.c @@ -9,12 +9,12 @@ #include "sysbus.h" #include "pxa.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "serial.h" #include "i2c.h" #include "ssi.h" #include "qemu-char.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" static struct { hwaddr io_base; diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c index b5efd4d426..512a27e702 100644 --- a/hw/pxa2xx_lcd.c +++ b/hw/pxa2xx_lcd.c @@ -15,7 +15,7 @@ #include "pxa.h" #include "ui/pixel_ops.h" /* FIXME: For graphic_rotate. Should probably be done in common code. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "framebuffer.h" struct DMAChannel { diff --git a/hw/pxa2xx_timer.c b/hw/pxa2xx_timer.c index 1481c6d3e1..e4ffb15bb2 100644 --- a/hw/pxa2xx_timer.c +++ b/hw/pxa2xx_timer.c @@ -9,7 +9,7 @@ #include "hw.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "pxa.h" #include "sysbus.h" diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 1c6712e6de..b73986759b 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -20,7 +20,7 @@ #include "qdev.h" #include "monitor/monitor.h" #include "qmp-commands.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" #include "qemu/config-file.h" /* diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index ba6c648fed..1cb97ea594 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -1,7 +1,7 @@ #include "net/net.h" #include "qdev.h" #include "qapi/qmp/qerror.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" #include "net/hub.h" #include "qapi/visitor.h" diff --git a/hw/qdev.c b/hw/qdev.c index 0a2a32d5d3..c4a9857a05 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -27,7 +27,7 @@ #include "net/net.h" #include "qdev.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/visitor.h" diff --git a/hw/qxl.c b/hw/qxl.c index b88a39cc93..d08b9bd3c1 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -24,7 +24,7 @@ #include "qemu/timer.h" #include "qemu/queue.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "qxl.h" diff --git a/hw/r2d.c b/hw/r2d.c index d7a26bf398..7cf1893d19 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -27,7 +27,7 @@ #include "hw.h" #include "sh.h" #include "devices.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "pci/pci.h" #include "net/net.h" @@ -36,7 +36,7 @@ #include "loader.h" #include "usb.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define FLASH_BASE 0x00000000 diff --git a/hw/realview.c b/hw/realview.c index 9c55bf29b7..872b3b468a 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -13,10 +13,10 @@ #include "devices.h" #include "pci/pci.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "i2c.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #define SMP_BOOT_ADDR 0xe0000000 diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 19c31a02c6..c59ec6b6df 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -53,11 +53,11 @@ #include "hw.h" #include "pci/pci.h" -#include "dma.h" +#include "sysemu/dma.h" #include "qemu/timer.h" #include "net/net.h" #include "loader.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/iov.h" /* debug RTL8139 card */ diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c index 769015c136..963b4f0dc2 100644 --- a/hw/s390-virtio-bus.c +++ b/hw/s390-virtio-bus.c @@ -19,7 +19,7 @@ #include "hw.h" #include "block/block.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "monitor/monitor.h" #include "loader.h" @@ -29,7 +29,7 @@ #include "hw/virtio-serial.h" #include "hw/virtio-net.h" #include "hw/sysbus.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "hw/s390-virtio-bus.h" diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index 7dfe87ade3..20827761d0 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -19,8 +19,8 @@ #include "hw.h" #include "block/block.h" -#include "blockdev.h" -#include "sysemu.h" +#include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" #include "net/net.h" #include "boards.h" #include "monitor/monitor.h" @@ -28,7 +28,7 @@ #include "elf.h" #include "hw/virtio.h" #include "hw/sysbus.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "exec/address-spaces.h" #include "hw/s390-virtio-bus.h" diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 748118d0f0..89b1b66bd2 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -16,7 +16,7 @@ */ #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sclp.h" #include "event-facility.h" diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index bc9b0aeb00..7ad791d5e3 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -13,7 +13,7 @@ */ #include "cpu.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "exec/memory.h" #include "sclp.h" diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c index 9a773b87ff..6e6f5624df 100644 --- a/hw/s390x/sclpquiesce.c +++ b/hw/s390x/sclpquiesce.c @@ -12,7 +12,7 @@ * */ #include -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sclp.h" #include "event-facility.h" diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 5dc9f512b5..970c1fc01b 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -3,9 +3,9 @@ #include "scsi.h" #include "scsi-defs.h" #include "qdev.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "trace.h" -#include "dma.h" +#include "sysemu/dma.h" static char *scsibus_get_dev_path(DeviceState *dev); static char *scsibus_get_fw_dev_path(DeviceState *dev); diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index c65da4a9c9..a69735b0a6 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -32,10 +32,10 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while (0) #include "qemu/error-report.h" #include "scsi.h" #include "scsi-defs.h" -#include "sysemu.h" -#include "blockdev.h" +#include "sysemu/sysemu.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" -#include "dma.h" +#include "sysemu/dma.h" #ifdef __linux #include diff --git a/hw/scsi-generic.c b/hw/scsi-generic.c index faeb61ee2c..4c702be19f 100644 --- a/hw/scsi-generic.c +++ b/hw/scsi-generic.c @@ -14,7 +14,7 @@ #include "qemu-common.h" #include "qemu/error-report.h" #include "scsi.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #ifdef __linux__ diff --git a/hw/scsi.h b/hw/scsi.h index 24ed522722..a5b5b2ec0d 100644 --- a/hw/scsi.h +++ b/hw/scsi.h @@ -4,7 +4,7 @@ #include "qdev.h" #include "block/block.h" #include "hw/block-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define MAX_SCSI_DEVS 255 diff --git a/hw/serial.h b/hw/serial.h index 5722f8a353..98ee4241be 100644 --- a/hw/serial.h +++ b/hw/serial.h @@ -26,7 +26,7 @@ #define HW_SERIAL_H 1 #include "hw.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/memory.h" #define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */ diff --git a/hw/sga.c b/hw/sga.c index 5d80efd0c2..d5c91ed98e 100644 --- a/hw/sga.c +++ b/hw/sga.c @@ -27,7 +27,7 @@ #include "pci/pci.h" #include "pc.h" #include "loader.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define SGABIOS_FILENAME "sgabios.bin" diff --git a/hw/sh7750.c b/hw/sh7750.c index 08945750c4..666f8655ed 100644 --- a/hw/sh7750.c +++ b/hw/sh7750.c @@ -25,7 +25,7 @@ #include #include "hw.h" #include "sh.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sh7750_regs.h" #include "sh7750_regnames.h" #include "sh_intc.h" diff --git a/hw/shix.c b/hw/shix.c index 821196e84c..86d703ad70 100644 --- a/hw/shix.c +++ b/hw/shix.c @@ -29,7 +29,7 @@ */ #include "hw.h" #include "sh.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "loader.h" #include "exec/address-spaces.h" diff --git a/hw/slavio_misc.c b/hw/slavio_misc.c index 682fb457f5..704f2b173b 100644 --- a/hw/slavio_misc.c +++ b/hw/slavio_misc.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "sysbus.h" #include "trace.h" diff --git a/hw/smbios.c b/hw/smbios.c index c57237d279..a7b8bfc383 100644 --- a/hw/smbios.c +++ b/hw/smbios.c @@ -13,7 +13,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "smbios.h" #include "loader.h" diff --git a/hw/smbus_ich9.c b/hw/smbus_ich9.c index b7bddc80d3..16db3a743c 100644 --- a/hw/smbus_ich9.c +++ b/hw/smbus_ich9.c @@ -28,7 +28,7 @@ #include "pc.h" #include "pm_smbus.h" #include "pci/pci.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "i2c.h" #include "smbus.h" diff --git a/hw/spapr.c b/hw/spapr.c index 1abfde2a05..fdd1eb6925 100644 --- a/hw/spapr.c +++ b/hw/spapr.c @@ -24,13 +24,13 @@ * THE SOFTWARE. * */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw.h" #include "elf.h" #include "net/net.h" -#include "blockdev.h" -#include "cpus.h" -#include "kvm.h" +#include "sysemu/blockdev.h" +#include "sysemu/cpus.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" #include "hw/boards.h" @@ -43,7 +43,7 @@ #include "hw/xics.h" #include "hw/pci/msi.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" #include "pci/pci.h" diff --git a/hw/spapr.h b/hw/spapr.h index 600722f132..3a1f69f2a9 100644 --- a/hw/spapr.h +++ b/hw/spapr.h @@ -1,7 +1,7 @@ #if !defined(__HW_SPAPR_H__) #define __HW_SPAPR_H__ -#include "dma.h" +#include "sysemu/dma.h" #include "hw/xics.h" struct VIOsPAPRBus; diff --git a/hw/spapr_events.c b/hw/spapr_events.c index 18ccd4a9e0..7956601466 100644 --- a/hw/spapr_events.c +++ b/hw/spapr_events.c @@ -25,10 +25,10 @@ * */ #include "cpu.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-char.h" #include "hw/qdev.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "hw/spapr.h" #include "hw/spapr_vio.h" diff --git a/hw/spapr_hcall.c b/hw/spapr_hcall.c index 1fac362329..afb12973f2 100644 --- a/hw/spapr_hcall.c +++ b/hw/spapr_hcall.c @@ -1,6 +1,6 @@ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "cpu.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "helper_regs.h" #include "hw/spapr.h" diff --git a/hw/spapr_iommu.c b/hw/spapr_iommu.c index fb968b250b..d8a098cb1b 100644 --- a/hw/spapr_iommu.c +++ b/hw/spapr_iommu.c @@ -17,10 +17,10 @@ * License along with this library; if not, see . */ #include "hw.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "qdev.h" #include "kvm_ppc.h" -#include "dma.h" +#include "sysemu/dma.h" #include "exec/address-spaces.h" #include "hw/spapr.h" diff --git a/hw/spapr_nvram.c b/hw/spapr_nvram.c index 512bb8d5d1..f20f6b4fdd 100644 --- a/hw/spapr_nvram.c +++ b/hw/spapr_nvram.c @@ -24,7 +24,7 @@ #include #include -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "hw/sysbus.h" #include "hw/spapr.h" #include "hw/spapr_vio.h" diff --git a/hw/spapr_rtas.c b/hw/spapr_rtas.c index e618c2db53..d29736285c 100644 --- a/hw/spapr_rtas.c +++ b/hw/spapr_rtas.c @@ -25,10 +25,10 @@ * */ #include "cpu.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-char.h" #include "hw/qdev.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "hw/spapr.h" #include "hw/spapr_vio.h" diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c index fdf8db9158..a58621d17e 100644 --- a/hw/spapr_vio.c +++ b/hw/spapr_vio.c @@ -20,14 +20,14 @@ */ #include "hw.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "monitor/monitor.h" #include "loader.h" #include "elf.h" #include "hw/sysbus.h" -#include "kvm.h" -#include "device_tree.h" +#include "sysemu/kvm.h" +#include "sysemu/device_tree.h" #include "kvm_ppc.h" #include "hw/spapr.h" diff --git a/hw/spapr_vio.h b/hw/spapr_vio.h index cc85d26101..f98ec0a2e5 100644 --- a/hw/spapr_vio.h +++ b/hw/spapr_vio.h @@ -21,7 +21,7 @@ * License along with this library; if not, see . */ -#include "dma.h" +#include "sysemu/dma.h" #define TYPE_VIO_SPAPR_DEVICE "vio-spapr-device" #define VIO_SPAPR_DEVICE(obj) \ diff --git a/hw/spitz.c b/hw/spitz.c index 1259e32974..8e1be7fb21 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -13,7 +13,7 @@ #include "hw.h" #include "pxa.h" #include "arm-misc.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "pcmcia.h" #include "i2c.h" #include "ssi.h" @@ -25,7 +25,7 @@ #include "block/block.h" #include "audio/audio.h" #include "boards.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "exec/address-spaces.h" diff --git a/hw/ssi-sd.c b/hw/ssi-sd.c index c5505ee24f..d61c3328d9 100644 --- a/hw/ssi-sd.c +++ b/hw/ssi-sd.c @@ -10,7 +10,7 @@ * GNU GPL, version 2 or (at your option) any later version. */ -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "ssi.h" #include "sd.h" diff --git a/hw/strongarm.c b/hw/strongarm.c index f776fee3bc..5d5f454b1d 100644 --- a/hw/strongarm.c +++ b/hw/strongarm.c @@ -31,7 +31,7 @@ #include "qemu/error-report.h" #include "arm-misc.h" #include "qemu-char.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "ssi.h" //#define DEBUG diff --git a/hw/sun4m.c b/hw/sun4m.c index 4245854949..0d84b373b1 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -27,7 +27,7 @@ #include "nvram.h" #include "sparc32_dma.h" #include "fdc.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "net/net.h" #include "boards.h" #include "firmware_abi.h" @@ -40,7 +40,7 @@ #include "qdev-addr.h" #include "loader.h" #include "elf.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "trace.h" /* diff --git a/hw/sun4u.c b/hw/sun4u.c index 8bca4fdff9..cbfd217587 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -30,7 +30,7 @@ #include "fdc.h" #include "net/net.h" #include "qemu/timer.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "firmware_abi.h" #include "fw_cfg.h" @@ -38,7 +38,7 @@ #include "ide.h" #include "loader.h" #include "elf.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" //#define DEBUG_IRQ diff --git a/hw/tc6393xb.c b/hw/tc6393xb.c index edf76817b5..e815f83198 100644 --- a/hw/tc6393xb.c +++ b/hw/tc6393xb.c @@ -15,7 +15,7 @@ #include "flash.h" #include "ui/console.h" #include "ui/pixel_ops.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #define IRQ_TC6393_NAND 0 #define IRQ_TC6393_MMC 1 diff --git a/hw/tosa.c b/hw/tosa.c index 6fdbec53ee..6ee4693840 100644 --- a/hw/tosa.c +++ b/hw/tosa.c @@ -21,7 +21,7 @@ #include "boards.h" #include "i2c.h" #include "ssi.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "sysbus.h" #include "exec/address-spaces.h" diff --git a/hw/twl92230.c b/hw/twl92230.c index 3210b9ef4e..c71e4a2af0 100644 --- a/hw/twl92230.c +++ b/hw/twl92230.c @@ -22,7 +22,7 @@ #include "hw.h" #include "qemu/timer.h" #include "i2c.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "ui/console.h" #define VERBOSE 1 diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 74728c94e5..10260a13ac 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -1,7 +1,7 @@ #include "hw/hw.h" #include "hw/usb.h" #include "hw/qdev.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "trace.h" diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index e8ada9f02c..1c54863452 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -29,7 +29,7 @@ #include "net/net.h" #include "qemu/queue.h" #include "qemu/config-file.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/iov.h" /*#define TRAFFIC_DEBUG*/ diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index 6d27bac94f..5025597673 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -15,8 +15,8 @@ #include "hw/scsi.h" #include "ui/console.h" #include "monitor/monitor.h" -#include "sysemu.h" -#include "blockdev.h" +#include "sysemu/sysemu.h" +#include "sysemu/blockdev.h" //#define DEBUG_MSD diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 5bc80031bf..e35144d386 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -22,8 +22,8 @@ #include "hw/usb.h" #include "monitor/monitor.h" #include "trace.h" -#include "dma.h" -#include "sysemu.h" +#include "sysemu/dma.h" +#include "sysemu/sysemu.h" #ifndef EHCI_DEBUG #define EHCI_DEBUG 0 diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index c9b8a31465..2af754b5cf 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -30,7 +30,7 @@ #include "hw/pci/pci.h" #include "qemu/timer.h" #include "qemu/iov.h" -#include "dma.h" +#include "sysemu/dma.h" #include "trace.h" //#define DEBUG diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index 9a8c26ceaf..669fbd245c 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -33,7 +33,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" #include diff --git a/hw/usb/libhw.c b/hw/usb/libhw.c index 672d7a5598..75f022f4ec 100644 --- a/hw/usb/libhw.c +++ b/hw/usb/libhw.c @@ -22,7 +22,7 @@ #include "qemu-common.h" #include "exec/cpu-common.h" #include "hw/usb.h" -#include "dma.h" +#include "sysemu/dma.h" int usb_packet_map(USBPacket *p, QEMUSGList *sgl) { diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 31e5f27595..b65e8682b6 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -28,7 +28,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/iov.h" #include diff --git a/hw/versatilepb.c b/hw/versatilepb.c index bd9c01564a..5e89e747a2 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -11,11 +11,11 @@ #include "arm-misc.h" #include "devices.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "pci/pci.h" #include "i2c.h" #include "boards.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "exec/address-spaces.h" #include "flash.h" diff --git a/hw/vexpress.c b/hw/vexpress.c index e7b9e93852..93c3176667 100644 --- a/hw/vexpress.c +++ b/hw/vexpress.c @@ -26,10 +26,10 @@ #include "primecell.h" #include "devices.h" #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "exec/address-spaces.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "flash.h" #define VEXPRESS_BOARD_ID 0x8e0 diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index 9f204bc113..41fb7ad1de 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -29,7 +29,7 @@ #include "config.h" #include "qemu/event_notifier.h" #include "exec/address-spaces.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "exec/memory.h" #include "pci/msi.h" #include "pci/msix.h" diff --git a/hw/virtex_ml507.c b/hw/virtex_ml507.c index 5134e2f477..5238c7cbd6 100644 --- a/hw/virtex_ml507.c +++ b/hw/virtex_ml507.c @@ -26,10 +26,10 @@ #include "hw.h" #include "serial.h" #include "flash.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "devices.h" #include "boards.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #include "loader.h" #include "elf.h" #include "qemu/log.h" @@ -39,7 +39,7 @@ #include "ppc4xx.h" #include "ppc405.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "xilinx.h" #define EPAPR_MAGIC (0x45504150) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index 2eb709b422..3040bc63ab 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -18,9 +18,9 @@ #include "virtio.h" #include "pc.h" #include "cpu.h" -#include "balloon.h" +#include "sysemu/balloon.h" #include "virtio-balloon.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "exec/address-spaces.h" #if defined(__linux__) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 208caa2642..90cfa246db 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -15,7 +15,7 @@ #include "qemu/error-report.h" #include "trace.h" #include "hw/block-common.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "virtio-blk.h" #include "scsi-defs.h" #ifdef __linux__ diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index f58917f75f..d2d2454493 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -27,8 +27,8 @@ #include "pci/msi.h" #include "pci/msix.h" #include "loader.h" -#include "kvm.h" -#include "blockdev.h" +#include "sysemu/kvm.h" +#include "sysemu/blockdev.h" #include "virtio-pci.h" #include "qemu/range.h" diff --git a/hw/virtio.h b/hw/virtio.h index 511a16992e..541600484e 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -17,7 +17,7 @@ #include "hw.h" #include "net/net.h" #include "qdev.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/event_notifier.h" #ifdef CONFIG_LINUX #include "9p.h" diff --git a/hw/vmport.c b/hw/vmport.c index 3ab3a1405c..7d425237ac 100644 --- a/hw/vmport.c +++ b/hw/vmport.c @@ -24,7 +24,7 @@ #include "hw.h" #include "isa.h" #include "pc.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "qdev.h" //#define VMPORT_DEBUG diff --git a/hw/vt82c686.c b/hw/vt82c686.c index a18aaed217..d3469d49f1 100644 --- a/hw/vt82c686.c +++ b/hw/vt82c686.c @@ -22,7 +22,7 @@ #include "apm.h" #include "acpi.h" #include "pm_smbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" #include "exec/address-spaces.h" diff --git a/hw/watchdog.c b/hw/watchdog.c index 5b04215374..072d256882 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -25,7 +25,7 @@ #include "qemu/queue.h" #include "qapi/qmp/types.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw/watchdog.h" /* Possible values for action parameter. */ diff --git a/hw/xen_backend.h b/hw/xen_backend.h index 92ab501d37..f37afb1f05 100644 --- a/hw/xen_backend.h +++ b/hw/xen_backend.h @@ -2,7 +2,7 @@ #define QEMU_HW_XEN_BACKEND_H 1 #include "xen_common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "net/net.h" /* ------------------------------------------------------------- */ diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c index d83e8d0f64..e2ba741d54 100644 --- a/hw/xen_devconfig.c +++ b/hw/xen_devconfig.c @@ -1,5 +1,5 @@ #include "xen_backend.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" /* ------------------------------------------------------------- */ diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 423b580cff..a6a64a2455 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -38,7 +38,7 @@ #include "hw.h" #include "xen_backend.h" #include "xen_blkif.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" /* ------------------------------------------------------------- */ diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c index 426470351e..9feecd5a27 100644 --- a/hw/xen_machine_pv.c +++ b/hw/xen_machine_pv.c @@ -27,7 +27,7 @@ #include "boards.h" #include "xen_backend.h" #include "xen_domainbuild.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" static void xen_init_pv(QEMUMachineInitArgs *args) { diff --git a/hw/xilinx_spi.c b/hw/xilinx_spi.c index 4eed1828e3..77f9178008 100644 --- a/hw/xilinx_spi.c +++ b/hw/xilinx_spi.c @@ -25,7 +25,7 @@ */ #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/log.h" #include "fifo.h" diff --git a/hw/xilinx_spips.c b/hw/xilinx_spips.c index ebe375e56f..42e019dc05 100644 --- a/hw/xilinx_spips.c +++ b/hw/xilinx_spips.c @@ -23,7 +23,7 @@ */ #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "ptimer.h" #include "qemu/log.h" #include "fifo.h" diff --git a/hw/xilinx_zynq.c b/hw/xilinx_zynq.c index 156648a5d1..da0a7d0aa1 100644 --- a/hw/xilinx_zynq.c +++ b/hw/xilinx_zynq.c @@ -19,10 +19,10 @@ #include "arm-misc.h" #include "net/net.h" #include "exec/address-spaces.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "loader.h" #include "ssi.h" diff --git a/hw/xtensa_lx60.c b/hw/xtensa_lx60.c index c6c880eba5..9c7bb75f81 100644 --- a/hw/xtensa_lx60.c +++ b/hw/xtensa_lx60.c @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "loader.h" #include "elf.h" @@ -35,7 +35,7 @@ #include "net/net.h" #include "sysbus.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qemu-char.h" #include "xtensa_bootparam.h" diff --git a/hw/xtensa_sim.c b/hw/xtensa_sim.c index 29b5f22a18..14fe85b2fc 100644 --- a/hw/xtensa_sim.c +++ b/hw/xtensa_sim.c @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "boards.h" #include "loader.h" #include "elf.h" diff --git a/hw/z2.c b/hw/z2.c index ec35f3e444..09b03687d1 100644 --- a/hw/z2.c +++ b/hw/z2.c @@ -18,9 +18,9 @@ #include "i2c.h" #include "ssi.h" #include "boards.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "flash.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "ui/console.h" #include "audio/audio.h" #include "exec/address-spaces.h" diff --git a/hw/zynq_slcr.c b/hw/zynq_slcr.c index c7ce51f4a6..97ec578262 100644 --- a/hw/zynq_slcr.c +++ b/hw/zynq_slcr.c @@ -17,7 +17,7 @@ #include "hw.h" #include "qemu/timer.h" #include "sysbus.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #ifdef ZYNQ_ARM_SLCR_ERR_DEBUG #define DB_PRINT(...) do { \ diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h new file mode 100644 index 0000000000..5fc780c63d --- /dev/null +++ b/include/sysemu/arch_init.h @@ -0,0 +1,39 @@ +#ifndef QEMU_ARCH_INIT_H +#define QEMU_ARCH_INIT_H + +#include "qmp-commands.h" + +enum { + QEMU_ARCH_ALL = -1, + QEMU_ARCH_ALPHA = 1, + QEMU_ARCH_ARM = 2, + QEMU_ARCH_CRIS = 4, + QEMU_ARCH_I386 = 8, + QEMU_ARCH_M68K = 16, + QEMU_ARCH_LM32 = 32, + QEMU_ARCH_MICROBLAZE = 64, + QEMU_ARCH_MIPS = 128, + QEMU_ARCH_PPC = 256, + QEMU_ARCH_S390X = 512, + QEMU_ARCH_SH4 = 1024, + QEMU_ARCH_SPARC = 2048, + QEMU_ARCH_XTENSA = 4096, + QEMU_ARCH_OPENRISC = 8192, + QEMU_ARCH_UNICORE32 = 0x4000, +}; + +extern const uint32_t arch_type; + +void select_soundhw(const char *optarg); +void do_acpitable_option(const char *optarg); +void do_smbios_option(const char *optarg); +void cpudef_init(void); +int audio_available(void); +void audio_init(ISABus *isa_bus, PCIBus *pci_bus); +int tcg_available(void); +int kvm_available(void); +int xen_available(void); + +CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp); + +#endif diff --git a/include/sysemu/balloon.h b/include/sysemu/balloon.h new file mode 100644 index 0000000000..bd9d39505d --- /dev/null +++ b/include/sysemu/balloon.h @@ -0,0 +1,29 @@ +/* + * Balloon + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef _QEMU_BALLOON_H +#define _QEMU_BALLOON_H + +#include "monitor/monitor.h" +#include "qapi-types.h" + +typedef void (QEMUBalloonEvent)(void *opaque, ram_addr_t target); +typedef void (QEMUBalloonStatus)(void *opaque, BalloonInfo *info); + +int qemu_add_balloon_handler(QEMUBalloonEvent *event_func, + QEMUBalloonStatus *stat_func, void *opaque); +void qemu_remove_balloon_handler(void *opaque); + +void qemu_balloon_changed(int64_t actual); + +#endif diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h new file mode 100644 index 0000000000..1fe533299e --- /dev/null +++ b/include/sysemu/blockdev.h @@ -0,0 +1,69 @@ +/* + * QEMU host block devices + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#ifndef BLOCKDEV_H +#define BLOCKDEV_H + +#include "block/block.h" +#include "qapi/error.h" +#include "qemu/queue.h" + +void blockdev_mark_auto_del(BlockDriverState *bs); +void blockdev_auto_del(BlockDriverState *bs); + +typedef enum { + IF_DEFAULT = -1, /* for use with drive_add() only */ + /* + * IF_IDE must be zero, because we want QEMUMachine member + * block_default_type to default-initialize to IF_IDE + */ + IF_IDE = 0, + IF_NONE, + IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, + IF_COUNT +} BlockInterfaceType; + +struct DriveInfo { + BlockDriverState *bdrv; + char *id; + const char *devaddr; + BlockInterfaceType type; + int bus; + int unit; + int auto_del; /* see blockdev_mark_auto_del() */ + int media_cd; + int cyls, heads, secs, trans; + QemuOpts *opts; + const char *serial; + QTAILQ_ENTRY(DriveInfo) next; + int refcount; +}; + +DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); +DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); +int drive_get_max_bus(BlockInterfaceType type); +DriveInfo *drive_get_next(BlockInterfaceType type); +void drive_get_ref(DriveInfo *dinfo); +void drive_put_ref(DriveInfo *dinfo); +DriveInfo *drive_get_by_blockdev(BlockDriverState *bs); + +QemuOpts *drive_def(const char *optstr); +QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, + const char *optstr); +DriveInfo *drive_init(QemuOpts *arg, BlockInterfaceType block_default_type); + +/* device-hotplug */ + +DriveInfo *add_init_drive(const char *opts); + +void qmp_change_blockdev(const char *device, const char *filename, + bool has_format, const char *format, Error **errp); +void do_commit(Monitor *mon, const QDict *qdict); +int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data); +#endif diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h new file mode 100644 index 0000000000..81bd81773f --- /dev/null +++ b/include/sysemu/cpus.h @@ -0,0 +1,24 @@ +#ifndef QEMU_CPUS_H +#define QEMU_CPUS_H + +/* cpus.c */ +void qemu_init_cpu_loop(void); +void resume_all_vcpus(void); +void pause_all_vcpus(void); +void cpu_stop_current(void); + +void cpu_synchronize_all_states(void); +void cpu_synchronize_all_post_reset(void); +void cpu_synchronize_all_post_init(void); + +void qtest_clock_warp(int64_t dest); + +/* vl.c */ +extern int smp_cores; +extern int smp_threads; +void set_numa_modes(void); +void set_cpu_log(const char *optarg); +void set_cpu_log_filename(const char *optarg); +void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg); + +#endif diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h new file mode 100644 index 0000000000..f0b3f35e03 --- /dev/null +++ b/include/sysemu/device_tree.h @@ -0,0 +1,54 @@ +/* + * Header with function prototypes to help device tree manipulation using + * libfdt. It also provides functions to read entries from device tree proc + * interface. + * + * Copyright 2008 IBM Corporation. + * Authors: Jerone Young + * Hollis Blanchard + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#ifndef __DEVICE_TREE_H__ +#define __DEVICE_TREE_H__ + +void *create_device_tree(int *sizep); +void *load_device_tree(const char *filename_path, int *sizep); + +int qemu_devtree_setprop(void *fdt, const char *node_path, + const char *property, const void *val_array, int size); +int qemu_devtree_setprop_cell(void *fdt, const char *node_path, + const char *property, uint32_t val); +int qemu_devtree_setprop_u64(void *fdt, const char *node_path, + const char *property, uint64_t val); +int qemu_devtree_setprop_string(void *fdt, const char *node_path, + const char *property, const char *string); +int qemu_devtree_setprop_phandle(void *fdt, const char *node_path, + const char *property, + const char *target_node_path); +const void *qemu_devtree_getprop(void *fdt, const char *node_path, + const char *property, int *lenp); +uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path, + const char *property); +uint32_t qemu_devtree_get_phandle(void *fdt, const char *path); +uint32_t qemu_devtree_alloc_phandle(void *fdt); +int qemu_devtree_nop_node(void *fdt, const char *node_path); +int qemu_devtree_add_subnode(void *fdt, const char *name); + +#define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \ + do { \ + uint32_t qdt_tmp[] = { __VA_ARGS__ }; \ + int i; \ + \ + for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \ + qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \ + } \ + qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \ + sizeof(qdt_tmp)); \ + } while (0) + +void qemu_devtree_dumpdtb(void *fdt, int size); + +#endif /* __DEVICE_TREE_H__ */ diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h new file mode 100644 index 0000000000..a52c93a553 --- /dev/null +++ b/include/sysemu/dma.h @@ -0,0 +1,282 @@ +/* + * DMA helper functions + * + * Copyright (c) 2009 Red Hat + * + * This work is licensed under the terms of the GNU General Public License + * (GNU GPL), version 2 or later. + */ + +#ifndef DMA_H +#define DMA_H + +#include +#include "exec/memory.h" +#include "hw/hw.h" +#include "block/block.h" +#include "sysemu/kvm.h" + +typedef struct DMAContext DMAContext; +typedef struct ScatterGatherEntry ScatterGatherEntry; + +typedef enum { + DMA_DIRECTION_TO_DEVICE = 0, + DMA_DIRECTION_FROM_DEVICE = 1, +} DMADirection; + +struct QEMUSGList { + ScatterGatherEntry *sg; + int nsg; + int nalloc; + size_t size; + DMAContext *dma; +}; + +#ifndef CONFIG_USER_ONLY + +/* + * When an IOMMU is present, bus addresses become distinct from + * CPU/memory physical addresses and may be a different size. Because + * the IOVA size depends more on the bus than on the platform, we more + * or less have to treat these as 64-bit always to cover all (or at + * least most) cases. + */ +typedef uint64_t dma_addr_t; + +#define DMA_ADDR_BITS 64 +#define DMA_ADDR_FMT "%" PRIx64 + +typedef int DMATranslateFunc(DMAContext *dma, + dma_addr_t addr, + hwaddr *paddr, + hwaddr *len, + DMADirection dir); +typedef void* DMAMapFunc(DMAContext *dma, + dma_addr_t addr, + dma_addr_t *len, + DMADirection dir); +typedef void DMAUnmapFunc(DMAContext *dma, + void *buffer, + dma_addr_t len, + DMADirection dir, + dma_addr_t access_len); + +struct DMAContext { + AddressSpace *as; + DMATranslateFunc *translate; + DMAMapFunc *map; + DMAUnmapFunc *unmap; +}; + +/* A global DMA context corresponding to the address_space_memory + * AddressSpace, for sysbus devices which do DMA. + */ +extern DMAContext dma_context_memory; + +static inline void dma_barrier(DMAContext *dma, DMADirection dir) +{ + /* + * This is called before DMA read and write operations + * unless the _relaxed form is used and is responsible + * for providing some sane ordering of accesses vs + * concurrently running VCPUs. + * + * Users of map(), unmap() or lower level st/ld_* + * operations are responsible for providing their own + * ordering via barriers. + * + * This primitive implementation does a simple smp_mb() + * before each operation which provides pretty much full + * ordering. + * + * A smarter implementation can be devised if needed to + * use lighter barriers based on the direction of the + * transfer, the DMA context, etc... + */ + if (kvm_enabled()) { + smp_mb(); + } +} + +static inline bool dma_has_iommu(DMAContext *dma) +{ + return dma && dma->translate; +} + +/* Checks that the given range of addresses is valid for DMA. This is + * useful for certain cases, but usually you should just use + * dma_memory_{read,write}() and check for errors */ +bool iommu_dma_memory_valid(DMAContext *dma, dma_addr_t addr, dma_addr_t len, + DMADirection dir); +static inline bool dma_memory_valid(DMAContext *dma, + dma_addr_t addr, dma_addr_t len, + DMADirection dir) +{ + if (!dma_has_iommu(dma)) { + return true; + } else { + return iommu_dma_memory_valid(dma, addr, len, dir); + } +} + +int iommu_dma_memory_rw(DMAContext *dma, dma_addr_t addr, + void *buf, dma_addr_t len, DMADirection dir); +static inline int dma_memory_rw_relaxed(DMAContext *dma, dma_addr_t addr, + void *buf, dma_addr_t len, + DMADirection dir) +{ + if (!dma_has_iommu(dma)) { + /* Fast-path for no IOMMU */ + address_space_rw(dma->as, addr, buf, len, dir == DMA_DIRECTION_FROM_DEVICE); + return 0; + } else { + return iommu_dma_memory_rw(dma, addr, buf, len, dir); + } +} + +static inline int dma_memory_read_relaxed(DMAContext *dma, dma_addr_t addr, + void *buf, dma_addr_t len) +{ + return dma_memory_rw_relaxed(dma, addr, buf, len, DMA_DIRECTION_TO_DEVICE); +} + +static inline int dma_memory_write_relaxed(DMAContext *dma, dma_addr_t addr, + const void *buf, dma_addr_t len) +{ + return dma_memory_rw_relaxed(dma, addr, (void *)buf, len, + DMA_DIRECTION_FROM_DEVICE); +} + +static inline int dma_memory_rw(DMAContext *dma, dma_addr_t addr, + void *buf, dma_addr_t len, + DMADirection dir) +{ + dma_barrier(dma, dir); + + return dma_memory_rw_relaxed(dma, addr, buf, len, dir); +} + +static inline int dma_memory_read(DMAContext *dma, dma_addr_t addr, + void *buf, dma_addr_t len) +{ + return dma_memory_rw(dma, addr, buf, len, DMA_DIRECTION_TO_DEVICE); +} + +static inline int dma_memory_write(DMAContext *dma, dma_addr_t addr, + const void *buf, dma_addr_t len) +{ + return dma_memory_rw(dma, addr, (void *)buf, len, + DMA_DIRECTION_FROM_DEVICE); +} + +int iommu_dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c, + dma_addr_t len); + +int dma_memory_set(DMAContext *dma, dma_addr_t addr, uint8_t c, dma_addr_t len); + +void *iommu_dma_memory_map(DMAContext *dma, + dma_addr_t addr, dma_addr_t *len, + DMADirection dir); +static inline void *dma_memory_map(DMAContext *dma, + dma_addr_t addr, dma_addr_t *len, + DMADirection dir) +{ + if (!dma_has_iommu(dma)) { + hwaddr xlen = *len; + void *p; + + p = address_space_map(dma->as, addr, &xlen, dir == DMA_DIRECTION_FROM_DEVICE); + *len = xlen; + return p; + } else { + return iommu_dma_memory_map(dma, addr, len, dir); + } +} + +void iommu_dma_memory_unmap(DMAContext *dma, + void *buffer, dma_addr_t len, + DMADirection dir, dma_addr_t access_len); +static inline void dma_memory_unmap(DMAContext *dma, + void *buffer, dma_addr_t len, + DMADirection dir, dma_addr_t access_len) +{ + if (!dma_has_iommu(dma)) { + address_space_unmap(dma->as, buffer, (hwaddr)len, + dir == DMA_DIRECTION_FROM_DEVICE, access_len); + } else { + iommu_dma_memory_unmap(dma, buffer, len, dir, access_len); + } +} + +#define DEFINE_LDST_DMA(_lname, _sname, _bits, _end) \ + static inline uint##_bits##_t ld##_lname##_##_end##_dma(DMAContext *dma, \ + dma_addr_t addr) \ + { \ + uint##_bits##_t val; \ + dma_memory_read(dma, addr, &val, (_bits) / 8); \ + return _end##_bits##_to_cpu(val); \ + } \ + static inline void st##_sname##_##_end##_dma(DMAContext *dma, \ + dma_addr_t addr, \ + uint##_bits##_t val) \ + { \ + val = cpu_to_##_end##_bits(val); \ + dma_memory_write(dma, addr, &val, (_bits) / 8); \ + } + +static inline uint8_t ldub_dma(DMAContext *dma, dma_addr_t addr) +{ + uint8_t val; + + dma_memory_read(dma, addr, &val, 1); + return val; +} + +static inline void stb_dma(DMAContext *dma, dma_addr_t addr, uint8_t val) +{ + dma_memory_write(dma, addr, &val, 1); +} + +DEFINE_LDST_DMA(uw, w, 16, le); +DEFINE_LDST_DMA(l, l, 32, le); +DEFINE_LDST_DMA(q, q, 64, le); +DEFINE_LDST_DMA(uw, w, 16, be); +DEFINE_LDST_DMA(l, l, 32, be); +DEFINE_LDST_DMA(q, q, 64, be); + +#undef DEFINE_LDST_DMA + +void dma_context_init(DMAContext *dma, AddressSpace *as, DMATranslateFunc translate, + DMAMapFunc map, DMAUnmapFunc unmap); + +struct ScatterGatherEntry { + dma_addr_t base; + dma_addr_t len; +}; + +void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint, DMAContext *dma); +void qemu_sglist_add(QEMUSGList *qsg, dma_addr_t base, dma_addr_t len); +void qemu_sglist_destroy(QEMUSGList *qsg); +#endif + +typedef BlockDriverAIOCB *DMAIOFunc(BlockDriverState *bs, int64_t sector_num, + QEMUIOVector *iov, int nb_sectors, + BlockDriverCompletionFunc *cb, void *opaque); + +BlockDriverAIOCB *dma_bdrv_io(BlockDriverState *bs, + QEMUSGList *sg, uint64_t sector_num, + DMAIOFunc *io_func, BlockDriverCompletionFunc *cb, + void *opaque, DMADirection dir); +BlockDriverAIOCB *dma_bdrv_read(BlockDriverState *bs, + QEMUSGList *sg, uint64_t sector, + BlockDriverCompletionFunc *cb, void *opaque); +BlockDriverAIOCB *dma_bdrv_write(BlockDriverState *bs, + QEMUSGList *sg, uint64_t sector, + BlockDriverCompletionFunc *cb, void *opaque); +uint64_t dma_buf_read(uint8_t *ptr, int32_t len, QEMUSGList *sg); +uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg); + +void dma_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, + QEMUSGList *sg, enum BlockAcctType type); + +#endif diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h new file mode 100644 index 0000000000..e25b7cfb73 --- /dev/null +++ b/include/sysemu/dump.h @@ -0,0 +1,35 @@ +/* + * QEMU dump + * + * Copyright Fujitsu, Corp. 2011, 2012 + * + * Authors: + * Wen Congyang + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef DUMP_H +#define DUMP_H + +typedef struct ArchDumpInfo { + int d_machine; /* Architecture */ + int d_endian; /* ELFDATA2LSB or ELFDATA2MSB */ + int d_class; /* ELFCLASS32 or ELFCLASS64 */ +} ArchDumpInfo; + +typedef int (*write_core_dump_function)(void *buf, size_t size, void *opaque); +int cpu_write_elf64_note(write_core_dump_function f, CPUArchState *env, + int cpuid, void *opaque); +int cpu_write_elf32_note(write_core_dump_function f, CPUArchState *env, + int cpuid, void *opaque); +int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env, + void *opaque); +int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env, + void *opaque); +int cpu_get_dump_info(ArchDumpInfo *info); +ssize_t cpu_get_note_size(int class, int machine, int nr_cpus); + +#endif diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h new file mode 100644 index 0000000000..131d2bdc15 --- /dev/null +++ b/include/sysemu/kvm.h @@ -0,0 +1,280 @@ +/* + * QEMU KVM support + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_KVM_H +#define QEMU_KVM_H + +#include +#include "config-host.h" +#include "qemu/queue.h" + +#ifdef CONFIG_KVM +#include +#include +#endif + +extern int kvm_allowed; +extern bool kvm_kernel_irqchip; +extern bool kvm_async_interrupts_allowed; +extern bool kvm_irqfds_allowed; +extern bool kvm_msi_via_irqfd_allowed; +extern bool kvm_gsi_routing_allowed; + +#if defined CONFIG_KVM || !defined NEED_CPU_H +#define kvm_enabled() (kvm_allowed) +/** + * kvm_irqchip_in_kernel: + * + * Returns: true if the user asked us to create an in-kernel + * irqchip via the "kernel_irqchip=on" machine option. + * What this actually means is architecture and machine model + * specific: on PC, for instance, it means that the LAPIC, + * IOAPIC and PIT are all in kernel. This function should never + * be used from generic target-independent code: use one of the + * following functions or some other specific check instead. + */ +#define kvm_irqchip_in_kernel() (kvm_kernel_irqchip) + +/** + * kvm_async_interrupts_enabled: + * + * Returns: true if we can deliver interrupts to KVM + * asynchronously (ie by ioctl from any thread at any time) + * rather than having to do interrupt delivery synchronously + * (where the vcpu must be stopped at a suitable point first). + */ +#define kvm_async_interrupts_enabled() (kvm_async_interrupts_allowed) + +/** + * kvm_irqfds_enabled: + * + * Returns: true if we can use irqfds to inject interrupts into + * a KVM CPU (ie the kernel supports irqfds and we are running + * with a configuration where it is meaningful to use them). + */ +#define kvm_irqfds_enabled() (kvm_irqfds_allowed) + +/** + * kvm_msi_via_irqfd_enabled: + * + * Returns: true if we can route a PCI MSI (Message Signaled Interrupt) + * to a KVM CPU via an irqfd. This requires that the kernel supports + * this and that we're running in a configuration that permits it. + */ +#define kvm_msi_via_irqfd_enabled() (kvm_msi_via_irqfd_allowed) + +/** + * kvm_gsi_routing_enabled: + * + * Returns: true if GSI routing is enabled (ie the kernel supports + * it and we're running in a configuration that permits it). + */ +#define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed) + +#else +#define kvm_enabled() (0) +#define kvm_irqchip_in_kernel() (false) +#define kvm_async_interrupts_enabled() (false) +#define kvm_irqfds_enabled() (false) +#define kvm_msi_via_irqfd_enabled() (false) +#define kvm_gsi_routing_allowed() (false) +#endif + +struct kvm_run; +struct kvm_lapic_state; + +typedef struct KVMCapabilityInfo { + const char *name; + int value; +} KVMCapabilityInfo; + +#define KVM_CAP_INFO(CAP) { "KVM_CAP_" stringify(CAP), KVM_CAP_##CAP } +#define KVM_CAP_LAST_INFO { NULL, 0 } + +struct KVMState; +typedef struct KVMState KVMState; +extern KVMState *kvm_state; + +/* external API */ + +int kvm_init(void); + +int kvm_has_sync_mmu(void); +int kvm_has_vcpu_events(void); +int kvm_has_robust_singlestep(void); +int kvm_has_debugregs(void); +int kvm_has_xsave(void); +int kvm_has_xcrs(void); +int kvm_has_pit_state2(void); +int kvm_has_many_ioeventfds(void); +int kvm_has_gsi_routing(void); +int kvm_has_intx_set_mask(void); + +#ifdef NEED_CPU_H +int kvm_init_vcpu(CPUArchState *env); + +int kvm_cpu_exec(CPUArchState *env); + +#if !defined(CONFIG_USER_ONLY) +void *kvm_vmalloc(ram_addr_t size); +void *kvm_arch_vmalloc(ram_addr_t size); +void kvm_setup_guest_memory(void *start, size_t size); + +void kvm_flush_coalesced_mmio_buffer(void); +#endif + +int kvm_insert_breakpoint(CPUArchState *current_env, target_ulong addr, + target_ulong len, int type); +int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr, + target_ulong len, int type); +void kvm_remove_all_breakpoints(CPUArchState *current_env); +int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap); +#ifndef _WIN32 +int kvm_set_signal_mask(CPUArchState *env, const sigset_t *sigset); +#endif + +int kvm_on_sigbus_vcpu(CPUArchState *env, int code, void *addr); +int kvm_on_sigbus(int code, void *addr); + +/* internal API */ + +int kvm_ioctl(KVMState *s, int type, ...); + +int kvm_vm_ioctl(KVMState *s, int type, ...); + +int kvm_vcpu_ioctl(CPUArchState *env, int type, ...); + +/* Arch specific hooks */ + +extern const KVMCapabilityInfo kvm_arch_required_capabilities[]; + +void kvm_arch_pre_run(CPUArchState *env, struct kvm_run *run); +void kvm_arch_post_run(CPUArchState *env, struct kvm_run *run); + +int kvm_arch_handle_exit(CPUArchState *env, struct kvm_run *run); + +int kvm_arch_process_async_events(CPUArchState *env); + +int kvm_arch_get_registers(CPUArchState *env); + +/* state subset only touched by the VCPU itself during runtime */ +#define KVM_PUT_RUNTIME_STATE 1 +/* state subset modified during VCPU reset */ +#define KVM_PUT_RESET_STATE 2 +/* full state set, modified during initialization or on vmload */ +#define KVM_PUT_FULL_STATE 3 + +int kvm_arch_put_registers(CPUArchState *env, int level); + +int kvm_arch_init(KVMState *s); + +int kvm_arch_init_vcpu(CPUArchState *env); + +void kvm_arch_reset_vcpu(CPUArchState *env); + +int kvm_arch_on_sigbus_vcpu(CPUArchState *env, int code, void *addr); +int kvm_arch_on_sigbus(int code, void *addr); + +void kvm_arch_init_irq_routing(KVMState *s); + +int kvm_set_irq(KVMState *s, int irq, int level); +int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg); + +void kvm_irqchip_add_irq_route(KVMState *s, int gsi, int irqchip, int pin); + +void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic); +void kvm_get_apic_state(DeviceState *d, struct kvm_lapic_state *kapic); + +struct kvm_guest_debug; +struct kvm_debug_exit_arch; + +struct kvm_sw_breakpoint { + target_ulong pc; + target_ulong saved_insn; + int use_count; + QTAILQ_ENTRY(kvm_sw_breakpoint) entry; +}; + +QTAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); + +struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUArchState *env, + target_ulong pc); + +int kvm_sw_breakpoints_active(CPUArchState *env); + +int kvm_arch_insert_sw_breakpoint(CPUArchState *current_env, + struct kvm_sw_breakpoint *bp); +int kvm_arch_remove_sw_breakpoint(CPUArchState *current_env, + struct kvm_sw_breakpoint *bp); +int kvm_arch_insert_hw_breakpoint(target_ulong addr, + target_ulong len, int type); +int kvm_arch_remove_hw_breakpoint(target_ulong addr, + target_ulong len, int type); +void kvm_arch_remove_all_hw_breakpoints(void); + +void kvm_arch_update_guest_debug(CPUArchState *env, struct kvm_guest_debug *dbg); + +bool kvm_arch_stop_on_emulation_error(CPUArchState *env); + +int kvm_check_extension(KVMState *s, unsigned int extension); + +uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, + uint32_t index, int reg); +void kvm_cpu_synchronize_state(CPUArchState *env); +void kvm_cpu_synchronize_post_reset(CPUArchState *env); +void kvm_cpu_synchronize_post_init(CPUArchState *env); + +/* generic hooks - to be moved/refactored once there are more users */ + +static inline void cpu_synchronize_state(CPUArchState *env) +{ + if (kvm_enabled()) { + kvm_cpu_synchronize_state(env); + } +} + +static inline void cpu_synchronize_post_reset(CPUArchState *env) +{ + if (kvm_enabled()) { + kvm_cpu_synchronize_post_reset(env); + } +} + +static inline void cpu_synchronize_post_init(CPUArchState *env) +{ + if (kvm_enabled()) { + kvm_cpu_synchronize_post_init(env); + } +} + + +#if !defined(CONFIG_USER_ONLY) +int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr, + hwaddr *phys_addr); +#endif + +#endif +int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign, + uint32_t size); + +int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); + +int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg); +int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg); +void kvm_irqchip_release_virq(KVMState *s, int virq); + +int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int virq); +int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq); +void kvm_pc_gsi_handler(void *opaque, int n, int level); +void kvm_pc_setup_irq_routing(bool pci_enabled); +#endif diff --git a/include/sysemu/memory_mapping.h b/include/sysemu/memory_mapping.h new file mode 100644 index 0000000000..1256125963 --- /dev/null +++ b/include/sysemu/memory_mapping.h @@ -0,0 +1,64 @@ +/* + * QEMU memory mapping + * + * Copyright Fujitsu, Corp. 2011, 2012 + * + * Authors: + * Wen Congyang + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef MEMORY_MAPPING_H +#define MEMORY_MAPPING_H + +#include "qemu/queue.h" + +/* The physical and virtual address in the memory mapping are contiguous. */ +typedef struct MemoryMapping { + hwaddr phys_addr; + target_ulong virt_addr; + ram_addr_t length; + QTAILQ_ENTRY(MemoryMapping) next; +} MemoryMapping; + +typedef struct MemoryMappingList { + unsigned int num; + MemoryMapping *last_mapping; + QTAILQ_HEAD(, MemoryMapping) head; +} MemoryMappingList; + +int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); +bool cpu_paging_enabled(CPUArchState *env); + +/* + * add or merge the memory region [phys_addr, phys_addr + length) into the + * memory mapping's list. The region's virtual address starts with virt_addr, + * and is contiguous. The list is sorted by phys_addr. + */ +void memory_mapping_list_add_merge_sorted(MemoryMappingList *list, + hwaddr phys_addr, + hwaddr virt_addr, + ram_addr_t length); + +void memory_mapping_list_free(MemoryMappingList *list); + +void memory_mapping_list_init(MemoryMappingList *list); + +/* + * Return value: + * 0: success + * -1: failed + * -2: unsupported + */ +int qemu_get_guest_memory_mapping(MemoryMappingList *list); + +/* get guest's memory mapping without do paging(virtual address is 0). */ +void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); + +void memory_mapping_filter(MemoryMappingList *list, int64_t begin, + int64_t length); + +#endif diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h new file mode 100644 index 0000000000..7f198e475c --- /dev/null +++ b/include/sysemu/os-posix.h @@ -0,0 +1,51 @@ +/* + * posix specific declarations + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Jes Sorensen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OS_POSIX_H +#define QEMU_OS_POSIX_H + +void os_set_line_buffering(void); +void os_set_proc_name(const char *s); +void os_setup_signal_handling(void); +void os_daemonize(void); +void os_setup_post(void); + +typedef struct timeval qemu_timeval; +#define qemu_gettimeofday(tp) gettimeofday(tp, NULL) + +#ifndef CONFIG_UTIMENSAT +#ifndef UTIME_NOW +# define UTIME_NOW ((1l << 30) - 1l) +#endif +#ifndef UTIME_OMIT +# define UTIME_OMIT ((1l << 30) - 2l) +#endif +#endif +typedef struct timespec qemu_timespec; +int qemu_utimens(const char *path, const qemu_timespec *times); + +bool is_daemonized(void); + +#endif diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h new file mode 100644 index 0000000000..d0e9234d24 --- /dev/null +++ b/include/sysemu/os-win32.h @@ -0,0 +1,99 @@ +/* + * win32 specific declarations + * + * Copyright (c) 2003-2008 Fabrice Bellard + * Copyright (c) 2010 Jes Sorensen + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef QEMU_OS_WIN32_H +#define QEMU_OS_WIN32_H + +#include +#include + +/* Workaround for older versions of MinGW. */ +#ifndef ECONNREFUSED +# define ECONNREFUSED WSAECONNREFUSED +#endif +#ifndef EINPROGRESS +# define EINPROGRESS WSAEINPROGRESS +#endif +#ifndef EHOSTUNREACH +# define EHOSTUNREACH WSAEHOSTUNREACH +#endif +#ifndef EINTR +# define EINTR WSAEINTR +#endif +#ifndef EINPROGRESS +# define EINPROGRESS WSAEINPROGRESS +#endif +#ifndef ENETUNREACH +# define ENETUNREACH WSAENETUNREACH +#endif +#ifndef ENOTCONN +# define ENOTCONN WSAENOTCONN +#endif +#ifndef EWOULDBLOCK +# define EWOULDBLOCK WSAEWOULDBLOCK +#endif + +#if defined(_WIN64) +/* On w64, setjmp is implemented by _setjmp which needs a second parameter. + * If this parameter is NULL, longjump does no stack unwinding. + * That is what we need for QEMU. Passing the value of register rsp (default) + * lets longjmp try a stack unwinding which will crash with generated code. */ +# undef setjmp +# define setjmp(env) _setjmp(env, NULL) +#endif + +/* Declaration of ffs() is missing in MinGW's strings.h. */ +int ffs(int i); + +/* Missing POSIX functions. Don't use MinGW-w64 macros. */ +#undef gmtime_r +struct tm *gmtime_r(const time_t *timep, struct tm *result); +#undef localtime_r +struct tm *localtime_r(const time_t *timep, struct tm *result); + +static inline void os_setup_signal_handling(void) {} +static inline void os_daemonize(void) {} +static inline void os_setup_post(void) {} +void os_set_line_buffering(void); +static inline void os_set_proc_name(const char *dummy) {} + +#if !defined(EPROTONOSUPPORT) +# define EPROTONOSUPPORT EINVAL +#endif + +int setenv(const char *name, const char *value, int overwrite); + +typedef struct { + long tv_sec; + long tv_usec; +} qemu_timeval; +int qemu_gettimeofday(qemu_timeval *tp); + +static inline bool is_daemonized(void) +{ + return false; +} + +#endif diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h new file mode 100644 index 0000000000..723a4f9536 --- /dev/null +++ b/include/sysemu/qtest.h @@ -0,0 +1,53 @@ +/* + * Test Server + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QTEST_H +#define QTEST_H + +#include "qemu-common.h" + +#if !defined(CONFIG_USER_ONLY) +extern int qtest_allowed; +extern const char *qtest_chrdev; +extern const char *qtest_log; + +static inline bool qtest_enabled(void) +{ + return qtest_allowed; +} + +static inline int qtest_available(void) +{ + return 1; +} + +int qtest_init(void); +#else +static inline bool qtest_enabled(void) +{ + return false; +} + +static inline int qtest_available(void) +{ + return 0; +} + +static inline int qtest_init(void) +{ + return 0; +} + +#endif + +#endif diff --git a/include/sysemu/seccomp.h b/include/sysemu/seccomp.h new file mode 100644 index 0000000000..1189fa241d --- /dev/null +++ b/include/sysemu/seccomp.h @@ -0,0 +1,22 @@ +/* + * QEMU seccomp mode 2 support with libseccomp + * + * Copyright IBM, Corp. 2012 + * + * Authors: + * Eduardo Otubo + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ +#ifndef QEMU_SECCOMP_H +#define QEMU_SECCOMP_H + +#include +#include "qemu/osdep.h" + +int seccomp_start(void); +#endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h new file mode 100644 index 0000000000..8eaa4707a0 --- /dev/null +++ b/include/sysemu/sysemu.h @@ -0,0 +1,185 @@ +#ifndef SYSEMU_H +#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" +#include "qapi-types.h" +#include "qemu/notify.h" +#include "qemu/main-loop.h" + +/* vl.c */ + +extern const char *bios_name; + +extern const char *qemu_name; +extern uint8_t qemu_uuid[]; +int qemu_uuid_parse(const char *str, uint8_t *uuid); +#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" + +bool runstate_check(RunState state); +void runstate_set(RunState new_state); +int runstate_is_running(void); +typedef struct vm_change_state_entry VMChangeStateEntry; +typedef void VMChangeStateHandler(void *opaque, int running, RunState state); + +VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, + void *opaque); +void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); +void vm_state_notify(int running, RunState state); + +#define VMRESET_SILENT false +#define VMRESET_REPORT true + +void vm_start(void); +void vm_stop(RunState state); +void vm_stop_force_state(RunState state); + +typedef enum WakeupReason { + QEMU_WAKEUP_REASON_OTHER = 0, + QEMU_WAKEUP_REASON_RTC, + QEMU_WAKEUP_REASON_PMTIMER, +} WakeupReason; + +void qemu_system_reset_request(void); +void qemu_system_suspend_request(void); +void qemu_register_suspend_notifier(Notifier *notifier); +void qemu_system_wakeup_request(WakeupReason reason); +void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); +void qemu_register_wakeup_notifier(Notifier *notifier); +void qemu_system_shutdown_request(void); +void qemu_system_powerdown_request(void); +void qemu_register_powerdown_notifier(Notifier *notifier); +void qemu_system_debug_request(void); +void qemu_system_vmstop_request(RunState reason); +int qemu_shutdown_requested_get(void); +int qemu_reset_requested_get(void); +void qemu_system_killed(int signal, pid_t pid); +void qemu_devices_reset(void); +void qemu_system_reset(bool report); + +void qemu_add_exit_notifier(Notifier *notify); +void qemu_remove_exit_notifier(Notifier *notify); + +void qemu_add_machine_init_done_notifier(Notifier *notify); + +void do_savevm(Monitor *mon, const QDict *qdict); +int load_vmstate(const char *name); +void do_delvm(Monitor *mon, const QDict *qdict); +void do_info_snapshots(Monitor *mon); + +void qemu_announce_self(void); + +bool qemu_savevm_state_blocked(Error **errp); +int qemu_savevm_state_begin(QEMUFile *f, + const MigrationParams *params); +int qemu_savevm_state_iterate(QEMUFile *f); +int qemu_savevm_state_complete(QEMUFile *f); +void qemu_savevm_state_cancel(QEMUFile *f); +int qemu_loadvm_state(QEMUFile *f); + +/* SLIRP */ +void do_info_slirp(Monitor *mon); + +typedef enum DisplayType +{ + DT_DEFAULT, + DT_CURSES, + DT_SDL, + DT_NOGRAPHIC, + DT_NONE, +} DisplayType; + +extern int autostart; +extern int bios_size; + +typedef enum { + VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL, +} VGAInterfaceType; + +extern int vga_interface_type; +#define xenfb_enabled (vga_interface_type == VGA_XENFB) +#define qxl_enabled (vga_interface_type == VGA_QXL) + +extern int graphic_width; +extern int graphic_height; +extern int graphic_depth; +extern DisplayType display_type; +extern const char *keyboard_layout; +extern int win2k_install_hack; +extern int alt_grab; +extern int ctrl_grab; +extern int smp_cpus; +extern int max_cpus; +extern int cursor_hide; +extern int graphic_rotate; +extern int no_quit; +extern int no_shutdown; +extern int semihosting_enabled; +extern int old_param; +extern int boot_menu; +extern uint8_t *boot_splash_filedata; +extern int boot_splash_filedata_size; +extern uint8_t qemu_extra_params_fw[2]; +extern QEMUClock *rtc_clock; + +#define MAX_NODES 64 +#define MAX_CPUMASK_BITS 255 +extern int nb_numa_nodes; +extern uint64_t node_mem[MAX_NODES]; +extern unsigned long *node_cpumask[MAX_NODES]; + +#define MAX_OPTION_ROMS 16 +typedef struct QEMUOptionRom { + const char *name; + int32_t bootindex; +} QEMUOptionRom; +extern QEMUOptionRom option_rom[MAX_OPTION_ROMS]; +extern int nb_option_roms; + +#define MAX_PROM_ENVS 128 +extern const char *prom_envs[MAX_PROM_ENVS]; +extern unsigned int nb_prom_envs; + +/* pci-hotplug */ +void pci_device_hot_add(Monitor *mon, const QDict *qdict); +int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo); +void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict); + +/* generic hotplug */ +void drive_hot_add(Monitor *mon, const QDict *qdict); + +/* pcie aer error injection */ +void pcie_aer_inject_error_print(Monitor *mon, const QObject *data); +int do_pcie_aer_inject_error(Monitor *mon, + const QDict *qdict, QObject **ret_data); + +/* serial ports */ + +#define MAX_SERIAL_PORTS 4 + +extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; + +/* parallel ports */ + +#define MAX_PARALLEL_PORTS 3 + +extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; + +void do_usb_add(Monitor *mon, const QDict *qdict); +void do_usb_del(Monitor *mon, const QDict *qdict); +void usb_info(Monitor *mon); + +void rtc_change_mon_event(struct tm *tm); + +void register_devices(void); + +void add_boot_device_path(int32_t bootindex, DeviceState *dev, + const char *suffix); +char *get_boot_devices_list(uint32_t *size); + +bool usb_enabled(bool default_usb); + +#endif diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h new file mode 100644 index 0000000000..c59804060b --- /dev/null +++ b/include/sysemu/xen-mapcache.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2011 Citrix Ltd. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#ifndef XEN_MAPCACHE_H +#define XEN_MAPCACHE_H + +#include + +typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr start_addr, + ram_addr_t size, + void *opaque); +#ifdef CONFIG_XEN + +void xen_map_cache_init(phys_offset_to_gaddr_t f, + void *opaque); +uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, + uint8_t lock); +ram_addr_t xen_ram_addr_from_mapcache(void *ptr); +void xen_invalidate_map_cache_entry(uint8_t *buffer); +void xen_invalidate_map_cache(void); + +#else + +static inline void xen_map_cache_init(phys_offset_to_gaddr_t f, + void *opaque) +{ +} + +static inline uint8_t *xen_map_cache(hwaddr phys_addr, + hwaddr size, + uint8_t lock) +{ + abort(); +} + +static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr) +{ + abort(); +} + +static inline void xen_invalidate_map_cache_entry(uint8_t *buffer) +{ +} + +static inline void xen_invalidate_map_cache(void) +{ +} + +#endif + +#endif /* !XEN_MAPCACHE_H */ diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index a0d1a50487..8b192e9613 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -21,7 +21,7 @@ #include "qemu/thread.h" #include "ui/qemu-pixman.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define NUM_MEMSLOTS 8 #define MEMSLOT_GENERATION_BITS 8 diff --git a/kvm-all.c b/kvm-all.c index 41ea3aa6ee..5aa65c4c15 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -24,11 +24,11 @@ #include "qemu/atomic.h" #include "qemu/option.h" #include "qemu/config-file.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "hw/hw.h" #include "hw/pci/msi.h" #include "exec/gdbstub.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "qemu/bswap.h" #include "exec/memory.h" #include "exec/address-spaces.h" diff --git a/kvm-stub.c b/kvm-stub.c index 8de8ebd3d2..5b971521cd 100644 --- a/kvm-stub.c +++ b/kvm-stub.c @@ -15,7 +15,7 @@ #include "hw/pci/msi.h" #include "cpu.h" #include "exec/gdbstub.h" -#include "kvm.h" +#include "sysemu/kvm.h" KVMState *kvm_state; bool kvm_kernel_irqchip; diff --git a/kvm.h b/kvm.h deleted file mode 100644 index 131d2bdc15..0000000000 --- a/kvm.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * QEMU KVM support - * - * Copyright IBM, Corp. 2008 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef QEMU_KVM_H -#define QEMU_KVM_H - -#include -#include "config-host.h" -#include "qemu/queue.h" - -#ifdef CONFIG_KVM -#include -#include -#endif - -extern int kvm_allowed; -extern bool kvm_kernel_irqchip; -extern bool kvm_async_interrupts_allowed; -extern bool kvm_irqfds_allowed; -extern bool kvm_msi_via_irqfd_allowed; -extern bool kvm_gsi_routing_allowed; - -#if defined CONFIG_KVM || !defined NEED_CPU_H -#define kvm_enabled() (kvm_allowed) -/** - * kvm_irqchip_in_kernel: - * - * Returns: true if the user asked us to create an in-kernel - * irqchip via the "kernel_irqchip=on" machine option. - * What this actually means is architecture and machine model - * specific: on PC, for instance, it means that the LAPIC, - * IOAPIC and PIT are all in kernel. This function should never - * be used from generic target-independent code: use one of the - * following functions or some other specific check instead. - */ -#define kvm_irqchip_in_kernel() (kvm_kernel_irqchip) - -/** - * kvm_async_interrupts_enabled: - * - * Returns: true if we can deliver interrupts to KVM - * asynchronously (ie by ioctl from any thread at any time) - * rather than having to do interrupt delivery synchronously - * (where the vcpu must be stopped at a suitable point first). - */ -#define kvm_async_interrupts_enabled() (kvm_async_interrupts_allowed) - -/** - * kvm_irqfds_enabled: - * - * Returns: true if we can use irqfds to inject interrupts into - * a KVM CPU (ie the kernel supports irqfds and we are running - * with a configuration where it is meaningful to use them). - */ -#define kvm_irqfds_enabled() (kvm_irqfds_allowed) - -/** - * kvm_msi_via_irqfd_enabled: - * - * Returns: true if we can route a PCI MSI (Message Signaled Interrupt) - * to a KVM CPU via an irqfd. This requires that the kernel supports - * this and that we're running in a configuration that permits it. - */ -#define kvm_msi_via_irqfd_enabled() (kvm_msi_via_irqfd_allowed) - -/** - * kvm_gsi_routing_enabled: - * - * Returns: true if GSI routing is enabled (ie the kernel supports - * it and we're running in a configuration that permits it). - */ -#define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed) - -#else -#define kvm_enabled() (0) -#define kvm_irqchip_in_kernel() (false) -#define kvm_async_interrupts_enabled() (false) -#define kvm_irqfds_enabled() (false) -#define kvm_msi_via_irqfd_enabled() (false) -#define kvm_gsi_routing_allowed() (false) -#endif - -struct kvm_run; -struct kvm_lapic_state; - -typedef struct KVMCapabilityInfo { - const char *name; - int value; -} KVMCapabilityInfo; - -#define KVM_CAP_INFO(CAP) { "KVM_CAP_" stringify(CAP), KVM_CAP_##CAP } -#define KVM_CAP_LAST_INFO { NULL, 0 } - -struct KVMState; -typedef struct KVMState KVMState; -extern KVMState *kvm_state; - -/* external API */ - -int kvm_init(void); - -int kvm_has_sync_mmu(void); -int kvm_has_vcpu_events(void); -int kvm_has_robust_singlestep(void); -int kvm_has_debugregs(void); -int kvm_has_xsave(void); -int kvm_has_xcrs(void); -int kvm_has_pit_state2(void); -int kvm_has_many_ioeventfds(void); -int kvm_has_gsi_routing(void); -int kvm_has_intx_set_mask(void); - -#ifdef NEED_CPU_H -int kvm_init_vcpu(CPUArchState *env); - -int kvm_cpu_exec(CPUArchState *env); - -#if !defined(CONFIG_USER_ONLY) -void *kvm_vmalloc(ram_addr_t size); -void *kvm_arch_vmalloc(ram_addr_t size); -void kvm_setup_guest_memory(void *start, size_t size); - -void kvm_flush_coalesced_mmio_buffer(void); -#endif - -int kvm_insert_breakpoint(CPUArchState *current_env, target_ulong addr, - target_ulong len, int type); -int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr, - target_ulong len, int type); -void kvm_remove_all_breakpoints(CPUArchState *current_env); -int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap); -#ifndef _WIN32 -int kvm_set_signal_mask(CPUArchState *env, const sigset_t *sigset); -#endif - -int kvm_on_sigbus_vcpu(CPUArchState *env, int code, void *addr); -int kvm_on_sigbus(int code, void *addr); - -/* internal API */ - -int kvm_ioctl(KVMState *s, int type, ...); - -int kvm_vm_ioctl(KVMState *s, int type, ...); - -int kvm_vcpu_ioctl(CPUArchState *env, int type, ...); - -/* Arch specific hooks */ - -extern const KVMCapabilityInfo kvm_arch_required_capabilities[]; - -void kvm_arch_pre_run(CPUArchState *env, struct kvm_run *run); -void kvm_arch_post_run(CPUArchState *env, struct kvm_run *run); - -int kvm_arch_handle_exit(CPUArchState *env, struct kvm_run *run); - -int kvm_arch_process_async_events(CPUArchState *env); - -int kvm_arch_get_registers(CPUArchState *env); - -/* state subset only touched by the VCPU itself during runtime */ -#define KVM_PUT_RUNTIME_STATE 1 -/* state subset modified during VCPU reset */ -#define KVM_PUT_RESET_STATE 2 -/* full state set, modified during initialization or on vmload */ -#define KVM_PUT_FULL_STATE 3 - -int kvm_arch_put_registers(CPUArchState *env, int level); - -int kvm_arch_init(KVMState *s); - -int kvm_arch_init_vcpu(CPUArchState *env); - -void kvm_arch_reset_vcpu(CPUArchState *env); - -int kvm_arch_on_sigbus_vcpu(CPUArchState *env, int code, void *addr); -int kvm_arch_on_sigbus(int code, void *addr); - -void kvm_arch_init_irq_routing(KVMState *s); - -int kvm_set_irq(KVMState *s, int irq, int level); -int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg); - -void kvm_irqchip_add_irq_route(KVMState *s, int gsi, int irqchip, int pin); - -void kvm_put_apic_state(DeviceState *d, struct kvm_lapic_state *kapic); -void kvm_get_apic_state(DeviceState *d, struct kvm_lapic_state *kapic); - -struct kvm_guest_debug; -struct kvm_debug_exit_arch; - -struct kvm_sw_breakpoint { - target_ulong pc; - target_ulong saved_insn; - int use_count; - QTAILQ_ENTRY(kvm_sw_breakpoint) entry; -}; - -QTAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); - -struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUArchState *env, - target_ulong pc); - -int kvm_sw_breakpoints_active(CPUArchState *env); - -int kvm_arch_insert_sw_breakpoint(CPUArchState *current_env, - struct kvm_sw_breakpoint *bp); -int kvm_arch_remove_sw_breakpoint(CPUArchState *current_env, - struct kvm_sw_breakpoint *bp); -int kvm_arch_insert_hw_breakpoint(target_ulong addr, - target_ulong len, int type); -int kvm_arch_remove_hw_breakpoint(target_ulong addr, - target_ulong len, int type); -void kvm_arch_remove_all_hw_breakpoints(void); - -void kvm_arch_update_guest_debug(CPUArchState *env, struct kvm_guest_debug *dbg); - -bool kvm_arch_stop_on_emulation_error(CPUArchState *env); - -int kvm_check_extension(KVMState *s, unsigned int extension); - -uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, - uint32_t index, int reg); -void kvm_cpu_synchronize_state(CPUArchState *env); -void kvm_cpu_synchronize_post_reset(CPUArchState *env); -void kvm_cpu_synchronize_post_init(CPUArchState *env); - -/* generic hooks - to be moved/refactored once there are more users */ - -static inline void cpu_synchronize_state(CPUArchState *env) -{ - if (kvm_enabled()) { - kvm_cpu_synchronize_state(env); - } -} - -static inline void cpu_synchronize_post_reset(CPUArchState *env) -{ - if (kvm_enabled()) { - kvm_cpu_synchronize_post_reset(env); - } -} - -static inline void cpu_synchronize_post_init(CPUArchState *env) -{ - if (kvm_enabled()) { - kvm_cpu_synchronize_post_init(env); - } -} - - -#if !defined(CONFIG_USER_ONLY) -int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr, - hwaddr *phys_addr); -#endif - -#endif -int kvm_set_ioeventfd_mmio(int fd, uint32_t adr, uint32_t val, bool assign, - uint32_t size); - -int kvm_set_ioeventfd_pio_word(int fd, uint16_t adr, uint16_t val, bool assign); - -int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg); -int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg); -void kvm_irqchip_release_virq(KVMState *s, int virq); - -int kvm_irqchip_add_irqfd_notifier(KVMState *s, EventNotifier *n, int virq); -int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq); -void kvm_pc_gsi_handler(void *opaque, int n, int level); -void kvm_pc_setup_irq_routing(bool pci_enabled); -#endif diff --git a/memory.c b/memory.c index d44200335b..35e6122dd7 100644 --- a/memory.c +++ b/memory.c @@ -17,7 +17,7 @@ #include "exec/address-spaces.h" #include "exec/ioport.h" #include "qemu/bitops.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include #include "exec/memory-internal.h" diff --git a/memory_mapping-stub.c b/memory_mapping-stub.c index 5f5fb99c58..24d5d67371 100644 --- a/memory_mapping-stub.c +++ b/memory_mapping-stub.c @@ -13,7 +13,7 @@ #include "cpu.h" #include "exec/cpu-all.h" -#include "memory_mapping.h" +#include "sysemu/memory_mapping.h" int qemu_get_guest_memory_mapping(MemoryMappingList *list) { diff --git a/memory_mapping.c b/memory_mapping.c index c829a9fa34..530f1d6793 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -13,7 +13,7 @@ #include "cpu.h" #include "exec/cpu-all.h" -#include "memory_mapping.h" +#include "sysemu/memory_mapping.h" static void memory_mapping_list_add_mapping_sorted(MemoryMappingList *list, MemoryMapping *mapping) diff --git a/memory_mapping.h b/memory_mapping.h deleted file mode 100644 index 1256125963..0000000000 --- a/memory_mapping.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * QEMU memory mapping - * - * Copyright Fujitsu, Corp. 2011, 2012 - * - * Authors: - * Wen Congyang - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef MEMORY_MAPPING_H -#define MEMORY_MAPPING_H - -#include "qemu/queue.h" - -/* The physical and virtual address in the memory mapping are contiguous. */ -typedef struct MemoryMapping { - hwaddr phys_addr; - target_ulong virt_addr; - ram_addr_t length; - QTAILQ_ENTRY(MemoryMapping) next; -} MemoryMapping; - -typedef struct MemoryMappingList { - unsigned int num; - MemoryMapping *last_mapping; - QTAILQ_HEAD(, MemoryMapping) head; -} MemoryMappingList; - -int cpu_get_memory_mapping(MemoryMappingList *list, CPUArchState *env); -bool cpu_paging_enabled(CPUArchState *env); - -/* - * add or merge the memory region [phys_addr, phys_addr + length) into the - * memory mapping's list. The region's virtual address starts with virt_addr, - * and is contiguous. The list is sorted by phys_addr. - */ -void memory_mapping_list_add_merge_sorted(MemoryMappingList *list, - hwaddr phys_addr, - hwaddr virt_addr, - ram_addr_t length); - -void memory_mapping_list_free(MemoryMappingList *list); - -void memory_mapping_list_init(MemoryMappingList *list); - -/* - * Return value: - * 0: success - * -1: failed - * -2: unsupported - */ -int qemu_get_guest_memory_mapping(MemoryMappingList *list); - -/* get guest's memory mapping without do paging(virtual address is 0). */ -void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list); - -void memory_mapping_filter(MemoryMappingList *list, int64_t begin, - int64_t length); - -#endif diff --git a/migration.c b/migration.c index 8c5c5670d8..810f25e7eb 100644 --- a/migration.c +++ b/migration.c @@ -17,7 +17,7 @@ #include "migration/migration.h" #include "monitor/monitor.h" #include "buffered_file.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "block/block.h" #include "qemu/sockets.h" #include "migration/block.h" diff --git a/monitor.c b/monitor.c index 878b2317af..200bef452f 100644 --- a/monitor.c +++ b/monitor.c @@ -35,17 +35,17 @@ #include "net/slirp.h" #include "qemu-char.h" #include "ui/qemu-spice.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "monitor/readline.h" #include "ui/console.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "audio/audio.h" #include "disas/disas.h" -#include "balloon.h" +#include "sysemu/balloon.h" #include "qemu/timer.h" #include "migration/migration.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "qemu/acl.h" #include "qapi/qmp/qint.h" #include "qapi/qmp/qfloat.h" diff --git a/net/tap-bsd.c b/net/tap-bsd.c index b48182f678..01c705b4c0 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -24,7 +24,7 @@ #include "tap_int.h" #include "qemu-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/error-report.h" #ifdef __NetBSD__ diff --git a/net/tap-linux.c b/net/tap-linux.c index dd4b915243..059f5f34ab 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -30,7 +30,7 @@ #include #include -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-common.h" #include "qemu/error-report.h" diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 3d5fee5542..486a7ea838 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -23,7 +23,7 @@ */ #include "tap_int.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include #include diff --git a/net/tap-win32.c b/net/tap-win32.c index 1ddd6fa6e6..0c63cbd203 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -31,7 +31,7 @@ #include "qemu-common.h" #include "clients.h" /* net_init_tap */ #include "net/net.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/error-report.h" #include #include diff --git a/net/tap.c b/net/tap.c index d34ff13398..eb40c42d7d 100644 --- a/net/tap.c +++ b/net/tap.c @@ -36,7 +36,7 @@ #include "net/net.h" #include "clients.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-common.h" #include "qemu/error-report.h" diff --git a/os-posix.c b/os-posix.c index 488e48005f..5c64518902 100644 --- a/os-posix.c +++ b/os-posix.c @@ -36,7 +36,7 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "net/slirp.h" #include "qemu-options.h" diff --git a/os-win32.c b/os-win32.c index 13892ba320..9673a81c7d 100644 --- a/os-win32.c +++ b/os-win32.c @@ -30,7 +30,7 @@ #include #include #include "config-host.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-options.h" /***********************************************************/ diff --git a/oslib-posix.c b/oslib-posix.c index a737d6e0e3..4f5ec6788b 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -49,7 +49,7 @@ extern int daemon(int, int); #endif #include "config-host.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "qemu/sockets.h" diff --git a/oslib-win32.c b/oslib-win32.c index 7f0dd07e5f..e7e283e875 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -27,7 +27,7 @@ */ #include #include "config-host.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/main-loop.h" #include "trace.h" #include "qemu/sockets.h" diff --git a/qemu-char.c b/qemu-char.c index 5a8d8f75a4..0cbe85318e 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -24,7 +24,7 @@ #include "qemu-common.h" #include "monitor/monitor.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" #include "qemu-char.h" #include "hw/usb.h" diff --git a/qemu-common.h b/qemu-common.h index 40cd198fc1..6871cab371 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -43,11 +43,11 @@ #include #ifdef _WIN32 -#include "qemu-os-win32.h" +#include "sysemu/os-win32.h" #endif #ifdef CONFIG_POSIX -#include "qemu-os-posix.h" +#include "sysemu/os-posix.h" #endif #ifndef O_LARGEFILE diff --git a/qemu-img.c b/qemu-img.c index 4c8e2f3849..69cc02871b 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -28,7 +28,7 @@ #include "qemu/option.h" #include "qemu/error-report.h" #include "qemu/osdep.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "block/block_int.h" #include #include diff --git a/qemu-os-posix.h b/qemu-os-posix.h deleted file mode 100644 index 7f198e475c..0000000000 --- a/qemu-os-posix.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * posix specific declarations - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2010 Jes Sorensen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OS_POSIX_H -#define QEMU_OS_POSIX_H - -void os_set_line_buffering(void); -void os_set_proc_name(const char *s); -void os_setup_signal_handling(void); -void os_daemonize(void); -void os_setup_post(void); - -typedef struct timeval qemu_timeval; -#define qemu_gettimeofday(tp) gettimeofday(tp, NULL) - -#ifndef CONFIG_UTIMENSAT -#ifndef UTIME_NOW -# define UTIME_NOW ((1l << 30) - 1l) -#endif -#ifndef UTIME_OMIT -# define UTIME_OMIT ((1l << 30) - 2l) -#endif -#endif -typedef struct timespec qemu_timespec; -int qemu_utimens(const char *path, const qemu_timespec *times); - -bool is_daemonized(void); - -#endif diff --git a/qemu-os-win32.h b/qemu-os-win32.h deleted file mode 100644 index d0e9234d24..0000000000 --- a/qemu-os-win32.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * win32 specific declarations - * - * Copyright (c) 2003-2008 Fabrice Bellard - * Copyright (c) 2010 Jes Sorensen - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef QEMU_OS_WIN32_H -#define QEMU_OS_WIN32_H - -#include -#include - -/* Workaround for older versions of MinGW. */ -#ifndef ECONNREFUSED -# define ECONNREFUSED WSAECONNREFUSED -#endif -#ifndef EINPROGRESS -# define EINPROGRESS WSAEINPROGRESS -#endif -#ifndef EHOSTUNREACH -# define EHOSTUNREACH WSAEHOSTUNREACH -#endif -#ifndef EINTR -# define EINTR WSAEINTR -#endif -#ifndef EINPROGRESS -# define EINPROGRESS WSAEINPROGRESS -#endif -#ifndef ENETUNREACH -# define ENETUNREACH WSAENETUNREACH -#endif -#ifndef ENOTCONN -# define ENOTCONN WSAENOTCONN -#endif -#ifndef EWOULDBLOCK -# define EWOULDBLOCK WSAEWOULDBLOCK -#endif - -#if defined(_WIN64) -/* On w64, setjmp is implemented by _setjmp which needs a second parameter. - * If this parameter is NULL, longjump does no stack unwinding. - * That is what we need for QEMU. Passing the value of register rsp (default) - * lets longjmp try a stack unwinding which will crash with generated code. */ -# undef setjmp -# define setjmp(env) _setjmp(env, NULL) -#endif - -/* Declaration of ffs() is missing in MinGW's strings.h. */ -int ffs(int i); - -/* Missing POSIX functions. Don't use MinGW-w64 macros. */ -#undef gmtime_r -struct tm *gmtime_r(const time_t *timep, struct tm *result); -#undef localtime_r -struct tm *localtime_r(const time_t *timep, struct tm *result); - -static inline void os_setup_signal_handling(void) {} -static inline void os_daemonize(void) {} -static inline void os_setup_post(void) {} -void os_set_line_buffering(void); -static inline void os_set_proc_name(const char *dummy) {} - -#if !defined(EPROTONOSUPPORT) -# define EPROTONOSUPPORT EINVAL -#endif - -int setenv(const char *name, const char *value, int overwrite); - -typedef struct { - long tv_sec; - long tv_usec; -} qemu_timeval; -int qemu_gettimeofday(qemu_timeval *tp); - -static inline bool is_daemonized(void) -{ - return false; -} - -#endif diff --git a/qemu-progress.c b/qemu-progress.c index 08d67949a1..9a3f96cd47 100644 --- a/qemu-progress.c +++ b/qemu-progress.c @@ -24,7 +24,7 @@ #include "qemu-common.h" #include "qemu/osdep.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include struct progress_state { diff --git a/qemu-seccomp.c b/qemu-seccomp.c index 2a71d6fee9..031da1dfee 100644 --- a/qemu-seccomp.c +++ b/qemu-seccomp.c @@ -14,7 +14,7 @@ */ #include #include -#include "qemu-seccomp.h" +#include "sysemu/seccomp.h" struct QemuSeccompSyscall { int32_t num; diff --git a/qemu-seccomp.h b/qemu-seccomp.h deleted file mode 100644 index 1189fa241d..0000000000 --- a/qemu-seccomp.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * QEMU seccomp mode 2 support with libseccomp - * - * Copyright IBM, Corp. 2012 - * - * Authors: - * Eduardo Otubo - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - * Contributions after 2012-01-13 are licensed under the terms of the - * GNU GPL, version 2 or (at your option) any later version. - */ -#ifndef QEMU_SECCOMP_H -#define QEMU_SECCOMP_H - -#include -#include "qemu/osdep.h" - -int seccomp_start(void); -#endif diff --git a/qemu-timer.c b/qemu-timer.c index 80b3f2eb31..8fb5c75df7 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "ui/console.h" diff --git a/qemu-tool.c b/qemu-tool.c index 8ac45ff39b..1a474c45bc 100644 --- a/qemu-tool.c +++ b/qemu-tool.c @@ -19,7 +19,7 @@ #include "qemu/log.h" #include "migration/migration.h" #include "qemu/main-loop.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/sockets.h" #include "slirp/libslirp.h" diff --git a/qmp.c b/qmp.c index 5b3a5d7d03..be63fe1029 100644 --- a/qmp.c +++ b/qmp.c @@ -14,15 +14,15 @@ */ #include "qemu-common.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qmp-commands.h" #include "qemu-char.h" #include "ui/qemu-spice.h" #include "ui/vnc.h" -#include "kvm.h" -#include "arch_init.h" +#include "sysemu/kvm.h" +#include "sysemu/arch_init.h" #include "hw/qdev.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qom/qom-qobject.h" NameInfo *qmp_query_name(Error **errp) diff --git a/qtest.c b/qtest.c index ebe3963167..468c921310 100644 --- a/qtest.c +++ b/qtest.c @@ -11,14 +11,14 @@ * */ -#include "qtest.h" +#include "sysemu/qtest.h" #include "hw/qdev.h" #include "qemu-char.h" #include "exec/ioport.h" #include "exec/memory.h" #include "hw/irq.h" -#include "sysemu.h" -#include "cpus.h" +#include "sysemu/sysemu.h" +#include "sysemu/cpus.h" #define MAX_IRQ 256 diff --git a/qtest.h b/qtest.h deleted file mode 100644 index 723a4f9536..0000000000 --- a/qtest.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Test Server - * - * Copyright IBM, Corp. 2011 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#ifndef QTEST_H -#define QTEST_H - -#include "qemu-common.h" - -#if !defined(CONFIG_USER_ONLY) -extern int qtest_allowed; -extern const char *qtest_chrdev; -extern const char *qtest_log; - -static inline bool qtest_enabled(void) -{ - return qtest_allowed; -} - -static inline int qtest_available(void) -{ - return 1; -} - -int qtest_init(void); -#else -static inline bool qtest_enabled(void) -{ - return false; -} - -static inline int qtest_available(void) -{ - return 0; -} - -static inline int qtest_init(void) -{ - return 0; -} - -#endif - -#endif diff --git a/savevm.c b/savevm.c index ea01e9baf6..b2a844f2b1 100644 --- a/savevm.c +++ b/savevm.c @@ -74,14 +74,14 @@ #include "hw/qdev.h" #include "net/net.h" #include "monitor/monitor.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" #include "audio/audio.h" #include "migration/migration.h" #include "qemu/sockets.h" #include "qemu/queue.h" #include "qemu/timer.h" -#include "cpus.h" +#include "sysemu/cpus.h" #include "exec/memory.h" #include "qmp-commands.h" #include "trace.h" diff --git a/stubs/arch-query-cpu-def.c b/stubs/arch-query-cpu-def.c index 6eca8527d2..fa6789598a 100644 --- a/stubs/arch-query-cpu-def.c +++ b/stubs/arch-query-cpu-def.c @@ -1,5 +1,5 @@ #include "qemu-common.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" #include "qapi/qmp/qerror.h" CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) diff --git a/sysemu.h b/sysemu.h deleted file mode 100644 index 8eaa4707a0..0000000000 --- a/sysemu.h +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef SYSEMU_H -#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" -#include "qapi-types.h" -#include "qemu/notify.h" -#include "qemu/main-loop.h" - -/* vl.c */ - -extern const char *bios_name; - -extern const char *qemu_name; -extern uint8_t qemu_uuid[]; -int qemu_uuid_parse(const char *str, uint8_t *uuid); -#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" - -bool runstate_check(RunState state); -void runstate_set(RunState new_state); -int runstate_is_running(void); -typedef struct vm_change_state_entry VMChangeStateEntry; -typedef void VMChangeStateHandler(void *opaque, int running, RunState state); - -VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, - void *opaque); -void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); -void vm_state_notify(int running, RunState state); - -#define VMRESET_SILENT false -#define VMRESET_REPORT true - -void vm_start(void); -void vm_stop(RunState state); -void vm_stop_force_state(RunState state); - -typedef enum WakeupReason { - QEMU_WAKEUP_REASON_OTHER = 0, - QEMU_WAKEUP_REASON_RTC, - QEMU_WAKEUP_REASON_PMTIMER, -} WakeupReason; - -void qemu_system_reset_request(void); -void qemu_system_suspend_request(void); -void qemu_register_suspend_notifier(Notifier *notifier); -void qemu_system_wakeup_request(WakeupReason reason); -void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); -void qemu_register_wakeup_notifier(Notifier *notifier); -void qemu_system_shutdown_request(void); -void qemu_system_powerdown_request(void); -void qemu_register_powerdown_notifier(Notifier *notifier); -void qemu_system_debug_request(void); -void qemu_system_vmstop_request(RunState reason); -int qemu_shutdown_requested_get(void); -int qemu_reset_requested_get(void); -void qemu_system_killed(int signal, pid_t pid); -void qemu_devices_reset(void); -void qemu_system_reset(bool report); - -void qemu_add_exit_notifier(Notifier *notify); -void qemu_remove_exit_notifier(Notifier *notify); - -void qemu_add_machine_init_done_notifier(Notifier *notify); - -void do_savevm(Monitor *mon, const QDict *qdict); -int load_vmstate(const char *name); -void do_delvm(Monitor *mon, const QDict *qdict); -void do_info_snapshots(Monitor *mon); - -void qemu_announce_self(void); - -bool qemu_savevm_state_blocked(Error **errp); -int qemu_savevm_state_begin(QEMUFile *f, - const MigrationParams *params); -int qemu_savevm_state_iterate(QEMUFile *f); -int qemu_savevm_state_complete(QEMUFile *f); -void qemu_savevm_state_cancel(QEMUFile *f); -int qemu_loadvm_state(QEMUFile *f); - -/* SLIRP */ -void do_info_slirp(Monitor *mon); - -typedef enum DisplayType -{ - DT_DEFAULT, - DT_CURSES, - DT_SDL, - DT_NOGRAPHIC, - DT_NONE, -} DisplayType; - -extern int autostart; -extern int bios_size; - -typedef enum { - VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL, -} VGAInterfaceType; - -extern int vga_interface_type; -#define xenfb_enabled (vga_interface_type == VGA_XENFB) -#define qxl_enabled (vga_interface_type == VGA_QXL) - -extern int graphic_width; -extern int graphic_height; -extern int graphic_depth; -extern DisplayType display_type; -extern const char *keyboard_layout; -extern int win2k_install_hack; -extern int alt_grab; -extern int ctrl_grab; -extern int smp_cpus; -extern int max_cpus; -extern int cursor_hide; -extern int graphic_rotate; -extern int no_quit; -extern int no_shutdown; -extern int semihosting_enabled; -extern int old_param; -extern int boot_menu; -extern uint8_t *boot_splash_filedata; -extern int boot_splash_filedata_size; -extern uint8_t qemu_extra_params_fw[2]; -extern QEMUClock *rtc_clock; - -#define MAX_NODES 64 -#define MAX_CPUMASK_BITS 255 -extern int nb_numa_nodes; -extern uint64_t node_mem[MAX_NODES]; -extern unsigned long *node_cpumask[MAX_NODES]; - -#define MAX_OPTION_ROMS 16 -typedef struct QEMUOptionRom { - const char *name; - int32_t bootindex; -} QEMUOptionRom; -extern QEMUOptionRom option_rom[MAX_OPTION_ROMS]; -extern int nb_option_roms; - -#define MAX_PROM_ENVS 128 -extern const char *prom_envs[MAX_PROM_ENVS]; -extern unsigned int nb_prom_envs; - -/* pci-hotplug */ -void pci_device_hot_add(Monitor *mon, const QDict *qdict); -int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo); -void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict); - -/* generic hotplug */ -void drive_hot_add(Monitor *mon, const QDict *qdict); - -/* pcie aer error injection */ -void pcie_aer_inject_error_print(Monitor *mon, const QObject *data); -int do_pcie_aer_inject_error(Monitor *mon, - const QDict *qdict, QObject **ret_data); - -/* serial ports */ - -#define MAX_SERIAL_PORTS 4 - -extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; - -/* parallel ports */ - -#define MAX_PARALLEL_PORTS 3 - -extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; - -void do_usb_add(Monitor *mon, const QDict *qdict); -void do_usb_del(Monitor *mon, const QDict *qdict); -void usb_info(Monitor *mon); - -void rtc_change_mon_event(struct tm *tm); - -void register_devices(void); - -void add_boot_device_path(int32_t bootindex, DeviceState *dev, - const char *suffix); -char *get_boot_devices_list(uint32_t *size); - -bool usb_enabled(bool default_usb); - -#endif diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c index 2bc2b02815..434a63a97d 100644 --- a/target-alpha/sys_helper.c +++ b/target-alpha/sys_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "helper.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/timer.h" diff --git a/target-arm/cpu.c b/target-arm/cpu.c index b00f5fa547..17875ed0f0 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -23,7 +23,7 @@ #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" #endif -#include "sysemu.h" +#include "sysemu/sysemu.h" static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) { diff --git a/target-arm/helper.c b/target-arm/helper.c index eef2acd18a..e343fac853 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2,7 +2,7 @@ #include "exec/gdbstub.h" #include "helper.h" #include "qemu/host-utils.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/bitops.h" #ifndef CONFIG_USER_ONLY diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c index 50d866f4c6..8209ce9ee2 100644 --- a/target-i386/arch_dump.c +++ b/target-i386/arch_dump.c @@ -13,7 +13,7 @@ #include "cpu.h" #include "exec/cpu-all.h" -#include "dump.h" +#include "sysemu/dump.h" #include "elf.h" #ifdef TARGET_X86_64 diff --git a/target-i386/arch_memory_mapping.c b/target-i386/arch_memory_mapping.c index 6dfb0f3f56..c6c7874474 100644 --- a/target-i386/arch_memory_mapping.c +++ b/target-i386/arch_memory_mapping.c @@ -13,7 +13,7 @@ #include "cpu.h" #include "exec/cpu-all.h" -#include "memory_mapping.h" +#include "sysemu/memory_mapping.h" /* PAE Paging or IA-32e Paging */ static void walk_pte(MemoryMappingList *list, hwaddr pte_start_addr, diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 8abc5561e9..1837f5af04 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -22,14 +22,14 @@ #include #include "cpu.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "qemu/option.h" #include "qemu/config-file.h" #include "qapi/qmp/qerror.h" #include "qapi/visitor.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" #include "hyperv.h" @@ -38,7 +38,7 @@ #include #endif -#include "sysemu.h" +#include "sysemu/sysemu.h" #ifndef CONFIG_USER_ONLY #include "hw/xen.h" #include "hw/sysbus.h" diff --git a/target-i386/excp_helper.c b/target-i386/excp_helper.c index 64c8346d3b..179ea82f0f 100644 --- a/target-i386/excp_helper.c +++ b/target-i386/excp_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "qemu/log.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "helper.h" #if 0 diff --git a/target-i386/helper.c b/target-i386/helper.c index bd47b8e58e..dca1360962 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -18,9 +18,9 @@ */ #include "cpu.h" -#include "kvm.h" +#include "sysemu/kvm.h" #ifndef CONFIG_USER_ONLY -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" #endif diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 340ed3f33e..f63b1fbfda 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -21,8 +21,8 @@ #include #include "qemu-common.h" -#include "sysemu.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "kvm_i386.h" #include "cpu.h" #include "exec/gdbstub.h" diff --git a/target-i386/kvm_i386.h b/target-i386/kvm_i386.h index f6ab82f93c..4392ab4359 100644 --- a/target-i386/kvm_i386.h +++ b/target-i386/kvm_i386.h @@ -11,7 +11,7 @@ #ifndef QEMU_KVM_I386_H #define QEMU_KVM_I386_H -#include "kvm.h" +#include "sysemu/kvm.h" bool kvm_allows_irq0_override(void); diff --git a/target-i386/machine.c b/target-i386/machine.c index 477150887b..8c1fed1005 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -4,7 +4,7 @@ #include "hw/isa.h" #include "cpu.h" -#include "kvm.h" +#include "sysemu/kvm.h" static const VMStateDescription vmstate_segment = { .name = "segment", diff --git a/target-m68k/m68k-semi.c b/target-m68k/m68k-semi.c index e6c7dd2f9b..239fadbad5 100644 --- a/target-m68k/m68k-semi.c +++ b/target-m68k/m68k-semi.c @@ -36,7 +36,7 @@ #include "exec/gdbstub.h" #include "exec/softmmu-semi.h" #endif -#include "sysemu.h" +#include "sysemu/sysemu.h" #define HOSTED_EXIT 0 #define HOSTED_INIT_SIM 1 diff --git a/target-ppc/helper.c b/target-ppc/helper.c index 48b19a7e1d..103855afe0 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -19,9 +19,9 @@ #include "cpu.h" #include "helper_regs.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" -#include "cpus.h" +#include "sysemu/cpus.h" PowerPCCPU *cpu_ppc_init(const char *cpu_model) { diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 2546c577f6..88650d4ae4 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -24,12 +24,12 @@ #include "qemu-common.h" #include "qemu/timer.h" -#include "sysemu.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" #include "cpu.h" -#include "cpus.h" -#include "device_tree.h" +#include "sysemu/cpus.h" +#include "sysemu/device_tree.h" #include "hw/sysbus.h" #include "hw/spapr.h" diff --git a/target-ppc/kvm_ppc.c b/target-ppc/kvm_ppc.c index 2de59fd43b..1b192a8038 100644 --- a/target-ppc/kvm_ppc.c +++ b/target-ppc/kvm_ppc.c @@ -14,7 +14,7 @@ #include "qemu-common.h" #include "qemu/timer.h" #include "kvm_ppc.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" #define PROC_DEVTREE_PATH "/proc/device-tree" diff --git a/target-ppc/machine.c b/target-ppc/machine.c index 5e7bc00e26..e014c0c1af 100644 --- a/target-ppc/machine.c +++ b/target-ppc/machine.c @@ -1,6 +1,6 @@ #include "hw/hw.h" #include "hw/boards.h" -#include "kvm.h" +#include "sysemu/kvm.h" void cpu_save(QEMUFile *f, void *opaque) { diff --git a/target-ppc/mmu_helper.c b/target-ppc/mmu_helper.c index 318ce92adb..0aee7a9063 100644 --- a/target-ppc/mmu_helper.c +++ b/target-ppc/mmu_helper.c @@ -18,7 +18,7 @@ */ #include "cpu.h" #include "helper.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "kvm_ppc.h" //#define DEBUG_MMU diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index cca63abf5d..42ed748b59 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -25,9 +25,9 @@ #include "disas/bfd.h" #include "exec/gdbstub.h" -#include +#include #include "kvm_ppc.h" -#include "arch_init.h" +#include "sysemu/arch_init.h" //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 8e135457a3..42e06eb85e 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -22,7 +22,7 @@ #include "exec/gdbstub.h" #include "qemu/timer.h" #ifndef CONFIG_USER_ONLY -#include "sysemu.h" +#include "sysemu/sysemu.h" #endif //#define DEBUG_S390 diff --git a/target-s390x/interrupt.c b/target-s390x/interrupt.c index c1b034f775..6c0024b426 100644 --- a/target-s390x/interrupt.c +++ b/target-s390x/interrupt.c @@ -8,7 +8,7 @@ */ #include "cpu.h" -#include "kvm.h" +#include "sysemu/kvm.h" #if !defined(CONFIG_USER_ONLY) /* service interrupts are floating therefore we must not pass an cpustate */ diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index dc70699919..762231d845 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -26,10 +26,10 @@ #include "qemu-common.h" #include "qemu/timer.h" -#include "sysemu.h" -#include "kvm.h" +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "cpu.h" -#include "device_tree.h" +#include "sysemu/device_tree.h" /* #define DEBUG_KVM */ diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c index 2e73d30756..e521ed55cc 100644 --- a/target-s390x/misc_helper.c +++ b/target-s390x/misc_helper.c @@ -23,7 +23,7 @@ #include "qemu/host-utils.h" #include "helper.h" #include -#include "kvm.h" +#include "sysemu/kvm.h" #include "qemu/timer.h" #ifdef CONFIG_KVM #include @@ -31,7 +31,7 @@ #if !defined(CONFIG_USER_ONLY) #include "exec/softmmu_exec.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #endif /* #define DEBUG_HELPER */ diff --git a/target-sparc/helper.c b/target-sparc/helper.c index e0d78f3852..91ecfc7aa8 100644 --- a/target-sparc/helper.c +++ b/target-sparc/helper.c @@ -20,7 +20,7 @@ #include "cpu.h" #include "qemu/host-utils.h" #include "helper.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" void helper_raise_exception(CPUSPARCState *env, int tt) { diff --git a/target-sparc/int32_helper.c b/target-sparc/int32_helper.c index 507c355cac..c35f522e0f 100644 --- a/target-sparc/int32_helper.c +++ b/target-sparc/int32_helper.c @@ -19,7 +19,7 @@ #include "cpu.h" #include "trace.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define DEBUG_PCALL diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c index f61a497d21..0a037291ef 100644 --- a/target-xtensa/translate.c +++ b/target-xtensa/translate.c @@ -35,7 +35,7 @@ #include "disas/disas.h" #include "tcg-op.h" #include "qemu/log.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "helper.h" #define GEN_HELPER 1 diff --git a/ui/cocoa.m b/ui/cocoa.m index 0afa6f86dd..3bf1c6e890 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -27,7 +27,7 @@ #include "qemu-common.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #ifndef MAC_OS_X_VERSION_10_4 #define MAC_OS_X_VERSION_10_4 1040 diff --git a/ui/curses.c b/ui/curses.c index 5d15e9e16e..d78e378440 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -30,7 +30,7 @@ #include "qemu-common.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #define FONT_HEIGHT 16 #define FONT_WIDTH 8 diff --git a/ui/input.c b/ui/input.c index 05f6c0c849..259fd1808d 100644 --- a/ui/input.c +++ b/ui/input.c @@ -22,7 +22,7 @@ * THE SOFTWARE. */ -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "ui/console.h" #include "qapi/error.h" diff --git a/ui/keymaps.c b/ui/keymaps.c index f55a2aa464..9625d82fa1 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -23,7 +23,7 @@ */ #include "keymaps.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" static int get_keysym(const name2keysym_t *table, const char *name) diff --git a/ui/sdl.c b/ui/sdl.c index bcbf89daeb..1657848e9f 100644 --- a/ui/sdl.c +++ b/ui/sdl.c @@ -30,7 +30,7 @@ #include "qemu-common.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "x_keymap.h" #include "sdl_zoom.h" diff --git a/ui/spice-core.c b/ui/spice-core.c index 8727bf49ca..5fe3e0e4cf 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -19,7 +19,7 @@ #include #include -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu-common.h" #include "ui/qemu-spice.h" diff --git a/ui/spice-display.c b/ui/spice-display.c index a19b3d95fb..dc7e58d0ed 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -21,7 +21,7 @@ #include "qemu/queue.h" #include "monitor/monitor.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "ui/spice-display.h" diff --git a/ui/vnc.c b/ui/vnc.c index d9e5315e79..8912b78945 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -26,7 +26,7 @@ #include "vnc.h" #include "vnc-jobs.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "qemu/sockets.h" #include "qemu/timer.h" #include "qemu/acl.h" diff --git a/vl.c b/vl.c index 9b80e7abc4..75a30a1720 100644 --- a/vl.c +++ b/vl.c @@ -65,7 +65,7 @@ #endif #ifdef CONFIG_SECCOMP -#include "qemu-seccomp.h" +#include "sysemu/seccomp.h" #endif #ifdef __sun__ @@ -131,18 +131,18 @@ int main(int argc, char **argv) #include "net/slirp.h" #include "monitor/monitor.h" #include "ui/console.h" -#include "sysemu.h" +#include "sysemu/sysemu.h" #include "exec/gdbstub.h" #include "qemu/timer.h" #include "qemu-char.h" #include "qemu/cache-utils.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "hw/block-common.h" #include "migration/block.h" -#include "dma.h" +#include "sysemu/dma.h" #include "audio/audio.h" #include "migration/migration.h" -#include "kvm.h" +#include "sysemu/kvm.h" #include "qapi/qmp/qjson.h" #include "qemu/option.h" #include "qemu/config-file.h" @@ -152,7 +152,7 @@ int main(int argc, char **argv) #ifdef CONFIG_VIRTFS #include "fsdev/qemu-fsdev.h" #endif -#include "qtest.h" +#include "sysemu/qtest.h" #include "disas/disas.h" @@ -163,8 +163,8 @@ int main(int argc, char **argv) #include "trace.h" #include "trace/control.h" #include "qemu/queue.h" -#include "cpus.h" -#include "arch_init.h" +#include "sysemu/cpus.h" +#include "sysemu/arch_init.h" #include "qemu/osdep.h" #include "ui/qemu-spice.h" diff --git a/xen-all.c b/xen-all.c index 6965626db8..b659321184 100644 --- a/xen-all.c +++ b/xen-all.c @@ -17,7 +17,7 @@ #include "qmp-commands.h" #include "qemu/range.h" -#include "xen-mapcache.h" +#include "sysemu/xen-mapcache.h" #include "trace.h" #include "exec/address-spaces.h" diff --git a/xen-mapcache.c b/xen-mapcache.c index 8f4648cc32..dc6d1fadb7 100644 --- a/xen-mapcache.c +++ b/xen-mapcache.c @@ -13,13 +13,13 @@ #include #include "hw/xen_backend.h" -#include "blockdev.h" +#include "sysemu/blockdev.h" #include "qemu/bitmap.h" #include #include -#include "xen-mapcache.h" +#include "sysemu/xen-mapcache.h" #include "trace.h" diff --git a/xen-mapcache.h b/xen-mapcache.h deleted file mode 100644 index c59804060b..0000000000 --- a/xen-mapcache.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2011 Citrix Ltd. - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - * - */ - -#ifndef XEN_MAPCACHE_H -#define XEN_MAPCACHE_H - -#include - -typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr start_addr, - ram_addr_t size, - void *opaque); -#ifdef CONFIG_XEN - -void xen_map_cache_init(phys_offset_to_gaddr_t f, - void *opaque); -uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, - uint8_t lock); -ram_addr_t xen_ram_addr_from_mapcache(void *ptr); -void xen_invalidate_map_cache_entry(uint8_t *buffer); -void xen_invalidate_map_cache(void); - -#else - -static inline void xen_map_cache_init(phys_offset_to_gaddr_t f, - void *opaque) -{ -} - -static inline uint8_t *xen_map_cache(hwaddr phys_addr, - hwaddr size, - uint8_t lock) -{ - abort(); -} - -static inline ram_addr_t xen_ram_addr_from_mapcache(void *ptr) -{ - abort(); -} - -static inline void xen_invalidate_map_cache_entry(uint8_t *buffer) -{ -} - -static inline void xen_invalidate_map_cache(void) -{ -} - -#endif - -#endif /* !XEN_MAPCACHE_H */ -- cgit v1.2.3-55-g7522 From 244eaa7514a944b36273eb8428f32da8e9124fcf Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 12 Dec 2012 12:54:43 +0100 Subject: migration: fix migration_bitmap leak Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- arch_init.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index a8b65416da..e01f0e5ea1 100644 --- a/arch_init.c +++ b/arch_init.c @@ -535,9 +535,13 @@ static void sort_ram_list(void) static void migration_end(void) { - memory_global_dirty_log_stop(); + if (migration_bitmap) { + memory_global_dirty_log_stop(); + g_free(migration_bitmap); + migration_bitmap = NULL; + } - if (migrate_use_xbzrle()) { + if (XBZRLE.cache) { cache_fini(XBZRLE.cache); g_free(XBZRLE.cache); g_free(XBZRLE.encoded_buf); @@ -689,13 +693,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque) } bytes_transferred += bytes_sent; } - memory_global_dirty_log_stop(); + migration_end(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - g_free(migration_bitmap); - migration_bitmap = NULL; - return 0; } -- cgit v1.2.3-55-g7522 From 0d6d3c87a232cc27641dde3491d75c8021745d02 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 14 Nov 2012 15:45:02 +0100 Subject: exec: change ramlist from MRU order to a 1-item cache Most of the time, only 2 items will be active (from/to for a string operation, or code/data). But TCG guests likely won't have gigabytes of memory, so this actually goes down to 1 item. Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- arch_init.c | 1 + exec.c | 49 ++++++++++++++++++++++++++++--------------------- include/exec/cpu-all.h | 1 + 3 files changed, 30 insertions(+), 21 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index e01f0e5ea1..6695ccfdc5 100644 --- a/arch_init.c +++ b/arch_init.c @@ -48,6 +48,7 @@ #include "qemu/config-file.h" #include "qmp-commands.h" #include "trace.h" +#include "exec/cpu-all.h" #ifdef DEBUG_ARCH_INIT #define DPRINTF(fmt, ...) \ diff --git a/exec.c b/exec.c index 28abd7e710..78bae1c7ac 100644 --- a/exec.c +++ b/exec.c @@ -43,6 +43,7 @@ #include "sysemu/xen-mapcache.h" #include "trace.h" #endif +#include "exec/cpu-all.h" #include "exec/cputlb.h" #include "translate-all.h" @@ -1043,6 +1044,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, new_block->length = size; QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next); + ram_list.mru_block = NULL; ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, last_ram_offset() >> TARGET_PAGE_BITS); @@ -1071,6 +1073,7 @@ void qemu_ram_free_from_ptr(ram_addr_t addr) QLIST_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { QLIST_REMOVE(block, next); + ram_list.mru_block = NULL; g_free(block); return; } @@ -1084,6 +1087,7 @@ void qemu_ram_free(ram_addr_t addr) QLIST_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { QLIST_REMOVE(block, next); + ram_list.mru_block = NULL; if (block->flags & RAM_PREALLOC_MASK) { ; } else if (mem_path) { @@ -1189,37 +1193,40 @@ void *qemu_get_ram_ptr(ram_addr_t addr) { RAMBlock *block; + block = ram_list.mru_block; + if (block && addr - block->offset < block->length) { + goto found; + } QLIST_FOREACH(block, &ram_list.blocks, next) { if (addr - block->offset < block->length) { - /* Move this entry to to start of the list. */ - if (block != QLIST_FIRST(&ram_list.blocks)) { - QLIST_REMOVE(block, next); - QLIST_INSERT_HEAD(&ram_list.blocks, block, next); - } - if (xen_enabled()) { - /* We need to check if the requested address is in the RAM - * because we don't want to map the entire memory in QEMU. - * In that case just map until the end of the page. - */ - if (block->offset == 0) { - return xen_map_cache(addr, 0, 0); - } else if (block->host == NULL) { - block->host = - xen_map_cache(block->offset, block->length, 1); - } - } - return block->host + (addr - block->offset); + goto found; } } fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr); abort(); - return NULL; +found: + ram_list.mru_block = block; + if (xen_enabled()) { + /* We need to check if the requested address is in the RAM + * because we don't want to map the entire memory in QEMU. + * In that case just map until the end of the page. + */ + if (block->offset == 0) { + return xen_map_cache(addr, 0, 0); + } else if (block->host == NULL) { + block->host = + xen_map_cache(block->offset, block->length, 1); + } + } + return block->host + (addr - block->offset); } -/* Return a host pointer to ram allocated with qemu_ram_alloc. - * Same as qemu_get_ram_ptr but avoid reordering ramblocks. +/* Return a host pointer to ram allocated with qemu_ram_alloc. Same as + * qemu_get_ram_ptr but do not touch ram_list.mru_block. + * + * ??? Is this still necessary? */ static void *qemu_safe_ram_ptr(ram_addr_t addr) { diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index c12e35f54d..9fe6fc0751 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -495,6 +495,7 @@ typedef struct RAMBlock { typedef struct RAMList { uint8_t *phys_dirty; + RAMBlock *mru_block; QLIST_HEAD(, RAMBlock) blocks; } RAMList; extern RAMList ram_list; -- cgit v1.2.3-55-g7522 From a3161038a1fd17a638a0c606f71e1f799f65f41b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 14 Nov 2012 15:54:48 +0100 Subject: exec: change RAM list to a TAILQ Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- arch_init.c | 24 ++++++++++++------------ dump.c | 8 ++++---- exec.c | 34 +++++++++++++++++----------------- include/exec/cpu-all.h | 4 ++-- memory_mapping.c | 4 ++-- target-i386/arch_dump.c | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 6695ccfdc5..67b14d24c1 100644 --- a/arch_init.c +++ b/arch_init.c @@ -382,7 +382,7 @@ static void migration_bitmap_sync(void) trace_migration_bitmap_sync_start(); memory_global_sync_dirty_bitmap(get_system_memory()); - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) { if (memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE, DIRTY_MEMORY_MIGRATION)) { @@ -424,7 +424,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) ram_addr_t current_addr; if (!block) - block = QLIST_FIRST(&ram_list.blocks); + block = QTAILQ_FIRST(&ram_list.blocks); do { mr = block->mr; @@ -465,9 +465,9 @@ static int ram_save_block(QEMUFile *f, bool last_stage) offset += TARGET_PAGE_SIZE; if (offset >= block->length) { offset = 0; - block = QLIST_NEXT(block, next); + block = QTAILQ_NEXT(block, next); if (!block) - block = QLIST_FIRST(&ram_list.blocks); + block = QTAILQ_FIRST(&ram_list.blocks); } } while (block != last_block || offset != last_offset); @@ -499,7 +499,7 @@ uint64_t ram_bytes_total(void) RAMBlock *block; uint64_t total = 0; - QLIST_FOREACH(block, &ram_list.blocks, next) + QTAILQ_FOREACH(block, &ram_list.blocks, next) total += block->length; return total; @@ -518,18 +518,18 @@ static void sort_ram_list(void) RAMBlock *block, *nblock, **blocks; int n; n = 0; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { ++n; } blocks = g_malloc(n * sizeof *blocks); n = 0; - QLIST_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) { + QTAILQ_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) { blocks[n++] = block; - QLIST_REMOVE(block, next); + QTAILQ_REMOVE(&ram_list.blocks, block, next); } qsort(blocks, n, sizeof *blocks, block_compar); while (--n >= 0) { - QLIST_INSERT_HEAD(&ram_list.blocks, blocks[n], next); + QTAILQ_INSERT_HEAD(&ram_list.blocks, blocks[n], next); } g_free(blocks); } @@ -597,7 +597,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); qemu_put_be64(f, block->length); @@ -763,7 +763,7 @@ static inline void *host_from_stream_offset(QEMUFile *f, qemu_get_buffer(f, (uint8_t *)id, len); id[len] = 0; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (!strncmp(id, block->idstr, sizeof(id))) return memory_region_get_ram_ptr(block->mr) + offset; } @@ -807,7 +807,7 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) id[len] = 0; length = qemu_get_be64(f); - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (!strncmp(id, block->idstr, sizeof(id))) { if (block->length != length) { ret = -EINVAL; diff --git a/dump.c b/dump.c index a26b1a5e1a..4ed1fa8622 100644 --- a/dump.c +++ b/dump.c @@ -427,7 +427,7 @@ static hwaddr get_offset(hwaddr phys_addr, } } - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (s->has_filter) { if (block->offset >= s->begin + s->length || block->offset + block->length <= s->begin) { @@ -594,7 +594,7 @@ static int dump_completed(DumpState *s) static int get_next_block(DumpState *s, RAMBlock *block) { while (1) { - block = QLIST_NEXT(block, next); + block = QTAILQ_NEXT(block, next); if (!block) { /* no more block */ return 1; @@ -670,11 +670,11 @@ static ram_addr_t get_start_block(DumpState *s) RAMBlock *block; if (!s->has_filter) { - s->block = QLIST_FIRST(&ram_list.blocks); + s->block = QTAILQ_FIRST(&ram_list.blocks); return 0; } - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block->offset >= s->begin + s->length || block->offset + block->length <= s->begin) { /* This block is out of the range */ diff --git a/exec.c b/exec.c index 78bae1c7ac..584279a2e3 100644 --- a/exec.c +++ b/exec.c @@ -57,7 +57,7 @@ int phys_ram_fd; static int in_migration; -RAMList ram_list = { .blocks = QLIST_HEAD_INITIALIZER(ram_list.blocks) }; +RAMList ram_list = { .blocks = QTAILQ_HEAD_INITIALIZER(ram_list.blocks) }; static MemoryRegion *system_memory; static MemoryRegion *system_io; @@ -902,15 +902,15 @@ static ram_addr_t find_ram_offset(ram_addr_t size) RAMBlock *block, *next_block; ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX; - if (QLIST_EMPTY(&ram_list.blocks)) + if (QTAILQ_EMPTY(&ram_list.blocks)) return 0; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { ram_addr_t end, next = RAM_ADDR_MAX; end = block->offset + block->length; - QLIST_FOREACH(next_block, &ram_list.blocks, next) { + QTAILQ_FOREACH(next_block, &ram_list.blocks, next) { if (next_block->offset >= end) { next = MIN(next, next_block->offset); } @@ -935,7 +935,7 @@ ram_addr_t last_ram_offset(void) RAMBlock *block; ram_addr_t last = 0; - QLIST_FOREACH(block, &ram_list.blocks, next) + QTAILQ_FOREACH(block, &ram_list.blocks, next) last = MAX(last, block->offset + block->length); return last; @@ -964,7 +964,7 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) RAMBlock *new_block, *block; new_block = NULL; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block->offset == addr) { new_block = block; break; @@ -982,7 +982,7 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) } pstrcat(new_block->idstr, sizeof(new_block->idstr), name); - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block != new_block && !strcmp(block->idstr, new_block->idstr)) { fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n", new_block->idstr); @@ -1043,7 +1043,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, } new_block->length = size; - QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next); + QTAILQ_INSERT_HEAD(&ram_list.blocks, new_block, next); ram_list.mru_block = NULL; ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, @@ -1070,9 +1070,9 @@ void qemu_ram_free_from_ptr(ram_addr_t addr) { RAMBlock *block; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { - QLIST_REMOVE(block, next); + QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; g_free(block); return; @@ -1084,9 +1084,9 @@ void qemu_ram_free(ram_addr_t addr) { RAMBlock *block; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { - QLIST_REMOVE(block, next); + QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; if (block->flags & RAM_PREALLOC_MASK) { ; @@ -1127,7 +1127,7 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length) int flags; void *area, *vaddr; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { offset = addr - block->offset; if (offset < block->length) { vaddr = block->host + offset; @@ -1197,7 +1197,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr) if (block && addr - block->offset < block->length) { goto found; } - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr - block->offset < block->length) { goto found; } @@ -1232,7 +1232,7 @@ static void *qemu_safe_ram_ptr(ram_addr_t addr) { RAMBlock *block; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr - block->offset < block->length) { if (xen_enabled()) { /* We need to check if the requested address is in the RAM @@ -1268,7 +1268,7 @@ static void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size) } else { RAMBlock *block; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr - block->offset < block->length) { if (addr - block->offset + *size > block->length) *size = block->length - addr + block->offset; @@ -1296,7 +1296,7 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr) return 0; } - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { /* This case append when the block is not mapped. */ if (block->host == NULL) { continue; diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 9fe6fc0751..612e95005b 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -487,7 +487,7 @@ typedef struct RAMBlock { ram_addr_t length; uint32_t flags; char idstr[256]; - QLIST_ENTRY(RAMBlock) next; + QTAILQ_ENTRY(RAMBlock) next; #if defined(__linux__) && !defined(TARGET_S390X) int fd; #endif @@ -496,7 +496,7 @@ typedef struct RAMBlock { typedef struct RAMList { uint8_t *phys_dirty; RAMBlock *mru_block; - QLIST_HEAD(, RAMBlock) blocks; + QTAILQ_HEAD(, RAMBlock) blocks; } RAMList; extern RAMList ram_list; diff --git a/memory_mapping.c b/memory_mapping.c index 530f1d6793..ff45b3a239 100644 --- a/memory_mapping.c +++ b/memory_mapping.c @@ -200,7 +200,7 @@ int qemu_get_guest_memory_mapping(MemoryMappingList *list) * If the guest doesn't use paging, the virtual address is equal to physical * address. */ - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { offset = block->offset; length = block->length; create_new_memory_mapping(list, offset, offset, length); @@ -213,7 +213,7 @@ void qemu_get_guest_simple_memory_mapping(MemoryMappingList *list) { RAMBlock *block; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { create_new_memory_mapping(list, block->offset, 0, block->length); } } diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c index 8209ce9ee2..2cd2f7f09e 100644 --- a/target-i386/arch_dump.c +++ b/target-i386/arch_dump.c @@ -403,7 +403,7 @@ int cpu_get_dump_info(ArchDumpInfo *info) } else { info->d_class = ELFCLASS32; - QLIST_FOREACH(block, &ram_list.blocks, next) { + QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block->offset + block->length > UINT_MAX) { /* The memory size is greater than 4G */ info->d_class = ELFCLASS64; -- cgit v1.2.3-55-g7522 From abb26d63e7e4492d306c13b7e0e799d4c11a067c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 14 Nov 2012 16:00:51 +0100 Subject: exec: sort the memory from biggest to smallest Signed-off-by: Paolo Bonzini Signed-off-by: Juan Quintela --- arch_init.c | 30 ------------------------------ exec.c | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 32 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 67b14d24c1..5c8df3af41 100644 --- a/arch_init.c +++ b/arch_init.c @@ -505,35 +505,6 @@ uint64_t ram_bytes_total(void) return total; } -static int block_compar(const void *a, const void *b) -{ - RAMBlock * const *ablock = a; - RAMBlock * const *bblock = b; - - return strcmp((*ablock)->idstr, (*bblock)->idstr); -} - -static void sort_ram_list(void) -{ - RAMBlock *block, *nblock, **blocks; - int n; - n = 0; - QTAILQ_FOREACH(block, &ram_list.blocks, next) { - ++n; - } - blocks = g_malloc(n * sizeof *blocks); - n = 0; - QTAILQ_FOREACH_SAFE(block, &ram_list.blocks, next, nblock) { - blocks[n++] = block; - QTAILQ_REMOVE(&ram_list.blocks, block, next); - } - qsort(blocks, n, sizeof *blocks, block_compar); - while (--n >= 0) { - QTAILQ_INSERT_HEAD(&ram_list.blocks, blocks[n], next); - } - g_free(blocks); -} - static void migration_end(void) { if (migration_bitmap) { @@ -562,7 +533,6 @@ static void reset_ram_globals(void) { last_block = NULL; last_offset = 0; - sort_ram_list(); } #define MAX_WAIT 50 /* ms, half buffered_file limit */ diff --git a/exec.c b/exec.c index 584279a2e3..1ee4fa649d 100644 --- a/exec.c +++ b/exec.c @@ -1007,7 +1007,7 @@ static int memory_try_enable_merging(void *addr, size_t len) ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr) { - RAMBlock *new_block; + RAMBlock *block, *new_block; size = TARGET_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); @@ -1043,7 +1043,17 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, } new_block->length = size; - QTAILQ_INSERT_HEAD(&ram_list.blocks, new_block, next); + /* Keep the list sorted from biggest to smallest block. */ + QTAILQ_FOREACH(block, &ram_list.blocks, next) { + if (block->length < new_block->length) { + break; + } + } + if (block) { + QTAILQ_INSERT_BEFORE(block, new_block, next); + } else { + QTAILQ_INSERT_TAIL(&ram_list.blocks, new_block, next); + } ram_list.mru_block = NULL; ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, -- cgit v1.2.3-55-g7522 From f798b07f517143df3a1e38bccc3f72ade2f080dc Mon Sep 17 00:00:00 2001 From: Umesh Deshpande Date: Thu, 18 Aug 2011 11:41:17 -0700 Subject: add a version number to ram_list This will be used to detect if last_block might have become invalid across different calls to ram_save_live. Signed-off-by: Paolo Bonzini Signed-off-by: Umesh Deshpande Signed-off-by: Juan Quintela Reviewed-by: Orit Wasserman --- arch_init.c | 7 ++++++- exec.c | 4 ++++ include/exec/cpu-all.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 5c8df3af41..1f737dc1eb 100644 --- a/arch_init.c +++ b/arch_init.c @@ -336,6 +336,7 @@ static RAMBlock *last_block; static ram_addr_t last_offset; static unsigned long *migration_bitmap; static uint64_t migration_dirty_pages; +static uint32_t last_version; static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr, ram_addr_t offset) @@ -406,7 +407,6 @@ static void migration_bitmap_sync(void) } } - /* * ram_save_block: Writes a page of memory to the stream f * @@ -533,6 +533,7 @@ static void reset_ram_globals(void) { last_block = NULL; last_offset = 0; + last_version = ram_list.version; } #define MAX_WAIT 50 /* ms, half buffered_file limit */ @@ -587,6 +588,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) uint64_t expected_downtime; MigrationState *s = migrate_get_current(); + if (ram_list.version != last_version) { + reset_ram_globals(); + } + bytes_transferred_last = bytes_transferred; bwidth = qemu_get_clock_ns(rt_clock); diff --git a/exec.c b/exec.c index 1ee4fa649d..8478bef548 100644 --- a/exec.c +++ b/exec.c @@ -1056,6 +1056,8 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, } ram_list.mru_block = NULL; + ram_list.version++; + ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, last_ram_offset() >> TARGET_PAGE_BITS); memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS), @@ -1084,6 +1086,7 @@ void qemu_ram_free_from_ptr(ram_addr_t addr) if (addr == block->offset) { QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; + ram_list.version++; g_free(block); return; } @@ -1098,6 +1101,7 @@ void qemu_ram_free(ram_addr_t addr) if (addr == block->offset) { QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; + ram_list.version++; if (block->flags & RAM_PREALLOC_MASK) { ; } else if (mem_path) { diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 612e95005b..f052b38974 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -497,6 +497,7 @@ typedef struct RAMList { uint8_t *phys_dirty; RAMBlock *mru_block; QTAILQ_HEAD(, RAMBlock) blocks; + uint32_t version; } RAMList; extern RAMList ram_list; -- cgit v1.2.3-55-g7522 From b2a8658ef5dc57ea9e7a45091724a719dd4bdcd3 Mon Sep 17 00:00:00 2001 From: Umesh Deshpande Date: Wed, 17 Aug 2011 00:01:33 -0700 Subject: protect the ramlist with a separate mutex Add the new mutex that protects shared state between ram_save_live and the iothread. If the iothread mutex has to be taken together with the ramlist mutex, the iothread shall always be _outside_. Signed-off-by: Paolo Bonzini Signed-off-by: Umesh Deshpande Signed-off-by: Juan Quintela Reviewed-by: Orit Wasserman --- arch_init.c | 9 ++++++++- exec.c | 29 +++++++++++++++++++++++++++-- include/exec/cpu-all.h | 9 +++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 1f737dc1eb..fad1c4099a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -528,7 +528,6 @@ static void ram_migration_cancel(void *opaque) migration_end(); } - static void reset_ram_globals(void) { last_block = NULL; @@ -547,6 +546,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) bitmap_set(migration_bitmap, 0, ram_pages); migration_dirty_pages = ram_pages; + qemu_mutex_lock_ramlist(); bytes_transferred = 0; reset_ram_globals(); @@ -574,6 +574,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, block->length); } + qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); return 0; @@ -588,6 +589,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) uint64_t expected_downtime; MigrationState *s = migrate_get_current(); + qemu_mutex_lock_ramlist(); + if (ram_list.version != last_version) { reset_ram_globals(); } @@ -636,6 +639,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) bwidth = 0.000001; } + qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; @@ -656,6 +660,8 @@ static int ram_save_complete(QEMUFile *f, void *opaque) { migration_bitmap_sync(); + qemu_mutex_lock_ramlist(); + /* try transferring iterative blocks of memory */ /* flush all remaining blocks regardless of rate limiting */ @@ -671,6 +677,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) } migration_end(); + qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); return 0; diff --git a/exec.c b/exec.c index 8478bef548..a6923addd4 100644 --- a/exec.c +++ b/exec.c @@ -213,6 +213,7 @@ bool memory_region_is_unassigned(MemoryRegion *mr) void cpu_exec_init_all(void) { #if !defined(CONFIG_USER_ONLY) + qemu_mutex_init(&ram_list.mutex); memory_map_init(); io_mem_init(); #endif @@ -801,6 +802,16 @@ void qemu_flush_coalesced_mmio_buffer(void) kvm_flush_coalesced_mmio_buffer(); } +void qemu_mutex_lock_ramlist(void) +{ + qemu_mutex_lock(&ram_list.mutex); +} + +void qemu_mutex_unlock_ramlist(void) +{ + qemu_mutex_unlock(&ram_list.mutex); +} + #if defined(__linux__) && !defined(TARGET_S390X) #include @@ -982,6 +993,8 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) } pstrcat(new_block->idstr, sizeof(new_block->idstr), name); + /* This assumes the iothread lock is taken here too. */ + qemu_mutex_lock_ramlist(); QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block != new_block && !strcmp(block->idstr, new_block->idstr)) { fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n", @@ -989,6 +1002,7 @@ void qemu_ram_set_idstr(ram_addr_t addr, const char *name, DeviceState *dev) abort(); } } + qemu_mutex_unlock_ramlist(); } static int memory_try_enable_merging(void *addr, size_t len) @@ -1012,6 +1026,8 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, size = TARGET_PAGE_ALIGN(size); new_block = g_malloc0(sizeof(*new_block)); + /* This assumes the iothread lock is taken here too. */ + qemu_mutex_lock_ramlist(); new_block->mr = mr; new_block->offset = find_ram_offset(size); if (host) { @@ -1057,6 +1073,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, ram_list.mru_block = NULL; ram_list.version++; + qemu_mutex_unlock_ramlist(); ram_list.phys_dirty = g_realloc(ram_list.phys_dirty, last_ram_offset() >> TARGET_PAGE_BITS); @@ -1082,21 +1099,26 @@ void qemu_ram_free_from_ptr(ram_addr_t addr) { RAMBlock *block; + /* This assumes the iothread lock is taken here too. */ + qemu_mutex_lock_ramlist(); QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; ram_list.version++; g_free(block); - return; + break; } } + qemu_mutex_unlock_ramlist(); } void qemu_ram_free(ram_addr_t addr) { RAMBlock *block; + /* This assumes the iothread lock is taken here too. */ + qemu_mutex_lock_ramlist(); QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { QTAILQ_REMOVE(&ram_list.blocks, block, next); @@ -1127,9 +1149,10 @@ void qemu_ram_free(ram_addr_t addr) #endif } g_free(block); - return; + break; } } + qemu_mutex_unlock_ramlist(); } @@ -1207,6 +1230,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr) { RAMBlock *block; + /* The list is protected by the iothread lock here. */ block = ram_list.mru_block; if (block && addr - block->offset < block->length) { goto found; @@ -1246,6 +1270,7 @@ static void *qemu_safe_ram_ptr(ram_addr_t addr) { RAMBlock *block; + /* The list is protected by the iothread lock here. */ QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr - block->offset < block->length) { if (xen_enabled()) { diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index f052b38974..439e88deb4 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -22,6 +22,7 @@ #include "qemu-common.h" #include "qemu/tls.h" #include "exec/cpu-common.h" +#include "qemu/thread.h" /* some important defines: * @@ -487,6 +488,9 @@ typedef struct RAMBlock { ram_addr_t length; uint32_t flags; char idstr[256]; + /* Reads can take either the iothread or the ramlist lock. + * Writes must take both locks. + */ QTAILQ_ENTRY(RAMBlock) next; #if defined(__linux__) && !defined(TARGET_S390X) int fd; @@ -494,8 +498,11 @@ typedef struct RAMBlock { } RAMBlock; typedef struct RAMList { + QemuMutex mutex; + /* Protected by the iothread lock. */ uint8_t *phys_dirty; RAMBlock *mru_block; + /* Protected by the ramlist lock. */ QTAILQ_HEAD(, RAMBlock) blocks; uint32_t version; } RAMList; @@ -516,6 +523,8 @@ extern int mem_prealloc; void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); ram_addr_t last_ram_offset(void); +void qemu_mutex_lock_ramlist(void); +void qemu_mutex_unlock_ramlist(void); #endif /* !CONFIG_USER_ONLY */ int cpu_memory_rw_debug(CPUArchState *env, target_ulong addr, -- cgit v1.2.3-55-g7522 From e4ed1541ac9413eac494a03532e34beaf8a7d1c5 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Fri, 21 Sep 2012 11:18:18 +0200 Subject: savevm: New save live migration method: pending Code just now does (simplified for clarity) if (qemu_savevm_state_iterate(s->file) == 1) { vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); qemu_savevm_state_complete(s->file); } Problem here is that qemu_savevm_state_iterate() returns 1 when it knows that remaining memory to sent takes less than max downtime. But this means that we could end spending 2x max_downtime, one downtime in qemu_savevm_iterate, and the other in qemu_savevm_state_complete. Changed code to: pending_size = qemu_savevm_state_pending(s->file, max_size); DPRINTF("pending size %lu max %lu\n", pending_size, max_size); if (pending_size >= max_size) { ret = qemu_savevm_state_iterate(s->file); } else { vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); qemu_savevm_state_complete(s->file); } So what we do is: at current network speed, we calculate the maximum number of bytes we can sent: max_size. Then we ask every save_live section how much they have pending. If they are less than max_size, we move to complete phase, otherwise we do an iterate one. This makes things much simpler, because now individual sections don't have to caluclate the bandwidth (it was implossible to do right from there). Signed-off-by: Juan Quintela Reviewed-by: Paolo Bonzini --- arch_init.c | 48 ++++++++++++++++-------------------------- block-migration.c | 49 +++++++++---------------------------------- buffered_file.c | 25 +++++++++++++++------- include/migration/migration.h | 2 +- include/migration/vmstate.h | 1 + include/sysemu/sysemu.h | 1 + migration.c | 22 ++++++++++++------- savevm.c | 19 +++++++++++++++++ 8 files changed, 83 insertions(+), 84 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index fad1c4099a..af1ae9f72a 100644 --- a/arch_init.c +++ b/arch_init.c @@ -582,12 +582,9 @@ static int ram_save_setup(QEMUFile *f, void *opaque) static int ram_save_iterate(QEMUFile *f, void *opaque) { - uint64_t bytes_transferred_last; - double bwidth = 0; int ret; int i; - uint64_t expected_downtime; - MigrationState *s = migrate_get_current(); + int64_t t0; qemu_mutex_lock_ramlist(); @@ -595,9 +592,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) reset_ram_globals(); } - bytes_transferred_last = bytes_transferred; - bwidth = qemu_get_clock_ns(rt_clock); - + t0 = qemu_get_clock_ns(rt_clock); i = 0; while ((ret = qemu_file_rate_limit(f)) == 0) { int bytes_sent; @@ -615,7 +610,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) iterations */ if ((i & 63) == 0) { - uint64_t t1 = (qemu_get_clock_ns(rt_clock) - bwidth) / 1000000; + uint64_t t1 = (qemu_get_clock_ns(rt_clock) - t0) / 1000000; if (t1 > MAX_WAIT) { DPRINTF("big wait: %" PRIu64 " milliseconds, %d iterations\n", t1, i); @@ -629,31 +624,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) return ret; } - bwidth = qemu_get_clock_ns(rt_clock) - bwidth; - bwidth = (bytes_transferred - bytes_transferred_last) / bwidth; - - /* if we haven't transferred anything this round, force - * expected_downtime to a very high value, but without - * crashing */ - if (bwidth == 0) { - bwidth = 0.000001; - } - qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; - DPRINTF("ram_save_live: expected(%" PRIu64 ") <= max(" PRIu64 ")?\n", - expected_downtime, migrate_max_downtime()); - - if (expected_downtime <= migrate_max_downtime()) { - migration_bitmap_sync(); - expected_downtime = ram_save_remaining() * TARGET_PAGE_SIZE / bwidth; - s->expected_downtime = expected_downtime / 1000000; /* ns -> ms */ - - return expected_downtime <= migrate_max_downtime(); - } - return 0; + return i; } static int ram_save_complete(QEMUFile *f, void *opaque) @@ -683,6 +657,19 @@ static int ram_save_complete(QEMUFile *f, void *opaque) return 0; } +static uint64_t ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size) +{ + uint64_t remaining_size; + + remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE; + + if (remaining_size < max_size) { + migration_bitmap_sync(); + remaining_size = ram_save_remaining() * TARGET_PAGE_SIZE; + } + return remaining_size; +} + static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host) { int ret, rc = 0; @@ -869,6 +856,7 @@ SaveVMHandlers savevm_ram_handlers = { .save_live_setup = ram_save_setup, .save_live_iterate = ram_save_iterate, .save_live_complete = ram_save_complete, + .save_live_pending = ram_save_pending, .load_state = ram_load, .cancel = ram_migration_cancel, }; diff --git a/block-migration.c b/block-migration.c index ca4ba3fffb..6acf3e1682 100644 --- a/block-migration.c +++ b/block-migration.c @@ -77,9 +77,7 @@ typedef struct BlkMigState { int64_t total_sector_sum; int prev_progress; int bulk_completed; - long double total_time; long double prev_time_offset; - int reads; } BlkMigState; static BlkMigState block_mig_state; @@ -132,12 +130,6 @@ uint64_t blk_mig_bytes_total(void) return sum << BDRV_SECTOR_BITS; } -static inline long double compute_read_bwidth(void) -{ - assert(block_mig_state.total_time != 0); - return (block_mig_state.reads / block_mig_state.total_time) * BLOCK_SIZE; -} - static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector) { int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK; @@ -191,8 +183,6 @@ static void blk_mig_read_cb(void *opaque, int ret) blk->ret = ret; - block_mig_state.reads++; - block_mig_state.total_time += (curr_time - block_mig_state.prev_time_offset); block_mig_state.prev_time_offset = curr_time; QSIMPLEQ_INSERT_TAIL(&block_mig_state.blk_list, blk, entry); @@ -310,8 +300,6 @@ static void init_blk_migration(QEMUFile *f) block_mig_state.total_sector_sum = 0; block_mig_state.prev_progress = -1; block_mig_state.bulk_completed = 0; - block_mig_state.total_time = 0; - block_mig_state.reads = 0; bdrv_iterate(init_blk_migration_it, NULL); } @@ -493,32 +481,6 @@ static int64_t get_remaining_dirty(void) return dirty * BLOCK_SIZE; } -static int is_stage2_completed(void) -{ - int64_t remaining_dirty; - long double bwidth; - - if (block_mig_state.bulk_completed == 1) { - - remaining_dirty = get_remaining_dirty(); - if (remaining_dirty == 0) { - return 1; - } - - bwidth = compute_read_bwidth(); - - if ((remaining_dirty / bwidth) <= - migrate_max_downtime()) { - /* finish stage2 because we think that we can finish remaining work - below max_downtime */ - - return 1; - } - } - - return 0; -} - static void blk_mig_cleanup(void) { BlkMigDevState *bmds; @@ -619,7 +581,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque) qemu_put_be64(f, BLK_MIG_FLAG_EOS); - return is_stage2_completed(); + return 0; } static int block_save_complete(QEMUFile *f, void *opaque) @@ -659,6 +621,14 @@ static int block_save_complete(QEMUFile *f, void *opaque) return 0; } +static uint64_t block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size) +{ + + DPRINTF("Enter save live pending %ld\n", get_remaining_dirty()); + + return get_remaining_dirty(); +} + static int block_load(QEMUFile *f, void *opaque, int version_id) { static int banner_printed; @@ -755,6 +725,7 @@ SaveVMHandlers savevm_block_handlers = { .save_live_setup = block_save_setup, .save_live_iterate = block_save_iterate, .save_live_complete = block_save_complete, + .save_live_pending = block_save_pending, .load_state = block_load, .cancel = block_migration_cancel, .is_active = block_is_active, diff --git a/buffered_file.c b/buffered_file.c index be9424b543..fdf7efa964 100644 --- a/buffered_file.c +++ b/buffered_file.c @@ -181,13 +181,15 @@ static int64_t buffered_get_rate_limit(void *opaque) return s->xfer_limit; } -/* 10ms xfer_limit is the limit that we should write each 10ms */ +/* 100ms xfer_limit is the limit that we should write each 100ms */ #define BUFFER_DELAY 100 static void *buffered_file_thread(void *opaque) { QEMUFileBuffered *s = opaque; - int64_t expire_time = qemu_get_clock_ms(rt_clock) + BUFFER_DELAY; + int64_t initial_time = qemu_get_clock_ms(rt_clock); + int64_t max_size = 0; + bool last_round = false; while (true) { int64_t current_time = qemu_get_clock_ms(rt_clock); @@ -195,13 +197,22 @@ static void *buffered_file_thread(void *opaque) if (s->migration_state->complete) { break; } - if (current_time >= expire_time) { + if (current_time >= initial_time + BUFFER_DELAY) { + uint64_t transferred_bytes = s->bytes_xfer; + uint64_t time_spent = current_time - initial_time; + double bandwidth = transferred_bytes / time_spent; + max_size = bandwidth * migrate_max_downtime() / 1000000; + + DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64 + " bandwidth %g max_size %" PRId64 "\n", + transferred_bytes, time_spent, bandwidth, max_size); + s->bytes_xfer = 0; - expire_time = current_time + BUFFER_DELAY; + initial_time = current_time; } - if (s->bytes_xfer >= s->xfer_limit) { + if (!last_round && (s->bytes_xfer >= s->xfer_limit)) { /* usleep expects microseconds */ - g_usleep((expire_time - current_time)*1000); + g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); } if (buffered_flush(s) < 0) { break; @@ -210,7 +221,7 @@ static void *buffered_file_thread(void *opaque) DPRINTF("file is ready\n"); if (s->bytes_xfer < s->xfer_limit) { DPRINTF("notifying client\n"); - migrate_fd_put_ready(s->migration_state); + last_round = migrate_fd_put_ready(s->migration_state, max_size); } } diff --git a/include/migration/migration.h b/include/migration/migration.h index 92190f2afd..9571ec532c 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -81,7 +81,7 @@ void migrate_fd_connect(MigrationState *s); ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, size_t size); -void migrate_fd_put_ready(MigrationState *s); +bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size); int migrate_fd_close(MigrationState *s); void add_migration_state_change_notifier(Notifier *notify); diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 623af0a29a..f27276c2d8 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -35,6 +35,7 @@ typedef struct SaveVMHandlers { int (*save_live_setup)(QEMUFile *f, void *opaque); int (*save_live_iterate)(QEMUFile *f, void *opaque); int (*save_live_complete)(QEMUFile *f, void *opaque); + uint64_t (*save_live_pending)(QEMUFile *f, void *opaque, uint64_t max_size); void (*cancel)(void *opaque); LoadStateHandler *load_state; bool (*is_active)(void *opaque); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 8eaa4707a0..28a783e2be 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -78,6 +78,7 @@ int qemu_savevm_state_begin(QEMUFile *f, int qemu_savevm_state_iterate(QEMUFile *f); int qemu_savevm_state_complete(QEMUFile *f); void qemu_savevm_state_cancel(QEMUFile *f); +uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); int qemu_loadvm_state(QEMUFile *f); /* SLIRP */ diff --git a/migration.c b/migration.c index 11123bcea0..b6374ae072 100644 --- a/migration.c +++ b/migration.c @@ -316,15 +316,17 @@ ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data, return ret; } -void migrate_fd_put_ready(MigrationState *s) +bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size) { int ret; + uint64_t pending_size; + bool last_round = false; qemu_mutex_lock_iothread(); if (s->state != MIG_STATE_ACTIVE) { DPRINTF("put_ready returning because of non-active state\n"); qemu_mutex_unlock_iothread(); - return; + return false; } if (s->first_time) { s->first_time = false; @@ -334,15 +336,19 @@ void migrate_fd_put_ready(MigrationState *s) DPRINTF("failed, %d\n", ret); migrate_fd_error(s); qemu_mutex_unlock_iothread(); - return; + return false; } } DPRINTF("iterate\n"); - ret = qemu_savevm_state_iterate(s->file); - if (ret < 0) { - migrate_fd_error(s); - } else if (ret == 1) { + pending_size = qemu_savevm_state_pending(s->file, max_size); + DPRINTF("pending size %lu max %lu\n", pending_size, max_size); + if (pending_size >= max_size) { + ret = qemu_savevm_state_iterate(s->file); + if (ret < 0) { + migrate_fd_error(s); + } + } else { int old_vm_running = runstate_is_running(); int64_t start_time, end_time; @@ -368,9 +374,11 @@ void migrate_fd_put_ready(MigrationState *s) vm_start(); } } + last_round = true; } qemu_mutex_unlock_iothread(); + return last_round; } static void migrate_fd_cancel(MigrationState *s) diff --git a/savevm.c b/savevm.c index c93d0b4fde..bcdb92ee81 100644 --- a/savevm.c +++ b/savevm.c @@ -1753,6 +1753,25 @@ int qemu_savevm_state_complete(QEMUFile *f) return qemu_file_get_error(f); } +uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size) +{ + SaveStateEntry *se; + uint64_t ret = 0; + + QTAILQ_FOREACH(se, &savevm_handlers, entry) { + if (!se->ops || !se->ops->save_live_pending) { + continue; + } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } + ret += se->ops->save_live_pending(f, se->opaque, max_size); + } + return ret; +} + void qemu_savevm_state_cancel(QEMUFile *f) { SaveStateEntry *se; -- cgit v1.2.3-55-g7522 From b23a9a5cad356cdc8e25d4be72e53096a27ea722 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 17 Oct 2012 20:08:04 +0200 Subject: ram: rename last_block to last_seen_block Signed-off-by: Juan Quintela --- arch_init.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index af1ae9f72a..4351d304a8 100644 --- a/arch_init.c +++ b/arch_init.c @@ -332,7 +332,10 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, return bytes_sent; } -static RAMBlock *last_block; + +/* This is the last block that we have visited serching for dirty pages + */ +static RAMBlock *last_seen_block; static ram_addr_t last_offset; static unsigned long *migration_bitmap; static uint64_t migration_dirty_pages; @@ -417,7 +420,7 @@ static void migration_bitmap_sync(void) static int ram_save_block(QEMUFile *f, bool last_stage) { - RAMBlock *block = last_block; + RAMBlock *block = last_seen_block; ram_addr_t offset = last_offset; int bytes_sent = -1; MemoryRegion *mr; @@ -430,7 +433,8 @@ static int ram_save_block(QEMUFile *f, bool last_stage) mr = block->mr; if (migration_bitmap_test_and_reset_dirty(mr, offset)) { uint8_t *p; - int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0; + int cont = (block == last_seen_block) ? + RAM_SAVE_FLAG_CONTINUE : 0; p = memory_region_get_ram_ptr(mr) + offset; @@ -469,9 +473,9 @@ static int ram_save_block(QEMUFile *f, bool last_stage) if (!block) block = QTAILQ_FIRST(&ram_list.blocks); } - } while (block != last_block || offset != last_offset); + } while (block != last_seen_block || offset != last_offset); - last_block = block; + last_seen_block = block; last_offset = offset; return bytes_sent; @@ -530,7 +534,7 @@ static void ram_migration_cancel(void *opaque) static void reset_ram_globals(void) { - last_block = NULL; + last_seen_block = NULL; last_offset = 0; last_version = ram_list.version; } -- cgit v1.2.3-55-g7522 From 5f718a15d0db3775bbcf2755a35dd6b019bcff8b Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 17 Oct 2012 20:10:55 +0200 Subject: ram: Add last_sent_block This is the last block from where we have sent data. Signed-off-by: Orit Wasserman Signed-off-by: Juan Quintela --- arch_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 4351d304a8..caac526f2f 100644 --- a/arch_init.c +++ b/arch_init.c @@ -336,6 +336,8 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, /* This is the last block that we have visited serching for dirty pages */ static RAMBlock *last_seen_block; +/* This is the last block from where we have sent data */ +static RAMBlock *last_sent_block; static ram_addr_t last_offset; static unsigned long *migration_bitmap; static uint64_t migration_dirty_pages; @@ -433,7 +435,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) mr = block->mr; if (migration_bitmap_test_and_reset_dirty(mr, offset)) { uint8_t *p; - int cont = (block == last_seen_block) ? + int cont = (block == last_sent_block) ? RAM_SAVE_FLAG_CONTINUE : 0; p = memory_region_get_ram_ptr(mr) + offset; @@ -462,6 +464,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) /* if page is unmodified, continue to the next */ if (bytes_sent != 0) { + last_sent_block = block; break; } } @@ -535,6 +538,7 @@ static void ram_migration_cancel(void *opaque) static void reset_ram_globals(void) { last_seen_block = NULL; + last_sent_block = NULL; last_offset = 0; last_version = ram_list.version; } -- cgit v1.2.3-55-g7522 From ece7931817e03a4d946c15716fab5e4f781663c9 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Wed, 17 Oct 2012 20:27:15 +0200 Subject: ram: Use memory_region_test_and_clear_dirty This avoids having to do two walks over the dirty bitmap, once reading the dirty bits, and anthoer cleaning them. Signed-off-by: Juan Quintela --- arch_init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index caac526f2f..9f32ee0124 100644 --- a/arch_init.c +++ b/arch_init.c @@ -390,13 +390,12 @@ static void migration_bitmap_sync(void) QTAILQ_FOREACH(block, &ram_list.blocks, next) { for (addr = 0; addr < block->length; addr += TARGET_PAGE_SIZE) { - if (memory_region_get_dirty(block->mr, addr, TARGET_PAGE_SIZE, - DIRTY_MEMORY_MIGRATION)) { + if (memory_region_test_and_clear_dirty(block->mr, + addr, TARGET_PAGE_SIZE, + DIRTY_MEMORY_MIGRATION)) { migration_bitmap_set_dirty(block->mr, addr); } } - memory_region_reset_dirty(block->mr, 0, block->length, - DIRTY_MEMORY_MIGRATION); } trace_migration_bitmap_sync_end(migration_dirty_pages - num_dirty_pages_init); -- cgit v1.2.3-55-g7522 From 4c8ae0f60e63478aea0a1741cca95474b68fb949 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 18 Oct 2012 00:00:59 +0200 Subject: ram: optimize migration bitmap walking Instead of testing each page individually, we search what is the next dirty page with a bitmap operation. We have to reorganize the code to move from a "for" loop, to a while(dirty) loop. Signed-off-by: Juan Quintela --- arch_init.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 9f32ee0124..74dc9c8c51 100644 --- a/arch_init.c +++ b/arch_init.c @@ -343,18 +343,21 @@ static unsigned long *migration_bitmap; static uint64_t migration_dirty_pages; static uint32_t last_version; -static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr, - ram_addr_t offset) +static inline +ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr, + ram_addr_t start) { - bool ret; - int nr = (mr->ram_addr + offset) >> TARGET_PAGE_BITS; + unsigned long base = mr->ram_addr >> TARGET_PAGE_BITS; + unsigned long nr = base + (start >> TARGET_PAGE_BITS); + unsigned long size = base + (int128_get64(mr->size) >> TARGET_PAGE_BITS); - ret = test_and_clear_bit(nr, migration_bitmap); + unsigned long next = find_next_bit(migration_bitmap, size, nr); - if (ret) { + if (next < size) { + clear_bit(next, migration_bitmap); migration_dirty_pages--; } - return ret; + return (next - base) << TARGET_PAGE_BITS; } static inline bool migration_bitmap_set_dirty(MemoryRegion *mr, @@ -423,6 +426,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) { RAMBlock *block = last_seen_block; ram_addr_t offset = last_offset; + bool complete_round = false; int bytes_sent = -1; MemoryRegion *mr; ram_addr_t current_addr; @@ -430,9 +434,21 @@ static int ram_save_block(QEMUFile *f, bool last_stage) if (!block) block = QTAILQ_FIRST(&ram_list.blocks); - do { + while (true) { mr = block->mr; - if (migration_bitmap_test_and_reset_dirty(mr, offset)) { + offset = migration_bitmap_find_and_reset_dirty(mr, offset); + if (complete_round && block == last_seen_block && + offset >= last_offset) { + break; + } + if (offset >= block->length) { + offset = 0; + block = QTAILQ_NEXT(block, next); + if (!block) { + block = QTAILQ_FIRST(&ram_list.blocks); + complete_round = true; + } + } else { uint8_t *p; int cont = (block == last_sent_block) ? RAM_SAVE_FLAG_CONTINUE : 0; @@ -467,16 +483,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) break; } } - - offset += TARGET_PAGE_SIZE; - if (offset >= block->length) { - offset = 0; - block = QTAILQ_NEXT(block, next); - if (!block) - block = QTAILQ_FIRST(&ram_list.blocks); - } - } while (block != last_seen_block || offset != last_offset); - + } last_seen_block = block; last_offset = offset; -- cgit v1.2.3-55-g7522 From 3f7d7b098194ec893efa037491f6231687ff043a Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Thu, 18 Oct 2012 13:56:35 +0200 Subject: ram: account the amount of transferred ram better Signed-off-by: Juan Quintela --- arch_init.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 74dc9c8c51..4015bfd8c5 100644 --- a/arch_init.c +++ b/arch_init.c @@ -265,16 +265,21 @@ uint64_t xbzrle_mig_pages_overflow(void) return acct_info.xbzrle_overflows; } -static void save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset, - int cont, int flag) +static size_t save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t offset, + int cont, int flag) { - qemu_put_be64(f, offset | cont | flag); - if (!cont) { - qemu_put_byte(f, strlen(block->idstr)); - qemu_put_buffer(f, (uint8_t *)block->idstr, - strlen(block->idstr)); - } + size_t size; + + qemu_put_be64(f, offset | cont | flag); + size = 8; + if (!cont) { + qemu_put_byte(f, strlen(block->idstr)); + qemu_put_buffer(f, (uint8_t *)block->idstr, + strlen(block->idstr)); + size += 1 + strlen(block->idstr); + } + return size; } #define ENCODING_FLAG_XBZRLE 0x1 @@ -321,11 +326,11 @@ static int save_xbzrle_page(QEMUFile *f, uint8_t *current_data, } /* Send XBZRLE based compressed page */ - save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE); + bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_XBZRLE); qemu_put_byte(f, ENCODING_FLAG_XBZRLE); qemu_put_be16(f, encoded_len); qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); - bytes_sent = encoded_len + 1 + 2; + bytes_sent += encoded_len + 1 + 2; acct_info.xbzrle_pages++; acct_info.xbzrle_bytes += bytes_sent; @@ -457,9 +462,10 @@ static int ram_save_block(QEMUFile *f, bool last_stage) if (is_dup_page(p)) { acct_info.dup_pages++; - save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_COMPRESS); + bytes_sent = save_block_hdr(f, block, offset, cont, + RAM_SAVE_FLAG_COMPRESS); qemu_put_byte(f, *p); - bytes_sent = 1; + bytes_sent += 1; } else if (migrate_use_xbzrle()) { current_addr = block->offset + offset; bytes_sent = save_xbzrle_page(f, p, current_addr, block, @@ -471,9 +477,9 @@ static int ram_save_block(QEMUFile *f, bool last_stage) /* either we didn't send yet (we may have had XBZRLE overflow) */ if (bytes_sent == -1) { - save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE); + bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE); qemu_put_buffer(f, p, TARGET_PAGE_SIZE); - bytes_sent = TARGET_PAGE_SIZE; + bytes_sent += TARGET_PAGE_SIZE; acct_info.norm_pages++; } -- cgit v1.2.3-55-g7522 From b823ceaadfaad65f3a034ada394b33ca1bf1a914 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Mon, 10 Dec 2012 13:27:50 +0100 Subject: ram: refactor ram_save_block() return value It could only return 0 if we only found dirty xbzrle pages that hadn't changed (i.e. they were written with the same content). We don't care about that case, it is the same than nothing dirty. So now the return of the function is how much have it written, nothing else. Adjust callers. And we also made ram_save_iterate() return the number of transferred bytes, not the number of transferred pages. Signed-off-by: Juan Quintela --- arch_init.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'arch_init.c') diff --git a/arch_init.c b/arch_init.c index 4015bfd8c5..86f85443d7 100644 --- a/arch_init.c +++ b/arch_init.c @@ -422,9 +422,8 @@ static void migration_bitmap_sync(void) /* * ram_save_block: Writes a page of memory to the stream f * - * Returns: 0: if the page hasn't changed - * -1: if there are no more dirty pages - * n: the amount of bytes written in other case + * Returns: The number of bytes written. + * 0 means no dirty pages */ static int ram_save_block(QEMUFile *f, bool last_stage) @@ -432,7 +431,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) RAMBlock *block = last_seen_block; ram_addr_t offset = last_offset; bool complete_round = false; - int bytes_sent = -1; + int bytes_sent = 0; MemoryRegion *mr; ram_addr_t current_addr; @@ -460,6 +459,8 @@ static int ram_save_block(QEMUFile *f, bool last_stage) p = memory_region_get_ram_ptr(mr) + offset; + /* In doubt sent page as normal */ + bytes_sent = -1; if (is_dup_page(p)) { acct_info.dup_pages++; bytes_sent = save_block_hdr(f, block, offset, cont, @@ -475,7 +476,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) } } - /* either we didn't send yet (we may have had XBZRLE overflow) */ + /* XBZRLE overflow or normal page */ if (bytes_sent == -1) { bytes_sent = save_block_hdr(f, block, offset, cont, RAM_SAVE_FLAG_PAGE); qemu_put_buffer(f, p, TARGET_PAGE_SIZE); @@ -484,7 +485,7 @@ static int ram_save_block(QEMUFile *f, bool last_stage) } /* if page is unmodified, continue to the next */ - if (bytes_sent != 0) { + if (bytes_sent > 0) { last_sent_block = block; break; } @@ -605,6 +606,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) int ret; int i; int64_t t0; + int total_sent = 0; qemu_mutex_lock_ramlist(); @@ -619,10 +621,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) bytes_sent = ram_save_block(f, false); /* no more blocks to sent */ - if (bytes_sent < 0) { + if (bytes_sent == 0) { break; } - bytes_transferred += bytes_sent; + total_sent += bytes_sent; acct_info.iterations++; /* we want to check in the 1st loop, just in case it was the 1st time and we had to sync the dirty bitmap. @@ -641,13 +643,16 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } if (ret < 0) { + bytes_transferred += total_sent; return ret; } qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); + total_sent += 8; + bytes_transferred += total_sent; - return i; + return total_sent; } static int ram_save_complete(QEMUFile *f, void *opaque) @@ -664,7 +669,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) bytes_sent = ram_save_block(f, true); /* no more blocks to sent */ - if (bytes_sent < 0) { + if (bytes_sent == 0) { break; } bytes_transferred += bytes_sent; -- cgit v1.2.3-55-g7522