forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sircs on 5.XX

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Fri Jun 05, 2009 11:09 am    Post subject: Sircs on 5.XX Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Jun 05, 2009 5:42 pm    Post subject: Reply with quote

You need to dump sirc.prx from older 3.xx firmware and load it manually.
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Fri Jun 05, 2009 5:50 pm    Post subject: Thanks Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Jun 05, 2009 5:52 pm    Post subject: Reply with quote

Just load and start normally with sceKernelLoadModule/StartModule.
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Sat Jun 06, 2009 1:49 am    Post subject: Question Reply with quote

Hi,
I have added the following code:
Code:
SceUID mod = sceKernelLoadModule("ms0:/path/to/module/sircs.prx", 0, NULL);
   if (mod >= 0)
   {
      mod = sceKernelStartModule(mod, 0, NULL, NULL, NULL);
      if (mod < 0)
      {
        message = "Fail2";
      }
      else
      {
        message = "Success1";
      }
   }
   else
   {
    message = "Fail1";
   }


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
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat Jun 06, 2009 5:28 am    Post subject: Reply with quote

Post the make file and source.
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Sat Jun 06, 2009 12:00 pm    Post subject: SVN Reply with quote

I have it in a SVN repo.
Code:
svn://www.nicksplace.com.au/Nicksplace/trunk/UniMote


Thanks,
Darky
Back to top
View user's profile Send private message Visit poster's website
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Mon Jun 08, 2009 1:39 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Mon Jun 08, 2009 6:41 am    Post subject: Re: Question Reply with quote

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?p=50787&highlight=stubstart#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:
   .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:
   .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.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Mon Jun 08, 2009 2:44 pm    Post subject: Re: Question Reply with quote

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:
int (* sceSircsSend)(struct sircs_data* sd, int count);
sceSircsSend = (void *)sctrlHENFindFunction("sceSIRCS_IrDA_Driver", "sceSircs_driver", 0x71EEF62D);
//or use libs.h from psplinkusb to find export if you don't want M33 SDK
Back to top
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Mon Jun 08, 2009 11:19 pm    Post subject: Re: Question Reply with quote

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.)
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Tue Jun 09, 2009 12:31 pm    Post subject: @cory1492 Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Tue Jun 09, 2009 2:32 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Tue Jun 09, 2009 2:35 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Jun 09, 2009 2:36 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Tue Jun 09, 2009 2:44 pm    Post subject: Reply with quote

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:
include $(PSPSDK)/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
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Jun 09, 2009 2:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Tue Jun 09, 2009 3:01 pm    Post subject: Reply with quote

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

Sorry to a pain :(

Thanks,
Darky
Back to top
View user's profile Send private message Visit poster's website
cory1492



Joined: 10 Dec 2004
Posts: 216

PostPosted: Tue Jun 09, 2009 6:21 pm    Post subject: Reply with quote

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:
int LoadStartModule(char *path)
{
    char result[45];
   u32 loadResult;
    u32 startResult;
    int status;
   SceKernelLMOption option;
   SceUID mpid = 1;
   memset(&option, 0, sizeof(option));
   option.size = sizeof(option);
   option.mpidtext = mpid;
   option.mpiddata = mpid;
   option.position = 0;
   option.access = 1;

    loadResult = sceKernelLoadModule(path, 0, &option);
    if (loadResult & 0x80000000)
   {
      sprintf(result, "load error: 0x%08x", loadResult);
      message = result;
      return -1;
    }
   else
   startResult = sceKernelStartModule(loadResult, 0, NULL, &status, NULL);

    if (startResult & 0x80000000)
   {
      sprintf(result, "start error: 0x%08x", startResult);
      message = result;
      return -2;
    }
   return 0;
}

and change to this in main function of main.cpp, provided you have sircs.prx in flash0:/kd/ of course
Code:
   sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
   sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
   LoadStartModule("flash0:/kd/sircs.prx");

   netInit();   
Back to top
View user's profile Send private message
darksaboteur



Joined: 11 Dec 2007
Posts: 18
Location: Australia

PostPosted: Tue Jun 09, 2009 11:28 pm    Post subject: YAY :D Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group