Commit graph

46 commits

Author SHA1 Message Date
Michael Sevakis
7d1a47cf13 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>
2014-08-30 03:48:23 +02:00
Michael Sevakis
95a4c3afcd Fix up the bootloaders
They can't access the raw RBVERSION define any longer.

Change-Id: I698062b36306399945c01de54cdccaa1a1a8434e
2014-08-28 10:44:22 -04:00
Michael Sevakis
4ea4cdfc11 Bootloaders need the reacharound to get at the internal goods
They need to include kernel-internal.h in order to perform inits.

Change-Id: I5b0f155e4ff49a065c6cb97691ecd4396a199979
2014-08-08 02:28:11 -04:00
Marcin Bukat
0b29691324 Move load_firmware() to separate file
The idea is to share loading code between bootloaders and rolo().

Change-Id: I1656ed91946d7a05cb7c9fa7a16793c3c862a5cd
Reviewed-on: http://gerrit.rockbox.org/190
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2013-06-27 13:50:11 +02:00
Thomas Martitz
c1bd9b0361 Rework powermgmt to enable code re-use on appliation and sims.
* Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application)
to break powermgmt.c's assumption about the ability to read battery voltage.
There's now additionally percentage (android) and remaining time measure
(maemo). No measure at all also works (sdl app). If voltage can't be measured,
then battery_level() is king and it'll be used for power_history and runtime
estimation.

* Implement target's API in the simulator, i.e. _battery_voltage(), so it
doesn't need to implement it's own powermgmt.c and other stubs. Now
the sim behaves much more like a native target, although it still
changes the simulated battery voltage quickly,

* Other changes include include renaming battery_adc_voltage() to
_battery_voltage(), for consistency with the new target functions and
making some of the apps code aware that voltage and runtime estimation
is not always available.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657
2012-01-03 23:44:38 +00:00
Michael Sevakis
36bc6a1fd5 Gigabeat S: Revert removal of usb_plugged in r31489
Synchronous cable read is still required because the timing of the receipt of
the cable event cannot be known for sure-- basically it introduced a thread
race between main and pmic. If a keypress is desired instead to enter BL USB
mode a la AS3525, then it's possible to remove that.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31510 a1c6a512-1295-4272-9138-f99709370657
2012-01-01 03:19:52 +00:00
Rafaël Carré
568c441fd8 usb-target.h: remove
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31498 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 18:44:55 +00:00
Rafaël Carré
2115eac7bb usb_plugged() is PP only
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31489 a1c6a512-1295-4272-9138-f99709370657
2011-12-31 18:43:59 +00:00
Michael Sevakis
6a67707b5e Commit to certain names for cache coherency APIs and discard the aliases.
Wouldn't surprise me a bit to get some non-green.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31339 a1c6a512-1295-4272-9138-f99709370657
2011-12-17 07:27:24 +00:00
Bertrik Sikken
7e3a3f491d Remove return value from show_logo() in bootloader/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30485 a1c6a512-1295-4272-9138-f99709370657
2011-09-08 18:31:15 +00:00
Michael Sevakis
480c663e5b i.MX31: Now that it matters because there's a debug screeen that allows changing things while running, some DVFS/DPTC stuff has to be done more carefully. Trim out some stuff and group functions better as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29122 a1c6a512-1295-4272-9138-f99709370657
2011-01-23 20:21:35 +00:00
Michael Sevakis
863c03f2ae Gigabeat S: Renovate bootloader a bit to show splash, implement verbose, shutdown on low battery, handle hold-switch-on and wait only so long for USB if a USB charger is inserted at boot instead of being connected to a host. 'Bootloader USB mode' display is just part of normal printf stream now. Move interrupt stacks into .bss area so they aren't loaded (for firmware too).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29099 a1c6a512-1295-4272-9138-f99709370657
2011-01-21 07:05:51 +00:00
Michael Sevakis
453550a687 Try to get some control over #ifdef hell in usb.c by refactoring and inline function use. SYS_USB_DISCONNECTED_ACK hasn't been doing anything useful for the USB thread; remove it. USB thread simply ignores that value. Observe only valid usb_state transitions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29084 a1c6a512-1295-4272-9138-f99709370657
2011-01-18 14:10:06 +00:00
Michael Sevakis
89a7a8138e Gigabeat S: Make it a removable mass-storage device. Windows will assign a drive to only the main data partition by default. To access the bootloader partition instead, press 'Vol -' while it connects (in bootloader and firmware). Hopefully doesn't break anything for anyone.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28972 a1c6a512-1295-4272-9138-f99709370657
2011-01-05 19:35:51 +00:00
Thomas Martitz
0e2286f226 Introduce NORETURN_ATTR wrapper for __attribute__((noreturn)), using this and a bit further cleanup in main gets rid of a warning when compiling for android.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27788 a1c6a512-1295-4272-9138-f99709370657
2010-08-12 13:38:25 +00:00
Rafaël Carré
1ec821244a Sansa AMS bootloader: enter USB mode only when needed
- If an error happens when reading partitions / rockbox.sansa
- If the select button was pressed

add an argument to error() to not power off, when we're going to enter
USB mode to try to fix the problem, but display the error message anyway
for debugging purpose

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27075 a1c6a512-1295-4272-9138-f99709370657
2010-06-23 05:08:36 +00:00
Rafaël Carré
5d236b2bfd Generate C file / header for svn version string
It's now easier to force rebuild of files depending on the svn revision

version.c/version.h are generated once with new tools/genversion.sh
Changes in the VCS are still not auto detected, so you'll have to remove
builddir/version.* if you want to change the string in your binaries

APPSVERSION is now called RBVERSION and is defined in the generated
header instead of being defined by the Makefiles
appsversion is now called rbversion (the plugin api number didn't change
since old modules are still binary compatible)

Change some bootloaders to use knwon-at-buildtime RBVERSION instead of
"%s" + rbversion

You'll need to run make clean to regenerate dependencies after the
removal of apps/version.h

To build binaries with a different version string, hand-edit
tools/version.sh or tools/genversion.sh (which calls the former)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26320 a1c6a512-1295-4272-9138-f99709370657
2010-05-27 09:41:46 +00:00
Frank Gevaerts
ab4a162763 Fix gigabeat S includes so it builds again
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25855 a1c6a512-1295-4272-9138-f99709370657
2010-05-06 22:13:54 +00:00
Thomas Martitz
c61e89c0ed Make creat() posix compliant API-wise. Shouldn't affect the core as it's wrapped via a static inline.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25843 a1c6a512-1295-4272-9138-f99709370657
2010-05-06 17:35:04 +00:00
Michael Sevakis
0defb8483c Gigabeat S bootloader: Fix archaic call placement in dptc_stop which hangs the bootloader before jumping to FW. Let the backlight LED ramp up after unplugging USB which just looks better.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25840 a1c6a512-1295-4272-9138-f99709370657
2010-05-06 04:45:05 +00:00
Michael Sevakis
21f0c9a282 Make basic cache functions into calls, and get rid of CACHE_FUNCTION_WRAPPERS and CACHE_FUNCTIONS_AS_CALL macros. Rename flush/invalidate_icache to cpucache_flush/invalidate. They're inlined only if an implementation isn't provided by defining HAVE_CPUCACHE_FLUSH/INVALIDATE.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19971 a1c6a512-1295-4272-9138-f99709370657
2009-02-11 12:55:51 +00:00
Michael Sevakis
4d3a020f27 Gigabeat S: Move the LCD framebuffer address so that DRAM can be mapped flat between physical and virtual addresses. NO BOOTLOADER UPDATE SHOULD BE NEEDED. The firmware image now handles low-level system setup as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19935 a1c6a512-1295-4272-9138-f99709370657
2009-02-07 10:09:13 +00:00
Michael Sevakis
47509fafa4 Fix up ZVM builds. It appeared to share common definitions with PP502x targets so use those. Remove one stale comment left behind in last commit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19798 a1c6a512-1295-4272-9138-f99709370657
2009-01-19 14:06:47 +00:00
Michael Sevakis
616c98b38f USB detection changes. c200/e200: Consider USB to be powered when charger is plugged but detect USB connection by bus reset. When received, disconnect and restart the driver fully enabled. imx31: Fix hack used to make initial connect succeeded-- set PHY type before initial reset. General: Move some target code out of usb-drv-arc.c and implement it in respective usb sources and CPU headers so things stay clean.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19797 a1c6a512-1295-4272-9138-f99709370657
2009-01-19 13:41:25 +00:00
Björn Stenberg
b69be10d98 Use BOOTDIR and BOOTFILE defines instead of hardcoded path and file. FS#9559
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19190 a1c6a512-1295-4272-9138-f99709370657
2008-11-23 22:07:48 +00:00
Frank Gevaerts
2f8a0081c6 Apply FS#9500. This adds a storage_*() abstraction to replace ata_*(). To do that, it also introduces sd_*, nand_*, and mmc_*.
This should be a good first step to allow multi-driver targets, like the Elio (ATA/SD), or the D2 (NAND/SD).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18960 a1c6a512-1295-4272-9138-f99709370657
2008-11-01 16:14:28 +00:00
Daniel Stenberg
2acc0ac542 Updated our source code header to explicitly mention that we are GPL v2 or
later. We still need to hunt down snippets used that are not. 1324 modified
files...
http://www.rockbox.org/mail/archive/rockbox-dev-archive-2008-06/0060.shtml


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17847 a1c6a512-1295-4272-9138-f99709370657
2008-06-28 18:10:04 +00:00
Michael Sevakis
80278e45aa Bring Gigabeat S bootloader one step close to a release version.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17442 a1c6a512-1295-4272-9138-f99709370657
2008-05-10 18:00:11 +00:00
Michael Sevakis
c41cacaf30 Do some gigabeat S bootloader cleanup (includes, const, static-ing, number of variables, etc.). Make sure a tar file isn't too big before loading it however unlikely that is. No overall functional change but bump to v.00000013 for tracking purposes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17403 a1c6a512-1295-4272-9138-f99709370657
2008-05-07 07:14:39 +00:00
Michael Sevakis
0218397cf4 Gigabeat S bootloader: 1) Switch order of .vectors to be contiguous with initialized sections. 2) Clean all caches in main before doing anything else because vector copying counts as self-modifying code. Up to v.00000012.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17381 a1c6a512-1295-4272-9138-f99709370657
2008-05-05 13:30:29 +00:00
Michael Sevakis
75fe8875bc Fix firmware load error display and handling in Gigabeat S bootloader. Remove "Hello World". v.00000011 now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17347 a1c6a512-1295-4272-9138-f99709370657
2008-05-04 03:44:49 +00:00
Jens Arnold
2bbacf89fe Make sure the linker considers crt0*.o before all files specified on the command line by using STARTUP() instead of INPUT() in the .lds. Using INPUT() makes the linker process crt0*.o after all files specified on the command line, making linking fail if there are librockbox.a members which are only referenced by crt0*.o. Remove the hackaround that was needed for building the gigabeat S bootloader before (aka UIE() problem).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17289 a1c6a512-1295-4272-9138-f99709370657
2008-04-29 06:19:32 +00:00
Michael Sevakis
8ec1dca0da Enable program flow prediction in the system control coprocessor setup in the bootloader.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17211 a1c6a512-1295-4272-9138-f99709370657
2008-04-21 21:45:58 +00:00
Michael Sevakis
2920359cca Unreverse Gigabeat S bootloader. Boot Rockbox with hold switch off.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17203 a1c6a512-1295-4272-9138-f99709370657
2008-04-21 04:34:39 +00:00
Michael Sevakis
9003dbe5b2 Make the inital connect problem go away on Gigabeat S. Would be nice if a better way were found but it works for me. Update the bootloader to have it work.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17181 a1c6a512-1295-4272-9138-f99709370657
2008-04-20 03:30:57 +00:00
Michael Sevakis
94f7d0f290 UMS for the Gigabeat S. Bootloader USB mode. Has a couple quirks 1) First plug has problems if cold. Replug if it doesn't connect or not at high speed 2) Linux doesn't like the odd bootable flag value used in the partitions so it won't mount but Windows works. Fix minor OTG driver bugs and clean up device memory handling. Generic name for ARC controller driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17154 a1c6a512-1295-4272-9138-f99709370657
2008-04-18 16:42:50 +00:00
Nicolas Pennequin
90a3d58013 Gigabeat S bootloader: Improve untarring by reading the whole file to memory before starting to write the output files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17136 a1c6a512-1295-4272-9138-f99709370657
2008-04-16 00:38:06 +00:00
Nicolas Pennequin
620e6b4d93 Gigabeat S bootloader: make it move a rockbox binary back to /.rockbox/ when it finds one in the MTP directory.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17133 a1c6a512-1295-4272-9138-f99709370657
2008-04-15 23:17:03 +00:00
Michael Sevakis
ec05b66b5d That was stupid. Should be enable_interrupt.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16898 a1c6a512-1295-4272-9138-f99709370657
2008-03-31 06:05:16 +00:00
Michael Sevakis
75f2d441e9 Change the remaining set_interrupt_status usage to the more parsimonious disable/enable/restore.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16897 a1c6a512-1295-4272-9138-f99709370657
2008-03-31 06:00:23 +00:00
Nicolas Pennequin
e2f5f21e5b Give the Gigabeat S bootloader the ability to untar a tarball.
To test a build, use 'make tar' and send the tar to the unit. The bootloader will unarchive it and delete it before loading the main binary.
This is a temporary hack to make testing possible until we have a better way of sending a complete build.
Also enable writing to the disk by disabling the optimised write stubs.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16338 a1c6a512-1295-4272-9138-f99709370657
2008-02-17 23:17:08 +00:00
Michael Sevakis
a07c034de7 Gigabeat S: Interrupt enabled bootloader. Miscellaneous integration changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16243 a1c6a512-1295-4272-9138-f99709370657
2008-02-08 02:20:05 +00:00
Michael Sevakis
1f021af60c Gigabeat S mixer: Make some progress. Get the tick and core sleep working using the AVIC. Redo the startup code to remap from IRAM and not include the lcd driver frambuffer in the remapping (until it can be moved). Clean up LCD driver. For other misc. changes, see the diffs. Now it progresses to ATA init and fails with -11 but without crashing or hanging. Replace all bootloaders.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16216 a1c6a512-1295-4272-9138-f99709370657
2008-02-05 04:43:19 +00:00
Will Robertson
32f6109fb1 Gigabeat S memory management stuff.
* Moved crt0.S to imx31 subdirectory, as it was the last target using the unified file.
* DRAM is now remapped to 0x0, facilitating interrupts (which aren't done yet)


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15965 a1c6a512-1295-4272-9138-f99709370657
2007-12-23 12:19:40 +00:00
Nicolas Pennequin
c2ca8c710c * Make the Gigabeat S bootloader a bit more interesting: it looks for the first firmware file it finds on the second partition and attempts to load it. Loading fails to get past the splash screen though.
* Make the main binary compile.
To send a firmware file, use mtp-sendfile. To update you'll need to delete the previous firmware file, as files are named sequentially and the first one is loaded.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15836 a1c6a512-1295-4272-9138-f99709370657
2007-11-27 15:40:29 +00:00
Will Robertson
590501cfe4 Merge the Gigabeat S branch back into trunk. Fingers crossed nothing breaks.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14805 a1c6a512-1295-4272-9138-f99709370657
2007-09-21 15:51:53 +00:00