| 54 |
theseven |
1 |
/***************************************************************************
|
|
|
2 |
* __________ __ ___.
|
|
|
3 |
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
4 |
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
5 |
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
6 |
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
7 |
* \/ \/ \/ \/ \/
|
|
|
8 |
* $Id$
|
|
|
9 |
*
|
|
|
10 |
* Copyright (C) 2002 by Alan Korr
|
|
|
11 |
* Copyright (C) 2008 by Frank Gevaerts
|
|
|
12 |
*
|
|
|
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.
|
|
|
17 |
*
|
|
|
18 |
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
19 |
* KIND, either express or implied.
|
|
|
20 |
*
|
|
|
21 |
****************************************************************************/
|
|
|
22 |
#ifndef __STORAGE_H__
|
|
|
23 |
#define __STORAGE_H__
|
|
|
24 |
|
|
|
25 |
#include "global.h"
|
|
|
26 |
#include "mv.h"
|
|
|
27 |
|
| 153 |
theseven |
28 |
#define STORAGE_GET_INFO
|
|
|
29 |
|
| 54 |
theseven |
30 |
#if (CONFIG_STORAGE & STORAGE_SD)
|
|
|
31 |
#include "storage_sd.h"
|
|
|
32 |
#endif
|
|
|
33 |
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
34 |
#include "storage_mmc.h"
|
|
|
35 |
#endif
|
|
|
36 |
#if (CONFIG_STORAGE & STORAGE_ATA)
|
|
|
37 |
#include "storage_ata.h"
|
|
|
38 |
#endif
|
|
|
39 |
#if (CONFIG_STORAGE & STORAGE_NAND)
|
|
|
40 |
#include "storage_nand.h"
|
|
|
41 |
#endif
|
|
|
42 |
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
|
|
43 |
#include "storage_ramdisk.h"
|
|
|
44 |
#endif
|
|
|
45 |
|
|
|
46 |
struct storage_info
|
|
|
47 |
{
|
|
|
48 |
unsigned int sector_size;
|
|
|
49 |
unsigned int num_sectors;
|
|
|
50 |
char *vendor;
|
|
|
51 |
char *product;
|
|
|
52 |
char *revision;
|
| 612 |
theseven |
53 |
void *driverinfo;
|
| 54 |
theseven |
54 |
};
|
|
|
55 |
|
|
|
56 |
#if !defined(CONFIG_STORAGE_MULTI)
|
|
|
57 |
/* storage_spindown, storage_sleep and storage_spin are passed as
|
|
|
58 |
* pointers, which doesn't work with argument-macros.
|
|
|
59 |
*/
|
|
|
60 |
#define storage_num_drives() NUM_DRIVES
|
|
|
61 |
#if (CONFIG_STORAGE & STORAGE_ATA)
|
|
|
62 |
#define STORAGE_FUNCTION(NAME) (ata_## NAME)
|
|
|
63 |
#define storage_spindown ata_spindown
|
|
|
64 |
#define storage_sleep ata_sleep
|
|
|
65 |
#define storage_spin ata_spin
|
|
|
66 |
|
|
|
67 |
#define storage_enable(on) ata_enable(on)
|
|
|
68 |
#define storage_sleepnow() ata_sleepnow()
|
|
|
69 |
#define storage_disk_is_active() ata_disk_is_active()
|
|
|
70 |
#define storage_soft_reset() ata_soft_reset()
|
|
|
71 |
#define storage_init() ata_init()
|
|
|
72 |
#define storage_close() ata_close()
|
|
|
73 |
#ifdef HAVE_STORAGE_FLUSH
|
|
|
74 |
#define storage_flush() (void)0
|
|
|
75 |
#endif
|
|
|
76 |
#define storage_last_disk_activity() ata_last_disk_activity()
|
|
|
77 |
#define storage_get_identify() ata_get_identify()
|
|
|
78 |
|
|
|
79 |
#ifdef HAVE_HOTSWAP
|
|
|
80 |
#define storage_removable(drive) ata_removable(IF_MD(drive))
|
|
|
81 |
#define storage_present(drive) ata_present(IF_MD(drive))
|
|
|
82 |
#endif
|
|
|
83 |
#elif (CONFIG_STORAGE & STORAGE_SD)
|
|
|
84 |
#define STORAGE_FUNCTION(NAME) (sd_## NAME)
|
|
|
85 |
#define storage_spindown sd_spindown
|
|
|
86 |
#define storage_sleep sd_sleep
|
|
|
87 |
#define storage_spin sd_spin
|
|
|
88 |
|
|
|
89 |
#define storage_enable(on) sd_enable(on)
|
|
|
90 |
#define storage_sleepnow() sd_sleepnow()
|
|
|
91 |
#define storage_disk_is_active() 0
|
|
|
92 |
#define storage_soft_reset() (void)0
|
|
|
93 |
#define storage_init() sd_init()
|
|
|
94 |
#ifdef HAVE_STORAGE_FLUSH
|
|
|
95 |
#define storage_flush() (void)0
|
|
|
96 |
#endif
|
|
|
97 |
#define storage_last_disk_activity() sd_last_disk_activity()
|
|
|
98 |
#define storage_get_identify() sd_get_identify()
|
|
|
99 |
|
|
|
100 |
#ifdef HAVE_HOTSWAP
|
|
|
101 |
#define storage_removable(drive) sd_removable(IF_MD(drive))
|
|
|
102 |
#define storage_present(drive) sd_present(IF_MD(drive))
|
|
|
103 |
#endif
|
|
|
104 |
#elif (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
105 |
#define STORAGE_FUNCTION(NAME) (mmc_## NAME)
|
|
|
106 |
#define storage_spindown mmc_spindown
|
|
|
107 |
#define storage_sleep mmc_sleep
|
|
|
108 |
#define storage_spin mmc_spin
|
|
|
109 |
|
|
|
110 |
#define storage_enable(on) mmc_enable(on)
|
|
|
111 |
#define storage_sleepnow() mmc_sleepnow()
|
|
|
112 |
#define storage_disk_is_active() mmc_disk_is_active()
|
|
|
113 |
#define storage_soft_reset() (void)0
|
|
|
114 |
#define storage_init() mmc_init()
|
|
|
115 |
#ifdef HAVE_STORAGE_FLUSH
|
|
|
116 |
#define storage_flush() (void)0
|
|
|
117 |
#endif
|
|
|
118 |
#define storage_last_disk_activity() mmc_last_disk_activity()
|
|
|
119 |
#define storage_get_identify() mmc_get_identify()
|
|
|
120 |
|
|
|
121 |
#ifdef HAVE_HOTSWAP
|
|
|
122 |
#define storage_removable(drive) mmc_removable(IF_MD(drive))
|
|
|
123 |
#define storage_present(drive) mmc_present(IF_MD(drive))
|
|
|
124 |
#endif
|
|
|
125 |
#elif (CONFIG_STORAGE & STORAGE_NAND)
|
|
|
126 |
#define STORAGE_FUNCTION(NAME) (nand_## NAME)
|
|
|
127 |
#define storage_spindown nand_spindown
|
|
|
128 |
#define storage_sleep nand_sleep
|
|
|
129 |
#define storage_spin nand_spin
|
|
|
130 |
|
|
|
131 |
#define storage_enable(on) (void)0
|
|
|
132 |
#define storage_sleepnow() nand_sleepnow()
|
|
|
133 |
#define storage_disk_is_active() 0
|
|
|
134 |
#define storage_soft_reset() (void)0
|
|
|
135 |
#define storage_init() nand_init()
|
|
|
136 |
#ifdef HAVE_STORAGE_FLUSH
|
|
|
137 |
#define storage_flush() nand_flush()
|
|
|
138 |
#endif
|
|
|
139 |
#define storage_last_disk_activity() nand_last_disk_activity()
|
|
|
140 |
#define storage_get_identify() nand_get_identify()
|
|
|
141 |
|
|
|
142 |
#ifdef HAVE_HOTSWAP
|
|
|
143 |
#define storage_removable(drive) nand_removable(IF_MD(drive))
|
|
|
144 |
#define storage_present(drive) nand_present(IF_MD(drive))
|
|
|
145 |
#endif
|
|
|
146 |
#elif (CONFIG_STORAGE & STORAGE_RAMDISK)
|
|
|
147 |
#define STORAGE_FUNCTION(NAME) (ramdisk_## NAME)
|
|
|
148 |
#define storage_spindown ramdisk_spindown
|
|
|
149 |
#define storage_sleep ramdisk_sleep
|
|
|
150 |
#define storage_spin ramdisk_spin
|
|
|
151 |
|
|
|
152 |
#define storage_enable(on) (void)0
|
|
|
153 |
#define storage_sleepnow() ramdisk_sleepnow()
|
|
|
154 |
#define storage_disk_is_active() 0
|
|
|
155 |
#define storage_soft_reset() (void)0
|
|
|
156 |
#define storage_init() ramdisk_init()
|
|
|
157 |
#ifdef HAVE_STORAGE_FLUSH
|
|
|
158 |
#define storage_flush() (void)0
|
|
|
159 |
#endif
|
|
|
160 |
#define storage_last_disk_activity() ramdisk_last_disk_activity()
|
|
|
161 |
#define storage_get_identify() ramdisk_get_identify()
|
|
|
162 |
|
|
|
163 |
#ifdef HAVE_HOTSWAP
|
|
|
164 |
#define storage_removable(drive) ramdisk_removable(IF_MD(drive))
|
|
|
165 |
#define storage_present(drive) ramdisk_present(IF_MD(drive))
|
|
|
166 |
#endif
|
|
|
167 |
#else
|
|
|
168 |
//#error No storage driver!
|
|
|
169 |
#endif
|
| 57 |
theseven |
170 |
#else /* NOT CONFIG_STORAGE_MULTI */
|
| 54 |
theseven |
171 |
|
|
|
172 |
/* Simulator and multi-driver use normal functions */
|
|
|
173 |
|
|
|
174 |
void storage_enable(bool on);
|
|
|
175 |
void storage_sleep(void);
|
|
|
176 |
void storage_sleepnow(void);
|
|
|
177 |
bool storage_disk_is_active(void);
|
|
|
178 |
int storage_soft_reset(void);
|
|
|
179 |
int storage_init(void);
|
|
|
180 |
int storage_flush(void);
|
|
|
181 |
void storage_spin(void);
|
|
|
182 |
void storage_spindown(int seconds);
|
|
|
183 |
long storage_last_disk_activity(void);
|
|
|
184 |
int storage_num_drives(void);
|
|
|
185 |
#ifdef HAVE_HOTSWAP
|
|
|
186 |
bool storage_removable(int drive);
|
|
|
187 |
bool storage_present(int drive);
|
|
|
188 |
#endif
|
|
|
189 |
|
| 57 |
theseven |
190 |
#endif /* NOT CONFIG_STORAGE_MULTI */
|
| 54 |
theseven |
191 |
|
|
|
192 |
int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
| 116 |
theseven |
193 |
int storage_read_sectors_md(int drive, unsigned long start, int count, void* buf);
|
| 54 |
theseven |
194 |
int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
| 116 |
theseven |
195 |
int storage_write_sectors_md(int drive, unsigned long start, int count, const void* buf);
|
| 153 |
theseven |
196 |
#ifdef STORAGE_GET_INFO
|
|
|
197 |
void storage_get_info(int drive, struct storage_info *info);
|
| 54 |
theseven |
198 |
#endif
|
| 153 |
theseven |
199 |
#endif
|