summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2008-11-03 20:52:27 +0000
committerFrank Gevaerts <frank@gevaerts.be>2008-11-03 20:52:27 +0000
commit214cd81f080436fddb1994ed712f1000e143dfd7 (patch)
tree98e8deb0db4160385c4b73291031e61c4bc0c516 /firmware/drivers
parent65d9ca8a6f557847cf87ffe37e5b1ef48b1fa11b (diff)
downloadrockbox-214cd81f080436fddb1994ed712f1000e143dfd7.tar.gz
rockbox-214cd81f080436fddb1994ed712f1000e143dfd7.zip
Add ramdisk storage driver. It will be useful for developing multi-driver storage
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18993 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/ramdisk.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/firmware/drivers/ramdisk.c b/firmware/drivers/ramdisk.c
new file mode 100644
index 0000000000..da0a12f836
--- /dev/null
+++ b/firmware/drivers/ramdisk.c
@@ -0,0 +1,102 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: ramdisk.c 18965 2008-11-01 17:33:21Z gevaerts $
9 *
10 * Copyright (C) 2008 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#include <stdbool.h>
23#include <string.h>
24
25#include "storage.h"
26
27#define SECTOR_SIZE 512
28#define NUM_SECTORS 16384
29
30extern unsigned char ramdisk[SECTOR_SIZE * NUM_SECTORS];
31
32long last_disk_activity = -1;
33
34int ramdisk_read_sectors(IF_MV2(int drive,)
35 unsigned long start,
36 int count,
37 void* buf)
38{
39 if(start+count>=NUM_SECTORS)
40 {
41 return -1;
42 }
43 memcpy(buf,&ramdisk[start*SECTOR_SIZE],count*SECTOR_SIZE);
44 return 0;
45}
46
47int ramdisk_write_sectors(IF_MV2(int drive,)
48 unsigned long start,
49 int count,
50 const void* buf)
51{
52 if(start+count>=NUM_SECTORS)
53 {
54 return -1;
55 }
56 memcpy(&ramdisk[start*SECTOR_SIZE],buf,count*SECTOR_SIZE);
57 return 0;
58}
59
60int ramdisk_init(void)
61{
62 return 0;
63}
64
65long ramdisk_last_disk_activity(void)
66{
67 return last_disk_activity;
68}
69
70void ramdisk_sleep(void)
71{
72}
73
74void ramdisk_spin(void)
75{
76}
77
78void ramdisk_sleepnow(void)
79{
80}
81
82void ramdisk_spindown(int seconds)
83{
84 (void)seconds;
85}
86#ifdef STORAGE_GET_INFO
87void ramdisk_get_info(struct storage_info *info)
88{
89 /* firmware version */
90 info->revision="0.00";
91
92 /* vendor field, need better name? */
93 info->vendor="Rockbox";
94 /* model field, need better name? */
95 info->product="Ramdisk";
96
97 /* blocks count */
98 info->num_sectors=NUM_SECTORS;
99 info->sector_size=SECTOR_SIZE;
100}
101#endif
102