import
This commit is contained in:
82
qemu/include/hw/arm/arm.h
Normal file
82
qemu/include/hw/arm/arm.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
void tosa_machine_init(struct uc_struct *uc);
|
||||
void machvirt_machine_init(struct uc_struct *uc); // ARM64
|
||||
|
||||
/* armv7m.c */
|
||||
qemu_irq *armv7m_init(MemoryRegion *system_memory,
|
||||
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);
|
||||
/* if a board is able to create a dtb without a dtb file then it
|
||||
* sets get_dtb. This will only be used if no dtb file is provided
|
||||
* by the user. On success, sets *size to the length of the created
|
||||
* dtb, and returns a pointer to it. (The caller must free this memory
|
||||
* with g_free() when it has finished with it.) On failure, returns NULL.
|
||||
*/
|
||||
void *(*get_dtb)(const struct arm_boot_info *info, int *size);
|
||||
/* if a board needs to be able to modify a device tree provided by
|
||||
* the user it should implement this hook.
|
||||
*/
|
||||
void (*modify_dtb)(const struct arm_boot_info *info, void *fdt);
|
||||
/* 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;
|
||||
|
||||
void arm_cpu_register_types(void *opaque);
|
||||
void aarch64_cpu_register_types(void *opaque);
|
||||
|
||||
#endif /* !ARM_MISC_H */
|
||||
82
qemu/include/hw/boards.h
Normal file
82
qemu/include/hw/boards.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* Declarations for use by board files for creating devices. */
|
||||
|
||||
#ifndef HW_BOARDS_H
|
||||
#define HW_BOARDS_H
|
||||
|
||||
#include "qemu/typedefs.h"
|
||||
#include "sysemu/accel.h"
|
||||
#include "hw/qdev.h"
|
||||
#include "qom/object.h"
|
||||
#include "uc_priv.h"
|
||||
|
||||
typedef void QEMUMachineInitFunc(struct uc_struct *uc, MachineState *ms);
|
||||
|
||||
typedef void QEMUMachineResetFunc(void);
|
||||
|
||||
struct QEMUMachine {
|
||||
const char *family; /* NULL iff @name identifies a standalone machtype */
|
||||
const char *name;
|
||||
QEMUMachineInitFunc *init;
|
||||
QEMUMachineResetFunc *reset;
|
||||
int max_cpus;
|
||||
int is_default;
|
||||
int arch;
|
||||
};
|
||||
|
||||
void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
|
||||
const char *name,
|
||||
uint64_t ram_size);
|
||||
|
||||
void qemu_register_machine(struct uc_struct *uc, QEMUMachine *m, const char *type_machine,
|
||||
void (*init)(struct uc_struct *uc, ObjectClass *oc, void *data));
|
||||
|
||||
#define TYPE_MACHINE_SUFFIX "-machine"
|
||||
#define TYPE_MACHINE "machine"
|
||||
#undef MACHINE /* BSD defines it and QEMU does not use it */
|
||||
#define MACHINE(uc, obj) \
|
||||
OBJECT_CHECK(uc, MachineState, (obj), TYPE_MACHINE)
|
||||
#define MACHINE_GET_CLASS(uc, obj) \
|
||||
OBJECT_GET_CLASS(uc, MachineClass, (obj), TYPE_MACHINE)
|
||||
#define MACHINE_CLASS(uc, klass) \
|
||||
OBJECT_CLASS_CHECK(uc, MachineClass, (klass), TYPE_MACHINE)
|
||||
|
||||
MachineClass *find_default_machine(struct uc_struct *uc, int arch);
|
||||
|
||||
/**
|
||||
* MachineClass:
|
||||
* @qemu_machine: #QEMUMachine
|
||||
*/
|
||||
struct MachineClass {
|
||||
/*< private >*/
|
||||
ObjectClass parent_class;
|
||||
/*< public >*/
|
||||
|
||||
const char *family; /* NULL iff @name identifies a standalone machtype */
|
||||
const char *name;
|
||||
|
||||
void (*init)(struct uc_struct *uc, MachineState *state);
|
||||
void (*reset)(void);
|
||||
|
||||
int max_cpus;
|
||||
int is_default;
|
||||
int arch;
|
||||
};
|
||||
|
||||
/**
|
||||
* MachineState:
|
||||
*/
|
||||
struct MachineState {
|
||||
/*< private >*/
|
||||
Object parent_obj;
|
||||
|
||||
/*< public >*/
|
||||
ram_addr_t ram_size;
|
||||
ram_addr_t maxram_size;
|
||||
const char *cpu_model;
|
||||
struct uc_struct *uc;
|
||||
AccelState *accelerator;
|
||||
};
|
||||
|
||||
void machine_register_types(struct uc_struct *uc);
|
||||
|
||||
#endif
|
||||
79
qemu/include/hw/cpu/icc_bus.h
Normal file
79
qemu/include/hw/cpu/icc_bus.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* icc_bus.h
|
||||
* emulate x86 ICC (Interrupt Controller Communications) bus
|
||||
*
|
||||
* Copyright (c) 2013 Red Hat, Inc
|
||||
*
|
||||
* Authors:
|
||||
* Igor Mammedov <imammedo@redhat.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
#ifndef ICC_BUS_H
|
||||
#define ICC_BUS_H
|
||||
|
||||
#include "exec/memory.h"
|
||||
#include "hw/qdev-core.h"
|
||||
|
||||
#define TYPE_ICC_BUS "icc-bus"
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
/**
|
||||
* ICCBus:
|
||||
*
|
||||
* ICC bus
|
||||
*/
|
||||
typedef struct ICCBus {
|
||||
/*< private >*/
|
||||
BusState parent_obj;
|
||||
/*< public >*/
|
||||
|
||||
MemoryRegion *apic_address_space;
|
||||
} ICCBus;
|
||||
|
||||
#define ICC_BUS(uc, obj) OBJECT_CHECK(uc, ICCBus, (obj), TYPE_ICC_BUS)
|
||||
|
||||
/**
|
||||
* ICCDevice:
|
||||
*
|
||||
* ICC device
|
||||
*/
|
||||
typedef struct ICCDevice {
|
||||
/*< private >*/
|
||||
DeviceState qdev;
|
||||
/*< public >*/
|
||||
} ICCDevice;
|
||||
|
||||
/**
|
||||
* ICCDeviceClass:
|
||||
* @init: Initialization callback for derived classes.
|
||||
*
|
||||
* ICC device class
|
||||
*/
|
||||
typedef struct ICCDeviceClass {
|
||||
/*< private >*/
|
||||
DeviceClass parent_class;
|
||||
/*< public >*/
|
||||
|
||||
DeviceRealize realize;
|
||||
} ICCDeviceClass;
|
||||
|
||||
#define TYPE_ICC_DEVICE "icc-device"
|
||||
#define ICC_DEVICE_CLASS(uc, klass) \
|
||||
OBJECT_CLASS_CHECK(uc, ICCDeviceClass, (klass), TYPE_ICC_DEVICE)
|
||||
|
||||
void icc_bus_register_types(struct uc_struct *uc);
|
||||
|
||||
#endif /* CONFIG_USER_ONLY */
|
||||
#endif
|
||||
42
qemu/include/hw/hw.h
Normal file
42
qemu/include/hw/hw.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Declarations for use by hardware emulation. */
|
||||
#ifndef QEMU_HW_H
|
||||
#define QEMU_HW_H
|
||||
|
||||
#include "qemu-common.h"
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY) && !defined(NEED_CPU_H)
|
||||
#include "exec/cpu-common.h"
|
||||
#endif
|
||||
|
||||
#include "exec/ioport.h"
|
||||
#include "hw/irq.h"
|
||||
#include "qemu/log.h"
|
||||
|
||||
#ifdef NEED_CPU_H
|
||||
#if TARGET_LONG_BITS == 64
|
||||
#define qemu_put_betl qemu_put_be64
|
||||
#define qemu_get_betl qemu_get_be64
|
||||
#define qemu_put_betls qemu_put_be64s
|
||||
#define qemu_get_betls qemu_get_be64s
|
||||
#define qemu_put_sbetl qemu_put_sbe64
|
||||
#define qemu_get_sbetl qemu_get_sbe64
|
||||
#define qemu_put_sbetls qemu_put_sbe64s
|
||||
#define qemu_get_sbetls qemu_get_sbe64s
|
||||
#else
|
||||
#define qemu_put_betl qemu_put_be32
|
||||
#define qemu_get_betl qemu_get_be32
|
||||
#define qemu_put_betls qemu_put_be32s
|
||||
#define qemu_get_betls qemu_get_be32s
|
||||
#define qemu_put_sbetl qemu_put_sbe32
|
||||
#define qemu_get_sbetl qemu_get_sbe32
|
||||
#define qemu_put_sbetls qemu_put_sbe32s
|
||||
#define qemu_get_sbetls qemu_get_sbe32s
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef void QEMUResetHandler(void *opaque);
|
||||
|
||||
void qemu_register_reset(QEMUResetHandler *func, void *opaque);
|
||||
void qemu_unregister_reset(QEMUResetHandler *func, void *opaque);
|
||||
|
||||
#endif
|
||||
29
qemu/include/hw/i386/apic.h
Normal file
29
qemu/include/hw/i386/apic.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef APIC_H
|
||||
#define APIC_H
|
||||
|
||||
#include "qemu-common.h"
|
||||
|
||||
/* apic.c */
|
||||
int apic_accept_pic_intr(DeviceState *s);
|
||||
int apic_get_interrupt(DeviceState *s);
|
||||
void cpu_set_apic_base(struct uc_struct *uc, DeviceState *s, uint64_t val);
|
||||
uint64_t cpu_get_apic_base(struct uc_struct *uc, DeviceState *s);
|
||||
void cpu_set_apic_tpr(struct uc_struct *uc, DeviceState *s, uint8_t val);
|
||||
uint8_t cpu_get_apic_tpr(struct uc_struct *uc, DeviceState *s);
|
||||
void apic_init_reset(struct uc_struct *uc, DeviceState *s);
|
||||
void apic_sipi(DeviceState *s);
|
||||
void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip,
|
||||
TPRAccess access);
|
||||
void apic_poll_irq(DeviceState *d);
|
||||
void apic_designate_bsp(struct uc_struct *uc, DeviceState *d);
|
||||
|
||||
/* pc.c */
|
||||
DeviceState *cpu_get_current_apic(struct uc_struct *uc);
|
||||
|
||||
/* cpu.c */
|
||||
bool cpu_is_bsp(X86CPU *cpu);
|
||||
|
||||
void apic_register_types(struct uc_struct *uc);
|
||||
void apic_common_register_types(struct uc_struct *uc);
|
||||
|
||||
#endif
|
||||
147
qemu/include/hw/i386/apic_internal.h
Normal file
147
qemu/include/hw/i386/apic_internal.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* APIC support - internal interfaces
|
||||
*
|
||||
* Copyright (c) 2004-2005 Fabrice Bellard
|
||||
* Copyright (c) 2011 Jan Kiszka, Siemens AG
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
#ifndef QEMU_APIC_INTERNAL_H
|
||||
#define QEMU_APIC_INTERNAL_H
|
||||
|
||||
#include "exec/memory.h"
|
||||
#include "hw/cpu/icc_bus.h"
|
||||
#include "qemu/timer.h"
|
||||
|
||||
/* APIC Local Vector Table */
|
||||
#define APIC_LVT_TIMER 0
|
||||
#define APIC_LVT_THERMAL 1
|
||||
#define APIC_LVT_PERFORM 2
|
||||
#define APIC_LVT_LINT0 3
|
||||
#define APIC_LVT_LINT1 4
|
||||
#define APIC_LVT_ERROR 5
|
||||
#define APIC_LVT_NB 6
|
||||
|
||||
/* APIC delivery modes */
|
||||
#define APIC_DM_FIXED 0
|
||||
#define APIC_DM_LOWPRI 1
|
||||
#define APIC_DM_SMI 2
|
||||
#define APIC_DM_NMI 4
|
||||
#define APIC_DM_INIT 5
|
||||
#define APIC_DM_SIPI 6
|
||||
#define APIC_DM_EXTINT 7
|
||||
|
||||
/* APIC destination mode */
|
||||
#define APIC_DESTMODE_FLAT 0xf
|
||||
#define APIC_DESTMODE_CLUSTER 1
|
||||
|
||||
#define APIC_TRIGGER_EDGE 0
|
||||
#define APIC_TRIGGER_LEVEL 1
|
||||
|
||||
#define APIC_LVT_TIMER_PERIODIC (1<<17)
|
||||
#define APIC_LVT_MASKED (1<<16)
|
||||
#define APIC_LVT_LEVEL_TRIGGER (1<<15)
|
||||
#define APIC_LVT_REMOTE_IRR (1<<14)
|
||||
#define APIC_INPUT_POLARITY (1<<13)
|
||||
#define APIC_SEND_PENDING (1<<12)
|
||||
|
||||
#define ESR_ILLEGAL_ADDRESS (1 << 7)
|
||||
|
||||
#define APIC_SV_DIRECTED_IO (1<<12)
|
||||
#define APIC_SV_ENABLE (1<<8)
|
||||
|
||||
#define VAPIC_ENABLE_BIT 0
|
||||
#define VAPIC_ENABLE_MASK (1 << VAPIC_ENABLE_BIT)
|
||||
|
||||
#define MAX_APICS 255
|
||||
|
||||
typedef struct APICCommonState APICCommonState;
|
||||
|
||||
#define TYPE_APIC_COMMON "apic-common"
|
||||
#define APIC_COMMON(uc, obj) \
|
||||
OBJECT_CHECK(uc, APICCommonState, (obj), TYPE_APIC_COMMON)
|
||||
#define APIC_COMMON_CLASS(uc, klass) \
|
||||
OBJECT_CLASS_CHECK(uc, APICCommonClass, (klass), TYPE_APIC_COMMON)
|
||||
#define APIC_COMMON_GET_CLASS(uc, obj) \
|
||||
OBJECT_GET_CLASS(uc, APICCommonClass, (obj), TYPE_APIC_COMMON)
|
||||
|
||||
typedef struct APICCommonClass
|
||||
{
|
||||
ICCDeviceClass parent_class;
|
||||
|
||||
DeviceRealize realize;
|
||||
void (*set_base)(APICCommonState *s, uint64_t val);
|
||||
void (*set_tpr)(APICCommonState *s, uint8_t val);
|
||||
uint8_t (*get_tpr)(APICCommonState *s);
|
||||
void (*enable_tpr_reporting)(APICCommonState *s, bool enable);
|
||||
void (*vapic_base_update)(APICCommonState *s);
|
||||
void (*external_nmi)(APICCommonState *s);
|
||||
void (*pre_save)(APICCommonState *s);
|
||||
void (*post_load)(APICCommonState *s);
|
||||
void (*reset)(APICCommonState *s);
|
||||
} APICCommonClass;
|
||||
|
||||
struct APICCommonState {
|
||||
ICCDevice busdev;
|
||||
|
||||
MemoryRegion io_memory;
|
||||
X86CPU *cpu;
|
||||
uint32_t apicbase;
|
||||
uint8_t id;
|
||||
uint8_t version;
|
||||
uint8_t arb_id;
|
||||
uint8_t tpr;
|
||||
uint32_t spurious_vec;
|
||||
uint8_t log_dest;
|
||||
uint8_t dest_mode;
|
||||
uint32_t isr[8]; /* in service register */
|
||||
uint32_t tmr[8]; /* trigger mode register */
|
||||
uint32_t irr[8]; /* interrupt request register */
|
||||
uint32_t lvt[APIC_LVT_NB];
|
||||
uint32_t esr; /* error register */
|
||||
uint32_t icr[2];
|
||||
|
||||
uint32_t divide_conf;
|
||||
int count_shift;
|
||||
uint32_t initial_count;
|
||||
int64_t initial_count_load_time;
|
||||
int64_t next_time;
|
||||
int idx;
|
||||
QEMUTimer *timer;
|
||||
int64_t timer_expiry;
|
||||
int sipi_vector;
|
||||
int wait_for_sipi;
|
||||
|
||||
uint32_t vapic_control;
|
||||
DeviceState *vapic;
|
||||
hwaddr vapic_paddr; /* note: persistence via kvmvapic */
|
||||
};
|
||||
|
||||
typedef struct VAPICState {
|
||||
uint8_t tpr;
|
||||
uint8_t isr;
|
||||
uint8_t zero;
|
||||
uint8_t irr;
|
||||
uint8_t enabled;
|
||||
} QEMU_PACKED VAPICState;
|
||||
|
||||
extern bool apic_report_tpr_access;
|
||||
|
||||
bool apic_next_timer(APICCommonState *s, int64_t current_time);
|
||||
void apic_enable_vapic(struct uc_struct *uc, DeviceState *d, hwaddr paddr);
|
||||
|
||||
void vapic_report_tpr_access(DeviceState *dev, CPUState *cpu, target_ulong ip,
|
||||
TPRAccess access);
|
||||
|
||||
#endif /* !QEMU_APIC_INTERNAL_H */
|
||||
52
qemu/include/hw/i386/pc.h
Normal file
52
qemu/include/hw/i386/pc.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef HW_PC_H
|
||||
#define HW_PC_H
|
||||
|
||||
#include "hw/boards.h"
|
||||
|
||||
/**
|
||||
* PCMachineState:
|
||||
*/
|
||||
struct PCMachineState {
|
||||
/*< private >*/
|
||||
MachineState parent_obj;
|
||||
|
||||
uint64_t max_ram_below_4g;
|
||||
};
|
||||
|
||||
#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
|
||||
|
||||
/**
|
||||
* PCMachineClass:
|
||||
*/
|
||||
struct PCMachineClass {
|
||||
/*< private >*/
|
||||
MachineClass parent_class;
|
||||
};
|
||||
|
||||
typedef struct PCMachineState PCMachineState;
|
||||
typedef struct PCMachineClass PCMachineClass;
|
||||
|
||||
#define TYPE_PC_MACHINE "generic-pc-machine"
|
||||
#define PC_MACHINE(uc, obj) \
|
||||
OBJECT_CHECK(uc, PCMachineState, (obj), TYPE_PC_MACHINE)
|
||||
#define PC_MACHINE_GET_CLASS(obj) \
|
||||
OBJECT_GET_CLASS(PCMachineClass, (obj), TYPE_PC_MACHINE)
|
||||
#define PC_MACHINE_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
|
||||
|
||||
void pc_cpus_init(struct uc_struct *uc, const char *cpu_model);
|
||||
|
||||
FWCfgState *pc_memory_init(MachineState *machine,
|
||||
MemoryRegion *system_memory,
|
||||
ram_addr_t begin,
|
||||
MemoryRegion **ram_memory);
|
||||
typedef void (*cpu_set_smm_t)(int smm, void *arg);
|
||||
void cpu_smm_register(cpu_set_smm_t callback, void *arg);
|
||||
|
||||
void pc_machine_register_types(struct uc_struct *uc);
|
||||
void x86_cpu_register_types(struct uc_struct *uc);
|
||||
|
||||
#define PC_DEFAULT_MACHINE_OPTIONS \
|
||||
.max_cpus = 255
|
||||
|
||||
#endif
|
||||
64
qemu/include/hw/irq.h
Normal file
64
qemu/include/hw/irq.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef QEMU_IRQ_H
|
||||
#define QEMU_IRQ_H
|
||||
|
||||
/* Generic IRQ/GPIO pin infrastructure. */
|
||||
|
||||
#define TYPE_IRQ "irq"
|
||||
|
||||
typedef struct IRQState *qemu_irq;
|
||||
|
||||
typedef void (*qemu_irq_handler)(void *opaque, int n, int level);
|
||||
|
||||
void qemu_set_irq(qemu_irq irq, int level);
|
||||
|
||||
static inline void qemu_irq_raise(qemu_irq irq)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void qemu_irq_lower(qemu_irq irq)
|
||||
{
|
||||
qemu_set_irq(irq, 0);
|
||||
}
|
||||
|
||||
static inline void qemu_irq_pulse(qemu_irq irq)
|
||||
{
|
||||
qemu_set_irq(irq, 1);
|
||||
qemu_set_irq(irq, 0);
|
||||
}
|
||||
|
||||
/* Returns an array of N IRQs. Each IRQ is assigned the argument handler and
|
||||
* opaque data.
|
||||
*/
|
||||
qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n);
|
||||
|
||||
/*
|
||||
* Allocates a single IRQ. The irq is assigned with a handler, an opaque
|
||||
* data and the interrupt number.
|
||||
*/
|
||||
qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n);
|
||||
|
||||
/* Extends an Array of IRQs. Old IRQs have their handlers and opaque data
|
||||
* preserved. New IRQs are assigned the argument handler and opaque data.
|
||||
*/
|
||||
qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler handler,
|
||||
void *opaque, int n);
|
||||
|
||||
void qemu_free_irqs(qemu_irq *s, int n);
|
||||
void qemu_free_irq(qemu_irq irq);
|
||||
|
||||
/* Returns a new IRQ with opposite polarity. */
|
||||
qemu_irq qemu_irq_invert(qemu_irq irq);
|
||||
|
||||
/* Returns a new IRQ which feeds into both the passed IRQs */
|
||||
qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
|
||||
|
||||
/* Returns a new IRQ set which connects 1:1 to another IRQ set, which
|
||||
* may be set later.
|
||||
*/
|
||||
qemu_irq *qemu_irq_proxy(qemu_irq **target, int n);
|
||||
|
||||
/* For internal use in qtest. Similar to qemu_irq_split, but operating
|
||||
on an existing vector of qemu_irq. */
|
||||
void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n);
|
||||
|
||||
#endif
|
||||
10
qemu/include/hw/m68k/m68k.h
Normal file
10
qemu/include/hw/m68k/m68k.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef HW_M68K_H
|
||||
#define HW_M68K_H
|
||||
|
||||
#include "uc_priv.h"
|
||||
|
||||
void dummy_m68k_machine_init(struct uc_struct *uc);
|
||||
|
||||
void m68k_cpu_register_types(void *opaque);
|
||||
|
||||
#endif
|
||||
30
qemu/include/hw/m68k/mcf.h
Normal file
30
qemu/include/hw/m68k/mcf.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef HW_MCF_H
|
||||
#define HW_MCF_H
|
||||
/* Motorola ColdFire device prototypes. */
|
||||
|
||||
struct MemoryRegion;
|
||||
|
||||
/* mcf_uart.c */
|
||||
uint64_t mcf_uart_read(void *opaque, hwaddr addr,
|
||||
unsigned size);
|
||||
void mcf_uart_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size);
|
||||
void *mcf_uart_init(qemu_irq irq, CharDriverState *chr);
|
||||
void mcf_uart_mm_init(struct MemoryRegion *sysmem,
|
||||
hwaddr base,
|
||||
qemu_irq irq, CharDriverState *chr);
|
||||
|
||||
/* mcf_intc.c */
|
||||
qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem,
|
||||
hwaddr base,
|
||||
M68kCPU *cpu);
|
||||
|
||||
/* mcf_fec.c */
|
||||
void mcf_fec_init(struct MemoryRegion *sysmem, NICInfo *nd,
|
||||
hwaddr base, qemu_irq *irq);
|
||||
|
||||
/* mcf5206.c */
|
||||
qemu_irq *mcf5206_init(struct MemoryRegion *sysmem,
|
||||
uint32_t base, M68kCPU *cpu);
|
||||
|
||||
#endif
|
||||
8
qemu/include/hw/mips/bios.h
Normal file
8
qemu/include/hw/mips/bios.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "cpu.h"
|
||||
|
||||
#define BIOS_SIZE (4 * 1024 * 1024)
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
#define BIOS_FILENAME "mips_bios.bin"
|
||||
#else
|
||||
#define BIOS_FILENAME "mipsel_bios.bin"
|
||||
#endif
|
||||
17
qemu/include/hw/mips/cpudevs.h
Normal file
17
qemu/include/hw/mips/cpudevs.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef HW_MIPS_CPUDEVS_H
|
||||
#define HW_MIPS_CPUDEVS_H
|
||||
/* Definitions for MIPS CPU internal devices. */
|
||||
|
||||
/* mips_addr.c */
|
||||
uint64_t cpu_mips_kseg0_to_phys(void *opaque, uint64_t addr);
|
||||
uint64_t cpu_mips_phys_to_kseg0(void *opaque, uint64_t addr);
|
||||
uint64_t cpu_mips_kvm_um_phys_to_kseg0(void *opaque, uint64_t addr);
|
||||
|
||||
|
||||
/* mips_int.c */
|
||||
void cpu_mips_irq_init_cpu(CPUMIPSState *env);
|
||||
|
||||
/* mips_timer.c */
|
||||
void cpu_mips_clock_init(CPUMIPSState *);
|
||||
|
||||
#endif
|
||||
36
qemu/include/hw/mips/mips.h
Normal file
36
qemu/include/hw/mips/mips.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef HW_MIPS_H
|
||||
#define HW_MIPS_H
|
||||
/* Definitions for mips board emulation. */
|
||||
|
||||
/* Kernels can be configured with 64KB pages */
|
||||
#define INITRD_PAGE_MASK (~((1 << 16) - 1))
|
||||
|
||||
#include "exec/memory.h"
|
||||
|
||||
/* gt64xxx.c */
|
||||
PCIBus *gt64120_register(qemu_irq *pic);
|
||||
|
||||
/* bonito.c */
|
||||
PCIBus *bonito_init(qemu_irq *pic);
|
||||
|
||||
/* rc4030.c */
|
||||
typedef struct rc4030DMAState *rc4030_dma;
|
||||
void rc4030_dma_memory_rw(void *opaque, hwaddr addr, uint8_t *buf, int len, int is_write);
|
||||
void rc4030_dma_read(void *dma, uint8_t *buf, int len);
|
||||
void rc4030_dma_write(void *dma, uint8_t *buf, int len);
|
||||
|
||||
void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
|
||||
qemu_irq **irqs, rc4030_dma **dmas,
|
||||
MemoryRegion *sysmem);
|
||||
|
||||
/* dp8393x.c */
|
||||
void dp83932_init(NICInfo *nd, hwaddr base, int it_shift,
|
||||
MemoryRegion *address_space,
|
||||
qemu_irq irq, void* mem_opaque,
|
||||
void (*memory_rw)(void *opaque, hwaddr addr, uint8_t *buf, int len, int is_write));
|
||||
|
||||
void mips_machine_init(struct uc_struct *uc);
|
||||
|
||||
void mips_cpu_register_types(void *opaque);
|
||||
|
||||
#endif
|
||||
373
qemu/include/hw/qdev-core.h
Normal file
373
qemu/include/hw/qdev-core.h
Normal file
@@ -0,0 +1,373 @@
|
||||
#ifndef QDEV_CORE_H
|
||||
#define QDEV_CORE_H
|
||||
|
||||
#include "qemu/queue.h"
|
||||
#include "qemu/typedefs.h"
|
||||
#include "qemu/bitmap.h"
|
||||
#include "qom/object.h"
|
||||
#include "hw/irq.h"
|
||||
#include "qapi/error.h"
|
||||
|
||||
enum {
|
||||
DEV_NVECTORS_UNSPECIFIED = -1,
|
||||
};
|
||||
|
||||
#define TYPE_DEVICE "device"
|
||||
#define DEVICE(uc, obj) OBJECT_CHECK(uc, DeviceState, (obj), TYPE_DEVICE)
|
||||
#define DEVICE_CLASS(uc, klass) OBJECT_CLASS_CHECK(uc, DeviceClass, (klass), TYPE_DEVICE)
|
||||
#define DEVICE_GET_CLASS(uc, obj) OBJECT_GET_CLASS(uc, DeviceClass, (obj), TYPE_DEVICE)
|
||||
|
||||
typedef enum DeviceCategory {
|
||||
DEVICE_CATEGORY_BRIDGE,
|
||||
DEVICE_CATEGORY_USB,
|
||||
DEVICE_CATEGORY_STORAGE,
|
||||
DEVICE_CATEGORY_NETWORK,
|
||||
DEVICE_CATEGORY_INPUT,
|
||||
DEVICE_CATEGORY_DISPLAY,
|
||||
DEVICE_CATEGORY_SOUND,
|
||||
DEVICE_CATEGORY_MISC,
|
||||
DEVICE_CATEGORY_MAX
|
||||
} DeviceCategory;
|
||||
|
||||
typedef int (*qdev_initfn)(DeviceState *dev);
|
||||
typedef int (*qdev_event)(DeviceState *dev);
|
||||
typedef void (*qdev_resetfn)(DeviceState *dev);
|
||||
typedef void (*DeviceRealize)(struct uc_struct *uc, DeviceState *dev, Error **errp);
|
||||
typedef void (*DeviceUnrealize)(DeviceState *dev, Error **errp);
|
||||
typedef void (*BusRealize)(BusState *bus, Error **errp);
|
||||
typedef void (*BusUnrealize)(BusState *bus, Error **errp);
|
||||
|
||||
struct VMStateDescription;
|
||||
|
||||
/**
|
||||
* DeviceClass:
|
||||
* @props: Properties accessing state fields.
|
||||
* @realize: Callback function invoked when the #DeviceState:realized
|
||||
* property is changed to %true. The default invokes @init if not %NULL.
|
||||
* @unrealize: Callback function invoked when the #DeviceState:realized
|
||||
* property is changed to %false.
|
||||
* @init: Callback function invoked when the #DeviceState::realized property
|
||||
* is changed to %true. Deprecated, new types inheriting directly from
|
||||
* TYPE_DEVICE should use @realize instead, new leaf types should consult
|
||||
* their respective parent type.
|
||||
* @hotpluggable: indicates if #DeviceClass is hotpluggable, available
|
||||
* as readonly "hotpluggable" property of #DeviceState instance
|
||||
*
|
||||
* # Realization #
|
||||
* Devices are constructed in two stages,
|
||||
* 1) object instantiation via object_initialize() and
|
||||
* 2) device realization via #DeviceState:realized property.
|
||||
* The former may not fail (it might assert or exit), the latter may return
|
||||
* error information to the caller and must be re-entrant.
|
||||
* Trivial field initializations should go into #TypeInfo.instance_init.
|
||||
* Operations depending on @props static properties should go into @realize.
|
||||
* After successful realization, setting static properties will fail.
|
||||
*
|
||||
* As an interim step, the #DeviceState:realized property is set by deprecated
|
||||
* functions qdev_init() and qdev_init_nofail().
|
||||
* In the future, devices will propagate this state change to their children
|
||||
* and along busses they expose.
|
||||
* The point in time will be deferred to machine creation, so that values
|
||||
* set in @realize will not be introspectable beforehand. Therefore devices
|
||||
* must not create children during @realize; they should initialize them via
|
||||
* object_initialize() in their own #TypeInfo.instance_init and forward the
|
||||
* realization events appropriately.
|
||||
*
|
||||
* The @init callback is considered private to a particular bus implementation
|
||||
* (immediate abstract child types of TYPE_DEVICE). Derived leaf types set an
|
||||
* "init" callback on their parent class instead.
|
||||
*
|
||||
* Any type may override the @realize and/or @unrealize callbacks but needs
|
||||
* to call the parent type's implementation if keeping their functionality
|
||||
* is desired. Refer to QOM documentation for further discussion and examples.
|
||||
*
|
||||
* <note>
|
||||
* <para>
|
||||
* If a type derived directly from TYPE_DEVICE implements @realize, it does
|
||||
* not need to implement @init and therefore does not need to store and call
|
||||
* #DeviceClass' default @realize callback.
|
||||
* For other types consult the documentation and implementation of the
|
||||
* respective parent types.
|
||||
* </para>
|
||||
* </note>
|
||||
*/
|
||||
typedef struct DeviceClass {
|
||||
/*< private >*/
|
||||
ObjectClass parent_class;
|
||||
/*< public >*/
|
||||
|
||||
DECLARE_BITMAP(categories, DEVICE_CATEGORY_MAX);
|
||||
const char *fw_name;
|
||||
const char *desc;
|
||||
Property *props;
|
||||
|
||||
/*
|
||||
* Shall we hide this device model from -device / device_add?
|
||||
* All devices should support instantiation with device_add, and
|
||||
* this flag should not exist. But we're not there, yet. Some
|
||||
* devices fail to instantiate with cryptic error messages.
|
||||
* Others instantiate, but don't work. Exposing users to such
|
||||
* behavior would be cruel; this flag serves to protect them. It
|
||||
* should never be set without a comment explaining why it is set.
|
||||
* TODO remove once we're there
|
||||
*/
|
||||
bool cannot_instantiate_with_device_add_yet;
|
||||
bool hotpluggable;
|
||||
|
||||
/* callbacks */
|
||||
void (*reset)(struct uc_struct *uc, DeviceState *dev);
|
||||
DeviceRealize realize;
|
||||
DeviceUnrealize unrealize;
|
||||
|
||||
/* device state */
|
||||
const struct VMStateDescription *vmsd;
|
||||
|
||||
/* Private to qdev / bus. */
|
||||
qdev_initfn init; /* TODO remove, once users are converted to realize */
|
||||
qdev_event exit; /* TODO remove, once users are converted to unrealize */
|
||||
const char *bus_type;
|
||||
} DeviceClass;
|
||||
|
||||
typedef struct NamedGPIOList NamedGPIOList;
|
||||
|
||||
struct NamedGPIOList {
|
||||
char *name;
|
||||
qemu_irq *in;
|
||||
int num_in;
|
||||
int num_out;
|
||||
QLIST_ENTRY(NamedGPIOList) node;
|
||||
};
|
||||
|
||||
/**
|
||||
* DeviceState:
|
||||
* @realized: Indicates whether the device has been fully constructed.
|
||||
*
|
||||
* This structure should not be accessed directly. We declare it here
|
||||
* so that it can be embedded in individual device state structures.
|
||||
*/
|
||||
struct DeviceState {
|
||||
/*< private >*/
|
||||
Object parent_obj;
|
||||
/*< public >*/
|
||||
|
||||
const char *id;
|
||||
bool realized;
|
||||
bool pending_deleted_event;
|
||||
int hotplugged;
|
||||
BusState *parent_bus;
|
||||
QLIST_HEAD(, NamedGPIOList) gpios;
|
||||
QLIST_HEAD(, BusState) child_bus;
|
||||
int num_child_bus;
|
||||
int instance_id_alias;
|
||||
int alias_required_for_version;
|
||||
};
|
||||
|
||||
#define TYPE_BUS "bus"
|
||||
#define BUS(uc, obj) OBJECT_CHECK(uc, BusState, (obj), TYPE_BUS)
|
||||
#define BUS_CLASS(klass) OBJECT_CLASS_CHECK(BusClass, (klass), TYPE_BUS)
|
||||
#define BUS_GET_CLASS(obj) OBJECT_GET_CLASS(BusClass, (obj), TYPE_BUS)
|
||||
|
||||
struct BusClass {
|
||||
ObjectClass parent_class;
|
||||
|
||||
/* FIXME first arg should be BusState */
|
||||
void (*print_dev)(Monitor *mon, DeviceState *dev, int indent);
|
||||
char *(*get_dev_path)(DeviceState *dev);
|
||||
/*
|
||||
* This callback is used to create Open Firmware device path in accordance
|
||||
* with OF spec http://forthworks.com/standards/of1275.pdf. Individual bus
|
||||
* bindings can be found at http://playground.sun.com/1275/bindings/.
|
||||
*/
|
||||
char *(*get_fw_dev_path)(DeviceState *dev);
|
||||
void (*reset)(BusState *bus);
|
||||
BusRealize realize;
|
||||
BusUnrealize unrealize;
|
||||
|
||||
/* maximum devices allowed on the bus, 0: no limit. */
|
||||
int max_dev;
|
||||
/* number of automatically allocated bus ids (e.g. ide.0) */
|
||||
int automatic_ids;
|
||||
};
|
||||
|
||||
typedef struct BusChild {
|
||||
DeviceState *child;
|
||||
int index;
|
||||
QTAILQ_ENTRY(BusChild) sibling;
|
||||
} BusChild;
|
||||
|
||||
#define QDEV_HOTPLUG_HANDLER_PROPERTY "hotplug-handler"
|
||||
|
||||
/**
|
||||
* BusState:
|
||||
* @hotplug_device: link to a hotplug device associated with bus.
|
||||
*/
|
||||
struct BusState {
|
||||
Object obj;
|
||||
DeviceState *parent;
|
||||
const char *name;
|
||||
int max_index;
|
||||
bool realized;
|
||||
QTAILQ_HEAD(ChildrenHead, BusChild) children;
|
||||
QLIST_ENTRY(BusState) sibling;
|
||||
};
|
||||
|
||||
struct Property {
|
||||
const char *name;
|
||||
PropertyInfo *info;
|
||||
int offset;
|
||||
uint8_t bitnr;
|
||||
uint8_t qtype;
|
||||
int64_t defval;
|
||||
int arrayoffset;
|
||||
PropertyInfo *arrayinfo;
|
||||
int arrayfieldsize;
|
||||
};
|
||||
|
||||
struct PropertyInfo {
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char **enum_table;
|
||||
int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
|
||||
ObjectPropertyAccessor *get;
|
||||
ObjectPropertyAccessor *set;
|
||||
ObjectPropertyRelease *release;
|
||||
};
|
||||
|
||||
/**
|
||||
* GlobalProperty:
|
||||
* @user_provided: Set to true if property comes from user-provided config
|
||||
* (command-line or config file).
|
||||
* @used: Set to true if property was used when initializing a device.
|
||||
*/
|
||||
typedef struct GlobalProperty {
|
||||
const char *driver;
|
||||
const char *property;
|
||||
const char *value;
|
||||
bool user_provided;
|
||||
bool used;
|
||||
QTAILQ_ENTRY(GlobalProperty) next;
|
||||
} GlobalProperty;
|
||||
|
||||
/*** Board API. This should go away once we have a machine config file. ***/
|
||||
|
||||
DeviceState *qdev_create(BusState *bus, const char *name);
|
||||
DeviceState *qdev_try_create(BusState *bus, const char *name);
|
||||
int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
|
||||
void qdev_init_nofail(DeviceState *dev);
|
||||
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
|
||||
int required_for_version);
|
||||
void qdev_unplug(DeviceState *dev, Error **errp);
|
||||
void qdev_machine_creation_done(void);
|
||||
bool qdev_machine_modified(void);
|
||||
|
||||
qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
|
||||
qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n);
|
||||
|
||||
void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
|
||||
void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
|
||||
qemu_irq pin);
|
||||
qemu_irq qdev_get_gpio_out_connector(DeviceState *dev, const char *name, int n);
|
||||
qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt,
|
||||
const char *name, int n);
|
||||
|
||||
BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
|
||||
|
||||
/*** Device API. ***/
|
||||
|
||||
/* Register device properties. */
|
||||
/* GPIO inputs also double as IRQ sinks. */
|
||||
void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
|
||||
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
|
||||
void qdev_init_gpio_in_named(DeviceState *dev, qemu_irq_handler handler,
|
||||
const char *name, int n);
|
||||
void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
|
||||
const char *name, int n);
|
||||
|
||||
void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
|
||||
const char *name);
|
||||
|
||||
BusState *qdev_get_parent_bus(DeviceState *dev);
|
||||
|
||||
/*** BUS API. ***/
|
||||
|
||||
DeviceState *qdev_find_recursive(BusState *bus, const char *id);
|
||||
|
||||
/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */
|
||||
typedef int (qbus_walkerfn)(BusState *bus, void *opaque);
|
||||
typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque);
|
||||
|
||||
void qbus_create_inplace(void *bus, size_t size, const char *typename,
|
||||
DeviceState *parent, const char *name);
|
||||
BusState *qbus_create(const char *typename, DeviceState *parent, const char *name);
|
||||
/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion,
|
||||
* < 0 if either devfn or busfn terminate walk somewhere in cursion,
|
||||
* 0 otherwise. */
|
||||
int qbus_walk_children(BusState *bus,
|
||||
qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
|
||||
qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
|
||||
void *opaque);
|
||||
int qdev_walk_children(DeviceState *dev,
|
||||
qdev_walkerfn *pre_devfn, qbus_walkerfn *pre_busfn,
|
||||
qdev_walkerfn *post_devfn, qbus_walkerfn *post_busfn,
|
||||
void *opaque);
|
||||
|
||||
void qdev_reset_all(DeviceState *dev);
|
||||
|
||||
/**
|
||||
* @qbus_reset_all:
|
||||
* @bus: Bus to be reset.
|
||||
*
|
||||
* Reset @bus and perform a bus-level ("hard") reset of all devices connected
|
||||
* to it, including recursive processing of all buses below @bus itself. A
|
||||
* hard reset means that qbus_reset_all will reset all state of the device.
|
||||
* For PCI devices, for example, this will include the base address registers
|
||||
* or configuration space.
|
||||
*/
|
||||
void qbus_reset_all(BusState *bus);
|
||||
void qbus_reset_all_fn(void *opaque);
|
||||
|
||||
/* This should go away once we get rid of the NULL bus hack */
|
||||
BusState *sysbus_get_default(void);
|
||||
|
||||
char *qdev_get_fw_dev_path(DeviceState *dev);
|
||||
|
||||
/**
|
||||
* @qdev_machine_init
|
||||
*
|
||||
* Initialize platform devices before machine init. This is a hack until full
|
||||
* support for composition is added.
|
||||
*/
|
||||
void qdev_machine_init(void);
|
||||
|
||||
/**
|
||||
* @device_reset
|
||||
*
|
||||
* Reset a single device (by calling the reset method).
|
||||
*/
|
||||
void device_reset(DeviceState *dev);
|
||||
|
||||
const struct VMStateDescription *qdev_get_vmsd(DeviceState *dev);
|
||||
|
||||
const char *qdev_fw_name(DeviceState *dev);
|
||||
|
||||
Object *qdev_get_machine(struct uc_struct *);
|
||||
|
||||
/* FIXME: make this a link<> */
|
||||
void qdev_set_parent_bus(DeviceState *dev, BusState *bus);
|
||||
|
||||
extern int qdev_hotplug;
|
||||
|
||||
char *qdev_get_dev_path(DeviceState *dev);
|
||||
|
||||
GSList *qdev_build_hotpluggable_device_list(Object *peripheral);
|
||||
|
||||
void qbus_set_hotplug_handler(BusState *bus, DeviceState *handler,
|
||||
Error **errp);
|
||||
|
||||
void qbus_set_bus_hotplug_handler(BusState *bus, Error **errp);
|
||||
|
||||
void qdev_register_types(struct uc_struct *uc);
|
||||
|
||||
void sysbus_register_types(struct uc_struct *uc);
|
||||
|
||||
#endif
|
||||
7
qemu/include/hw/qdev.h
Normal file
7
qemu/include/hw/qdev.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef QDEV_H
|
||||
#define QDEV_H
|
||||
|
||||
#include "hw/hw.h"
|
||||
#include "hw/qdev-core.h"
|
||||
|
||||
#endif
|
||||
125
qemu/include/hw/sparc/grlib.h
Normal file
125
qemu/include/hw/sparc/grlib.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* QEMU GRLIB Components
|
||||
*
|
||||
* Copyright (c) 2010-2011 AdaCore
|
||||
*
|
||||
* 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 _GRLIB_H_
|
||||
#define _GRLIB_H_
|
||||
|
||||
#include "hw/qdev.h"
|
||||
|
||||
/* Emulation of GrLib device is base on the GRLIB IP Core User's Manual:
|
||||
* http://www.gaisler.com/products/grlib/grip.pdf
|
||||
*/
|
||||
|
||||
/* IRQMP */
|
||||
|
||||
typedef void (*set_pil_in_fn) (void *opaque, uint32_t pil_in);
|
||||
|
||||
void grlib_irqmp_set_irq(void *opaque, int irq, int level);
|
||||
|
||||
void grlib_irqmp_ack(DeviceState *dev, int intno);
|
||||
|
||||
static inline
|
||||
DeviceState *grlib_irqmp_create(hwaddr base,
|
||||
CPUSPARCState *env,
|
||||
qemu_irq **cpu_irqs,
|
||||
uint32_t nr_irqs,
|
||||
set_pil_in_fn set_pil_in)
|
||||
{
|
||||
DeviceState *dev;
|
||||
|
||||
assert(cpu_irqs != NULL);
|
||||
|
||||
dev = qdev_create(NULL, "grlib,irqmp");
|
||||
qdev_prop_set_ptr(dev, "set_pil_in", set_pil_in);
|
||||
qdev_prop_set_ptr(dev, "set_pil_in_opaque", env);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env->irq_manager = dev;
|
||||
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
|
||||
*cpu_irqs = qemu_allocate_irqs(grlib_irqmp_set_irq,
|
||||
dev,
|
||||
nr_irqs);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
/* GPTimer */
|
||||
|
||||
static inline
|
||||
DeviceState *grlib_gptimer_create(hwaddr base,
|
||||
uint32_t nr_timers,
|
||||
uint32_t freq,
|
||||
qemu_irq *cpu_irqs,
|
||||
int base_irq)
|
||||
{
|
||||
DeviceState *dev;
|
||||
int i;
|
||||
|
||||
dev = qdev_create(NULL, "grlib,gptimer");
|
||||
qdev_prop_set_uint32(dev, "nr-timers", nr_timers);
|
||||
qdev_prop_set_uint32(dev, "frequency", freq);
|
||||
qdev_prop_set_uint32(dev, "irq-line", base_irq);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
|
||||
for (i = 0; i < nr_timers; i++) {
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, cpu_irqs[base_irq + i]);
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
/* APB UART */
|
||||
|
||||
static inline
|
||||
DeviceState *grlib_apbuart_create(hwaddr base,
|
||||
CharDriverState *serial,
|
||||
qemu_irq irq)
|
||||
{
|
||||
DeviceState *dev;
|
||||
|
||||
dev = qdev_create(NULL, "grlib,apbuart");
|
||||
qdev_prop_set_chr(dev, "chrdev", serial);
|
||||
|
||||
if (qdev_init(dev)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
|
||||
|
||||
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
#endif /* ! _GRLIB_H_ */
|
||||
8
qemu/include/hw/sparc/sparc.h
Normal file
8
qemu/include/hw/sparc/sparc.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef HW_SPARC_H
|
||||
#define HW_SPARC_H
|
||||
|
||||
void sparc_cpu_register_types(void *opaque);
|
||||
void leon3_machine_init(struct uc_struct *uc);
|
||||
void sun4u_machine_init(struct uc_struct *uc);
|
||||
|
||||
#endif
|
||||
12
qemu/include/hw/sparc/sparc32_dma.h
Normal file
12
qemu/include/hw/sparc/sparc32_dma.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef SPARC32_DMA_H
|
||||
#define SPARC32_DMA_H
|
||||
|
||||
/* sparc32_dma.c */
|
||||
void ledma_memory_read(void *opaque, hwaddr addr,
|
||||
uint8_t *buf, int len, int do_bswap);
|
||||
void ledma_memory_write(void *opaque, hwaddr addr,
|
||||
uint8_t *buf, int len, int do_bswap);
|
||||
void espdma_memory_read(void *opaque, uint8_t *buf, int len);
|
||||
void espdma_memory_write(void *opaque, uint8_t *buf, int len);
|
||||
|
||||
#endif
|
||||
38
qemu/include/hw/sparc/sun4m.h
Normal file
38
qemu/include/hw/sparc/sun4m.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef SUN4M_H
|
||||
#define SUN4M_H
|
||||
|
||||
#include "qemu-common.h"
|
||||
#include "exec/hwaddr.h"
|
||||
#include "qapi/qmp/types.h"
|
||||
|
||||
/* Devices used by sparc32 system. */
|
||||
|
||||
/* iommu.c */
|
||||
void sparc_iommu_memory_rw(void *opaque, hwaddr addr,
|
||||
uint8_t *buf, int len, int is_write);
|
||||
static inline void sparc_iommu_memory_read(void *opaque,
|
||||
hwaddr addr,
|
||||
uint8_t *buf, int len)
|
||||
{
|
||||
sparc_iommu_memory_rw(opaque, addr, buf, len, 0);
|
||||
}
|
||||
|
||||
static inline void sparc_iommu_memory_write(void *opaque,
|
||||
hwaddr addr,
|
||||
uint8_t *buf, int len)
|
||||
{
|
||||
sparc_iommu_memory_rw(opaque, addr, buf, len, 1);
|
||||
}
|
||||
|
||||
/* slavio_intctl.c */
|
||||
void slavio_pic_info(Monitor *mon, DeviceState *dev);
|
||||
void slavio_irq_info(Monitor *mon, DeviceState *dev);
|
||||
|
||||
/* sun4m.c */
|
||||
void sun4m_pic_info(Monitor *mon, const QDict *qdict);
|
||||
void sun4m_irq_info(Monitor *mon, const QDict *qdict);
|
||||
|
||||
/* sparc32_dma.c */
|
||||
#include "hw/sparc/sparc32_dma.h"
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user