As I wrote: if I do not reset the iop, then the modules are loaded correctly (from buffer). At first I used the dma-ing function for upload to IOP and then SifLoadBuffer call. Current code use the SifExecModuleBuffer() function only.
The data buffer is alligned like this:
unsigned char usbd[] __attribute__((aligned(64))) = {
0x7F, 0x45, 0x4C, 0x46,.......
};
Both versions give me the same results (ExecBuffer use the LoadBuffer too). When IOP is reset(NULL, 0), loadBuffer returns the iop address. When IOP is reset("rom0:UDNL rom0:EELOADCNF",0) then loadBuffers freeze the EE.
My test code that doesn't work for me is here:
Code: Select all
#include <tamtypes.h>
#include <kernel.h>
#include <iopheap.h>
#include <sifrpc.h>
#include <sifcmd.h>
#include <loadfile.h>
#include "sbv_patches.h"
#include "iopcontrol.h"
#include "usbd.h" //usbd.irx module
#include "usbtest.h" //usbtest.irx module
#include "usbtest_size.h"
/*
// content of these header files:
int usbd_size = 33216;
unsigned char usbd[] __attribute__((aligned(64))) = {
0x7F, 0x45, 0x4C, 0x46,.....
};
*/
#define USB_TEST 0x500C0F1
static SifRpcClientData_t client __attribute__((aligned(64)));
unsigned char rpcBuffer[2048] __attribute__((aligned(64)));
void printMessage()
{
SifCallRpc(&client,0,0,(void*)(&rpcBuffer[0]),0,(void*)(&rpcBuffer[0]),2048,0,0);
if (rpcBuffer[0] == 0) {
return;
}
scr_printf("%s", rpcBuffer);
SifCallRpc(&client,1,0,(void*)(&rpcBuffer[0]),0,(void*)(&rpcBuffer[0]),128,0,0);
}
void initUsb()
{
SifCallRpc(&client,2,0,(void*)(&rpcBuffer[0]),0,(void*)(&rpcBuffer[0]),128,0,0);
}
void loadModules() {
int ret;
int iop_ret;
SifInitIopHeap();
SifLoadFileInit();
fioInit();
ret = SifExecModuleBuffer(usbd, usbd_size, 0, NULL, &iop_ret);
if (ret < 0) {
scr_printf("sifLoadModule %s failed: %d\n", "usbd", ret);
while(1);
} else scr_printf("usbd.irx ok ret=%i\n", ret );
ret = SifExecModuleBuffer(usbtest, usbtest_size, 0, NULL, &iop_ret);
if (ret < 0) {
scr_printf("sifLoadModule %s failed: %d\n", "test", ret);
while(1);
} else {
scr_printf("test.irx ok. ret=%i \n", ret);
}
//short delay
ret = 0x01000000;
while(ret--) asm("nop\nnop\nnop\nnop");
scr_printf ("SifBindRpc...");
while(1) {
ret = SifBindRpc( &client, USB_TEST, 0);
if ( ret < 0) {
break;
}
if (client.server != 0) break;
// short delay ???
ret = 0x10000;
while(ret--);
}
if (ret < 0 ) {
scr_printf("\nSifBindRpc failed: %d !!!!\n", ret);
}else {
scr_printf("ok\n");
}
}
void resetIOP() {
int ret;
SifInitRpc(0);
SifExitIopHeap();
SifLoadFileExit();
SifExitRpc();
SifIopReset(NULL,0);
while (!SifIopSync()) ;
ret = sbv_patch_enable_lmb(); //sbv-1.0-lite
scr_printf("patch lmb=%i \n", ret);
}
int main()
{
init_scr();
scr_printf("Test...\n");
resetIOP();
SifInitRpc(0);
loadModules();
initUsb();
while(1) printMessage();
}