In themiddle of somethign
This commit is contained in:
parent
5e7e5468f3
commit
d8a071f0ab
@ -1,6 +1,6 @@
|
||||
include $(MK)/prologue.mk
|
||||
|
||||
SRC_$(d) := init.c \
|
||||
SRC_$(d) := boot.c \
|
||||
intr.c \
|
||||
mem.c \
|
||||
print.c
|
||||
|
35
hal/mem.c
35
hal/mem.c
@ -12,7 +12,34 @@ static hal_gdt_ptr_t _gdt_ptrs[HAL_CORE_COUNT];
|
||||
|
||||
char kernel_heap[KERNEL_HEAP_SIZE];
|
||||
|
||||
void KABI hal_write_pt_entry(void *const base, uint64_t const p_addr, uint64_t const attr)
|
||||
/**
|
||||
* helper for boot.asm, not open to C headers
|
||||
* @param k_start kernel start paddr
|
||||
* @param k_end kernel end paddr
|
||||
* @param multiboot_info multibootinfo paddr
|
||||
* @param pt_base page table base paddr
|
||||
* @param pt_end page table entry paddr
|
||||
*/
|
||||
void KABI hal_write_initial_page_table(void* k_start, void* k_end, void* multiboot_info, void* pt_base, void* pt_end)
|
||||
{
|
||||
uint32_t pt_num = 0;
|
||||
uint32_t pd_num = 0;
|
||||
uint32_t pdpt_num = 0;
|
||||
uint32_t pml4_num = 0;
|
||||
|
||||
// calculate the number of page tables required:
|
||||
uint64_t k_size = (uintptr_t)k_start - (uintptr_t)k_end;
|
||||
//
|
||||
uint32_t m_size = *(uint32_t *)multiboot_info;
|
||||
|
||||
|
||||
// construct recursive mapping with the first page table
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void KABI hal_write_pt(void *const base, uintptr_t const p_addr, uint64_t const attr)
|
||||
{
|
||||
if (base == NULL)
|
||||
return;
|
||||
@ -28,7 +55,7 @@ void KABI hal_write_pt_entry(void *const base, uint64_t const p_addr, uint64_t c
|
||||
return;
|
||||
}
|
||||
|
||||
void KABI hal_write_pd_entry(void *const base, uint64_t const pt_addr, uint64_t const attr)
|
||||
void KABI hal_write_pd(void *const base, uintptr_t const pt_addr, uint64_t const attr)
|
||||
{
|
||||
if (base == NULL)
|
||||
return;
|
||||
@ -44,7 +71,7 @@ void KABI hal_write_pd_entry(void *const base, uint64_t const pt_addr, uint64_t
|
||||
return;
|
||||
}
|
||||
|
||||
void KABI hal_write_pdpt_entry(void *const base, uint64_t const pd_addr, uint64_t const attr)
|
||||
void KABI hal_write_pdpt(void *const base, uintptr_t const pd_addr, uint64_t const attr)
|
||||
{
|
||||
if (base == NULL)
|
||||
return;
|
||||
@ -60,7 +87,7 @@ void KABI hal_write_pdpt_entry(void *const base, uint64_t const pd_addr, uint64_
|
||||
return;
|
||||
}
|
||||
|
||||
void KABI hal_write_pml4_entry(void *const base, uint64_t const pdpt_addr, uint64_t const attr)
|
||||
void KABI hal_write_pml4(void *const base, uintptr_t const pdpt_addr, uint64_t const attr)
|
||||
{
|
||||
if (base == NULL)
|
||||
return;
|
||||
|
@ -81,13 +81,13 @@ void KABI hal_write_segment_descriptor(void *const gdt, uint32_t const base, uin
|
||||
|
||||
#define PAGE_ENTRY_BASE(PAGE_ENTRY) ((PAGE_ENTRY) & 0xFFFFFFFFFF000)
|
||||
|
||||
void KABI hal_write_pml4_entry(void *const base, uint64_t const pdpt_addr, uint64_t const attr);
|
||||
void KABI hal_write_pml4(void *const base, uintptr_t const pdpt_addr, uint64_t const attr);
|
||||
|
||||
void KABI hal_write_pdpt_entry(void *const base, uint64_t const pd_addr, uint64_t const attr);
|
||||
void KABI hal_write_pdpt(void *const base, uintptr_t const pd_addr, uint64_t const attr);
|
||||
|
||||
void KABI hal_write_pd_entry(void *const base, uint64_t const pt_addr, uint64_t const attr);
|
||||
void KABI hal_write_pd(void *const base, uintptr_t const pt_addr, uint64_t const attr);
|
||||
|
||||
void KABI hal_write_pt_entry(void *const base, uint64_t const p_addr, uint64_t const attr);
|
||||
void KABI hal_write_pt(void *const base, uintptr_t const p_addr, uint64_t const attr);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -7,9 +7,6 @@
|
||||
/**
|
||||
Kernel Memory Layout
|
||||
**/
|
||||
typedef uintptr_t physical_addr_t;
|
||||
typedef uintptr_t virtual_addr_t;
|
||||
|
||||
#define KERNEL_PAGE_SIZE (0x1000ull)
|
||||
|
||||
#define KERNEL_AREA_START_VADDR (0xFFFF800000000000ull)
|
||||
@ -41,7 +38,7 @@ typedef uintptr_t virtual_addr_t;
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
physical_addr_t base;
|
||||
uintptr_t base;
|
||||
uint64_t size;
|
||||
uint32_t attr;
|
||||
} pmm_node_t;
|
||||
|
@ -6,8 +6,7 @@
|
||||
#include "kernel/ke/boot.h"
|
||||
#include "kernel/ke/alloc.h"
|
||||
#include "test/test_case.h"
|
||||
|
||||
extern void KABI hal_printf(char const *, ...);
|
||||
#include "kernel/ke/print.h"
|
||||
|
||||
// returning from this function results in halting the cpu
|
||||
void KABI ke_main(boot_info_t *boot_info)
|
||||
@ -15,7 +14,7 @@ void KABI ke_main(boot_info_t *boot_info)
|
||||
if (boot_info == NULL)
|
||||
{
|
||||
// failed.
|
||||
hal_printf("KERNEL: HAL init failed.\n");
|
||||
ke_printf("KERNEL: HAL init failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -24,12 +23,12 @@ void KABI ke_main(boot_info_t *boot_info)
|
||||
|
||||
ke_alloc_init();
|
||||
|
||||
hal_printf("KERNEL: Base Addr is 0x%X. Size is %uB, %uKB.\n",
|
||||
ke_printf("KERNEL: Base Addr is 0x%X. Size is %uB, %uKB.\n",
|
||||
boot_info->krnl_start,
|
||||
(boot_info->krnl_end - boot_info->krnl_start),
|
||||
(boot_info->krnl_end - boot_info->krnl_start) / 1024);
|
||||
|
||||
hal_printf("KERNEL: CPU Vendor is \"%s\".\n", boot_info->cpu_vd_str);
|
||||
ke_printf("KERNEL: CPU Vendor is \"%s\".\n", boot_info->cpu_vd_str);
|
||||
|
||||
linked_list_test();
|
||||
|
||||
@ -37,7 +36,7 @@ void KABI ke_main(boot_info_t *boot_info)
|
||||
|
||||
salloc_test();
|
||||
|
||||
hal_printf("KERNEL: Kernel tasks finished.\n");
|
||||
ke_printf("KERNEL: Kernel tasks finished.\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user