I've now succesfully built a user mode app which calls ME functions from a kernel mode prx. After the app has initialized the ME it calls scePowerSetClockFrequency() and then freezes. I removed that call and then the app freezes somewhere else, at this stage I don't know where. None of this problems occur if the app is a kernel mode module which statically links the ME routines.
Can anyone explain this behaviour?
EDIT: I can upload the application source code if someone requires it, it's pmpmod 202b with Raphael's subtitle patch.
WPA support in kernel mode apps for 3.03oe
Are you making your functions look like this?jockyw2001 wrote:I've now succesfully built a user mode app which calls ME functions from a kernel mode prx. After the app has initialized the ME it calls scePowerSetClockFrequency() and then freezes. I removed that call and then the app freezes somewhere else, at this stage I don't know where. None of this problems occur if the app is a kernel mode module which statically links the ME routines.
Can anyone explain this behaviour?
EDIT: I can upload the application source code if someone requires it, it's pmpmod 202b with Raphael's subtitle patch.
Code: Select all
int k1 = pspSdkSetK1(0);
code...;
pspSdkSetK1(k1);
return something;
-
- Posts: 339
- Joined: Thu Sep 29, 2005 4:19 pm
moonlight: Is that a suggestion for avoiding the freeze caused by calling scePowerSetClockFrequency() ? Is it just surrounding the call with it? Didn't find much about pspSdkSetK1() other than here:
http://forums.ps2dev.org/viewtopic.php? ... spsdksetk1
I found the cause for the other freezes: the ME can only access kernel mode memory and I was passing it function pointers which are in user mode memory. The solution is a self contained kernel mode ME prx which unfortunately isn't as small as originally intended.
By doing that I stumbled over another problem, exporting variables, which I will post in the "building PRXes" thread:
http://forums.ps2dev.org/viewtopic.php?t=4269
EDIT1:
moonlight: I thought about your reply, do you mean with pspSdkSetK1(0) I can run user mode functions in the ME like this?
EDIT2: I found some more info about pspSdkSetK1()
http://forums.ps2dev.org/viewtopic.php? ... spsdksetk1
I found the cause for the other freezes: the ME can only access kernel mode memory and I was passing it function pointers which are in user mode memory. The solution is a self contained kernel mode ME prx which unfortunately isn't as small as originally intended.
By doing that I stumbled over another problem, exporting variables, which I will post in the "building PRXes" thread:
http://forums.ps2dev.org/viewtopic.php?t=4269
EDIT1:
moonlight: I thought about your reply, do you mean with pspSdkSetK1(0) I can run user mode functions in the ME like this?
Code: Select all
void me_function(int unused)
{
while (1) // ME runs this loop forever
{
while (nocache->start == 0); // me_start() breaks out of this loop by setting start=1 and end=0
nocache->start = 0;
nocache->k1 = pspSdkSetK1(0);
nocache->func(nocache->param); // run our function in ME
pspSdkSetK1(nocache->k1);
nocache->end = 1;
}
}
Code: Select all
Set the processors K1 register to a known value.
Note:
This function is for use in kernel mode syscall exports. The kernel sets the k1 register to indicate what mode called the function, i.e. whether it was directly called, was called via a syscall from a kernel thread or called via a syscall from a user thread. By setting k1 to 0 before doing anything in your code you can make the other functions think you are calling from a kernel thread and therefore disable numerous protections.
Parameters:
k1 - The k1 value to set
Returns:
The previous value of k1