Changeset f2cb80a in mainline for kernel/arch/amd64/include/arch/mm/pat.h
- Timestamp:
- 2024-02-23T17:57:23Z (11 months ago)
- Children:
- 192019f
- Parents:
- 86f862c (diff), 90ba06c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2024-02-23 17:57:23)
- git-committer:
- GitHub <noreply@…> (2024-02-23 17:57:23)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/amd64/include/arch/mm/pat.h
r86f862c rf2cb80a 1 1 /* 2 * Copyright (c) 20 06 Josef Cejka2 * Copyright (c) 2024 Jiří Zárevúcky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libcamd6429 /** @addtogroup kernel_amd64_mm 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef _LIBC_STACKARG_H_ 36 #define _LIBC_STACKARG_H_ 35 #ifndef KERN_amd64_MM_PAT_H_ 36 #define KERN_amd64_MM_PAT_H_ 37 38 #include <arch/asm.h> 39 #include <arch/cpuid.h> 40 41 #define MSR_IA32_PAT 0x00000277 42 43 typedef enum { 44 PAT_TYPE_UNCACHEABLE = 0, 45 PAT_TYPE_WRITE_COMBINING = 1, 46 PAT_TYPE_WRITE_THROUGH = 4, 47 PAT_TYPE_WRITE_PROTECTED = 5, 48 PAT_TYPE_WRITE_BACK = 6, 49 PAT_TYPE_UNCACHED = 7, 50 } pat_type_t; 51 52 /** 53 * Assign caching type for a particular combination of PAT, 54 * PCD and PWT bits in PTE. 55 */ 56 static inline void pat_set_mapping(bool pat, bool pcd, bool pwt, 57 pat_type_t type) 58 { 59 int index = pat << 2 | pcd << 1 | pwt; 60 int shift = index * 8; 61 62 uint64_t r = read_msr(MSR_IA32_PAT); 63 r &= ~(0xffull << shift); 64 r |= ((uint64_t) type) << shift; 65 write_msr(MSR_IA32_PAT, r); 66 } 67 68 static inline bool pat_supported(void) 69 { 70 if (!has_cpuid()) 71 return false; 72 73 cpu_info_t info; 74 cpuid(INTEL_CPUID_STANDARD, &info); 75 76 return (info.cpuid_edx & (1 << 16)) != 0; 77 } 37 78 38 79 #endif
Note:
See TracChangeset
for help on using the changeset viewer.