diff options
Diffstat (limited to 'kernel/src/apic')
| -rw-r--r-- | kernel/src/apic/apic.c | 32 | ||||
| -rw-r--r-- | kernel/src/apic/ioapic.c | 16 | ||||
| -rw-r--r-- | kernel/src/apic/madt.c | 26 |
3 files changed, 37 insertions, 37 deletions
diff --git a/kernel/src/apic/apic.c b/kernel/src/apic/apic.c index 2b650b0..f543c82 100644 --- a/kernel/src/apic/apic.c +++ b/kernel/src/apic/apic.c @@ -30,69 +30,69 @@ void init_ap_cpus() map_addr(lapic_addr, lapic_addr, FLAG_PRESENT); for (size_t i = 0; i < numcores; i++) { - // do not start BSP, that's already running this code + /* do not start BSP, that's already running this code */ if (cpu_apic_ids[i] == bspid) continue; - // send INIT IPI + /* send INIT IPI */ - // clear APIC errors + /* clear APIC errors */ *((__volatile__ uint32_t *)(lapic_addr + 0x280)) = 0; - // select AP + /* select AP */ *((__volatile__ uint32_t *)(lapic_addr + 0x310)) = (*((__volatile__ uint32_t *)(lapic_addr + 0x310)) & 0x00ffffff) | ((uint32_t)cpu_apic_ids[i] << 24); - // trigger INIT IPI + /* trigger INIT IPI */ *((__volatile__ uint32_t *)(lapic_addr + 0x300)) = (*((__volatile__ uint32_t *)(lapic_addr + 0x300)) & 0xfff00000) | 0x00C500; - // wait for delivery + /* wait for delivery */ do { __asm__ __volatile__("pause" : : : "memory"); } while (*((__volatile__ uint32_t *)(uint64_t)(lapic_addr + 0x300)) & (1 << 12)); - // select AP + /* select AP */ *((__volatile__ uint32_t *)(lapic_addr + 0x310)) = (*((__volatile__ uint32_t *)(lapic_addr + 0x310)) & 0x00ffffff) | ((uint32_t)cpu_apic_ids[i] << 24); - // deassert + /* deassert */ *((__volatile__ uint32_t *)(lapic_addr + 0x300)) = (*((__volatile__ uint32_t *)(lapic_addr + 0x300)) & 0xfff00000) | 0x008500; - // wait for delivery + /* wait for delivery */ do { __asm__ __volatile__("pause" : : : "memory"); } while (*((__volatile__ uint32_t *)(uint64_t)(lapic_addr + 0x300)) & (1 << 12)); - // wait 10 msec + /* wait 10 msec */ wait(10); - // send STARTUP IPI (twice) + /* send STARTUP IPI (twice) */ for (size_t j = 0; j < 2; j++) { - // clear APIC errors + /* clear APIC errors */ *((__volatile__ uint32_t *)(lapic_addr + 0x280)) = 0; - // select AP + /* select AP */ *((__volatile__ uint32_t *)(lapic_addr + 0x310)) = (*((__volatile__ uint32_t *)(lapic_addr + 0x310)) & 0x00ffffff) | ((uint32_t)cpu_apic_ids[i] << 24); - // trigger STARTUP IPI for 0800:0000 + /* trigger STARTUP IPI for 0800:0000 */ *((__volatile__ uint32_t *)(lapic_addr + 0x300)) = (*((__volatile__ uint32_t *)(lapic_addr + 0x300)) & 0xfff0f800) | 0x000608; - // wait 200 usec + /* wait 200 usec */ wait(1); - // wait for delivery + /* wait for delivery */ do { __asm__ __volatile__("pause" : : : "memory"); } while (*((__volatile__ uint32_t diff --git a/kernel/src/apic/ioapic.c b/kernel/src/apic/ioapic.c index cfda8be..7fe005b 100644 --- a/kernel/src/apic/ioapic.c +++ b/kernel/src/apic/ioapic.c @@ -32,23 +32,23 @@ void ioapic_set_irq(uint8_t irq, uint64_t apic_id, uint8_t vector) const uint32_t high_index = (uint32_t)0x10 + irq * 2 + 1; uint32_t high = ioapic_read((uint8_t)high_index); - // set APIC ID + /* set APIC ID */ high &= (uint32_t)~0xff000000; high |= (uint32_t)apic_id << 24; ioapic_write((uint8_t)high_index, high); uint32_t low = ioapic_read((uint8_t)low_index); - // unmask the IRQ + /* unmask the IRQ */ low &= (uint32_t) ~(1 << 16); - // set to physical delivery mode + /* set to physical delivery mode */ low &= (uint32_t) ~(1 << 11); - // set to fixed delivery mode + /* set to fixed delivery mode */ low &= (uint32_t)~0x700; - // set delivery vector + /* set delivery vector */ low &= (uint32_t)~0xff; low |= vector; @@ -62,9 +62,9 @@ void apic_remap_interrupts() uint8_t bspid = curr_cpu_apic_id(); - // irq is 2 because of gsi remap - ioapic_set_irq(0x2, bspid, 0x20); // timer - ioapic_set_irq(0x1, bspid, 0x21); // keyboard + /* irq is 2 because of gsi remap */ + 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)) = diff --git a/kernel/src/apic/madt.c b/kernel/src/apic/madt.c index 5a6e914..3a152aa 100644 --- a/kernel/src/apic/madt.c +++ b/kernel/src/apic/madt.c @@ -29,7 +29,7 @@ void parse_madt() kfree(m); if (type == 0) { - // Processor Local APIC + /* Processor Local APIC */ struct MADT_cpu_local_apic *cpu = (struct MADT_cpu_local_apic *)kalloc( sizeof(struct MADT_cpu_local_apic)); @@ -43,10 +43,10 @@ void parse_madt() numcores++; } - // printf("found cpu: acpi_id: 0x%x, apic_id: 0x%x, flags: 0x%x\n", cpu->acpi_id, cpu->apic_id, cpu->flags); + /* printf("found cpu: acpi_id: 0x%x, apic_id: 0x%x, flags: 0x%x\n", cpu->acpi_id, cpu->apic_id, cpu->flags); */ kfree(cpu); } else if (type == 1) { - // I/O APIC + /* I/O APIC */ struct MADT_io_apic *io = (struct MADT_io_apic *)kalloc( sizeof(struct MADT_io_apic)); memcpy(io, @@ -56,10 +56,10 @@ void parse_madt() ioapic_addr = io->io_apic_addr; - // printf("found io: apic_id: 0x%x, addr: 0x%x, int_base: 0x%x\n", io->apic_id, io->io_apic_addr, io->int_base); + /* printf("found io: apic_id: 0x%x, addr: 0x%x, int_base: 0x%x\n", io->apic_id, io->io_apic_addr, io->int_base); */ kfree(io); } else if (type == 2) { - // IO/APIC Interrupt Source Override + /* IO/APIC Interrupt Source Override */ struct MADT_io_apic_int *io_apic_int = (struct MADT_io_apic_int *)kalloc( sizeof(struct MADT_io_apic_int)); @@ -68,13 +68,13 @@ void parse_madt() (uint64_t)curr_size), sizeof(struct MADT_io_apic_int)); - // printf("found io_apic_int: bus: 0x%x, irq_source: 0x%x, global_sys_int: 0x%x, flags: 0x%x\n", io_apic_int->bus_source, io_apic_int->irq_source, io_apic_int->global_sys_int, io_apic_int->flags); + /* printf("found io_apic_int: bus: 0x%x, irq_source: 0x%x, global_sys_int: 0x%x, flags: 0x%x\n", io_apic_int->bus_source, io_apic_int->irq_source, io_apic_int->global_sys_int, io_apic_int->flags); */ kfree(io_apic_int); } else if (type == 3) { - // IO/APIC Non-maskable interrupt source + /* IO/APIC Non-maskable interrupt source */ printf("MADT entry of type %d\n", type); } else if (type == 4) { - // Local APIC Non-maskable interrupts + /* Local APIC Non-maskable interrupts */ struct MADT_lapic_nmi *lapic_nmi = (struct MADT_lapic_nmi *)kalloc( sizeof(struct MADT_lapic_nmi)); @@ -83,10 +83,10 @@ void parse_madt() (uint64_t)curr_size), sizeof(struct MADT_lapic_nmi)); - // printf("found lapic_nmi: acpi_cpu_id: 0x%x, flags: 0x%x, lint: 0x%x\n", lapic_nmi->acpi_cpu_id, lapic_nmi->flags, lapic_nmi->lint); + /* printf("found lapic_nmi: acpi_cpu_id: 0x%x, flags: 0x%x, lint: 0x%x\n", lapic_nmi->acpi_cpu_id, lapic_nmi->flags, lapic_nmi->lint); */ kfree(lapic_nmi); } else if (type == 5) { - // Local APIC Address Override + /* Local APIC Address Override */ struct MADT_lapic_addr *lapic_addr_ovr = (struct MADT_lapic_addr *)kalloc( sizeof(struct MADT_lapic_addr)); @@ -95,13 +95,13 @@ void parse_madt() (uint64_t)curr_size), sizeof(struct MADT_lapic_addr)); - // printf("found lapic: addr: 0x%x\n", lapic_addr_ovr->phys_addr); + /* printf("found lapic: addr: 0x%x\n", lapic_addr_ovr->phys_addr); */ kfree(lapic_addr_ovr); } else if (type == 9) { - // Processor Local x2APIC + /* Processor Local x2APIC */ printf("MADT entry of type %d\n", type); } else { - // ERROR + /* ERROR */ printf("ERROR: MADT entry of type %d\n", type); } curr_size += len; |
