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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [common/] [current/] [include/] [devtab.h] - Blame information for rev 786

Details | Compare with Previous | View Log

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