Cleanup multiboot entry code
This commit is contained in:
parent
828b51034e
commit
19e9bbc22b
@ -17,6 +17,7 @@
|
||||
|
||||
extern void PCI_Init();
|
||||
extern void IDE_Init();
|
||||
extern void MachineBoot_AddMem();
|
||||
|
||||
#define GDT_MAX 7
|
||||
|
||||
@ -111,6 +112,8 @@ void Machine_Init()
|
||||
|
||||
PAlloc_AddRegion(16*1024*1024, 16*1024*1024);
|
||||
PMap_Init();
|
||||
MachineBoot_AddMem();
|
||||
//XMem_Init();
|
||||
|
||||
IRQ_Init();
|
||||
LAPIC_Init();
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "amd64.h"
|
||||
#include "multiboot.h"
|
||||
|
||||
void mbentry(unsigned long magic, unsigned long addr);
|
||||
void MachineBoot_Entry(unsigned long magic, unsigned long addr);
|
||||
|
||||
#define CHECK_FLAG(flag, bit) ((flag) & (1 << (bit)))
|
||||
|
||||
@ -53,8 +53,14 @@ PAGE_ALIGN DATA_SECTION PageTable bootpgtbl1 = { .entries = {
|
||||
0
|
||||
}};
|
||||
|
||||
#define MAX_REGIONS 16
|
||||
|
||||
static uintptr_t memRegionStart[MAX_REGIONS];
|
||||
static uintptr_t memRegionLen[MAX_REGIONS];
|
||||
static int memRegionIdx;
|
||||
|
||||
void
|
||||
mb_entry(unsigned long magic, unsigned long addr)
|
||||
MachineBoot_Entry(unsigned long magic, unsigned long addr)
|
||||
{
|
||||
multiboot_info_t *mbi = (multiboot_info_t *)addr;
|
||||
|
||||
@ -130,57 +136,40 @@ mb_entry(unsigned long magic, unsigned long addr)
|
||||
(unsigned) multiboot_elf_sec->addr, (unsigned) multiboot_elf_sec->shndx);
|
||||
}
|
||||
|
||||
memRegionIdx = 0;
|
||||
|
||||
/* @r{Are mmap_* valid?} */
|
||||
if (CHECK_FLAG (mbi->flags, 6))
|
||||
{
|
||||
multiboot_memory_map_t *mmap;
|
||||
|
||||
kprintf("mmap_addr = 0x%x, mmap_length = 0x%x\n",
|
||||
(unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
|
||||
for (mmap = (multiboot_memory_map_t *)(uintptr_t) mbi->mmap_addr;
|
||||
(unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
|
||||
mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
|
||||
+ mmap->size + sizeof (mmap->size)))
|
||||
{
|
||||
kprintf(" size = 0x%x, base_addr = 0x%x,"
|
||||
" length = 0x%x, type = 0x%x\n",
|
||||
(unsigned) mmap->size,
|
||||
mmap->addr,
|
||||
mmap->len,
|
||||
(unsigned) mmap->type);
|
||||
}
|
||||
multiboot_memory_map_t *mmap;
|
||||
|
||||
kprintf("mmap_addr = 0x%x, mmap_length = 0x%x\n",
|
||||
(unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
|
||||
for (mmap = (multiboot_memory_map_t *)(uintptr_t) mbi->mmap_addr;
|
||||
(unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
|
||||
mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
|
||||
+ mmap->size + sizeof (mmap->size)))
|
||||
{
|
||||
kprintf(" size = 0x%x, base_addr = 0x%x,"
|
||||
" length = 0x%x, type = 0x%x\n",
|
||||
(unsigned) mmap->size,
|
||||
mmap->addr,
|
||||
mmap->len,
|
||||
(unsigned) mmap->type);
|
||||
memRegionStart[memRegionIdx] = mmap->addr;
|
||||
memRegionLen[memRegionIdx] = mmap->len;
|
||||
memRegionIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
// Main initialization
|
||||
Machine_Init();
|
||||
|
||||
return;
|
||||
/* @r{Are mmap_* valid?} */
|
||||
if (CHECK_FLAG (mbi->flags, 6))
|
||||
{
|
||||
multiboot_memory_map_t *mmap;
|
||||
|
||||
for (mmap = (multiboot_memory_map_t *)(uintptr_t) mbi->mmap_addr;
|
||||
(unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
|
||||
mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
|
||||
+ mmap->size + sizeof (mmap->size)))
|
||||
{
|
||||
if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) {
|
||||
kprintf(" size = 0x%x, base_addr = 0x%x,"
|
||||
" length = 0x%x, type = 0x%x\n",
|
||||
(unsigned) mmap->size,
|
||||
mmap->addr,
|
||||
mmap->len,
|
||||
(unsigned) mmap->type);
|
||||
uintptr_t start = mmap->addr;
|
||||
uintptr_t len = mmap->len;
|
||||
|
||||
if ((len % PGSIZE) != 0)
|
||||
len = len - len % PGSIZE;
|
||||
|
||||
// XXX: Fix me to skip kernel
|
||||
PAlloc_AddRegion(start, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MachineBoot_AddMem()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ lmenter: .code64
|
||||
movq %rdx, %rdi // Magic
|
||||
movq %rbx, %rsi // Multiboot info pointer
|
||||
|
||||
call mb_entry
|
||||
call MachineBoot_Entry
|
||||
|
||||
movw $(0x5000 + 'H'), (0xB8098)
|
||||
movw $(0x5000 + 'A'), (0xB809A)
|
||||
|
Loading…
x
Reference in New Issue
Block a user