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 

Arguments to main()

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



Joined: 28 Sep 2005
Posts: 217

PostPosted: Sun Oct 16, 2005 12:18 am    Post subject: Arguments to main() Reply with quote

I'm trying to replicate the argument-passing that the kernel does to _startup(), for the EBOOT loader.

But I'm a bit confused about what it actually passes.

The PSPSDK API docs claim that the arguments passed to a thread via StartThread() are:

SceSize arglen (size of argp data in bytes)
void * argp

That seems to correlate with the code for _start() in crt0.c too.

My question is: should this be the same as the classic argc, argv? Clearly argc is normally a count of elements in the argv[] array, so would be a count of 32-bit words rather than bytes.

And regardless of that, when I pass:

arglen = 4
argp = { char * => "test" }

I don't seem to get anything like those params passed to main.

Can anyone shed any light on what's going on? What gets passed to argc, argv on a 1.5 PSP?
Back to top
View user's profile Send private message
groepaz



Joined: 01 Sep 2005
Posts: 305

PostPosted: Sun Oct 16, 2005 12:27 am    Post subject: Reply with quote

if you are calling crt0 directly from your code, and not through a kernel function such as sceLoadExec, i would think that you need to pass argc=0 and argv[0]="ms0:/path/to/eboot". the description in the pspsdk probably relates to how those params are passed via loadexec, which is a bit different. (it takes a struct with some info about the params)
_________________
http://www.hitmen-console.org
http://hitmen.c02.at/files/yapspd/
Back to top
View user's profile Send private message Visit poster's website
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Sun Oct 16, 2005 12:45 am    Post subject: Reply with quote

I do pass the EBOOT path in argv[0] - because I figured out that the problem with some EBOOTs is that they use that to determine their working directory.

But that parameter never actually reaches the app, and I don't understand why not.

I'll take a look at the KernelLoadExec params - maybe that will offer some clues.
Back to top
View user's profile Send private message
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Sun Oct 16, 2005 12:53 am    Post subject: Reply with quote

Ah, yes, the LoadExec params gave me the right clue.

The argp argument to _start() is just a pointer to the argv[0] string. The args argument is the length.

Now it works just fine.

Thanks!
Back to top
View user's profile Send private message
CyberBill



Joined: 26 Jul 2005
Posts: 86
Location: Redmond, WA

PostPosted: Sun Oct 16, 2005 6:46 am    Post subject: Reply with quote

Yeah, it was very confusing the first time I used it too. You expect it to use the COUNT in number of arguments, but it doesnt. Its just the count in bytes.

Internally it does a copy, too, which can throw you off but is expected.
Back to top
View user's profile Send private message AIM Address MSN Messenger
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