Commit graph

423 commits

Author SHA1 Message Date
Lephe
6d86c54507
keyboard: add keypressed() and keyreleased() functions 2023-07-24 14:08:23 +02:00
Lephe
16259deb20
render: expose some internal text rendering utilities 2023-06-04 23:24:34 +02:00
redoste
6f53fa7842
gdb: move recv buffer to the heap to support fx-9860G III smaller .data 2023-06-04 23:20:42 +02:00
redoste
5087a91101
gdb: make memory map XML more generic to ensure fx-9860G III support 2023-06-04 23:20:42 +02:00
redoste
7d3663483f
gdb: break before panicking in user code 2023-06-04 23:20:42 +02:00
redoste
6efcfa6018
ubc: panic when trying to break in code using register bank 1 2023-06-04 23:20:42 +02:00
redoste
0b7d8d6800
ubc: ignore breaks when no debug handler is set 2023-06-04 23:20:42 +02:00
redoste
9c22ecea8d
gdb: prevent TLB misses during arbitrary memory RW operations 2023-05-30 01:03:38 +02:00
redoste
02a97719ac
gdb: break when a message is recived during execution
This behaviour implements support for breaking the add-in during
execution by pressing ^C in GDB without setting a breakpoint beforehand.
2023-05-27 19:06:29 +02:00
redoste
33dae5d218
ubc: add a global lock to inform if a UBC break is being handled 2023-05-27 18:59:24 +02:00
redoste
21ff5c1d53
usb: expose the context of the interrupted function on USB interrupt 2023-05-27 18:52:05 +02:00
redoste
76c82beec6
intc: allow user-space handlers to access the interrupted context
This workaround using a gint_call_t with an odd address is not realy the
cleanest idea but it helps keep the existing intc_generic_handler in
the 32 bytes size limit of the VBR space.
2023-05-27 18:36:15 +02:00
redoste
eca05ec64c
gdb: send memory map XML to GDB to enforce hw-breakpoints 2023-05-27 17:50:44 +02:00
redoste
2f6ee59d43
gdb: add memory write support 2023-05-24 23:30:29 +02:00
redoste
3aa11b4252
gdb: add register write support 2023-05-24 23:07:41 +02:00
redoste
eab3184dbb
gdb: add "kill request" packet support by abort()ing the add-in 2023-05-24 22:22:54 +02:00
redoste
238bccddbe
gdb: add hw-breakpoint and single step support using the UBC 2023-05-24 22:21:01 +02:00
redoste
aa0ff7b10b
ubc: basic User Break Controller driver 2023-05-24 22:21:01 +02:00
redoste
0bea485f4b
gdb: first implementation with basic memory and register read support 2023-05-21 19:49:23 +02:00
Lephe
82258b9f89
keysc: bind SHIFT+7+3+AC/ON to abort() for un-freeze attempts 2023-04-01 23:24:55 +02:00
Lephe
b5f0f08183
usb: use optimized DSP loop for read from module 2023-03-26 20:40:48 +02:00
Lephe
1423f40a96
usb: disable USB_LOG_TR() when no log is configured
For some reason this has a *massive* impact on read performance, like
78 ms -> 20 ms on a full-screen read (177 kB) on the CG-50.
2023-03-26 20:40:08 +02:00
Lephe
3a2a194693
usb: unaligned reading (release candidate on features)
The only thing left on the bucket list is performance.
2023-03-26 11:36:40 +02:00
Lephe
4983849510
usb: consolidate reading logic again, now beta-worthy
This looks like it could work in the long term. The only issue that
really hasn't been addressed is how to use packet counters to cut
transactions when there's no ZLP, but we can leave that for later.
2023-03-18 19:51:57 +01:00
Lephe
fc1f510288
usb: consolidate reading mode (basic multi-segment reads now working) 2023-03-12 17:53:44 +01:00
Lephe
c59b2f90fb
usb: prototype reading mode
Currently only tested with short messages using the fxlink interface.
There is much to be expanded upon, but this is a worthy start.
2023-03-04 18:06:38 +01:00
Lephe
eb1f9a35a1
usb: use negative values for error codes
This will allow usb_read_sync() to return a combined error code / size
read integer.
2023-03-04 18:06:38 +01:00
Lephe
f4e13afa84
usb: fix a missing PIPESEL access
This resulted in a random PIPECFG access.
2023-03-04 10:59:06 +01:00
Lephe
911691461f
usb: clarify functions used to access endpoint configuration
The previous scheme was really unclear. Now, an endpoint_t carries all
of the endpoint info (instead of the global address being implicitly
its array index, which couldn't be returned).

An _endpoint address_ is the 8-bit value consisting of an endpoint
number (bits 0x0f) and a direction (bit 0x80).

The _global address_ of an endpoint is the address used to communicate
with the host, and it is unique. The _local address_ of an endpoint is
the interface-specific numbering that gint provides to allow interfaces
to compose without risks of address collisions.

The complete data for an endpoint can be queried with the new functions
usb_get_endpoint_by_*() which accept global addresses, local addresses,
and pipe numbers.
2023-03-04 10:58:07 +01:00
Lephe
aee67a76f3
usb: clear pipes/FIFOs during world switches, delay configuration
* Clear pipes and FIFOs during world switches to avoid interference
  with the OS. LINK uses pipes 3 and 4, and attempts to add a second
  pipe to the fxlink interface (thus using pipe 4) would interfere with
  LINK and somehow prevent the pipe from being used (Wireshark captures
  showed no responses on that pipe). Forcing a blank state is a valid
  move because that state occurs naturally after a RESET, thus LINK and
  other add-ins must support it as well.

* Delay the application of configuration to the USB configuration stage
  (specifically, the DVST configured interrupt, even though technically
  we should do that in SET_CONFIGURATION 0). This is because we
  previously relied on world switches preserving pipe settings (by not
  changing them) to reconnect the gint driver after a world switch.
  This is no longer possible as the world switch now clears the pipes.
  The new timing makes the driver automatically re-configure as the
  connection restarts.
2023-02-18 17:15:28 +01:00
Lephe
c0671649df
usb: prevent double opening
This could happen in gintctl's USB tracer and obviously cause all sorts
of problems.
2023-02-18 16:48:28 +01:00
Lephe
53c67af52d
usb: fix wrong interface numbering (+ comments)
This worked previously because the only interface (number 0) had its
interface descriptor in first position (position 0).
2023-02-18 16:47:49 +01:00
Lephe
6910714c2c
asyncio: remove unused field asyncio_op_t.flying_w 2023-02-16 16:09:53 +01:00
Lephe
af5c16a3d3
usb: massively improve writing logic
* Move logic around tracking transfers to asyncio.c.

* Add a "short buffer" holding 0-3 bytes between writes, so that the
  driver performs only 4-byte writes in the FIFO and a short write in
  the commit, if needed.
  - This is partially due to me thinking at some point that degrading
    writing size was impossible, but it might actually be possible by
    writing to FIFO/FIFO+2 or FIFO/FIFO+1/FIFO+2/FIFO+3.
  - In any case I think this new approach wins on performance.

* Get rid of unit_size since we now always use 4 bytes.

* Add a waiting function which is used in usb_close() (and once tested
  should be used in world switches too).

* Eliminate some of the special cases for the DCP, though not all (in
  particular I can't get the commit to rely on the BEMP interrupt yet,
  nor can I properly clear PID to NAK when unbinding).
2023-02-09 23:00:44 +01:00
Lephe
1a61e97ef0
mmu: provide read-only access to ITLB 2023-02-02 14:23:03 +01:00
Lephe
a091efc894
usb: replace struct transfer with a more generic async. I/O op structure (WIP)
This lays the ground for both generalization to reading and sharing
that logic with the serial driver.
2023-01-31 16:04:35 +01:00
Lephe
6f758cd36c
defs: allow NULL callbacks in gint_call() 2023-01-31 16:04:35 +01:00
Lephe
18e0db3886
usb: improve driver with updated knowledge and prepare reading
* Finish updating the register list
* Use RTC-based timeouts to not involve more interrupts
* Be a lot more conservative about PID=BUF
* Start setting up parameters and checking invariants for future
  bidirectional communications
2023-01-31 16:04:35 +01:00
Lephe
cf2b86deaa
usb: update module details with register analysis experiments
Unknown writable bits and host-only registers were found.
2023-01-28 13:10:03 +01:00
Lephe
db50c9b192
kernel: more options in System ERROR screen
* Add options to RESET, go to menu, or abort()
* Define weak symbols for driver functions so that low-level debugging
  add-ins can be linked with minimal drivers (CPU/INTC/MMU)
2023-01-25 22:38:39 +01:00
Lephe
42853103aa
usb: remove incorrectly-ordered bits in USB registers 2023-01-25 16:28:20 +01:00
Lephe
45881995e9
fs: initialize dynamically-allocated fd table
Obvious oversight from 736b58f205.
2023-01-14 22:28:27 +01:00
Lephe
70dccc29da
style: initialize non-trivially initialized pointer
We always have c <= 15 but it's not structural enough that we can
outright skip initializing the pointer.
2023-01-14 22:28:18 +01:00
Lephe
7e859169fe
cpg: add overclock save/restore functions 2023-01-05 20:25:44 +01:00
Lephe
b3416dcc25
cpg: add overclock for SH3/SH4 fx-9860G and G-III (#23)
Co-authored-by: Slyvtt <pillot.sylvain@gmail.com>
2023-01-05 20:02:41 +01:00
Lephe
736b58f205
reduce static user RAM footprint for mono targets
* Make INTC data const (it should've always been)
* Introduce GRODATA3/.gint.rodata.sh3 for that purpose
* Dynamically allocate file descriptor table
2023-01-01 19:22:41 +01:00
Lephe
478fdaea76
keysc: don't emit KEYEV_DOWN for keys pressed at startup 2023-01-01 18:49:50 +01:00
Lephe
a4cf3516e7
usb: fix some messages being lost after a post-world-switch reconnect 2022-12-03 11:05:35 +01:00
Lephe
177879d432
usb: add a USB_TRACE() debugging mechanism 2022-12-03 11:04:43 +01:00
Lephe
feb74a38ec
usb: hide USB_LOG() behind a compile-time debug option 2022-11-29 20:03:03 +01:00
Lephenixnoir
a5fb6d3401 Merge pull request 'Added SetQuitHandler syscall into gint' (#21) from mibi88/gint:dev into dev
Reviewed-on: https://gitea.planet-casio.com/Lephenixnoir/gint/pulls/21
2022-11-27 22:50:10 +01:00
Lephe
e2c507855f
render-cg: allocate VRAM in _ostk to keep _uram for large allocs 2022-11-26 18:38:09 +01:00
mibi88
984f162cb2 Added gint_set_quit_handler() 2022-11-20 11:48:26 +01:00
mibi88
2fe67412cc Added SetQuitHandler. 2022-11-20 11:48:26 +01:00
Lephe
8442e0b9cf
render: fix missed clipping test in dtext() 2022-11-19 23:41:47 +01:00
Lephe
4df3d69d8c
render: add a window setting to restrict rendering
Mono text rendering is a bad hack and probably not that fast, but meh.
We can optimize it the day it becomes a bottleneck, if ever...
2022-11-19 17:19:28 +01:00
Lephe
74438f5da5
render: add a dgetpixel() function 2022-11-16 19:12:48 +01:00
Lephe
45fa6c87c2
render-cg: fix a bug with unaligned C_INVERT drect()
The alignment optimization would write the edges twice, which is fine
for opaque color fills, but cancels out for C_INVERT.
2022-11-16 18:10:22 +01:00
Lephe
5e35871c98
usb: add timeout variants for functions
We're not using them yet (specifically in fxlink) because timeouts
leave the pipes in undesirable states that currently end up crashing.
Some reset mechanism is needed, plus support from the protocol for
canceling messages, etc.
2022-11-13 08:56:59 +01:00
Lephe
5f9553f3b8
usb: fix transmissions resuming early after world switch
When the driver goes through a world switch a reconnection with the host
is needed before operations can resume. This requires usb_open_status to
be reset.

Also: bind a FIFO before a commit that involves data transfer, mirroring
what happens in writes. This ensures that PID is set to BUF, mainly.
2022-11-12 14:51:00 +01:00
Lephe
d110ab608e
usb: fix freeze on sync commit for inactive pipes
Performing an asynchronous commit on an inactive pipe would yield
USB_COMMIT_INACTVE and *not* invoke the callback (as intended),
which usb_commit_sync() ignored, causing a freeze.

This issue appeared after a world switch, which (for reasons not yet
known) appear to fail the first writes until a commit, and that commit
would then hit an inactive pipe.
2022-11-11 17:47:29 +01:00
Lephe
bbda77769d
kmalloc: fix krealloc() not trying across arenas 2022-11-10 19:54:45 +01:00
Lephe
7b662987f8
kmalloc: add kmalloc_max() function 2022-11-09 21:35:32 +01:00
Lephe
252bd4eb41
keydev: add low-level filter for async keyboard handlers 2022-11-08 22:22:41 +01:00
calamari
1d5675c99f Update Slim scancodes for the row unswap 2022-10-09 11:00:53 -07:00
Lephe
16890ab71b
iokbd: don't swap rows; keydev doesn't need it 2022-10-09 18:19:25 +02:00
Lephe
c9df6326e4
reduce static RAM usage to maintain SH3 support 2022-10-09 18:15:12 +02:00
calamari
a735e074d8 Clean up style mismatch 2022-09-25 11:23:07 -07:00
calamari
ddf340cccd Support gint_osmenu() on fx-9860G Slim 2022-09-25 10:37:41 -07:00
calamari
5c331e5fa0 Add isSlim() macro 2022-09-25 10:37:18 -07:00
calamari
98fea4f2ec Translate fx-9860G Slim keyboard scancodes to standard scancodes
The Slim has two keys that the standard 9860G doesn't: HELP and LIGHT.
Those are mapped to virtual scancodes, resulting in virtual keycodes.
2022-09-25 01:34:40 -07:00
calamari
a4adc5e1bd Support fx-9860G Slim backlight 2022-09-24 19:49:29 -07:00
calamari
b23ed9629e Add HWCALC entry for fx-9860G Slim 2022-09-24 19:48:07 -07:00
Lephe
2b4075c8f9
keysc: have getkey() sleep
This was embarassingly no longer the case since the move to the keydev
API.
2022-09-07 23:25:57 +02:00
Lephe
e95a91d5ab
minor API comment update 2022-09-07 23:25:57 +02:00
Lephe
3e5c45c5ad
kernel: make gint_setrestart() reset everything 2022-09-02 22:29:19 +02:00
Lephe
9924dc4684
fs: add rename() function on fx-CG 2022-08-22 15:25:14 +02:00
Lephe
6ea2f991a3
keysc: make repeat settings global instead of just for getkey()
Having repeat settings only for getkey() meant that repeats that occur
while getkey() is not running (i.e., all of them) would be lost. This is
due to e57efb5e3 which replaced on-demand repeats with normal event
generation.

Now the settings are applied globally, which allows repeats to be
enabled even when getkey() is not active. This also reduces the feature
gap between getkey() and raw events, which reduces the risk of running
into edges cases by using both.

The previous API is retained for source compatibility until gint 3.0 but
the changes are now applied globally so the semantics are slightly
different.
2022-07-24 21:57:18 +01:00
Lephe
4e1136d0ac
r61525: now account for the inverted x-axis on the display (!)
Always has been.
2022-07-17 21:17:46 +01:00
Lephe
1c3c9727a5
r61524: add a r61524_display_rect() function for small regions 2022-07-16 22:30:59 +01:00
Lephe
e8b4bcc9cb
tmu: fix delay truncation in subfunction call 2022-06-13 21:36:52 +01:00
Lephe
b17d4de4a8
cpg: do read and write CS3 on fx-CG 10/20 2022-05-23 21:20:47 +01:00
Lephe
f69f92b938
cpg: fix parameter check minding CS3 on the fx-CG 10/20 2022-05-22 20:00:22 +01:00
Lephe
291c3cef17
cpg: restore overclock settings when leaving 2022-05-16 20:13:13 +01:00
Lephe
b942bc5d19
clock: add overclock support on fx-CG 10/20/50 2022-05-15 19:20:14 +01:00
Lephe
c2ff07427b
image: add image_linear_alloc() 2022-05-15 13:45:59 +01:00
Lephe
09c13676d3
image: arbitrary linear transforms 2022-05-15 12:59:28 +01:00
Lephe
780acb3fc9
image: arbitrary linear transforms [WIP] 2022-05-14 22:32:59 +01:00
Lephe
818f950fff
image: flips, including in-place 2022-05-14 20:27:16 +01:00
Lephe
9468a8d725
image: clean up palette semantics, and conversion 2022-05-14 15:36:07 +01:00
Lephe
fc6f7d3051
image: remove alpha field of images 2022-05-14 12:54:59 +01:00
Lephe
5a69e44078
image: new image format and base for the image library 2022-05-13 23:31:03 +01:00
Lephe
7822899b1f
render-cg: fix incorrect margin size for VRAMs 2022-05-07 18:22:38 +01:00
Lephe
d2f788a3fc
render-cg: fix negative alpha values being miscompared in P8 2022-05-07 18:12:44 +01:00
Lephe
667f43b45c
render-cg: remove now-unused section of .effects field of image command 2022-05-06 16:52:05 +01:00
Lephe
ede19fc878
render-cg: restore bopti method on P4 and defined p4_clearbg_alt 2022-05-06 16:26:44 +01:00
Lephe
a4df076214
render-cg: replace dimage and dsubimage with new renderer 2022-05-04 20:53:56 +01:00
Lephe
7a3604ccbb
render-cg: allocate VRAM in the heap; default to double buffering
* Create a heap arena over the OS stack, large enough to hold two VRAMs
  as was previously done, unless GINT_NO_OS_STACK is set at compile
  time. (This replaces GINT_USER_VRAM.)

* Allocate a single VRAM in the heap at startup.

* Use double buffering by default as triple buffering is almost entirely
  useless. dudpate() waits if both VRAMs are identical to prevent
  corruption, but this can be bypassed with R61524 functions as usual.
  This adds about 180 kB of heap data to any add-in using default
  settings.
2022-05-04 20:08:52 +01:00
Lephe
f219e5c882
render-cg: add new image rendering functions with dynamic effects 2022-05-04 19:08:54 +01:00
Lephe
8210524152
ld: merge XRAM and YRAM into a single 16-kiB section 2022-05-04 19:08:54 +01:00