page fault in setting up heap

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
goku
Member
Member
Posts: 29
Joined: Sat Oct 25, 2008 11:32 am
Location: until we meet again!!

page fault in setting up heap

Post by goku »

Hi
I am referring JamesM tutorial. While setting up the heap i am getting a page fault as

Page fault! ( present read-only ) at 0xc0100000 - EIP: 0x1002e7

Its causing a page fault when i try to when it executes the following statement in initialise_paging()

Code: Select all

kheap = create_heap(KHEAP_START, KHEAP_START+KHEAP_INITIAL_SIZE, 0xCFFFF000, 0, 0);
Using the print command i found that the page fault actually occurs in function place_ordered_array when it tries to clear the memory in which to place heap->index.

Code: Select all

memset(temp.array, 0, max_size*sizeof(type_t));
I am using Bochs and gcc on Ubuntu.I have also attached my code.Any help is appreciated.

Thanks.
Attachments
src.rar
(24.28 KiB) Downloaded 64 times
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: page fault in setting up heap

Post by CodeCat »

Has the memory you're trying to write to been mapped into your address space?
User avatar
goku
Member
Member
Posts: 29
Joined: Sat Oct 25, 2008 11:32 am
Location: until we meet again!!

Re: page fault in setting up heap

Post by goku »

Solved the problem. The pages were not loaded into the memory so had to increase the KHEAP_INITIAL_SIZE.
Also another change that was made was:

Code: Select all

for(i = KHEAP_START; i< KHEAP_START+KHEAP_INITIAL_SIZE; i += 0x1000)
	{
	get_page(i, 1, kernel_directory);
	}
to

Code: Select all

for(i = KHEAP_START; i< KHEAP_END; i += 0x1000)
	{
	get_page(i, 1, kernel_directory);
	}
so as to create entries for the entire heap in the page directory. I came across this bug on this forum itself. So if anyone using JamesM heap code do make the latter change (if not already present).

Thanks.
Post Reply