PDA

View Full Version : PSX Virtual Memory


egm
June 3rd, 2004, 01:24
I dont know if this is the best place to ask but...

As far as i know there is 3 memory segments, mirrors of 0x0 .. 0x01fffff. That are linear mirrored to the real RAM.

But in Joshua walker documents there is the TLB, used for translating Virtual Addresses to phisical ones.

But it's not suposed to be a linear proyection? Why the TLB is needed?

In other words if we can get the phisical address directly... why using TLB?

Thx a lot.

zenogais
June 3rd, 2004, 05:51
The TLB is used to control access to memory, this is to avoid two threads from accessing the same segment of memory at the same time. As the playstation does have support for multithreading, this is a method implemented into the Playstation to avoid threads overwriting each others memory and producing some generally nasty results. While you could get the physical address directly, I don't believe there is any way to circumvent the TLB. Hope this helps, you might check here for more info.

http://pj64.emulation64.com/emubook/

Theres a short section on Translation Lookaside Buffers in there, very informative :)

Xeven
June 3rd, 2004, 06:34
the psx uses a modified r3k cpu, with stripped mmu.

egm
June 3rd, 2004, 11:43
I have an idea about what are you saying, but... if the 3 segments are hard wired. What is the TLB responsability?

For example:

if you have a reference to 0x8000_0000, the fact is your are accesing to the physical 0x0000_0000. Then for translating this adress you DON'T use the TLB to translate.

When the TLB is used for translating?

however if you want to translate 0xFxxx_xxxx, what should i do? Because is not a valid segment as far as i know.

zenogais
June 4th, 2004, 00:02
I have an idea about what are you saying, but... if the 3 segments are hard wired. What is the TLB responsability?

For example:

if you have a reference to 0x8000_0000, the fact is your are accesing to the physical 0x0000_0000. Then for translating this adress you DON'T use the TLB to translate.

When the TLB is used for translating?

however if you want to translate 0xFxxx_xxxx, what should i do? Because is not a valid segment as far as i know.

The segments aren't hardwired, the TLB translates virtual addresses, so all address translations go through the TLB. Even if you are acessing an address that is not virtual memory, you are still going through the TLB. To answer your final question, since 0xF***_**** isn't a legitimate virtual address, a write to this address will probably fail.

Xeven
June 4th, 2004, 01:57
I have an idea about what are you saying, but... if the 3 segments are hard wired. What is the TLB responsability?

For example:

if you have a reference to 0x8000_0000, the fact is your are accesing to the physical 0x0000_0000. Then for translating this adress you DON'T use the TLB to translate.

When the TLB is used for translating?

however if you want to translate 0xFxxx_xxxx, what should i do? Because is not a valid segment as far as i know.
Most of the time when its writing to "unknown" memory space, the software is actually trying to do something specific to the psx. The only advice i can give you is to spend sometime reversing what the software is doing. For example, if the program accesses 0xFFFE0130, then it's doing something very specific. Depending on the data it's writing it might be isolating the cache, usually inorder to flush it.

egm
June 4th, 2004, 14:02
So, the fact is that every virtual adress is translated in TLB.

Then 0x8000_0000 is translated to 0x0000_0000 because the TLB is filled with data to resolve this translation. And in general the linear proyection of memory segments.

I imagine that when psx is booting, the TLB will be programed acordlingly. If not TLB can't resolve the physical adress.

Does the BIOS do that? ( I mean initializing TLB)

This is correct?

I cannot totally understand why a TLB is used if the Memory segments can be translated linearly. Like i don't think i'm smarter than Sony Engieers... Where i am wrong?

And thx a lot.

zenogais
June 8th, 2004, 02:34
So, the fact is that every virtual adress is translated in TLB.

Then 0x8000_0000 is translated to 0x0000_0000 because the TLB is filled with data to resolve this translation. And in general the linear proyection of memory segments.

I imagine that when psx is booting, the TLB will be programed acordlingly. If not TLB can't resolve the physical adress.

Does the BIOS do that? ( I mean initializing TLB)

This is correct?

I cannot totally understand why a TLB is used if the Memory segments can be translated linearly. Like i don't think i'm smarter than Sony Engieers... Where i am wrong?

And thx a lot.


I believe the TLB is hardware based, so therefore there is no initialization by the PSX required.

hal
June 14th, 2004, 01:01
Hi there. This is Josh, the guy who wrote that document....

Because the PSX has no Memeory manager, you can't use the TLB for refrencing protected memory segements, as the PSX has no protected memory...

However....

The three zones of memory *DO* cache differently and run at different speeds when common data is accessed.

I don't have the doc in front of me, but when you read 0x0000_0000 (K0) the CPU will not cache this access, however 0x8000_0000 will cache and will be quicker if you access it again. even though it's the same phyisical memory location.

If I remeber right, K0 is non cacheable, K1 is cachable and K2 is user selectable. I have't touch my doc in ages so I don't quite remeber. You will have to review it.

It's just a slick way to cacheing your memory

zenogais
June 14th, 2004, 01:06
Thanks very much for clearing that up Josh. :)