Changeset 275 for trunk/hal/x86_64/core
- Timestamp:
- Jul 26, 2017, 1:20:36 PM (7 years ago)
- Location:
- trunk/hal/x86_64/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_acpi.c
r241 r275 173 173 /* -------------------------------------------------------------------------- */ 174 174 175 static void hal_acpi_parse_srat(srat_t *srat) 176 { 177 srat_cpu_affinity_t *cpu; 178 srat_mem_affinity_t *mem; 179 void *ptr, *end; 180 subheader_t *sub; 181 uint32_t dom; 182 183 ptr = (void *)(srat + 1); 184 end = (void *)srat + srat->Header.Length; 185 186 while (ptr < end) { 187 sub = (subheader_t *)ptr; 188 if (sub->Type == ACPI_SRAT_TYPE_CPU_AFFINITY) { 189 cpu = (srat_cpu_affinity_t *)sub; 190 if (cpu->Flags & ACPI_SRAT_CPU_USE_AFFINITY) { 191 dom = ((uint32_t)cpu->ProximityDomainHi[2] << 24) | 192 ((uint32_t)cpu->ProximityDomainHi[1] << 16) | 193 ((uint32_t)cpu->ProximityDomainHi[0] << 8) | 194 (uint32_t)cpu->ProximityDomainLo; 195 x86_printf("-> found CPU affinity: %z->%z\n", 196 (uint64_t)cpu->ApicId, (uint64_t)dom); 197 } 198 } else if (sub->Type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) { 199 mem = (srat_mem_affinity_t *)sub; 200 // if (mem->Flags & ACPI_SRAT_MEM_ENABLED) 201 x86_printf("-> found MEM affinity: %z->[%Z,%Z,%Z]\n", 202 mem->ProximityDomain, 203 mem->BaseAddress, mem->Length,(uint64_t)mem->Flags); 204 } 205 206 ptr += sub->Length; 207 } 208 209 } 210 211 static srat_t *hal_acpi_map_srat(rsdt_t *rsdt) 212 { 213 vaddr_t va; 214 paddr_t pa; 215 uint32_t *ent; 216 size_t i, n; 217 218 n = RSDT_NENTRIES(rsdt); 219 ent = RSDT_ENTRIES(rsdt); 220 221 for (i = 0; i < n; i++) { 222 pa = (paddr_t)ent[i]; 223 va = hal_acpi_map_table(pa, "SRAT"); 224 if (va == 0) 225 continue; 226 227 return (srat_t *)va; 228 } 229 230 return NULL; 231 } 232 233 /* -------------------------------------------------------------------------- */ 234 175 235 static rsdt_t *hal_acpi_map_rsdt(rsdp_t *rsdp) 176 236 { … … 242 302 rsdt_t *rsdt; 243 303 madt_t *madt; 304 srat_t *srat; 244 305 paddr_t bios_min = 0x0E0000; 245 306 paddr_t bios_max = 0x100000; … … 262 323 x86_panic("RSDT not found"); 263 324 264 /* Now, map MADT*/325 /* Map MADT and parse it */ 265 326 madt = hal_acpi_map_madt(rsdt); 266 327 if (madt == NULL) 267 328 x86_panic("MADT not found"); 268 269 /* Parse it */270 329 hal_acpi_parse_madt(madt); 271 } 272 330 331 /* Map SRAT and parse it */ 332 srat = hal_acpi_map_srat(rsdt); 333 if (srat != NULL) 334 hal_acpi_parse_srat(srat); 335 else 336 x86_printf("-> SRAT not found, single cluster\n"); 337 } 338 -
trunk/hal/x86_64/core/hal_acpi.h
r241 r275 192 192 typedef struct acpi_madt_io_apic madt_ioapic_t; 193 193 194 /******************************************************************************* 195 * SRAT - System Resource Affinity Table 196 * Version 3 197 ******************************************************************************/ 198 199 struct acpi_table_srat { 200 header_t Header; /* Common ACPI table header */ 201 uint32_t TableRevision; /* Must be value '1' */ 202 uint64_t Reserved; /* Reserved, must be zero */ 203 }; 204 typedef struct acpi_table_srat srat_t; 205 206 /******************************************************************************* 207 * SRAT structures 208 ******************************************************************************/ 209 210 enum AcpiSratType { 211 ACPI_SRAT_TYPE_CPU_AFFINITY = 0, 212 ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, 213 ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, 214 ACPI_SRAT_TYPE_GICC_AFFINITY = 3, 215 ACPI_SRAT_TYPE_RESERVED = 4 /* 4 and greater are reserved */ 216 }; 217 218 #define ACPI_SRAT_CPU_USE_AFFINITY (1) /* 00: Use affinity structure */ 219 220 struct acpi_srat_cpu_affinity { 221 subheader_t Header; 222 uint8_t ProximityDomainLo; 223 uint8_t ApicId; 224 uint32_t Flags; 225 uint8_t LocalSapicEid; 226 uint8_t ProximityDomainHi[3]; 227 uint32_t ClockDomain; 228 }; 229 typedef struct acpi_srat_cpu_affinity srat_cpu_affinity_t; 230 231 #define ACPI_SRAT_MEM_ENABLED (1) /* 00: Use affinity structure */ 232 #define ACPI_SRAT_MEM_HOT_PLUGGABLE (1<<1) /* 01: Memory region is hot pluggable */ 233 #define ACPI_SRAT_MEM_NON_VOLATILE (1<<2) /* 02: Memory region is non-volatile */ 234 235 struct acpi_srat_mem_affinity { 236 subheader_t Header; 237 uint32_t ProximityDomain; 238 uint16_t Reserved; /* Reserved, must be zero */ 239 uint64_t BaseAddress; 240 uint64_t Length; 241 uint32_t Reserved1; 242 uint32_t Flags; 243 uint64_t Reserved2; /* Reserved, must be zero */ 244 }; 245 typedef struct acpi_srat_mem_affinity srat_mem_affinity_t; 246
Note: See TracChangeset
for help on using the changeset viewer.