Compare commits
2 Commits
121fb3b33c
...
1341dc00d9
| Author | SHA1 | Date | |
|---|---|---|---|
| 1341dc00d9 | |||
| 99bab4ceee |
@@ -6,6 +6,7 @@
|
|||||||
#include <limine/requests.h>
|
#include <limine/requests.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
#include <sys/mm.h>
|
#include <sys/mm.h>
|
||||||
|
#include <sys/spin.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <uacpi/acpi.h>
|
#include <uacpi/acpi.h>
|
||||||
#include <uacpi/status.h>
|
#include <uacpi/status.h>
|
||||||
@@ -45,10 +46,6 @@ static size_t intr_src_override_entries = 0;
|
|||||||
/// Local APIC MMIO base address. It comes from MSR_APIC_BASE
|
/// Local APIC MMIO base address. It comes from MSR_APIC_BASE
|
||||||
static uintptr_t lapic_mmio_base = 0;
|
static uintptr_t lapic_mmio_base = 0;
|
||||||
|
|
||||||
/** @cond DOXYGEN_IGNORE */
|
|
||||||
extern void amd64_spin (void);
|
|
||||||
/** @endcond */
|
|
||||||
|
|
||||||
/// Read IOAPIC
|
/// Read IOAPIC
|
||||||
static uint32_t amd64_ioapic_read (uintptr_t vaddr, uint32_t reg) {
|
static uint32_t amd64_ioapic_read (uintptr_t vaddr, uint32_t reg) {
|
||||||
*(volatile uint32_t*)vaddr = reg;
|
*(volatile uint32_t*)vaddr = reg;
|
||||||
@@ -177,7 +174,7 @@ void amd64_ioapic_init (void) {
|
|||||||
uacpi_status status = uacpi_table_find_by_signature (ACPI_MADT_SIGNATURE, &apic_table);
|
uacpi_status status = uacpi_table_find_by_signature (ACPI_MADT_SIGNATURE, &apic_table);
|
||||||
if (status != UACPI_STATUS_OK) {
|
if (status != UACPI_STATUS_OK) {
|
||||||
DEBUG ("Could not find MADT table!\n");
|
DEBUG ("Could not find MADT table!\n");
|
||||||
amd64_spin ();
|
spin ();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct acpi_madt* apic = (struct acpi_madt*)apic_table.virt_addr;
|
struct acpi_madt* apic = (struct acpi_madt*)apic_table.virt_addr;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <sync/spin_lock.h>
|
#include <sync/spin_lock.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
#include <sys/mm.h>
|
#include <sys/mm.h>
|
||||||
|
#include <sys/spin.h>
|
||||||
#include <uacpi/acpi.h>
|
#include <uacpi/acpi.h>
|
||||||
#include <uacpi/status.h>
|
#include <uacpi/status.h>
|
||||||
#include <uacpi/tables.h>
|
#include <uacpi/tables.h>
|
||||||
@@ -32,10 +33,6 @@ static uint64_t hpet_clock_nano;
|
|||||||
/// Lock, which protects concurrent access. See \ref amd64/smp.c
|
/// Lock, which protects concurrent access. See \ref amd64/smp.c
|
||||||
static spin_lock_t hpet_lock = SPIN_LOCK_INIT;
|
static spin_lock_t hpet_lock = SPIN_LOCK_INIT;
|
||||||
|
|
||||||
/** @cond DOXYGEN_IGNORE */
|
|
||||||
extern void amd64_spin (void);
|
|
||||||
/** @endcond */
|
|
||||||
|
|
||||||
/// Read a HPET register. Assumes caller holds \ref hpet_lock
|
/// Read a HPET register. Assumes caller holds \ref hpet_lock
|
||||||
static uint64_t amd64_hpet_read (uint32_t reg) {
|
static uint64_t amd64_hpet_read (uint32_t reg) {
|
||||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||||
@@ -93,7 +90,7 @@ void amd64_hpet_init (void) {
|
|||||||
uacpi_status status = uacpi_table_find_by_signature (ACPI_HPET_SIGNATURE, &hpet_table);
|
uacpi_status status = uacpi_table_find_by_signature (ACPI_HPET_SIGNATURE, &hpet_table);
|
||||||
if (status != UACPI_STATUS_OK) {
|
if (status != UACPI_STATUS_OK) {
|
||||||
DEBUG ("Could not find HPET table!\n");
|
DEBUG ("Could not find HPET table!\n");
|
||||||
amd64_spin ();
|
spin ();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct acpi_hpet* hpet = (struct acpi_hpet*)hpet_table.virt_addr;
|
struct acpi_hpet* hpet = (struct acpi_hpet*)hpet_table.virt_addr;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
#include <sys/irq.h>
|
#include <sys/irq.h>
|
||||||
#include <sys/smp.h>
|
#include <sys/smp.h>
|
||||||
|
#include <sys/spin.h>
|
||||||
|
|
||||||
/* 8259 PIC defs. */
|
/* 8259 PIC defs. */
|
||||||
#define PIC1 0x20
|
#define PIC1 0x20
|
||||||
@@ -58,10 +59,6 @@ ALIGNED (16) static volatile struct idt_entry idt_entries[IDT_ENTRIES_MAX];
|
|||||||
/** @endcond */
|
/** @endcond */
|
||||||
static volatile struct idt idt;
|
static volatile struct idt idt;
|
||||||
|
|
||||||
/** @cond DOXYGEN_IGNORE */
|
|
||||||
extern void amd64_spin (void);
|
|
||||||
/** @endcond */
|
|
||||||
|
|
||||||
/// Remaps and disables old 8259 PIC, since we'll be using APIC.
|
/// Remaps and disables old 8259 PIC, since we'll be using APIC.
|
||||||
static void amd64_init_pic (void) {
|
static void amd64_init_pic (void) {
|
||||||
/** @cond DOXYGEN_IGNORE */
|
/** @cond DOXYGEN_IGNORE */
|
||||||
@@ -169,7 +166,7 @@ static void amd64_intr_exception (struct saved_regs* regs) {
|
|||||||
if (regs->cs == (0x18 | 0x03)) {
|
if (regs->cs == (0x18 | 0x03)) {
|
||||||
proc_kill (thiscpu->proc_current);
|
proc_kill (thiscpu->proc_current);
|
||||||
} else {
|
} else {
|
||||||
amd64_spin ();
|
spin ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
#include <aux/elf.h>
|
||||||
#include <libk/std.h>
|
#include <libk/std.h>
|
||||||
#include <libk/string.h>
|
#include <libk/string.h>
|
||||||
#include <sync/spin_lock.h>
|
|
||||||
#include <mm/pmm.h>
|
|
||||||
#include <mm/liballoc.h>
|
#include <mm/liballoc.h>
|
||||||
|
#include <mm/pmm.h>
|
||||||
#include <proc/proc.h>
|
#include <proc/proc.h>
|
||||||
#include <aux/elf.h>
|
#include <sync/spin_lock.h>
|
||||||
|
|
||||||
struct proc* proc_from_elf (uint8_t* elf_contents) {
|
struct proc* proc_from_elf (uint8_t* elf_contents) {
|
||||||
struct proc* proc = malloc (sizeof (*proc));
|
struct proc* proc = malloc (sizeof (*proc));
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
#include <sync/spin_lock.h>
|
#include <sync/spin_lock.h>
|
||||||
#include <sys/debug.h>
|
#include <sys/debug.h>
|
||||||
#include <sys/mm.h>
|
#include <sys/mm.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
#include <sys/sched.h>
|
#include <sys/sched.h>
|
||||||
#include <sys/smp.h>
|
#include <sys/smp.h>
|
||||||
#include <sys/proc.h>
|
|
||||||
#include <sys/spin.h>
|
#include <sys/spin.h>
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
#include <amd64/intr_defs.h>
|
#include <amd64/intr_defs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct procw* procs;
|
static struct procw* procs;
|
||||||
@@ -131,9 +131,9 @@ static void proc_register (struct proc* proc) {
|
|||||||
spin_unlock (&procs_lock);
|
spin_unlock (&procs_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct proc *proc_find_sched (void) {
|
static struct proc* proc_find_sched (void) {
|
||||||
struct proc *start = thiscpu->proc_current;
|
struct proc* start = thiscpu->proc_current;
|
||||||
struct proc *proc = start->next;
|
struct proc* proc = start->next;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (proc == NULL) {
|
if (proc == NULL) {
|
||||||
@@ -154,7 +154,7 @@ static struct proc *proc_find_sched (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void proc_sched (void) {
|
void proc_sched (void) {
|
||||||
struct proc *next = NULL;
|
struct proc* next = NULL;
|
||||||
|
|
||||||
spin_lock (&thiscpu->lock);
|
spin_lock (&thiscpu->lock);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
/// Process marked garbage collection
|
/// Process marked garbage collection
|
||||||
#define PROC_DEAD 1
|
#define PROC_DEAD 1
|
||||||
|
|
||||||
|
|
||||||
struct cpu;
|
struct cpu;
|
||||||
|
|
||||||
struct proc_mapping {
|
struct proc_mapping {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
#define _KERNEL_SYS_SPIN_H
|
#define _KERNEL_SYS_SPIN_H
|
||||||
|
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
extern void amd64_spin (void);
|
extern void amd64_spin (void);
|
||||||
#define spin amd64_spin
|
#define spin amd64_spin
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _KERNEL_SYS_SPIN_H
|
#endif // _KERNEL_SYS_SPIN_H
|
||||||
|
|||||||
Reference in New Issue
Block a user