diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-25 06:56:01 +0100 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-25 08:45:09 +0100 |
| commit | 239900af293f192931391dc5579afab39a43e6c6 (patch) | |
| tree | 72d7f87ee6adf5aa84b78436197e03e61fba8d97 /kernel/src/apic/ioapic.c | |
| parent | aaa23fffd02fb49cdbc56a480dbb5a8fa95bff38 (diff) | |
clang-format
Diffstat (limited to 'kernel/src/apic/ioapic.c')
| -rw-r--r-- | kernel/src/apic/ioapic.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/kernel/src/apic/ioapic.c b/kernel/src/apic/ioapic.c index bcd5a4d..cfda8be 100644 --- a/kernel/src/apic/ioapic.c +++ b/kernel/src/apic/ioapic.c @@ -7,29 +7,29 @@ void ioapic_eoi() { - *((__volatile__ uint32_t*)((uint64_t)lapic_addr + 0xB0)) = 0; + *((__volatile__ uint32_t *)((uint64_t)lapic_addr + 0xB0)) = 0; } uint32_t ioapic_read(const uint8_t offset) { - /* tell IOREGSEL where we want to read from */ - *(__volatile__ uint32_t*)(uint64_t)ioapic_addr = offset; - /* return the data from IOWIN */ - return *(__volatile__ uint32_t*)((uint64_t)ioapic_addr + 0x10); + /* tell IOREGSEL where we want to read from */ + *(__volatile__ uint32_t *)(uint64_t)ioapic_addr = offset; + /* return the data from IOWIN */ + return *(__volatile__ uint32_t *)((uint64_t)ioapic_addr + 0x10); } void ioapic_write(const uint8_t offset, const uint32_t val) { - /* tell IOREGSEL where we want to write to */ - *(__volatile__ uint32_t*)(uint64_t)ioapic_addr = offset; - /* write the value to IOWIN */ - *(__volatile__ uint32_t*)((uint64_t)ioapic_addr + 0x10) = val; + /* tell IOREGSEL where we want to write to */ + *(__volatile__ uint32_t *)(uint64_t)ioapic_addr = offset; + /* write the value to IOWIN */ + *(__volatile__ uint32_t *)((uint64_t)ioapic_addr + 0x10) = val; } void ioapic_set_irq(uint8_t irq, uint64_t apic_id, uint8_t vector) { - const uint32_t low_index = (uint32_t)0x10 + irq*2; - const uint32_t high_index = (uint32_t)0x10 + irq*2 + 1; + const uint32_t low_index = (uint32_t)0x10 + irq * 2; + const uint32_t high_index = (uint32_t)0x10 + irq * 2 + 1; uint32_t high = ioapic_read((uint8_t)high_index); // set APIC ID @@ -40,10 +40,10 @@ void ioapic_set_irq(uint8_t irq, uint64_t apic_id, uint8_t vector) uint32_t low = ioapic_read((uint8_t)low_index); // unmask the IRQ - low &= (uint32_t)~(1<<16); + low &= (uint32_t) ~(1 << 16); // set to physical delivery mode - low &= (uint32_t)~(1<<11); + low &= (uint32_t) ~(1 << 11); // set to fixed delivery mode low &= (uint32_t)~0x700; @@ -66,6 +66,7 @@ void apic_remap_interrupts() ioapic_set_irq(0x2, bspid, 0x20); // timer ioapic_set_irq(0x1, bspid, 0x21); // keyboard - write_msr(APIC_BASE_MSR, read_msr(APIC_BASE_MSR) | (1<<11)); - *((__volatile__ uint32_t*)(lapic_addr + 0xF0)) = (*(__volatile__ uint32_t*)(lapic_addr + 0xF0) | 0x1FF ); + write_msr(APIC_BASE_MSR, read_msr(APIC_BASE_MSR) | (1 << 11)); + *((__volatile__ uint32_t *)(lapic_addr + 0xF0)) = + (*(__volatile__ uint32_t *)(lapic_addr + 0xF0) | 0x1FF); } |
