Prepare new maemo release
[maemo-rb.git] / firmware / drivers / ramdisk.c
blob7324af9f0af1adc041b2957f214ad5c0d9f9ae16
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include <stdbool.h>
23 #include <string.h>
25 #include "storage.h"
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,)
35 unsigned long start,
36 int count,
37 void* buf)
39 #ifdef HAVE_MULTIDRIVE
40 (void)drive; /* unused for now */
41 #endif
42 if(start+count>NUM_SECTORS)
44 return -1;
46 memcpy(buf,&ramdisk[start*SECTOR_SIZE],count*SECTOR_SIZE);
47 return 0;
50 int ramdisk_write_sectors(IF_MD2(int drive,)
51 unsigned long start,
52 int count,
53 const void* buf)
55 #ifdef HAVE_MULTIDRIVE
56 (void)drive; /* unused for now */
57 #endif
58 if(start+count>NUM_SECTORS)
60 return -1;
62 memcpy(&ramdisk[start*SECTOR_SIZE],buf,count*SECTOR_SIZE);
63 return 0;
66 int ramdisk_init(void)
68 return 0;
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)
90 (void)on;
93 bool ramdisk_disk_is_active(void)
95 return true;
98 int ramdisk_soft_reset(void)
100 return 0;
103 int ramdisk_spinup_time(void)
105 return 0;
108 void ramdisk_spindown(int seconds)
110 (void)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 */
117 #endif
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";
126 /* blocks count */
127 info->num_sectors=NUM_SECTORS;
128 info->sector_size=SECTOR_SIZE;
130 #endif
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 */
136 (void)first_drive;
138 return 1;
140 #endif
142 #ifdef HAVE_HOTSWAP
143 bool ramdisk_removable(IF_MD(int drive))
145 #ifdef HAVE_MULTIDRIVE
146 (void)drive; /* unused for now */
147 #endif
149 return false;
152 bool ramdisk_present(IF_MD(int drive))
154 #ifdef HAVE_MULTIDRIVE
155 (void)drive; /* unused for now */
156 #endif
158 return true;
160 #endif