2011-10-16 21:38:22 +04:00
|
|
|
/*
|
|
|
|
* IOAPIC emulation logic - internal interfaces
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004-2005 Fabrice Bellard
|
|
|
|
* Copyright (c) 2009 Xiantao Zhang, Intel
|
|
|
|
* 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
|
2020-10-23 15:44:24 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2011-10-16 21:38:22 +04:00
|
|
|
*
|
|
|
|
* 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_IOAPIC_INTERNAL_H
|
|
|
|
#define QEMU_IOAPIC_INTERNAL_H
|
|
|
|
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/memory.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/sysbus.h"
|
2016-07-14 08:56:27 +03:00
|
|
|
#include "qemu/notify.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2011-10-16 21:38:22 +04:00
|
|
|
|
2020-12-03 13:54:14 +03:00
|
|
|
#define MAX_IOAPICS 2
|
2011-10-16 21:38:22 +04:00
|
|
|
|
|
|
|
#define IOAPIC_LVT_DEST_SHIFT 56
|
2016-07-14 08:56:23 +03:00
|
|
|
#define IOAPIC_LVT_DEST_IDX_SHIFT 48
|
2011-10-16 21:38:22 +04:00
|
|
|
#define IOAPIC_LVT_MASKED_SHIFT 16
|
|
|
|
#define IOAPIC_LVT_TRIGGER_MODE_SHIFT 15
|
|
|
|
#define IOAPIC_LVT_REMOTE_IRR_SHIFT 14
|
|
|
|
#define IOAPIC_LVT_POLARITY_SHIFT 13
|
|
|
|
#define IOAPIC_LVT_DELIV_STATUS_SHIFT 12
|
|
|
|
#define IOAPIC_LVT_DEST_MODE_SHIFT 11
|
|
|
|
#define IOAPIC_LVT_DELIV_MODE_SHIFT 8
|
|
|
|
|
|
|
|
#define IOAPIC_LVT_MASKED (1 << IOAPIC_LVT_MASKED_SHIFT)
|
2015-09-22 16:18:19 +03:00
|
|
|
#define IOAPIC_LVT_TRIGGER_MODE (1 << IOAPIC_LVT_TRIGGER_MODE_SHIFT)
|
2011-10-16 21:38:22 +04:00
|
|
|
#define IOAPIC_LVT_REMOTE_IRR (1 << IOAPIC_LVT_REMOTE_IRR_SHIFT)
|
2015-09-22 16:18:19 +03:00
|
|
|
#define IOAPIC_LVT_POLARITY (1 << IOAPIC_LVT_POLARITY_SHIFT)
|
|
|
|
#define IOAPIC_LVT_DELIV_STATUS (1 << IOAPIC_LVT_DELIV_STATUS_SHIFT)
|
|
|
|
#define IOAPIC_LVT_DEST_MODE (1 << IOAPIC_LVT_DEST_MODE_SHIFT)
|
|
|
|
#define IOAPIC_LVT_DELIV_MODE (7 << IOAPIC_LVT_DELIV_MODE_SHIFT)
|
2011-10-16 21:38:22 +04:00
|
|
|
|
2016-05-10 13:21:21 +03:00
|
|
|
/* Bits that are read-only for IOAPIC entry */
|
|
|
|
#define IOAPIC_RO_BITS (IOAPIC_LVT_REMOTE_IRR | \
|
|
|
|
IOAPIC_LVT_DELIV_STATUS)
|
|
|
|
#define IOAPIC_RW_BITS (~(uint64_t)IOAPIC_RO_BITS)
|
|
|
|
|
2011-10-16 21:38:22 +04:00
|
|
|
#define IOAPIC_TRIGGER_EDGE 0
|
|
|
|
#define IOAPIC_TRIGGER_LEVEL 1
|
|
|
|
|
|
|
|
/*io{apic,sapic} delivery mode*/
|
|
|
|
#define IOAPIC_DM_FIXED 0x0
|
|
|
|
#define IOAPIC_DM_LOWEST_PRIORITY 0x1
|
|
|
|
#define IOAPIC_DM_PMI 0x2
|
|
|
|
#define IOAPIC_DM_NMI 0x4
|
|
|
|
#define IOAPIC_DM_INIT 0x5
|
|
|
|
#define IOAPIC_DM_SIPI 0x6
|
|
|
|
#define IOAPIC_DM_EXTINT 0x7
|
|
|
|
#define IOAPIC_DM_MASK 0x7
|
|
|
|
|
|
|
|
#define IOAPIC_VECTOR_MASK 0xff
|
|
|
|
|
|
|
|
#define IOAPIC_IOREGSEL 0x00
|
|
|
|
#define IOAPIC_IOWIN 0x10
|
2016-08-01 16:59:19 +03:00
|
|
|
#define IOAPIC_EOI 0x40
|
2011-10-16 21:38:22 +04:00
|
|
|
|
|
|
|
#define IOAPIC_REG_ID 0x00
|
|
|
|
#define IOAPIC_REG_VER 0x01
|
|
|
|
#define IOAPIC_REG_ARB 0x02
|
|
|
|
#define IOAPIC_REG_REDTBL_BASE 0x10
|
|
|
|
#define IOAPIC_ID 0x00
|
|
|
|
|
|
|
|
#define IOAPIC_ID_SHIFT 24
|
|
|
|
#define IOAPIC_ID_MASK 0xf
|
|
|
|
|
|
|
|
#define IOAPIC_VER_ENTRIES_SHIFT 16
|
|
|
|
|
|
|
|
|
2012-01-24 23:12:29 +04:00
|
|
|
#define TYPE_IOAPIC_COMMON "ioapic-common"
|
2020-09-16 21:25:18 +03:00
|
|
|
OBJECT_DECLARE_TYPE(IOAPICCommonState, IOAPICCommonClass, IOAPIC_COMMON)
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct IOAPICCommonClass {
|
2012-01-24 23:12:29 +04:00
|
|
|
SysBusDeviceClass parent_class;
|
2013-11-05 14:16:05 +04:00
|
|
|
|
|
|
|
DeviceRealize realize;
|
2019-04-02 11:02:15 +03:00
|
|
|
DeviceUnrealize unrealize;
|
2012-01-24 23:12:29 +04:00
|
|
|
void (*pre_save)(IOAPICCommonState *s);
|
|
|
|
void (*post_load)(IOAPICCommonState *s);
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2012-01-24 23:12:29 +04:00
|
|
|
|
2011-10-16 21:38:22 +04:00
|
|
|
struct IOAPICCommonState {
|
|
|
|
SysBusDevice busdev;
|
|
|
|
MemoryRegion io_memory;
|
|
|
|
uint8_t id;
|
|
|
|
uint8_t ioregsel;
|
|
|
|
uint32_t irr;
|
|
|
|
uint64_t ioredtbl[IOAPIC_NUM_PINS];
|
2016-07-14 08:56:27 +03:00
|
|
|
Notifier machine_done;
|
2016-08-01 16:59:19 +03:00
|
|
|
uint8_t version;
|
2017-12-29 10:31:03 +03:00
|
|
|
uint64_t irq_count[IOAPIC_NUM_PINS];
|
|
|
|
int irq_level[IOAPIC_NUM_PINS];
|
2019-04-02 11:02:15 +03:00
|
|
|
int irq_eoi[IOAPIC_NUM_PINS];
|
|
|
|
QEMUTimer *delayed_ioapic_service_timer;
|
2011-10-16 21:38:22 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void ioapic_reset_common(DeviceState *dev);
|
|
|
|
|
2017-12-29 10:31:03 +03:00
|
|
|
void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level);
|
2015-09-22 16:18:20 +03:00
|
|
|
|
2016-06-29 16:29:06 +03:00
|
|
|
#endif /* QEMU_IOAPIC_INTERNAL_H */
|