1pktdrive(3z)               z88dk Programmer's Manual              pktdrive(3z)
2
3
4

NAME

6       pktdrive - packet driver descriptor structure
7

SYNOPSIS

9       #include <net/device.h>
10

DESCRIPTION

12       The  pktdrive  structure defines access to a device, it is only used by
13       the ZSock kernel. Should you wish to write a packet  driver  then  this
14       structure should be filled with the relevent routines.
15
16       All  external packet drivers run at address 8192 ($2000) and it as this
17       address that the structure should be placed. Had z88dk  the  capability
18       pktdrive would be defined as follows:
19
20              struct pktdrive {
21                      char    magic[10];
22                      char    *type;
23                      char    *copymsg;
24                      void    (*initfunc)(void);
25                      void    (*queuefn)(void *pkt, size_t len);
26                      void    *(*packetfn)(void);
27                      void    *(*sendfn)(void);
28                      int     (*readfn)(void);
29                      void    (*onlinefn)();
30                      void    (*offlinefn)(int);
31                      int     (*statusfn)(void);
32              };
33
34       The members of the pktdrive structure are:
35
36       magic  Magic to identifier the file as a packet driver, this is defined
37              as ZS0PKTDRV
38
39       type   A pointer to the type of the device
40
41       copymsg
42              A pointer to the copyright message
43
44       initfunc
45              A function that initialises the device during the  initial  con‐
46              figurationin this function.
47
48       queuefn
49              A function that stores outgoing backets in a queue pending send‐
50              ing.  Depending on the speed of the device it  may  also  inject
51              packets into the interface.
52
53       packetfn
54              A function that returns the address of the incoming packet. This
55              function is called immediately after  initialisation  and  after
56              the readfn function (below) has returned a packet.
57
58       sendfn A  function  that is called on the interrupt to inject bytes out
59              of the interface. If this function returns non-zero then  packet
60              at the address returned is freed.
61
62       readfn A  function  that  is  called  on the interrupt to read incoming
63              bytes.  If the  function  returns  non-zero  then  a  packet  is
64              assumed to have been read, with length as returned by readfn and
65              lying at the address specified by packetfn.
66
67       onlinefn
68              A function that is called when the device is to be turned online
69
70       offlinefn
71              A function that is called when the device is to be  turned  off‐
72              line, if the parameter is non-zero then the function should hang
73              up line (if appropriate) otherwise it should just suspend  send‐
74              ing and receiving packets.
75
76       statusfn
77              A  function  that returns the status of the device. It is envis‐
78              aged that it will return 0 for offline and 1 for  online  though
79              it  may  return other values. The value returned is left for the
80              user to understand.
81
82

NOTES

84       When the packet is passed to the driver for output a 4 bytes of  header
85       space  is available at dp-4. The SLIP driver by Dominic Morris utilises
86       these bytes to implement a linked list and to hold the  length  of  the
87       outgoing packet.
88
89       Other packet drivers might wish to copy the packet to their own address
90       space for converting into other forms - eg  CSLIP  form.  Alternatively
91       they  might  simply create a link from their own space to the packet in
92       the queue so to reduce time wasted copying bytes.
93
94

AUTHOR

96       Dominic Morris <dom@jb.man.ac.uk>
97
98
99
100                               18 February 2000                   pktdrive(3z)
Impressum