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