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: Devices header file
20 #ifndef angel_devices_h
21 #define angel_devices_h
24 * Provides common types for using devices, and provides access to the
31 /* General purpose constants, macros, enums, typedefs */
33 /* a non-enum holder for device IDs */
34 typedef unsigned int DeviceID;
36 /* device error codes */
37 typedef enum DevError {
38 DE_OKAY, /* no error */
39 DE_NO_DEV, /* no such device */
40 DE_BAD_DEV, /* device does not support angel */
41 DE_BAD_CHAN, /* no such device channel */
42 DE_BAD_OP, /* operation not supported by this device */
43 DE_BUSY, /* device already busy */
44 DE_INVAL, /* length invalid */
45 DE_FAILED /* something else went wrong */
48 /* return codes from asynchronous calls - primarily for channels' benefit */
49 typedef enum DevStatus {
50 DS_DONE, /* operation succeeded */
51 DS_OVERFLOW, /* not enough buffer space */
52 DS_BAD_PACKET, /* packet failed */
53 DS_DEV_ERROR, /* device error */
54 DS_INT_ERROR /* internal error */
57 /* Callback for async. writes */
58 typedef void (*DevWrite_CB_Fn)(
59 void *buff, /* pointer to data -- cast to p_Buffer */
60 void *length, /* how much done -- cast to unsigned */
61 void *status, /* success code -- cast to DevStatus */
62 void *cb_data /* as supplied */
65 /* Callback for async. reads */
66 typedef void (*DevRead_CB_Fn)(
67 void *buff, /* pointer to data -- cast to p_Buffer */
68 void *length, /* how much read -- cast to unsigned */
69 void *status, /* success code -- cast to DevStatus */
70 void *cb_data /* as supplied */
73 /* control operations */
74 typedef enum DeviceControl {
75 DC_INIT, /* initialise device */
76 DC_RESET, /* reset device */
77 DC_RECEIVE_MODE, /* control reception */
78 DC_SET_PARAMS, /* set parameters of device */
80 DC_GET_USER_PARAMS, /* params set by user at open */
81 DC_GET_DEFAULT_PARAMS, /* device default parameters */
82 DC_RESYNC, /* resynchronise with new agent */
84 DC_PRIVATE /* start of private device codes */
87 typedef enum DevRecvMode {
93 * callback to allow a device driver to request a buffer, to be filled
94 * with an incoming packet
96 typedef p_Buffer (*DevGetBuff_Fn)(unsigned req_size, void *cb_data);
99 /* Publically-accessible globals */
102 #endif /* ndef angel_devices_h */