boot.asm:
Code: Select all
extern meminit
[BITS 32]
global setup ;GRUB loads kernel and enters here
setup:
cmp eax,0x2BADB002
jne notmb
mov eax, 0xFFFF
mov esp, eax ;set temp stack pointer
mov ebp, eax ;set temp base pointer
push ebx ;push pointer to multiboot info
call meminit
pop ebx
notmb:
hlt
jmp notmb
;multiboot header info below
.
.
.
Code: Select all
static uint32_t pages;
void meminit(multiboot_info_t *mb_info)
{
uint32_t *pdir, *ptab;
int i;
pages = ((mb_info->mem_lower + mb_info->mem_upper)*1024) / PAGESIZE;
//Use the last page in memory for the page directory
pdir = (uint32_t *)(--pages * PAGESIZE);
//map the Page Directory to the last PDE
//this will now be mapped to virtual 0xffc00000
pdir[1023] = (uint32_t)pdir | PG_PRESENT | PG_WRITABLE;
//Identity Map the first 4Megs of memory
ptab = (uint32_t *)((--pages * PAGESIZE) | PG_PRESENT | PG_WRITABLE);
for(i=0; i<1024; i++)
{
ptab[i]=(i*PAGESIZE)| PG_PRESENT | PG_WRITABLE;
}
pdir[0] = (uint32_t)ptab;
//set page directory base address
set_cr3(pdi
//enable paging
set_cr0(get_cr0 | CR0_PG);
}
but if i comment out the line that enables paging, it will hit the notmb loop fine and endlessly loop like its supposed to. I dont see any blatantly obvious problems. Could someone please help me with this?