Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printf not working fine with fileXio #332

Closed
fjtrujy opened this issue Aug 21, 2022 · 7 comments
Closed

printf not working fine with fileXio #332

fjtrujy opened this issue Aug 21, 2022 · 7 comments

Comments

@fjtrujy
Copy link
Member

fjtrujy commented Aug 21, 2022

When we use fileXio the printf messages stop working when running PCSX2.

When using ps2client is still working because the udptty driver is closing and opening again the fd 0 and 1, as you can see here, for redirecting the output:
https://github.com/ps2dev/ps2sdk/blob/master/iop/network/udptty/src/udptty.c#L200-L208

I suppose that something similar should be done in fileXio.
Are the printf messages with fileXio working in DevTool machines? (@uyjulian could you double-check it)?

The example:

int main(int argc, char **argv) {
  SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, NULL, NULL);	
  SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, NULL, NULL);
  fileXioInit();

  while(1) {
    printf("Hello world with fileXio drivers!\n");
  }
}
@uyjulian
Copy link
Member

Last time I checked, printf messages with fileXio are working with DTL-T machines.

Once I reverse the STDIO and IOMAN module, I'll probably have a better understanding of how this all integrates and how to resolve this.

@fjtrujy
Copy link
Member Author

fjtrujy commented Aug 21, 2022

Last time I checked, printf messages with fileXio are working with DTL-T machines.

Once I reverse the STDIO and IOMAN module, I'll probably have a better understanding of how this all integrates and how to resolve this.

Was it before or after the newlib integration, #161 ?

@uyjulian
Copy link
Member

Last time I checked, printf messages with fileXio are working with DTL-T machines.
Once I reverse the STDIO and IOMAN module, I'll probably have a better understanding of how this all integrates and how to resolve this.

Was it before or after the newlib integration, #161 ?

After

@rickgaiser
Copy link
Member

These printf messages that magically appear in PCSX2, do you know how they get there?

I'm assuming they are IOP SIO writes, not EE SIO? And I'm assuming ioman somehow uses fd=0 and fd=1 to write to the IOP serial port. Can you confirm the PCSX2 output you see is the IOP serial port output? And if not, do you know what it is?

Searching in the ps2sdk sources I can find no driver for using the iop serial port.
We could probably make an iop serial port driver (using ps1 code as example), then do the same thing we do with udptty:

close(0);
close(1);
DelDrv(tty_device.name);
if (AddDrv(&tty_device) < 0)
return MODULE_NO_RESIDENT_END;
open(DEVNAME "00:", 0x1000 | O_RDWR);
open(DEVNAME "00:", O_WRONLY);

@fjtrujy
Copy link
Member Author

fjtrujy commented Aug 21, 2022

These printf messages that magically appear in PCSX2, do you know how they get there?

I'm assuming they are IOP SIO writes, not EE SIO? And I'm assuming ioman somehow uses fd=0 and fd=1 to write to the IOP serial port. Can you confirm the PCSX2 output you see is the IOP serial port output? And if not, do you know what it is?

Searching in the ps2sdk sources I can find no driver for using the iop serial port. We could probably make an iop serial port driver (using ps1 code as example), then do the same thing we do with udptty:

close(0);
close(1);
DelDrv(tty_device.name);
if (AddDrv(&tty_device) < 0)
return MODULE_NO_RESIDENT_END;
open(DEVNAME "00:", 0x1000 | O_RDWR);
open(DEVNAME "00:", O_WRONLY);

Watching into the PCSX2 code I saw it print messages coming from SIO_TXFIFO

https://github.com/PCSX2/pcsx2/blob/master/pcsx2/HwWrite.cpp#L314

I think that somehow fio redirect to SIO Write

@uyjulian
Copy link
Member

uyjulian commented Aug 21, 2022

PCSX2 hooks IOMAN write and SYSMEM Kprintf.

write: https://github.com/PCSX2/pcsx2/blob/e3eae7fbe83aad3952e3ed6a8e56fc016b51a9c3/pcsx2/IopBios.cpp#L725
Kprintf: https://github.com/PCSX2/pcsx2/blob/e3eae7fbe83aad3952e3ed6a8e56fc016b51a9c3/pcsx2/IopBios.cpp#L752

In order to resolve this, probably need to determine if IOMAN is hooked already, and if so, use its functionality instead

@fjtrujy
Copy link
Member Author

fjtrujy commented Sep 7, 2022

In the end, it wasn't an issue in the ps2sdk it was PCSX2 that wasn't hooking properly fileXio.
This PR PCSX2/pcsx2#7007 has fixed the issue.

Cheers

@fjtrujy fjtrujy closed this as completed Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants