Changeset 24244
- Timestamp:
- 03/05/08 15:06:18 (9 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
haiku/trunk/src/system/kernel/arch/x86/arch_vm.cpp
r22326 r24244 92 92 return B_OK; 93 93 94 uint32 newType; 95 94 96 switch (type) { 95 97 case B_MTR_UC: 96 type = IA32_MTR_UNCACHED;98 newType = IA32_MTR_UNCACHED; 97 99 break; 98 100 case B_MTR_WC: 99 type = IA32_MTR_WRITE_COMBINING;101 newType = IA32_MTR_WRITE_COMBINING; 100 102 break; 101 103 case B_MTR_WT: 102 type = IA32_MTR_WRITE_THROUGH;104 newType = IA32_MTR_WRITE_THROUGH; 103 105 break; 104 106 case B_MTR_WP: 105 type = IA32_MTR_WRITE_PROTECTED;107 newType = IA32_MTR_WRITE_PROTECTED; 106 108 break; 107 109 case B_MTR_WB: 108 type = IA32_MTR_WRITE_BACK;110 newType = IA32_MTR_WRITE_BACK; 109 111 break; 110 112 … … 117 119 118 120 // length must be a power of 2; just round it up to the next value 119 length = nearest_power(length); 120 if (length + base <= base) { 121 uint64 newLength = nearest_power(length); 122 123 // avoids more than 2GB slots 124 if (newLength > 0x80000000) 125 newLength = 0x80000000; 126 127 if (newLength + base <= base) { 121 128 // 4GB overflow 122 129 return B_BAD_VALUE; … … 124 131 125 132 // base must be aligned to the length 126 if (base & ( length - 1))133 if (base & (newLength - 1)) 127 134 return B_BAD_VALUE; 128 135 … … 132 139 133 140 TRACE(("allocate MTRR slot %ld, base = %Lx, length = %Lx\n", index, 134 base, length));141 base, newLength)); 135 142 136 143 sMemoryTypeIDs[index] = id; 137 x86_set_mtrr(index, base, length, type); 144 x86_set_mtrr(index, base, newLength, newType); 145 146 // now handle remaining memory 147 if (length > newLength) { 148 // TODO iterate over smaller lengths to avoid the PCI hole after the physical memory. 149 set_memory_type(id, base + newLength, length - newLength, type); 150 } 138 151 139 152 return B_OK;
