2 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
4 * This software may be freely used, copied, modified, and distributed
5 * provided that the above copyright notice is preserved in all copies of the
17 * Title: Definitions for device driver interface.
19 #ifndef angsd_drivers_h
20 #define angsd_drivers_h
25 typedef struct DeviceDescr DeviceDescr
;
26 typedef struct DriverCall DriverCall
;
30 * used to pass packets across the driver interface
34 struct data_packet dc_packet
;
39 * used to describe a device driver
44 int (*DeviceOpen
)(const char *name
, const char *arg
);
45 int (*DeviceMatch
)(const char *name
, const char *arg
);
46 void (*DeviceClose
)(void);
47 int (*DeviceRead
)(DriverCall
*dc
, bool block
);
48 int (*DeviceWrite
)(DriverCall
*dc
);
49 int (*DeviceIoctl
)(const int opcode
, void *args
);
50 void *SwitcherState
; /* used by switcher interface */
54 * Function: DeviceOpen
56 * Purpose: Open a communications device
58 * Pre-conditions: No previous open is still active
61 * Input: name Identifies which device to open. This can either be
62 * a host specific identifier (e.g. "/dev/ttya",
63 * "COM1:"), or a number which is used to refer to
64 * `standard' interfaces, so "1" would be the first host
65 * interface, "2" the second, and so on.
67 * arg Driver specific arguments. For example, some serial
68 * drivers accept speed and control arguments such as
69 * "9600" or "19200/NO_BREAK". These arguments are
70 * completely free-form: it is the individual drivers
71 * which do the necessary interpretation.
77 extern int DeviceOpen(const char *name
, const char *arg
);
80 * Function: DeviceMatch
82 * Purpose: Check whether parameters are OK to be passed to DeviceOpen
85 * Input: name Identifies which device to open. This can either be
86 * a host specific identifier (e.g. "/dev/ttya",
87 * "COM1:"), or a number which is used to refer to
88 * `standard' interfaces, so "1" would be the first host
89 * interface, "2" the second, and so on.
91 * arg Driver specific arguments. For example, some serial
92 * drivers accept speed and control arguments such as
93 * "9600" or "19200/NO_BREAK". These arguments are
94 * completely free-form: it is the individual drivers
95 * which do the necessary interpretation.
101 extern int DeviceMatch(const char *name
, const char *arg
);
104 * Function: DeviceClose
106 * Purpose: Close a communications device
108 * Pre-conditions: Device must have been previously opened
114 extern void DeviceClose(void);
117 * Function: DeviceRead
119 * Purpose: Try to read a complete packet from a communications device.
120 * This read must usually be non-blocking, i.e. it should read as
121 * many data from the device as needed to complete the packet,
122 * but it should not wait if the packet is not complete, and no
123 * more data are currently available from the device.
124 * As an optimisation the read can optionally block when 'block'
125 * is TRUE, but only for a short time. It is acceptable for the
126 * 'block' parameter to be ignored in which case all reads
127 * should be non-blocking.
129 * Pre-conditions: Device has been opened via DeviceOpen()
132 * In/Out: dc Describes the packet being read (dc->dc_packet);
133 * dc->dc_context is for the driver to store private
134 * context, and is guaranteed to be NULL the first
135 * time DeviceRead is called for a given packet.
137 * In: block If TRUE, read may safely block for a short period
138 * of time (say up to 20ms), to avoid high CPU load
139 * whilst waiting for a reply.
140 * If FALSE, read MUST NOT block.
143 * OK: 1 (packet is complete)
144 * 0 (packet is not yet complete)
145 * Error: -1 bad packet
147 * Post-conditions: should a calamatous error occur panic() will be called
149 extern int DeviceRead(DriverCall
*dc
, bool block
);
152 * Function: DeviceWrite
154 * Purpose: Try to write a packet to a communications device. This write
155 * must be non-blocking, i.e. it should write as many data to
156 * the device as is immediately possible, but should not wait
157 * for space to send any more after that.
159 * Pre-conditions: Device has been opened via DeviceOpen()
162 * In/Out: dc Describes the packet being written (dc->dc_packet);
163 * dc->dc_context is for the driver to store private
164 * context, and is guaranteed to be NULL the first
165 * time DeviceWrite is called for a given packet.
168 * OK: 1 (all of the packet has been written)
169 * 0 (some of the packet remains to be written)
172 extern int DeviceWrite(DriverCall
*dc
);
175 * Function: DeviceIoctl
177 * Purpose: Perform miscellaneous driver operations
179 * Pre-conditions: Device has been open via DeviceOpen()
182 * Input: opcode Reason code indicating the operation to perform
183 * In/Out: args Pointer to opcode-sensitive arguments/result space
189 extern int DeviceIoctl(const int opcode
, void *args
);
191 #endif /* !defined(angsd_drivers_h) */
This page took 0.033226 seconds and 4 git commands to generate.