mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
* Create new 'sector_t' type alias: * uint64_t for all targets with HAVE_LBA48 or HAVE_SDUC * unsigned long for the everything else * Alter all storage APIs to use sector_t instead of 'unsigned long' * Alter Volume/Partition/storage info structures to use sector_t * Disk cache converted to sector_t * ATA Core: * convert to using sector_t for sector addresses and drive sizes * Always fill out upper 16 bits of LBA48 addresses * IDENTIFY INFO is fixed at 512 bytes, not SECTOR_SIZE * USB mass storage: * convert to using sector_t for sector addesses and drive sizes * Implement READ_16/WRITE_16 for LBA48 addresses * Convert FAT code to use sector_t for all sector references * output_dyn_value() now accepts int64_t instead of 'int' * Corrected "rockbox info" to work for (MULTIVOLUME & !MULTIDRIVE) * Better reporting of disk and (logical+physical) sector sizes in debug info * Detect SDUC cards and report on storage debug_info screen To-do: SDUC * Refactor SD core to remove duplicate code in every driver * Card probe and init state machine * Implement core SDUC support * SD2.0 needs to be 2.0+ (fixed for jz47xx and x1000) * Host and Card ID (ACMD41) * 32-bit addressing for all read/write/erase operations (CMD22) * ADD SDUC to target device drivers, defining HAVE_SDUC as appropriate Change-Id: Ib0138781a0081664d11511037685503df1b93608
154 lines
4.7 KiB
C
154 lines
4.7 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* 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.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#ifndef __MV_H__
|
|
#define __MV_H__
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include "config.h"
|
|
|
|
/* 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 /* valist contents or empty */
|
|
#define IF_MD_NONVOID(x...) x /* valist contents or 'void' */
|
|
#define IF_MD_DRV(d) d /* drive argument or '0' */
|
|
#else /* empty definitions if no multi-drive */
|
|
#define IF_MD(x...)
|
|
#define IF_MD_NONVOID(x...) void
|
|
#define IF_MD_DRV(d) 0
|
|
#endif /* HAVE_MULTIDRIVE */
|
|
|
|
/* Storage size */
|
|
#if (CONFIG_STORAGE & STORAGE_ATA) && defined(HAVE_LBA48)
|
|
typedef uint64_t sector_t;
|
|
#define STORAGE_64BIT_SECTOR
|
|
#elif (CONFIG_STORAGE & STORAGE_SD) && defined(HAVE_SDUC)
|
|
typedef uint64_t sector_t;
|
|
#define STORAGE_64BIT_SECTOR
|
|
#else
|
|
typedef unsigned long sector_t;
|
|
#undef STORAGE_64BIT_SECTOR
|
|
#endif
|
|
|
|
|
|
/* Volumes mean things that have filesystems on them, like partitions */
|
|
#ifdef HAVE_MULTIVOLUME
|
|
#define IF_MV(x...) x /* valist contents or empty */
|
|
#define IF_MV_NONVOID(x...) x /* valist contents or 'void' */
|
|
#define IF_MV_VOL(v) v /* volume argument or '0' */
|
|
|
|
/* Format: "/<DEC###>/foo/bar"
|
|
* The "DEC" is pure decoration and treated as a comment. Only an unbroken
|
|
* trailing string of digits within the brackets is parsed as the volume
|
|
* number.
|
|
*
|
|
* IMPORTANT!: Adjust VOL_DEC_MAX_LEN if needed to the longest of these
|
|
*/
|
|
#define DEFAULT_VOL_DEC "Volume"
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA)
|
|
#define ATA_VOL_DEC "HDD"
|
|
#endif
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
#define MMC_VOL_DEC "MMC"
|
|
#endif
|
|
#if (CONFIG_STORAGE & STORAGE_SD)
|
|
#define SD_VOL_DEC "microSD"
|
|
#endif
|
|
#if (CONFIG_STORAGE & STORAGE_NAND)
|
|
#define NAND_VOL_DEC "NAND"
|
|
#endif
|
|
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
|
#define RAMDISK_VOL_DEC "RAMDisk"
|
|
#endif
|
|
#if (CONFIG_STORAGE & STORAGE_USB)
|
|
#define USB_VOL_DEC "USB"
|
|
#endif
|
|
#if (CONFIG_STORAGE & STORAGE_HOSTFS)
|
|
#ifndef HOSTFS_VOL_DEC /* overridable */
|
|
#define HOSTFS_VOL_DEC DEFAULT_VOL_DEC
|
|
#endif
|
|
#endif
|
|
|
|
/* Characters that delimit a volume specifier at any root point in the path.
|
|
The tokens must be outside of legal filename characters */
|
|
#define VOL_START_TOK '<'
|
|
#define VOL_END_TOK '>'
|
|
#define VOL_DEC_MAX_LEN 7 /* biggest of all xxx_VOL_DEC defines */
|
|
#define VOL_MAX_LEN (1 + VOL_DEC_MAX_LEN + 2 + 1)
|
|
#define VOL_NUM_MAX 100
|
|
|
|
#ifndef ROOT_VOLUME
|
|
#define ROOT_VOLUME INT_MAX
|
|
#endif
|
|
|
|
#else /* empty definitions if no multi-volume */
|
|
#define IF_MV(x...)
|
|
#define IF_MV_NONVOID(x...) void
|
|
#define IF_MV_VOL(v) 0
|
|
#endif /* HAVE_MULTIVOLUME */
|
|
|
|
#define CHECK_VOL(volume) \
|
|
((unsigned int)IF_MV_VOL(volume) < NUM_VOLUMES)
|
|
|
|
#define CHECK_DRV(drive) \
|
|
((unsigned int)IF_MD_DRV(drive) < NUM_DRIVES)
|
|
|
|
/* contains info about a volume */
|
|
struct volumeinfo
|
|
{
|
|
int drive; /* drive number */
|
|
int partition; /* partition number (0 for superfloppy drives) */
|
|
};
|
|
|
|
/* Volume-centric functions (in disk.c) */
|
|
void volume_recalc_free(IF_MV_NONVOID(int volume));
|
|
unsigned int volume_get_cluster_size(IF_MV_NONVOID(int volume));
|
|
void volume_size(IF_MV(int volume,) sector_t *size, sector_t *free);
|
|
#ifdef HAVE_DIRCACHE
|
|
bool volume_ismounted(IF_MV_NONVOID(int volume));
|
|
#endif
|
|
#ifdef HAVE_HOTSWAP
|
|
bool volume_removable(int volume);
|
|
bool volume_present(int volume);
|
|
#else
|
|
#define volume_present(x) 1
|
|
#define volueme_removeable(x) 0
|
|
#endif /* HAVE_HOTSWAP */
|
|
|
|
#ifdef HAVE_MULTIDRIVE
|
|
int volume_drive(int volume);
|
|
#else /* !HAVE_MULTIDRIVE */
|
|
static inline int volume_drive(int volume)
|
|
{
|
|
return 0;
|
|
(void)volume;
|
|
}
|
|
#endif /* HAVE_MULTIDRIVE */
|
|
|
|
int volume_partition(int volume);
|
|
|
|
#endif /* __MV_H__ */
|