x86_64: init local apic on boot, or legacy pic/pit as fallback
This commit is contained in:
@@ -3,27 +3,6 @@
|
||||
#include <socks/vm.h>
|
||||
#include <socks/cpu.h>
|
||||
|
||||
#define AP_TRAMPOLINE_PADDR 0x8000
|
||||
#define LAPIC_IPI_STATUS_REG 0x0280
|
||||
#define LAPIC_IPI_DEST_REG 0x0310
|
||||
#define LAPIC_IPI_ICR_REG 0x0300
|
||||
|
||||
struct acpi_madt_record {
|
||||
uint8_t r_type;
|
||||
uint8_t r_length;
|
||||
} __packed;
|
||||
|
||||
struct lapic_record {
|
||||
uint8_t l_cpu_id;
|
||||
uint8_t l_apic_id;
|
||||
uint32_t l_flags;
|
||||
} __packed;
|
||||
|
||||
struct lapic_override_record {
|
||||
uint16_t l_reserved;
|
||||
uint64_t l_lapic_ptr;
|
||||
} __packed;
|
||||
|
||||
extern uint8_t acpi_bsp_lapic_id(void);
|
||||
extern char ap_trampoline[];
|
||||
|
||||
@@ -61,31 +40,6 @@ static int __used init_ap(struct acpi_madt_record *rec, void *bsp_lapic, uint8_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *__used find_lapic(struct acpi_madt *madt)
|
||||
{
|
||||
phys_addr_t local_apic = madt->m_lapic_ptr;
|
||||
|
||||
unsigned char *p = (unsigned char *)madt + sizeof *madt;
|
||||
unsigned char *madt_end = (unsigned char *)madt + madt->m_base.s_length;
|
||||
|
||||
while (p < madt_end) {
|
||||
struct acpi_madt_record *rec = (struct acpi_madt_record *)p;
|
||||
struct lapic_override_record *lapic;
|
||||
|
||||
switch (rec->r_type) {
|
||||
case ACPI_MADT_LAPIC_OVERRIDE:
|
||||
lapic = (struct lapic_override_record *)(rec + 1);
|
||||
return vm_phys_to_virt(lapic->l_lapic_ptr);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
p += rec->r_length;
|
||||
}
|
||||
|
||||
return vm_phys_to_virt(local_apic);
|
||||
}
|
||||
|
||||
/*
|
||||
kern_status_t acpi_smp_init(void)
|
||||
{
|
||||
@@ -125,10 +79,20 @@ kern_status_t acpi_smp_init(void)
|
||||
}
|
||||
*/
|
||||
|
||||
static void no_smp_config(void)
|
||||
{
|
||||
cpu_set_available(0);
|
||||
cpu_set_online(0);
|
||||
|
||||
ml_cpu_block *self = ml_this_cpu();
|
||||
self->c_cpu_id = 0;
|
||||
}
|
||||
|
||||
kern_status_t acpi_scan_cpu_topology(void)
|
||||
{
|
||||
struct acpi_madt *madt = (struct acpi_madt *)acpi_find_sdt(ACPI_SIG_MADT);
|
||||
if (!madt) {
|
||||
no_smp_config();
|
||||
return KERN_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -171,3 +135,8 @@ kern_status_t acpi_scan_cpu_topology(void)
|
||||
printk("acpi: found %u logical cores", nr_processors);
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
kern_status_t smp_init(void)
|
||||
{
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user