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

DEV9 module #5

Open
1 of 6 tasks
frno7 opened this issue Jul 11, 2021 · 7 comments
Open
1 of 6 tasks

DEV9 module #5

frno7 opened this issue Jul 11, 2021 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@frno7
Copy link
Owner

frno7 commented Jul 11, 2021

It seems a DEV9 IOP module is needed, for various expansion bay hardware. A prototype has been implemented in module/dev9.c, to support a harddisk driver. Important DEV9 registers are only available from the IOP, so the EE cannot easily manage DEV9 by itself, as it seems. Furthermore, DEV9 resources need to be shared among multiple devices, such as harddisk and network. Plan:

  • identify attached DEV9 hardware;
  • power off DEV9 if it isn’t used;
  • power on DEV9 if some driver needs it;
  • initialise DEV9 registers as needed;
  • share, acknowledge and mask DEV9 interrupts as needed;
  • document DEV9 registers, etc. (is there some reliable source?).
@frno7 frno7 added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Jul 11, 2021
@AKuHAK
Copy link
Contributor

AKuHAK commented Jul 11, 2021

Maybe @wisi-w can help with DEV9 registers?

@frno7
Copy link
Owner Author

frno7 commented Jul 11, 2021

Thanks, @AKuHAK, that would be lovely! I’ve begun to implement cascading interrupts for DEV9, which is to say that its IRQs from the drivers point of view behaves like all the standard IOP IRQs. Right now I’m searching for information on how to acknowledge the DEV9 (or SPD) interrupts.

@frno7
Copy link
Owner Author

frno7 commented Jul 12, 2021

DEV9 SPD interrupts seem to work nicely now. The main invention is that these IRQs are first-class, so that request_irq
release_irq, enable_irq and disable_irq (corresponding to RegisterIntrHandler, ReleaseIntrHandler, EnableIntr and DisableIntr in the PS2SDK) handle them directly, as any other intrman IRQ. This makes drivers simpler, and in some cases effortless, when special IRQ cases go away. Relaying these IRQs to the EE works automatically, for example.

The DEV9 SPD virtual IRQ assignments

IRQ_IOP_SPD_ATA0 = 46,
IRQ_IOP_SPD_ATA1 = 47,
IRQ_IOP_SPD_TXDNV = 48,
IRQ_IOP_SPD_RXDNV = 49,
IRQ_IOP_SPD_TXEND = 50,
IRQ_IOP_SPD_RXEND = 51,
IRQ_IOP_SPD_EMAC3 = 52,
IRQ_IOP_SPD_DVR = 55,
IRQ_IOP_SPD_UART = 58,

make the IRQs a superset of intrman.h in the PS2SDK.

@rickgaiser
Copy link

Nice work, It would be nice to have this in ps2sdk as well, but I'm not sure we can. Since it probably involves making all drivers depend on a new module that handles the cascaded interrupts. About the naming of the cascading interrupts, they don't seem logical to me:

  • IRQ_IOP_DMA -> IRQ_IOP_DMA_*
  • IRQ_IOP_DEV9 -> IRQ_IOP_SPD_* ?

Rename IRQ_IOP_DEV9 to IRQ_IOP_SPD, or rename IRQ_IOP_SPD_* to IRQ_IOP_DEV9_* to make it more consistent?
IRQ_IOP_SPD is also defined to be equal to IRQ_IOP_SPD_ATA0. Rename IRQ_IOP_SPD to IRQ_IOP_SPD_BASE or remove it?

@frno7
Copy link
Owner Author

frno7 commented Jul 12, 2021

Thanks, @rickgaiser! Regarding renaming, I’m not sure the SPD IRQs are the only DEV9 IRQs. Are they? If SPD covers all IRQs for DEV9, your suggestion makes sense to me.

@wisi-w
Copy link

wisi-w commented Jul 12, 2021

Dev9 covers more than the SPEED chip (for example if you connect something different from a net adapter to the expansion bay), so to the IOP, they are Dev9 intrs. Inside the SPEED chip, there is further subdivision of the intr causes, to the various devices inside it, as you have seen.

@frno7
Copy link
Owner Author

frno7 commented Jul 12, 2021

Thanks for the clarification, @wisi-w! To improve the code somewhat in line with @rickgaiser’s suggestion I’m planning to add the special symbols IRQ_IOP_SPD_BASE, and IRQ_IOP_SPD_LAST, as well the comment /* Virtual SPD IRQ */ to clarify that these aren’t hardware IRQs in the traditional sense. Someone might get confused otherwise, as to where exactly these IRQs actually come from.

	IRQ_IOP_SPD_BASE     = 46,
	IRQ_IOP_SPD_ATA0     = IRQ_IOP_SPD_BASE,/* Virtual SPD IRQ */
	IRQ_IOP_SPD_ATA1     = 47,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_TXDNV    = 48,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_RXDNV    = 49,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_TXEND    = 50,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_RXEND    = 51,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_EMAC3    = 52,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_DVR      = 55,		/* Virtual SPD IRQ */
	IRQ_IOP_SPD_UART     = 58,		/* Virtual SPD IRQ */
        IRQ_IOP_SPD_LAST     = IRQ_IOP_SPD_UART,                                

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants