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
|
@ -126,19 +126,28 @@ drivers/touchscreen.c
|
|||
#ifndef SIMULATOR
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
drivers/ata_mmc.c
|
||||
#elif (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_IFP7XX)
|
||||
#endif
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_IFP7XX)
|
||||
drivers/ata_flash.c
|
||||
#elif (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_TCC)
|
||||
#endif
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_TCC)
|
||||
target/arm/ata-nand-telechips.c
|
||||
#elif (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_SAMSUNG)
|
||||
#endif
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND) && (CONFIG_NAND == NAND_SAMSUNG)
|
||||
target/arm/s5l8700/ata-nand-s5l8700.c
|
||||
#elif (CONFIG_STORAGE & STORAGE_ATA)
|
||||
#endif
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
drivers/ata.c
|
||||
#elif (CONFIG_STORAGE & STORAGE_SD)
|
||||
#endif
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
drivers/sd.c
|
||||
#elif (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
#endif
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
drivers/ramdisk.c
|
||||
#endif /* CONFIG_STORAGE */
|
||||
#endif
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
storage.c
|
||||
#endif
|
||||
drivers/fat.c
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
|
||||
hotswap.c
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
12-15: nr of sectors in partition
|
||||
*/
|
||||
|
||||
#define BYTES2INT32(array,pos) \
|
||||
((long)array[pos] | ((long)array[pos+1] << 8 ) | \
|
||||
#define BYTES2INT32(array,pos) \
|
||||
((long)array[pos] | ((long)array[pos+1] << 8 ) | \
|
||||
((long)array[pos+2] << 16 ) | ((long)array[pos+3] << 24 ))
|
||||
|
||||
static const unsigned char fat_partition_types[] = {
|
||||
|
@ -58,18 +58,18 @@ static const unsigned char fat_partition_types[] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static struct partinfo part[8]; /* space for 4 partitions on 2 drives */
|
||||
static struct partinfo part[NUM_DRIVES*4]; /* space for 4 partitions on 2 drives */
|
||||
static int vol_drive[NUM_VOLUMES]; /* mounted to which drive (-1 if none) */
|
||||
|
||||
#ifdef MAX_LOG_SECTOR_SIZE
|
||||
int disk_sector_multiplier = 1;
|
||||
#endif
|
||||
|
||||
struct partinfo* disk_init(IF_MV_NONVOID(int drive))
|
||||
struct partinfo* disk_init(IF_MD_NONVOID(int drive))
|
||||
{
|
||||
int i;
|
||||
unsigned char sector[512];
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
/* For each drive, start at a different position, in order not to destroy
|
||||
the first entry of drive 0.
|
||||
That one is needed to calculate config sector position. */
|
||||
|
@ -115,7 +115,7 @@ struct partinfo* disk_partinfo(int partition)
|
|||
|
||||
int disk_mount_all(void)
|
||||
{
|
||||
int mounted;
|
||||
int mounted=0;
|
||||
int i;
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
|
@ -126,13 +126,19 @@ int disk_mount_all(void)
|
|||
for (i=0; i<NUM_VOLUMES; i++)
|
||||
vol_drive[i] = -1; /* mark all as unassigned */
|
||||
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
mounted = disk_mount(0);
|
||||
#ifdef HAVE_HOTSWAP
|
||||
if (card_detect())
|
||||
#else
|
||||
for(i=0;i<NUM_DRIVES;i++)
|
||||
{
|
||||
mounted += disk_mount(1); /* try 2nd "drive", too */
|
||||
#ifdef HAVE_HOTSWAP
|
||||
if (storage_present(i))
|
||||
#endif
|
||||
mounted += disk_mount(i);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
card_enable_monitoring(true);
|
||||
#endif
|
||||
|
||||
|
@ -155,7 +161,7 @@ int disk_mount(int drive)
|
|||
{
|
||||
int mounted = 0; /* reset partition-on-drive flag */
|
||||
int volume = get_free_volume();
|
||||
struct partinfo* pinfo = disk_init(IF_MV(drive));
|
||||
struct partinfo* pinfo = disk_init(IF_MD(drive));
|
||||
|
||||
if (pinfo == NULL)
|
||||
{
|
||||
|
@ -166,7 +172,7 @@ int disk_mount(int drive)
|
|||
#else
|
||||
int i = 0;
|
||||
#endif
|
||||
for (; volume != -1 && i<4; i++)
|
||||
for (; volume != -1 && i<4 && mounted<NUM_VOLUMES_PER_DRIVE; i++)
|
||||
{
|
||||
if (memchr(fat_partition_types, pinfo[i].type,
|
||||
sizeof(fat_partition_types)) == NULL)
|
||||
|
@ -177,7 +183,7 @@ int disk_mount(int drive)
|
|||
|
||||
for (j = 1; j <= (MAX_LOG_SECTOR_SIZE/SECTOR_SIZE); j <<= 1)
|
||||
{
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MV2(drive,) pinfo[i].start * j))
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start * j))
|
||||
{
|
||||
pinfo[i].start *= j;
|
||||
pinfo[i].size *= j;
|
||||
|
@ -190,7 +196,7 @@ int disk_mount(int drive)
|
|||
}
|
||||
}
|
||||
#else
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MV2(drive,) pinfo[i].start))
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) pinfo[i].start))
|
||||
{
|
||||
mounted++;
|
||||
vol_drive[volume] = drive; /* remember the drive for this volume */
|
||||
|
@ -202,7 +208,7 @@ int disk_mount(int drive)
|
|||
if (mounted == 0 && volume != -1) /* none of the 4 entries worked? */
|
||||
{ /* try "superfloppy" mode */
|
||||
DEBUGF("No partition found, trying to mount sector 0.\n");
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MV2(drive,) 0))
|
||||
if (!fat_mount(IF_MV2(volume,) IF_MD2(drive,) 0))
|
||||
{
|
||||
mounted = 1;
|
||||
vol_drive[volume] = drive; /* remember the drive for this volume */
|
||||
|
|
|
@ -307,7 +307,7 @@ static int _read_sectors(unsigned long start,
|
|||
int incount,
|
||||
void* inbuf)
|
||||
#else
|
||||
int ata_read_sectors(IF_MV2(int drive,)
|
||||
int ata_read_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -323,7 +323,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
#endif
|
||||
|
||||
#ifndef MAX_PHYS_SECTOR_SIZE
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
mutex_lock(&ata_mtx);
|
||||
|
@ -555,7 +555,7 @@ static int _write_sectors(unsigned long start,
|
|||
int count,
|
||||
const void* buf)
|
||||
#else
|
||||
int ata_write_sectors(IF_MV2(int drive,)
|
||||
int ata_write_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -569,7 +569,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
#endif
|
||||
|
||||
#ifndef MAX_PHYS_SECTOR_SIZE
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
mutex_lock(&ata_mtx);
|
||||
|
@ -728,7 +728,7 @@ static inline int flush_current_sector(void)
|
|||
sector_cache.data);
|
||||
}
|
||||
|
||||
int ata_read_sectors(IF_MV2(int drive,)
|
||||
int ata_read_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -736,7 +736,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
int rc = 0;
|
||||
int offset;
|
||||
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
mutex_lock(&ata_mtx);
|
||||
|
@ -794,7 +794,7 @@ int ata_read_sectors(IF_MV2(int drive,)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int ata_write_sectors(IF_MV2(int drive,)
|
||||
int ata_write_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -802,7 +802,7 @@ int ata_write_sectors(IF_MV2(int drive,)
|
|||
int rc = 0;
|
||||
int offset;
|
||||
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
mutex_lock(&ata_mtx);
|
||||
|
@ -1503,7 +1503,7 @@ int ata_init(void)
|
|||
create_thread(ata_thread, ata_stack,
|
||||
sizeof(ata_stack), 0, ata_thread_name
|
||||
IF_PRIO(, PRIORITY_USER_INTERFACE)
|
||||
IF_COP(, CPU));
|
||||
IF_COP(, CPU));
|
||||
initialized = true;
|
||||
|
||||
}
|
||||
|
@ -1552,12 +1552,15 @@ int ata_spinup_time(void)
|
|||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ata_get_info(struct storage_info *info)
|
||||
void ata_get_info(IF_MD2(int drive,)struct storage_info *info)
|
||||
{
|
||||
unsigned short *src,*dest;
|
||||
static char vendor[8];
|
||||
static char product[16];
|
||||
static char revision[4];
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
int i;
|
||||
info->sector_size = SECTOR_SIZE;
|
||||
info->num_sectors= total_sectors;
|
||||
|
@ -1595,3 +1598,13 @@ void ata_keep_active(void)
|
|||
last_disk_activity = current_tick;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int ata_num_drives(int first_drive)
|
||||
{
|
||||
/* We don't care which logical drive number(s) we have been assigned */
|
||||
(void)first_drive;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -384,7 +384,7 @@ int flash_disk_read_sectors(unsigned long start,
|
|||
return done;
|
||||
}
|
||||
|
||||
int nand_read_sectors(IF_MV2(int drive,)
|
||||
int nand_read_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -401,7 +401,7 @@ int nand_read_sectors(IF_MV2(int drive,)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int nand_write_sectors(IF_MV2(int drive,)
|
||||
int nand_write_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -472,3 +472,13 @@ void nand_get_info(struct storage_info *info)
|
|||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ static int current_buffer = 0;
|
|||
static const unsigned char *send_block_addr = NULL;
|
||||
|
||||
static tCardInfo card_info[2];
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
static int current_card = 0;
|
||||
#endif
|
||||
static bool last_mmc_status = false;
|
||||
|
@ -602,7 +602,7 @@ static int send_block_send(unsigned char start_token, long timeout,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int mmc_read_sectors(IF_MV2(int drive,)
|
||||
int mmc_read_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int incount,
|
||||
void* inbuf)
|
||||
|
@ -611,7 +611,7 @@ int mmc_read_sectors(IF_MV2(int drive,)
|
|||
int lastblock = 0;
|
||||
unsigned long end_block;
|
||||
tCardInfo *card;
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int drive = current_card;
|
||||
#endif
|
||||
|
||||
|
@ -688,7 +688,7 @@ int mmc_read_sectors(IF_MV2(int drive,)
|
|||
return rc;
|
||||
}
|
||||
|
||||
int mmc_write_sectors(IF_MV2(int drive,)
|
||||
int mmc_write_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
|
@ -697,7 +697,7 @@ int mmc_write_sectors(IF_MV2(int drive,)
|
|||
int write_cmd;
|
||||
unsigned char start_token;
|
||||
tCardInfo *card;
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
int drive = current_card;
|
||||
#endif
|
||||
|
||||
|
@ -920,7 +920,7 @@ int mmc_init(void)
|
|||
led(false);
|
||||
|
||||
last_mmc_status = mmc_detect();
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
/* Use MMC if inserted, internal flash otherwise */
|
||||
current_card = last_mmc_status ? 1 : 0;
|
||||
#endif
|
||||
|
@ -949,7 +949,7 @@ int mmc_init(void)
|
|||
create_thread(mmc_thread, mmc_stack,
|
||||
sizeof(mmc_stack), 0, mmc_thread_name
|
||||
IF_PRIO(, PRIORITY_SYSTEM)
|
||||
IF_COP(, CPU));
|
||||
IF_COP(, CPU));
|
||||
tick_add_task(mmc_tick);
|
||||
initialized = true;
|
||||
}
|
||||
|
@ -965,9 +965,9 @@ long mmc_last_disk_activity(void)
|
|||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void mmc_get_info(IF_MV2(int drive,) struct storage_info *info)
|
||||
void mmc_get_info(IF_MD2(int drive,) struct storage_info *info)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
#endif
|
||||
info->sector_size=card_info[drive].blocksize;
|
||||
|
@ -986,17 +986,17 @@ void mmc_get_info(IF_MV2(int drive,) struct storage_info *info)
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool mmc_removable(IF_MV_NONVOID(int drive))
|
||||
bool mmc_removable(IF_MD_NONVOID(int drive))
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
#ifndef HAVE_MULTIDRIVE
|
||||
const int drive=0;
|
||||
#endif
|
||||
return (drive==1);
|
||||
}
|
||||
|
||||
bool mmc_present(IF_MV_NONVOID(int drive))
|
||||
bool mmc_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);
|
||||
|
@ -1016,3 +1016,17 @@ void mmc_spindown(int seconds)
|
|||
{
|
||||
(void)seconds;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int mmc_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
|
||||
|
|
|
@ -167,7 +167,9 @@ struct bpb
|
|||
* of first pseudo cluster */
|
||||
#endif /* #ifdef HAVE_FAT16SUPPORT */
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
int drive; /* on which physical device is this located */
|
||||
#endif
|
||||
bool mounted; /* flag if this volume is mounted */
|
||||
#endif
|
||||
};
|
||||
|
@ -285,7 +287,7 @@ void fat_init(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector)
|
||||
int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector)
|
||||
{
|
||||
#ifndef HAVE_MULTIVOLUME
|
||||
const int volume = 0;
|
||||
|
@ -309,7 +311,7 @@ int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector)
|
|||
|
||||
memset(fat_bpb, 0, sizeof(struct bpb));
|
||||
fat_bpb->startsector = startsector;
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
fat_bpb->drive = drive;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -31,11 +31,14 @@ unsigned char ramdisk[SECTOR_SIZE * NUM_SECTORS];
|
|||
|
||||
long last_disk_activity = -1;
|
||||
|
||||
int ramdisk_read_sectors(IF_MV2(int drive,)
|
||||
int ramdisk_read_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
if(start+count>NUM_SECTORS)
|
||||
{
|
||||
return -1;
|
||||
|
@ -44,11 +47,14 @@ int ramdisk_read_sectors(IF_MV2(int drive,)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ramdisk_write_sectors(IF_MV2(int drive,)
|
||||
int ramdisk_write_sectors(IF_MD2(int drive,)
|
||||
unsigned long start,
|
||||
int count,
|
||||
const void* buf)
|
||||
{
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
(void)drive; /* unused for now */
|
||||
#endif
|
||||
if(start+count>NUM_SECTORS)
|
||||
{
|
||||
return -1;
|
||||
|
@ -79,13 +85,36 @@ void ramdisk_sleepnow(void)
|
|||
{
|
||||
}
|
||||
|
||||
void ramdisk_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
bool ramdisk_disk_is_active(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int ramdisk_soft_reset(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ramdisk_spinup_time(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ramdisk_spindown(int seconds)
|
||||
{
|
||||
(void)seconds;
|
||||
}
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ramdisk_get_info(IF_MV2(int drive,) struct storage_info *info)
|
||||
void ramdisk_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";
|
||||
|
||||
|
@ -100,3 +129,14 @@ void ramdisk_get_info(IF_MV2(int drive,) struct storage_info *info)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int ramdisk_num_drives(int first_drive)
|
||||
{
|
||||
/* We don't care which logical drive number(s) we have been assigned */
|
||||
(void)first_drive;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ bool ata_disk_is_active(void);
|
|||
int ata_soft_reset(void);
|
||||
int ata_init(void);
|
||||
void ata_close(void);
|
||||
int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
int ata_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int ata_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
void ata_spin(void);
|
||||
#if (CONFIG_LED == LED_REAL)
|
||||
void ata_set_led_enabled(bool enabled);
|
||||
|
@ -48,14 +48,18 @@ void ata_set_led_enabled(bool enabled);
|
|||
unsigned short* ata_get_identify(void);
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ata_get_info(IF_MV2(int drive,) struct storage_info *info);
|
||||
void ata_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool ata_removable(IF_MV_NONVOID(int drive));
|
||||
bool ata_present(IF_MV_NONVOID(int drive));
|
||||
bool ata_removable(IF_MD_NONVOID(int drive));
|
||||
bool ata_present(IF_MD_NONVOID(int drive));
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int ata_num_drives(int first_drive);
|
||||
#endif
|
||||
|
||||
|
||||
long ata_last_disk_activity(void);
|
||||
int ata_spinup_time(void); /* ticks */
|
||||
|
|
|
@ -177,7 +177,8 @@
|
|||
#define FIRMWARE_OFFSET_FILE_DATA 0x8
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
#define HAVE_HOTSWAP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -171,7 +171,8 @@
|
|||
#define FIRMWARE_OFFSET_FILE_DATA 0x8
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
#define HAVE_HOTSWAP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -180,7 +180,8 @@
|
|||
#define FIRMWARE_OFFSET_FILE_DATA 0x8
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
#define HAVE_HOTSWAP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -178,7 +178,8 @@
|
|||
#define FIRMWARE_OFFSET_FILE_DATA 0x8
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
#define HAVE_HOTSWAP
|
||||
#endif
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
//#define HAVE_ATA_SD
|
||||
//#define HAVE_HOTSWAP
|
||||
|
||||
//#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
|
||||
#define CONFIG_STORAGE STORAGE_SD
|
||||
#define CONFIG_STORAGE (STORAGE_NAND | STORAGE_SD)
|
||||
|
||||
/* Support FAT16 for SD cards <= 2GB */
|
||||
#define HAVE_FAT16SUPPORT
|
||||
|
@ -51,6 +50,9 @@
|
|||
/* ChinaChip NAND FTL */
|
||||
#define CONFIG_NAND NAND_CC
|
||||
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
|
||||
/* define this if you have a bitmap LCD display */
|
||||
#define HAVE_LCD_BITMAP
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
|
||||
#define CONFIG_NAND NAND_CC
|
||||
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
|
||||
/* define this if you have a bitmap LCD display */
|
||||
#define HAVE_LCD_BITMAP
|
||||
|
|
|
@ -125,7 +125,8 @@
|
|||
#define HAVE_MAS_SIBI_CONTROL
|
||||
|
||||
/* define this if more than one device/partition can be used */
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
|
||||
/* define this if media can be exchanged on the fly */
|
||||
#define HAVE_HOTSWAP
|
||||
|
|
|
@ -106,7 +106,8 @@
|
|||
#define HAVE_MAS_SIBI_CONTROL
|
||||
|
||||
/* define this if more than one device/partition can be used */
|
||||
#define HAVE_MULTIVOLUME
|
||||
#define HAVE_MULTIDRIVE
|
||||
#define NUM_DRIVES 2
|
||||
|
||||
/* define this if media can be exchanged on the fly */
|
||||
#define HAVE_HOTSWAP
|
||||
|
|
|
@ -539,11 +539,6 @@ Lyre prototype 1*/
|
|||
#define CONFIG_TUNER_MULTI
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0
|
||||
/* Multiple storage drivers */
|
||||
#define CONFIG_STORAGE_MULTI
|
||||
#endif
|
||||
|
||||
/* deactivate fading in bootloader/sim */
|
||||
#if defined(BOOTLOADER) || defined(SIMULATOR)
|
||||
#undef CONFIG_BACKLIGHT_FADING
|
||||
|
@ -571,6 +566,37 @@ Lyre prototype 1*/
|
|||
|
||||
#endif /* CONFIG_BACKLIGHT_FADING */
|
||||
|
||||
/* Storage related config handling */
|
||||
|
||||
#if (CONFIG_STORAGE & (CONFIG_STORAGE - 1)) != 0
|
||||
/* Multiple storage drivers */
|
||||
#define CONFIG_STORAGE_MULTI
|
||||
#endif
|
||||
|
||||
/* Explicit HAVE_MULTIVOLUME in the config file. Allow the maximum number */
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#define NUM_VOLUMES_PER_DRIVE 4
|
||||
#else
|
||||
#define NUM_VOLUMES_PER_DRIVE 1
|
||||
#endif
|
||||
#if defined(CONFIG_STORAGE_MULTI) && !defined(HAVE_MULTIDRIVE)
|
||||
#define HAVE_MULTIDRIVE
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MULTIDRIVE) && !defined(HAVE_MULTIVOLUME)
|
||||
#define HAVE_MULTIVOLUME
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MULTIDRIVE) && !defined(NUM_DRIVES)
|
||||
#error HAVE_MULTIDRIVE needs to have an explicit NUM_DRIVES
|
||||
#endif
|
||||
|
||||
#ifndef NUM_DRIVES
|
||||
#define NUM_DRIVES 1
|
||||
#endif
|
||||
|
||||
#define NUM_VOLUMES (NUM_DRIVES * NUM_VOLUMES_PER_DRIVE)
|
||||
|
||||
#if defined(BOOTLOADER) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
|
||||
/* Bootloaders don't use CPU frequency adjustment */
|
||||
#undef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
|
|
|
@ -35,7 +35,7 @@ struct partinfo {
|
|||
#define PARTITION_TYPE_OS2_HIDDEN_C_DRIVE 0x84
|
||||
|
||||
/* returns a pointer to an array of 8 partinfo structs */
|
||||
struct partinfo* disk_init(IF_MV_NONVOID(int volume));
|
||||
struct partinfo* disk_init(IF_MD_NONVOID(int drive));
|
||||
struct partinfo* disk_partinfo(int partition);
|
||||
int disk_mount_all(void); /* returns the # of successful mounts */
|
||||
int disk_mount(int drive);
|
||||
|
|
|
@ -90,7 +90,7 @@ extern void fat_unlock(void);
|
|||
#endif
|
||||
|
||||
extern void fat_init(void);
|
||||
extern int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector);
|
||||
extern int fat_mount(IF_MV2(int volume,) IF_MD2(int drive,) long startsector);
|
||||
extern int fat_unmount(int volume, bool flush);
|
||||
extern void fat_size(IF_MV2(int volume,) /* public for info */
|
||||
unsigned long* size,
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __MMC_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "mv.h" /* for HAVE_MULTIVOLUME or not */
|
||||
#include "mv.h" /* for HAVE_MULTIDRIVE or not */
|
||||
|
||||
struct storage_info;
|
||||
|
||||
|
@ -35,19 +35,24 @@ bool mmc_disk_is_active(void);
|
|||
int mmc_soft_reset(void);
|
||||
int mmc_init(void);
|
||||
void mmc_close(void);
|
||||
int mmc_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
int mmc_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
int mmc_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int mmc_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
void mmc_spin(void);
|
||||
int mmc_spinup_time(void);
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void mmc_get_info(IF_MV2(int drive,) struct storage_info *info);
|
||||
void mmc_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool mmc_removable(IF_MV_NONVOID(int drive));
|
||||
bool mmc_present(IF_MV_NONVOID(int drive));
|
||||
bool mmc_removable(IF_MD_NONVOID(int drive));
|
||||
bool mmc_present(IF_MD_NONVOID(int drive));
|
||||
#endif
|
||||
|
||||
long mmc_last_disk_activity(void);
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int mmc_num_drives(int first_drive);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,16 +26,28 @@
|
|||
|
||||
/* FixMe: These macros are a bit nasty and perhaps misplaced here.
|
||||
We'll get rid of them once decided on how to proceed with multivolume. */
|
||||
|
||||
/* Drives are things like a disk, a card, a flash chip. They can have volumes on them */
|
||||
#ifdef HAVE_MULTIDRIVE
|
||||
#define IF_MD(x) x /* optional drive parameter */
|
||||
#define IF_MD2(x,y) x,y /* same, for a list of arguments */
|
||||
#define IF_MD_NONVOID(x) x /* for prototype with sole volume parameter */
|
||||
#else /* empty definitions if no multi-drive */
|
||||
#define IF_MD(x)
|
||||
#define IF_MD2(x,y)
|
||||
#define IF_MD_NONVOID(x) void
|
||||
#endif
|
||||
|
||||
/* Volumes mean things that have filesystems on them, like partitions */
|
||||
#ifdef HAVE_MULTIVOLUME
|
||||
#define IF_MV(x) x /* optional volume/drive parameter */
|
||||
#define IF_MV(x) x /* optional volume parameter */
|
||||
#define IF_MV2(x,y) x,y /* same, for a list of arguments */
|
||||
#define IF_MV_NONVOID(x) x /* for prototype with sole volume parameter */
|
||||
#define NUM_VOLUMES 2
|
||||
#else /* empty definitions if no multi-volume */
|
||||
#define IF_MV(x)
|
||||
#define IF_MV2(x,y)
|
||||
#define IF_MV_NONVOID(x) void
|
||||
#define NUM_VOLUMES 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,25 +23,31 @@
|
|||
#define __NAND_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "mv.h" /* for HAVE_MULTIVOLUME or not */
|
||||
#include "mv.h" /* for HAVE_MULTIDRIVE or not */
|
||||
|
||||
struct storage_info;
|
||||
|
||||
void nand_enable(bool on);
|
||||
void nand_spindown(int seconds);
|
||||
void nand_sleep(void);
|
||||
void nand_sleepnow(void);
|
||||
bool nand_disk_is_active(void);
|
||||
int nand_soft_reset(void);
|
||||
int nand_init(void);
|
||||
int nand_soft_reset(void);
|
||||
int nand_init(void);
|
||||
void nand_close(void);
|
||||
int nand_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
int nand_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
int nand_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int nand_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
void nand_spin(void);
|
||||
int nand_spinup_time(void); /* ticks */
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void nand_get_info(IF_MV2(int drive,) struct storage_info *info);
|
||||
void nand_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
|
||||
long nand_last_disk_activity(void);
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int nand_num_drives(int first_drive);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __RAMDISK_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "mv.h" /* for HAVE_MULTIVOLUME or not */
|
||||
#include "mv.h" /* for HAVE_MULTIDRIVE or not */
|
||||
|
||||
struct storage_info;
|
||||
|
||||
|
@ -34,15 +34,20 @@ bool ramdisk_disk_is_active(void);
|
|||
int ramdisk_soft_reset(void);
|
||||
int ramdisk_init(void);
|
||||
void ramdisk_close(void);
|
||||
int ramdisk_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
int ramdisk_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
int ramdisk_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int ramdisk_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
void ramdisk_spin(void);
|
||||
void ramdisk_sleepnow(void);
|
||||
int ramdisk_spinup_time(void);
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void ramdisk_get_info(IF_MV2(int drive,) struct storage_info *info);
|
||||
void ramdisk_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
|
||||
long ramdisk_last_disk_activity(void);
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int ramdisk_num_drives(int first_drive);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __SD_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "mv.h" /* for HAVE_MULTIVOLUME or not */
|
||||
#include "mv.h" /* for HAVE_MULTIDRIVE or not */
|
||||
|
||||
#define SD_BLOCK_SIZE 512 /* XXX : support other sizes ? */
|
||||
|
||||
|
@ -32,27 +32,34 @@ struct storage_info;
|
|||
void sd_enable(bool on);
|
||||
void sd_spindown(int seconds);
|
||||
void sd_sleep(void);
|
||||
void sd_sleepnow(void);
|
||||
bool sd_disk_is_active(void);
|
||||
int sd_soft_reset(void);
|
||||
int sd_init(void);
|
||||
int sd_soft_reset(void);
|
||||
int sd_init(void);
|
||||
void sd_close(void);
|
||||
int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf);
|
||||
int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf);
|
||||
int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, void* buf);
|
||||
int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, const void* buf);
|
||||
void sd_spin(void);
|
||||
int sd_spinup_time(void); /* ticks */
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void sd_get_info(IF_MV2(int drive,) struct storage_info *info);
|
||||
void sd_get_info(IF_MD2(int drive,) struct storage_info *info);
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool sd_removable(IF_MV_NONVOID(int drive));
|
||||
bool sd_present(IF_MV_NONVOID(int drive));
|
||||
void card_enable_monitoring_target(bool on);
|
||||
void card_enable_monitoring_target(bool on);
|
||||
#endif
|
||||
|
||||
bool card_detect_target(void);
|
||||
bool card_detect_target(void);
|
||||
|
||||
long sd_last_disk_activity(void);
|
||||
|
||||
#ifdef CONFIG_STORAGE_MULTI
|
||||
int sd_num_drives(int first_drive);
|
||||
#endif
|
||||
|
||||
|
||||
/* SD States */
|
||||
#define SD_IDLE 0
|
||||
#define SD_READY 1
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define __STORAGE_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "config.h" /* for HAVE_MULTIVOLUME or not */
|
||||
#include "config.h" /* for HAVE_MULTIDRIVE or not */
|
||||
#include "mv.h"
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
|
@ -51,154 +51,147 @@ struct storage_info
|
|||
char *revision;
|
||||
};
|
||||
|
||||
#ifndef SIMULATOR
|
||||
#ifndef CONFIG_STORAGE_MULTI
|
||||
/* storage_spindown, storage_sleep and storage_spin are passed as
|
||||
* pointers, which doesn't work with argument-macros.
|
||||
*/
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
#define storage_spindown ata_spindown
|
||||
#define storage_sleep ata_sleep
|
||||
#define storage_spin ata_spin
|
||||
|
||||
#define storage_enable(on) ata_enable(on)
|
||||
#define storage_sleepnow() ata_sleepnow()
|
||||
#define storage_disk_is_active() ata_disk_is_active()
|
||||
#define storage_soft_reset() ata_soft_reset()
|
||||
#define storage_init() ata_init()
|
||||
#define storage_close() ata_close()
|
||||
#define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() ata_last_disk_activity()
|
||||
#define storage_spinup_time() ata_spinup_time()
|
||||
#define storage_get_identify() ata_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) ata_get_info(IF_MV2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) ata_removable(IF_MV(drive))
|
||||
#define storage_present(drive) ata_present(IF_MV(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_SD)
|
||||
#define storage_spindown sd_spindown
|
||||
#define storage_sleep sd_sleep
|
||||
#define storage_spin sd_spin
|
||||
|
||||
#define storage_enable(on) sd_enable(on)
|
||||
#define storage_sleepnow() sd_sleepnow()
|
||||
#define storage_disk_is_active() 0
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() sd_init()
|
||||
#define storage_close() sd_close()
|
||||
#define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() sd_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() sd_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) sd_get_info(IF_MV2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) sd_removable(IF_MV(drive))
|
||||
#define storage_present(drive) sd_present(IF_MV(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_MMC)
|
||||
#define storage_spindown mmc_spindown
|
||||
#define storage_sleep mmc_sleep
|
||||
#define storage_spin mmc_spin
|
||||
|
||||
#define storage_enable(on) mmc_enable(on)
|
||||
#define storage_sleepnow() mmc_sleepnow()
|
||||
#define storage_disk_is_active() mmc_disk_is_active()
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() mmc_init()
|
||||
#define storage_close() mmc_close()
|
||||
#define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() mmc_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() mmc_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) mmc_get_info(IF_MV2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) mmc_removable(IF_MV(drive))
|
||||
#define storage_present(drive) mmc_present(IF_MV(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_NAND)
|
||||
#define storage_spindown nand_spindown
|
||||
#define storage_sleep nand_sleep
|
||||
#define storage_spin nand_spin
|
||||
|
||||
#define storage_enable(on) (void)0
|
||||
#define storage_sleepnow() nand_sleepnow()
|
||||
#define storage_disk_is_active() 0
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() nand_init()
|
||||
#define storage_close() nand_close()
|
||||
#define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() nand_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() nand_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) nand_get_info(IF_MV2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) nand_removable(IF_MV(drive))
|
||||
#define storage_present(drive) nand_present(IF_MV(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
#define storage_spindown ramdisk_spindown
|
||||
#define storage_sleep ramdisk_sleep
|
||||
#define storage_spin ramdisk_spin
|
||||
|
||||
#define storage_enable(on) (void)0
|
||||
#define storage_sleepnow() ramdisk_sleepnow()
|
||||
#define storage_disk_is_active() 0
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() ramdisk_init()
|
||||
#define storage_close() ramdisk_close()
|
||||
#define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MV2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() ramdisk_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() ramdisk_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) ramdisk_get_info(IF_MV2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) ramdisk_removable(IF_MV(drive))
|
||||
#define storage_present(drive) ramdisk_present(IF_MV(drive))
|
||||
#endif
|
||||
#else
|
||||
//#error No storage driver!
|
||||
#endif
|
||||
#else /* NOT CONFIG_STORAGE_MULTI */
|
||||
|
||||
/* TODO : implement multi-driver here */
|
||||
#error Multi-driver storage not implemented yet
|
||||
|
||||
#endif /* NOT CONFIG_STORAGE_MULTI */
|
||||
#else /*NOT SIMULATOR */
|
||||
#if !defined(SIMULATOR) && !defined(CONFIG_STORAGE_MULTI)
|
||||
/* storage_spindown, storage_sleep and storage_spin are passed as
|
||||
* pointers, which doesn't work with argument-macros.
|
||||
*/
|
||||
#define storage_num_drives() NUM_DRIVES
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
#define storage_spindown ata_spindown
|
||||
#define storage_sleep ata_sleep
|
||||
#define storage_spin ata_spin
|
||||
|
||||
#define storage_enable(on) ata_enable(on)
|
||||
#define storage_sleepnow() ata_sleepnow()
|
||||
#define storage_disk_is_active() ata_disk_is_active()
|
||||
#define storage_soft_reset() ata_soft_reset()
|
||||
#define storage_init() ata_init()
|
||||
#define storage_close() ata_close()
|
||||
#define storage_read_sectors(drive, start, count, buf) ata_read_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) ata_write_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() ata_last_disk_activity()
|
||||
#define storage_spinup_time() ata_spinup_time()
|
||||
#define storage_get_identify() ata_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) ata_get_info(IF_MD2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) ata_removable(IF_MD(drive))
|
||||
#define storage_present(drive) ata_present(IF_MD(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_SD)
|
||||
#define storage_spindown sd_spindown
|
||||
#define storage_sleep sd_sleep
|
||||
#define storage_spin sd_spin
|
||||
|
||||
#define storage_enable(on) sd_enable(on)
|
||||
#define storage_sleepnow() sd_sleepnow()
|
||||
#define storage_disk_is_active() 0
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() sd_init()
|
||||
#define storage_read_sectors(drive, start, count, buf) sd_read_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) sd_write_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() sd_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() sd_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) sd_get_info(IF_MD2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) sd_removable(IF_MD(drive))
|
||||
#define storage_present(drive) sd_present(IF_MD(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_MMC)
|
||||
#define storage_spindown mmc_spindown
|
||||
#define storage_sleep mmc_sleep
|
||||
#define storage_spin mmc_spin
|
||||
|
||||
#define storage_enable(on) mmc_enable(on)
|
||||
#define storage_sleepnow() mmc_sleepnow()
|
||||
#define storage_disk_is_active() mmc_disk_is_active()
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() mmc_init()
|
||||
#define storage_read_sectors(drive, start, count, buf) mmc_read_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) mmc_write_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() mmc_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() mmc_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) mmc_get_info(IF_MD2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) mmc_removable(IF_MD(drive))
|
||||
#define storage_present(drive) mmc_present(IF_MD(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_NAND)
|
||||
#define storage_spindown nand_spindown
|
||||
#define storage_sleep nand_sleep
|
||||
#define storage_spin nand_spin
|
||||
|
||||
#define storage_enable(on) (void)0
|
||||
#define storage_sleepnow() nand_sleepnow()
|
||||
#define storage_disk_is_active() 0
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() nand_init()
|
||||
#define storage_read_sectors(drive, start, count, buf) nand_read_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) nand_write_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() nand_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() nand_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) nand_get_info(IF_MD2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) nand_removable(IF_MD(drive))
|
||||
#define storage_present(drive) nand_present(IF_MD(drive))
|
||||
#endif
|
||||
#elif (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
#define storage_spindown ramdisk_spindown
|
||||
#define storage_sleep ramdisk_sleep
|
||||
#define storage_spin ramdisk_spin
|
||||
|
||||
#define storage_enable(on) (void)0
|
||||
#define storage_sleepnow() ramdisk_sleepnow()
|
||||
#define storage_disk_is_active() 0
|
||||
#define storage_soft_reset() (void)0
|
||||
#define storage_init() ramdisk_init()
|
||||
#define storage_read_sectors(drive, start, count, buf) ramdisk_read_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_write_sectors(drive, start, count, buf) ramdisk_write_sectors(IF_MD2(drive,) start, count, buf)
|
||||
#define storage_last_disk_activity() ramdisk_last_disk_activity()
|
||||
#define storage_spinup_time() 0
|
||||
#define storage_get_identify() ramdisk_get_identify()
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
#define storage_get_info(drive, info) ramdisk_get_info(IF_MD2(drive,) info)
|
||||
#endif
|
||||
#ifdef HAVE_HOTSWAP
|
||||
#define storage_removable(drive) ramdisk_removable(IF_MD(drive))
|
||||
#define storage_present(drive) ramdisk_present(IF_MD(drive))
|
||||
#endif
|
||||
#else
|
||||
//#error No storage driver!
|
||||
#endif
|
||||
#else /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
|
||||
|
||||
/* Simulator and multi-driver use normal functions */
|
||||
|
||||
void storage_enable(bool on);
|
||||
void storage_sleep(void);
|
||||
void storage_sleepnow(void);
|
||||
bool storage_disk_is_active(void);
|
||||
int storage_soft_reset(void);
|
||||
int storage_init(void);
|
||||
void storage_close(void);
|
||||
int storage_read_sectors(int drive, unsigned long start, int count, void* buf);
|
||||
int storage_write_sectors(int drive, unsigned long start, int count, const void* buf);
|
||||
void storage_spin(void);
|
||||
void storage_spindown(int seconds);
|
||||
long storage_last_disk_activity(void);
|
||||
int storage_spinup_time(void);
|
||||
int storage_num_drives(void);
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void storage_get_info(int drive, struct storage_info *info);
|
||||
#endif
|
||||
|
@ -206,5 +199,6 @@ void storage_get_info(int drive, struct storage_info *info);
|
|||
bool storage_removable(int drive);
|
||||
bool storage_present(int drive);
|
||||
#endif
|
||||
#endif/*NOT SIMULATOR */
|
||||
|
||||
#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
|
||||
#endif
|
||||
|
|
545
firmware/storage.c
Normal file
545
firmware/storage.c
Normal file
|
@ -0,0 +1,545 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id: buffer.c 17847 2008-06-28 18:10:04Z bagder $
|
||||
*
|
||||
* Copyright (C) 2008 by Frank Gevaerts
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "storage.h"
|
||||
|
||||
#define DRIVER_MASK 0xff000000
|
||||
#define DRIVER_OFFSET 24
|
||||
#define DRIVE_MASK 0x00ff0000
|
||||
#define DRIVE_OFFSET 16
|
||||
#define PARTITION_MASK 0x0000ff00
|
||||
|
||||
static unsigned int storage_drivers[NUM_DRIVES];
|
||||
static unsigned int num_drives;
|
||||
|
||||
int storage_num_drives(void)
|
||||
{
|
||||
return num_drives;
|
||||
}
|
||||
|
||||
int storage_init(void)
|
||||
{
|
||||
int rc=0;
|
||||
int i;
|
||||
num_drives=0;
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
if ((rc=ata_init())) return rc;
|
||||
|
||||
int ata_drives = ata_num_drives(num_drives);
|
||||
for (i=0; i<ata_drives; i++)
|
||||
{
|
||||
storage_drivers[num_drives++] =
|
||||
(STORAGE_ATA<<DRIVER_OFFSET) | (i << DRIVE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
if ((rc=mmc_init())) return rc;
|
||||
|
||||
int mmc_drives = mmc_num_drives(num_drives);
|
||||
for (i=0; i<mmc_drives ;i++)
|
||||
{
|
||||
storage_drivers[num_drives++] =
|
||||
(STORAGE_MMC<<DRIVER_OFFSET) | (i << DRIVE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
if ((rc=sd_init())) return rc;
|
||||
|
||||
int sd_drives = sd_num_drives(num_drives);
|
||||
for (i=0; i<sd_drives; i++)
|
||||
{
|
||||
storage_drivers[num_drives++] =
|
||||
(STORAGE_SD<<DRIVER_OFFSET) | (i << DRIVE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
if ((rc=nand_init())) return rc;
|
||||
|
||||
int nand_drives = nand_num_drives(num_drives);
|
||||
for (i=0; i<nand_drives; i++)
|
||||
{
|
||||
storage_drivers[num_drives++] =
|
||||
(STORAGE_NAND<<DRIVER_OFFSET) | (i << DRIVE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
if ((rc=ramdisk_init())) return rc;
|
||||
|
||||
int ramdisk_drives = ramdisk_num_drives(num_drives);
|
||||
for (i=0; i<ramdisk_drives; i++)
|
||||
{
|
||||
storage_drivers[num_drives++] =
|
||||
(STORAGE_RAMDISK<<DRIVER_OFFSET) | (i << DRIVE_OFFSET);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int storage_read_sectors(int drive, unsigned long start, int count,
|
||||
void* buf)
|
||||
{
|
||||
int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
|
||||
int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;
|
||||
|
||||
switch (driver)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
return ata_read_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
return mmc_read_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
return sd_read_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
return nand_read_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
return ramdisk_read_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int storage_write_sectors(int drive, unsigned long start, int count,
|
||||
const void* buf)
|
||||
{
|
||||
int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
|
||||
int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;
|
||||
|
||||
switch (driver)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
return ata_write_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
return mmc_write_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
return sd_write_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
return nand_write_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
return ramdisk_write_sectors(ldrive,start,count,buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void storage_enable(bool on)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
ata_enable(on);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
mmc_enable(on);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
sd_enable(on);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
nand_enable(on);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
ramdisk_enable(on);
|
||||
#endif
|
||||
}
|
||||
|
||||
void storage_sleep(void)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
ata_sleep();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
mmc_sleep();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
sd_sleep();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
nand_sleep();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
ramdisk_sleep();
|
||||
#endif
|
||||
}
|
||||
|
||||
void storage_sleepnow(void)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
ata_sleepnow();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
mmc_sleepnow();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
//sd_sleepnow();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
nand_sleepnow();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
ramdisk_sleepnow();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool storage_disk_is_active(void)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
if (ata_disk_is_active()) return true;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
if (mmc_disk_is_active()) return true;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
//if (sd_disk_is_active()) return true;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
if (nand_disk_is_active()) return true;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
if (ramdisk_disk_is_active()) return true;
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int storage_soft_reset(void)
|
||||
{
|
||||
int rc=0;
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
if ((rc=ata_soft_reset())) return rc;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
if ((rc=mmc_soft_reset())) return rc;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
//if ((rc=sd_soft_reset())) return rc;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
if ((rc=nand_soft_reset())) return rc;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
if ((rc=ramdisk_soft_reset())) return rc;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void storage_spin(void)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
ata_spin();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
mmc_spin();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
sd_spin();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
nand_spin();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
ramdisk_spin();
|
||||
#endif
|
||||
}
|
||||
|
||||
void storage_spindown(int seconds)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
ata_spindown(seconds);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
mmc_spindown(seconds);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
sd_spindown(seconds);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
nand_spindown(seconds);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
ramdisk_spindown(seconds);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (CONFIG_LED == LED_REAL)
|
||||
void storage_set_led_enabled(bool enabled)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
ata_set_led_enabled(enabled);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
mmc_set_led_enabled(enabled);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
sd_set_led_enabled(enabled);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
nand_set_led_enabled(enabled);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
ramdisk_set_led_enabled(enabled);
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_LED == LED_REAL */
|
||||
|
||||
long storage_last_disk_activity(void)
|
||||
{
|
||||
long max=0;
|
||||
long t;
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
t=ata_last_disk_activity();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
t=mmc_last_disk_activity();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
t=sd_last_disk_activity();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
t=nand_last_disk_activity();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
t=ramdisk_last_disk_activity();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
int storage_spinup_time(void)
|
||||
{
|
||||
int max=0;
|
||||
int t;
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
t=ata_spinup_time();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
t=mmc_spinup_time();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
//t=sd_spinup_time();
|
||||
//if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
t=nand_spinup_time();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
t=ramdisk_spinup_time();
|
||||
if (t>max) max=t;
|
||||
#endif
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void storage_get_info(int drive, struct storage_info *info)
|
||||
{
|
||||
int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
|
||||
int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;
|
||||
|
||||
switch(driver)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
return ata_get_info(ldrive,info);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
return mmc_get_info(ldrive,info);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
return sd_get_info(ldrive,info);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
return nand_get_info(ldrive,info);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
return ramdisk_get_info(ldrive,info);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* STORAGE_GET_INFO */
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool storage_removable(int drive)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
|
||||
int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;
|
||||
|
||||
switch(driver)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
ret = ata_removable(ldrive);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
ret = mmc_removable(ldrive);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
ret = sd_removable(ldrive);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
ret = false;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
ret = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool storage_present(int drive)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
int driver=(storage_drivers[drive] & DRIVER_MASK)>>DRIVER_OFFSET;
|
||||
int ldrive=(storage_drivers[drive] & DRIVE_MASK)>>DRIVE_OFFSET;
|
||||
|
||||
switch(driver)
|
||||
{
|
||||
#if (CONFIG_STORAGE & STORAGE_ATA)
|
||||
case STORAGE_ATA:
|
||||
ret = ata_present(ldrive);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_MMC)
|
||||
case STORAGE_MMC:
|
||||
ret = mmc_present(ldrive);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_SD)
|
||||
case STORAGE_SD:
|
||||
ret = sd_present(ldrive);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_NAND)
|
||||
case STORAGE_NAND:
|
||||
ret = true;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
||||
case STORAGE_RAMDISK:
|
||||
ret = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
|
@ -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
|
||||
|
|
|
@ -707,6 +707,21 @@ void nand_enable(bool on)
|
|||
(void)on;
|
||||
}
|
||||
|
||||
/* TODO */
|
||||
long nand_last_disk_activity(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nand_spinup_time(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nand_sleepnow(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef STORAGE_GET_INFO
|
||||
void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
|
||||
{
|
||||
|
@ -725,3 +740,13 @@ void nand_get_info(IF_MV2(int drive,) struct storage_info *info)
|
|||
info->sector_size = 512;
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
|
|
@ -1328,6 +1328,31 @@ long sd_last_disk_activity(void)
|
|||
return last_disk_activity;
|
||||
}
|
||||
|
||||
int sd_spinup_time(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sd_enable(bool on)
|
||||
{
|
||||
(void)on;
|
||||
}
|
||||
|
||||
void sd_sleepnow(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* TODO */
|
||||
bool sd_disk_is_active(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int sd_soft_reset(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_HOTSWAP
|
||||
bool sd_removable(IF_MV_NONVOID(int drive))
|
||||
{
|
||||
|
@ -1346,3 +1371,13 @@ bool sd_present(IF_MV_NONVOID(int drive))
|
|||
#endif
|
||||
return (card.numblocks > 0 && card_detect_target());
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -696,7 +696,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
) {
|
||||
DEBUGF("*** Mounting at block %ld\n",pinfo[i].start);
|
||||
rc = fat_mount(IF_MV2(0,) IF_MV2(0,) pinfo[i].start);
|
||||
rc = fat_mount(IF_MV2(0,) IF_MD2(0,) pinfo[i].start);
|
||||
if(rc) {
|
||||
DEBUGF("mount: %d",rc);
|
||||
return -1;
|
||||
|
@ -705,7 +705,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
if ( i==4 ) {
|
||||
if(fat_mount(IF_MV2(0,) IF_MV2(0,) 0)) {
|
||||
if(fat_mount(IF_MV2(0,) IF_MD2(0,) 0)) {
|
||||
DEBUGF("No FAT32 partition!");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -642,7 +642,7 @@ int main(void)
|
|||
|
||||
|
||||
|
||||
i = fat_mount(IF_MV2(0,) IF_MV2(0,) part[0].start);
|
||||
i = fat_mount(IF_MV2(0,) IF_MD2(0,) part[0].start);
|
||||
|
||||
debugf("fat_mount() returned %d\n", i);
|
||||
|
||||
|
|
|
@ -153,8 +153,7 @@ struct inquiry_data {
|
|||
struct report_lun_data {
|
||||
unsigned int lun_list_length;
|
||||
unsigned int reserved1;
|
||||
// TODO this should be cleaned up with the VOLUMES vs DRIVES mess
|
||||
unsigned char luns[NUM_VOLUMES][8];
|
||||
unsigned char luns[NUM_DRIVES][8];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct sense_data {
|
||||
|
@ -271,10 +270,10 @@ static void send_command_result(void *data,int size);
|
|||
static void send_command_failed_result(void);
|
||||
static void send_block_data(void *data,int size);
|
||||
static void receive_block_data(void *data,int size);
|
||||
static void fill_inquiry(IF_MV_NONVOID(int lun));
|
||||
static void fill_inquiry(IF_MD_NONVOID(int lun));
|
||||
static void send_and_read_next(void);
|
||||
static bool ejected[NUM_VOLUMES];
|
||||
static bool locked[NUM_VOLUMES];
|
||||
static bool ejected[NUM_DRIVES];
|
||||
static bool locked[NUM_DRIVES];
|
||||
|
||||
static int usb_interface;
|
||||
static int ep_in, ep_out;
|
||||
|
@ -309,7 +308,7 @@ static void fix_mbr(unsigned char* mbr)
|
|||
}
|
||||
#endif
|
||||
|
||||
static bool check_disk_present(IF_MV_NONVOID(int volume))
|
||||
static bool check_disk_present(IF_MD_NONVOID(int volume))
|
||||
{
|
||||
#ifdef USB_USE_RAMDISK
|
||||
return true;
|
||||
|
@ -325,7 +324,7 @@ void usb_storage_try_release_storage(void)
|
|||
release excusive access */
|
||||
bool canrelease=true;
|
||||
int i;
|
||||
for(i=0;i<NUM_VOLUMES;i++) {
|
||||
for(i=0;i<storage_num_drives();i++) {
|
||||
if(ejected[i]==false && locked[i]==true) {
|
||||
canrelease=false;
|
||||
break;
|
||||
|
@ -341,7 +340,7 @@ void usb_storage_try_release_storage(void)
|
|||
void usb_storage_notify_hotswap(int volume,bool inserted)
|
||||
{
|
||||
logf("notify %d",inserted);
|
||||
if(inserted && check_disk_present(IF_MV(volume))) {
|
||||
if(inserted && check_disk_present(IF_MD(volume))) {
|
||||
ejected[volume] = false;
|
||||
}
|
||||
else {
|
||||
|
@ -436,7 +435,7 @@ void usb_storage_init_connection(void)
|
|||
usb_drv_recv(ep_out, cbw_buffer, 1024);
|
||||
|
||||
int i;
|
||||
for(i=0;i<NUM_VOLUMES;i++) {
|
||||
for(i=0;i<storage_num_drives();i++) {
|
||||
#ifdef TOSHIBA_GIGABEAT_S
|
||||
/* As long as the Gigabeat S is a non-removable device, we need
|
||||
to mark the device as locked to avoid usb_storage_try_release_ata()
|
||||
|
@ -445,7 +444,7 @@ void usb_storage_init_connection(void)
|
|||
#else
|
||||
locked[i] = false;
|
||||
#endif
|
||||
ejected[i] = !check_disk_present(IF_MV(i));
|
||||
ejected[i] = !check_disk_present(IF_MD(i));
|
||||
queue_broadcast(SYS_USB_LUN_LOCKED, (i<<16)+0);
|
||||
}
|
||||
}
|
||||
|
@ -614,10 +613,9 @@ bool usb_storage_control_request(struct usb_ctrlrequest* req, unsigned char* des
|
|||
(void)dest;
|
||||
switch (req->bRequest) {
|
||||
case USB_BULK_GET_MAX_LUN: {
|
||||
#ifdef ONLY_EXPOSE_CARD_SLOT
|
||||
*tb.max_lun = 0;
|
||||
#else
|
||||
*tb.max_lun = NUM_VOLUMES - 1;
|
||||
*tb.max_lun = storage_num_drives() - 1;
|
||||
#ifdef HIDE_FIRST_DRIVE
|
||||
*tb.max_lun --;
|
||||
#endif
|
||||
logf("ums: getmaxlun");
|
||||
usb_drv_send(EP_CONTROL, tb.max_lun, 1);
|
||||
|
@ -690,12 +688,12 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
|||
unsigned int block_size = 0;
|
||||
unsigned int block_count = 0;
|
||||
bool lun_present=true;
|
||||
#ifdef ONLY_EXPOSE_CARD_SLOT
|
||||
unsigned char lun = cbw->lun+1;
|
||||
#else
|
||||
unsigned char lun = cbw->lun;
|
||||
#endif
|
||||
unsigned int block_size_mult = 1;
|
||||
#ifdef HIDE_FIRST_DRIVE
|
||||
lun++;
|
||||
#endif
|
||||
|
||||
storage_get_info(lun,&info);
|
||||
#ifdef USB_USE_RAMDISK
|
||||
block_size = SECTOR_SIZE;
|
||||
|
@ -747,13 +745,14 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
|||
logf("scsi report luns %d",lun);
|
||||
int allocation_length=0;
|
||||
int i;
|
||||
unsigned int response_length = 8+8*storage_num_drives();
|
||||
allocation_length|=(cbw->command_block[6]<<24);
|
||||
allocation_length|=(cbw->command_block[7]<<16);
|
||||
allocation_length|=(cbw->command_block[8]<<8);
|
||||
allocation_length|=(cbw->command_block[9]);
|
||||
memset(tb.lun_data,0,sizeof(struct report_lun_data));
|
||||
tb.lun_data->lun_list_length=htobe32(8*NUM_VOLUMES);
|
||||
for(i=0;i<NUM_VOLUMES;i++)
|
||||
tb.lun_data->lun_list_length=htobe32(8*storage_num_drives());
|
||||
for(i=0;i<storage_num_drives();i++)
|
||||
{
|
||||
#ifdef HAVE_HOTSWAP
|
||||
if(storage_removable(i))
|
||||
|
@ -763,13 +762,13 @@ static void handle_scsi(struct command_block_wrapper* cbw)
|
|||
tb.lun_data->luns[i][1]=0;
|
||||
}
|
||||
send_command_result(tb.lun_data,
|
||||
MIN(sizeof(struct report_lun_data), length));
|
||||
MIN(response_length, length));
|
||||
break;
|
||||
}
|
||||
|
||||
case SCSI_INQUIRY:
|
||||
logf("scsi inquiry %d",lun);
|
||||
fill_inquiry(IF_MV(lun));
|
||||
fill_inquiry(IF_MD(lun));
|
||||
length = MIN(length, cbw->command_block[4]);
|
||||
send_command_result(tb.inquiry,
|
||||
MIN(sizeof(struct inquiry_data), length));
|
||||
|
@ -1136,7 +1135,7 @@ static void copy_padded(char *dest, char *src, int len)
|
|||
}
|
||||
|
||||
/* build SCSI INQUIRY */
|
||||
static void fill_inquiry(IF_MV_NONVOID(int lun))
|
||||
static void fill_inquiry(IF_MD_NONVOID(int lun))
|
||||
{
|
||||
struct storage_info info;
|
||||
memset(tb.inquiry, 0, sizeof(struct inquiry_data));
|
||||
|
|
Loading…
Reference in a new issue