Ps2Link and printf without the entire sdk

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
Cugo
Posts: 5
Joined: Mon Apr 28, 2008 2:29 am
Location: Home or equivalent

Ps2Link and printf without the entire sdk

Post by Cugo »

Hello to all and a happy new year.

I'm using a sdk that is not the ps2dev sdk and according to how I interpreted the forums rules I am not allowed to mention here so I'll just explain what I need without actually making a full example.

So here's the deal:
Uppon creating a simple hello world appication consisting mainly of the function:
printf("Hello world\n");
an import of stdio.h
and of course the main function I already encountered my first problem:
With the ps2sdk I usually use ps2link to run the elf file and get output in the console via ps2client (in linux), I also tried xlink in windows and it works too.

But the program created with this other sdk does not seem to send it's output to ps2link and therefore I don't get anything on my computer.
I suppose it expects something else instead of ps2link and calls that (which is obviously not present - I didn't find any loaders with that sdk).

So I thought that I could manually check how ps2sdk applications communicate with ps2link when using printf and implement a (small) library that would do the same and just call ps2link_printf or something.

But before I start looking throught the ps2sdk source trying to figure out how it does that I thought to ask if someone could point me in the right direction.
By this I mainly mean if someone could tell me where to look for the info I need. Which parts (files) of the sdk.
(since the ps2dev sdk is pretty large)
Or if there is any kind of documentation describing how to interface ps2link from my ps2 app directly.

I suppose I will have to reimplement loading of files from the host as well but that comes at a later time.

Well I'm off to printing out the ps2link source code (which as far as i could see is poorly documented. so I can only hope I'll understand what it does = hours of endress fun)

Anyway thanks in advance for possible replies
Cugo
Cugo
Posts: 5
Joined: Mon Apr 28, 2008 2:29 am
Location: Home or equivalent

Post by Cugo »

Ok if I understood correctly what happenes in ps2link's tty.c is that
ps2link registers a protocol with the name tty.
(although I don't understand why it later opens it with the name "tty00:" instead of "tty:")
And writing to a file opened with this protocol should send it to the pc.
To register the protocol it uses AddDrv of which I still havent found much info except that it resides in rom0 (the bios if i'm not mistaken).
from here: http://wiki.ps2dev.org/ps2:adddrv

Since it is a bios call I therefore suppose it get's registered by the bios in a way accessible by another bios call or some function that uses the bios to handle protocols.
Therefore even if I'm using a different sdk it should still be accessible in some way.

So I tried opening it with:
i = open("tty00:", O_WRONLY); //O_WRONLY = 1
and writing to it using:
char * str = "test\n";
write(i, str, strlen(str));

In ps2dev it printed out "test" so i guess I got the concept.

If it is as I hope and the bios manages protocol calls I might make it work.
Still the same technique didn't work in the other sdk.

Atleast I think I'm working in the right way.

Could anyone tell me how could I get the tty_functarray (iop_device_ops_t) that ps2link passes to the bios in the adddrv call from the bios? (i suppose it is another bios call)
Since the array contains pointers to functions used to send data I could call them directly if i could get this array.

Thanks
Cugo
radad
Posts: 246
Joined: Wed May 19, 2004 4:54 pm
Location: Melbourne, Australia

Post by radad »

Cugo wrote:To register the protocol it uses AddDrv of which I still havent found much info except that it resides in rom0 (the bios if i'm not mistaken).
from here: http://wiki.ps2dev.org/ps2:adddrv
That web page points to the AddDrv module. The AddDrv used in ps2link is a function in the IOMAN module. http://wiki.ps2dev.org/ps2:ioman
Cugo wrote:So I tried opening it with:
i = open("tty00:", O_WRONLY); //O_WRONLY = 1
and writing to it using:
char * str = "test\n";
write(i, str, strlen(str));

In ps2dev it printed out "test" so i guess I got the concept.
The other part of how this works is that IOMAN redirects file descriptor 2 to the tty device. It is in this module that opens "tty00:". So this should work also:
char * str = "test\n";
write(2, str, strlen(str));
Cugo wrote:Could anyone tell me how could I get the tty_functarray (iop_device_ops_t) that ps2link passes to the bios in the adddrv call from the bios? (i suppose it is another bios call)
Since the array contains pointers to functions used to send data I could call them directly if i could get this array.
The tty_functarray and the functions it contains pointers to are defined by ps2link to register with AddDrv when anyone tries to use the tty device. They are not in the bios.

RadAd.
Cugo
Posts: 5
Joined: Mon Apr 28, 2008 2:29 am
Location: Home or equivalent

Post by Cugo »

Thanks.
You just saved me hours of work that would have turned out invain.

Well I guess I'll just return to the good old ps2dev sdk. :)
What I was trying to do is just not worth the time compared to the results it would get me.
Cugo
Post Reply