pc: apic: introduce APIC macro
Introduce a new APIC macro to replace APIC_COMMON macro in hw/intc/apic.c in order to capture access LAPIC in qemu even if LAPIC is emulated in kvm. Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com> Message-Id: <1473923759-13912-1-git-send-email-wanpeng.li@hotmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
885b7c44e4
commit
927d5a1d98
|
@ -39,6 +39,10 @@
|
||||||
|
|
||||||
static APICCommonState *local_apics[MAX_APICS + 1];
|
static APICCommonState *local_apics[MAX_APICS + 1];
|
||||||
|
|
||||||
|
#define TYPE_APIC "apic"
|
||||||
|
#define APIC(obj) \
|
||||||
|
OBJECT_CHECK(APICCommonState, (obj), TYPE_APIC)
|
||||||
|
|
||||||
static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode);
|
static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode);
|
||||||
static void apic_update_irq(APICCommonState *s);
|
static void apic_update_irq(APICCommonState *s);
|
||||||
static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
|
static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask,
|
||||||
|
@ -163,7 +167,7 @@ static void apic_local_deliver(APICCommonState *s, int vector)
|
||||||
|
|
||||||
void apic_deliver_pic_intr(DeviceState *dev, int level)
|
void apic_deliver_pic_intr(DeviceState *dev, int level)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
|
|
||||||
if (level) {
|
if (level) {
|
||||||
apic_local_deliver(s, APIC_LVT_LINT0);
|
apic_local_deliver(s, APIC_LVT_LINT0);
|
||||||
|
@ -373,7 +377,7 @@ static void apic_update_irq(APICCommonState *s)
|
||||||
|
|
||||||
void apic_poll_irq(DeviceState *dev)
|
void apic_poll_irq(DeviceState *dev)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
|
|
||||||
apic_sync_vapic(s, SYNC_FROM_VAPIC);
|
apic_sync_vapic(s, SYNC_FROM_VAPIC);
|
||||||
apic_update_irq(s);
|
apic_update_irq(s);
|
||||||
|
@ -479,7 +483,7 @@ static void apic_startup(APICCommonState *s, int vector_num)
|
||||||
|
|
||||||
void apic_sipi(DeviceState *dev)
|
void apic_sipi(DeviceState *dev)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
|
|
||||||
cpu_reset_interrupt(CPU(s->cpu), CPU_INTERRUPT_SIPI);
|
cpu_reset_interrupt(CPU(s->cpu), CPU_INTERRUPT_SIPI);
|
||||||
|
|
||||||
|
@ -493,7 +497,7 @@ static void apic_deliver(DeviceState *dev, uint8_t dest, uint8_t dest_mode,
|
||||||
uint8_t delivery_mode, uint8_t vector_num,
|
uint8_t delivery_mode, uint8_t vector_num,
|
||||||
uint8_t trigger_mode)
|
uint8_t trigger_mode)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
uint32_t deliver_bitmask[MAX_APIC_WORDS];
|
uint32_t deliver_bitmask[MAX_APIC_WORDS];
|
||||||
int dest_shorthand = (s->icr[0] >> 18) & 3;
|
int dest_shorthand = (s->icr[0] >> 18) & 3;
|
||||||
APICCommonState *apic_iter;
|
APICCommonState *apic_iter;
|
||||||
|
@ -550,7 +554,7 @@ static bool apic_check_pic(APICCommonState *s)
|
||||||
|
|
||||||
int apic_get_interrupt(DeviceState *dev)
|
int apic_get_interrupt(DeviceState *dev)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
int intno;
|
int intno;
|
||||||
|
|
||||||
/* if the APIC is installed or enabled, we let the 8259 handle the
|
/* if the APIC is installed or enabled, we let the 8259 handle the
|
||||||
|
@ -584,7 +588,7 @@ int apic_get_interrupt(DeviceState *dev)
|
||||||
|
|
||||||
int apic_accept_pic_intr(DeviceState *dev)
|
int apic_accept_pic_intr(DeviceState *dev)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
uint32_t lvt0;
|
uint32_t lvt0;
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
|
@ -663,7 +667,7 @@ static uint32_t apic_mem_readl(void *opaque, hwaddr addr)
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
s = APIC_COMMON(dev);
|
s = APIC(dev);
|
||||||
|
|
||||||
index = (addr >> 4) & 0xff;
|
index = (addr >> 4) & 0xff;
|
||||||
switch(index) {
|
switch(index) {
|
||||||
|
@ -766,7 +770,7 @@ static void apic_mem_writel(void *opaque, hwaddr addr, uint32_t val)
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s = APIC_COMMON(dev);
|
s = APIC(dev);
|
||||||
|
|
||||||
trace_apic_mem_writel(addr, val);
|
trace_apic_mem_writel(addr, val);
|
||||||
|
|
||||||
|
@ -870,7 +874,7 @@ static const MemoryRegionOps apic_io_ops = {
|
||||||
|
|
||||||
static void apic_realize(DeviceState *dev, Error **errp)
|
static void apic_realize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
|
|
||||||
if (s->id >= MAX_APICS) {
|
if (s->id >= MAX_APICS) {
|
||||||
error_setg(errp, "%s initialization failed. APIC ID %d is invalid",
|
error_setg(errp, "%s initialization failed. APIC ID %d is invalid",
|
||||||
|
@ -889,7 +893,7 @@ static void apic_realize(DeviceState *dev, Error **errp)
|
||||||
|
|
||||||
static void apic_unrealize(DeviceState *dev, Error **errp)
|
static void apic_unrealize(DeviceState *dev, Error **errp)
|
||||||
{
|
{
|
||||||
APICCommonState *s = APIC_COMMON(dev);
|
APICCommonState *s = APIC(dev);
|
||||||
|
|
||||||
timer_del(s->timer);
|
timer_del(s->timer);
|
||||||
timer_free(s->timer);
|
timer_free(s->timer);
|
||||||
|
@ -912,7 +916,7 @@ static void apic_class_init(ObjectClass *klass, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo apic_info = {
|
static const TypeInfo apic_info = {
|
||||||
.name = "apic",
|
.name = TYPE_APIC,
|
||||||
.instance_size = sizeof(APICCommonState),
|
.instance_size = sizeof(APICCommonState),
|
||||||
.parent = TYPE_APIC_COMMON,
|
.parent = TYPE_APIC_COMMON,
|
||||||
.class_init = apic_class_init,
|
.class_init = apic_class_init,
|
||||||
|
|
Loading…
Reference in a new issue