.skip 0x1000 - 16
.quad PDPT_high - KERNEL_VMA + 3
PDPT_low: .quad 0x83
- .quad 0x83 + 1024 * 1024 * 1024
- .skip 0x1000 - 16
+ .skip 0x1000 - 8
PDPT_high: .skip 0x1000 - 16
.quad 0x83
.quad 0x83 + 1024 * 1024 * 1024
// You should have received a copy of the GNU General Public License along with this program. If
// not, see <https://www.gnu.org/licenses/>.
-#include "interrupts.hpp"
-#include "utils.hpp"
#include <cpuid.h>
+#include "interrupts.hpp"
-void os::cli() {
- asm volatile("cli");
-}
-void os::sti() {
- asm volatile("sti");
-}
void os::lidt(idtr idtr) {
asm volatile("lidt %0" : : "m"(idtr));
}
#include <cstdint>
#include "lib/phys_ptr.hpp"
#include "serial.hpp"
+#include "utils.hpp"
namespace os {
std::uint64_t offset;
};
-void cli();
-void sti();
void lidt(idtr idtr);
bool is_APIC_builtin();
void disable_PIC();
// Unmap low RAM, and free corresponding page.
PML4T.contents[0].P = false;
os::paging::page_allocator.deallocate({.ptr = os::phys_ptr<os::paging::page>(get_base_address(PML4T.contents[0]).get_phys_addr()), .size = 1});
+ os::invlpg((void*)0x0);
+
// Load test-module elf file:
const os::elf::header elf_header = *os::phys_ptr<os::elf::header>(test_module.start_address.get_phys_addr());
os::paging::setup_page(PML4T, stack + i * 0x1000, 1, 1, true);
}
- asm volatile("invlpg (%0)" ::"r" (0x1000) : "memory");
-
os::print("Loading ring 3 interrupts stack.\n");
os::set_ring0_stack(TSS, std::uint64_t(&interrupt_stack_top));
os::print("Loading TSS.\n");
PT.contents[indices.pe] = {.P = 1, .R_W = R_W, .U_S = U_S, .PWT = 0, .PCD = 0, .PAT = 0, .G = 0, .base_address = 0, .NX = 0};
const auto page_alloc = os::paging::page_allocator.allocate(1);
set_page_base_address(PT.contents[indices.pe], os::phys_ptr<os::paging::page>(page_alloc.ptr.get_phys_addr()));
+ invlpg(vaddr);
} else {
os::assert(!must_be_unmapped, "Memory at address 0x{} has already been mapped.", std::uintptr_t(vaddr));
}
#include "interrupts.hpp"
#include <cpuid.h>
+void os::invlpg(const void* vaddr) {
+ asm volatile("invlpg (%0)" :: "r" (vaddr) : "memory");
+}
+void os::cli() {
+ asm volatile("cli" :);
+}
+void os::sti() {
+ asm volatile("sti" :);
+}
void os::hlt() {
- asm volatile("hlt");
+ asm volatile("hlt" :);
}
void os::outb(std::uint16_t port, std::uint8_t data) {
namespace os {
+void invlpg(const void* vaddr);
+void cli();
+void sti();
void hlt();
void outb(std::uint16_t port, std::uint8_t data);
std::uint8_t inb(std::uint16_t port);