Commit graph

528 commits

Author SHA1 Message Date
Lephe
545db2f9ce
r61524: add low-level get/set and start_frame functions 2021-06-22 17:52:26 +02:00
Lephe
02c1b551cd
mpu/cpg.h: specify DDCLKCR 2021-06-22 17:51:54 +02:00
Lephe
89d540ee91
kernel: add basic C++ support for GINT_CALL() 2021-06-22 17:51:27 +02:00
Lephe
8d444b4f78
kernel: add crash details on illegal instructions 2021-06-17 14:33:45 +02:00
Lephe
03ef59521c
dma: add support for standard DMA access to SPU memory
* Mark SPU memory as sleep-blocking.
* Perform 4-byte accesses only in dma_memset() and dma_memcpy() (32-byte
  accesses freeze as one would expect).

This change does *NOT* implement support for SPU's integrated DMAC.
2021-06-17 14:32:27 +02:00
Lephe
5bd04a9613
cpu, dma: add interrupt-cancellable sleep (perfect async sleep) 2021-06-17 14:32:08 +02:00
Lephe
658413ba19
r61524: fix hardcoded VRAM and don't assume full-size 2021-06-16 21:12:53 +02:00
Lephe
10180d31bc
add C++ header guards 2021-06-13 18:13:09 +02:00
Lephe
9939896c6a
bump version to 2.5.3 2021-06-08 23:50:38 +02:00
Lephe
824a150dfb
cmake: set HASH to 0, not empty string, when building out-of-git 2021-06-08 23:04:41 +02:00
Lephe
086ad19d13
getkey: properly specify -1 as blocking repeats, not 0 2021-06-08 15:25:36 +02:00
Lephe
57531e63bf
bopti: fix mistake in edcebff31
Test case was flawed.
2021-06-08 14:52:56 +02:00
Lephe
73ab18e457
bump version to 2.5.2 2021-06-08 11:01:27 +02:00
Lephe
8e730c2f78
replace gint/std headers with standard ones 2021-06-08 11:01:27 +02:00
Lephe
20b7238057
std: move endian.h to fxlibc 2021-06-08 10:05:33 +02:00
Lephe
edcebff311
bopti: fix a VRAM overflow through the rightmost column
The checks for VRAM access account for image columns intersecting the
longword before the start of a VRAM line, but not the longword after the
start of a VRAM line. This is now fixed.
2021-06-08 09:38:09 +02:00
Lephe
fc6fb9dc09
std: remove the malloc impl and string header 2021-06-07 21:52:52 +02:00
Lephe
3a6165f026
std: remove the TinyMT-based rand implementation 2021-06-07 19:16:58 +02:00
Lephe
b25924d740
std: remove the asprintf/vasprintf implementation 2021-06-07 19:04:48 +02:00
Lephe
991b616a10
std: remove the printf implementation 2021-06-07 18:53:05 +02:00
Lephe
faf5dc711a
bump version to 2.5.1 2021-06-02 11:23:10 +02:00
Lephe
a9f6c4b622
display-cg: fix a bug in bopti r5g6b6 for very thin images 2021-06-02 11:22:29 +02:00
Lephe
7b40e1e0d0
display: fix a bad overflow for empty lines due to clipping 2021-05-30 23:46:11 +02:00
Lephe
850544349c
kernel: implement _Exit to support exit 2021-05-29 16:29:50 +02:00
Lephe
2f6f49feea
bump version to 2.5.0 2021-05-25 22:07:09 +02:00
Lephe
f2d7338658
make fxlibc a GiteaPC dependency, and update README 2021-05-25 22:07:08 +02:00
Lephe
8f7799dbd5
cmake: add interface flags for OpenLibm and the libc
Known limitation: OpenLibm can't be installed out of the compiler prefix
yet (because of that pesky openlibm/ prefix that it installs to but does
not use when including).
2021-05-25 21:28:50 +02:00
Lephe
242c41d1f2
display-cg: fix C_LIGHT and C_DARK (#16) 2021-05-25 11:18:36 +02:00
Lephe
9e43dcb27a
std: remove string functions now in the fxlibc 2021-05-25 11:18:36 +02:00
Lephe
6c12217777
std: move memcmp, memcpy, memmove, memset to fxlibc 2021-05-25 11:18:33 +02:00
Lephe
7e0ccc3f69
kprint: do not call Grisu2b with input 0.0
It doesn't generate the expected string "0" for some reason, which
causes a freeze somewhere.
2021-05-21 22:30:51 +02:00
Lephe
bc3b8f5602
kprint: add support for L modifier in %f
This is just a parsing trick because long double and double are the same
type on this platform.
2021-05-21 22:30:30 +02:00
Lephe
21e91b30d5
keysc: set the key_event_t.mod bit as getkey() did before 2021-05-15 18:37:36 +02:00
Lephe
99403a9504
render: support C_INVERT on fx-CG 50 2021-05-12 09:17:25 +02:00
Lephe
31dcc6fd6c
usb: enable writing with DMA
Nothing particular to change, simply make sure that the DMA channels
have higher priority than the USB module, otherwise the BEMP interrupt
might be executed before the DMA frees the channel, resulting in the
transfer failing because the channel is still busy.

Also reduce BUSWAIT since it works even on high overclock levels, and
keeping it high won't help increase performance.
2021-05-12 09:17:25 +02:00
Lephe
a547235f8f
usb: FIFO controllers and fxlink API
This changes fixes the way gint uses the FIFO controllers D0F and D1F
to access the FIFO. It previously used D0F in the main thread and D1F
during interrupt handling, but this is incorrect for several reasons,
mainly the possible change of controllers between a write and a commit,
and numerous instances of two FIFOs managing the same pipe caused by
the constant switching.

gint now treats FIFO controllers as resources allocated to pipes for
the duration of a commit-terminated sequence of writes. The same
controller is used for a single pipe in both normal and interrupt
modes, and released when the pipe is committed. If no controller is
available, asynchronous writes fail and synchronous ones wait.

The fxlink API is also added with a small amount of functions, namely
to transfer screenshots and raw text. Currently these are synchronous
and do not use the DMA, this will be improved later.

Finally:
* Removed pipe logic from src/usb/setup.c, instead letting pipes.c
  handle the special case of the DCP (which might be regularized later)
* Removed the usb_pipe_mode_{read,write} functions as they're actually
  about FIFo controllers and it's not clear yet how a pipe with both
  read and write should be handled. This is left for the future.
* Clarified end-of-sequence semantics after a successful commit.
2021-05-12 09:17:25 +02:00
Lephe
7aa86235a3
cpu: fix a data race occurring on the cpu_atomic lock
The function was designed with multi-threaded concurrency in mind,
where threads can take over while the lock is held and simply block
trying to acquire it, which allows the lock holder to proceed.

However interrupt handlers are different; they have priority, so once
they start they must complete immediately. The cannot afford to block
on the lock as the program would simply freeze. In exchange, they clean
up before they leave, so there are some guarantees on the execution
state even when interrupted.

The correct protection is therefore not a lock but a temporary block on
interrupts. There is no data race on the value of the saved IMASK
because it is preserved during interrupt handling.
2021-05-12 09:17:25 +02:00
Lephe
95dbec17ab
cpu: allow functions to block the sleep() function
This change introduces new sleep_block() and sleep_unblock() functions
that control whether the sleep() function actually sleeps. This type of
behavior was already implemented in the DMA driver, since DMA access to
on-chip memory is paused when sleeping (on-chip memory being paused
itself), which would make waiting for a DMA transfer a freeze.

Because DMA transfers are now asynchronous, and USB transfers that may
involve on-chip memory are coming, this API change allows the DMA and
USB drivers to block the sleep() function so that user code can sleep()
for interrupts without having to worry about asynchronous tasks
requiring on-chip memory to complete.
2021-05-12 09:17:25 +02:00
Lephe
4c3fcf66a7
getkey: add a "feature function" to create application-wide shortcuts
This change introduces the global "feature function" that can be
enabled in getkey() to receive events, and use them for
application-wide features. This would be useful, for instance, to
toggle screen backlight with a different key combination that the
default, to capture screenshots, or to implement a catalog.

When enabled, the feature function is present with all new events and
can perform actions, then decide whether or not to return them from
getkey().
2021-05-12 09:17:24 +02:00
Lephe
dbba1d7b1d
defs: use auto instead of __auto_type in C++ 2021-05-12 09:17:24 +02:00
Lephe
78bf9dac7d
gray: expose pointers to the screen buffers 2021-05-12 09:17:24 +02:00
Lephe
c4ec06d6ab
display: fix bound checking in drect_border (#14)
Bounds would be moved before drawing the border, therefore displacing
the border. Since drect() already performs all the necessary checks,
this change doesn't try to save a couple of function calls and drops the
redundant checks.
2021-05-12 09:17:24 +02:00
Lephe
392d033e4a
usb: improve and expose the sync/async write API
* Properly define the callback time of a write/commit as the time when
  the pipe is available again for further writing.
* Refuse commits when writes are pending; instead, enforce a strict
  order of finishing writes before committing, which makes sense since
  consecutive writes are ordered this way already.
* Properly support callbacks for writes and for commits.
* Define the synchronous APIs in terms of waiting until the callbacks
  for equivalent asynchronous functions are invoked (plus initial
  waiting for pipes to be ready).
2021-05-12 09:17:24 +02:00
Lephe
4147236343
(minor changes) 2021-05-12 09:17:24 +02:00
Lephe
acc35d774f
dma: add an asynchronous API
This change adds asynchronous capabilities to the DMA API. Previously,
transfers would start asynchronously but could only be completed by a
call to dma_transfer_wait(). The API now supports a callback, as well
as the dma_transfer_sync() variant, to be consistent with the upcoming
USB API that has both _sync and _async versions of functions.

The interrupt handler of the DMA was changed to include a return to
userland, which is required to perform the callback.

* dma_transfer() is now an obsolete synonym for dma_transfer_async()
  with no callback.
* dma_transfer_noint() is now a synonym for dma_transfer_atomic(), for
  consistency with the upcoming USB API.
2021-05-12 09:17:24 +02:00
Lephe
42081c9968
intc: allow any call in intc_handler_function() 2021-05-12 09:17:24 +02:00
Lephe
0233088565
cmake: do not require a build from the gint tree (#15) 2021-05-12 09:16:14 +02:00
Lephe
58170b9e5b
cmake: lower minimum required version to 3.15 2021-05-12 09:16:11 +02:00
Lephe
f05a94ca15
bump version number 2021-04-27 16:20:09 +02:00
Lephe
c1e96173da
cmake: make OpenLibm a dependency
This is required for the floating-point printing with Grisu2b.
2021-04-27 15:24:24 +02:00