From bd2be1500337f0349f70802e4d8d43f5aca61477 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 9 Apr 2013 15:26:55 +0100 Subject: arm: fix location of some include files The recent rearrangement of include files had some minor errors: devices.h is not ARM specific and should not be in arm/ arm.h should be in arm/ Move these two headers to correct this. Signed-off-by: Peter Maydell Signed-off-by: Paolo Bonzini --- include/hw/arm.h | 70 ------------------------------------------------ include/hw/arm/arm.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/devices.h | 70 ------------------------------------------------ include/hw/devices.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 140 deletions(-) delete mode 100644 include/hw/arm.h create mode 100644 include/hw/arm/arm.h delete mode 100644 include/hw/arm/devices.h create mode 100644 include/hw/devices.h (limited to 'include') diff --git a/include/hw/arm.h b/include/hw/arm.h deleted file mode 100644 index 7b2b02daaf..0000000000 --- a/include/hw/arm.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Misc ARM declarations - * - * Copyright (c) 2006 CodeSourcery. - * Written by Paul Brook - * - * This code is licensed under the LGPL. - * - */ - -#ifndef ARM_MISC_H -#define ARM_MISC_H 1 - -#include "exec/memory.h" -#include "hw/irq.h" - -/* The CPU is also modelled as an interrupt controller. */ -#define ARM_PIC_CPU_IRQ 0 -#define ARM_PIC_CPU_FIQ 1 -qemu_irq *arm_pic_init_cpu(ARMCPU *cpu); - -/* armv7m.c */ -qemu_irq *armv7m_init(MemoryRegion *address_space_mem, - int flash_size, int sram_size, - const char *kernel_filename, const char *cpu_model); - -/* arm_boot.c */ -struct arm_boot_info { - uint64_t ram_size; - const char *kernel_filename; - const char *kernel_cmdline; - const char *initrd_filename; - const char *dtb_filename; - hwaddr loader_start; - /* multicore boards that use the default secondary core boot functions - * need to put the address of the secondary boot code, the boot reg, - * and the GIC address in the next 3 values, respectively. boards that - * have their own boot functions can use these values as they want. - */ - hwaddr smp_loader_start; - hwaddr smp_bootreg_addr; - hwaddr gic_cpu_if_addr; - int nb_cpus; - int board_id; - int (*atag_board)(const struct arm_boot_info *info, void *p); - /* multicore boards that use the default secondary core boot functions - * can ignore these two function calls. If the default functions won't - * work, then write_secondary_boot() should write a suitable blob of - * code mimicking the secondary CPU startup process used by the board's - * boot loader/boot ROM code, and secondary_cpu_reset_hook() should - * perform any necessary CPU reset handling and set the PC for the - * secondary CPUs to point at this boot blob. - */ - void (*write_secondary_boot)(ARMCPU *cpu, - const struct arm_boot_info *info); - void (*secondary_cpu_reset_hook)(ARMCPU *cpu, - const struct arm_boot_info *info); - /* Used internally by arm_boot.c */ - int is_linux; - hwaddr initrd_start; - hwaddr initrd_size; - hwaddr entry; -}; -void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); - -/* Multiplication factor to convert from system clock ticks to qemu timer - ticks. */ -extern int system_clock_scale; - -#endif /* !ARM_MISC_H */ diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h new file mode 100644 index 0000000000..7b2b02daaf --- /dev/null +++ b/include/hw/arm/arm.h @@ -0,0 +1,70 @@ +/* + * Misc ARM declarations + * + * Copyright (c) 2006 CodeSourcery. + * Written by Paul Brook + * + * This code is licensed under the LGPL. + * + */ + +#ifndef ARM_MISC_H +#define ARM_MISC_H 1 + +#include "exec/memory.h" +#include "hw/irq.h" + +/* The CPU is also modelled as an interrupt controller. */ +#define ARM_PIC_CPU_IRQ 0 +#define ARM_PIC_CPU_FIQ 1 +qemu_irq *arm_pic_init_cpu(ARMCPU *cpu); + +/* armv7m.c */ +qemu_irq *armv7m_init(MemoryRegion *address_space_mem, + int flash_size, int sram_size, + const char *kernel_filename, const char *cpu_model); + +/* arm_boot.c */ +struct arm_boot_info { + uint64_t ram_size; + const char *kernel_filename; + const char *kernel_cmdline; + const char *initrd_filename; + const char *dtb_filename; + hwaddr loader_start; + /* multicore boards that use the default secondary core boot functions + * need to put the address of the secondary boot code, the boot reg, + * and the GIC address in the next 3 values, respectively. boards that + * have their own boot functions can use these values as they want. + */ + hwaddr smp_loader_start; + hwaddr smp_bootreg_addr; + hwaddr gic_cpu_if_addr; + int nb_cpus; + int board_id; + int (*atag_board)(const struct arm_boot_info *info, void *p); + /* multicore boards that use the default secondary core boot functions + * can ignore these two function calls. If the default functions won't + * work, then write_secondary_boot() should write a suitable blob of + * code mimicking the secondary CPU startup process used by the board's + * boot loader/boot ROM code, and secondary_cpu_reset_hook() should + * perform any necessary CPU reset handling and set the PC for the + * secondary CPUs to point at this boot blob. + */ + void (*write_secondary_boot)(ARMCPU *cpu, + const struct arm_boot_info *info); + void (*secondary_cpu_reset_hook)(ARMCPU *cpu, + const struct arm_boot_info *info); + /* Used internally by arm_boot.c */ + int is_linux; + hwaddr initrd_start; + hwaddr initrd_size; + hwaddr entry; +}; +void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info); + +/* Multiplication factor to convert from system clock ticks to qemu timer + ticks. */ +extern int system_clock_scale; + +#endif /* !ARM_MISC_H */ diff --git a/include/hw/arm/devices.h b/include/hw/arm/devices.h deleted file mode 100644 index c60bcabae3..0000000000 --- a/include/hw/arm/devices.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef QEMU_DEVICES_H -#define QEMU_DEVICES_H - -#include "hw/irq.h" - -/* ??? Not all users of this file can include cpu-common.h. */ -struct MemoryRegion; - -/* Devices that have nowhere better to go. */ - -/* smc91c111.c */ -void smc91c111_init(NICInfo *, uint32_t, qemu_irq); - -/* lan9118.c */ -void lan9118_init(NICInfo *, uint32_t, qemu_irq); - -/* tsc210x.c */ -uWireSlave *tsc2102_init(qemu_irq pint); -uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); -I2SCodec *tsc210x_codec(uWireSlave *chip); -uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); -void tsc210x_set_transform(uWireSlave *chip, - MouseTransformInfo *info); -void tsc210x_key_event(uWireSlave *chip, int key, int down); - -/* tsc2005.c */ -void *tsc2005_init(qemu_irq pintdav); -uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); -void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); - -/* stellaris_input.c */ -void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); - -/* blizzard.c */ -void *s1d13745_init(qemu_irq gpio_int); -void s1d13745_write(void *opaque, int dc, uint16_t value); -void s1d13745_write_block(void *opaque, int dc, - void *buf, size_t len, int pitch); -uint16_t s1d13745_read(void *opaque, int dc); - -/* cbus.c */ -typedef struct { - qemu_irq clk; - qemu_irq dat; - qemu_irq sel; -} CBus; -CBus *cbus_init(qemu_irq dat_out); -void cbus_attach(CBus *bus, void *slave_opaque); - -void *retu_init(qemu_irq irq, int vilma); -void *tahvo_init(qemu_irq irq, int betty); - -void retu_key_event(void *retu, int state); - -/* tc6393xb.c */ -typedef struct TC6393xbState TC6393xbState; -#define TC6393XB_RAM 0x110000 /* amount of ram for Video and USB */ -TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, - uint32_t base, qemu_irq irq); -void tc6393xb_gpio_out_set(TC6393xbState *s, int line, - qemu_irq handler); -qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s); -qemu_irq tc6393xb_l3v_get(TC6393xbState *s); - -/* sm501.c */ -void sm501_init(struct MemoryRegion *address_space_mem, uint32_t base, - uint32_t local_mem_bytes, qemu_irq irq, - CharDriverState *chr); - -#endif diff --git a/include/hw/devices.h b/include/hw/devices.h new file mode 100644 index 0000000000..c60bcabae3 --- /dev/null +++ b/include/hw/devices.h @@ -0,0 +1,70 @@ +#ifndef QEMU_DEVICES_H +#define QEMU_DEVICES_H + +#include "hw/irq.h" + +/* ??? Not all users of this file can include cpu-common.h. */ +struct MemoryRegion; + +/* Devices that have nowhere better to go. */ + +/* smc91c111.c */ +void smc91c111_init(NICInfo *, uint32_t, qemu_irq); + +/* lan9118.c */ +void lan9118_init(NICInfo *, uint32_t, qemu_irq); + +/* tsc210x.c */ +uWireSlave *tsc2102_init(qemu_irq pint); +uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav); +I2SCodec *tsc210x_codec(uWireSlave *chip); +uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len); +void tsc210x_set_transform(uWireSlave *chip, + MouseTransformInfo *info); +void tsc210x_key_event(uWireSlave *chip, int key, int down); + +/* tsc2005.c */ +void *tsc2005_init(qemu_irq pintdav); +uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len); +void tsc2005_set_transform(void *opaque, MouseTransformInfo *info); + +/* stellaris_input.c */ +void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); + +/* blizzard.c */ +void *s1d13745_init(qemu_irq gpio_int); +void s1d13745_write(void *opaque, int dc, uint16_t value); +void s1d13745_write_block(void *opaque, int dc, + void *buf, size_t len, int pitch); +uint16_t s1d13745_read(void *opaque, int dc); + +/* cbus.c */ +typedef struct { + qemu_irq clk; + qemu_irq dat; + qemu_irq sel; +} CBus; +CBus *cbus_init(qemu_irq dat_out); +void cbus_attach(CBus *bus, void *slave_opaque); + +void *retu_init(qemu_irq irq, int vilma); +void *tahvo_init(qemu_irq irq, int betty); + +void retu_key_event(void *retu, int state); + +/* tc6393xb.c */ +typedef struct TC6393xbState TC6393xbState; +#define TC6393XB_RAM 0x110000 /* amount of ram for Video and USB */ +TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem, + uint32_t base, qemu_irq irq); +void tc6393xb_gpio_out_set(TC6393xbState *s, int line, + qemu_irq handler); +qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s); +qemu_irq tc6393xb_l3v_get(TC6393xbState *s); + +/* sm501.c */ +void sm501_init(struct MemoryRegion *address_space_mem, uint32_t base, + uint32_t local_mem_bytes, qemu_irq irq, + CharDriverState *chr); + +#endif -- cgit v1.2.3 From 0445259ba686f9ddf395f700c7d5b1ac400a451c Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Mon, 15 Apr 2013 09:19:22 +0300 Subject: acpi: move declarations from pc.h to acpi.h Functions defined in acpi/ should be declared in acpi.h Signed-off-by: Michael S. Tsirkin Signed-off-by: Paolo Bonzini --- include/hw/acpi/acpi.h | 7 +++++++ include/hw/i386/pc.h | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index e18ef28fd3..4cd52c1b36 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -154,4 +154,11 @@ void acpi_gpe_reset(ACPIREGS *ar); void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val); uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr); +/* acpi.c */ +extern int acpi_enabled; +extern char unsigned *acpi_tables; +extern size_t acpi_tables_len; + +void acpi_table_add(const QemuOpts *opts, Error **errp); + #endif /* !QEMU_HW_ACPI_H */ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 5d40914f49..9bcc8193b7 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -107,14 +107,6 @@ void cpu_smm_register(cpu_set_smm_t callback, void *arg); void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name); -/* acpi.c */ -extern int acpi_enabled; -extern char unsigned *acpi_tables; -extern size_t acpi_tables_len; - -void acpi_bios_init(void); -void acpi_table_add(const QemuOpts *opts, Error **errp); - /* acpi_piix.c */ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, -- cgit v1.2.3 From e53339cf7cf90cf5c7a6bca64d0e7c0956f53a66 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Mon, 15 Apr 2013 11:12:50 +0300 Subject: acpi.h: make it self contained Headers shouldn't assume another header is included, pull in everything necessary. Signed-off-by: Michael S. Tsirkin Signed-off-by: Paolo Bonzini --- include/hw/acpi/acpi.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 4cd52c1b36..635be7be10 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -19,6 +19,12 @@ * . */ +#include "qapi/error.h" +#include "qemu/typedefs.h" +#include "qemu/notify.h" +#include "qemu/option.h" +#include "exec/memory.h" + /* from linux include/acpi/actype.h */ /* Default ACPI register widths */ -- cgit v1.2.3 From bdee56f5466a724f043e6cfcfcf69866cc48cc94 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 2 Apr 2013 18:28:41 +0200 Subject: tpm: reorganize headers and split hardware part The TPM subsystem does not have a full front-end/back-end separation. The sole available backend, tpm_passthrough, depends on the data structures of the sole available frontend, tpm_tis. However, we can at least try to split the user interface (tpm.c) from the implementation (hw/tpm). The patches makes tpm.c not include tpm_int.h, which is shared between tpm_tis.c and tpm_passthrough.c; instead it moves more stuff to tpm_backend.h. Signed-off-by: Paolo Bonzini --- include/backends/tpm.h | 41 +++++++++++++++++++++++++++++++++++- include/sysemu/tpm.h | 23 ++++++++++++++++++++ include/sysemu/tpm_backend_int.h | 45 ++++++++++++++++++++++++++++++++++++++++ include/tpm/tpm.h | 25 ---------------------- 4 files changed, 108 insertions(+), 26 deletions(-) create mode 100644 include/sysemu/tpm.h create mode 100644 include/sysemu/tpm_backend_int.h delete mode 100644 include/tpm/tpm.h (limited to 'include') diff --git a/include/backends/tpm.h b/include/backends/tpm.h index 9e93cc5060..466787453d 100644 --- a/include/backends/tpm.h +++ b/include/backends/tpm.h @@ -18,7 +18,7 @@ #include "qapi/error.h" #include "qapi-types.h" #include "qemu/option.h" -#include "tpm/tpm.h" +#include "sysemu/tpm.h" #define TYPE_TPM_BACKEND "tpm-backend" #define TPM_BACKEND(obj) \ @@ -56,6 +56,39 @@ struct TPMBackend { QLIST_ENTRY(TPMBackend) list; }; +typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty); + +typedef struct TPMSizedBuffer { + uint32_t size; + uint8_t *buffer; +} TPMSizedBuffer; + +struct TPMDriverOps { + enum TpmType type; + /* get a descriptive text of the backend to display to the user */ + const char *(*desc)(void); + + TPMBackend *(*create)(QemuOpts *opts, const char *id); + void (*destroy)(TPMBackend *t); + + /* initialize the backend */ + int (*init)(TPMBackend *t, TPMState *s, TPMRecvDataCB *datacb); + /* start up the TPM on the backend */ + int (*startup_tpm)(TPMBackend *t); + /* returns true if nothing will ever answer TPM requests */ + bool (*had_startup_error)(TPMBackend *t); + + size_t (*realloc_buffer)(TPMSizedBuffer *sb); + + void (*deliver_request)(TPMBackend *t); + + void (*reset)(TPMBackend *t); + + void (*cancel_cmd)(TPMBackend *t); + + bool (*get_tpm_established_flag)(TPMBackend *t); +}; + /** * tpm_backend_get_type: @@ -167,4 +200,10 @@ bool tpm_backend_get_tpm_established_flag(TPMBackend *s); */ void tpm_backend_open(TPMBackend *s, Error **errp); +TPMBackend *qemu_find_tpm(const char *id); + +const TPMDriverOps *tpm_get_backend_driver(const char *type); +int tpm_register_model(enum TpmModel model); +int tpm_register_driver(const TPMDriverOps *tdo); + #endif diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h new file mode 100644 index 0000000000..13febddbee --- /dev/null +++ b/include/sysemu/tpm.h @@ -0,0 +1,23 @@ +/* + * Public TPM functions + * + * Copyright (C) 2011-2013 IBM Corporation + * + * Authors: + * Stefan Berger + * + * 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_TPM_H +#define QEMU_TPM_H + +#include "qemu/option.h" + +typedef struct TPMState TPMState; + +int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); +int tpm_init(void); +void tpm_cleanup(void); + +#endif /* QEMU_TPM_H */ diff --git a/include/sysemu/tpm_backend_int.h b/include/sysemu/tpm_backend_int.h new file mode 100644 index 0000000000..05d94d0f5b --- /dev/null +++ b/include/sysemu/tpm_backend_int.h @@ -0,0 +1,45 @@ +/* + * common TPM backend driver functions + * + * Copyright (c) 2012-2013 IBM Corporation + * Authors: + * Stefan Berger + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#ifndef TPM_TPM_BACKEND_H +#define TPM_TPM_BACKEND_H + +#include + +typedef struct TPMBackendThread { + GThreadPool *pool; +} TPMBackendThread; + +void tpm_backend_thread_deliver_request(TPMBackendThread *tbt); +void tpm_backend_thread_create(TPMBackendThread *tbt, + GFunc func, gpointer user_data); +void tpm_backend_thread_end(TPMBackendThread *tbt); +void tpm_backend_thread_tpm_reset(TPMBackendThread *tbt, + GFunc func, gpointer user_data); + +typedef enum TPMBackendCmd { + TPM_BACKEND_CMD_INIT = 1, + TPM_BACKEND_CMD_PROCESS_CMD, + TPM_BACKEND_CMD_END, + TPM_BACKEND_CMD_TPM_RESET, +} TPMBackendCmd; + +#endif /* TPM_TPM_BACKEND_H */ diff --git a/include/tpm/tpm.h b/include/tpm/tpm.h deleted file mode 100644 index 2d457c4439..0000000000 --- a/include/tpm/tpm.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Public TPM functions - * - * Copyright (C) 2011-2013 IBM Corporation - * - * Authors: - * Stefan Berger - * - * 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_TPM_H -#define QEMU_TPM_H - -#include "qemu/option.h" - -typedef struct TPMState TPMState; -typedef struct TPMSizedBuffer TPMSizedBuffer; -typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty); - -int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); -int tpm_init(void); -void tpm_cleanup(void); - -#endif /* QEMU_TPM_H */ -- cgit v1.2.3 From dccfcd0e5f8f37360ebda11ccc4dab164c04d5a3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 8 Apr 2013 16:55:25 +0200 Subject: sysemu: avoid proliferation of include/ subdirectories Signed-off-by: Paolo Bonzini --- include/backends/tpm.h | 209 ---------------------------- include/bt/bt.h | 20 --- include/char/char.h | 306 ----------------------------------------- include/hw/virtio/virtio-rng.h | 4 +- include/qemu/rng-random.h | 22 --- include/qemu/rng.h | 93 ------------- include/sysemu/bt.h | 20 +++ include/sysemu/char.h | 306 +++++++++++++++++++++++++++++++++++++++++ include/sysemu/rng-random.h | 22 +++ include/sysemu/rng.h | 93 +++++++++++++ include/sysemu/tpm_backend.h | 209 ++++++++++++++++++++++++++++ 11 files changed, 652 insertions(+), 652 deletions(-) delete mode 100644 include/backends/tpm.h delete mode 100644 include/bt/bt.h delete mode 100644 include/char/char.h delete mode 100644 include/qemu/rng-random.h delete mode 100644 include/qemu/rng.h create mode 100644 include/sysemu/bt.h create mode 100644 include/sysemu/char.h create mode 100644 include/sysemu/rng-random.h create mode 100644 include/sysemu/rng.h create mode 100644 include/sysemu/tpm_backend.h (limited to 'include') diff --git a/include/backends/tpm.h b/include/backends/tpm.h deleted file mode 100644 index 466787453d..0000000000 --- a/include/backends/tpm.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * QEMU TPM Backend - * - * Copyright IBM, Corp. 2013 - * - * Authors: - * Stefan Berger - * - * 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_TPM_H -#define _QEMU_TPM_H - -#include "qom/object.h" -#include "qemu-common.h" -#include "qapi/error.h" -#include "qapi-types.h" -#include "qemu/option.h" -#include "sysemu/tpm.h" - -#define TYPE_TPM_BACKEND "tpm-backend" -#define TPM_BACKEND(obj) \ - OBJECT_CHECK(TPMBackend, (obj), TYPE_TPM_BACKEND) -#define TPM_BACKEND_GET_CLASS(obj) \ - OBJECT_GET_CLASS(TPMBackendClass, (obj), TYPE_TPM_BACKEND) -#define TPM_BACKEND_CLASS(klass) \ - OBJECT_CLASS_CHECK(TPMBackendClass, (klass), TYPE_TPM_BACKEND) - -typedef struct TPMBackendClass TPMBackendClass; -typedef struct TPMBackend TPMBackend; - -typedef struct TPMDriverOps TPMDriverOps; - -struct TPMBackendClass { - ObjectClass parent_class; - - const TPMDriverOps *ops; - - void (*opened)(TPMBackend *s, Error **errp); -}; - -struct TPMBackend { - Object parent; - - /*< protected >*/ - bool opened; - - char *id; - enum TpmModel fe_model; - char *path; - char *cancel_path; - const TPMDriverOps *ops; - - QLIST_ENTRY(TPMBackend) list; -}; - -typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty); - -typedef struct TPMSizedBuffer { - uint32_t size; - uint8_t *buffer; -} TPMSizedBuffer; - -struct TPMDriverOps { - enum TpmType type; - /* get a descriptive text of the backend to display to the user */ - const char *(*desc)(void); - - TPMBackend *(*create)(QemuOpts *opts, const char *id); - void (*destroy)(TPMBackend *t); - - /* initialize the backend */ - int (*init)(TPMBackend *t, TPMState *s, TPMRecvDataCB *datacb); - /* start up the TPM on the backend */ - int (*startup_tpm)(TPMBackend *t); - /* returns true if nothing will ever answer TPM requests */ - bool (*had_startup_error)(TPMBackend *t); - - size_t (*realloc_buffer)(TPMSizedBuffer *sb); - - void (*deliver_request)(TPMBackend *t); - - void (*reset)(TPMBackend *t); - - void (*cancel_cmd)(TPMBackend *t); - - bool (*get_tpm_established_flag)(TPMBackend *t); -}; - - -/** - * tpm_backend_get_type: - * @s: the backend - * - * Returns the TpmType of the backend. - */ -enum TpmType tpm_backend_get_type(TPMBackend *s); - -/** - * tpm_backend_get_desc: - * @s: the backend - * - * Returns a human readable description of the backend. - */ -const char *tpm_backend_get_desc(TPMBackend *s); - -/** - * tpm_backend_destroy: - * @s: the backend to destroy - */ -void tpm_backend_destroy(TPMBackend *s); - -/** - * tpm_backend_init: - * @s: the backend to initialized - * @state: TPMState - * @datacb: callback for sending data to frontend - * - * Initialize the backend with the given variables. - * - * Returns 0 on success. - */ -int tpm_backend_init(TPMBackend *s, TPMState *state, - TPMRecvDataCB *datacb); - -/** - * tpm_backend_startup_tpm: - * @s: the backend whose TPM support is to be started - * - * Returns 0 on success. - */ -int tpm_backend_startup_tpm(TPMBackend *s); - -/** - * tpm_backend_had_startup_error: - * @s: the backend to query for a statup error - * - * Check whether the backend had an error during startup. Returns - * false if no error occurred and the backend can be used, true - * otherwise. - */ -bool tpm_backend_had_startup_error(TPMBackend *s); - -/** - * tpm_backend_realloc_buffer: - * @s: the backend - * @sb: the TPMSizedBuffer to re-allocated to the size suitable for the - * backend. - * - * This function returns the size of the allocated buffer - */ -size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb); - -/** - * tpm_backend_deliver_request: - * @s: the backend to send the request to - * - * Send a request to the backend. The backend will then send the request - * to the TPM implementation. - */ -void tpm_backend_deliver_request(TPMBackend *s); - -/** - * tpm_backend_reset: - * @s: the backend to reset - * - * Reset the backend into a well defined state with all previous errors - * reset. - */ -void tpm_backend_reset(TPMBackend *s); - -/** - * tpm_backend_cancel_cmd: - * @s: the backend - * - * Cancel any ongoing command being processed by the TPM implementation - * on behalf of the QEMU guest. - */ -void tpm_backend_cancel_cmd(TPMBackend *s); - -/** - * tpm_backend_get_tpm_established_flag: - * @s: the backend - * - * Get the TPM establishment flag. This function may be called very - * frequently by the frontend since for example in the TIS implementation - * this flag is part of a register. - */ -bool tpm_backend_get_tpm_established_flag(TPMBackend *s); - -/** - * tpm_backend_open: - * @s: the backend to open - * @errp: a pointer to return the #Error object if an error occurs. - * - * This function will open the backend if it is not already open. Calling this - * function on an already opened backend will not result in an error. - */ -void tpm_backend_open(TPMBackend *s, Error **errp); - -TPMBackend *qemu_find_tpm(const char *id); - -const TPMDriverOps *tpm_get_backend_driver(const char *type); -int tpm_register_model(enum TpmModel model); -int tpm_register_driver(const TPMDriverOps *tdo); - -#endif diff --git a/include/bt/bt.h b/include/bt/bt.h deleted file mode 100644 index 2bc6d53cca..0000000000 --- a/include/bt/bt.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef BT_HOST_H -#define BT_HOST_H - -/* BT HCI info */ - -struct HCIInfo { - int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr); - void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len); - void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len); - void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len); - void *opaque; - void (*evt_recv)(void *opaque, const uint8_t *data, int len); - void (*acl_recv)(void *opaque, const uint8_t *data, int len); -}; - -/* bt-host.c */ -struct HCIInfo *bt_host_hci(const char *id); -struct HCIInfo *qemu_next_hci(void); - -#endif diff --git a/include/char/char.h b/include/char/char.h deleted file mode 100644 index 9d1ea46117..0000000000 --- a/include/char/char.h +++ /dev/null @@ -1,306 +0,0 @@ -#ifndef QEMU_CHAR_H -#define QEMU_CHAR_H - -#include "qemu-common.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 "qemu/main-loop.h" - -/* character device */ - -#define CHR_EVENT_BREAK 0 /* serial break char */ -#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ -#define CHR_EVENT_OPENED 2 /* new connection established */ -#define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */ -#define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */ -#define CHR_EVENT_CLOSED 5 /* connection closed */ - - -#define CHR_IOCTL_SERIAL_SET_PARAMS 1 -typedef struct { - int speed; - int parity; - int data_bits; - int stop_bits; -} QEMUSerialSetParams; - -#define CHR_IOCTL_SERIAL_SET_BREAK 2 - -#define CHR_IOCTL_PP_READ_DATA 3 -#define CHR_IOCTL_PP_WRITE_DATA 4 -#define CHR_IOCTL_PP_READ_CONTROL 5 -#define CHR_IOCTL_PP_WRITE_CONTROL 6 -#define CHR_IOCTL_PP_READ_STATUS 7 -#define CHR_IOCTL_PP_EPP_READ_ADDR 8 -#define CHR_IOCTL_PP_EPP_READ 9 -#define CHR_IOCTL_PP_EPP_WRITE_ADDR 10 -#define CHR_IOCTL_PP_EPP_WRITE 11 -#define CHR_IOCTL_PP_DATA_DIR 12 - -#define CHR_IOCTL_SERIAL_SET_TIOCM 13 -#define CHR_IOCTL_SERIAL_GET_TIOCM 14 - -#define CHR_TIOCM_CTS 0x020 -#define CHR_TIOCM_CAR 0x040 -#define CHR_TIOCM_DSR 0x100 -#define CHR_TIOCM_RI 0x080 -#define CHR_TIOCM_DTR 0x002 -#define CHR_TIOCM_RTS 0x004 - -typedef void IOEventHandler(void *opaque, int event); - -struct CharDriverState { - void (*init)(struct CharDriverState *s); - int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); - GSource *(*chr_add_watch)(struct CharDriverState *s, GIOCondition cond); - void (*chr_update_read_handler)(struct CharDriverState *s); - int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); - int (*get_msgfd)(struct CharDriverState *s); - int (*chr_add_client)(struct CharDriverState *chr, int fd); - IOEventHandler *chr_event; - IOCanReadHandler *chr_can_read; - IOReadHandler *chr_read; - void *handler_opaque; - void (*chr_close)(struct CharDriverState *chr); - void (*chr_accept_input)(struct CharDriverState *chr); - void (*chr_set_echo)(struct CharDriverState *chr, bool echo); - void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open); - void *opaque; - int idle_tag; - char *label; - char *filename; - int be_open; - int fe_open; - int explicit_fe_open; - int avail_connections; - QemuOpts *opts; - QTAILQ_ENTRY(CharDriverState) next; -}; - -/** - * @qemu_chr_new_from_opts: - * - * Create a new character backend from a QemuOpts list. - * - * @opts see qemu-config.c for a list of valid options - * @init not sure.. - * - * Returns: a new character backend - */ -CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, - void (*init)(struct CharDriverState *s), - Error **errp); - -/** - * @qemu_chr_new: - * - * Create a new character backend from a URI. - * - * @label the name of the backend - * @filename the URI - * @init not sure.. - * - * Returns: a new character backend - */ -CharDriverState *qemu_chr_new(const char *label, const char *filename, - void (*init)(struct CharDriverState *s)); - -/** - * @qemu_chr_delete: - * - * Destroy a character backend. - */ -void qemu_chr_delete(CharDriverState *chr); - -/** - * @qemu_chr_fe_set_echo: - * - * Ask the backend to override its normal echo setting. This only really - * applies to the stdio backend and is used by the QMP server such that you - * can see what you type if you try to type QMP commands. - * - * @echo true to enable echo, false to disable echo - */ -void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo); - -/** - * @qemu_chr_fe_set_open: - * - * Set character frontend open status. This is an indication that the - * front end is ready (or not) to begin doing I/O. - */ -void qemu_chr_fe_set_open(struct CharDriverState *chr, int fe_open); - -/** - * @qemu_chr_fe_printf: - * - * Write to a character backend using a printf style interface. - * - * @fmt see #printf - */ -void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...) - GCC_FMT_ATTR(2, 3); - -int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond, - GIOFunc func, void *user_data); - -/** - * @qemu_chr_fe_write: - * - * Write data to a character backend from the front end. This function will - * send data from the front end to the back end. - * - * @buf the data - * @len the number of bytes to send - * - * Returns: the number of bytes consumed - */ -int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len); - -/** - * @qemu_chr_fe_write_all: - * - * Write data to a character backend from the front end. This function will - * send data from the front end to the back end. Unlike @qemu_chr_fe_write, - * this function will block if the back end cannot consume all of the data - * attempted to be written. - * - * @buf the data - * @len the number of bytes to send - * - * Returns: the number of bytes consumed - */ -int qemu_chr_fe_write_all(CharDriverState *s, const uint8_t *buf, int len); - -/** - * @qemu_chr_fe_ioctl: - * - * Issue a device specific ioctl to a backend. - * - * @cmd see CHR_IOCTL_* - * @arg the data associated with @cmd - * - * Returns: if @cmd is not supported by the backend, -ENOTSUP, otherwise the - * return value depends on the semantics of @cmd - */ -int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg); - -/** - * @qemu_chr_fe_get_msgfd: - * - * For backends capable of fd passing, return the latest file descriptor passed - * by a client. - * - * Returns: -1 if fd passing isn't supported or there is no pending file - * descriptor. If a file descriptor is returned, subsequent calls to - * this function will return -1 until a client sends a new file - * descriptor. - */ -int qemu_chr_fe_get_msgfd(CharDriverState *s); - -/** - * @qemu_chr_fe_claim: - * - * Claim a backend before using it, should be called before calling - * qemu_chr_add_handlers(). - * - * Returns: -1 if the backend is already in use by another frontend, 0 on - * success. - */ -int qemu_chr_fe_claim(CharDriverState *s); - -/** - * @qemu_chr_fe_claim_no_fail: - * - * Like qemu_chr_fe_claim, but will exit qemu with an error when the - * backend is already in use. - */ -void qemu_chr_fe_claim_no_fail(CharDriverState *s); - -/** - * @qemu_chr_fe_claim: - * - * Release a backend for use by another frontend. - * - * Returns: -1 if the backend is already in use by another frontend, 0 on - * success. - */ -void qemu_chr_fe_release(CharDriverState *s); - -/** - * @qemu_chr_be_can_write: - * - * Determine how much data the front end can currently accept. This function - * returns the number of bytes the front end can accept. If it returns 0, the - * front end cannot receive data at the moment. The function must be polled - * to determine when data can be received. - * - * Returns: the number of bytes the front end can receive via @qemu_chr_be_write - */ -int qemu_chr_be_can_write(CharDriverState *s); - -/** - * @qemu_chr_be_write: - * - * Write data from the back end to the front end. Before issuing this call, - * the caller should call @qemu_chr_be_can_write to determine how much data - * the front end can currently accept. - * - * @buf a buffer to receive data from the front end - * @len the number of bytes to receive from the front end - */ -void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len); - - -/** - * @qemu_chr_be_event: - * - * Send an event from the back end to the front end. - * - * @event the event to send - */ -void qemu_chr_be_event(CharDriverState *s, int event); - -void qemu_chr_add_handlers(CharDriverState *s, - IOCanReadHandler *fd_can_read, - IOReadHandler *fd_read, - IOEventHandler *fd_event, - void *opaque); - -void qemu_chr_be_generic_open(CharDriverState *s); -void qemu_chr_accept_input(CharDriverState *s); -int qemu_chr_add_client(CharDriverState *s, int fd); -void qemu_chr_info_print(Monitor *mon, const QObject *ret_data); -void qemu_chr_info(Monitor *mon, QObject **ret_data); -CharDriverState *qemu_chr_find(const char *name); - -QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); - -void register_char_driver(const char *name, CharDriverState *(*open)(QemuOpts *)); -void register_char_driver_qapi(const char *name, int kind, - void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp)); - -/* add an eventfd to the qemu devices that are polled */ -CharDriverState *qemu_chr_open_eventfd(int eventfd); - -extern int term_escape_char; - -/* memory chardev */ -void qemu_chr_init_mem(CharDriverState *chr); -void qemu_chr_close_mem(CharDriverState *chr); -QString *qemu_chr_mem_to_qs(CharDriverState *chr); -size_t qemu_chr_mem_osize(const CharDriverState *chr); - -CharDriverState *qemu_char_get_next_serial(void); - -/* msmouse */ -CharDriverState *qemu_chr_open_msmouse(void); - -/* baum.c */ -CharDriverState *chr_baum_init(void); - -#endif diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index 3711c97a70..c9cadc24b6 100644 --- a/include/hw/virtio/virtio-rng.h +++ b/include/hw/virtio/virtio-rng.h @@ -12,8 +12,8 @@ #ifndef _QEMU_VIRTIO_RNG_H #define _QEMU_VIRTIO_RNG_H -#include "qemu/rng.h" -#include "qemu/rng-random.h" +#include "sysemu/rng.h" +#include "sysemu/rng-random.h" /* The Virtio ID for the virtio rng device */ #define VIRTIO_ID_RNG 4 diff --git a/include/qemu/rng-random.h b/include/qemu/rng-random.h deleted file mode 100644 index 4332772a24..0000000000 --- a/include/qemu/rng-random.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * QEMU Random Number Generator Backend - * - * Copyright IBM, Corp. 2012 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ -#ifndef QEMU_RNG_RANDOM_H -#define QEMU_RNG_RANDOM_H - -#include "qom/object.h" - -#define TYPE_RNG_RANDOM "rng-random" -#define RNG_RANDOM(obj) OBJECT_CHECK(RndRandom, (obj), TYPE_RNG_RANDOM) - -typedef struct RndRandom RndRandom; - -#endif diff --git a/include/qemu/rng.h b/include/qemu/rng.h deleted file mode 100644 index 509abd023d..0000000000 --- a/include/qemu/rng.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * QEMU Random Number Generator Backend - * - * Copyright IBM, Corp. 2012 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_RNG_H -#define QEMU_RNG_H - -#include "qom/object.h" -#include "qemu-common.h" -#include "qapi/error.h" - -#define TYPE_RNG_BACKEND "rng-backend" -#define RNG_BACKEND(obj) \ - OBJECT_CHECK(RngBackend, (obj), TYPE_RNG_BACKEND) -#define RNG_BACKEND_GET_CLASS(obj) \ - OBJECT_GET_CLASS(RngBackendClass, (obj), TYPE_RNG_BACKEND) -#define RNG_BACKEND_CLASS(klass) \ - OBJECT_CLASS_CHECK(RngBackendClass, (klass), TYPE_RNG_BACKEND) - -typedef struct RngBackendClass RngBackendClass; -typedef struct RngBackend RngBackend; - -typedef void (EntropyReceiveFunc)(void *opaque, - const void *data, - size_t size); - -struct RngBackendClass -{ - ObjectClass parent_class; - - void (*request_entropy)(RngBackend *s, size_t size, - EntropyReceiveFunc *recieve_entropy, void *opaque); - void (*cancel_requests)(RngBackend *s); - - void (*opened)(RngBackend *s, Error **errp); -}; - -struct RngBackend -{ - Object parent; - - /*< protected >*/ - bool opened; -}; - -/** - * rng_backend_request_entropy: - * @s: the backend to request entropy from - * @size: the number of bytes of data to request - * @receive_entropy: a function to be invoked when entropy is available - * @opaque: data that should be passed to @receive_entropy - * - * This function is used by the front-end to request entropy from an entropy - * source. This function can be called multiple times before @receive_entropy - * is invoked with different values of @receive_entropy and @opaque. The - * backend will queue each request and handle appropriately. - * - * The backend does not need to pass the full amount of data to @receive_entropy - * but will pass a value greater than 0. - */ -void rng_backend_request_entropy(RngBackend *s, size_t size, - EntropyReceiveFunc *receive_entropy, - void *opaque); - -/** - * rng_backend_cancel_requests: - * @s: the backend to cancel all pending requests in - * - * Cancels all pending requests submitted by @rng_backend_request_entropy. This - * should be used by a device during reset or in preparation for live migration - * to stop tracking any request. - */ -void rng_backend_cancel_requests(RngBackend *s); - -/** - * rng_backend_open: - * @s: the backend to open - * @errp: a pointer to return the #Error object if an error occurs. - * - * This function will open the backend if it is not already open. Calling this - * function on an already opened backend will not result in an error. - */ -void rng_backend_open(RngBackend *s, Error **errp); - -#endif diff --git a/include/sysemu/bt.h b/include/sysemu/bt.h new file mode 100644 index 0000000000..2bc6d53cca --- /dev/null +++ b/include/sysemu/bt.h @@ -0,0 +1,20 @@ +#ifndef BT_HOST_H +#define BT_HOST_H + +/* BT HCI info */ + +struct HCIInfo { + int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr); + void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len); + void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len); + void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len); + void *opaque; + void (*evt_recv)(void *opaque, const uint8_t *data, int len); + void (*acl_recv)(void *opaque, const uint8_t *data, int len); +}; + +/* bt-host.c */ +struct HCIInfo *bt_host_hci(const char *id); +struct HCIInfo *qemu_next_hci(void); + +#endif diff --git a/include/sysemu/char.h b/include/sysemu/char.h new file mode 100644 index 0000000000..9d1ea46117 --- /dev/null +++ b/include/sysemu/char.h @@ -0,0 +1,306 @@ +#ifndef QEMU_CHAR_H +#define QEMU_CHAR_H + +#include "qemu-common.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 "qemu/main-loop.h" + +/* character device */ + +#define CHR_EVENT_BREAK 0 /* serial break char */ +#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ +#define CHR_EVENT_OPENED 2 /* new connection established */ +#define CHR_EVENT_MUX_IN 3 /* mux-focus was set to this terminal */ +#define CHR_EVENT_MUX_OUT 4 /* mux-focus will move on */ +#define CHR_EVENT_CLOSED 5 /* connection closed */ + + +#define CHR_IOCTL_SERIAL_SET_PARAMS 1 +typedef struct { + int speed; + int parity; + int data_bits; + int stop_bits; +} QEMUSerialSetParams; + +#define CHR_IOCTL_SERIAL_SET_BREAK 2 + +#define CHR_IOCTL_PP_READ_DATA 3 +#define CHR_IOCTL_PP_WRITE_DATA 4 +#define CHR_IOCTL_PP_READ_CONTROL 5 +#define CHR_IOCTL_PP_WRITE_CONTROL 6 +#define CHR_IOCTL_PP_READ_STATUS 7 +#define CHR_IOCTL_PP_EPP_READ_ADDR 8 +#define CHR_IOCTL_PP_EPP_READ 9 +#define CHR_IOCTL_PP_EPP_WRITE_ADDR 10 +#define CHR_IOCTL_PP_EPP_WRITE 11 +#define CHR_IOCTL_PP_DATA_DIR 12 + +#define CHR_IOCTL_SERIAL_SET_TIOCM 13 +#define CHR_IOCTL_SERIAL_GET_TIOCM 14 + +#define CHR_TIOCM_CTS 0x020 +#define CHR_TIOCM_CAR 0x040 +#define CHR_TIOCM_DSR 0x100 +#define CHR_TIOCM_RI 0x080 +#define CHR_TIOCM_DTR 0x002 +#define CHR_TIOCM_RTS 0x004 + +typedef void IOEventHandler(void *opaque, int event); + +struct CharDriverState { + void (*init)(struct CharDriverState *s); + int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); + GSource *(*chr_add_watch)(struct CharDriverState *s, GIOCondition cond); + void (*chr_update_read_handler)(struct CharDriverState *s); + int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); + int (*get_msgfd)(struct CharDriverState *s); + int (*chr_add_client)(struct CharDriverState *chr, int fd); + IOEventHandler *chr_event; + IOCanReadHandler *chr_can_read; + IOReadHandler *chr_read; + void *handler_opaque; + void (*chr_close)(struct CharDriverState *chr); + void (*chr_accept_input)(struct CharDriverState *chr); + void (*chr_set_echo)(struct CharDriverState *chr, bool echo); + void (*chr_set_fe_open)(struct CharDriverState *chr, int fe_open); + void *opaque; + int idle_tag; + char *label; + char *filename; + int be_open; + int fe_open; + int explicit_fe_open; + int avail_connections; + QemuOpts *opts; + QTAILQ_ENTRY(CharDriverState) next; +}; + +/** + * @qemu_chr_new_from_opts: + * + * Create a new character backend from a QemuOpts list. + * + * @opts see qemu-config.c for a list of valid options + * @init not sure.. + * + * Returns: a new character backend + */ +CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts, + void (*init)(struct CharDriverState *s), + Error **errp); + +/** + * @qemu_chr_new: + * + * Create a new character backend from a URI. + * + * @label the name of the backend + * @filename the URI + * @init not sure.. + * + * Returns: a new character backend + */ +CharDriverState *qemu_chr_new(const char *label, const char *filename, + void (*init)(struct CharDriverState *s)); + +/** + * @qemu_chr_delete: + * + * Destroy a character backend. + */ +void qemu_chr_delete(CharDriverState *chr); + +/** + * @qemu_chr_fe_set_echo: + * + * Ask the backend to override its normal echo setting. This only really + * applies to the stdio backend and is used by the QMP server such that you + * can see what you type if you try to type QMP commands. + * + * @echo true to enable echo, false to disable echo + */ +void qemu_chr_fe_set_echo(struct CharDriverState *chr, bool echo); + +/** + * @qemu_chr_fe_set_open: + * + * Set character frontend open status. This is an indication that the + * front end is ready (or not) to begin doing I/O. + */ +void qemu_chr_fe_set_open(struct CharDriverState *chr, int fe_open); + +/** + * @qemu_chr_fe_printf: + * + * Write to a character backend using a printf style interface. + * + * @fmt see #printf + */ +void qemu_chr_fe_printf(CharDriverState *s, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); + +int qemu_chr_fe_add_watch(CharDriverState *s, GIOCondition cond, + GIOFunc func, void *user_data); + +/** + * @qemu_chr_fe_write: + * + * Write data to a character backend from the front end. This function will + * send data from the front end to the back end. + * + * @buf the data + * @len the number of bytes to send + * + * Returns: the number of bytes consumed + */ +int qemu_chr_fe_write(CharDriverState *s, const uint8_t *buf, int len); + +/** + * @qemu_chr_fe_write_all: + * + * Write data to a character backend from the front end. This function will + * send data from the front end to the back end. Unlike @qemu_chr_fe_write, + * this function will block if the back end cannot consume all of the data + * attempted to be written. + * + * @buf the data + * @len the number of bytes to send + * + * Returns: the number of bytes consumed + */ +int qemu_chr_fe_write_all(CharDriverState *s, const uint8_t *buf, int len); + +/** + * @qemu_chr_fe_ioctl: + * + * Issue a device specific ioctl to a backend. + * + * @cmd see CHR_IOCTL_* + * @arg the data associated with @cmd + * + * Returns: if @cmd is not supported by the backend, -ENOTSUP, otherwise the + * return value depends on the semantics of @cmd + */ +int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg); + +/** + * @qemu_chr_fe_get_msgfd: + * + * For backends capable of fd passing, return the latest file descriptor passed + * by a client. + * + * Returns: -1 if fd passing isn't supported or there is no pending file + * descriptor. If a file descriptor is returned, subsequent calls to + * this function will return -1 until a client sends a new file + * descriptor. + */ +int qemu_chr_fe_get_msgfd(CharDriverState *s); + +/** + * @qemu_chr_fe_claim: + * + * Claim a backend before using it, should be called before calling + * qemu_chr_add_handlers(). + * + * Returns: -1 if the backend is already in use by another frontend, 0 on + * success. + */ +int qemu_chr_fe_claim(CharDriverState *s); + +/** + * @qemu_chr_fe_claim_no_fail: + * + * Like qemu_chr_fe_claim, but will exit qemu with an error when the + * backend is already in use. + */ +void qemu_chr_fe_claim_no_fail(CharDriverState *s); + +/** + * @qemu_chr_fe_claim: + * + * Release a backend for use by another frontend. + * + * Returns: -1 if the backend is already in use by another frontend, 0 on + * success. + */ +void qemu_chr_fe_release(CharDriverState *s); + +/** + * @qemu_chr_be_can_write: + * + * Determine how much data the front end can currently accept. This function + * returns the number of bytes the front end can accept. If it returns 0, the + * front end cannot receive data at the moment. The function must be polled + * to determine when data can be received. + * + * Returns: the number of bytes the front end can receive via @qemu_chr_be_write + */ +int qemu_chr_be_can_write(CharDriverState *s); + +/** + * @qemu_chr_be_write: + * + * Write data from the back end to the front end. Before issuing this call, + * the caller should call @qemu_chr_be_can_write to determine how much data + * the front end can currently accept. + * + * @buf a buffer to receive data from the front end + * @len the number of bytes to receive from the front end + */ +void qemu_chr_be_write(CharDriverState *s, uint8_t *buf, int len); + + +/** + * @qemu_chr_be_event: + * + * Send an event from the back end to the front end. + * + * @event the event to send + */ +void qemu_chr_be_event(CharDriverState *s, int event); + +void qemu_chr_add_handlers(CharDriverState *s, + IOCanReadHandler *fd_can_read, + IOReadHandler *fd_read, + IOEventHandler *fd_event, + void *opaque); + +void qemu_chr_be_generic_open(CharDriverState *s); +void qemu_chr_accept_input(CharDriverState *s); +int qemu_chr_add_client(CharDriverState *s, int fd); +void qemu_chr_info_print(Monitor *mon, const QObject *ret_data); +void qemu_chr_info(Monitor *mon, QObject **ret_data); +CharDriverState *qemu_chr_find(const char *name); + +QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename); + +void register_char_driver(const char *name, CharDriverState *(*open)(QemuOpts *)); +void register_char_driver_qapi(const char *name, int kind, + void (*parse)(QemuOpts *opts, ChardevBackend *backend, Error **errp)); + +/* add an eventfd to the qemu devices that are polled */ +CharDriverState *qemu_chr_open_eventfd(int eventfd); + +extern int term_escape_char; + +/* memory chardev */ +void qemu_chr_init_mem(CharDriverState *chr); +void qemu_chr_close_mem(CharDriverState *chr); +QString *qemu_chr_mem_to_qs(CharDriverState *chr); +size_t qemu_chr_mem_osize(const CharDriverState *chr); + +CharDriverState *qemu_char_get_next_serial(void); + +/* msmouse */ +CharDriverState *qemu_chr_open_msmouse(void); + +/* baum.c */ +CharDriverState *chr_baum_init(void); + +#endif diff --git a/include/sysemu/rng-random.h b/include/sysemu/rng-random.h new file mode 100644 index 0000000000..4332772a24 --- /dev/null +++ b/include/sysemu/rng-random.h @@ -0,0 +1,22 @@ +/* + * QEMU Random Number Generator Backend + * + * Copyright IBM, Corp. 2012 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#ifndef QEMU_RNG_RANDOM_H +#define QEMU_RNG_RANDOM_H + +#include "qom/object.h" + +#define TYPE_RNG_RANDOM "rng-random" +#define RNG_RANDOM(obj) OBJECT_CHECK(RndRandom, (obj), TYPE_RNG_RANDOM) + +typedef struct RndRandom RndRandom; + +#endif diff --git a/include/sysemu/rng.h b/include/sysemu/rng.h new file mode 100644 index 0000000000..509abd023d --- /dev/null +++ b/include/sysemu/rng.h @@ -0,0 +1,93 @@ +/* + * QEMU Random Number Generator Backend + * + * Copyright IBM, Corp. 2012 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_RNG_H +#define QEMU_RNG_H + +#include "qom/object.h" +#include "qemu-common.h" +#include "qapi/error.h" + +#define TYPE_RNG_BACKEND "rng-backend" +#define RNG_BACKEND(obj) \ + OBJECT_CHECK(RngBackend, (obj), TYPE_RNG_BACKEND) +#define RNG_BACKEND_GET_CLASS(obj) \ + OBJECT_GET_CLASS(RngBackendClass, (obj), TYPE_RNG_BACKEND) +#define RNG_BACKEND_CLASS(klass) \ + OBJECT_CLASS_CHECK(RngBackendClass, (klass), TYPE_RNG_BACKEND) + +typedef struct RngBackendClass RngBackendClass; +typedef struct RngBackend RngBackend; + +typedef void (EntropyReceiveFunc)(void *opaque, + const void *data, + size_t size); + +struct RngBackendClass +{ + ObjectClass parent_class; + + void (*request_entropy)(RngBackend *s, size_t size, + EntropyReceiveFunc *recieve_entropy, void *opaque); + void (*cancel_requests)(RngBackend *s); + + void (*opened)(RngBackend *s, Error **errp); +}; + +struct RngBackend +{ + Object parent; + + /*< protected >*/ + bool opened; +}; + +/** + * rng_backend_request_entropy: + * @s: the backend to request entropy from + * @size: the number of bytes of data to request + * @receive_entropy: a function to be invoked when entropy is available + * @opaque: data that should be passed to @receive_entropy + * + * This function is used by the front-end to request entropy from an entropy + * source. This function can be called multiple times before @receive_entropy + * is invoked with different values of @receive_entropy and @opaque. The + * backend will queue each request and handle appropriately. + * + * The backend does not need to pass the full amount of data to @receive_entropy + * but will pass a value greater than 0. + */ +void rng_backend_request_entropy(RngBackend *s, size_t size, + EntropyReceiveFunc *receive_entropy, + void *opaque); + +/** + * rng_backend_cancel_requests: + * @s: the backend to cancel all pending requests in + * + * Cancels all pending requests submitted by @rng_backend_request_entropy. This + * should be used by a device during reset or in preparation for live migration + * to stop tracking any request. + */ +void rng_backend_cancel_requests(RngBackend *s); + +/** + * rng_backend_open: + * @s: the backend to open + * @errp: a pointer to return the #Error object if an error occurs. + * + * This function will open the backend if it is not already open. Calling this + * function on an already opened backend will not result in an error. + */ +void rng_backend_open(RngBackend *s, Error **errp); + +#endif diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h new file mode 100644 index 0000000000..466787453d --- /dev/null +++ b/include/sysemu/tpm_backend.h @@ -0,0 +1,209 @@ +/* + * QEMU TPM Backend + * + * Copyright IBM, Corp. 2013 + * + * Authors: + * Stefan Berger + * + * 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_TPM_H +#define _QEMU_TPM_H + +#include "qom/object.h" +#include "qemu-common.h" +#include "qapi/error.h" +#include "qapi-types.h" +#include "qemu/option.h" +#include "sysemu/tpm.h" + +#define TYPE_TPM_BACKEND "tpm-backend" +#define TPM_BACKEND(obj) \ + OBJECT_CHECK(TPMBackend, (obj), TYPE_TPM_BACKEND) +#define TPM_BACKEND_GET_CLASS(obj) \ + OBJECT_GET_CLASS(TPMBackendClass, (obj), TYPE_TPM_BACKEND) +#define TPM_BACKEND_CLASS(klass) \ + OBJECT_CLASS_CHECK(TPMBackendClass, (klass), TYPE_TPM_BACKEND) + +typedef struct TPMBackendClass TPMBackendClass; +typedef struct TPMBackend TPMBackend; + +typedef struct TPMDriverOps TPMDriverOps; + +struct TPMBackendClass { + ObjectClass parent_class; + + const TPMDriverOps *ops; + + void (*opened)(TPMBackend *s, Error **errp); +}; + +struct TPMBackend { + Object parent; + + /*< protected >*/ + bool opened; + + char *id; + enum TpmModel fe_model; + char *path; + char *cancel_path; + const TPMDriverOps *ops; + + QLIST_ENTRY(TPMBackend) list; +}; + +typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty); + +typedef struct TPMSizedBuffer { + uint32_t size; + uint8_t *buffer; +} TPMSizedBuffer; + +struct TPMDriverOps { + enum TpmType type; + /* get a descriptive text of the backend to display to the user */ + const char *(*desc)(void); + + TPMBackend *(*create)(QemuOpts *opts, const char *id); + void (*destroy)(TPMBackend *t); + + /* initialize the backend */ + int (*init)(TPMBackend *t, TPMState *s, TPMRecvDataCB *datacb); + /* start up the TPM on the backend */ + int (*startup_tpm)(TPMBackend *t); + /* returns true if nothing will ever answer TPM requests */ + bool (*had_startup_error)(TPMBackend *t); + + size_t (*realloc_buffer)(TPMSizedBuffer *sb); + + void (*deliver_request)(TPMBackend *t); + + void (*reset)(TPMBackend *t); + + void (*cancel_cmd)(TPMBackend *t); + + bool (*get_tpm_established_flag)(TPMBackend *t); +}; + + +/** + * tpm_backend_get_type: + * @s: the backend + * + * Returns the TpmType of the backend. + */ +enum TpmType tpm_backend_get_type(TPMBackend *s); + +/** + * tpm_backend_get_desc: + * @s: the backend + * + * Returns a human readable description of the backend. + */ +const char *tpm_backend_get_desc(TPMBackend *s); + +/** + * tpm_backend_destroy: + * @s: the backend to destroy + */ +void tpm_backend_destroy(TPMBackend *s); + +/** + * tpm_backend_init: + * @s: the backend to initialized + * @state: TPMState + * @datacb: callback for sending data to frontend + * + * Initialize the backend with the given variables. + * + * Returns 0 on success. + */ +int tpm_backend_init(TPMBackend *s, TPMState *state, + TPMRecvDataCB *datacb); + +/** + * tpm_backend_startup_tpm: + * @s: the backend whose TPM support is to be started + * + * Returns 0 on success. + */ +int tpm_backend_startup_tpm(TPMBackend *s); + +/** + * tpm_backend_had_startup_error: + * @s: the backend to query for a statup error + * + * Check whether the backend had an error during startup. Returns + * false if no error occurred and the backend can be used, true + * otherwise. + */ +bool tpm_backend_had_startup_error(TPMBackend *s); + +/** + * tpm_backend_realloc_buffer: + * @s: the backend + * @sb: the TPMSizedBuffer to re-allocated to the size suitable for the + * backend. + * + * This function returns the size of the allocated buffer + */ +size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb); + +/** + * tpm_backend_deliver_request: + * @s: the backend to send the request to + * + * Send a request to the backend. The backend will then send the request + * to the TPM implementation. + */ +void tpm_backend_deliver_request(TPMBackend *s); + +/** + * tpm_backend_reset: + * @s: the backend to reset + * + * Reset the backend into a well defined state with all previous errors + * reset. + */ +void tpm_backend_reset(TPMBackend *s); + +/** + * tpm_backend_cancel_cmd: + * @s: the backend + * + * Cancel any ongoing command being processed by the TPM implementation + * on behalf of the QEMU guest. + */ +void tpm_backend_cancel_cmd(TPMBackend *s); + +/** + * tpm_backend_get_tpm_established_flag: + * @s: the backend + * + * Get the TPM establishment flag. This function may be called very + * frequently by the frontend since for example in the TIS implementation + * this flag is part of a register. + */ +bool tpm_backend_get_tpm_established_flag(TPMBackend *s); + +/** + * tpm_backend_open: + * @s: the backend to open + * @errp: a pointer to return the #Error object if an error occurs. + * + * This function will open the backend if it is not already open. Calling this + * function on an already opened backend will not result in an error. + */ +void tpm_backend_open(TPMBackend *s, Error **errp); + +TPMBackend *qemu_find_tpm(const char *id); + +const TPMDriverOps *tpm_get_backend_driver(const char *type); +int tpm_register_model(enum TpmModel model); +int tpm_register_driver(const TPMDriverOps *tdo); + +#endif -- cgit v1.2.3 From b421d9c6aba0ba3338c00b56cf45edbc150c42f3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 9 Apr 2013 11:10:27 +0200 Subject: memory: move core typedefs to qemu/typedefs.h Signed-off-by: Paolo Bonzini --- include/exec/memory.h | 5 ----- include/qemu/typedefs.h | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/exec/memory.h b/include/exec/memory.h index 2322732dce..9e88320113 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -27,7 +27,6 @@ #include "qemu/int128.h" typedef struct MemoryRegionOps MemoryRegionOps; -typedef struct MemoryRegion MemoryRegion; typedef struct MemoryRegionPortio MemoryRegionPortio; typedef struct MemoryRegionMmio MemoryRegionMmio; @@ -157,8 +156,6 @@ struct MemoryRegionPortio { #define PORTIO_END_OF_LIST() { } -typedef struct AddressSpace AddressSpace; - /** * AddressSpace: describes a mapping of addresses to #MemoryRegion objects */ @@ -173,8 +170,6 @@ struct AddressSpace { QTAILQ_ENTRY(AddressSpace) address_spaces_link; }; -typedef struct MemoryRegionSection MemoryRegionSection; - /** * MemoryRegionSection: describes a fragment of a #MemoryRegion * diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index fd532a268d..93aae81a82 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -18,6 +18,10 @@ typedef struct DeviceState DeviceState; typedef struct BusState BusState; typedef struct BusClass BusClass; +typedef struct AddressSpace AddressSpace; +typedef struct MemoryRegion MemoryRegion; +typedef struct MemoryRegionSection MemoryRegionSection; + typedef struct NICInfo NICInfo; typedef struct HCIInfo HCIInfo; typedef struct AudioState AudioState; -- cgit v1.2.3 From c72dd2d04bd28f7ec6b073316270258684ba5fc3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 8 Apr 2013 18:26:41 +0200 Subject: exec: remove useless declarations from memory-internal.h Signed-off-by: Paolo Bonzini --- include/exec/memory-internal.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 977467bb57..1b156fd58f 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -49,12 +49,6 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size, MemoryRegion *mr); void qemu_ram_free(ram_addr_t addr); void qemu_ram_free_from_ptr(ram_addr_t addr); -struct MemoryRegion; -struct MemoryRegionSection; - -void qemu_register_coalesced_mmio(hwaddr addr, ram_addr_t size); -void qemu_unregister_coalesced_mmio(hwaddr addr, ram_addr_t size); - #define VGA_DIRTY_FLAG 0x01 #define CODE_DIRTY_FLAG 0x02 #define MIGRATION_DIRTY_FLAG 0x08 -- cgit v1.2.3