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.
14 // Copyright (C) 2003 Savin Zlobec
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later version.
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 // You should have received a copy of the GNU General Public License along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
39 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40 // at http://sources.redhat.com/ecos/ecos-license/
41 // -------------------------------------------
42 //####ECOSGPLCOPYRIGHTEND####
43 // ====================================================================
44 //#####DESCRIPTIONBEGIN####
47 // Original data: gthomas
49 // Purpose: Internal interfaces for disk I/O drivers
52 //####DESCRIPTIONEND####
54 // ====================================================================
56 // Disk I/O interfaces
58 #include <pkgconf/system.h>
59 #include <pkgconf/io_disk.h>
61 #include <cyg/infra/cyg_type.h>
62 #include <cyg/io/io.h>
63 #include <cyg/io/diskio.h>
64 #include <cyg/hal/drv_api.h>
66 typedef struct disk_channel disk_channel;
67 typedef struct disk_funs disk_funs;
69 // Pointers into upper-level driver
72 // Initialize the disk
73 cyg_bool (*disk_init)(struct cyg_devtab_entry *tab);
75 // Disk device has been connected
76 Cyg_ErrNo (*disk_connected)(struct cyg_devtab_entry *tab,
77 cyg_disk_identify_t *ident);
79 // Disk device has been disconnected
80 Cyg_ErrNo (*disk_disconnected)(struct cyg_devtab_entry *tab);
83 Cyg_ErrNo (*disk_lookup)(struct cyg_devtab_entry **tab,
84 struct cyg_devtab_entry *sub_tab,
88 #define DISK_CALLBACKS(_l, \
93 disk_callbacks_t _l = { \
100 extern disk_callbacks_t cyg_io_disk_callbacks;
102 // Private data which describes this channel
103 struct disk_channel {
105 disk_callbacks_t *callbacks;
106 void *dev_priv; // device private data
107 cyg_disk_info_t *info; // disk info
108 cyg_disk_partition_t *partition; // partition data
109 struct cyg_devtab_entry *pdevs_dev; // partition devs devtab ents
110 disk_channel *pdevs_chan; // partition devs disk chans
111 cyg_bool mbr_support; // true if disk has MBR
112 cyg_bool valid; // true if device valid
113 cyg_bool init; // true if initialized
116 // Initialization macro for disk channel
117 #define DISK_CHANNEL(_l, \
122 static struct cyg_devtab_entry _l##_part_dev[_max_part_num]; \
123 static disk_channel _l##_part_chan[_max_part_num]; \
124 static cyg_disk_partition_t _l##_part_tab[_max_part_num]; \
125 static cyg_disk_info_t _l##_disk_info = { \
129 static disk_channel _l = { \
131 &cyg_io_disk_callbacks, \
142 // Low level interface functions
145 // Read block data into buf
146 Cyg_ErrNo (*read)(disk_channel *priv,
149 cyg_uint32 block_num);
151 // Write block data from buf
152 Cyg_ErrNo (*write)(disk_channel *priv,
155 cyg_uint32 block_num);
157 // Get hardware configuration
158 Cyg_ErrNo (*get_config)(disk_channel *priv,
163 // Set hardware configuration
164 Cyg_ErrNo (*set_config)(disk_channel *priv,
170 #define DISK_FUNS(_l,_read,_write,_get_config,_set_config) \
178 extern cyg_devio_table_t cyg_io_disk_devio;
180 #endif // CYGONCE_DISK_H