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

  1. ;History:508,1
  2. version    equ    0
  3.  
  4.     include    defs.asm
  5.  
  6. ;  Copyright, 1991-1992, Russell Nelson, Crynwr Software
  7.  
  8. ;   This program is free software; you can redistribute it and/or modify
  9. ;   it under the terms of the GNU General Public License as published by
  10. ;   the Free Software Foundation, version 1.
  11. ;
  12. ;   This program is distributed in the hope that it will be useful,
  13. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;   GNU General Public License for more details.
  16. ;
  17. ;   You should have received a copy of the GNU General Public License
  18. ;   along with this program; if not, write to the Free Software
  19. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. arlan_segment    segment at 0
  22.  
  23.         org    000h
  24. ar_signature    db    ?
  25.  
  26.         org    030h
  27. ar_reset    db    ?
  28.  
  29.         org    031h
  30. ar_diagnostics    db    ?
  31.  
  32.         org    040h
  33. ar_node_id    db    EADDR_LEN dup(?)    ;6 byte node address field.
  34.  
  35.         org    046h
  36. ar_node_bcast    db    EADDR_LEN dup(?)    ;6 byte broadcast address.
  37.  
  38.         org    04ch
  39. ar_type        db    ?        ;1 byte hardware type
  40. ar_type_A450    equ    00h
  41. ar_type_A650    equ    01h
  42. ar_type_A670    equ    0bh
  43. ar_type_A670E    equ    0ch
  44. ar_type_A650E    equ    0dh
  45. ar_type_A440LT    equ    0eh
  46.  
  47.         org    04dh
  48. ar_version    label    word        ;Version number.
  49. ar_version_maj    db    ?
  50. ar_version_min    db    ?
  51.  
  52.         org    080h
  53. ar_interrupt    db    ?        ;not used by LANCPU
  54.  
  55.         org    081h
  56. ar_control_i    db    ?        ;image of the control register.
  57.  
  58.         org    090h
  59. ar_command    db    ?
  60.  
  61. COM_CONF    equ    1
  62. COM_RX_ENABLE    equ    3
  63. COM_RX_ABORT    equ    4
  64. COM_TX_ENABLE    equ    5
  65. COM_TX_ABORT    equ    6
  66. COM_NOP        equ    7
  67. COM_INT        equ    80h
  68.  
  69.         org    0a0h
  70. ar_rx_status    db    ?
  71.  
  72.         org    0a2h
  73. ar_rx_offset    dw    ?        ;start of received datagram
  74.  
  75.         org    0a4h
  76. ar_rx_length    dw    ?        ;length of received datagram
  77.  
  78.         org    0a6h
  79. ar_rx_src    db    EADDR_LEN dup(?)    ;RX source address.
  80.  
  81.         org    0ach
  82. ar_rx_bcast    db    ?        ;<>0 if received frame was bcast.
  83.  
  84.         org    0adh
  85. ar_rx_quality    db    ?        ;indicates quality of received packet.
  86.  
  87.         org    0b0h
  88. ar_tx_status    db    ?
  89.  
  90.         org    0b1h
  91. ar_tx_quality    db    ?
  92.  
  93.         org    100h
  94. ar_sys_params    label    byte
  95.  
  96.         org    108h
  97. ar_irq_level    db    ?        ;IRQ level
  98.  
  99.         org    109h
  100. ar_spreading    db    3 dup(?)    ;Spread spectrum code ID.
  101.  
  102.         org    10ch
  103. ar_NID        dw    ?        ;Radio address of LAN card.
  104.  
  105.         org    11dh
  106. ar_tx_atten    db    ?        ;attenuation of radio transmitter in db.
  107.  
  108.         org    11eh
  109. ar_system_id    dd    ?        ;system ID.
  110.  
  111.         org    128h
  112. ar_MDS        dw    ?        ;Maximum Datagram Size.
  113.  
  114.         org    12ah
  115. ar_MFS        dw    ?        ;Maximum Frame Size.
  116.  
  117.         org    12ch
  118. ar_max_retry    db    ?
  119.  
  120.         org    162h
  121. ar_register    db    ?        ;indicates if card must register w/ router.
  122.  
  123.         org    164h
  124. ar_poll_rate    dw    ?        ;<>0 if power saving is used.
  125.  
  126.         org    166h
  127. ar_refresh_rate    dw    ?        ;tens of msecs between registration
  128.                     ;refreshes.
  129.         org    168h
  130. ar_name        db    16 dup(?)
  131.  
  132.         org    400h
  133. ar_tx_buffer    label    byte
  134.  
  135.         org    0c00h
  136. ar_rx_buffer    label    byte
  137.  
  138.         org    1fffh
  139. ar_control    db    ?
  140. CONTROL_RESET    equ    1
  141. CONTROL_CA    equ    2
  142. CONTROL_IE    equ    4
  143. CONTROL_CLRI    equ    8
  144.  
  145.  
  146. arlan_segment    ends
  147.  
  148. code    segment    word public
  149.     assume    cs:code, ds:code
  150.  
  151.     public    int_no
  152. int_no    db    0,0,0,0            ;must be four bytes long for get_number.
  153.  
  154. base_addr    dw    ?        ;The base address of the board.
  155.  
  156. xmit_bdcast    db    ?
  157.  
  158.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  159. driver_class    db    BLUEBOOK,0    ;from the packet spec
  160. driver_type    db    99        ;from the packet spec
  161. driver_name    db    'ARLAN 450',0    ;name of the driver.
  162. driver_function    db    2
  163. parameter_list    label    byte
  164.     db    1    ;major rev of packet driver
  165.     db    9    ;minor rev of packet driver
  166.     db    14    ;length of parameter list
  167.     db    EADDR_LEN    ;length of MAC-layer address
  168.     dw    GIANT    ;MTU, including MAC headers
  169.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  170.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  171.     dw    0    ;(# of successive xmits) - 1
  172. int_num    dw    0    ;Interrupt # to hook for post-EOI
  173.             ;processing, 0 == none,
  174.  
  175.     public    rcv_modes
  176. rcv_modes    dw    4        ;number of receive modes in our table.
  177.         dw    0,0,0,rcv_mode_3
  178.  
  179.     public bad_command_intercept
  180. bad_command_intercept:
  181. ;called with ah=command, unknown to the skeleton.
  182. ;exit with nc if okay, cy, dh=error if not.
  183.     mov    dh,BAD_COMMAND
  184.     stc
  185.     ret
  186.  
  187.     public    as_send_pkt
  188. ; The Asynchronous Transmit Packet routine.
  189. ; Enter with es:di -> i/o control block, ds:si -> packet, cx = packet length,
  190. ;   interrupts possibly enabled.
  191. ; Exit with nc if ok, or else cy if error, dh set to error number.
  192. ;   es:di and interrupt enable flag preserved on exit.
  193. as_send_pkt:
  194.     ret
  195.  
  196.     public    drop_pkt
  197. ; Drop a packet from the queue.
  198. ; Enter with es:di -> iocb.
  199. drop_pkt:
  200.     assume    ds:nothing
  201.     ret
  202.  
  203.     public    xmit
  204. ; Process a transmit interrupt with the least possible latency to achieve
  205. ;   back-to-back packet transmissions.
  206. ; May only use ax and dx.
  207. xmit:
  208.     assume    ds:nothing
  209.     ret
  210.  
  211.  
  212.     include    popf.asm
  213.     include    timeout.asm
  214.     include    movemem.asm
  215.  
  216.     public    send_pkt
  217. send_pkt:
  218. ;enter with es:di->upcall routine, (0:0) if no upcall is desired.
  219. ;  (only if the high-performance bit is set in driver_function)
  220. ;enter with ds:si -> packet, cx = packet length.
  221. ;if we're a high-performance driver, es:di -> upcall.
  222. ;exit with nc if ok, or else cy if error, dh set to error number.
  223.     assume    ds:nothing
  224.  
  225.     mov    es,base_addr
  226.     assume    es:arlan_segment
  227.  
  228.     cmp    cx,ar_MDS        ;Is this packet too large?
  229.     mov    dh,NO_SPACE
  230.     ja    send_pkt_toobig        ;yes, don't bother sending it.
  231.  
  232.   if 0
  233.     mov    bx,2            ;count the number of times around...
  234. wait_again:
  235.     mov    ax,10            ;don't wait too long...
  236.     call    set_timeout
  237. wait_for_xmit:
  238.     sti
  239.     cmp    ar_tx_status,0        ;is the transmit done?
  240.     jne    xmit_done        ;yes, exit now.
  241.     call    do_timeout
  242.     jne    wait_for_xmit        ;no, wait for it to finish.
  243.     cli
  244.  
  245.     inc    ar_interrupt        ;note that we had to crap out.
  246.  
  247.     mov    ar_command,COM_TX_ABORT
  248.     call    doca
  249.     mov    ar_tx_status,1
  250.   else
  251.     sti
  252. wait_for_xmit:
  253.     cmp    ar_tx_status,0        ;is the transmit done?
  254.     jne    xmit_done        ;yes, exit now.
  255.     jmp    wait_for_xmit        ;no, wait for it to finish.
  256.   endif
  257.     clc                ;pretend we actually sent it.
  258.     ret
  259. send_pkt_toobig:
  260.     stc
  261.     ret
  262. xmit_done:
  263.     cli
  264.  
  265.     mov    di,offset ar_command + 5
  266.  
  267.     mov    xmit_bdcast,0
  268.  
  269. ;check to see if it's an Ethernet broadcast (all ones).
  270.     push    ds
  271.     push    si
  272.     push    cx
  273.     mov    cx,EADDR_LEN
  274. send_pkt_1:
  275.     lodsb
  276.     cmp    al,0ffh
  277.     loope    send_pkt_1
  278.     jne    send_pkt_2        ;not Ethernet broadcast.
  279.  
  280.     inc    xmit_bdcast        ;remember that it was a broadcast.
  281.  
  282.     mov    si,offset ar_node_bcast    ;use our broadcast address.
  283.     mov    ds,base_addr
  284.  
  285.     movsw                ;move the broadcast address over.
  286.     movsw
  287.     movsw
  288.  
  289.     pop    cx
  290.     pop    si
  291.     pop    ds
  292.  
  293.     add    si,EADDR_LEN        ;skip the addresses.
  294.     jmp    short send_pkt_3
  295. send_pkt_2:
  296.     pop    cx
  297.     pop    si
  298.     pop    ds
  299.  
  300.     movsw                ;move the destination address over.
  301.     movsw
  302.     movsw
  303.  
  304. send_pkt_3:
  305.     add    si,EADDR_LEN        ;skip the addresses.
  306.     sub    cx,EADDR_LEN+EADDR_LEN    ;. .
  307.  
  308.     mov    di,offset ar_tx_buffer
  309.     mov    al,xmit_bdcast
  310.     stosb
  311.     push    cx
  312.     call    movemem
  313.     pop    cx
  314.  
  315.     inc    cx            ;include the broadcast byte.
  316.  
  317.     mov    ar_command,COM_TX_ENABLE
  318.     mov    word ptr ar_command[1],offset ar_tx_buffer
  319.     mov    word ptr ar_command[3],cx
  320.  
  321.     mov    ar_tx_status,0        ;let the board fill it in.
  322.  
  323.     call    doca
  324.  
  325.     clc
  326.     ret
  327.  
  328.  
  329.     public    set_address
  330. set_address:
  331. ;enter with ds:si -> Ethernet address, CX = length of address.
  332. ;exit with nc if okay, or cy, dh=error if any errors.
  333.     assume    ds:nothing
  334.     ret
  335.  
  336.  
  337. rcv_mode_3:
  338. ;receive mode 3 is the only one we support, so we don't have to do anything.
  339.     ret
  340.  
  341.  
  342.     public    set_multicast_list
  343. set_multicast_list:
  344. ;enter with ds:si ->list of multicast addresses, ax = number of addresses,
  345. ;  cx = number of bytes.
  346. ;return nc if we set all of them, or cy,dh=error if we didn't.
  347.     mov    dh,NO_MULTICAST
  348.     stc
  349.     ret
  350.  
  351.  
  352.     public    terminate
  353. terminate:
  354.     clc
  355.     ret
  356.  
  357.     public    reset_interface
  358. reset_interface:
  359. ;reset the interface.
  360.     assume    ds:code
  361.     ret
  362.  
  363.  
  364. ;called when we want to determine what to do with a received packet.
  365. ;enter with cx = packet length, es:di -> packet type, dl = packet class.
  366.     extrn    recv_find: near
  367.  
  368. ;called after we have copied the packet into the buffer.
  369. ;enter with ds:si ->the packet, cx = length of the packet.
  370.     extrn    recv_copy: near
  371.  
  372. ;call this routine to schedule a subroutine that gets run after the
  373. ;recv_isr.  This is done by stuffing routine's address in place
  374. ;of the recv_isr iret's address.  This routine should push the flags when it
  375. ;is entered, and should jump to recv_exiting_exit to leave.
  376. ;enter with ax = address of routine to run.
  377.     extrn    schedule_exiting: near
  378.  
  379. ;recv_exiting jumps here to exit, after pushing the flags.
  380.     extrn    recv_exiting_exit: near
  381.  
  382.     extrn    count_in_err: near
  383.     extrn    count_out_err: near
  384.  
  385.     public    recv
  386. recv:
  387. ;called from the recv isr.  All registers have been saved, and ds=cs.
  388. ;Upon exit, the interrupt will be acknowledged.
  389.     assume    ds:code, es:arlan_segment
  390.     mov    es,base_addr
  391.  
  392. ;clear the interrupt request.
  393.  
  394.     mov    al,ar_control_i    ;drop the clear interrupt bit.
  395.     and    al,not CONTROL_CLRI
  396.     mov    ar_control,al
  397.     or    al,CONTROL_CLRI        ;raise the clear interrupt bit.
  398.     mov    ar_control,al
  399.  
  400.     cmp    ar_rx_status,0        ;was this our receive interrupt?
  401.     jne    recv_recv
  402.     cmp    ar_tx_status,0        ;was this our transmit interrupt?
  403.     jne    recv_xmit
  404.     jmp    recv_exit
  405. recv_xmit:
  406.     jmp    recv_exit
  407.  
  408. recv_recv:
  409.     mov    di,ar_rx_offset        ;get a pointer to the packet.
  410.     mov    cx,ar_rx_length        ;get the length.
  411.     dec    cx            ;omit the "was broadcast" flag.
  412.     inc    di            ;. .
  413.     add    cx,EADDR_LEN+EADDR_LEN    ;add the two headers in.
  414.     push    es
  415.     push    di
  416.     push    cx
  417.     mov    dl, BLUEBOOK        ;assume bluebook Ethernet.
  418.     call    recv_find
  419.     pop    cx
  420.     pop    si
  421.     pop    ds
  422.     assume    ds:arlan_segment, es:nothing
  423.  
  424.     mov    ax,es            ;is this pointer null?
  425.     or    ax,di
  426.     je    recv_free        ;yes - just free the frame.
  427.  
  428.     push    es
  429.     push    di
  430.     push    cx
  431.     sub    cx,EADDR_LEN+EADDR_LEN
  432.     mov    al,ds:[si-1]        ;get the "was broadcast" flag.
  433.     cmp    al,0            ;was it a broadcast?
  434.     je    recv_us            ;no.
  435.     mov    ax,0ffffh        ;yes, stuff an Ethernet broadcast in.
  436.     stosw
  437.     stosw
  438.     stosw
  439.     jmp    short recv_source
  440. recv_us:
  441.     mov    si,offset ar_node_id
  442.     movsw
  443.     movsw
  444.     movsw
  445. recv_source:
  446.     mov    si,offset ar_rx_src    ;move the source address over.
  447.     movsw
  448.     movsw
  449.     movsw
  450.     mov    si,ar_rx_offset        ;get a pointer to the packet.
  451.     inc    si
  452.     rep    movsb
  453.     pop    cx
  454.     pop    si
  455.     pop    ds
  456.     assume    ds:nothing
  457.  
  458.     call    recv_copy
  459.  
  460. recv_free:
  461.  
  462.     movseg    ds,cs
  463.     assume    ds:code
  464.     mov    es,base_addr
  465.     assume    es:arlan_segment
  466.  
  467. enable_receive:
  468.  
  469.     mov    ar_rx_status,0        ;clear the current status.
  470.     mov    ar_command,COM_RX_ENABLE+COM_INT
  471.     mov    ar_command+1,1        ;receive broadcasts.
  472.     call    doca
  473.  
  474.     cmp    ar_rx_status,0        ;is there another packet?
  475.     jne    recv_recv        ;yes, receive it now.
  476.  
  477. recv_exit:
  478.     ret
  479.  
  480.  
  481. doca:
  482. ;toggle the CA bit in the control register.
  483. ;must be executed with interrupts off to protect ar_control_i.
  484. ;return cy if we had a horrible failure.
  485.     assume    es:arlan_segment
  486.     pushf                ;make up a fake iret stack frame.
  487.     cli
  488.     mov    al,ar_control_i    ;toggle the bit in the image
  489.     xor    al,CONTROL_CA
  490.     mov    ar_control_i,al    ;and store them both.
  491.     mov    ar_control,al
  492.     popf
  493.  
  494.     mov    ax,5            ;wait about 1/7th of a second.
  495.     call    set_timeout
  496. doca_2:
  497.     cmp    ar_command,0        ;wait for the command to finish.
  498.     je    doca_1            ;it did.
  499.     call    do_timeout
  500.     jne    doca_2
  501.     stc
  502.     ret
  503. doca_1:
  504.     clc
  505.     ret
  506.  
  507.  
  508.     public    timer_isr
  509. timer_isr:
  510. ;if the first instruction is an iret, then the timer is not hooked
  511.     iret
  512.  
  513. ;any code after this will not be kept after initialization. Buffers
  514. ;used by the program, if any, are allocated from the memory between
  515. ;end_resident and end_free_mem.
  516.     public end_resident,end_free_mem
  517. end_resident    label    byte
  518. end_free_mem    label    byte
  519.  
  520.  
  521.     public    usage_msg
  522. usage_msg    db    "usage: ar450 [options] <packet_int_no>",CR,LF,'$'
  523.  
  524.     public    copyright_msg
  525. copyright_msg    db    "Packet driver for an ARLAN 450, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,CR,LF
  526.         db    "Portions Copyright 1990, Russell Nelson",CR,LF,'$'
  527.  
  528.     extrn    set_recv_isr: near
  529.  
  530. ;enter with si -> argument string, di -> wword to store.
  531. ;if there is no number, don't change the number.
  532.     extrn    get_number: near
  533.  
  534. ;enter with dx -> argument string, di -> wword to print.
  535.     extrn    print_number: near
  536.  
  537. ;-> the assigned Ethernet address of the card.
  538.     extrn    rom_address: byte
  539.  
  540.     public    parse_args
  541. parse_args:
  542. ;exit with nc if all went well, cy otherwise.
  543.     clc
  544.     ret
  545.  
  546.  
  547. signature    db    "TELESYSTEM"
  548. signature_len    equ    $-signature
  549.  
  550. no_board_msg    db    "Cannot locate an ARLAN board.",'$'
  551. self_test_msg    db    "ARLAN board self-tests bad.",'$'
  552. bad_mem_msg    db    "The on-card memory tests as bad.",'$'
  553. file_not_found    db    "File not found",'$'
  554. read_trouble    db    "Trouble reading the file",'$'
  555. timeout_msg_xx    db    "x"
  556. timeout_msg_x    db    "x"
  557. timeout_msg    db    "Timed out waiting for the board",'$'
  558. configure_bad    db    "The configure attempt failed",'$'
  559.  
  560. arlan_cfg    db    "arlan.cfg",0
  561. handle        dw    ?
  562.  
  563. int_no_name    db    "Interrupt number ",'$'
  564.  
  565.     public    etopen
  566. etopen:
  567.     assume    ds:code, es:arlan_segment
  568.  
  569. ;look for the arlan card in memory
  570.     mov    dx,0c000h
  571. etopen_1:
  572.     mov    si,offset signature
  573.     mov    es,dx
  574.     mov    di,offset ar_signature
  575.     mov    cx,signature_len
  576.     repe    cmpsb
  577.     je    etopen_2
  578.  
  579.     add    dx,200h
  580.     cmp    dx,0de00h
  581.     jb    etopen_1
  582.     mov    dx,offset no_board_msg
  583.     stc
  584.     ret
  585. etopen_2:
  586.     mov    base_addr,dx
  587.  
  588.     mov    ar_control,1        ;reset the board.
  589.  
  590.     mov    ax,base_addr        ;test the memory.
  591.     mov    cx,2000h-3
  592.     call    memory_test
  593.     je    memory_ok
  594.     mov    dx,offset bad_mem_msg
  595.     stc
  596.     ret
  597. memory_ok:
  598.  
  599.     xor    di,di            ;zero all the memory.
  600.     mov    cx,2000h-1
  601.     xor    al,al
  602.     rep    stosb
  603.  
  604.     mov    ar_reset,1        ;set the reset flag.
  605.     mov    ar_control,0        ;remove the reset.
  606.  
  607.     mov    ax,36
  608.     call    set_timeout
  609. wait_for_reset:
  610.     cmp    ar_reset,0        ;did it finish resetting yet?
  611.     je    wait_for_reset_1    ;yes, exit.
  612.     call    do_timeout
  613.     jne    wait_for_reset
  614.     mov    dx,offset timeout_msg
  615.     stc
  616.     ret
  617. wait_for_reset_1:
  618.  
  619. ;set the reset flag again, so that we can detect if we somehow got reset.
  620.  
  621.     mov    ar_reset,1
  622.  
  623.     cmp    ar_diagnostics,0ffh    ;Did it self-check okay?
  624.     je    self_test_ok
  625.     mov    dx,offset self_test_msg
  626.     stc
  627.     ret
  628. self_test_ok:
  629.  
  630.     mov    ar_command,COM_NOP    ;do a NOP.
  631.     call    doca
  632.     jnc    wait_for_first_nop_1
  633.     mov    dx,offset self_test_msg
  634.     stc
  635.     ret
  636. wait_for_first_nop_1:
  637.  
  638. ;;; They say to do another with with COM_INT set...
  639.  
  640.     mov    al,ar_irq_level        ;copy the interrupt number out of
  641.     mov    int_no,al        ;  the configuration file.
  642.  
  643.     mov    ax,3d00h        ;open for reading.
  644.     mov    dx,offset arlan_cfg
  645.     int    21h
  646.     jnc    file_found
  647.     mov    dx,offset file_not_found
  648.     stc
  649.     ret
  650.  
  651. file_found:
  652.     mov    handle,ax
  653.  
  654.     mov    ax,4200h
  655.     mov    bx,handle
  656.     xor    cx,cx
  657.     mov    dx,100h            ;skip past the first 100h bytes.
  658.     int    21h
  659.  
  660.     mov    ah,3fh            ;read the system parameters.
  661.     mov    bx,handle
  662.     mov    cx,100h
  663.     mov    dx,offset ar_sys_params
  664.     push    ds
  665.     mov    ds,base_addr
  666.     int    21h
  667.     pop    ds
  668.     jnc    no_trouble
  669.     mov    dx,offset read_trouble
  670.     stc
  671.     ret
  672.  
  673. no_trouble:
  674.  
  675.     mov    ah,3eh            ;close the file.
  676.     mov    bx,handle
  677.     int    21h
  678.  
  679.     cmp    int_no,0        ;Does the board know its interrupt
  680.     jne    set_int_no        ;  number?  go if it does.
  681.     mov    al,ar_irq_level        ;No, so use the one
  682.     mov    int_no,al        ;  in the configuration file.
  683. set_int_no:
  684.  
  685. ; do the configure.
  686.  
  687.     mov    ar_command,COM_CONF
  688.     call    doca
  689.     jnc    wait_for_configure_1    ;it did.
  690.     mov    dx,offset timeout_msg_x
  691.     stc
  692.     ret
  693. wait_for_configure_1:
  694.  
  695.     cmp    ar_diagnostics,0ffh    ;did the configure succeed?
  696.     je    configure_ok
  697.     mov    dx,offset configure_bad
  698.     stc
  699.     ret
  700. configure_ok:
  701.  
  702. ;wait a short while for the AR450.  For the AR440, wait up to 15 seconds.
  703.  
  704.     mov    ax,36
  705.     call    set_timeout
  706. wait_for_address:
  707.     mov    cx,EADDR_LEN        ;see if our address is still zeroes.
  708.     mov    si,offset ar_node_id
  709.     xor    al,al
  710. wait_for_address_2:
  711.     or    al,es:[si]
  712.     inc    si
  713.     loop    wait_for_address_2
  714.     or    al,al            ;do we have an address yet?
  715.     jne    wait_for_address_1    ;yes.
  716.     call    do_timeout
  717.     jne    wait_for_address
  718.     mov    dx,offset timeout_msg_xx
  719.     stc
  720.     ret
  721. wait_for_address_1:
  722.  
  723. ;say that the max we'll send is an Ethernet GIANT packet, less the two
  724. ;  Ethernet addresses that we don't include in the datagram, plus the one
  725. ;  broadcast byte that we *do* include.
  726.  
  727.     mov    ax,GIANT - EADDR_LEN*2 + 1
  728.     mov    ax,1023
  729.     mov    ar_MDS,ax
  730.     mov    ar_MFS,ax
  731.  
  732. ; reduce the number of retries
  733.  
  734.     mov    ar_max_retry,16
  735.  
  736. ;enable reception
  737.  
  738.     call    enable_receive
  739.  
  740. ;mark transmission as done
  741.  
  742.     mov    ar_tx_status,1
  743.  
  744. ;enable our interrupts.
  745.  
  746.     mov    al,ar_control_i
  747.     or    al,CONTROL_IE or CONTROL_CLRI
  748.     mov    ar_control_i,al
  749.     mov    ar_control,al
  750.  
  751.  
  752. ;get our address
  753.  
  754.     movseg    es,cs
  755.     mov    di,offset rom_address
  756.     mov    cx,EADDR_LEN        ; Move one ethernet address from our copy
  757.     mov    si,offset ar_node_id    ; Copy from the board.
  758.     push    ds
  759.     mov    ds,base_addr
  760.     rep     movsb
  761.     pop    ds
  762.  
  763. ; Now hook in our interrupt
  764.  
  765.     call    set_recv_isr
  766.  
  767.     sti
  768.  
  769.     mov    al, int_no        ; Get board's interrupt vector
  770.     add    al, 8
  771.     cmp    al, 8+8            ; Is it a slave 8259 interrupt?
  772.     jb    set_int_num        ; No.
  773.     add    al, 70h - 8 - 8        ; Map it to the real interrupt.
  774. set_int_num:
  775.     xor    ah, ah            ; Clear high byte
  776.     mov    int_num, ax        ; Set parameter_list int num.
  777.  
  778.     clc
  779.     ret
  780.  
  781.  
  782.     public    print_parameters
  783. print_parameters:
  784. ;echo our command-line parameters
  785.     mov    dx,offset int_no_name
  786.     mov    di,offset int_no
  787.     call    print_number
  788.  
  789.     ret
  790.  
  791.     include    memtest.asm
  792.  
  793. code    ends
  794.  
  795.     end
  796.