mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
Commit FS#9545, storage cleanup and multi-driver support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bb3b57f645
commit
c0a5a67387
37 changed files with 1157 additions and 315 deletions
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
/* TODO: Find the real capacity of >2GB models (will be useful for USB) */
|
||||
|
||||
#include "config.h" /* for HAVE_MULTIVOLUME & AMS_OF_SIZE */
|
||||
#include "config.h" /* for HAVE_MULTIDRIVE & AMS_OF_SIZE */
|
||||
#include "fat.h"
|
||||
#include "thread.h"
|
||||
#include "led.h"
|
||||
|
|
@ -88,9 +88,9 @@
|
|||
#define INTERNAL_AS3525 0 /* embedded SD card */
|
||||
#define SD_SLOT_AS3525 1 /* SD slot if present */
|
||||
|
||||
static const int pl180_base[NUM_VOLUMES] = {
|
||||
static const int pl180_base[NUM_DRIVES] = {
|
||||
NAND_FLASH_BASE
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
, SD_MCI_BASE
|
||||
#endif
|
||||
};
|
||||
|
|
@ -101,7 +101,7 @@ static void init_pl180_controller(const int drive);
|
|||
#define SECTOR_SIZE 512 /* XXX: different sector sizes ? */
|
||||
#define BLOCKS_PER_BANK 0x7a7800
|
||||
|
||||
static tCardInfo card_info[NUM_VOLUMES];
|
||||
static tCardInfo card_info[NUM_DRIVES];
|
||||
|
||||
/* maximum timeouts recommanded in the SD Specification v2.00 */
|
||||
#define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */
|
||||
|
|
@ -169,7 +169,7 @@ void INT_NAND(void)
|
|||
MCI_CLEAR(INTERNAL_AS3525) = status;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
void INT_MCI0(void)
|
||||
{
|
||||
const int status = MCI_STATUS(SD_SLOT_AS3525);
|
||||
|
|
@ -436,7 +436,7 @@ static void init_pl180_controller(const int drive)
|
|||
|
||||
MCI_MASK0(drive) = MCI_MASK1(drive) = MCI_ERROR | MCI_DATA_END;
|
||||
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
VIC_INT_ENABLE |=
|
||||
(drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0;
|
||||
|
||||
|
|
@ -478,7 +478,7 @@ int sd_init(void)
|
|||
|
||||
|
||||
CGU_PERI |= CGU_NAF_CLOCK_ENABLE;
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
CGU_PERI |= CGU_MCI_CLOCK_ENABLE;
|
||||
CCU_IO &= ~(1<<3); /* bits 3:2 = 01, xpd is SD interface */
|
||||
CCU_IO |= (1<<2);
|
||||
|
|
@ -490,7 +490,7 @@ int sd_init(void)
|
|||
ret = sd_init_card(INTERNAL_AS3525);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
init_pl180_controller(SD_SLOT_AS3525);
|
||||
#endif
|
||||
|
||||
|
|
@ -509,17 +509,17 @@ int sd_init(void)
|
|||
}
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool sd_removable(IF_MV_NONVOID(int drive))
|
||||
bool sd_removable(IF_MD_NONVOID(int drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
#endif
|
||||
return (drive==1);
|
||||
}
|
||||
|
||||
bool sd_present(IF_MV_NONVOID(int drive))
|
||||
bool sd_present(IF_MD_NONVOID(int drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
#endif
|
||||
return (card_info[drive].initialized && card_info[drive].numblocks > 0);
|
||||
|
|
@ -619,10 +619,10 @@ static int sd_select_bank(signed char bank)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
|
||||
static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
|
||||
int count, void* buf, const bool write)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive = 0;
|
||||
#endif
|
||||
int ret = 0;
|
||||
|
|
@ -774,18 +774,18 @@ sd_transfer_error:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
return sd_transfer_sectors(IF_MV2(drive,) start, count, buf, false);
|
||||
return sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false);
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
|
||||
#ifdef BOOTLOADER /* we don't need write support in bootloader */
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void) drive;
|
||||
#endif
|
||||
(void) start;
|
||||
|
|
@ -793,7 +793,7 @@ int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
|||
(void) buf;
|
||||
return -1;
|
||||
#else
|
||||
return sd_transfer_sectors(IF_MV2(drive,) start, count, (void*)buf, true);
|
||||
return sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -807,7 +807,7 @@ void sd_enable(bool on)
|
|||
{
|
||||
/* buttonlight AMSes need a bit of special handling for the buttonlight here,
|
||||
* due to the dual mapping of GPIOD and XPD */
|
||||
#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIVOLUME)
|
||||
#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE)
|
||||
extern int buttonlight_is_on;
|
||||
#endif
|
||||
if (sd_enabled == on)
|
||||
|
|
@ -815,7 +815,7 @@ void sd_enable(bool on)
|
|||
if(on)
|
||||
{
|
||||
CGU_PERI |= CGU_NAF_CLOCK_ENABLE;
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
CGU_PERI |= CGU_MCI_CLOCK_ENABLE;
|
||||
#ifdef HAVE_BUTTON_LIGHT
|
||||
CCU_IO |= (1<<2);
|
||||
|
|
@ -832,7 +832,7 @@ void sd_enable(bool on)
|
|||
else
|
||||
{
|
||||
CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE;
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
#ifdef HAVE_BUTTON_LIGHT
|
||||
CCU_IO &= ~(1<<2);
|
||||
if (buttonlight_is_on)
|
||||
|
|
@ -882,3 +882,17 @@ void card_enable_monitoring_target(bool on)
|
|||
#endif
|
||||
|
||||
#endif /* BOOTLOADER */
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int sd_num_drives(int first_drive)
|
||||
{
|
||||
/* We don't care which logical drive number(s) we have been assigned */
|
||||
(void)first_drive;
|
||||
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
return 2;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -696,10 +696,10 @@ static void read_inplace_writes_cache(int bank, int phys_segment)
|
|||
}
|
||||
|
||||
|
||||
int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
|
||||
|
|
@ -753,11 +753,10 @@ nand_read_error:
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
|
||||
|
|
@ -770,8 +769,12 @@ int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
|||
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void nand_get_info(struct storage_info *info)
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
|
||||
/* firmware version */
|
||||
info->revision="0.00";
|
||||
|
||||
|
|
@ -913,3 +916,39 @@ void nand_spindown(int seconds)
|
|||
{
|
||||
(void)seconds;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
|
||||
int nand_num_drives(int first_drive)
|
||||
{
|
||||
/* We don't care which logical drive number we have been assigned */
|
||||
(void)first_drive;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void nand_sleepnow(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool nand_disk_is_active(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int nand_soft_reset(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nand_spinup_time(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nand_enable(bool onoff)
|
||||
{
|
||||
(void)onoff;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_STORAGE_MULTI */
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "config.h" /* for HAVE_MULTIVOLUME */
|
||||
#include "config.h" /* for HAVE_MULTIDRIVE */
|
||||
#include "fat.h"
|
||||
#include "hotswap.h"
|
||||
#ifdef HAVE_HOTSWAP
|
||||
|
|
@ -166,10 +166,10 @@ struct sd_card_status
|
|||
int retry_max;
|
||||
};
|
||||
|
||||
static struct sd_card_status sd_status[NUM_VOLUMES] =
|
||||
static struct sd_card_status sd_status[NUM_DRIVES] =
|
||||
{
|
||||
{ 0, 1 },
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
{ 0, 10 }
|
||||
#endif
|
||||
};
|
||||
|
|
@ -839,10 +839,10 @@ static void sd_select_device(int card_no)
|
|||
|
||||
/* API Functions */
|
||||
|
||||
int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive = 0;
|
||||
#endif
|
||||
int ret;
|
||||
|
|
@ -956,13 +956,13 @@ sd_read_error:
|
|||
}
|
||||
}
|
||||
|
||||
int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
/* Write support is not finished yet */
|
||||
/* TODO: The standard suggests using ACMD23 prior to writing multiple blocks
|
||||
to improve performance */
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive = 0;
|
||||
#endif
|
||||
int ret;
|
||||
|
|
@ -1330,19 +1330,33 @@ long sd_last_disk_activity(void)
|
|||
}
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool sd_removable(IF_MV_NONVOID(int drive))
|
||||
bool sd_removable(IF_MD_NONVOID(int drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
#endif
|
||||
return (drive==1);
|
||||
}
|
||||
|
||||
bool sd_present(IF_MV_NONVOID(int drive))
|
||||
bool sd_present(IF_MD_NONVOID(int drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
#endif
|
||||
return (card_info[drive].initialized && card_info[drive].numblocks > 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int sd_num_drives(int first_drive)
|
||||
{
|
||||
/* We don't care which logical drive number(s) we have been assigned */
|
||||
(void)first_drive;
|
||||
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
return 2;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void nand_led(bool onoff)
|
|||
led(onoff);
|
||||
}
|
||||
|
||||
int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int incount,
|
||||
void* inbuf)
|
||||
{
|
||||
(void)start;
|
||||
|
|
@ -55,7 +55,7 @@ int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count,
|
||||
const void* outbuf)
|
||||
{
|
||||
(void)start;
|
||||
|
|
@ -82,7 +82,7 @@ void nand_enable(bool on)
|
|||
(void)on;
|
||||
}
|
||||
|
||||
void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
{
|
||||
(void)info;
|
||||
}
|
||||
|
|
@ -98,3 +98,12 @@ int nand_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int nand_num_drives(int first_drive)
|
||||
{
|
||||
/* We don't care which logical drive number(s) we have been assigned */
|
||||
(void)first_drive;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -125,8 +125,8 @@ void GIO2(void)
|
|||
|
||||
#define VFAT_SECTOR_SIZE(x) ( (x)/0x8000 ) /* 1GB array requires 80kB of RAM */
|
||||
|
||||
extern int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
extern int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
|
||||
struct main_header
|
||||
{
|
||||
|
|
@ -378,14 +378,14 @@ static inline unsigned long map_sector(unsigned long sector)
|
|||
return cfs_start+sectors[sector/64]*64+sector%64;
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf)
|
||||
int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_read_sectors(IF_MV2(drive,) map_sector(start), count, buf);
|
||||
return _ata_read_sectors(IF_MD2(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
|
|
@ -394,7 +394,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* bu
|
|||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_read_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
|
||||
ret = _ata_read_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* bu
|
|||
}
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf)
|
||||
int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf)
|
||||
{
|
||||
if(!cfs_inited)
|
||||
cfs_init();
|
||||
|
|
@ -413,7 +413,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v
|
|||
#if 0 /* Disabled for now */
|
||||
/* Check if count is lesser than or equal to 1 native CFS sector */
|
||||
if(count <= 64)
|
||||
return _ata_write_sectors(IF_MV2(drive,) map_sector(start), count, buf);
|
||||
return _ata_write_sectors(IF_MD2(drive,) map_sector(start), count, buf);
|
||||
else
|
||||
{
|
||||
int i, ret;
|
||||
|
|
@ -422,7 +422,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const v
|
|||
/* Read sectors in parts of 0x8000 */
|
||||
for(i=0; i<count; i+=64)
|
||||
{
|
||||
ret = _ata_write_sectors(IF_MV2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
|
||||
ret = _ata_write_sectors(IF_MD2(drive,) map_sector(start+i), (count-i >= 64 ? 64 : count-i), (const void*)dest);
|
||||
if(ret != 0)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ void copy_write_sectors(const unsigned char* buf, int wordcount);
|
|||
/* Nasty hack, but Creative is nasty... */
|
||||
#define ata_read_sectors _ata_read_sectors
|
||||
#define ata_write_sectors _ata_write_sectors
|
||||
extern int _ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int _ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
extern int _ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
extern int _ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
|
||||
/* General purpose memory region #1 */
|
||||
#define ATA_IOBASE 0x50FEE000
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue