feat: main function
This commit is contained in:
parent
beb7fb38ae
commit
ba608513e6
10 changed files with 151 additions and 57 deletions
|
|
@ -13,4 +13,7 @@ struct discovery_result_t {
|
|||
optional<Fadt> fadt;
|
||||
};
|
||||
|
||||
void initDiscovery();
|
||||
const discovery_result_t& getDiscovery();
|
||||
|
||||
} // namespace acpi
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "memory/pointer.h"
|
||||
|
||||
#include "acpi/discovery.h"
|
||||
#include "cpu/gdt.h"
|
||||
#include "memory/pagetable.h"
|
||||
|
||||
namespace apic {
|
||||
|
|
@ -18,12 +19,13 @@ struct Core {
|
|||
core_id id;
|
||||
stack_t stack;
|
||||
PageTable kernelPageTable;
|
||||
Gdt gdt;
|
||||
};
|
||||
|
||||
optional<Core> initCore(acpi::Madt madt, core_id id);
|
||||
|
||||
void initCores(acpi::discovery_result_t);
|
||||
|
||||
void transitionStartupCore();
|
||||
[[noreturn]] void transitionStartupCore();
|
||||
|
||||
} // namespace apic
|
||||
|
|
@ -56,3 +56,22 @@ struct [[gnu::packed]] tss_t {
|
|||
static_assert(sizeof(tss_t) == 104);
|
||||
|
||||
void reloadSegments(Gdt::selector_t code_selector, Gdt::selector_t data_selector);
|
||||
|
||||
[[noreturn]] inline void longjump(
|
||||
uint64_t code, uint64_t stack, Gdt::selector_t code_selector, Gdt::selector_t stack_selector, uint64_t arg
|
||||
) {
|
||||
uint64_t code_sel = code_selector;
|
||||
uint16_t stack_sel = stack_selector;
|
||||
asm volatile(
|
||||
"mov %[stack_sel], %%ss\n"
|
||||
"mov %[stack], %%rsp\n"
|
||||
"pushq %[code_sel]\n"
|
||||
"pushq %[code]\n"
|
||||
"mov %[arg], %%rdi\n"
|
||||
"lretq\n"
|
||||
:
|
||||
: [stack_sel] "r"(stack_sel), [stack] "r"(stack), [code_sel] "r"(code_sel), [code] "r"(code), [arg] "r"(arg)
|
||||
: "memory", "rdi"
|
||||
);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
[[noreturn]] void main();
|
||||
#include "apic/core.h"
|
||||
|
||||
[[noreturn]] void main(apic::Core* core);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue