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