Add phys init

This commit is contained in:
Mark
2019-10-12 13:57:32 +03:00
parent 6297d1bfb2
commit bfcc6d7bdf
3 changed files with 33 additions and 12 deletions
+9
View File
@@ -19,3 +19,12 @@ struct thread {
// TODO: maybe __sched_thread
struct thread *next;
};
int thread_init(struct thread *t,
mm_space_t *space,
uintptr_t entry,
uintptr_t stack0_base,
size_t stack0_size,
uintptr_t stack3_base,
size_t stack3_size,
uint32_t flags);
+11 -1
View File
@@ -1,13 +1,23 @@
#include "sys/debug.h"
#include "sys/amd64/loader/multiboot.h"
#include "sys/amd64/hw/gdt.h"
#include "sys/amd64/hw/idt.h"
#include "sys/amd64/mm/mm.h"
#include "sys/amd64/mm/phys.h"
#include "sys/amd64/hw/acpi.h"
static multiboot_info_t *multiboot_info;
void kernel_main(struct amd64_loader_data *data) {
data = (struct amd64_loader_data *) MM_VIRTUALIZE(data);
multiboot_info = (multiboot_info_t *) MM_VIRTUALIZE(data->multiboot_info_ptr);
amd64_phys_memory_map((multiboot_memory_map_t *) MM_VIRTUALIZE(multiboot_info->mmap_addr),
multiboot_info->mmap_length);
amd64_gdt_init();
amd64_idt_init();
amd64_mm_init(NULL);
amd64_mm_init(data);
extern void sched_init(void);
sched_init();
+13 -11
View File
@@ -1,12 +1,14 @@
// #include "sys/vmalloc.h"
// #include "sys/assert.h"
#include "sys/vmalloc.h"
#include "sys/assert.h"
#include "sys/debug.h"
#include "sys/string.h"
#include "sys/amd64/mm/mm.h"
// #include "sys/panic.h"
// #include "sys/heap.h"
#include "sys/panic.h"
#include "sys/heap.h"
#include "sys/amd64/mm/pool.h"
#include "sys/amd64/mm/phys.h"
// #include "sys/mem.h"
// #include "sys/mm.h"
#include "sys/mm.h"
mm_space_t mm_kernel;
@@ -40,15 +42,15 @@ void amd64_mm_init(struct amd64_loader_data *data) {
asm volatile ("mov %0, %%cr3"::"a"(pml4):"memory");
// Create a pool located right after kernel image
// amd64_mm_pool_init((uintptr_t) &_kernel_end, MM_POOL_SIZE);
amd64_mm_pool_init((uintptr_t) &_kernel_end, MM_POOL_SIZE);
mm_kernel = (mm_space_t) (MM_VIRTUALIZE(pml4));
// // Allocate some pages for kernel heap (base size: 16MiB)
// uintptr_t heap_base_phys = amd64_phys_alloc_contiguous(KERNEL_HEAP >> 12);
// assert(heap_base_phys != MM_NADDR, "Could not allocate %S of memory for kernel heap\n", KERNEL_HEAP);
// kdebug("Setting up kernel heap of %S @ %p\n", KERNEL_HEAP, heap_base_phys);
// amd64_heap_init(heap_global, heap_base_phys, KERNEL_HEAP);
uintptr_t heap_base_phys = amd64_phys_alloc_contiguous(KERNEL_HEAP >> 12);
assert(heap_base_phys != MM_NADDR, "Could not allocate %S of memory for kernel heap\n", KERNEL_HEAP);
kdebug("Setting up kernel heap of %S @ %p\n", KERNEL_HEAP, heap_base_phys);
amd64_heap_init(heap_global, heap_base_phys, KERNEL_HEAP);
// amd64_heap_dump(heap_global);
amd64_heap_dump(heap_global);
}