aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ioemu/hw/ioapic.h
blob: a243b7f59d6ccb7894b23764b76f485c6b128175 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/////////////////////////////////////////////////////////////////////////
//
//  Copyright (C) 2001  MandrakeSoft S.A.
//
//    MandrakeSoft S.A.
//    43, rue d'Aboukir
//    75002 Paris - France
//    http://www.linux-mandrake.com/
//    http://www.mandrakesoft.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, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
//

#ifndef __IOAPIC_H
#define __IOAPIC_H

#include "xc.h"
#include <io/ioreq.h>
#include <io/vmx_vlapic.h>

#define IOAPIC_NUM_PINS 24
#define IOAPIC_VERSION_ID 0x11
#define IOAPIC_LEVEL_TRIGGER 1
#define APIC_DM_FIXED	0
#define APIC_DM_LOWPRI	1



#ifdef CONFIG_SMP
#define LOCK_PREFIX "lock ; "
#else
#define LOCK_PREFIX ""
#endif

#ifdef __I386__
#define __OS "q" 
#define __OP "r" 
#else
#define __OS "l"  /* Operation Suffix */
#define __OP "e"  /* Operand Prefix */
#endif

#define ADDR (*(volatile long *) addr)
#if 0
#endif
extern void *shared_page;
extern FILE *logfile;
#ifdef __BIGENDIAN__
typedef union RedirStatus
{
    uint64_t value;
    struct {
        uint8_t dest_id;
        uint8_t reserved[4];
        uint8_t reserve:7;
        uint8_t mask:1;         /* interrupt mask*/
        uint8_t trigmod:1;
        uint8_t remoteirr:1;
        uint8_t polarity:1;
        uint8_t delivestatus:1;
        uint8_t destmode:1;
        uint8_t deliver_mode:3;
        uint8_t vector;
    }RedirForm;
}RedirStatus;
#else
typedef union RedirStatus
{
    uint64_t value;
    struct {
        uint8_t vector;
        uint8_t deliver_mode:3;
        uint8_t destmode:1;
        uint8_t delivestatus:1;
        uint8_t polarity:1;
        uint8_t remoteirr:1;
        uint8_t trigmod:1;
        uint8_t mask:1;         /* interrupt mask*/
        uint8_t reserve:7;
        uint8_t reserved[4];
        uint8_t dest_id;
    }RedirForm;
}RedirStatus;
#endif
/*
 * IOAPICState stands for a instance of a IOAPIC
 */

/* FIXME tmp before working with Local APIC */
#define IOAPIC_MEM_LENGTH 0x100
#define IOAPIC_ENABLE_MASK 0x0
#define IOAPIC_ENABLE_FLAG (1 << IOAPIC_ENABLE_MASK)
#define MAX_LAPIC_NUM 32

struct IOAPICState{
    uint32_t INTR;
    uint32_t id;
    uint32_t arb_id;
    uint32_t  flags;
    unsigned long base_address;
    uint32_t irr;
    uint32_t isr;           /* This is used for level trigger */
    uint8_t  vector_irr[256];
    RedirStatus redirtbl[IOAPIC_NUM_PINS];
    uint32_t ioregsel;
    uint32_t lapic_count;
    vlapic_info *lapic_info[MAX_LAPIC_NUM];
};
#define IOAPIC_REG_APIC_ID 0x0
#define IOAPIC_REG_VERSION 0x1
#define IOAPIC_REG_ARB_ID  0x2
#define IOAPICEnabled(s) (s->flags & IOAPIC_ENABLE_FLAG)

typedef struct IOAPICState IOAPICState;

#endif