File: devices.h

package info (click to toggle)
insight 6.1%2Bcvs.2004.08.11-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 150,436 kB
  • ctags: 171,195
  • sloc: ansic: 1,431,500; exp: 89,955; tcl: 56,199; asm: 47,136; makefile: 42,498; sh: 27,919; yacc: 8,337; cpp: 5,534; perl: 5,281; lisp: 2,204; lex: 895; pascal: 663; awk: 443; sed: 339; objc: 134; ada: 15; java: 14; fortran: 5
file content (104 lines) | stat: -rw-r--r-- 3,086 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* 
 * Copyright (C) 1995 Advanced RISC Machines Limited. All rights reserved.
 * 
 * This software may be freely used, copied, modified, and distributed
 * provided that the above copyright notice is preserved in all copies of the
 * software.
 */

/* -*-C-*-
 *
 * $Revision: 1.2 $
 *     $Date: 1998/01/08 11:11:56 $
 *
 *
 *   Project: ANGEL
 *
 *     Title: Devices header file
 */

#ifndef angel_devices_h
#define angel_devices_h

/*
 * Provides common types for using devices, and provides access to the
 * device table.
 */

#include "angel.h"
#include "buffers.h"

/* General purpose constants, macros, enums, typedefs */

/* a non-enum holder for device IDs */
typedef unsigned int DeviceID;

/* device error codes */
typedef enum DevError {
  DE_OKAY,     /* no error */
  DE_NO_DEV,   /* no such device */
  DE_BAD_DEV,  /* device does not support angel */
  DE_BAD_CHAN, /* no such device channel */
  DE_BAD_OP,   /* operation not supported by this device */
  DE_BUSY,     /* device already busy */
  DE_INVAL,    /* length invalid */
  DE_FAILED    /* something else went wrong */
} DevError;

/* return codes from asynchronous calls - primarily for channels' benefit */
typedef enum DevStatus {
  DS_DONE,                      /* operation succeeded */
  DS_OVERFLOW,                  /* not enough buffer space */
  DS_BAD_PACKET,                /* packet failed */
  DS_DEV_ERROR,                 /* device error */
  DS_INT_ERROR                  /* internal error */
} DevStatus;

/* Callback for async. writes */
typedef void (*DevWrite_CB_Fn)(
    void *buff,     /* pointer to data -- cast to p_Buffer  */
    void *length,   /* how much done   -- cast to unsigned  */
    void *status,   /* success code    -- cast to DevStatus */
    void *cb_data   /* as supplied */
    );

/* Callback for async. reads */
typedef void (*DevRead_CB_Fn)(
    void *buff,     /* pointer to data -- cast to p_Buffer  */
    void *length,   /* how much read   -- cast to unsigned  */
    void *status,   /* success code    -- cast to DevStatus */
    void *cb_data   /* as supplied */
    );

/* control operations */
typedef enum DeviceControl {
  DC_INIT,                      /* initialise device             */
  DC_RESET,                     /* reset device                  */
  DC_RECEIVE_MODE,              /* control reception             */
  DC_SET_PARAMS,                /* set parameters of device      */
#ifndef TARGET
  DC_GET_USER_PARAMS,           /* params set by user at open    */
  DC_GET_DEFAULT_PARAMS,        /* device default parameters     */
  DC_RESYNC,                    /* resynchronise with new agent  */
#endif
  DC_PRIVATE                    /* start of private device codes */
} DeviceControl;

typedef enum DevRecvMode {
  DR_DISABLE,
  DR_ENABLE
} DevRecvMode;

/*
 * callback to allow a device driver to request a buffer, to be filled
 * with an incoming packet
 */
typedef p_Buffer (*DevGetBuff_Fn)(unsigned req_size, void *cb_data);


/* Publically-accessible globals */
/* none */

#endif /* ndef angel_devices_h */

/* EOF devices.h */