Subject: Re: Question about A2232
To: John Klos , Ignatios Souvatzis <is@netbsd.org>
From: Jukka Marin <jmarin@pyy.jmp.fi>
List: port-amiga
Date: 03/31/2001 23:42:38
Hello All,

I'm doing a group reply so I don't have to explain things several times :)

On Sat, Mar 31, 2001 at 01:48:46PM -0500, John Klos wrote:

> > I used the A2232 for 6 modems at the time I worked on the driver.  Worked
> > very well..
> 
> Good! I don't think people will be running all seven ports at once,
> because it's mostly for maintenance and emergencies, but that's really
> good to know.

Well, I was running an Internet server on my A3000.  One port of A2232 was
used for Internet traffic over a leased-line modem and the other lines
were used for dial-in modems.  I modified the A2232 for the 38400 bps
speed (by replacing the crystal oscillator) and with _all_ 5 or 6 lines
pushing data simultaneously, I saw no data losses and the 68030 load was
very small (because my driver doesn't interrupt the 68030 at all; the
Amiga CPU just pulls the A2232 dual-port RAM flags every 20 ms to see
if any new events have occurred).

> > > I performed the handshaking modification as described in the Aminet
> > > a2232tuning.lha docs, thinking that because the clock doubling and the
> > > polling were supported in the NetBSD code, that the handshaking mod might
> > > be supported, too.
> >
> > Handshaking mod?  What is it supposed to do?
> 
> The document on Aminet is in German, and the english translation isn't as
> clear as it could be, but let me quote:
> 
> "o Functioning RTS/CTS-Handshake for unidirectional Transfers
> 
>   The original Device had Problems with the RTS-Handshaking when receiving
>   Data. This Problem is fixed with the new Device. However it only works if
>   while receiving data, no data is sent on the same port simultaneously.
>   To get fully working bidirectional handshaking, you have to modify the
>   hardware as described later in this document.

Hmm.  It's been a long time and I no longer run NetBSD on Amiga.. but as
far as I recall, the only problem with the RTS/CTS handshaking was that
you have no way of disabling CTS handshaking with the A2232 hardware.
The CTS input goes to the 6551 ACIA chip and whenever the input goes
passive, the RS232 transmitter is disabled, PERIOD.  (So Commodore had
to use pull-up resistors at the RS232 receiver chip inputs to set CTS
in the active state by default, in case the user was using a 3-wire
cable with no connection to the CTS input at all).

The AmigaOS driver has (had) problems with higher speeds because (I think,
I can't recall any more) the RTS/CTS handshaking was done on the Amiga
side and required the 68030 to control the RTS output.

My driver does everything on the 6502 side: If the 6502 notices that the
input FIFO is filling up, it automatically negates the RTS output, so the
remote system stops transmitting data.  _No_ help from the 68030 is
required.

The CTS input is also checked by the 6502 code and transmission occurs
only when the CTS input is active.

I do not know anything about this AmiNet driver, but as far as I recall,
my NetBSD driver had _no_ handshaking problems and required _no_ hardware
modifications to the A2232 board.  If someone knows a problem about my
driver, please speak up ;-)  I also _know_ that I used the standard A2232
serial cables with standard modems, so _no_ special wiring was required
when using the A2232 with modems.

> Whew! So I did this mod before checking to see if NetBSD knows about it.
> Silly me. I thought that since the source mentions support of the
> clock-doubled board, and because the only place I've ever seen mention of
> that mod is in the one document on Aminet that is about the A2232, that
> the NetBSD code evolved from the Aminet A2232 stuff. Oops!

My NetBSD driver handles the clock-doubled boards properly.  When the
A2232 is booted, my driver transmits one byte of data over the ACIA channel
0 and uses a 6526 CIA timer to measure the transmission time and sets an
internal variable accordingly.  No other hardware modifications are required,
just the change of crystal oscillator.

> Cool! Obviously I won't be working on the A2232 and the mod in the machine
> that gets colocated, but if I can find another A2232, I'd love to try to
> merge in the support from the Aminet code into the NetBSD code.

I'm still not convinced that any modifications are required. ;-)

My driver did NOT handle other word lenghts but 8N1 and it _always_ uses
RTS/CTS handshaking - so it's not perfect.. but the changes discussed here
do not sound useful to me.

On Sat, Mar 31, 2001 at 09:31:41PM +0200, Ignatios Souvatzis wrote:
> Hm. The 6502 code from the Aminet archive is definitely different from 
> the one in NetBSD. Note that the NetBSD code is older; according to the
> comments in the Aminet archive, their software was based on Jukkas work.

Originally, I disassembled the Commodore 6502 code to find out how it worked.
Then I wrote my own code from scratch, trying to optimize it for speed and
to make RTS/CTS handshaking work reliably.  My goal was to use the A2232
for a "terminal server" and I was successful.  The Amiga was replaced by a
pc at a later time - not because of A2232 problems (the A2232 and my driver
were more reliable than my existing pc serial solutions including the
Cyclades "RISC based" serial cards which tend to drop characters) - but
because the Amiga's 68030 wasn't too fast for a multi-user server.

> Anyway, so I guess you can leave the clock-doubling part in. Fortunately
> you won't really need really high speeds for serial consoles... 19200
> is faster than most people can read.
> 
> Regards,
> 	Ignatios
> 
> [1] Guesswork on how to support the handshake modification: the trick would
> be to just _measure_ the clock speed like they do; I guess Jukkas code
> does the same, and use the "connected pin" trick they mention to detect
> the handshake change. Hopefully that would work. Problem is that their license
> terms are not acceptable for the BSD kernel, so we'd have to negotiate with
> them to use their microcode, or write one from scratch for NetBSD, using the
> textual description and the wiring diagram.

Just forget about these modifications. ;-)  Or try to convince me.. ;-)

  -jm