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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
//**********************************************************************
//**********************************************************************
//** **
//** (C)Copyright 1985-2013, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SB Protocols/SbHpet.h 1 11/19/13 7:27a Barretlin $
//
// $Revision: 1 $
//
// $Date: 11/19/13 7:27a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Chipset/SB Protocols/SbHpet.h $
//
// 1 11/19/13 7:27a Barretlin
// [TAG] EIP141917
// [Category] New Feature
// [Description] Support SetTimer() with HPET Timer on Lynx Point
// [Files] SB.sdl SBGeneric.c SBDxe.c SbHpet.h SamrtTimer.sdl
//
// 6 1/13/10 2:13p Felixp
//
//**********************************************************************
//<AMI_FHDR_START>
//
// Name: SbHPET.h
//
// Description: High Precision Event Timer register definitions.
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef __SB_HPET__H__
#define __SB_HPET__H__
#ifdef __cplusplus
extern "C" {
#endif
#include <Efi.h>
//----------------------------------------------------------------------------
// High Precision Event Timer Registers
//----------------------------------------------------------------------------
// HPET General Register Offsets
#define HPET_GENERAL_CAPABILITIES_ID_OFFSET 0x000
#define HPET_GENERAL_CONFIGURATION_OFFSET 0x010
#define HPET_GENERAL_INTERRUPT_STATUS_OFFSET 0x020
// HPET Timer Register Offsets
#define HPET_MAIN_COUNTER_OFFSET 0x0F0
#define HPET_TIMER_CONFIGURATION_OFFSET 0x100
#define HPET_TIMER_COMPARATOR_OFFSET 0x108
#define HPET_TIMER_MSI_ROUTE_OFFSET 0x110
// Stride between sets of HPET Timer Registers
#define HPET_TIMER_STRIDE 0x020
#pragma pack(push,1)
// HPET General Capabilities and ID Register
typedef union {
struct {
UINT32 Revision:8;
UINT32 NumberOfTimers:5;
UINT32 CounterSize:1;
UINT32 Reserved0:1;
UINT32 LegacyRoute:1;
UINT32 VendorId:16;
UINT32 CounterClockPeriod:32;
} Bits;
UINT64 Uint64;
} HPET_GENERAL_CAPABILITIES_ID_REGISTER;
// HPET General Configuration Register
typedef union {
struct {
UINT32 MainCounterEnable:1;
UINT32 LegacyRouteEnable:1;
UINT32 Reserved0:30;
UINT32 Reserved1:32;
} Bits;
UINT64 Uint64;
} HPET_GENERAL_CONFIGURATION_REGISTER;
// HPET General Interrupt Status Register
typedef union {
struct {
UINT32 Timer0InterruptActive:1;
UINT32 Timer1InterruptActive:1;
UINT32 Timer2InterruptActive:1;
UINT32 Reserved0:29;
UINT32 Reserved1:32;
} Bits;
UINT64 Uint64;
} HPET_GENERAL_INTERRUPT_STATUS_REGISTER;
// HPET Timer Configuration Register
typedef union {
struct {
UINT32 Reserved0:1;
UINT32 LevelTriggeredInterrupt:1;
UINT32 InterruptEnable:1;
UINT32 PeriodicInterruptEnable:1;
UINT32 PeriodicInterruptCapablity:1;
UINT32 CounterSizeCapablity:1;
UINT32 ValueSetEnable:1;
UINT32 Reserved1:1;
UINT32 CounterSizeEnable:1;
UINT32 InterruptRoute:5;
UINT32 MsiInterruptEnable:1;
UINT32 MsiInterruptCapablity:1;
UINT32 Reserved2:16;
UINT32 InterruptRouteCapability;
} Bits;
UINT64 Uint64;
} HPET_TIMER_CONFIGURATION_REGISTER;
// HPET Timer MSI Route Register
typedef union {
struct {
UINT32 Value:32;
UINT32 Address:32;
} Bits;
UINT64 Uint64;
} HPET_TIMER_MSI_ROUTE_REGISTER;
#if defined(HPET_APIC_INTERRUPT_MODE) && (HPET_APIC_INTERRUPT_MODE != 0)
//-------------------------
// HPET APIC Support
//-------------------------
#define IO_APIC_REDIR_TABLE_LOW 0x10 // Reditection Table Low 32 bits.
#define IO_APIC_REDIR_TABLE_HIGH 0x11 // Reditection Table High 32 bits.
#define APIC_EOI_REGISTER 0xB0
#define APIC_PPR_REGISTER 0xA0
#define APIC_APR_REGISTER 0x90
#define APIC_ISR_REGISTER 0x100
#define ISR_REG(v) (APIC_ISR_REGISTER + (v / 32) * 0x10)
#define ISR_BIT(v) (UINT32) (1 << (v % 32))
struct IO_APIC {
UINT8 Index;
UINT8 Unused[3];
UINT32 Unused1[3];
UINT32 Data;
UINT32 Unused2[11];
UINT32 Eoi;
};
typedef struct {
UINT32 Vector : 8,
DeliveryMode : 3,
DestMode : 1,
DeliveryStatus : 1,
Polarity : 1,
Irr : 1,
Trigger : 1,
Mask : 1,
__Reserved_2 : 15;
UINT32 __Reserved_3 : 24,
Dest : 8;
} IO_APIC_ROUTE_ENTRY;
union ENTRY_UNION {
struct { UINT32 W1, W2; };
IO_APIC_ROUTE_ENTRY Entry;
};
//---------------------------------------------------------------------------
struct IO_APIC* IoApicBase( VOID );
EFI_STATUS IoApicWrite (
IN UINT8 Reg,
IN UINT32 Value
);
UINT32 IoApicRead(
IN UINT8 Reg
);
EFI_STATUS IoApicEnableIrq (
IN UINT8 Irq,
IN BOOLEAN LevelTriggered,
IN BOOLEAN Polarity
);
EFI_STATUS
IoApicDisableIrq (
IN UINT8 Irq
);
EFI_STATUS IoApicEoi (
IN UINT8 Irq
);
EFI_STATUS IoApicMaskIrq (
IN UINT8 Irq
);
EFI_STATUS IoApicUnmaskIrq (
IN UINT8 Irq
);
UINT8 GetHpetApicPin ( VOID );
BOOLEAN IsHpetApicEnable ( VOID );
#endif
#pragma pack(pop)
/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif
#endif
//**********************************************************************
//**********************************************************************
//** **
//** (C)Copyright 1985-2013, American Megatrends, Inc. **
//** **
//** All Rights Reserved. **
//** **
//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
//** **
//** Phone: (770)-246-8600 **
//** **
//**********************************************************************
//**********************************************************************
|