fix: able to read multiboot mmap
This commit is contained in:
parent
09ea386b21
commit
20ba985b34
@ -26,7 +26,7 @@ extern uint32_t boot_page_directory;
|
|||||||
extern uint32_t *page_directory;
|
extern uint32_t *page_directory;
|
||||||
extern uint32_t page_table_default[1024];
|
extern uint32_t page_table_default[1024];
|
||||||
extern uint32_t mem_size;
|
extern uint32_t mem_size;
|
||||||
extern multiboot_uint32_t *mmap_addr;
|
extern multiboot_memory_map_t *mmap_addr;
|
||||||
extern multiboot_uint32_t mmap_length;
|
extern multiboot_uint32_t mmap_length;
|
||||||
|
|
||||||
uint32_t *virt_to_phys(uint32_t *virt_addr);
|
uint32_t *virt_to_phys(uint32_t *virt_addr);
|
||||||
|
@ -17,9 +17,6 @@ void kpanic(const char *format, ...)
|
|||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
kvprintf(format, &va);
|
kvprintf(format, &va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
uint32_t faulting_address;
|
|
||||||
__asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address));
|
|
||||||
kprintf("fault at address: %p\n", faulting_address);
|
|
||||||
/* for (int i = 16; i < 32; i++) */
|
/* for (int i = 16; i < 32; i++) */
|
||||||
/* kprintf("%p\n", page_table1[i]); */
|
/* kprintf("%p\n", page_table1[i]); */
|
||||||
/* show_valloc_mem(); */
|
/* show_valloc_mem(); */
|
||||||
|
@ -5,27 +5,20 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
#include "string.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
void *alloc_frames(size_t size)
|
void *alloc_frames(size_t size)
|
||||||
{
|
{
|
||||||
const uint32_t nb_frames = CEIL(size, PAGE_SIZE);
|
const uint32_t nb_frames = CEIL(size, PAGE_SIZE);
|
||||||
/* PRINT_PTR(((multiboot_memory_map_t *)mmap_addr)->addr); */
|
for (uint32_t i = 0; i < mmap_length; i++) {
|
||||||
/* PRINT_UINT(((multiboot_memory_map_t *)mmap_addr)->len); */
|
|
||||||
/* PRINT_UINT(((multiboot_memory_map_t *)mmap_addr)->type); */
|
|
||||||
for (uint32_t i = 0; i < mmap_length;
|
|
||||||
i += sizeof(multiboot_memory_map_t)) {
|
|
||||||
multiboot_memory_map_t *mmmt =
|
multiboot_memory_map_t *mmmt =
|
||||||
(multiboot_memory_map_t *)(mmap_addr + i);
|
(multiboot_memory_map_t *)mmap_addr + i;
|
||||||
if (mmmt->type == MULTIBOOT_MEMORY_AVAILABLE) {
|
if (mmmt->type == MULTIBOOT_MEMORY_AVAILABLE) {
|
||||||
|
kprintf("type: %d, addr: %p, len: %u, size: %u, \n",
|
||||||
|
mmmt->type, mmmt->addr, mmmt->len, mmmt->size);
|
||||||
}
|
}
|
||||||
PRINT_UINT(mmmt->len);
|
|
||||||
/* kprintf("[%d] available %p: %u bytes\n", i, mmmt->addr, */
|
|
||||||
/* mmmt->len); */
|
|
||||||
/* PRINT_UINT(mmmt->type); */
|
|
||||||
}
|
}
|
||||||
/* for (size_t i = 0; i < mmap_length; i++) { */
|
|
||||||
/* } */
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ uint32_t *page_directory = &boot_page_directory;
|
|||||||
uint32_t page_table_default[1024] __attribute__((aligned(PAGE_SIZE)));
|
uint32_t page_table_default[1024] __attribute__((aligned(PAGE_SIZE)));
|
||||||
uint32_t multiboot_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
|
uint32_t multiboot_page_table[1024] __attribute__((aligned(PAGE_SIZE)));
|
||||||
uint32_t mem_size;
|
uint32_t mem_size;
|
||||||
multiboot_uint32_t *mmap_addr;
|
multiboot_memory_map_t *mmap_addr;
|
||||||
multiboot_uint32_t mmap_length;
|
multiboot_uint32_t mmap_length;
|
||||||
|
|
||||||
static void init_multiboot(multiboot_info_t *mbd, uint32_t magic)
|
static void init_multiboot(multiboot_info_t *mbd, uint32_t magic)
|
||||||
@ -36,10 +36,10 @@ static void init_multiboot(multiboot_info_t *mbd, uint32_t magic)
|
|||||||
multiboot_page_table[i + mbd_size] =
|
multiboot_page_table[i + mbd_size] =
|
||||||
((mbd_virt->mmap_addr + i * PAGE_SIZE) & PAGE_MASK) |
|
((mbd_virt->mmap_addr + i * PAGE_SIZE) & PAGE_MASK) |
|
||||||
INIT_FLAGS;
|
INIT_FLAGS;
|
||||||
mmap_addr =
|
mmap_addr = (multiboot_memory_map_t *)(GET_PAGE_ADDR(1023, mbd_size) +
|
||||||
(multiboot_uint32_t *)(GET_PAGE_ADDR(1023, mbd_size) +
|
(uint32_t)mbd_virt->mmap_addr %
|
||||||
(uint32_t)mbd_virt->mmap_addr % PAGE_SIZE);
|
PAGE_SIZE);
|
||||||
mmap_length = mbd_virt->mmap_length;
|
mmap_length = mbd_virt->mmap_length / sizeof(multiboot_memory_map_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_memory(multiboot_info_t *mbd, uint32_t magic)
|
void init_memory(multiboot_info_t *mbd, uint32_t magic)
|
||||||
|
Loading…
Reference in New Issue
Block a user