Commit graph

615 commits

Author SHA1 Message Date
William Wilgus
f850bbbbc4 Revert root_redirect :(
This reverts commit 31fc46ded6.

Change-Id: Ia78618c0e8b25ca65f7c8ae0db1cb9c9b321bad9
2020-08-20 21:54:00 -04:00
William Wilgus
bd744059cf Multiboot Firmware Root Redirect
Firmware now includes rudimentary redirect functionality
but this only supports /.rockbox in the root of the device

This patch allows loading external drive and directory into root namespace

Root Redirects can now be put into different folders
For instance placing '/_test' into SD1/rockbox_main.<playername>
will redirect to /<1>/_test/.rockbox

Debug menu>Bootdata now has root directory listed in addition to RAW Bootdata

Redirect root work from Michael Sevakis g#1556

Redirect will be updated if code refactor is ever done

Requires Multiboot bootloader (already in main)

Change-Id: I697b3d0499f85e789c3020bc2133fbe0023f72a2
2020-08-20 19:19:55 -04:00
William Wilgus
5ef28cccf9 Allow mounting of any directory as the root directory.
Provide definitions for the macros:
* RB_ROOT_VOL_HIDDEN(v) to exclude certain items from the root.
* RB_ROOT_CONTENTS to return a string with the name of the
directory to mount in the root.

Defaults are in export/rbpaths.h

It's a bit much for those that don't need the full functionality.
Some conditional define can cut it back a lot to cut out things only
needed if alternate root mounts are required. I'm just not bothering
yet. The basic concept would be applied to all targets to keep file
code from forking too much.

Change-Id: I90b5c0a1c949283d3102c16734b0b6ac73901a30
2020-08-20 23:08:57 +00:00
William Wilgus
31fc46ded6 Revert g#1612
Change-Id: Ia971919ecb1690875c916c62ced04bccf99c5aee
2020-08-20 19:04:05 -04:00
William Wilgus
d7b9eb6b63 ROLO - Enable multiboot firmware
I never added multiboot awareness to ROLO

When a new firmware file was loaded [Bootdata] would not be
copied to the new instance resulting in the firmware
running off the internal drive till next reboot

Bootloaders shares the rb-loader code but should not be
affected by the removal of static from write_bootdata()

Change-Id: Iccb18eebeee5c59f9534df51eb6826876c441762
2020-08-08 02:41:13 -04:00
Solomon Peachy
658026e626 [4/4] Remove HAVE_LCD_BITMAP, as it's now the only choice.
Note:  I left behind lcd_bitmap in features.txt, because removing it
would require considerable work in the manual and the translations.

Change-Id: Ia8ca7761f610d9332a0d22a7d189775fb15ec88a
2020-07-24 21:20:13 +00:00
Solomon Peachy
092c340a20 [1/4] Remove SH support and all archos targets
This removes all code specific to SH targets

Change-Id: I7980523785d2596e65c06430f4638eec74a06061
2020-07-24 21:20:13 +00:00
Moshe Piekarski
7fb438b06c Try mounting as "superfloppy" first
This allows for a superfloppy that has MBR-like data in the BPB.
this solves FS#12294 while allowing arbitrary partition types.

Change-Id: I53880fe7dd53e5015f5f15be0ddba11105fcd778
2020-06-30 21:11:52 +00:00
Moshe Piekarski
0d24a7176e Also remove the fat_partition_types array.
If we aren't going to check for the partition type, we don't need the array of
known FAT partition types.

Original Author:    Torne Wuff <torne@wolfpuppy.org.uk>

Change-Id: I558d4287189408c513dfbca49e13906cdb7918b1
2020-06-30 21:11:52 +00:00
Moshe Piekarski
a2b8204718 Allow any partition type, not just known FAT types.
Instead of only mounting partitions with a FAT partition type, try any
partition that isn't type 0 (unallocated) or 5 (extended). This makes it easier
to reformat SDXC cards which have the exFAT partition type, and also brings us
in line with pretty much every other OS at this point. Anything with a
valid-looking FAT superblock will get mounted.

original author:    Torne Wuff <torne@wolfpuppy.org.uk>

Change-Id: I3ea8d437a79f9da270f9d119cc670e472331a9da
2020-06-30 21:11:52 +00:00
William Wilgus
9cfdbdb355 MultiBoot_Firmware Fix red for bootloaders
Change-Id: I0446258d1f14f5423cca55de04abf545a92c61cf
2019-11-15 05:05:20 -06:00
William Wilgus
62e5a3076c MultiBoot_Firmware
Stop gap till I get a chance to work on the root folder stuff

Makes whatever volume marked by bootdata.boot_volume
the base or root volume, mounts all other volumes after
the specified boot volume.
Has the effect of swapping the SD card to the slot for internal
and Internal storage is mounted as the Sd-card.

Does not honor root redirect -- uses .rockbox folder in the root of boot volume

Change-Id: I0f786aa0c8721e21cba607366775be3e3c0cf474
2019-11-15 11:26:56 +01:00
Franklin Wei
b0e9bb1b91 Limit float formatting to only targets building Quake
The Quake plugin is the only code that actually relies on float
formatting. Because Quake only runs on targets with huge memory
anyway, limiting their formatting to just those targets will minimize
the increased memory use in the core.

Change-Id: Icdbe26ec6ede564861cc01ac4add76a12b00ecd5
2019-07-19 23:20:56 -04:00
Michael Sevakis
b70fecf21d Add proper float formatting to vuprintf
Wanted to see how gnarly it is to do.

Big number handling could be done with better algorithms
since it can get a bit slow with large integers or tiny
fractions with many lead zeros when only a few digits are
needed.

Anyway, it supports %e, %E, %f, %F, %g and %G. No %a or long
double support seems warranted at the moment.

Assumes IEEE 754 double format but it's laid out to be able to
replace a function to handle others if needed.

Tested in a driver program that has a duplicate vuprintf and
the content was pasted in once it looked sound enough to put
up a patch.

Change-Id: I6dae8624d3208e644c88e36e6a17d8fc9144f988
2019-07-19 22:07:41 -04:00
William Wilgus
de6618a271 Fix vuprintf fix possible %s buffer over-read
when precision is not specified memchr recieved -1 for count
count is unsigned so it looks in a potentially very large area
for a terminator and returns this whole area if \0 is not found

Instead we should use memchr when precision is specified
and if precision is not specified use strlen

Fixes 60+Mb Config.cfg files

Change-Id: Ic4d1439334588f999c9071235430c42df2af5cc4
2018-11-10 02:47:19 +01:00
William Wilgus
7c2295ea46 Diacritic.c add newline to EOF
Change-Id: Ide8934fa267bfb745fc397cdb7450f3ac0453174
2018-10-18 08:03:20 -04:00
William Wilgus
b977b77fb7 Optimize is_diacritic
is_diacritic is used for pretty much all of the text display sizing
Timing here matters, so important it uses a
priority buffer in order to cut down on searching the database.

This patch is verified functionally equlivalent but
saves 80 bytes and is ~20% faster for the clip+ I tested it on

Several things were done:

Optimizing the copy loop for the priority buffer

Globbing some operations together

but the main one has to do with the database structure its self
--
Rather than a bit packed struct it combines the lower 8 bytes into
one value [info] and uses flags to access the values instead

Change-Id: I475073419b647639ef1eeaa3b9213e4e1067c0db
2018-10-18 13:29:32 +02:00
Michael Giacomelli
0b2f5187a3 Don't enable full vuprintf file in bootloader. Saves ~2KB packed space when patching clip+ OF.
Change-Id: Ie03714778918bfb4a1087f60534d60ff349a8330
2018-05-23 00:07:57 +01:00
Franklin Wei
6a843ca2b2 Revert "Support floating-point formatting"
This reverts commit 01c6dcf6c7.

The hack isn't used in duke, so having it is redundant.

Change-Id: Ieb36d75718e0c2d1305440d08021744625117886
2017-12-24 19:22:17 -05:00
Franklin Wei
6416d96fbc fix red
Change-Id: I20f1bd6f0208f6108d68fb59206b09dd9da4f1af
2017-12-23 21:28:20 -05:00
Franklin Wei
a855d62025 Port of Duke Nukem 3D
This ports Fabien Sanglard's Chocolate Duke to run on a version of SDL
for Rockbox.

Change-Id: I8f2c4c78af19de10c1633ed7bb7a997b43256dd9
2017-12-23 21:01:26 -05:00
Franklin Wei
01c6dcf6c7 Support floating-point formatting
This is just a quick and dirty way to get %f formatting to work for
some games. It works.

Change-Id: I75585e0c6a0f9d6db41a87b71ca405b067d8b85d
2017-12-23 20:55:02 -05:00
Michael Sevakis
055e2115de Add a small 32-byte write buffer to fdprintf.
Avoids a call to write() for every output character. It doesn't
need to be very large to have a great effect on speed and realize
most of the potential.

Change-Id: I11820c1968ed7b20aa00e106a022c1b864b03d21
2017-11-28 09:01:17 -05:00
Michael Sevakis
f4c4221306 Convert i.MX31 and AMS target to use RTC interrupt
Instead of checking ticks, set a sticky dirty flag that indicates
that the RTC needs to be read. This gives a timely update and more
accurate readout without actually reading the RTC until it changes.
The implementation should atomically read the flag and clear it.
Setting the flag would typically happen in an RTC tick ISR.

Change-Id: I6fd325f22845029a485c502c884812d3676026ea
2017-11-21 07:52:02 -05:00
Michael Sevakis
5c9688961e Implement a much more capable vuprintf()
New support as well as some buggy support fixed.

Still no floating point support if ever that would be desired.

Support (*):
* Flags: '-', '+', ' ', '#', '0'

* Width and precision: 'n', '.n', '*' and '.*'

* Length modifiers: 'hh', 'h', 'j', 'l', 'll', 't', 'z'

* Radix: 'c', 'd', 'i', 'n', 'o', 'p/P', 's', 'u', 'x/X'

(*) Provision exists to switch lesser-used stuff on or off or when
certain functionality isn't desired (bootloader?). The compulsory
radixes are everything but 'o', 'n', 'p/P' and 'x/X' with length
modifiers being optional. The default setup is 'l', 'z', 'c', 'd',
'p/P', 's', 'u', 'x/X'.

* Move fdprintf() to its own file. It was in a strange place.

* Make callers compatible and fix a couple snprintf() bugs while
at it.

Could smush it down in size but I'm gonna get over the binsize
neurosis and just the let optimizer do its thing.

Change-Id: Ibdc613a9b6775802c188b29b9dd46c568c94f7c3
2017-11-21 05:00:27 -05:00
William Wilgus
e9de9c1452 Add boot from other volumes in bootloader on targets with HAVE_MULTIVOLUME
Adds the ability to load firmware from other drives on MULTIVOLUME targets
Mihail Zenkov <mihail.zenkov@gmail.com> had posted a hard coded patch
to allow this on several Sansa players, I made it more universal

Redirect file rockbox_main.<name> should placed in root of
drive you would like to be main, if this file empty or there a single
slash '/' firmware will be loaded from /.rockbox in root of this drive
If instead a /<*DIRECTORY*> is supplied in rockbox_main.<name> then
firmware will be loaded from /<dir>/.rockbox/

NOTES*

The directory can have multiple levels however..
leading slash MUST be included
trailing slash can be omitted
(eg. /test/.rockbox would be simply '/test' in the redirect file)

Redirect file will not work on internal drive (whatever is default boot drive)

Volume with the highest index containing redirect file will be loaded
first.

Firmware file is checked for boot data region, if missing, firmware
image will not be loaded.

On failure or if no redirect file is found load will fallback to
internal drive

Currently only Sansa Fuze+, Sansa Clip+,
Sansa Clip Zip, Sansa Fuzev2, and Sansa Fuzev1 are implemented.

Players (with HAVE_MULTIVOLUME)
will need #define HAVE_BOOTDATA and #define BOOT_REDIR "rockbox_main.<name>"
added to their config file

boot_data is implemented in crt0.s file (See g#1552)
ARM and IMX233 have aleady been implemented

Once these conditions are met <HAVE_MULTIBOOT> will be defined by config.h

Partitions on the drives are able to have a redirect as
well.

Change-Id: Iada3263919f6bcad7d0d7d8279b4239aafa07ee9
2017-10-29 17:53:04 +01:00
William Wilgus
41869a6534 Add boot data support to rockbox.
Bootdata is a special location in the Firmware marked by a magic header
The bootloader is able to copy information to the firmware by locating
this struct and passing data to the firmware when it is loaded but
before it is actually executed

Data is verified by a crc of the bootdata


Change-Id: Ib3d78cc0c3a9d47d6fe73be4747a11b7ad6f0a9e
2017-10-29 17:50:59 +01:00
Michael Sevakis
dbacee67c4 Optimize lld_remove() a bit
Just need to check prev and next for NULL to know whether to mess
with the head and/or tail pointers.

Change-Id: I0aee057111e11735b7806e7214af0a6038f0ab53
2017-04-13 18:59:45 -04:00
Michael Sevakis
bfd04df480 Dircache: Improve freed name memory recallocation
There's only a need to check every MAX_TINYNAME+1 bytes and that the
last character of the needed size 0xff in order to verify the size
of the block since the minimum indirectly-stored string is
MAX_TINYNAME+1.

Change-Id: Ic789376b8575bab9266fcd54c610db0961de5d7f
2017-03-21 23:11:55 -04:00
Boris Gjenero
05739efe8d Avoid having to wait for dircache builds if shut down too soon
When dircache scanning is happening in the background, the user
can shut down the device before it is complete. Then, reset_cache()
sets size to 0 before it is copied to last_size at the end of
build_volumes(). When saved last_size is zero, scanning happens in
the foreground during next startup.

Avoid shrinking the size if the build is suspended.

Change-Id: Ife133e0be0dc0dfd53a4de119f70dba014c7ee68
2017-03-21 21:04:36 -04:00
Michael Sevakis
6db80020b4 Do some housekeeping with fat.h and SECTOR_SIZE
Many includes of fat.h are pointless. Some includes are just for
SECTOR_SIZE. Add a file 'firmware/include/fs_defines.h' for that
and to define tuneable values that were scattered amongst various
headers.

Remove some local definitions of SECTOR_SIZE since they have to be
in agreement with the rest of the fs code anyway.

(We'll see what's in fact pointless in a moment ;)

Change-Id: I9ba183bf58bd87f5c45eba7bd675c7e2c1c18ed5
2017-03-12 22:05:44 -04:00
Michael Sevakis
70c929179b Dircache: Refine name allocation and error handling.
* 8 bits is enough to allow 260 character base names when five
bytes is the minimum indirect storage size (0..255->5..260).

* Don't truncate anything that's too long as that can lead to
bad behavior, simply don't include the offending entry in the
parent.

* Set the .tinyname flag to 1 by default to indicate that
the entry's name doesn't need freeing. Clear it only when
allocating indirect storage.

* Rename some things to help catch all instances

Change-Id: Iff747b624acbb8e03ed26c24afdf0fc715fd9d99
2017-03-12 21:09:16 -04:00
Michael Sevakis
e3081b35cd Fix a couple dircache oopsies.
Moving binding from queued to resolved was messed up if it was the
first queued one and there were other resolved files open at the
time of resolving it.

Dircache info for a directory about to be recursively scanned should
be filled before opening it. Would only affect a directory if it
happened to be opening while it was being initialized.

Change-Id: I26ccf219c382d7caf1424b5ddddc4793e74cb390
2017-03-08 11:51:34 -05:00
Michael Sevakis
8ff1b6b603 Remove FF_CREAT and FF_EXCL flags in from file code.
These flags aren't stored for an open file because they're simply
actions for open() to take, corresponding to O_CREAT and O_EXCL.
Just pass the oflag argument along to the deeper call, with some
minor filtering.

Change-Id: Ic8bcfba718ebf4228bdc45de3088af1974820557
2017-02-14 17:54:50 -05:00
Michael Sevakis
7373cf518f Restore dircache hookup in the database ramcache.
Do a few other changes to dircache and file code flags to
accomodate its demands.

Change-Id: I4742a54e8cfbe4d8b9cffb75faaf920dd907cf8a
2017-02-10 05:05:23 -05:00
Michael Sevakis
e5042fd090 Add some comments about the behavior of a couple path functions.
Critical reminders about the reasons path_dirname() and
path_basename() do certain things with a given kind of input and
how to interpret them.

Change-Id: I4e6ad29476bdd30abfb644f9360cc7dfd86298df
2017-02-07 02:45:26 -05:00
Michael Sevakis
72dc239299 Make sure dircache resolves outstanding references on volume root.
If a volume root was open at the beginning of a build, its dircache
reference wouldn't be resolved on an already open volume root
directory because the call to do it was simply omitted. Nothing
horribly bad unless a root were opened at mount time and kept open
long term.

Change-Id: I09de30ff8174ad1d14eeeb9539bd23fb51b9e31a
2017-02-06 03:21:25 -05:00
Michael Sevakis
29c493dd74 Fix a bug in disk.c that really wasn't affecting anything.
volume_onmount_internal() was being given the next volume to mount
instead of the one just mounted. Only dircache was being notified
for now, which always attempts to scan everything that needs to be
rebuilt, currently making the volume parameter value immaterial.

Put things in the right place and also set the disk sector
multiplier before notifying anybody of the new volume.

Change-Id: Ibc8f26c1d1eca672c753280b49fd8259fde51047
2017-02-06 02:25:22 -05:00
Michael Sevakis
58b849c451 Move intrinsic RTC implmentation differences to driver files
Some drivers set tm_wday just fine and do not need it coerced to
be correct. Others set tm_yday, so don't overwrite what the driver
sets; just zero it inside if it can't fill the field. Move calls
to set_day_of_week() to the sorts of drivers that presumably
required the hammer (FS#11814) in get_time() where the weekday
isn't locked to the date.

Change-Id: Idd0ded6bfc9d9f48fcc1a6074068164c42fcf24a
2017-01-26 23:07:49 -05:00
Michael Sevakis
15e1f592de Make consitent internal file API flag behvior, FF_PROBE.
FF_PROBE should leave nothing for caller to clean up whether
testing only the cache or permitting disk access. Less to worry
about.

Change-Id: Iea5aa3c1ae7f9025a9de528b127f08e490154048
2017-01-18 07:45:07 -05:00
Michael Sevakis
a931c76b3a Do some debug and preparatory work for ramcache and playlist
The file system rework introduced incompatibility between dircache
and the tagcache ramcache and playlist dircache path caching. This
update makes changes to filesystem code to reintegrate all that.

It also fixes a couple bugs that were found when vetting all the
code. The filestream cache was being reset without regard to
the stream even if it was shared in write mode (made work of
.playlist_control). Better handling of unmounting gives files a
better go at force-closing them without risk to disk integrity.

Did some miscellaneous pedantic changes. Improved efficiency of
testing a file's existence (a little) since the path parser will
be shared between file code and parsing for the sake of finding
dircache references, not duplicated as before.

This commit doesn't reenable said items just for the sake of
keeping changes separate and related.

Plan for the next is to enable dircache again for the playlists
(easy peasy) and reenable tagcache ramcache but *without* the
dircache path caching because it's rather substantial to change
in itself. The ramcache will still function without dircache.

Change-Id: I7e2a9910b866251fa8333e1275f72fcfc8425d2d
2017-01-17 14:35:36 -05:00
Michael Sevakis
0a5b0dd908 Dircache: Fix a tiny-block reclaim bug
Logic left over from before switching from NULL-terminated to
counted strings would prevent a single-byte tiny free block gap
from being properly reclaimed into free string bytes.

Due to rarity, not as disasterous to functionality so much as
wrong.

Change-Id: I68e0875b04bb0ab6cdead0fdf535144b9c1bc13e
2017-01-14 00:20:07 -05:00
Michael Sevakis
077e20664c Improve the implementation of a couple linked list routines.
ll_insert_next() and ll_remove_next() can be done more elegantly
by adding a level of indirection to reference the 'next' pointer.

Change-Id: If3ab2bc2a659b517c793749cfa9088938ae08d0d
2017-01-07 21:14:32 -05:00
Michael Sevakis
5c6ccb43b5 Fix track formatting problems in playlist.c
Some changes in behavior were made with filesystem code commit
for the sake of compatibility that changed expected behavior.

* Restore substitution of drive spec in fully-qualified DOS paths
with the playlists's volume spec (or root on univolume targets).
Drive-relative paths of the form "c:foo" (no separator after
':') will be treated as purely relative.

* Restore old behavior of preserving leading whitespace in the
source path and trimming only trailing tabs and spaces.

* Multivolume: Volume substition on fully-qualified UNIX/RB paths
has NOT been reintroduced (and perhaps wasn't intended in the
first place). They will not be modified because there is no
ambiguity to resolve. Doing so would prevent a playlist on
external storage from referencing a file on main storage without
qualifying it with "/<0>...".

* Plain relative paths are and always have been interpreted as
relative to the location of the playlist.

Change-Id: Ic0800cea79c59563b7bac20f8b08abb5051906c7
2017-01-07 19:10:02 -05:00
Cástor Muñoz
c7fc5ca6eb Fix (D)EBUG compilation errors on targets using FAT
Change-Id: I9517f9b470076a6febeafae76d735c2436812e7c
2015-10-09 20:45:01 +02:00
Franklin Wei
e4108a3726 Fix warning in firmware/common/structec.c
Change-Id: I3de9891042b7ae7ce695209c651bd075c861928d
2015-02-24 16:27:16 -05:00
Franklin Wei
08724860a8 Whitespace fixes in firmware/common/structec.c
Change-Id: I2a6c5d5bd0c5b8fb516e167df74dc1f18508d702
2015-02-24 16:21:59 -05:00
Thomas Jarosch
812406f430 Limit "struct dircache_runinfo" to file scope
Change-Id: Ib3edef9a4568605a36bdacde174dfa6bca2d26fa
2015-01-01 13:51:08 +01:00
nialv7
5fd5b13939 unicode: Fix getle16 and getbe16
Change-Id: I8e1df113eee156491fc9624d148eb64c388bd962
Reviewed-on: http://gerrit.rockbox.org/958
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
Tested: Chiwen Chang <rock1104.tw@yahoo.com.tw>
Reviewed-by: Nick Peskett <rockbox@peskett.co.uk>
Tested: Nick Peskett <rockbox@peskett.co.uk>
2014-09-21 07:42:49 +02:00
Michael Sevakis
c1bbaf4050 Fix path_trim_whitespace() sign extension.
It should have been implemented as interpreting chars as unsigned
so that code points >= 0x80 would not get sign-extended and seen as
negative values.

Fixes FS#12995 - path_trim_whitespace() assumes unsigned char

Change-Id: I514e369681e00151588585311a0b6c66b9b5200c
2014-09-15 23:07:34 -04:00
Michael Sevakis
0a66545487 Clean up a bit and get switch statement out of loop in walk_path()
It's nicer to look at and it obfuscated a bug where it should have
exited the loop instead of the case (you probably wouldn't observe
the effect very often).

Change-Id: I33f3c72c8bb7e11b9d418f66cf84efc3082a37b4
2014-09-02 15:57:18 -04:00
Michael Sevakis
802e0110db Fix a small late creep-in goof in path parsing on native targets
Anything of one dot and one character (e.g. ".a") would get treated as
"." because I left out a condition when converting to recursionless
parsing of relative components. Git 'er fixed up.

Change-Id: Id5603ce0858b419dc08b1d496b4b187a573595f9
2014-09-01 00:00:19 -04:00
Michael Sevakis
f3d60aea34 Hopefully fix most of the errors and warnings from the last push
Change-Id: I1a466b2d55f120796910039a0296ca324c58e891
2014-08-29 23:36:11 -04:00
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
21e2b595c2 Prevent spurious recompiles on account of changed version.
After a local commit, any file that included version.h would have to
be recompiled on account of the changed version string. This changes
version.h in the build directory to rbversion.h and includes the
preprocessor macro from rbversion.h in firmware/common/version.c so
that only that one file needs to be recompiled after a local commit
rather than a whole slew of them.

Change-Id: I900d97e3a24a0610698283416d97b4fa3a3a2cf6
Reviewed-on: http://gerrit.rockbox.org/937
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-08-28 15:48:56 +02:00
Michael Sevakis
eb63d8b4a2 Add common linked list functions
Forms implemented to a greater or lesser degree at the moment:
ll_*   = singly-linked list
lld_*  = doubly-linked list
lldc_* = doubly-linked circular list

Change-Id: Ieed5af50fc59165c8b14c3513b3b5d0e6f7de9fa
2014-08-16 00:27:01 -04:00
Marcin Bukat
e557951c94 crc-mi4: use const lookup table for crc
This doesn't touch external tools as I see no need for.

Change-Id: Ia69248c4b6a033c3772916525257e3540bddcffa
Reviewed-on: http://gerrit.rockbox.org/891
Tested: Sebastian Leonhardt <sebastian.leonhardt@web.de>
Reviewed-by: Marcin Bukat <marcin.bukat@gmail.com>
2014-07-07 12:54:50 +02:00
Thomas Martitz
506b8718fc application(ypr0): Fix mount option selected by the current codepage.
A missing comma messed the lookup table up :'( Be aware that the kernel
on the ypr0 doesn't support many codepages in which case its default (iso8859)
will be used.

Change-Id: Iaa4a4b8338fb047d29f6a4e2a80eba5c296d27ce
2014-02-28 07:22:37 +01:00
Thomas Martitz
6b01da8bed application: fix opendir() for "/" directory.
"/" couldn't be opened. This regression was introduced by 731072d. Trailing
slash should not be stripped for the root directory.

Change-Id: Idd2d9b1f33e7be789bcf432e586e6715eb4152f4
2014-02-26 00:24:51 +01:00
Thomas Martitz
731072de7a application: Remove trailing slashes from the input in opendir().
This is needed for readdir() and dir_get_info() to work properly because
they depend on hash/path matching.

Change-Id: Ibd23def10eebabd76cdddac2739a5274159e88a9
2014-02-25 09:52:07 +01:00
Thomas Martitz
5fd8dd1321 application: Speed up dir_get_info() further.
It's quite rare that it is called for a symlink to a directory. But it only
needs a second syscall to stat() if that happened. Therefore speed up the
common case by avoiding an unecessary second syscall.

Change-Id: I911105f76631ebccc7696a1540e9cf069a706000
2014-02-24 23:13:00 +01:00
Thomas Martitz
c27c3f10fd hosted/multidrive: Speed up readdir()/get_dir_info().
The two functions need to check whether they are called for a specific path
to implement the virtual mount point for the external storage. This
is statistically rare and a hit on the common case. Therefore speed up
the common case by performing integer comparision first, and only expensive
string construction and comparision if that succeeds.

Change-Id: I3c41fe073e1f4f8eb62d2b8556a36937c9cb8290
2014-02-24 23:07:37 +01:00
Thomas Martitz
f6c26d33a4 samsungypr0: Support or mounting the microsd
A thread polls the appropriate GPIO pin for sd card presence and mounts
using the mount system call.

Change-Id: I31ab41c4120f4af64eb6998b7e7b6f9051585efb
2014-02-23 20:23:52 +01:00
Thomas Martitz
0f928f8785 RaaA: Move directory related stuff from filesystem-unix.c into rbpaths.c.
Part of this change is to align sdlapp builds to other application targets
in that the sim_* wrappers are not used anymore (except for sim_read/write).
Path mangling is now done in rbpaths.c as well.

Change-Id: I9726da73b50a83d9e1a1840288de16ec01ea029d
2014-02-23 20:23:52 +01:00
Thomas Martitz
07f484824c codepages: Translate to linux codepage names for use on APPLICATION.
The iocharset mount option names the codepages slightly differently and
must be translated properly.

Change-Id: I147a256e3453136282244201c27225a30cdfdca0
2014-02-23 20:23:52 +01:00
Lorenzo Miori
e876f4df6d Samsung YP-R1 target port
This is the basic port to the new target Samsung
YP-R1, which runs on a similar platform as YP-R0.
Port is usable, although there are still
some optimizations that have to be done.

Change-Id: If83a8e386369e413581753780c159026d9e41f04
2014-02-05 09:56:21 +01:00
Marcin Bukat
7ab237b025 buflib: Add crc field protecting buflib cookie integrity
This should catch the case of buffer misuse which results
in corrupted cookie of next allocation. The check is performed
on move_block() so it may be a bit late.

There is buflib_check_valid() provided which checks the
integrity of all cookies for given context.
On DEBUG build with --sdl-thread this check is carried out
for core_ctx on every context switch to catch problems earlier.

Change-Id: I999d4576084592394e3dbd3bdf0f32935ff5f601
Reviewed-on: http://gerrit.rockbox.org/711
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
2014-01-16 10:17:39 +01:00
Amaury Pouly
193753aa1f Introduce volume_{present,removable} and fix invalid calls in apps/
The code was trying to probe for volume presence by calling drive layer
with volume index. It is a miracle it get unnoticed so far. Introduce
proper volume probing using the vol->drive map in the disk layer.

Change-Id: I463a5bcc8170f007cad049536094207d2ba3c6fc
Reviewed-on: http://gerrit.rockbox.org/669
Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
2013-11-20 21:34:04 +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
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
Amaury Pouly
9b7edbf609 fix yellow on simulator + multivolume
Change-Id: Idc6d0e2e8fb06c2df4cac13ad7253b0b8628c308
2013-01-15 22:59:29 +00:00
Thomas Martitz
efe73e143a Fix database tool.
It was also broken functionally, probably since a while.So restore the
functionality. Run it on the dap, the tcd files will be placed into .rockbox folder.

Change-Id: Id7a6ce4389dfaf99799258902be80d630af0601c
2012-07-31 10:33:27 +02:00
Dominik Riebeling
2d9c0bab54 Add support for cp1252 (Western European) codepage.
In Europe Windows defaults to its own codepage cp1252 (also known as "WinLatin"
or "Windows-1252"). cp1252 adds some characters to ISO-8859-1.

Some mp3 tagging software on Windows uses cp1252 instead of ISO-8859-1. This
violates the ID3 specification, which requires tags to be ISO-8859-1 or
Unicode. However, similar violations are made for other codepages and supported
by Rockbox using the "Default Codepage" setting. Add support for cp1252 to
enable people using such broken tools to override the correct decoding to get
their tags displayed properly.

Change-Id: I9f2ec478afe2503e99ee8e6609416c92b0f453e0
Reviewed-on: http://gerrit.rockbox.org/209
Reviewed-by: Jens Arnold <amiconn@rockbox.org>
Tested-by: Jens Arnold <amiconn@rockbox.org>
2012-05-19 01:42:53 +02:00
Bertrik Sikken
449dff44ce Calculate day-of-week after reading time from RTC. Should fix FS#11814
Change-Id: I31dc0b0db5272d16ae55790252e3963e1a91d5bb
2012-04-12 21:32:25 +02:00
Marcin Bukat
2f8b44aae2 Add RKW firmware file format loader
Change-Id: I5283fdcdb8d263fd9375a6d29396f82650aeb686
2012-03-04 00:34:26 +01:00
Frank Gevaerts
efd25bf6db Disable some more sim_ and app_ redirection for __PCTOOL__.
This makes checkwps build again for apps

Change-Id: I6fcd299076bd201053012d09e208a0845c2145e2
2012-03-03 20:23:51 +01:00
Thomas Martitz
295c1c1e8b checkwps: Fix buildall.sh and some RaaA/ypr0 versions.
Change-Id: I5889743e94ed568c8f7dcc50de0b03b8421969f7
2012-02-10 20:27:59 +01:00
Thomas Martitz
c94cf3b888 Move optimized ffs to firmware/asm, using the new automatic-asm-picking infrastructure.
Change-Id: I5e7bdc8be7de50ef604c16078857fff1b84650dc
2012-01-22 18:46:45 +01:00
Thomas Martitz
a035261089 Move optimized memcpy and friends and strlen to firmware/asm,
using the new automatic-asm-picking infrastructure.
2012-01-22 18:46:45 +01:00
Thomas Martitz
5d13ecc4a8 android/ypr0: Merge fs-*.c to generic filesystem-unix.c.
Change-Id: I52e2c29346baf0d282243880477cd149311ce3d1
2012-01-21 18:39:19 +01:00
Thomas Martitz
20b662a946 rbpaths: Add new special dir HOME_DIR for RaaA.
HOME_DIR is intended for not-so-advanced files which shall be user
visible, and thus not in /.rockbox. Therefore HOME_DIR is translated
to $HOME on RaaA, /sdcard on android, the internal memory on ypr0
and "/" on native targets.

ROCKBOX_DIR ("/.rockbox") already existed as special and is translated
to whatever the real rockbox dir is on the target (e.g. /sdcard/rockbox
on android), but it's not suitable for some files we generate
(e.g. battery-bench.txt).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31430 a1c6a512-1295-4272-9138-f99709370657
2011-12-25 20:11:18 +00:00
Thomas Martitz
249bba03f1 Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.

The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).

Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.

This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.

Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.

Flyspray: FS#12348
Author: Lorenzo Miori, myself

Merry christmas to ypr0 owners! :)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
Amaury Pouly
ba2740a5b8 disk: fix sector multiplier init, also remove a test which has became obsolete
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31356 a1c6a512-1295-4272-9138-f99709370657
2011-12-19 00:40:11 +00:00
Boris Gjenero
ff1c567417 Remove USB time sync code when there's no RTC.
Without an RTC, Rockbox doesn't keep time. In that situation, USB time sync
previously did nothing but reported success. After this change, the USB time
sync request won't be recognized on those targets.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31319 a1c6a512-1295-4272-9138-f99709370657
2011-12-16 00:09:28 +00:00
Boris Gjenero
8414a44ad4 Remove conditional added around set_day_of_week in r31301.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31305 a1c6a512-1295-4272-9138-f99709370657
2011-12-15 21:49:48 +00:00
Boris Gjenero
871c7bd34c Add conditionals around functions that are only needed when RTC is present.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31301 a1c6a512-1295-4272-9138-f99709370657
2011-12-15 21:38:23 +00:00
Amaury Pouly
5ab697e8e1 Really fix red
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31273 a1c6a512-1295-4272-9138-f99709370657
2011-12-15 17:22:47 +00:00
Amaury Pouly
853638274d Fix red
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31272 a1c6a512-1295-4272-9138-f99709370657
2011-12-15 17:19:59 +00:00
Amaury Pouly
3a6e3c254e Add support for for per-drive logical sector size. This allows targets to have a different logical sector size for the internal storage and the sd card, like on the fuze+ for example.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31270 a1c6a512-1295-4272-9138-f99709370657
2011-12-15 17:07:19 +00:00
Jonathan Gordon
6461f74ae4 Try $RBROOT before $HOME when looking for the sdl apps rockbox root dir
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31151 a1c6a512-1295-4272-9138-f99709370657
2011-12-05 12:07:23 +00:00
Rafaël Carré
09f6556e22 Compile fix for mingw-w64
Don't build str(n)casecmp as functions if they are already defined by preprocessor

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31147 a1c6a512-1295-4272-9138-f99709370657
2011-12-04 21:07:06 +00:00
Fred Bauer
a71e87f132 Update some missed pointers when moving the dircache allocation
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31028 a1c6a512-1295-4272-9138-f99709370657
2011-11-19 14:57:56 +00:00
Thomas Martitz
1645c148e3 Simulate usb plugging on the sim better using sim_tasks.
Now all threads need to ack the connection like on real target, dircache is unloaded and playback stops accordingly.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31009 a1c6a512-1295-4272-9138-f99709370657
2011-11-17 18:40:00 +00:00
Thomas Martitz
9886126858 Fix FS#12325 - screen corruption on early usb.
When booting with USB inserted, the dircache build can get interrupted by the usb connection, in which case the dircache buffer is freed.
Due to a bug the re-creation of dircache used the old freed buffer and overwrite new allocs (causing screen corruption).

Set allocated_size to 0 to make it not take the code path that assumes an existing buffer,
and bring that and freeing together in the code.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30845 a1c6a512-1295-4272-9138-f99709370657
2011-10-28 16:38:52 +00:00
Fred Bauer
8e18dc85cf fix sign error
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30812 a1c6a512-1295-4272-9138-f99709370657
2011-10-21 06:45:26 +00:00
Robert Kukla
d25341a032 revert r30566 and r30567 to fix FS#12294 (superfloppy not mounting)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30632 a1c6a512-1295-4272-9138-f99709370657
2011-10-02 11:39:31 +00:00
Torne Wuff
e12a832758 Also remove the fat_partition_types array.
If we aren't going to check for the partition type, we don't need the array of
known FAT partition types.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30567 a1c6a512-1295-4272-9138-f99709370657
2011-09-17 22:49:30 +00:00
Torne Wuff
36d04ac76e Allow any partition type, not just known FAT types.
Instead of only mounting partitions with a FAT partition type, try any
partition that isn't type 0 (unallocated) or 5 (extended). This makes it easier
to reformat SDXC cards which have the exFAT partition type, and also brings us
in line with pretty much every other OS at this point. Anything with a
valid-looking FAT superblock will get mounted.



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30566 a1c6a512-1295-4272-9138-f99709370657
2011-09-17 22:45:59 +00:00
Thomas Martitz
7e14b935df Dircache: Allow dircache to be enabled without reboot.
Also add two dircache function, one of which does what dircache_disable()
did previously as this now also frees the dircache buffer.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30393 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 21:07:46 +00:00
Thomas Martitz
baa070cca6 GSoC/Buflib: Enable compaction in buflib.
This enables the ability to allocate (and free) memory dynamically
without fragmentation, through compaction. This means allocations can move
and fragmentation be reduced. Most changes are preparing Rockbox for this,
which many times means adding a move callback which can temporarily disable
movement when the corresponding code is in a critical section.

For now, the audio buffer allocation has a central role, because it's the one
having allocated most. This buffer is able to shrink itself, for which it
needs to stop playback for a very short moment. For this,
audio_buffer_available() returns the size of the audio buffer which can
possibly be used by other allocations because the audio buffer can shrink.

lastfm scrobbling and timestretch can now be toggled at runtime without
requiring a reboot.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30381 a1c6a512-1295-4272-9138-f99709370657
2011-08-30 14:01:45 +00:00