Some changes required to get yabel working on v2 (and they generally make
[coreboot.git] / src / include / cpu / x86 / smm.h
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20
21 /* AMD64 SMM State-Save Area 
22  * starts @ 0x7e00
23  */
24 typedef struct {
25         u16     es_selector;
26         u16     es_attributes;
27         u32     es_limit;
28         u64     es_base;
29
30         u16     cs_selector;
31         u16     cs_attributcs;
32         u32     cs_limit;
33         u64     cs_base;
34
35         u16     ss_selector;
36         u16     ss_attributss;
37         u32     ss_limit;
38         u64     ss_base;
39
40         u16     ds_selector;
41         u16     ds_attributds;
42         u32     ds_limit;
43         u64     ds_base;
44
45         u16     fs_selector;
46         u16     fs_attributfs;
47         u32     fs_limit;
48         u64     fs_base;
49
50         u16     gs_selector;
51         u16     gs_attributgs;
52         u32     gs_limit;
53         u64     gs_base;
54
55         u8      reserved0[4];
56         u16     gdtr_limit;
57         u8      reserved1[2];
58         u64     gdtr_base;
59
60         u16     ldtr_selector;
61         u16     ldtr_attributes;
62         u32     ldtr_limit;
63         u64     ldtr_base;
64
65         u8      reserved2[4];
66         u16     idtr_limit;
67         u8      reserved3[2];
68         u64     idtr_base;
69
70         u16     tr_selector;
71         u16     tr_attributes;
72         u32     tr_limit;
73         u64     tr_base;
74
75         u8      reserved4[40];
76
77         u8      io_restart;
78         u8      autohalt_restart;
79
80         u8      reserved5[6];
81
82         u64     efer;
83
84         u8      reserved6[36];
85
86         u32     smm_revision;
87         u32     smbase;
88
89         u8      reserved7[68];
90
91         u64     cr4;
92         u64     cr3;
93         u64     cr0;
94         u64     dr7;
95         u64     dr6;
96
97         u64     rflags;
98         u64     rip;
99         u64     r15;
100         u64     r14;
101         u64     r13;
102         u64     r12;
103         u64     r11;
104         u64     r10;
105         u64     r9;
106         u64     r8;
107
108         u64     rdi;
109         u64     rsi;
110         u64     rpb;
111         u64     rsp;
112         u64     rbx;
113         u64     rdx;
114         u64     rcx;
115         u64     rax;
116 } __attribute__((packed)) amd64_smm_state_save_area_t;
117
118
119 /* Intel Core 2 (EM64T) SMM State-Save Area 
120  * starts @ 0x7d00
121  */
122 typedef struct {
123         u8      reserved0[208];
124
125         u32     gdtr_upper_base;
126         u32     ldtr_upper_base;
127         u32     idtr_upper_base;
128
129         u8      reserved1[4];
130
131         u64     io_rdi;
132         u64     io_rip;
133         u64     io_rcx;
134         u64     io_rsi;
135         u64     cr4;
136
137         u8      reserved2[68];
138
139         u64     gdtr_base;
140         u64     idtr_base;
141         u64     ldtr_base;
142
143         u8      reserved3[84];
144
145         u32     smm_revision;
146         u32     smbase;
147
148         u16     io_restart;
149         u16     autohalt_restart;
150
151         u8      reserved4[24];
152
153         u64     r15;
154         u64     r14;
155         u64     r13;
156         u64     r12;
157         u64     r11;
158         u64     r10;
159         u64     r9;
160         u64     r8;
161
162         u64     rax;
163         u64     rcx;
164         u64     rdx;
165         u64     rbx;
166
167         u64     rsp;
168         u64     rbp;
169         u64     rsi;
170         u64     rdi;
171
172
173         u64     io_mem_addr;
174         u32     io_misc_info;
175
176         u32     es_sel;
177         u32     cs_sel;
178         u32     ss_sel;
179         u32     ds_sel;
180         u32     fs_sel;
181         u32     gs_sel;
182
183         u32     ldtr_sel;
184         u32     tr_sel;
185
186         u64     dr7;
187         u64     dr6;
188         u64     rip;
189         u64     efer;
190         u64     rflags;
191
192         u64     cr3;
193         u64     cr0;
194 } __attribute__((packed)) em64t_smm_state_save_area_t;
195
196
197 /* Legacy x86 SMM State-Save Area 
198  * starts @ 0x7e00
199  */
200
201 typedef struct {
202         u8      reserved0[248];
203         u32     smbase;
204         u32     smm_revision;
205         u16     io_restart;
206         u16     autohalt_restart;
207         u8      reserved1[132];
208         u32     gdtbase;
209         u8      reserved2[8];
210         u32     idtbase;
211         u8      reserved3[16];
212         u32     es;
213         u32     cs;
214         u32     ss;
215         u32     ds;
216         u32     fs;
217         u32     gs;
218         u32     ldtbase;
219         u32     tr;
220         u32     dr7;
221         u32     dr6;
222         u32     eax;
223         u32     ecx;
224         u32     edx;
225         u32     ebx;
226         u32     esp;
227         u32     ebp;
228         u32     esi;
229         u32     edi;
230         u32     eip;
231         u32     eflags;
232         u32     cr3;
233         u32     cr0;
234 } __attribute__((packed)) legacy_smm_state_save_area_t;
235
236 typedef enum {
237         AMD64,
238         EM64T,
239         LEGACY
240 } save_state_type_t;
241
242
243 typedef struct {
244         save_state_type_t type;
245         union {
246         amd64_smm_state_save_area_t *amd64_state_save;
247         em64t_smm_state_save_area_t *em64t_state_save;
248         legacy_smm_state_save_area_t *legacy_state_save;
249         };
250 } smm_state_save_area_t;
251