00001 #ifndef _SYS_DEVICE_H_
00002 #define _SYS_DEVICE_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #include <sys/file.h>
00093
00099 __BEGIN_DECLS
00100
00101
00102
00103
00104 #ifndef __EMULATION__
00105 #define WAIT5 5
00106 #define WAIT50 50
00107 #define WAIT100 100
00108 #define WAIT250 250
00109 #define WAIT500 500
00110 #else
00111 #define WAIT5 1
00112 #define WAIT50 5
00113 #define WAIT100 10
00114 #define WAIT250 25
00115 #define WAIT500 50
00116 #endif
00117
00122
00123 #define IFTYP_RAM 0
00124 #define IFTYP_ROM 1
00125 #define IFTYP_STREAM 2
00126 #define IFTYP_NET 3
00127 #define IFTYP_TCPSOCK 4
00128 #define IFTYP_CHAR 5
00129 #define IFTYP_CAN 6
00130 #define IFTYP_FS 16
00135 typedef struct _NUTDEVICE NUTDEVICE;
00136
00151 struct _NUTDEVICE {
00152
00156 NUTDEVICE *dev_next;
00157
00161 char dev_name[9];
00162
00174 u_char dev_type;
00175
00182 uptr_t dev_base;
00183
00189 u_char dev_irq;
00190
00196 void *dev_icb;
00197
00203 void *dev_dcb;
00204
00210 int (*dev_init) (NUTDEVICE *);
00211
00217 int (*dev_ioctl) (NUTDEVICE *, int, void *);
00218
00222 int (*dev_read) (NUTFILE *, void *, int);
00223
00227 int (*dev_write) (NUTFILE *, CONST void *, int);
00228
00232 #ifdef __HARVARD_ARCH__
00233 int (*dev_write_P) (NUTFILE *, PGM_P, int);
00234 #endif
00235
00239 NUTFILE * (*dev_open) (NUTDEVICE *, CONST char *, int, int);
00240
00244 int (*dev_close) (NUTFILE *);
00245
00249 long (*dev_size) (NUTFILE *);
00250
00251 };
00252
00256 typedef struct _NUTVIRTUALDEVICE NUTVIRTUALDEVICE;
00257
00261 struct _NUTVIRTUALDEVICE {
00262 NUTVIRTUALDEVICE *vdv_next;
00263 NUTVIRTUALDEVICE *vdv_zero;
00264 u_char vdv_type;
00265 int (*vdv_read) (void *, void *, int);
00266 int (*vdv_write) (void *, CONST void *, int);
00267 #ifdef __HARVARD_ARCH__
00268 int (*vdv_write_P) (void *, PGM_P, int);
00269 #endif
00270 int (*vdv_ioctl) (void *, int, void *);
00271 };
00272
00276 typedef struct _IFSTREAM IFSTREAM;
00277
00284 struct _IFSTREAM {
00285 int (*if_input)(NUTDEVICE *);
00286 int (*if_output)(NUTDEVICE *);
00287 int (*if_flush)(NUTDEVICE *);
00288 volatile u_char if_rx_idx;
00289 u_char if_rd_idx;
00290 volatile u_char if_tx_idx;
00291 u_char if_wr_idx;
00292 volatile u_char if_tx_act;
00293 u_char if_last_eol;
00294 u_char if_rx_buf[256];
00295 u_char if_tx_buf[256];
00296 };
00297
00301 extern NUTDEVICE *nutDeviceList;
00302
00303 extern int NutRegisterDevice(NUTDEVICE * dev, uptr_t base, u_char irq);
00304 extern NUTDEVICE *NutDeviceLookup(CONST char *name);
00305
00306 __END_DECLS
00307
00308 #endif