2008-11-01 16:25:04 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Alan Korr
|
|
|
|
* 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 __STORAGE_H__
|
|
|
|
#define __STORAGE_H__
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2009-07-17 22:28:49 +00:00
|
|
|
#include "config.h" /* for HAVE_MULTIDRIVE or not */
|
2008-11-01 16:25:04 +00:00
|
|
|
#include "mv.h"
|
2017-03-15 05:51:54 +00:00
|
|
|
#include <kernel.h>
|
2008-11-01 16:25:04 +00:00
|
|
|
|
2014-02-07 17:12:31 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_HOSTFS) || defined(SIMULATOR)
|
|
|
|
#define HAVE_HOSTFS
|
|
|
|
#endif
|
|
|
|
|
2008-11-01 16:25:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_SD)
|
|
|
|
#include "sd.h"
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
|
#include "mmc.h"
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA)
|
|
|
|
#include "ata.h"
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_NAND)
|
|
|
|
#include "nand.h"
|
|
|
|
#endif
|
2008-11-03 20:52:27 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
|
|
|
#include "ramdisk.h"
|
|
|
|
#endif
|
2008-11-01 16:25:04 +00:00
|
|
|
|
2017-03-15 05:51:54 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
Q_STORAGE_TICK = 1,
|
|
|
|
Q_STORAGE_SLEEP,
|
|
|
|
Q_STORAGE_SLEEPNOW,
|
|
|
|
#ifdef STORAGE_CLOSE
|
|
|
|
Q_STORAGE_CLOSE,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#define STG_EVENT_ASSERT_ACTIVE(type) \
|
|
|
|
({ intptr_t __data = (data); \
|
|
|
|
*((unsigned int *)(__data)) |= (type); })
|
|
|
|
|
|
|
|
static FORCE_INLINE int storage_event_default_handler(long id,
|
|
|
|
intptr_t data,
|
|
|
|
long last_activity,
|
|
|
|
unsigned int type)
|
|
|
|
{
|
|
|
|
/* fake sleep in order to trigger storage idle sequence */
|
|
|
|
static long slept_at = -1;
|
|
|
|
|
|
|
|
if (id == Q_STORAGE_TICK) {
|
|
|
|
if (last_activity == slept_at ||
|
|
|
|
TIME_BEFORE(current_tick, last_activity + 3*HZ)) {
|
|
|
|
STG_EVENT_ASSERT_ACTIVE(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (id == Q_STORAGE_SLEEPNOW) {
|
|
|
|
slept_at = last_activity;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_SD)
|
|
|
|
int sd_event(long id, intptr_t data);
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
|
|
|
int mmc_event(long id, intptr_t data);
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA)
|
|
|
|
int ata_event(long id, intptr_t data);
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_NAND)
|
|
|
|
int nand_event(long id, intptr_t data);
|
|
|
|
#endif
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_RAMDISK)
|
|
|
|
int ramdisk_event(long id, intptr_t data);
|
|
|
|
#endif
|
|
|
|
|
2008-11-01 16:25:04 +00:00
|
|
|
struct storage_info
|
|
|
|
{
|
|
|
|
unsigned int sector_size;
|
|
|
|
unsigned int num_sectors;
|
|
|
|
char *vendor;
|
|
|
|
char *product;
|
|
|
|
char *revision;
|
|
|
|
};
|
|
|
|
|
2017-03-15 05:51:54 +00:00
|
|
|
int storage_init(void) STORAGE_INIT_ATTR;
|
|
|
|
void storage_close(void);
|
|
|
|
|
2014-02-07 17:12:31 +00:00
|
|
|
#ifdef HAVE_HOSTFS
|
|
|
|
#include "hostfs.h"
|
2010-09-02 00:24:40 +00:00
|
|
|
/* stubs for the plugin api */
|
|
|
|
static inline void stub_storage_sleep(void) {}
|
|
|
|
static inline void stub_storage_spin(void) {}
|
|
|
|
static inline void stub_storage_spindown(int timeout) { (void)timeout; }
|
2017-03-15 05:51:54 +00:00
|
|
|
static inline int stub_storage_event(long id, intptr_t data)
|
|
|
|
{ return 0; (void)id; (void)data; }
|
2020-07-17 03:23:25 +00:00
|
|
|
static inline void storage_sleep(void) {};
|
2017-03-15 05:51:54 +00:00
|
|
|
#else /* ndef HAVE_HOSTFS */
|
|
|
|
#if (CONFIG_STORAGE & STORAGE_ATA)
|
|
|
|
void storage_sleep(void);
|
|
|
|
#else
|
2020-07-17 03:23:25 +00:00
|
|
|
static inline void storage_sleep(void) {};
|
2010-09-02 00:24:40 +00:00
|
|
|
#endif
|
2017-03-15 05:51:54 +00:00
|
|
|
#endif /* HAVE_HOSTFS */
|
2010-09-02 00:24:40 +00:00
|
|
|
|
2014-02-07 17:12:31 +00:00
|
|
|
#if !defined(CONFIG_STORAGE_MULTI) || defined(HAVE_HOSTFS)
|
2009-07-17 22:28:49 +00:00
|
|
|
/* storage_spindown, storage_sleep and storage_spin are passed as
|
|
|
|
* pointers, which doesn't work with argument-macros.
|
|
|
|
*/
|
|
|
|
#define storage_num_drives() NUM_DRIVES
|
2014-02-07 17:12:31 +00:00
|
|
|
#if defined(HAVE_HOSTFS)
|
2020-07-17 03:23:25 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (stub_storage_## NAME)
|
2017-03-15 05:51:54 +00:00
|
|
|
#define storage_event stub_storage_event
|
2020-07-17 03:23:25 +00:00
|
|
|
#define storage_spindown(sec) stub_storage_spindown(sec)
|
|
|
|
#define storage_sleep() stub_storage_sleep()
|
|
|
|
#define storage_spin() stub_storage_spin()
|
2010-09-02 00:24:40 +00:00
|
|
|
|
|
|
|
#define storage_enable(on)
|
|
|
|
#define storage_sleepnow()
|
2011-12-31 13:34:56 +00:00
|
|
|
#define storage_disk_is_active() 0
|
2010-09-02 00:24:40 +00:00
|
|
|
#define storage_soft_reset()
|
2014-02-07 17:12:31 +00:00
|
|
|
#define storage_init() hostfs_init()
|
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
|
|
|
#define storage_flush() hostfs_flush()
|
|
|
|
#endif
|
|
|
|
#define storage_last_disk_activity() (-1)
|
|
|
|
#define storage_spinup_time() 0
|
|
|
|
#define storage_get_identify() (NULL) /* not actually called anywher */
|
|
|
|
|
|
|
|
#ifdef STORAGE_GET_INFO
|
|
|
|
#error storage_get_info not implemented
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
#define storage_removable(drive) hostfs_removable(IF_MD(drive))
|
|
|
|
#define storage_present(drive) hostfs_present(IF_MD(drive))
|
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#define storage_driver_type(drive) hostfs_driver_type(IF_MV(drive))
|
2010-09-02 00:24:40 +00:00
|
|
|
#elif (CONFIG_STORAGE & STORAGE_ATA)
|
2010-04-03 22:02:09 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (ata_## NAME)
|
2020-07-17 03:23:25 +00:00
|
|
|
#define storage_spindown(sec) ata_spindown(sec)
|
|
|
|
#define storage_spin() ata_spin()
|
2010-01-03 10:27:43 +00:00
|
|
|
#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()
|
2009-10-09 20:36:09 +00:00
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
|
|
|
#define storage_flush() (void)0
|
|
|
|
#endif
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_last_disk_activity() ata_last_disk_activity()
|
|
|
|
#define storage_spinup_time() ata_spinup_time()
|
|
|
|
#define storage_get_identify() ata_get_identify()
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2010-01-03 10:27:43 +00:00
|
|
|
#ifdef STORAGE_GET_INFO
|
2013-08-17 16:18:22 +00:00
|
|
|
#define storage_get_info(drive, info) ata_get_info(IF_MD(drive,) info)
|
2010-01-03 10:27:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
#define storage_removable(drive) ata_removable(IF_MD(drive))
|
|
|
|
#define storage_present(drive) ata_present(IF_MD(drive))
|
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#define storage_driver_type(drive) (STORAGE_ATA_NUM)
|
2010-01-03 10:27:43 +00:00
|
|
|
#elif (CONFIG_STORAGE & STORAGE_SD)
|
2010-04-03 22:02:09 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (sd_## NAME)
|
2020-07-17 03:23:25 +00:00
|
|
|
#define storage_spindown(sec) sd_spindown(sec)
|
|
|
|
#define storage_spin() sd_spin()
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_enable(on) sd_enable(on)
|
2017-10-26 20:32:53 +00:00
|
|
|
#define storage_sleepnow() do {} while (0)
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_disk_is_active() 0
|
|
|
|
#define storage_soft_reset() (void)0
|
2009-10-09 20:36:09 +00:00
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
|
|
|
#define storage_flush() (void)0
|
|
|
|
#endif
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_last_disk_activity() sd_last_disk_activity()
|
|
|
|
#define storage_spinup_time() 0
|
|
|
|
#define storage_get_identify() sd_get_identify()
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2010-01-03 10:27:43 +00:00
|
|
|
#ifdef STORAGE_GET_INFO
|
2013-08-17 16:18:22 +00:00
|
|
|
#define storage_get_info(drive, info) sd_get_info(IF_MD(drive,) info)
|
2010-01-03 10:27:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
#define storage_removable(drive) sd_removable(IF_MD(drive))
|
|
|
|
#define storage_present(drive) sd_present(IF_MD(drive))
|
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#define storage_driver_type(drive) (STORAGE_SD_NUM)
|
2010-01-03 10:27:43 +00:00
|
|
|
#elif (CONFIG_STORAGE & STORAGE_MMC)
|
2010-04-03 22:02:09 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (mmc_## NAME)
|
2020-07-17 03:23:25 +00:00
|
|
|
#define storage_spindown(sec) mmc_spindown(sec)
|
|
|
|
#define storage_spin() mmc_spin()
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2010-01-03 10:27:43 +00:00
|
|
|
#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
|
2009-10-09 20:36:09 +00:00
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
|
|
|
#define storage_flush() (void)0
|
|
|
|
#endif
|
2010-01-03 10:27:43 +00:00
|
|
|
#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
|
2013-08-17 16:18:22 +00:00
|
|
|
#define storage_get_info(drive, info) mmc_get_info(IF_MD(drive,) info)
|
2010-01-03 10:27:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
#define storage_removable(drive) mmc_removable(IF_MD(drive))
|
|
|
|
#define storage_present(drive) mmc_present(IF_MD(drive))
|
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#define storage_driver_type(drive) (STORAGE_MMC_NUM)
|
2010-01-03 10:27:43 +00:00
|
|
|
#elif (CONFIG_STORAGE & STORAGE_NAND)
|
2010-04-03 22:02:09 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (nand_## NAME)
|
2020-07-17 03:23:25 +00:00
|
|
|
#define storage_spindown(sec) nand_spindown(sec)
|
|
|
|
#define storage_spin() nand_spin()
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_enable(on) (void)0
|
|
|
|
#define storage_sleepnow() nand_sleepnow()
|
|
|
|
#define storage_disk_is_active() 0
|
|
|
|
#define storage_soft_reset() (void)0
|
2009-10-09 20:36:09 +00:00
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_flush() nand_flush()
|
|
|
|
#endif
|
|
|
|
#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
|
2013-08-17 16:18:22 +00:00
|
|
|
#define storage_get_info(drive, info) nand_get_info(IF_MD(drive,) info)
|
2010-01-03 10:27:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
#define storage_removable(drive) nand_removable(IF_MD(drive))
|
|
|
|
#define storage_present(drive) nand_present(IF_MD(drive))
|
2009-10-09 20:36:09 +00:00
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#define storage_driver_type(drive) (STORAGE_NAND_NUM)
|
2010-01-03 10:27:43 +00:00
|
|
|
#elif (CONFIG_STORAGE & STORAGE_RAMDISK)
|
2010-04-03 22:02:09 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (ramdisk_## NAME)
|
2020-07-17 03:23:25 +00:00
|
|
|
#define storage_spindown(sec) ramdisk_spindown(sec)
|
|
|
|
#define storage_spin() ramdisk_spin()
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2010-01-03 10:27:43 +00:00
|
|
|
#define storage_enable(on) (void)0
|
|
|
|
#define storage_sleepnow() ramdisk_sleepnow()
|
|
|
|
#define storage_disk_is_active() 0
|
|
|
|
#define storage_soft_reset() (void)0
|
2009-10-09 20:36:09 +00:00
|
|
|
#ifdef HAVE_STORAGE_FLUSH
|
|
|
|
#define storage_flush() (void)0
|
|
|
|
#endif
|
2010-01-03 10:27:43 +00:00
|
|
|
#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
|
2013-08-17 16:18:22 +00:00
|
|
|
#define storage_get_info(drive, info) ramdisk_get_info(IF_MD(drive,) info)
|
2010-01-03 10:27:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_HOTSWAP
|
|
|
|
#define storage_removable(drive) ramdisk_removable(IF_MD(drive))
|
|
|
|
#define storage_present(drive) ramdisk_present(IF_MD(drive))
|
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
#define storage_driver_type(drive) (STORAGE_RAMDISK_NUM)
|
2010-01-03 10:27:43 +00:00
|
|
|
#else
|
|
|
|
//#error No storage driver!
|
|
|
|
#endif
|
2014-02-07 17:12:31 +00:00
|
|
|
#else /* CONFIG_STORAGE_MULTI || !HAVE_HOSTFS */
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2014-02-07 17:12:31 +00:00
|
|
|
/* Multi-driver use normal functions */
|
2020-07-17 03:23:25 +00:00
|
|
|
#define STORAGE_FUNCTION(NAME) (storage_## NAME)
|
2009-07-17 22:28:49 +00:00
|
|
|
|
2008-11-02 02:01:57 +00:00
|
|
|
void storage_enable(bool on);
|
|
|
|
void storage_sleepnow(void);
|
|
|
|
bool storage_disk_is_active(void);
|
|
|
|
int storage_soft_reset(void);
|
2009-10-09 20:36:09 +00:00
|
|
|
int storage_flush(void);
|
2008-11-02 02:01:57 +00:00
|
|
|
void storage_spin(void);
|
|
|
|
void storage_spindown(int seconds);
|
|
|
|
long storage_last_disk_activity(void);
|
|
|
|
int storage_spinup_time(void);
|
2009-07-17 22:28:49 +00:00
|
|
|
int storage_num_drives(void);
|
2008-11-01 17:33:21 +00:00
|
|
|
#ifdef STORAGE_GET_INFO
|
2008-11-02 02:01:57 +00:00
|
|
|
void storage_get_info(int drive, struct storage_info *info);
|
|
|
|
#endif
|
2009-07-19 17:49:06 +00:00
|
|
|
#ifdef HAVE_HOTSWAP
|
2008-11-02 02:01:57 +00:00
|
|
|
bool storage_removable(int drive);
|
|
|
|
bool storage_present(int drive);
|
2008-11-02 01:31:52 +00:00
|
|
|
#endif
|
Rewrite filesystem code (WIP)
This patch redoes the filesystem code from the FAT driver up to the
clipboard code in onplay.c.
Not every aspect of this is finished therefore it is still "WIP". I
don't wish to do too much at once (haha!). What is left to do is get
dircache back in the sim and find an implementation for the dircache
indicies in the tagcache and playlist code or do something else that
has the same benefit. Leaving these out for now does not make anything
unusable. All the basics are done.
Phone app code should probably get vetted (and app path handling
just plain rewritten as environment expansions); the SDL app and
Android run well.
Main things addressed:
1) Thread safety: There is none right now in the trunk code. Most of
what currently works is luck when multiple threads are involved or
multiple descriptors to the same file are open.
2) POSIX compliance: Many of the functions behave nothing like their
counterparts on a host system. This leads to inconsistent code or very
different behavior from native to hosted. One huge offender was
rename(). Going point by point would fill a book.
3) Actual running RAM usage: Many targets will use less RAM and less
stack space (some more RAM because I upped the number of cache buffers
for large memory). There's very little memory lying fallow in rarely-used
areas (see 'Key core changes' below). Also, all targets may open the same
number of directory streams whereas before those with less than 8MB RAM
were limited to 8, not 12 implying those targets will save slightly
less.
4) Performance: The test_disk plugin shows markedly improved performance,
particularly in the area of (uncached) directory scanning, due partly to
more optimal directory reading and to a better sector cache algorithm.
Uncached times tend to be better while there is a bit of a slowdown in
dircache due to it being a bit heavier of an implementation. It's not
noticeable by a human as far as I can say.
Key core changes:
1) Files and directories share core code and data structures.
2) The filesystem code knows which descriptors refer to same file.
This ensures that changes from one stream are appropriately reflected
in every open descriptor for that file (fileobj_mgr.c).
3) File and directory cache buffers are borrowed from the main sector
cache. This means that when they are not in use by a file, they are not
wasted, but used for the cache. Most of the time, only a few of them
are needed. It also means that adding more file and directory handles
is less expensive. All one must do in ensure a large enough cache to
borrow from.
4) Relative path components are supported and the namespace is unified.
It does not support full relative paths to an implied current directory;
what is does support is use of "." and "..". Adding the former would
not be very difficult. The namespace is unified in the sense that
volumes may be specified several times along with relative parts, e.g.:
"/<0>/foo/../../<1>/bar" :<=> "/<1>/bar".
5) Stack usage is down due to sharing of data, static allocation and
less duplication of strings on the stack. This requires more
serialization than I would like but since the number of threads is
limited to a low number, the tradoff in favor of the stack seems
reasonable.
6) Separates and heirarchicalizes (sic) the SIM and APP filesystem
code. SIM path and volume handling is just like the target. Some
aspects of the APP file code get more straightforward (e.g. no path
hashing is needed).
Dircache:
Deserves its own section. Dircache is new but pays homage to the old.
The old one was not compatible and so it, since it got redone, does
all the stuff it always should have done such as:
1) It may be update and used at any time during the build process.
No longer has one to wait for it to finish building to do basic file
management (create, remove, rename, etc.).
2) It does not need to be either fully scanned or completely disabled;
it can be incomplete (i.e. overfilled, missing paths), still be
of benefit and be correct.
3) Handles mounting and dismounting of individual volumes which means
a full rebuild is not needed just because you pop a new SD card in the
slot. Now, because it reuses its freed entry data, may rebuild only
that volume.
4) Much more fundamental to the file code. When it is built, it is
the keeper of the master file list whether enabled or not ("disabled"
is just a state of the cache). Its must always to ready to be started
and bind all streams opened prior to being enabled.
5) Maintains any short filenames in OEM format which means that it does
not need to be rebuilt when changing the default codepage.
Miscellaneous Compatibility:
1) Update any other code that would otherwise not work such as the
hotswap mounting code in various card drivers.
2) File management: Clipboard needed updating because of the behavioral
changes. Still needs a little more work on some finer points.
3) Remove now-obsolete functionality such as the mutex's "no preempt"
flag (which was only for the prior FAT driver).
4) struct dirinfo uses time_t rather than raw FAT directory entry
time fields. I plan to follow up on genericizing everything there
(i.e. no FAT attributes).
5) unicode.c needed some redoing so that the file code does not try
try to load codepages during a scan, which is actually a problem with
the current code. The default codepage, if any is required, is now
kept in RAM separarately (bufalloced) from codepages specified to
iso_decode() (which must not be bufalloced because the conversion
may be done by playback threads).
Brings with it some additional reusable core code:
1) Revised file functions: Reusable code that does things such as
safe path concatenation and parsing without buffer limitations or
data duplication. Variants that copy or alter the input path may be
based off these.
To do:
1) Put dircache functionality back in the sim. Treating it internally
as a different kind of file system seems the best approach at this
time.
2) Restore use of dircache indexes in the playlist and database or
something effectively the same. Since the cache doesn't have to be
complete in order to be used, not getting a hit on the cache doesn't
unambiguously say if the path exists or not.
Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8
Reviewed-on: http://gerrit.rockbox.org/566
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2013-08-06 02:02:45 +00:00
|
|
|
int storage_driver_type(int drive);
|
2009-07-17 22:28:49 +00:00
|
|
|
|
|
|
|
#endif /* NOT CONFIG_STORAGE_MULTI and NOT SIMULATOR*/
|
2010-04-03 22:02:09 +00:00
|
|
|
|
2013-08-17 16:18:22 +00:00
|
|
|
int storage_read_sectors(IF_MD(int drive,) unsigned long start, int count, void* buf);
|
|
|
|
int storage_write_sectors(IF_MD(int drive,) unsigned long start, int count, const void* buf);
|
2008-11-01 16:25:04 +00:00
|
|
|
#endif
|