1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 Frank Gevaerts
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 #define SECTOR_SIZE 512
28 #define NUM_SECTORS 16384
30 unsigned char ramdisk
[SECTOR_SIZE
* NUM_SECTORS
];
32 long last_disk_activity
= -1;
34 int ramdisk_read_sectors(IF_MD2(int drive
,)
39 #ifdef HAVE_MULTIDRIVE
40 (void)drive
; /* unused for now */
42 if(start
+count
>NUM_SECTORS
)
46 memcpy(buf
,&ramdisk
[start
*SECTOR_SIZE
],count
*SECTOR_SIZE
);
50 int ramdisk_write_sectors(IF_MD2(int drive
,)
55 #ifdef HAVE_MULTIDRIVE
56 (void)drive
; /* unused for now */
58 if(start
+count
>NUM_SECTORS
)
62 memcpy(&ramdisk
[start
*SECTOR_SIZE
],buf
,count
*SECTOR_SIZE
);
66 int ramdisk_init(void)
71 long ramdisk_last_disk_activity(void)
73 return last_disk_activity
;
76 void ramdisk_sleep(void)
80 void ramdisk_spin(void)
84 void ramdisk_sleepnow(void)
88 void ramdisk_enable(bool on
)
93 bool ramdisk_disk_is_active(void)
98 int ramdisk_soft_reset(void)
103 int ramdisk_spinup_time(void)
108 void ramdisk_spindown(int seconds
)
112 #ifdef STORAGE_GET_INFO
113 void ramdisk_get_info(IF_MD2(int drive
,) struct storage_info
*info
)
115 #ifdef HAVE_MULTIDRIVE
116 (void)drive
; /* unused for now */
118 /* firmware version */
119 info
->revision
="0.00";
121 /* vendor field, need better name? */
122 info
->vendor
="Rockbox";
123 /* model field, need better name? */
124 info
->product
="Ramdisk";
127 info
->num_sectors
=NUM_SECTORS
;
128 info
->sector_size
=SECTOR_SIZE
;
132 #ifdef CONFIG_STORAGE_MULTI
133 int ramdisk_num_drives(int first_drive
)
135 /* We don't care which logical drive number(s) we have been assigned */
143 bool ramdisk_removable(IF_MD(int drive
))
145 #ifdef HAVE_MULTIDRIVE
146 (void)drive
; /* unused for now */
152 bool ramdisk_present(IF_MD(int drive
))
154 #ifdef HAVE_MULTIDRIVE
155 (void)drive
; /* unused for now */