Page 1 of 1
Access memory >= 400000h cause stack fault
Posted: Sat Sep 01, 2007 9:42 am
by 2442_m4
I'm pretty sure this has been up before, I can't just find it.
I'm pretty new to os developing, and my kernel is everything but complete.
Teh question: Do I need to do anything special to access memory over the 4MB border? I have a pointer, that points to a memory location, and use it to check in the memory it points to is equal to 0. When it points to anything below 3FFFFF, it works, but if I change it to 400000, I get this error.
Most of the code is "borrowed" from
http://osdever.net/bkerndev/index.php .
The "debug-code" i used to find the problem looks like this
Code: Select all
char *pointer = (char *) 0x400000;
if (*pointer == 0x00)
{
k_set_txtm_byte(0,2,0x16,"M");
};
Posted: Sat Sep 01, 2007 10:04 am
by jerryleecooper
First, are you sure your emulator is not set to 4mb?
Second, it can be a problem with your limit fields in your gdt
4mb, I don't know, it does mean it's 24bit addresses? can be the gdt, or the emulator not set to higher mem
Posted: Sat Sep 01, 2007 10:08 am
by 2442_m4
I'll check the gdt.
The emulator (VmWare) is set to 192MB what I can see. I've also tried a real computer, it just reset. (witch is what VmWare said whould happen.)
EDIT: GDT looks ok.
Posted: Sat Sep 01, 2007 10:47 am
by jerryleecooper
2442_m4 wrote:I'll check the gdt.
The emulator (VmWare) is set to 192MB what I can see. I've also tried a real computer, it just reset. (witch is what VmWare said whould happen.)
EDIT: GDT looks ok.
Ttry it in bochs, it will give some usefull insights from the bochsout file.
Posted: Sat Sep 01, 2007 11:03 am
by 2442_m4
Well, got some output. But i don't have any idea about how I shall fix it
Code: Select all
00001686350i[CPU0 ] CS.d_b = 32 bit
00001686350i[CPU0 ] SS.d_b = 32 bit
00001686350i[CPU0 ] | EAX=00400000 EBX=00000fff ECX=00000010 EDX=000b8003
00001686350i[CPU0 ] | ESP=000007f0 EBP=000007f8 ESI=00000fff EDI=000c3000
00001686350i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af PF cf
00001686350i[CPU0 ] | SEG selector base limit G D
00001686350i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00001686350i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 000ffbff 1 1
00001686350i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001686350i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001686350i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001686350i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001686350i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00001686350i[CPU0 ] | EIP=ff800197 (ff800197)
00001686350i[CPU0 ] | CR0=0x80000011 CR1=0 CR2=0x00400000
00001686350i[CPU0 ] | CR3=0x0009e000 CR4=0x00000000
00001686350i[CPU0 ] >> cmp byte ptr ds:[eax], 0x00 : 803800
00001686350e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
That's the output I get (That i think have anything with this to do?)
Anyone bother to think out/post whats causing it?
Posted: Sat Sep 01, 2007 12:08 pm
by jerryleecooper
You triple faulted. Also, I see that your code segment has ffbff as its value, not good.
Posted: Sat Sep 01, 2007 12:17 pm
by frank
You are getting a page fault. The first 4mb is identity mapped by your bootloader. Because you don't have an IDT the code triple faults.
Posted: Sat Sep 01, 2007 12:34 pm
by 2442_m4
Thanks!
That was the answer I was looking for. Will try when I get the Dev-machine working again...
EDIT: I don't understand a **** about IDT, does anyone know a good tutorial? The only thing I found in the wiki was complete gibberish to me, nothing seemed to affect the memory, but that's probibly me who don't understand what I read...