Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* |
2 | * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved. | |
3 | * | |
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 | |
6 | * software. | |
7 | */ | |
8 | ||
9 | /* -*-C-*- | |
10 | * | |
11 | * $Revision$ | |
12 | * $Date$ | |
13 | * | |
14 | * | |
15 | * Project: ANGEL | |
16 | * | |
17 | * Title: Devices header file | |
18 | */ | |
19 | ||
20 | #ifndef angel_devices_h | |
21 | #define angel_devices_h | |
22 | ||
23 | /* | |
24 | * Provides common types for using devices, and provides access to the | |
25 | * device table. | |
26 | */ | |
27 | ||
28 | #include "angel.h" | |
29 | #include "buffers.h" | |
30 | ||
31 | /* General purpose constants, macros, enums, typedefs */ | |
32 | ||
33 | /* a non-enum holder for device IDs */ | |
34 | typedef unsigned int DeviceID; | |
35 | ||
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 */ | |
46 | } DevError; | |
47 | ||
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 */ | |
55 | } DevStatus; | |
56 | ||
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 */ | |
63 | ); | |
64 | ||
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 */ | |
71 | ); | |
72 | ||
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 */ | |
79 | #ifndef TARGET | |
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 */ | |
83 | #endif | |
84 | DC_PRIVATE /* start of private device codes */ | |
85 | } DeviceControl; | |
86 | ||
87 | typedef enum DevRecvMode { | |
88 | DR_DISABLE, | |
89 | DR_ENABLE | |
90 | } DevRecvMode; | |
91 | ||
92 | /* | |
93 | * callback to allow a device driver to request a buffer, to be filled | |
94 | * with an incoming packet | |
95 | */ | |
96 | typedef p_Buffer (*DevGetBuff_Fn)(unsigned req_size, void *cb_data); | |
97 | ||
98 | ||
99 | /* Publically-accessible globals */ | |
100 | /* none */ | |
101 | ||
102 | #endif /* ndef angel_devices_h */ | |
103 | ||
104 | /* EOF devices.h */ |