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

  1. version    equ    0
  2.  
  3. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  4.  
  5. ;   This program is free software; you can redistribute it and/or modify
  6. ;   it under the terms of the GNU General Public License as published by
  7. ;   the Free Software Foundation, version 1.
  8. ;
  9. ;   This program is distributed in the hope that it will be useful,
  10. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ;   GNU General Public License for more details.
  13. ;
  14. ;   You should have received a copy of the GNU General Public License
  15. ;   along with this program; if not, write to the Free Software
  16. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.     include    defs.asm
  19.  
  20. code    segment    word public
  21.     assume    cs:code, ds:code
  22.  
  23.     public    int_no
  24. int_no    db    0,0,0,0            ;must be four bytes long for get_number.
  25.  
  26.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  27. driver_class    db    BLUEBOOK,0    ;null terminated list of classes.
  28. driver_type    db    0        ;assigned by FTP Software, <jbvb@ftp.com>
  29. driver_name    db    'skeleton',0    ;name of the driver.
  30. driver_function    db    2
  31. parameter_list    label    byte
  32.     db    1    ;major rev of packet driver specification
  33.     db    9    ;minor rev of packet driver specification
  34.     db    14    ;length of parameter list
  35.     db    EADDR_LEN    ;length of MAC-layer address
  36.     dw    GIANT    ;MTU, including MAC headers
  37.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  38.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  39.     dw    0    ;(# of successive xmits) - 1
  40. int_num    dw    0    ;Interrupt # to hook for post-EOI
  41.             ;processing, 0 == none,
  42.  
  43.     public    rcv_modes
  44. rcv_modes    dw    4        ;number of receive modes in our table.
  45.         dw    0        ;there is no mode zero.
  46.         dw    0,0,rcv_mode_3
  47.  
  48.     public bad_command_intercept
  49. bad_command_intercept:
  50. ;called with ah=command, unknown to the skeleton.
  51. ;exit with nc if okay, cy, dh=error if not.
  52.     mov    dh,BAD_COMMAND
  53.     stc
  54.     ret
  55.  
  56.     public    as_send_pkt
  57. ; The Asynchronous Transmit Packet routine.
  58. ; Enter with es:di -> i/o control block, ds:si -> packet, cx = packet length,
  59. ;   interrupts possibly enabled.
  60. ; Exit with nc if ok, or else cy if error, dh set to error number.
  61. ;   es:di and interrupt enable flag preserved on exit.
  62. as_send_pkt:
  63.     ret
  64.  
  65.     public    drop_pkt
  66. ; Drop a packet from the queue.
  67. ; Enter with es:di -> iocb.
  68. drop_pkt:
  69.     assume    ds:nothing
  70.     ret
  71.  
  72.     public    xmit
  73. ; Process a transmit interrupt with the least possible latency to achieve
  74. ;   back-to-back packet transmissions.
  75. ; May only use ax and dx.
  76. xmit:
  77.     assume    ds:nothing
  78.     ret
  79.  
  80.  
  81.     public    send_pkt
  82. send_pkt:
  83. ;enter with es:di->upcall routine, (0:0) if no upcall is desired.
  84. ;  (only if the high-performance bit is set in driver_function)
  85. ;enter with ds:si -> packet, cx = packet length.
  86. ;if we're a high-performance driver, es:di -> upcall.
  87. ;exit with nc if ok, or else cy if error, dh set to error number.
  88.     assume    ds:nothing
  89.     mov    dh,CANT_SEND
  90.     stc
  91.     ret
  92.  
  93.  
  94.     public    set_address
  95. set_address:
  96. ;enter with ds:si -> Ethernet address, CX = length of address.
  97. ;exit with nc if okay, or cy, dh=error if any errors.
  98.     assume    ds:nothing
  99.     mov    dh,CANT_SET
  100.     stc
  101.     ret
  102.  
  103.  
  104. rcv_mode_3:
  105. ;receive mode 3 is the only one we support, so we don't have to do anything.
  106.     ret
  107.  
  108.  
  109.     public    set_multicast_list
  110. set_multicast_list:
  111. ;enter with ds:si ->list of multicast addresses, ax = number of addresses,
  112. ;  cx = number of bytes.
  113. ;return nc if we set all of them, or cy,dh=error if we didn't.
  114.     mov    dh,NO_MULTICAST
  115.     stc
  116.     ret
  117.  
  118.  
  119.     public    terminate
  120. terminate:
  121.     ret
  122.  
  123.  
  124.     public    reset_interface
  125. reset_interface:
  126. ;reset the interface.
  127.     assume    ds:code
  128.     ret
  129.  
  130.  
  131. ;called when we want to determine what to do with a received packet.
  132. ;enter with cx = packet length, es:di -> packet type, dl = packet class.
  133.     extrn    recv_find: near
  134.  
  135. ;called after we have copied the packet into the buffer.
  136. ;enter with ds:si ->the packet, cx = length of the packet.
  137.     extrn    recv_copy: near
  138.  
  139. ;call this routine to schedule a subroutine that gets run after the
  140. ;recv_isr.  This is done by stuffing routine's address in place
  141. ;of the recv_isr iret's address.  This routine should push the flags when it
  142. ;is entered, and should jump to recv_exiting_exit to leave.
  143. ;enter with ax = address of routine to run.
  144.     extrn    schedule_exiting: near
  145.  
  146. ;recv_exiting jumps here to exit, after pushing the flags.
  147.     extrn    recv_exiting_exit: near
  148.  
  149.     extrn    count_in_err: near
  150.     extrn    count_out_err: near
  151.  
  152.     public    recv
  153. recv:
  154. ;called from the recv isr.  All registers have been saved, ds=cs,
  155. ;our interrupt has been acknowledged, and our interrupts have been
  156. ;masked at the interrupt controller.
  157.     assume    ds:code
  158.     ret
  159.  
  160.  
  161.     public    timer_isr
  162. timer_isr:
  163. ;if the first instruction is an iret, then the timer is not hooked
  164.     iret
  165.  
  166. ;any code after this will not be kept.  Buffers used by the program, if any,
  167. ;are allocated from the memory between end_resident and end_free_mem.
  168.     public end_resident,end_free_mem
  169. end_resident    label    byte
  170. end_free_mem    label    byte
  171.  
  172.  
  173.     public    usage_msg
  174. usage_msg    db    "usage: skeleton [options] <packet_int_no>",CR,LF,'$'
  175.  
  176.     public    copyright_msg
  177. copyright_msg    db    "Packet driver for a <foo> device, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,CR,LF
  178.         db    "Portions Copyright 19xx, <your name here>",CR,LF,'$'
  179.  
  180. ;called when you're ready to receive interrupts.
  181.     extrn    set_recv_isr: near
  182.  
  183. ;enter with si -> argument string, di -> dword to store.
  184. ;if there is no number, don't change the number.
  185.     extrn    get_number: near
  186.  
  187. ;enter with dx -> argument string, di -> dword to print.
  188.     extrn    print_number: near
  189.  
  190. ;-> the unique Ethernet address of the card.  Filled in by the etopen routine.
  191.     extrn    rom_address: byte
  192.  
  193. ;-> current address.  Normally the same as rom_address, unless changed
  194. ;by the set_address() call.
  195.     extrn    my_address: byte
  196.  
  197. ;parse_args is called with si -> first parameter (CR if none).
  198.     public    parse_args
  199. parse_args:
  200. ;exit with nc if all went well, cy otherwise.
  201.     clc
  202.     ret
  203.  
  204.  
  205.     public    etopen
  206. etopen:
  207. ;initialize the driver.  Fill in rom_address with the assigned address of
  208. ;the board.  Exit with nc if all went well, or cy, dx -> $ terminated error msg.
  209. ;if all is okay,
  210.     clc
  211.     ret
  212. ;if we got an error,
  213.     stc
  214.     ret
  215.  
  216.     public    print_parameters
  217. print_parameters:
  218. ;echo our command-line parameters
  219.     ret
  220.  
  221. code    ends
  222.  
  223.     end
  224.