Page 2 of 2
Posted: Mon Feb 11, 2008 5:12 am
by JamesM
Now i am getting a new problem, there is general protection fault occuring after the page fault (both are happening) ...
Yes, calling INT 0xE explicitly WILL NOT WORK. The Page Fault exception has an error code associated with it, which will be pushed by the processor when an exception is encountered, but NOT when explicitly called via software interrupt.
I'll look through your code.
Posted: Mon Feb 11, 2008 5:59 am
by JamesM
Solved.
You missed out a line in your get_page() function.
Code: Select all
page_t *get_page(u32int address, int make, page_directory_t *dir)
{
// Turn the address into an index.
//size of each page is 4KB hence divide by 1024*4 to get the index
address /= 0x1000;
// Find the page table containing this address.
u32int table_idx = address/ 1024;
if (dir->tables[table_idx]) // If this table is already assigned
{
return &dir->tables[table_idx]->pages[address%1024];
}
else if(make)
{
u32int tmp;
dir->tables[table_idx] = (page_table_t*)kmalloc_ap(sizeof(page_table_t), &tmp);
memset(dir->tables[table_idx], 0, 0x1000); // THIS LINE WAS MISSING!
dir->tablesPhysical[table_idx] = tmp | 0x7; // PRESENT, RW, US.
return &dir->tables[table_idx]->pages[address%1024];
}
else
{
return 0;
}
}
JamesM
@SOLVED
Posted: Mon Feb 11, 2008 1:50 pm
by redDot
thanks for ur kind attention to my problem.
The info about the general protection fault came as a fresh air. At least one problem is solved.
Now regarding the second problem ???
I did wat u had mentioned, but still nothing is happening....
I tried to test ur floppy image, and its working perfectly, but when i write the code, as given in ur tutorial and the source code, its just not working ...
There must be something very minor that i am missing on, n its just going unnoticed, but the fight is still on, n m not going to give up so easily...
Posted: Mon Feb 11, 2008 2:52 pm
by JamesM
I'll check tomorrow when I get back to work. I think I added another memset() somewhere to keep in line with my sample code.
One thing to check is differences between the code snippets on the website and sample code given - the sample code always works. Sometimes I bugfix the sample code but forget to merge the changes into the main pages.
On another note: Please for the love of God clean up your code - it's FULL of warnings which make errors very difficult to read.
Posted: Tue Feb 12, 2008 9:14 am
by redDot
still no success...
i am posting the output of jame's kernel(running successfullly) and mine (sucks!!!),
james output is ...
Code: Select all
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x3f8/8 irq 4
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x378
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
00000000000i[ ] reset of 'serial' plugin device by virtual method
00000000000i[ ] reset of 'parallel' plugin device by virtual method
00000004256i[BIOS ] rombios.c,v 1.85.2.1 2003/01/16 21:58:42 cbothamy Exp $
00000330043i[KBD ] reset-disable command received
00000506792e[HD ] device set to 0 which does not exist
00000507085e[HD ] device set to 1 which does not exist
00000984058i[BIOS ] int15: Func 24h, subfunc 01h, A20 gate control not supported
00000989943i[BIOS ] int13_harddisk: function 41, unmapped device for DL=80
00000994443i[BIOS ] int13_harddisk: function 08, unmapped device for DL=80
00000998976i[BIOS ] *** int 15h function AX=00C0, BX=0000 not yet supported!
00001003473i[BIOS ] *** int 15h function AX=5300, BX=0000 not yet supported!
00001007887i[BIOS ] *** int 15h function AX=5304, BX=0000 not yet supported!
00038958500p[WGUI ] >>PANIC<< Window closed, exiting!
00038958500i[SYS ] Last time is 1202827468
00038958500i[CPU ] protected mode
00038958500i[CPU ] CS.d_b = 32 bit
00038958500i[CPU ] SS.d_b = 32 bit
00038958500i[CPU ] | EAX=00102031 EBX=0002d000 ECX=00067db8 EDX=000003d5
00038958500i[CPU ] | ESP=00067dd8 EBP=00067de0 ESI=00067eb8 EDI=00067e58
00038958500i[CPU ] | IOPL=0 NV UP DI PL NZ NA PE NC
00038958500i[CPU ] | SEG selector base limit G D
00038958500i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00038958500i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00038958500i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00038958500i[CPU ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00038958500i[CPU ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00038958500i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00038958500i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00038958500i[CPU ] | EIP=001006e8 (001006e8)
00038958500i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0xa0000000
00038958500i[CPU ] | CR3=0x00106000 CR4=0x00000000
00038958500i[ ] restoring default signal behavior
00038958500i[CTRL ] quit_sim called with exit code 1
and mine is ...
Code: Select all
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[ ] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x3f8/8 irq 4
00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x378
00000000000i[ ] reset of 'harddrv' plugin device by virtual method
00000000000i[ ] reset of 'keyboard' plugin device by virtual method
00000000000i[ ] reset of 'serial' plugin device by virtual method
00000000000i[ ] reset of 'parallel' plugin device by virtual method
00000004256i[BIOS ] rombios.c,v 1.85.2.1 2003/01/16 21:58:42 cbothamy Exp $
00000330043i[KBD ] reset-disable command received
00000506792e[HD ] device set to 0 which does not exist
00000507085e[HD ] device set to 1 which does not exist
00042738500p[WGUI ] >>PANIC<< POWER button turned off.
00042738500i[SYS ] Last time is 1202827957
00042738500i[CPU ] protected mode
00042738500i[CPU ] CS.d_b = 32 bit
00042738500i[CPU ] SS.d_b = 32 bit
00042738500i[CPU ] | EAX=00000018 EBX=00026260 ECX=000b8000 EDX=0010036f
00042738500i[CPU ] | ESP=00104fe0 EBP=00067edc ESI=00026373 EDI=00026385
00042738500i[CPU ] | IOPL=0 NV UP DI PL NZ NA PO NC
00042738500i[CPU ] | SEG selector base limit G D
00042738500i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00042738500i[CPU ] | DS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00042738500i[CPU ] | ES:0010( 0002| 0| 0) 00000000 000fffff 1 1
00042738500i[CPU ] | FS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00042738500i[CPU ] | GS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00042738500i[CPU ] | SS:0010( 0002| 0| 0) 00000000 000fffff 1 1
00042738500i[CPU ] | CS:0008( 0001| 0| 0) 00000000 000fffff 1 1
00042738500i[CPU ] | EIP=001003ef (001003ef)
00042738500i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x00000000
00042738500i[CPU ] | CR3=0x00108000 CR4=0x00000000
00042738500i[ ] restoring default signal behavior
00042738500i[CTRL ] quit_sim called with exit code 1
as you can notice the lines
Code: Select all
00000506792e[HD ] device set to 0 which does not exist
00000507085e[HD ] device set to 1 which does not exist
00000984058i[BIOS ] int15: Func 24h, subfunc 01h, A20 gate control not supported
00000989943i[BIOS ] int13_harddisk: function 41, unmapped device for DL=80
00000994443i[BIOS ] int13_harddisk: function 08, unmapped device for DL=80
00000998976i[BIOS ] *** int 15h function AX=00C0, BX=0000 not yet supported!
00001003473i[BIOS ] *** int 15h function AX=5300, BX=0000 not yet supported!
00001007887i[BIOS ] *** int 15h function AX=5304, BX=0000 not yet supported!
00038958500p[WGUI ] >>PANIC<< Window closed, exiting!
clearly shows that page fault has happened and its being processed ...
nothing like this is present in my output...
why ???
Posted: Tue Feb 12, 2008 9:25 am
by AJ
How do those lines show the page fault has happened? Looks like a normal Bochs main window shutdown to me.
Please try zeroing all your page tables and page directory before you start using them. I'm almost certain that the only way an access to 0xA0000000 is *not* causing a page fault, is if either paging is not enabled (which it is) or if that page is already present.
The way you can tell a page fault (other than a NULL page fault) has *not* occurred on your system, is that CR2 is clear.
Cheers,
Adam
Posted: Tue Feb 12, 2008 9:28 am
by JamesM
Code: Select all
// Let's make a page directory.
kernel_directory = (page_directory_t*)kmalloc_a(sizeof(page_directory_t));
memset(kernel_directory, 0, sizeof(page_directory_t)); // JAMESM CHANGED
current_directory = kernel_directory;
kernel_directory->physicalAddr = (u32int)kernel_directory->tablesPhysical;
Line added in page.c, to bring it in line with my tutorial code. That memset is required.
Posted: Tue Feb 12, 2008 9:44 am
by redDot
if either paging is not enabled (which it is)
how are you reaching to this conclusion that paging has not been enabled?
as it can be seen,
Code: Select all
00042738500i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x00000000
00042738500i[CPU ] | CR3=0x00108000 CR4=0x00000000
the cr0 has a 1 in the bit 31, and there is some value in cr3(supposse to be the physical table address)...
i have initialised the table with 0s
Code: Select all
kernel_directory = (page_directory_t*)kmalloc_a(sizeof(page_directory_t));
memset(kernel_directory,0,sizeof(page_directory_t));
current_directory = kernel_directory;
Posted: Tue Feb 12, 2008 9:58 am
by JamesM
Dude, that *works* for me.
Posted: Tue Feb 12, 2008 10:00 am
by AJ
redDot wrote:if either paging is not enabled (which it is)
how are you reaching to this conclusion that paging has not been enabled?
as it can be seen,
Code: Select all
00042738500i[CPU ] | CR0=0xe0000011 CR1=0x00000000 CR2=0x00000000
00042738500i[CPU ] | CR3=0x00108000 CR4=0x00000000
the cr0 has a 1 in the bit 31, and there is some value in cr3(supposse to be the physical table address)...
Sorry for the double negative. I mentioned that there are only two ways your code is not causing a page fault. One of these ways was if paging is not enabled. But it is. So that's not causing the fault. So it's the other option.
Posted: Tue Feb 12, 2008 12:57 pm
by redDot
let me try jame's code....
EUREKA EUREKA EUREKA !!!! Its done !!!!
Posted: Tue Feb 12, 2008 1:48 pm
by redDot
thanks to all u geniuses, its working now !!!
james, thanks for ur time. I really really appriciate the attention that you gave to my problem. Also AJ and everyone else, thanks for ur support.
Ok, now let me do some biopsy of the problem...
james returned me the code with some modification,
he added the lines
Code: Select all
1)memset(kernel_directory,0,sizeof(page_directory_t));
2)kernel_directory->physicalAddr = (u32int)kernel_directory->tablesPhysical;
3)memset(dir->tables[table_idx],0,0x1000);
&
added this to the main for testing page fault
1)*ptr = 99999;
what he did was initialized the directories and tables to 0...
and also initialized the member physicalAddr, which was not done earlier.
well, what made the code run was the last addition,
i only added this line to my previous code, (without the 1st three changes), and it shows a page fault.
Whats so special about this *ptr = 99999; ???
when earlier, we tried to invoke the page fault by
it wasn't getting invoked, but with *ptr = 99999; it is ????
why ?
Posted: Wed Feb 13, 2008 2:52 am
by JamesM
I added that because you're using different optimisation levels to me. I believe the compiler removed the "do_page_fault=bleh" line, but forcing a write to memory is unoptimisable.
Posted: Wed Feb 13, 2008 5:48 am
by redDot
Learnt a lot of new things during the 'paging errors'...
should have thought about the compiler optimization issues during debugging...
m working on the heap part now...
thanks...