Page 1 of 1

Paging Problems...

Posted: Wed Oct 10, 2007 7:32 pm
by t0xic
After re-writing my paging code, every time I enable paging in my OS, I get a triple fault.
-Page directory is aligned(4096)
-IDT and GDT haven't been touched.
-ASM code (write_cr0, etc) is fine.

I see that it is a page fault(14) to address 0x001061c0, but all that is there are my isr/irq macro functions... I attached my code if someone wants to take the time to look at it.

Here is the error message... maybe I'm missing something you can see:

Code: Select all

03409746575i[KBD  ] reset-disable command received
03416715133i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
03416719898i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
03416724540i[BIOS ] *** int 15h function AX=00C0, BX=0000 not yet supported!
03509361341i[CPU0 ] protected mode
03509361341i[CPU0 ] CS.d_b = 32 bit
03509361341i[CPU0 ] SS.d_b = 32 bit
03509361341i[CPU0 ] | EAX=80000011  EBX=0002bd40  ECX=00066e88  EDX=00066e88
03509361341i[CPU0 ] | ESP=00066e68  EBP=00066e68  ESI=0002beb5  EDI=0002beb6
03509361341i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf SF zf af PF cf
03509361341i[CPU0 ] | SEG selector     base    limit G D
03509361341i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
03509361341i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 000fffff 1 1
03509361341i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 000fffff 1 1
03509361341i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 000fffff 1 1
03509361341i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 000fffff 1 1
03509361341i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 000fffff 1 1
03509361341i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 000fffff 1 1
03509361341i[CPU0 ] | EIP=00100b33 (00100b33)
03509361341i[CPU0 ] | CR0=0x80000011 CR1=0 CR2=0x001061c0
03509361341i[CPU0 ] | CR3=0x00108000 CR4=0x00000000
03509361341i[CPU0 ] >> add byte ptr ds:[eax], al : 0000
03509361341e[CPU0 ] exception(): 3rd (14) exception with no resolution, shutdown
 status is 00h, resetting
EDIT:
Looking at the objdump, it looks like the faulting address is my printf() function...

Thanks,
Michael

Posted: Wed Oct 10, 2007 10:56 pm
by AndrewAPrice
Okay, there are a few things wrong:

Code: Select all

ulong_t pt[1024];
You can't store your page table in pt for 2 reasons:
a) It's declared in side of a function so it'll lose scope and be removed from the stack when the function finishes.
b) The page table needs to be 4KB aligned! The last bits of the address are used as parameters (when 4KB these will be zerod), so

Code: Select all

currentdir[0] = pt;
won't work since it's not aligned. Also you need to set the bit to state that the table has an entry.

EDIT: I have the feeling your code is copy and pasted.

Posted: Wed Oct 10, 2007 10:58 pm
by jerryleecooper
edit, already answered, oops.

Posted: Thu Oct 11, 2007 2:54 am
by JamesM
Pah, I cba to download your code to look at it. Why don't you use the SVN repository googlecode gives you? Then I can view it online! :)

Posted: Thu Oct 11, 2007 5:11 am
by t0xic
Thanks, I'll update the code when i get home.

@JamesM. It WAS on there. But I', doing a complete re-write of my kernel, so I took it down.

Thanks again,

EDIT: @Andrw, yes, it is cp'ed for now. I just need an easy fix so I can start working on my multi-tasking.

Michael