summaryrefslogtreecommitdiff
path: root/firmware/common (follow)
Commit message (Collapse)AuthorAge
* Optimize lld_remove() a bitMichael Sevakis2017-04-13
| | | | | | | Just need to check prev and next for NULL to know whether to mess with the head and/or tail pointers. Change-Id: I0aee057111e11735b7806e7214af0a6038f0ab53
* Dircache: Improve freed name memory recallocationMichael Sevakis2017-03-21
| | | | | | | | | 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
* Avoid having to wait for dircache builds if shut down too soonBoris Gjenero2017-03-21
| | | | | | | | | | | | 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
* Do some housekeeping with fat.h and SECTOR_SIZEMichael Sevakis2017-03-12
| | | | | | | | | | | | | | 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
* Dircache: Refine name allocation and error handling.Michael Sevakis2017-03-12
| | | | | | | | | | | | | | | | | * 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
* Fix a couple dircache oopsies.Michael Sevakis2017-03-08
| | | | | | | | | | | | 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
* Remove FF_CREAT and FF_EXCL flags in from file code.Michael Sevakis2017-02-14
| | | | | | | | | 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
* Restore dircache hookup in the database ramcache.Michael Sevakis2017-02-10
| | | | | | | Do a few other changes to dircache and file code flags to accomodate its demands. Change-Id: I4742a54e8cfbe4d8b9cffb75faaf920dd907cf8a
* Add some comments about the behavior of a couple path functions.Michael Sevakis2017-02-07
| | | | | | | | 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
* Make sure dircache resolves outstanding references on volume root.Michael Sevakis2017-02-06
| | | | | | | | | | 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
* Fix a bug in disk.c that really wasn't affecting anything.Michael Sevakis2017-02-06
| | | | | | | | | | | | 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
* Move intrinsic RTC implmentation differences to driver filesMichael Sevakis2017-01-26
| | | | | | | | | | | 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
* Make consitent internal file API flag behvior, FF_PROBE.Michael Sevakis2017-01-18
| | | | | | | | 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
* Do some debug and preparatory work for ramcache and playlistMichael Sevakis2017-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Dircache: Fix a tiny-block reclaim bugMichael Sevakis2017-01-14
| | | | | | | | | | | 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
* Improve the implementation of a couple linked list routines.Michael Sevakis2017-01-07
| | | | | | | 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
* Fix track formatting problems in playlist.cMichael Sevakis2017-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix (D)EBUG compilation errors on targets using FATCástor Muñoz2015-10-09
| | | | Change-Id: I9517f9b470076a6febeafae76d735c2436812e7c
* Fix warning in firmware/common/structec.cFranklin Wei2015-02-24
| | | | Change-Id: I3de9891042b7ae7ce695209c651bd075c861928d
* Whitespace fixes in firmware/common/structec.cFranklin Wei2015-02-24
| | | | Change-Id: I2a6c5d5bd0c5b8fb516e167df74dc1f18508d702
* Limit "struct dircache_runinfo" to file scopeThomas Jarosch2015-01-01
| | | | Change-Id: Ib3edef9a4568605a36bdacde174dfa6bca2d26fa
* unicode: Fix getle16 and getbe16nialv72014-09-21
| | | | | | | | | 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>
* Fix path_trim_whitespace() sign extension.Michael Sevakis2014-09-15
| | | | | | | | | | 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
* Clean up a bit and get switch statement out of loop in walk_path()Michael Sevakis2014-09-02
| | | | | | | | 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
* Fix a small late creep-in goof in path parsing on native targetsMichael Sevakis2014-09-01
| | | | | | | | 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
* Hopefully fix most of the errors and warnings from the last pushMichael Sevakis2014-08-29
| | | | Change-Id: I1a466b2d55f120796910039a0296ca324c58e891
* Rewrite filesystem code (WIP)Michael Sevakis2014-08-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Prevent spurious recompiles on account of changed version.Michael Sevakis2014-08-28
| | | | | | | | | | | | | | 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>
* Add common linked list functionsMichael Sevakis2014-08-16
| | | | | | | | | 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
* crc-mi4: use const lookup table for crcMarcin Bukat2014-07-07
| | | | | | | | | 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>
* application(ypr0): Fix mount option selected by the current codepage.Thomas Martitz2014-02-28
| | | | | | | | 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
* application: fix opendir() for "/" directory.Thomas Martitz2014-02-26
| | | | | | | "/" couldn't be opened. This regression was introduced by 731072d. Trailing slash should not be stripped for the root directory. Change-Id: Idd2d9b1f33e7be789bcf432e586e6715eb4152f4
* application: Remove trailing slashes from the input in opendir().Thomas Martitz2014-02-25
| | | | | | | This is needed for readdir() and dir_get_info() to work properly because they depend on hash/path matching. Change-Id: Ibd23def10eebabd76cdddac2739a5274159e88a9
* application: Speed up dir_get_info() further.Thomas Martitz2014-02-24
| | | | | | | | 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
* hosted/multidrive: Speed up readdir()/get_dir_info().Thomas Martitz2014-02-24
| | | | | | | | | | 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
* samsungypr0: Support or mounting the microsdThomas Martitz2014-02-23
| | | | | | | A thread polls the appropriate GPIO pin for sd card presence and mounts using the mount system call. Change-Id: I31ab41c4120f4af64eb6998b7e7b6f9051585efb
* RaaA: Move directory related stuff from filesystem-unix.c into rbpaths.c.Thomas Martitz2014-02-23
| | | | | | | | 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
* codepages: Translate to linux codepage names for use on APPLICATION.Thomas Martitz2014-02-23
| | | | | | | The iocharset mount option names the codepages slightly differently and must be translated properly. Change-Id: I147a256e3453136282244201c27225a30cdfdca0
* Samsung YP-R1 target portLorenzo Miori2014-02-05
| | | | | | | | | 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
* buflib: Add crc field protecting buflib cookie integrityMarcin Bukat2014-01-16
| | | | | | | | | | | | | | | 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>
* Introduce volume_{present,removable} and fix invalid calls in apps/Amaury Pouly2013-11-20
| | | | | | | | | | 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>
* Cleanup MV/MD macros a little.Michael Sevakis2013-08-17
| | | | | | | | | | 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
* Move load_firmware() to separate fileMarcin Bukat2013-06-27
| | | | | | | | 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>
* fix yellow on simulator + multivolumeAmaury Pouly2013-01-15
| | | | Change-Id: Idc6d0e2e8fb06c2df4cac13ad7253b0b8628c308
* Fix database tool.Thomas Martitz2012-07-31
| | | | | | | 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
* Add support for cp1252 (Western European) codepage.Dominik Riebeling2012-05-19
| | | | | | | | | | | | | | | | | 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>
* Calculate day-of-week after reading time from RTC. Should fix FS#11814Bertrik Sikken2012-04-12
| | | | Change-Id: I31dc0b0db5272d16ae55790252e3963e1a91d5bb
* Add RKW firmware file format loaderMarcin Bukat2012-03-04
| | | | Change-Id: I5283fdcdb8d263fd9375a6d29396f82650aeb686
* Disable some more sim_ and app_ redirection for __PCTOOL__.Frank Gevaerts2012-03-03
| | | | | | This makes checkwps build again for apps Change-Id: I6fcd299076bd201053012d09e208a0845c2145e2
* checkwps: Fix buildall.sh and some RaaA/ypr0 versions.Thomas Martitz2012-02-10
| | | | Change-Id: I5889743e94ed568c8f7dcc50de0b03b8421969f7