a547235f8f
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. |
||
---|---|---|
cmake | ||
include/gint | ||
src | ||
.gitignore | ||
CMakeLists.txt | ||
fx9860g.ld | ||
fxcg50.ld | ||
giteapc.make | ||
README.md | ||
TODO |
gint project
gint (pronounce “guin”) is an add-in unikernel for CASIO calculators of the fx-9860G II and fx-CG 50 families. It provides a mostly free-standing runtime and is used to develop add-ins under Linux, along with specialized GCC toolchains and the fxSDK.
When running in an add-in, gint takes control of the calculator's hardware from the operating system, and manages it with its own drivers. It exposes a new, richer API that takes advantage of the full capabilities of the machine.
This is free software: you may use it for any purpose, share it, modify it, and share your changes. Credit is not required, but please let me know!
gint also includes third-party code that is distributed under its own license. Currently, this includes:
- A stripped-down version of the TinyMT random number generator
(GitHub repository) by
Mutsuo Saito and Makoto Matsumoto. See
src/3rdparty/tinymt32/LICENSE.txt
. - A stripped-down version of the Grisu2b floating-point representation
algorithm
with α=-59 and γ=-56, by Florian Loitsch. See
src/3rdparty/grisu2b_59_56/README
for details, and the original code here.
Programming interface
Because of its free-standing design, gint's API provides direct and efficient access to low-level MPU features, which includes:
- Multi-key management with event systems suitable for games
- Hardware timers with sub-millisecond and sub-microsecond resolution
- Fast screen drivers with DMAC on fx-CG 50
- Efficient and user-extendable interrupt management
- Safe access to on-chip and DSP memory areas
- Hardware-driven memory primitives (DMA, DSP)
The library also offers powerful higher-level features:
- An enhanced version of the system's GetKey() and GetKeyWait()
- A gray engine that works by rapidly swapping monochrome images on fx-9860G II
- Blazingly fast rendering functions (image rendering is 10 times faster tha MonochromeLib)
- Integrated font management
A couple of libraries extend these features, including:
- libprof: Profiling and performance evaluation
- libimg: Versatile image transformations
- OpenLibm: A port of the standard math library
- Integration with a Newlib port by Memallox (unstable)
Installing with GiteaPC
gint can be installed automatically with GiteaPC.
% giteapc install Lephenixnoir/gint
Normally you don't use gint directly, instead the fxSDK provides project templates that are set up to use gint. Please see the fxSDK README file for details.
Building and installing manually
gint is built using the fxSDK, which provides a suitable
CMake environment for the calculator. gint is always installed in the
compiler's install path (as given by sh-elf-gcc --print-search-dirs
) which is
detected automatically, so normally you don't need to set the install prefix.
fx-CG 50 developers probably want a g3a wrapper as well; the reference implementation is Tari's mkg3a. This is needed at the very last compilation step to create the g3a file. On Arch Linux, you can use the AUR/mkg3a package maintained directly by Tari.
Building for fx-9860G II
fxsdk build-fx
will invoke CMake and make. If you have specific configuration
options, run once with -c
to configure.
% fxsdk build-fx -c <OPTIONS...>
Run without -c
to build. This configures automatically.
% fxsdk build-fx
The available options are:
-DGINT_STATIC_GRAY=1
: Put the gray engine's VRAMs in static RAM instead of usingmalloc()
Building for fx-CG 50
Same as fx-9860G II, except the command is fxsdk build-cg
instead of fxsdk build-fx
.
The available options are:
-DGINT_USER_VRAM=1
: Store all VRAMs in the user stack (takes up 350k/512k)
Using in CMake-based add-ins
Find the Gint
module and link against Gint::Gint
.
find_module(Gint 2.1 REQUIRED)
target_link_libraries(<target_name> Gint::Gint)
Using in Makefile-based add-ins
Projects created with the fxSDK link with gint out-of-the-box. If you're not using the fxSDK, you will need to:
- Build with
-ffreestanding -fstrict-volatile-bitfields
; - Link with
-T fx9860g.ld
and-lgint-fx
on fx-9860G; - Link with
-T fxcg50.ld
and-lgint-cg
on fx-CG 50.
If you don't have a standard library such as
Memallox's port of newlib, you also need -nostdlib
. I
typically use -m3 -mb
or -m4-nofpu -mb
to specify the platform, but that
may not even be necessary.