Add IO priority handling. Currently all IO has equal priority, except the dircache...
[kugel-rb.git] / firmware / export / storage.h
blobe62cf0d902a63b66a80589cab1d50088ecf3980d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Alan Korr
11 * Copyright (C) 2008 by Frank Gevaerts
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
22 #ifndef __STORAGE_H__
23 #define __STORAGE_H__
25 #include <stdbool.h>
26 #include "config.h" /* for HAVE_MULTIDRIVE or not */
27 #include "mv.h"
29 #if (CONFIG_STORAGE & STORAGE_SD)
30 #include "sd.h"
31 #endif
32 #if (CONFIG_STORAGE & STORAGE_MMC)
33 #include "mmc.h"
34 #endif
35 #if (CONFIG_STORAGE & STORAGE_ATA)
36 #include "ata.h"
37 #endif
38 #if (CONFIG_STORAGE & STORAGE_NAND)
39 #include "nand.h"
40 #endif
41 #if (CONFIG_STORAGE & STORAGE_RAMDISK)
42 #include "ramdisk.h"
43 #endif
45 struct storage_info
47 unsigned int sector_size;
48 unsigned int num_sectors;
49 char *vendor;
50 char *product;
51 char *revision;
54 #if !defined(SIMULATOR) && !defined(CONFIG_STORAGE_MULTI)
55 /* storage_spindown, storage_sleep and storage_spin are passed as
56 * pointers, which doesn't work with argument-macros.
58 #define storage_num_drives() NUM_DRIVES
59 #if (CONFIG_STORAGE & STORAGE_ATA)
60 #define STORAGE_FUNCTION(NAME) (ata_## NAME)
61 #define storage_spindown ata_spindown
62 #define storage_sleep ata_sleep
63 #define storage_spin ata_spin
65 #define storage_enable(on) ata_enable(on)
66 #define storage_sleepnow() ata_sleepnow()
67 #define storage_disk_is_active() ata_disk_is_active()
68 #define storage_soft_reset() ata_soft_reset()
69 #define storage_init() ata_init()
70 #define storage_close() ata_close()
71 #ifdef HAVE_STORAGE_FLUSH
72 #define storage_flush() (void)0
73 #endif
74 #define storage_last_disk_activity() ata_last_disk_activity()
75 #define storage_spinup_time() ata_spinup_time()
76 #define storage_get_identify() ata_get_identify()
78 #ifdef STORAGE_GET_INFO
79 #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
80 #endif
81 #ifdef HAVE_HOTSWAP
82 #define storage_removable(drive) ata_removable(IF_MD(drive))
83 #define storage_present(drive) ata_present(IF_MD(drive))
84 #endif
85 #elif (CONFIG_STORAGE & STORAGE_SD)
86 #define STORAGE_FUNCTION(NAME) (sd_## NAME)
87 #define storage_spindown sd_spindown
88 #define storage_sleep sd_sleep
89 #define storage_spin sd_spin
91 #define storage_enable(on) sd_enable(on)
92 #define storage_sleepnow() sd_sleepnow()
93 #define storage_disk_is_active() 0
94 #define storage_soft_reset() (void)0
95 #define storage_init() sd_init()
96 #ifdef HAVE_STORAGE_FLUSH
97 #define storage_flush() (void)0
98 #endif
99 #define storage_last_disk_activity() sd_last_disk_activity()
100 #define storage_spinup_time() 0
101 #define storage_get_identify() sd_get_identify()
103 #ifdef STORAGE_GET_INFO
104 #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
105 #endif
106 #ifdef HAVE_HOTSWAP
107 #define storage_removable(drive) sd_removable(IF_MD(drive))
108 #define storage_present(drive) sd_present(IF_MD(drive))
109 #endif
110 #elif (CONFIG_STORAGE & STORAGE_MMC)
111 #define STORAGE_FUNCTION(NAME) (mmc_## NAME)
112 #define storage_spindown mmc_spindown
113 #define storage_sleep mmc_sleep
114 #define storage_spin mmc_spin
116 #define storage_enable(on) mmc_enable(on)
117 #define storage_sleepnow() mmc_sleepnow()
118 #define storage_disk_is_active() mmc_disk_is_active()
119 #define storage_soft_reset() (void)0
120 #define storage_init() mmc_init()
121 #ifdef HAVE_STORAGE_FLUSH
122 #define storage_flush() (void)0
123 #endif
124 #define storage_last_disk_activity() mmc_last_disk_activity()
125 #define storage_spinup_time() 0
126 #define storage_get_identify() mmc_get_identify()
128 #ifdef STORAGE_GET_INFO
129 #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
130 #endif
131 #ifdef HAVE_HOTSWAP
132 #define storage_removable(drive) mmc_removable(IF_MD(drive))
133 #define storage_present(drive) mmc_present(IF_MD(drive))
134 #endif
135 #elif (CONFIG_STORAGE & STORAGE_NAND)
136 #define STORAGE_FUNCTION(NAME) (nand_## NAME)
137 #define storage_spindown nand_spindown
138 #define storage_sleep nand_sleep
139 #define storage_spin nand_spin
141 #define storage_enable(on) (void)0
142 #define storage_sleepnow() nand_sleepnow()
143 #define storage_disk_is_active() 0
144 #define storage_soft_reset() (void)0
145 #define storage_init() nand_init()
146 #ifdef HAVE_STORAGE_FLUSH
147 #define storage_flush() nand_flush()
148 #endif
149 #define storage_last_disk_activity() nand_last_disk_activity()
150 #define storage_spinup_time() 0
151 #define storage_get_identify() nand_get_identify()
153 #ifdef STORAGE_GET_INFO
154 #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
155 #endif
156 #ifdef HAVE_HOTSWAP
157 #define storage_removable(drive) nand_removable(IF_MD(drive))
158 #define storage_present(drive) nand_present(IF_MD(drive))
159 #endif
160 #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
161 #define STORAGE_FUNCTION(NAME) (ramdisk_## NAME)
162 #define storage_spindown ramdisk_spindown
163 #define storage_sleep ramdisk_sleep
164 #define storage_spin ramdisk_spin
166 #define storage_enable(on) (void)0
167 #define storage_sleepnow() ramdisk_sleepnow()
168 #define storage_disk_is_active() 0
169 #define storage_soft_reset() (void)0
170 #define storage_init() ramdisk_init()
171 #ifdef HAVE_STORAGE_FLUSH
172 #define storage_flush() (void)0
173 #endif
174 #define storage_last_disk_activity() ramdisk_last_disk_activity()
175 #define storage_spinup_time() 0
176 #define storage_get_identify() ramdisk_get_identify()
178 #ifdef STORAGE_GET_INFO
179 #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
180 #endif
181 #ifdef HAVE_HOTSWAP
182 #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
183 #define storage_present(drive) ramdisk_present(IF_MD(drive))
184 #endif
185 #else
186 //#error No storage driver!
187 #endif
188 #else /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
190 /* Simulator and multi-driver use normal functions */
192 void storage_enable(bool on);
193 void storage_sleep(void);
194 void storage_sleepnow(void);
195 bool storage_disk_is_active(void);
196 int storage_soft_reset(void);
197 int storage_init(void);
198 int storage_flush(void);
199 void storage_spin(void);
200 void storage_spindown(int seconds);
201 long storage_last_disk_activity(void);
202 int storage_spinup_time(void);
203 int storage_num_drives(void);
204 #ifdef STORAGE_GET_INFO
205 void storage_get_info(int drive, struct storage_info *info);
206 #endif
207 #ifdef HAVE_HOTSWAP
208 bool storage_removable(int drive);
209 bool storage_present(int drive);
210 #endif
212 #endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
214 int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
215 int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
216 #endif