Interrupt Controller
Interrupt Controller
Hi to all. Actualy I am just started PSP Development.
Can somebody promt me where to read in details about Interrupt Controller on PSP and how to programm it, because "The Naked PSP" and "PSPSDK Doc" gives only light mention about it existance.
I tryed using some functions from pspintrman.h and pspintrman_kernel.h but my programms even not loaded.
Great thx for all help.
Can somebody promt me where to read in details about Interrupt Controller on PSP and how to programm it, because "The Naked PSP" and "PSPSDK Doc" gives only light mention about it existance.
I tryed using some functions from pspintrman.h and pspintrman_kernel.h but my programms even not loaded.
Great thx for all help.
uhmm... you just started, and you already want to use IRQs and NMIs? what an idea... Check groepaz's docs (google for yapspd) if needed... And since the PSP got a VERY good API set already, why would you need such low level? It's not a GBA, ya know? Everything is handled thry sce* libs: display, sound, pad...
Bump. Sorry to say it, but if you didn't manage to get it working with sce*, you won't be able to go much further... Did you set the MAIN_THREAD_ATTR to 0? and 0x1000 attr in MODULE_INFO?Cy-4AH wrote:I tryed functions sceKernelRegisterIntrHandler and sceKernelDisableIntr in programm with PSP_MODULE_KERNEL attribute but it stopped after calling them. So I'd like to know how to use them.
Also I'd like to know PSP ASM commands.
Yes, when I useadrahil wrote:Bump. Sorry to say it, but if you didn't manage to get it working with sce*, you won't be able to go much further... Did you set the MAIN_THREAD_ATTR to 0? and 0x1000 attr in MODULE_INFO?
programm even not start,PSP_MODULE_INFO("Irq Test", PSP_MODULE_USER, 1, 1);
when
programm crash when calling sceKernelRegisterIntrHandler or sceKernelDisableIntr.[/quote]PSP_MODULE_INFO("Irq Test", PSP_MODULE_KERNEL, 1, 1);
Ok, now I back to problem with Interrupt Controller.
Resently I found in psplink sources
And then found topick http://forums.ps2dev.org/viewtopic.php? ... 7f3c53508c with TyRaNiD advice to use void *func = (void *) ((unsigned int) intr_handler | 0x80000000);
So, there is my code:
FW 3.03OE-C
In both cases I get error code 0x80020067.
What's wrong with this code?
Resently I found in psplink sources
Code: Select all
sceKernelRegisterIntrHandler(PSP_HPREMOTE_INT, 1, intr_handler, NULL, NULL);
sceKernelEnableIntr(PSP_HPREMOTE_INT);
So, there is my code:
Code: Select all
#include <CyLib.h>
PSP_MODULE_INFO("IntTest", PSP_MODULE_KERNEL, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
#define SC 200000
static int handler (void *p)
{
pspDebugScreenPrintf("handler\n");
return -1;
}
int main()
{
bool need_exit;
SetupCallbacks(&need_exit);
pspDebugScreenInit();
sceCtrlSetSamplingCycle(SC);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
SceCtrlLatch latch;
int res = sceKernelRegisterIntrHandler(PSP_HPREMOTE_INT, 1, (void*)handler, NULL, NULL);
pspDebugScreenPrintf("Intr Init Res: 0x%08X\n", res);
void *func = (void *) ((unsigned int) handler | 0x80000000);
res = sceKernelRegisterIntrHandler(PSP_HPREMOTE_INT, 1, func, NULL, NULL);
pspDebugScreenPrintf("Intr Init Res: 0x%08X\n", res);
pspDebugScreenPrintf("press triangle for exit\n");
while (!need_exit)
{
sceCtrlReadLatch(&latch);
if (latch.uiMake & PSP_CTRL_TRIANGLE) need_exit = true;
}
sceKernelExitGame();
return 0;
}
Code: Select all
TARGET = IntTest
OBJS = IntTest.o ../CyLib/Src/CyLib.o
CFLAGS = -O2 -G0 -Wall -I../CyLib/Include
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBS= -lpspgu
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = IntTest
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
In both cases I get error code 0x80020067.
What's wrong with this code?
Thx, adrahil, now I know where find meaning of error codes. BTW, do you know if some one wrote lib, where I can find function that convert error code to readable string?
And now next problem: I want call old irq handler in my handler, so I'd like to know how get its offset.
I was theanking that sceKernelRegisterIntrHandler gives me old handler, but I don't know how, because of
May be there is exist flag, that make psp replace irq handler with mine and return old handler in arg2.
So I found function QueryIntrHandlerInfo. And use it in that way:
Functions sceKernelReleaseIntrHandler and sceKernelRegisterIntrHandler return 0, but QueryIntrHandlerInfo return 0x8002006B witch mean ILLEGAL_INTRPARAM. And now I can't understand what is illegal in IRQ, SUB_IRQ and pointer to int_par, if thay worked for sceKernelRegisterIntrHandler and sceKernelReleaseIntrHandler
And now next problem: I want call old irq handler in my handler, so I'd like to know how get its offset.
I was theanking that sceKernelRegisterIntrHandler gives me old handler, but I don't know how, because of
Code: Select all
arg1 - Unknown (probably a set of flags)
arg2 - Unknown (probably a common pointer)
So I found function QueryIntrHandlerInfo. And use it in that way:
Code: Select all
int arg1 = 0, arg2 = 0, res;
PspIntrHandlerOptionParam int_par;
sceKernelDisableIntr(IRQ);
res = QueryIntrHandlerInfo(IRQ, SUB_IRQ, &int_par);
pspDebugScreenPrintf("Query Res: 0x%08X 0x%08X\n", res, int_par.entry);
res = sceKernelReleaseIntrHandler(IRQ);
pspDebugScreenPrintf("Intr Release Res: 0x%08X\n", res);
void *func = (void *) ((unsigned int) handler | 0x80000000);
res = sceKernelRegisterIntrHandler(IRQ, SUB_IRQ, func, NULL, NULL);
pspDebugScreenPrintf("Intr Init Res: 0x%08X\n0x%08X\n", res, arg1);
res = QueryIntrHandlerInfo(IRQ, SUB_IRQ, &int_par);
pspDebugScreenPrintf("Query Res: 0x%08X 0x%08X 0x%08X\n", res, int_par.entry, handler);
sceKernelEnableIntr(IRQ);
which of the first or the second QueryIntrHandlerInfo returns 0x8002006B ?
i think SUBIRQ must be between 0 and 31, but here for PSP_HPREMOTE, you don't have subirq, so you probably need to give 0 instead of 1, assuming for IRQ having no subirq have a SUBIRQ # to 0.
i think SUBIRQ must be between 0 and 31, but here for PSP_HPREMOTE, you don't have subirq, so you probably need to give 0 instead of 1, assuming for IRQ having no subirq have a SUBIRQ # to 0.
Last edited by hlide on Fri Mar 16, 2007 8:50 pm, edited 1 time in total.
just before calling QueryIntrHandlerInfo, try to do :
maybe this param needs that you put the size of your structure (in case of different structure for old firmware revisions, meseems to recall something like that).
Code: Select all
memset(&int_par, 0, sizeof(int_par));
int_par.size = sizeof(int_par);
An partial answer is given here : http://forums.ps2dev.org/viewtopic.php? ... andlerinfo
this topic said it always returns this error code for system intr, but you can still get infos apparently.
But I strongly suggest for you to try to set the size in int_parm if it discards the error code.
this topic said it always returns this error code for system intr, but you can still get infos apparently.
But I strongly suggest for you to try to set the size in int_parm if it discards the error code.
By the way, this function doesn't have an usual naming : we should normally have sceKernelQueryIntrHandlerInfo. So i suspect it to be an internal function (exported for only internal usage, i mean). It means that the param structure may change between firmware versions. The size may be a helper for the function to check if a program calls this function with an old param structure (size being different). Only my guess. I may be totally wrong of course.
Sorry for all day noob questions, but how call old handler?
I have such code, that didn't work:
Look like all perfectly inited, but when interrupt occur I see on PSP Screen "handler 0x..." and after few seconds PSP shut down.
I have such code, that didn't work:
Code: Select all
int (*old_handler)(void*);
int handler (void *p)
{
pspDebugScreenPrintf("handler 0x%08X\n", old_handler);
return (*old_handler)(p);
}
int main()
{
...
memset(&int_par, 0, sizeof(PspIntrHandlerOptionParam));
int_par.size = sizeof(PspIntrHandlerOptionParam);
res = QueryIntrHandlerInfo(IRQ, SUB_IRQ, &int_par);
old_handler = (int (*)(void*))int_par.entry;
pspDebugScreenPrintf("Query Res: 0x%08X 0x%08X 0x%08X\n", res, int_par.entry, old_handler);
...
i would suggest you to have a simple counter instead of pspDebugScreenPrintf in your handler and polling this counter in the main function. That way you will know if pspDebugScreenPrintf is not the trouble.Cy-4AH wrote: Look like all perfectly inited, but when interrupt occur I see on PSP Screen "handler 0x..." and after few seconds PSP shut down.