Commit graph

23 commits

Author SHA1 Message Date
Michael Sevakis
1654efc313 Unify storage threads into one
* Editing a bunch of drivers' thread routines in order to
implement a new feature is tedious.

* No matter the number of storage drivers, they share one thread.
No extra threads needed for CONFIG_STORAGE_MULTI.

* Each has an event callback called by the storage thread.

* A default callback is provided to fake sleeping in order to
trigger idle callbacks. It could also do other default processing.
Changes to it will be part of driver code without editing each
one.

* Drivers may sleep and wake as they please as long as they give
a low pulse on their storage bit to ask to go into sleep mode.
Idle callback is called on its behalf and driver immediately put
into sleep mode.

* Drivers may indicate they are to continue receiving events in
USB mode, otherwise they receve nothing until disconnect (they
do receive SYS_USB_DISCONNECTED no matter what).

* Rework a few things to keep the callback implementation sane
and maintainable. ata.c was dreadful with all those bools; make
it a state machine and easier to follow. Remove last_user_activity;
it has no purpose that isn't served by keeping the disk active
through last_disk_activity instead.

* Even-out stack sizes partly because of a lack of a decent place
to define them by driver or SoC or whatever; it doesn't seem too
critical to do that anyway. Many are simply too large while at
least one isn't really adequate. They may be individually
overridden if necessary (figure out where). The thread uses the
greatest size demanded. Newer file code is much more frugal with
stack space. I barely see use crack 50% after idle callbacks
(usually mid-40s). Card insert/eject doesn't demand much.

* No forcing of idle callbacks. If it isn't necessary for one or
more non-disk storage types, it really isn't any more necessary for
disk storage. Besides, it makes the whole thing easier to implement.

Change-Id: Id30c284d82a8af66e47f2cfe104c52cbd8aa7215
2017-10-26 14:35:41 -04:00
Amaury Pouly
065910663a storage: fix MD vs MV confusion
Change-Id: If0e4b0ac8b24413b77f1d67293c652c6a0e01bbd
2013-12-06 01:55:21 +01:00
Michael Sevakis
a56f1ca1ed Cleanup MV/MD macros a little.
When using variadic macros there's no need for IF_MD2/IF_MV2 to deal
with function parameters. IF_MD/IF_MV are enough.

Throw in IF_MD_DRV/ID_MV_VOL that return the parameter if MD/MV, or 0
if not.

Change-Id: I7605e6039f3be19cb47110c84dcb3c5516f2c3eb
2013-08-17 12:18:22 -04:00
Boris Gjenero
fdc29d0ea4 Add more INIT_ATTR and add config.h includes to header files with INIT_ATTR.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31370 a1c6a512-1295-4272-9138-f99709370657
2011-12-19 20:12:52 +00:00
Rafaël Carré
814ffffdbe Add INIT_ATTR to storage_init() when possible
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31036 a1c6a512-1295-4272-9138-f99709370657
2011-11-20 18:44:40 +00:00
Michael Sevakis
3a1127785b Bootloader USB mode for PP502x. Enable only on GoGear SA9200 for the time being. Add HAVE_BOOTLOADER_USB_MODE to config if BOOTLOADER is defined to enable it. Clean up some kernel stuff a little to support it. Mess up a bunch of other stuff (hopefully not too badly).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29053 a1c6a512-1295-4272-9138-f99709370657
2011-01-15 08:19:30 +00:00
Frank Gevaerts
9c43b2ce17 Remove card_enable_monitoring() and use a mutex instead. The card_enable_monitoring() method actually didn't eliminate the possible race conditions it was meant to fix.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26627 a1c6a512-1295-4272-9138-f99709370657
2010-06-06 13:20:47 +00:00
Thomas Martitz
ee7cf6c63c Remove unused card_detect(), and make card_detect_target() static inline in each sd driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23757 a1c6a512-1295-4272-9138-f99709370657
2009-11-26 00:51:09 +00:00
Jack Halpin
50d75f35e9 sd.h: No functional changes to present code. Added some additional SD CMD's and a #define for card errors flagged in an R1 response.
Add SD_SD_STATUS(ACMD13), SD_SET_WR_BLK_ERASE_COUNT(ACMD23), SD_PROGRAM_CSD(CMD27).

Add #define SD_R1_CARD_ERROR to make card error checking easier.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23560 a1c6a512-1295-4272-9138-f99709370657
2009-11-07 22:11:25 +00:00
Jack Halpin
094dd2b716 Add define for SD_SET_CLR_CARD_DETECT 42 /* acmd42 */ to sd.h for use with 4 bit WIDEBUS.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23340 a1c6a512-1295-4272-9138-f99709370657
2009-10-25 05:49:35 +00:00
Dominik Wenger
5b4938a8ca Working Bootloader for mini2440.
Flyspray: FS#10701
Author: Bob Cousins

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23316 a1c6a512-1295-4272-9138-f99709370657
2009-10-22 17:45:02 +00:00
Frank Gevaerts
c0a5a67387 Commit FS#9545, storage cleanup and multi-driver support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
2009-07-17 22:28:49 +00:00
Rafaël Carré
bdb5974c0e Revert r21912 : "Storage API : remove undeeded target-specific functions"
After a discussion mixed on mailing list and irc, it was agreed that
more abstraction for plugins is better (so developers don't have to add
a check to HAVE_DISK_STORAGE when writing disk-specific code)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21923 a1c6a512-1295-4272-9138-f99709370657
2009-07-17 16:34:34 +00:00
Rafaël Carré
8eba69f91b Storage API : remove undeeded target-specific functions
storage_sleep, storage_spin, storage_spindown are only defined if #defiend (HAVE_DISK_STORAGE), not for MMC/ATA/SD
remove already unneeded nand_disk_is_active, nand_soft_reset

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21912 a1c6a512-1295-4272-9138-f99709370657
2009-07-17 00:09:14 +00:00
Rafaël Carré
90d7a8c4fc Ingenic jz4740 SD driver: remove custom list of SD commands
Replace most references to MMC/mmc with SD/sd
Remove MMC failover code since MMC cards aren't supported

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21604 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 22:41:33 +00:00
Rafaël Carré
c0eb9aeb9e add firmware/driver/sd.c which contains common code between SD drivers
ingenic SD driver needs more cleanup so it still doesn't use the common code
correct a comment in hotswap.c: card_extract_bits assume most significant word of register first (so, use this order)
fix debug menu which used MMC specific commands / bits positions in csd/cid
move the default block size of 512 into sd.h
move the mantissa & exponent table into a single file (sd.c) to reduce binsize. we don't need to export it anymore anyway

TODO : ingenic cleanup (will happen soon so building sd.c is not conditional)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21601 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 21:49:13 +00:00
Rafaël Carré
e0e24cbf0a Merge tCardInfo struct (MMC) and tSDCardInfo struct (SD)
Put specific members under #ifdef (CONFIG_STORAGE & STORAGE_xx) (2 members for SD and 1 for MMC)
Fix a typo: tsac doesn't exist and must be read taac
Move card_get_info functions declaration inside hotswap.h to remove mutual inclusion of ata_mmc.h and hotswap.h
Move static const data structures from SD drivers into sd.h (sd_exponent and sd_mantissa)
Fix sd_command prototypes in SD drivers (card registers are unsigned long)
Fix speed calculation in Sansa AMS driver (PP SD driver needs to be checked)
Move ata-sd-target.h to sd-pp-target.h to reflect the PP specifity. Now it only contains declaration of microsd_int()
Remove unused ata-sd-target.h for injenic

TODO:
- check if CSD register bits are extracted correctly in PP driver
- correctly define read_timeout and write_timeout unit for MMC & SD, and use timeouts in Sansa AMS driver

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21586 a1c6a512-1295-4272-9138-f99709370657
2009-07-01 10:07:22 +00:00
Rafaël Carré
fa748db6ff sd.h : avoid namespace collision by prefixing defines with SD_
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19055 a1c6a512-1295-4272-9138-f99709370657
2008-11-09 23:40:21 +00:00
Rafaël Carré
6e73019894 SD PP: move non specific defines to sd.h, to be reused by other SD drivers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19043 a1c6a512-1295-4272-9138-f99709370657
2008-11-09 06:17:14 +00:00
Frank Gevaerts
059fff29ec Since *set_led_enabled() is actually an ata-specific feature, move it back to ata_* only
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19006 a1c6a512-1295-4272-9138-f99709370657
2008-11-04 19:57:36 +00:00
Frank Gevaerts
6f32dab2ae *_hard_reset() is only used inside ata.c, so there's no need to export it to the world
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19004 a1c6a512-1295-4272-9138-f99709370657
2008-11-04 19:37:28 +00:00
Frank Gevaerts
19eb800f75 conditionalise *_get_info() to get some binsize back
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18965 a1c6a512-1295-4272-9138-f99709370657
2008-11-01 17:33:21 +00:00
Frank Gevaerts
ad9db4de3d Now also commit added files
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18961 a1c6a512-1295-4272-9138-f99709370657
2008-11-01 16:25:04 +00:00