Paging problem (memory is filled after every read)

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
tarrox
Posts: 19
Joined: Wed Dec 31, 2008 8:40 am

Paging problem (memory is filled after every read)

Post by tarrox »

Hello,
I am trying to implement Paging and for so far the paging works. I have paging enabled and there arent any errors so far.
It is also no problem to map a page to the virtual address, but now i get a strange problem. I can give a pointer the address so far, but when i am accessing the content, it is making strange things. I can write to the address, but after i looked what is written in it, the accessed memory is written full with 1. For example:

Code: Select all

//Maps a page
map_page(paging.get_kernel_directory(), (u32int*)0x10000000, (u32int*)memory.get_page(NMEMORY::UPPER_MEM), FPAGING_IS_WRITEABLE);
//a Pointer
u32int* tmp;
//gives the pointer an address of the new mapped virtual space
tmp = (u32int*)0x10000010;
//prints the given address, it is correct
std::cout<<"Addr: "<<std::HEX<<(u32int)tmp<<"\n";
//prints the content of the address space, it should be 0x0, because it is a new page, but it is 0xFFFFFFFF
std::cout<<"inhalt: "<<std::HEX<<*tmp<<"\n";
//Now i am writing into the memory
*tmp = 10;
//It worked he prints 0xA
console.writeint_hex(*tmp);
//It stoped working it prints 0xFFFFFFFF, why the hell?
console.writeint_hex(*tmp);
//Now i could make the thing over and over^^
I though it could be the virtual Machine i am testing on but with bochs and VirtualPC it is the same error. And in VirtualBox it only changes OxFFFFFFFF to 0x0.

I dont know where the problem is and what the problem is. I hope someone of you knows maybe the problem, or has an idea what to do. The code itself ended up being pretty much the same as the new code of JamesM's paging code, but if you want i can post it.

MfG Tarrox.
Last edited by tarrox on Thu Jan 22, 2009 9:10 am, edited 1 time in total.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Paging problem (memory is filled after evry read)

Post by Brendan »

Hi,

Try this piece by itself:

Code: Select all

u32int* tmp;
tmp = (u32int*)0x10000010;
std::cout<<"Addr: "<<std::HEX<<(u32int)tmp<<"\n";
I'm guessing that paging has nothing to do with the problem... ;)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Paging problem (memory is filled after every read)

Post by thepowersgang »

Try running it with the Bochs debugger and place a write watch point on the physical address that tmp points to (use `watch write <physaddr>`)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Paging problem (memory is filled after every read)

Post by Combuster »

And in VirtualBox it only changes OxFFFFFFFF to 0x0.
Sounds like accessing unconnected memory...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
tarrox
Posts: 19
Joined: Wed Dec 31, 2008 8:40 am

Re: Paging problem (memory is filled after every read)

Post by tarrox »

I tried the bochs debugger and found out that when i want to access a mapped place, i get an "Write outside the limits of physical memory" Error, which is ignored. I think this is the Problem, but how do i get rid of it, or better question what is my kernel doing to get something like this. Is it an error of the Paging or somewhere else.
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: Paging problem (memory is filled after every read)

Post by Firestryke31 »

It's an error with your paging code, because you're trying to write to RAM you don't have (or isn't really RAM). There are several ways to find how much RAM you really have, as well as where usable RAM is. One common way is to drop to real mode temporarily to use a BIOS function call (can't remember exactly which one, someone else will say) or, more often, to have it passed in by a boot loader (which most likely uses the BIOS function call). Also, remember that in the tables and directories, the value you write are the physical address (where it really is), and where you write it corresponds to the virtual address (where you want it).
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Post Reply