source: trunk/hal/x86_64/core/hal_lapic.h @ 81

Last change on this file since 81 was 80, checked in by max@…, 7 years ago

add the timer vector, for now it double-faults

File size: 4.6 KB
Line 
1/*
2 * hal_lapic.h - Local APIC values
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22uint32_t hal_lapic_gid();
23void hal_lapic_init();
24
25#define LAPIC_SPURIOUS_VECTOR   LAPICVEC_MIN
26#define LAPIC_TIMER_VECTOR      (LAPICVEC_MIN + 1)
27
28#define LAPIC_ID                0x020   /* ID. RW */
29#       define LAPIC_ID_MASK            0xff000000
30#       define LAPIC_ID_SHIFT           24
31
32#define LAPIC_VERS              0x030   /* Version. RO */
33#       define LAPIC_VERSION_MASK       0x000000ff
34#       define LAPIC_VERSION_LVT_MASK   0x00ff0000
35#       define LAPIC_VERSION_LVT_SHIFT  16
36#       define LAPIC_VERSION_DIRECTED_EOI 0x01000000
37#       define LAPIC_VERSION_EXTAPIC_SPACE 0x80000000
38
39#define LAPIC_TPR               0x080   /* Task Prio. RW */
40#       define LAPIC_TPR_MASK           0x000000ff
41#       define LAPIC_TPR_INT_MASK       0x000000f0
42#       define LAPIC_TPR_SUB_MASK       0x0000000f
43
44#define LAPIC_APRI              0x090   /* Arbitration prio. RO */
45#       define LAPIC_APRI_MASK          0x000000ff
46
47#define LAPIC_PPRI              0x0a0   /* Processor prio. RO */
48#define LAPIC_EOI               0x0b0   /* End Int. W */
49#define LAPIC_RRR               0x0c0   /* Remote read. RO */
50#define LAPIC_LDR               0x0d0   /* Logical dest. RW */
51
52#define LAPIC_DFR               0x0e0   /* Dest. format. RW */
53#       define LAPIC_DFR_MASK           0xf0000000
54#       define LAPIC_DFR_FLAT           0xf0000000
55#       define LAPIC_DFR_CLUSTER        0x00000000
56
57#define LAPIC_SVR               0x0f0   /* Spurious intvec. RW */
58#       define LAPIC_SVR_VECTOR_MASK    0x000000ff
59#       define LAPIC_SVR_VEC_FIX        0x0000000f
60#       define LAPIC_SVR_VEC_PROG       0x000000f0
61#       define LAPIC_SVR_ENABLE         0x00000100
62#       define LAPIC_SVR_FOCUS          0x00000200
63#       define LAPIC_SVR_FDIS           0x00000200
64#       define LAPIC_SVR_EOI_BC_DIS     0x00001000
65
66#define LAPIC_ISR       0x100           /* In-Service Status RO */
67#define LAPIC_TMR       0x180           /* Trigger Mode RO */
68#define LAPIC_IRR       0x200           /* Interrupt Req RO */
69#define LAPIC_ESR       0x280           /* Err status. RW */
70
71#define LAPIC_LVT_CMCI  0x2f0           /* LVT CMCI RW */
72
73#define LAPIC_ICRLO     0x300           /* Int. cmd. RW */
74#       define LAPIC_DLMODE_MASK        0x00000700      /* Delivery Mode */
75#       define LAPIC_DLMODE_FIXED       0x00000000
76#       define LAPIC_DLMODE_LOW         0x00000100
77#       define LAPIC_DLMODE_SMI         0x00000200
78#       define LAPIC_DLMODE_NMI         0x00000400
79#       define LAPIC_DLMODE_INIT        0x00000500
80#       define LAPIC_DLMODE_STARTUP     0x00000600
81#       define LAPIC_DLMODE_EXTINT      0x00000700
82
83#       define LAPIC_DSTMODE_PHYS       0x00000000
84#       define LAPIC_DSTMODE_LOG        0x00000800
85
86#       define LAPIC_DLSTAT_BUSY        0x00001000
87#       define LAPIC_DLSTAT_IDLE        0x00000000
88
89#       define LAPIC_LEVEL_MASK         0x00004000
90#       define LAPIC_LEVEL_ASSERT       0x00004000
91#       define LAPIC_LEVEL_DEASSERT     0x00000000
92
93#       define LAPIC_TRIGGER_MASK       0x00008000
94#       define LAPIC_TRIGGER_EDGE       0x00000000
95#       define LAPIC_TRIGGER_LEVEL      0x00008000
96
97#       define LAPIC_DEST_MASK          0x000c0000
98#       define LAPIC_DEST_DEFAULT       0x00000000
99#       define LAPIC_DEST_SELF          0x00040000
100#       define LAPIC_DEST_ALLINCL       0x00080000
101#       define LAPIC_DEST_ALLEXCL       0x000c0000
102
103#define LAPIC_ICRHI     0x310           /* Int. cmd. RW */
104
105#define LAPIC_LVTT      0x320           /* Loc.vec.(timer) RW */
106#       define LAPIC_LVTT_VEC_MASK      0x000000ff
107#       define LAPIC_LVTT_DS            0x00001000
108#       define LAPIC_LVTT_M             0x00010000
109#       define LAPIC_LVTT_TM            0x00020000
110
111#define LAPIC_TMINT     0x330           /* Loc.vec (Thermal) RW */
112#define LAPIC_PCINT     0x340           /* Loc.vec (Perf Mon) RW */
113#define LAPIC_LVINT0    0x350           /* Loc.vec (LINT0) RW */
114#       define LAPIC_LVT_DM_MASK        0x00000700
115#       define LAPIC_LVT_DM_FIXED       0x00000000
116#       define LAPIC_LVT_DM_SMI         0x00000200
117#       define LAPIC_LVT_DM_NMI         0x00000400
118#       define LAPIC_LVT_DM_INIT        0x00000500
119#       define LAPIC_LVT_DM_EXTINT      0x00000700
120#       define LAPIC_LVT_MASKED         0x00010000
121#       define LAPIC_LVT_LEVTRIG        0x00008000
122#       define LAPIC_LVT_REMOTE_IRR     0x00004000
123#       define LAPIC_INP_POL            0x00002000
124#       define LAPIC_PEND_SEND          0x00001000
125
126#define LAPIC_LVINT1    0x360           /* Loc.vec (LINT1) RW */
127#define LAPIC_LVERR     0x370           /* Loc.vec (ERROR) RW */
128#define LAPIC_ICR_TIMER 0x380           /* Initial count RW */
129#define LAPIC_CCR_TIMER 0x390           /* Current count RO */
130
131#define LAPIC_DCR_TIMER 0x3e0           /* Divisor config RW */
132#       define LAPIC_DCRT_DIV1          0x0b
133#       define LAPIC_DCRT_DIV2          0x00
134#       define LAPIC_DCRT_DIV4          0x01
135#       define LAPIC_DCRT_DIV8          0x02
136#       define LAPIC_DCRT_DIV16         0x03
137#       define LAPIC_DCRT_DIV32         0x08
138#       define LAPIC_DCRT_DIV64         0x09
139#       define LAPIC_DCRT_DIV128        0x0a
140
Note: See TracBrowser for help on using the repository browser.