Commit graph

11463 commits

Author SHA1 Message Date
Richard Goedeken
f3b522cac6 bugfix: for Eros Q / Surfans F20, when the scroll wheel is moved, in addition to resetting the power-off timer, we also need to reset the backlight timer and turn it on in case it's currently off.
Change-Id: I73b463e74727a2d00b0d4ce599f0cc611fb98685
2022-12-07 08:16:13 -05:00
Richard Goedeken
d06cf3ac2d bugfix: for ErosQ/SurfansF20, reset poweroff timer when scroll wheel is moved so that we dont blank the screen while the user is scrolling through a list
Change-Id: Ifdce301e2d75e3f6f54fba5b3eef15b2141cb954
2022-12-04 10:16:14 -05:00
Aidan MacDonald
7819a06d74 Add rectangle utility functions
Change-Id: Iebcddfc36733aab5131d2fcb9fd8c8a32eff84b8
2022-12-01 12:36:28 -05:00
Aidan MacDonald
52ca658069 x1000: Add support for DS35x1GAxxx flash chips
This flash chip is found on some Surfans F20 units. For our purposes
it's the same as the GD5F1GA4xExx so just #define an alias instead of
adding a whole new chip struct.

Change-Id: I2f4c4fbf1faf3a0c7a1503534430afacbddc426e
2022-12-01 12:11:46 -05:00
Solomon Peachy
0c7394e39a ata: Improve heuristics for detecting SSDs
mSATA devices should be new enough to report their form factor proprerly

Change-Id: I2605c8ee0c97432e6e03bd78719e12bb14837f8d
2022-11-27 09:15:29 -05:00
Solomon Peachy
65db4acabe pcf56065: Fix a compile warning uncovered by GCC8
Basically, use '!' instead of '~' on bools.

Change-Id: If0d94b294e69a939101e16808d4adc50a9fe1c81
2022-11-27 01:20:03 -05:00
William Wilgus
eb9b3513fa Remove strtok_r.c
strtokspn emulates the original libc function

Change-Id: Ie6cd033ebf5d4f78ce4462f19bfb8ffb16d04ae1
2022-11-20 23:37:20 -05:00
William Wilgus
016090b2a4 Bug fix multiboot.c get_redirect_dir didn't reach index 0
add_path[0] was never reached

Change-Id: If375a70832b0666d87f7d87b136cc377484b9ec1
2022-11-17 05:36:55 -05:00
William Wilgus
00f915d92e strnatcmp.c use a fn pointer to call strcmp/strcasecmp
Change-Id: I2bfaeec4cf2af4bed8f0781bcfa24b0b104fb22a
2022-11-17 04:15:38 -05:00
William Wilgus
972810f6cf strlcpy finish cleanup
remove strlcpy & strlcat from string.h

document suspicious strlcpy call

convert strlcat.h users to string-extra

Change-Id: I313e75db86385c0e6d1aee75d252093be4935f60
2022-11-17 01:54:46 -05:00
William Wilgus
7733abce29 strlcat use strlcpy for the copy part
Change-Id: I729b292a58d9f6542e58ac01d1dc90d36175886d
2022-11-16 00:36:47 -05:00
William Wilgus
f6c719d7ec replace strlcpy with strmemccpy
replace applicable calls to strlcpy with calls to strmemccpy
which null terminates on truncation

in theory the strmemccpy calls should be slightly faster since they
don't traverse the rest of the source string on truncation
but I seriously doubt there is too much of that going on in the code base

Change-Id: Ia0251514e36a6242bbf3f03c5e0df123aba60ed2
2022-11-14 23:56:16 -05:00
William Wilgus
b25a9d8f99 add memccpy.c
Not sure if this is worth the added bin size yet but I will
see where I can use it to try and make it worth it

Change-Id: Icc299d3986172ff224a14be48da3bf065d728a66
2022-11-15 00:56:01 -04:00
William Wilgus
034b6d5bfb Remove some shadowed variables identified by -Wshadow
there are plenty more but these are the low hanging fruit

Change-Id: I86d9f4f56e8cd9b381d1bf6a6679cd58c6a4004d
2022-11-14 09:01:43 -05:00
William Wilgus
f94a14b859 increase the number of file & directory handles for devices with more ram
Change-Id: I06f517b3b1388aa43fe1aa9edae53c92d0b137e8
2022-11-14 08:21:29 -05:00
William Wilgus
a634557a88 fix strptokspn, add strcspn, fix splash.c
fix off by 1 error in strptokspn, add strcspn, fix fallout in splash.c

Change-Id: I61475d9633fc35db5a8ae30cbe588f69f2f7fabc
2022-11-13 01:14:49 -05:00
William Wilgus
c756a8a89d make splash split on control characters
splits on spaces also considers \r\n\f\v\t as mandatory breaks

I'm still working on the strptokspn function
my goal is to use it directly rather than storing the matched char
and modifying the source string with \0 in order to tokenize the output
--Done

Change-Id: I7f378b5b9c4df8f10899b9a55a98950afb3931dc
2022-11-12 06:22:16 -05:00
Aidan MacDonald
d09fb6bb6b x1000: Pass CPM scratch register to the bootloader
Change-Id: Iaef4606dc6f3cb9904d87ee92db69fb9ef48bcb0
2022-10-28 20:58:26 +01:00
Aidan MacDonald
744ea2ff43 x1000: Allow SPL and bootloader to pass arguments to next stage
Change-Id: I61591d704c14acf06cd192a6e9355f0a9c25d0d8
2022-10-28 20:32:38 +01:00
Aidan MacDonald
9e258652c4 x1000: Add a basic sanity check for bootloader backups
The bootloader backup is intentionally simple, but it's a little
*too* simple. Add a sanity check to make sure what we're backing
up or restoring contains the first 8 bytes of the SPL header.
This isn't going to catch all possible problems, but it'll stop
obviously non-functional backups from being restored.

Change-Id: I6e80351aeb96c467f0514bd0ecd77d94ff72a8f8
2022-10-28 20:32:38 +01:00
Aidan MacDonald
4bd97c6535 mips: consolidate exception handling, add exception backtraces
Merge the x1000 and jz47xx exception handling code since they use
the same exception vectors and handlers. The interrupt handler is
now called from the common exception vector, but remains separate
for each board since they have different IRQ layouts.

The new exception handler can provide a stack traceback from the
interrupted code, rather than the (uninteresting) caller traceback
displayed by panicf. This allows you to see what led up to a null
pointer deref or division by zero, which makes it _much_ easier to
track down errors that occur in common leaf functions like strcmp.

Change-Id: I59a0ebb5e40fcb36505c3bfdb47f8cac2f9936b1
2022-10-17 09:04:18 -04:00
Aidan MacDonald
5e864ecde9 linked list: add lld_insert_prev/next()
Change-Id: I55ff061ccc0e6e2dad3125a8150c082c163db329
2022-10-16 16:10:24 +01:00
Aidan MacDonald
ee9679993b linked list: inline list init functions
These functions are so trivial it's always cheaper to inline them.

Change-Id: Ie0c77c8b6e7a716312105445a22e62ff57a76d90
2022-10-16 16:10:24 +01:00
Aidan MacDonald
8bf8036021 lcd: Fix clear_viewport on grayscale displays
The original drawmode change was "x = (~x & INVERSEVID) | SOLID"
which is essentially XOR'ing the INVERSEVID bit, but I changed it
to mask out INVERSEVID by mistake.

Fixes 44b9785465.

Change-Id: I87b059b89aea9c31a8ff408016264285e67ca80c
2022-10-16 15:41:50 +01:00
Aidan MacDonald
1718cf5f8a Convert a number of allocations to use buflib pinning
Several places in the codebase implemented an ad-hoc form of pinning;
they can be converted to use buflib pinning instead.

Change-Id: I4450be007e80f6c9cc9f56c2929fa4b9b85ebff3
2022-10-16 14:50:39 +01:00
Aidan MacDonald
5e7c34f5b3 lcd: Fix off by one error in clipping check
When I converted all the clipping checks in 4b8fe8acd1 I messed
up the hline and vline checks. This produced some weird panics on
the Shanling Q1, probably memory corruption -- but somehow it got
past AddressSanitizer. Go figure.

Change-Id: I84820c23a491d422218c72d2d5e199e2fc7def0f
2022-10-15 20:56:11 +01:00
William Wilgus
12ef045fdf move buflib_free invalid handle check to the function
allow buflib_free to check for invalid or already freed handles
within the function -- remove all the invalid handle guards thru core_free

Change-Id: Ibdcbc82760fc93b674c42283fca420d94907df8e
2022-10-15 09:26:58 -04:00
Solomon Peachy
418169aff8 Revert "Remove YUV blitting functions and LCD modes"
This reverts commit fe6aa21e9e.

Change-Id: I8bb1e5d6c52ed1478002d2140ef494ec5d62b8e3
2022-10-13 11:08:06 -04:00
Aidan MacDonald
c607bfac6f lcd: Fix update_viewport() for non-default stride viewports
Simplify update_viewport() by calling update_viewport_rect().
The resulting LCD driver calls are the same either way and
for some reason, update_viewport() didn't handle non-default
stride viewports correctly.

Change-Id: Ic34d3d40e4f758db897cb3944d9d7475bbdb4d2c
2022-10-12 08:06:12 -04:00
Aidan MacDonald
9549ddabba lcd: Fix bug in grayscale clear_display() implementation
clear_display() on grayscale LCDs sets the number of scrolling
lines to 0 but that's wrong, the scollers need to be shut down
first. Call scroll_stop() for that, as is done on color LCDs.

Change-Id: I75fb6839ed04f6fe1eb8e2855c8db820fcedddb8
2022-10-12 07:58:57 -04:00
Aidan MacDonald
44b9785465 lcd: Move grayscale clear_viewport() to lcd-bitmap-common.c
All grayscale LCDs have the same clear_viewport() implementation.

Change-Id: I087ac3be824c97a1f42857b4e2fedb0675d453fa
2022-10-12 07:58:57 -04:00
Aidan MacDonald
f737e5025d lcd: Refactor viewport clipping functions
There's no need to generate separate copies of these functions
for main and remote LCDs; we can just pass the viewport directly.

Change-Id: I20aa04a58d327b479a942708e161068bd6a3357b
2022-10-12 07:34:15 -04:00
Aidan MacDonald
6acc8a81a7 lcd: Cosmetic variable renaming
Assign lcd_current_viewport to a local variable for easier typing.

Change-Id: Ib5d4283fd1c5a21c94d3bd3c2c28ce206383fb96
2022-10-12 07:34:15 -04:00
Solomon Peachy
2928b71a69 mips: Work around an issue with GCC 8.
Change-Id: I9867674978ab6d4c99f5fa67c93e5b830531aefd
2022-10-10 08:24:33 -04:00
Solomon Peachy
af75619585 usb dwc2: Fix a potential garbage string print in an error path.
Change-Id: I56f8ee9bc883baac8707f136be396bb2669f911b
2022-10-10 08:24:33 -04:00
Aidan MacDonald
f8e968991d lcd: Move parameter handling calls to lcd-bitmap-common.c
No need to reimplement the same drawmode, getwidth, etc, calls
for each pixel format.

Change-Id: Ibbe32814f72e1492c190ba578cec303c1cf29b12
2022-10-09 22:07:49 +01:00
Aidan MacDonald
eaccdeeae2 lcd: Remove internal function get_viewport()
Only the scroll engine calls this, but it's easily replaced
by the return value of set_viewport_ex().

Change-Id: I2e2c8234f969bc07c9ff7d864e58551115175e26
2022-10-09 22:07:48 +01:00
Aidan MacDonald
4f9e4ddb99 lcd: Consolidate drawpixel, drawline, and drawrect functions
All three functions are nearly identical regardless of the
LCD pixel format. Consolidate them into a generic version in
lcd-bitmap-common.c.

Change-Id: Iab13429ea27ea2b0150b9004535bd27d4a4121a0
2022-10-09 22:07:46 +01:00
Aidan MacDonald
4b8fe8acd1 lcd: Consolidate in-viewport clipping routines
In-viewport clipping code is duplicated across 8 files, making
it a chore to change anything related to clipping; refactor the
clipping logic into dedicated functions.

Change-Id: I4ab20bb3c59b0406098d0c7d23833025f17a320a
2022-10-09 22:07:44 +01:00
Aidan MacDonald
fe6aa21e9e Remove YUV blitting functions and LCD modes
None of this is needed now that mpegplayer is gone.

Change-Id: I360366db8513e4d988021e8d7b7d8eb09930efb8
2022-10-03 13:30:01 +01:00
Aidan MacDonald
b371ff1f47 mrobe500: Fix missing parentheses in #define
Change-Id: Ifbba50a951fb3212eabe430dfef6868a7ad5e391
2022-10-03 13:29:52 +01:00
Aidan MacDonald
3bc6408bbe lcd: Fix incorrect use of LCD_STRIDEFORMAT for remote LCDs
The get_address_fn implementations for some remote LCDs were
checking LCD_STRIDEFORMAT unconditionally, but that macro is
only valid for the main LCD. The remote LCD code only supports
horizontal strides, so when compiling for a remote LCD, force
the use of horizontal stride addressing.

This fixes a buffer overflow and out of bounds write that occurs
with the M:Robe 500 remote LCD. (Tested with sim + ASan only.)

Change-Id: I99c6aa11d38f5105b096fc448948b9ec1b27dfe6
2022-09-30 10:49:39 +01:00
Aidan MacDonald
f373c97c90 Define LCD_STRIDEFORMAT unconditionally
Instead of putting "#ifdef LCD_STRIDEFORMAT" at every usage of the
macro it's simpler to have config.h define LCD_STRIDEFORMAT to the
default of horizontal stride when the target leaves it unspecified.

Change-Id: Ib187012aad65ac678dbd837b1464a83bad722411
2022-09-30 10:42:49 +01:00
Solomon Peachy
9ed36ec22f FS#13361: Fix some compilation under MacOS (Michael Landherr)
Change-Id: Id7e0576e355a1d71493fb7b277fd92f38b7edab4
2022-09-27 10:00:03 -04:00
Aidan MacDonald
09cb3c7843 lcd: Remove HAVE_VIEWPORT_CLIP
This was only enabled for the mrobe500 and sansaconnect targets.
Most targets are therefore running without this "safety" measure,
and presumably we'd have noticed long ago if there was a problem.
So in all likelihood this is just a bunch of dead code that we
don't need to carry around.

Change-Id: I7d27701a38b1c2a985ee73fa6f277ad215d8d385
2022-09-27 14:13:15 +01:00
Aidan MacDonald
464889ecee Fix red in e75a3fb8
Change-Id: I2e98f68d03df757688b6c556b69d934c12f40a7c
2022-09-25 12:23:40 +01:00
Aidan MacDonald
e75a3fb8c7 usb: add debounce interval for USB status by event
This makes status by event debounce status changes over
a 200ms period, which is what polling was already using.

This is helpful on targets where events are excessively
noisy and generate a lot of transitions during insertion
and extraction.

Change-Id: I0eae2cca93aaa865e33c94a1318c27e91c7f7c4b
2022-09-25 06:49:11 -04:00
Aidan MacDonald
f47aa584a8 buflib: add pin/unpin operation
An allocation is pinned by calling buflib_pin() to up its pin count.
The pin count is like a reference count: when above 0, buflib won't
move the allocation and won't call its move callbacks. This makes it
safe to hold the pointer returned by buflib_get_data() across yields
or allocations.

Note that pinned allocations can still shrink because there are some
use cases where this would be valid, if buffer users coordinate with
the shrink callback.

Change-Id: I0d0c2a8ac7d891d3ad6b3d0eb80c5b5a1b4b9a9d
2022-09-19 15:09:51 -04:00
Aidan MacDonald
ecfec3e9bf buflib: add handle_to_block_end
Change-Id: I598cf32bc8cd08ab4bca3827645e0a38b284468f
2022-09-19 15:09:51 -04:00
Aidan MacDonald
88b21731fc buflib: enable all paranoia checks
Since allocation is infrequent in Rockbox enabling the extra
checks to catch memory corruption is probably worth the time
and code size cost.

Change-Id: If0d701421054328c57b69e4d0af30759d799d158
2022-09-19 15:09:51 -04:00
Aidan MacDonald
8f896b14d3 buflib: remove the 'name' member from union buflib_data
Using a length 1 char array to point to the name buffer triggers
a -Warray-bounds warning from GCC when fortified strcpy is used.

This type of construct isn't safe in general -- if the compiler
makes assumptions based on the array bound it can create subtle
bugs when accessing the array out of bounds.

Instead, add a function get_block_name() which returns a pointer
to the name field by casting. This suppresses the warning and it
should be a bit more portable.

Change-Id: I25d4f46f799022ad0ec23bef0218f7595cc741ea
2022-09-19 15:09:51 -04:00
Aidan MacDonald
6e9b1b344b buflib: remove buflib_print_allocs / buflib_print_blocks
These don't have any users and there is already another way to
print blocks (which is actually used by the debug menu).

Change-Id: Ic6a4f874c6499c42bc046e8af3e4aaddc9e68276
2022-09-19 15:09:51 -04:00
Aidan MacDonald
3090cf0da4 buflib: update BUFLIB_ALLOC_OVERHEAD
Allocation overhead should be 5 units, not 6.

Change-Id: I30aa0925aa49eb25d232f7de2bf8b8ce1509d862
2022-09-19 15:09:51 -04:00
Aidan MacDonald
59edcc57a2 buflib: omit CRC field if CRC paranoia is not enabled
If we don't check or generate CRCs then the CRC field can be left
out of the header, which reduces buflib overhead slightly.

Change-Id: I08b4cf77a701d8f6da453e019a0373d858a79ae4
2022-09-19 15:09:51 -04:00
Aidan MacDonald
dcc4e54b77 buflib: refactor CRC checks as paranoia
Move CRC checking and updating behind a paranoia bit, like the
other checks, so it can be enabled and disabled.

Change-Id: Icff66c842cbd5af2d99aa91e6c40447a64e6d4b2
2022-09-19 15:09:51 -04:00
Aidan MacDonald
f82f3044a7 buflib: add paranoia checks for handles
Handle checks ensure that the data in the handle table points
within buflib memory and checks handle entry pointers in block
headers before dereferencing them.

Change-Id: Ic16f1b81c1a0ea63c0e7f48d87938293b75c2419
2022-09-19 15:09:51 -04:00
Aidan MacDonald
73b9b227eb buflib: add block length paranoia checks for loops
Tighten up checking by adding length checks to loops which
ensure the iteration stays within bounds. Check is disabled
by default and can be enabled using a BUFLIB_PARANOIA bit.

Change-Id: I35e911e0878797d5ebf732be548ca659f6910fe0
2022-09-19 15:09:51 -04:00
Aidan MacDonald
b12427741a buflib: clean up and refactor to improve maintainability
Buflib is written with a lot of hardcoded offsets to header fields,
arbitrary pointer arithmetic, and similar but not quite duplicated
code, making maintenance a nightmare.

Most of the pointer arithmetic involving header fields is replaced
by indexing from two well-defined pointers, the block start and end
pointers. The start pointer points to the first header field, and
he end pointer is one past the end of the header.

Hardcoded field indices are replaced by two enums. Forward indices
(fidx_XXX) are used to access fields from a block start pointer and
negated backward indices (-bidx_XXX) are used to index from a block
end pointer. There is no overlap between the indices because of the
variable length name field in the middle of the header. The length
of the fixed fields in the block header is now a #define'd constant
rather than being open coded.

There is now a function to acquire the block end pointer from the
user data pointer (ie. the pointer stored in the handle table). The
old code was not consistent in this; some functions would handle a
non-aligned user pointer, which may occur as a result of shrinking,
while other uses just assumed the user pointer was aligned.

Block CRC calculations have also been factored out to a function
that accepts block start and end pointers.

Change-Id: I6a7e8a8c58aec6c6eaf0e5021400032d8e5f841e
2022-09-19 15:09:51 -04:00
Aidan MacDonald
fdde6bb5a7 buflib: optimize getting start of block from end of block
The block header has a variable length due to the embedded name.
The name length is stored at the back of the header after the
name, in order to allow finding the start of the header if only
the user data pointer is known (eg. from the handle table).

The name length is actually not interesting in itself; storing
the total length of the block header instead is marginally more
efficient, saving one addition in handle_to_block().

Instead the extra arithmetic must be done by buflib_get_name(),
which is a much less common operation than handle_to_block().

Change-Id: Ia339a1d2f556a11a49deae0871203e70548bd234
2022-09-19 15:09:51 -04:00
Aidan MacDonald
ef476ba298 buflib: correct a confusingly indented comment
Change-Id: I9ef13d697c4abb81883d4a47273e69fcc2dafe37
2022-09-19 15:09:51 -04:00
Aidan MacDonald
c8365b2bdd buflib: fix bug in handle_table_shrink
The way it iterated over the handle table is unsafe if *every*
handle is free, leading to an out of bounds access.

This is a contrived example, but the bug can be triggered by
making several allocations, freeing them out of order so that
the handle table remains uncompacted, and then triggering a
compaction using buflib_alloc_maximum().

Change-Id: I879e2f0b223e6ca596769610ac46f4edf1107f5c
2022-09-19 15:09:51 -04:00
Aidan MacDonald
4d3bf1c446 buflib: add comment in handle_alloc, remove a dead store
It isn't obvious why the "handle->val = -1" at the end of handle_alloc
is needed so add an explanatory comment. But "handle->val = 1" prior to
calling handle_free is simply a dead store.

Change-Id: I9ab4e96e87e940cfd1a2ed56f089287821669c73
2022-09-19 15:09:51 -04:00
Aidan MacDonald
840f6b79c7 buflib: update first_free_handle in handle_alloc
Since we're scanning the handle table for the first free slot,
we know none of the scanned slots are free. Use that knowledge
to update first_free_handle and avoid rescanning filled slots
again when the next handle is allocated.

Change-Id: I457372f66c231168cfffa7e905d1e9fb80002f5f
2022-09-19 15:09:51 -04:00
Aidan MacDonald
f622bcfe4f buflib: fix buflib_context_relocate alignment check
Use the standard IS_ALIGNED macro and check alignment against
sizeof(buflib_data), as it can be greater than 4 bytes if we're
on a 64-bit platform (eg. simulator).

Change-Id: I15110937d1f2978e733d169050de9531fe218214
2022-09-19 15:09:51 -04:00
Aidan MacDonald
bcaa9465e9 buflib: optimize find_block_before
Exiting the loop implies next_block == block, so remove that check.
The check ret < block is false only if block is the first block, which
can be checked before the loop, saving a few cycles in that case.

Change-Id: Id493b5259a23a35a70b09dfe4bc4eacaf420760c
2022-09-19 15:09:51 -04:00
Aidan MacDonald
bab8a41532 x1000: add support for GD5F1GQ4xExx NAND flash
This is another chip used in newer Surfans F20 units. Like the
Winbond chip, it's a 1-gigabit chip with on-die ECC. Notably it
has an expanded 128-byte OOB area that is only accessible when
on-die ECC is disabled.

Change-Id: I2203918a15c914097f5a6bbe4afa2d3a60dc67f7
2022-09-17 10:14:26 -04:00
Aidan MacDonald
e64b0e81ad x1000: add support for the W25N01GVxx NAND flash
This chip is apparently used in some Surfans F20 units, and has
the same geometry as the ATO25D1GA. It has an on-die ECC engine.

Change-Id: I4d37a2455620ce43cec0a9bcbb32c776d1a8eba1
2022-09-17 10:14:26 -04:00
Aidan MacDonald
17443de221 x1000: refactor NAND chip identification
Decouple chip IDs from chips, and allow the chip ID table to list
which read ID method should be used. Use a safe controller setup
during identification instead of using the first chip's parameters.

Change-Id: Ia725959c31b2838f4a3a30e5bb7fa6652ef377ed
2022-09-17 10:14:26 -04:00
Aidan MacDonald
4101aeac54 x1000: simplify NAND command macros
There is actually no need to parameterize most commands with row
or column cycles, usually the opcode and row/column address width
are linked. When this is not the case we can use raw SFC commands
or define new macros.

Change-Id: I22459d732dc01012e6a8ae026c4fb85495d372b4
2022-07-21 11:39:19 +01:00
Aidan MacDonald
9ab5d311cb x1000: move NAND commands to chip data
Using predefined commands is too inflexible so allow the chip data
to specify I/O commands directly.

Change-Id: Ie8f943914da4b8299678a59b1063c4c6d226e83e
2022-07-21 11:39:03 +01:00
Aidan MacDonald
c72f9c6d0f x1000: add NAND OTP access switch
Provide a way to toggle the OTP bit for reading OTP pages, mostly
useful for debug purposes.

Change-Id: Iec697de2dc188588c43d9ed466201971cac8f30c
2022-07-19 13:15:26 +01:00
Christian Soffke
5901ac8756 ipod6g: increase plugin buffer size from 512 KiB to 2 MiB
The iPod classic/6G comes with 64MB of RAM. This
brings it in line with the plugin buffer size of some
other targets that have the same amount of RAM,
such as the Fiio M3K, and enables the use of
PictureFlow for users with very large databases.

Change-Id: I1ccae1cacda7a243139f4887f54bd35cc8e501cf
2022-07-12 01:01:47 -04:00
Aidan MacDonald
db2817eb1a Fix red in commit 131566b8f8
Use per-function sections to avoid linking in x1000_boot_linux()
on normal builds, which prevents link errors due to referencing
a non-existent usb_close().

Change-Id: Ied7b233603c49fc856db8445e368675b181e2f1f
2022-07-10 15:58:45 +01:00
Aidan MacDonald
47cbeb2e67 x1000: add support for simple on-die ECC with NAND flash
Many SPI NAND flash chips have on-die ECC engines that report
ECC status via the status feature register. This code handles
the common case where ECC status is reported with 2 bits: one
bit to indicate if flips were detected & corrected, and another
bit to indicate an uncorrectable error.

Change-Id: I5d587cd960ca9d090d2629e890724a6bc411e70c
2022-07-10 15:22:32 +01:00
Aidan MacDonald
df29c7991a x1000: add setup_chip hook for NAND chips
Add a chip setup hook for configuring vendor specific registers
after the chip is identified.

Change-Id: Ifffa7f01be16fd147a9db3d6e402b7b0debd7e12
2022-07-10 15:22:31 +01:00
Aidan MacDonald
ad8ace53e5 x1000: remove 'typedef struct' from NAND driver
Using 'typedef struct' is not in line with the project coding style
and somewhat problematic, so get rid of it here.

Change-Id: Icfe79de72ed82cb7526e9f4e8296ec12084c01ac
2022-07-10 15:22:10 +01:00
Aidan MacDonald
cc017f211a x1000: support 2nd device ID byte for NAND flash
Some components have additional ID bytes. Add support for an
optional 2nd device ID byte during the identification routine.

Change-Id: I5bbad73fb57004067c6f13f223f7bf4d43ff7849
2022-07-10 15:22:10 +01:00
Aidan MacDonald
131566b8f8 x1000: fix linux boot USB issues
If the USB controller is active when we hand over to Linux it'll
often trigger "irq nobody cared" warnings. Disabling the controller
before boot prevents that.

Also move the USB PHY bit workaround from the dualboot cleanup hook
to the main Linux boot function. Mainline kernels don't clear these
bits either.

Change-Id: Ieaf896c3b8c3e58a8c47de5afeb384ae2511a5fa
2022-07-10 09:48:39 -04:00
Aidan MacDonald
d0d13baf3e x1000: fix command line passing for linux boot
Change-Id: I2a016a5f64ef980f49a8cbdcbb0e0af9ad768ce0
2022-07-10 09:48:39 -04:00
Aidan MacDonald
ec9e484f64 firmware: Add load/store with endianness functions
Define common functions for loading 16/32/64-bit unsigned integers
with big, little, or host endianness, and distinguishing unaligned
and aligned cases.

Unaligned loads are supported generically by default, but this can
be overridden with a more efficient implementation on architectures
which support unaligned loads natively.

Change-Id: I3d826ec1a7646777876366eeece2cbccab60c1fb
2022-06-26 17:19:40 +01:00
Aidan MacDonald
7e0492444c usb: remove "Ask" USB Mode (FS#13317)
USB ask mode is basically a footgun: it can't work on native targets
and doesn't work reliably on hosted ones, and it continually produces
a slow trickle of problems. FS#13317 gives a rundown of the issues.
Removing the setting seems like the best solution for now, since a fix
would be pretty involved.

This partially reverts 60f581e8f5. The USB Mode setting is left in
place so the option can be added back later in a non-buggy way.

Change-Id: Ie01b28dd2ed95a31b509a7834d85bac8eb866098
2022-06-21 18:11:53 -04:00
Solomon Peachy
7296f30490 jz4760: Reformat USB driver a little. Prep work for later changes.
Change-Id: I74d068661ea8a8a59a88f0c2c5a938dcf6fb8b20
2022-06-12 17:09:32 -04:00
Aidan MacDonald
4d01168b9b x1000: add flash probe tool to bootloader
The flash probe mimics the boot ROM's flash read routines and
dumps the manufacturer & device IDs and 16-byte parameter data
to a file on the SD card.

Change-Id: I3d413bd0cc05a9d7f2285b85454420c3e90274e9
2022-05-30 14:08:02 +01:00
Aidan MacDonald
e05aa27124 x1000: move NAND commands to header file
Change-Id: Ic95b80494a101f7b349e115d82e9dfe3a64b643f
2022-05-30 14:02:13 +01:00
Aidan MacDonald
5ee9a45126 mips: stop backtraces at main()
Initialize ra=0 before calling main so backtraces don't walk
through the startup code.

Change-Id: Ia8796ce38b32d14025b47b3e00061267ee25cbaf
2022-05-22 07:16:11 -04:00
Aidan MacDonald
981e972839 mips: add native backtrace implementation
Should make debugging crashes on native MIPS targets far easier.
This is by no means a 100% complete or robust implementation but
it seems to handle the vast majority of functions.

Change-Id: Id5f430270e02b5092b79026b6876675c784aa649
2022-05-22 07:16:11 -04:00
Aidan MacDonald
2315266628 kernel: remove unused function mutex_test()
No longer needed since the only user was in the Archos code.

Change-Id: I763f58050c70f2bb1d8cc0a044c63698f3157a8d
2022-05-14 11:29:55 -04:00
Aidan MacDonald
dafc8e5904 kernel: remove unused kernel/pthread/*.c files
These don't seem usable and it looks like the files were added by
accident by d66346789c "buflib: Check the validity of of handles
passed to buflib_get_data() in DEBUG builds."

Change-Id: I4d4601f1fef7901c08ae86448853d008f48d5f43
2022-05-14 11:29:55 -04:00
William Wilgus
79864c6ec2 add const to const * strings
I don't think this will amke any difference except maybe for hosted ports

Change-Id: I84f898aea92a6963901a6d889dd18b63f24c9a41
2022-05-03 23:00:58 -04:00
Aidan MacDonald
a234df30df Fix sim build for glibc >=2.34
Change-Id: If63787514b6bffc0afb71f9d651f8c6f0c328a2d
2022-04-18 09:54:07 -04:00
Aidan MacDonald
fca7b8e2ff Fix undefined behavior that blocks compiling with UBSan
Left shifts are not defined in C if they would cause signed overflow,
so these expressions get instrumented, which makes them unusable as
switch values and triggers compile errors when compiling with UBSan.

Change-Id: I0588d4be1e00ba1cfde0eac119ead368b20d10c9
2022-04-17 11:37:34 -04:00
William Wilgus
c4156b1909 viewports, set flags to VP_DEFAULT_FLAGS
flags were getting un-initialized memory
it really didn't matter with the flags getting initialized
anyway
But once I added a new flag that didn't explicitly
set or clear the flag at init well here we are

set flags to VP_DEFAULT_FLAGS in viewport_set_defaults()

add the flags variable to the default vp's set to 0
(it was already initialized to 0 by bss, make it explicit)

Change-Id: I3a9a062455b4cf66d2b8c70fdf05402a5c0c091c
2022-04-17 10:59:56 -04:00
Aidan MacDonald
d55dceff37 apps: Add ability to do a clean reboot
Allow a clean shutdown to end in either power off or reboot. Add a
new event SYS_REBOOT to signal it and sys_reboot() to trigger the
event. SYS_REBOOT signals a reboot request and should be listened
for alongside SYS_POWEROFF events.

Change-Id: I99ba7fb5feed2bb5a0a40a274e8466ad74fe3a43
2022-04-16 14:36:39 +01:00
William Wilgus
ff08841ea9 viewport FIX RED remote screens
Change-Id: I894a5c3e9053f44dee4803e9cdbbcb8f651ee318
2022-04-15 08:16:28 -04:00
William Wilgus
d56d96031c viewports add flag to disable updates
when drwing multiple areas of the screen with other gui elements
you might want to combine updates into a single screen redraw

Change-Id: Ie4130366fa13e25d3d14e937257d11547dd61134
2022-04-15 01:54:42 -04:00
Aidan MacDonald
98f762316f system: update MEM_ALIGN_ATTR for targets with CPU caches
MEM_ALIGN_ATTR should take advantage of cache line alignment on
all native CPUs which define it, not just ARM CPUs. (This could
arguably be done for hosted targets too, but we don't necessarily
know the size of a cache line there.)

Change-Id: Ife9302105ea57388afd55ce31da848b00b5b1b25
2022-04-01 12:08:41 -04:00
Dana Conrad
de285741bf ErosQ Native: Make power delay bootloader-only
gotta go fast

Change-Id: Ic01e4aa70a2bec4c48ae7cf8f32f8dfd366decad
2022-04-01 12:04:46 -04:00
Dana Conrad
7aa2a23b95 Eros Q Native: Add Original Firmware Boot option
Hold "Play" to boot the OF, or boot it from the recovery menu
by holding "Vol. Up". If you had the hosted port installed on your
player before installing the native port, you'll still have to go
through the hosted bootloader.

A couple notes:

- When booting from the menu, the recovery menu disappears, then
  reappears before going into the OF.

- You need to hold the play button for like a half second after the
  blue light comes on in order to get into the OF.

The recovery appears to be there, but it doesn't seem to be intended
for end users - it just says "Updater V1.1 - Insert TF Pls". I haven't
tested it beyond seeing that it boots, so I'm going to comment it out
for now.

Change-Id: Ie271ee479bb628cc74141b7fe07273b3f193f358
2022-04-01 12:04:30 -04:00
Aidan MacDonald
4f05a9d066 Add path_strip_last_volume
This gets the volume that the path eventually refers to by parsing
the last volume specifier and returning the part of the path after
it (which does not contain any volume specifiers). The initial part
of the path therefore contains everything up to and including the
last volume specifier.

Change-Id: I9a935543256f8f22e0b8b1e3c88d4e47bd9dae8a
2022-04-01 11:40:02 -04:00
Aidan MacDonald
412dbaeffe hosted: call 'sync' before poweroff
Might be needed to avoid filesystem corruption with buggy OF kernels.

Change-Id: I589eec6c1536beccf849716f11204b4b83a942a1
2022-03-31 21:40:04 -04:00