The GG2 Bus+ User Software Interface

The GG2 Bus+ card also allows you to read and write to PC cards using your 
own software. The first issue is to find the base address of your PC card 
in Amiga address space.  The GG2 Bus+ card is a normal Zorro II card and uses the 
Amiga AUTOCONFIG(tm) feature to have its base address assigned to it by the 
host computer at boot-up time.  By knowing the manufacturer number (2150)
and the product number (1) of the GG2 Bus+ card, your software can request
the base address from the AmigaDOS operating system. 


Let us assume for the moment that the AUTOCONFIG base address has been 
assigned as (in hexadecimal notation) $200000.  Once we have the the base 
address of the GG2 Bus+ card, we need to find the base address the PC card is 
looking for.  This information should be in your documentation.  Generally, 
PC cards will have "I/O space" addresses in the range hex $0200 to $03FF.

For example, internal modems can be set up to look like the standard 
serial port COM1, which has a base address of hex $03F8.  There is a (fairly)
complete list of standard I/O space address assignments in Appendix C.

Now we have to put these two pieces of information together.  There 
is a small quirk in the way we do this, arising due to differences between 
the PC and Amiga busses.  Because the Amiga is a true 16 bit machine, it 
reads data in 16 bit words (i.e. two bytes at a time).  Thus the Amiga 
16 bit Zorro II bus does not provide the least-significant-bit A0 address 
signal, because it is not needed.  The PC bus, however, runs on 8 bits, reads 
one byte at a time, and therefore requires the A0 line.  To fix this 
problem, the Amiga A1 address line must be connected to the PC A0 address 
line.  The net effect of all this is that addresses in PC space are shifted
left by 1 bit, i.e. multiplied by two.

Shifting our COM1 port address hex $03F8 over by one bit (multiplying it by 2)
yields a base address of hex $07F0.  Adding this to our AUTOCONFIG base gives
a true base address of hex $2007F0. 

We are not quite done yet though!  The Amiga is a true 16 bit machine that 
reads in its data two bytes at a time.  In Amiga address space, all EVEN 
addresses correspond to the UPPER 8 data lines, while all ODD addresses 
correspond to the LOWER 8 data lines.  Since our internal modem card uses 
only the lower 8 data lines, we must use only ODD addresses.  Thus, the "0" 
register of our modem will actually appear at address hex $2007F1.  The "1" 
register will appear offset by one byte (the upper 8 bits of the next word) at 
address hex $2007F3, and so on.  Your software can also do a 16 bit word 
access at an EVEN address and just mask off the upper 8 bits.  Thus, the 
formula to access a byte address in PC IO space is:


Amiga_Memory_Address = AUTOCONFIG_Base_Address + (2 * PC_IO_Address) + 1


To do a 16 bit word access from Amiga memory, the address is:

Amiga_Memory_Address = AUTOCONFIG_Base_Address + (2 * PC_IO_Address)

with the byte value of the PC IO location in the upper 8 bits of the word 
value you read.

All IO addresses are read/write capable through the GG2 Bus+ card, but 
your PC card may not support them all as read/write.  The GG2 Bus+ card 
supports addressing for 32K worth of PC I/O space, much more than is normally 
used.  In our example, you can read and write from hex $200000 up to 
hex $20FFFF, 64K of Amiga space mapped to 32K of PC space.  As I described,
all EVEN addresses correspond to the upper 8 bits of data, all ODD addresses
to the lower 8 bits of data.  If you want to manually look at the registers
of your PC card, you can examine memory locations directly by using a machine
language monitor such as "Mon" on Fish disk 310.

The GG2 Bus+ also supports reading and writing to a 448K section of PC 
memory space from addresses $90000 to $FFFFF.  This is an important area used 
as a memory buffer by PC video cards, ethernet cards, and many others.  On 
the GG2 Bus+ board, for our example, it is mapped to Amiga addresses $220000 to 
$2FFFFF, but in a slightly different way than for IO space.  As in accessing
PC I/O space registers, the addresses in memory space are multiplied by two, 
but there is an additional twist.  The formula for byte accesses to PC memory 
space is:

Amiga_Memory_Address =

AUTOCONFIG_Base_Address + ((2 * PC_Memory_Address) & $FFFFF) + 1

where the "&" means to do a logical AND operation, and $FFFFF is the 
hexidecimal representation of the decimal number 1048575.  For 16 bit 
word accesses to Amiga memory space, the formula is:

Amiga_Memory_Address =

AUTOCONFIG_Base_Address + ((2 * PC_Memory_Address) & $FFFFF)

with the byte value of the PC memory location in the upper 8 bits of the 
word value you read.

The GG2 Bus+ card is also capable of handling 16 bit AT cards.  PC cards,
just as on the Amiga, expect 16 bit transfers to occur with even addresses, 
so, you would read out a 16 bit PC AT location just as described above for
doing 16 bit word Amiga accesses.  However, the Intel byte ordering in a
16-bit word is reversed from that of Motorola.  That means that when reading
PC-AT 16 bit cards, the low order byte is at the EVEN address, and the high
order byte is at the ODD address. In our example, to read a 16-bit word at
PC memory location $A0000, you would do a 16-bit word read of Amiga memory
location $240000.  The upper byte of this word would contain the lower byte
from the PC card, and the lower byte of this word would contain upper
byte from the PC card.  To access the next 16 bit location in PC memory
space, $A0002, you would read a 16-bit word from Amiga location $240004. 
Do not do a word access to Amiga memory location $24002 (or any other 
address not divisible by 4) or you will get erroneous (garbage) data from 
the PC card.

Note that if you have several different PC cards plugged in that you will 
be accessing via the GG2 Bus+ board, you must ensure that they do not
have conflicting addresses.  For example, you cannot have two cards both 
be COM1 or you will not be able to control them independently.  This is just 
like on an PC.  Likewise, multiple cards cannot use the same interrupts. 
For example, you can only have one PC card with the INT3 interrupt level, 
and one with INT4, etc.  Set the DIP switches or jumpers on your PC cards 
accordingly.


Interrupts


All PC interrupts are supported through the GG2 Bus+ card as Amiga INT6 
interrupts.  This means that any PC interrupt generated on your card as
IRQ3, IRQ4, IRQ7, etc. gets mapped to generate a single Amiga INT6
interrupt.  Multiple PC cards can generate different interrupts, with
the INT6 line simply staying active until all the interrupts have been
serviced.

If you plan to use PC card interrupts, you must write an interrupt server
routine.  Since all PC interrupts are linked to one Amiga interrupt,
their various priorities have been lost.  If you have multiple PC cards 
plugged in with one GG2 Bus+ card, and you know one card must be serviced 
ahead of another, simply write your interrupt driver routine to support this.
You can read out which interrupts have occurred by accessing the on-board 
Register 1 (see  Appendix B  ), and then put back any necessary prioritizing 
by writing your service routines accordingly.

At powerup, the GG2 Bus+ master interrupt enable is off, so no PC 
interrupts will be passed on to the Amiga.  You can turn on the master 
enable by writing anything to Register 2 (see  Appendix B ).  
This is done automatically by the COM1-4 ibmser.device driver included as
part of the GG2 Bus+ software package.  You can also toggle the master
interrupt enable manually by using the supplied  SwitchControl  program
(although this is usually not necessary).

Once the master interrupt enable is on, it will stay on through a system reset
until you turn it off (or turn off the power to your Amiga!).  You can turn 
off the interrupt enable by reading the value of Register 2.  The returned 
value will be the same as for Register 1, but the master enable will be turned
off as well.

Be careful with interrupts, because if you generate an interrupt with the 
master interrupt enable on, but without having a service routine in place,
your Amiga will crash instantly.  Note also that many PC cards have their 
own interrupt enable bit which must be set to generate interrupts.  In COM
devices, for example, this bit is bit 3 of register 4, labeled as "OUT2".



HTML Conversion by AG2HTML.pl V2.950424, perl 5.000 & witbrock@cs.cmu.edu