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_get_identify() ata_get_identify()
75
 
76
        #ifdef STORAGE_GET_INFO
77
            #define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
78
        #endif
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 STORAGE_GET_INFO
101
            #define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
102
        #endif
103
        #ifdef HAVE_HOTSWAP
104
            #define storage_removable(drive) sd_removable(IF_MD(drive))
105
            #define storage_present(drive) sd_present(IF_MD(drive))
106
        #endif
107
     #elif (CONFIG_STORAGE & STORAGE_MMC)
108
        #define STORAGE_FUNCTION(NAME) (mmc_## NAME)
109
        #define storage_spindown mmc_spindown
110
        #define storage_sleep mmc_sleep
111
        #define storage_spin mmc_spin
112
 
113
        #define storage_enable(on) mmc_enable(on)
114
        #define storage_sleepnow() mmc_sleepnow()
115
        #define storage_disk_is_active() mmc_disk_is_active()
116
        #define storage_soft_reset() (void)0
117
        #define storage_init() mmc_init()
118
        #ifdef HAVE_STORAGE_FLUSH
119
            #define storage_flush() (void)0
120
        #endif
121
        #define storage_last_disk_activity() mmc_last_disk_activity()
122
        #define storage_get_identify() mmc_get_identify()
123
 
124
        #ifdef STORAGE_GET_INFO
125
            #define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
126
        #endif
127
        #ifdef HAVE_HOTSWAP
128
            #define storage_removable(drive) mmc_removable(IF_MD(drive))
129
            #define storage_present(drive) mmc_present(IF_MD(drive))
130
        #endif
131
    #elif (CONFIG_STORAGE & STORAGE_NAND)
132
        #define STORAGE_FUNCTION(NAME) (nand_## NAME)
133
        #define storage_spindown nand_spindown
134
        #define storage_sleep nand_sleep
135
        #define storage_spin nand_spin
136
 
137
        #define storage_enable(on) (void)0
138
        #define storage_sleepnow() nand_sleepnow()
139
        #define storage_disk_is_active() 0
140
        #define storage_soft_reset() (void)0
141
        #define storage_init() nand_init()
142
        #ifdef HAVE_STORAGE_FLUSH
143
            #define storage_flush() nand_flush()
144
        #endif
145
        #define storage_last_disk_activity() nand_last_disk_activity()
146
        #define storage_get_identify() nand_get_identify()
147
 
148
        #ifdef STORAGE_GET_INFO
149
            #define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
150
        #endif
151
        #ifdef HAVE_HOTSWAP
152
            #define storage_removable(drive) nand_removable(IF_MD(drive))
153
            #define storage_present(drive) nand_present(IF_MD(drive))
154
        #endif
155
    #elif (CONFIG_STORAGE & STORAGE_RAMDISK)
156
        #define STORAGE_FUNCTION(NAME) (ramdisk_## NAME)
157
        #define storage_spindown ramdisk_spindown
158
        #define storage_sleep ramdisk_sleep
159
        #define storage_spin ramdisk_spin
160
 
161
        #define storage_enable(on) (void)0
162
        #define storage_sleepnow() ramdisk_sleepnow()
163
        #define storage_disk_is_active() 0
164
        #define storage_soft_reset() (void)0
165
        #define storage_init() ramdisk_init()
166
        #ifdef HAVE_STORAGE_FLUSH
167
            #define storage_flush() (void)0
168
        #endif
169
        #define storage_last_disk_activity() ramdisk_last_disk_activity()
170
        #define storage_get_identify() ramdisk_get_identify()
171
 
172
        #ifdef STORAGE_GET_INFO
173
            #define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
174
        #endif
175
        #ifdef HAVE_HOTSWAP
176
            #define storage_removable(drive) ramdisk_removable(IF_MD(drive))
177
            #define storage_present(drive) ramdisk_present(IF_MD(drive))
178
        #endif
179
    #else
180
        //#error No storage driver!
181
    #endif
57 theseven 182
#else /* NOT CONFIG_STORAGE_MULTI */
54 theseven 183
 
184
/* Simulator and multi-driver use normal functions */
185
 
186
void storage_enable(bool on);
187
void storage_sleep(void);
188
void storage_sleepnow(void);
189
bool storage_disk_is_active(void);
190
int storage_soft_reset(void);
191
int storage_init(void);
192
int storage_flush(void);
193
void storage_spin(void);
194
void storage_spindown(int seconds);
195
long storage_last_disk_activity(void);
196
int storage_num_drives(void);
197
#ifdef STORAGE_GET_INFO
198
void storage_get_info(int drive, struct storage_info *info);
199
#endif
200
#ifdef HAVE_HOTSWAP
201
bool storage_removable(int drive);
202
bool storage_present(int drive);
203
#endif
204
 
57 theseven 205
#endif /* NOT CONFIG_STORAGE_MULTI */
54 theseven 206
 
207
int storage_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
116 theseven 208
int storage_read_sectors_md(int drive, unsigned long start, int count, void* buf);
54 theseven 209
int storage_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
116 theseven 210
int storage_write_sectors_md(int drive, unsigned long start, int count, const void* buf);
54 theseven 211
#endif