Sircs on 5.XX

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

Sircs on 5.XX

Post by darksaboteur »

Hi,
I am trying to get sircs to work on 5.xx.
When I call "sceSircsSend" I get "The game could not be loaded" (or similar).
I have looked into this and it seems that sircs was removed from newer firmwares.
Is there a way I can load it in my program? I noticed the file "f0:\km\sircs.prx". Would I be able to load this?
I have never loaded modules or anything like that so please be nice ;)

Thanks,
Darky
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

You need to dump sirc.prx from older 3.xx firmware and load it manually.
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

Thanks

Post by darksaboteur »

Thanks for that, I had a feeling that's what I would need to do.
Are you able to push me in the right direction for the actual module loading?

Thanks,
Darky
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Just load and start normally with sceKernelLoadModule/StartModule.
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

Question

Post by darksaboteur »

Hi,
I have added the following code:

Code: Select all

SceUID mod = sceKernelLoadModule("ms0:/path/to/module/sircs.prx", 0, NULL);
	if (mod >= 0)
	{
		mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
		if &#40;mod < 0&#41;
		&#123;
        message = "Fail2";
		&#125;
		else
		&#123;
        message = "Success1";
		&#125;
	&#125;
	else
	&#123;
    message = "Fail1";
	&#125;
When running this code it prints "Success1", so the module seems to be loading ok.
But if I add a call to sceSircsSend() the program fails to load with "The game could not be started. (8002013C).

I am lost (and am probably in a little over my head).

What am I missing?

Thanks,
Darky
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Post the make file and source.
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

SVN

Post by darksaboteur »

I have it in a SVN repo.

Code: Select all

svn&#58;//www.nicksplace.com.au/Nicksplace/trunk/UniMote
Thanks,
Darky
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

I think you may just miss the correct nids. From what i understand, "SceSircsSend" is just an alias to the nid. You should use something like prx tool and silversprings nids list to search for the corrects nids.
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Re: Question

Post by cory1492 »

The NID hasn't changed between 3.50 and 5.00 for the sircs driver so I doubt that is the issue. He should be able to load/start the one in flash.
darksaboteur wrote:When running this code it prints "Success1", so the module seems to be loading ok.
But if I add a call to sceSircsSend() the program fails to load with "The game could not be started. (8002013C).
When your program is started by the PSP loadexec it is trying to link to sceSircsSend through the NID stub - but you haven't loaded the sircs module yet as the module isn't in the btcnf for the mode you are loading into, and your program isn't actually running at that initial link point to have hit the loadmodule call, so the result is a library not found/loaded error. When you don't actually call the function in code, the compile process doesn't link the stub into the binary and because of that it's never attempted to link to it at load time so this problem doesn't happen.

There is a way to use your own stub and modify the STUB_START params, see moonlight's post here:
http://forums.ps2dev.org/viewtopic.php? ... tart#50787
it's always useful to try your error code in the search engine here.

Basically, remove -lpspsircs from your makefile and add one of these files to your project (depending on kernel/user mode of your app I imagine):
(for user functions, by default it is STUB_START "sceSircs",0x40010011,0x00020005)
mySceSircs.S

Code: Select all

	.set noreorder

#include "pspstub.s"

	STUB_START	"sceSircs",0x40090011,0x00020005
	STUB_FUNC	0x71EEF62D,sceSircsSend
	STUB_FUNC	0x83381633,sceSircsReceive
	STUB_END
(for kernel functions, by default it is STUB_START "sceSircs_driver",0x00010011,0x00040005)
mySceSircs_driver.S

Code: Select all

	.set noreorder

#include "pspstub.s"

	STUB_START	"sceSircs_driver",0x00090011,0x00040005
	STUB_FUNC	0x19155A2F,sceSircsEnd
	STUB_FUNC	0x62411801,sceSircsInit
	STUB_FUNC	0x71EEF62D,sceSircsSend
	STUB_FUNC	0x83381633,sceSircsReceive
	STUB_END
You should be able to get away with using the header from the sdk, but if not you might need to change the function names in the stubs slightly and make your own header file with function prototypes as well.

btw, fyi and whatnot, I got these stub files automatically with prxtool using
prxtool.exe -u sircs.prx
and just hand copied the function names from here.

The other way to do it is to use a pointer to a function instead of calling the function through stubs/header includes from the SDK, and make your own code to find out where that pointer needs to point to for that function after loading the module.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Re: Question

Post by Torch »

cory1492 wrote:The NID hasn't changed between 3.50 and 5.00 for the sircs driver so I doubt that is the issue. He should be able to load/start the one in flash.
It looks like they reintroduced sircs.prx in 3.80. It was removed before that. Remember IRShell needed it to be manually installed?
cory1492 wrote:The other way to do it is to use a pointer to a function instead of calling the function through stubs/header includes from the SDK, and make your own code to find out where that pointer needs to point to for that function after loading the module.
Something like this but I guess its kernel mode only :/

Code: Select all

int &#40;* sceSircsSend&#41;&#40;struct sircs_data* sd, int count&#41;;
sceSircsSend = &#40;void *&#41;sctrlHENFindFunction&#40;"sceSIRCS_IrDA_Driver", "sceSircs_driver", 0x71EEF62D&#41;;
//or use libs.h from psplinkusb to find export if you don't want M33 SDK
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Re: Question

Post by cory1492 »

Torch wrote:It looks like they reintroduced sircs.prx in 3.80. It was removed before that. Remember IRShell needed it to be manually installed?
I rarely touch IRShell, most of what I'd use it to do I can do from the PSP menu or filer. I've been meaning to look at it again though since ir learning ability was added, means it would actually be useful for me.

Wonder why they omitted it for a while, and have never really had any official use for the ir port at all... though sony seems to like to do that (add hardware in initial versions they never wind up using, or possibly not even support through developer sdk.)
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

@cory1492

Post by darksaboteur »

Hi,
Thanks for that, I tried your suggestion but couldn't get it to work (I'm in over my head somewhat)

Heres what I did:
- Created the mySceSircs.S file.
- Included it with #include "mySceSircs.S"
- Removed -lpspsircs from the makefile

I ended up with lots of compile errors.
I have committed the changes to SVN if anyone can check it out (or I can pastebin it if thats easier)

Thanks for all the help :),
Darky

P.S Can give write access to the SVN if it will make helping easier, just PM me
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

I don't recall saying you had to mess with the includes? I gave pretty specific instructions, at any rate.

-create stub file
-remove -lpspsircs from makefile (so it doesn't use pspsdk pre made stubs)

.S files are not headers, they are stubs (technically it is assembly macros) - you don't include them anywhere in your C code, you just need function prototypes to call those stubs (which the original pspsircs.h should handle fine) which are later resolved to function addresses by the NID and PSP's loadcore.
Last edited by cory1492 on Tue Jun 09, 2009 2:39 pm, edited 1 time in total.
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

Post by darksaboteur »

Ok, sorry about that. I am pretty new to C (and programming in general).
Do I still need "#include <pspsircs.h>"?

Thanks,
Darky
Last edited by darksaboteur on Tue Jun 09, 2009 2:37 pm, edited 1 time in total.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

cory1492 wrote:.S files are not headers, they are stubs - you don't include them anywhere. You just need to make the file and build.mak (which is included already in your makefile) should handle it.
Don't they need to be included in the "objs = main.o stubfile.o" etc in the make file?

So for mySceSircs.S you should have "objs = ..... mySceSircs.o ..." in your makefile.

If you have a header that declares the functions like "#include <pspsircs.h>" then that is enough.

If you don't have a header then give prototypes for them in your code like this:
int sceSircsSend (struct sircs_data* sd, int count);
Last edited by Torch on Tue Jun 09, 2009 2:45 pm, edited 1 time in total.
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

torch: Not sure why you are telling him to use a NULL pointer when a standard prototype works just fine and should get resolved by loadcore? And no,

Code: Select all

include $&#40;PSPSDK&#41;/lib/build.mak
from the makefile should have macros to handle .s and .S files, but it might do things out of order on some platforms (esp. heimdall's win toolchain) that might require building a .a file first instead. I've never had to do it though, it's enough to just have the .S present with the source to get the asm link code.
darksaboteur wrote:Ok, sorry about that. I am pretty new to C (and programming in general).
Do I still need "#include <pspsircs.h>"?
You need the prototypes for the functions and data types for the functions you are going to import from your stub, which are in the pspsircs.h file. By all means include those from the sdk, so long as you remove the pre-built library linking reference from the makefile it should work.
Last edited by cory1492 on Tue Jun 09, 2009 2:50 pm, edited 2 times in total.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

cory1492 wrote:torch: Not sure why you are telling him to use a pointer when a standard prototype works just fine?
My bad, i copied it from my previous post and forgot to change it.
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

Post by darksaboteur »

Thanks for that.
It now compiles and runs but does not actually work
SceSircsSend returns -2147352262

Sorry to a pain :(

Thanks,
Darky
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post by cory1492 »

lol, you are running into all the problems you can, I guess...

-2147352262 in hex is 0x8002013a, the error being "Library is not linked yet" meaning it hasn't been loaded/started. I see you stripped the module loading code out of your svn...

Try this, add this function above main in main.cpp - as you can see I'm not sure how to get debug messages in your code. Tried it on 5.00m33 slim and didn't see anything unusual, but I'm not sure what I'd need to test it anyway.

Code: Select all

int LoadStartModule&#40;char *path&#41;
&#123;
    char result&#91;45&#93;;
	u32 loadResult;
    u32 startResult;
    int status;
	SceKernelLMOption option;
	SceUID mpid = 1;
	memset&#40;&option, 0, sizeof&#40;option&#41;&#41;;
	option.size = sizeof&#40;option&#41;;
	option.mpidtext = mpid;
	option.mpiddata = mpid;
	option.position = 0;
	option.access = 1;

    loadResult = sceKernelLoadModule&#40;path, 0, &option&#41;;
    if &#40;loadResult & 0x80000000&#41;
	&#123;
		sprintf&#40;result, "load error&#58; 0x%08x", loadResult&#41;;
		message = result;
		return -1;
    &#125;
	else
	startResult = sceKernelStartModule&#40;loadResult, 0, NULL, &status, NULL&#41;;

    if &#40;startResult & 0x80000000&#41;
	&#123;
		sprintf&#40;result, "start error&#58; 0x%08x", startResult&#41;;
		message = result;
		return -2;
    &#125;
	return 0;
&#125;
and change to this in main function of main.cpp, provided you have sircs.prx in flash0:/kd/ of course

Code: Select all

	sceUtilityLoadNetModule&#40;PSP_NET_MODULE_COMMON&#41;;
	sceUtilityLoadNetModule&#40;PSP_NET_MODULE_INET&#41;;
	LoadStartModule&#40;"flash0&#58;/kd/sircs.prx"&#41;;

	netInit&#40;&#41;;   
User avatar
darksaboteur
Posts: 18
Joined: Tue Dec 11, 2007 8:44 pm
Location: Australia
Contact:

YAY :D

Post by darksaboteur »

Hi,
First off I'd like to thank you both for you help and say thank you for all your help :).
It works!

I plan to put together a sample of how to use sircs on 5.XX for other noobs like me ;)

No one happens to know some sircs codes for a Sony Receiver.....

Thanks again,
Darky
Post Reply