mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-18 09:04:49 -04:00
Clean
This commit is contained in:
parent
576605487b
commit
c210f397bc
@ -32,6 +32,9 @@ static_assert(sizeof(int32_t) == 4, "int32_t must be 4 bytes long");
|
|||||||
static_assert(sizeof(int64_t) == 8, "int64_t must be 8 bytes long");
|
static_assert(sizeof(int64_t) == 8, "int64_t must be 8 bytes long");
|
||||||
|
|
||||||
static_assert(sizeof(size_t) == 8, "size_t must be 8 bytes long");
|
static_assert(sizeof(size_t) == 8, "size_t must be 8 bytes long");
|
||||||
|
|
||||||
|
#ifndef CODE_32
|
||||||
static_assert(sizeof(uintptr_t) == sizeof(uint64_t*), "uintptr_t must have the same size as a pointer");
|
static_assert(sizeof(uintptr_t) == sizeof(uint64_t*), "uintptr_t must have the same size as a pointer");
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
|
#define CODE_32
|
||||||
|
|
||||||
#include "boot/boot_32.hpp"
|
#include "boot/boot_32.hpp"
|
||||||
#include "kernel.hpp"
|
#include "kernel.hpp"
|
||||||
|
#include "paging.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -20,7 +23,6 @@ static_assert(sizeof(uint16_t) == 2, "uint16_t must be 2 bytes long");
|
|||||||
static_assert(sizeof(uint32_t) == 4, "uint32_t must be 4 bytes long");
|
static_assert(sizeof(uint32_t) == 4, "uint32_t must be 4 bytes long");
|
||||||
static_assert(sizeof(uint64_t) == 8, "uint64_t must be 8 bytes long");
|
static_assert(sizeof(uint64_t) == 8, "uint64_t must be 8 bytes long");
|
||||||
|
|
||||||
const uint32_t PAGE_SIZE = 0x1000;
|
|
||||||
const uint32_t PML4T = 0x70000;
|
const uint32_t PML4T = 0x70000;
|
||||||
|
|
||||||
void set_segments(){
|
void set_segments(){
|
||||||
@ -52,22 +54,22 @@ void setup_paging(){
|
|||||||
//Link tables (0x3 means Writeable and Supervisor)
|
//Link tables (0x3 means Writeable and Supervisor)
|
||||||
|
|
||||||
//PML4T[0] -> PDPT
|
//PML4T[0] -> PDPT
|
||||||
*reinterpret_cast<uint32_t*>(PML4T) = PML4T + PAGE_SIZE + 0x7;
|
*reinterpret_cast<uint32_t*>(PML4T) = PML4T + paging::PAGE_SIZE + 0x7;
|
||||||
|
|
||||||
//PDPT[0] -> PDT
|
//PDPT[0] -> PDT
|
||||||
*reinterpret_cast<uint32_t*>(PML4T + 1 * PAGE_SIZE) = PML4T + 2 * PAGE_SIZE + 0x7;
|
*reinterpret_cast<uint32_t*>(PML4T + 1 * paging::PAGE_SIZE) = PML4T + 2 * paging::PAGE_SIZE + 0x7;
|
||||||
|
|
||||||
//PDT[0] -> PD
|
//PDT[0] -> PD
|
||||||
*reinterpret_cast<uint32_t*>(PML4T + 2 * PAGE_SIZE) = PML4T + 3 * PAGE_SIZE + 0x7;
|
*reinterpret_cast<uint32_t*>(PML4T + 2 * paging::PAGE_SIZE) = PML4T + 3 * paging::PAGE_SIZE + 0x7;
|
||||||
|
|
||||||
//Map the first MiB
|
//Map the first MiB
|
||||||
|
|
||||||
auto page_table_ptr = reinterpret_cast<uint32_t*>(PML4T + 3 * PAGE_SIZE);
|
auto page_table_ptr = reinterpret_cast<uint32_t*>(PML4T + 3 * paging::PAGE_SIZE);
|
||||||
auto phys = 0x3;
|
auto phys = 0x3;
|
||||||
for(uint32_t i = 0; i < 256; ++i){
|
for(uint32_t i = 0; i < 256; ++i){
|
||||||
*page_table_ptr = phys;
|
*page_table_ptr = phys;
|
||||||
|
|
||||||
phys += 0x1000;
|
phys += paging::PAGE_SIZE;
|
||||||
|
|
||||||
//A page entry is 64 bit in size
|
//A page entry is 64 bit in size
|
||||||
page_table_ptr += 2;
|
page_table_ptr += 2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user