OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [io/] [common/] [v2_0/] [include/] [devtab.h] - Blame information for rev 223

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_IO_DEVTAB_H
2
#define CYGONCE_IO_DEVTAB_H
3
// ====================================================================
4
//
5
//      devtab.h
6
//
7
//      Device I/O Table
8
//
9
// ====================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
// ====================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   gthomas
46
// Contributors:        gthomas
47
// Date:        1999-02-04
48
// Purpose:     Describe low level I/O interfaces.
49
// Description:
50
//
51
//####DESCRIPTIONEND####
52
//
53
// ====================================================================
54
 
55
// Private include file.  This file should only be used by device 
56
// drivers, not application code.
57
 
58
#include <pkgconf/system.h>
59
#include <cyg/io/io.h>
60
#include <cyg/hal/drv_api.h>
61
#include <cyg/hal/hal_tables.h>
62
 
63
// Set of functions which handle top level I/O functions
64
typedef struct {
65
    Cyg_ErrNo (*write)(cyg_io_handle_t handle,
66
                       const void *buf,
67
                       cyg_uint32 *len);
68
    Cyg_ErrNo (*read)(cyg_io_handle_t handle,
69
                      void *buf,
70
                      cyg_uint32 *len);
71
    Cyg_ErrNo (*bwrite)(cyg_io_handle_t handle,
72
                       const void *buf,
73
                       cyg_uint32 *len,
74
                       cyg_uint32 pos);
75
    Cyg_ErrNo (*bread)(cyg_io_handle_t handle,
76
                      void *buf,
77
                      cyg_uint32 *len,
78
                      cyg_uint32 pos);
79
    cyg_bool  (*select)(cyg_io_handle_t handle,
80
                        cyg_uint32 which,
81
                        CYG_ADDRWORD info);
82
    Cyg_ErrNo (*get_config)(cyg_io_handle_t handle,
83
                            cyg_uint32 key,
84
                            void *buf,
85
                            cyg_uint32 *len);
86
    Cyg_ErrNo (*set_config)(cyg_io_handle_t handle,
87
                            cyg_uint32 key,
88
                            const void *buf,
89
                            cyg_uint32 *len);
90
} cyg_devio_table_t;
91
 
92
 
93
// Default functions
94
 
95
__externC Cyg_ErrNo cyg_devio_cwrite(cyg_io_handle_t handle,
96
                                     const void *buf, cyg_uint32 *len);
97
__externC Cyg_ErrNo cyg_devio_cread(cyg_io_handle_t handle,
98
                                    void *buf, cyg_uint32 *len);
99
__externC Cyg_ErrNo cyg_devio_bwrite(cyg_io_handle_t handle,
100
                                     const void *buf, cyg_uint32 *len,
101
                                     cyg_uint32 pos);
102
__externC Cyg_ErrNo cyg_devio_bread(cyg_io_handle_t handle,
103
                                    void *buf, cyg_uint32 *len,
104
                                    cyg_uint32 pos);
105
 
106
__externC Cyg_ErrNo cyg_devio_select(cyg_io_handle_t handle,
107
                                     cyg_uint32 which,
108
                                     CYG_ADDRWORD info);
109
 
110
__externC Cyg_ErrNo cyg_devio_get_config(cyg_io_handle_t handle,
111
                                         cyg_uint32 key,
112
                                         void* buf,
113
                                         cyg_uint32* len);
114
 
115
__externC Cyg_ErrNo cyg_devio_set_config(cyg_io_handle_t handle,
116
                                         cyg_uint32 key,
117
                                         void* buf,
118
                                         cyg_uint32* len);
119
 
120
// Initialization macros
121
 
122
#define CHAR_DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config)    \
123
cyg_devio_table_t _l = {                                        \
124
    _write,                                                     \
125
    _read,                                                      \
126
    cyg_devio_bwrite,                                           \
127
    cyg_devio_bread,                                            \
128
    _select,                                                    \
129
    _get_config,                                                \
130
    _set_config,                                                \
131
};
132
 
133
#define BLOCK_DEVIO_TABLE(_l,_bwrite,_bread,_select,_get_config,_set_config)    \
134
cyg_devio_table_t _l = {                                        \
135
    cyg_devio_cwrite,                                           \
136
    cyg_devio_cread,                                            \
137
    _bwrite,                                                    \
138
    _bread,                                                     \
139
    _select,                                                    \
140
    _get_config,                                                \
141
    _set_config,                                                \
142
};
143
 
144
#define DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config) \
145
        CHAR_DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config)
146
 
147
typedef struct cyg_devtab_entry {
148
    const char        *name;
149
    const char        *dep_name;
150
    cyg_devio_table_t *handlers;
151
    bool             (*init)(struct cyg_devtab_entry *tab);
152
    Cyg_ErrNo        (*lookup)(struct cyg_devtab_entry **tab,
153
                               struct cyg_devtab_entry *sub_tab,
154
                               const char *name);
155
    void              *priv;
156
    unsigned long     status;
157
} CYG_HAL_TABLE_TYPE cyg_devtab_entry_t;
158
 
159
#define CYG_DEVTAB_STATUS_AVAIL   0x0001
160
#define CYG_DEVTAB_STATUS_CHAR    0x1000
161
#define CYG_DEVTAB_STATUS_BLOCK   0x2000
162
 
163
extern cyg_devtab_entry_t __DEVTAB__[], __DEVTAB_END__;
164
 
165
#define CHAR_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv)  \
166
cyg_devtab_entry_t _l CYG_HAL_TABLE_ENTRY(devtab) = {                   \
167
   _name,                                                               \
168
   _dep_name,                                                           \
169
   _handlers,                                                           \
170
   _init,                                                               \
171
   _lookup,                                                             \
172
   _priv,                                                               \
173
   CYG_DEVTAB_STATUS_CHAR                                               \
174
};
175
 
176
#define BLOCK_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv)  \
177
cyg_devtab_entry_t _l CYG_HAL_TABLE_ENTRY(devtab) = {                   \
178
   _name,                                                               \
179
   _dep_name,                                                           \
180
   _handlers,                                                           \
181
   _init,                                                               \
182
   _lookup,                                                             \
183
   _priv,                                                               \
184
   CYG_DEVTAB_STATUS_BLOCK                                              \
185
};
186
 
187
#define DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \
188
        CHAR_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv)
189
 
190
 
191
#define DEVTAB_ENTRY_NO_INIT(_l,_name,_dep_name,_handlers,_init,_lookup,_priv)  \
192
cyg_devtab_entry_t _l = {                                                       \
193
   _name,                                                                       \
194
   _dep_name,                                                                   \
195
   _handlers,                                                                   \
196
   _init,                                                                       \
197
   _lookup,                                                                     \
198
   _priv,                                                                       \
199
   CYG_DEVTAB_STATUS_CHAR                                                       \
200
};
201
 
202
#endif // CYGONCE_IO_DEVTAB_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.