home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / dk86965.asm < prev    next >
Assembly Source File  |  1995-06-25  |  6KB  |  244 lines

  1. ;History:14,1
  2.  
  3. DR_TYPE    equ    100
  4. DR_NAME equ    'DK86965'
  5.  
  6.     include    ecoupler.asm
  7.  
  8.     public    usage_msg
  9. ;    we don't support -d (delay init till first open)
  10. ;    since several of the config parameters come from the device's EEPROM
  11. usage_msg    db    "usage: dk86965 [options] <packet_int_no>",CR,LF,'$'
  12.  
  13.     public    copyright_msg
  14. copyright_msg    db    "Packet driver for Fujitsu EtherCoupler (86965) device, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,CR,LF
  15.         db    "Portions Copyright 1993, RF Nets,Cupertino,CA",CR,LF,'$'
  16. ;---------------------------------------------------------------------------
  17. ; Ethercoupler specific data items - not needed after driver goes resident
  18. ;---------------------------------------------------------------------------
  19. iobtbl    Dw    260h,280h,2A0h,240h,340h,320h,380h,300h 
  20.         ;table of all I/O base addresses to try. Count is 8.
  21. IRQ_table Db    3,4,5,9        ;INTSEL to real IRQ (for FM DK86965 kit)
  22.  
  23.     extrn    flagbyte: byte
  24.  
  25. no_dopt_msg    db    "Error: -d option invalid for dk86965",CR,LF,'$'
  26. no_ec_msg    db    "No dk86965 found",CR,LF,'$'
  27. ec_problem_msg    db    "dk86965 and EEPROM don't agree",CR,LF,'$'
  28.  
  29.  
  30.     public    parse_args
  31. parse_args:
  32. ;
  33. ;  Only argument needed is the packet interrupt number.
  34. ;  tail.asm routines took care of that one.  Just need to check that
  35. ;  -d option wasn't specified.
  36. ;
  37. ; exit with nc if all went well, cy otherwise.
  38. ;
  39.     assume    ds:code
  40.     test    flagbyte,D_OPTION    ;delayed init option(-d) present?
  41.     Jz    PA_01
  42.     Mov    DX,offset no_dopt_msg
  43.     Mov    AH,9        ;DOS FC print $ term string
  44.     Int    21h        ;DOS Funct Call
  45.     Stc            ;error!
  46.     Ret
  47.  
  48. PA_01:        ;-d option not found...we're okay
  49.     clc
  50.     ret
  51.  
  52. get_board_parameters:
  53. ;   find the ethercoupler adapter
  54.     mov    io_addr+2,0        ;always search.
  55.     Call    SearchforEC
  56.         ;search for EC signature, filling in io_addr variable
  57.         ;if not found then, io_addr is set to zero.
  58.     Mov    DX,io_addr    ;get EC base addres
  59.     Or    DX,DX        ;EC found?
  60.     Jnz    ETO_01        ;make into long jump
  61.     mov    dx,offset no_ec_msg
  62.     Jmp    noEC        ;Nyet..gripe and exit
  63. ETO_01:
  64.     Mov    AL,EEP_CONFIG_R0    ;read EEPROM config reg 0 (H/W setup)
  65.     Call    read_EEPROM_reg
  66.     Mov    BX,AX        ;save - we'll cmpare to BMPR19 (J'less config)
  67.     Mov    DX,io_addr
  68.     Add    DX,BMPR19
  69.     Xor    AX,AX        ;clear upper byte
  70.     In    AL,DX        ;read EC's idea of J'less config
  71.     Cmp    BH,AL        ;how can they differ?
  72.     Jz    ETC_02
  73.     mov    dx,offset ec_problem_msg
  74.     Jmp    EC_problem
  75. ETC_02:
  76.     Shr    AX,6        ;move INTSEL bits to lower byte
  77.     Mov    SI,AX
  78.     Mov    AL,IRQ_table[SI] ;get real IRQ number
  79.     Mov    int_no,AL    
  80.  
  81.     ret
  82.  
  83. read_mac_addr:
  84. ;enter with si -> place to store Ethernet address
  85.     Mov    AX,4        ;addr of word ot get
  86.     Call    read_EEPROM_reg    ;read the word
  87.     mov    [si+0],ax
  88.  
  89.     Mov    AX,5        ;addr of word ot get
  90.     Call    read_EEPROM_reg    ;read the word
  91.     mov    [si+2],ax
  92.  
  93.     Mov    AX,6        ;addr of word ot get
  94.     Call    read_EEPROM_reg    ;read the word
  95.     mov    [si+4],ax
  96.     ret
  97.  
  98. ;-------------------------------------------------------------------
  99. ; SearchforEC
  100. ;-------------------------------------------------------------------
  101. SearchforEC    Proc
  102.  
  103.     Push    SI
  104.     Push    CX
  105.     Push    AX
  106.     
  107.     Mov    CX,8        ;count of tbale entries
  108.     Mov    SI,0         ;index into I/O base addr table
  109.  
  110. SEC_01:
  111.     Mov    DX,iobtbl[SI]    ;get table entry
  112.  
  113.     Add    DX,2        ;check DLCR2 first
  114.     In    AL,DX        ;get DLCR2
  115.     And    AL,DLCR2_sig_mask ;0x71
  116.     Jnz    sig_fail    ;if any bits left on, then not valid sig
  117.     Add    DX,2        ;DLCR4
  118.     In    AL,DX
  119.     And    AL,DLCR4_sig_mask  ;0x08
  120.     Jnz    sig_fail
  121.     Inc    DX        ;DLCR5
  122.     In    AL,DX
  123.     And    AL,DLCR5_sig_mask ;0x80
  124.     Jnz    sig_fail
  125.     Add    DX,2        ;DLCR7
  126.     In    AL,DX
  127.     And    AL,DLCR7_sig_mask ;0x10
  128.     Jnz    sig_fail
  129. ;
  130. ;  valid EC signature found
  131. ;
  132.     Mov    DX,iobtbl[SI]    ;get the base address back
  133.     Jmp    SEC_02        ;return to caller
  134.  
  135. sig_fail:    ;come here when one of the signature checks fails
  136.     Inc    SI
  137.     Inc    SI
  138.     Loop    SEC_01
  139. ;
  140. ;  didn't find the EC signature..maybe a conflict exists, or it's dead!
  141. ;    
  142.     Mov    DX,0        ;return base address, none
  143. SEC_02:
  144.     Mov    io_addr,DX    ;save for future use
  145.     Pop    AX
  146.     Pop    CX
  147.     Pop    SI
  148.     Ret
  149.  
  150. DLCR2_sig_mask    Equ    71h
  151. DLCR4_sig_mask    Equ    08h
  152. DLCR5_sig_mask    Equ    80h
  153. DLCR7_sig_mask    Equ    10h
  154.  
  155. SearchforEC    endp
  156.  
  157. ;--------------------------------------------------------------------
  158. ;
  159. ; read_EEPROM_reg - read one of 16 registers in the EEPROM
  160. ;
  161. ;    input - register address in AL
  162. ;   output - register value in AX
  163. ;
  164. ;--------------------------------------------------------------------
  165. read_EEPROM_reg:
  166.  
  167.     Push    DX
  168.     Push    CX
  169.     Push    BX
  170.     Push    AX        ;used to save data value
  171.  
  172.     Mov    DX,io_addr
  173.     Add    DX,BMPR16    ;get offset to EEPROM ctl reg
  174.     Xor    AX,AX        ;clear CS and SK
  175.     Out    DX,AL        ;
  176.     Inc    DX        ;BMPR17
  177.     Out    DX,AL        ;clear EDIO bit
  178.     Dec    DX        ;BMPR16
  179.     Mov    AL,EEP_ECS    ;set chip select
  180.     Out    DX,AL
  181.     Mov    AL,80h        ;set data start bit
  182.     Inc    DX        ;set DX to address of BMPR17
  183.     Out    DX,AL
  184.     Mov    AL,EEP_ECS+EEP_ESK ;set CS and clock high
  185.     Dec    DX        ;back to addr of BMPR16 (EEPROM CTL Reg)
  186.     Out    DX,AL
  187.     Pop    AX        ;get desired address back
  188.     Or    AX,EEP_CMD_READ    ;combine reg addr and EEPROM opcode
  189.  
  190.     Mov    CX,8        ;# of bits in data byte
  191. RRE_01:        ;top of serial shift out data to EEPROM loop
  192.     Inc    DX        ;EEPROM Data register addr
  193.     Out    DX,AL        ;set upper bit into serial data register
  194.     Dec    Dx
  195.     Mov    BX,AX        ;save AL
  196.     Mov    AL,EEP_ECS    ;clock low
  197.     Out    DX,AL
  198.     Or    AL,EEP_ESK    ;clock high
  199.     Out    DX,AL
  200. ;  bit clocked out, now shift in next bit
  201.     Mov    AX,BX        ;get data byte back
  202.     Shl    AL,1        ;shift left
  203.     Loop    RRE_01        ;
  204.  
  205. ; command byte clocked out, now clock in data bits.  
  206. ;   Note: the initial zero bit for data read overlaps the last bit of
  207. ;   command byte, and hence is lost.
  208.     Mov    CX,16        ;16 bits
  209.     Xor    BX,BX        ;need lower byte cleared
  210.  
  211. rre_02:        ;top of loop for shifting in data bits (17 total)
  212.     Mov    AL,EEP_ECS    ;clock low
  213.     Out    DX,AL
  214.     Or    AL,EEP_ESK    ;clock high
  215.     Out    DX,AL
  216.     Inc    DX        ;addr to BMPR17 (EEPROM data reg)
  217.     In    AL,DX        ;get a data bit
  218.     shr    al,8        ;get into cy
  219.     rcl    bx,1            ;move into LSB of bx.
  220.     dec    dx        ;back to BMPR16 (EEPROM ctl)
  221.     loop    rre_02
  222.  
  223. ; done, put output data into AX, pop stack, and disappear
  224.     Mov    AX,BX
  225.     Pop    BX
  226.     Pop    CX
  227.     Pop    DX
  228.     Ret
  229.  
  230. code    ends
  231.  
  232.     end
  233.  
  234. ; $Log: ecoupler.s%v $
  235. ;Revision 1.3  1993/02/10  06:30:26  N6RCE
  236. ;banner additions
  237. ;
  238. ;Revision 1.2  1993/01/18  03:49:10  N6RCE
  239. ;new recv ISR logic.
  240. ;
  241. ;Revision 1.1  1993/01/17  20:29:38  N6RCE
  242. ;Initial revision
  243. ;
  244.