Commit Graph

484 Commits (dev)

Author SHA1 Message Date
Lephe 2bb5294578
gint: avoid annoying banner on return from menu on fx-CG
Instead of using GetKeyWait(), we directly call into an internal OS
function, which avoids the need to press a key before we can redraw over
the OS banner and VRAM when coming back. The disassembly to locate the
function was developed by Dr-Carlos.

We still have to redraw when coming back; getkey() will do it by
dupdate() by default, and it that's not a possibility for the
application an option to receive a special event and handle it manually
is provided.
2023-08-19 22:52:53 +02:00
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
Lephe dcb876dfe0
bump version to 2.10.0 2023-04-02 00:10:13 +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 eb49f0258d
usb: show prototypes of debug functions in non-debug mode 2023-04-01 23:24:21 +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 c28d06002f
ld: add support for FastLoad config for circuit10's Add-In Push 2023-01-17 09:53:58 +01:00
Lephe ac6b1c7d70
ld: generate linker scripts; add fxcg50_fastload.ld 2023-01-15 01:36:28 +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 <>
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 d3b29c50e6
defs: use C++ min/max when compiling in C++ mode 2023-01-01 18:49:13 +01:00
Lephe 1272a6a71a
scif: fix incorrect base module address 2022-12-20 22:27:35 +01:00
Lephe 723bae134b
serial: add template header for future implementation
Co-authored-by: Slyvtt <>
2022-12-10 15:27:38 +01:00
Lephe 3bc3892524
scif: add the SH7705 and SH7305 SCIF descriptions
Co-authored-by: Slyvtt <>
2022-12-10 14:41:30 +01:00
Lephe 211d236496
pfc: add the SH7305 PFC description
Co-authored-by: Slyvtt <>
2022-12-10 11:46:44 +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
Lephe 3192078c4c
kernel: more detailed quit handler documentation 2022-11-27 22:57:50 +01:00
Lephenixnoir a5fb6d3401 Merge pull request 'Added SetQuitHandler syscall into gint' (#21) from mibi88/gint:dev into dev
Reviewed-on: #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 813af222fd Merge branch 'dev' of into dev 2022-11-20 11:48:37 +01:00
mibi88 984f162cb2 Added gint_set_quit_handler() 2022-11-20 11:48:26 +01:00
mibi88 6426406043 Fix typo 2022-11-20 11:48:26 +01:00
mibi88 2fe67412cc Added SetQuitHandler. 2022-11-20 11:48:26 +01:00