1 #ifndef CYGONCE_IO_DEVTAB_H
2 #define CYGONCE_IO_DEVTAB_H
3 // ====================================================================
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.
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.
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
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.
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.
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.
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####
46 // Contributors: gthomas
48 // Purpose: Describe low level I/O interfaces.
51 //####DESCRIPTIONEND####
53 // ====================================================================
55 // Private include file. This file should only be used by device
56 // drivers, not application code.
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>
63 // Set of functions which handle top level I/O functions
65 Cyg_ErrNo (*write)(cyg_io_handle_t handle,
68 Cyg_ErrNo (*read)(cyg_io_handle_t handle,
71 Cyg_ErrNo (*bwrite)(cyg_io_handle_t handle,
73 cyg_uint32 *len, // in blocks
74 cyg_uint32 pos); // in blocks
75 Cyg_ErrNo (*bread)(cyg_io_handle_t handle,
77 cyg_uint32 *len, // in blocks
78 cyg_uint32 pos); // in blocks
79 cyg_bool (*select)(cyg_io_handle_t handle,
82 Cyg_ErrNo (*get_config)(cyg_io_handle_t handle,
86 Cyg_ErrNo (*set_config)(cyg_io_handle_t handle,
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,
102 __externC Cyg_ErrNo cyg_devio_bread(cyg_io_handle_t handle,
103 void *buf, cyg_uint32 *len,
106 __externC Cyg_ErrNo cyg_devio_select(cyg_io_handle_t handle,
110 __externC Cyg_ErrNo cyg_devio_get_config(cyg_io_handle_t handle,
115 __externC Cyg_ErrNo cyg_devio_set_config(cyg_io_handle_t handle,
120 // Initialization macros
122 #define CHAR_DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config) \
123 cyg_devio_table_t _l = { \
133 // Note: _bwrite and _bread pass len and pos in terms of blocks, not
135 #define BLOCK_DEVIO_TABLE(_l,_bwrite,_bread,_select,_get_config,_set_config) \
136 cyg_devio_table_t _l = { \
146 #define DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config) \
147 CHAR_DEVIO_TABLE(_l,_write,_read,_select,_get_config,_set_config)
149 typedef struct cyg_devtab_entry {
151 const char *dep_name;
152 cyg_devio_table_t *handlers;
153 bool (*init)(struct cyg_devtab_entry *tab);
154 Cyg_ErrNo (*lookup)(struct cyg_devtab_entry **tab,
155 struct cyg_devtab_entry *sub_tab,
158 unsigned long status;
159 } CYG_HAL_TABLE_TYPE cyg_devtab_entry_t;
161 #define CYG_DEVTAB_STATUS_AVAIL 0x0001
162 #define CYG_DEVTAB_STATUS_CHAR 0x1000
163 #define CYG_DEVTAB_STATUS_BLOCK 0x2000
165 extern cyg_devtab_entry_t __DEVTAB__[], __DEVTAB_END__;
167 #define CHAR_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \
168 cyg_devtab_entry_t _l CYG_HAL_TABLE_ENTRY(devtab) = { \
175 CYG_DEVTAB_STATUS_CHAR \
178 #define BLOCK_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \
179 cyg_devtab_entry_t _l CYG_HAL_TABLE_ENTRY(devtab) = { \
186 CYG_DEVTAB_STATUS_BLOCK \
189 #define DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \
190 CHAR_DEVTAB_ENTRY(_l,_name,_dep_name,_handlers,_init,_lookup,_priv)
193 #define DEVTAB_ENTRY_NO_INIT(_l,_name,_dep_name,_handlers,_init,_lookup,_priv) \
194 cyg_devtab_entry_t _l = { \
201 CYG_DEVTAB_STATUS_CHAR \
204 #endif // CYGONCE_IO_DEVTAB_H