Changeset 166 for trunk/hal/x86_64/core/hal_init.c
- Timestamp:
- Jul 10, 2017, 10:14:27 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/x86_64/core/hal_init.c
r165 r166 27 27 #include <hal_apic.h> 28 28 #include <hal_internal.h> 29 #include <hal_register.h> 30 29 31 #include <hal_remote.h> 30 32 #include <hal_irqmask.h> … … 46 48 static void gdt_create(); 47 49 static void idt_create(); 50 void cpu_identify(); 48 51 void cpu_attach(); 49 52 … … 250 253 } 251 254 255 /* -------------------------------------------------------------------------- */ 256 252 257 void init_x86_64(paddr_t firstpa) 253 258 { … … 262 267 gdt_create(); 263 268 idt_create(); 269 270 /* Identify the features of the cpu */ 271 cpu_identify(); 264 272 265 273 /* Attach cpu0 */ … … 477 485 /* -------------------------------------------------------------------------- */ 478 486 487 uint64_t cpu_features[4] __in_kdata; 488 489 void cpu_identify() 490 { 491 /* 492 * desc[0] = eax 493 * desc[1] = ebx 494 * desc[2] = ecx 495 * desc[3] = edx 496 */ 497 uint32_t desc[4]; 498 char vendor[13]; 499 size_t lvl; 500 501 /* 502 * Get information from the standard cpuid leafs 503 */ 504 cpuid(0, 0, (uint32_t *)&desc); 505 506 lvl = (uint64_t)desc[0]; 507 x86_printf("-> cpuid standard level: %z\n", lvl); 508 509 memcpy(vendor + 0, &desc[1], sizeof(uint32_t)); 510 memcpy(vendor + 8, &desc[2], sizeof(uint32_t)); 511 memcpy(vendor + 4, &desc[3], sizeof(uint32_t)); 512 vendor[12] = '\0'; 513 x86_printf("-> CPU vendor: '%s'\n", vendor); 514 515 if (lvl >= 1) { 516 cpuid(1, 0, (uint32_t *)&desc); 517 cpu_features[0] = desc[3]; 518 cpu_features[1] = desc[2]; 519 } 520 521 /* 522 * Get information from the extended cpuid leafs 523 */ 524 cpuid(0x80000000, 0, desc); 525 526 lvl = (uint64_t)desc[0]; 527 x86_printf("-> cpuid extended level: %Z\n", lvl); 528 } 529 530 /* -------------------------------------------------------------------------- */ 531 479 532 void cpu_attach(size_t lid) 480 533 { … … 482 535 cpu_load_idt(); 483 536 cpu_create_tss(lid); 484 } 485 537 538 if (cpu_features[0] & CPUID_PSE) { 539 lcr4(rcr4() | CR4_PSE); 540 tlbflushg(); 541 } else { 542 /* 543 * amd64 supports PSE by default, if it's not here we have a 544 * problem 545 */ 546 x86_panic("PSE not supported"); 547 } 548 } 549
Note: See TracChangeset
for help on using the changeset viewer.