feat: implement core initialization and local APIC setup
This commit is contained in:
parent
ada1859910
commit
beb7fb38ae
19 changed files with 747 additions and 41 deletions
|
|
@ -2,6 +2,28 @@
|
|||
|
||||
#include "memory/pointer.h"
|
||||
|
||||
#include "acpi/discovery.h"
|
||||
#include "memory/pagetable.h"
|
||||
|
||||
namespace apic {
|
||||
void startupCore(paddr_t code, paddr_t stack);
|
||||
}
|
||||
|
||||
struct stack_t {
|
||||
paddr_t ptr;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
using core_id = uint8_t;
|
||||
|
||||
struct Core {
|
||||
core_id id;
|
||||
stack_t stack;
|
||||
PageTable kernelPageTable;
|
||||
};
|
||||
|
||||
optional<Core> initCore(acpi::Madt madt, core_id id);
|
||||
|
||||
void initCores(acpi::discovery_result_t);
|
||||
|
||||
void transitionStartupCore();
|
||||
|
||||
} // namespace apic
|
||||
24
kernel/include/apic/lapic.h
Normal file
24
kernel/include/apic/lapic.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include "acpi/discovery.h"
|
||||
#include "util/number.h"
|
||||
|
||||
namespace apic {
|
||||
|
||||
using lapic_id_t = uint32_t;
|
||||
|
||||
void initLocalApic(const acpi::discovery_result_t& discovery);
|
||||
|
||||
lapic_id_t localApicId();
|
||||
|
||||
void sendInit(lapic_id_t destination);
|
||||
|
||||
// startup_page: physical address of the real-mode entry point divided by 4096;
|
||||
// must point below 1 MiB, so only values < 0x100 are meaningful.
|
||||
void sendStartup(lapic_id_t destination, uint8_t startup_page);
|
||||
|
||||
void sendInterrupt(lapic_id_t destination, uint8_t vector);
|
||||
|
||||
void signalEndOfInterrupt();
|
||||
|
||||
} // namespace apic
|
||||
|
|
@ -33,6 +33,26 @@ constexpr duration_t operator*(uint64_t scalar, duration_t duration) {
|
|||
return duration_t{duration.timer_count * scalar};
|
||||
}
|
||||
|
||||
constexpr bool operator==(duration_t left, duration_t right) {
|
||||
return left.timer_count == right.timer_count;
|
||||
}
|
||||
|
||||
constexpr bool operator<(duration_t left, duration_t right) {
|
||||
return left.timer_count < right.timer_count;
|
||||
}
|
||||
|
||||
constexpr bool operator<=(duration_t left, duration_t right) {
|
||||
return left.timer_count <= right.timer_count;
|
||||
}
|
||||
|
||||
constexpr bool operator>(duration_t left, duration_t right) {
|
||||
return left.timer_count > right.timer_count;
|
||||
}
|
||||
|
||||
constexpr bool operator>=(duration_t left, duration_t right) {
|
||||
return left.timer_count >= right.timer_count;
|
||||
}
|
||||
|
||||
constexpr timestamp_t operator+(timestamp_t timestamp, duration_t duration) {
|
||||
return timestamp_t{timestamp.timer_count + duration.timer_count};
|
||||
}
|
||||
|
|
@ -62,9 +82,4 @@ void busyWait(duration_t duration);
|
|||
|
||||
timestamp_t now();
|
||||
|
||||
// TODO: when dynamic allocation and lists are available
|
||||
// struct Timer {};
|
||||
//
|
||||
// Timer getCoreTimerInstance();
|
||||
|
||||
} // namespace apic
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue