6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 19, 2024 3:39 pm

All times are UTC




Post new topic Reply to topic  [ 564 posts ]  Go to page Previous  1 ... 11, 12, 13, 14, 15, 16, 17 ... 38  Next
Author Message
 Post subject: Re: POC
PostPosted: Fri Apr 20, 2012 5:46 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
BigEd wrote:
I think 'single-event upsets' is the general term - it might be worth considering that this wasn't something that can be tracked down.

You may have a point. I'm well aware of the trouble background radiation can cause with DRAM. However, there's no DRAM here and I've never heard of background radiation upsetting static RAM. Since the MPU is supposed to be in control of the buses, I wonder if it is background radiation sensitive. The MPU is a static design, though, so you would think it would be inherently stable. Who knows...?

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC
PostPosted: Fri Apr 20, 2012 5:47 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3354
Location: Ontario, Canada
BigDumbDinosaur wrote:
it may be the buses are being diddled in some strange fashion right at power-on.
Or at power-off...
BigDumbDinosaur wrote:
This will take a bit of planning.
If it were me I'd start with the simplest possible yes-or-no test that reveals whether power cycling can cause the problem. If the answer is yes, then devise a fancier test. Translation: Be lazy! 8) Good luck!

Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Sun Apr 29, 2012 8:00 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
BigDumbDinosaur wrote:
I do have one hardware issue to solve and that is attempting to access the SCSI controller's FIFO through the chip's DMA channel doesn't work. I see the correct setup lines are being diddled when I execute an instruction that is supposed to do a direct FIFO read or write but nothing happens. First step will be to slow down Ø2 to 1 MHz to eliminate any timing issues (Ø2 is currently at 8 MHz). If that fixes it then I will progressively increase Ø2 until failure occurs. The odd thing, though, is that my I/O timing, at least according to what I worked out, is well within the 53C94's specs. Hmmm...

Okay, I got this problem solved. It turned out to be a software procedural issue caused, in part, by incomplete documentation. Reading up on a part related to the 53C94 (the 53CF94) highlighted the matter and I now have working DMA channel access to the 53C94's FIFO.

Gaining this capability means I don't have to go through a time-consuming procedure of commanding the controller to get or put from/to the SCSI device for each byte. Now I tell the 'C94 how many bytes I'm going to move, do one command to start DMA data transfer and then read or write the FIFO until the 'C94 says all data has been transferred. The result is a substantial reduction of the number of clock cycles required to get or put a byte from/to a SCSI device and a corresponding performance improvement. Based on the cycles consumed per byte transferred, I now estimate a transfer rate of about 300 KB per second with a 10 MHz Ø2 clock.

In studying the code that gets/puts bytes from/to the FIFO, I see where I can tighten things up a bit. The resulting improvements should ultimately produce about 500 KB per second at 10 MHz. I may gain a little more when I use the 53C94's interrupt capabilities to eliminate the need to test status after each byte is transferred. I believe approximately 600 KB/sec at 10 MHz is the absolute limit.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Tue May 01, 2012 4:14 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
BigDumbDinosaur wrote:
Uptime is now 32.6 days and absolutely nothing untoward has happened. The past instability problem I thought I was seeing has not materialized and all functions are working, including SCSI I/O. Baffled...but maybe relieved.

This time, the POC unit made it to almost 40 days and then the instability problem popped up. By chance I happened to have the 'scope connected to it, with one probe on the Ø2 signal and the other on a signal called /WD, the latter which is the logical ANDing of the MPU's inverted RWB signal and Ø2. The 'scope noted that /WD went low while Ø2 was also low, which is wrong. /WD should only go low when RWB is low and Ø2 is high.

Thinking there might be something amiss with the gate that is producing /WD, I removed the MPU from its socket and used my logic probe's pulse feature to manually strobe RWB. Every so often the logic glitch would occur but with no discernible pattern. This didn't sound at all like a defective piece of silicon. So I decided to carefully examine the board for something that could conceivably affect /WD other than the gate that is supposed to drive it. Sure enough: there was an almost invisible speck of solder on a via that was part of the /WD circuit. That solder speck was right by another via, which happens to be part of the RWB circuit. Both via are immediately adjacent to a chip pin.

So what was happening was periodically that tiny piece of solder was able to tie RWB directly to /WD, bypassing the qualification that prevents a write to any hardware unless Ø2 is high. I'm guessing temperature was playing a role, as expansion of the solder speck would make it bridge the two via—they are only .010 inches (.25 mm) apart.

The instability cause further makes sense when you consider that the W65C816S places the A16-A23 component of the effective address on D0-D7 when Ø2 is low. If /WD were to go low while Ø2 is low, the addressed device would be written to with the A16-A23 value, rather than the correct data. Depending on the device, instability could briefly occur.

Fixing the problem required nothing more than a thorough cleaning of the PCB.

Note to self: watch out for solder splashes! :oops:

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Wed May 02, 2012 2:30 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
I've decided to build a new version of POC V1. The basic circuit and characteristics will be the same as the original. However, the new PCB layout will include the patches I made early on to fix hardware bugs, as well as to interface the SCSI host adapter. Once this new unit has been built and tested I will turn my attention to creating a new SCSI driver that uses DMA channel access to the 53C94's FIFO, and reacts to bus phase changes via interrupts.

Speaking of the 53C94, I found out that large quantities of it and the 53CF94 (the 'C94 with some extra features, but 100 percent pin-compatible and 99.99 percent software compatible) are available through Quest Components. If you want to add high performance SCSI to your SBC here's your chance. :D

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Thu May 03, 2012 6:57 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
Here are the schematics and printed circuit board layout for the POC upgrade.
Attachment:
File comment: POC schematic, page 1, memory map
poc_v1.5.1.1.gif
poc_v1.5.1.1.gif [ 113.01 KiB | Viewed 14282 times ]
Attachment:
File comment: POC schematic, page 2, MPU interface
sbc_v1.5.1.2.gif
sbc_v1.5.1.2.gif [ 163.3 KiB | Viewed 14138 times ]
Attachment:
File comment: POC schematic, page 3, RAM, ROM & I/O
poc_v1.5.1.3.gif
poc_v1.5.1.3.gif [ 114.95 KiB | Viewed 14282 times ]
Attachment:
File comment: POC schematic, page 4, external interface
poc_v1.5.1.4.gif
poc_v1.5.1.4.gif [ 96.26 KiB | Viewed 14282 times ]
Attachment:
File comment: POC printed circuit board layout
poc_v1.5.1_pcb.jpg
poc_v1.5.1_pcb.jpg [ 1.55 MiB | Viewed 14282 times ]

A significant change is that the watchdog timer socket (J8 on page 3, which is now designated as the "expansion port" on the printed circuit board layout) is wired so the SCSI host adapter can plug into it, or the watchdog can be plugged in and the POC run without the host adapter. I also connected the IO-3 output ($D300-$D3FF) from the 74AC138 decoder to an unused pin on J8, which allows me to access the 53C94's FIFO through the DMA port. FIFO DMA access, even without the benefit of a real DMA controller, substantially improves performance and was a goal from the onset when I designed the host adapter.

Other changes include more stringent address qualification using the MPU's VDA and VPA outputs, and an experimental NMI debouncing circuit using a Dallas 1813 reset generator. I have the BIOS arranged so an NMI breaks the currently running program and enters the M/L monitor via its BRK entry point, giving me a way to regain control if a program error puts the MPU into an endless loop. A push button on the NMI input will ground NMI and the DS1813 will release NMI about 250 milliseconds later to debounce the circuit. That's the theory anyhow. :lol:

On the PCB, all patches have been incorporated into the new layout and the PDIP24 version of the MAX238 transceiver has been replaced with the SOIC-24 version (bottom left corner of the layout). I did this to allow me to shift the position of the TIA-232 dual jack assembly to get it away from a couple of protruding pins on the underside of the host adapter. There was a little trace rerouting in areas where some length reduction was possible, and I relocated the /RESET and /NMI inputs to the right hand side of the board for easier access. Board dimensions remain at 6 inches by 3.25 inches. Boards will be made using Express PCB's four-layer Proto-Pro service.

—————————————————————————————————————————————————————————————————
Edit: Replaced schematic page 2. Previous version had a typo in the read/write qualification truth table.
—————————————————————————————————————————————————————————————————

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Last edited by BigDumbDinosaur on Wed May 30, 2012 5:15 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Thu May 03, 2012 8:02 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
Here also are the schematic and printed circuit board layout for the SCSI host adapter (HBA). The HBA piggy-backs on the POC and plugs in to socket J8, and the Dallas watchdog timer plugs into U2 on the HBA. This PCB version incorporates the patches I made to extend the /DACK input of the 53C94 to the POC for DMA port access.


Attachments:
File comment: SCSI host adapter schematic
scsi-2_adapter.gif
scsi-2_adapter.gif [ 179.25 KiB | Viewed 14271 times ]
File comment: SCSI host adapter printed circuit board layout
scsi-2_adapter.jpg
scsi-2_adapter.jpg [ 752.01 KiB | Viewed 14271 times ]

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Last edited by BigDumbDinosaur on Sat May 26, 2012 4:41 am, edited 1 time in total.
Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Fri May 25, 2012 9:03 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
I was in the process of posting this update when the board went down. Fortunately, I had saved a copy of the text, so I didn't have to completely start over.

BigDumbDinosaur wrote:
Here are the schematics and printed circuit board layout for the POC upgrade.

POC V1.1 has been built and fired up on the first try. It is running in a stable fashion on a 12.5 MHz Ø2 clock.
Attachment:
File comment: New POC Test Setup
test_setup01.jpg
test_setup01.jpg [ 685.6 KiB | Viewed 14216 times ]
Attachment:
File comment: New POC Test Setup
test_setup02.jpg
test_setup02.jpg [ 725.3 KiB | Viewed 14216 times ]

Quote:
Other changes include...an experimental NMI debouncing circuit using a Dallas 1813 reset generator...A push button on the NMI input will ground NMI and the DS1813 will release NMI about 250 milliseconds later to debounce the circuit. That's the theory anyhow. :lol:

The theory works!

I actually used a small screw driver to short the NMI header pins, since I haven't rigged up a push button as yet. Despite that crude method of grounding NMI, it worked and halted a running loop I had started. The theory is based on the fact that when the I/O pin on the DS1813 is grounded it will take about 250 milliseconds to go high again. I tied NMI to the 1813's I/O pin, so when I short NMI to ground it stays down for 250 msecs, effectively debouncing the circuit. Since NMI is edge sensitive, the duration of the low state is unimportant—repeated NMIs won't occur. Who needs a Schmidt trigger? :D The NMI causes a response like hitting a BRK instruction: the M/L monitor is started and the registers are dumped. The interrupted program can be restarted without any problem.

Quote:
I also connected the IO-3 output ($00D300-$00D3FF) from the 74AC138 decoder to an unused pin on J8, which allows me to access the 53C94's FIFO through the DMA port. FIFO DMA access, even without the benefit of a real DMA controller, substantially improves performance and was a goal from the onset when I designed the host adapter.

Although using the DMA port does produce high transfer rates (close to 400 KB/second), it doesn't always work right, as I occasionally get data overrun errors. My original theory in using the DMA port was that the SCSI bus would be much faster than the W65C816S when it came to moving bytes, so a strict handshaking protocol wouldn't be necessary. That part is true, but the fly in the ointment is that when the requested number of bytes has been transferred there is a small but inexorable delay before the 53C94 finally interrupts the MPU to tell it to quit. Until the IRQ comes and gets processed, the MPU stupidly keeps reading from the 'C94's FIFO and storing garbage into RAM.

In my first host adapter (HBA) design, I had ignored a 'C94 DMA handshaking signal called DREQ because I didn't expect the data overrun problem—I figured the instant that last byte was read from the FIFO the 'C94 would interrupt. DREQ is used along with the 'C94's /DACK input to control DMA access to the chip's FIFO during the SCSI data-in and data-out bus phases, which is when protracted data flow would be expected. During a read operation, DREQ is asserted by the 'C94 any time it has data waiting in the FIFO. During a write operation, DREQ is asserted as long as the 'C94's FIFO has room for a byte (it's a 16 deep FIFO). When used with a real DMA controller, a tight handshaking relationship exists and there's no problem. My circuit didn't produce that relationship, opening the door to the data overrun problem.

It is now clear that I need to use DREQ to qualify FIFO accesses. With that settled, the question was how to arrange the HBA so the MPU can poll DREQ. If I were using a W65C02S I could connect DREQ to the MPU's SOB input and test the status register V flag to see if DREQ was asserted (a trick used in some Commodore floppy disk drives). However, the W65C816S doesn't have an SOB input and, in fact, doesn't have any input that can be used for the purpose.

So, after giving it some thought, I decided to add a 74ABT541 bus driver chip to the HBA to put the state of DREQ on the data bus (see schematic; the '541 is in the middle of the drawing).
Attachment:
File comment: SCSI-SE HBA Schematic
scsi-se_adapter_sch.gif
scsi-se_adapter_sch.gif [ 197.38 KiB | Viewed 14216 times ]
The A8 input on the '541 is connected to the 'C94's DREQ output and the '541 Y outputs are connected to the MPU's data bus. Access to the '541 is via /IO-4, which is $00D400 in the memory map. To gate the '541, I connected the /OE1 (output enable) input to /IO-4, and to make the '541 read-only, connected /RD (read data) to the '541's /OE2 input—both /OE1 and /OE2 have to be low to enable the '541, otherwise it stays in a high-Z state. Hence a read on any address in the $00D400 page will cause the '541 to drive the data bus, with the state of DREQ appearing as bit 7 for convenient testing.

I needed to mount the '541 on the HBA but was hesitant to do it via the cut 'n patch method, especially since I also needed to add /IO-4 to the circuit. As the HBA effectively takes the MPU's buses off the mainboard, reactive effects become a concern, and blue wire running all over the place certainly doesn't help in that regard. Complicating matters, the one remaining available expansion port pin, through which /IO-4 would be connected, is underneath the watchdog socket and thus is only accessible by wrapping a piece of wire around the edge of the board, certainly not an elegant technique.

So I decided to make a new host adapter (see PCB illustration below).
Attachment:
File comment: SCSI-SE HBA PCB Layout
scsi-se_adapter_hba.png
scsi-se_adapter_hba.png [ 60.88 KiB | Viewed 14216 times ]
I extended one end of the PCB enough to mount the '541 and its decoupling capacitor. Previous patches are incorporated into the new design, so there won't be any blue wire (for now, at least :lol:). However, a patch is needed on the POC mainboard to bring /IO-4 to the expansion socket. Fortunately, that's an easy one involving about 2-1/2 inches of wire.

The new HBA PCBs have been ordered and should be in-hand early next week. I'll post results and pictures when the new HBA is ready to go to work.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Fri May 25, 2012 11:48 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
Nice progress BDD!
I see you are using a power connector on the first pic of your last post. What part # is that if I may ask?
I use the DS1818 POR IC in my project. It is similar to yours except it's 3.3V and I think the reset may last half as long... Nice simple circuit there for a reset without worrying about an additional debounce circuit.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Sat May 26, 2012 1:53 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
ElEctric_EyE wrote:
Nice progress BDD!
I see you are using a power connector on the first pic of your last post. What part # is that if I may ask?

That is a disk drive jack like you would see on a 5-1/4 inch floppy drive or a non-SATA hard drive, Molex part number 15-24-4441. It snaps into several holes in the PCB to mechanically anchor it and keep stress off the electrical connections. Here's the data sheet. I have created a component for it in Express PCB, in case anyone is interested.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Last edited by BigDumbDinosaur on Sat May 26, 2012 5:57 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer w/SCSI
PostPosted: Sat May 26, 2012 5:46 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
BigDumbDinosaur wrote:
The new HBA PCBs have been ordered and should be in-hand early next week. I'll post results and pictures when the new HBA is ready to go to work.

The new SCSI host adapter (HBA) has been assembled and functioned right out of the gate. Here are some pictures:
Attachment:
File comment: SCSI-SE Host Adapter Bare PCB
scsi_hba01.jpg
scsi_hba01.jpg [ 681.69 KiB | Viewed 14190 times ]
Attachment:
File comment: SCSI-SE Host Adapter Assembly
scsi_hba02.jpg
scsi_hba02.jpg [ 1.06 MiB | Viewed 14190 times ]
Attachment:
File comment: SCSI-SE Host Adaptor Attached to POC V1.1. In this picture, I have my logic probe monitoring the DREQ DMA handshake signal.
scsi_hba03.JPG
scsi_hba03.JPG [ 357.3 KiB | Viewed 14190 times ]

Quote:
In my first host adapter (HBA) design, I had ignored a 'C94 DMA handshaking signal called DREQ because I didn't expect the data overrun problem—I figured the instant that last byte was read from the FIFO the 'C94 would interrupt. DREQ is used along with the 'C94's /DACK input to control DMA access to the chip's FIFO during the SCSI data-in and data-out bus phases, which is when protracted data flow would be expected. During a read operation, DREQ is asserted by the 'C94 any time it has data waiting in the FIFO. During a write operation, DREQ is asserted as long as the 'C94's FIFO has room for a byte (it's a 16 deep FIFO). When used with a real DMA controller, a tight handshaking relationship exists and there's no problem. My circuit didn't produce that relationship, opening the door to the data overrun problem.
The DREQ add-on circuit works as expected and now gives me the ability to make the W65C816S mimic the functions of a real DMA controller. The key word is "mimic." I'll have some more thoughts on how I might go about this in another post.
Attachment:
File comment: POC V1.1 POST screen.
scsi_hba04.JPG
scsi_hba04.JPG [ 395.68 KiB | Viewed 14190 times ]
In this last picture, the POC has POSTed and attempted to perform an ISL from disk. The boot block has been read from the hard drive, but boot can't continue because there is no root filesystem on the disk. At this point, I'm still using the old PIO SCSI driver.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Sat May 26, 2012 6:46 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3354
Location: Ontario, Canada
The photos look great, BDD! I'd been hoping that sooner or later we'd get a look at what you're doing :)

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Sat May 26, 2012 7:38 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
Dr Jefyll wrote:
The photos look great, BDD! I'd been hoping that sooner or later we'd get a look at what you're doing :)

-- Jeff

Thanks! Best part was when I applied power and there were no sparks, billowing clouds of smoke, explosions, fires or other calamities to mar the day. :lol: Incidentally, with a 4 ns average propagation time, that 74ABT541 bus driver on the host adapter is the fastest piece of silicon in the entire unit. It's surely a bit of overkill in that respect, but I had several laying around.

BTW, although POC V1.1 is strictly a hobby device (remember, POC = Proof Of Concept), its basic design may find its way into a practical application as part of a machine controller. I can't elaborate at this point in time, but will do so if it comes to fruition.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC Computer
PostPosted: Sun May 27, 2012 2:12 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
BigDumbDinosaur wrote:
The DREQ add-on circuit works as expected and now gives me the ability to make the W65C816S mimic the functions of a real DMA controller. The key word is "mimic." I'll have some more thoughts on how I might go about this in another post.

The purpose of fabricating a new host adapter was to make it possible to use the 53C94's DMA access functions. Programmed input/output (PIO) operation of the 'C94 is impractical during protracted data transfers, as the controller will interrupt for each byte moved. Reading a single hard disk block would entail 512 IRQs in rapid succession, plus other IRQs generated as the SCSI controller is sequenced. Throughput using PIO would be severely limited due to all the code the MPU would have to execute. Hence the focus on DMA.

When used with DMA, the 'C94 only interrupts when the last byte has been transferred (or an error occurs), which means that DMA transfer can be very efficient compared to PIO operation. I estimate the performance difference between PIO and DMA operation in the POC could be at least 10 to 1, maybe better—depending on how efficiently I write the driver. As I don't have the luxury of a real DMA controller I have to make the 65C816 pretend to be one. This is more complicated than it might appear at first blush. A real DMA controller can function independently of the MPU once the latter has programmed it. In the context of the 53C94, all a DMA controller has to do is handshake and move bytes. It doesn't have to worry about IRQs or what to do about them. Not so with the '816 and hence the greater programming complexity. In order to understand what is needed, detailed understanding of the behavior of the 53C94 is necessary.

The 'C94 is intended to automate the SCSI bus protocol and thus has been given a fair amount of intelligence. Ergo the chip has a number of registers that have to be programmed at boot time, while others have to be programmed before or during a SCSI transaction. The key registers are:

  • Destination ID. The SCSI ID of the device that is to be accessed is written here before each operation. As the 'C94 is designed to connect to the "narrow" (8-bit) SCSI bus, the target ID ranges from $00 to $07 inclusive. Traditionally, the HBA is assigned SCSI ID $07, as that ID has the highest priority on the bus. Hence seven devices, in addition to the HBA, may be attached to the bus, these devices using IDs $00 through $06.

  • FIFO. The 16-deep FIFO is the data conduit between the MPU's data bus and the SCSI bus. During a read operation, data coming in off the SCSI bus is deposited in the FIFO and eventually copied to RAM. During a write operation, data from RAM is written into the FIFO and eventually placed on the bus so it can be read by the target device. The details of how the 'C94 moves bytes between the FIFO and SCSI bus are of no concern to the MPU—the controller's intelligence insulates the MPU from the bus protocol details.

  • Command. The 'C94 is told what to do by writing a command opcode into this register. Many commands may be PIO or DMA, the latter indicated by setting bit seven of the opcode. The difference comes in how data movement occurs between the FIFO and RAM, as well as how the 'C94 must be set up before data flow can occur.

  • DMA Transfer count. Prior to using DMA to move bytes between the FIFO and RAM, the 'C94 must be told how many bytes to expect, up to 64 KB maximum. It uses this information to sequence the DMA handshake and also to report an error if the requested amount of data is not the same as the amount actually moved. If PIO is used to transfer between the FIFO and RAM this counter is not used.

    Internally the DMA transfer counter consists of two sets of registers, one which stores the most recent count setting and another that down-counts with each DMA handshake. In order to start the DMA transfer an appropriate DMA command must be written into the command register. Doing so will copy the previously set DMA count into the down-counter and the 'C94 will start the DMA handshake. On each completed DMA handshake, the count will decrement. When the down-count reaches zero the 'C94 will discontinue the DMA handshake and interrupt the MPU.

The DMA handshake is a hardware sequence that the DMA controller utilizes to communicate with the 'C94's FIFO. Two 'C94 signals are involved:

  • DREQ. This is an active high output from the 'C94, whose meaning depends on the direction of data transfer. During a read operation, DREQ will be true when the 'C94 has data for the DMA controller. During a write operation, DREQ will be true when the 'C94 is able to accept data from the DMA controller.

  • /DACK. This is an active low input to the 'C94. When true, the 'C94 will connect the FIFO to the data bus so it can be read or written. Each toggle of /DACK will decrement the DMA transfer counter. Due to the way in which the 'C94 operates, /DACK must never be asserted unless either /RD (read data) or /WD (write data) is likewise asserted—the transfer counter can get out of sync with the SCSI bus if this dictum is not observed. Also, the use of /DACK and /CS (chip select) are mutually exclusive. /CS is used for general register access (including FIFO access during PIO operation), whereas /DACK only accesses the FIFO. Operation is undefined if /CS and /DACK are simultaneously asserted.

The handshake sequence is as follows:

  1. Test the state of DREQ. If it is false, the 'C94 is not ready, so keep testing until it is ready.
  2. Assert /DACK. As soon as /DACK is asserted read from or write to the FIFO.
  3. Increment buffer pointer. Go back to step 1.

The above is repeated for as many bytes as are to be transferred. When the full count has been transferred, or some other significant event occurs, the 'C94 will interrupt the MPU.

An interesting "gotcha" exists in this scenario and it has to do with the basic nature of the SCSI bus protocol. Once the 'C94 has selected the target device, sent a valid command descriptor block (CDB) to it and the target has accepted the command, the target assumes control of the SCSI bus and thereafter dictates which operations are to be performed. Usually the target will switch the bus to the data-in (read) or data-out (write) phase, either of which will cause the 'C94 to interrupt the MPU. Upon servicing the interrupt, the MPU would execute code that would load the 'C94's DMA transfer counter with the number of bytes to move and then start the DMA handshake sequence described above. Data should start flowing. So far, so good.

The problem is what happens in the event the target device stalls for some reason, e.g., it suffers an internal failure that prevents it from communicating with the 'C94. The 'C94 has no way of knowing this, as it can only react to the current state of the SCSI bus. With a dead target, no changes will occur on the bus and the 'C94 will endlessly wait. Meanwhile, since there isn't any bus activity, the DMA controller will also be twiddling its thumbs, as the 'C94 won't assert DREQ until there's some data to process. Since no data is moving, the transfer counter isn't decrementing and therefore the 'C94 will not interrupt the MPU. Everything comes to a screeching halt.

Fortunately, there is a solution. In almost any system that would avail itself of SCSI, there is a jiffy interrupt that is driven by a hardware timer. For example, in a UNIX-like system, the jiffy IRQ is used to update the software clock, select jobs to run and the like. UNIX also has an alarm function that can be used to interrupt a process. Therefore the solution to the stalled bus problem is to set an alarm that will break the DMA handshake loop should the 'C94 IRQ not occur in a reasonable amount of time. Since a stalled bus will most likely be caused by failed hardware or a cable becoming unplugged, the alarm interrupt would vector the MPU to an error handler that can report higher up in the operating system.

POC also has a jiffy IRQ, which is generated by the Dallas watchdog timer at 10 millisecond intervals. The jiffy IRQ drives a 32 bit uptime counter, as well as a 16 bit down-counter that can be used for programmed time delays. I was able to add some code to the BIOS ROM that makes it possible to harness the down-counter to activate an alarm function. The alarm is set up as follows:
Code:
         longa                 ;16 bit .A
         lda #seconds          ;alarm time in seconds from now
         ldx #<vector          ;alarm vector LSB
         ldy #>vector          ;alarm vector MSB
         jsr alarm             ;set the alarm

In the above, VECTOR points to code that will be executed when the alarm goes off. Once the alarm has been set, the down-counter will decrement at one second intervals. When the counter reaches zero, the BIOS interrupt service routine (ISR) will replace the address that was pushed to the stack when the interrupt was serviced with VECTOR. Upon executing the RTI at the end of the ISR, the MPU will resume execution at VECTOR. The alarm automatically cancels itself when it goes off. It can be "manually" canceled by calling ALARM with zero in the 16 bit accumulator.

So my SCSI driver will have to set an alarm as part of the DMA transfer setup, just in case the bus stalls. If the transfer is successful the alarm would be canceled. The exact amount of alarm time needed is something I probably will have to determine by experimentation.

The most complicated part of the driver will be in the SCSI ISR. When the 'C94 interrupts there are four major conditions that have to be accounted for in the ISR:

  1. Successful operation.This condition will occur after each successful command to the 'C94. The meaning of "success" depends on context, so there are additional status bits that can be examined to determine what it was that was successful.
  2. Bus service request. This interrupt occurs when the target device changes the bus phase, and is generally paired with a successful operation IRQ (but not always—the target could change the bus phase to status-in because of an error). As I earlier noted, following selection and receipt of a valid CDB, the target will change the bus phase to data-in or data-out, depending on the direction of data transfer. When this happens, the 'C94, which will be waiting for the target to respond to the command, will interrupt with a bus service request.
  3. Selection timeout. According to the ANSI standard, the target device has a maximum of 250 milliseconds to respond to selection. If that time elapses without a response the 'C94 will interrupt with a selection timeout. This would constitute a "device not present" error.
  4. Gross error. The most recent operation can't be completed due to a hardware fault or because the command was not acceptable to the 'C94. For example, if the 'C94 is operating as an initiator (as it would be in the POC) and a target command is given to it, it will generate a gross error interrupt. Another possible error would be if a previously selected target unexpectedly disconnected from the bus. Yet another would be if somehow the direction of DMA was opposite of the direction of data flow (most likely the result of a logic error in the driver).

In each case, the ISR would not only have to recognize the condition, it would have to vector the MPU to the correct code block for that condition. The vectoring will be accomplished by tinkering with the RTI address on the stack. Obviously, monkeying with the stack in an ISR can be fraught with danger. If a mistake is made in the code, most likely the machine will crash and leave little or no evidence of what happened.

Therefore, my first tack in developing this driver will be to write a version that uses DMA access but no IRQs. Each of the code blocks will have to look at the 'C94's interrupt status register and decided what to do for each condition. Since this is all foreground code, it should be easier to debug. Once I have a suitable program flow worked out then I can rig up the IRQ stuff with reasonable confidence that it will work. I already have the alarm part working, so the rest is up to the driver.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: POC V1.1 Computer
PostPosted: Mon May 28, 2012 5:56 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8190
Location: Midwestern USA
In order to prove some of my ideas about driving the SCSI host adapter DMA style, I cobbled together a driver that uses the DREQ and /DACK handshake, but doesn't actually generate IRQs. The host adapter has a jumper block that allows me to either isolate or connect the low-true interrupt output of the 53C94 from or to /IRQ on the mainboard. Since writing a crash-proof IRQ driver for a chip like the 'C94 is not a trivial matter, I decided that in order to test the behavior and performance of the DMA style access, as well as prove that the DREQ and /DACK handshake works right, I would isolate the 'C94 from /IRQ and "manually" test for an IRQ after each handshake. That way, if something got hung up I could recover control with an NMI and thus preserve the conditions that led to the problem.

Like just about any I/O chip that uses interrupts, the 'C94 has a status register bit (bit 7) that goes true when the device is interrupting. So my read data code goes like this:
Code:
;================================================================================
;
;PROCESS DATA IN PHASE
;
phdatin  jsr dmaxfrsu          ;do DMA transfer setup steps
;
.0000010 bit dreq_srd          ;FIFO have data?
         bpl .0000020          ;no
;
         lda fifo_srd          ;yes, get &...
         sta mm_ram,x          ;store data (16 bit .X)
         inx                   ;next buffer location
         bra .0000010          ;get more
;
.0000020 lda stat_sr           ;did 'C94 interrupt?
         bpl .0000010          ;no, so get more data
;
;
;   DMA transfer completed...execute next step
;

The 'C94 will interrupt as soon as the last byte is read from the data FIFO and the IRQ will be cleared when the interrupt status register (separate from the status register) is read. Actually, there may be a small lag between the time when the last byte is read and the IRQ arrives, which means the MPU may loop a number of times testing DREQ. However, the IRQ will eventually arrive and signal (we hope) that a bus phase change has occurred, usually to the status phase. However, an IRQ could also signal trouble, so some testing is required to ascertain what the IRQ is all about. As the 'C94 maintains a count of how many bytes were transferred via DMA, it is also important to look at that count to verify that a full transfer occurred. Fortunately, the 'C94's status register has a bit that is set when the full count has been processed, so it's a simple test.

The above loop is pretty efficient, and during testing with the POC running a 10 MHz clock and reading 32 KB from the disk, it achieved a bit over 400 KB/second transfer rate, with no errors. That's about nine times faster than my present PIO driver can go. This testing, in addition to demonstrating how much faster DMA is than PIO, also proved that the DREQ and /DACK handshake is reliable. There were no data overruns like I was getting before I got the handshake into the picture.

The next step is to get the POC's interrupt handler to process 'C94 interrupts. Doing so would cut the execution time of the loop by six clock cycles, since the code needed to test the 'C94's status register would be eliminated—nothing would need to look at the 'C94's status register until it actually interrupted. Those six cycles are a not-insignificant improvement when one considers that over the time required to perform that 32 KB read from the disk, a savings of 196,608 clock cycles would be realized, which is 19.6 milliseconds at 10 MHz. That may cut the total processing time by 25 percent, which could increase performance to over 500 KB/seconds.

Incidentally, 10 MHz is as fast as I can run the system with the host adapter installed.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Last edited by BigDumbDinosaur on Fri Jun 22, 2012 6:31 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 564 posts ]  Go to page Previous  1 ... 11, 12, 13, 14, 15, 16, 17 ... 38  Next

All times are UTC


Who is online

Users browsing this forum: GARTHWILSON, Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: