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 

cdvdman imported functions

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



Joined: 17 Sep 2004
Posts: 23

PostPosted: Wed Oct 27, 2004 3:23 am    Post subject: cdvdman imported functions Reply with quote

I was reading through the source to libcdvd and traced some of the functions, like CdInit(), to cdvdman.h in ps2sdk. From there I noticed that CdInit is the same as sceCdInit which is imported from elsewhere. I was wondering where this function is imported from?
Back to top
View user's profile Send private message Visit poster's website AIM Address
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Wed Oct 27, 2004 4:23 am    Post subject: Reply with quote

Okay. You have to understand the mechanism used into the PS2. Here is a quick scheme.

You have two processors. The "main" one, the 'EE', and a "slave" one, the 'IOP'. On the IOP, you have modules, called 'IRX' files. Lot of modules exists into the BIOS, and 'CDVDMAN' is one of them.

When the EE wants to call back an IOP's IRX function, it has to use 'RPC' (Remote Procedure Call).

Now, inside ps2sdk, you can find a file, called libcdvd.c, which contains the reversed RPC to call CDVDMAN's functions. That's when EE wants to call CDVDMAN.

When an IOP's IRX wants to call CDVDMAN's functions, it has to go thru another (simple) mechanism: function imports. You (more or less) only have to include the file cdvdman.h, which will build up some code for you, that will create "stubs" into the IRX. These stubs, in asm, looks like:
Code:
CdInit:
        j       $31
        li      $0, 4


(you can see the file cdvdman.s for a complete sample of what such a stub would look like)

The "4" here is the import number that will get called "for real".


So, in short, when you want to call an IRX from another IRX, say, foo.irx wants to call CDVDMAN, then foo.irx has to contain the cdvdman.s stub (or parts of it). Then, to create the stub file, you have to know the list of imports of the imported irx. Such a list could be, like:
Code:
4 sceCdInit
5 sceCdStandby
6 sceCdRead
7 sceCdSeek
8 sceCdGetError
9 sceCdGetToc
...


Finally: usually, sce-prefixed function names are immediately aliased to their non-prefixed equivalents. For example, see cdvdman.h:
Code:
#define CdInit sceCdInit
#define CdStandby sceCdStandby
#define CdRead sceCdRead
#define CdSeek sceCdSeek
#define CdGetError sceCdGetError
#define CdGetToc sceCdGetToc
...




Hope I was clear...
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
tumnes



Joined: 17 Sep 2004
Posts: 23

PostPosted: Wed Oct 27, 2004 4:31 am    Post subject: Reply with quote

That seems clear enough. So basically cdvdman is an irx module that is always present in the ps2 bios and cdvdman.h provides a way to use that module, correct?
Back to top
View user's profile Send private message Visit poster's website AIM Address
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Wed Oct 27, 2004 4:45 am    Post subject: Reply with quote

Ding.
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 -> PS2 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