summaryrefslogtreecommitdiff
path: root/gdb/rdi-share/devices.h
blob: eac6ee20fd7a284a2ffdfda17ba56624d3b92caa (plain)
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$
 *     $Date$
 *
 *
 *   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 */