You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(35) |
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(37) |
Feb
(10) |
Mar
|
Apr
(2) |
May
(17) |
Jun
(1) |
Jul
(14) |
Aug
(14) |
Sep
(4) |
Oct
|
Nov
(14) |
Dec
(4) |
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
(92) |
Dec
(12) |
2006 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(5) |
May
(3) |
Jun
(15) |
Jul
(3) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
(6) |
Dec
(5) |
2007 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(3) |
May
(14) |
Jun
(2) |
Jul
(16) |
Aug
(73) |
Sep
(12) |
Oct
(9) |
Nov
(27) |
Dec
(3) |
2008 |
Jan
(4) |
Feb
(4) |
Mar
(3) |
Apr
(8) |
May
(23) |
Jun
(4) |
Jul
(1) |
Aug
(3) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
|
Feb
(10) |
Mar
|
Apr
(4) |
May
(4) |
Jun
(10) |
Jul
|
Aug
(1) |
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
2010 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
|
Jun
(3) |
Jul
(11) |
Aug
(1) |
Sep
|
Oct
(15) |
Nov
(1) |
Dec
(5) |
2011 |
Jan
(4) |
Feb
(1) |
Mar
(6) |
Apr
|
May
(22) |
Jun
|
Jul
(8) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2012 |
Jan
|
Feb
(10) |
Mar
(1) |
Apr
(6) |
May
(27) |
Jun
(48) |
Jul
(30) |
Aug
(4) |
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(11) |
2013 |
Jan
(4) |
Feb
(7) |
Mar
(6) |
Apr
(18) |
May
(28) |
Jun
(20) |
Jul
|
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(7) |
2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(9) |
May
(11) |
Jun
(10) |
Jul
|
Aug
(18) |
Sep
(12) |
Oct
(17) |
Nov
(10) |
Dec
(16) |
2015 |
Jan
(5) |
Feb
(1) |
Mar
(5) |
Apr
(4) |
May
(28) |
Jun
(2) |
Jul
|
Aug
|
Sep
(6) |
Oct
|
Nov
(2) |
Dec
(1) |
2016 |
Jan
(14) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(1) |
2017 |
Jan
(11) |
Feb
|
Mar
(21) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(2) |
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2020 |
Jan
(10) |
Feb
(9) |
Mar
(5) |
Apr
(4) |
May
(3) |
Jun
(18) |
Jul
(4) |
Aug
(2) |
Sep
(20) |
Oct
(2) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2023 |
Jan
(10) |
Feb
(7) |
Mar
(29) |
Apr
(31) |
May
(29) |
Jun
(34) |
Jul
(3) |
Aug
(24) |
Sep
(22) |
Oct
(10) |
Nov
(38) |
Dec
(27) |
2024 |
Jan
(15) |
Feb
(8) |
Mar
(4) |
Apr
(20) |
May
(33) |
Jun
(18) |
Jul
(15) |
Aug
(23) |
Sep
(26) |
Oct
(32) |
Nov
(6) |
Dec
(4) |
2025 |
Jan
(7) |
Feb
(1) |
Mar
(1) |
Apr
(4) |
May
(46) |
Jun
(19) |
Jul
(20) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: quzar <qu...@us...> - 2024-12-25 17:38:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, v2.1.x has been created at d6f42aecdfef897de019f8a82345194bec17d1c6 (commit) - Log ----------------------------------------------------------------- commit d6f42aecdfef897de019f8a82345194bec17d1c6 Author: QuzarDC <qu...@co...> Date: Wed Dec 25 12:06:49 2024 -0500 Updating and truncating changelog and relnotes for v2.1.1 commit 9e07dbe5a02639fb93364edfdf691e2d1ec11bff Author: Jose Ribeiro <jos...@gm...> Date: Thu Nov 14 12:40:18 2024 -0500 Add documentation guide for users and maintainers (#759) commit ff95da13b91dc119d9b158508c3c365f7e958174 Author: Donald Haase <qu...@ya...> Date: Mon Oct 21 01:17:29 2024 -0400 The sys/queue `_FOREACH` functions are not safe to free their elements. (#823) Swap usage to the `_FOREACH_SAFE` which is the safe version. Without this, each time `qpkt` is freed, the next loop iteration is based on a use-after-free. Co-authored-by: QuzarDC <qu...@co...> commit 80fe86ffb2aa827b115456c4ec28d221d583604e Author: Andy Barajas <and...@gm...> Date: Fri Oct 11 14:13:14 2024 -0700 Fix dreampresent compile error by moving constants out of the methods (#814) commit 07547de28a36fdbc1850a441c5821062942af524 Author: voxel-public <797...@us...> Date: Tue Oct 8 17:03:58 2024 +1000 Update mat_transform parameter description (#770) Correct description of mat_transform parameter from vecskip to stride, to ensure generated documentation is no longer misleading commit 3ce5f136a1263fb3e615c93e797855b0d17f79b2 Author: Donald Haase <qu...@ya...> Date: Tue Oct 8 04:28:13 2024 -0400 By default have dbgio disabled until init. This prevents asserting if we try to use it prior to dbgio being initialized, which happens if we use KM_DBG with dcload serial as it allocates memory (triggering dbgio) to set up a compression buffer. (#673) Co-authored-by: QuzarDC <qu...@co...> commit 423271940f259c4683c54190eae6180b7fcf0890 Author: Falco Girgis <gyr...@gm...> Date: Tue Oct 8 02:49:40 2024 -0500 Fixed pvrtex warnings with Clang18 host compiler (#791) * Fixed pvrtex warnings with Clang18 host compiler - A couple of warnings are manifesting in the pvrtex codebase when bulding with a recent verison of Clang. - ATOMIC_INIT() was deprecated in later versions of C, which Clang defaults to now * forcing project to be built uniformly using GNU17 C standard for everyone * got rid of ATOMIC_INIT() usage - Clang correctly diagnosed a set but unused variable in pvrtex... commit a42667fdbacf9fd0ca4f106ebc95c10791922e1b Author: Andy Barajas <and...@gm...> Date: Sat Oct 5 06:55:38 2024 -0700 Remove compiling pvrtex with LTO because it is not needed and can cause issues on certain hosts. (#789) commit 3fb2207629c5072b173c649048193ec152692de9 Author: Andy Barajas <and...@gm...> Date: Mon Sep 30 16:00:34 2024 -0700 Network speedtest (#671) Add bba/lan network speed test example. commit 85ffebaf03a57f68340f0a866b561d1c09700836 Author: Andy Barajas <and...@gm...> Date: Thu Sep 26 20:44:52 2024 -0700 Bug in bin2c's Makefile, the bin2c target does not depend on bin2c.c (#777) commit 3bdf6a1b240230a7b75df5acb8d566f3fb9c2f45 Author: Donald Haase <qu...@ya...> Date: Thu Sep 26 23:46:01 2024 -0400 Clean up usage of `INLINE` in utils (#771) * Just use c99 inline rather than the custom one. When this was originally written it wasn't as widely supported. Clean up unnessary commented out bits. * Remove copy-pasted CFLAGS define. * Clean up copy-pasted CFLAG define and commented out debug option. --------- Co-authored-by: QuzarDC <qu...@co...> Co-authored-by: Falco Girgis <gyr...@gm...> commit 098877903698d188ca7ba45ff8f035ab90712fbb Author: Falco Girgis <gyr...@gm...> Date: Mon Sep 23 11:45:22 2024 -0500 Fixed KOS's Makefile.rules. (#752) They were incorrect and were causing really annoying warnings on other projects, such as GTA3, where C++ was warning that "-std=gnu17" is only available in C++. How does this happen? Because our Makefile.rules file was INCORRECTLY concatenating CFLAGS and CXXFLAGS and sending them to the C++ compiler. This is incorrect. Those two are separate and should go to their respective compilers only; however, CPPFLAGS is supposed to be common, shared, preprocessor flags that go to both. - Removed CFLAGS from C++ rules - Added CPPFLAGS to C, C++, ObjC, and ObjC++ rules commit f93ccb141cd24c3abad4f2f318fed2fd179a89cf Author: Donald Haase <qu...@ya...> Date: Mon Sep 23 12:42:35 2024 -0400 Add workaround for inlining to support c89 user code (namely opus libs from kos-ports). (#768) commit 89bf2daea63f617029ebb06e77841f2d3c29b75d Author: dfchil <dan...@gm...> Date: Sun Sep 22 21:47:29 2024 +0200 Added small approval test on binary output from pvrtex (#732) commit 0034b77525ccc3f9316ac56a82f730a5a3c88687 Author: Andy Barajas <and...@gm...> Date: Sun Sep 22 18:02:18 2024 -0700 Update wav2adpcm (#755) Replaced encoding/decoding GPL code with public domain code. Added interleave(-i) option thanks to SKMP. commit 1d54f2bc42598015353e05decf178e40651aa18a Author: Falco Girgis <gyr...@gm...> Date: Tue Sep 17 19:59:17 2024 -0500 Modified PVR cxt compilation to be write-only. (#751) Modified the following PVR API routines to be WRITE-ONLY to their destination vertex header pointers: - pvr_poly_compile() - pvr_sprite_compile() - pvr_mod_compile() This will allow us to compile headers "in-place" within the SQ-mapped pointers returned by pvr_dr_target(), for better gainz using the direct rendering API... This is required since according to some docs, the SQs are write-only while others claim only 32-bit reads are valid... Either way, this was necessary to be safe. commit e2e666a4d6a83b1ef128cf0587c59eae62dc0037 Author: darcagn <da...@pr...> Date: Mon Sep 16 21:43:27 2024 -0500 Prevent thd_shutdown() from destroying kernel thread (#757) commit b3231422c275b60b7af14038065528389a8b872b Author: Stefanos Kornilios Mitsis Poiitidis <sk...@ni...> Date: Sat Sep 7 19:25:08 2024 +0300 aica: Channel masks are 64 bits, use ULL consts commit fed37dd2628b76c0925f85af8840f72db49ec458 Author: darcagn <da...@pr...> Date: Sat Aug 31 23:24:15 2024 -0500 Update pvrtex/stb_image.h from v2.27 to v2.30 to fix compilation warning (#731) commit 622f58d896d8b17255b88cd17361963f0dca858e Author: Andy Barajas <and...@gm...> Date: Thu Aug 22 19:19:21 2024 -0700 Fix KOS warning when compiling SDL2 using m4-single (#724) * Fix warning when compiling SDL2 using m4-single * Update kernel/arch/dreamcast/include/arch/args.h commit 99cf81ab38b5d077642b421cccabc758983b247c Author: SiZiOUS <si...@gm...> Date: Mon Aug 19 06:59:56 2024 +0100 `utils`: adding `font2txf`, a tool to make TXF from TrueType/OpenType fonts (#704) * `utils`: adding `font2txf`, a tool to make TXF from TrueType/OpenType fonts. This tool is an updated version of the ttf2txf tool created by Chris Laurel for the Celestia project. TXF font format was created in 1997 by Mark J. Kilgard for the OpenGL Utility Toolkit (GLUT). TXF is supported using the `libdcplib` kos-port via the PLIB FNT component. * `utils`: don't build `font2txf` by default (at least for now) commit aa132dc229204bec204ac90a94d9d99aaab4b188 Author: Andy Barajas <and...@gm...> Date: Sun Aug 18 20:44:40 2024 -0700 Cleanup documentation. Rearrange error checking code. Remove unused symbol. (#716) commit 13236211bdd97aa56e119c561885e667178f7393 Author: Gleb Mazovetskiy <gle...@gm...> Date: Sat Oct 5 15:17:22 2024 +0100 environ_base.sh: Remove `-fno-operator-names` flag (#785) This flag disabled support for `and/or/not` operator aliases, which are part of the C++ standard since its very first version (C++98) and are used in some open-source libraries, such as https://github.com/realnc/SDL_audiolib. commit ef83c751deb3df299ca29cd166a8324497d9e681 Author: Paul Cercueil <pa...@cr...> Date: Mon Sep 30 12:01:56 2024 +0200 CMake: Use kos-cc as the assembler (#782) CMake does detect the GNU assembler correctly, but does not seem to know how to use it properly; it passes flags it shouldn't (e.g. -with-sysroot or -isystem), or flags with the incorrect arguments. This is because on most (all?) GNU platforms, CMake is configured to use GCC itself as the assembler. In that case, it passes the correct (and different) flags which makes it able to compile assembler files. Fix compilation of assembler files in CMake by using kos-cc as the assembler. Signed-off-by: Paul Cercueil <pa...@cr...> commit c5877747c52aa0ccddd65c69c067039a55b9d16b Author: Cole Hall <col...@gm...> Date: Fri Sep 27 07:55:12 2024 +0100 Fix license link in README.md (#776) commit 54ef320fc3a88ef21bb45de6b7e84aba4b9bd503 Author: Paul Cercueil <pa...@cr...> Date: Mon Sep 23 03:38:04 2024 +0200 utils/pvrtex: fix and improve Makefile (#749) We must not add KOS specific include paths when compiling a *host* utility. This can cause the compilation to fail (as it did on my system). A lot of the rules are unnecesary, the default rules can be used as long as the proper variable names are used. The "all" rule is moved as the first rule, so that running "make" will be equivalent to running "make all". Signed-off-by: Paul Cercueil <pa...@cr...> commit ba8c7d47d33a0015c139b55edae93f04d870e0ba Author: dfchil <dan...@gm...> Date: Fri Sep 6 08:36:05 2024 +0200 Added a set of known working purupuru bit patterns to the rumble example (#682) --------- Co-authored-by: drxl <da...@vm...> Co-authored-by: Daniel Fairchild <da...@vi...> commit 2981c6c6d5ffbe79c728e922cd70812ce1f40ca4 Author: SiZiOUS <si...@gm...> Date: Mon Aug 19 06:25:26 2024 +0100 `LibADX`: adding an example for ADX playback (#715) This example was written by Josh 'PH3NOM' Pearson <ph3...@gm...> (@PH3NOM-PRO). commit 0fe922f9d3a20766ede3b280c7db1654fcdb6fe1 Author: jnmartin84 <jnm...@gm...> Date: Mon Nov 11 00:58:17 2024 -0500 Add an example of how to render lines with the PVR. (#714) commit f018f4b4e83982a3d2c20918094c14f92bd6d679 Author: darcagn <da...@pr...> Date: Wed Aug 21 10:51:42 2024 -0500 Adjust pvrtex .gitignore and Makefile (#721) -Create info folder as needed rather than forcing it to always exist. commit 26934634f0885315eeeb1dc4330e50ccc9fa7e6e Author: dfchil <dan...@gm...> Date: Tue Aug 20 17:29:43 2024 +0200 Pvrtex minor fixes (#720) * removed dependency on xxd, used the standarized install path in $DC_TOOLS_BASE * removed the autogenerated info/*.h files --------- Co-authored-by: Daniel Fairchild <da...@vi...> commit d05cda6951973f9678a6d2f8d1ab37096d55311e Author: dfchil <dan...@gm...> Date: Mon Aug 19 06:26:56 2024 +0200 Add pvrtex utility (#602) * Added pvrtex source files * Added install target in Makefile * Fix compilation on ARM64 targets * Added targets for generating header files from selected sections in the README file * Added command line option --examples/-E which outputs the "Usage Examples" section of the README file * Changed -h/--help option to output the "Command Line Options:" section of the README file * Fixed bug with printing of non zero terminated char arrays from info/*.h files * Various minor bug, build, and warning fixes --------- Co-authored-by: drxl <da...@vm...> Co-authored-by: Daniel Fairchild <da...@vi...> commit b843f4be7dc83405ed34f79dbcf14aecb4bd5fd3 Author: Andy Barajas <and...@gm...> Date: Sun Aug 18 20:47:59 2024 -0700 Fix kos doxygen warnings (#711) commit 8477b76a5b6c7c838b7098fe8c4015594eb5c463 Author: Tchan0 <617...@us...> Date: Mon Aug 19 05:46:43 2024 +0200 Naomi: examples Makefile: exclude network, modem & g1ata (#713) * Naomi: examples Makefile: exclude modem & g1ata Exclude examples /modem & /g1ata when building for Naomi, as the corresponding functions do not exist for Naomi * Naomi: examples Makefile: exclude network Exclude network examples, as network is also excluded when building KallistiOS for Naomi commit 3689a6741dc67ff809f969ab1f6d1cb81fb774a1 Author: Tchan0 <617...@us...> Date: Thu Aug 15 19:50:42 2024 +0200 gitignore: add .vscode folders Add .vscode folders that could be added in the examples by the users, when using Visual Studio Code commit 0e03341ca3f96b74baeae46ffe0cf7477680a814 Author: QuzarDC <qu...@co...> Date: Mon Nov 11 00:28:43 2024 -0500 Expanded VFS documentation (#684) Including some information on how it works, how to start it and image size limitations. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-12-04 19:16:25
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via bae7adbde177c04560de31577932ace50988b238 (commit) via 968f4ac212387d0353c863670a578059a03cbafa (commit) via 6f10c0e34b9654546bd00a8cb4ada9516717061b (commit) via 0544b0ad66c620c065565155bd8dbc33fc85858b (commit) from e1d7e5b49431ff043652f09cbd81e8bb414b0b5b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bae7adbde177c04560de31577932ace50988b238 Author: Donald Haase <qu...@ya...> Date: Wed Dec 4 14:15:10 2024 -0500 Reverse the order of searching the genwait queue. (#820) This should provide an optimization for the more common scenario of new entries waiting longer than old. commit 968f4ac212387d0353c863670a578059a03cbafa Author: Donald Haase <qu...@ya...> Date: Wed Dec 4 14:14:27 2024 -0500 Correct out-of-memory test in scandir (#853) The test after realloc was improperly testing 'list' for NULL rather than '*list'. commit 6f10c0e34b9654546bd00a8cb4ada9516717061b Author: Donald Haase <qu...@ya...> Date: Wed Dec 4 14:01:12 2024 -0500 Fix wide character support. (#857) The previous cleanup of bfont.h accidentally used the size of a thin char to calculate the offsets for all the wide chars. The impact was visible in the bfont example where instead of printing the start button icon, a JISX-0208 character was printed. commit 0544b0ad66c620c065565155bd8dbc33fc85858b Author: Donald Haase <qu...@ya...> Date: Wed Dec 4 13:57:52 2024 -0500 Update byteorder to not rely on arch types (#855) byteorder.h was including <sys/_types.h> taking advantage of an old workaround that exports our internal types through that header and into stdio. This was the only file relying on that workaround in the KOS codebase and adjusting it is needed for #840 ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/arch/byteorder.h | 6 ++---- kernel/arch/dreamcast/include/dc/biosfont.h | 12 +++++++----- kernel/libc/koslib/scandir.c | 2 +- kernel/thread/genwait.c | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/kernel/arch/dreamcast/include/arch/byteorder.h b/kernel/arch/dreamcast/include/arch/byteorder.h index 2585f247..f21aa92a 100644 --- a/kernel/arch/dreamcast/include/arch/byteorder.h +++ b/kernel/arch/dreamcast/include/arch/byteorder.h @@ -25,8 +25,6 @@ #include <sys/cdefs.h> __BEGIN_DECLS -#include <sys/_types.h> - #ifdef BYTE_ORDER /* If we've included <arch/types.h>, this might already be defined... */ #undef BYTE_ORDER @@ -52,7 +50,7 @@ __BEGIN_DECLS \return The swapped value. */ #define arch_swap16(x) ({ \ - uint16 __x = (x); \ + uint16_t __x = (x); \ __asm__ __volatile__("swap.b %0, %0" : "=r" (__x) : "0" (__x)); \ __x; \ }) @@ -67,7 +65,7 @@ __BEGIN_DECLS \return The swapped value. */ #define arch_swap32(x) ({ \ - uint32 __x = (x); \ + uint32_t __x = (x); \ __asm__ __volatile__("swap.b %0, %0\n\t" \ "swap.w %0, %0\n\t" \ "swap.b %0, %0\n\t" : "=r"(__x) : "0" (__x)); \ diff --git a/kernel/arch/dreamcast/include/dc/biosfont.h b/kernel/arch/dreamcast/include/dc/biosfont.h index b2a77cb3..f4be15f9 100644 --- a/kernel/arch/dreamcast/include/dc/biosfont.h +++ b/kernel/arch/dreamcast/include/dc/biosfont.h @@ -55,6 +55,7 @@ __BEGIN_DECLS /** \brief Number of bytes to represent a single character within the BIOS font. */ #define BFONT_BYTES_PER_CHAR (BFONT_THIN_WIDTH * BFONT_HEIGHT / 8) +#define BFONT_BYTES_PER_WIDE_CHAR (BFONT_WIDE_WIDTH * BFONT_HEIGHT / 8) /** \defgroup bfont_indicies Structure \brief Structure of the Bios Font @@ -76,14 +77,15 @@ __BEGIN_DECLS /** \brief Start of JISX-0208 Rows 1-7 in Font Block */ #define BFONT_JISX_0208_ROW1 BFONT_WIDE_START /** \brief Start of JISX-0208 Row 16-47 (Start of Level 1) in Font Block */ -#define BFONT_JISX_0208_ROW16 (BFONT_WIDE_START + (658 * BFONT_BYTES_PER_CHAR)) +#define BFONT_JISX_0208_ROW16 (BFONT_WIDE_START + (658 * BFONT_BYTES_PER_WIDE_CHAR)) /** \brief JISX-0208 Row 48-84 (Start of Level 2) in Font Block */ -#define BFONT_JISX_0208_ROW48 (BFONT_JISX_0208_ROW16 + ((32 * JISX_0208_ROW_SIZE) * BFONT_BYTES_PER_CHAR)) +#define BFONT_JISX_0208_ROW48 (BFONT_JISX_0208_ROW16 + ((32 * JISX_0208_ROW_SIZE) * BFONT_BYTES_PER_WIDE_CHAR)) /** \brief Start of DC Specific Characters in Font Block */ -#define BFONT_DREAMCAST_SPECIFIC (BFONT_WIDE_START + (7056 * BFONT_BYTES_PER_CHAR)) +#define BFONT_DREAMCAST_SPECIFIC (BFONT_WIDE_START + (7056 * BFONT_BYTES_PER_WIDE_CHAR)) + /** \brief Takes a DC-specific icon index and returns a character offset. */ -#define BFONT_DC_ICON(offset) (BFONT_DREAMCAST_SPECIFIC + ((offset) * BFONT_BYTES_PER_CHAR)) +#define BFONT_DC_ICON(offset) (BFONT_DREAMCAST_SPECIFIC + ((offset) * BFONT_BYTES_PER_WIDE_CHAR)) /** \defgroup bfont_dc_indices Dreamcast-Specific \brief Dreamcast-specific BIOS icon offsets. @@ -114,7 +116,7 @@ __BEGIN_DECLS /** @} */ #define BFONT_ICON_DIMEN 32 /**< \brief Dimension of vmu icons */ -#define BFONT_VMU_DREAMCAST_SPECIFIC (BFONT_DREAMCAST_SPECIFIC+(22 * BFONT_BYTES_PER_CHAR)) +#define BFONT_VMU_DREAMCAST_SPECIFIC (BFONT_DREAMCAST_SPECIFIC+(22 * BFONT_BYTES_PER_WIDE_CHAR)) /** @} */ /** \brief Builtin VMU Icons diff --git a/kernel/libc/koslib/scandir.c b/kernel/libc/koslib/scandir.c index c81106e5..bff4b488 100644 --- a/kernel/libc/koslib/scandir.c +++ b/kernel/libc/koslib/scandir.c @@ -48,7 +48,7 @@ static int push_back(struct dirent ***list, int *size, int *capacity, *list = realloc(*list, *capacity * sizeof(struct dirent*)); /* Handle out-of-memory in case realloc() failed. */ - if(!list) + if(!*list) goto out_of_memory; else list_tmp = list; diff --git a/kernel/thread/genwait.c b/kernel/thread/genwait.c index b5c8fa4f..11e40fa2 100644 --- a/kernel/thread/genwait.c +++ b/kernel/thread/genwait.c @@ -45,15 +45,15 @@ static void tq_insert(kthread_t * thd) { /* Search for its place; note that new threads will be placed at the end of a group with the same timeout. */ - TAILQ_FOREACH(t, &timer_queue, timerq) { - if(thd->wait_timeout < t->wait_timeout) { - TAILQ_INSERT_BEFORE(t, thd, timerq); + TAILQ_FOREACH_REVERSE(t, &timer_queue, slpquehead, timerq) { + if(thd->wait_timeout >= t->wait_timeout) { + TAILQ_INSERT_AFTER(&timer_queue, t, thd, timerq); return; } } - /* Couldn't find anything scheduled later, put this at the end. */ - TAILQ_INSERT_TAIL(&timer_queue, thd, timerq); + /* Couldn't find anything scheduled earlier, put this at the start. */ + TAILQ_INSERT_HEAD(&timer_queue, thd, timerq); } /* Internal function to remove a thread from the timer queue. */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-11-20 01:45:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e1d7e5b49431ff043652f09cbd81e8bb414b0b5b (commit) from 99308c534d03c585d4b4aa14ad278e072081300b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e1d7e5b49431ff043652f09cbd81e8bb414b0b5b Author: Ruslan Rostovtsev <sw...@21...> Date: Wed Nov 20 05:29:36 2024 +0700 Loadable library recovery and example (#819) * Fix and improve loadable library build. * Fixed library ref counting and cleanup. * Added library_lookup_fn. * Aligned elf image to cache line and DMA. * Added export_lookup_path and export_lookup_addr. * Added loadable library full example. ----------------------------------------------------------------------- Summary of changes: .gitignore | 9 +- Makefile.rules | 18 ++ environ_base.sh | 1 + examples/dreamcast/library/Makefile | 47 ++++ examples/dreamcast/library/exports.txt | 7 + examples/dreamcast/library/library-test.c | 137 ++++++++++ .../dreamcast/library/loadable-dependence/Makefile | 24 ++ .../library/loadable-dependence/exports.txt | 10 + .../loadable-dependence/library-dependence.c | 55 ++++ .../loadable-dependence/library-dependence.h | 18 ++ .../dreamcast/library/loadable-dependent/Makefile | 18 ++ .../library/loadable-dependent/library-dependent.c | 52 ++++ include/kos/exports.h | 30 ++- include/kos/library.h | 61 +++-- kernel/exports/exports.c | 64 ++++- kernel/exports/library.c | 77 +++--- kernel/fs/elf.c | 2 +- loadable/Makefile.prefab | 39 +-- loadable/shlelf_dc.xr | 288 ++++++++------------- 19 files changed, 680 insertions(+), 277 deletions(-) create mode 100644 examples/dreamcast/library/Makefile create mode 100644 examples/dreamcast/library/exports.txt create mode 100644 examples/dreamcast/library/library-test.c create mode 100644 examples/dreamcast/library/loadable-dependence/Makefile create mode 100644 examples/dreamcast/library/loadable-dependence/exports.txt create mode 100644 examples/dreamcast/library/loadable-dependence/library-dependence.c create mode 100644 examples/dreamcast/library/loadable-dependence/library-dependence.h create mode 100644 examples/dreamcast/library/loadable-dependent/Makefile create mode 100644 examples/dreamcast/library/loadable-dependent/library-dependent.c diff --git a/.gitignore b/.gitignore index 107e5e4f..7552e5e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ *.o +*.a *.elf +*.bin +*.klf *.exe *.dll *.map @@ -15,8 +18,6 @@ kernel/exports/kernel_exports.c kernel/arch/dreamcast/kernel/arch_exports.c kernel/arch/dreamcast/kernel/banner.h kernel/arch/dreamcast/sound/arm/stream.drv -lib/dreamcast/*.a -addons/lib/dreamcast/*.a utils/bincnv/bincnv utils/genromfs/genromfs utils/vqenc/vqenc @@ -45,6 +46,10 @@ examples/dreamcast/pvr/bumpmap/romdisk/bumpmap.raw examples/dreamcast/pvr/modifier_volume_tex/romdisk/fruit.kmg examples/dreamcast/pvr/texture_render/texture_render.bin examples/dreamcast/video/screenshot/screenshot*.ppm +examples/dreamcast/library/exports.c +examples/dreamcast/library/exports_stubs.c +examples/dreamcast/library/*/exports.c +examples/dreamcast/library/*/exports_stubs.c utils/dc-chain/logs utils/dc-chain/*.tar.bz2 utils/dc-chain/*.tar.gz diff --git a/Makefile.rules b/Makefile.rules index f8f1b16e..9fa4aa62 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -3,6 +3,7 @@ # Makefile.rules # Copyright (c) 2000, 2001 Megan Potter # Copyright (c) 2024 Eric Fradella +# Copyright (C) 2024 Ruslan Rostovtsev # # Global KallistiOS Makefile include @@ -104,3 +105,20 @@ endef define KOS_GCCVER_MIN_WARNING @echo "Skipping $(TARGET) build as current GCC version ($(KOS_GCCVER)) is less than $(KOS_GCCVER_MIN)." endef + +ifdef EXPORTS_FILE + +OBJS += exports.o + +exports.o: exports.c +exports.c: $(EXPORTS_FILE) + $(KOS_BASE)/utils/genexports/genexports.sh $(EXPORTS_FILE) exports.c $(EXPORTS_SYMBOL) + +exports_stubs.o: exports_stubs.c +exports_stubs.c: $(EXPORTS_FILE) + $(KOS_BASE)/utils/genexports/genexportstubs.sh $(EXPORTS_FILE) exports_stubs.c + +$(TARGET_LIB): exports_stubs.o + $(KOS_AR) rcs $(TARGET_LIB) exports_stubs.o + +endif diff --git a/environ_base.sh b/environ_base.sh index a6fada44..ca64b7b4 100644 --- a/environ_base.sh +++ b/environ_base.sh @@ -47,6 +47,7 @@ export KOS_ADDR2LINE="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-addr2line" export KOS_LD="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-ld" export KOS_RANLIB="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-gcc-ranlib" export KOS_STRIP="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-strip" +export KOS_SIZE="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-size" export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_INC_PATHS} -D_arch_${KOS_ARCH} -D_arch_sub_${KOS_SUBARCH} -Wall -g" export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP}" diff --git a/examples/dreamcast/library/Makefile b/examples/dreamcast/library/Makefile new file mode 100644 index 00000000..18bd32fc --- /dev/null +++ b/examples/dreamcast/library/Makefile @@ -0,0 +1,47 @@ +# KallistiOS ##version## +# +# examples/dreamcast/library/Makefile +# Copyright (C) 2024 Ruslan Rostovtsev +# + +TARGET_NAME = library-test +TARGET = $(TARGET_NAME).elf +TARGET_LIB = lib$(TARGET_NAME).a +TARGET_BIN = $(TARGET_NAME).bin +OBJS = $(TARGET_NAME).o romdisk.o + +EXPORTS_FILE = exports.txt +EXPORTS_SYMBOL = libtest_symtab +KOS_ROMDISK_DIR = romdisk + +include $(KOS_BASE)/Makefile.rules + +KOS_CFLAGS += -I./loadable-dependence + +all: rm-elf $(TARGET_LIB) loadable $(TARGET) + +clean: rm-elf + -rm -f $(OBJS) + -rm -rf ./romdisk + cd loadable-dependence && make clean + cd loadable-dependent && make clean + +rm-elf: + -rm -f $(TARGET) $(TARGET_BIN) $(TARGET_LIB) romdisk.* + +loadable: + mkdir -p romdisk + cd loadable-dependence && make && cp library-dependence.klf ../romdisk + cd loadable-dependent && make && cp library-dependent.klf ../romdisk + +$(TARGET): $(OBJS) + kos-cc -o $(TARGET) $(OBJS) + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: $(TARGET) + -rm -f $(OBJS) romdisk.img + $(KOS_STRIP) $(TARGET) + $(KOS_OBJCOPY) -R .stack -O binary $(TARGET) $(TARGET_BIN) + $(KOS_SIZE) $(TARGET) diff --git a/examples/dreamcast/library/exports.txt b/examples/dreamcast/library/exports.txt new file mode 100644 index 00000000..6a8503c3 --- /dev/null +++ b/examples/dreamcast/library/exports.txt @@ -0,0 +1,7 @@ +include kos/exports.h +include string.h + +# Additional newlib functions to export +# Some part of it already exported by kernel/exports.txt +strcmp +strncmp diff --git a/examples/dreamcast/library/library-test.c b/examples/dreamcast/library/library-test.c new file mode 100644 index 00000000..680db5c1 --- /dev/null +++ b/examples/dreamcast/library/library-test.c @@ -0,0 +1,137 @@ +/* KallistiOS ##version## + + library-test.c + Copyright (C) 2024 Ruslan Rostovtsev + + This example program simply show how library works. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> + +#include <dc/maple.h> +#include <dc/maple/controller.h> + +#include <arch/arch.h> + +#include <kos/init.h> +#include <kos/dbgio.h> +#include <kos/dbglog.h> +#include <kos/library.h> +#include <kos/exports.h> + +#include "library-dependence.h" + +KOS_INIT_FLAGS(INIT_DEFAULT | INIT_EXPORT); + +extern export_sym_t libtest_symtab[]; +static symtab_handler_t st_libtest = { + { + "sym/library/test", + 0, + 0x00010000, + 0, + NMMGR_TYPE_SYMTAB, + NMMGR_LIST_INIT + }, + libtest_symtab +}; + +static void __attribute__((__noreturn__)) wait_exit(void) { + maple_device_t *dev; + cont_state_t *state; + + dbglog(DBG_DEBUG, "Press any button to exit.\n"); + + for(;;) { + dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(dev) { + state = (cont_state_t *)maple_dev_status(dev); + if(state) { + if(state->buttons) { + arch_exit(); + } + } + } + } +} + +int main(int argc, char *argv[]) { + + klibrary_t *lib_dependence; + klibrary_t *lib_dependent; + export_sym_t *sym; + uint32_t ver; + library_test_func_t library_test_func; + library_test_func2_t library_test_func2; + + // dbgio_dev_select("fb"); + dbglog(DBG_DEBUG, "Initializing exports.\n"); + + if(nmmgr_handler_add(&st_libtest.nmmgr) < 0) { + dbglog(DBG_ERROR, "Failed."); + wait_exit(); + return -1; + } + + dbglog(DBG_DEBUG, "Loading /rd/library-dependence.klf\n"); + lib_dependence = library_open("dependence", "/rd/library-dependence.klf"); + + if (lib_dependence == NULL) { + dbglog(DBG_ERROR, "Loading failed.\n"); + wait_exit(); + return -1; + } + + ver = library_get_version(lib_dependence); + + dbglog(DBG_DEBUG, "Successfully loaded: %s v%ld.%ld.%ld\n", + library_get_name(lib_dependence), + (ver >> 16) & 0xff, (ver >> 8) & 0xff, ver & 0xff); + + dbglog(DBG_DEBUG, "Loading /rd/library-dependence.klf\n"); + lib_dependent = library_open("dependent", "/rd/library-dependent.klf"); + + if (lib_dependence == NULL) { + dbglog(DBG_ERROR, "Loading failed.\n"); + wait_exit(); + return -1; + } + + ver = library_get_version(lib_dependent); + + dbglog(DBG_DEBUG, "Successfully loaded: %s v%ld.%ld.%ld\n", + library_get_name(lib_dependent), + (ver >> 16) & 0xff, (ver >> 8) & 0xff, ver & 0xff); + + dbglog(DBG_DEBUG, "Testing exports runtime on host\n"); + + sym = export_lookup("library_test_func"); + + if (sym && sym->ptr != (uint32_t)-1) { + library_test_func = (library_test_func_t)sym->ptr; + library_test_func(444); + } + else { + dbglog(DBG_ERROR, "Lookup symbol failed: library_test_func"); + } + + sym = export_lookup("library_test_func2"); + + if (sym && sym->ptr != (uint32_t)-1) { + library_test_func2 = (library_test_func2_t)sym->ptr; + library_test_func2("Hello from library test"); + } + else { + dbglog(DBG_ERROR, "Lookup symbol failed: library_test_func"); + } + + library_close(lib_dependent); + library_close(lib_dependence); + nmmgr_handler_remove(&st_libtest.nmmgr); + + wait_exit(); + return 0; +} diff --git a/examples/dreamcast/library/loadable-dependence/Makefile b/examples/dreamcast/library/loadable-dependence/Makefile new file mode 100644 index 00000000..4037085e --- /dev/null +++ b/examples/dreamcast/library/loadable-dependence/Makefile @@ -0,0 +1,24 @@ +# KallistiOS ##version## +# +# examples/dreamcast/library/loadable-dependence/Makefile +# Copyright (C) 2024 Ruslan Rostovtsev +# + +TARGET_NAME = library-dependence +TARGET = $(TARGET_NAME).klf +TARGET_LIB = lib$(TARGET_NAME).a +OBJS = $(TARGET_NAME).o + +# For exporting kos_md5 +LIBS = -lkosutils + +# library-test exported stub for link test +DBG_LIBS = -llibrary-test + +EXPORTS_SYMBOL = library_symtab +EXPORTS_FILE = exports.txt + +KOS_CFLAGS += -I./ +KOS_LIB_PATHS += -L../ + +include $(KOS_BASE)/loadable/Makefile.prefab diff --git a/examples/dreamcast/library/loadable-dependence/exports.txt b/examples/dreamcast/library/loadable-dependence/exports.txt new file mode 100644 index 00000000..8577494f --- /dev/null +++ b/examples/dreamcast/library/loadable-dependence/exports.txt @@ -0,0 +1,10 @@ +include kos/exports.h +include kos/md5.h +include library-dependence.h + +# Loadable library exported functions +library_test_func +library_test_func2 + +# Linked library exported functions +kos_md5 diff --git a/examples/dreamcast/library/loadable-dependence/library-dependence.c b/examples/dreamcast/library/loadable-dependence/library-dependence.c new file mode 100644 index 00000000..28dd0b76 --- /dev/null +++ b/examples/dreamcast/library/loadable-dependence/library-dependence.c @@ -0,0 +1,55 @@ +/* KallistiOS ##version## + + library-dependence.c + Copyright (C) 2024 Ruslan Rostovtsev + + This example program simply show how library works. +*/ + +#include <stdint.h> +#include <kos/dbglog.h> +#include <kos/library.h> +#include <kos/exports.h> +#include <kos/version.h> + +extern export_sym_t library_symtab[]; +static symtab_handler_t library_hnd = { + { + "sym/library/dependence", + 0, + 0x00010000, + 0, + NMMGR_TYPE_SYMTAB, + NMMGR_LIST_INIT + }, + library_symtab +}; + +/* Library functions */ +const char *lib_get_name() { + return library_hnd.nmmgr.pathname + 12; +} + +uint32_t lib_get_version() { + return KOS_VERSION_MAKE(1, 0, 0); +} + +int lib_open(klibrary_t *lib) { + dbglog(DBG_DEBUG, "Library \"%s\" opened.\n", lib_get_name()); + return nmmgr_handler_add(&library_hnd.nmmgr); +} + +int lib_close(klibrary_t *lib) { + dbglog(DBG_DEBUG, "Library \"%s\" closed.\n", lib_get_name()); + return nmmgr_handler_remove(&library_hnd.nmmgr); +} + +/* Exported functions */ +int library_test_func(int arg) { + dbglog(DBG_DEBUG, "Library \"%s\" test int: %d\n", lib_get_name(), arg); + return 0; +} + +void library_test_func2(const char *arg) { + dbglog(DBG_DEBUG, "Library \"%s\" test char: %s\n", lib_get_name(), arg); +} diff --git a/examples/dreamcast/library/loadable-dependence/library-dependence.h b/examples/dreamcast/library/loadable-dependence/library-dependence.h new file mode 100644 index 00000000..241b7ac7 --- /dev/null +++ b/examples/dreamcast/library/loadable-dependence/library-dependence.h @@ -0,0 +1,18 @@ +/* KallistiOS ##version## + + library-dependence.h + Copyright (C) 2024 Ruslan Rostovtsev + + This example program simply show how library works. +*/ + +#include <stdint.h> + +/** + * @brief Exported test functions + */ +int library_test_func(int arg); +void library_test_func2(const char *arg); + +typedef int (*library_test_func_t)(int arg); +typedef void (*library_test_func2_t)(const char *arg); diff --git a/examples/dreamcast/library/loadable-dependent/Makefile b/examples/dreamcast/library/loadable-dependent/Makefile new file mode 100644 index 00000000..772a00a4 --- /dev/null +++ b/examples/dreamcast/library/loadable-dependent/Makefile @@ -0,0 +1,18 @@ +# KallistiOS ##version## +# +# examples/dreamcast/library/loadable-dependent/Makefile +# Copyright (C) 2024 Ruslan Rostovtsev +# + +TARGET_NAME = library-dependent +TARGET = $(TARGET_NAME).klf +OBJS = $(TARGET_NAME).o + +# Dependence library and host stubs for link test +DBG_LIBS = -llibrary-dependence -llibrary-test +KOS_LIB_PATHS += -L../loadable-dependence -L../ + +# Dependence include +KOS_CFLAGS += -I../loadable-dependence + +include $(KOS_BASE)/loadable/Makefile.prefab diff --git a/examples/dreamcast/library/loadable-dependent/library-dependent.c b/examples/dreamcast/library/loadable-dependent/library-dependent.c new file mode 100644 index 00000000..e2fad53a --- /dev/null +++ b/examples/dreamcast/library/loadable-dependent/library-dependent.c @@ -0,0 +1,52 @@ +/* KallistiOS ##version## + + library-dependent.c + Copyright (C) 2024 Ruslan Rostovtsev + + This example program simply show how library works. +*/ + +#include <stdint.h> +#include <string.h> +#include <kos/dbglog.h> +#include <kos/library.h> +#include <kos/exports.h> +#include <kos/version.h> +#include <kos/md5.h> + +#include "library-dependence.h" + +const char *lib_get_name() { + return "dependent"; +} + +uint32_t lib_get_version() { + return KOS_VERSION_MAKE(1, 0, 0); +} + +int lib_open(klibrary_t *lib) { + uint8_t output[16]; + + dbglog(DBG_DEBUG, "Library \"%s\" opened.\n", lib_get_name()); + + // Test exports from dependence library + library_test_func(333); + library_test_func2("Hello from library dependent"); ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-11-17 20:13:59
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 99308c534d03c585d4b4aa14ad278e072081300b (commit) via a60375e8ff1fdd99431cfbae34f54a3429d1bd94 (commit) via 43ba9b2e4b1a50b6e7a12bbc58685e5601963260 (commit) via 829d092102cd832b7b5d43ad114d5edff50e7ffc (commit) via 84a66f8d4a06b071365c637a10efd3ac41e90c9f (commit) from 33958108179edd3a73e21ef7437ed9a49b996fd9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 99308c534d03c585d4b4aa14ad278e072081300b Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 17 02:17:24 2024 +0100 Make: Avoid complaints from Make about redefined clean rules (#852) Fixes #822. Signed-off-by: Paul Cercueil <pa...@cr...> commit a60375e8ff1fdd99431cfbae34f54a3429d1bd94 Author: Falco Girgis <gyr...@gm...> Date: Fri Nov 15 22:18:48 2024 -0600 Gracefully return 0 for ARM/PVR pre-initted stats. (#830) - Rather than asserting and crashing, which isn't really warranted, modified pvr_mem_available() and snd_mem_available() to gracefully return 0 when called before PVR/Sound RAM has been initialized. - This way profilers and monitors in other threads can still boot up and show proper stats while things are being initialized, rather than simply crashing in debug builds and returning garbage in release builds. commit 43ba9b2e4b1a50b6e7a12bbc58685e5601963260 Author: Paul Cercueil <pa...@cr...> Date: Sat Nov 16 04:49:09 2024 +0100 Add support for Store Queues with MMU (#779) * mmu: Add function mmu_enabled() This function can be used to know whether or not the MMU is in use. * mmu: Support address translation of store queues Reserve the last two TLB entries and map a 1 MiB page each for use with the SQ area. Add the function mmu_set_sq_addr(), which will overwrite the physical address that the SQ area points to in the TLB. * sq: Update sq_lock() prototype to work with MMU Change its prototype: it now returns a pointer, which is the translated address of the source pointer. In non-MMU use, it's returns the same value as SQ_MASK_DEST(src). When MMU is enabled, sq_lock() will reset the address translation for the SQ memory area, and convert the source address as an offset to that memory area, making it possible to use SQs when MMU is enabled. The caveat is that we only map one megabyte of SQ memory area for simplicity, and therefore the SQ memory window is reduced. This should be fine though, as apart from e.g. a whole-VRAM clear, nobody will ever need such a big window. * sq: Update sq_cpy() to work with MMU When using the MMU the SQ area is a 1 MiB page, so we must not copy data outside this area. * sq: Update sq_set32() to work with MMU When using the MMU the SQ area is a 1 MiB page, so we must not copy data outside this area. * mmu: Remove mmu_disable() / mmu_restore() Now that SQs work with MMU, those two functions aren't useful anymore and can be dropped. --------- Signed-off-by: Paul Cercueil <pa...@cr...> commit 829d092102cd832b7b5d43ad114d5edff50e7ffc Author: Paul Cercueil <pa...@cr...> Date: Sat Nov 9 03:16:26 2024 +0100 Add new regfield.h header, and clean up PVR code (#839) * Add new <kos/regfield.h> include This new include will provide macros that are useful when dealing with register fields. * pvr.h: Add new macros for the TA command fields These new macros will replace the old ones, which are now deprecated. * pvr: Simplify code using the new register field macros Use the new <dc/regfield.h> to clean up the context->header compilation functions in pvr_prim.c and pvr_misc.c. commit 84a66f8d4a06b071365c637a10efd3ac41e90c9f Author: Donald Haase <qu...@ya...> Date: Thu Nov 7 23:04:00 2024 -0500 Revert "Update position when playing (#764)" (#846) This reverts commit 41c37da08d71af6ee29f3b5195897971ee718485. The change had left a gap by which the position will not get updated for it's last run it will no longer be playing. ----------------------------------------------------------------------- Summary of changes: Makefile.prefab | 4 +- include/kos.h | 1 + include/kos/regfield.h | 55 ++ kernel/Makefile | 2 +- kernel/arch/dreamcast/hardware/pvr/pvr_mem.c | 3 +- kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 2 +- kernel/arch/dreamcast/hardware/pvr/pvr_prim.c | 591 ++++++--------------- kernel/arch/dreamcast/hardware/sq.c | 122 +++-- kernel/arch/dreamcast/include/arch/mmu.h | 22 +- kernel/arch/dreamcast/include/dc/pvr.h | 55 +- kernel/arch/dreamcast/include/dc/sq.h | 5 +- kernel/arch/dreamcast/kernel/mmu.c | 29 +- kernel/arch/dreamcast/sound/arm/main.c | 7 +- .../arch/dreamcast/sound/arm/stream.drv.prebuilt | Bin 3312 -> 3272 bytes kernel/arch/dreamcast/sound/snd_mem.c | 3 +- kernel/exports/Makefile | 4 +- 16 files changed, 382 insertions(+), 523 deletions(-) create mode 100644 include/kos/regfield.h diff --git a/Makefile.prefab b/Makefile.prefab index adcba60e..dc9a3e86 100644 --- a/Makefile.prefab +++ b/Makefile.prefab @@ -15,9 +15,11 @@ endif defaultall: $(OBJS) subdirs -cp $(OBJS) $(KOS_BASE)/$(BUILD_TARGET)/build/ -clean: clean_subdirs +defaultclean: clean_subdirs -rm -f $(OBJS) *.bck +clean: defaultclean + include $(KOS_BASE)/Makefile.rules diff --git a/include/kos.h b/include/kos.h index 4731e25f..f2d48638 100644 --- a/include/kos.h +++ b/include/kos.h @@ -59,6 +59,7 @@ __BEGIN_DECLS #include <kos/string.h> #include <kos/init.h> #include <kos/oneshot_timer.h> +#include <kos/regfield.h> #include <arch/arch.h> #include <arch/cache.h> diff --git a/include/kos/regfield.h b/include/kos/regfield.h new file mode 100644 index 00000000..f3e66ed3 --- /dev/null +++ b/include/kos/regfield.h @@ -0,0 +1,55 @@ +/* KallistiOS ##version## + + kos/compiler.h + Copyright (C) 2024 Paul Cercueil + + Macros to extract / insert bit fields +*/ + +/** \file kos/regfield.h + \brief Macros to help dealing with register fields. + \ingroup kernel + + \author Paul Cercueil +*/ + +#ifndef __KOS_REGFIELD_H +#define __KOS_REGFIELD_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +/** \brief Create a mask with a bit set + + \param bit The bit to set (from 0 to 31) + \return A 32-bit mask with the corresponding bit set + */ +#define BIT(bit) (1u << (bit)) + +/** \brief Create a mask with a range of bits set + + \param h The high bit of the range to set, included + \param l The low bit of the range to set, included + \return A 32-bit mask with the corresponding bits set + */ +#define GENMASK(h, l) ((0xffffffff << (l)) & (0xffffffff >> (31 - (h)))) + +/** \brief Extract a field value from a variable + + \param var The 32-bit variable containing the field + \param field A 32-bit mask that corresponds to the field + \return The value of the field (shifted) + */ +#define FIELD_GET(var, field) \ + (((var) & (field)) >> __builtin_ctz(field)) + +/** \brief Prepare a field with a given value + + \param field A 32-bit mask that corresponds to the field + \param value The value to be put in the field + */ +#define FIELD_PREP(field, value) \ + (((value) << __builtin_ctz(field)) & (field)) + +__END_DECLS +#endif /* __KOS_REGFIELD_H */ diff --git a/kernel/Makefile b/kernel/Makefile index 5a438c65..62dfa91c 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -26,7 +26,7 @@ stubs/arch_export_stubs.c: arch/$(KOS_ARCH)/exports-$(KOS_SUBARCH).txt include $(KOS_BASE)/Makefile.prefab -clean: clean_subdirs +clean: defaultclean rm -f build/*.o rm -f build/libc/*.o rm -f romdisk/*.o diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c b/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c index 19fdf92c..eeddf80c 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c @@ -179,7 +179,8 @@ static uint32 pvr_mem_available_int(void) { } uint32 pvr_mem_available(void) { - CHECK_MEM_BASE; + if(!pvr_mem_base) + return 0; return pvr_mem_available_int() + (PVR_RAM_INT_TOP - (uint32)pvr_mem_base); diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c index b484dc99..e2efa10a 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c @@ -263,7 +263,7 @@ void pvr_blank_polyhdr_buf(int type, pvr_poly_hdr_t * poly) { memset(poly, 0, sizeof(pvr_poly_hdr_t)); /* Put in the list type */ - poly->cmd = (type << PVR_TA_CMD_TYPE_SHIFT) | 0x80840012; + poly->cmd = FIELD_PREP(PVR_TA_CMD_TYPE, type) | 0x80840012; /* Fill in dummy values */ poly->d1 = poly->d2 = poly->d3 = poly->d4 = 0xffffffff; diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c index 55952e5e..2558b1e8 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c @@ -21,148 +21,78 @@ /* Compile a polygon context into a polygon header */ void pvr_poly_compile(pvr_poly_hdr_t *dst, const pvr_poly_cxt_t *src) { - int u, v; uint32_t txr_base; /* Temporary variables we can read-write-modify, since we cannot do so from within the SQs, and we want to be able to compile this header from a PVR DR API submission target. */ - uint32_t cmd, mode[3]; + uint32_t mode2, mode3; /* Basically we just take each parameter, clip it, shift it into place, and OR it into the final result. */ /* The base values for CMD */ - cmd = PVR_CMD_POLYHDR; - - if(src->txr.enable == PVR_TEXTURE_ENABLE) - cmd |= 8; - - /* Or in the list type, shading type, color and UV formats */ - cmd |= (src->list_type << PVR_TA_CMD_TYPE_SHIFT) & PVR_TA_CMD_TYPE_MASK; - cmd |= (src->fmt.color << PVR_TA_CMD_CLRFMT_SHIFT) & PVR_TA_CMD_CLRFMT_MASK; - cmd |= (src->gen.shading << PVR_TA_CMD_SHADE_SHIFT) & PVR_TA_CMD_SHADE_MASK; - cmd |= (src->fmt.uv << PVR_TA_CMD_UVFMT_SHIFT) & PVR_TA_CMD_UVFMT_MASK; - cmd |= (src->gen.clip_mode << PVR_TA_CMD_USERCLIP_SHIFT) & PVR_TA_CMD_USERCLIP_MASK; - cmd |= (src->fmt.modifier << PVR_TA_CMD_MODIFIER_SHIFT) & PVR_TA_CMD_MODIFIER_MASK; - cmd |= (src->gen.modifier_mode << PVR_TA_CMD_MODIFIERMODE_SHIFT) & PVR_TA_CMD_MODIFIERMODE_MASK; - cmd |= (src->gen.specular << PVR_TA_CMD_SPECULAR_SHIFT) & PVR_TA_CMD_SPECULAR_MASK; - - dst->cmd = cmd; + dst->cmd = PVR_CMD_POLYHDR + | FIELD_PREP(PVR_TA_CMD_TXRENABLE, src->txr.enable) + | FIELD_PREP(PVR_TA_CMD_TYPE, src->list_type) + | FIELD_PREP(PVR_TA_CMD_CLRFMT, src->fmt.color) + | FIELD_PREP(PVR_TA_CMD_SHADE, src->gen.shading) + | FIELD_PREP(PVR_TA_CMD_UVFMT, src->fmt.uv) + | FIELD_PREP(PVR_TA_CMD_USERCLIP, src->gen.clip_mode) + | FIELD_PREP(PVR_TA_CMD_MODIFIER, src->fmt.modifier) + | FIELD_PREP(PVR_TA_CMD_MODIFIERMODE, src->gen.modifier_mode) + | FIELD_PREP(PVR_TA_CMD_SPECULAR, src->gen.specular); /* Polygon mode 1 */ - mode[0] = (src->depth.comparison << PVR_TA_PM1_DEPTHCMP_SHIFT) & PVR_TA_PM1_DEPTHCMP_MASK; - mode[0] |= (src->gen.culling << PVR_TA_PM1_CULLING_SHIFT) & PVR_TA_PM1_CULLING_MASK; - mode[0] |= (src->depth.write << PVR_TA_PM1_DEPTHWRITE_SHIFT) & PVR_TA_PM1_DEPTHWRITE_MASK; - mode[0] |= (src->txr.enable << PVR_TA_PM1_TXRENABLE_SHIFT) & PVR_TA_PM1_TXRENABLE_MASK; - - dst->mode1 = mode[0]; + dst->mode1 = FIELD_PREP(PVR_TA_PM1_DEPTHCMP, src->depth.comparison) + | FIELD_PREP(PVR_TA_PM1_CULLING, src->gen.culling) + | FIELD_PREP(PVR_TA_PM1_DEPTHWRITE, src->depth.write) + | FIELD_PREP(PVR_TA_PM1_TXRENABLE, src->txr.enable); /* Polygon mode 2 */ - mode[1] = (src->blend.src << PVR_TA_PM2_SRCBLEND_SHIFT) & PVR_TA_PM2_SRCBLEND_MASK; - mode[1] |= (src->blend.dst << PVR_TA_PM2_DSTBLEND_SHIFT) & PVR_TA_PM2_DSTBLEND_MASK; - mode[1] |= (src->blend.src_enable << PVR_TA_PM2_SRCENABLE_SHIFT) & PVR_TA_PM2_SRCENABLE_MASK; - mode[1] |= (src->blend.dst_enable << PVR_TA_PM2_DSTENABLE_SHIFT) & PVR_TA_PM2_DSTENABLE_MASK; - mode[1] |= (src->gen.fog_type << PVR_TA_PM2_FOG_SHIFT) & PVR_TA_PM2_FOG_MASK; - mode[1] |= (src->gen.color_clamp << PVR_TA_PM2_CLAMP_SHIFT) & PVR_TA_PM2_CLAMP_MASK; - mode[1] |= (src->gen.alpha << PVR_TA_PM2_ALPHA_SHIFT) & PVR_TA_PM2_ALPHA_MASK; + mode2 = FIELD_PREP(PVR_TA_PM2_SRCBLEND, src->blend.src) + | FIELD_PREP(PVR_TA_PM2_DSTBLEND, src->blend.dst) + | FIELD_PREP(PVR_TA_PM2_SRCENABLE, src->blend.src_enable) + | FIELD_PREP(PVR_TA_PM2_DSTENABLE, src->blend.dst_enable) + | FIELD_PREP(PVR_TA_PM2_FOG, src->gen.fog_type) + | FIELD_PREP(PVR_TA_PM2_CLAMP, src->gen.color_clamp) + | FIELD_PREP(PVR_TA_PM2_ALPHA, src->gen.alpha); if(src->txr.enable == PVR_TEXTURE_DISABLE) { - dst->mode2 = mode[1]; - mode[2] = 0; - dst->mode3 = mode[2]; + mode3 = 0; } else { - mode[1] |= (src->txr.alpha << PVR_TA_PM2_TXRALPHA_SHIFT) & PVR_TA_PM2_TXRALPHA_MASK; - mode[1] |= (src->txr.uv_flip << PVR_TA_PM2_UVFLIP_SHIFT) & PVR_TA_PM2_UVFLIP_MASK; - mode[1] |= (src->txr.uv_clamp << PVR_TA_PM2_UVCLAMP_SHIFT) & PVR_TA_PM2_UVCLAMP_MASK; - mode[1] |= (src->txr.filter << PVR_TA_PM2_FILTER_SHIFT) & PVR_TA_PM2_FILTER_MASK; - mode[1] |= (src->txr.mipmap_bias << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; - mode[1] |= (src->txr.env << PVR_TA_PM2_TXRENV_SHIFT) & PVR_TA_PM2_TXRENV_MASK; - - switch(src->txr.width) { - case 8: - u = 0; - break; - case 16: - u = 1; - break; - case 32: - u = 2; - break; - case 64: - u = 3; - break; - case 128: - u = 4; - break; - case 256: - u = 5; - break; - case 512: - u = 6; - break; - case 1024: - u = 7; - break; - default: - assert_msg(0, "Invalid texture U size"); - u = 0; - break; - } - - switch(src->txr.height) { - case 8: - v = 0; - break; - case 16: - v = 1; - break; - case 32: - v = 2; - break; - case 64: - v = 3; - break; - case 128: - v = 4; - break; - case 256: - v = 5; - break; - case 512: - v = 6; - break; - case 1024: - v = 7; - break; - default: - assert_msg(0, "Invalid texture V size"); - v = 0; - break; - } - - mode[1] |= (u << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; - mode[1] |= (v << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; - - dst->mode2 = mode[1]; - - /* Polygon mode 3 */ - mode[2] = (src->txr.mipmap << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK; - mode[2] |= (src->txr.format << PVR_TA_PM3_TXRFMT_SHIFT) & PVR_TA_PM3_TXRFMT_MASK; + assert_msg(__builtin_popcount(src->txr.width) == 1 + && src->txr.width <= 1024, "Invalid texture U size"); + assert_msg(__builtin_popcount(src->txr.height) == 1 + && src->txr.height <= 1024, "Invalid texture V size"); + + mode2 |= FIELD_PREP(PVR_TA_PM2_TXRALPHA, src->txr.alpha) + | FIELD_PREP(PVR_TA_PM2_UVFLIP, src->txr.uv_flip) + | FIELD_PREP(PVR_TA_PM2_UVCLAMP, src->txr.uv_clamp) + | FIELD_PREP(PVR_TA_PM2_FILTER, src->txr.filter) + | FIELD_PREP(PVR_TA_PM2_MIPBIAS, src->txr.mipmap_bias) + | FIELD_PREP(PVR_TA_PM2_TXRENV, src->txr.env) + | FIELD_PREP(PVR_TA_PM2_USIZE, __builtin_ctz(src->txr.width) - 3) + | FIELD_PREP(PVR_TA_PM2_VSIZE, __builtin_ctz(src->txr.height) - 3); /* Convert the texture address */ txr_base = (uint32_t)src->txr.base; txr_base = (txr_base & 0x00fffff8) >> 3; - mode[2] |= txr_base; - dst->mode3 = mode[2]; + /* Polygon mode 3 */ + mode3 = FIELD_PREP(PVR_TA_PM3_MIPMAP, src->txr.mipmap) + | src->txr.format + | txr_base; } + dst->mode2 = mode2; + dst->mode3 = mode3; + if(src->fmt.modifier && src->gen.modifier_mode) { /* If we're affected by a modifier volume, silently promote the header to the one that is affected by a modifier volume. */ - dst->d1 = mode[1]; - dst->d2 = mode[2]; + dst->d1 = mode2; + dst->d2 = mode3; } else { dst->d1 = 0xffffffff; @@ -338,145 +268,75 @@ void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, } void pvr_sprite_compile(pvr_sprite_hdr_t *dst, const pvr_sprite_cxt_t *src) { - int u, v; - uint32_t txr_base; - uint32_t cmd, mode[3]; + uint32_t txr_base, mode2, mode3; /* Basically we just take each parameter, clip it, shift it into place, and OR it into the final result. */ /* The base values for CMD */ - cmd = PVR_CMD_SPRITE; - - if(src->txr.enable == PVR_TEXTURE_ENABLE) - cmd |= 8; - - /* Or in the list type, clipping mode, and UV formats */ - cmd |= (src->list_type << PVR_TA_CMD_TYPE_SHIFT) & PVR_TA_CMD_TYPE_MASK; - cmd |= (PVR_UVFMT_16BIT << PVR_TA_CMD_UVFMT_SHIFT) & PVR_TA_CMD_UVFMT_MASK; - cmd |= (src->gen.clip_mode << PVR_TA_CMD_USERCLIP_SHIFT) & PVR_TA_CMD_USERCLIP_MASK; - cmd |= (src->gen.specular << PVR_TA_CMD_SPECULAR_SHIFT) & PVR_TA_CMD_SPECULAR_MASK; - - dst->cmd = cmd; + dst->cmd = PVR_CMD_SPRITE + | FIELD_PREP(PVR_TA_CMD_TXRENABLE, src->txr.enable) + | FIELD_PREP(PVR_TA_CMD_TYPE, src->list_type) + | FIELD_PREP(PVR_TA_CMD_UVFMT, PVR_UVFMT_16BIT) + | FIELD_PREP(PVR_TA_CMD_USERCLIP, src->gen.clip_mode) + | FIELD_PREP(PVR_TA_CMD_SPECULAR, src->gen.specular); /* Polygon mode 1 */ - mode[0] = (src->depth.comparison << PVR_TA_PM1_DEPTHCMP_SHIFT) & PVR_TA_PM1_DEPTHCMP_MASK; - mode[0] |= (src->gen.culling << PVR_TA_PM1_CULLING_SHIFT) & PVR_TA_PM1_CULLING_MASK; - mode[0] |= (src->depth.write << PVR_TA_PM1_DEPTHWRITE_SHIFT) & PVR_TA_PM1_DEPTHWRITE_MASK; - mode[0] |= (src->txr.enable << PVR_TA_PM1_TXRENABLE_SHIFT) & PVR_TA_PM1_TXRENABLE_MASK; - - dst->mode1 = mode[0]; + dst->mode1 = FIELD_PREP(PVR_TA_PM1_DEPTHCMP, src->depth.comparison) + | FIELD_PREP(PVR_TA_PM1_CULLING, src->gen.culling) + | FIELD_PREP(PVR_TA_PM1_DEPTHWRITE, src->depth.write) + | FIELD_PREP(PVR_TA_PM1_TXRENABLE, src->txr.enable); /* Polygon mode 2 */ - mode[1] = (src->blend.src << PVR_TA_PM2_SRCBLEND_SHIFT) & PVR_TA_PM2_SRCBLEND_MASK; - mode[1] |= (src->blend.dst << PVR_TA_PM2_DSTBLEND_SHIFT) & PVR_TA_PM2_DSTBLEND_MASK; - mode[1] |= (src->blend.src_enable << PVR_TA_PM2_SRCENABLE_SHIFT) & PVR_TA_PM2_SRCENABLE_MASK; - mode[1] |= (src->blend.dst_enable << PVR_TA_PM2_DSTENABLE_SHIFT) & PVR_TA_PM2_DSTENABLE_MASK; - mode[1] |= (src->gen.fog_type << PVR_TA_PM2_FOG_SHIFT) & PVR_TA_PM2_FOG_MASK; - mode[1] |= (src->gen.color_clamp << PVR_TA_PM2_CLAMP_SHIFT) & PVR_TA_PM2_CLAMP_MASK; - mode[1] |= (src->gen.alpha << PVR_TA_PM2_ALPHA_SHIFT) & PVR_TA_PM2_ALPHA_MASK; + mode2 = FIELD_PREP(PVR_TA_PM2_SRCBLEND, src->blend.src) + | FIELD_PREP(PVR_TA_PM2_DSTBLEND, src->blend.dst) + | FIELD_PREP(PVR_TA_PM2_SRCENABLE, src->blend.src_enable) + | FIELD_PREP(PVR_TA_PM2_DSTENABLE, src->blend.dst_enable) + | FIELD_PREP(PVR_TA_PM2_FOG, src->gen.fog_type) + | FIELD_PREP(PVR_TA_PM2_CLAMP, src->gen.color_clamp) + | FIELD_PREP(PVR_TA_PM2_ALPHA, src->gen.alpha); if(src->txr.enable == PVR_TEXTURE_DISABLE) { - dst->mode2 = mode[1]; - dst->mode3 = 0; + mode3 = 0; } else { - mode[1] |= (src->txr.alpha << PVR_TA_PM2_TXRALPHA_SHIFT) & PVR_TA_PM2_TXRALPHA_MASK; - mode[1] |= (src->txr.uv_flip << PVR_TA_PM2_UVFLIP_SHIFT) & PVR_TA_PM2_UVFLIP_MASK; - mode[1] |= (src->txr.uv_clamp << PVR_TA_PM2_UVCLAMP_SHIFT) & PVR_TA_PM2_UVCLAMP_MASK; - mode[1] |= (src->txr.filter << PVR_TA_PM2_FILTER_SHIFT) & PVR_TA_PM2_FILTER_MASK; - mode[1] |= (src->txr.mipmap_bias << PVR_TA_PM2_MIPBIAS_SHIFT) & PVR_TA_PM2_MIPBIAS_MASK; - mode[1] |= (src->txr.env << PVR_TA_PM2_TXRENV_SHIFT) & PVR_TA_PM2_TXRENV_MASK; - - switch(src->txr.width) { - case 8: - u = 0; - break; - case 16: - u = 1; - break; - case 32: - u = 2; - break; - case 64: - u = 3; - break; - case 128: - u = 4; - break; - case 256: - u = 5; - break; - case 512: - u = 6; - break; - case 1024: - u = 7; - break; - default: - assert_msg(0, "Invalid texture U size"); - u = 0; - break; - } - - switch(src->txr.height) { - case 8: - v = 0; - break; - case 16: - v = 1; - break; - case 32: - v = 2; - break; - case 64: - v = 3; - break; - case 128: - v = 4; - break; - case 256: - v = 5; - break; - case 512: - v = 6; - break; - case 1024: - v = 7; - break; - default: - assert_msg(0, "Invalid texture V size"); - v = 0; - break; - } - - mode[1] |= (u << PVR_TA_PM2_USIZE_SHIFT) & PVR_TA_PM2_USIZE_MASK; - mode[1] |= (v << PVR_TA_PM2_VSIZE_SHIFT) & PVR_TA_PM2_VSIZE_MASK; - - dst->mode2 = mode[1]; - - /* Polygon mode 3 */ - mode[2] = (src->txr.mipmap << PVR_TA_PM3_MIPMAP_SHIFT) & PVR_TA_PM3_MIPMAP_MASK; - mode[2] |= (src->txr.format << PVR_TA_PM3_TXRFMT_SHIFT) & PVR_TA_PM3_TXRFMT_MASK; + assert_msg(__builtin_popcount(src->txr.width) == 1 + && src->txr.width <= 1024, "Invalid texture U size"); + assert_msg(__builtin_popcount(src->txr.height) == 1 + && src->txr.height <= 1024, "Invalid texture V size"); + + mode2 |= FIELD_PREP(PVR_TA_PM2_TXRALPHA, src->txr.alpha) + | FIELD_PREP(PVR_TA_PM2_UVFLIP, src->txr.uv_flip) + | FIELD_PREP(PVR_TA_PM2_UVCLAMP, src->txr.uv_clamp) + | FIELD_PREP(PVR_TA_PM2_FILTER, src->txr.filter) + | FIELD_PREP(PVR_TA_PM2_MIPBIAS, src->txr.mipmap_bias) + | FIELD_PREP(PVR_TA_PM2_TXRENV, src->txr.env) + | FIELD_PREP(PVR_TA_PM2_USIZE, __builtin_ctz(src->txr.width) - 3) + | FIELD_PREP(PVR_TA_PM2_VSIZE, __builtin_ctz(src->txr.height) - 3); + /* Convert the texture address */ txr_base = (uint32_t)src->txr.base; txr_base = (txr_base & 0x00fffff8) >> 3; - mode[2] |= txr_base; - dst->mode3 = mode[2]; + /* Polygon mode 3 */ + mode3 = FIELD_PREP(PVR_TA_PM3_MIPMAP, src->txr.mipmap) ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-11-06 13:30:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 33958108179edd3a73e21ef7437ed9a49b996fd9 (commit) via e7ebae1f6ac3c91fef4174d09dfda03733cc0862 (commit) via c520b0b815c0e11006a4e95f207b146351b0358f (commit) via d6c26d169d8db24cadcc6979ae93c2b806eee5ae (commit) via df95ad288ae8bc5963158da63fe33af9037c12f9 (commit) via 12824439b7eddb9439cff8970a9e9a9f660570a2 (commit) via a01d0e2cf7ee6b76cd995f668c86d460533979c6 (commit) from 65cc060af59a607a2a05c742089d08f8271b0eb9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 33958108179edd3a73e21ef7437ed9a49b996fd9 Author: Paul Cercueil <pa...@cr...> Date: Wed Nov 6 14:01:42 2024 +0100 pvr: Fix hang when enabled lists aren't submitted When two lists were enabled, one for direct-rendering and one for deferred (DMA) rendering, but the first one was not used, only the IRQ corresponding to the second list fired, causing the IRQ handler to not start the PVR CORE rendering step, as it waited for all enabled lists to be transferred. Address this issue by adding dummy vertices to enabled lists that were not used in the current scene. Signed-off-by: Paul Cercueil <pa...@cr...> commit e7ebae1f6ac3c91fef4174d09dfda03733cc0862 Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 3 22:17:07 2024 +0100 pvr: Rework and improve IRQ handling The previous way of handling IRQs was weird at best. The PVR rendering was not started directly after all lists were transferred by the Tile Accelerator, but following the next VBLANK event. This caused some games to be throttled down, as they had to wait for the PVR rendering to be completed before starting a new scene, and the PVR rendering was not started as soon as possible. Address that by starting the PVR rendering as soon as all lists have been transferred. In the case where the previous rendered scene hasn't been flipped yet (which happens when the game tries to render faster than the refresh rate), the PVR rendering is instead started from the VBLANK interrupt handler. Note that for simplicity the VBLANK handling code has been separated from the main PVR IRQ handler. Signed-off-by: Paul Cercueil <pa...@cr...> commit c520b0b815c0e11006a4e95f207b146351b0358f Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 3 22:03:14 2024 +0100 pvr: Move PVR render code into its own pvr_render_lists() function No functional change (intended). This new function will be called at two different spots in the future. Signed-off-by: Paul Cercueil <pa...@cr...> commit d6c26d169d8db24cadcc6979ae93c2b806eee5ae Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 3 21:57:54 2024 +0100 pvr: Always wait for TA ready before trying to use it again Attempting to use the Tile Accelerator for a new scene while it is busy processing the previous scene will almost always result in a crash. Call pvr_wait_ready() when starting a new scene to make sure that the TA is idle. Instead of calling it in pvr_scene_begin(), delay the call as much as possible, to leave time for the TA to complete its task. This means calling it in pvr_list_begin() for lists that use direct rendering, and right before uploading the DMA data for lists that use DMA. Signed-off-by: Paul Cercueil <pa...@cr...> commit df95ad288ae8bc5963158da63fe33af9037c12f9 Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 3 21:48:12 2024 +0100 pvr: Rework pvr_wait_ready() The previous implementation used a semaphore, which was somewhat problematic; it meant that there had to be a 1:1 ratio between the number of calls to pvr_wait_ready(), and the number of renders by the PVR. Having two successive calls, for instance, would cause the second one to time out. Rework the implementation so that pvr_wait_ready() will wait until the PVR is ready if needed, but will always return straight away if the PVR is free. Instead of a semaphore, this new implementation uses the genwait mechanism on the pvr_state.ta_busy object. This field has also changed in its meaning, as it is now a generic "Tile Accelerator is busy" flag, independently on whether or not the hybrid mode is in use. Signed-off-by: Paul Cercueil <pa...@cr...> commit 12824439b7eddb9439cff8970a9e9a9f660570a2 Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 3 21:41:15 2024 +0100 pvr: Start DMA for hybrid mode in pvr_scene_finish() There is no point in waiting for the next VBLANK to submit the data queued; it just causes unnecesary delays. Note that at that point it is guaranteed that the Tile Accelerator is free so we can remove the redundant checks. Signed-off-by: Paul Cercueil <pa...@cr...> commit a01d0e2cf7ee6b76cd995f668c86d460533979c6 Author: Paul Cercueil <pa...@cr...> Date: Sun Nov 3 21:30:39 2024 +0100 pvr: Fix hybrid mode signaling TA completion too early The dma_next_list() function was setting the "list transferred" flag for the lists that used DMA to transfer the vertices and also for the other ones. It also signaled completion through the semaphore after the last transfer completed. The problem with that, is that there is a difference between "the vertex data has been transferred to the TA" and "the TA is done processing the lists"; and the "list transferred" flags are to be set in the second case. Address this issue by leaving it to the IRQ handler to set the "list transferred" flags and handle the completion semaphore. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG.md | 1 + .../dreamcast/hardware/pvr/pvr_init_shutdown.c | 8 +- kernel/arch/dreamcast/hardware/pvr/pvr_internal.h | 12 +- kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 175 ++++++++++----------- kernel/arch/dreamcast/hardware/pvr/pvr_scene.c | 55 +++++-- 5 files changed, 138 insertions(+), 113 deletions(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 9c764a38..bda36885 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -12,6 +12,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha - Add/Fixed stat() implementations for all filesystems [AB] - **Dreamcast**: Add network speedtest and pvr palette examples [AB] - **Dreamcast**: Cleaned up, documented, and enhanced BIOS font API [FG] +- Rework PVR hybrid mode + IRQ handling [PC] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c index 29103411..cbe77d70 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_init_shutdown.c @@ -140,7 +140,7 @@ int pvr_init(pvr_init_params_t *params) { } /* Hook the PVR interrupt events on G2 */ - pvr_state.vbl_handle = vblank_handler_add(pvr_int_handler, NULL); + pvr_state.vbl_handle = vblank_handler_add(pvr_vblank_handler, NULL); asic_evt_set_handler(ASIC_EVT_PVR_OPAQUEDONE, pvr_int_handler, NULL); asic_evt_enable(ASIC_EVT_PVR_OPAQUEDONE, ASIC_IRQ_DEFAULT); @@ -194,9 +194,6 @@ int pvr_init(pvr_init_params_t *params) { mutex_init((mutex_t *)&pvr_state.dma_lock, MUTEX_TYPE_NORMAL); pvr_dma_init(); - /* Setup our wait-ready semaphore */ - sem_init((semaphore_t *)&pvr_state.ready_sem, 0); - /* Set us as valid and return success */ pvr_state.valid = 1; @@ -245,8 +242,7 @@ int pvr_shutdown(void) { /* Invalidate our memory pool */ pvr_mem_reset(); - /* Destroy the semaphore */ - sem_destroy((semaphore_t *)&pvr_state.ready_sem); + /* Destroy the mutex */ mutex_destroy((mutex_t *)&pvr_state.dma_lock); /* Clear video memory */ diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h b/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h index 3db2278d..4c7c72da 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h @@ -16,7 +16,6 @@ code. If something is needed from this, an external interface should be added to dc/pvr.h. */ -#include <kos/sem.h> #include <kos/mutex.h> /**** State stuff ***************************************************/ @@ -169,7 +168,8 @@ typedef struct { uint32 lists_dmaed; // (1 << idx) for each list which has been DMA'd (DMA mode only) mutex_t dma_lock; // Locked if a DMA is in progress (vertex or texture) - int ta_busy; // >0 if a DMA is in progress and the TA hasn't signaled completion + int ta_ready; // >0 if the TA is ready for the new scene + int ta_busy; // >0 if a scene is ongoing and the TA hasn't signaled completion int render_busy; // >0 if a render is in progress int render_completed; // >1 if a render has recently finished @@ -204,10 +204,6 @@ typedef struct { size_t vtx_buf_used; // Vertex buffer used size for the last frame size_t vtx_buf_used_max; // Maximum used vertex buffer size - /* Wait-ready semaphore: this will be signaled whenever the pvr_wait_ready() - call should be ready to return. */ - semaphore_t ready_sem; - // Handle for the vblank interrupt int vbl_handle; @@ -292,8 +288,10 @@ void pvr_blank_polyhdr_buf(int type, pvr_poly_hdr_t * buf); /**** pvr_irq.c *******************************************************/ -/* Interrupt handler for PVR events */ +/* Interrupt handlers for PVR events */ void pvr_int_handler(uint32 code, void *data); +void pvr_vblank_handler(uint32 code, void *data); +void pvr_start_dma(void); #endif diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c index 8e72fb94..9d456c32 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c @@ -11,6 +11,8 @@ #include <arch/cache.h> #include "pvr_internal.h" +#include <kos/genwait.h> + #ifdef PVR_RENDER_DBG #include <stdio.h> #endif @@ -46,7 +48,6 @@ static void dma_next_list(void *data) { mark it as complete, so we skip trying to DMA it. */ if(!b->base[i]) { pvr_state.lists_dmaed |= 1 << i; - pvr_state.lists_transferred |= 1 << i; continue; } @@ -74,22 +75,96 @@ static void dma_next_list(void *data) { if(!did) { //DBG(("dma_complete(buf %d)\n", pvr_state.ram_target ^ 1)); + // If that was the last one, then free up the DMA channel. + pvr_state.lists_dmaed = 0; + // Unlock mutex_unlock((mutex_t *)&pvr_state.dma_lock); - pvr_state.lists_dmaed = 0; // Buffers are now empty again pvr_state.dma_buffers[pvr_state.ram_target ^ 1].ready = 0; + } +} + +void pvr_start_dma(void) { + pvr_sync_stats(PVR_SYNC_REGSTART); + + mutex_lock((mutex_t *)&pvr_state.dma_lock); + + // Begin DMAing the first list. + dma_next_list(0); +} + +static void pvr_render_lists(void) { + int bufn = pvr_state.view_target ^ 1; + + if(pvr_state.ta_busy + && !pvr_state.render_busy + && (!pvr_state.render_completed || pvr_state.to_texture[bufn]) + && pvr_state.lists_transferred == pvr_state.lists_enabled) { + + /* XXX Note: + For some reason, the render must be started _before_ we sync + to the new reg buffers. The only reasons I can think of for this + are that there may be something in the reg sync that messes up + the render in progress, or we are misusing some bits somewhere. */ + + // Begin rendering from the dirty TA buffer into the clean + // frame buffer. + //DBG(("start_render(%d -> %d)\n", pvr_state.ta_target, pvr_state.view_target ^ 1)); + pvr_state.ta_target ^= 1; + pvr_begin_queued_render(); + pvr_state.render_busy = 1; + pvr_sync_stats(PVR_SYNC_RNDSTART); + + // Clear the texture render flag if we had it set. + pvr_state.to_texture[bufn] = 0; + + // Switch to the clean TA buffer. + pvr_state.lists_transferred = 0; + pvr_sync_reg_buffer(); + + // The TA is no longer busy. + pvr_state.ta_busy = 0; // Signal the client code to continue onwards. - sem_signal((semaphore_t *)&pvr_state.ready_sem); + genwait_wake_all((void *)&pvr_state.ta_busy); thd_schedule(1, 0); } } -void pvr_int_handler(uint32 code, void *data) { - int bufn = pvr_state.view_target; +void pvr_vblank_handler(uint32 code, void *data) { + (void)code; + (void)data; + + pvr_sync_stats(PVR_SYNC_VBLANK); + + // If the render-done interrupt has fired then we are ready to flip to the + // new frame buffer. + if(pvr_state.render_completed) { + int bufn = pvr_state.view_target; + //DBG(("view(%d)\n", pvr_state.view_target ^ 1)); + + // Handle PVR stats + pvr_sync_stats(PVR_SYNC_PAGEFLIP); + + // Switch view address to the "good" buffer + pvr_state.view_target ^= 1; + + if(!pvr_state.to_texture[bufn]) + pvr_sync_view(); + + // Clear the render completed flag. + pvr_state.render_completed = 0; + } + + // We may have a pending render, that couldn't be done as the previous + // render wasn't flipped yet; do it now. + pvr_render_lists(); +} + +void pvr_int_handler(uint32 code, void *data) { (void)data; // What kind of event did we get? @@ -117,9 +192,6 @@ void pvr_int_handler(uint32 code, void *data) { pvr_state.render_completed = 1; pvr_sync_stats(PVR_SYNC_RNDDONE); break; - case ASIC_EVT_PVR_VBLANK_BEGIN: - pvr_sync_stats(PVR_SYNC_VBLANK); - break; } #ifdef PVR_RENDER_DBG @@ -159,91 +231,14 @@ void pvr_int_handler(uint32 code, void *data) { case ASIC_EVT_PVR_TRANSMODDONE: case ASIC_EVT_PVR_PTDONE: - if(pvr_state.lists_transferred == pvr_state.lists_enabled) { - pvr_sync_stats(PVR_SYNC_REGDONE); - } - - return; - } - - if(!pvr_state.to_texture[bufn]) { - // If it's not a vblank, ignore the rest of this for now. - if(code != ASIC_EVT_PVR_VBLANK_BEGIN) - return; - } - else { - // We don't need to wait for a vblank for rendering to a texture, but - // we really don't care about anything else unless we've actually gotten - // all the data submitted to the TA. - if(pvr_state.lists_transferred != pvr_state.lists_enabled && - !pvr_state.render_completed) - return; - } - - // If the render-done interrupt has fired then we are ready to flip to the - // new frame buffer. - if(pvr_state.render_completed) { - //DBG(("view(%d)\n", pvr_state.view_target ^ 1)); - - // Handle PVR stats - pvr_sync_stats(PVR_SYNC_PAGEFLIP); - - // Switch view address to the "good" buffer - pvr_state.view_target ^= 1; - - if(!pvr_state.to_texture[bufn]) - pvr_sync_view(); + if(pvr_state.lists_transferred != pvr_state.lists_enabled) + return; - // Clear the render completed flag. - pvr_state.render_completed = 0; + pvr_sync_stats(PVR_SYNC_REGDONE); + break; } // If all lists are fully transferred and a render is not in progress, // we are ready to start rendering. - if(!pvr_state.render_busy - && pvr_state.lists_transferred == pvr_state.lists_enabled) { - /* XXX Note: - For some reason, the render must be started _before_ we sync - to the new reg buffers. The only reasons I can think of for this - are that there may be something in the reg sync that messes up - the render in progress, or we are misusing some bits somewhere. */ - - // Begin rendering from the dirty TA buffer into the clean - // frame buffer. - //DBG(("start_render(%d -> %d)\n", pvr_state.ta_target, pvr_state.view_target ^ 1)); - pvr_state.ta_target ^= 1; - pvr_begin_queued_render(); - pvr_state.render_busy = 1; - pvr_sync_stats(PVR_SYNC_RNDSTART); - - // Clear the texture render flag if we had it set. - pvr_state.to_texture[bufn] = 0; - - // If we're not in DMA mode, then signal the client code - // to continue onwards. - if(!pvr_state.dma_mode) { - sem_signal((semaphore_t *)&pvr_state.ready_sem); - thd_schedule(1, 0); - } - - // Switch to the clean TA buffer. - pvr_state.lists_transferred = 0; - pvr_sync_reg_buffer(); - - // The TA is no longer busy. - pvr_state.ta_busy = 0; - } - - // If we're in DMA mode, the DMA source buffers are ready, and a DMA - // is not in progress, then we are ready to start DMAing. - if(pvr_state.dma_mode - && !pvr_state.ta_busy - && pvr_state.dma_buffers[pvr_state.ram_target ^ 1].ready - && mutex_trylock((mutex_t *)&pvr_state.dma_lock) >= 0) { - pvr_sync_stats(PVR_SYNC_REGSTART); - - // Begin DMAing the first list. - pvr_state.ta_busy = 1; - dma_next_list(0); - } + pvr_render_lists(); } diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c b/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c index 922c6500..b7f18862 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c @@ -9,6 +9,7 @@ #include <assert.h> #include <stdio.h> #include <string.h> +#include <kos/genwait.h> #include <kos/string.h> #include <kos/thread.h> #include <dc/pvr.h> @@ -86,11 +87,25 @@ void pvr_vertbuf_written(pvr_list_t list, uint32 amt) { pvr_state.dma_buffers[pvr_state.ram_target].ptr[list] = val; } +static void pvr_start_ta_rendering(void) { + // Make sure to wait until the TA is ready to start rendering a new scene + if(!pvr_state.ta_ready) { + pvr_wait_ready(); + pvr_state.ta_ready = 1; + } + + // Starting from that point, we consider that the Tile Accelerator + // might be busy. + pvr_state.ta_busy = 1; +} + /* Begin collecting data for a frame of 3D output to the off-screen frame buffer */ void pvr_scene_begin(void) { int i; + pvr_state.ta_ready = 0; + // Get general stuff ready. pvr_state.list_reg_open = -1; @@ -164,8 +179,10 @@ int pvr_list_begin(pvr_list_t list) { pvr_list_dma = pvr_list_uses_dma(list); - if(!pvr_list_dma) + if(!pvr_list_dma) { + pvr_start_ta_rendering(); sq_lock((void *)PVR_TA_INPUT); + } /* Ok, set the flag */ pvr_state.list_reg_open = list; @@ -304,12 +321,21 @@ int pvr_scene_finish(void) { b = pvr_state.dma_buffers + pvr_state.ram_target; for(i = 0; i < PVR_OPB_COUNT; i++) { - /* Check whether the current list type should be skipped: - A. We never enabled the list globally with pvr_init(). - B. We never associated an in-RAM DMA vertex buffer with - the given list type, because we're using hybrid - rendering and submitted that list type directly. */ - if(!(pvr_state.lists_enabled & (1 << i)) || !b->base[i]) + /* We never enabled the list globally with pvr_init() - skip it */ + if(!(pvr_state.lists_enabled & (1 << i))) + continue; + + /* If any lists weren't used in this scene, submit blank ones now */ + if(!(pvr_state.lists_closed & (1 << i))) { + pvr_list_begin(i); + pvr_blank_polyhdr(i); + pvr_list_finish(); + } + + /* We never associated an in-RAM DMA vertex buffer with the given + list type, because we're using hybrid rendering and submitted + that list type directly - skip it */ + if(!b->base[i]) continue; // Make sure there's at least one primitive in each. @@ -326,6 +352,8 @@ int pvr_scene_finish(void) { assert(b->ptr[i] <= b->size[i]); } + pvr_start_ta_rendering(); + // Flip buffers and mark them complete. o = irq_disable(); pvr_state.dma_buffers[pvr_state.ram_target].ready = 1; @@ -333,6 +361,8 @@ int pvr_scene_finish(void) { irq_restore(o); pvr_sync_stats(PVR_SYNC_BUFDONE); + + pvr_start_dma(); } else { /* If a list was open, close it */ @@ -355,11 +385,16 @@ int pvr_scene_finish(void) { } int pvr_wait_ready(void) { - int t; + int flags, t = 0; assert(pvr_state.valid); - t = sem_wait_timed((semaphore_t *)&pvr_state.ready_sem, 100); + flags = irq_disable(); + + if(pvr_state.ta_busy) + t = genwait_wait((void *)&pvr_state.ta_busy, "PVR wait ready", 100, NULL); + + irq_restore(flags); if(t < 0) { #if 0 @@ -383,7 +418,7 @@ int pvr_wait_ready(void) { int pvr_check_ready(void) { assert(pvr_state.valid); - if(sem_count((semaphore_t *)&pvr_state.ready_sem) > 0) + if(!pvr_state.ta_busy) return 0; else return -1; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-11-05 03:28:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, v2.1.0 has been updated via 22f4385da4e9767bda60460e468a5d634e71d813 (commit) via b8ff0fce6f109e8aa8a0dbe81cbd46d25acb191d (commit) from 52140509f51a9d262ea75353f2eb0f7e18c2ec6b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 22f4385da4e9767bda60460e468a5d634e71d813 Author: Andy Barajas <and...@gm...> Date: Mon Nov 4 19:15:43 2024 -0800 Bump tag to 1 (#845) commit b8ff0fce6f109e8aa8a0dbe81cbd46d25acb191d Author: Andy Barajas <and...@gm...> Date: Mon Nov 4 19:11:34 2024 -0800 Fix versioning (#844) ----------------------------------------------------------------------- Summary of changes: include/kos/version.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/kos/version.h b/include/kos/version.h index 431a3430..9b2cb1d9 100644 --- a/include/kos/version.h +++ b/include/kos/version.h @@ -99,7 +99,7 @@ #define KOS_VERSION_MAJOR 2 /**< KOS's current major revision number. */ #define KOS_VERSION_MINOR 1 /**< KOS's current minor revision number. */ -#define KOS_VERSION_PATCH 0 /**< KOS's current patch revision number. */ +#define KOS_VERSION_PATCH 1 /**< KOS's current patch revision number. */ /** KOS's current version as an integer ID. */ #define KOS_VERSION \ @@ -249,7 +249,7 @@ \returns Packed version identifier. */ #define KOS_VERSION_MAKE(major, minor, patch) \ - ((kos_version_t)((major) << 16) | ((minor) << 8) | (patch)) + (((major) << 16) | ((minor) << 8) | (patch)) /** Creates a version string from its constituents. @@ -305,7 +305,7 @@ \retval false The given version is at or below \p version. */ #define KOS_VERSION_MAKE_ABOVE(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <, version)) /** Creates a minimum version check. @@ -323,7 +323,7 @@ \retval false The given version is below \p version. */ #define KOS_VERSION_MAKE_MIN(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >=, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <=, version)) /** Creates an exact version check. @@ -360,7 +360,7 @@ */ #define KOS_VERSION_MAKE_MAX(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <=, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >=, version)) /** Creates a check for being below a given version. @@ -378,7 +378,7 @@ \retval false The given version is at or above \p version. */ #define KOS_VERSION_MAKE_BELOW(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >, version)) /** @} */ /** \cond INTERNAL */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-11-05 03:01:00
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 65cc060af59a607a2a05c742089d08f8271b0eb9 (commit) from e1b97e4314fa1a2e933fc3846c3971a8439a0f0b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 65cc060af59a607a2a05c742089d08f8271b0eb9 Author: Andy Barajas <and...@gm...> Date: Mon Nov 4 19:00:39 2024 -0800 Fix versioning macros (#843) ----------------------------------------------------------------------- Summary of changes: include/kos/version.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/kos/version.h b/include/kos/version.h index 431a3430..5fe98b1a 100644 --- a/include/kos/version.h +++ b/include/kos/version.h @@ -249,7 +249,7 @@ \returns Packed version identifier. */ #define KOS_VERSION_MAKE(major, minor, patch) \ - ((kos_version_t)((major) << 16) | ((minor) << 8) | (patch)) + (((major) << 16) | ((minor) << 8) | (patch)) /** Creates a version string from its constituents. @@ -305,7 +305,7 @@ \retval false The given version is at or below \p version. */ #define KOS_VERSION_MAKE_ABOVE(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <, version)) /** Creates a minimum version check. @@ -323,7 +323,7 @@ \retval false The given version is below \p version. */ #define KOS_VERSION_MAKE_MIN(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >=, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <=, version)) /** Creates an exact version check. @@ -360,7 +360,7 @@ */ #define KOS_VERSION_MAKE_MAX(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <=, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >=, version)) /** Creates a check for being below a given version. @@ -378,7 +378,7 @@ \retval false The given version is at or above \p version. */ #define KOS_VERSION_MAKE_BELOW(major, minor, patch, version) \ - (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <, version)) + (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >, version)) /** @} */ /** \cond INTERNAL */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-11-02 07:43:36
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e1b97e4314fa1a2e933fc3846c3971a8439a0f0b (commit) from 8e49da92f2824f43414078a021fd82f78ff26f07 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e1b97e4314fa1a2e933fc3846c3971a8439a0f0b Author: Ruslan Rostovtsev <sw...@21...> Date: Sat Nov 2 14:42:53 2024 +0700 Fix G2 DMA race conditions. (#833) - Channel params sets before check DMA is in progress. - The start (progress) register can be zero before IRQ are executed. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/g2dma.c | 39 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/g2dma.c b/kernel/arch/dreamcast/hardware/g2dma.c index 5f9a301b..d618a4b4 100644 --- a/kernel/arch/dreamcast/hardware/g2dma.c +++ b/kernel/arch/dreamcast/hardware/g2dma.c @@ -3,6 +3,7 @@ g2dma.c Copyright (C) 2001, 2002, 2004 Megan Potter Copyright (C) 2023 Andy Barajas + Copyright (C) 2024 Ruslan Rostovtsev */ #include <assert.h> @@ -38,6 +39,7 @@ typedef struct { /* Signaling semaphore */ static semaphore_t dma_done[4]; +static int dma_progress[4]; static int dma_blocking[4]; static g2_dma_callback_t dma_callback[4]; static void *dma_cbdata[4]; @@ -140,16 +142,20 @@ static void g2_dma_irq_hnd(uint32_t code, void *data) { /* VP : changed the order of things so that we can chain dma calls */ - /* Signal the calling thread to continue, if any. */ - if(dma_blocking[chn]) { - sem_signal(&dma_done[chn]); - thd_schedule(1, 0); - dma_blocking[chn] = 0; - } + if(dma_progress[chn]) { + dma_progress[chn] = 0; + + /* Signal the calling thread to continue, if any. */ + if(dma_blocking[chn]) { + dma_blocking[chn] = 0; + sem_signal(&dma_done[chn]); + thd_schedule(1, 0); + } - /* Call the callback, if any. */ - if(dma_callback[chn]) { - dma_callback[chn](dma_cbdata[chn]); + /* Call the callback, if any. */ + if(dma_callback[chn]) { + dma_callback[chn](dma_cbdata[chn]); + } } } @@ -178,6 +184,13 @@ int g2_dma_transfer(void *sh4, void *g2bus, size_t length, uint32_t block, return -1; } + /* Make sure we're not already DMA'ing */ + if(dma_progress[g2chn] != 0) { + errno = EINPROGRESS; + return -1; + } + dma_progress[g2chn] = 1; + /* Make sure length is a multiple of 32 */ length = (length + 0x1f) & ~0x1f; @@ -185,13 +198,6 @@ int g2_dma_transfer(void *sh4, void *g2bus, size_t length, uint32_t block, dma_callback[g2chn] = callback; dma_cbdata[g2chn] = cbdata; - /* Make sure we're not already DMA'ing */ - if(g2_dma->dma[g2chn].start != 0) { - dbglog(DBG_ERROR, "g2_dma: Already DMA'ing for channel %ld\n", g2chn); - errno = EINPROGRESS; - return -1; - } - /* Set needed registers */ g2_dma->dma[g2chn].g2_addr = ((uint32_t)g2bus) & MASK_ADDRESS; g2_dma->dma[g2chn].sh4_addr = ((uint32_t)sh4) & MASK_ADDRESS; @@ -228,6 +234,7 @@ int g2_dma_init(void) { for(i = 0; i < 4; i++) { /* Create an initially blocked semaphore */ sem_init(&dma_done[i], 0); + dma_progress[i] = 0; dma_blocking[i] = 0; dma_callback[i] = NULL; dma_cbdata[i] = 0; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-23 11:45:45
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 8e49da92f2824f43414078a021fd82f78ff26f07 (commit) from 63ee447e3b4bcd2b48e15ed289e1c82a80145ff7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8e49da92f2824f43414078a021fd82f78ff26f07 Author: Cypress <140...@us...> Date: Wed Oct 23 11:44:44 2024 +0000 Consistency fix (#832) Added periods to all commented sentences. ----------------------------------------------------------------------- Summary of changes: environ_base.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/environ_base.sh b/environ_base.sh index a4d98cf0..a6fada44 100644 --- a/environ_base.sh +++ b/environ_base.sh @@ -11,32 +11,32 @@ if [ -z "${KOS_PORTS}" ] ; then export KOS_PORTS="${KOS_BASE}/../kos-ports" fi -# Arch kernel folder +# Arch kernel folder. export KOS_ARCH_DIR="${KOS_BASE}/kernel/arch/${KOS_ARCH}" -# Pull in the arch environ file +# Pull in the arch environ file. . ${KOS_BASE}/environ_${KOS_ARCH}.sh -# Add the compiler bins dir to the path if it is not already +# Add the compiler bins dir to the path if it is not already. if [[ ":$PATH:" != *":${KOS_CC_BASE}/bin:"* ]]; then export PATH="${PATH}:${KOS_CC_BASE}/bin" fi -# Add the build wrappers dir to the path if it is not already +# Add the build wrappers dir to the path if it is not already. if [[ ":$PATH:" != *":${KOS_BASE}/utils/build_wrappers:"* ]]; then export PATH="${PATH}:${KOS_BASE}/utils/build_wrappers" fi -# Our includes +# Our includes. export KOS_INC_PATHS="${KOS_INC_PATHS} -I${KOS_BASE}/include \ -I${KOS_BASE}/kernel/arch/${KOS_ARCH}/include -I${KOS_BASE}/addons/include \ -I${KOS_PORTS}/include" -# "System" libraries +# "System" libraries. export KOS_LIB_PATHS="-L${KOS_BASE}/lib/${KOS_ARCH} -L${KOS_BASE}/addons/lib/${KOS_ARCH} -L${KOS_PORTS}/lib" export KOS_LIBS="-Wl,--start-group -lkallisti -lm -lc -lgcc -Wl,--end-group" -# Main arch compiler paths +# Main arch compiler paths. export KOS_CC="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-gcc" export KOS_CCPLUS="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-g++" export KOS_AS="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-as" @@ -50,7 +50,7 @@ export KOS_STRIP="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-strip" export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_INC_PATHS} -D_arch_${KOS_ARCH} -D_arch_sub_${KOS_SUBARCH} -Wall -g" export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP}" -# Which standards modes we want to compile for +# Which standards modes we want to compile for. # Note that this only covers KOS itself, not necessarily anything else compiled # with kos-cc or kos-c++. export KOS_CSTD="-std=gnu17" @@ -66,7 +66,7 @@ case $KOS_GCCVER in export KOS_LDFLAGS="${KOS_CFLAGS} ${KOS_LDFLAGS} ${KOS_LD_SCRIPT} -nodefaultlibs ${KOS_LIB_PATHS}" ;; esac -# Some extra vars based on architecture +# Some extra vars based on architecture. case $KOS_GCCVER in 2* | 3*) export KOS_START="${KOS_ARCH_DIR}/kernel/startup.o" ;; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-21 05:46:51
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 63ee447e3b4bcd2b48e15ed289e1c82a80145ff7 (commit) from f5c0a4c7ce9325a5969319afa17903436f50d4e1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 63ee447e3b4bcd2b48e15ed289e1c82a80145ff7 Author: Paul Cercueil <pa...@cr...> Date: Mon Oct 21 07:46:29 2024 +0200 pvr: Add new function pvr_send_to_ta() (#817) This function can be used to upload a 32-byte payload to the Tile Accelerator. The difference with the Direct Rendering approach is that the SQs are not used, and therefore can be used for anything else. Signed-off-by: Paul Cercueil <pa...@cr...> Co-authored-by: Falco Girgis <gyr...@gm...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/pvr/Makefile | 3 ++ .../arch/dreamcast/hardware/pvr/pvr_send_to_ta.s | 43 ++++++++++++++++++++++ kernel/arch/dreamcast/include/dc/pvr.h | 11 ++++++ 3 files changed, 57 insertions(+) create mode 100644 kernel/arch/dreamcast/hardware/pvr/pvr_send_to_ta.s diff --git a/kernel/arch/dreamcast/hardware/pvr/Makefile b/kernel/arch/dreamcast/hardware/pvr/Makefile index 1eda21b1..3d9f1a77 100644 --- a/kernel/arch/dreamcast/hardware/pvr/Makefile +++ b/kernel/arch/dreamcast/hardware/pvr/Makefile @@ -13,6 +13,9 @@ OBJS += pvr_buffers.o pvr_irq.o # Init / Shutdown / Globals / Misc OBJS += pvr_init_shutdown.o pvr_globals.o pvr_misc.o +# Fast Tile Accelerator upload function +OBJS += pvr_send_to_ta.o + # Fog OBJS += pvr_fog.o diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_send_to_ta.s b/kernel/arch/dreamcast/hardware/pvr/pvr_send_to_ta.s new file mode 100644 index 00000000..11629bab --- /dev/null +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_send_to_ta.s @@ -0,0 +1,43 @@ +! KallistiOS ##version## +! +! arch/dreamcast/hardware/pvr/pvr_send_to_ta.s +! Copyright (C) 2024 Paul Cercueil +! +! Fast function to upload geometry to the Tile Accelerator without SQs +! + +.globl _pvr_send_to_ta + +_pvr_send_to_ta: + fschg + mov.l _irq_and,r1 + mov #0x78,r2 + mov.l _ta_addr,r3 + stc sr,r0 + and r0,r1 + fmov @r4+,dr0 + shll r2 + fmov @r4+,dr2 + or r2,r1 + fmov @r4+,dr4 + fmov @r4+,dr6 + ldc r1,sr + + movca.l r0,@r3 + add #32,r3 + fmov dr6,@-r3 + fmov dr4,@-r3 + fmov dr2,@-r3 + fmov dr0,@-r3 + fschg + + ldc r0,sr + + rts + ocbp @r3 + +.align 2 +_irq_and: + .long 0xefffff0f +_ta_addr: + .long 0x90000000 diff --git a/kernel/arch/dreamcast/include/dc/pvr.h b/kernel/arch/dreamcast/include/dc/pvr.h index eb2ac36f..7ec55b35 100644 --- a/kernel/arch/dreamcast/include/dc/pvr.h +++ b/kernel/arch/dreamcast/include/dc/pvr.h @@ -2006,6 +2006,17 @@ void pvr_dr_init(pvr_dr_state_t *vtx_buf_ptr); */ void pvr_dr_finish(void); +/** \brief Upload a 32-byte payload to the Tile Accelerator + + Upload the given payload to the Tile Accelerator. The difference with the + Direct Rendering approach above is that the Store Queues are not used, and + therefore can be used for anything else. + + \param data A pointer to the 32-byte payload. + The pointer must be aligned to 8 bytes. +*/ +void pvr_send_to_ta(void *data); + /** @} */ /** \brief Submit a primitive of the given list type. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-21 05:19:49
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via f5c0a4c7ce9325a5969319afa17903436f50d4e1 (commit) from 41f2fd3f82d822099cdcea8f08e323c24da84d2c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f5c0a4c7ce9325a5969319afa17903436f50d4e1 Author: Donald Haase <qu...@ya...> Date: Mon Oct 21 01:19:33 2024 -0400 Stat is intended to return 0 upon successful completion. Was returning -1. (#821) Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: kernel/fs/fs_ramdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fs/fs_ramdisk.c b/kernel/fs/fs_ramdisk.c index f86bbd09..97720aad 100644 --- a/kernel/fs/fs_ramdisk.c +++ b/kernel/fs/fs_ramdisk.c @@ -624,7 +624,7 @@ static int ramdisk_stat(vfs_handler_t *vfs, const char *path, struct stat *st, if(f->datasize & 0x3ff) ++st->st_blocks; - return -1; + return 0; } static int ramdisk_fcntl(void *h, int cmd, va_list ap) { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-21 05:17:40
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 41f2fd3f82d822099cdcea8f08e323c24da84d2c (commit) from 9ced3a9b8b3f0cbbce7c5c1dc83cfa9376fa3e7d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 41f2fd3f82d822099cdcea8f08e323c24da84d2c Author: Donald Haase <qu...@ya...> Date: Mon Oct 21 01:17:29 2024 -0400 The sys/queue `_FOREACH` functions are not safe to free their elements. (#823) Swap usage to the `_FOREACH_SAFE` which is the safe version. Without this, each time `qpkt` is freed, the next loop iteration is based on a use-after-free. Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: kernel/net/net_dhcp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/net/net_dhcp.c b/kernel/net/net_dhcp.c index 064a8964..b14e159e 100644 --- a/kernel/net/net_dhcp.c +++ b/kernel/net/net_dhcp.c @@ -480,7 +480,7 @@ static void net_dhcp_bind(dhcp_pkt_t *pkt, int len) { } static void net_dhcp_thd(void *obj) { - struct dhcp_pkt_out *qpkt; + struct dhcp_pkt_out *qpkt, *q_tmp; uint64 now; struct sockaddr_in addr; uint8 buf[1500]; @@ -499,7 +499,7 @@ static void net_dhcp_thd(void *obj) { /* Make sure we don't need to renew our lease */ if(lease_expires <= now && (state == DHCP_STATE_BOUND || state == DHCP_STATE_RENEWING || state == DHCP_STATE_REBINDING)) { - STAILQ_FOREACH(qpkt, &dhcp_pkts, pkt_queue) { + STAILQ_FOREACH_SAFE(qpkt, &dhcp_pkts, pkt_queue, q_tmp) { STAILQ_REMOVE(&dhcp_pkts, qpkt, dhcp_pkt_out, pkt_queue); free(qpkt->buf); free(qpkt); @@ -513,7 +513,7 @@ static void net_dhcp_thd(void *obj) { else if(rebind_time <= now && (state == DHCP_STATE_BOUND || state == DHCP_STATE_RENEWING)) { /* Clear out any existing packets. */ - STAILQ_FOREACH(qpkt, &dhcp_pkts, pkt_queue) { + STAILQ_FOREACH_SAFE(qpkt, &dhcp_pkts, pkt_queue, q_tmp) { STAILQ_REMOVE(&dhcp_pkts, qpkt, dhcp_pkt_out, pkt_queue); free(qpkt->buf); free(qpkt); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-21 05:16:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 9ced3a9b8b3f0cbbce7c5c1dc83cfa9376fa3e7d (commit) from f3be5205f542e667ff8d39cca0b9b2024276c2ce (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9ced3a9b8b3f0cbbce7c5c1dc83cfa9376fa3e7d Author: Paul Cercueil <pa...@cr...> Date: Mon Oct 21 07:15:35 2024 +0200 perf_monitor: Add macro for branch likeliness analysis (#826) Introduce a new perf_monitor_if() macro. This macro is designed to be used inside an "if" expression, for instance: if (perf_monitor_if(!strcmp("test", str))) { ... } The resulting performance monitor will measure the number of calls, and the number of times the branch was taken (in event1) and the number of time it was not (in event0). Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/perf_monitor.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/kernel/arch/dreamcast/include/dc/perf_monitor.h b/kernel/arch/dreamcast/include/dc/perf_monitor.h index cdf20cdf..20617623 100644 --- a/kernel/arch/dreamcast/include/dc/perf_monitor.h +++ b/kernel/arch/dreamcast/include/dc/perf_monitor.h @@ -59,6 +59,15 @@ struct perf_monitor *__start_perf_monitor(struct perf_monitor *monitor); __start_perf_monitor(&__perf_monitor_##l) #define _perf_monitor(f, l) __perf_monitor(f, l) + +#define __perf_monitor_if(f, l, tst) ({ \ + static struct perf_monitor __perf_monitor_##l \ + __attribute__((section(".monitors"))) = { f, l, }; \ + __perf_monitor_##l.calls++; \ + (tst) ? (__perf_monitor_##l.event1++,1) : (__perf_monitor_##l.event0++,0); \ +}) + +#define _perf_monitor_if(f, l, tst) __perf_monitor_if(f, l, tst) /** /endcond */ /** \brief Register a performance monitor in the current functional block @@ -68,6 +77,20 @@ struct perf_monitor *__start_perf_monitor(struct perf_monitor *monitor); */ #define perf_monitor() _perf_monitor(__func__, __LINE__) +/** \brief Register a performance monitor for branch likeliness analysis + + This macro is designed to be used inside an "if" expression, for instance: + if (perf_monitor_if(!strcmp("test", str))) { ... } + + The resulting performance monitor will measure the number of calls, and + the number of times the branch was taken (in event1) and the number of + time it was not (in event0). + + \param tst The boolean expression that is normally used inside + the "if" check +*/ +#define perf_monitor_if(tst) _perf_monitor_if(__func__, __LINE__, tst) + /** \brief Initialize the performance monitor system Set up the performance monitor system. Note that using the performance hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-10-19 06:33:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via f3be5205f542e667ff8d39cca0b9b2024276c2ce (commit) via 20f1380057375fb2b885ad4eb97d3d24fd84e99a (commit) via 6e8a811fd773d7ab64e34940a2a0f1923d6793ba (commit) from fb5168a380cac5cb99696ad38ceb4b360dedcd20 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f3be5205f542e667ff8d39cca0b9b2024276c2ce Author: Andy Barajas <and...@gm...> Date: Fri Oct 18 23:28:08 2024 -0700 Exclude system generated files from being included in romdisk generation (#824) commit 20f1380057375fb2b885ad4eb97d3d24fd84e99a Author: Stefanos Kornilios Mitsis Poiitidis <st...@sk...v> Date: Sat Oct 19 09:27:31 2024 +0300 audio: Fix makefile race condition and arm clean (#828) commit 6e8a811fd773d7ab64e34940a2a0f1923d6793ba Author: Andy Barajas <and...@gm...> Date: Fri Oct 18 23:24:20 2024 -0700 Added functionality to biosfont (#816) - Extend bfont API to take common formatted prints to the framebuffer. - Remove deprecated `32-bit mode` which was a legacy of the framebuffer being expanded to work against different bitdepths and hasn't been needed in years. ----------------------------------------------------------------------- Summary of changes: Makefile.rules | 2 +- examples/dreamcast/video/screenshot/screenshot.c | 14 +-- examples/dreamcast/vmu/vmu_game/vmu_game.c | 18 ++-- kernel/arch/dreamcast/exports-pristine.txt | 15 +++- kernel/arch/dreamcast/hardware/biosfont.c | 108 +++++++++++++++++------ kernel/arch/dreamcast/include/dc/biosfont.h | 106 +++++++++++++--------- kernel/arch/dreamcast/sound/Makefile | 4 +- kernel/arch/dreamcast/sound/arm/Makefile | 2 +- 8 files changed, 173 insertions(+), 96 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index 678c882a..f8f1b16e 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -77,7 +77,7 @@ $(patsubst %, _clean_dir_%, $(SUBDIRS)): # Define KOS_ROMDISK_DIR in your Makefile if you want these two handy rules. ifdef KOS_ROMDISK_DIR romdisk.img: - $(KOS_GENROMFS) -f romdisk.img -d $(KOS_ROMDISK_DIR) -v -x .svn -x .keepme + $(KOS_GENROMFS) -f romdisk.img -d $(KOS_ROMDISK_DIR) -v -x .keepme -x .DS_Store -x Thumbs.db romdisk.o: romdisk.img $(KOS_BASE)/utils/bin2c/bin2c romdisk.img romdisk_tmp.c romdisk diff --git a/examples/dreamcast/video/screenshot/screenshot.c b/examples/dreamcast/video/screenshot/screenshot.c index 1f77d807..fab1c61e 100644 --- a/examples/dreamcast/video/screenshot/screenshot.c +++ b/examples/dreamcast/video/screenshot/screenshot.c @@ -30,7 +30,7 @@ #include <kos/thread.h> -#define SHOW_BLACK_BG 1 +#define SHOW_BLACK_BG true /* Keeps track of the amount of screenshots you have taken */ static int counter = 0; @@ -38,7 +38,6 @@ static int counter = 0; int main(int argc, char **argv) { uint8_t r, g, b; uint32_t t = 0; - int font_height_offset = 0; char filename[256]; /* Adjust frequency for faster or slower transitions */ @@ -48,7 +47,7 @@ int main(int argc, char **argv) { cont_state_t *state; /* Set the video mode */ - vid_set_mode(DM_640x480, PM_RGB565); + vid_set_mode(DM_640x480, PM_RGB565); while(1) { if((cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER)) != NULL) { @@ -82,13 +81,8 @@ int main(int argc, char **argv) { vid_clear(r, g, b); /* Draw Foreground */ - font_height_offset = (640 * (480 - (BFONT_HEIGHT * 6))) + (BFONT_THIN_WIDTH * 2); - bfont_draw_str(vram_s + font_height_offset, 640, SHOW_BLACK_BG, - "Press Start to exit"); - - font_height_offset += 640 * BFONT_HEIGHT * 2; - bfont_draw_str(vram_s + font_height_offset, 640, SHOW_BLACK_BG, - "Press A to take a screen shot"); + bfont_draw_str_vram_fmt(24, 336, SHOW_BLACK_BG, + "Press Start to exit\n\nPress A to take a screen shot"); vid_flip(-1); } diff --git a/examples/dreamcast/vmu/vmu_game/vmu_game.c b/examples/dreamcast/vmu/vmu_game/vmu_game.c index 12d5c42d..7b90b0ef 100644 --- a/examples/dreamcast/vmu/vmu_game/vmu_game.c +++ b/examples/dreamcast/vmu/vmu_game/vmu_game.c @@ -12,15 +12,14 @@ void draw_findings(void) { file_t d; - int y = 88; d = fs_open("/vmu/a1", O_RDONLY | O_DIR); if(!d) { - bfont_draw_str(vram_s + y * 640 + 10, 640, 0, "Can't read VMU"); + bfont_draw_str_vram_fmt(10, 88, false, "Can't read VMU"); } else { - bfont_draw_str(vram_s + y * 640 + 10, 640, 0, "VMU found. Press Start."); + bfont_draw_str_vram_fmt(10, 88, false, "VMU found. Press Start."); } } @@ -33,7 +32,7 @@ void new_vmu(void) { if(dev == NULL) { if(dev_checked) { memset4(vram_s + 88 * 640, 0, 640 * (480 - 64) * 2); - bfont_draw_str(vram_s + 88 * 640 + 10, 640, 0, "No VMU"); + bfont_draw_str_vram_fmt(10, 88, false, "No VMU"); dev_checked = 0; } } @@ -88,18 +87,13 @@ void write_game_entry(void) { dev = maple_enum_type(0, MAPLE_FUNC_MEMCARD); - if (dev) - { + if(dev) vmufs_write(dev, "Tetris", data, data_size, VMUFS_VMUGAME); - } } int main(int argc, char **argv) { - bfont_draw_str(vram_s + 20 * 640 + 20, 640, 0, - "Put a VMU you don't care too much about"); - bfont_draw_str(vram_s + 42 * 640 + 20, 640, 0, - "in slot A1 and press START"); - bfont_draw_str(vram_s + 88 * 640 + 10, 640, 0, "No VMU"); + bfont_draw_str_vram_fmt(20, 20, false, + "Put a VMU you don't care too much about\nin slot A1 and press START\n\nNo VMU"); if(wait_start() < 0) return 0; diff --git a/kernel/arch/dreamcast/exports-pristine.txt b/kernel/arch/dreamcast/exports-pristine.txt index bdb05bf9..89750ed6 100644 --- a/kernel/arch/dreamcast/exports-pristine.txt +++ b/kernel/arch/dreamcast/exports-pristine.txt @@ -93,11 +93,24 @@ vmu_pkg_build vmu_pkg_parse # Bios Font +bfont_set_foreground_color +bfont_set_background_color bfont_set_encoding +bfont_find_char +bfont_find_char_jp +bfont_find_char_jp_half +bfont_find_icon +bfont_draw_ex +bfont_draw bfont_draw_thin bfont_draw_wide -bfont_draw +bfont_draw_str_ex +bfont_draw_str_ex_fmt +bfont_draw_str_ex_vfmt bfont_draw_str +bfont_draw_str_fmt +bfont_draw_str_vram_vfmt +bfont_draw_str_vram_fmt # CD-Rom cdrom_reinit diff --git a/kernel/arch/dreamcast/hardware/biosfont.c b/kernel/arch/dreamcast/hardware/biosfont.c index 7ac5bfb9..0a3bd1ca 100644 --- a/kernel/arch/dreamcast/hardware/biosfont.c +++ b/kernel/arch/dreamcast/hardware/biosfont.c @@ -13,6 +13,7 @@ #include <string.h> #include <stdio.h> +#include <dc/video.h> #include <dc/biosfont.h> #include <dc/syscalls.h> @@ -44,7 +45,6 @@ static uint8_t bfont_code_mode = BFONT_CODE_ISO8859_1; been forever. */ static uint32_t bfont_fgcolor = 0xFFFFFFFF; static uint32_t bfont_bgcolor = 0x00000000; -static bool bfont_32bit = false; static uint8_t *font_address = NULL; @@ -55,6 +55,10 @@ static uint8_t *get_font_address(void) { return font_address; } +static inline uint8_t bits_per_pixel() { + return ((vid_mode->pm == PM_RGB0888) ? sizeof(uint32_t) : sizeof(uint16_t)) << 3; +} + /* Select an encoding for Japanese (or disable) */ void bfont_set_encoding(bfont_code_t enc) { if(enc <= BFONT_CODE_RAW) @@ -77,15 +81,6 @@ uint32_t bfont_set_background_color(uint32_t c) { return rv; } -/* Set the font to draw in 32 or 16 bit mode. - Deprecated: This will only impact compat functions for now. - Moving forward, the compat will be 16bit only. */ -bool bfont_set_32bit_mode(bool on) { - bool rv = bfont_32bit; - bfont_32bit = on; - return rv; -} - int lock_bfont(void) { /* Just make sure no outside system took the lock */ while(syscall_font_lock() != 0) @@ -129,7 +124,7 @@ static uint32_t euc2jis(uint32_t euc) { /* Given an ASCII character, find it in the BIOS font if possible */ uint8_t *bfont_find_char(uint32_t ch) { - uint8_t *fa = get_font_address(); + uint8_t *fa = get_font_address(); /* By default, map to a space */ uint32_t index = 72 << 2; @@ -146,7 +141,7 @@ uint8_t *bfont_find_char(uint32_t ch) { /* JIS -> (kuten) -> address conversion */ uint8_t *bfont_find_char_jp(uint32_t ch) { - uint8_t *fa = get_font_address(); + uint8_t *fa = get_font_address(); uint32_t ku, ten, kuten = 0; /* Do the requested code conversion */ @@ -293,66 +288,95 @@ size_t bfont_draw_ex(void *buf, uint32_t bufwidth, uint32_t fg, uint32_t bg, /* Draw half-width kana */ size_t bfont_draw_thin(void *b, uint32_t bufwidth, bool opaque, uint32_t c, bool iskana) { return bfont_draw_ex(b, bufwidth, bfont_fgcolor, bfont_bgcolor, - (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, opaque, c, 0, iskana); + bits_per_pixel(), opaque, c, false, iskana); } /* Compat function */ size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c) { return bfont_draw_ex(buffer, bufwidth, bfont_fgcolor, bfont_bgcolor, - (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, opaque, c, 0, 0); + bits_per_pixel(), opaque, c, false, false); } /* Draw wide character */ size_t bfont_draw_wide(void *b, uint32_t bufwidth, bool opaque, uint32_t c) { return bfont_draw_ex(b, bufwidth, bfont_fgcolor, bfont_bgcolor, - (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, opaque, c, 1, 0); + bits_per_pixel(), opaque, c, true, false); } -void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, - const char *str) { - uint16_t nChr, nMask, nFlag; +void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg, + uint8_t bpp, bool opaque, const char *str) { + bool wideChr; + uint16_t nChr, nMask; + uint32_t line_start = 0; uint8_t *buffer = (uint8_t *)b; while(*str) { - nFlag = 0; + wideChr = false; nChr = *str & 0xff; + if(nChr == '\n') { + /* Move to the beginning of the next line */ + buffer = (uint8_t *)b + line_start + (width * BFONT_HEIGHT * (bpp / 8)); + line_start = buffer - (uint8_t *)b; + str++; + continue; + } + else if(nChr == '\t') { + /* Draw four spaces on the current line */ + if(opaque) { + nChr = bfont_code_mode == BFONT_CODE_ISO8859_1 ? 0x20 : 0xa0; + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, false, false); + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, false, false); + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, false, false); + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, false, false); + } + else /* Spaces are always thin width characters */ + buffer += (4 * ((BFONT_THIN_WIDTH * bpp)/8)); + + str++; + continue; + } + + /* Non-western, non-ASCII character */ if(bfont_code_mode != BFONT_CODE_ISO8859_1 && (nChr & 0x80)) { switch(bfont_code_mode) { case BFONT_CODE_EUC: + /* Check if the character is the 'SS2' character in EUC-JP */ if(nChr == 0x8e) { str++; nChr = *str & 0xff; + /* Is a valid half-width katakana character? */ if((nChr < 0xa1) || (nChr > 0xdf)) nChr = 0xa0; /* Blank Space */ } else - nFlag = 1; + wideChr = true; break; case BFONT_CODE_SJIS: nMask = nChr & 0xf0; + /* Check if the character is part of the valid Shift ranges */ if((nMask == 0x80) || (nMask == 0x90) || (nMask == 0xe0)) - nFlag = 1; + wideChr = true; break; default: assert_msg(0, "Unknown bfont encoding mode"); } - if(nFlag == 1) { + if(wideChr) { str++; nChr = (nChr << 8) | (*str & 0xff); - buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, 1, 0); + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, true, false); } else - buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, 0, 1); + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, false, true); } else - buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, 0, 0); + buffer += bfont_draw_ex(buffer, width, fg, bg, bpp, opaque, nChr, false, false); str++; } @@ -384,8 +408,7 @@ void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, ui void bfont_draw_str(void *b, uint32_t width, bool opaque, const char *str) { bfont_draw_str_ex(b, width, bfont_fgcolor, bfont_bgcolor, - (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, - opaque, str); + bits_per_pixel(), opaque, str); } void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt, @@ -394,8 +417,34 @@ void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt, va_start(var_args, fmt); bfont_draw_str_ex_vfmt(b, width, bfont_fgcolor, bfont_bgcolor, - (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, - opaque, fmt, &var_args); + bits_per_pixel(), opaque, fmt, &var_args); + + va_end(var_args); +} + +void bfont_draw_str_vram_vfmt(uint32_t x, uint32_t y, uint32_t fg, + uint32_t bg, bool opaque, const char *fmt, + va_list *var_args) { + uint32_t bpp = bits_per_pixel(); + void *vram = vram_s; + uint32_t offset = (y * vid_mode->width + x); + + if(bpp == 16) + vram = (uint16_t *)vram + offset; + else if(bpp == 32) + vram = (uint32_t *)vram + offset; + + bfont_draw_str_ex_vfmt(vram, vid_mode->width, fg, bg, bpp, opaque, fmt, + var_args); +} + +void bfont_draw_str_vram_fmt(uint32_t x, uint32_t y, bool opaque, + const char *fmt, ...) { + va_list var_args; + va_start(var_args, fmt); + + bfont_draw_str_vram_vfmt(x, y, bfont_fgcolor, bfont_bgcolor, opaque, fmt, + &var_args); va_end(var_args); } @@ -407,5 +456,6 @@ uint8_t *bfont_find_icon(bfont_vmu_icon_t icon) { int icon_offset = BFONT_VMU_DREAMCAST_SPECIFIC + (icon * BFONT_ICON_DIMEN * BFONT_ICON_DIMEN / 8); uint8_t *fa = get_font_address(); + return fa + icon_offset; } diff --git a/kernel/arch/dreamcast/include/dc/biosfont.h b/kernel/arch/dreamcast/include/dc/biosfont.h index 520cfa47..b2a77cb3 100644 --- a/kernel/arch/dreamcast/include/dc/biosfont.h +++ b/kernel/arch/dreamcast/include/dc/biosfont.h @@ -5,6 +5,7 @@ Japanese Functions Copyright (C) 2002 Kazuaki Matsumoto Copyright (C) 2017 Donald Haase Copyright (C) 2024 Falco Girgis + Copyright (C) 2024 Andress Barajas */ @@ -286,18 +287,6 @@ uint32_t bfont_set_foreground_color(uint32_t c); */ uint32_t bfont_set_background_color(uint32_t c); -/** \brief Set the font to draw 32-bit color. - \deprecated Use the bpp parameter of the bfont_draw_ex() functions. - - This function changes whether the font draws colors as 32-bit or 16-bit. The - default is to use 16-bit. - - \param on Set to 0 to use 16-bit color, 32-bit otherwise. - \return The old state (1 = 32-bit, 0 = 16-bit). -*/ -bool bfont_set_32bit_mode(bool on) - __depr("Please use the bpp function of the the bfont_draw_ex functions"); - /** @} */ /* Constants for the function below */ @@ -391,7 +380,7 @@ uint8_t *bfont_find_icon(bfont_vmu_icon_t icon); \param fg The foreground color to use. \param bg The background color to use. \param bpp The number of bits per pixel in the buffer. - \param opaque If non-zero, overwrite background areas with black, + \param opaque If true, overwrite background areas with black, otherwise do not change them from what they are. \param c The character to draw. \param wide Draw a wide character. @@ -410,7 +399,7 @@ size_t bfont_draw_ex(void *buffer, uint32_t bufwidth, uint32_t fg, \param buffer The buffer to draw to (at least 12 x 24 pixels) \param bufwidth The width of the buffer in pixels - \param opaque If non-zero, overwrite blank areas with black, + \param opaque If true, overwrite blank areas with black, otherwise do not change them from what they are \param c The character to draw \return Amount of width covered in bytes. @@ -424,7 +413,7 @@ size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c); \param buffer The buffer to draw to (at least 12 x 24 pixels) \param bufwidth The width of the buffer in pixels - \param opaque If non-zero, overwrite blank areas with black, + \param opaque If true, overwrite blank areas with black, otherwise do not change them from what they are \param c The character to draw \param iskana Set to 1 if the character is a kana, 0 if ISO-8859-1 @@ -440,7 +429,7 @@ size_t bfont_draw_thin(void *buffer, uint32_t bufwidth, bool opaque, \param buffer The buffer to draw to (at least 24 x 24 pixels) \param bufwidth The width of the buffer in pixels - \param opaque If non-zero, overwrite blank areas with black, + \param opaque If true, overwrite blank areas with black, otherwise do not change them from what they are \param c The character to draw \return Amount of width covered in bytes. @@ -463,12 +452,12 @@ size_t bfont_draw_wide(void *buffer, uint32_t bufwidth, bool opaque, if the encoding is set to one of the Japanese encodings. Colors and bitdepth can be set. - \param b The buffer to draw to. - \param width The width of the buffer in pixels. - \param fg The foreground color to use. - \param bg The background color to use. - \param bpp The number of bits per pixel in the buffer. - \param opaque If non-zero, overwrite background areas with black, + \param b The buffer to draw to. + \param width The width of the buffer in pixels. + \param fg The foreground color to use. + \param bg The background color to use. + \param bpp The number of bits per pixel in the buffer. + \param opaque If true, overwrite background areas with black, otherwise do not change them from what they are. \param str The string to draw. @@ -482,15 +471,15 @@ void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg, This function is equivalent to bfont_draw_str_ex(), except that the string is formatted as with the `printf()` function. - \param b The buffer to draw to. - \param width The width of the buffer in pixels. - \param fg The foreground color to use. - \param bg The background color to use. - \param bpp The number of bits per pixel in the buffer. - \param opaque If non-zero, overwrite background areas with black, + \param b The buffer to draw to. + \param width The width of the buffer in pixels. + \param fg The foreground color to use. + \param bg The background color to use. + \param bpp The number of bits per pixel in the buffer. + \param opaque If true, overwrite background areas with black, otherwise do not change them from what they are. - \param fmt The printf-style format string to draw. - \param ... Additional printf-style variadic arguments + \param fmt The printf-style format string to draw. + \param ... Additional printf-style variadic arguments \sa bfont_draw_str_ex_vfmt() */ @@ -503,15 +492,15 @@ void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, This function is equivalent to bfont_draw_str_ex_fmt(), except that the variadic argument list is passed via a pointer to a va_list. - \param b The buffer to draw to. - \param width The width of the buffer in pixels. - \param fg The foreground color to use. - \param bg The background color to use. - \param bpp The number of bits per pixel in the buffer. - \param opaque If non-zero, overwrite background areas with black, + \param b The buffer to draw to. + \param width The width of the buffer in pixels. + \param fg The foreground color to use. + \param bg The background color to use. + \param bpp The number of bits per pixel in the buffer. + \param opaque If true, overwrite background areas with black, otherwise do not change them from what they are. - \param fmt The printf-style format string to draw. - \param var_args Additional printf-style variadic arguments + \param fmt The printf-style format string to draw. + \param var_args Additional printf-style variadic arguments ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-10-16 03:17:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via fb5168a380cac5cb99696ad38ceb4b360dedcd20 (commit) from 45525d79ba9ec9a3dd17f45a8ed3c4cf8bf77053 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fb5168a380cac5cb99696ad38ceb4b360dedcd20 Author: Ruslan Rostovtsev <sw...@21...> Date: Wed Oct 16 10:15:33 2024 +0700 Sound improvements and fixes (#762) * Added snd_stream_init_ex() with the ability to reduce consumption of memory. * Added direct DMA streaming capability for G1Bus-based storage devices. * Improved sound streams data transfer to the SPU. * Reduced the number of data requests for sound streams. * Improved ADPCM channel separation by 56%. * Added spu_memload_dma() as an alternative for spu_memload_sq(). * Added snd_stream_pan() to use 2 separate mono streams as one stereo or something. * Added snd_sfx_load_ex() for optimized loading of RAW files with ability to direct transfer from G1Bus-based devices. * Handling out of SPU memory in snd_sfx_load(). * Added snd_sfx_load_fd() the same as snd_sfx_load_ex() but for working with sets. * Changed SPU DMA trigger to avoid extra stalls since SH4 can frequently accesses AICA registers. * Reduced the impact and number of mutex triggers on streams. * Some minor fixes and optimizations. * Improved ADPCM channel separation by 56%. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/exports-naomi.txt | 6 + kernel/arch/dreamcast/exports-pristine.txt | 6 + kernel/arch/dreamcast/hardware/g2dma.c | 9 +- kernel/arch/dreamcast/hardware/spu.c | 54 +++++- kernel/arch/dreamcast/include/dc/sound/sfxmgr.h | 40 +++- kernel/arch/dreamcast/include/dc/sound/stream.h | 52 +++++- kernel/arch/dreamcast/include/dc/spu.h | 16 +- kernel/arch/dreamcast/sound/snd_pcm_split.s | 226 +++++++++++++++++++--- kernel/arch/dreamcast/sound/snd_sfxmgr.c | 239 +++++++++++++++++------- kernel/arch/dreamcast/sound/snd_stream.c | 233 +++++++++++++++++------ 10 files changed, 721 insertions(+), 160 deletions(-) diff --git a/kernel/arch/dreamcast/exports-naomi.txt b/kernel/arch/dreamcast/exports-naomi.txt index 38740a2f..4e3c4615 100644 --- a/kernel/arch/dreamcast/exports-naomi.txt +++ b/kernel/arch/dreamcast/exports-naomi.txt @@ -77,6 +77,7 @@ vmu_pkg_parse # SPU spu_memload spu_memload_sq +spu_memload_dma spu_memread spu_memset spu_memset_sq @@ -112,6 +113,8 @@ snd_poll_resp snd_sfx_unload_all snd_sfx_unload snd_sfx_load +snd_sfx_load_ex +snd_sfx_load_fd snd_sfx_play snd_sfx_stop_all snd_sfx_play_chn @@ -119,9 +122,11 @@ snd_sfx_stop snd_sfx_chn_alloc snd_sfx_chn_free snd_stream_set_callback +snd_stream_set_callback_direct snd_stream_filter_add snd_stream_filter_remove snd_stream_init +snd_stream_init_ex snd_stream_shutdown snd_stream_queue_enable snd_stream_queue_disable @@ -132,6 +137,7 @@ snd_stream_queue_go snd_stream_stop snd_stream_poll snd_stream_volume +snd_stream_pan snd_stream_alloc snd_stream_destroy snd_stream_reinit diff --git a/kernel/arch/dreamcast/exports-pristine.txt b/kernel/arch/dreamcast/exports-pristine.txt index f3b46562..bdb05bf9 100644 --- a/kernel/arch/dreamcast/exports-pristine.txt +++ b/kernel/arch/dreamcast/exports-pristine.txt @@ -120,6 +120,7 @@ flashrom_get_region # SPU spu_memload spu_memload_sq +spu_memload_dma spu_memread spu_memset spu_memset_sq @@ -155,6 +156,8 @@ snd_poll_resp snd_sfx_unload_all snd_sfx_unload snd_sfx_load +snd_sfx_load_ex +snd_sfx_load_fd snd_sfx_play snd_sfx_stop_all snd_sfx_play_chn @@ -162,9 +165,11 @@ snd_sfx_stop snd_sfx_chn_alloc snd_sfx_chn_free snd_stream_set_callback +snd_stream_set_callback_direct snd_stream_filter_add snd_stream_filter_remove snd_stream_init +snd_stream_init_ex snd_stream_shutdown snd_stream_queue_enable snd_stream_queue_disable @@ -175,6 +180,7 @@ snd_stream_queue_go snd_stream_stop snd_stream_poll snd_stream_volume +snd_stream_pan snd_stream_alloc snd_stream_destroy snd_stream_reinit diff --git a/kernel/arch/dreamcast/hardware/g2dma.c b/kernel/arch/dreamcast/hardware/g2dma.c index 829b76f0..5f9a301b 100644 --- a/kernel/arch/dreamcast/hardware/g2dma.c +++ b/kernel/arch/dreamcast/hardware/g2dma.c @@ -197,7 +197,14 @@ int g2_dma_transfer(void *sh4, void *g2bus, size_t length, uint32_t block, g2_dma->dma[g2chn].sh4_addr = ((uint32_t)sh4) & MASK_ADDRESS; g2_dma->dma[g2chn].size = length | RESET_ENABLED; g2_dma->dma[g2chn].dir = dir; - g2_dma->dma[g2chn].trigger_select = CPU_TRIGGER | DMA_SUSPEND_ENABLED; + + if(g2chn == G2_DMA_CHAN_SPU) { + /* Wait until fifo is empty and start. */ + g2_dma->dma[g2chn].trigger_select = HARDWARE_TRIGGER | DMA_SUSPEND_ENABLED; + } + else { + g2_dma->dma[g2chn].trigger_select = CPU_TRIGGER | DMA_SUSPEND_ENABLED; + } /* Start the DMA transfer */ g2_dma->dma[g2chn].enable = 1; diff --git a/kernel/arch/dreamcast/hardware/spu.c b/kernel/arch/dreamcast/hardware/spu.c index 8d80e5d6..b17ddde7 100644 --- a/kernel/arch/dreamcast/hardware/spu.c +++ b/kernel/arch/dreamcast/hardware/spu.c @@ -2,13 +2,15 @@ spu.c Copyright (C) 2000, 2001 Megan Potter - Copyright (C) 2023 Ruslan Rostovtsev + Copyright (C) 2023, 2024 Ruslan Rostovtsev */ +#include <kos/thread.h> #include <dc/spu.h> #include <dc/g2bus.h> #include <dc/sq.h> #include <arch/timer.h> +#include <errno.h> /* @@ -62,7 +64,12 @@ void spu_memload(uintptr_t dst, void *src_void, size_t length) { void spu_memload_sq(uintptr_t dst, void *src_void, size_t length) { uint8_t *src = (uint8_t *)src_void; - int aligned_len; + size_t aligned_len; + + if(length < 32) { + spu_memload(dst, src_void, length); + return; + } /* Round up to the nearest multiple of 4 */ if(length & 3) { @@ -91,6 +98,49 @@ void spu_memload_sq(uintptr_t dst, void *src_void, size_t length) { } } +void spu_memload_dma(uintptr_t dst, void *src_void, size_t length) { + uint8_t *src = (uint8_t *)src_void; + size_t aligned_len; + + if(length < 32) { + spu_memload(dst, src_void, length); + return; + } + if(((uintptr_t)src_void) & 31) { + spu_memload_sq(dst, src_void, length); + return; + } + + /* Round up to the nearest multiple of 4 */ + if(length & 3) { + length = (length + 4) & ~3; + } + + /* Using DMA (or SQ's on fail) for all that is divisible by 32 */ + aligned_len = length & ~31; + length &= 31; + + do { + if(spu_dma_transfer(src_void, dst, aligned_len, 1, NULL, NULL) < 0) { + if(errno == EINPROGRESS) { + thd_pass(); + continue; + } + spu_memload_sq(dst, src_void, aligned_len); + } + break; + } while (1); + + if(length > 0) { + /* Make sure the destination is in a non-cached area */ + dst |= (MEM_AREA_P2_BASE | SPU_RAM_BASE); + dst += aligned_len; + src += aligned_len; + g2_fifo_wait(); + g2_write_block_32((uint32_t *)src, dst, length >> 2); + } +} + void spu_memread(void *dst_void, uintptr_t src, size_t length) { uint8_t *dst = (uint8_t *)dst_void; diff --git a/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h b/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h index cfb67785..39451dcd 100644 --- a/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h +++ b/kernel/arch/dreamcast/include/dc/sound/sfxmgr.h @@ -2,7 +2,7 @@ dc/sound/sfxmgr.h Copyright (C) 2002 Megan Potter - Copyright (C) 2023 Ruslan Rostovtsev + Copyright (C) 2023, 2024 Ruslan Rostovtsev Copyright (C) 2023 Andy Barajas */ @@ -30,6 +30,7 @@ __BEGIN_DECLS #include <arch/types.h> +#include <kos/fs.h> #include <stdint.h> /** \defgroup audio_sfx Sound Effects @@ -68,6 +69,43 @@ typedef uint32_t sfxhnd_t; */ sfxhnd_t snd_sfx_load(const char *fn); +/** \brief Load a sound effect without wav header. + + This function loads a sound effect from a RAW file and returns a handle to + it. The sound effect can be either stereo or mono, and must either be 8-bit + or 16-bit uncompressed PCM samples, or 4-bit Yamaha ADPCM. + + \warning The sound effect you are loading must be at most 65534 samples + in length and multiple by 32 bytes for each channel. + + \param fn The file to load. + \param rate The frequency of the sound. + \param bitsize The sample size (bits per sample). + \param channels Number of channels. + \return A handle to the sound effect on success. On error, + SFXHND_INVALID is returned. +*/ +sfxhnd_t snd_sfx_load_ex(const char *fn, uint32_t rate, uint16_t bitsize, uint16_t channels); + +/** \brief Load a sound effect without wav header by file handler. + + This function loads a sound effect from a RAW file and returns a handle to + it. The sound effect can be either stereo or mono, and must either be 8-bit + or 16-bit uncompressed PCM samples, or 4-bit Yamaha ADPCM. + + \warning The sound effect you are loading must be at most 65534 samples + in length and multiple by 32 bytes for each channel. + + \param fd The file handler. + \param len The file length. + \param rate The frequency of the sound. + \param bitsize The sample size (bits per sample). + \param channels Number of channels. + \return A handle to the sound effect on success. On error, + SFXHND_INVALID is returned. +*/ +sfxhnd_t snd_sfx_load_fd(file_t fd, size_t len, uint32_t rate, uint16_t bitsize, uint16_t channels); + /** \brief Unload a sound effect. This function unloads a previously loaded sound effect, and frees the memory diff --git a/kernel/arch/dreamcast/include/dc/sound/stream.h b/kernel/arch/dreamcast/include/dc/sound/stream.h index 38dd622c..80395f06 100644 --- a/kernel/arch/dreamcast/include/dc/sound/stream.h +++ b/kernel/arch/dreamcast/include/dc/sound/stream.h @@ -3,7 +3,7 @@ dc/sound/stream.h Copyright (C) 2002, 2004 Megan Potter Copyright (C) 2020 Lawrence Sebald - Copyright (C) 2023 Ruslan Rostovtsev + Copyright (C) 2023, 2024 Ruslan Rostovtsev */ @@ -71,6 +71,21 @@ typedef int snd_stream_hnd_t; typedef void *(*snd_stream_callback_t)(snd_stream_hnd_t hnd, int smp_req, int *smp_recv); +/** \brief Direct stream data transfer callback type. + + Functions for providing stream data will be of this type, and can be + registered with snd_stream_set_callback_direct(). + + \param hnd The stream handle being referred to. + \param left Left channel buffer address on AICA side. + \param right Right channel buffer address on AICA side. + \param size_req Requested size for each channel. + \retval -1 On failure. + \retval size_recv On success, received size. +*/ +typedef size_t (*snd_stream_callback_direct_t)(snd_stream_hnd_t hnd, + uintptr_t left, uintptr_t right, size_t size_req); + /** \brief Set the callback for a given stream. This function sets the get data callback function for a given stream, @@ -81,6 +96,16 @@ typedef void *(*snd_stream_callback_t)(snd_stream_hnd_t hnd, int smp_req, */ void snd_stream_set_callback(snd_stream_hnd_t hnd, snd_stream_callback_t cb); +/** \brief Set the callback for a given stream with direct transfer. + + This function sets the get data callback function for a given stream, + overwriting any old callback that may have been in place. + + \param hnd The stream handle for the callback. + \param cb A pointer to the callback function. +*/ +void snd_stream_set_callback_direct(snd_stream_hnd_t hnd, snd_stream_callback_direct_t cb); + /** \brief Set the user data for a given stream. This function sets the user data pointer for the given stream, overwriting @@ -177,6 +202,19 @@ void snd_stream_prefill(snd_stream_hnd_t hnd); */ int snd_stream_init(void); +/** \brief Initialize the stream system with limits. + + The same as \ref snd_stream_init but it can either reduce or not allocate + the buffer for splitting the stereo stream at all. + + \param channels Max channels for any streams. + \param buffer_size Max channel buffer size for any streams. + + \retval -1 On failure. + \retval 0 On success. +*/ +int snd_stream_init_ex(int channels, size_t buffer_size); + /** \brief Shut down the stream system. This function shuts down the stream system and frees the memory associated @@ -189,7 +227,7 @@ void snd_stream_shutdown(void); This function allocates a stream and sets its parameters. \param cb The get data callback for the stream. - \param bufsize The size of the buffer for the stream. + \param bufsize The size of the buffer for each channel of the stream. \return A handle to the new stream on success, SND_STREAM_INVALID on failure. */ @@ -309,6 +347,16 @@ int snd_stream_poll(snd_stream_hnd_t hnd); */ void snd_stream_volume(snd_stream_hnd_t hnd, int vol); +/** \brief Set the panning on the stream. + + This function sets the panning of the specified stream. + + \param hnd The stream to set volume on. + \param left_pan The left panning to set. Valid values are 0-255. + \param right_pan The right panning to set. Valid values are 0-255. +*/ +void snd_stream_pan(snd_stream_hnd_t hnd, int left_pan, int right_pan); + /** @} */ __END_DECLS diff --git a/kernel/arch/dreamcast/include/dc/spu.h b/kernel/arch/dreamcast/include/dc/spu.h index ee081100..b2232093 100644 --- a/kernel/arch/dreamcast/include/dc/spu.h +++ b/kernel/arch/dreamcast/include/dc/spu.h @@ -2,7 +2,7 @@ dc/spu.h Copyright (C) 2000, 2001 Megan Potter - Copyright (C) 2023 Ruslan Rostovtsev + Copyright (C) 2023, 2024 Ruslan Rostovtsev */ @@ -47,7 +47,7 @@ __BEGIN_DECLS void spu_memload(uintptr_t to, void *from, size_t length); -/** \brief Copy a block of data to sound RAM. +/** \brief Copy a block of data to sound RAM by using the Store Queues. This function acts much like memcpy() but copies to the sound RAM area by using the Store Queues. @@ -60,6 +60,18 @@ void spu_memload(uintptr_t to, void *from, size_t length); */ void spu_memload_sq(uintptr_t to, void *from, size_t length); +/** \brief Copy a block of data to sound RAM by using DMA (or SQ on fails). + + This function acts much like memcpy() but copies to the sound RAM area + by using the DMA. If DMA fails, then will be used the Store Queues. + + \param to The offset in sound RAM to copy to. Do not include + the 0xA0800000 part, it is implied. + \param from A pointer to copy from. + \param length The number of bytes to copy. Must be a multiple of 32. +*/ +void spu_memload_dma(uintptr_t to, void *from, size_t length); + /** \brief Copy a block of data from sound RAM. This function acts much like memcpy() but copies from the sound RAM area. diff --git a/kernel/arch/dreamcast/sound/snd_pcm_split.s b/kernel/arch/dreamcast/sound/snd_pcm_split.s index 089b568c..2fd6faec 100644 --- a/kernel/arch/dreamcast/sound/snd_pcm_split.s +++ b/kernel/arch/dreamcast/sound/snd_pcm_split.s @@ -1,7 +1,7 @@ ! KallistiOS ##version## ! ! arch/dreamcast/sound/snd_pcm_split.s -! Copyright (C) 2023 Ruslan Rostovtsev +! Copyright (C) 2023, 2024 Ruslan Rostovtsev ! ! Optimized SH4 assembler code for separating stereo 8/16-bit PCM and ! stereo 4-bit ADPCM into independent single channels. @@ -67,7 +67,7 @@ _snd_pcm16_split: ! ! void snd_pcm8_split(uint32_t *data, uint32_t *left, uint32_t *right, size_t size); ! - .align 2 + .align 2 _snd_pcm8_split: mov #-5, r1 shld r1, r7 @@ -94,44 +94,216 @@ _snd_pcm8_split: ! ! void snd_adpcm_split(uint32_t *data, uint32_t *left, uint32_t *right, size_t size); ! - .align 2 + .align 2 _snd_adpcm_split: mov #-5, r1 shld r1, r7 + mov.l r8, @-r15 + mov.l r9, @-r15 mov.l r10, @-r15 - mov #16, r1 + mov.l r11, @-r15 + mov #4, r1 + mov #15, r11 .adpcm_pref: add #32, r4 pref @r4 add #-32, r4 .adpcm_copy: dt r1 - mov.w @r4+, r10 - mov r10, r0 - and #0xf0, r0 - mov r0, r2 - shlr2 r2 - mov r10, r0 - shlr2 r2 - and #0x0f, r0 + !!! src = *data++; + mov.l @r4+, r0 + + !!! dst_r = src & 0xf mov r0, r3 - shlr8 r10 - mov r10, r0 - and #0xf0, r0 - or r0, r2 - mov.b r2, @r5 - add #1, r5 - mov r10, r0 - and #0x0f, r0 - shll2 r0 - shll2 r0 - or r0, r3 - mov.b r3, @r6 + and r11, r3 + + !!! src >>= 4 + mov #-4, r10 + shld r10, r0 + + !!! dst_l = src & 0xf + mov r0, r2 + and r11, r2 + + !!! src >>= 4 + shld r10, r0 + + !!! tmp_r = src & 0xf + mov r0, r9 + and r11, r9 + + !!! src >>= 4 + shld r10, r0 + + !!! tmp_l = src & 0xf + mov r0, r8 + and r11, r8 + + !!! src >>= 4 + shld r10, r0 + + !!! tmp <<= 4, + mov #4, r10 + shld r10, r9 + shld r10, r8 + + !!! dst |= tmp + or r9, r3 + or r8, r2 + + !!! tmp_r = src & 0xf + mov r0, r9 + and r11, r9 + ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-12 07:04:01
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 45525d79ba9ec9a3dd17f45a8ed3c4cf8bf77053 (commit) from 0b6686cdbee523cf32968c20faaa12f3174a64f4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 45525d79ba9ec9a3dd17f45a8ed3c4cf8bf77053 Author: Donald Haase <qu...@ya...> Date: Sat Oct 12 03:03:23 2024 -0400 * Refactor and cleanup of IRQ system. (#815) * Authored by Falco Girgis * Retype interrupt codes to an enum. * Use stdint and bool types where possible. * Various minor code cleanups. * Restructure layout and doxygen in header. * Clean up register accesses in irq.c to match other drivers. * Retype global handler into proper irq_cb type. Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/arch/irq.h | 582 +++++++++++++++++-------------- kernel/arch/dreamcast/kernel/irq.c | 126 ++++--- 2 files changed, 374 insertions(+), 334 deletions(-) diff --git a/kernel/arch/dreamcast/include/arch/irq.h b/kernel/arch/dreamcast/include/arch/irq.h index 0d3ce1c4..54c46889 100644 --- a/kernel/arch/dreamcast/include/arch/irq.h +++ b/kernel/arch/dreamcast/include/arch/irq.h @@ -2,10 +2,12 @@ arch/dreamcast/include/irq.h Copyright (C) 2000-2001 Megan Potter + Copyright (C) 2024 Paul Cercueil + Copyright (C) 2024 Falco Girgis */ -/** \file arch/irq.h +/** \file \brief Interrupt and exception handling. \ingroup irqs @@ -15,12 +17,16 @@ actually differentiating "external" interrupts. \author Megan Potter - \see dc/asic.h + \author Paul Cercueil + \author Falco Girgis + + \see dc/asic.h, arch/trap.h */ #ifndef __ARCH_IRQ_H #define __ARCH_IRQ_H +#include <stdbool.h> #include <stdint.h> #include <sys/cdefs.h> __BEGIN_DECLS @@ -33,218 +39,222 @@ __BEGIN_DECLS /** \defgroup irqs Interrupts \brief IRQs and ISRs for the SH4's CPU \ingroup system + + This is an API for managing interrupts, their masks, and their + handler routines along with thread context information. + + \warning + This is a low-level, internal kernel API. Many of these + interrupts are utilized by various KOS drivers and have higher-level APIs + for hooking into them. Care must be taken to not interfere with the IRQ + handling which is being done by in-use KOS drivers. + + @{ */ -/** \brief The number of bytes required to save thread context. - \ingroup irqs +/** \defgroup Context + \brief Thread execution state and accessors + + This API includes the structure and accessors for a + thread's context state, which contains the registers that are stored + and loaded upon thread context switches, which are passed back to + interrupt handlers. + + @{ +*/ + +/** The number of bytes required to save thread context. This should include all general CPU registers, FP registers, and status regs (even if not all of these are actually used). - On the Dreamcast, we need 228 bytes for all of that, but we round it up to a + \note + On the Dreamcast, we need `228` bytes for all of that, but we round it up to a nicer number for sanity. */ -#define REG_BYTE_CNT 256 /* Currently really 228 */ +#define REG_BYTE_CNT 256 -/** \brief Architecture-specific structure for holding the processor state. - \ingroup irqs +/** Architecture-specific structure for holding the processor state. This structure should hold register values and other important parts of the - processor state. The size of this structure should be less than or equal - to the REG_BYTE_CNT value. - - \headerfile arch/irq.h -*/ -typedef struct irq_context { - uint32_t pc; /**< \brief Program counter */ - uint32_t pr; /**< \brief Procedure register (aka return address) */ - uint32_t gbr; /**< \brief Global base register */ - uint32_t vbr; /**< \brief Vector base register */ - uint32_t mach; /**< \brief Multiply-and-accumulate register (high) */ - uint32_t macl; /**< \brief Multiply-and-accumulate register (low) */ - uint32_t sr; /**< \brief Status register */ - uint32_t fpul; /**< \brief Floatint-point communication register */ - uint32_t fr[16]; /**< \brief Primary floating point registers */ - uint32_t frbank[16]; /**< \brief Secondary floating point registers */ - uint32_t r[16]; /**< \brief 16 general purpose (integer) registers */ - uint32_t fpscr; /**< \brief Floating-point status/control register */ -} irq_context_t __attribute__((aligned(32))); - -/* A couple of architecture independent access macros */ -/** \brief Fetch the program counter from an irq_context_t. - \ingroup irqs - + processor state. + + \note + The size of this structure should be less than or equal to the + \ref REG_BYTE_CNT value. +*/ +typedef __attribute__((aligned(32))) struct irq_context { + uint32_t pc; /**< Program counter */ + uint32_t pr; /**< Procedure register (aka return address) */ + uint32_t gbr; /**< Global base register (TLS segment ptr) */ + uint32_t vbr; /**< Vector base register */ + uint32_t mach; /**< Multiply-and-accumulate register (high) */ + uint32_t macl; /**< Multiply-and-accumulate register (low) */ + uint32_t sr; /**< Status register */ + uint32_t fpul; /**< Floating-point communication register */ + uint32_t fr[16]; /**< Primary floating point registers */ + uint32_t frbank[16]; /**< Secondary floating point registers */ + uint32_t r[16]; /**< 16 general purpose (integer) registers */ + uint32_t fpscr; /**< Floating-point status/control register */ +} irq_context_t; + +/** \name Register Accessors + \brief Convenience macros for accessing context registers + @{ +*/ +/** Fetch the program counter from an irq_context_t. \param c The context to read from. - \return The program counter value. */ #define CONTEXT_PC(c) ((c).pc) -/** \brief Fetch the frame pointer from an irq_context_t. - \ingroup irqs - +/** Fetch the frame pointer from an irq_context_t. \param c The context to read from. - \return The frame pointer value. */ #define CONTEXT_FP(c) ((c).r[14]) -/** \brief Fetch the stack pointer from an irq_context_t. - \ingroup irqs - +/** Fetch the stack pointer from an irq_context_t. \param c The context to read from. - \return The stack pointer value. */ #define CONTEXT_SP(c) ((c).r[15]) -/** \brief Fetch the return value from an irq_context_t. - \ingroup irqs - +/** Fetch the return value from an irq_context_t. \param c The context to read from. - \return The return value. */ #define CONTEXT_RET(c) ((c).r[0]) +/** @} */ -/** \defgroup irq_exception_codes Exception Codes - \brief IRQ exception code values - \ingroup irqs - - These are all of the exceptions that can be raised on the SH4, and their - codes. They're divided into several logical groups. +/** Switch out contexts (for interrupt return). - @{ -*/ -/* Dreamcast-specific exception codes.. use these when getting or setting an - exception code value. */ - -/** \defgroup irq_reset_codes Reset Type - \brief IRQ reset type codes + This function will set the processor state that will be restored when the + exception returns. - These are exceptions that essentially cause a reset of the system. They - cannot actually be caught by normal means. They will all automatically cause - a branch to address 0xA0000000. These are pretty much fatal. + \param regbank The values of all registers to be restored. - @{ + \sa irq_get_context() */ -#define EXC_RESET_POWERON 0x0000 /**< \brief Power-on reset */ -#define EXC_RESET_MANUAL 0x0020 /**< \brief Manual reset */ -#define EXC_RESET_UDI 0x0000 /**< \brief Hitachi UDI reset */ -#define EXC_ITLB_MULTIPLE 0x0140 /**< \brief Instruction TLB multiple hit */ -#define EXC_DTLB_MULTIPLE 0x0140 /**< \brief Data TLB multiple hit */ -/** @} */ - -/** \defgroup irq_reexec_codes Re-Execution Type - \brief IRQ re-execution type codes - - These exceptions will stop the currently processing instruction, and - transition into exception processing. After handling the exception (assuming - that it can be handled by the code), the offending instruction will be - re-executed from the start. +void irq_set_context(irq_context_t *regbank); - @{ -*/ -#define EXC_USER_BREAK_PRE 0x01e0 /**< \brief User break before instruction */ -#define EXC_INSTR_ADDRESS 0x00e0 /**< \brief Instruction address */ -#define EXC_ITLB_MISS 0x0040 /**< \brief Instruction TLB miss */ -#define EXC_ITLB_PV 0x00a0 /**< \brief Instruction TLB protection violation */ -#define EXC_ILLEGAL_INSTR 0x0180 /**< \brief Illegal instruction */ -#define EXC_SLOT_ILLEGAL_INSTR 0x01a0 /**< \brief Slot illegal instruction */ -#define EXC_GENERAL_FPU 0x0800 /**< \brief General FPU exception */ -#define EXC_SLOT_FPU 0x0820 /**< \brief Slot FPU exception */ -#define EXC_DATA_ADDRESS_READ 0x00e0 /**< \brief Data address (read) */ -#define EXC_DATA_ADDRESS_WRITE 0x0100 /**< \brief Data address (write) */ -#define EXC_DTLB_MISS_READ 0x0040 /**< \brief Data TLB miss (read) */ -#define EXC_DTLB_MISS_WRITE 0x0060 /**< \brief Data TLB miss (write) */ -#define EXC_DTLB_PV_READ 0x00a0 /**< \brief Data TLB protection violation (read) */ -#define EXC_DTLB_PV_WRITE 0x00c0 /**< \brief Data TLB protection violation (write) */ -#define EXC_FPU 0x0120 /**< \brief FPU exception */ -#define EXC_INITIAL_PAGE_WRITE 0x0080 /**< \brief Initial page write exception */ -/** @} */ +/** Get the current IRQ context. -/** \defgroup irq_completion_codes Completion Type - \brief IRQ completion type codes + This will fetch the processor context prior to the exception handling during + an IRQ service routine. - These exceptions are actually handled in-between instructions, allowing the - instruction that causes them to finish completely. The saved PC thus is the - value of the next instruction. + \return The current IRQ context. - @{ + \sa irq_set_context() */ -#define EXC_TRAPA 0x0160 /**< \brief Unconditional trap (trapa) */ -#define EXC_USER_BREAK_POST 0x01e0 /**< \brief User break after instruction */ -/** @} */ - -/** \defgroup irq_interrupt_codes Interrupt (Completion Type) - \brief IRQ interrupt completiion type codes +irq_context_t *irq_get_context(void); - \note Not all of these have any meaning on the Dreamcast. Those that have - no meaning are only included for completeness. +/** Fill a newly allocated context block. - These exceptions are caused by interrupt requests. These generally are from - peripheral devices, but NMIs, timer interrupts, and DMAC interrupts are also - included here. + The given parameters will be passed to the called routine (up to the + architecture maximum). For the Dreamcast, this maximum is 4. - @{ + \param context The IRQ context to fill in. + \param stack_pointer The value to set in the stack pointer. + \param routine The address of the program counter for the context. + \param args Any arguments to set in the registers. This cannot + be NULL, and must have enough values to fill in up + to the architecture maximum. + \param usermode true to run the routine in user mode, false for + supervisor. */ -#define EXC_NMI 0x01c0 /**< \brief Nonmaskable interrupt */ -#define EXC_IRQ0 0x0200 /**< \brief External IRQ request (level 0) */ -#define EXC_IRQ1 0x0220 /**< \brief External IRQ request (level 1) */ -#define EXC_IRQ2 0x0240 /**< \brief External IRQ request (level 2) */ -#define EXC_IRQ3 0x0260 /**< \brief External IRQ request (level 3) */ -#define EXC_IRQ4 0x0280 /**< \brief External IRQ request (level 4) */ -#define EXC_IRQ5 0x02a0 /**< \brief External IRQ request (level 5) */ -#define EXC_IRQ6 0x02c0 /**< \brief External IRQ request (level 6) */ -#define EXC_IRQ7 0x02e0 /**< \brief External IRQ request (level 7) */ -#define EXC_IRQ8 0x0300 /**< \brief External IRQ request (level 8) */ -#define EXC_IRQ9 0x0320 /**< \brief External IRQ request (level 9) */ -#define EXC_IRQA 0x0340 /**< \brief External IRQ request (level 10) */ -#define EXC_IRQB 0x0360 /**< \brief External IRQ request (level 11) */ -#define EXC_IRQC 0x0380 /**< \brief External IRQ request (level 12) */ -#define EXC_IRQD 0x03a0 /**< \brief External IRQ request (level 13) */ -#define EXC_IRQE 0x03c0 /**< \brief External IRQ request (level 14) */ -#define EXC_TMU0_TUNI0 0x0400 /**< \brief TMU0 underflow */ -#define EXC_TMU1_TUNI1 0x0420 /**< \brief TMU1 underflow */ -#define EXC_TMU2_TUNI2 0x0440 /**< \brief TMU2 underflow */ -#define EXC_TMU2_TICPI2 0x0460 /**< \brief TMU2 input capture */ -#define EXC_RTC_ATI 0x0480 /**< \brief RTC alarm interrupt */ -#define EXC_RTC_PRI 0x04a0 /**< \brief RTC periodic interrupt */ -#define EXC_RTC_CUI 0x04c0 /**< \brief RTC carry interrupt */ -#define EXC_SCI_ERI 0x04e0 /**< \brief SCI Error receive */ -#define EXC_SCI_RXI 0x0500 /**< \brief SCI Receive ready */ -#define EXC_SCI_TXI 0x0520 /**< \brief SCI Transmit ready */ -#define EXC_SCI_TEI 0x0540 /**< \brief SCI Transmit error */ -#define EXC_WDT_ITI 0x0560 /**< \brief Watchdog timer */ -#define EXC_REF_RCMI 0x0580 /**< \brief Memory refresh compare-match interrupt */ -#define EXC_REF_ROVI 0x05a0 /**< \brief Memory refresh counter overflow interrupt */ -#define EXC_UDI 0x0600 /**< \brief Hitachi UDI */ -#define EXC_GPIO_GPIOI 0x0620 /**< \brief I/O port interrupt */ -#define EXC_DMAC_DMTE0 0x0640 /**< \brief DMAC transfer end (channel 0) */ -#define EXC_DMAC_DMTE1 0x0660 /**< \brief DMAC transfer end (channel 1) */ -#define EXC_DMAC_DMTE2 0x0680 /**< \brief DMAC transfer end (channel 2) */ -#define EXC_DMAC_DMTE3 0x06a0 /**< \brief DMAC transfer end (channel 3) */ -#define EXC_DMA_DMAE 0x06c0 /**< \brief DMAC address error */ -#define EXC_SCIF_ERI 0x0700 /**< \brief SCIF Error receive */ -#define EXC_SCIF_RXI 0x0720 /**< \brief SCIF Receive ready */ -#define EXC_SCIF_BRI 0x0740 /**< \brief SCIF break */ -#define EXC_SCIF_TXI 0x0760 /**< \brief SCIF Transmit ready */ -/** @} */ - -/** \brief Double fault +void irq_create_context(irq_context_t *context, uint32_t stack_pointer, + uint32_t routine, const uint32_t *args, bool usermode); - This exception is completely done in software (not represented on the CPU at - all). Its used for when an exception occurs during an IRQ service routine. -*/ -#define EXC_DOUBLE_FAULT 0x0ff0 +/** @} */ -/** \brief Unhandled exception +/** Interrupt exception codes + + Dreamcast-specific exception codes. Used to identify the source or type of + an interrupt. Each exception code is of a certain "type" which dictates how the interrupt + is generated and handled. + + List of exception types: + + |Type | Description + |--------|------------ + |`RESET` | Caused by system reset. Uncatchable and fatal. Automatically branch to address `0xA0000000`. + |`REEXEC`| Restarts current instruction after interrupt processing. Context PC is the triggering instruction. + |`POST` | Continues with next instruciton after interrupt processing. Context PC is the next instruction. + |`SOFT` | Software-driven exceptions for triggering interrupts upon special events. + |`UNUSED`| Known to not be present and usable with the DC's SH4 configuration. + + List of exception codes: +*/ +typedef enum irq_exception { + EXC_RESET_POWERON = 0x0000, /**< `[RESET ]` Power-on reset */ + EXC_RESET_MANUAL = 0x0020, /**< `[RESET ]` Manual reset */ + EXC_RESET_UDI = 0x0000, /**< `[RESET ]` Hitachi UDI reset */ + EXC_ITLB_MULTIPLE = 0x0140, /**< `[RESET ]` Instruction TLB multiple hit */ + EXC_DTLB_MULTIPLE = 0x0140, /**< `[RESET ]` Data TLB multiple hit */ + EXC_USER_BREAK_PRE = 0x01e0, /**< `[REEXEC]` User break before instruction */ + EXC_INSTR_ADDRESS = 0x00e0, /**< `[REEXEC]` Instruction address */ + EXC_ITLB_MISS = 0x0040, /**< `[REEXEC]` Instruction TLB miss */ + EXC_ITLB_PV = 0x00a0, /**< `[REEXEC]` Instruction TLB protection violation */ + EXC_ILLEGAL_INSTR = 0x0180, /**< `[REEXEC]` Illegal instruction */ + EXC_SLOT_ILLEGAL_INSTR = 0x01a0, /**< `[REEXEC]` Slot illegal instruction */ + EXC_GENERAL_FPU = 0x0800, /**< `[REEXEC]` General FPU exception */ + EXC_SLOT_FPU = 0x0820, /**< `[REEXEC]` Slot FPU exception */ + EXC_DATA_ADDRESS_READ = 0x00e0, /**< `[REEXEC]` Data address (read) */ + EXC_DATA_ADDRESS_WRITE = 0x0100, /**< `[REEXEC]` Data address (write) */ + EXC_DTLB_MISS_READ = 0x0040, /**< `[REEXEC]` Data TLB miss (read) */ + EXC_DTLB_MISS_WRITE = 0x0060, /**< `[REEXEC]` Data TLB miss (write) */ + EXC_DTLB_PV_READ = 0x00a0, /**< `[REEXEC]` Data TLB protection violation (read) */ + EXC_DTLB_PV_WRITE = 0x00c0, /**< `[REEXEC]` Data TLB protection violation (write) */ + EXC_FPU = 0x0120, /**< `[REEXEC]` FPU exception */ + EXC_INITIAL_PAGE_WRITE = 0x0080, /**< `[REEXEC]` Initial page write exception */ + EXC_TRAPA = 0x0160, /**< `[POST ]` Unconditional trap (`TRAPA`) */ + EXC_USER_BREAK_POST = 0x01e0, /**< `[POST ]` User break after instruction */ + EXC_NMI = 0x01c0, /**< `[POST ]` Nonmaskable interrupt */ + EXC_IRQ0 = 0x0200, /**< `[POST ]` External IRQ request (level 0) */ + EXC_IRQ1 = 0x0220, /**< `[POST ]` External IRQ request (level 1) */ + EXC_IRQ2 = 0x0240, /**< `[POST ]` External IRQ request (level 2) */ + EXC_IRQ3 = 0x0260, /**< `[POST ]` External IRQ request (level 3) */ + EXC_IRQ4 = 0x0280, /**< `[POST ]` External IRQ request (level 4) */ + EXC_IRQ5 = 0x02a0, /**< `[POST ]` External IRQ request (level 5) */ + EXC_IRQ6 = 0x02c0, /**< `[POST ]` External IRQ request (level 6) */ + EXC_IRQ7 = 0x02e0, /**< `[POST ]` External IRQ request (level 7) */ + EXC_IRQ8 = 0x0300, /**< `[POST ]` External IRQ request (level 8) */ + EXC_IRQ9 = 0x0320, /**< `[POST ]` External IRQ request (level 9) */ + EXC_IRQA = 0x0340, /**< `[POST ]` External IRQ request (level 10) */ + EXC_IRQB = 0x0360, /**< `[POST ]` External IRQ request (level 11) */ + EXC_IRQC = 0x0380, /**< `[POST ]` External IRQ request (level 12) */ + EXC_IRQD = 0x03a0, /**< `[POST ]` External IRQ request (level 13) */ + EXC_IRQE = 0x03c0, /**< `[POST ]` External IRQ request (level 14) */ + EXC_TMU0_TUNI0 = 0x0400, /**< `[POST ]` TMU0 underflow */ + EXC_TMU1_TUNI1 = 0x0420, /**< `[POST ]` TMU1 underflow */ + EXC_TMU2_TUNI2 = 0x0440, /**< `[POST ]` TMU2 underflow */ + EXC_TMU2_TICPI2 = 0x0460, /**< `[UNUSED]` TMU2 input capture */ + EXC_RTC_ATI = 0x0480, /**< `[UNUSED]` RTC alarm interrupt */ + EXC_RTC_PRI = 0x04a0, /**< `[UNUSED]` RTC periodic interrupt */ + EXC_RTC_CUI = 0x04c0, /**< `[UNUSED]` RTC carry interrupt */ + EXC_SCI_ERI = 0x04e0, /**< `[UNUSED]` SCI Error receive */ + EXC_SCI_RXI = 0x0500, /**< `[UNUSED]` SCI Receive ready */ + EXC_SCI_TXI = 0x0520, /**< `[UNUSED]` SCI Transmit ready */ + EXC_SCI_TEI = 0x0540, /**< `[UNUSED]` SCI Transmit error */ + EXC_WDT_ITI = 0x0560, /**< `[POST ]` Watchdog timer */ + EXC_REF_RCMI = 0x0580, /**< `[POST ]` Memory refresh compare-match interrupt */ + EXC_REF_ROVI = 0x05a0, /**< `[POST ]` Memory refresh counter overflow interrupt */ + EXC_UDI = 0x0600, /**< `[POST ]` Hitachi UDI */ + EXC_GPIO_GPIOI = 0x0620, /**< `[POST ]` I/O port interrupt */ + EXC_DMAC_DMTE0 = 0x0640, /**< `[POST ]` DMAC transfer end (channel 0) */ + EXC_DMAC_DMTE1 = 0x0660, /**< `[POST ]` DMAC transfer end (channel 1) */ + EXC_DMAC_DMTE2 = 0x0680, /**< `[POST ]` DMAC transfer end (channel 2) */ + EXC_DMAC_DMTE3 = 0x06a0, /**< `[POST ]` DMAC transfer end (channel 3) */ + EXC_DMA_DMAE = 0x06c0, /**< `[POST ]` DMAC address error */ + EXC_SCIF_ERI = 0x0700, /**< `[POST ]` SCIF Error receive */ + EXC_SCIF_RXI = 0x0720, /**< `[POST ]` SCIF Receive ready */ + EXC_SCIF_BRI = 0x0740, /**< `[POST ]` SCIF break */ + EXC_SCIF_TXI = 0x0760, /**< `[POST ]` SCIF Transmit ready */ + EXC_DOUBLE_FAULT = 0x0ff0, /**< `[SOFT ]` Exception happened in an ISR */ + EXC_UNHANDLED_EXC = 0x0fe0 /**< `[SOFT ]` Exception went unhandled */ +} irq_t; - This exception is a software-generated exception for a generic unhandled - exception. -*/ -#define EXC_UNHANDLED_EXC 0x0fe0 -/** @} */ /** \defgroup irq_type_offsets Exception type offsets \brief Offsets within exception types @@ -266,64 +276,157 @@ typedef struct irq_context { */ #define TIMER_IRQ EXC_TMU0_TUNI0 -/** \brief The type of an interrupt identifier - \ingroup irqs -*/ -typedef uint32_t irq_t; +/** \defgroup irq_state State + \brief Methods for querying active IRQ information. -/** \brief The type of an IRQ handler - \ingroup irqs + Provides an API for accessing the state of the current IRQ context such + as the active interrupt or whether it has been handled. - \param source The IRQ that caused the handler to be called. - \param context The CPU's context. + @{ */ -typedef void (*irq_handler)(irq_t source, irq_context_t *context, void *data); -/** \brief Are we inside an interrupt handler? - \ingroup irqs - \retval 1 If interrupt handling is in progress. +/** Returns whether inside of an interrupt context. + + \retval non-zero If interrupt handling is in progress. + ((code&0xf)<<16) | (evt&0xffff) \retval 0 If normal processing is in progress. + */ int irq_inside_int(void); -/** \brief Pretend like we just came in from an interrupt and force - a context switch back to the "current" context. - \ingroup irqs +/** @} */ + +/** \defgroup irq_mask Mask + \brief Accessors and modifiers of the IMASK state. + + This API is provided for managing and querying information regarding the + interrupt mask, a series of bitflags representing whether each type of + interrupt has been enabled or not. + + @{ +*/ + +/** Type representing an interrupt mask state. */ +typedef uint32_t irq_mask_t; +/** Disable interrupts. + + This function will disable interrupts, but will leave exceptions enabled. + + \return The state of IRQs before calling the function. This + can be used to restore this state later on with + irq_restore(). + + \sa irq_restore(), irq_enable() +*/ +irq_mask_t irq_disable(void); + +/** Enable all interrupts. + + This function will enable ALL interrupts, including external ones. + + \sa irq_disable() +*/ +void irq_enable(void); + +/** Restore IRQ state. + + This function will restore the interrupt state to the value specified. This + should correspond to a value returned by irq_disable(). + + \param v The IRQ state to restore. This should be a value + returned by irq_disable(). + + \sa irq_disable() +*/ +void irq_restore(irq_mask_t v); + ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-12 07:03:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, irq_cleanup_2 has been created at db0216a06395840a6ca7930643dd650d893b216f (commit) - Log ----------------------------------------------------------------- commit db0216a06395840a6ca7930643dd650d893b216f Author: QuzarDC <qu...@co...> Date: Sat Oct 12 00:44:12 2024 -0400 * Refactor and cleanup of IRQ system. * Authored by Falco Girgis * Retype interrupt codes to an enum. * Use stdint and bool types where possible. * Various minor code cleanups. * Restructure layout and doxygen in header. * Clean up register accesses in irq.c to match other drivers. * Retype global handler into proper irq_cb type. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-12 05:34:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 0b6686cdbee523cf32968c20faaa12f3174a64f4 (commit) from fab5f404c7abe0ee593dd8d9b105cc5d11f71d50 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0b6686cdbee523cf32968c20faaa12f3174a64f4 Author: Donald Haase <qu...@ya...> Date: Sat Oct 12 01:33:50 2024 -0400 Minor cleanups in FS (#595) * Correct typo in documentation for d_type. * On shutdown, ensure we don't accidentally race against other fs changes by locking the fh table mutex. Use TAILQ_FOREACH_SAFE whose pattern was being manually implemented. * De-magic FH 0/-1 markers. De-magic fs constants from genromfs. Switch dir to be a bool rather than int. Clean up some comments. Remove unneeded temp flag in unmount. Implement write and unlink that provide more contextual errnos. * Clean up FH comments. Set dir and broken to be bools as they are ints that are always 0 or 1. * Remove duplicated setting of errno = EBADF. These are set within fs_map_hnd already. Additionally normalize the relevant error checking of fs_map_hnd throughout. --------- Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: include/sys/dirent.h | 2 +- kernel/arch/dreamcast/fs/fs_iso9660.c | 16 +++--- kernel/arch/dreamcast/fs/fs_vmu.c | 7 +-- kernel/fs/fs.c | 58 +++++++------------ kernel/fs/fs_null.c | 9 ++- kernel/fs/fs_random.c | 9 ++- kernel/fs/fs_romdisk.c | 104 +++++++++++++++++++++++----------- 7 files changed, 110 insertions(+), 95 deletions(-) diff --git a/include/sys/dirent.h b/include/sys/dirent.h index 37bff92f..61cdbceb 100644 --- a/include/sys/dirent.h +++ b/include/sys/dirent.h @@ -33,7 +33,7 @@ __BEGIN_DECLS */ /** \name Directory File Types - \brief POSIX file types for dirent::d_name + \brief POSIX file types for dirent::d_type \remark These directory entry types are not part of the POSIX specifican per-se, diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index 03e2930a..4b228bc5 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -573,11 +573,11 @@ static iso_dirent_t *find_object_path(const char *fn, int dir, iso_dirent_t *sta too lazy right now. =) */ static struct { uint32 first_extent; /* First sector */ - int dir; /* >0 if a directory */ - uint32 ptr; /* Current read position in bytes */ - uint32 size; /* Length of file in bytes */ - dirent_t dirent; /* A static dirent to pass back to clients */ - int broken; /* >0 if the CD has been swapped out since open */ + bool dir; /* True if a directory */ + uint32 ptr; /* Current read position in bytes */ + uint32 size; /* Length of file in bytes */ + dirent_t dirent; /* A static dirent to pass back to clients */ + bool broken; /* True if the CD has been swapped out since open */ } fh[FS_CD_MAX_FILES]; /* Mutex for file handles */ @@ -593,7 +593,7 @@ static void iso_break_all(void) { mutex_lock(&fh_mutex); for(i = 0; i < FS_CD_MAX_FILES; i++) - fh[i].broken = 1; + fh[i].broken = true; mutex_unlock(&fh_mutex); } @@ -645,10 +645,10 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) { /* Fill in the file handle and return the fd */ fh[fd].first_extent = iso_733(de->extent); - fh[fd].dir = (mode & O_DIR) ? 1 : 0; + fh[fd].dir = ((mode & O_DIR) != 0); fh[fd].ptr = 0; fh[fd].size = iso_733(de->size); - fh[fd].broken = 0; + fh[fd].broken = false; return (void *)fd; } diff --git a/kernel/arch/dreamcast/fs/fs_vmu.c b/kernel/arch/dreamcast/fs/fs_vmu.c index 6b691efc..817a20ee 100644 --- a/kernel/arch/dreamcast/fs/fs_vmu.c +++ b/kernel/arch/dreamcast/fs/fs_vmu.c @@ -748,10 +748,9 @@ int fs_vmu_init(void) { int fs_vmu_shutdown(void) { vmu_fh_t * c, * n; - c = TAILQ_FIRST(&vmu_fh); + mutex_lock(&fh_mutex); - while(c) { - n = TAILQ_NEXT(c, listent); + TAILQ_FOREACH_SAFE(c, &vmu_fh, listent, n) { switch(c->strtype) { case VMU_DIR: { @@ -772,9 +771,9 @@ int fs_vmu_shutdown(void) { } free(c); - c = n; } + mutex_unlock(&fh_mutex); mutex_destroy(&fh_mutex); return nmmgr_handler_remove(&vh.nmmgr); diff --git a/kernel/fs/fs.c b/kernel/fs/fs.c index 5969b251..572d94b0 100644 --- a/kernel/fs/fs.c +++ b/kernel/fs/fs.c @@ -333,19 +333,16 @@ static fs_hnd_t * fs_map_hnd(file_t fd) { /* Close a file and clean up the handle */ int fs_close(file_t fd) { int retval; - fs_hnd_t *hnd = fs_map_hnd(fd); + fs_hnd_t *h = fs_map_hnd(fd); - if(!hnd) { - errno = EBADF; - return -1; - } + if(!h) return -1; /* Deref it and remove it from our table */ - retval = fs_hnd_unref(hnd); + retval = fs_hnd_unref(h); /* Reset our position */ - if(hnd->refcnt == 0) - hnd->idx = 0; + if(h->refcnt == 0) + h->idx = 0; fd_table[fd] = NULL; return retval ? -1 : 0; @@ -355,7 +352,7 @@ int fs_close(file_t fd) { ssize_t fs_read(file_t fd, void *buffer, size_t cnt) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL || h->handler->read == NULL) { errno = EINVAL; @@ -370,7 +367,7 @@ ssize_t fs_write(file_t fd, const void *buffer, size_t cnt) { h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL || h->handler->write == NULL) { errno = EINVAL; @@ -383,7 +380,7 @@ ssize_t fs_write(file_t fd, const void *buffer, size_t cnt) { off_t fs_seek(file_t fd, off_t offset, int whence) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL) { errno = EINVAL; @@ -403,7 +400,7 @@ off_t fs_seek(file_t fd, off_t offset, int whence) { _off64_t fs_seek64(file_t fd, _off64_t offset, int whence) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL) { errno = EINVAL; @@ -423,7 +420,7 @@ _off64_t fs_seek64(file_t fd, _off64_t offset, int whence) { off_t fs_tell(file_t fd) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL) { errno = EINVAL; @@ -443,7 +440,7 @@ off_t fs_tell(file_t fd) { _off64_t fs_tell64(file_t fd) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL) { errno = EINVAL; @@ -463,7 +460,7 @@ _off64_t fs_tell64(file_t fd) { size_t fs_total(file_t fd) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL) { errno = EINVAL; @@ -483,7 +480,7 @@ size_t fs_total(file_t fd) { uint64 fs_total64(file_t fd) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL) { errno = EINVAL; @@ -505,10 +502,7 @@ dirent_t *fs_readdir(file_t fd) { static dirent_t *temp_dirent; fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) { - errno = EBADF; - return NULL; - } + if(!h) return NULL; if(h->handler == NULL) return fs_root_readdir(h); @@ -569,10 +563,7 @@ int fs_vioctl(file_t fd, int cmd, va_list ap) { fs_hnd_t *h = fs_map_hnd(fd); int rv; - if(!h) { - errno = EBADF; - return -1; - } + if(!h) return -1; if(!h->handler || !h->handler->ioctl) { errno = EINVAL; @@ -678,7 +669,7 @@ const char *fs_getwd(void) { void *fs_mmap(file_t fd) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return NULL; + if(!h) return NULL; if(h->handler == NULL || h->handler->mmap == NULL) { errno = EINVAL; @@ -691,7 +682,7 @@ void *fs_mmap(file_t fd) { int fs_complete(file_t fd, ssize_t * rv) { fs_hnd_t *h = fs_map_hnd(fd); - if(h == NULL) return -1; + if(!h) return -1; if(h->handler == NULL || h->handler->complete == NULL) { errno = EINVAL; @@ -745,10 +736,7 @@ static int fs_vfcntl(file_t fd, int cmd, va_list ap) { fs_hnd_t *h = fs_map_hnd(fd); int rv; - if(!h) { - errno = EBADF; - return -1; - } + if(!h) return -1; if(!h->handler || !h->handler->fcntl) { errno = ENOSYS; @@ -908,10 +896,7 @@ int fs_stat(const char *path, struct stat *buf, int flag) { int fs_rewinddir(file_t fd) { fs_hnd_t *h = fs_map_hnd(fd); - if(!h) { - errno = EBADF; - return -1; - } + if(!h) return -1; if(h->handler == NULL) { h->hnd = (void *)0; @@ -931,10 +916,7 @@ int fs_rewinddir(file_t fd) { int fs_fstat(file_t fd, struct stat *st) { fs_hnd_t *h = fs_map_hnd(fd); - if(!h) { - errno = EBADF; - return -1; - } + if(!h) return -1; if(!st) { errno = EFAULT; diff --git a/kernel/fs/fs_null.c b/kernel/fs/fs_null.c index d508b692..44a4fa50 100644 --- a/kernel/fs/fs_null.c +++ b/kernel/fs/fs_null.c @@ -258,15 +258,14 @@ int fs_null_init(void) { int fs_null_shutdown(void) { null_fh_t * c, * n; - /* First, clean up any open files */ - c = TAILQ_FIRST(&null_fh); + mutex_lock(&fh_mutex); - while(c) { - n = TAILQ_NEXT(c, listent); + /* First, clean up any open files */ + TAILQ_FOREACH_SAFE(c, &null_fh, listent, n) { free(c); - c = n; } + mutex_unlock(&fh_mutex); mutex_destroy(&fh_mutex); nmmgr_handler_remove(&vh.nmmgr); diff --git a/kernel/fs/fs_random.c b/kernel/fs/fs_random.c index e136a5f5..3d77f63a 100644 --- a/kernel/fs/fs_random.c +++ b/kernel/fs/fs_random.c @@ -334,15 +334,14 @@ int fs_rnd_init(void) { int fs_rnd_shutdown(void) { rnd_fh_t * c, * n; - /* First, clean up any open files */ - c = TAILQ_FIRST(&rnd_fh); + mutex_lock(&fh_mutex); - while(c) { - n = TAILQ_NEXT(c, listent); + /* First, clean up any open files */ + TAILQ_FOREACH_SAFE(c, &rnd_fh, listent, n) { free(c); - c = n; } + mutex_unlock(&fh_mutex); mutex_destroy(&fh_mutex); nmmgr_handler_remove(&vh.nmmgr); diff --git a/kernel/fs/fs_romdisk.c b/kernel/fs/fs_romdisk.c index b068352c..060313a5 100644 --- a/kernel/fs/fs_romdisk.c +++ b/kernel/fs/fs_romdisk.c @@ -22,31 +22,46 @@ on sunsite.unc.edu in /pub/Linux/system/recovery/, or as a package under Debian #include <kos/fs_romdisk.h> #include <kos/opts.h> #include <malloc.h> +#include <stdbool.h> #include <string.h> #include <strings.h> #include <stdio.h> #include <assert.h> #include <errno.h> +#define ROMFS_MAXFN 128 +#define ROMFH_HRD 0 +#define ROMFH_DIR 1 +#define ROMFH_REG 2 +#define ROMFH_LNK 3 +#define ROMFH_BLK 4 +#define ROMFH_CHR 5 +#define ROMFH_SCK 6 +#define ROMFH_FIF 7 +#define ROMFH_EXEC 8 + +#define RD_VN_MAX 16 +#define RD_FN_MAX 16 + /* Header definitions from Linux ROMFS documentation; all integer quantities are expressed in big-endian notation. Unfortunately the ROMFS guys were being clever and made this header a variable length depending on the size of the volume name *groan*. Its size will be a multiple of 16 bytes though. */ typedef struct { - char magic[8]; /* Should be "-rom1fs-" */ - uint32 full_size; /* Full size of the file system */ - uint32 checksum; /* Checksum */ - char volume_name[16]; /* Volume name (zero-terminated) */ + char magic[8]; /* Should be "-rom1fs-" */ + uint32 full_size; /* Full size of the file system */ + uint32 checksum; /* Checksum */ + char volume_name[RD_VN_MAX]; /* Volume name (zero-terminated) */ } romdisk_hdr_t; /* File header info; note that this header plus filename must be a multiple of 16 bytes, and the following file data must also be a multiple of 16 bytes. */ typedef struct { - uint32 next_header; /* Offset of next header */ - uint32 spec_info; /* Spec info */ - uint32 size; /* Data size */ - uint32 checksum; /* File checksum */ - char filename[16]; /* File name (zero-terminated) */ + uint32 next_header; /* Offset of next header */ + uint32 spec_info; /* Spec info */ + uint32 size; /* Data size */ + uint32 checksum; /* File checksum */ + char filename[RD_FN_MAX]; /* File name (zero-terminated) */ } romdisk_file_t; @@ -84,13 +99,16 @@ static rdi_list_t romdisks; too lazy right now. =) */ static struct { uint32 index; /* romfs image index */ - int dir; /* >0 if a directory */ + bool dir; /* true if a directory */ uint32 ptr; /* Current read position in bytes */ uint32 size; /* Length of file in bytes */ dirent_t dirent; /* A static dirent to pass back to clients */ rd_image_t * mnt; /* Which mount instance are we using? */ } fh[FS_ROMDISK_MAX_FILES]; +#define FH_INDEX_FREE 0 +#define FH_INDEX_RESERVED -1 + /* File type */ #define ROMFH_DIR 1 @@ -102,7 +120,7 @@ static mutex_t fh_mutex; /* Given a filename and a starting romdisk directory listing (byte offset), search for the entry in the directory and return the byte offset to its entry. */ -static uint32 romdisk_find_object(rd_image_t * mnt, const char *fn, size_t fnlen, int dir, uint32 offset) { +static uint32_t romdisk_find_object(rd_image_t *mnt, const char *fn, size_t fnlen, bool dir, uint32_t offset) { uint32 i, ni, type; const romdisk_file_t *fhdr; @@ -156,10 +174,10 @@ static uint32 romdisk_find_object(rd_image_t * mnt, const char *fn, size_t fnlen find_object_path in iso9660. fn: object filename (absolute path) - dir: 0 if looking for a file, 1 if looking for a dir + dir: false if looking for a file, true if looking for a dir It will return an offset in the romdisk image for the object. */ -static uint32 romdisk_find(rd_image_t * mnt, const char *fn, int dir) { +static uint32_t romdisk_find(rd_image_t *mnt, const char *fn, bool dir) { const char *cur; uint32 i; const romdisk_file_t *fhdr; @@ -170,7 +188,7 @@ static uint32 romdisk_find(rd_image_t * mnt, const char *fn, int dir) { while((cur = strchr(fn, '/'))) { if(cur != fn) { - i = romdisk_find_object(mnt, fn, cur - fn, 1, i); + i = romdisk_find_object(mnt, fn, cur - fn, true, i); if(i == 0) return 0; @@ -223,8 +241,8 @@ static void * romdisk_open(vfs_handler_t * vfs, const char *fn, int mode) { mutex_lock(&fh_mutex); for(fd = 0; fd < FS_ROMDISK_MAX_FILES; fd++) - if(fh[fd].index == 0) { - fh[fd].index = -1; + if(fh[fd].index == FH_INDEX_FREE) { + fh[fd].index = FH_INDEX_RESERVED; break; } @@ -237,8 +255,8 @@ static void * romdisk_open(vfs_handler_t * vfs, const char *fn, int mode) { /* Fill the fd structure */ fhdr = (const romdisk_file_t *)(mnt->image + filehdr); - fh[fd].index = filehdr + sizeof(romdisk_file_t) + (strlen(fhdr->filename) / 16) * 16; - fh[fd].dir = (mode & O_DIR) ? 1 : 0; + fh[fd].index = filehdr + sizeof(romdisk_file_t) + (strlen(fhdr->filename) / RD_FN_MAX) * RD_FN_MAX; + fh[fd].dir = ((mode & O_DIR) != 0); fh[fd].ptr = 0; fh[fd].size = ntohl_32(&fhdr->size); fh[fd].mnt = mnt; @@ -253,7 +271,7 @@ static int romdisk_close(void * h) { /* Check that the fd is valid */ if(fd < FS_ROMDISK_MAX_FILES) { /* No need to lock the mutex: this is an atomic op */ - fh[fd].index = 0; + fh[fd].index = FH_INDEX_FREE; } return 0; } @@ -263,7 +281,7 @@ static ssize_t romdisk_read(void * h, void *buf, size_t bytes) { file_t fd = (file_t)h; /* Check that the fd is valid */ - if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == 0 || fh[fd].dir) { + if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) { errno = EINVAL; return -1; } @@ -279,12 +297,22 @@ static ssize_t romdisk_read(void * h, void *buf, size_t bytes) { return bytes; } +/* Just to get the errno that might be better recognized upstream. */ +static ssize_t romdisk_write(void *h, const void *buf, size_t bytes) { + (void)h; + (void)buf; + (void)bytes; + + errno = ENXIO; + return -1; +} + /* Seek elsewhere in a file */ static off_t romdisk_seek(void * h, off_t offset, int whence) { file_t fd = (file_t)h; /* Check that the fd is valid */ - if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == 0 || fh[fd].dir) { + if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) { errno = EBADF; return -1; } @@ -333,7 +361,7 @@ static off_t romdisk_seek(void * h, off_t offset, int whence) { static off_t romdisk_tell(void * h) { file_t fd = (file_t)h; - if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == 0 || fh[fd].dir) { + if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) { errno = EINVAL; return -1; } @@ -345,7 +373,7 @@ static off_t romdisk_tell(void * h) { static size_t romdisk_total(void * h) { file_t fd = (file_t)h; - if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == 0 || fh[fd].dir) { + if(fd >= FS_ROMDISK_MAX_FILES || fh[fd].index == FH_INDEX_FREE || fh[fd].dir) { errno = EINVAL; return -1; } @@ -359,7 +387,7 @@ static dirent_t *romdisk_readdir(void * h) { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-10-12 00:42:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via fab5f404c7abe0ee593dd8d9b105cc5d11f71d50 (commit) via 7d7e9bdda3d64a1b993456ab6879d9d5a3e73486 (commit) from d7ad90091d76a5e9cfe1d73d83dd9f85e0c25484 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fab5f404c7abe0ee593dd8d9b105cc5d11f71d50 Author: Falco Girgis <gyr...@gm...> Date: Fri Oct 11 19:41:33 2024 -0500 BIOS Font Cleanup, Refactor, and More Ergonomic API (#581) * Cleaned up + Enhanced BIOS font API - Everything is now idiomatic C with proper typing - Everything is documented and organized better in Doxygen - Draw string functions now handle printf-style formatted text - Added a va_list equivalent of the variadic argument draw text - Added Doxygen grouping - Cleaned up examples using more ergonomic bfont API commit 7d7e9bdda3d64a1b993456ab6879d9d5a3e73486 Author: Donald Haase <qu...@ya...> Date: Fri Oct 11 17:28:52 2024 -0400 Separate out trap from irq. Add its own internal and external types. Add getter to match the setter. Update gdb_stub to the new API. (#810) Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG.md | 1 + examples/dreamcast/libdream/320x240/320x240.c | 8 +- examples/dreamcast/mruby/mrbtris/dckos.c | 4 +- examples/dreamcast/sound/multi-stream/main.c | 11 +- examples/dreamcast/video/multibuffer/multibuffer.c | 5 +- kernel/arch/dreamcast/hardware/biosfont.c | 170 ++++--- kernel/arch/dreamcast/include/arch/irq.h | 15 +- kernel/arch/dreamcast/include/arch/trap.h | 102 ++++ kernel/arch/dreamcast/include/dc/biosfont.h | 551 ++++++++++++--------- kernel/arch/dreamcast/kernel/gdb_stub.c | 4 +- kernel/arch/dreamcast/kernel/irq.c | 21 +- 11 files changed, 569 insertions(+), 323 deletions(-) create mode 100644 kernel/arch/dreamcast/include/arch/trap.h diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 736668db..9c764a38 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -11,6 +11,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha - Add performance monitor API [PC] - Add/Fixed stat() implementations for all filesystems [AB] - **Dreamcast**: Add network speedtest and pvr palette examples [AB] +- **Dreamcast**: Cleaned up, documented, and enhanced BIOS font API [FG] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/examples/dreamcast/libdream/320x240/320x240.c b/examples/dreamcast/libdream/320x240/320x240.c index 5eadc8a6..bb1781f8 100644 --- a/examples/dreamcast/libdream/320x240/320x240.c +++ b/examples/dreamcast/libdream/320x240/320x240.c @@ -22,15 +22,11 @@ int main(int argc, char **argv) { } for(y = 0; y < H; y += 24) { - char tmp[16]; - sprintf(tmp, "%d", y); - bfont_draw_str(vram_s + y * W + 10, W, 0, tmp); + bfont_draw_str_fmt(vram_s + y * W + 10, W, 0, "%d", y); } for(x = 0; x < W; x += 100) { - char tmp[16]; - sprintf(tmp, "%d", x / 10); - bfont_draw_str(vram_s + 10 * W + x, W, 0, tmp); + bfont_draw_str_fmt(vram_s + 10 * W + x, W, 0, "%d", x / 10); } printf("\n\nPress all buttons simultaneously to exit.\n"); diff --git a/examples/dreamcast/mruby/mrbtris/dckos.c b/examples/dreamcast/mruby/mrbtris/dckos.c index ea2e3e51..b8b23ffd 100644 --- a/examples/dreamcast/mruby/mrbtris/dckos.c +++ b/examples/dreamcast/mruby/mrbtris/dckos.c @@ -308,9 +308,7 @@ static mrb_value clear_score(mrb_state *mrb, mrb_value self) { static mrb_value render_score(mrb_state *mrb, mrb_value self) { struct mrb_value score; mrb_get_args(mrb, "i", &score); - char buf[20]; - snprintf(buf, 20, "Score: %8" PRId32, mrb_fixnum(score)); - bfont_draw_str(vram_s + 640 * 100 + 16, 640, 1, buf); + bfont_draw_str_fmt(vram_s + 640 * 100 + 16, 640, 1, "Score: %8" PRId32, mrb_fixnum(score)); return mrb_nil_value(); } diff --git a/examples/dreamcast/sound/multi-stream/main.c b/examples/dreamcast/sound/multi-stream/main.c index 474c725f..4758bfab 100644 --- a/examples/dreamcast/sound/multi-stream/main.c +++ b/examples/dreamcast/sound/multi-stream/main.c @@ -103,7 +103,6 @@ int main(int argc, char **argv) { static void draw_instructions(int faucet_vol, int brushing_vol) { int x = 20, y = 20+24; int color = 1; - char volume_str[32]; bfont_draw_str(vram_s + y*640+x, 640, color, "Press X to play faucet sound"); y += 24; @@ -111,10 +110,8 @@ static void draw_instructions(int faucet_vol, int brushing_vol) { y += 24; bfont_draw_str(vram_s + y*640+x, 640, color, "Press L-Trigger to increase faucet volume"); y += 24; - memset(volume_str, 0, 32); - snprintf(volume_str, 32, "Faucet Volume: %3i", faucet_vol); - bfont_draw_str(vram_s + y*640+x, 640, color, volume_str); - + bfont_draw_str_fmt(vram_s + y*640+x, 640, color, "Faucet Volume: %3i", faucet_vol); + y += 48; bfont_draw_str(vram_s + y*640+x, 640, color, "Press Y to play brushing sound"); y += 24; @@ -122,9 +119,7 @@ static void draw_instructions(int faucet_vol, int brushing_vol) { y += 24; bfont_draw_str(vram_s + y*640+x, 640, color, "Press R-Trigger to increase brushing volume"); y += 24; - memset(volume_str, 0, 32); - snprintf(volume_str, 32, "Brushing Volume: %3i", brushing_vol); - bfont_draw_str(vram_s + y*640+x, 640, color, volume_str); + bfont_draw_str_fmt(vram_s + y*640+x, 640, color, "Brushing Volume: %3i", brushing_vol); y += 48; bfont_draw_str(vram_s + y*640+x, 640, color, "Press Start to exit program"); diff --git a/examples/dreamcast/video/multibuffer/multibuffer.c b/examples/dreamcast/video/multibuffer/multibuffer.c index 8cf08f8e..97e43dee 100644 --- a/examples/dreamcast/video/multibuffer/multibuffer.c +++ b/examples/dreamcast/video/multibuffer/multibuffer.c @@ -16,7 +16,6 @@ int main(int argc, char **argv) { unsigned short x, y, mb; - char text_buff [20]; /* Press all buttons to exit */ cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, @@ -39,8 +38,8 @@ int main(int argc, char **argv) { } } - snprintf(text_buff, 20, "This is FB %u", (mb + 1) % vid_mode->fb_count); - bfont_draw_str(vram_s + (640 * BFONT_HEIGHT) + (BFONT_THIN_WIDTH * 2), 640, 1, text_buff); + bfont_draw_str_fmt(vram_s + (640 * BFONT_HEIGHT) + (BFONT_THIN_WIDTH * 2), 640, 1, + "This is FB %u", (mb + 1) % vid_mode->fb_count); /* This tells the pvr to move to the framebuffer we've been drawing to, then adjusts the vram_* pointers to the next one. */ diff --git a/kernel/arch/dreamcast/hardware/biosfont.c b/kernel/arch/dreamcast/hardware/biosfont.c index 0792279a..7ac5bfb9 100644 --- a/kernel/arch/dreamcast/hardware/biosfont.c +++ b/kernel/arch/dreamcast/hardware/biosfont.c @@ -6,9 +6,12 @@ Japanese code Copyright (C) Kazuaki Matsumoto Copyright (C) 2017, 2024 Donald Haase Copyright (C) 2024 Andy Barajas + Copyright (C) 2024 Falco Girgis */ #include <assert.h> +#include <string.h> +#include <stdio.h> #include <dc/biosfont.h> #include <dc/syscalls.h> @@ -34,17 +37,26 @@ Expansion to 4 and 8 bpp by Donald Haase. */ /* Our current conversion mode */ -static uint8 bfont_code_mode = BFONT_CODE_ISO8859_1; +static uint8_t bfont_code_mode = BFONT_CODE_ISO8859_1; /* Current colors/pixel format. Default to white foreground, black background and 16-bit drawing, so the default behavior doesn't change from what it has been forever. */ -static uint32 bfont_fgcolor = 0xFFFFFFFF; -static uint32 bfont_bgcolor = 0x00000000; -static int bfont_32bit = 0; +static uint32_t bfont_fgcolor = 0xFFFFFFFF; +static uint32_t bfont_bgcolor = 0x00000000; +static bool bfont_32bit = false; + +static uint8_t *font_address = NULL; + +static uint8_t *get_font_address(void) { + if(!font_address) + font_address = syscall_font_address(); + + return font_address; +} /* Select an encoding for Japanese (or disable) */ -void bfont_set_encoding(uint8 enc) { +void bfont_set_encoding(bfont_code_t enc) { if(enc <= BFONT_CODE_RAW) bfont_code_mode = enc; else @@ -52,15 +64,15 @@ void bfont_set_encoding(uint8 enc) { } /* Set the foreground color and return the old color */ -uint32 bfont_set_foreground_color(uint32 c) { - uint32 rv = bfont_fgcolor; +uint32_t bfont_set_foreground_color(uint32_t c) { + uint32_t rv = bfont_fgcolor; bfont_fgcolor = c; return rv; } /* Set the background color and return the old color */ -uint32 bfont_set_background_color(uint32 c) { - uint32 rv = bfont_bgcolor; +uint32_t bfont_set_background_color(uint32_t c) { + uint32_t rv = bfont_bgcolor; bfont_bgcolor = c; return rv; } @@ -68,9 +80,9 @@ uint32 bfont_set_background_color(uint32 c) { /* Set the font to draw in 32 or 16 bit mode. Deprecated: This will only impact compat functions for now. Moving forward, the compat will be 16bit only. */ -int bfont_set_32bit_mode(int on) { - int rv = bfont_32bit; - bfont_32bit = !!on; +bool bfont_set_32bit_mode(bool on) { + bool rv = bfont_32bit; + bfont_32bit = on; return rv; } @@ -89,7 +101,7 @@ int unlock_bfont(void) { } /* Shift-JIS -> JIS conversion */ -uint32 sjis2jis(uint32 sjis) { +static uint32_t sjis2jis(uint32_t sjis) { unsigned int hib, lob; hib = (sjis >> 8) & 0xff; @@ -111,15 +123,15 @@ uint32 sjis2jis(uint32 sjis) { /* EUC -> JIS conversion */ -uint32 euc2jis(uint32 euc) { +static uint32_t euc2jis(uint32_t euc) { return euc & ~0x8080; } /* Given an ASCII character, find it in the BIOS font if possible */ -uint8 *bfont_find_char(uint32 ch) { - uint8 *fa = syscall_font_address(); +uint8_t *bfont_find_char(uint32_t ch) { + uint8_t *fa = get_font_address(); /* By default, map to a space */ - uint32 index = 72 << 2; + uint32_t index = 72 << 2; /* 33-126 in ASCII are 1-94 in the font */ if(ch >= 33 && ch <= 126) @@ -133,9 +145,9 @@ uint8 *bfont_find_char(uint32 ch) { } /* JIS -> (kuten) -> address conversion */ -uint8 *bfont_find_char_jp(uint32 ch) { - uint8 *fa = syscall_font_address(); - uint32 ku, ten, kuten = 0; +uint8_t *bfont_find_char_jp(uint32_t ch) { + uint8_t *fa = get_font_address(); + uint32_t ku, ten, kuten = 0; /* Do the requested code conversion */ switch(bfont_code_mode) { @@ -166,22 +178,22 @@ uint8 *bfont_find_char_jp(uint32 ch) { /* Half-width kana -> address conversion */ -uint8 *bfont_find_char_jp_half(uint32 ch) { - uint8 *fa = syscall_font_address(); +uint8_t *bfont_find_char_jp_half(uint32_t ch) { + uint8_t *fa = get_font_address(); return fa + (32 + ch) * (BFONT_THIN_WIDTH*BFONT_HEIGHT/8); } /* Draws one half-width row of a character to an output buffer of bit depth in bits per pixel */ -uint16 *bfont_draw_one_row(uint16 *b, uint16 word, uint8 opaque, uint32 fg, uint32 bg, uint8 bpp) { - uint8 x; - uint32 color = 0x0000; - uint16 write16 = 0x0000; - uint16 oldcolor = *b; +static uint16_t *bfont_draw_one_row(uint16_t *b, uint16_t word, bool opaque, uint32_t fg, uint32_t bg, uint8_t bpp) { + uint8_t x; + uint32_t color = 0x0000; + uint16_t write16 = 0x0000; + uint16_t oldcolor = *b; if((bpp == 4)||(bpp == 8)) { /* For 4 or 8bpp we have to go 2 or 4 pixels at a time to properly write out in all cases. */ - uint8 bMask = (bpp==4) ? 0xf : 0xff; - uint8 pix = 16/bpp; + uint8_t bMask = (bpp==4) ? 0xf : 0xff; + uint8_t pix = 16/bpp; for(x = 0; x < BFONT_THIN_WIDTH; x++) { if(x%pix == 0) { oldcolor = *b; @@ -206,17 +218,19 @@ uint16 *bfont_draw_one_row(uint16 *b, uint16 word, uint8 opaque, uint32 fg, uint else continue; } if(bpp==16) *b = color & 0xffff; - else if(bpp == 32) {*(uint32 *)b = color; b++;} + else if(bpp == 32) {*(uint32_t *)b = color; b++;} } } return b; } -unsigned char bfont_draw_ex(uint8 *buffer, uint32 bufwidth, uint32 fg, uint32 bg, uint8 bpp, uint8 opaque, uint32 c, uint8 wide, uint8 iskana) { - uint8 *ch; - uint16 word; - uint8 y; +size_t bfont_draw_ex(void *buf, uint32_t bufwidth, uint32_t fg, uint32_t bg, + uint8_t bpp, bool opaque, uint32_t c, bool wide, bool iskana) { + uint8_t *ch; + uint16_t word; + uint8_t y; + uint8_t *buffer = (uint8_t *)buf; /* If they're requesting a wide char and in the wrong format, kick this out */ if(wide && (bfont_code_mode == BFONT_CODE_ISO8859_1)) { @@ -225,7 +239,7 @@ unsigned char bfont_draw_ex(uint8 *buffer, uint32 bufwidth, uint32 fg, uint32 bg } /* Just making sure we can draw the character we want to */ - if(bufwidth < (uint32)(BFONT_THIN_WIDTH*(wide+1))) { + if(bufwidth < (uint32_t)(BFONT_THIN_WIDTH*(wide+1))) { dbglog(DBG_ERROR, "bfont_draw_ex: buffer is too small to draw into\n"); return 0; } @@ -237,7 +251,7 @@ unsigned char bfont_draw_ex(uint8 *buffer, uint32 bufwidth, uint32 fg, uint32 bg /* Translate the character */ if(bfont_code_mode == BFONT_CODE_RAW) - ch = syscall_font_address() + c; + ch = get_font_address() + c; else if(wide && ((bfont_code_mode == BFONT_CODE_EUC) || (bfont_code_mode == BFONT_CODE_SJIS))) ch = bfont_find_char_jp(c); else { @@ -250,16 +264,16 @@ unsigned char bfont_draw_ex(uint8 *buffer, uint32 bufwidth, uint32 fg, uint32 bg /* Increment over the height of the font. 3bytes at a time (2 thin or 1 wide row) */ for(y = 0; y < BFONT_HEIGHT; y+= (2-wide),ch+=((BFONT_THIN_WIDTH*2)/8)) { /* Do the first row, or half row */ - word = (((uint16)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f); - buffer = (uint8*)bfont_draw_one_row((uint16*)buffer, word, opaque, fg, bg, bpp); + word = (((uint16_t)ch[0]) << 4) | ((ch[1] >> 4) & 0x0f); + buffer = (uint8_t *)bfont_draw_one_row((uint16_t *)buffer, word, opaque, fg, bg, bpp); /* If we're thin, increment to next row, otherwise continue the row */ if(!wide) buffer += ((bufwidth - BFONT_THIN_WIDTH)*bpp)/8; /* Do the second row, or second half */ - word = ((((uint16)ch[1]) << 8) & 0xf00) | ch[2]; + word = ((((uint16_t)ch[1]) << 8) & 0xf00) | ch[2]; - buffer = (uint8*)bfont_draw_one_row((uint16*)buffer, word, opaque, fg, bg, bpp); + buffer = (uint8_t *)bfont_draw_one_row((uint16_t *)buffer, word, opaque, fg, bg, bpp); /* Increment to the next row. */ if(!wide) buffer += ((bufwidth - BFONT_THIN_WIDTH)*bpp)/8; @@ -277,29 +291,27 @@ unsigned char bfont_draw_ex(uint8 *buffer, uint32 bufwidth, uint32 fg, uint32 bg } /* Draw half-width kana */ -unsigned char bfont_draw_thin(void *b, uint32 bufwidth, uint8 opaque, uint32 c, uint8 iskana) { - return bfont_draw_ex((uint8 *)b, bufwidth, bfont_fgcolor, bfont_bgcolor, (bfont_32bit ? (sizeof (uint32)) : (sizeof (uint16))) << 3, opaque, c, 0, iskana); +size_t bfont_draw_thin(void *b, uint32_t bufwidth, bool opaque, uint32_t c, bool iskana) { + return bfont_draw_ex(b, bufwidth, bfont_fgcolor, bfont_bgcolor, + (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, opaque, c, 0, iskana); } /* Compat function */ -unsigned char bfont_draw(void *buffer, uint32 bufwidth, uint8 opaque, uint32 c) { - return bfont_draw_ex((uint8 *)buffer, bufwidth, bfont_fgcolor, bfont_bgcolor, (bfont_32bit ? (sizeof (uint32)) : (sizeof (uint16))) << 3, opaque, c, 0, 0); +size_t bfont_draw(void *buffer, uint32_t bufwidth, bool opaque, uint32_t c) { + return bfont_draw_ex(buffer, bufwidth, bfont_fgcolor, bfont_bgcolor, + (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, opaque, c, 0, 0); } /* Draw wide character */ -unsigned char bfont_draw_wide(void *b, uint32 bufwidth, uint8 opaque, uint32 c) { - return bfont_draw_ex((uint8 *)b, bufwidth, bfont_fgcolor, bfont_bgcolor, (bfont_32bit ? (sizeof (uint32)) : (sizeof (uint16))) << 3, opaque, c, 1, 0); +size_t bfont_draw_wide(void *b, uint32_t bufwidth, bool opaque, uint32_t c) { + return bfont_draw_ex(b, bufwidth, bfont_fgcolor, bfont_bgcolor, + (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, opaque, c, 1, 0); } -/* Draw string of full-width (wide) and half-width (thin) characters - Note that this handles the case of mixed encodings unless Japanese - support is disabled (BFONT_CODE_ISO8859_1). - XXX: Seems like this can be shrunk to use uint8 for nChr/Mask/Flag and - getting rid of nMask. - */ -void bfont_draw_str_ex(void *b, uint32 width, uint32 fg, uint32 bg, uint8 bpp, uint8 opaque, const char *str) { - uint16 nChr, nMask, nFlag; - uint8 *buffer = (uint8 *)b; +void bfont_draw_str_ex(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, bool opaque, + const char *str) { + uint16_t nChr, nMask, nFlag; + uint8_t *buffer = (uint8_t *)b; while(*str) { nFlag = 0; @@ -346,16 +358,54 @@ void bfont_draw_str_ex(void *b, uint32 width, uint32 fg, uint32 bg, uint8 bpp, u } } -void bfont_draw_str(void *b, uint32 width, uint8 opaque, const char *str) { - bfont_draw_str_ex(b, width, bfont_fgcolor, bfont_bgcolor, (bfont_32bit ? (sizeof (uint32)) : (sizeof (uint16))) << 3, opaque, str); +void bfont_draw_str_ex_vfmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, + uint8_t bpp, bool opaque, const char *fmt, + va_list *var_args) { + /* Maximum of 1060 thin characters onscreen, plus padding for multiple of 32. */ + char string[1088]; + + vsnprintf(string, sizeof(string), fmt, *var_args); + bfont_draw_str_ex(b, width, fg, bg, bpp, opaque, string); +} + +/* Draw string of full-width (wide) and half-width (thin) characters + Note that this handles the case of mixed encodings unless Japanese + support is disabled (BFONT_CODE_ISO8859_1). +*/ +void bfont_draw_str_ex_fmt(void *b, uint32_t width, uint32_t fg, uint32_t bg, uint8_t bpp, + bool opaque, const char *fmt, ...) { + va_list var_args; + va_start(var_args, fmt); + + bfont_draw_str_ex_vfmt(b, width, fg, bg, bpp, opaque, fmt, &var_args); + + va_end(var_args); +} + +void bfont_draw_str(void *b, uint32_t width, bool opaque, const char *str) { + bfont_draw_str_ex(b, width, bfont_fgcolor, bfont_bgcolor, + (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, + opaque, str); +} + +void bfont_draw_str_fmt(void *b, uint32_t width, bool opaque, const char *fmt, + ...) { + va_list var_args; + va_start(var_args, fmt); + + bfont_draw_str_ex_vfmt(b, width, bfont_fgcolor, bfont_bgcolor, + (bfont_32bit ? (sizeof (uint32_t)) : (sizeof (uint16_t))) << 3, + opaque, fmt, &var_args); + + va_end(var_args); } -uint8 *bfont_find_icon(uint8 icon) { +uint8_t *bfont_find_icon(bfont_vmu_icon_t icon) { if(icon > BFONT_ICON_EMBROIDERY) return NULL; int icon_offset = BFONT_VMU_DREAMCAST_SPECIFIC + - (icon * BFONT_ICON_DIMEN * BFONT_ICON_DIMEN/8); - uint8 *fa = syscall_font_address(); + (icon * BFONT_ICON_DIMEN * BFONT_ICON_DIMEN / 8); + uint8_t *fa = get_font_address(); return fa + icon_offset; } diff --git a/kernel/arch/dreamcast/include/arch/irq.h b/kernel/arch/dreamcast/include/arch/irq.h index 8b47a5e9..0d3ce1c4 100644 --- a/kernel/arch/dreamcast/include/arch/irq.h +++ b/kernel/arch/dreamcast/include/arch/irq.h @@ -27,6 +27,9 @@ __BEGIN_DECLS #include <arch/types.h> +/* Included for legacy compatibility with these two APIs being one. */ +#include <arch/trap.h> + /** \defgroup irqs Interrupts \brief IRQs and ISRs for the SH4's CPU \ingroup system @@ -317,18 +320,6 @@ int irq_set_handler(irq_t source, irq_handler hnd, void *data); */ irq_handler irq_get_handler(irq_t source); -/** \brief Set or remove a handler for a trapa code. - \ingroup irqs - - \param code The value passed to the trapa opcode. - \param hnd A pointer to the procedure to handle the trap. - \param data A pointer that will be passed along to the callback. - - \retval 0 On success. - \retval -1 If the code is invalid (greater than 0xFF). -*/ -int trapa_set_handler(irq_t code, irq_handler hnd, void *data); - /** \brief Set a global exception handler. \ingroup irqs diff --git a/kernel/arch/dreamcast/include/arch/trap.h b/kernel/arch/dreamcast/include/arch/trap.h new file mode 100644 index 00000000..cb2c0978 --- /dev/null +++ b/kernel/arch/dreamcast/include/arch/trap.h @@ -0,0 +1,102 @@ +/* KallistiOS ##version## + + arch/dreamcast/include/arch/trap.h + Copyright (C) 2024 Falco Girgis + +*/ + +/** \file + \brief Interrupt and exception handling. + \ingroup traps + + This file contains various definitions and declarations related to handling + trap events, as are invoked through the `TRAPA` instruction. + + \author Falco Girgis + + \see arch/irq.h, dc/asic.h + + \todo + - state management, propagation + - TRAPA instruction inline ASM + - document reserved TRAP codes +*/ + +#ifndef __ARCH_TRAP_H +#define __ARCH_TRAP_H + +#include <stdint.h> ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-11 21:29:07
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, irq_cleanup_1 has been created at 4c6c3cad43a0a9ef2ff5cf0b758a0f1ca1369992 (commit) - Log ----------------------------------------------------------------- commit 4c6c3cad43a0a9ef2ff5cf0b758a0f1ca1369992 Author: QuzarDC <qu...@co...> Date: Fri Oct 11 10:28:21 2024 -0400 Separate out trap from irq. Add its own internal and external types. Add getter to match the setter. Update gdb_stub to the new API. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-11 21:25:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via d7ad90091d76a5e9cfe1d73d83dd9f85e0c25484 (commit) from e883288299e92adb04a6ce21d2d9f7ec5e6f0d8d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d7ad90091d76a5e9cfe1d73d83dd9f85e0c25484 Author: Paul Cercueil <pa...@cr...> Date: Fri Oct 11 23:25:06 2024 +0200 matrix.h: Constify and rename some parameters (#812) Constify parameters where it makes sense, and rename an "out" parameter that's actually an input. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/matrix.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/arch/dreamcast/include/dc/matrix.h b/kernel/arch/dreamcast/include/dc/matrix.h index 106b867a..01d58861 100644 --- a/kernel/arch/dreamcast/include/dc/matrix.h +++ b/kernel/arch/dreamcast/include/dc/matrix.h @@ -60,10 +60,10 @@ void mat_store(matrix_t *out); \note For best performance, 32-byte alignment of \p out is recommended. - \param out A pointer to where to load the matrix from (must be + \param src A pointer to where to load the matrix from (must be at least 8-byte aligned, should be 32-byte aligned). */ -void mat_load(matrix_t *out); +void mat_load(const matrix_t *src); /** \brief Clear the internal matrix to identity. @@ -83,7 +83,7 @@ void mat_identity(void); \param src A pointer to the matrix to multiply. */ -void mat_apply(matrix_t *src); +void mat_apply(const matrix_t *src); /** \brief Transform vectors by the internal matrix. @@ -95,7 +95,8 @@ void mat_apply(matrix_t *src); \param veccnt How many vectors are in the list. \param stride Number of bytes between vectors. */ -void mat_transform(vector_t *invecs, vector_t *outvecs, int veccnt, int stride); +void mat_transform(const vector_t *invecs, vector_t *outvecs, + int veccnt, int stride); /** \brief Transform vectors by the internal matrix into the store queues. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-11 21:16:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via e883288299e92adb04a6ce21d2d9f7ec5e6f0d8d (commit) from ee2324f6fc2a1de27033539bd088913d869df4a3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e883288299e92adb04a6ce21d2d9f7ec5e6f0d8d Author: Paul Cercueil <pa...@cr...> Date: Fri Oct 11 23:16:29 2024 +0200 perf_monitor: Improve perf_monitor_print() (#813) - Don't print anything if no perf monitor is present; - Print the monitors in reverse order, as the first ones in the .monitors section correspond to the last ones in a C file; - Print the line number after the function name, so that it is easy to differenciate perf monitors used within a single function. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/perf_monitor.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/arch/dreamcast/kernel/perf_monitor.c b/kernel/arch/dreamcast/kernel/perf_monitor.c index bb596078..765a4a06 100644 --- a/kernel/arch/dreamcast/kernel/perf_monitor.c +++ b/kernel/arch/dreamcast/kernel/perf_monitor.c @@ -49,11 +49,12 @@ void perf_monitor_exit(void) { void perf_monitor_print(FILE *f) { struct perf_monitor *monitor; - fprintf(f, "Performance monitors:\n"); + if((uintptr_t)&_monitors_end != (uintptr_t)&_monitors_start) + fprintf(f, "Performance monitors:\n"); - for (monitor = &_monitors_start; monitor < &_monitors_end; monitor++) { - fprintf(f, "\t%s: %llu calls\n\t\t%llu ns (%f ns/call)\n\t\tevent 0: %llu (%f event/call)\n\t\tevent 1: %llu (%f event/call)\n", - monitor->fn, monitor->calls, monitor->time_ns, + for(monitor = &_monitors_end - 1; monitor >= &_monitors_start; monitor--) { + fprintf(f, "\t%s L%u: %llu calls\n\t\t%llu ns (%f ns/call)\n\t\tevent 0: %llu (%f event/call)\n\t\tevent 1: %llu (%f event/call)\n", + monitor->fn, monitor->line, monitor->calls, monitor->time_ns, monitor->calls ? (float)monitor->time_ns / (float)monitor->calls : 0.0f, monitor->event0, monitor->event0 ? (float)monitor->event0 / (float)monitor->calls : 0.0f, hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-11 21:13:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via ee2324f6fc2a1de27033539bd088913d869df4a3 (commit) from 22c8c2063dc13ddfcf717aa3f5a335f8f0d493ad (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ee2324f6fc2a1de27033539bd088913d869df4a3 Author: Andy Barajas <and...@gm...> Date: Fri Oct 11 14:13:14 2024 -0700 Fix dreampresent compile error by moving constants out of the methods (#814) ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/mruby/dreampresent/page_data.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/examples/dreamcast/mruby/dreampresent/page_data.rb b/examples/dreamcast/mruby/dreampresent/page_data.rb index e6dfadf0..05954f16 100644 --- a/examples/dreamcast/mruby/dreampresent/page_data.rb +++ b/examples/dreamcast/mruby/dreampresent/page_data.rb @@ -256,6 +256,12 @@ end # This renders a 'background' with 640x480 image # It also renders timer and page progress class PageBaseContent + PAGES_BAR_LEN = 640 - 32 + PAGES_Y_POS = 410 + DURATION = 20 * 60 # 20 mins + PROGRESS_LEN = 640 - 32 + PROGRESS_Y_POS = 440 + def initialize(path, page_count) @page_count = page_count @path = String(path).strip @@ -276,9 +282,6 @@ class PageBaseContent end def render_page_progress(dc_kos, page_count, page_index) - PAGES_BAR_LEN = 640 - 32 - PAGES_Y_POS = 410 - pos_x = if page_count <= 1 0 @@ -290,10 +293,6 @@ class PageBaseContent end def render_timer_progress(dc_kos, start_time, time_adjustment) - DURATION = 20 * 60 # 20 mins - PROGRESS_LEN = 640 - 32 - PROGRESS_Y_POS = 440 - pos_x = ((Time.now.to_i - start_time.to_i + time_adjustment) / DURATION * PROGRESS_LEN).to_i puts "#################### start_time: #{start_time}, adj: #{time_adjustment}, now: #{Time.now}, pos_x: #{pos_x}" pos_x = PROGRESS_LEN if pos_x > PROGRESS_LEN hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-10-11 08:50:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 22c8c2063dc13ddfcf717aa3f5a335f8f0d493ad (commit) from b96c8042f0e7f9c51dd75216d18164dfb298fe95 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 22c8c2063dc13ddfcf717aa3f5a335f8f0d493ad Author: Falco Girgis <gyr...@gm...> Date: Fri Oct 11 03:50:26 2024 -0500 Fixed Thread Starvation Issue with Priority Boosting (#803) * Fixed thread starvation issue with priority boost - Added comments - Added #define for pseudo-IRQ Thread for sake of my sanity. :) * Only reschedule threads in STATE_READY. Previously it would allow sleeping/waiting threads to be rescheduled when they weren't in the runnable queue to begin with. Now *only* STATE_READY threads, which also helps by excluding zombie/finished threads. * Only reset priority back if you are releasing the last lock a thread holds. Previously recursive mutexes may have reverted priority after locally unlocking but before waking the thread that boosted them. ----------------------------------------------------------------------- Summary of changes: kernel/thread/mutex.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c index 3d438965..4490ad63 100644 --- a/kernel/thread/mutex.c +++ b/kernel/thread/mutex.c @@ -2,6 +2,7 @@ mutex.c Copyright (C) 2012, 2015 Lawrence Sebald + Copyright (C) 2024 Paul Cercueil */ @@ -16,6 +17,9 @@ #include <arch/irq.h> #include <arch/timer.h> +/* Thread pseudo-ptr representing an active IRQ context. */ +#define IRQ_THREAD ((kthread_t *)0xFFFFFFFF) + mutex_t *mutex_create(void) { mutex_t *rv; @@ -133,13 +137,17 @@ int mutex_lock_timed(mutex_t *m, int timeout) { deadline = timer_ms_gettime64() + timeout; for(;;) { + /* Check whether we should boost priority. */ if (m->holder->prio >= thd_current->prio) { m->holder->prio = thd_current->prio; - /* Thread list is sorted by priority, update the position - * of the thread holding the lock */ - thd_remove_from_runnable(m->holder); - thd_add_to_runnable(m->holder, true); + /* Reschedule if currently scheduled. */ + if(m->holder->state == STATE_READY) { + /* Thread list is sorted by priority, update the position + * of the thread holding the lock */ + thd_remove_from_runnable(m->holder); + thd_add_to_runnable(m->holder, true); + } } rv = genwait_wait(m, timeout ? "mutex_lock_timed" : "mutex_lock", @@ -181,7 +189,7 @@ int mutex_trylock(mutex_t *m) { /* If we're inside of an interrupt, pick a special value for the thread that would otherwise be impossible... */ if(irq_inside_int()) - thd = (kthread_t *)0xFFFFFFFF; + thd = IRQ_THREAD; if(m->type < MUTEX_TYPE_NORMAL || m->type > MUTEX_TYPE_RECURSIVE) { errno = EINVAL; @@ -262,12 +270,14 @@ static int mutex_unlock_common(mutex_t *m, kthread_t *thd) { return -1; } - if (thd != (kthread_t *)0xffffffff) - thd->prio = thd->real_prio; - /* If we need to wake up a thread, do so. */ - if(wakeup) + if(wakeup) { + /* Restore real priority in case we were dynamically boosted. */ + if (thd != IRQ_THREAD) + thd->prio = thd->real_prio; + genwait_wake_one(m); + } return 0; } @@ -278,7 +288,7 @@ int mutex_unlock(mutex_t *m) { /* If we're inside of an interrupt, use the special value for the thread from mutex_trylock(). */ if(irq_inside_int()) - thd = (kthread_t *)0xFFFFFFFF; + thd = IRQ_THREAD; return mutex_unlock_common(m, thd); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-11 05:12:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via b96c8042f0e7f9c51dd75216d18164dfb298fe95 (commit) via 8b78cd111a4af8c32f65afbd9baf1eb3ad02f05f (commit) via 3b708837842d9a1c907fb8113b4d616d51e3ba5b (commit) from a11364a33bbd9fd5bbd40ba76743d2a8f0eb9cc0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b96c8042f0e7f9c51dd75216d18164dfb298fe95 Author: Andy Barajas <and...@gm...> Date: Thu Oct 10 22:11:43 2024 -0700 Fix spacing and added more documentation to vmu_set_font() (#809) commit 8b78cd111a4af8c32f65afbd9baf1eb3ad02f05f Merge: a11364a3 3b708837 Author: Donald Haase <qu...@ya...> Date: Thu Oct 10 18:05:18 2024 -0400 Merge pull request #805 from Dreamcast-Projects/vmu_lcd_fix Fix vmu_lcd compile error and extend vmu font API commit 3b708837842d9a1c907fb8113b4d616d51e3ba5b Author: Andress Barajas <and...@gm...> Date: Thu Oct 10 13:24:23 2024 -0700 Fix VMU LCD compile error and update VMU font API - Remove extern vmufb_font4x6 - Handle NULL param in vmu_set_font() - Add id property to font for differentiation ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/vmu/vmu_lcd/lcd.c | 119 +------------------------- kernel/arch/dreamcast/include/dc/vmu_fb.h | 48 +++++------ kernel/arch/dreamcast/util/vmu_fb.c | 133 +++++++++++++++++++++++++++--- kernel/arch/dreamcast/util/vmu_printf.c | 113 +------------------------ 4 files changed, 149 insertions(+), 264 deletions(-) diff --git a/examples/dreamcast/vmu/vmu_lcd/lcd.c b/examples/dreamcast/vmu/vmu_lcd/lcd.c index 49f7a6be..904a7e27 100644 --- a/examples/dreamcast/vmu/vmu_lcd/lcd.c +++ b/examples/dreamcast/vmu/vmu_lcd/lcd.c @@ -30,120 +30,6 @@ #include <arch/arch.h> -/* 4x6 font from the Linux kernel: - https://github.com/torvalds/linux/blob/master/lib/fonts/font_mini_4x6.c - - Modified locally to pack the data better. - - Created by Kenneth Albanowski. - No rights reserved, released to the public domain. - */ -static const char fontdata_4x6[] = { - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, - 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, - 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, - 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, - 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, - 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, - 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, - 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, - 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, - 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, - 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, - 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, - 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, - 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, - 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, - 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, - 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, - 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, - 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, - 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, - 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, - 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, - 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, - 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, - 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, - 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, - 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, - 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, - 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, - 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, - 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, - 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, - 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, - 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, - 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, - 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0x06, 0xc6, 0x00, 0x0c, 0x6c, 0x00, - 0x82, 0x82, 0x82, 0xa5, 0xa5, 0xa5, 0xdb, 0xdb, - 0xdb, 0x44, 0x44, 0x44, 0x44, 0xc4, 0x44, 0x44, - 0xcc, 0x44, 0x66, 0xe6, 0x66, 0x00, 0xe6, 0x66, - 0x00, 0xcc, 0x44, 0x66, 0xee, 0x66, 0x66, 0x66, - 0x66, 0x00, 0xee, 0x66, 0x66, 0xee, 0x00, 0x66, - 0xe0, 0x00, 0x44, 0xcc, 0x00, 0x00, 0xc4, 0x44, - 0x44, 0x70, 0x00, 0x44, 0xf0, 0x00, 0x00, 0xf4, - 0x44, 0x44, 0x74, 0x44, 0x00, 0xf0, 0x00, 0x44, - 0xf4, 0x44, 0x44, 0x77, 0x44, 0x66, 0x76, 0x66, - 0x66, 0x77, 0x00, 0x00, 0x77, 0x66, 0x66, 0xff, - 0x00, 0x00, 0xff, 0x66, 0x66, 0x77, 0x66, 0x00, - 0xff, 0x00, 0x66, 0xff, 0x66, 0x44, 0xff, 0x00, - 0x66, 0xf0, 0x00, 0x00, 0xff, 0x44, 0x00, 0xf6, - 0x66, 0x66, 0x70, 0x00, 0x44, 0x77, 0x00, 0x00, - 0x77, 0x44, 0x00, 0x76, 0x66, 0x66, 0xf6, 0x66, - 0x44, 0xff, 0x44, 0x44, 0xc0, 0x00, 0x00, 0x74, - 0x44, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xcc, - 0xcc, 0xcc, 0x33, 0x33, 0x33, 0xff, 0xf0, 0x00, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0, -}; - -static const vmufb_font_t vmufb_font4x6 = { - .w = 4, - .h = 6, - .stride = 3, - .fontdata = fontdata_4x6, -}; - static const char smiley[] = { 0b00111100, 0b01000010, @@ -164,12 +50,15 @@ KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS); int main(int argc, char **argv) { unsigned int x, y, i, vmu; maple_device_t *dev; + const vmufb_font_t *font; float val; /* If start is pressed, exit the app. */ cont_btn_callback(0, CONT_START, (cont_btn_callback_t)arch_exit); + font = vmu_get_font(); + for(i = 0; ; i++) { vmufb_clear(&vmufb); @@ -179,7 +68,7 @@ int main(int argc, char **argv) { vmufb_paint_area(&vmufb, x, y, 8, 8, smiley); - vmufb_print_string_into(&vmufb, &vmufb_font4x6, + vmufb_print_string_into(&vmufb, font, 12, 12, 24, 6, 0, &message[(i / 16) % sizeof(message)]); diff --git a/kernel/arch/dreamcast/include/dc/vmu_fb.h b/kernel/arch/dreamcast/include/dc/vmu_fb.h index cad3a684..98cc6bef 100644 --- a/kernel/arch/dreamcast/include/dc/vmu_fb.h +++ b/kernel/arch/dreamcast/include/dc/vmu_fb.h @@ -50,6 +50,7 @@ typedef struct vmufb { layout, and a pointer to the raw font data. */ typedef struct vmufb_font { + unsigned int id; /**< Font id */ unsigned int w; /**< Character width in pixels */ unsigned int h; /**< Character height in pixels */ size_t stride; /**< Size of one character in bytes */ @@ -147,9 +148,9 @@ void vmufb_print_string_into(vmufb_t *fb, \param str The text to render */ static __inline__ -void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *fnt, +void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) { - vmufb_print_string_into(fb, fnt, 0, 0, + vmufb_print_string_into(fb, font, 0, 0, VMU_SCREEN_WIDTH, VMU_SCREEN_HEIGHT, 0, str); } @@ -169,37 +170,30 @@ void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *fnt, void vmu_printf(const char *fmt, ...) __printflike(1, 2); /** \brief Sets the default font for drawing text to the VMU. - * - * \warning - * The API does not take ownership of or copy \p font, so - * the given pointer must remain valid as long as it is set - * as the default! - * - * \param font Pointer to the font to set as default - * \returns Pointer to the previous default font - * - * \sa vmu_get_font() + + This function allows you to set a custom font for drawing text + to the VMU screen. If the \p font parameter is set to `NULL`, + the built-in VMU font will be used as the default. + + \warning + The API does not take ownership of or copy \p font, so + the given pointer must remain valid as long as it is set + as the default! + + \param font Pointer to the font to set as default + \returns Pointer to the previous default font + + \sa vmu_get_font() */ const vmufb_font_t *vmu_set_font(const vmufb_font_t *font); /** \brief Returns the default font used to draw text to the VMU. - * - * \returns Pointer to the font currently set as the default - * - * \sa vmu_set_font() - */ -const vmufb_font_t *vmu_get_font(void); -/** \brief Built-in VMU framebuffer font. - * - * \note - * This is the font that is currently used as the default. - * - * Linux 4x6 font: lib/fonts/font_mino_4x6.c - * - * \author Kenneth Albanowski + \returns Pointer to the font currently set as the default + + \sa vmu_set_font() */ -extern const vmufb_font_t vmufb_font4x6; +const vmufb_font_t *vmu_get_font(void); /** @} */ diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c index 1be9e6d6..f590ce8c 100644 --- a/kernel/arch/dreamcast/util/vmu_fb.c +++ b/kernel/arch/dreamcast/util/vmu_fb.c @@ -15,6 +15,118 @@ #define GENMASK(h, l) \ (((unsigned int)-1 << (l)) & ((unsigned int)-1 >> (31 - (h)))) +/* Linux 4x6 font: lib/fonts/font_mini_4x6.c + * + * Created by Kenneth Albanowski. + * No rights reserved, released to the public domain. + */ +static const char fontdata_4x6[] = { + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, + 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, + 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, + 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, + 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, + 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, + 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, + 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, + 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, + 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, + 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, + 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, + 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, + 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, + 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, + 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, + 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, + 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, + 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, + 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, + 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, + 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, + 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, + 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, + 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, + 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, + 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, + 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, + 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, + 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, + 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, + 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, + 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, + 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0x06, 0xc6, 0x00, 0x0c, 0x6c, 0x00, + 0x82, 0x82, 0x82, 0xa5, 0xa5, 0xa5, 0xdb, 0xdb, + 0xdb, 0x44, 0x44, 0x44, 0x44, 0xc4, 0x44, 0x44, + 0xcc, 0x44, 0x66, 0xe6, 0x66, 0x00, 0xe6, 0x66, + 0x00, 0xcc, 0x44, 0x66, 0xee, 0x66, 0x66, 0x66, + 0x66, 0x00, 0xee, 0x66, 0x66, 0xee, 0x00, 0x66, + 0xe0, 0x00, 0x44, 0xcc, 0x00, 0x00, 0xc4, 0x44, + 0x44, 0x70, 0x00, 0x44, 0xf0, 0x00, 0x00, 0xf4, + 0x44, 0x44, 0x74, 0x44, 0x00, 0xf0, 0x00, 0x44, + 0xf4, 0x44, 0x44, 0x77, 0x44, 0x66, 0x76, 0x66, + 0x66, 0x77, 0x00, 0x00, 0x77, 0x66, 0x66, 0xff, + 0x00, 0x00, 0xff, 0x66, 0x66, 0x77, 0x66, 0x00, + 0xff, 0x00, 0x66, 0xff, 0x66, 0x44, 0xff, 0x00, + 0x66, 0xf0, 0x00, 0x00, 0xff, 0x44, 0x00, 0xf6, + 0x66, 0x66, 0x70, 0x00, 0x44, 0x77, 0x00, 0x00, + 0x77, 0x44, 0x00, 0x76, 0x66, 0x66, 0xf6, 0x66, + 0x44, 0xff, 0x44, 0x44, 0xc0, 0x00, 0x00, 0x74, + 0x44, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xcc, + 0xcc, 0xcc, 0x33, 0x33, 0x33, 0xff, 0xf0, 0x00, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, + 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, + 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, + 0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0, +}; + +static const vmufb_font_t vmufb_font4x6 = { + .id = 0, + .w = 4, + .h = 6, + .stride = 3, + .fontdata = fontdata_4x6, +}; + static const vmufb_font_t *default_font = &vmufb_font4x6; static uint64_t extract_bits(const uint8_t *data, @@ -28,10 +140,10 @@ static uint64_t extract_bits(const uint8_t *data, Since we manipulate 8 bits at a time, and neither "w" nor "offt" are required to be byte-aligned, we need to compute a mask of valid bits for each byte that is processed. */ - while (w) { + while(w) { tmp = data[offt / 8]; - if (8 - (offt & 0x7) > w) + if(8 - (offt & 0x7) > w) lsb = 8 - (offt & 0x7) - w; else lsb = 0; @@ -54,10 +166,10 @@ static void insert_bits(uint8_t *data, unsigned int offt, unsigned int w, uint64_t bits) { uint32_t tmp, lsb, nb_bits, mask; - while (w) { + while(w) { tmp = data[offt / 8]; - if (8 - (offt & 0x7) > w) + if(8 - (offt & 0x7) > w) lsb = 8 - (offt & 0x7) - w; else lsb = 0; @@ -82,7 +194,7 @@ void vmufb_paint_area(vmufb_t *fb, unsigned int i; uint64_t bits; - for (i = 0; i < h; i++) { + for(i = 0; i < h; i++) { bits = extract_bits((const uint8_t *)data, i * w, w); insert_bits((uint8_t *)fb->data, (y + i) * VMU_SCREEN_WIDTH + x, w, bits); } @@ -125,7 +237,7 @@ void vmufb_print_string_into(vmufb_t *fb, unsigned int xorig = x, yorig = y; font = font? font : default_font; - for (; *str; str++) { + for(; *str; str++) { switch (*str) { case '\n': x = xorig; @@ -135,13 +247,13 @@ void vmufb_print_string_into(vmufb_t *fb, break; } - if (x > xorig + w - font->w) { + if(x > xorig + w - font->w) { /* We run out of horizontal space - put character on new line */ x = xorig; y += line_spacing + font->h; } - if (y > yorig + h - font->h) { + if(y > yorig + h - font->h) { /* We ran out of space */ break; } @@ -155,10 +267,11 @@ void vmufb_print_string_into(vmufb_t *fb, const vmufb_font_t *vmu_set_font(const vmufb_font_t *font) { const vmufb_font_t *temp = default_font; - default_font = font; + default_font = (font) ? font : &vmufb_font4x6; + return temp; } const vmufb_font_t *vmu_get_font(void) { return default_font; -} \ No newline at end of file +} diff --git a/kernel/arch/dreamcast/util/vmu_printf.c b/kernel/arch/dreamcast/util/vmu_printf.c index 92840001..4a725954 100644 --- a/kernel/arch/dreamcast/util/vmu_printf.c +++ b/kernel/arch/dreamcast/util/vmu_printf.c @@ -1,6 +1,6 @@ /* KallistiOS ##version## - util/vmu_fb.c + util/vmu_printf.c Copyright (C) 2024 Paul Cercueil */ @@ -11,117 +11,6 @@ static vmufb_t vmufb; -/* Linux 4x6 font: lib/fonts/font_mini_4x6.c - * - * Created by Kenneth Albanowski. - * No rights reserved, released to the public domain. - */ -static const char fontdata_4x6[] = { - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0x00, 0x00, 0x00, 0x44, 0x40, 0x40, 0xaa, 0x00, - 0x00, 0xaf, 0xfa, 0x00, 0x46, 0xec, 0x40, 0xa2, - 0x48, 0xa0, 0x69, 0x6a, 0xd0, 0x24, 0x00, 0x00, - 0x24, 0x44, 0x20, 0x42, 0x22, 0x40, 0x0e, 0xee, - 0x00, 0x04, 0xe4, 0x00, 0x00, 0x04, 0x80, 0x00, - 0xe0, 0x00, 0x00, 0x00, 0x40, 0x02, 0x48, 0x00, - 0x4a, 0xaa, 0x40, 0x4c, 0x44, 0xe0, 0xc2, 0x48, - 0xe0, 0xe2, 0x62, 0xe0, 0xaa, 0xe2, 0x20, 0xe8, - 0xe2, 0xe0, 0xe8, 0xea, 0xe0, 0xe2, 0x22, 0x20, - 0xea, 0xea, 0xe0, 0xea, 0xe2, 0x20, 0x00, 0x40, - 0x40, 0x00, 0x40, 0x48, 0x24, 0x84, 0x20, 0x0e, - 0x0e, 0x00, 0x84, 0x24, 0x80, 0xe2, 0x60, 0x40, - 0x4e, 0xe8, 0x40, 0x4a, 0xea, 0xa0, 0xca, 0xca, - 0xc0, 0x68, 0x88, 0x60, 0xca, 0xaa, 0xc0, 0xe8, - 0xe8, 0xe0, 0xe8, 0xe8, 0x80, 0x68, 0xea, 0x60, - 0xaa, 0xea, 0xa0, 0xe4, 0x44, 0xe0, 0x22, 0x2a, - 0x40, 0xaa, 0xca, 0xa0, 0x88, 0x88, 0xe0, 0xae, - 0xea, 0xa0, 0xae, 0xee, 0xa0, 0x4a, 0xaa, 0x40, - 0xca, 0xc8, 0x80, 0x4a, 0xae, 0x60, 0xca, 0xec, - 0xa0, 0x68, 0x42, 0xc0, 0xe4, 0x44, 0x40, 0xaa, - 0xaa, 0x60, 0xaa, 0xa4, 0x40, 0xaa, 0xee, 0xa0, - 0xaa, 0x4a, 0xa0, 0xaa, 0x44, 0x40, 0xe2, 0x48, - 0xe0, 0x64, 0x44, 0x60, 0x08, 0x42, 0x00, 0x62, - 0x22, 0x60, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x0f, - 0x84, 0x00, 0x00, 0x00, 0x6a, 0xe0, 0x88, 0xca, - 0xc0, 0x00, 0x68, 0x60, 0x22, 0x6a, 0x60, 0x0e, - 0xe8, 0x60, 0x24, 0xe4, 0x40, 0x06, 0xa6, 0xe0, - 0x88, 0xca, 0xa0, 0x40, 0x44, 0x40, 0x40, 0x44, - 0x80, 0x08, 0xac, 0xa0, 0x0c, 0x44, 0xe0, 0x00, - 0xee, 0xa0, 0x00, 0xca, 0xa0, 0x04, 0xaa, 0x40, - 0x00, 0xca, 0xc8, 0x00, 0x6a, 0x62, 0x0c, 0xa8, - 0x80, 0x06, 0xc2, 0xc0, 0x04, 0xe4, 0x40, 0x00, - 0xaa, 0x60, 0x00, 0xae, 0x40, 0x00, 0xae, 0xe0, - 0x00, 0xa4, 0xa0, 0x00, 0xae, 0x2c, 0x0e, 0x6c, - 0xe0, 0x24, 0xc4, 0x20, 0x44, 0x44, 0x40, 0x84, - 0x64, 0x80, 0x5a, 0x00, 0x00, 0x4a, 0xae, 0x00, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, - 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, - 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, - 0xe0, 0xee, 0xee, 0xe0, 0xee, 0xee, 0xe0, 0xee, ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |