From 0daf53047da0b817e40c4931580e59e73b420f41 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 10 Aug 2012 13:06:05 +0200 Subject: usb: update uas product id Pick other product id to fix clash with audio. Current usage list (after applying this patch): 46f4:0001 -- usb-storage 46f4:0002 -- usb-audio 46f4:0003 -- usb-uas Signed-off-by: Gerd Hoffmann --- hw/usb/dev-uas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/usb/dev-uas.c') diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 9b02ff48fa..b13eeba565 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -223,7 +223,7 @@ static const USBDescDevice desc_device_high = { static const USBDesc desc = { .id = { .idVendor = 0x46f4, /* CRC16() of "QEMU" */ - .idProduct = 0x0002, + .idProduct = 0x0003, .bcdDevice = 0, .iManufacturer = STR_MANUFACTURER, .iProduct = STR_PRODUCT, -- cgit v1.2.3-55-g7522 From 347e40ffe61b7cc8d4565be476c20acd00611669 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 31 Aug 2012 14:34:19 +0200 Subject: uas: move transfer kickoff Kick next scsi transfer from request release callback instead of command completion callback, otherwise we might get stuck in case scsi_req_unref() doesn't release the request instantly due to someone else holding a reference too. Signed-off-by: Gerd Hoffmann --- hw/usb/dev-uas.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'hw/usb/dev-uas.c') diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index b13eeba565..5a0057a36b 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -424,6 +424,7 @@ static void usb_uas_scsi_free_request(SCSIBus *bus, void *priv) } QTAILQ_REMOVE(&uas->requests, req, next); g_free(req); + usb_uas_start_next_transfer(uas); } static UASRequest *usb_uas_find_request(UASDevice *uas, uint16_t tag) @@ -456,7 +457,6 @@ static void usb_uas_scsi_command_complete(SCSIRequest *r, uint32_t status, size_t resid) { UASRequest *req = r->hba_private; - UASDevice *uas = req->uas; trace_usb_uas_scsi_complete(req->uas->dev.addr, req->tag, status, resid); req->complete = true; @@ -465,7 +465,6 @@ static void usb_uas_scsi_command_complete(SCSIRequest *r, } usb_uas_queue_sense(req, status); scsi_req_unref(req->req); - usb_uas_start_next_transfer(uas); } static void usb_uas_scsi_request_cancelled(SCSIRequest *r) -- cgit v1.2.3-55-g7522 From 4d5b97da35ecbfdad6fe1cbe7fdd7d71ef735602 Mon Sep 17 00:00:00 2001 From: Amos Kong Date: Sat, 29 Sep 2012 13:36:21 +0800 Subject: cleanup useless return sentence This patch cleans up return sentences in the end of void functions. Reported-by: Paolo Bonzini Signed-off-by: Amos Kong Signed-off-by: Stefan Hajnoczi --- block/qed-table.c | 1 - blockdev.c | 1 - hw/9pfs/virtio-9p.c | 5 ----- hw/blizzard.c | 2 -- hw/bt-hci.c | 1 - hw/device-hotplug.c | 1 - hw/exynos4210_combiner.c | 4 ---- hw/exynos4210_gic.c | 4 ---- hw/exynos4210_mct.c | 2 -- hw/fdc.c | 2 -- hw/framebuffer.c | 1 - hw/ide/macio.c | 1 - hw/ivshmem.c | 4 ---- hw/megasas.c | 1 - hw/msix.c | 1 - hw/pflash_cfi01.c | 1 - hw/pflash_cfi02.c | 1 - hw/pxa2xx_keypad.c | 1 - hw/sb16.c | 1 - hw/scsi-disk.c | 2 -- hw/tcx.c | 1 - hw/usb/dev-uas.c | 2 -- hw/usb/hcd-ohci.c | 2 -- hw/usb/hcd-xhci.c | 1 - hw/xen_domainbuild.c | 1 - libcacard/vcard.c | 1 - libcacard/vcard_emul_nss.c | 3 --- libcacard/vreader.c | 1 - linux-user/signal.c | 2 -- os-posix.c | 1 - qemu-sockets.c | 1 - qga/commands-posix.c | 2 -- qga/commands-win32.c | 2 -- savevm.c | 1 - slirp/ip_input.c | 1 - slirp/tcp_input.c | 2 -- slirp/udp.c | 1 - target-unicore32/translate.c | 2 -- ui/vnc-auth-sasl.c | 1 - vl.c | 1 - xen-all.c | 1 - 41 files changed, 67 deletions(-) (limited to 'hw/usb/dev-uas.c') diff --git a/block/qed-table.c b/block/qed-table.c index ce07b05549..de845ec3d0 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -103,7 +103,6 @@ static void qed_write_table_cb(void *opaque, int ret) out: qemu_vfree(write_table_cb->table); gencb_complete(&write_table_cb->gencb, ret); - return; } /** diff --git a/blockdev.c b/blockdev.c index 5f18dfa97b..99828ad2bd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -830,7 +830,6 @@ exit: QSIMPLEQ_FOREACH_SAFE(states, &snap_bdrv_states, entry, next) { g_free(states); } - return; } diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 4b52540116..8b9cdc96ed 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -505,7 +505,6 @@ static void virtfs_reset(V9fsPDU *pdu) error_report("9pfs:%s: One or more uncluncked fids " "found during reset", __func__); } - return; } #define P9_QID_TYPE_DIR 0x80 @@ -934,7 +933,6 @@ static void v9fs_version(void *opaque) out: complete_pdu(s, pdu, offset); v9fs_string_free(&version); - return; } static void v9fs_attach(void *opaque) @@ -1314,7 +1312,6 @@ out_nofid: g_free(wnames); g_free(qids); } - return; } static int32_t get_iounit(V9fsPDU *pdu, V9fsPath *path) @@ -2257,7 +2254,6 @@ static void v9fs_flush(void *opaque) free_pdu(pdu->s, cancel_pdu); } complete_pdu(s, pdu, 7); - return; } static void v9fs_link(void *opaque) @@ -2763,7 +2759,6 @@ out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, retval); - return; } static void v9fs_mknod(void *opaque) diff --git a/hw/blizzard.c b/hw/blizzard.c index d1c9d81510..06e19b364b 100644 --- a/hw/blizzard.c +++ b/hw/blizzard.c @@ -878,8 +878,6 @@ void s1d13745_write_block(void *opaque, int dc, len -= 2; buf += 2; } - - return; } static void blizzard_update_display(void *opaque) diff --git a/hw/bt-hci.c b/hw/bt-hci.c index a3a7fb49e2..f19299a778 100644 --- a/hw/bt-hci.c +++ b/hw/bt-hci.c @@ -786,7 +786,6 @@ static void bt_hci_lmp_connection_request(struct bt_link_s *link) memcpy(¶ms.dev_class, &link->host->class, sizeof(params.dev_class)); params.link_type = ACL_LINK; bt_hci_event(hci, EVT_CONN_REQUEST, ¶ms, EVT_CONN_REQUEST_SIZE); - return; } static void bt_hci_conn_accept_timeout(void *opaque) diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index 2bdc615b49..eec0fe3148 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -89,5 +89,4 @@ err: if (dinfo) { drive_put_ref(dinfo); } - return; } diff --git a/hw/exynos4210_combiner.c b/hw/exynos4210_combiner.c index 80af22cc33..60b33c7886 100644 --- a/hw/exynos4210_combiner.c +++ b/hw/exynos4210_combiner.c @@ -347,8 +347,6 @@ static void exynos4210_combiner_write(void *opaque, target_phys_addr_t offset, TARGET_FMT_plx "\n", offset); break; } - - return; } /* Get combiner group and bit from irq number */ @@ -380,8 +378,6 @@ static void exynos4210_combiner_handler(void *opaque, int irq, int level) } exynos4210_combiner_update(s, group_n); - - return; } static void exynos4210_combiner_reset(DeviceState *d) diff --git a/hw/exynos4210_gic.c b/hw/exynos4210_gic.c index 7d03dd9ae3..4fea09873a 100644 --- a/hw/exynos4210_gic.c +++ b/hw/exynos4210_gic.c @@ -193,8 +193,6 @@ static void exynos4210_irq_handler(void *opaque, int irq, int level) /* Bypass */ qemu_set_irq(s->board_irqs[irq], level); - - return; } /* @@ -410,8 +408,6 @@ static void exynos4210_irq_gate_handler(void *opaque, int irq, int level) } qemu_irq_lower(s->out); - - return; } static void exynos4210_irq_gate_reset(DeviceState *d) diff --git a/hw/exynos4210_mct.c b/hw/exynos4210_mct.c index 7a22b1f900..6f94ce230c 100644 --- a/hw/exynos4210_mct.c +++ b/hw/exynos4210_mct.c @@ -574,8 +574,6 @@ static void exynos4210_gfrc_event(void *opaque) exynos4210_gfrc_set_count(&s->g_timer, distance); exynos4210_gfrc_start(&s->g_timer); - - return; } /* diff --git a/hw/fdc.c b/hw/fdc.c index 43b0f20503..25a49e350c 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -1286,8 +1286,6 @@ static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction) fdctrl->msr |= FD_MSR_DIO; /* IO based transfer: calculate len */ fdctrl_raise_irq(fdctrl, FD_SR0_SEEK); - - return; } /* Prepare a transfer of deleted data */ diff --git a/hw/framebuffer.c b/hw/framebuffer.c index 85a00a5798..27fa6f51fb 100644 --- a/hw/framebuffer.c +++ b/hw/framebuffer.c @@ -107,5 +107,4 @@ void framebuffer_update_display( DIRTY_MEMORY_VGA); *first_row = first; *last_row = last; - return; } diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 848cb31429..f228725142 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -89,7 +89,6 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) done: bdrv_acct_done(s->bs, &s->acct); io->dma_end(opaque); - return; } static void pmac_ide_transfer_cb(void *opaque, int ret) diff --git a/hw/ivshmem.c b/hw/ivshmem.c index 59f1aa4265..5c4ccb85f0 100644 --- a/hw/ivshmem.c +++ b/hw/ivshmem.c @@ -149,7 +149,6 @@ static void ivshmem_IntrStatus_write(IVShmemState *s, uint32_t val) s->intrstatus = val; ivshmem_update_irq(s, val); - return; } static uint32_t ivshmem_IntrStatus_read(IVShmemState *s) @@ -510,8 +509,6 @@ static void ivshmem_read(void *opaque, const uint8_t * buf, int flags) if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) { ivshmem_add_eventfd(s, incoming_posn, guest_max_eventfd); } - - return; } /* Select the MSI-X vectors used by device. @@ -536,7 +533,6 @@ static void ivshmem_reset(DeviceState *d) s->intrstatus = 0; ivshmem_use_msix(s); - return; } static uint64_t ivshmem_get_size(IVShmemState * s) { diff --git a/hw/megasas.c b/hw/megasas.c index c728aea699..0e57740fd2 100644 --- a/hw/megasas.c +++ b/hw/megasas.c @@ -652,7 +652,6 @@ static void megasas_finish_dcmd(MegasasCmd *cmd, uint32_t iov_size) } } cmd->iov_size = 0; - return; } static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) diff --git a/hw/msix.c b/hw/msix.c index d812094139..b623cb597c 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -366,7 +366,6 @@ void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar) g_free(dev->msix_entry_used); dev->msix_entry_used = NULL; dev->cap_present &= ~QEMU_PCI_CAP_MSIX; - return; } void msix_uninit_exclusive_bar(PCIDevice *dev) diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c index 855890d1f1..3b437da9c3 100644 --- a/hw/pflash_cfi01.c +++ b/hw/pflash_cfi01.c @@ -442,7 +442,6 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset, pfl->bypass = 0; pfl->wcycle = 0; pfl->cmd = 0; - return; } diff --git a/hw/pflash_cfi02.c b/hw/pflash_cfi02.c index 8cb1549587..39337ec304 100644 --- a/hw/pflash_cfi02.c +++ b/hw/pflash_cfi02.c @@ -474,7 +474,6 @@ static void pflash_write (pflash_t *pfl, target_phys_addr_t offset, do_bypass: pfl->wcycle = 2; pfl->cmd = 0; - return; } diff --git a/hw/pxa2xx_keypad.c b/hw/pxa2xx_keypad.c index 59db02584e..1a997c9c83 100644 --- a/hw/pxa2xx_keypad.c +++ b/hw/pxa2xx_keypad.c @@ -172,7 +172,6 @@ static void pxa27x_keyboard_event (PXA2xxKeyPadState *kp, int keycode) kp->kpc |= KPC_MI; qemu_irq_raise(kp->irq); } - return; } static uint64_t pxa2xx_keypad_read(void *opaque, target_phys_addr_t offset, diff --git a/hw/sb16.c b/hw/sb16.c index c81455d7f3..523ab0d5fd 100644 --- a/hw/sb16.c +++ b/hw/sb16.c @@ -822,7 +822,6 @@ static void complete (SB16State *s) ldebug ("\n"); s->cmd = -1; - return; } static void legacy_reset (SB16State *s) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 99bb02ebf8..1b0afa6352 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1437,7 +1437,6 @@ invalid_param_len: invalid_field: scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); - return; } static inline bool check_lba_range(SCSIDiskState *s, @@ -1535,7 +1534,6 @@ static void scsi_disk_emulate_unmap(SCSIDiskReq *r, uint8_t *inbuf) invalid_param_len: scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); - return; } static void scsi_disk_emulate_write_data(SCSIRequest *req) diff --git a/hw/tcx.c b/hw/tcx.c index 93994d6440..2db2db1235 100644 --- a/hw/tcx.c +++ b/hw/tcx.c @@ -472,7 +472,6 @@ static void tcx_dac_writel(void *opaque, target_phys_addr_t addr, uint64_t val, default: break; } - return; } static const MemoryRegionOps tcx_dac_ops = { diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 5a0057a36b..4389380e95 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -576,7 +576,6 @@ bad_target: */ usb_uas_queue_response(uas, req->tag, UAS_RC_INVALID_INFO_UNIT, 0); g_free(req); - return; } static void usb_uas_task(UASDevice *uas, uas_ui *ui) @@ -640,7 +639,6 @@ bad_target: incorrect_lun: usb_uas_queue_response(uas, tag, UAS_RC_INCORRECT_LUN, 0); - return; } static int usb_uas_handle_data(USBDevice *dev, USBPacket *p) diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index c36184ae4f..59c7055cb5 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -1470,8 +1470,6 @@ static void ohci_port_set_status(OHCIState *ohci, int portnum, uint32_t val) if (old_state != port->ctrl) ohci_set_interrupt(ohci, OHCI_INTR_RHSC); - - return; } static uint64_t ohci_mem_read(void *opaque, diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index e79a8724c5..3a41b067c4 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -807,7 +807,6 @@ static void xhci_events_update(XHCIState *xhci, int v) DPRINTF("xhci_events_update(): event ring no longer full\n"); intr->er_full = 0; } - return; } static void xhci_event(XHCIState *xhci, XHCIEvent *event, int v) diff --git a/hw/xen_domainbuild.c b/hw/xen_domainbuild.c index a6a12e5930..db1497469a 100644 --- a/hw/xen_domainbuild.c +++ b/hw/xen_domainbuild.c @@ -153,7 +153,6 @@ static void xen_domain_poll(void *opaque) quit: qemu_system_shutdown_request(); - return; } static int xen_domain_watcher(void) diff --git a/libcacard/vcard.c b/libcacard/vcard.c index b02556ee0c..539177bb4c 100644 --- a/libcacard/vcard.c +++ b/libcacard/vcard.c @@ -200,7 +200,6 @@ vcard_free(VCard *vcard) } vcard_buffer_response_delete(vcard->vcard_buffer_response); g_free(vcard); - return; } void diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index 802cae3a29..b861c5afcc 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -168,7 +168,6 @@ vcard_emul_delete_key(VCardKey *key) if (key->slot) { PK11_FreeSlot(key->slot); } - return; } /* @@ -418,7 +417,6 @@ vcard_emul_reset(VCard *card, VCardPower power) /* TODO: we may also need to send insertion/removal events? */ slot = vcard_emul_card_get_slot(card); PK11_Logout(slot); /* NOTE: ignoring SECStatus return value */ - return; } @@ -535,7 +533,6 @@ vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len) memcpy(atr, nss_atr, len); *atr_len = len; - return; } /* diff --git a/libcacard/vreader.c b/libcacard/vreader.c index ec126dfa46..96d2407e78 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -93,7 +93,6 @@ vreader_free(VReader *reader) reader->reader_private_free(reader->reader_private); } g_free(reader); - return; } static VCard * diff --git a/linux-user/signal.c b/linux-user/signal.c index 78691473fa..15bc4e8f62 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2762,7 +2762,6 @@ static void setup_frame(int sig, struct target_sigaction * ka, give_sigsegv: unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV/*, current*/); - return; } long do_sigreturn(CPUMIPSState *regs) @@ -2871,7 +2870,6 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, give_sigsegv: unlock_user_struct(frame, frame_addr, 1); force_sig(TARGET_SIGSEGV/*, current*/); - return; } long do_rt_sigreturn(CPUMIPSState *env) diff --git a/os-posix.c b/os-posix.c index eabccb8fe0..178e7caa4a 100644 --- a/os-posix.c +++ b/os-posix.c @@ -194,7 +194,6 @@ void os_parse_cmd_args(int index, const char *optarg) break; #endif } - return; } static void change_process_uid(void) diff --git a/qemu-sockets.c b/qemu-sockets.c index 0f59490859..2b1ed2f0e9 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -266,7 +266,6 @@ static void wait_for_connect(void *opaque) s->callback(s->fd, s->opaque); } g_free(s); - return; } static int inet_connect_addr(struct addrinfo *addr, bool *in_progress, diff --git a/qga/commands-posix.c b/qga/commands-posix.c index ce9042123c..b0eec74148 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -988,8 +988,6 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err) void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) { error_set(err, QERR_UNSUPPORTED); - - return; } #endif diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 54bc5462e2..5bd8fb27f2 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -180,8 +180,6 @@ int64_t qmp_guest_fsfreeze_thaw(Error **err) void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) { error_set(err, QERR_UNSUPPORTED); - - return; } typedef enum { diff --git a/savevm.c b/savevm.c index c7fe283145..31fd2e0ad3 100644 --- a/savevm.c +++ b/savevm.c @@ -2201,7 +2201,6 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) the_end: if (saved_vm_running) vm_start(); - return; } int load_vmstate(const char *name) diff --git a/slirp/ip_input.c b/slirp/ip_input.c index ce24faf165..6f4cff8fdd 100644 --- a/slirp/ip_input.c +++ b/slirp/ip_input.c @@ -213,7 +213,6 @@ ip_input(struct mbuf *m) return; bad: m_free(m); - return; } #define iptofrag(P) ((struct ipasfrag *)(((char*)(P)) - sizeof(struct qlink))) diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c index 942aaf44f1..6440eae7fa 100644 --- a/slirp/tcp_input.c +++ b/slirp/tcp_input.c @@ -1281,8 +1281,6 @@ drop: * Drop space held by incoming segment and return. */ m_free(m); - - return; } static void diff --git a/slirp/udp.c b/slirp/udp.c index ced509656d..9286cb7d31 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -231,7 +231,6 @@ udp_input(register struct mbuf *m, int iphlen) return; bad: m_free(m); - return; } int udp_output2(struct socket *so, struct mbuf *m, diff --git a/target-unicore32/translate.c b/target-unicore32/translate.c index 36f4f2f966..c3cdafa18e 100644 --- a/target-unicore32/translate.c +++ b/target-unicore32/translate.c @@ -1932,8 +1932,6 @@ static void disas_uc32_insn(CPUUniCore32State *env, DisasContext *s) } ILLEGAL; } - - return; } /* generate intermediate code in gen_opc_buf and gen_opparam_buf for diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index 8fba7702c2..9a0ad30a94 100644 --- a/ui/vnc-auth-sasl.c +++ b/ui/vnc-auth-sasl.c @@ -619,7 +619,6 @@ void start_auth_sasl(VncState *vs) authabort: vnc_client_error(vs); - return; } diff --git a/vl.c b/vl.c index 8d305ca59b..29e05a303b 100644 --- a/vl.c +++ b/vl.c @@ -1023,7 +1023,6 @@ static void numa_add(const char *optarg) } nb_numa_nodes++; } - return; } static void smp_parse(const char *optarg) diff --git a/xen-all.c b/xen-all.c index e6308be23a..bcb7ef7c84 100644 --- a/xen-all.c +++ b/xen-all.c @@ -1092,7 +1092,6 @@ static void xen_read_physmap(XenIOState *state) QLIST_INSERT_HEAD(&state->physmap, physmap, list); } free(entries); - return; } int xen_hvm_init(void) -- cgit v1.2.3-55-g7522 From 9a77a0f58923443913e1071ffb47b74c54566e70 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 1 Nov 2012 17:15:01 +0100 Subject: usb: split packet result into actual_length + status Since with the ehci and xhci controllers a single packet can be larger then maxpacketsize, it is possible for the result of a single packet to be both having transferred some data as well as the transfer to have an error. An example would be an input transfer from a bulk endpoint successfully receiving 1 or more maxpacketsize packets from the device, followed by a packet signalling halt. While already touching all the devices and controllers handle_packet / handle_data / handle_control code, also change the return type of these functions to void, solely storing the status in the packet. To make the code paths for regular versus async packet handling more uniform. This patch unfortunately is somewhat invasive, since makeing the qemu usb core deal with this requires changes everywhere. This patch only prepares the usb core for this, all the hcd / device changes are done in such a way that there are no functional changes. This patch has been tested with uhci and ehci hcds, together with usb-audio, usb-hid and usb-storage devices, as well as with usb-redir redirection with a wide variety of real devices. Note that there is usually no need to directly set packet->actual_length form devices handle_data callback, as that is done by usb_packet_copy() Signed-off-by: Hans de Goede Signed-off-by: Gerd Hoffmann --- hw/usb.h | 24 +++-- hw/usb/bus.c | 13 +-- hw/usb/combined-packet.c | 29 +++--- hw/usb/core.c | 209 ++++++++++++++++++++++-------------------- hw/usb/desc.c | 16 +++- hw/usb/desc.h | 3 +- hw/usb/dev-audio.c | 49 ++++------ hw/usb/dev-bluetooth.c | 33 +++---- hw/usb/dev-hid.c | 42 ++++----- hw/usb/dev-hub.c | 34 +++---- hw/usb/dev-network.c | 101 ++++++++++---------- hw/usb/dev-serial.c | 29 +++--- hw/usb/dev-smartcard-reader.c | 69 ++++++-------- hw/usb/dev-storage.c | 51 ++++------- hw/usb/dev-uas.c | 36 ++++---- hw/usb/dev-wacom.c | 38 ++++---- hw/usb/hcd-ehci.c | 26 ++++-- hw/usb/hcd-musb.c | 16 ++-- hw/usb/hcd-ohci.c | 26 ++++-- hw/usb/hcd-uhci.c | 34 ++++--- hw/usb/hcd-xhci.c | 46 +++++----- hw/usb/host-bsd.c | 27 +++--- hw/usb/host-linux.c | 128 ++++++++++++++------------ hw/usb/redirect.c | 157 +++++++++++++++++-------------- 24 files changed, 610 insertions(+), 626 deletions(-) (limited to 'hw/usb/dev-uas.c') diff --git a/hw/usb.h b/hw/usb.h index aef07f4a07..7d6de69ec4 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -38,6 +38,7 @@ #define USB_TOKEN_IN 0x69 /* device -> host */ #define USB_TOKEN_OUT 0xe1 /* host -> device */ +#define USB_RET_SUCCESS (0) #define USB_RET_NODEV (-1) #define USB_RET_NAK (-2) #define USB_RET_STALL (-3) @@ -280,18 +281,20 @@ typedef struct USBDeviceClass { * Process control request. * Called from handle_packet(). * - * Returns length or one of the USB_RET_ codes. + * Status gets stored in p->status, and if p->status == USB_RET_SUCCESS + * then the number of bytes transfered is stored in p->actual_length */ - int (*handle_control)(USBDevice *dev, USBPacket *p, int request, int value, - int index, int length, uint8_t *data); + void (*handle_control)(USBDevice *dev, USBPacket *p, int request, int value, + int index, int length, uint8_t *data); /* * Process data transfers (both BULK and ISOC). * Called from handle_packet(). * - * Returns length or one of the USB_RET_ codes. + * Status gets stored in p->status, and if p->status == USB_RET_SUCCESS + * then the number of bytes transfered is stored in p->actual_length */ - int (*handle_data)(USBDevice *dev, USBPacket *p); + void (*handle_data)(USBDevice *dev, USBPacket *p); void (*set_interface)(USBDevice *dev, int interface, int alt_old, int alt_new); @@ -354,7 +357,8 @@ struct USBPacket { uint64_t parameter; /* control transfers */ bool short_not_ok; bool int_req; - int result; /* transfer length or USB_RET_* status code */ + int status; /* USB_RET_* status code */ + int actual_length; /* Number of bytes actually transfered */ /* Internal use by the USB layer. */ USBPacketState state; USBCombinedPacket *combined; @@ -388,7 +392,7 @@ static inline bool usb_packet_is_inflight(USBPacket *p) USBDevice *usb_find_device(USBPort *port, uint8_t addr); -int usb_handle_packet(USBDevice *dev, USBPacket *p); +void usb_handle_packet(USBDevice *dev, USBPacket *p); void usb_packet_complete(USBDevice *dev, USBPacket *p); void usb_packet_complete_one(USBDevice *dev, USBPacket *p); void usb_cancel_packet(USBPacket * p); @@ -523,10 +527,10 @@ void usb_device_handle_attach(USBDevice *dev); void usb_device_handle_reset(USBDevice *dev); -int usb_device_handle_control(USBDevice *dev, USBPacket *p, int request, int value, - int index, int length, uint8_t *data); +void usb_device_handle_control(USBDevice *dev, USBPacket *p, int request, + int val, int index, int length, uint8_t *data); -int usb_device_handle_data(USBDevice *dev, USBPacket *p); +void usb_device_handle_data(USBDevice *dev, USBPacket *p); void usb_device_set_interface(USBDevice *dev, int interface, int alt_old, int alt_new); diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 8066291b34..99aac7a2c0 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -140,24 +140,21 @@ void usb_device_handle_reset(USBDevice *dev) } } -int usb_device_handle_control(USBDevice *dev, USBPacket *p, int request, - int value, int index, int length, uint8_t *data) +void usb_device_handle_control(USBDevice *dev, USBPacket *p, int request, + int value, int index, int length, uint8_t *data) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); if (klass->handle_control) { - return klass->handle_control(dev, p, request, value, index, length, - data); + klass->handle_control(dev, p, request, value, index, length, data); } - return -ENOSYS; } -int usb_device_handle_data(USBDevice *dev, USBPacket *p) +void usb_device_handle_data(USBDevice *dev, USBPacket *p) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); if (klass->handle_data) { - return klass->handle_data(dev, p); + klass->handle_data(dev, p); } - return -ENOSYS; } const char *usb_device_get_product_desc(USBDevice *dev) diff --git a/hw/usb/combined-packet.c b/hw/usb/combined-packet.c index 3904e71634..e72219894b 100644 --- a/hw/usb/combined-packet.c +++ b/hw/usb/combined-packet.c @@ -46,7 +46,7 @@ void usb_combined_input_packet_complete(USBDevice *dev, USBPacket *p) USBEndpoint *ep = p->ep; USBPacket *next; enum { completing, complete, leftover }; - int result, state = completing; + int status, actual_length, state = completing; bool short_not_ok; if (combined == NULL) { @@ -56,27 +56,34 @@ void usb_combined_input_packet_complete(USBDevice *dev, USBPacket *p) assert(combined->first == p && p == QTAILQ_FIRST(&combined->packets)); - result = combined->first->result; + status = combined->first->status; + actual_length = combined->first->actual_length; short_not_ok = QTAILQ_LAST(&combined->packets, packets_head)->short_not_ok; QTAILQ_FOREACH_SAFE(p, &combined->packets, combined_entry, next) { if (state == completing) { /* Distribute data over uncombined packets */ - if (result >= p->iov.size) { - p->result = p->iov.size; + if (actual_length >= p->iov.size) { + p->actual_length = p->iov.size; } else { /* Send short or error packet to complete the transfer */ - p->result = result; + p->actual_length = actual_length; state = complete; } + /* Report status on the last packet */ + if (state == complete || next == NULL) { + p->status = status; + } else { + p->status = USB_RET_SUCCESS; + } p->short_not_ok = short_not_ok; usb_combined_packet_remove(combined, p); usb_packet_complete_one(dev, p); - result -= p->result; + actual_length -= p->actual_length; } else { /* Remove any leftover packets from the queue */ state = leftover; - p->result = USB_RET_REMOVE_FROM_QUEUE; + p->status = USB_RET_REMOVE_FROM_QUEUE; dev->port->ops->complete(dev->port, p); } } @@ -117,7 +124,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep) { USBPacket *p, *u, *next, *prev = NULL, *first = NULL; USBPort *port = ep->dev->port; - int ret, totalsize; + int totalsize; assert(ep->pipeline); assert(ep->pid == USB_TOKEN_IN); @@ -125,7 +132,7 @@ void usb_ep_combine_input_packets(USBEndpoint *ep) QTAILQ_FOREACH_SAFE(p, &ep->queue, queue, next) { /* Empty the queue on a halt */ if (ep->halted) { - p->result = USB_RET_REMOVE_FROM_QUEUE; + p->status = USB_RET_REMOVE_FROM_QUEUE; port->ops->complete(port, p); continue; } @@ -166,8 +173,8 @@ void usb_ep_combine_input_packets(USBEndpoint *ep) next == NULL || /* Work around for Linux usbfs bulk splitting + migration */ (totalsize == 16348 && p->int_req)) { - ret = usb_device_handle_data(ep->dev, first); - assert(ret == USB_RET_ASYNC); + usb_device_handle_data(ep->dev, first); + assert(first->status == USB_RET_ASYNC); if (first->combined) { QTAILQ_FOREACH(u, &first->combined->packets, combined_entry) { usb_packet_set_state(u, USB_PACKET_ASYNC); diff --git a/hw/usb/core.c b/hw/usb/core.c index ab37f6f7b8..52b53108cd 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -97,17 +97,17 @@ void usb_wakeup(USBEndpoint *ep) #define SETUP_STATE_ACK 3 #define SETUP_STATE_PARAM 4 -static int do_token_setup(USBDevice *s, USBPacket *p) +static void do_token_setup(USBDevice *s, USBPacket *p) { int request, value, index; - int ret = 0; if (p->iov.size != 8) { - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } usb_packet_copy(p, s->setup_buf, p->iov.size); - p->result = 0; + p->actual_length = 0; s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; s->setup_index = 0; @@ -116,24 +116,26 @@ static int do_token_setup(USBDevice *s, USBPacket *p) index = (s->setup_buf[5] << 8) | s->setup_buf[4]; if (s->setup_buf[0] & USB_DIR_IN) { - ret = usb_device_handle_control(s, p, request, value, index, - s->setup_len, s->data_buf); - if (ret == USB_RET_ASYNC) { - s->setup_state = SETUP_STATE_SETUP; - return USB_RET_ASYNC; + usb_device_handle_control(s, p, request, value, index, + s->setup_len, s->data_buf); + if (p->status == USB_RET_ASYNC) { + s->setup_state = SETUP_STATE_SETUP; + } + if (p->status != USB_RET_SUCCESS) { + return; } - if (ret < 0) - return ret; - if (ret < s->setup_len) - s->setup_len = ret; + if (p->actual_length < s->setup_len) { + s->setup_len = p->actual_length; + } s->setup_state = SETUP_STATE_DATA; } else { if (s->setup_len > sizeof(s->data_buf)) { fprintf(stderr, "usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n", s->setup_len, sizeof(s->data_buf)); - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } if (s->setup_len == 0) s->setup_state = SETUP_STATE_ACK; @@ -141,13 +143,12 @@ static int do_token_setup(USBDevice *s, USBPacket *p) s->setup_state = SETUP_STATE_DATA; } - return ret; + p->actual_length = 8; } -static int do_token_in(USBDevice *s, USBPacket *p) +static void do_token_in(USBDevice *s, USBPacket *p) { int request, value, index; - int ret = 0; assert(p->ep->nr == 0); @@ -158,19 +159,15 @@ static int do_token_in(USBDevice *s, USBPacket *p) switch(s->setup_state) { case SETUP_STATE_ACK: if (!(s->setup_buf[0] & USB_DIR_IN)) { - ret = usb_device_handle_control(s, p, request, value, index, - s->setup_len, s->data_buf); - if (ret == USB_RET_ASYNC) { - return USB_RET_ASYNC; + usb_device_handle_control(s, p, request, value, index, + s->setup_len, s->data_buf); + if (p->status == USB_RET_ASYNC) { + return; } s->setup_state = SETUP_STATE_IDLE; - if (ret > 0) - return 0; - return ret; + p->actual_length = 0; } - - /* return 0 byte */ - return 0; + break; case SETUP_STATE_DATA: if (s->setup_buf[0] & USB_DIR_IN) { @@ -180,20 +177,21 @@ static int do_token_in(USBDevice *s, USBPacket *p) } usb_packet_copy(p, s->data_buf + s->setup_index, len); s->setup_index += len; - if (s->setup_index >= s->setup_len) + if (s->setup_index >= s->setup_len) { s->setup_state = SETUP_STATE_ACK; - return len; + } + return; } - s->setup_state = SETUP_STATE_IDLE; - return USB_RET_STALL; + p->status = USB_RET_STALL; + break; default: - return USB_RET_STALL; + p->status = USB_RET_STALL; } } -static int do_token_out(USBDevice *s, USBPacket *p) +static void do_token_out(USBDevice *s, USBPacket *p) { assert(p->ep->nr == 0); @@ -205,7 +203,7 @@ static int do_token_out(USBDevice *s, USBPacket *p) } else { /* ignore additional output */ } - return 0; + break; case SETUP_STATE_DATA: if (!(s->setup_buf[0] & USB_DIR_IN)) { @@ -215,23 +213,23 @@ static int do_token_out(USBDevice *s, USBPacket *p) } usb_packet_copy(p, s->data_buf + s->setup_index, len); s->setup_index += len; - if (s->setup_index >= s->setup_len) + if (s->setup_index >= s->setup_len) { s->setup_state = SETUP_STATE_ACK; - return len; + } + return; } - s->setup_state = SETUP_STATE_IDLE; - return USB_RET_STALL; + p->status = USB_RET_STALL; + break; default: - return USB_RET_STALL; + p->status = USB_RET_STALL; } } -static int do_parameter(USBDevice *s, USBPacket *p) +static void do_parameter(USBDevice *s, USBPacket *p) { - int request, value, index; - int i, ret = 0; + int i, request, value, index; for (i = 0; i < 8; i++) { s->setup_buf[i] = p->parameter >> (i*8); @@ -249,27 +247,27 @@ static int do_parameter(USBDevice *s, USBPacket *p) fprintf(stderr, "usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n", s->setup_len, sizeof(s->data_buf)); - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } if (p->pid == USB_TOKEN_OUT) { usb_packet_copy(p, s->data_buf, s->setup_len); } - ret = usb_device_handle_control(s, p, request, value, index, - s->setup_len, s->data_buf); - if (ret < 0) { - return ret; + usb_device_handle_control(s, p, request, value, index, + s->setup_len, s->data_buf); + if (p->status == USB_RET_ASYNC) { + return; } - if (ret < s->setup_len) { - s->setup_len = ret; + if (p->actual_length < s->setup_len) { + s->setup_len = p->actual_length; } if (p->pid == USB_TOKEN_IN) { + p->actual_length = 0; usb_packet_copy(p, s->data_buf, s->setup_len); } - - return ret; } /* ctrl complete function for devices which use usb_generic_handle_packet and @@ -278,30 +276,30 @@ static int do_parameter(USBDevice *s, USBPacket *p) usb_packet_complete to complete their async control packets. */ void usb_generic_async_ctrl_complete(USBDevice *s, USBPacket *p) { - if (p->result < 0) { + if (p->status < 0) { s->setup_state = SETUP_STATE_IDLE; } switch (s->setup_state) { case SETUP_STATE_SETUP: - if (p->result < s->setup_len) { - s->setup_len = p->result; + if (p->actual_length < s->setup_len) { + s->setup_len = p->actual_length; } s->setup_state = SETUP_STATE_DATA; - p->result = 8; + p->actual_length = 8; break; case SETUP_STATE_ACK: s->setup_state = SETUP_STATE_IDLE; - p->result = 0; + p->actual_length = 0; break; case SETUP_STATE_PARAM: - if (p->result < s->setup_len) { - s->setup_len = p->result; + if (p->actual_length < s->setup_len) { + s->setup_len = p->actual_length; } if (p->pid == USB_TOKEN_IN) { - p->result = 0; + p->actual_length = 0; usb_packet_copy(p, s->data_buf, s->setup_len); } break; @@ -342,40 +340,57 @@ USBDevice *usb_find_device(USBPort *port, uint8_t addr) return usb_device_find_device(dev, addr); } -static int usb_process_one(USBPacket *p) +static void usb_process_one(USBPacket *p) { USBDevice *dev = p->ep->dev; + /* + * Handlers expect status to be initialized to USB_RET_SUCCESS, but it + * can be USB_RET_NAK here from a previous usb_process_one() call, + * or USB_RET_ASYNC from going through usb_queue_one(). + */ + p->status = USB_RET_SUCCESS; + if (p->ep->nr == 0) { /* control pipe */ if (p->parameter) { - return do_parameter(dev, p); + do_parameter(dev, p); + return; } switch (p->pid) { case USB_TOKEN_SETUP: - return do_token_setup(dev, p); + do_token_setup(dev, p); + break; case USB_TOKEN_IN: - return do_token_in(dev, p); + do_token_in(dev, p); + break; case USB_TOKEN_OUT: - return do_token_out(dev, p); + do_token_out(dev, p); + break; default: - return USB_RET_STALL; + p->status = USB_RET_STALL; } } else { /* data pipe */ - return usb_device_handle_data(dev, p); + usb_device_handle_data(dev, p); } } -/* Hand over a packet to a device for processing. Return value +static void usb_queue_one(USBPacket *p) +{ + usb_packet_set_state(p, USB_PACKET_QUEUED); + QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue); + p->status = USB_RET_ASYNC; +} + +/* Hand over a packet to a device for processing. p->status == USB_RET_ASYNC indicates the processing isn't finished yet, the driver will call usb_packet_complete() when done processing it. */ -int usb_handle_packet(USBDevice *dev, USBPacket *p) +void usb_handle_packet(USBDevice *dev, USBPacket *p) { - int ret; - if (dev == NULL) { - return USB_RET_NODEV; + p->status = USB_RET_NODEV; + return; } assert(dev == p->ep->dev); assert(dev->state == USB_STATE_DEFAULT); @@ -389,32 +404,26 @@ int usb_handle_packet(USBDevice *dev, USBPacket *p) } if (QTAILQ_EMPTY(&p->ep->queue) || p->ep->pipeline) { - ret = usb_process_one(p); - if (ret == USB_RET_ASYNC) { + usb_process_one(p); + if (p->status == USB_RET_ASYNC) { assert(p->ep->type != USB_ENDPOINT_XFER_ISOC); usb_packet_set_state(p, USB_PACKET_ASYNC); QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue); - } else if (ret == USB_RET_ADD_TO_QUEUE) { - usb_packet_set_state(p, USB_PACKET_QUEUED); - QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue); - ret = USB_RET_ASYNC; + } else if (p->status == USB_RET_ADD_TO_QUEUE) { + usb_queue_one(p); } else { /* * When pipelining is enabled usb-devices must always return async, * otherwise packets can complete out of order! */ assert(!p->ep->pipeline || QTAILQ_EMPTY(&p->ep->queue)); - if (ret != USB_RET_NAK) { - p->result = ret; + if (p->status != USB_RET_NAK) { usb_packet_set_state(p, USB_PACKET_COMPLETE); } } } else { - ret = USB_RET_ASYNC; - usb_packet_set_state(p, USB_PACKET_QUEUED); - QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue); + usb_queue_one(p); } - return ret; } void usb_packet_complete_one(USBDevice *dev, USBPacket *p) @@ -422,9 +431,10 @@ void usb_packet_complete_one(USBDevice *dev, USBPacket *p) USBEndpoint *ep = p->ep; assert(QTAILQ_FIRST(&ep->queue) == p); - assert(p->result != USB_RET_ASYNC && p->result != USB_RET_NAK); + assert(p->status != USB_RET_ASYNC && p->status != USB_RET_NAK); - if (p->result < 0 || (p->short_not_ok && (p->result < p->iov.size))) { + if (p->status != USB_RET_SUCCESS || + (p->short_not_ok && (p->actual_length < p->iov.size))) { ep->halted = true; } usb_packet_set_state(p, USB_PACKET_COMPLETE); @@ -438,7 +448,6 @@ void usb_packet_complete_one(USBDevice *dev, USBPacket *p) void usb_packet_complete(USBDevice *dev, USBPacket *p) { USBEndpoint *ep = p->ep; - int ret; usb_packet_check_state(p, USB_PACKET_ASYNC); usb_packet_complete_one(dev, p); @@ -447,7 +456,7 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p) p = QTAILQ_FIRST(&ep->queue); if (ep->halted) { /* Empty the queue on a halt */ - p->result = USB_RET_REMOVE_FROM_QUEUE; + p->status = USB_RET_REMOVE_FROM_QUEUE; dev->port->ops->complete(dev->port, p); continue; } @@ -455,12 +464,11 @@ void usb_packet_complete(USBDevice *dev, USBPacket *p) break; } usb_packet_check_state(p, USB_PACKET_QUEUED); - ret = usb_process_one(p); - if (ret == USB_RET_ASYNC) { + usb_process_one(p); + if (p->status == USB_RET_ASYNC) { usb_packet_set_state(p, USB_PACKET_ASYNC); break; } - p->result = ret; usb_packet_complete_one(ep->dev, p); } } @@ -541,7 +549,8 @@ void usb_packet_setup(USBPacket *p, int pid, USBEndpoint *ep, uint64_t id, p->id = id; p->pid = pid; p->ep = ep; - p->result = 0; + p->status = USB_RET_SUCCESS; + p->actual_length = 0; p->parameter = 0; p->short_not_ok = short_not_ok; p->int_req = int_req; @@ -557,31 +566,31 @@ void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len) void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes) { - assert(p->result >= 0); - assert(p->result + bytes <= p->iov.size); + assert(p->actual_length >= 0); + assert(p->actual_length + bytes <= p->iov.size); switch (p->pid) { case USB_TOKEN_SETUP: case USB_TOKEN_OUT: - iov_to_buf(p->iov.iov, p->iov.niov, p->result, ptr, bytes); + iov_to_buf(p->iov.iov, p->iov.niov, p->actual_length, ptr, bytes); break; case USB_TOKEN_IN: - iov_from_buf(p->iov.iov, p->iov.niov, p->result, ptr, bytes); + iov_from_buf(p->iov.iov, p->iov.niov, p->actual_length, ptr, bytes); break; default: fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid); abort(); } - p->result += bytes; + p->actual_length += bytes; } void usb_packet_skip(USBPacket *p, size_t bytes) { - assert(p->result >= 0); - assert(p->result + bytes <= p->iov.size); + assert(p->actual_length >= 0); + assert(p->actual_length + bytes <= p->iov.size); if (p->pid == USB_TOKEN_IN) { - iov_memset(p->iov.iov, p->iov.niov, p->result, 0, bytes); + iov_memset(p->iov.iov, p->iov.niov, p->actual_length, 0, bytes); } - p->result += bytes; + p->actual_length += bytes; } void usb_packet_cleanup(USBPacket *p) diff --git a/hw/usb/desc.c b/hw/usb/desc.c index 1f12eaecbf..b7c32333d7 100644 --- a/hw/usb/desc.c +++ b/hw/usb/desc.c @@ -626,7 +626,8 @@ int usb_desc_string(USBDevice *dev, int index, uint8_t *dest, size_t len) return pos; } -int usb_desc_get_descriptor(USBDevice *dev, int value, uint8_t *dest, size_t len) +int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p, + int value, uint8_t *dest, size_t len) { const USBDesc *desc = usb_device_get_usb_desc(dev); const USBDescDevice *other_dev; @@ -696,6 +697,8 @@ int usb_desc_get_descriptor(USBDevice *dev, int value, uint8_t *dest, size_t len ret = len; } memcpy(dest, buf, ret); + p->actual_length = ret; + ret = 0; } return ret; } @@ -715,7 +718,7 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p, break; case DeviceRequest | USB_REQ_GET_DESCRIPTOR: - ret = usb_desc_get_descriptor(dev, value, data, length); + ret = usb_desc_get_descriptor(dev, p, value, data, length); break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: @@ -724,7 +727,8 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p, * the non zero value of bConfigurationValue. */ data[0] = dev->config ? dev->config->bConfigurationValue : 0; - ret = 1; + p->actual_length = 1; + ret = 0; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: ret = usb_desc_set_config(dev, value); @@ -749,7 +753,8 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p, data[0] |= 1 << USB_DEVICE_REMOTE_WAKEUP; } data[1] = 0x00; - ret = 2; + p->actual_length = 2; + ret = 0; break; } case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: @@ -772,7 +777,8 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket *p, break; } data[0] = dev->altsetting[index]; - ret = 1; + p->actual_length = 1; + ret = 0; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: ret = usb_desc_set_interface(dev, index, value); diff --git a/hw/usb/desc.h b/hw/usb/desc.h index 68bb570679..ddd3e7485c 100644 --- a/hw/usb/desc.h +++ b/hw/usb/desc.h @@ -216,7 +216,8 @@ void usb_desc_set_string(USBDevice *dev, uint8_t index, const char *str); void usb_desc_create_serial(USBDevice *dev); const char *usb_desc_get_string(USBDevice *dev, uint8_t index); int usb_desc_string(USBDevice *dev, int index, uint8_t *dest, size_t len); -int usb_desc_get_descriptor(USBDevice *dev, int value, uint8_t *dest, size_t len); +int usb_desc_get_descriptor(USBDevice *dev, USBPacket *p, + int value, uint8_t *dest, size_t len); int usb_desc_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data); diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c index 2594c78104..b669601c92 100644 --- a/hw/usb/dev-audio.c +++ b/hw/usb/dev-audio.c @@ -503,7 +503,7 @@ static int usb_audio_set_control(USBAudioState *s, uint8_t attrib, return ret; } -static int usb_audio_handle_control(USBDevice *dev, USBPacket *p, +static void usb_audio_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { @@ -518,7 +518,7 @@ static int usb_audio_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } switch (request) { @@ -534,6 +534,7 @@ static int usb_audio_handle_control(USBDevice *dev, USBPacket *p, } goto fail; } + p->actual_length = ret; break; case ClassInterfaceOutRequest | CR_SET_CUR: @@ -557,10 +558,9 @@ fail: "request 0x%04x value 0x%04x index 0x%04x length 0x%04x\n", request, value, index, length); } - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static void usb_audio_set_interface(USBDevice *dev, int iface, @@ -583,50 +583,35 @@ static void usb_audio_handle_reset(USBDevice *dev) usb_audio_set_output_altset(s, ALTSET_OFF); } -static int usb_audio_handle_dataout(USBAudioState *s, USBPacket *p) +static void usb_audio_handle_dataout(USBAudioState *s, USBPacket *p) { - int rc; - if (s->out.altset == ALTSET_OFF) { - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } - rc = streambuf_put(&s->out.buf, p); - if (rc < p->iov.size && s->debug > 1) { + streambuf_put(&s->out.buf, p); + if (p->actual_length < p->iov.size && s->debug > 1) { fprintf(stderr, "usb-audio: output overrun (%zd bytes)\n", - p->iov.size - rc); + p->iov.size - p->actual_length); } - - return 0; } -static int usb_audio_handle_data(USBDevice *dev, USBPacket *p) +static void usb_audio_handle_data(USBDevice *dev, USBPacket *p) { USBAudioState *s = (USBAudioState *) dev; - int ret = 0; - switch (p->pid) { - case USB_TOKEN_OUT: - switch (p->ep->nr) { - case 1: - ret = usb_audio_handle_dataout(s, p); - break; - default: - goto fail; - } - break; - - default: -fail: - ret = USB_RET_STALL; - break; + if (p->pid == USB_TOKEN_OUT && p->ep->nr == 1) { + usb_audio_handle_dataout(s, p); + return; } - if (ret == USB_RET_STALL && s->debug) { + + p->status = USB_RET_STALL; + if (s->debug) { fprintf(stderr, "usb-audio: failed data transaction: " "pid 0x%x ep 0x%x len 0x%zx\n", p->pid, p->ep->nr, p->iov.size); } - return ret; } static void usb_audio_handle_destroy(USBDevice *dev) diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c index 55bc19184b..bfb96bf9f0 100644 --- a/hw/usb/dev-bluetooth.c +++ b/hw/usb/dev-bluetooth.c @@ -285,13 +285,15 @@ static void usb_bt_fifo_enqueue(struct usb_hci_in_fifo_s *fifo, fifo->fifo[off].len = len; } -static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo, +static inline void usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo, USBPacket *p) { int len; - if (likely(!fifo->len)) - return USB_RET_STALL; + if (likely(!fifo->len)) { + p->status = USB_RET_STALL; + return; + } len = MIN(p->iov.size, fifo->fifo[fifo->start].len); usb_packet_copy(p, fifo->fifo[fifo->start].data, len); @@ -310,8 +312,6 @@ static inline int usb_bt_fifo_dequeue(struct usb_hci_in_fifo_s *fifo, fifo->dstart = 0; fifo->dsize = DFIFO_LEN_MASK + 1; } - - return len; } static inline void usb_bt_fifo_out_enqueue(struct USBBtState *s, @@ -363,7 +363,7 @@ static void usb_bt_handle_reset(USBDevice *dev) s->outsco.len = 0; } -static int usb_bt_handle_control(USBDevice *dev, USBPacket *p, +static void usb_bt_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { struct USBBtState *s = (struct USBBtState *) dev->opaque; @@ -382,16 +382,15 @@ static int usb_bt_handle_control(USBDevice *dev, USBPacket *p, usb_bt_fifo_reset(&s->sco); break; } - return ret; + return; } - ret = 0; switch (request) { case InterfaceRequest | USB_REQ_GET_STATUS: case EndpointRequest | USB_REQ_GET_STATUS: data[0] = 0x00; data[1] = 0x00; - ret = 2; + p->actual_length = 2; break; case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE: case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: @@ -407,16 +406,14 @@ static int usb_bt_handle_control(USBDevice *dev, USBPacket *p, break; default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } -static int usb_bt_handle_data(USBDevice *dev, USBPacket *p) +static void usb_bt_handle_data(USBDevice *dev, USBPacket *p) { struct USBBtState *s = (struct USBBtState *) dev->opaque; - int ret = 0; if (!s->config) goto fail; @@ -425,15 +422,15 @@ static int usb_bt_handle_data(USBDevice *dev, USBPacket *p) case USB_TOKEN_IN: switch (p->ep->nr) { case USB_EVT_EP: - ret = usb_bt_fifo_dequeue(&s->evt, p); + usb_bt_fifo_dequeue(&s->evt, p); break; case USB_ACL_EP: - ret = usb_bt_fifo_dequeue(&s->acl, p); + usb_bt_fifo_dequeue(&s->acl, p); break; case USB_SCO_EP: - ret = usb_bt_fifo_dequeue(&s->sco, p); + usb_bt_fifo_dequeue(&s->sco, p); break; default: @@ -460,11 +457,9 @@ static int usb_bt_handle_data(USBDevice *dev, USBPacket *p) default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - - return ret; } static void usb_bt_out_hci_packet_event(void *opaque, diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index b3dcd23109..55266b18ef 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -371,7 +371,7 @@ static void usb_hid_handle_reset(USBDevice *dev) hid_reset(&us->hid); } -static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, +static void usb_hid_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev); @@ -380,10 +380,9 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } - ret = 0; switch (request) { /* hid specific requests */ case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: @@ -392,15 +391,15 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, if (hs->kind == HID_MOUSE) { memcpy(data, qemu_mouse_hid_report_descriptor, sizeof(qemu_mouse_hid_report_descriptor)); - ret = sizeof(qemu_mouse_hid_report_descriptor); + p->actual_length = sizeof(qemu_mouse_hid_report_descriptor); } else if (hs->kind == HID_TABLET) { memcpy(data, qemu_tablet_hid_report_descriptor, sizeof(qemu_tablet_hid_report_descriptor)); - ret = sizeof(qemu_tablet_hid_report_descriptor); + p->actual_length = sizeof(qemu_tablet_hid_report_descriptor); } else if (hs->kind == HID_KEYBOARD) { memcpy(data, qemu_keyboard_hid_report_descriptor, sizeof(qemu_keyboard_hid_report_descriptor)); - ret = sizeof(qemu_keyboard_hid_report_descriptor); + p->actual_length = sizeof(qemu_keyboard_hid_report_descriptor); } break; default: @@ -409,14 +408,14 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, break; case GET_REPORT: if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { - ret = hid_pointer_poll(hs, data, length); + p->actual_length = hid_pointer_poll(hs, data, length); } else if (hs->kind == HID_KEYBOARD) { - ret = hid_keyboard_poll(hs, data, length); + p->actual_length = hid_keyboard_poll(hs, data, length); } break; case SET_REPORT: if (hs->kind == HID_KEYBOARD) { - ret = hid_keyboard_write(hs, data, length); + p->actual_length = hid_keyboard_write(hs, data, length); } else { goto fail; } @@ -425,19 +424,18 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, if (hs->kind != HID_KEYBOARD && hs->kind != HID_MOUSE) { goto fail; } - ret = 1; data[0] = hs->protocol; + p->actual_length = 1; break; case SET_PROTOCOL: if (hs->kind != HID_KEYBOARD && hs->kind != HID_MOUSE) { goto fail; } - ret = 0; hs->protocol = value; break; case GET_IDLE: - ret = 1; data[0] = hs->idle; + p->actual_length = 1; break; case SET_IDLE: hs->idle = (uint8_t) (value >> 8); @@ -445,22 +443,20 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p, if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { hid_pointer_activate(hs); } - ret = 0; break; default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } -static int usb_hid_handle_data(USBDevice *dev, USBPacket *p) +static void usb_hid_handle_data(USBDevice *dev, USBPacket *p) { USBHIDState *us = DO_UPCAST(USBHIDState, dev, dev); HIDState *hs = &us->hid; uint8_t buf[p->iov.size]; - int ret = 0; + int len = 0; switch (p->pid) { case USB_TOKEN_IN: @@ -471,15 +467,16 @@ static int usb_hid_handle_data(USBDevice *dev, USBPacket *p) } if (!hid_has_events(hs) && (!hs->idle || hs->next_idle_clock - curtime > 0)) { - return USB_RET_NAK; + p->status = USB_RET_NAK; + return; } hid_set_next_idle(hs, curtime); if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) { - ret = hid_pointer_poll(hs, buf, p->iov.size); + len = hid_pointer_poll(hs, buf, p->iov.size); } else if (hs->kind == HID_KEYBOARD) { - ret = hid_keyboard_poll(hs, buf, p->iov.size); + len = hid_keyboard_poll(hs, buf, p->iov.size); } - usb_packet_copy(p, buf, ret); + usb_packet_copy(p, buf, len); } else { goto fail; } @@ -487,10 +484,9 @@ static int usb_hid_handle_data(USBDevice *dev, USBPacket *p) case USB_TOKEN_OUT: default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static void usb_hid_handle_destroy(USBDevice *dev) diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index 8fd30df0e6..9ee60dd412 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -288,7 +288,7 @@ static const char *feature_name(int feature) return name[feature] ?: "?"; } -static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, +static void usb_hub_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBHubState *s = (USBHubState *)dev; @@ -298,7 +298,7 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } switch(request) { @@ -306,7 +306,6 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, if (value == 0 && index != 0x81) { /* clear ep halt */ goto fail; } - ret = 0; break; /* usb specific requests */ case GetHubStatus: @@ -314,7 +313,7 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, data[1] = 0; data[2] = 0; data[3] = 0; - ret = 4; + p->actual_length = 4; break; case GetPortStatus: { @@ -331,16 +330,14 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, data[1] = port->wPortStatus >> 8; data[2] = port->wPortChange; data[3] = port->wPortChange >> 8; - ret = 4; + p->actual_length = 4; } break; case SetHubFeature: case ClearHubFeature: - if (value == 0 || value == 1) { - } else { + if (value != 0 && value != 1) { goto fail; } - ret = 0; break; case SetPortFeature: { @@ -373,7 +370,6 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, default: goto fail; } - ret = 0; } break; case ClearPortFeature: @@ -413,7 +409,6 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, default: goto fail; } - ret = 0; } break; case GetHubDescriptor: @@ -437,22 +432,20 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, var_hub_size++; } - ret = sizeof(qemu_hub_hub_descriptor) + var_hub_size; - data[0] = ret; + p->actual_length = sizeof(qemu_hub_hub_descriptor) + var_hub_size; + data[0] = p->actual_length; break; } default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } -static int usb_hub_handle_data(USBDevice *dev, USBPacket *p) +static void usb_hub_handle_data(USBDevice *dev, USBPacket *p) { USBHubState *s = (USBHubState *)dev; - int ret; switch(p->pid) { case USB_TOKEN_IN: @@ -465,7 +458,8 @@ static int usb_hub_handle_data(USBDevice *dev, USBPacket *p) if (p->iov.size == 1) { /* FreeBSD workaround */ n = 1; } else if (n > p->iov.size) { - return USB_RET_BABBLE; + p->status = USB_RET_BABBLE; + return; } status = 0; for(i = 0; i < NUM_PORTS; i++) { @@ -478,9 +472,8 @@ static int usb_hub_handle_data(USBDevice *dev, USBPacket *p) buf[i] = status >> (8 * i); } usb_packet_copy(p, buf, n); - ret = n; } else { - ret = USB_RET_NAK; /* usb11 11.13.1 */ + p->status = USB_RET_NAK; /* usb11 11.13.1 */ } } else { goto fail; @@ -489,10 +482,9 @@ static int usb_hub_handle_data(USBDevice *dev, USBPacket *p) case USB_TOKEN_OUT: default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static void usb_hub_handle_destroy(USBDevice *dev) diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c index e4a43599b5..14d9e5aa5b 100644 --- a/hw/usb/dev-network.c +++ b/hw/usb/dev-network.c @@ -1048,7 +1048,7 @@ static void usb_net_handle_reset(USBDevice *dev) { } -static int usb_net_handle_control(USBDevice *dev, USBPacket *p, +static void usb_net_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBNetState *s = (USBNetState *) dev; @@ -1056,10 +1056,9 @@ static int usb_net_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } - ret = 0; switch(request) { case ClassInterfaceOutRequest | USB_CDC_SEND_ENCAPSULATED_COMMAND: if (!is_rndis(s) || value || index != 0) { @@ -1078,22 +1077,25 @@ static int usb_net_handle_control(USBDevice *dev, USBPacket *p, } #endif ret = rndis_parse(s, data, length); + if (ret < 0) { + p->status = ret; + } break; case ClassInterfaceRequest | USB_CDC_GET_ENCAPSULATED_RESPONSE: if (!is_rndis(s) || value || index != 0) { goto fail; } - ret = rndis_get_response(s, data); - if (!ret) { + p->actual_length = rndis_get_response(s, data); + if (p->actual_length == 0) { data[0] = 0; - ret = 1; + p->actual_length = 1; } #ifdef TRAFFIC_DEBUG { unsigned int i; fprintf(stderr, "GET_ENCAPSULATED_RESPONSE:"); - for (i = 0; i < ret; i++) { + for (i = 0; i < p->actual_length; i++) { if (!(i & 15)) fprintf(stderr, "\n%04x:", i); fprintf(stderr, " %02x", data[i]); @@ -1108,72 +1110,67 @@ static int usb_net_handle_control(USBDevice *dev, USBPacket *p, fprintf(stderr, "usbnet: failed control transaction: " "request 0x%x value 0x%x index 0x%x length 0x%x\n", request, value, index, length); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } -static int usb_net_handle_statusin(USBNetState *s, USBPacket *p) +static void usb_net_handle_statusin(USBNetState *s, USBPacket *p) { le32 buf[2]; - int ret = 8; if (p->iov.size < 8) { - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } buf[0] = cpu_to_le32(1); buf[1] = cpu_to_le32(0); usb_packet_copy(p, buf, 8); - if (!s->rndis_resp.tqh_first) - ret = USB_RET_NAK; + if (!s->rndis_resp.tqh_first) { + p->status = USB_RET_NAK; + } #ifdef TRAFFIC_DEBUG fprintf(stderr, "usbnet: interrupt poll len %zu return %d", - p->iov.size, ret); - iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", ret); + p->iov.size, p->status); + iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", p->status); #endif - - return ret; } -static int usb_net_handle_datain(USBNetState *s, USBPacket *p) +static void usb_net_handle_datain(USBNetState *s, USBPacket *p) { - int ret = USB_RET_NAK; + int len; if (s->in_ptr > s->in_len) { usb_net_reset_in_buf(s); - ret = USB_RET_NAK; - return ret; + p->status = USB_RET_NAK; + return; } if (!s->in_len) { - ret = USB_RET_NAK; - return ret; + p->status = USB_RET_NAK; + return; } - ret = s->in_len - s->in_ptr; - if (ret > p->iov.size) { - ret = p->iov.size; + len = s->in_len - s->in_ptr; + if (len > p->iov.size) { + len = p->iov.size; } - usb_packet_copy(p, &s->in_buf[s->in_ptr], ret); - s->in_ptr += ret; + usb_packet_copy(p, &s->in_buf[s->in_ptr], len); + s->in_ptr += len; if (s->in_ptr >= s->in_len && - (is_rndis(s) || (s->in_len & (64 - 1)) || !ret)) { + (is_rndis(s) || (s->in_len & (64 - 1)) || !len)) { /* no short packet necessary */ usb_net_reset_in_buf(s); } #ifdef TRAFFIC_DEBUG - fprintf(stderr, "usbnet: data in len %zu return %d", p->iov.size, ret); - iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", ret); + fprintf(stderr, "usbnet: data in len %zu return %d", p->iov.size, len); + iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", len); #endif - - return ret; } -static int usb_net_handle_dataout(USBNetState *s, USBPacket *p) +static void usb_net_handle_dataout(USBNetState *s, USBPacket *p) { - int ret = p->iov.size; int sz = sizeof(s->out_buf) - s->out_ptr; struct rndis_packet_msg_type *msg = (struct rndis_packet_msg_type *) s->out_buf; @@ -1184,21 +1181,23 @@ static int usb_net_handle_dataout(USBNetState *s, USBPacket *p) iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", p->iov.size); #endif - if (sz > ret) - sz = ret; + if (sz > p->iov.size) { + sz = p->iov.size; + } usb_packet_copy(p, &s->out_buf[s->out_ptr], sz); s->out_ptr += sz; if (!is_rndis(s)) { - if (ret < 64) { + if (p->iov.size < 64) { qemu_send_packet(&s->nic->nc, s->out_buf, s->out_ptr); s->out_ptr = 0; } - return ret; + return; } len = le32_to_cpu(msg->MessageLength); - if (s->out_ptr < 8 || s->out_ptr < len) - return ret; + if (s->out_ptr < 8 || s->out_ptr < len) { + return; + } if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) { uint32_t offs = 8 + le32_to_cpu(msg->DataOffset); uint32_t size = le32_to_cpu(msg->DataLength); @@ -1207,24 +1206,21 @@ static int usb_net_handle_dataout(USBNetState *s, USBPacket *p) } s->out_ptr -= len; memmove(s->out_buf, &s->out_buf[len], s->out_ptr); - - return ret; } -static int usb_net_handle_data(USBDevice *dev, USBPacket *p) +static void usb_net_handle_data(USBDevice *dev, USBPacket *p) { USBNetState *s = (USBNetState *) dev; - int ret = 0; switch(p->pid) { case USB_TOKEN_IN: switch (p->ep->nr) { case 1: - ret = usb_net_handle_statusin(s, p); + usb_net_handle_statusin(s, p); break; case 2: - ret = usb_net_handle_datain(s, p); + usb_net_handle_datain(s, p); break; default: @@ -1235,7 +1231,7 @@ static int usb_net_handle_data(USBDevice *dev, USBPacket *p) case USB_TOKEN_OUT: switch (p->ep->nr) { case 2: - ret = usb_net_handle_dataout(s, p); + usb_net_handle_dataout(s, p); break; default: @@ -1245,14 +1241,15 @@ static int usb_net_handle_data(USBDevice *dev, USBPacket *p) default: fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - if (ret == USB_RET_STALL) + + if (p->status == USB_RET_STALL) { fprintf(stderr, "usbnet: failed data transaction: " "pid 0x%x ep 0x%x len 0x%zx\n", p->pid, p->ep->nr, p->iov.size); - return ret; + } } static ssize_t usbnet_receive(NetClientState *nc, const uint8_t *buf, size_t size) diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index a466f9929c..99b19df1d1 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -219,7 +219,7 @@ static uint8_t usb_get_modem_lines(USBSerialState *s) return ret; } -static int usb_serial_handle_control(USBDevice *dev, USBPacket *p, +static void usb_serial_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBSerialState *s = (USBSerialState *)dev; @@ -228,13 +228,11 @@ static int usb_serial_handle_control(USBDevice *dev, USBPacket *p, DPRINTF("got control %x, value %x\n",request, value); ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } - ret = 0; switch (request) { case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: - ret = 0; break; /* Class specific requests. */ @@ -323,7 +321,7 @@ static int usb_serial_handle_control(USBDevice *dev, USBPacket *p, case DeviceInVendor | FTDI_GET_MDM_ST: data[0] = usb_get_modem_lines(s) | 1; data[1] = 0; - ret = 2; + p->actual_length = 2; break; case DeviceOutVendor | FTDI_SET_EVENT_CHR: /* TODO: handle it */ @@ -338,25 +336,23 @@ static int usb_serial_handle_control(USBDevice *dev, USBPacket *p, break; case DeviceInVendor | FTDI_GET_LATENCY: data[0] = s->latency; - ret = 1; + p->actual_length = 1; break; default: fail: DPRINTF("got unsupported/bogus control %x, value %x\n", request, value); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } -static int usb_serial_handle_data(USBDevice *dev, USBPacket *p) +static void usb_serial_handle_data(USBDevice *dev, USBPacket *p) { USBSerialState *s = (USBSerialState *)dev; - int i, ret = 0; uint8_t devep = p->ep->nr; struct iovec *iov; uint8_t header[2]; - int first_len, len; + int i, first_len, len; switch (p->pid) { case USB_TOKEN_OUT: @@ -366,6 +362,7 @@ static int usb_serial_handle_data(USBDevice *dev, USBPacket *p) iov = p->iov.iov + i; qemu_chr_fe_write(s->cs, iov->iov_base, iov->iov_len); } + p->actual_length = p->iov.size; break; case USB_TOKEN_IN: @@ -374,7 +371,7 @@ static int usb_serial_handle_data(USBDevice *dev, USBPacket *p) first_len = RECV_BUF - s->recv_ptr; len = p->iov.size; if (len <= 2) { - ret = USB_RET_NAK; + p->status = USB_RET_NAK; break; } header[0] = usb_get_modem_lines(s) | 1; @@ -384,7 +381,6 @@ static int usb_serial_handle_data(USBDevice *dev, USBPacket *p) s->event_trigger &= ~FTDI_BI; header[1] = FTDI_BI; usb_packet_copy(p, header, 2); - ret = 2; break; } else { header[1] = 0; @@ -393,7 +389,7 @@ static int usb_serial_handle_data(USBDevice *dev, USBPacket *p) if (len > s->recv_used) len = s->recv_used; if (!len) { - ret = USB_RET_NAK; + p->status = USB_RET_NAK; break; } if (first_len > len) @@ -404,17 +400,14 @@ static int usb_serial_handle_data(USBDevice *dev, USBPacket *p) usb_packet_copy(p, s->recv_buf, len - first_len); s->recv_used -= len; s->recv_ptr = (s->recv_ptr + len) % RECV_BUF; - ret = len + 2; break; default: DPRINTF("Bad token\n"); fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - - return ret; } static void usb_serial_handle_destroy(USBDevice *dev) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 1ea079176a..190fcd62d4 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -635,39 +635,38 @@ static void ccid_handle_reset(USBDevice *dev) ccid_reset(s); } -static int ccid_handle_control(USBDevice *dev, USBPacket *p, int request, +static void ccid_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev); - int ret = 0; + int ret; DPRINTF(s, 1, "got control %x, value %x\n", request, value); ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } switch (request) { /* Class specific requests. */ case InterfaceOutClass | CCID_CONTROL_ABORT: DPRINTF(s, 1, "ccid_control abort UNIMPLEMENTED\n"); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; case InterfaceInClass | CCID_CONTROL_GET_CLOCK_FREQUENCIES: DPRINTF(s, 1, "ccid_control get clock frequencies UNIMPLEMENTED\n"); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; case InterfaceInClass | CCID_CONTROL_GET_DATA_RATES: DPRINTF(s, 1, "ccid_control get data rates UNIMPLEMENTED\n"); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; default: DPRINTF(s, 1, "got unsupported/bogus control %x, value %x\n", request, value); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static bool ccid_card_inserted(USBCCIDState *s) @@ -870,18 +869,13 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s, CCID_XferBlock *recv) } } -/* - * Handle a single USB_TOKEN_OUT, return value returned to guest. - * Return value: - * 0 - all ok - * USB_RET_STALL - failed to handle packet - */ -static int ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p) +static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p) { CCID_Header *ccid_header; if (p->iov.size + s->bulk_out_pos > BULK_OUT_DATA_SIZE) { - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } ccid_header = (CCID_Header *)s->bulk_out_data; usb_packet_copy(p, s->bulk_out_data + s->bulk_out_pos, p->iov.size); @@ -890,7 +884,7 @@ static int ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p) DPRINTF(s, D_VERBOSE, "usb-ccid: bulk_in: expecting more packets (%zd/%d)\n", p->iov.size, ccid_header->dwLength); - return 0; + return; } if (s->bulk_out_pos < 10) { DPRINTF(s, 1, @@ -949,60 +943,52 @@ static int ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p) } } s->bulk_out_pos = 0; - return 0; } -static int ccid_bulk_in_copy_to_guest(USBCCIDState *s, USBPacket *p) +static void ccid_bulk_in_copy_to_guest(USBCCIDState *s, USBPacket *p) { - int ret = 0; + int len = 0; - assert(p->iov.size > 0); ccid_bulk_in_get(s); if (s->current_bulk_in != NULL) { - ret = MIN(s->current_bulk_in->len - s->current_bulk_in->pos, + len = MIN(s->current_bulk_in->len - s->current_bulk_in->pos, p->iov.size); usb_packet_copy(p, s->current_bulk_in->data + - s->current_bulk_in->pos, ret); - s->current_bulk_in->pos += ret; + s->current_bulk_in->pos, len); + s->current_bulk_in->pos += len; if (s->current_bulk_in->pos == s->current_bulk_in->len) { ccid_bulk_in_release(s); } } else { /* return when device has no data - usb 2.0 spec Table 8-4 */ - ret = USB_RET_NAK; + p->status = USB_RET_NAK; } - if (ret > 0) { + if (len) { DPRINTF(s, D_MORE_INFO, "%s: %zd/%d req/act to guest (BULK_IN)\n", - __func__, p->iov.size, ret); + __func__, p->iov.size, len); } - if (ret != USB_RET_NAK && ret < p->iov.size) { + if (len < p->iov.size) { DPRINTF(s, 1, "%s: returning short (EREMOTEIO) %d < %zd\n", - __func__, ret, p->iov.size); + __func__, len, p->iov.size); } - return ret; } -static int ccid_handle_data(USBDevice *dev, USBPacket *p) +static void ccid_handle_data(USBDevice *dev, USBPacket *p) { USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev); - int ret = 0; uint8_t buf[2]; switch (p->pid) { case USB_TOKEN_OUT: - ret = ccid_handle_bulk_out(s, p); + ccid_handle_bulk_out(s, p); break; case USB_TOKEN_IN: switch (p->ep->nr) { case CCID_BULK_IN_EP: - if (!p->iov.size) { - ret = USB_RET_NAK; - } else { - ret = ccid_bulk_in_copy_to_guest(s, p); - } + ccid_bulk_in_copy_to_guest(s, p); break; case CCID_INT_IN_EP: if (s->notify_slot_change) { @@ -1010,7 +996,6 @@ static int ccid_handle_data(USBDevice *dev, USBPacket *p) buf[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange; buf[1] = s->bmSlotICCState; usb_packet_copy(p, buf, 2); - ret = 2; s->notify_slot_change = false; s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK; DPRINTF(s, D_INFO, @@ -1021,17 +1006,15 @@ static int ccid_handle_data(USBDevice *dev, USBPacket *p) break; default: DPRINTF(s, 1, "Bad endpoint\n"); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } break; default: DPRINTF(s, 1, "Bad token\n"); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - - return ret; } static void ccid_handle_destroy(USBDevice *dev) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index e732191a26..50af97109b 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -215,7 +215,7 @@ static const USBDesc desc = { static void usb_msd_copy_data(MSDState *s, USBPacket *p) { uint32_t len; - len = p->iov.size - p->result; + len = p->iov.size - p->actual_length; if (len > s->scsi_len) len = s->scsi_len; usb_packet_copy(p, scsi_req_get_buf(s->req) + s->scsi_off, len); @@ -263,7 +263,8 @@ static void usb_msd_transfer_data(SCSIRequest *req, uint32_t len) if (p) { usb_msd_copy_data(s, p); p = s->packet; - if (p && p->result == p->iov.size) { + if (p && p->actual_length == p->iov.size) { + p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */ usb_msd_packet_complete(s); } } @@ -292,7 +293,7 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r s->mode = USB_MSDM_CBW; } else { if (s->data_len) { - int len = (p->iov.size - p->result); + int len = (p->iov.size - p->actual_length); usb_packet_skip(p, len); s->data_len -= len; } @@ -300,6 +301,7 @@ static void usb_msd_command_complete(SCSIRequest *req, uint32_t status, size_t r s->mode = USB_MSDM_CSW; } } + p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */ usb_msd_packet_complete(s); } else if (s->data_len == 0) { s->mode = USB_MSDM_CSW; @@ -330,14 +332,14 @@ static void usb_msd_handle_reset(USBDevice *dev) assert(s->req == NULL); if (s->packet) { - s->packet->result = USB_RET_STALL; + s->packet->status = USB_RET_STALL; usb_msd_packet_complete(s); } s->mode = USB_MSDM_CBW; } -static int usb_msd_handle_control(USBDevice *dev, USBPacket *p, +static void usb_msd_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { MSDState *s = (MSDState *)dev; @@ -345,29 +347,25 @@ static int usb_msd_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } - ret = 0; switch (request) { case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: - ret = 0; break; /* Class specific requests. */ case ClassInterfaceOutRequest | MassStorageReset: /* Reset state ready for the next CBW. */ s->mode = USB_MSDM_CBW; - ret = 0; break; case ClassInterfaceRequest | GetMaxLun: data[0] = 0; - ret = 1; + p->actual_length = 1; break; default: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p) @@ -382,11 +380,10 @@ static void usb_msd_cancel_io(USBDevice *dev, USBPacket *p) } } -static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) +static void usb_msd_handle_data(USBDevice *dev, USBPacket *p) { MSDState *s = (MSDState *)dev; uint32_t tag; - int ret = 0; struct usb_msd_cbw cbw; uint8_t devep = p->ep->nr; @@ -433,7 +430,6 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) if (s->req && s->req->cmd.xfer != SCSI_XFER_NONE) { scsi_req_continue(s->req); } - ret = p->result; break; case USB_MSDM_DATAOUT: @@ -446,7 +442,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) usb_msd_copy_data(s, p); } if (le32_to_cpu(s->csw.residue)) { - int len = p->iov.size - p->result; + int len = p->iov.size - p->actual_length; if (len) { usb_packet_skip(p, len); s->data_len -= len; @@ -455,12 +451,10 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) } } } - if (p->result < p->iov.size) { + if (p->actual_length < p->iov.size) { DPRINTF("Deferring packet %p [wait data-out]\n", p); s->packet = p; - ret = USB_RET_ASYNC; - } else { - ret = p->result; + p->status = USB_RET_ASYNC; } break; @@ -481,7 +475,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) } /* Waiting for SCSI write to complete. */ s->packet = p; - ret = USB_RET_ASYNC; + p->status = USB_RET_ASYNC; break; case USB_MSDM_CSW: @@ -493,11 +487,10 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) /* still in flight */ DPRINTF("Deferring packet %p [wait status]\n", p); s->packet = p; - ret = USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } else { usb_msd_send_status(s, p); s->mode = USB_MSDM_CBW; - ret = 13; } break; @@ -508,7 +501,7 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) usb_msd_copy_data(s, p); } if (le32_to_cpu(s->csw.residue)) { - int len = p->iov.size - p->result; + int len = p->iov.size - p->actual_length; if (len) { usb_packet_skip(p, len); s->data_len -= len; @@ -517,12 +510,10 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) } } } - if (p->result < p->iov.size) { + if (p->actual_length < p->iov.size) { DPRINTF("Deferring packet %p [wait data-in]\n", p); s->packet = p; - ret = USB_RET_ASYNC; - } else { - ret = p->result; + p->status = USB_RET_ASYNC; } break; @@ -535,11 +526,9 @@ static int usb_msd_handle_data(USBDevice *dev, USBPacket *p) default: DPRINTF("Bad token\n"); fail: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - - return ret; } static void usb_msd_password_cb(void *opaque, int err) diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 4389380e95..a21b2ba627 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -256,10 +256,10 @@ static void usb_uas_send_status_bh(void *opaque) uas->status = NULL; usb_packet_copy(p, &st->status, st->length); - p->result = st->length; QTAILQ_REMOVE(&uas->results, st, next); g_free(st); + p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */ usb_packet_complete(&uas->dev, p); } @@ -349,6 +349,7 @@ static void usb_uas_complete_data_packet(UASRequest *req) p = req->data; req->data = NULL; req->data_async = false; + p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */ usb_packet_complete(&req->uas->dev, p); } @@ -357,16 +358,16 @@ static void usb_uas_copy_data(UASRequest *req) uint32_t length; length = MIN(req->buf_size - req->buf_off, - req->data->iov.size - req->data->result); + req->data->iov.size - req->data->actual_length); trace_usb_uas_xfer_data(req->uas->dev.addr, req->tag, length, - req->data->result, req->data->iov.size, + req->data->actual_length, req->data->iov.size, req->buf_off, req->buf_size); usb_packet_copy(req->data, scsi_req_get_buf(req->req) + req->buf_off, length); req->buf_off += length; req->data_off += length; - if (req->data->result == req->data->iov.size) { + if (req->data->actual_length == req->data->iov.size) { usb_uas_complete_data_packet(req); } if (req->buf_size && req->buf_off == req->buf_size) { @@ -504,17 +505,17 @@ static void usb_uas_handle_reset(USBDevice *dev) } } -static int usb_uas_handle_control(USBDevice *dev, USBPacket *p, +static void usb_uas_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { int ret; ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } fprintf(stderr, "%s: unhandled control request\n", __func__); - return USB_RET_STALL; + p->status = USB_RET_STALL; } static void usb_uas_cancel_io(USBDevice *dev, USBPacket *p) @@ -641,13 +642,13 @@ incorrect_lun: usb_uas_queue_response(uas, tag, UAS_RC_INCORRECT_LUN, 0); } -static int usb_uas_handle_data(USBDevice *dev, USBPacket *p) +static void usb_uas_handle_data(USBDevice *dev, USBPacket *p) { UASDevice *uas = DO_UPCAST(UASDevice, dev, dev); uas_ui ui; UASStatus *st; UASRequest *req; - int length, ret = 0; + int length; switch (p->ep->nr) { case UAS_PIPE_ID_COMMAND: @@ -656,16 +657,14 @@ static int usb_uas_handle_data(USBDevice *dev, USBPacket *p) switch (ui.hdr.id) { case UAS_UI_COMMAND: usb_uas_command(uas, &ui); - ret = length; break; case UAS_UI_TASK_MGMT: usb_uas_task(uas, &ui); - ret = length; break; default: fprintf(stderr, "%s: unknown command ui: id 0x%x\n", __func__, ui.hdr.id); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } break; @@ -674,11 +673,10 @@ static int usb_uas_handle_data(USBDevice *dev, USBPacket *p) if (st == NULL) { assert(uas->status == NULL); uas->status = p; - ret = USB_RET_ASYNC; + p->status = USB_RET_ASYNC; break; } usb_packet_copy(p, &st->status, st->length); - ret = st->length; QTAILQ_REMOVE(&uas->results, st, next); g_free(st); break; @@ -687,28 +685,26 @@ static int usb_uas_handle_data(USBDevice *dev, USBPacket *p) req = (p->ep->nr == UAS_PIPE_ID_DATA_IN) ? uas->datain : uas->dataout; if (req == NULL) { fprintf(stderr, "%s: no inflight request\n", __func__); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } scsi_req_ref(req->req); req->data = p; usb_uas_copy_data(req); - if (p->result == p->iov.size || req->complete) { + if (p->actual_length == p->iov.size || req->complete) { req->data = NULL; - ret = p->result; } else { req->data_async = true; - ret = USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } scsi_req_unref(req->req); usb_uas_start_next_transfer(uas); break; default: fprintf(stderr, "%s: invalid endpoint %d\n", __func__, p->ep->nr); - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } static void usb_uas_handle_destroy(USBDevice *dev) diff --git a/hw/usb/dev-wacom.c b/hw/usb/dev-wacom.c index ed9a5ee358..08b416daa6 100644 --- a/hw/usb/dev-wacom.c +++ b/hw/usb/dev-wacom.c @@ -250,7 +250,7 @@ static void usb_wacom_handle_reset(USBDevice *dev) s->mode = WACOM_MODE_HID; } -static int usb_wacom_handle_control(USBDevice *dev, USBPacket *p, +static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBWacomState *s = (USBWacomState *) dev; @@ -258,10 +258,9 @@ static int usb_wacom_handle_control(USBDevice *dev, USBPacket *p, ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { - return ret; + return; } - ret = 0; switch (request) { case WACOM_SET_REPORT: if (s->mouse_grabbed) { @@ -269,61 +268,58 @@ static int usb_wacom_handle_control(USBDevice *dev, USBPacket *p, s->mouse_grabbed = 0; } s->mode = data[0]; - ret = 0; break; case WACOM_GET_REPORT: data[0] = 0; data[1] = s->mode; - ret = 2; + p->actual_length = 2; break; /* USB HID requests */ case HID_GET_REPORT: if (s->mode == WACOM_MODE_HID) - ret = usb_mouse_poll(s, data, length); + p->actual_length = usb_mouse_poll(s, data, length); else if (s->mode == WACOM_MODE_WACOM) - ret = usb_wacom_poll(s, data, length); + p->actual_length = usb_wacom_poll(s, data, length); break; case HID_GET_IDLE: - ret = 1; data[0] = s->idle; + p->actual_length = 1; break; case HID_SET_IDLE: s->idle = (uint8_t) (value >> 8); - ret = 0; break; default: - ret = USB_RET_STALL; + p->status = USB_RET_STALL; break; } - return ret; } -static int usb_wacom_handle_data(USBDevice *dev, USBPacket *p) +static void usb_wacom_handle_data(USBDevice *dev, USBPacket *p) { USBWacomState *s = (USBWacomState *) dev; uint8_t buf[p->iov.size]; - int ret = 0; + int len = 0; switch (p->pid) { case USB_TOKEN_IN: if (p->ep->nr == 1) { - if (!(s->changed || s->idle)) - return USB_RET_NAK; + if (!(s->changed || s->idle)) { + p->status = USB_RET_NAK; + return; + } s->changed = 0; if (s->mode == WACOM_MODE_HID) - ret = usb_mouse_poll(s, buf, p->iov.size); + len = usb_mouse_poll(s, buf, p->iov.size); else if (s->mode == WACOM_MODE_WACOM) - ret = usb_wacom_poll(s, buf, p->iov.size); - usb_packet_copy(p, buf, ret); + len = usb_wacom_poll(s, buf, p->iov.size); + usb_packet_copy(p, buf, len); break; } /* Fall through. */ case USB_TOKEN_OUT: default: - ret = USB_RET_STALL; - break; + p->status = USB_RET_STALL; } - return ret; } static void usb_wacom_handle_destroy(USBDevice *dev) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index d9dc576e7c..3a1f5134ea 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1163,7 +1163,7 @@ static void ehci_async_complete_packet(USBPort *port, USBPacket *packet) p = container_of(packet, EHCIPacket, packet); assert(p->async == EHCI_ASYNC_INFLIGHT); - if (packet->result == USB_RET_REMOVE_FROM_QUEUE) { + if (packet->status == USB_RET_REMOVE_FROM_QUEUE) { trace_usb_ehci_packet_action(p->queue, p, "remove"); ehci_free_packet(p); return; @@ -1171,7 +1171,7 @@ static void ehci_async_complete_packet(USBPort *port, USBPacket *packet) trace_usb_ehci_packet_action(p->queue, p, "wakeup"); p->async = EHCI_ASYNC_FINISHED; - p->usb_status = packet->result; + p->usb_status = packet->status ? packet->status : packet->actual_length; if (p->queue->async) { qemu_bh_schedule(p->queue->ehci->async_bh); @@ -1253,7 +1253,6 @@ static void ehci_execute_complete(EHCIQueue *q) static int ehci_execute(EHCIPacket *p, const char *action) { USBEndpoint *ep; - int ret; int endp; bool spd; @@ -1303,17 +1302,22 @@ static int ehci_execute(EHCIPacket *p, const char *action) } trace_usb_ehci_packet_action(p->queue, p, action); - ret = usb_handle_packet(p->queue->dev, &p->packet); - DPRINTF("submit: qh %x next %x qtd %x pid %x len %zd endp %x ret %d\n", - q->qhaddr, q->qh.next, q->qtdaddr, q->pid, - q->packet.iov.size, endp, ret); + usb_handle_packet(p->queue->dev, &p->packet); + DPRINTF("submit: qh 0x%x next 0x%x qtd 0x%x pid 0x%x len %zd endp 0x%x " + "status %d actual_length %d\n", p->queue->qhaddr, p->qtd.next, + p->qtdaddr, p->pid, p->packet.iov.size, endp, p->packet.status, + p->packet.actual_length); - if (ret > BUFF_SIZE) { + if (p->packet.actual_length > BUFF_SIZE) { fprintf(stderr, "ret from usb_handle_packet > BUFF_SIZE\n"); return USB_RET_PROCERR; } - return ret; + if (p->packet.status == USB_RET_SUCCESS) { + return p->packet.actual_length; + } else { + return p->packet.status; + } } /* 4.7.2 @@ -1370,8 +1374,10 @@ static int ehci_process_itd(EHCIState *ehci, usb_packet_setup(&ehci->ipacket, pid, ep, addr, false, (itd->transact[i] & ITD_XACT_IOC) != 0); usb_packet_map(&ehci->ipacket, &ehci->isgl); - ret = usb_handle_packet(dev, &ehci->ipacket); + usb_handle_packet(dev, &ehci->ipacket); usb_packet_unmap(&ehci->ipacket, &ehci->isgl); + ret = (ehci->ipacket.status == USB_RET_SUCCESS) ? + ehci->ipacket.actual_length : ehci->ipacket.status; } else { DPRINTF("ISOCH: attempt to addess non-iso endpoint\n"); ret = USB_RET_NAK; diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c index 4f5539020b..c707f7a2bb 100644 --- a/hw/usb/hcd-musb.c +++ b/hw/usb/hcd-musb.c @@ -607,7 +607,6 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep, { USBDevice *dev; USBEndpoint *uep; - int ret; int idx = epnum && dir; int ttype; @@ -632,15 +631,19 @@ static void musb_packet(MUSBState *s, MUSBEndPoint *ep, ep->packey[dir].ep = ep; ep->packey[dir].dir = dir; - ret = usb_handle_packet(dev, &ep->packey[dir].p); + usb_handle_packet(dev, &ep->packey[dir].p); - if (ret == USB_RET_ASYNC) { + if (ep->packey[dir].p.status == USB_RET_ASYNC) { usb_device_flush_ep_queue(dev, uep); ep->status[dir] = len; return; } - ep->status[dir] = ret; + if (ep->packey[dir].p.status == USB_RET_SUCCESS) { + ep->status[dir] = ep->packey[dir].p.actual_length; + } else { + ep->status[dir] = ep->packey[dir].p.status; + } musb_schedule_cb(&s->port, &ep->packey[dir].p); } @@ -754,7 +757,6 @@ static void musb_rx_packet_complete(USBPacket *packey, void *opaque) if (ep->status[1] == USB_RET_STALL) { ep->status[1] = 0; - packey->result = 0; ep->csr[1] |= MGC_M_RXCSR_H_RXSTALL; if (!epnum) @@ -793,14 +795,12 @@ static void musb_rx_packet_complete(USBPacket *packey, void *opaque) /* TODO: check len for over/underruns of an OUT packet? */ /* TODO: perhaps make use of e->ext_size[1] here. */ - packey->result = ep->status[1]; - if (!(ep->csr[1] & (MGC_M_RXCSR_H_RXSTALL | MGC_M_RXCSR_DATAERROR))) { ep->csr[1] |= MGC_M_RXCSR_FIFOFULL | MGC_M_RXCSR_RXPKTRDY; if (!epnum) ep->csr[0] |= MGC_M_CSR0_RXPKTRDY; - ep->rxcount = packey->result; /* XXX: MIN(packey->len, ep->maxp[1]); */ + ep->rxcount = ep->status[1]; /* XXX: MIN(packey->len, ep->maxp[1]); */ /* In DMA mode: assert DMA request for this EP */ } diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c index 7571e9e44a..6a39e9697b 100644 --- a/hw/usb/hcd-ohci.c +++ b/hw/usb/hcd-ohci.c @@ -807,21 +807,24 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed, DMA_DIRECTION_TO_DEVICE); } - if (completion) { - ret = ohci->usb_packet.result; - } else { + if (!completion) { bool int_req = relative_frame_number == frame_count && OHCI_BM(iso_td.flags, TD_DI) == 0; dev = ohci_find_device(ohci, OHCI_BM(ed->flags, ED_FA)); ep = usb_ep_get(dev, pid, OHCI_BM(ed->flags, ED_EN)); usb_packet_setup(&ohci->usb_packet, pid, ep, addr, false, int_req); usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, len); - ret = usb_handle_packet(dev, &ohci->usb_packet); - if (ret == USB_RET_ASYNC) { + usb_handle_packet(dev, &ohci->usb_packet); + if (ohci->usb_packet.status == USB_RET_ASYNC) { usb_device_flush_ep_queue(dev, ep); return 1; } } + if (ohci->usb_packet.status == USB_RET_SUCCESS) { + ret = ohci->usb_packet.actual_length; + } else { + ret = ohci->usb_packet.status; + } #ifdef DEBUG_ISOCH printf("so 0x%.8x eo 0x%.8x\nsa 0x%.8x ea 0x%.8x\ndir %s len %zu ret %d\n", @@ -997,7 +1000,6 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed) } #endif if (completion) { - ret = ohci->usb_packet.result; ohci->async_td = 0; ohci->async_complete = 0; } else { @@ -1017,16 +1019,22 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed) usb_packet_setup(&ohci->usb_packet, pid, ep, addr, !flag_r, OHCI_BM(td.flags, TD_DI) == 0); usb_packet_addbuf(&ohci->usb_packet, ohci->usb_buf, pktlen); - ret = usb_handle_packet(dev, &ohci->usb_packet); + usb_handle_packet(dev, &ohci->usb_packet); #ifdef DEBUG_PACKET - DPRINTF("ret=%d\n", ret); + DPRINTF("status=%d\n", ohci->usb_packet.status); #endif - if (ret == USB_RET_ASYNC) { + if (ohci->usb_packet.status == USB_RET_ASYNC) { usb_device_flush_ep_queue(dev, ep); ohci->async_td = addr; return 1; } } + if (ohci->usb_packet.status == USB_RET_SUCCESS) { + ret = ohci->usb_packet.actual_length; + } else { + ret = ohci->usb_packet.status; + } + if (ret >= 0) { if (dir == OHCI_TD_DIR_IN) { ohci_copy_td(ohci, &td, ohci->usb_buf, ret, diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c index f4b555addc..2838d21644 100644 --- a/hw/usb/hcd-uhci.c +++ b/hw/usb/hcd-uhci.c @@ -780,22 +780,21 @@ static int uhci_handle_td_error(UHCIState *s, UHCI_TD *td, uint32_t td_addr, static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_t *int_mask) { - int len = 0, max_len, ret; + int len = 0, max_len; uint8_t pid; max_len = ((td->token >> 21) + 1) & 0x7ff; pid = td->token & 0xff; - ret = async->packet.result; - if (td->ctrl & TD_CTRL_IOS) td->ctrl &= ~TD_CTRL_ACTIVE; - if (ret < 0) { - return uhci_handle_td_error(s, td, async->td_addr, ret, int_mask); + if (async->packet.status != USB_RET_SUCCESS) { + return uhci_handle_td_error(s, td, async->td_addr, + async->packet.status, int_mask); } - len = async->packet.result; + len = async->packet.actual_length; td->ctrl = (td->ctrl & ~0x7ff) | ((len - 1) & 0x7ff); /* The NAK bit may have been set by a previous frame, so clear it @@ -824,7 +823,7 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, UHCI_TD *td, uint32_t td_addr, uint32_t *int_mask) { - int len = 0, max_len; + int ret, max_len; bool spd; bool queuing = (q != NULL); uint8_t pid = td->token & 0xff; @@ -915,13 +914,14 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, switch(pid) { case USB_TOKEN_OUT: case USB_TOKEN_SETUP: - len = usb_handle_packet(q->ep->dev, &async->packet); - if (len >= 0) - len = max_len; + usb_handle_packet(q->ep->dev, &async->packet); + if (async->packet.status == USB_RET_SUCCESS) { + async->packet.actual_length = max_len; + } break; case USB_TOKEN_IN: - len = usb_handle_packet(q->ep->dev, &async->packet); + usb_handle_packet(q->ep->dev, &async->packet); break; default: @@ -932,8 +932,8 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, uhci_update_irq(s); return TD_RESULT_STOP_FRAME; } - - if (len == USB_RET_ASYNC) { + + if (async->packet.status == USB_RET_ASYNC) { uhci_async_link(async); if (!queuing) { uhci_queue_fill(q, td); @@ -941,13 +941,11 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, return TD_RESULT_ASYNC_START; } - async->packet.result = len; - done: - len = uhci_complete_td(s, td, async, int_mask); + ret = uhci_complete_td(s, td, async, int_mask); usb_packet_unmap(&async->packet, &async->sgl); uhci_async_free(async); - return len; + return ret; } static void uhci_async_complete(USBPort *port, USBPacket *packet) @@ -955,7 +953,7 @@ static void uhci_async_complete(USBPort *port, USBPacket *packet) UHCIAsync *async = container_of(packet, UHCIAsync, packet); UHCIState *s = async->queue->uhci; - if (packet->result == USB_RET_REMOVE_FROM_QUEUE) { + if (packet->status == USB_RET_REMOVE_FROM_QUEUE) { uhci_async_unlink(async); uhci_async_cancel(async); return; diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 900abf5566..d4a2e0c3ec 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1388,7 +1388,7 @@ static void xhci_xfer_report(XHCITransfer *xfer) XHCIState *xhci = xfer->xhci; int i; - left = xfer->packet.result < 0 ? 0 : xfer->packet.result; + left = xfer->packet.status ? 0 : xfer->packet.actual_length; for (i = 0; i < xfer->trb_count; i++) { XHCITRB *trb = &xfer->trbs[i]; @@ -1490,16 +1490,16 @@ static int xhci_setup_packet(XHCITransfer *xfer) return 0; } -static int xhci_complete_packet(XHCITransfer *xfer, int ret) +static int xhci_complete_packet(XHCITransfer *xfer) { - if (ret == USB_RET_ASYNC) { + if (xfer->packet.status == USB_RET_ASYNC) { trace_usb_xhci_xfer_async(xfer); xfer->running_async = 1; xfer->running_retry = 0; xfer->complete = 0; xfer->cancelled = 0; return 0; - } else if (ret == USB_RET_NAK) { + } else if (xfer->packet.status == USB_RET_NAK) { trace_usb_xhci_xfer_nak(xfer); xfer->running_async = 0; xfer->running_retry = 1; @@ -1513,16 +1513,16 @@ static int xhci_complete_packet(XHCITransfer *xfer, int ret) xhci_xfer_unmap(xfer); } - if (ret >= 0) { - trace_usb_xhci_xfer_success(xfer, ret); + if (xfer->packet.status == USB_RET_SUCCESS) { + trace_usb_xhci_xfer_success(xfer, xfer->packet.actual_length); xfer->status = CC_SUCCESS; xhci_xfer_report(xfer); return 0; } /* error */ - trace_usb_xhci_xfer_error(xfer, ret); - switch (ret) { + trace_usb_xhci_xfer_error(xfer, xfer->packet.status); + switch (xfer->packet.status) { case USB_RET_NODEV: xfer->status = CC_USB_TRANSACTION_ERROR; xhci_xfer_report(xfer); @@ -1534,7 +1534,8 @@ static int xhci_complete_packet(XHCITransfer *xfer, int ret) xhci_stall_ep(xfer); break; default: - fprintf(stderr, "%s: FIXME: ret = %d\n", __FUNCTION__, ret); + fprintf(stderr, "%s: FIXME: status = %d\n", __func__, + xfer->packet.status); FIXME(); } return 0; @@ -1544,7 +1545,6 @@ static int xhci_fire_ctl_transfer(XHCIState *xhci, XHCITransfer *xfer) { XHCITRB *trb_setup, *trb_status; uint8_t bmRequestType; - int ret; trb_setup = &xfer->trbs[0]; trb_status = &xfer->trbs[xfer->trb_count-1]; @@ -1587,9 +1587,9 @@ static int xhci_fire_ctl_transfer(XHCIState *xhci, XHCITransfer *xfer) } xfer->packet.parameter = trb_setup->parameter; - ret = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); + usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); - xhci_complete_packet(xfer, ret); + xhci_complete_packet(xfer); if (!xfer->running_async && !xfer->running_retry) { xhci_kick_ep(xhci, xfer->slotid, xfer->epid); } @@ -1636,7 +1636,6 @@ static void xhci_check_iso_kick(XHCIState *xhci, XHCITransfer *xfer, static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx) { uint64_t mfindex; - int ret; DPRINTF("xhci_submit(slotid=%d,epid=%d)\n", xfer->slotid, xfer->epid); @@ -1671,9 +1670,9 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx if (xhci_setup_packet(xfer) < 0) { return -1; } - ret = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); + usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); - xhci_complete_packet(xfer, ret); + xhci_complete_packet(xfer); if (!xfer->running_async && !xfer->running_retry) { xhci_kick_ep(xhci, xfer->slotid, xfer->epid); } @@ -1711,7 +1710,6 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid, unsigned int epid if (epctx->retry) { XHCITransfer *xfer = epctx->retry; - int result; trace_usb_xhci_xfer_retry(xfer); assert(xfer->running_retry); @@ -1725,19 +1723,19 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned int slotid, unsigned int epid if (xhci_setup_packet(xfer) < 0) { return; } - result = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); - assert(result != USB_RET_NAK); - xhci_complete_packet(xfer, result); + usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); + assert(xfer->packet.status != USB_RET_NAK); + xhci_complete_packet(xfer); } else { /* retry nak'ed transfer */ if (xhci_setup_packet(xfer) < 0) { return; } - result = usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); - if (result == USB_RET_NAK) { + usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); + if (xfer->packet.status == USB_RET_NAK) { return; } - xhci_complete_packet(xfer, result); + xhci_complete_packet(xfer); } assert(!xfer->running_retry); epctx->retry = NULL; @@ -2922,11 +2920,11 @@ static void xhci_complete(USBPort *port, USBPacket *packet) { XHCITransfer *xfer = container_of(packet, XHCITransfer, packet); - if (packet->result == USB_RET_REMOVE_FROM_QUEUE) { + if (packet->status == USB_RET_REMOVE_FROM_QUEUE) { xhci_ep_nuke_one_xfer(xfer); return; } - xhci_complete_packet(xfer, packet->result); + xhci_complete_packet(xfer); xhci_kick_ep(xfer->xhci, xfer->slotid, xfer->epid); } diff --git a/hw/usb/host-bsd.c b/hw/usb/host-bsd.c index ec26266620..6473e8b747 100644 --- a/hw/usb/host-bsd.c +++ b/hw/usb/host-bsd.c @@ -121,7 +121,7 @@ static void usb_host_handle_reset(USBDevice *dev) * -check device states against transfer requests * and return appropriate response */ -static int usb_host_handle_control(USBDevice *dev, +static void usb_host_handle_control(USBDevice *dev, USBPacket *p, int request, int value, @@ -139,7 +139,6 @@ static int usb_host_handle_control(USBDevice *dev, /* specific SET_ADDRESS support */ dev->addr = value; - return 0; } else if ((request >> 8) == UT_WRITE_DEVICE && (request & 0xff) == UR_SET_CONFIG) { @@ -151,10 +150,8 @@ static int usb_host_handle_control(USBDevice *dev, printf("handle_control: failed to set configuration - %s\n", strerror(errno)); #endif - return USB_RET_STALL; + p->status = USB_RET_STALL; } - - return 0; } else if ((request >> 8) == UT_WRITE_INTERFACE && (request & 0xff) == UR_SET_INTERFACE) { @@ -168,10 +165,8 @@ static int usb_host_handle_control(USBDevice *dev, printf("handle_control: failed to set alternate interface - %s\n", strerror(errno)); #endif - return USB_RET_STALL; + p->status = USB_RET_STALL; } - - return 0; } else { req.ucr_request.bmRequestType = request >> 8; req.ucr_request.bRequest = request & 0xff; @@ -201,14 +196,14 @@ static int usb_host_handle_control(USBDevice *dev, printf("handle_control: error after request - %s\n", strerror(errno)); #endif - return USB_RET_NAK; // STALL + p->status = USB_RET_NAK; /* STALL */ } else { - return req.ucr_actlen; + p->actual_length = req.ucr_actlen; } } } -static int usb_host_handle_data(USBDevice *dev, USBPacket *p) +static void usb_host_handle_data(USBDevice *dev, USBPacket *p) { USBHostDevice *s = (USBHostDevice *)dev; int ret, fd, mode; @@ -232,7 +227,8 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) fd = ensure_ep_open(s, devep, mode); if (fd < 0) { sigprocmask(SIG_SETMASK, &old_mask, NULL); - return USB_RET_NODEV; + p->status = USB_RET_NODEV; + return; } if (ioctl(fd, USB_SET_TIMEOUT, &timeout) < 0) { @@ -267,12 +263,13 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) switch(errno) { case ETIMEDOUT: case EINTR: - return USB_RET_NAK; + p->status = USB_RET_NAK; + break; default: - return USB_RET_STALL; + p->status = USB_RET_STALL; } } else { - return ret; + p->actual_length = ret; } } diff --git a/hw/usb/host-linux.c b/hw/usb/host-linux.c index 3a258b4bd4..ca3e24a850 100644 --- a/hw/usb/host-linux.c +++ b/hw/usb/host-linux.c @@ -366,28 +366,29 @@ static void async_complete(void *opaque) if (p) { switch (aurb->urb.status) { case 0: - p->result += aurb->urb.actual_length; + p->actual_length = aurb->urb.actual_length; + p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */ break; case -EPIPE: set_halt(s, p->pid, p->ep->nr); - p->result = USB_RET_STALL; + p->status = USB_RET_STALL; break; case -EOVERFLOW: - p->result = USB_RET_BABBLE; + p->status = USB_RET_BABBLE; break; default: - p->result = USB_RET_IOERROR; + p->status = USB_RET_IOERROR; break; } if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL) { - trace_usb_host_req_complete(s->bus_num, s->addr, p, p->result); + trace_usb_host_req_complete(s->bus_num, s->addr, p, p->status); usb_generic_async_ctrl_complete(&s->dev, p); } else if (!aurb->more) { - trace_usb_host_req_complete(s->bus_num, s->addr, p, p->result); + trace_usb_host_req_complete(s->bus_num, s->addr, p, p->status); usb_packet_complete(&s->dev, p); } } @@ -733,27 +734,31 @@ static void usb_host_stop_n_free_iso(USBHostDevice *s, int pid, uint8_t ep) clear_iso_started(s, pid, ep); } -static int urb_status_to_usb_ret(int status) +static void urb_status_to_usb_ret(int status, USBPacket *p) { switch (status) { case -EPIPE: - return USB_RET_STALL; + p->status = USB_RET_STALL; + break; case -EOVERFLOW: - return USB_RET_BABBLE; + p->status = USB_RET_BABBLE; + break; default: - return USB_RET_IOERROR; + p->status = USB_RET_IOERROR; } } -static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) +static void usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) { AsyncURB *aurb; - int i, j, ret, max_packet_size, offset, len = 0; + int i, j, max_packet_size, offset, len; uint8_t *buf; max_packet_size = p->ep->max_packet_size; - if (max_packet_size == 0) - return USB_RET_NAK; + if (max_packet_size == 0) { + p->status = USB_RET_NAK; + return; + } aurb = get_iso_urb(s, p->pid, p->ep->nr); if (!aurb) { @@ -766,18 +771,17 @@ static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) if (in) { /* Check urb status */ if (aurb[i].urb.status) { - len = urb_status_to_usb_ret(aurb[i].urb.status); + urb_status_to_usb_ret(aurb[i].urb.status, p); /* Move to the next urb */ aurb[i].iso_frame_idx = ISO_FRAME_DESC_PER_URB - 1; /* Check frame status */ } else if (aurb[i].urb.iso_frame_desc[j].status) { - len = urb_status_to_usb_ret( - aurb[i].urb.iso_frame_desc[j].status); + urb_status_to_usb_ret(aurb[i].urb.iso_frame_desc[j].status, p); /* Check the frame fits */ } else if (aurb[i].urb.iso_frame_desc[j].actual_length > p->iov.size) { printf("husb: received iso data is larger then packet\n"); - len = USB_RET_BABBLE; + p->status = USB_RET_BABBLE; /* All good copy data over */ } else { len = aurb[i].urb.iso_frame_desc[j].actual_length; @@ -792,7 +796,8 @@ static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) /* Check the frame fits */ if (len > max_packet_size) { printf("husb: send iso data is larger then max packet size\n"); - return USB_RET_NAK; + p->status = USB_RET_NAK; + return; } /* All good copy data over */ @@ -823,17 +828,16 @@ static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) /* (Re)-submit all fully consumed / filled urbs */ for (i = 0; i < s->iso_urb_count; i++) { if (aurb[i].iso_frame_idx == ISO_FRAME_DESC_PER_URB) { - ret = ioctl(s->fd, USBDEVFS_SUBMITURB, &aurb[i]); - if (ret < 0) { + if (ioctl(s->fd, USBDEVFS_SUBMITURB, &aurb[i]) < 0) { perror("USBDEVFS_SUBMITURB"); - if (!in || len == 0) { + if (!in || p->status == USB_RET_SUCCESS) { switch(errno) { case ETIMEDOUT: - len = USB_RET_NAK; + p->status = USB_RET_NAK; break; case EPIPE: default: - len = USB_RET_STALL; + p->status = USB_RET_STALL; } } break; @@ -843,11 +847,9 @@ static int usb_host_handle_iso_data(USBHostDevice *s, USBPacket *p, int in) } } } - - return len; } -static int usb_host_handle_data(USBDevice *dev, USBPacket *p) +static void usb_host_handle_data(USBDevice *dev, USBPacket *p) { USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev); struct usbdevfs_urb *urb; @@ -862,7 +864,8 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) if (!is_valid(s, p->pid, p->ep->nr)) { trace_usb_host_req_complete(s->bus_num, s->addr, p, USB_RET_NAK); - return USB_RET_NAK; + p->status = USB_RET_NAK; + return; } if (p->pid == USB_TOKEN_IN) { @@ -877,13 +880,15 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) if (ret < 0) { perror("USBDEVFS_CLEAR_HALT"); trace_usb_host_req_complete(s->bus_num, s->addr, p, USB_RET_NAK); - return USB_RET_NAK; + p->status = USB_RET_NAK; + return; } clear_halt(s, p->pid, p->ep->nr); } if (is_isoc(s, p->pid, p->ep->nr)) { - return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN); + usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN); + return; } v = 0; @@ -933,17 +938,19 @@ static int usb_host_handle_data(USBDevice *dev, USBPacket *p) case ETIMEDOUT: trace_usb_host_req_complete(s->bus_num, s->addr, p, USB_RET_NAK); - return USB_RET_NAK; + p->status = USB_RET_NAK; + break; case EPIPE: default: trace_usb_host_req_complete(s->bus_num, s->addr, p, USB_RET_STALL); - return USB_RET_STALL; + p->status = USB_RET_STALL; } + return; } } while (rem > 0); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } static int ctrl_error(void) @@ -955,14 +962,13 @@ static int ctrl_error(void) } } -static int usb_host_set_address(USBHostDevice *s, int addr) +static void usb_host_set_address(USBHostDevice *s, int addr) { trace_usb_host_set_address(s->bus_num, s->addr, addr); s->dev.addr = addr; - return 0; } -static int usb_host_set_config(USBHostDevice *s, int config) +static void usb_host_set_config(USBHostDevice *s, int config, USBPacket *p) { int ret, first = 1; @@ -987,14 +993,15 @@ again: } if (ret < 0) { - return ctrl_error(); + p->status = ctrl_error(); + return; } usb_host_claim_interfaces(s, config); usb_linux_update_endp_table(s); - return 0; } -static int usb_host_set_interface(USBHostDevice *s, int iface, int alt) +static void usb_host_set_interface(USBHostDevice *s, int iface, int alt, + USBPacket *p) { struct usbdevfs_setinterface si; int i, ret; @@ -1011,7 +1018,8 @@ static int usb_host_set_interface(USBHostDevice *s, int iface, int alt) } if (iface >= USB_MAX_INTERFACES) { - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } si.interface = iface; @@ -1022,15 +1030,15 @@ static int usb_host_set_interface(USBHostDevice *s, int iface, int alt) iface, alt, ret, errno); if (ret < 0) { - return ctrl_error(); + p->status = ctrl_error(); + return; } s->dev.altsetting[iface] = alt; usb_linux_update_endp_table(s); - return 0; } -static int usb_host_handle_control(USBDevice *dev, USBPacket *p, +static void usb_host_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev); @@ -1048,19 +1056,19 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p, switch (request) { case DeviceOutRequest | USB_REQ_SET_ADDRESS: - ret = usb_host_set_address(s, value); - trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret); - return ret; + usb_host_set_address(s, value); + trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status); + return; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: - ret = usb_host_set_config(s, value & 0xff); - trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret); - return ret; + usb_host_set_config(s, value & 0xff, p); + trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status); + return; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: - ret = usb_host_set_interface(s, index, value); - trace_usb_host_req_emulated(s->bus_num, s->addr, p, ret); - return ret; + usb_host_set_interface(s, index, value, p); + trace_usb_host_req_emulated(s->bus_num, s->addr, p, p->status); + return; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: if (value == 0) { /* clear halt */ @@ -1068,17 +1076,16 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p, ioctl(s->fd, USBDEVFS_CLEAR_HALT, &index); clear_halt(s, pid, index & 0x0f); trace_usb_host_req_emulated(s->bus_num, s->addr, p, 0); - return 0; + return; } } /* The rest are asynchronous */ - assert(p && p->result == 0); - if (length > sizeof(dev->data_buf)) { fprintf(stderr, "husb: ctrl buffer too small (%d > %zu)\n", length, sizeof(dev->data_buf)); - return USB_RET_STALL; + p->status = USB_RET_STALL; + return; } aurb = async_alloc(s); @@ -1112,14 +1119,17 @@ static int usb_host_handle_control(USBDevice *dev, USBPacket *p, switch(errno) { case ETIMEDOUT: - return USB_RET_NAK; + p->status = USB_RET_NAK; + break; case EPIPE: default: - return USB_RET_STALL; + p->status = USB_RET_STALL; + break; } + return; } - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } /* returns 1 on problem encountered or 0 for success */ diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index c5cfe0b313..cd4388e332 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -141,8 +141,8 @@ static void usbredir_interrupt_packet(void *priv, uint64_t id, struct usb_redir_interrupt_packet_header *interrupt_header, uint8_t *data, int data_len); -static int usbredir_handle_status(USBRedirDevice *dev, - int status, int actual_len); +static void usbredir_handle_status(USBRedirDevice *dev, USBPacket *p, + int status); #define VERSION "qemu usb-redir guest " QEMU_VERSION @@ -443,7 +443,7 @@ static void usbredir_handle_reset(USBDevice *udev) usbredirparser_do_write(dev->parser); } -static int usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, +static void usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { int status, len; @@ -500,7 +500,7 @@ static int usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, !dev->endpoint[EP2I(ep)].bufpq_prefilled) { if (dev->endpoint[EP2I(ep)].bufpq_size < dev->endpoint[EP2I(ep)].bufpq_target_size) { - return usbredir_handle_status(dev, 0, 0); + return; } dev->endpoint[EP2I(ep)].bufpq_prefilled = 1; } @@ -514,7 +514,8 @@ static int usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, /* Check iso_error for stream errors, otherwise its an underrun */ status = dev->endpoint[EP2I(ep)].iso_error; dev->endpoint[EP2I(ep)].iso_error = 0; - return status ? USB_RET_IOERROR : 0; + p->status = status ? USB_RET_IOERROR : USB_RET_SUCCESS; + return; } DPRINTF2("iso-token-in ep %02X status %d len %d queue-size: %d\n", ep, isop->status, isop->len, dev->endpoint[EP2I(ep)].bufpq_size); @@ -522,7 +523,8 @@ static int usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, status = isop->status; if (status != usb_redir_success) { bufp_free(dev, isop, ep); - return USB_RET_IOERROR; + p->status = USB_RET_IOERROR; + return; } len = isop->len; @@ -530,11 +532,11 @@ static int usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, ERROR("received iso data is larger then packet ep %02X (%d > %d)\n", ep, len, (int)p->iov.size); bufp_free(dev, isop, ep); - return USB_RET_BABBLE; + p->status = USB_RET_BABBLE; + return; } usb_packet_copy(p, isop->data, len); bufp_free(dev, isop, ep); - return len; } else { /* If the stream was not started because of a pending error don't send the packet to the usb-host */ @@ -554,7 +556,7 @@ static int usbredir_handle_iso_data(USBRedirDevice *dev, USBPacket *p, dev->endpoint[EP2I(ep)].iso_error = 0; DPRINTF2("iso-token-out ep %02X status %d len %zd\n", ep, status, p->iov.size); - return usbredir_handle_status(dev, status, p->iov.size); + usbredir_handle_status(dev, p, status); } } @@ -572,7 +574,7 @@ static void usbredir_stop_iso_stream(USBRedirDevice *dev, uint8_t ep) usbredir_free_bufpq(dev, ep); } -static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, +static void usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { struct usb_redir_bulk_packet_header bulk_packet; @@ -581,7 +583,8 @@ static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, DPRINTF("bulk-out ep %02X len %zd id %"PRIu64"\n", ep, size, p->id); if (usbredir_already_in_flight(dev, p->id)) { - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; + return; } bulk_packet.endpoint = ep; @@ -608,10 +611,10 @@ static int usbredir_handle_bulk_data(USBRedirDevice *dev, USBPacket *p, &bulk_packet, buf, size); } usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } -static int usbredir_handle_interrupt_data(USBRedirDevice *dev, +static void usbredir_handle_interrupt_data(USBRedirDevice *dev, USBPacket *p, uint8_t ep) { if (ep & USB_DIR_IN) { @@ -643,9 +646,11 @@ static int usbredir_handle_interrupt_data(USBRedirDevice *dev, status = dev->endpoint[EP2I(ep)].interrupt_error; dev->endpoint[EP2I(ep)].interrupt_error = 0; if (status) { - return usbredir_handle_status(dev, status, 0); + usbredir_handle_status(dev, p, status); + } else { + p->status = USB_RET_NAK; } - return USB_RET_NAK; + return; } DPRINTF("interrupt-token-in ep %02X status %d len %d\n", ep, intp->status, intp->len); @@ -653,18 +658,19 @@ static int usbredir_handle_interrupt_data(USBRedirDevice *dev, status = intp->status; if (status != usb_redir_success) { bufp_free(dev, intp, ep); - return usbredir_handle_status(dev, status, 0); + usbredir_handle_status(dev, p, status); + return; } len = intp->len; if (len > p->iov.size) { ERROR("received int data is larger then packet ep %02X\n", ep); bufp_free(dev, intp, ep); - return USB_RET_BABBLE; + p->status = USB_RET_BABBLE; + return; } usb_packet_copy(p, intp->data, len); bufp_free(dev, intp, ep); - return len; } else { /* Output interrupt endpoint, normal async operation */ struct usb_redir_interrupt_packet_header interrupt_packet; @@ -674,7 +680,8 @@ static int usbredir_handle_interrupt_data(USBRedirDevice *dev, p->iov.size, p->id); if (usbredir_already_in_flight(dev, p->id)) { - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; + return; } interrupt_packet.endpoint = ep; @@ -685,7 +692,7 @@ static int usbredir_handle_interrupt_data(USBRedirDevice *dev, usbredirparser_send_interrupt_packet(dev->parser, p->id, &interrupt_packet, buf, p->iov.size); usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } } @@ -705,7 +712,7 @@ static void usbredir_stop_interrupt_receiving(USBRedirDevice *dev, usbredir_free_bufpq(dev, ep); } -static int usbredir_handle_data(USBDevice *udev, USBPacket *p) +static void usbredir_handle_data(USBDevice *udev, USBPacket *p) { USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev); uint8_t ep; @@ -718,21 +725,26 @@ static int usbredir_handle_data(USBDevice *udev, USBPacket *p) switch (dev->endpoint[EP2I(ep)].type) { case USB_ENDPOINT_XFER_CONTROL: ERROR("handle_data called for control transfer on ep %02X\n", ep); - return USB_RET_NAK; + p->status = USB_RET_NAK; + break; case USB_ENDPOINT_XFER_ISOC: - return usbredir_handle_iso_data(dev, p, ep); + usbredir_handle_iso_data(dev, p, ep); + break; case USB_ENDPOINT_XFER_BULK: if (p->state == USB_PACKET_SETUP && p->pid == USB_TOKEN_IN && p->ep->pipeline) { - return USB_RET_ADD_TO_QUEUE; + p->status = USB_RET_ADD_TO_QUEUE; + break; } - return usbredir_handle_bulk_data(dev, p, ep); + usbredir_handle_bulk_data(dev, p, ep); + break; case USB_ENDPOINT_XFER_INT: - return usbredir_handle_interrupt_data(dev, p, ep); + usbredir_handle_interrupt_data(dev, p, ep); + break; default: ERROR("handle_data ep %02X has unknown type %d\n", ep, dev->endpoint[EP2I(ep)].type); - return USB_RET_NAK; + p->status = USB_RET_NAK; } } @@ -743,7 +755,7 @@ static void usbredir_flush_ep_queue(USBDevice *dev, USBEndpoint *ep) } } -static int usbredir_set_config(USBRedirDevice *dev, USBPacket *p, +static void usbredir_set_config(USBRedirDevice *dev, USBPacket *p, int config) { struct usb_redir_set_configuration_header set_config; @@ -768,19 +780,19 @@ static int usbredir_set_config(USBRedirDevice *dev, USBPacket *p, set_config.configuration = config; usbredirparser_send_set_configuration(dev->parser, p->id, &set_config); usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } -static int usbredir_get_config(USBRedirDevice *dev, USBPacket *p) +static void usbredir_get_config(USBRedirDevice *dev, USBPacket *p) { DPRINTF("get config id %"PRIu64"\n", p->id); usbredirparser_send_get_configuration(dev->parser, p->id); usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } -static int usbredir_set_interface(USBRedirDevice *dev, USBPacket *p, +static void usbredir_set_interface(USBRedirDevice *dev, USBPacket *p, int interface, int alt) { struct usb_redir_set_alt_setting_header set_alt; @@ -808,10 +820,10 @@ static int usbredir_set_interface(USBRedirDevice *dev, USBPacket *p, set_alt.alt = alt; usbredirparser_send_set_alt_setting(dev->parser, p->id, &set_alt); usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } -static int usbredir_get_interface(USBRedirDevice *dev, USBPacket *p, +static void usbredir_get_interface(USBRedirDevice *dev, USBPacket *p, int interface) { struct usb_redir_get_alt_setting_header get_alt; @@ -821,17 +833,18 @@ static int usbredir_get_interface(USBRedirDevice *dev, USBPacket *p, get_alt.interface = interface; usbredirparser_send_get_alt_setting(dev->parser, p->id, &get_alt); usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } -static int usbredir_handle_control(USBDevice *udev, USBPacket *p, +static void usbredir_handle_control(USBDevice *udev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBRedirDevice *dev = DO_UPCAST(USBRedirDevice, dev, udev); struct usb_redir_control_packet_header control_packet; if (usbredir_already_in_flight(dev, p->id)) { - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; + return; } /* Special cases for certain standard device requests */ @@ -839,15 +852,19 @@ static int usbredir_handle_control(USBDevice *udev, USBPacket *p, case DeviceOutRequest | USB_REQ_SET_ADDRESS: DPRINTF("set address %d\n", value); dev->dev.addr = value; - return 0; + return; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: - return usbredir_set_config(dev, p, value & 0xff); + usbredir_set_config(dev, p, value & 0xff); + return; case DeviceRequest | USB_REQ_GET_CONFIGURATION: - return usbredir_get_config(dev, p); + usbredir_get_config(dev, p); + return; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: - return usbredir_set_interface(dev, p, index, value); + usbredir_set_interface(dev, p, index, value); + return; case InterfaceRequest | USB_REQ_GET_INTERFACE: - return usbredir_get_interface(dev, p, index); + usbredir_get_interface(dev, p, index); + return; } /* Normal ctrl requests, note request is (bRequestType << 8) | bRequest */ @@ -871,7 +888,7 @@ static int usbredir_handle_control(USBDevice *udev, USBPacket *p, &control_packet, data, length); } usbredirparser_do_write(dev->parser); - return USB_RET_ASYNC; + p->status = USB_RET_ASYNC; } /* @@ -1159,29 +1176,34 @@ error: * usbredirparser packet complete callbacks */ -static int usbredir_handle_status(USBRedirDevice *dev, - int status, int actual_len) +static void usbredir_handle_status(USBRedirDevice *dev, USBPacket *p, + int status) { switch (status) { case usb_redir_success: - return actual_len; + p->status = USB_RET_SUCCESS; /* Clear previous ASYNC status */ + break; case usb_redir_stall: - return USB_RET_STALL; + p->status = USB_RET_STALL; + break; case usb_redir_cancelled: /* * When the usbredir-host unredirects a device, it will report a status * of cancelled for all pending packets, followed by a disconnect msg. */ - return USB_RET_IOERROR; + p->status = USB_RET_IOERROR; + break; case usb_redir_inval: WARNING("got invalid param error from usb-host?\n"); - return USB_RET_IOERROR; + p->status = USB_RET_IOERROR; + break; case usb_redir_babble: - return USB_RET_BABBLE; + p->status = USB_RET_BABBLE; + break; case usb_redir_ioerror: case usb_redir_timeout: default: - return USB_RET_IOERROR; + p->status = USB_RET_IOERROR; } } @@ -1412,7 +1434,6 @@ static void usbredir_configuration_status(void *priv, uint64_t id, { USBRedirDevice *dev = priv; USBPacket *p; - int len = 0; DPRINTF("set config status %d config %d id %"PRIu64"\n", config_status->status, config_status->configuration, id); @@ -1421,9 +1442,9 @@ static void usbredir_configuration_status(void *priv, uint64_t id, if (p) { if (dev->dev.setup_buf[0] & USB_DIR_IN) { dev->dev.data_buf[0] = config_status->configuration; - len = 1; + p->actual_length = 1; } - p->result = usbredir_handle_status(dev, config_status->status, len); + usbredir_handle_status(dev, p, config_status->status); usb_generic_async_ctrl_complete(&dev->dev, p); } } @@ -1433,7 +1454,6 @@ static void usbredir_alt_setting_status(void *priv, uint64_t id, { USBRedirDevice *dev = priv; USBPacket *p; - int len = 0; DPRINTF("alt status %d intf %d alt %d id: %"PRIu64"\n", alt_setting_status->status, alt_setting_status->interface, @@ -1443,10 +1463,9 @@ static void usbredir_alt_setting_status(void *priv, uint64_t id, if (p) { if (dev->dev.setup_buf[0] & USB_DIR_IN) { dev->dev.data_buf[0] = alt_setting_status->alt; - len = 1; + p->actual_length = 1; } - p->result = - usbredir_handle_status(dev, alt_setting_status->status, len); + usbredir_handle_status(dev, p, alt_setting_status->status); usb_generic_async_ctrl_complete(&dev->dev, p); } } @@ -1522,18 +1541,19 @@ static void usbredir_control_packet(void *priv, uint64_t id, p = usbredir_find_packet_by_id(dev, 0, id); if (p) { - len = usbredir_handle_status(dev, control_packet->status, len); - if (len > 0) { + usbredir_handle_status(dev, p, control_packet->status); + if (p->status == USB_RET_SUCCESS) { usbredir_log_data(dev, "ctrl data in:", data, data_len); if (data_len <= sizeof(dev->dev.data_buf)) { memcpy(dev->dev.data_buf, data, data_len); } else { ERROR("ctrl buffer too small (%d > %zu)\n", data_len, sizeof(dev->dev.data_buf)); - len = USB_RET_STALL; + p->status = USB_RET_STALL; + len = 0; } } - p->result = len; + p->actual_length = len; usb_generic_async_ctrl_complete(&dev->dev, p); } free(data); @@ -1554,8 +1574,8 @@ static void usbredir_bulk_packet(void *priv, uint64_t id, p = usbredir_find_packet_by_id(dev, ep, id); if (p) { size_t size = (p->combined) ? p->combined->iov.size : p->iov.size; - len = usbredir_handle_status(dev, bulk_packet->status, len); - if (len > 0) { + usbredir_handle_status(dev, p, bulk_packet->status); + if (p->status == USB_RET_SUCCESS) { usbredir_log_data(dev, "bulk data in:", data, data_len); if (data_len <= size) { if (p->combined) { @@ -1567,10 +1587,11 @@ static void usbredir_bulk_packet(void *priv, uint64_t id, } else { ERROR("bulk got more data then requested (%d > %zd)\n", data_len, p->iov.size); - len = USB_RET_BABBLE; + p->status = USB_RET_BABBLE; + len = 0; } } - p->result = len; + p->actual_length = len; if (p->pid == USB_TOKEN_IN && p->ep->pipeline) { usb_combined_input_packet_complete(&dev->dev, p); } else { @@ -1636,8 +1657,8 @@ static void usbredir_interrupt_packet(void *priv, uint64_t id, USBPacket *p = usbredir_find_packet_by_id(dev, ep, id); if (p) { - p->result = usbredir_handle_status(dev, - interrupt_packet->status, len); + usbredir_handle_status(dev, p, interrupt_packet->status); + p->actual_length = len; usb_packet_complete(&dev->dev, p); } } -- 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 'hw/usb/dev-uas.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