summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-11-01 16:25:04 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-11-01 16:25:04 +0000
commitad9db4de3dee9db8f08b5a28f731b066c35e41e6 (patch)
tree266209a72c75a7436b253719408d092477396354
parent2f8a0081c64534da23fc0fa9cc685eb7454fd9c9 (diff)
downloadrockbox-ad9db4de3dee9db8f08b5a28f731b066c35e41e6.tar.gz
rockbox-ad9db4de3dee9db8f08b5a28f731b066c35e41e6.zip
Now also commit added files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18961 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/mmc.h55
-rw-r--r--firmware/export/mv.h41
-rw-r--r--firmware/export/nand.h50
-rw-r--r--firmware/export/sd.h54
-rw-r--r--firmware/export/storage.h239
-rw-r--r--firmware/storage.c35
6 files changed, 474 insertions, 0 deletions
diff --git a/firmware/export/mmc.h b/firmware/export/mmc.h
new file mode 100644
index 0000000000..2e7fb2441d
--- /dev/null
+++ b/firmware/export/mmc.h
@@ -0,0 +1,55 @@
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 __MMC_H__
23#define __MMC_H__
24
25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */
27
28struct storage_info;
29
30void mmc_enable(bool on);
31void mmc_spindown(int seconds);
32void mmc_sleep(void);
33void mmc_sleepnow(void);
34bool mmc_disk_is_active(void);
35int mmc_hard_reset(void);
36int mmc_soft_reset(void);
37int mmc_init(void);
38void mmc_close(void);
39int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
40int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
41void mmc_spin(void);
42
43#if (CONFIG_LED == LED_REAL)
44void mmc_set_led_enabled(bool enabled);
45#endif
46
47void mmc_get_info(IF_MV2(int drive,) struct storage_info *info);
48#ifdef HAVE_HOTSWAP
49bool mmc_removable(IF_MV_NONVOID(int drive));
50bool mmc_present(IF_MV_NONVOID(int drive));
51#endif
52
53long mmc_last_disk_activity(void);
54
55#endif
diff --git a/firmware/export/mv.h b/firmware/export/mv.h
new file mode 100644
index 0000000000..fda650c7e9
--- /dev/null
+++ b/firmware/export/mv.h
@@ -0,0 +1,41 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Frank Gevaerts
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __MV_H__
23#define __MV_H__
24
25#include "config.h"
26
27/* FixMe: These macros are a bit nasty and perhaps misplaced here.
28 We'll get rid of them once decided on how to proceed with multivolume. */
29#ifdef HAVE_MULTIVOLUME
30#define IF_MV(x) x /* optional volume/drive parameter */
31#define IF_MV2(x,y) x,y /* same, for a list of arguments */
32#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */
33#define NUM_VOLUMES 2
34#else /* empty definitions if no multi-volume */
35#define IF_MV(x)
36#define IF_MV2(x,y)
37#define IF_MV_NONVOID(x) void
38#define NUM_VOLUMES 1
39#endif
40
41#endif
diff --git a/firmware/export/nand.h b/firmware/export/nand.h
new file mode 100644
index 0000000000..3d4d1ce166
--- /dev/null
+++ b/firmware/export/nand.h
@@ -0,0 +1,50 @@
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 __NAND_H__
23#define __NAND_H__
24
25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */
27
28struct storage_info;
29
30void nand_enable(bool on);
31void nand_spindown(int seconds);
32void nand_sleep(void);
33bool nand_disk_is_active(void);
34int nand_hard_reset(void);
35int nand_soft_reset(void);
36int nand_init(void);
37void nand_close(void);
38int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
39int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
40void nand_spin(void);
41
42#if (CONFIG_LED == LED_REAL)
43void nand_set_led_enabled(bool enabled);
44#endif
45
46void nand_get_info(IF_MV2(int drive,) struct storage_info *info);
47
48long nand_last_disk_activity(void);
49
50#endif
diff --git a/firmware/export/sd.h b/firmware/export/sd.h
new file mode 100644
index 0000000000..8e1fa88ceb
--- /dev/null
+++ b/firmware/export/sd.h
@@ -0,0 +1,54 @@
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 __SD_H__
23#define __SD_H__
24
25#include <stdbool.h>
26#include "mv.h" /* for HAVE_MULTIVOLUME or not */
27
28struct storage_info;
29
30void sd_enable(bool on);
31void sd_spindown(int seconds);
32void sd_sleep(void);
33bool sd_disk_is_active(void);
34int sd_hard_reset(void);
35int sd_soft_reset(void);
36int sd_init(void);
37void sd_close(void);
38int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
39int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
40void sd_spin(void);
41
42#if (CONFIG_LED == LED_REAL)
43void sd_set_led_enabled(bool enabled);
44#endif
45
46void sd_get_info(IF_MV2(int drive,) struct storage_info *info);
47#ifdef HAVE_HOTSWAP
48bool sd_removable(IF_MV_NONVOID(int drive));
49bool sd_present(IF_MV_NONVOID(int drive));
50#endif
51
52long sd_last_disk_activity(void);
53
54#endif
diff --git a/firmware/export/storage.h b/firmware/export/storage.h
new file mode 100644
index 0000000000..95e42f67f4
--- /dev/null
+++ b/firmware/export/storage.h
@@ -0,0 +1,239 @@
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 <stdbool.h>
26#include "config.h" /* for HAVE_MULTIVOLUME or not */
27#include "mv.h"
28
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
42struct storage_info
43{
44 unsigned int sector_size;
45 unsigned int num_sectors;
46 char *vendor;
47 char *product;
48 char *revision;
49};
50
51void storage_spindown(int seconds);
52
53static inline void storage_enable(bool on)
54{
55#if (CONFIG_STORAGE & STORAGE_ATA)
56 ata_enable(on);
57#elif (CONFIG_STORAGE & STORAGE_SD)
58 sd_enable(on);
59#elif (CONFIG_STORAGE & STORAGE_MMC)
60 mmc_enable(on);
61#else
62 (void)on;
63#endif
64}
65static inline void storage_sleep(void)
66{
67#if (CONFIG_STORAGE & STORAGE_ATA)
68 ata_sleep();
69#endif
70}
71static inline void storage_sleepnow(void)
72{
73#if (CONFIG_STORAGE & STORAGE_ATA)
74 ata_sleepnow();
75#endif
76}
77static inline bool storage_disk_is_active(void)
78{
79#if (CONFIG_STORAGE & STORAGE_ATA)
80 return ata_disk_is_active();
81#elif (CONFIG_STORAGE & STORAGE_MMC)
82 return mmc_disk_is_active();
83#else
84 return 0;
85#endif
86}
87static inline int storage_hard_reset(void)
88{
89#if (CONFIG_STORAGE & STORAGE_ATA)
90 return ata_hard_reset();
91#else
92 return 0;
93#endif
94}
95static inline int storage_soft_reset(void)
96{
97#if (CONFIG_STORAGE & STORAGE_ATA)
98 return ata_soft_reset();
99#else
100 return 0;
101#endif
102}
103static inline int storage_init(void)
104{
105#if (CONFIG_STORAGE & STORAGE_ATA)
106 return ata_init();
107#elif (CONFIG_STORAGE & STORAGE_SD)
108 return sd_init();
109#elif (CONFIG_STORAGE & STORAGE_NAND)
110 return nand_init();
111#elif (CONFIG_STORAGE & STORAGE_MMC)
112 return mmc_init();
113#else
114 #error No storage driver!
115#endif
116}
117static inline int storage_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
118{
119#if (CONFIG_STORAGE & STORAGE_ATA)
120 return ata_read_sectors(IF_MV2(drive,) start, count, buf);
121#elif (CONFIG_STORAGE & STORAGE_SD)
122 return sd_read_sectors(IF_MV2(drive,) start, count, buf);
123#elif (CONFIG_STORAGE & STORAGE_NAND)
124 return nand_read_sectors(IF_MV2(drive,) start, count, buf);
125#elif (CONFIG_STORAGE & STORAGE_MMC)
126 return mmc_read_sectors(IF_MV2(drive,) start, count, buf);
127#else
128 #error No storage driver!
129#endif
130}
131static inline int storage_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
132{
133#if (CONFIG_STORAGE & STORAGE_ATA)
134 return ata_write_sectors(IF_MV2(drive,) start, count, buf);
135#elif (CONFIG_STORAGE & STORAGE_SD)
136 return sd_write_sectors(IF_MV2(drive,) start, count, buf);
137#elif (CONFIG_STORAGE & STORAGE_NAND)
138 return nand_write_sectors(IF_MV2(drive,) start, count, buf);
139#elif (CONFIG_STORAGE & STORAGE_MMC)
140 return mmc_write_sectors(IF_MV2(drive,) start, count, buf);
141#else
142 #error No storage driver!
143#endif
144}
145static inline void storage_spin(void)
146{
147#if (CONFIG_STORAGE & STORAGE_ATA)
148 ata_spin();
149#endif
150}
151
152#if (CONFIG_LED == LED_REAL)
153static inline void storage_set_led_enabled(bool enabled)
154{
155#if (CONFIG_STORAGE & STORAGE_ATA)
156 ata_set_led_enabled(enabled);
157#elif (CONFIG_STORAGE & STORAGE_SD)
158 sd_set_led_enabled(enabled);
159#elif (CONFIG_STORAGE & STORAGE_NAND)
160 nand_set_led_enabled(enabled);
161#elif (CONFIG_STORAGE & STORAGE_MMC)
162 mmc_set_led_enabled(enabled);
163#else
164 #error No storage driver!
165#endif
166}
167#endif
168
169static inline long storage_last_disk_activity(void)
170{
171#if (CONFIG_STORAGE & STORAGE_ATA)
172 return ata_last_disk_activity();
173#elif (CONFIG_STORAGE & STORAGE_SD)
174 return sd_last_disk_activity();
175#elif (CONFIG_STORAGE & STORAGE_NAND)
176 return nand_last_disk_activity();
177#elif (CONFIG_STORAGE & STORAGE_MMC)
178 return mmc_last_disk_activity();
179#else
180 #error No storage driver!
181#endif
182}
183
184static inline int storage_spinup_time(void)
185{
186#if (CONFIG_STORAGE & STORAGE_ATA)
187 return ata_spinup_time();
188#else
189 return 0;
190#endif
191}
192
193static inline void storage_get_info(IF_MV2(int drive,) struct storage_info *info)
194{
195#if (CONFIG_STORAGE & STORAGE_ATA)
196 return ata_get_info(IF_MV2(drive,) info);
197#elif (CONFIG_STORAGE & STORAGE_SD)
198 return sd_get_info(IF_MV2(drive,) info);
199#elif (CONFIG_STORAGE & STORAGE_NAND)
200 return nand_get_info(IF_MV2(drive,) info);
201#elif (CONFIG_STORAGE & STORAGE_MMC)
202 return mmc_get_info(IF_MV2(drive,) info);
203#else
204 #error No storage driver!
205#endif
206}
207
208#ifdef HAVE_HOTSWAP
209static inline bool storage_removable(IF_MV_NONVOID(int drive))
210{
211#if (CONFIG_STORAGE & STORAGE_ATA)
212 return ata_removable(IF_MV(drive));
213#elif (CONFIG_STORAGE & STORAGE_SD)
214 return sd_removable(IF_MV(drive));
215#elif (CONFIG_STORAGE & STORAGE_NAND)
216 return nand_removable(IF_MV(drive));
217#elif (CONFIG_STORAGE & STORAGE_MMC)
218 return mmc_removable(IF_MV(drive));
219#else
220 #error No storage driver!
221#endif
222}
223
224static inline bool storage_present(IF_MV_NONVOID(int drive))
225{
226#if (CONFIG_STORAGE & STORAGE_ATA)
227 return ata_present(IF_MV(drive));
228#elif (CONFIG_STORAGE & STORAGE_SD)
229 return sd_present(IF_MV(drive));
230#elif (CONFIG_STORAGE & STORAGE_NAND)
231 return nand_present(IF_MV(drive));
232#elif (CONFIG_STORAGE & STORAGE_MMC)
233 return mmc_present(IF_MV(drive));
234#else
235 #error No storage driver!
236#endif
237}
238#endif
239#endif
diff --git a/firmware/storage.c b/firmware/storage.c
new file mode 100644
index 0000000000..631fbe6177
--- /dev/null
+++ b/firmware/storage.c
@@ -0,0 +1,35 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: $
9 *
10 * Copyright (C) 2008 by Frank Gevaerts
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h" /* for HAVE_MULTIVOLUME or not */
22#include "storage.h"
23
24/* storage_spindown() can't be inlined as it is passed as a function
25 pointer in settings_list.c
26*/
27
28void storage_spindown(int seconds)
29{
30#if (CONFIG_STORAGE & STORAGE_ATA)
31 ata_spindown(seconds);
32#else
33 (void)seconds;
34#endif
35}