Subversion Repositories freemyipod

Rev

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