| View previous topic :: View next topic |
| Author |
Message |
Anissian
Joined: 26 Jan 2007 Posts: 16
|
Posted: Wed Feb 28, 2007 7:15 pm Post subject: [Ann] PSP Development Tutorial, modules |
|
|
All,
Please find (link below, PSP dev totorials section) a new PSP development tutorial concerning modules and PRXs, written by yours truly. There are a few rough edges and some parts are being fixed / completed / clarified. Many thanks to the reviewers for their insighful comments.
http://ps2dev.org/psp/Tutorials/PSP_Modules,_Exports,_Imports_and_Patches.download
Comments, suggestions or fixes are welcome. I hope this can be helpful.
Thanks :o)
Ani. |
|
| Back to top |
|
 |
jockyw2001
Joined: 29 Sep 2005 Posts: 339
|
Posted: Wed Feb 28, 2007 10:55 pm Post subject: |
|
|
Wonderful !
Very well written.
You should consider writing a book :)
Cheers
JockyW |
|
| Back to top |
|
 |
adrahil
Joined: 16 Mar 2006 Posts: 277
|
Posted: Wed Feb 28, 2007 11:48 pm Post subject: |
|
|
| nice :) |
|
| Back to top |
|
 |
Holmz
Joined: 14 Feb 2007 Posts: 5 Location: Las Vegas, NV
|
Posted: Thu Mar 01, 2007 3:41 am Post subject: Wow... |
|
|
| A very good read, thanks for taking the time to write it. |
|
| Back to top |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Thu Mar 01, 2007 4:43 am Post subject: Re: [Ann] PSP Development Tutorial, modules |
|
|
| Anissian wrote: | All,
Please find (link below, PSP dev totorials section) a new PSP development tutorial concerning modules and PRXs, written by yours truly. There are a few rough edges and some parts are being fixed / completed / clarified. Many thanks to the reviewers for their insighful comments.
http://ps2dev.org/psp/Tutorials/PSP_Modules,_Exports,_Imports_and_Patches.download
Comments, suggestions or fixes are welcome. I hope this can be helpful.
Thanks :o)
Ani. |
it sounds very good but there is a common error about GPR usage :
SONY uses t0-t3 as arguments registers, that is, a4-a7 or r4-r11. Even our gcc uses those registers as arguments registers (up to 8 max, not 4 !). I think this common error comes from when you try to disassemble with psp-objdump or prxtool which uses the old register naming by default. |
|
| Back to top |
|
 |
Anissian
Joined: 26 Jan 2007 Posts: 16
|
Posted: Thu Mar 01, 2007 4:57 am Post subject: Re: [Ann] PSP Development Tutorial, modules |
|
|
| hlide wrote: |
I think this common error comes from when you try to disassemble with psp-objdump or prxtool which uses the old register naming by default. |
Indeed. Thank you hlide, I will incorporate these remarks in the reviewed version. I used prxtool extensively, and a few docs about R4000. I will dobule check the text, and whether prxtool has a switch or option to show register usage as you state. |
|
| Back to top |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Thu Mar 01, 2007 5:17 am Post subject: |
|
|
i don't think prxtool uses the new register naming but it can display registers as r0-r31 at last. Don't forget that prxtools was coded with no assumption about the right name on registers.
In fact, using $4-$11 or a0-a3,t0-t3 or a0-a7 or r4-r11 doesn't make any change. What is important is to know that there is trully up to 8 argument registers for a function. |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Thu Mar 01, 2007 5:39 am Post subject: |
|
|
prxtool disasm was written to the register model I use which uses t0 to t3 mnemonics instead of a4 to a7 and realistically that is how the toolchain maps them and I dont think the PSP uses the _new_ ABI anyway ;)
Admittedly you can switch prxtool to disasm the registers in the format 'rN' if you cant stand arbitrary mnemonics :) ('--disopts r' if I recall). |
|
| Back to top |
|
 |
harleyg

Joined: 05 Oct 2005 Posts: 123
|
Posted: Thu Mar 01, 2007 5:45 am Post subject: |
|
|
| Nice read. :) |
|
| Back to top |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Thu Mar 01, 2007 6:04 am Post subject: |
|
|
| TyRaNiD wrote: | prxtool disasm was written to the register model I use which uses t0 to t3 mnemonics instead of a4 to a7 and realistically that is how the toolchain maps them and I dont think the PSP uses the _new_ ABI anyway ;)
Admittedly you can switch prxtool to disasm the registers in the format 'rN' if you cant stand arbitrary mnemonics :) ('--disopts r' if I recall). |
yes i checked it : gcc maps them from $0 to $31 except for $sp, and can eventually accept them as additional register names with "$t0"-"$t3" instead of "$a3"-"$a7" even if you can have up to 8 registers.
And sure, psp-gcc uses ABI_EABI which is not ABI_O32 or ABI_N32. |
|
| Back to top |
|
 |
fergie4000
Joined: 19 Jan 2007 Posts: 25
|
Posted: Thu Mar 01, 2007 10:44 pm Post subject: |
|
|
i am having trouble compiling the prx code on page 7 i think it is. has anyone got it to work? if so can you say how/give me a makefile? thanks
EDIT
just needed to change build.mak to build_prx.mak. thanks to medium gauge the immortal |
|
| Back to top |
|
 |
monsti
Joined: 04 Mar 2007 Posts: 13 Location: Germany
|
Posted: Wed Mar 07, 2007 5:18 am Post subject: Re: [Ann] PSP Development Tutorial, modules |
|
|
nice work!
Can you also create a Bookr "friendly" version? e.g. a DIN-A-5 format. _________________ Bye,
Monsti |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Mar 07, 2007 5:52 am Post subject: Re: [Ann] PSP Development Tutorial, modules |
|
|
| monsti wrote: |
nice work!
Can you also create a Bookr "friendly" version? e.g. a DIN-A-5 format. |
With the latest updates, too... |
|
| Back to top |
|
 |
Zenurb
Joined: 30 Sep 2005 Posts: 106 Location: United Kingdom
|
Posted: Wed Mar 07, 2007 6:28 am Post subject: |
|
|
Good work man :D[/list] _________________ Proud Dvorak User
US 1.5 PSP (Original) |
|
| Back to top |
|
 |
Grizzly_cf
Joined: 24 Jul 2006 Posts: 6
|
Posted: Sat Mar 10, 2007 11:31 am Post subject: |
|
|
Hi.
I have a one question.
In page 6 you give a small example. I try to compile it, but there is some error. btw. You don't give source code to makefile and exports.exp. So I add from makefile and exports from PSPSDK - \psp\sdk\samples\prx\testprx:
makefile
| Quote: | TARGET = test
OBJS = main.o
# Define to build this as a prx (instead of a static elf)
BUILD_PRX=1
# Define the name of our custom exports (minus the .exp extension)
PRX_EXPORTS=exports.exp
USE_PSPSDK_LIBC = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
and:
exports.exp
| Quote: | # Define the exports for the prx
PSP_BEGIN_EXPORTS
# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.
PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_FUNC_HASH(module_start)
PSP_EXPORT_VAR_HASH(module_info)
PSP_EXPORT_END
# Export our function
PSP_EXPORT_START(MyLib, 0, 0x0001)
PSP_EXPORT_FUNC_HASH(getModuleInfo)
PSP_EXPORT_END
PSP_END_EXPORTS |
But I get some errors:
Log
| Quote: | make.exe -f "Makefile" all
psp-gcc -IC:/pspdev/psp/sdk/include/libc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o main.c
main.c: In function 'plugin_dump_file':
main.c(15) : error: 'SP_O_CREAT' undeclared (first use in this function)
main.c(15) : error: (Each undeclared identifier is reported only once
main.c(15) : error: for each function it appears in.)
main.c: In function 'plugin_thread':
main.c(42) : warning: unused variable 'res'
make: *** [main.o] Error 1 |
When I delete SP_O_CREAT I get:
Log2
| Quote: | make.exe -f "Makefile" all
psp-gcc -IC:/pspdev/psp/sdk/include/libc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o main.o main.c
main.c: In function 'plugin_thread':
main.c(42) : warning: unused variable 'res'
psp-build-exports -b exports.exp > exports.c
psp-gcc -IC:/pspdev/psp/sdk/include/libc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -c -o exports.o exports.c
psp-gcc -IC:/pspdev/psp/sdk/include/libc -I. -IC:/pspdev/psp/sdk/include -O2 -G0 -Wall -L. -LC:/pspdev/psp/sdk/lib -specs=C:/pspdev/psp/sdk/lib/prxspecs -Wl,-q,-TC:/pspdev/psp/sdk/lib/linkfile.prx main.o exports.o -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpsplibc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o test.elf
main.o: In function `module_start':
main.c:(.text+0x104): multiple definition of `module_start'
/cygdrive/c/pspdev/bin/../lib/gcc/psp/4.0.2/../../../../psp/lib/crt0_prx.o:/tmp/pspdev/pspsdk/src/startup/crt0_prx.c:109: first defined here
/cygdrive/c/pspdev/bin/../lib/gcc/psp/4.0.2/../../../../psp/lib/crt0_prx.o: In function `_main':
/tmp/pspdev/pspsdk/src/startup/crt0_prx.c:91: undefined reference to `main'
exports.o:(.rodata.sceResident+0x4): undefined reference to `getModuleInfo'
collect2: ld returned 1 exit status
make: *** [test.elf] Error 1
rm exports.c |
Could You help(or/and give me some advices to compile exapmle) me with compile your exapmle, please?
Regards
Grizzly_cf
p.s. Sorry for my english. I know is terrible :/ _________________
 |
|
| Back to top |
|
 |
Holmz
Joined: 14 Feb 2007 Posts: 5 Location: Las Vegas, NV
|
Posted: Sat Mar 10, 2007 1:35 pm Post subject: |
|
|
| SP_O_CREAT should be PSP_O_CREAT, simple typo in the tutorial that you duplicated. |
|
| Back to top |
|
 |
Anissian
Joined: 26 Jan 2007 Posts: 16
|
Posted: Sat Mar 10, 2007 6:23 pm Post subject: |
|
|
| Grizzly_cf wrote: | | You don't give source code to makefile and exports.exp. |
thanks for your comments. I will provide the source for the examples in the fixed version. Unfortunately, several typos are present in the document, such as the SP_CREATE.
Regarding the error yo get, that's because the example is supposed to be a pure export module with no main thread iirc, the missing Makefile should have the -mnostartfiles -mnocrt-thingie as described in the document.
Sorry for the inconveniences, but they'll be fixed.
Regards,
Ani. |
|
| Back to top |
|
 |
rzxiao
Joined: 05 Feb 2006 Posts: 13
|
Posted: Wed Mar 14, 2007 12:33 pm Post subject: |
|
|
| Great!,That's a great document I'm looking for |
|
| Back to top |
|
 |
Grizzly_cf
Joined: 24 Jul 2006 Posts: 6
|
Posted: Thu Mar 15, 2007 7:27 am Post subject: |
|
|
Ok, thanks. Its works!!! :D _________________
 |
|
| Back to top |
|
 |
dot_blank

Joined: 28 Sep 2005 Posts: 498 Location: Brasil
|
Posted: Tue Mar 27, 2007 1:10 pm Post subject: |
|
|
some typos
page 13
... Assembler dump of the server.prx module
should be ...Assembler dump of the supervisor.prx module
page 08
... The following table shows the most common instruction mnemonics. It MIPS assembly, the result of
should be ...The following table shows the most common instruction mnemonics. In MIPS assembly, the result of
page 08 (Instruction table)
... lw rd offset(base) load the word at address into rd
... w rd load word at addr offset+base into rd
should be ...
... lw rd address load the word at address into rd
... w rd offset(base) load word at addr offset+base into rd
page 20
... you can use the sceKernelGetModuleIdList fuction,
should be ... you can use the sceKernelGetModuleIdList function,
page 27
... // offset to the "jla supervisor_0xB2C390CB", compute the
should be ... // offset to the "jal supervisor_0xB2C390CB", compute the
in all was decent read ...you must improve your grammatical skills
and use the comma (' , ') more properly :P as this is most common error
ex. Jack who loves to deny others of goods is one big asshole
is incorrect in grammar for the reason of improper comma usage
correct form is:
Jack, who loves to deny others of goods, is one big asshole
simple i know but you do this error many times ...i do not aspire to be a
grammatical cop, but if you, a aspiring writer, would def need to know
just exactly what can improve your writing _________________ 10011011 00101010 11010111 10001001 10111010 |
|
| Back to top |
|
 |
Diddl
Joined: 27 Mar 2007 Posts: 9
|
Posted: Thu Mar 29, 2007 4:53 am Post subject: |
|
|
| Thank a lot, this tutorial is exactly what I need now!!!! |
|
| Back to top |
|
 |
genshiken
Joined: 31 Mar 2007 Posts: 1
|
Posted: Sat Mar 31, 2007 2:24 am Post subject: |
|
|
well, that's what i want
thx _________________ FLCL |
|
| Back to top |
|
 |
fishdrop
Joined: 31 Oct 2006 Posts: 16
|
Posted: Wed Nov 21, 2007 6:47 pm Post subject: Is working patching import stub? |
|
|
I executed examples in your tutorial.
But patching import table method is not work in CF3.03 above.
Is it ture at CF 3.xx? |
|
| Back to top |
|
 |
fishdrop
Joined: 31 Oct 2006 Posts: 16
|
Posted: Thu Nov 22, 2007 3:31 pm Post subject: Re: Is working patching import stub? |
|
|
| fishdrop wrote: | I executed examples in your tutorial.
But patching import table method is not work in CF3.03 above.
Is it ture at CF 3.xx? |
Sorry, I solved it. |
|
| Back to top |
|
 |
|