home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 1 / Mecomp-CD.iso / amiga / tools / misc / cnetdevice / devnotes next >
Text File  |  1997-03-04  |  5KB  |  107 lines

  1.  
  2. PC-CARDs and the Amiga
  3.  
  4.  For those of you who might want to write drivers for PC-CARDs, here are
  5.  some things I have found out about them.
  6.  
  7.  Most cards are designed to be set up to look like an ISA bus card, which is
  8.  what the peecee needs for software compatibility.
  9.  
  10.  Since PCMCIA is quite different from ISA, the peecee has a controller
  11.  chip (PCIC) which can be programmed to translate from one bus to the other.
  12.  Using the PCIC, the PCMCIA memory can be mapped into the I/O and memory
  13.  space expected by an ISA card. Also the INT line is routed to one the ISA
  14.  interrupts. Once this setup has been done, the card would be accessed as if
  15.  it were a standard ISA bus card.
  16.  
  17.  Since the Amiga does not have a PCIC, we can access the memory and I/O
  18.  space directly. The single IRQ is handled for us by card.resource, we
  19.  merely have to provide a routine to run when the interrupt occurs.
  20.  It may be necessary to access odd I/O register locations at a different
  21.  address range from the even registers. Apparently this allows the card
  22.  to respond to byte accesses. A typical Amiga memory map for PCMCIA looks
  23.  like this:-
  24.  
  25.  $600000 - $9fffff  RAM (may be a mirror of attribute memory for I/O cards)
  26.  $a00000 - $a1ffff  attribute memory
  27.  $a20000 - $a2ffff  I/O space (16bit and even 8bit registers)
  28.  $a30000 - $a3ffff  I/O space (odd 8bit registers)
  29.  
  30.  If the PC-Card's registers were at the ISA I/O addresses of $0300 and $0301,
  31.  8bit access would appear in the Amiga at locations $a200300 ($0300) and
  32.  $a300300 ($0301). For 16bit access, both bytes would appear at $a200300/1.
  33.  Note that the Amiga PCMCIA slot has its data bus wires swapped to account
  34.  for INTEL byte order.
  35.  
  36.  In order to enable I/O access, the card may need to be programmed by first
  37.  writing to the Card Configuration Register in attribute memory. The location
  38.  of this register can be determined by examining the CCR tuple, however the
  39.  value to write is card specific.
  40.  
  41.  Determining this magic number can be a tricky job, because usually the
  42.  manufacturer is not interested in telling anyone what it is. Therefore
  43.  some sleuthing will probably be necessary. I have found some useful clues
  44.  by looking at FreeBSD and Linux source code, which can be downloaded from
  45.  the Internet. However this may not be enough, so hacking into the peecee
  46.  driver supplied with a PC-Card might be the ultimate answer.
  47.  
  48.  Once you have gathered enough infomation on the card's hardware features,
  49.  you will want to write a program to control it. This will involve use of
  50.  card.resource functions, so it is a good idea to read the docs on this
  51.  (available on the Amiga Developer CD). At a minimum, you will need to call
  52.  the functions OwnCard (to set up the interrupt) and CardMiscControl (to
  53.  enable I/O addressing). Other functions regarding Tuple parsing and Card
  54.  Memory Map etc. are not really necessary, as this information can be hard-
  55.  coded into your program.
  56.  
  57.  
  58. The case of the mysterious missing interrupts
  59.  
  60.  The Cnet card generates a standard level-sensitive interrupt. However Gayle
  61.  (the custom chip that controls the PCMCIA port) responds to interrupts on
  62.  negative and positive edges only. Since the card.resource resets Gayle's
  63.  interrupt latch _after_ the status interrupt routine finishes, there is a
  64.  small but fatal period of time where an interrupt could be missed. The
  65.  result is that the PCMCIA card could hold its INT line down expecting
  66.  service, but Gayle ignores it because the negative transition occurred
  67.  before her interrupt latch got reset.
  68.  
  69.  Commodore's recommended workaround for this is to add another PORTS
  70.  interrupt server, whose sole job is to make sure that card interrupts
  71.  are not enabled until after the status change interrupt has completed
  72.  (and the card.resource has reset the Gayle interrupt latch). This ensures
  73.  that the next downwards transition on the PCMCIA INT line gets detected.
  74.  
  75.  For V39 of card.resource a new method was provided, where by setting a flag
  76.  'CARDB_POSTSTATUS' your status interrupt would be called twice, the second
  77.  time would occur after Gayle had been reset. Unfortantely V39 did not make
  78.  it into the WB3.0 ROMS, so this is not an option for most A1200s and A600s.
  79.  
  80.  Being a lazy programmer, I could not be bothered writing conditional
  81.  code for different OS versions. I merely traced through the ROM to
  82.  find how the Gayle interrupts were reset, and included this in my
  83.  device code. Of course this is a 'hack' which may break if new PCMCIA
  84.  hardware is developed in future Amigas.
  85.  
  86.  
  87.  
  88. Accton EN2216
  89.  
  90.  I was recently loaned one of these cards, with the intention of modifying
  91.  my driver to suit it. Imagine my suprise when I plugged the card in and
  92.  it worked with my original driver!
  93.  
  94.  Actually the Accton is not quite the same as the CNet card. Firstly its
  95.  ethernet hardware addresses are in a different range, so I had to modify
  96.  my code a bit to accept it rather than dropping back to the default value.
  97.  I also suspect that my I/O enable byte is wrong for the Accton, however
  98.  this does not matter because the Accton card puts its registers at all
  99.  possible I/O locations! (later versions of the CNet card also do this).
  100.  
  101.  The Accton card makes its hardware address available in attribute memory.
  102.  This is an easier and more reliable place to get the address from, but
  103.  to make use of it I would have to detect the type of card inserted. maybe
  104.  in the next version I will pass tuples to find the card details, and then
  105.  add specific code for each model.
  106.  
  107.