Home Page

Pointers on using NSCSI?

Posted By: Just Desserts

Pointers on using NSCSI? - 11/09/18 12:53 PM

I'd like to convert the wd33c93 to use the NSCSI system, as I strongly suspect that it will most likely fix a lot of the SCSI issues that are dogging me with the SGI Indy driver.

Unfortunately, it's incredibly opaque and seems to presume a heavy knowledge of SCSI in general.

Where would I even start to figure out how to convert wd33c93 to use NSCSI? Or should I just discard it and re-write it from the ground up? And in either case, how would I go about gleaning enough information about how the NSCSI system works in order to successfully pull it off?
Posted By: R. Belmont

Re: Pointers on using NSCSI? - 11/09/18 01:52 PM

NSCSI is basically always a rewrite.

I assume you know about the NSCSI.txt, nicely marked up here: https://docs.mamedev.org/techspecs/nscsi.html

But it helps to understand the underlying SCSI state machine first. There's 3 state bits, C/D (Control or Data), I/O (transfer direction: host to device or vice versa), and MSG (bus contains message or command/data) and 8 states (called "bus phases" in SCSI), and a very simple set of rules as to what states can go in what order.

http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/Devices/Devices-120.html has a pretty clear description of the 8 bus phases, a diagram showing what state transitions are valid (not many), and a description of how the handshaking works for selection and the like.
Posted By: Olivier Galibert

Re: Pointers on using NSCSI? - 11/09/18 04:26 PM

In the wd93c33 case the real problem for a nscsi conversion is the way the dma is done. I recommend converting the current driver and users (it's the users that are the problem) to a sane dma interface, which means one that uses a drq signal and dma_r/w methods. After that the conversion will actually be easy, you can lift most of the ncr state machine, they're very similar.

OG.
Posted By: Just Desserts

Re: Pointers on using NSCSI? - 11/09/18 08:22 PM

Originally Posted by Olivier Galibert
In the wd93c33 case the real problem for a nscsi conversion is the way the dma is done. I recommend converting the current driver and users (it's the users that are the problem) to a sane dma interface, which means one that uses a drq signal and dma_r/w methods. After that the conversion will actually be easy, you can lift most of the ncr state machine, they're very similar.


Well, I have some good news in that regard: I just had a look through the whole source base, and the only driver that actually seems to make use of the wd33c93's DMA functionality is the Indy driver. So it should be pretty straightforward to update.
Posted By: Just Desserts

Re: Pointers on using NSCSI? - 11/10/18 04:35 PM

Unfortunately, the legacy SCSI system only seems to operate on a block level, not at a byte level. As a result, updating the existing wd33c93 to have a same DMA interface is not really viable. So, I'm going for broke and trying my best to graft the ncr5390 state machine into the wd33c93.

However, I've run into a bit of a roadblock with my understanding of the ncr5390 state machine versus how the wd33c93 works.

The ncr5390 has a 1-for-1 command set, one command does one thing. By contrast, the wd33c93 has a bunch of combined commands: Select and Transfer, Select w/ATN and Transfer, Reselct and Receive Data, Reselect and Send Data, Wait for Select And Receive, and Send Status and Command Complete.

What I'm thinking is that I can treat the combined commands as two commands taken sequentially. I would leave the actual command ID in the relevant register, but cache the appropriate half of the command as the "active" command, and at the relevant points in the state machine where function_complete, bus_complete, or function_bus_complete is normally called, I can instead check the cached command against the actual command, and in turn launch the second half of the command like it were a standalone command.

Does that sound reasonable, or am I most likely going to run into some ugly issues with that?
Posted By: Olivier Galibert

Re: Pointers on using NSCSI? - 11/10/18 05:30 PM

That's already how the 5390 does it. Look at DISC_SEL_ARBITRATION: for insteance:
case DISC_SEL_ARBITRATION:
if(c == CD_SELECT) {
state = DISC_SEL_WAIT_REQ;
} else
state = DISC_SEL_ATN_WAIT_REQ;

scsi_bus->ctrl_wait(scsi_refid, S_REQ, S_REQ);
if(ctrl & S_REQ)
step(false);
break;

The next state is chosen depending on the actual command, which is in 'c'.

OG.
Posted By: Just Desserts

Re: Pointers on using NSCSI? - 11/10/18 07:44 PM

Except there's a difference between "Select with ATN"/"Select without ATN", versus two entirely separate commands, isn't there?
Posted By: Olivier Galibert

Re: Pointers on using NSCSI? - 11/10/18 09:52 PM

Well, not really, frankly :-)
© 2019 Forums