Next on my list is to get the main core interrupt picking up the media engine interrupt requests.
Enjoy :)
Code: Select all
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <pspdisplay.h>
#include <stdlib.h>
#include <string.h>
PSP_MODULE_INFO("meccode", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
#define printf pspDebugScreenPrintf
void me_stub(void);
void me_stub_end(void);
void me_startproc(u32 func, u32 param)
{
memcpy((void *)0xbfc00040, me_stub, (int)(me_stub_end - me_stub));
_sw(func, 0xbfc00600);
_sw(param, 0xbfc00604);
sceKernelDcacheWritebackAll();
sceSysregMeResetEnable();
sceSysregMeBusClockEnable();
sceSysregMeResetDisable();
}
unsigned int g_counter;
void my_function(int param)
{
volatile unsigned int *pctr = (volatile unsigned int *)(((int)&g_counter)|0x40000000);
while(1)
{
int x;
for (x = 0; x < 1024*1024; x ++);
(*pctr) += param;
}
}
int start_me(int argc, char *argv[])
{
me_startproc((u32)my_function,0x10000);
sceKernelExitDeleteThread(0);
return 0;
}
__attribute__((constructor))
void start_up(void)
{
void (*_start_me_func)(SceSize args, void *argp) = (void *)start_me;
_start_me_func = (void *) ((u32) _start_me_func | 0x80000000);
SceUID thid;
thid = sceKernelCreateThread("Start ME", (void *) _start_me_func, 1, 512, 0, 0);
sceKernelStartThread(thid, 0, 0);
}
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
int main(int argc, char *argv[])
{
pspDebugScreenInit();
SetupCallbacks();
while(1)
{
unsigned int *pctr = (unsigned int *)(((int)&g_counter)|0x40000000); // uncached read pointer
pspDebugScreenSetXY(0, 0);
pspDebugScreenPrintf("ME Basic Example, press Home to exit\n");
pspDebugScreenPrintf("ME Counter: %08x\n", *pctr);
sceDisplayWaitVblankStart();
}
return 0;
}