APIC: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
Code style fix (no softians or javanians here) |
|||
Line 42: | Line 42: | ||
* note that this requires CPUID to be supported. |
* note that this requires CPUID to be supported. |
||
*/ |
*/ |
||
bool |
bool check_apic() { |
||
{ |
|||
uint32_t eax, edx; |
uint32_t eax, edx; |
||
cpuid(1, &eax, &edx); |
cpuid(1, &eax, &edx); |
||
Line 50: | Line 49: | ||
/* Set the physical address for local APIC registers */ |
/* Set the physical address for local APIC registers */ |
||
void |
void cpu_set_apic_base(uintptr_t apic) { |
||
{ |
|||
uint32_t edx = 0; |
uint32_t edx = 0; |
||
uint32_t eax = (apic & 0xfffff100) | IA32_APIC_BASE_MSR_ENABLE; |
uint32_t eax = (apic & 0xfffff100) | IA32_APIC_BASE_MSR_ENABLE; |
||
Line 59: | Line 57: | ||
#endif |
#endif |
||
cpu_set_msr(IA32_APIC_BASE_MSR, eax, edx); |
|||
} |
} |
||
Line 66: | Line 64: | ||
* make sure you map it to virtual memory ;) |
* make sure you map it to virtual memory ;) |
||
*/ |
*/ |
||
uintptr_t |
uintptr_t cpu_get_acpi_base() { |
||
{ |
|||
uint32_t eax, edx; |
uint32_t eax, edx; |
||
cpu_get_msr(IA32_APIC_BASE_MSR, &eax, &edx); |
|||
#ifdef __PHYSICAL_MEMORY_EXTENSION__ |
#ifdef __PHYSICAL_MEMORY_EXTENSION__ |
||
Line 78: | Line 75: | ||
} |
} |
||
void |
void enable_apic() { |
||
{ |
|||
/* Hardware enable the Local APIC if it wasn't enabled */ |
/* Hardware enable the Local APIC if it wasn't enabled */ |
||
cpu_set_apic_base(cpuGetAPICBase()); |
|||
/* Set the Spourious Interrupt Vector Register bit 8 to start receiving interrupts */ |
/* Set the Spourious Interrupt Vector Register bit 8 to start receiving interrupts */ |
||
write_reg(0xF0, ReadRegister(0xF0) | 0x100); |
|||
} |
} |
||
</source> |
</source> |