PCSX2 Documentation/So maybe it's about time we explained VTLB: Difference between revisions

no edit summary
(Created page with "''Originally written by Jake Stine'' Zerofrog documented the concepts of Virtual Memory a few years back. So now I figure it's VTLB's turn, since it's the new exclusive memor...")
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 13: Line 13:
The pseudo-code looks like this, as performed for a write memOp:
The pseudo-code looks like this, as performed for a write memOp:


<nowiki>
<source lang="cpp">
uint page = ps2_addr/4096;
uint page = ps2_addr/4096;
uptr pc_addr = vtlb_lookup[page];
uptr pc_addr = vtlb_lookup[page];
Line 22: Line 22:
{
{
     handler[page]( ps2_addr, data );
     handler[page]( ps2_addr, data );
}</nowiki>
}
</source>


By default, Pcsx2 utilizes the VTLB's handlers for several areas of Ps2 memory that hold hardware registers. Hardware registers are memory addresses that control the whats, whens, and hows of the Ps2 -- write to a specific memory address and the PS2 starts a DMA transfer, or changes the video mode, or plays a new audio sample. These writes have to be intercepted and handled by the emulator. The VTLB allows us to do that very efficiently.
By default, Pcsx2 utilizes the VTLB's handlers for several areas of Ps2 memory that hold hardware registers. Hardware registers are memory addresses that control the whats, whens, and hows of the Ps2 -- write to a specific memory address and the PS2 starts a DMA transfer, or changes the video mode, or plays a new audio sample. These writes have to be intercepted and handled by the emulator. The VTLB allows us to do that very efficiently.
Line 32: Line 33:
Ps2_Virtual_Address -> VTLB_Lookup -> Handler -> Ps2_Physical_Address
Ps2_Virtual_Address -> VTLB_Lookup -> Handler -> Ps2_Physical_Address


The benefits of this model are three-fold: efficiency, extensibility, and ease of debugging. If a game doesn't use the Ps2's TLB, then the VTLB will simply use direct memOps (fast!). If a game does happen to use the TLB, then VTLB can remap the memory as needed, allowing that game to emulate correctly also without having to needlessly burden other games with the overhead of virtual memory remapping logic. And to top it all off, handler mappings can be traced and dumped quickly and easily at any stage of emulation. Smile
The benefits of this model are three-fold: efficiency, extensibility, and ease of debugging. If a game doesn't use the Ps2's TLB, then the VTLB will simply use direct memOps (fast!). If a game does happen to use the TLB, then VTLB can remap the memory as needed, allowing that game to emulate correctly also without having to needlessly burden other games with the overhead of virtual memory remapping logic. And to top it all off, handler mappings can be traced and dumped quickly and easily at any stage of emulation. :)
 
 
{{PCSX2 Documentation Navbox}}
ninja
782

edits