x86_64: init local apic on boot, or legacy pic/pit as fallback
This commit is contained in:
@@ -13,6 +13,11 @@
|
||||
#define ACPI_SIG_FADT 0x50434146
|
||||
#define ACPI_SIG_MADT 0x43495041
|
||||
|
||||
#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_rsdp_10 {
|
||||
char r_sig[8];
|
||||
uint8_t r_chksum;
|
||||
@@ -65,9 +70,29 @@ struct acpi_madt {
|
||||
uint32_t m_flags;
|
||||
} __packed;
|
||||
|
||||
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 kern_status_t acpi_init(void);
|
||||
extern kern_status_t acpi_scan_cpu_topology(void);
|
||||
|
||||
extern kern_status_t apic_init(void);
|
||||
extern kern_status_t smp_init(void);
|
||||
|
||||
extern struct acpi_sdt *acpi_find_sdt(uint32_t sig);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,10 +2,35 @@
|
||||
#define ARCH_IRQ_H_
|
||||
|
||||
#include <socks/compiler.h>
|
||||
#include <socks/queue.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define NR_IDT_ENTRIES 48
|
||||
|
||||
typedef enum irq_vector {
|
||||
IRQ0 = 32,
|
||||
IRQ1,
|
||||
IRQ2,
|
||||
IRQ3,
|
||||
IRQ4,
|
||||
IRQ5,
|
||||
IRQ6,
|
||||
IRQ7,
|
||||
IRQ8,
|
||||
IRQ9,
|
||||
IRQ10,
|
||||
IRQ11,
|
||||
IRQ12,
|
||||
IRQ13,
|
||||
IRQ14,
|
||||
IRQ15,
|
||||
} irq_vector_t;
|
||||
|
||||
typedef struct irq_hook {
|
||||
queue_entry_t irq_entry;
|
||||
int (*irq_callback)(void);
|
||||
} irq_hook_t;
|
||||
|
||||
struct cpu_context {
|
||||
uint64_t r15, r14, r13, r12, r11, r10, r9, r8;
|
||||
uint64_t rdi, rsi, rbp, unused_rsp, rbx, rdx, rcx, rax;
|
||||
@@ -40,4 +65,6 @@ typedef void (*int_hook)(struct cpu_context *);
|
||||
extern int idt_init(struct idt_ptr *idtp);
|
||||
extern int idt_load(struct idt_ptr *idtp);
|
||||
|
||||
extern void hook_irq(irq_vector_t vec, irq_hook_t *hook);
|
||||
|
||||
#endif
|
||||
|
||||
6
arch/x86_64/include/arch/pit.h
Normal file
6
arch/x86_64/include/arch/pit.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef ARCH_PIT_H_
|
||||
#define ARCH_PIT_H_
|
||||
|
||||
extern void pit_init(unsigned int hz);
|
||||
|
||||
#endif
|
||||
@@ -16,6 +16,9 @@ typedef struct ml_cpu_block {
|
||||
unsigned int c_cpu_id;
|
||||
} ml_cpu_block;
|
||||
|
||||
#define ml_cpu_pause() asm volatile("hlt")
|
||||
#define ml_cpu_relax() asm volatile("pause")
|
||||
|
||||
extern int ml_init_bootcpu(void);
|
||||
|
||||
extern int ml_cpu_block_init(ml_cpu_block *p);
|
||||
|
||||
Reference in New Issue
Block a user