durgadas311 / cpnet-z80

26 stars 6 forks source link

Need a utility to shutdown the WizNET W5500 on CP/NET 1.2 #5

Closed durgadas311 closed 4 years ago

durgadas311 commented 4 years ago

There is currently no way to close all (CP/NET) sockets on a CP/NET 1.2 W5500-based system (CP/NET3 already shuts down cleanly when the RSX is removed).

The JMP table in the SNIOS has been extended to include a shutdown entry:

;       Jump vector for SNIOS entry points
        jmp     NTWKIN  ; network initialization
        jmp     NTWKST  ; network status
        jmp     CNFTBL  ; return config table addr
        jmp     SNDMSG  ; send message on network
        jmp     RCVMSG  ; receive message from network
        jmp     NTWKER  ; network error
        jmp     NTWKBT  ; network warm boot
        jmp     NTWKDN  ; network shutdown - extension

However, after calling that routine the program must not warmboot (or otherwise return to the OS) or else sockets will get re-opened. In the absence of a way to unload CP/NET entirely, this routine could be followed by a prompt like "Ready for RESET or Power off", and then just wait for console input. If the user types a character, then return to CP/NET (possibly announcing that the network is back up).

durgadas311 commented 4 years ago

If a solution to issue #6 is found, then this issue becomes unnecessary.

durgadas311 commented 4 years ago

The difficulty with making a generic CP/NET 1.2 utility is that there is no public access to the SNIOS. There is no way to discover the starting address of the SNIOS, without making assumptions about the size of the NDOS, or hacking through the NDOS code at runtime (assumptions about the NDOS code paths).

One other method is to assume that the SNIOS jump entries are immediately before the network config table. This is currently the case for all existing SNIOS implementations (in this repo), but we have no mechanism to enforce. This would allow retrieving the network config table address (NDOS function 69) and then backing up to the SNIOS JMPs (only if CP/NET 1.2, though).

durgadas311 commented 4 years ago

Added a generic NETDOWN utility to call SNIOS NTWKDN and wait for user to power-off or RESET.