SCRATCH PAD - Does the kernel use it ?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

SCRATCH PAD - Does the kernel use it ?

Post by hlide »

Hi,

PSP does have a scratch pad (0×00010000 - 0×00014000 (16 KiB)). Scratch pad is usually a faster memory than other memories. I was wondering if kernel or user libraries (i mean not ours) do really use it or it is eventually free for our purpose ? can it be cached ? or is it irrelevant ?
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

It's been said on IRC that the scratchpad ram ends up being no faster than normal ram on the PSP, haven't tested it myself though.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

not slower too ?

well, I remember when I was working on SH1, there is another reason to use scratch pad : to avoid both instructions and data to be fetched from the external bus (DRAM here) by running instructions in scratch pad to make memory transfer faster. But, well, there was no cache and it was running at 10 MHz.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Based on the odd system diagram which Sony have put out it looks like scratchpad is not really internal to the CPU (like on most processors where it has that name) but actually somewhere on the external bus, so you dont even get normal speed + no bus access it seems :(
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

At the presentation at BP2005, if I remember correctly, the presenter mentioned that there is a hardware bug that causes scratchpad RAM to be way slower than was intended. If it is separate from the CPU and actually is on the bus however as Tyranid says, I would call that bad design, not a bug :)
http://www.dtek.chalmers.se/~tronic/PSPTexTool.zip Free texture converter for PSP with source. More to come.
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

i have messed around with writing stuff to the scratchpad, and it didnt affect anything (atleast i didnt notice =D) and the data i wrote there also stayed unmodified...

but yeah its true, its not usefull for speedups (like it was on good old psx) :/
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Well there is a flag in CreateThread to allocate the stack on the scratch pad (think it is 1.5+ only) but none of the kernel threads use that flag afaik.
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

okay, to sum up :

1) scratch pad access is not more or less fast as main memory access due to the necessity for both to pass through an external bus. Sure, scratch pad sounds like a misname :/ and mostly a bad design rather than a bug indeed.

2) kernel doesn't use it, al least, for the running life of an application.

well, scratch pad still offers us 16 KiB for free.

By the way, do you know if GP is used by kernel ? by pspdev ? or can I set with my own address ?
Exophase
Posts: 2
Joined: Mon Nov 06, 2006 3:54 pm

Post by Exophase »

hlide wrote:okay, to sum up :
By the way, do you know if GP is used by kernel ? by pspdev ? or can I set with my own address ?
GP is not a kernel register, but the compiler will use it to access global variables. You can set it to whatever you want, just be sure that when you call non-ASM functions to set it to whatever it was when you started running the assembly code.
Post Reply