| View previous topic :: View next topic |
| Author |
Message |
Hellcat
Joined: 24 Jan 2007 Posts: 84
|
Posted: Wed Jan 16, 2008 3:46 pm Post subject: Calling a function in .PRX #1 from .PRX #2 via pointer.....? |
|
|
Hi all :)
In one .PRX (kernel mode) I have something like this:
| Code: | void (*myCallback)(void* someparameter);
....
void SomeFunction(void* apointer)
{
// some code here
myCallback(apointer);
// some code here
}
void SetCB(void* cbFunc)
{
myCallback = cbFunc;
} |
In another .PRX (usermode, this time) I have something like that:
| Code: | void BlahFunction(void* something)
{
// do something here
}
int main(...)
{
// some more code here
SetCB(&BlahFunction);
// some more code here
} |
Now, everything looks fine up to the instant my kernel PRX calls myCallback() - there the PSP crashs and shuts off....
The pointer to the function has been set before the kernel PRX can try to call the usermode PRX the first time, that's for sure.
The usermode PRX also didn't get unloaded while sitting around....
Maybe I just can't call userland stuff from kernelland?
Anyone any idea what I missed?
Pleeeaaase? :) |
|
| Back to top |
|
 |
KickinAezz
Joined: 03 Jun 2007 Posts: 328
|
Posted: Fri Jan 18, 2008 8:11 am Post subject: |
|
|
Back to basics,
Arent you using exports and imports? _________________ Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming. |
|
| Back to top |
|
 |
crazyc
Joined: 17 Jun 2005 Posts: 410
|
Posted: Fri Jan 18, 2008 1:18 pm Post subject: Re: Calling a function in .PRX #1 from .PRX #2 via pointer.. |
|
|
| Hellcat wrote: | Now, everything looks fine up to the instant my kernel PRX calls myCallback() - there the PSP crashs and shuts off....
| What are you trying to do here? |
|
| Back to top |
|
 |
Hellcat
Joined: 24 Jan 2007 Posts: 84
|
Posted: Fri Jan 18, 2008 7:06 pm Post subject: Re: Calling a function in .PRX #1 from .PRX #2 via pointer.. |
|
|
| KickinAezz wrote: | Back to basics,
Arent you using exports and imports? |
No, I wanted to pass the address of a function in PRX #1 over to PXR #2, so that PRX #2 could then directly call it....
| crazyc wrote: | | What are you trying to do here? |
I wanted to have PRX #1 engage in some action when PRX #2 tells it to do so.
(PRX #2 had to do some things before PRX #1 could do it's job and I wanted to prevent a loop that constantly checks if there's something to do....)
However, I managed to get exactely what I need by the use of "real" callbacks/callbackthreads.
I set up a callbackthread just like it's done for the exit-callback of the home button.
I posted a sample here of how I did set it up :) |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Fri Jan 18, 2008 8:48 pm Post subject: |
|
|
| You shouldn't call a user function from kernel mode. But if you do, make sure to "OR" the function address with 0x80000000, and be careful because that function would be still called in kernel mode, and depending of what user functions it calls, it could crash. |
|
| Back to top |
|
 |
Hellcat
Joined: 24 Jan 2007 Posts: 84
|
Posted: Fri Jan 18, 2008 9:36 pm Post subject: |
|
|
Yep, that's exactely what I got, crash over crash....
Already thought it's a bad idea at all to jump into "usercode" from kernel.
That's the main reason I started digging into real callback threads like the exit_game one.
Turned out to be more easy than I thought :)
And it's working flawlessly, no crashs anymore, even with intense printf usage....
And that brought me right into my next problem *lol* savegame reading/writing.... |
|
| Back to top |
|
 |
|