Statistics
| Branch: | Revision:

root / hw / apic_internal.h @ 57c83dac

History | View | Annotate | Download (3.8 kB)

1 dae01685 Jan Kiszka
/*
2 dae01685 Jan Kiszka
 *  APIC support - internal interfaces
3 dae01685 Jan Kiszka
 *
4 dae01685 Jan Kiszka
 *  Copyright (c) 2004-2005 Fabrice Bellard
5 dae01685 Jan Kiszka
 *  Copyright (c) 2011      Jan Kiszka, Siemens AG
6 dae01685 Jan Kiszka
 *
7 dae01685 Jan Kiszka
 * This library is free software; you can redistribute it and/or
8 dae01685 Jan Kiszka
 * modify it under the terms of the GNU Lesser General Public
9 dae01685 Jan Kiszka
 * License as published by the Free Software Foundation; either
10 dae01685 Jan Kiszka
 * version 2 of the License, or (at your option) any later version.
11 dae01685 Jan Kiszka
 *
12 dae01685 Jan Kiszka
 * This library is distributed in the hope that it will be useful,
13 dae01685 Jan Kiszka
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dae01685 Jan Kiszka
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 dae01685 Jan Kiszka
 * Lesser General Public License for more details.
16 dae01685 Jan Kiszka
 *
17 dae01685 Jan Kiszka
 * You should have received a copy of the GNU Lesser General Public
18 dae01685 Jan Kiszka
 * License along with this library; if not, see <http://www.gnu.org/licenses/>
19 dae01685 Jan Kiszka
 */
20 dae01685 Jan Kiszka
#ifndef QEMU_APIC_INTERNAL_H
21 dae01685 Jan Kiszka
#define QEMU_APIC_INTERNAL_H
22 dae01685 Jan Kiszka
23 dae01685 Jan Kiszka
#include "memory.h"
24 dae01685 Jan Kiszka
#include "sysbus.h"
25 dae01685 Jan Kiszka
#include "qemu-timer.h"
26 dae01685 Jan Kiszka
27 dae01685 Jan Kiszka
/* APIC Local Vector Table */
28 dae01685 Jan Kiszka
#define APIC_LVT_TIMER                  0
29 dae01685 Jan Kiszka
#define APIC_LVT_THERMAL                1
30 dae01685 Jan Kiszka
#define APIC_LVT_PERFORM                2
31 dae01685 Jan Kiszka
#define APIC_LVT_LINT0                  3
32 dae01685 Jan Kiszka
#define APIC_LVT_LINT1                  4
33 dae01685 Jan Kiszka
#define APIC_LVT_ERROR                  5
34 dae01685 Jan Kiszka
#define APIC_LVT_NB                     6
35 dae01685 Jan Kiszka
36 dae01685 Jan Kiszka
/* APIC delivery modes */
37 dae01685 Jan Kiszka
#define APIC_DM_FIXED                   0
38 dae01685 Jan Kiszka
#define APIC_DM_LOWPRI                  1
39 dae01685 Jan Kiszka
#define APIC_DM_SMI                     2
40 dae01685 Jan Kiszka
#define APIC_DM_NMI                     4
41 dae01685 Jan Kiszka
#define APIC_DM_INIT                    5
42 dae01685 Jan Kiszka
#define APIC_DM_SIPI                    6
43 dae01685 Jan Kiszka
#define APIC_DM_EXTINT                  7
44 dae01685 Jan Kiszka
45 dae01685 Jan Kiszka
/* APIC destination mode */
46 dae01685 Jan Kiszka
#define APIC_DESTMODE_FLAT              0xf
47 dae01685 Jan Kiszka
#define APIC_DESTMODE_CLUSTER           1
48 dae01685 Jan Kiszka
49 dae01685 Jan Kiszka
#define APIC_TRIGGER_EDGE               0
50 dae01685 Jan Kiszka
#define APIC_TRIGGER_LEVEL              1
51 dae01685 Jan Kiszka
52 dae01685 Jan Kiszka
#define APIC_LVT_TIMER_PERIODIC         (1<<17)
53 dae01685 Jan Kiszka
#define APIC_LVT_MASKED                 (1<<16)
54 dae01685 Jan Kiszka
#define APIC_LVT_LEVEL_TRIGGER          (1<<15)
55 dae01685 Jan Kiszka
#define APIC_LVT_REMOTE_IRR             (1<<14)
56 dae01685 Jan Kiszka
#define APIC_INPUT_POLARITY             (1<<13)
57 dae01685 Jan Kiszka
#define APIC_SEND_PENDING               (1<<12)
58 dae01685 Jan Kiszka
59 dae01685 Jan Kiszka
#define ESR_ILLEGAL_ADDRESS (1 << 7)
60 dae01685 Jan Kiszka
61 dae01685 Jan Kiszka
#define APIC_SV_DIRECTED_IO             (1<<12)
62 dae01685 Jan Kiszka
#define APIC_SV_ENABLE                  (1<<8)
63 dae01685 Jan Kiszka
64 dae01685 Jan Kiszka
#define MAX_APICS 255
65 dae01685 Jan Kiszka
66 dae01685 Jan Kiszka
#define MSI_SPACE_SIZE                  0x100000
67 dae01685 Jan Kiszka
68 dae01685 Jan Kiszka
typedef struct APICCommonState APICCommonState;
69 dae01685 Jan Kiszka
70 999e12bb Anthony Liguori
#define TYPE_APIC_COMMON "apic-common"
71 999e12bb Anthony Liguori
#define APIC_COMMON(obj) \
72 999e12bb Anthony Liguori
     OBJECT_CHECK(APICCommonState, (obj), TYPE_APIC_COMMON)
73 999e12bb Anthony Liguori
#define APIC_COMMON_CLASS(klass) \
74 999e12bb Anthony Liguori
     OBJECT_CLASS_CHECK(APICCommonClass, (klass), TYPE_APIC_COMMON)
75 999e12bb Anthony Liguori
#define APIC_COMMON_GET_CLASS(obj) \
76 999e12bb Anthony Liguori
     OBJECT_GET_CLASS(APICCommonClass, (obj), TYPE_APIC_COMMON)
77 999e12bb Anthony Liguori
78 999e12bb Anthony Liguori
typedef struct APICCommonClass
79 999e12bb Anthony Liguori
{
80 999e12bb Anthony Liguori
    SysBusDeviceClass parent_class;
81 999e12bb Anthony Liguori
82 999e12bb Anthony Liguori
    void (*init)(APICCommonState *s);
83 999e12bb Anthony Liguori
    void (*set_base)(APICCommonState *s, uint64_t val);
84 999e12bb Anthony Liguori
    void (*set_tpr)(APICCommonState *s, uint8_t val);
85 999e12bb Anthony Liguori
    void (*external_nmi)(APICCommonState *s);
86 999e12bb Anthony Liguori
    void (*post_load)(APICCommonState *s);
87 999e12bb Anthony Liguori
} APICCommonClass;
88 999e12bb Anthony Liguori
89 dae01685 Jan Kiszka
struct APICCommonState {
90 dae01685 Jan Kiszka
    SysBusDevice busdev;
91 dae01685 Jan Kiszka
    MemoryRegion io_memory;
92 dae01685 Jan Kiszka
    void *cpu_env;
93 dae01685 Jan Kiszka
    uint32_t apicbase;
94 dae01685 Jan Kiszka
    uint8_t id;
95 dae01685 Jan Kiszka
    uint8_t arb_id;
96 dae01685 Jan Kiszka
    uint8_t tpr;
97 dae01685 Jan Kiszka
    uint32_t spurious_vec;
98 dae01685 Jan Kiszka
    uint8_t log_dest;
99 dae01685 Jan Kiszka
    uint8_t dest_mode;
100 dae01685 Jan Kiszka
    uint32_t isr[8];  /* in service register */
101 dae01685 Jan Kiszka
    uint32_t tmr[8];  /* trigger mode register */
102 dae01685 Jan Kiszka
    uint32_t irr[8]; /* interrupt request register */
103 dae01685 Jan Kiszka
    uint32_t lvt[APIC_LVT_NB];
104 dae01685 Jan Kiszka
    uint32_t esr; /* error register */
105 dae01685 Jan Kiszka
    uint32_t icr[2];
106 dae01685 Jan Kiszka
107 dae01685 Jan Kiszka
    uint32_t divide_conf;
108 dae01685 Jan Kiszka
    int count_shift;
109 dae01685 Jan Kiszka
    uint32_t initial_count;
110 dae01685 Jan Kiszka
    int64_t initial_count_load_time;
111 dae01685 Jan Kiszka
    int64_t next_time;
112 dae01685 Jan Kiszka
    int idx;
113 dae01685 Jan Kiszka
    QEMUTimer *timer;
114 7a380ca3 Jan Kiszka
    int64_t timer_expiry;
115 dae01685 Jan Kiszka
    int sipi_vector;
116 dae01685 Jan Kiszka
    int wait_for_sipi;
117 dae01685 Jan Kiszka
};
118 dae01685 Jan Kiszka
119 dae01685 Jan Kiszka
void apic_report_irq_delivered(int delivered);
120 7a380ca3 Jan Kiszka
bool apic_next_timer(APICCommonState *s, int64_t current_time);
121 dae01685 Jan Kiszka
122 dae01685 Jan Kiszka
#endif /* !QEMU_APIC_INTERNAL_H */