| View previous topic :: View next topic |
| Author |
Message |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Sun Oct 16, 2005 12:18 am Post subject: Arguments to main() |
|
|
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 |
|
 |
groepaz

Joined: 01 Sep 2005 Posts: 305
|
Posted: Sun Oct 16, 2005 12:27 am Post subject: |
|
|
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 |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Sun Oct 16, 2005 12:45 am Post subject: |
|
|
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 |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Sun Oct 16, 2005 12:53 am Post subject: |
|
|
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 |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Oct 16, 2005 6:46 am Post subject: |
|
|
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 |
|
 |
|