]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
3f566587 | 2 | IA-32/x64 MSR functions.\r |
878ddf1f | 3 | \r |
4 | Copyright (c) 2006, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
3f566587 | 13 | Module Name: x86Msr.c\r |
878ddf1f | 14 | \r |
15 | **/\r | |
16 | \r | |
3f566587 | 17 | /**\r |
18 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
19 | \r | |
20 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
21 | No parameter checking is performed on Index, and some Index values may cause\r | |
22 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
23 | caller must set up exception handlers to catch the exceptions. This function\r | |
24 | is only available on IA-32 and X64.\r | |
25 | \r | |
26 | @param Index The 32-bit MSR index to read.\r | |
878ddf1f | 27 | \r |
3f566587 | 28 | @return The lower 32 bits of the MSR identified by Index.\r |
29 | \r | |
30 | **/\r | |
31 | UINT32\r | |
32 | EFIAPI\r | |
33 | AsmReadMsr32 (\r | |
34 | IN UINT32 Index\r | |
35 | )\r | |
36 | {\r | |
37 | return (UINT32)AsmReadMsr64 (Index);\r | |
38 | }\r | |
39 | \r | |
40 | /**\r | |
41 | Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r | |
42 | \r | |
43 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
44 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
45 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
46 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
47 | that Index and Value are valid, or the caller must establish proper exception\r | |
48 | handlers. This function is only available on IA-32 and X64.\r | |
49 | \r | |
50 | @param Index The 32-bit MSR index to write.\r | |
51 | @param Value The 32-bit value to write to the MSR.\r | |
52 | \r | |
53 | @return Value\r | |
54 | \r | |
55 | **/\r | |
56 | UINT32\r | |
57 | EFIAPI\r | |
58 | AsmWriteMsr32 (\r | |
59 | IN UINT32 Index,\r | |
60 | IN UINT32 Value\r | |
61 | )\r | |
62 | {\r | |
63 | return (UINT32)AsmWriteMsr64 (Index, Value);\r | |
64 | }\r | |
878ddf1f | 65 | \r |
66 | /**\r | |
67 | Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r | |
68 | writes the result back to the 64-bit MSR.\r | |
69 | \r | |
70 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
71 | between the lower 32-bits of the read result and the value specified by\r | |
72 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
73 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
74 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
75 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
76 | must establish proper exception handlers. This function is only available on\r | |
77 | IA-32 and X64.\r | |
78 | \r | |
79 | @param Index The 32-bit MSR index to write.\r | |
80 | @param OrData The value to OR with the read value from the MSR.\r | |
81 | \r | |
82 | @return The lower 32-bit value written to the MSR.\r | |
83 | \r | |
84 | **/\r | |
85 | UINT32\r | |
86 | EFIAPI\r | |
87 | AsmMsrOr32 (\r | |
88 | IN UINT32 Index,\r | |
89 | IN UINT32 OrData\r | |
90 | )\r | |
91 | {\r | |
92 | return (UINT32)AsmMsrOr64 (Index, OrData);\r | |
93 | }\r | |
94 | \r | |
95 | /**\r | |
96 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
97 | the result back to the 64-bit MSR.\r | |
98 | \r | |
99 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
100 | lower 32-bits of the read result and the value specified by AndData, and\r | |
101 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
102 | the value written to the MSR is returned. No parameter checking is performed\r | |
103 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
104 | must either guarantee that Index and AndData are valid, or the caller must\r | |
105 | establish proper exception handlers. This function is only available on IA-32\r | |
106 | and X64.\r | |
107 | \r | |
108 | @param Index The 32-bit MSR index to write.\r | |
109 | @param AndData The value to AND with the read value from the MSR.\r | |
110 | \r | |
111 | @return The lower 32-bit value written to the MSR.\r | |
112 | \r | |
113 | **/\r | |
114 | UINT32\r | |
115 | EFIAPI\r | |
116 | AsmMsrAnd32 (\r | |
117 | IN UINT32 Index,\r | |
118 | IN UINT32 AndData\r | |
119 | )\r | |
120 | {\r | |
121 | return (UINT32)AsmMsrAnd64 (Index, AndData);\r | |
122 | }\r | |
123 | \r | |
124 | /**\r | |
125 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r | |
126 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r | |
127 | \r | |
128 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
129 | lower 32-bits of the read result and the value specified by AndData\r | |
130 | preserving the upper 32-bits, performs a bitwise inclusive OR between the\r | |
131 | result of the AND operation and the value specified by OrData, and writes the\r | |
132 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
133 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
134 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
135 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
136 | caller must establish proper exception handlers. This function is only\r | |
137 | available on IA-32 and X64.\r | |
138 | \r | |
139 | @param Index The 32-bit MSR index to write.\r | |
140 | @param AndData The value to AND with the read value from the MSR.\r | |
141 | @param OrData The value to OR with the result of the AND operation.\r | |
142 | \r | |
143 | @return The lower 32-bit value written to the MSR.\r | |
144 | \r | |
145 | **/\r | |
146 | UINT32\r | |
147 | EFIAPI\r | |
148 | AsmMsrAndThenOr32 (\r | |
149 | IN UINT32 Index,\r | |
150 | IN UINT32 AndData,\r | |
151 | IN UINT32 OrData\r | |
152 | )\r | |
153 | {\r | |
154 | return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData);\r | |
155 | }\r | |
156 | \r | |
157 | /**\r | |
158 | Reads a bit field of an MSR.\r | |
159 | \r | |
160 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
161 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
162 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
163 | must set up exception handlers to catch the exceptions. This function is only\r | |
164 | available on IA-32 and X64.\r | |
165 | \r | |
166 | If StartBit is greater than 31, then ASSERT().\r | |
167 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 168 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 169 | \r |
170 | @param Index The 32-bit MSR index to read.\r | |
171 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
172 | Range 0..31.\r | |
173 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
174 | Range 0..31.\r | |
175 | \r | |
176 | @return The bit field read from the MSR.\r | |
177 | \r | |
178 | **/\r | |
179 | UINT32\r | |
180 | EFIAPI\r | |
181 | AsmMsrBitFieldRead32 (\r | |
182 | IN UINT32 Index,\r | |
183 | IN UINTN StartBit,\r | |
184 | IN UINTN EndBit\r | |
185 | )\r | |
186 | {\r | |
187 | return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit);\r | |
188 | }\r | |
189 | \r | |
190 | /**\r | |
191 | Writes a bit field to an MSR.\r | |
192 | \r | |
193 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r | |
194 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
195 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
196 | returned. Extra left bits in Value are stripped. The caller must either\r | |
197 | guarantee that Index and the data written is valid, or the caller must set up\r | |
198 | exception handlers to catch the exceptions. This function is only available\r | |
199 | on IA-32 and X64.\r | |
200 | \r | |
201 | If StartBit is greater than 31, then ASSERT().\r | |
202 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 203 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 204 | \r |
205 | @param Index The 32-bit MSR index to write.\r | |
206 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
207 | Range 0..31.\r | |
208 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
209 | Range 0..31.\r | |
210 | @param Value New value of the bit field.\r | |
211 | \r | |
212 | @return The lower 32-bit of the value written to the MSR.\r | |
213 | \r | |
214 | **/\r | |
215 | UINT32\r | |
216 | EFIAPI\r | |
217 | AsmMsrBitFieldWrite32 (\r | |
218 | IN UINT32 Index,\r | |
219 | IN UINTN StartBit,\r | |
220 | IN UINTN EndBit,\r | |
221 | IN UINT32 Value\r | |
222 | )\r | |
223 | {\r | |
224 | ASSERT (EndBit < sizeof (Value) * 8);\r | |
225 | ASSERT (StartBit <= EndBit);\r | |
226 | return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value);\r | |
227 | }\r | |
228 | \r | |
229 | /**\r | |
230 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
231 | result back to the bit field in the 64-bit MSR.\r | |
232 | \r | |
233 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
234 | between the read result and the value specified by OrData, and writes the\r | |
235 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
236 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
237 | caller must either guarantee that Index and the data written is valid, or\r | |
238 | the caller must set up exception handlers to catch the exceptions. This\r | |
239 | function is only available on IA-32 and X64.\r | |
240 | \r | |
241 | If StartBit is greater than 31, then ASSERT().\r | |
242 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 243 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 244 | \r |
245 | @param Index The 32-bit MSR index to write.\r | |
246 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
247 | Range 0..31.\r | |
248 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
249 | Range 0..31.\r | |
250 | @param OrData The value to OR with the read value from the MSR.\r | |
251 | \r | |
252 | @return The lower 32-bit of the value written to the MSR.\r | |
253 | \r | |
254 | **/\r | |
255 | UINT32\r | |
256 | EFIAPI\r | |
257 | AsmMsrBitFieldOr32 (\r | |
258 | IN UINT32 Index,\r | |
259 | IN UINTN StartBit,\r | |
260 | IN UINTN EndBit,\r | |
261 | IN UINT32 OrData\r | |
262 | )\r | |
263 | {\r | |
264 | ASSERT (EndBit < sizeof (OrData) * 8);\r | |
265 | ASSERT (StartBit <= EndBit);\r | |
266 | return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData);\r | |
267 | }\r | |
268 | \r | |
269 | /**\r | |
270 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
271 | result back to the bit field in the 64-bit MSR.\r | |
272 | \r | |
273 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
274 | read result and the value specified by AndData, and writes the result to the\r | |
275 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
276 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
277 | either guarantee that Index and the data written is valid, or the caller must\r | |
278 | set up exception handlers to catch the exceptions. This function is only\r | |
279 | available on IA-32 and X64.\r | |
280 | \r | |
281 | If StartBit is greater than 31, then ASSERT().\r | |
282 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 283 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 284 | \r |
285 | @param Index The 32-bit MSR index to write.\r | |
286 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
287 | Range 0..31.\r | |
288 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
289 | Range 0..31.\r | |
290 | @param AndData The value to AND with the read value from the MSR.\r | |
291 | \r | |
292 | @return The lower 32-bit of the value written to the MSR.\r | |
293 | \r | |
294 | **/\r | |
295 | UINT32\r | |
296 | EFIAPI\r | |
297 | AsmMsrBitFieldAnd32 (\r | |
298 | IN UINT32 Index,\r | |
299 | IN UINTN StartBit,\r | |
300 | IN UINTN EndBit,\r | |
301 | IN UINT32 AndData\r | |
302 | )\r | |
303 | {\r | |
304 | ASSERT (EndBit < sizeof (AndData) * 8);\r | |
305 | ASSERT (StartBit <= EndBit);\r | |
306 | return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData);\r | |
307 | }\r | |
308 | \r | |
309 | /**\r | |
310 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
311 | bitwise inclusive OR, and writes the result back to the bit field in the\r | |
312 | 64-bit MSR.\r | |
313 | \r | |
314 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
315 | bitwise inclusive OR between the read result and the value specified by\r | |
316 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r | |
317 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
318 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
319 | that Index and the data written is valid, or the caller must set up exception\r | |
320 | handlers to catch the exceptions. This function is only available on IA-32\r | |
321 | and X64.\r | |
322 | \r | |
323 | If StartBit is greater than 31, then ASSERT().\r | |
324 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 325 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 326 | \r |
327 | @param Index The 32-bit MSR index to write.\r | |
328 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
329 | Range 0..31.\r | |
330 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
331 | Range 0..31.\r | |
332 | @param AndData The value to AND with the read value from the MSR.\r | |
333 | @param OrData The value to OR with the result of the AND operation.\r | |
334 | \r | |
335 | @return The lower 32-bit of the value written to the MSR.\r | |
336 | \r | |
337 | **/\r | |
338 | UINT32\r | |
339 | EFIAPI\r | |
340 | AsmMsrBitFieldAndThenOr32 (\r | |
341 | IN UINT32 Index,\r | |
342 | IN UINTN StartBit,\r | |
343 | IN UINTN EndBit,\r | |
344 | IN UINT32 AndData,\r | |
345 | IN UINT32 OrData\r | |
346 | )\r | |
347 | {\r | |
348 | ASSERT (EndBit < sizeof (AndData) * 8);\r | |
349 | ASSERT (StartBit <= EndBit);\r | |
350 | return (UINT32)AsmMsrBitFieldAndThenOr64 (\r | |
351 | Index,\r | |
352 | StartBit,\r | |
353 | EndBit,\r | |
354 | AndData,\r | |
355 | OrData\r | |
356 | );\r | |
357 | }\r | |
358 | \r | |
359 | /**\r | |
360 | Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r | |
361 | back to the 64-bit MSR.\r | |
362 | \r | |
363 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
364 | between the read result and the value specified by OrData, and writes the\r | |
365 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
366 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
367 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
368 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
369 | This function is only available on IA-32 and X64.\r | |
370 | \r | |
371 | @param Index The 32-bit MSR index to write.\r | |
372 | @param OrData The value to OR with the read value from the MSR.\r | |
373 | \r | |
374 | @return The value written back to the MSR.\r | |
375 | \r | |
376 | **/\r | |
377 | UINT64\r | |
378 | EFIAPI\r | |
379 | AsmMsrOr64 (\r | |
380 | IN UINT32 Index,\r | |
381 | IN UINT64 OrData\r | |
382 | )\r | |
383 | {\r | |
384 | return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData);\r | |
385 | }\r | |
386 | \r | |
387 | /**\r | |
388 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
389 | 64-bit MSR.\r | |
390 | \r | |
391 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
392 | read result and the value specified by OrData, and writes the result to the\r | |
393 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
394 | parameter checking is performed on Index or OrData, and some of these may\r | |
395 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
396 | are valid, or the caller must establish proper exception handlers. This\r | |
397 | function is only available on IA-32 and X64.\r | |
398 | \r | |
399 | @param Index The 32-bit MSR index to write.\r | |
400 | @param AndData The value to AND with the read value from the MSR.\r | |
401 | \r | |
402 | @return The value written back to the MSR.\r | |
403 | \r | |
404 | **/\r | |
405 | UINT64\r | |
406 | EFIAPI\r | |
407 | AsmMsrAnd64 (\r | |
408 | IN UINT32 Index,\r | |
409 | IN UINT64 AndData\r | |
410 | )\r | |
411 | {\r | |
412 | return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData);\r | |
413 | }\r | |
414 | \r | |
415 | /**\r | |
416 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r | |
417 | OR, and writes the result back to the 64-bit MSR.\r | |
418 | \r | |
419 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
420 | result and the value specified by AndData, performs a bitwise inclusive OR\r | |
421 | between the result of the AND operation and the value specified by OrData,\r | |
422 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
423 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
424 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
425 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
426 | establish proper exception handlers. This function is only available on IA-32\r | |
427 | and X64.\r | |
428 | \r | |
429 | @param Index The 32-bit MSR index to write.\r | |
430 | @param AndData The value to AND with the read value from the MSR.\r | |
431 | @param OrData The value to OR with the result of the AND operation.\r | |
432 | \r | |
433 | @return The value written back to the MSR.\r | |
434 | \r | |
435 | **/\r | |
436 | UINT64\r | |
437 | EFIAPI\r | |
438 | AsmMsrAndThenOr64 (\r | |
439 | IN UINT32 Index,\r | |
440 | IN UINT64 AndData,\r | |
441 | IN UINT64 OrData\r | |
442 | )\r | |
443 | {\r | |
444 | return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData);\r | |
445 | }\r | |
446 | \r | |
447 | /**\r | |
448 | Reads a bit field of an MSR.\r | |
449 | \r | |
450 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
451 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
452 | must either guarantee that Index is valid, or the caller must set up\r | |
453 | exception handlers to catch the exceptions. This function is only available\r | |
454 | on IA-32 and X64.\r | |
455 | \r | |
456 | If StartBit is greater than 63, then ASSERT().\r | |
457 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 458 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 459 | \r |
460 | @param Index The 32-bit MSR index to read.\r | |
461 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
462 | Range 0..63.\r | |
463 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
464 | Range 0..63.\r | |
465 | \r | |
466 | @return The value written back to the MSR.\r | |
467 | \r | |
468 | **/\r | |
469 | UINT64\r | |
470 | EFIAPI\r | |
471 | AsmMsrBitFieldRead64 (\r | |
472 | IN UINT32 Index,\r | |
473 | IN UINTN StartBit,\r | |
474 | IN UINTN EndBit\r | |
475 | )\r | |
476 | {\r | |
477 | return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit);\r | |
478 | }\r | |
479 | \r | |
480 | /**\r | |
481 | Writes a bit field to an MSR.\r | |
482 | \r | |
483 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
484 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
485 | preserved. The MSR written is returned. Extra left bits in Value are\r | |
486 | stripped. The caller must either guarantee that Index and the data written is\r | |
487 | valid, or the caller must set up exception handlers to catch the exceptions.\r | |
488 | This function is only available on IA-32 and X64.\r | |
489 | \r | |
490 | If StartBit is greater than 63, then ASSERT().\r | |
491 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 492 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 493 | \r |
494 | @param Index The 32-bit MSR index to write.\r | |
495 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
496 | Range 0..63.\r | |
497 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
498 | Range 0..63.\r | |
499 | @param Value New value of the bit field.\r | |
500 | \r | |
501 | @return The value written back to the MSR.\r | |
502 | \r | |
503 | **/\r | |
504 | UINT64\r | |
505 | EFIAPI\r | |
506 | AsmMsrBitFieldWrite64 (\r | |
507 | IN UINT32 Index,\r | |
508 | IN UINTN StartBit,\r | |
509 | IN UINTN EndBit,\r | |
510 | IN UINT64 Value\r | |
511 | )\r | |
512 | {\r | |
513 | return AsmWriteMsr64 (\r | |
514 | Index,\r | |
515 | BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value)\r | |
516 | );\r | |
517 | }\r | |
518 | \r | |
519 | /**\r | |
520 | Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r | |
521 | writes the result back to the bit field in the 64-bit MSR.\r | |
522 | \r | |
523 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
524 | between the read result and the value specified by OrData, and writes the\r | |
525 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
526 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
527 | guarantee that Index and the data written is valid, or the caller must set up\r | |
528 | exception handlers to catch the exceptions. This function is only available\r | |
529 | on IA-32 and X64.\r | |
530 | \r | |
531 | If StartBit is greater than 63, then ASSERT().\r | |
532 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 533 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 534 | \r |
535 | @param Index The 32-bit MSR index to write.\r | |
536 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
537 | Range 0..63.\r | |
538 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
539 | Range 0..63.\r | |
540 | @param OrData The value to OR with the read value from the bit field.\r | |
541 | \r | |
542 | @return The value written back to the MSR.\r | |
543 | \r | |
544 | **/\r | |
545 | UINT64\r | |
546 | EFIAPI\r | |
547 | AsmMsrBitFieldOr64 (\r | |
548 | IN UINT32 Index,\r | |
549 | IN UINTN StartBit,\r | |
550 | IN UINTN EndBit,\r | |
551 | IN UINT64 OrData\r | |
552 | )\r | |
553 | {\r | |
554 | return AsmWriteMsr64 (\r | |
555 | Index,\r | |
556 | BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData)\r | |
557 | );\r | |
558 | }\r | |
559 | \r | |
560 | /**\r | |
561 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
562 | result back to the bit field in the 64-bit MSR.\r | |
563 | \r | |
564 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
565 | read result and the value specified by AndData, and writes the result to the\r | |
566 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
567 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
568 | that Index and the data written is valid, or the caller must set up exception\r | |
569 | handlers to catch the exceptions. This function is only available on IA-32\r | |
570 | and X64.\r | |
571 | \r | |
572 | If StartBit is greater than 63, then ASSERT().\r | |
573 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 574 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 575 | \r |
576 | @param Index The 32-bit MSR index to write.\r | |
577 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
578 | Range 0..63.\r | |
579 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
580 | Range 0..63.\r | |
581 | @param AndData The value to AND with the read value from the bit field.\r | |
582 | \r | |
583 | @return The value written back to the MSR.\r | |
584 | \r | |
585 | **/\r | |
586 | UINT64\r | |
587 | EFIAPI\r | |
588 | AsmMsrBitFieldAnd64 (\r | |
589 | IN UINT32 Index,\r | |
590 | IN UINTN StartBit,\r | |
591 | IN UINTN EndBit,\r | |
592 | IN UINT64 AndData\r | |
593 | )\r | |
594 | {\r | |
595 | return AsmWriteMsr64 (\r | |
596 | Index,\r | |
597 | BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData)\r | |
598 | );\r | |
599 | }\r | |
600 | \r | |
601 | /**\r | |
602 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
603 | bitwise inclusive OR, and writes the result back to the bit field in the\r | |
604 | 64-bit MSR.\r | |
605 | \r | |
606 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
607 | a bitwise inclusive OR between the read result and the value specified by\r | |
608 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r | |
609 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
610 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
611 | written is valid, or the caller must set up exception handlers to catch the\r | |
612 | exceptions. This function is only available on IA-32 and X64.\r | |
613 | \r | |
614 | If StartBit is greater than 63, then ASSERT().\r | |
615 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 616 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 617 | \r |
618 | @param Index The 32-bit MSR index to write.\r | |
619 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
620 | Range 0..63.\r | |
621 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
622 | Range 0..63.\r | |
623 | @param AndData The value to AND with the read value from the bit field.\r | |
624 | @param OrData The value to OR with the result of the AND operation.\r | |
625 | \r | |
626 | @return The value written back to the MSR.\r | |
627 | \r | |
628 | **/\r | |
629 | UINT64\r | |
630 | EFIAPI\r | |
631 | AsmMsrBitFieldAndThenOr64 (\r | |
632 | IN UINT32 Index,\r | |
633 | IN UINTN StartBit,\r | |
634 | IN UINTN EndBit,\r | |
635 | IN UINT64 AndData,\r | |
636 | IN UINT64 OrData\r | |
637 | )\r | |
638 | {\r | |
639 | return AsmWriteMsr64 (\r | |
640 | Index,\r | |
641 | BitFieldAndThenOr64 (\r | |
642 | AsmReadMsr64 (Index),\r | |
643 | StartBit,\r | |
644 | EndBit,\r | |
645 | AndData,\r | |
646 | OrData\r | |
647 | )\r | |
648 | );\r | |
649 | }\r |