Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
 
28
#if (CONFIG_STORAGE & STORAGE_SD)
29
#include "storage_sd.h"
30
#endif
31
#if (CONFIG_STORAGE & STORAGE_MMC)
32
#include "storage_mmc.h"
33
#endif
34
#if (CONFIG_STORAGE & STORAGE_ATA)
35
#include "storage_ata.h"
36
#endif
37
#if (CONFIG_STORAGE & STORAGE_NAND)
38
#include "storage_nand.h"
39
#endif
40
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
41
#include "storage_ramdisk.h"
42
#endif
43
 
44
struct storage_info
45
{
46
    unsigned int sector_size;
47
    unsigned int num_sectors;
48
    char *vendor;
49
    char *product;
50
    char *revision;
51
};
52
 
53
#if !defined(CONFIG_STORAGE_MULTI)
54
/* storage_spindown, storage_sleep and storage_spin are passed as
55
 * pointers, which doesn't work with argument-macros.
56
 */
57
    #define storage_num_drives() NUM_DRIVES
58
    #if (CONFIG_STORAGE & STORAGE_ATA)
59
        #define STORAGE_FUNCTION(NAME) (ata_## NAME)
60
        #define storage_spindown ata_spindown
61
        #define storage_sleep ata_sleep
62
        #define storage_spin ata_spin
63
 
64
        #define storage_enable(on) ata_enable(on)
65
        #define storage_sleepnow() ata_sleepnow()
66
        #define storage_disk_is_active() ata_disk_is_active()
67
        #define storage_soft_reset() ata_soft_reset()
68
        #define storage_init() ata_init()
69
        #define storage_close() ata_close()
70
        #ifdef HAVE_STORAGE_FLUSH
71
            #define storage_flush() (void)0
72
        #endif
73
        #define storage_last_disk_activity() ata_last_disk_activity()
74
        #define storage_spinup_time() ata_spinup_time()
75
        #define storage_get_identify() ata_get_identify()
76
 
77
        #ifdef STORAGE_GET_INFO
78
            #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
79
        #endif
80
        #ifdef HAVE_HOTSWAP
81
            #define storage_removable(drive) ata_removable(IF_MD(drive))
82
            #define storage_present(drive) ata_present(IF_MD(drive))
83
        #endif
84
    #elif (CONFIG_STORAGE & STORAGE_SD)
85
        #define STORAGE_FUNCTION(NAME) (sd_## NAME)
86
        #define storage_spindown sd_spindown
87
        #define storage_sleep sd_sleep
88
        #define storage_spin sd_spin
89
 
90
        #define storage_enable(on) sd_enable(on)
91
        #define storage_sleepnow() sd_sleepnow()
92
        #define storage_disk_is_active() 0
93
        #define storage_soft_reset() (void)0
94
        #define storage_init() sd_init()
95
        #ifdef HAVE_STORAGE_FLUSH
96
            #define storage_flush() (void)0
97
        #endif
98
        #define storage_last_disk_activity() sd_last_disk_activity()
99
        #define storage_spinup_time() 0
100
        #define storage_get_identify() sd_get_identify()
101
 
102
        #ifdef STORAGE_GET_INFO
103
            #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
104
        #endif
105
        #ifdef HAVE_HOTSWAP
106
            #define storage_removable(drive) sd_removable(IF_MD(drive))
107
            #define storage_present(drive) sd_present(IF_MD(drive))
108
        #endif
109
     #elif (CONFIG_STORAGE & STORAGE_MMC)
110
        #define STORAGE_FUNCTION(NAME) (mmc_## NAME)
111
        #define storage_spindown mmc_spindown
112
        #define storage_sleep mmc_sleep
113
        #define storage_spin mmc_spin
114
 
115
        #define storage_enable(on) mmc_enable(on)
116
        #define storage_sleepnow() mmc_sleepnow()
117
        #define storage_disk_is_active() mmc_disk_is_active()
118
        #define storage_soft_reset() (void)0
119
        #define storage_init() mmc_init()
120
        #ifdef HAVE_STORAGE_FLUSH
121
            #define storage_flush() (void)0
122
        #endif
123
        #define storage_last_disk_activity() mmc_last_disk_activity()
124
        #define storage_spinup_time() 0
125
        #define storage_get_identify() mmc_get_identify()
126
 
127
        #ifdef STORAGE_GET_INFO
128
            #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
129
        #endif
130
        #ifdef HAVE_HOTSWAP
131
            #define storage_removable(drive) mmc_removable(IF_MD(drive))
132
            #define storage_present(drive) mmc_present(IF_MD(drive))
133
        #endif
134
    #elif (CONFIG_STORAGE & STORAGE_NAND)
135
        #define STORAGE_FUNCTION(NAME) (nand_## NAME)
136
        #define storage_spindown nand_spindown
137
        #define storage_sleep nand_sleep
138
        #define storage_spin nand_spin
139
 
140
        #define storage_enable(on) (void)0
141
        #define storage_sleepnow() nand_sleepnow()
142
        #define storage_disk_is_active() 0
143
        #define storage_soft_reset() (void)0
144
        #define storage_init() nand_init()
145
        #ifdef HAVE_STORAGE_FLUSH
146
            #define storage_flush() nand_flush()
147
        #endif
148
        #define storage_last_disk_activity() nand_last_disk_activity()
149
        #define storage_spinup_time() 0
150
        #define storage_get_identify() nand_get_identify()
151
 
152
        #ifdef STORAGE_GET_INFO
153
            #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
154
        #endif
155
        #ifdef HAVE_HOTSWAP
156
            #define storage_removable(drive) nand_removable(IF_MD(drive))
157
            #define storage_present(drive) nand_present(IF_MD(drive))
158
        #endif
159
    #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
160
        #define STORAGE_FUNCTION(NAME) (ramdisk_## NAME)
161
        #define storage_spindown ramdisk_spindown
162
        #define storage_sleep ramdisk_sleep
163
        #define storage_spin ramdisk_spin
164
 
165
        #define storage_enable(on) (void)0
166
        #define storage_sleepnow() ramdisk_sleepnow()
167
        #define storage_disk_is_active() 0
168
        #define storage_soft_reset() (void)0
169
        #define storage_init() ramdisk_init()
170
        #ifdef HAVE_STORAGE_FLUSH
171
            #define storage_flush() (void)0
172
        #endif
173
        #define storage_last_disk_activity() ramdisk_last_disk_activity()
174
        #define storage_spinup_time() 0
175
        #define storage_get_identify() ramdisk_get_identify()
176
 
177
        #ifdef STORAGE_GET_INFO
178
            #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
179
        #endif
180
        #ifdef HAVE_HOTSWAP
181
            #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
182
            #define storage_present(drive) ramdisk_present(IF_MD(drive))
183
        #endif
184
    #else
185
        //#error No storage driver!
186
    #endif
187
#else /* NOT CONFIG_STORAGE_MULTI and PLATFORM_NATIVE*/
188
 
189
/* Simulator and multi-driver use normal functions */
190
 
191
void storage_enable(bool on);
192
void storage_sleep(void);
193
void storage_sleepnow(void);
194
bool storage_disk_is_active(void);
195
int storage_soft_reset(void);
196
int storage_init(void);
197
int storage_flush(void);
198
void storage_spin(void);
199
void storage_spindown(int seconds);
200
long storage_last_disk_activity(void);
201
int storage_spinup_time(void);
202
int storage_num_drives(void);
203
#ifdef STORAGE_GET_INFO
204
void storage_get_info(int drive, struct storage_info *info);
205
#endif
206
#ifdef HAVE_HOTSWAP
207
bool storage_removable(int drive);
208
bool storage_present(int drive);
209
#endif
210
 
211
#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
212
 
213
int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
214
int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
215
#endif