Subversion Repositories HelenOS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 jermar 1
/*
2
 * Copyright (C) 2001-2004 Jakub Jermar
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
14
 * - The name of the author may not be used to endorse or promote products
15
 *   derived from this software without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
28
 
29
#ifndef __APIC_H__
30
#define __APIC_H__
31
 
32
#include <arch/types.h>
33
#include <cpu.h>
34
 
35
#define FIXED		(0<<0)
36
#define LOPRI		(1<<0)
37
 
38
/* local APIC macros */
39
#define IPI_INIT 	0
40
#define IPI_STARTUP	0
41
 
42
#define DLVRMODE_INIT	(5<<8)
43
#define DLVRMODE_STUP	(6<<8)
44
#define DESTMODE_PHYS	(0<<11)
45
#define DESTMODE_LOGIC	(1<<11)
46
#define LEVEL_ASSERT	(1<<14)
47
#define LEVEL_DEASSERT	(0<<14)
48
#define TRGRMODE_LEVEL	(1<<15)
49
#define TRGRMODE_EDGE	(0<<15)
50
#define SHORTHAND_DEST	(0<<18)
51
#define SHORTHAND_INCL	(2<<18)
52
#define SHORTHAND_EXCL	(3<<18)
53
 
54
#define SEND_PENDING	(1<<12)
55
 
56
/* Interrupt Command Register */
57
#define ICRlo		(0x300/sizeof(__u32))
58
#define ICRhi		(0x310/sizeof(__u32))
59
#define ICRloClear	((0xff<<0)|(1<<13)|(3<<16)|(0xfff<<20))
60
#define ICRhiClear	(0xffffff<<0)
61
 
62
/* End Of Interrupt */
63
#define EOI		(0x0b0/sizeof(__u32))
64
 
65
/* Error Status Register */
66
#define ESR		(0x280/sizeof(__u32))
67
#define ESRClear	((0xffffff<<8)|(1<<4))
68
 
69
/* Task Priority Register */
70
#define TPR		(0x080/sizeof(__u32))
71
#define TPRClear	0xffffff00
72
 
73
/* Spurious Vector Register */
74
#define SVR		(0x0f0/sizeof(__u32))
75
#define SVRClear	(~0x3f0)
76
 
77
/* Time Divide Configuratio Register */
78
#define TDCR		(0x3e0/sizeof(__u32))
79
#define TDCRClear	(~0xb)
80
 
81
/* Initial Count Register for Timer */
82
#define ICRT		(0x380/sizeof(__u32))
83
 
84
/* Current Count Register for Timer */
85
#define CCRT		(0x390/sizeof(__u32))
86
 
87
/* LVT */
88
#define LVT_Tm		(0x320/sizeof(__u32))
89
#define LVT_LINT0	(0x350/sizeof(__u32))
90
#define LVT_LINT1	(0x360/sizeof(__u32))
91
#define LVT_Err		(0x370/sizeof(__u32))
92
#define LVT_PCINT	(0x340/sizeof(__u32))
93
 
94
/* Local APIC ID Register */
95
#define L_APIC_ID	(0x020/sizeof(__u32))
96
#define L_APIC_IDClear	(~(0xf<<24))
97
 
98
/* IO APIC */
99
#define IOREGSEL	(0x00/sizeof(__u32))
100
#define IOWIN		(0x10/sizeof(__u32))
101
 
102
#define IOAPICID	0x00
103
#define IOAPICVER	0x01
104
#define IOAPICARB	0x02
105
#define IOREDTBL	0x10
106
 
107
 
108
extern volatile __u32 *l_apic;
109
extern volatile __u32 *io_apic;
110
 
111
extern __u32 apic_id_mask;
112
 
113
extern void apic_init(void);
114
extern void apic_spurious(__u8 n, __u32 stack[]);
115
 
116
extern void l_apic_init(void);
117
extern void l_apic_eoi(void);
118
extern int l_apic_send_init_ipi(__u8 apicid);
119
extern void l_apic_debug(void);
120
extern void l_apic_timer_interrupt(__u8 n, __u32 stack[]);
121
 
122
extern __u32 io_apic_read(__u8 address);
123
extern void io_apic_write(__u8 address , __u32 x);
124
extern void io_apic_change_ioredtbl(int signal, int dest, __u8 v, int flags);
125
extern void io_apic_disable_irqs(__u16 irqmask);
126
extern void io_apic_enable_irqs(__u16 irqmask);
127
 
128
#endif