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