Okay, i used the debuger now.
It does not tell me much, except that the cpu crahes either at
mov cr0,eax
or at the return afterwards.
I also did a dump_cpu... Here are the interresting parts of the log of the debug session:
Code: Select all
(0).[18393492] [0x0010133e] 0008:0010133e (unk. ctxt): mov dword ptr ss:[esp+], 0x107860 ; c7042460781000
(0).[18393493] [0x00101345] 0008:00101345 (unk. ctxt): call 0x100033 ; e8e9ecffff
(0).[18393494] [0x00100033] 0008:00100033 (unk. ctxt): mov eax, dword ptr ss:[esp+0x4] ; 8b442404
(0).[18393495] [0x00100037] 0008:00100037 (unk. ctxt): mov cr3, eax ; 0f22d8
(0).[18393496] [0x0010003a] 0008:0010003a (unk. ctxt): mov eax, cr0 ; 0f20c0
(0).[18393497] [0x0010003d] 0008:0010003d (unk. ctxt): or eax, 0x80000000 ; 0d00000080
(0) Breakpoint 2, 0x100042 in ?? ()
Next at t=18393498
(0) [0x00100042] 0008:00100042 (unk. ctxt): mov cr0, eax ; 0f22c0
dump_cpu
eax:0xe0000011
ebx:0x106860
ecx:0x400000
edx:0x400
ebp:0x104ff8
esi:0x54617
edi:0x54618
esp:0x104fdc
eflags:0x212
eip:0x100042
cs:s=0x8, dl=0xffff, dh=0xcf9a00, valid=1
ss:s=0x10, dl=0xffff, dh=0xcf9300, valid=7
ds:s=0x10, dl=0xffff, dh=0xcf9200, valid=7
es:s=0x10, dl=0xffff, dh=0xcf9300, valid=1
fs:s=0x10, dl=0xffff, dh=0xcf9300, valid=1
gs:s=0x10, dl=0xffff, dh=0xcf9300, valid=1
ldtr:s=0x0, dl=0x0, dh=0x0, valid=0
tr:s=0x0, dl=0x0, dh=0x0, valid=0
gdtr:base=0x10600e, limit=0x17
idtr:base=0x106060, limit=0x7ff
dr0:0x0
dr1:0x0
dr2:0x0
dr3:0x0
dr6:0xffff0ff0
dr7:0x400
tr3:0x0
tr4:0x0
tr5:0x0
tr6:0x0
tr7:0x0
cr0:0x60000011
cr1:0x0
cr2:0x0
cr3:0x107860
cr4:0x0
inhibit_mask:0
done
c
(0).[18393498] [0x00100042] 0008:00100042 (unk. ctxt): mov cr0, eax ; 0f22c0
Maybe i have a wrong return-pointer as well?
It seems plausible, as the cpu crashes at the return-line...
Here is, as i said, my C-code. Maybe i made a mistake when i changed the code from the tutorial into mine....
Code: Select all
#include "../include/paging.h"
unsigned long page_dir[1024]; //Space reserved for the page directory
unsigned long page_table[1024]; //One page table
//Set up an entry in the page directory to point to a page table
void set_pagedirentry(int pos, unsigned long* table_adress, unsigned short flags)
{
page_dir[pos]=table_adress;
page_dir[pos]=page_dir[pos] | flags;
};
//Set up an entry in the page table to point to a physical starting adress
void set_pagetableentry(int pos, unsigned long addr, unsigned long* table_adress, unsigned short flags)
{
if(pos>=1024)
return;
else
table_adress[pos]=addr | flags;
};
//Set up Paging for the first 4MB of physical memory
void setup_paging()
{
int i;
unsigned long adress;
adress=0;
for(i=0; i<1024; i++)
{
set_pagetableentry(i, adress, page_table, 3);
adress+=4096;
};
set_pagedirentry(0, page_table, 3);
for(i=1; i<1024; i++)
set_pagedirentry(i, (unsigned long*) 0, 2);
start_paging(page_dir);
};
I hope it helps helping me
