Rockbox supports not only 1bpp BMPs
[kugel-rb.git] / firmware / drivers / ramdisk.c
blob266d3ea225f2a793a2e655d49fab1a9cb38d9e5e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: ramdisk.c 18965 2008-11-01 17:33:21Z gevaerts $
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_MV2(int drive,)
35 unsigned long start,
36 int count,
37 void* buf)
39 if(start+count>=NUM_SECTORS)
41 return -1;
43 memcpy(buf,&ramdisk[start*SECTOR_SIZE],count*SECTOR_SIZE);
44 return 0;
47 int ramdisk_write_sectors(IF_MV2(int drive,)
48 unsigned long start,
49 int count,
50 const void* buf)
52 if(start+count>=NUM_SECTORS)
54 return -1;
56 memcpy(&ramdisk[start*SECTOR_SIZE],buf,count*SECTOR_SIZE);
57 return 0;
60 int ramdisk_init(void)
62 return 0;
65 long ramdisk_last_disk_activity(void)
67 return last_disk_activity;
70 void ramdisk_sleep(void)
74 void ramdisk_spin(void)
78 void ramdisk_sleepnow(void)
82 void ramdisk_spindown(int seconds)
84 (void)seconds;
86 #ifdef STORAGE_GET_INFO
87 void ramdisk_get_info(IF_MV2(int drive,) struct storage_info *info)
89 /* firmware version */
90 info->revision="0.00";
92 /* vendor field, need better name? */
93 info->vendor="Rockbox";
94 /* model field, need better name? */
95 info->product="Ramdisk";
97 /* blocks count */
98 info->num_sectors=NUM_SECTORS;
99 info->sector_size=SECTOR_SIZE;
101 #endif