Back in 2016, we discussed[1] rules for headers, and these were generally liked: 1. Have a carefully curated header that's included everywhere first. We got that already thanks to Peter: osdep.h. 2. Headers should normally include everything they need beyond osdep.h. If exceptions are needed for some reason, they must be documented in the header. If all that's needed from a header is typedefs, put those into qemu/typedefs.h instead of including the header. 3. Cyclic inclusion is forbidden. This patch gets include/ closer to obeying 2. It's actually extracted from my "[RFC] Baby steps towards saner headers" series[2], which demonstrates a possible path towards checking 2 automatically. It passes the RFC test there. [1] Message-ID: <87h9g8j57d.fsf@blackfin.pond.sub.org> https://lists.nongnu.org/archive/html/qemu-devel/2016-03/msg03345.html [2] Message-Id: <20190711122827.18970-1-armbru@redhat.com> https://lists.nongnu.org/archive/html/qemu-devel/2019-07/msg02715.html Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20190812052359.30071-2-armbru@redhat.com> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
126 lines
4.4 KiB
C
126 lines
4.4 KiB
C
/*
|
|
* 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
|
|
* 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_IOAPIC_INTERNAL_H
|
|
#define QEMU_IOAPIC_INTERNAL_H
|
|
|
|
#include "hw/hw.h"
|
|
#include "exec/memory.h"
|
|
#include "hw/i386/ioapic.h"
|
|
#include "hw/sysbus.h"
|
|
#include "qemu/notify.h"
|
|
|
|
#define MAX_IOAPICS 1
|
|
|
|
#define IOAPIC_LVT_DEST_SHIFT 56
|
|
#define IOAPIC_LVT_DEST_IDX_SHIFT 48
|
|
#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)
|
|
#define IOAPIC_LVT_TRIGGER_MODE (1 << IOAPIC_LVT_TRIGGER_MODE_SHIFT)
|
|
#define IOAPIC_LVT_REMOTE_IRR (1 << IOAPIC_LVT_REMOTE_IRR_SHIFT)
|
|
#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)
|
|
|
|
/* 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)
|
|
|
|
#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
|
|
#define IOAPIC_EOI 0x40
|
|
|
|
#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
|
|
|
|
typedef struct IOAPICCommonState IOAPICCommonState;
|
|
|
|
#define TYPE_IOAPIC_COMMON "ioapic-common"
|
|
#define IOAPIC_COMMON(obj) \
|
|
OBJECT_CHECK(IOAPICCommonState, (obj), TYPE_IOAPIC_COMMON)
|
|
#define IOAPIC_COMMON_CLASS(klass) \
|
|
OBJECT_CLASS_CHECK(IOAPICCommonClass, (klass), TYPE_IOAPIC_COMMON)
|
|
#define IOAPIC_COMMON_GET_CLASS(obj) \
|
|
OBJECT_GET_CLASS(IOAPICCommonClass, (obj), TYPE_IOAPIC_COMMON)
|
|
|
|
typedef struct IOAPICCommonClass {
|
|
SysBusDeviceClass parent_class;
|
|
|
|
DeviceRealize realize;
|
|
DeviceUnrealize unrealize;
|
|
void (*pre_save)(IOAPICCommonState *s);
|
|
void (*post_load)(IOAPICCommonState *s);
|
|
} IOAPICCommonClass;
|
|
|
|
struct IOAPICCommonState {
|
|
SysBusDevice busdev;
|
|
MemoryRegion io_memory;
|
|
uint8_t id;
|
|
uint8_t ioregsel;
|
|
uint32_t irr;
|
|
uint64_t ioredtbl[IOAPIC_NUM_PINS];
|
|
Notifier machine_done;
|
|
uint8_t version;
|
|
uint64_t irq_count[IOAPIC_NUM_PINS];
|
|
int irq_level[IOAPIC_NUM_PINS];
|
|
int irq_eoi[IOAPIC_NUM_PINS];
|
|
QEMUTimer *delayed_ioapic_service_timer;
|
|
};
|
|
|
|
void ioapic_reset_common(DeviceState *dev);
|
|
|
|
void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s);
|
|
void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level);
|
|
|
|
#endif /* QEMU_IOAPIC_INTERNAL_H */
|