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-10-10 11:09:04
|
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 a11364a33bbd9fd5bbd40ba76743d2a8f0eb9cc0 (commit) via a3344a04ff8bdc6e1d2f9b2a48a442bb786ddbfd (commit) via 9c311e995eedead63761df6633cd91fbad0ea8d6 (commit) via 51828c0430a67811a51e65968e6664c564d666fd (commit) via d58c96531afa37472c0481881cd36da229a58c67 (commit) via 988263c4633daac7e60eae8bb9224f8e268ede66 (commit) via 2b84a77b08ceccc85b0bc5c0e844c3a34510611f (commit) via 75528f147efafdec89d0e9c4adc120a368852b6c (commit) via 60d5f0652b117bf4ce7922400b613b238df9d47f (commit) via 71c9fc8677dac5bd61757da37368a2032eb15100 (commit) via cae2bfcef1be5904277030d350628f68d115655b (commit) via 42f52062fa39676d75b4d59d1be97b7fdf77a60c (commit) via 1731eff6e4f865ac6037befb04f8b54b4927175a (commit) via ea713ead89a1a140479721ecde68c0b7f466ca4a (commit) via 3eac8bc7592faa9eacb29f18a94cabed961a8e81 (commit) via 805da828bba4ccbbd029d9fb070a3e150eedf8a4 (commit) via 93df6ff88880d15b803d108e8641ad5b7196efef (commit) via d8bf22ad058c4058b09f58133929131a3bb3cf67 (commit) via 5da9f618c9a52ff1e72d194bbdbadd078ebddb12 (commit) via e13a8bb04d295e34d576d35b1cbcda0567954118 (commit) via 59b1e327b8274c5b3bcc521911ffc065cd8c85e3 (commit) from 5170f0311e07c888631138720cf1ee2673166586 (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 a11364a33bbd9fd5bbd40ba76743d2a8f0eb9cc0 Merge: 5170f031 a3344a04 Author: Donald Haase <qu...@ya...> Date: Thu Oct 10 07:07:17 2024 -0400 Merge pull request #759 from JoseAFRibeiro/doc * Starting the doc guide draft * Development of the documentation guidelines * Description of the documentation levels * Where to write what * Style guide and some spelling * information about useful doxygen command --------- Co-authored-by: Falco Girgis <gyr...@gm...> commit a3344a04ff8bdc6e1d2f9b2a48a442bb786ddbfd Merge: 9c311e99 33b84c21 Author: Falco Girgis <gyr...@gm...> Date: Sat Oct 5 10:15:49 2024 -0500 Merge branch 'master' into doc commit 9c311e995eedead63761df6633cd91fbad0ea8d6 Author: Jose Ribeiro <jos...@gm...> Date: Sat Oct 5 11:14:36 2024 +0100 information about useful doxygen command commit 51828c0430a67811a51e65968e6664c564d666fd Author: Jose Ribeiro <jos...@gm...> Date: Sat Oct 5 11:00:09 2024 +0100 More spelling commit d58c96531afa37472c0481881cd36da229a58c67 Author: Jose Ribeiro <jos...@gm...> Date: Sat Oct 5 10:59:06 2024 +0100 Style guide and some spelling commit 988263c4633daac7e60eae8bb9224f8e268ede66 Author: Jose Ribeiro <jos...@gm...> Date: Sun Sep 15 12:46:30 2024 +0100 Little ajustments commit 2b84a77b08ceccc85b0bc5c0e844c3a34510611f Author: Jose Ribeiro <jos...@gm...> Date: Sun Sep 15 12:43:43 2024 +0100 Where to write what commit 75528f147efafdec89d0e9c4adc120a368852b6c Author: Jose Ribeiro <jos...@gm...> Date: Sun Sep 15 12:06:17 2024 +0100 Description of the documentation levels commit 60d5f0652b117bf4ce7922400b613b238df9d47f Author: Jose Ribeiro <jos...@gm...> Date: Fri Sep 13 19:49:04 2024 +0100 Development of the documentation guidelines commit 71c9fc8677dac5bd61757da37368a2032eb15100 Author: Jose Ribeiro <jos...@gm...> Date: Thu Sep 12 21:44:12 2024 +0100 Starting the doc guide draft commit cae2bfcef1be5904277030d350628f68d115655b Merge: 42f52062 63b9b963 Author: José Ribeiro <602...@us...> Date: Mon Sep 9 11:57:22 2024 +0100 Merge branch 'KallistiOS:master' into doc commit 42f52062fa39676d75b4d59d1be97b7fdf77a60c Merge: 1731eff6 002de35d Author: José Ribeiro <602...@us...> Date: Sun Aug 11 16:35:37 2024 +0100 Merge branch 'master' into doc commit 1731eff6e4f865ac6037befb04f8b54b4927175a Author: José Ribeiro <602...@us...> Date: Sun Aug 11 16:16:01 2024 +0100 Update include/kos/fs_romdisk.h Co-authored-by: Falco Girgis <gyr...@gm...> commit ea713ead89a1a140479721ecde68c0b7f466ca4a Author: Jose Ribeiro <jos...@gm...> Date: Sun Aug 11 11:51:30 2024 +0100 Rewworking the line sizes commit 3eac8bc7592faa9eacb29f18a94cabed961a8e81 Author: Jose Ribeiro <jos...@gm...> Date: Sun Aug 11 11:49:28 2024 +0100 Explain how to build and embed fs image commit 805da828bba4ccbbd029d9fb070a3e150eedf8a4 Author: José Ribeiro <602...@us...> Date: Sun Aug 11 10:37:50 2024 +0100 Update include/kos/fs_romdisk.h Co-authored-by: Falco Girgis <gyr...@gm...> commit 93df6ff88880d15b803d108e8641ad5b7196efef Author: Falco Girgis <gyr...@gm...> Date: Thu Aug 8 08:28:35 2024 -0500 Update include/kos/fs_romdisk.h Co-authored-by: Andy Barajas <and...@gm...> commit d8bf22ad058c4058b09f58133929131a3bb3cf67 Author: José Ribeiro <602...@us...> Date: Thu Jul 25 19:07:44 2024 +0100 Update include/kos/fs_romdisk.h Co-authored-by: Andy Barajas <and...@gm...> commit 5da9f618c9a52ff1e72d194bbdbadd078ebddb12 Author: José Ribeiro <602...@us...> Date: Thu Jul 25 19:07:36 2024 +0100 Update include/kos/fs_romdisk.h Co-authored-by: Andy Barajas <and...@gm...> commit e13a8bb04d295e34d576d35b1cbcda0567954118 Author: José Ribeiro <602...@us...> Date: Thu Jul 25 19:07:30 2024 +0100 Update include/kos/fs_romdisk.h Co-authored-by: Andy Barajas <and...@gm...> commit 59b1e327b8274c5b3bcc521911ffc065cd8c85e3 Author: Jose Ribeiro <jos...@gm...> Date: Thu Jul 18 21:27:33 2024 +0100 Reworking FS driver explanation and size warning ----------------------------------------------------------------------- Summary of changes: doc/DOCGUIDE.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 doc/DOCGUIDE.md diff --git a/doc/DOCGUIDE.md b/doc/DOCGUIDE.md new file mode 100644 index 00000000..8d054db0 --- /dev/null +++ b/doc/DOCGUIDE.md @@ -0,0 +1,113 @@ +# Documentation Style Guide + +## A Guide For Writing and Reading KOS' Documentation + +### Documentation Structure + +KallistiOS uses Doxygen to generate documentation from the project's header +files and the following .dox files: + +- attribution.dox +- audio.dox +- debugging.dox +- filesystem.dox +- math.dox +- networking.dox +- peripherals.dox +- system.dox +- threading.dox +- timing.dox +- video.dox + +All of them can be found in the doc folder. + +#### Topics + +Doxygen's documentation is organized in a tree-like structure constructed around +Topics and Files. In KallistiOS, the previously mentioned list of files describes +the top level Topics used to group the corresponding subtopics. As an example, +the audio Topic hosts the Driver, Sound Effects and Streaming subtopics. +Topics can link to Files and other topics as well. + +#### Files + +Files represent (optional) units of documentation that exist under Topics. Doxygen +typically uses them to document specific source or header files. In KallistiOS, +Files are used to list macros, function signatures, function lists and the +headers used in the file. + +--- + +### Documentation Level of Detail + +Different levels of detail are provided in KallistiOS' documentation as a way to +help the reader quickly find their way through the documentation and the OS. +To achieve these two goals, documentation should be written with more +detail as it gets closer to the File level. + +Topic level documentation should aim to inform the reader of what they will find +inside it. A top level Topic description must state the API's purpose and +hardware it might relate to. + +Subtopics are the place to start providing more detailed insights into the API +by describing its capabilities and limitations, providing function descriptions +and alerting the reader to common pitfalls and known issues. Subtopics that +aren't parents to other subtopics should also provide a basic guide into using +the API, with a focus on any setup required to use it and its key +functions. + +At the File level, the documentation should focus on describing the inner +workings of a module as well as more advanced API use cases and data structures. + +#### Linking to Other Pages + +When expanding the documentation, it is good practice to provide links to +important functions or macros mentioned. If a Topic has any type of relationship +with resources that belong to another Topic, Doxygen functionalities should be +used to ensure that the page points to the mentioned resources. +This will help readers reach important pages that might be of their interest. + +--- + +### Where to Write What + +Documentation should be kept in the header files of KallistiOS, while the .dox +files should be used to define groups. As modern IDEs are capable of parsing +Doxygen style documentation, keeping the majority of the documentation inside +header files can prove useful for users as they use KallistiOS' APIs. + +In cases where a module has a top level header and then headers specific to +other parts of the module, documentation should be kept on the specific header +and then use Doxygen commands to present it on the top level header file, if +needed. This allows for documentation to be kept in the corresponding header, +maintaining the ability to use Doxygen's function specific functionalities +without requiring a reorganising of function definitions inside the headers. + +--- + +### Style Guide + +When contributing to the docs (either with new documentation or updates to +existing docs), please make sure you follow this style guide so that everything +stays uniform across pages. + +It is possible that chunks of code or documentation written in some header files +belong on a different page than the one Doxygen is putting them on, but also contains +information that, by virtue of providing IDEs information about the code, must not +be moved. In these cases, Doxygen's `\addtogroup` allows writers to move documentation +blocks around, without changing the header file where it is written + +#### Topic hierarchy + +Top level Topics are defined in their own text file in the `./doc/` folder; its in these files +that their specific subtopics must be declared so that they can be referenced in the header files later. + +##### Functions + +When mentioned in the documentation, functions __must__ link back to their signatures. + +##### See Also + +Relevant macros or pages should be included in this section, so the reader can quickly move to pages that +can be of interest. Structs are also good candidates to this section, as it often isn't possible to cover +all of the thought that went into the members, alignments, padding and packing. \ No newline at end of file hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-09 23:51:08
|
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 5170f0311e07c888631138720cf1ee2673166586 (commit) from 4dd3433c258cb1e7bf3de599c50c49ad5181e851 (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 5170f0311e07c888631138720cf1ee2673166586 Author: Andy Barajas <and...@gm...> Date: Wed Oct 9 16:50:38 2024 -0700 Add pvr palette related examples (#802) ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG.md | 2 + examples/dreamcast/pvr/palette/4bpp/4bpp.c | 181 +++++++++++++++++++ .../{filesystem/pty => pvr/palette/4bpp}/Makefile | 10 +- examples/dreamcast/pvr/palette/8bpp/8bpp.c | 173 ++++++++++++++++++ .../{filesystem/pty => pvr/palette/8bpp}/Makefile | 10 +- .../pty => pvr/palette/wormhole}/Makefile | 9 +- examples/dreamcast/pvr/palette/wormhole/wormhole.c | 198 +++++++++++++++++++++ examples/dreamcast/readme.md | 1 + 8 files changed, 569 insertions(+), 15 deletions(-) create mode 100644 examples/dreamcast/pvr/palette/4bpp/4bpp.c copy examples/dreamcast/{filesystem/pty => pvr/palette/4bpp}/Makefile (76%) create mode 100644 examples/dreamcast/pvr/palette/8bpp/8bpp.c copy examples/dreamcast/{filesystem/pty => pvr/palette/8bpp}/Makefile (76%) copy examples/dreamcast/{filesystem/pty => pvr/palette/wormhole}/Makefile (81%) create mode 100644 examples/dreamcast/pvr/palette/wormhole/wormhole.c diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index f987f66f..736668db 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -9,6 +9,8 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha - Enabled hybrid PVR DR/DMA vertex submission in driver + sped up pvr_prim() [FG] - Add thread priority boosting system [Paul Cercueil = PC] - Add performance monitor API [PC] +- Add/Fixed stat() implementations for all filesystems [AB] +- **Dreamcast**: Add network speedtest and pvr palette examples [AB] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/examples/dreamcast/pvr/palette/4bpp/4bpp.c b/examples/dreamcast/pvr/palette/4bpp/4bpp.c new file mode 100644 index 00000000..04cebaf0 --- /dev/null +++ b/examples/dreamcast/pvr/palette/4bpp/4bpp.c @@ -0,0 +1,181 @@ +/* KallistiOS ##version## + + 4bpp.c + Copyright (C) 2024 Andress Barajas +*/ + +/* + 4bpp example that is a variation of the 8bpp example written by + Tvspelsfreak. + + This demo showcases the use of 4-bit palette-based textures on the Dreamcast. + The demo generates a radial gradient texture in RAM and uploads it to VRAM. + Since the texture uses 4bpp (16 colors), the palette consists of 16 entries, + and the texture is rendered as a static image. The colors in the palette are + continuously cycled through a smooth transition effect, creating an animated + appearance for the static gradient. + + The palette animation is driven by a sine wave function that modulates the + red, green, and blue color channels based on the frame number. The player can + press the START button to exit the demo. +*/ + +#include <stdlib.h> +#include <math.h> + +#include <dc/pvr.h> +#include <dc/maple.h> +#include <dc/fmath.h> +#include <dc/maple/controller.h> + +#define TEXTURE_WIDTH 256 +#define TEXTURE_HEIGHT 256 +#define PALETTE_ENTRY_COUNT 16 + +static pvr_poly_hdr_t hdr; + +static void draw_screen(void) { + pvr_vertex_t vert; + + pvr_prim(&hdr, sizeof(hdr)); + + vert.argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f); + vert.oargb = 0; + vert.flags = PVR_CMD_VERTEX; + + vert.x = 0.0f; + vert.y = 0.0f; + vert.z = 1.0f; + vert.u = 0.0f; + vert.v = 0.0f; + pvr_prim(&vert, sizeof(vert)); + + vert.x = 640.0f; + vert.y = 0.0f; + vert.z = 1.0f; + vert.u = 1.0f; + vert.v = 0.0f; + pvr_prim(&vert, sizeof(vert)); + + vert.x = 0.0f; + vert.y = 480.0f; + vert.z = 1.0f; + vert.u = 0.0f; + vert.v = 1.0f; + pvr_prim(&vert, sizeof(vert)); + + vert.x = 640.0f; + vert.y = 480.0f; + vert.z = 1.0f; + vert.u = 1.0f; + vert.v = 1.0f; + vert.flags = PVR_CMD_VERTEX_EOL; + pvr_prim(&vert, sizeof(vert)); +} + +static float distance(float x0, float y0, float x1, float y1) { + const float dx = x1 - x0; + const float dy = y1 - y0; + + return fsqrt(dx * dx + dy * dy); +} + +static pvr_ptr_t generate_texture(uint32_t width, uint32_t height) { + int i, j, mid_x, mid_y; + float max_dist; + + uint8_t *texbuf; + pvr_ptr_t texptr; + + /* Calculate texture midpoint and greatest distance from the + midpoint to another point for future usage */ + + mid_x = width / 2; + mid_y = height / 2; + max_dist = distance(0, 0, mid_x, mid_y); + + /* Allocate temp storage in RAM to generate texture in */ + texbuf = calloc(width * height / 2, sizeof(uint8_t)); + + /* Generate the texture */ + for(i = 0; i < height; i++) + for(j = 0; j < width; j++) { + uint8_t color = (fsin((distance(j, i, mid_x, mid_y) / max_dist) * F_PI) * 16.0f); + if (j % 2 == 0) + /* Store in high nibble for even pixels */ + texbuf[i * (width / 2) + (j / 2)] = color << 4; + else + /* Store in low nibble for odd pixels */ + texbuf[i * (width / 2) + (j / 2)] |= color; + } + + /* Allocate VRAM for the texture and upload it, twiddling it in the process */ + texptr = pvr_mem_malloc(width * height / 2); + pvr_txr_load_ex(texbuf, texptr, width, height, PVR_TXRLOAD_4BPP); + + /* As the texture is now residing in VRAM, we can free the temp storage + and return the VRAM pointer */ + free(texbuf); + + return texptr; +} + +static void animate_palette(uint32_t frame) { + uint32_t i, val; + + for(i = 0; i < PALETTE_ENTRY_COUNT; i++) { + /* Palette cycling, with a larger step between colors */ + val = (frame + i * 16) & 0xFF; + pvr_set_pal_entry(i, 0xFF00003F | (val << 16) | (val / 2 << 8)); + } +} + +static int check_start(void) { + MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st) + + if(st->buttons & CONT_START) + return 1; + + MAPLE_FOREACH_END() + return 0; +} + +int main(int argc, char** argv) { + uint32_t frame; + pvr_ptr_t texptr; + pvr_poly_cxt_t cxt; + + pvr_init_defaults(); + + /* First select a palette format */ + pvr_set_pal_format(PVR_PAL_ARGB8888); + + /* Initialize the texture */ + texptr = generate_texture(TEXTURE_WIDTH, TEXTURE_HEIGHT); + + /* Setup PVR context */ + pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_PAL4BPP | + PVR_TXRFMT_4BPP_PAL(0), TEXTURE_WIDTH, TEXTURE_HEIGHT, + texptr, PVR_FILTER_BILINEAR); + pvr_poly_compile(&hdr, &cxt); + + frame = 0; + while(!check_start()) { + frame = (frame + 1) % 256; + animate_palette(frame); + + pvr_wait_ready(); + pvr_scene_begin(); + + pvr_list_begin(PVR_LIST_OP_POLY); + + draw_screen(); + + pvr_list_finish(); + pvr_scene_finish(); + } + + pvr_mem_free(texptr); + + return 0; +} diff --git a/examples/dreamcast/filesystem/pty/Makefile b/examples/dreamcast/pvr/palette/4bpp/Makefile similarity index 76% copy from examples/dreamcast/filesystem/pty/Makefile copy to examples/dreamcast/pvr/palette/4bpp/Makefile index 4b6182d5..7cf22c02 100644 --- a/examples/dreamcast/filesystem/pty/Makefile +++ b/examples/dreamcast/pvr/palette/4bpp/Makefile @@ -1,12 +1,11 @@ # -# fs_pty test program -# +# PVR Palette 4bpp example +# Copyright (C) 2011 Tvspelsfreak # Copyright (C) 2024 Andress Barajas # -TARGET = pty.elf - -OBJS = pty.o +TARGET = 4bpp.elf +OBJS = 4bpp.o all: rm-elf $(TARGET) @@ -27,3 +26,4 @@ run: $(TARGET) dist: $(TARGET) -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) + diff --git a/examples/dreamcast/pvr/palette/8bpp/8bpp.c b/examples/dreamcast/pvr/palette/8bpp/8bpp.c new file mode 100644 index 00000000..4adb4489 --- /dev/null +++ b/examples/dreamcast/pvr/palette/8bpp/8bpp.c @@ -0,0 +1,173 @@ +/* KallistiOS ##version## + + 8bpp.c + Copyright (C) 2011 Tvspelsfreak + Copyright (C) 2024 Andress Barajas +*/ + +/* + 8bpp example written by Tvspelsfreak + + This demo showcases a simple use of 8-bit palette-based textures on the + Dreamcast. The demo generates a radial gradient texture in RAM and uploads + it to VRAM. The gradient texture is rendered as a static image, but the colors + in the palette are continuously cycled through a smooth transition effect, + making the gradient appear to animate over time. + + The palette animation is driven by a simple sine wave, with the red, green, + and blue channels modulating based on the frame number. The player can press + the START button to exit the demo. +*/ + +#include <stdlib.h> +#include <math.h> + +#include <dc/pvr.h> +#include <dc/maple.h> +#include <dc/fmath.h> +#include <dc/maple/controller.h> + +#define TEXTURE_WIDTH 256 +#define TEXTURE_HEIGHT 256 +#define PALETTE_ENTRY_COUNT 256 + +static pvr_poly_hdr_t hdr; + +static void draw_screen(void) { + pvr_vertex_t vert; + + pvr_prim(&hdr, sizeof(hdr)); + + vert.argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f); + vert.oargb = 0; + vert.flags = PVR_CMD_VERTEX; + + vert.x = 0.0f; + vert.y = 0.0f; + vert.z = 1.0f; + vert.u = 0.0f; + vert.v = 0.0f; + pvr_prim(&vert, sizeof(vert)); + + vert.x = 640.0f; + vert.y = 0.0f; + vert.z = 1.0f; + vert.u = 1.0f; + vert.v = 0.0f; + pvr_prim(&vert, sizeof(vert)); + + vert.x = 0.0f; + vert.y = 480.0f; + vert.z = 1.0f; + vert.u = 0.0f; + vert.v = 1.0f; + pvr_prim(&vert, sizeof(vert)); + + vert.x = 640.0f; + vert.y = 480.0f; + vert.z = 1.0f; + vert.u = 1.0f; + vert.v = 1.0f; + vert.flags = PVR_CMD_VERTEX_EOL; + pvr_prim(&vert, sizeof(vert)); +} + +static float distance(float x0, float y0, float x1, float y1) { + const float dx = x1 - x0; + const float dy = y1 - y0; + + return fsqrt(dx * dx + dy * dy); +} + +static pvr_ptr_t generate_texture(uint32_t width, uint32_t height) { + int i, j, mid_x, mid_y; + float max_dist; + + uint8_t *texbuf; + pvr_ptr_t texptr; + + /* Calculate texture midpoint and greatest distance from the + midpoint to another point for future usage */ + + mid_x = width / 2; + mid_y = height / 2; + max_dist = distance(0, 0, mid_x, mid_y); + + /* Allocate temp storage in RAM to generate texture in */ + texbuf = calloc(width * height, sizeof(uint8_t)); + + /* Generate the texture */ + for(i = 0; i < height; i++) + for(j = 0; j < width; j++) + texbuf[i * width + j] = fsin((distance(j, i, mid_x, mid_y) / max_dist) * F_PI) * 256.0f; + + /* Allocate VRAM for the texture and upload it, twiddling it in the process */ + texptr = pvr_mem_malloc(width * height); + pvr_txr_load_ex(texbuf, texptr, width, height, PVR_TXRLOAD_8BPP); + + /* As the texture is now residing in VRAM, we can free the temp storage + and return the VRAM pointer */ + free(texbuf); + + return texptr; +} + +static void animate_palette(uint32_t frame) { + uint32_t i, val; + + for(i = 0;i < PALETTE_ENTRY_COUNT; i++) { + val = (frame + i) & 0xFF; + pvr_set_pal_entry(i, 0xFF00003F | ( val << 16 ) | ( val/2 << 8 )); + } +} + +static int check_start(void) { + MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st) + + if(st->buttons & CONT_START) + return 1; + + MAPLE_FOREACH_END() + return 0; +} + +int main(int argc, char** argv) { + uint32_t frame; + pvr_ptr_t texptr; + pvr_poly_cxt_t cxt; + + pvr_init_defaults(); + + /* First select a palette format */ + pvr_set_pal_format(PVR_PAL_ARGB8888); + + /* Initialize the texture */ + texptr = generate_texture(TEXTURE_WIDTH, TEXTURE_HEIGHT); + + /* Setup PVR context */ + pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_PAL8BPP | + PVR_TXRFMT_8BPP_PAL(0), TEXTURE_WIDTH, TEXTURE_HEIGHT, + texptr, PVR_FILTER_BILINEAR); + pvr_poly_compile(&hdr, &cxt); + + frame = 0; + while(!check_start()) { + frame = (frame + 1) % 256; + + animate_palette(frame); + + pvr_wait_ready(); + pvr_scene_begin(); + + pvr_list_begin(PVR_LIST_OP_POLY); + + draw_screen(); + + pvr_list_finish(); + pvr_scene_finish(); + } + + pvr_mem_free(texptr); + + return 0; +} diff --git a/examples/dreamcast/filesystem/pty/Makefile b/examples/dreamcast/pvr/palette/8bpp/Makefile similarity index 76% copy from examples/dreamcast/filesystem/pty/Makefile copy to examples/dreamcast/pvr/palette/8bpp/Makefile index 4b6182d5..62b1b554 100644 --- a/examples/dreamcast/filesystem/pty/Makefile +++ b/examples/dreamcast/pvr/palette/8bpp/Makefile @@ -1,12 +1,11 @@ # -# fs_pty test program -# +# PVR Palette 8bpp example +# Copyright (C) 2011 Tvspelsfreak # Copyright (C) 2024 Andress Barajas # -TARGET = pty.elf - -OBJS = pty.o +TARGET = 8bpp.elf +OBJS = 8bpp.o all: rm-elf $(TARGET) @@ -27,3 +26,4 @@ run: $(TARGET) dist: $(TARGET) -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) + diff --git a/examples/dreamcast/filesystem/pty/Makefile b/examples/dreamcast/pvr/palette/wormhole/Makefile similarity index 81% copy from examples/dreamcast/filesystem/pty/Makefile copy to examples/dreamcast/pvr/palette/wormhole/Makefile index 4b6182d5..03765f07 100644 --- a/examples/dreamcast/filesystem/pty/Makefile +++ b/examples/dreamcast/pvr/palette/wormhole/Makefile @@ -1,12 +1,10 @@ # -# fs_pty test program -# +# PVR Palette wormhole example # Copyright (C) 2024 Andress Barajas # -TARGET = pty.elf - -OBJS = pty.o +TARGET = wormhole.elf +OBJS = wormhole.o all: rm-elf $(TARGET) @@ -27,3 +25,4 @@ run: $(TARGET) dist: $(TARGET) -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) + diff --git a/examples/dreamcast/pvr/palette/wormhole/wormhole.c b/examples/dreamcast/pvr/palette/wormhole/wormhole.c new file mode 100644 index 00000000..e8be75f6 --- /dev/null +++ b/examples/dreamcast/pvr/palette/wormhole/wormhole.c @@ -0,0 +1,198 @@ +/* KallistiOS ##version## + + wormhole.c + Copyright (C) 2024 Andress Barajas +*/ + +/* + This demo demonstrates the use of 8-bit palette-based textures to generate + and animate a wormhole effect on the Dreamcast. The pallete texture is created + programmatically in RAM, simulating a wormhole with radial distortion based + on distance and angle from the center, and then uploaded to VRAM for rendering. + + The wormhole texture consists of grayscale colors ranging from white to dark + gray, while the background remains black. The colors in the wormhole are + continuously cycled in the palette, creating the appearance of a swirling + motion. The palette cycling is handled using a simple offset mechanism, + where the wormholeâs color indices shift over time based on the current frame. + + This effect demonstrates how to use 8-bit textures with dynamic palette + animation, giving the appearance of a smoothly animated wormhole. The player + can press the START button on the controller to exit the demo. +*/ + +#include <stdlib.h> +#include <math.h> ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-09 02: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 4dd3433c258cb1e7bf3de599c50c49ad5181e851 (commit) from b2e9b3801754e805a345ae923bf290c4c847a04a (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 4dd3433c258cb1e7bf3de599c50c49ad5181e851 Author: Paul Cercueil <pa...@cr...> Date: Wed Oct 9 04:12:12 2024 +0200 thread: Improve priority boosting (#801) When failing to obtain an already locked mutex owned by a thread with the same priority than us, we want the other thread to be bumped to the front of the queue, not to the end of the queue. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: kernel/thread/mutex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c index afcd680c..3d438965 100644 --- a/kernel/thread/mutex.c +++ b/kernel/thread/mutex.c @@ -139,7 +139,7 @@ int mutex_lock_timed(mutex_t *m, int timeout) { /* 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, 0); + thd_add_to_runnable(m->holder, true); } rv = genwait_wait(m, timeout ? "mutex_lock_timed" : "mutex_lock", hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-09 00:05: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 b2e9b3801754e805a345ae923bf290c4c847a04a (commit) from d8a5b8379f4e6652ad98f81ccc6d3248c2986cb5 (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 b2e9b3801754e805a345ae923bf290c4c847a04a Author: Andy Barajas <and...@gm...> Date: Tue Oct 8 17:05:21 2024 -0700 Fix unused parameter warning (#800) ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/maple/maple_irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/maple/maple_irq.c b/kernel/arch/dreamcast/hardware/maple/maple_irq.c index 9bddebd5..c5cf21fe 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_irq.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_irq.c @@ -74,7 +74,7 @@ static void vbl_chk_next_subdev(maple_state_t *state, maple_frame_t *frm, int p) } } -static void vbl_dev_probed(maple_state_t *state, int p, int u) { +static void vbl_dev_probed(int p, int u) { maple_device_t *dev = maple_enum_dev(p, 0); if (dev) @@ -173,7 +173,7 @@ static void vbl_autodet_callback(maple_state_t *state, maple_frame_t *frm) { if(u == 0) vbl_chk_subdevs(state, p, resp->src_addr); else - vbl_dev_probed(state, p, u); + vbl_dev_probed(p, u); maple_frame_unlock(frm); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-10-08 19:24:05
|
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 d8a5b8379f4e6652ad98f81ccc6d3248c2986cb5 (commit) via 42cd2b6cec424c4e1c651536ed893675bd76a2b6 (commit) via 67155450e73fa430380a88aee0527d47807380ca (commit) from 98018e6f51e2e7bf6ffe3274e6e8d94769860640 (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 d8a5b8379f4e6652ad98f81ccc6d3248c2986cb5 Merge: 42cd2b6c 67155450 Author: Donald Haase <qu...@ya...> Date: Tue Oct 8 15:22:58 2024 -0400 Merge pull request #799 from pcercuei/fix-nehe26 examples: Fix nehe26 builds commit 42cd2b6cec424c4e1c651536ed893675bd76a2b6 Author: Falco Girgis <gyr...@gm...> Date: Tue Oct 8 14:20:44 2024 -0500 Made builtin font used by vmu_printf() public. (#793) * Made built in font used by vmu_printf() public. - Need a quick font without external dependencies to use with the extended font-drawing methods in the vmufb API? Sweet. We already have one used by vmu_printf() - Now get or set the vmufb font via vmu_get_font() and vmu_set_font(), or directly access the builtin one. commit 67155450e73fa430380a88aee0527d47807380ca Author: Paul Cercueil <pa...@cr...> Date: Tue Oct 8 13:17:36 2024 +0200 examples: Fix nehe26 builds Fix the gldc and KGL builds of nehe26. They caused problems because of the nested data/Makefile. The romdisk files are now generated by the example's main Makefile. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/gldc/nehe/nehe26/Makefile | 12 ++- examples/dreamcast/gldc/nehe/nehe26/data/Makefile | 12 --- .../dreamcast/gldc/nehe/nehe26/romdisk/.empty | 0 .../dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin | Bin 5836 -> 0 bytes .../dreamcast/gldc/nehe/nehe26/romdisk/torus.bin | Bin 5836 -> 0 bytes .../dreamcast/gldc/nehe/nehe26/romdisk/tube.bin | Bin 5836 -> 0 bytes examples/dreamcast/kgl/nehe/nehe26/Makefile | 12 ++- examples/dreamcast/kgl/nehe/nehe26/data/Makefile | 12 --- .../dreamcast/kgl/nehe/nehe26/romdisk/.empty | 0 .../dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin | Bin 5836 -> 0 bytes .../dreamcast/kgl/nehe/nehe26/romdisk/torus.bin | Bin 5836 -> 0 bytes .../dreamcast/kgl/nehe/nehe26/romdisk/tube.bin | Bin 5836 -> 0 bytes kernel/arch/dreamcast/include/dc/vmu_fb.h | 108 ++++++++++++++++----- kernel/arch/dreamcast/util/vmu_fb.c | 18 +++- kernel/arch/dreamcast/util/vmu_printf.c | 8 +- 15 files changed, 125 insertions(+), 57 deletions(-) delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/data/Makefile copy addons/lib/.keepme => examples/dreamcast/gldc/nehe/nehe26/romdisk/.empty (100%) delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin delete mode 100644 examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/data/Makefile copy addons/lib/.keepme => examples/dreamcast/kgl/nehe/nehe26/romdisk/.empty (100%) delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin delete mode 100644 examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin diff --git a/examples/dreamcast/gldc/nehe/nehe26/Makefile b/examples/dreamcast/gldc/nehe/nehe26/Makefile index 6c4816e7..0cccc720 100644 --- a/examples/dreamcast/gldc/nehe/nehe26/Makefile +++ b/examples/dreamcast/gldc/nehe/nehe26/Makefile @@ -7,13 +7,14 @@ TARGET = nehe26.elf OBJS = nehe26.o romdisk.o KOS_ROMDISK_DIR = romdisk +RD_DATA = romdisk/sphere.bin romdisk/torus.bin romdisk/tube.bin all: rm-elf $(TARGET) include $(KOS_BASE)/Makefile.rules clean: rm-elf - -rm -f $(OBJS) + -rm -f $(OBJS) $(RD_DATA) data/txt2bin rm-elf: -rm -f $(TARGET) romdisk.* @@ -28,3 +29,12 @@ dist: $(TARGET) -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) +data/txt2bin: data/txt2bin.c + $(CC) -o $@ $< + +romdisk.img: $(RD_DATA) + +$(RD_DATA): %.bin: data/txt2bin + +$(RD_DATA): romdisk/%.bin: data/%.txt + data/txt2bin $< $@ diff --git a/examples/dreamcast/gldc/nehe/nehe26/data/Makefile b/examples/dreamcast/gldc/nehe/nehe26/data/Makefile deleted file mode 100644 index dcaf81c2..00000000 --- a/examples/dreamcast/gldc/nehe/nehe26/data/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# Kallistios - txt2bin Makefile -# -# (c)2002, Paul Boese -# - -CC = gcc -Wall - -all: - $(CC) -o txt2bin txt2bin.c - -clean: - @rm txt2bin *.bin diff --git a/addons/lib/.keepme b/examples/dreamcast/gldc/nehe/nehe26/romdisk/.empty similarity index 100% copy from addons/lib/.keepme copy to examples/dreamcast/gldc/nehe/nehe26/romdisk/.empty diff --git a/examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin b/examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin deleted file mode 100644 index 6b6db530..00000000 Binary files a/examples/dreamcast/gldc/nehe/nehe26/romdisk/sphere.bin and /dev/null differ diff --git a/examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin b/examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin deleted file mode 100644 index da95c893..00000000 Binary files a/examples/dreamcast/gldc/nehe/nehe26/romdisk/torus.bin and /dev/null differ diff --git a/examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin b/examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin deleted file mode 100644 index 988bc75d..00000000 Binary files a/examples/dreamcast/gldc/nehe/nehe26/romdisk/tube.bin and /dev/null differ diff --git a/examples/dreamcast/kgl/nehe/nehe26/Makefile b/examples/dreamcast/kgl/nehe/nehe26/Makefile index 2a0c4c84..b15db8dc 100644 --- a/examples/dreamcast/kgl/nehe/nehe26/Makefile +++ b/examples/dreamcast/kgl/nehe/nehe26/Makefile @@ -7,13 +7,14 @@ TARGET = nehe26.elf OBJS = nehe26.o romdisk.o KOS_ROMDISK_DIR = romdisk +RD_DATA = romdisk/sphere.bin romdisk/torus.bin romdisk/tube.bin all: rm-elf $(TARGET) include $(KOS_BASE)/Makefile.rules clean: rm-elf - -rm -f $(OBJS) + -rm -f $(OBJS) $(RD_DATA) data/txt2bin rm-elf: -rm -f $(TARGET) romdisk.* @@ -28,3 +29,12 @@ dist: $(TARGET) -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) +data/txt2bin: data/txt2bin.c + $(CC) -o $@ $< + +romdisk.img: $(RD_DATA) + +$(RD_DATA): %.bin: data/txt2bin + +$(RD_DATA): romdisk/%.bin: data/%.txt + data/txt2bin $< $@ diff --git a/examples/dreamcast/kgl/nehe/nehe26/data/Makefile b/examples/dreamcast/kgl/nehe/nehe26/data/Makefile deleted file mode 100644 index dcaf81c2..00000000 --- a/examples/dreamcast/kgl/nehe/nehe26/data/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# Kallistios - txt2bin Makefile -# -# (c)2002, Paul Boese -# - -CC = gcc -Wall - -all: - $(CC) -o txt2bin txt2bin.c - -clean: - @rm txt2bin *.bin diff --git a/addons/lib/.keepme b/examples/dreamcast/kgl/nehe/nehe26/romdisk/.empty similarity index 100% copy from addons/lib/.keepme copy to examples/dreamcast/kgl/nehe/nehe26/romdisk/.empty diff --git a/examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin b/examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin deleted file mode 100644 index 6b6db530..00000000 Binary files a/examples/dreamcast/kgl/nehe/nehe26/romdisk/sphere.bin and /dev/null differ diff --git a/examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin b/examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin deleted file mode 100644 index da95c893..00000000 Binary files a/examples/dreamcast/kgl/nehe/nehe26/romdisk/torus.bin and /dev/null differ diff --git a/examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin b/examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin deleted file mode 100644 index 988bc75d..00000000 Binary files a/examples/dreamcast/kgl/nehe/nehe26/romdisk/tube.bin and /dev/null differ diff --git a/kernel/arch/dreamcast/include/dc/vmu_fb.h b/kernel/arch/dreamcast/include/dc/vmu_fb.h index ae38a21d..cad3a684 100644 --- a/kernel/arch/dreamcast/include/dc/vmu_fb.h +++ b/kernel/arch/dreamcast/include/dc/vmu_fb.h @@ -10,35 +10,50 @@ /** \file dc/vmu_fb.h \brief VMU framebuffer. - \ingroup vmu + \ingroup vmu_fb This file provides an API that can be used to compose a 48x32 image that can then be displayed on the VMUs connected to the system. + + \author Paul Cercueil */ +#include <sys/cdefs.h> +__BEGIN_DECLS + #include <dc/maple.h> +#include <dc/maple/vmu.h> #include <stdint.h> +#include <stdarg.h> + +/** \defgroup vmu_fb Framebuffer + * \ingroup vmu + * + * This API provides a virtual framebuffer abstraction for the VMU with a + * series of convenient methods for drawing complex and dynamic content. + * + * @{ +*/ -/** \brief VMU framebuffer. +/** \brief Virtual framebuffer for the VMU This object contains a 48x32 monochrome framebuffer. It can be painted to, - or displayed one the VMUs connected to the system, using the API below. - - \headerfile dc/vmu_fb.h + or displayed on one the VMUs connected to the system, using the API below. */ -typedef struct { - uint32_t data[48]; +typedef struct vmufb { + uint32_t data[VMU_SCREEN_WIDTH]; /**< Private framebuffer pixel data */ } vmufb_t; /** \brief VMU framebuffer font meta-data. - \headerfile dc/vmu_fb.h + This structure describes a font, including character sizes, + layout, and a pointer to the raw font data. */ -typedef struct { - unsigned int w; /**< \brief Character width in pixels */ - unsigned int h; /**< \brief Character height in pixels */ - unsigned int stride; /**< \brief Size of one character in bytes */ - const char *fontdata; /**< \brief Pointer to the font data */ +typedef struct vmufb_font { + unsigned int w; /**< Character width in pixels */ + unsigned int h; /**< Character height in pixels */ + size_t stride; /**< Size of one character in bytes */ + const char *fontdata; /**< Pointer to the font data */ } vmufb_font_t; /** \brief Render into the VMU framebuffer @@ -103,7 +118,7 @@ void vmufb_present(const vmufb_t *fb, maple_device_t *dev); \param fb A pointer to the vmufb_t to paint to. \param font A pointer to the vmufb_font_t that will be used for - painting the text + painting the text (or NULL to use the default) \param x The horizontal position of the top-left corner of the drawing area, in pixels \param y The vertical position of the top-left corner of the @@ -115,11 +130,11 @@ void vmufb_present(const vmufb_t *fb, maple_device_t *dev); \param str The text to render */ void vmufb_print_string_into(vmufb_t *fb, - const vmufb_font_t *font, - unsigned int x, unsigned int y, - unsigned int w, unsigned int h, - unsigned int line_spacing, - const char *str); + const vmufb_font_t *font, + unsigned int x, unsigned int y, + unsigned int w, unsigned int h, + unsigned int line_spacing, + const char *str); /** \brief Render a string into the VMU framebuffer @@ -128,12 +143,14 @@ void vmufb_print_string_into(vmufb_t *fb, \param fb A pointer to the vmufb_t to paint to. \param font A pointer to the vmufb_font_t that will be used for - painting the text + painting the text (or NULL to use the default) \param str The text to render */ -static __inline__ void -vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) { - vmufb_print_string_into(fb, font, 0, 0, 48, 32, 0, str); +static __inline__ +void vmufb_print_string(vmufb_t *fb, const vmufb_font_t *fnt, + const char *str) { + vmufb_print_string_into(fb, fnt, 0, 0, + VMU_SCREEN_WIDTH, VMU_SCREEN_HEIGHT, 0, str); } /** \brief Render a string to attached VMUs using the built-in font @@ -141,10 +158,51 @@ vmufb_print_string(vmufb_t *fb, const vmufb_font_t *font, const char *str) { Uses the built-in VMU font to render a string to all VMUs connected to the system. + \note + The font currently set as the default font will be used. + \param fmt The format string, optionally followed by extra arguments. + + \sa vmu_set_font() */ -__attribute__ ((format (printf, 1, 2))) -void vmu_printf(const char *fmt, ...); +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() + */ +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 + */ +extern const vmufb_font_t vmufb_font4x6; + +/** @} */ + +__END_DECLS #endif /* __DC_VMU_FB_H */ diff --git a/kernel/arch/dreamcast/util/vmu_fb.c b/kernel/arch/dreamcast/util/vmu_fb.c index 5fc94013..1be9e6d6 100644 --- a/kernel/arch/dreamcast/util/vmu_fb.c +++ b/kernel/arch/dreamcast/util/vmu_fb.c @@ -2,6 +2,7 @@ util/vmu_fb.c Copyright (C) 2023 Paul Cercueil + Copyright (C) 2024 Falco Girgis */ @@ -14,6 +15,8 @@ #define GENMASK(h, l) \ (((unsigned int)-1 << (l)) & ((unsigned int)-1 >> (31 - (h)))) +static const vmufb_font_t *default_font = &vmufb_font4x6; + static uint64_t extract_bits(const uint8_t *data, unsigned int offt, unsigned int w) { uint32_t tmp, lsb, nb_bits; @@ -81,7 +84,7 @@ void vmufb_paint_area(vmufb_t *fb, for (i = 0; i < h; i++) { bits = extract_bits((const uint8_t *)data, i * w, w); - insert_bits((uint8_t *)fb->data, (y + i) * 48 + x, w, bits); + insert_bits((uint8_t *)fb->data, (y + i) * VMU_SCREEN_WIDTH + x, w, bits); } } @@ -92,7 +95,7 @@ void vmufb_clear(vmufb_t *fb) { void vmufb_clear_area(vmufb_t *fb, unsigned int x, unsigned int y, unsigned int w, unsigned int h) { - uint32_t tmp[48] = {}; + uint32_t tmp[VMU_SCREEN_WIDTH] = {}; vmufb_paint_area(fb, x, y, w, h, (const char *) tmp); } @@ -120,6 +123,7 @@ void vmufb_print_string_into(vmufb_t *fb, unsigned int line_spacing, const char *str) { unsigned int xorig = x, yorig = y; + font = font? font : default_font; for (; *str; str++) { switch (*str) { @@ -148,3 +152,13 @@ void vmufb_print_string_into(vmufb_t *fb, x += font->w; } } + +const vmufb_font_t *vmu_set_font(const vmufb_font_t *font) { + const vmufb_font_t *temp = default_font; + default_font = font; + 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 6024415c..92840001 100644 --- a/kernel/arch/dreamcast/util/vmu_printf.c +++ b/kernel/arch/dreamcast/util/vmu_printf.c @@ -115,15 +115,14 @@ static const char fontdata_4x6[] = { 0xee, 0xe0, 0x00, 0x66, 0x00, 0xee, 0xee, 0xe0, }; -static const vmufb_font_t vmufb_font4x6 = { +const vmufb_font_t vmufb_font4x6 = { .w = 4, .h = 6, .stride = 3, .fontdata = fontdata_4x6, }; -void vmu_printf(const char *fmt, ...) -{ +void vmu_printf(const char *fmt, ...) { maple_device_t *dev; unsigned int vmu; char buf[256]; @@ -135,7 +134,8 @@ void vmu_printf(const char *fmt, ...) vsnprintf(buf, sizeof(buf), fmt, va); va_end(va); - vmufb_print_string(&vmufb, &vmufb_font4x6, buf); + vmufb_clear(&vmufb); + vmufb_print_string(&vmufb, vmu_get_font(), buf); for (vmu = 0; ; vmu++) { dev = maple_enum_type(vmu, MAPLE_FUNC_LCD); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-08 13:09: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 98018e6f51e2e7bf6ffe3274e6e8d94769860640 (commit) from d0f35280e58557ae330e5b00d013fb4cc77f1195 (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 98018e6f51e2e7bf6ffe3274e6e8d94769860640 Author: Paul Cercueil <pa...@cr...> Date: Tue Oct 8 15:09:37 2024 +0200 kernel: Add performance monitor API (#795) Add a new performance monitor API, built on top of the performance counters API. The performance monitor API is started with perf_monitor_init(), which takes two performance events (perf_cntr_event_t) that will be monitored aside from the call count and the total time, and is stopped with perf_monitor_exit(). Then, a performance monitor can be added to any functional block using the perf_monitor() macro. The performance will be monitored from the moment the macro is called until the end of the functional block, and the execution statistics of each call will be summed to total numbers. Finally, perf_monitor_print() will display the collected information about the performance monitors. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG.md | 1 + kernel/arch/dreamcast/include/dc/perf_monitor.h | 96 +++++++++++++++++++++++++ kernel/arch/dreamcast/kernel/Makefile | 2 +- kernel/arch/dreamcast/kernel/perf_monitor.c | 63 ++++++++++++++++ utils/ldscripts/shlelf.xc | 8 +++ 5 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 kernel/arch/dreamcast/include/dc/perf_monitor.h create mode 100644 kernel/arch/dreamcast/kernel/perf_monitor.c diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 83a7aed1..f987f66f 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -8,6 +8,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha - Replaced previous implementation of realpath() to remove license from AUTHORS [AB] - Enabled hybrid PVR DR/DMA vertex submission in driver + sped up pvr_prim() [FG] - Add thread priority boosting system [Paul Cercueil = PC] +- Add performance monitor API [PC] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/kernel/arch/dreamcast/include/dc/perf_monitor.h b/kernel/arch/dreamcast/include/dc/perf_monitor.h new file mode 100644 index 00000000..cdf20cdf --- /dev/null +++ b/kernel/arch/dreamcast/include/dc/perf_monitor.h @@ -0,0 +1,96 @@ +/* KallistiOS ##version## + + arch/dreamcast/include/dc/perf_monitor.h + * Copyright (C) 2024 Paul Cercueil + +*/ + +/** \file dc/perf_monitor.h + \brief Low-level performance monitor + \ingroup perf_monitor + + This file contains an API that can be used to monitor specific + performance events in one or several functional blocks. + + \author Paul Cercueil +*/ + +#ifndef __KOS_PERF_MONITOR_H +#define __KOS_PERF_MONITOR_H + +#include <sys/cdefs.h> +__BEGIN_DECLS + +#include <dc/perfctr.h> +#include <stdint.h> +#include <stdio.h> + +/** \defgroup perf_monitor Performance monitor + \brief Code performance monitor + \ingroup debugging + + The performance monitor API is built on top of the performance counter API, + and as such cannot be used at the same time. + With this API, programs can set probe points in different functional blocks + and later obtain statistics about the execution of said functional blocks. + + @{ +*/ + +/** /cond */ +struct perf_monitor { + const char *fn; + unsigned int line; + uint64_t calls; + uint64_t time_ns, time_start; + uint64_t event0, event0_start; + uint64_t event1, event1_start; +}; + +void __stop_perf_monitor(struct perf_monitor **monitor); + +struct perf_monitor *__start_perf_monitor(struct perf_monitor *monitor); + +#define __perf_monitor(f, l) \ + static struct perf_monitor __perf_monitor_##l \ + __attribute__((section(".monitors"))) = { f, l, }; \ + struct perf_monitor *___perf_monitor_##l \ + __attribute__((cleanup(__stop_perf_monitor))) = \ + __start_perf_monitor(&__perf_monitor_##l) + +#define _perf_monitor(f, l) __perf_monitor(f, l) +/** /endcond */ + +/** \brief Register a performance monitor in the current functional block + + The performance monitor will run from the moment this macro is used, till + the end of the functional block. +*/ +#define perf_monitor() _perf_monitor(__func__, __LINE__) + +/** \brief Initialize the performance monitor system + + Set up the performance monitor system. Note that using the performance + monitor system will conflict with any external usage of the performance + counter API. + + \param event1 The first event mode (pef_cntr_event_t). + \param event2 The second event mode (pef_cntr_event_t). +*/ +void perf_monitor_init(perf_cntr_event_t event1, perf_cntr_event_t event2); + +/** \brief De-initialize the performance monitor system + + After this function is called, the performance counter API can be + used again. +*/ +void perf_monitor_exit(void); + +/** \brief Print statistics about the probe points to the given file descriptor + \param f A valid file descriptor to which the messages will + be printed. Use "stdout" for the standard output. +*/ +void perf_monitor_print(FILE *f); + +__END_DECLS +#endif /* __KOS_PERF_MONITOR_H */ diff --git a/kernel/arch/dreamcast/kernel/Makefile b/kernel/arch/dreamcast/kernel/Makefile index 566efc80..7b202f44 100644 --- a/kernel/arch/dreamcast/kernel/Makefile +++ b/kernel/arch/dreamcast/kernel/Makefile @@ -10,7 +10,7 @@ # that minimum set must be present. COPYOBJS = banner.o cache.o entry.o irq.o init.o mm.o panic.o -COPYOBJS += rtc.o timer.o wdt.o perfctr.o +COPYOBJS += rtc.o timer.o wdt.o perfctr.o perf_monitor.o COPYOBJS += init_flags_default.o COPYOBJS += mmu.o itlb.o COPYOBJS += exec.o execasm.o stack.o gdb_stub.o thdswitch.o arch_exports.o diff --git a/kernel/arch/dreamcast/kernel/perf_monitor.c b/kernel/arch/dreamcast/kernel/perf_monitor.c new file mode 100644 index 00000000..bb596078 --- /dev/null +++ b/kernel/arch/dreamcast/kernel/perf_monitor.c @@ -0,0 +1,63 @@ +/* KallistiOS ##version## + + arch/dreamcast/kernel/perf_monitor.c + Copyright (C) 2024 Paul Cercueil +*/ + +#include <arch/timer.h> +#include <dc/perf_monitor.h> + +extern struct perf_monitor _monitors_start, _monitors_end; + +void __stop_perf_monitor(struct perf_monitor **monitor) { + struct perf_monitor *data = *monitor; + + data->event0 += perf_cntr_count(PRFC0) - data->event0_start; + data->event1 += perf_cntr_count(PRFC1) - data->event1_start; + data->time_ns += timer_ns_gettime64() - data->time_start; +} + +struct perf_monitor *__start_perf_monitor(struct perf_monitor *data) { + data->calls++; + data->time_start = timer_ns_gettime64(); + data->event0_start = perf_cntr_count(PRFC0); + data->event1_start = perf_cntr_count(PRFC1); + + return data; +} + +void perf_monitor_init(perf_cntr_event_t event1, perf_cntr_event_t event2) { + perf_cntr_timer_disable(); + + perf_cntr_clear(PRFC0); + perf_cntr_clear(PRFC1); + + perf_cntr_start(PRFC0, event1, PMCR_COUNT_CPU_CYCLES); + perf_cntr_start(PRFC1, event2, PMCR_COUNT_CPU_CYCLES); +} + +void perf_monitor_exit(void) { + perf_cntr_stop(PRFC0); + perf_cntr_stop(PRFC1); + + perf_cntr_clear(PRFC0); + perf_cntr_clear(PRFC1); + + perf_cntr_timer_enable(); +} + +void perf_monitor_print(FILE *f) { + struct perf_monitor *monitor; + + 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, + monitor->calls ? (float)monitor->time_ns / (float)monitor->calls : 0.0f, + monitor->event0, + monitor->event0 ? (float)monitor->event0 / (float)monitor->calls : 0.0f, + monitor->event1, + monitor->event1 ? (float)monitor->event1 / (float)monitor->calls : 0.0f); + } +} diff --git a/utils/ldscripts/shlelf.xc b/utils/ldscripts/shlelf.xc index 907a1d9c..10358882 100644 --- a/utils/ldscripts/shlelf.xc +++ b/utils/ldscripts/shlelf.xc @@ -184,6 +184,14 @@ SECTIONS *(.sdata .sdata.* .gnu.linkonce.s.*) } _edata = .; PROVIDE (edata = .); + . = ALIGN(8); + __monitors_start = .; + .monitors : + { + *(.monitors) + } + __monitors_end = .; + . = ALIGN(8); __bss_start = .; .sbss : { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-08 10:27: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 d0f35280e58557ae330e5b00d013fb4cc77f1195 (commit) from 8eed75b86e84a8459075e658ba840d563a70a633 (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 d0f35280e58557ae330e5b00d013fb4cc77f1195 Author: Andy Barajas <and...@gm...> Date: Tue Oct 8 03:27:25 2024 -0700 Improve diagnose message (#614) * Handle invalid PC and PR addresses. Make sure addresses are in the text section of program * Make the logic more clear * Add options to demangle C++ symbols, show function names, print inlined function calls ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/arch/arch.h | 14 ++++++++++ kernel/arch/dreamcast/kernel/irq.c | 44 ++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h index acb750d2..e944762b 100644 --- a/kernel/arch/dreamcast/include/arch/arch.h +++ b/kernel/arch/dreamcast/include/arch/arch.h @@ -40,6 +40,10 @@ extern uint32 _arch_mem_top; #define _arch_mem_top ((uint32) 0x8d000000) #endif +/** \brief Start and End address for .text portion of program. */ +extern char _executable_start; +extern char _etext; + #define PAGESIZE 4096 /**< \brief Page size (for MMU) */ #define PAGESIZE_BITS 12 /**< \brief Bits for page size */ #define PAGEMASK (PAGESIZE - 1) /**< \brief Mask for page offset */ @@ -415,6 +419,16 @@ const char *kos_get_authors(void); */ #define arch_valid_address(ptr) ((ptr_t)(ptr) >= 0x8c010000 && (ptr_t)(ptr) < _arch_mem_top) +/** \brief Returns true if the passed address is in the text section of your + program. + \ingroup arch + + \return Whether the address is valid or not for text + memory access. +*/ +#define arch_valid_text_address(ptr) \ + ((uintptr_t)(ptr) >= (uintptr_t)&_executable_start && (uintptr_t)(ptr) < (uintptr_t)&_etext) + __END_DECLS #endif /* __ARCH_ARCH_H */ diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c index dbb75e01..b5ad0eec 100644 --- a/kernel/arch/dreamcast/kernel/irq.c +++ b/kernel/arch/dreamcast/kernel/irq.c @@ -124,6 +124,8 @@ extern irq_context_t *irq_srt_addr; static void irq_dump_regs(int code, int evt) { uint32_t fp; uint32_t *regs = irq_srt_addr->r; + bool valid_pc; + bool valid_pr; dbglog(DBG_DEAD, "Unhandled exception: PC %08lx, code %d, evt %04x\n", irq_srt_addr->pc, code, (uint16)evt); @@ -136,27 +138,39 @@ static void irq_dump_regs(int code, int evt) { arch_stk_trace_at(fp, 0); if(code == 1) { - dbglog(DBG_DEAD, "Encountered %s. Use this terminal command to help" - " diagnose:\n\n\t$KOS_ADDR2LINE -e your_program.elf %08lx %08lx", - irq_exception_string(evt), irq_srt_addr->pc, irq_srt_addr->pr); + dbglog(DBG_DEAD, "\nEncountered %s. ", irq_exception_string(evt)); + + valid_pc = arch_valid_text_address(irq_srt_addr->pc); + valid_pr = arch_valid_text_address(irq_srt_addr->pr); + /* Construct template message only if either PC/PR address is valid */ + if(valid_pc || valid_pr) { + dbglog(DBG_DEAD, "Use this template terminal command to help" + " diagnose:\n\n\t$KOS_ADDR2LINE -f -C -i -e prog.elf"); + + if(valid_pc) + dbglog(DBG_DEAD, " %08lx", irq_srt_addr->pc); + + if(valid_pr) + dbglog(DBG_DEAD, " %08lx", irq_srt_addr->pr); #ifdef FRAME_POINTERS - while(fp != 0xffffffff) { - /* Validate the function pointer (fp) */ - if((fp & 3) || (fp < 0x8c000000) || (fp > _arch_mem_top)) - break; + while(fp != 0xffffffff) { + /* Validate the function pointer (fp) */ + if((fp & 3) || (fp < 0x8c000000) || (fp > _arch_mem_top)) + break; - /* Get the return address from the function pointer */ - fp = arch_fptr_ret_addr(fp); + /* Get the return address from the function pointer */ + fp = arch_fptr_ret_addr(fp); - /* Validate the return address */ - if(!arch_valid_address(fp)) - break; + /* Validate the return address */ + if(!arch_valid_text_address(fp)) + break; - dbglog(DBG_DEAD, " %08lx", fp); - fp = arch_fptr_next(fp); - } + dbglog(DBG_DEAD, " %08lx", fp); + fp = arch_fptr_next(fp); + } #endif + } dbglog(DBG_DEAD, "\n"); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-08 08: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, master has been updated via 8eed75b86e84a8459075e658ba840d563a70a633 (commit) from 9e86e5a61343d1745f07e23fd3dad69393950138 (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 8eed75b86e84a8459075e658ba840d563a70a633 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...> ----------------------------------------------------------------------- Summary of changes: kernel/debug/dbgio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/debug/dbgio.c b/kernel/debug/dbgio.c index 9b80e7f1..a7ecb9f8 100644 --- a/kernel/debug/dbgio.c +++ b/kernel/debug/dbgio.c @@ -51,7 +51,7 @@ const char * dbgio_dev_get(void) { return dbgio->name; } -static int dbgio_enabled = 1; +static int dbgio_enabled = 0; void dbgio_enable(void) { dbgio_enabled = 1; } @@ -72,6 +72,7 @@ int dbgio_init(void) { // next one anyway. if(!dbgio->init()) { // Worked. + dbgio_enable(); return 0; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-08 08:08:47
|
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 9e86e5a61343d1745f07e23fd3dad69393950138 (commit) via 2ea7584169179ef8a2d5d1971d8be1007ff93a50 (commit) via 93a780da0b042e4e9a535d3990f74ab416da376c (commit) from dab8d5dbaed1e6820e6eb037fed87c6263351ed6 (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 9e86e5a61343d1745f07e23fd3dad69393950138 Merge: 2ea75841 93a780da Author: Donald Haase <qu...@ya...> Date: Tue Oct 8 04:07:35 2024 -0400 Merge pull request #783 from pcercuei/prio-boosting thread: Add priority boosting system commit 2ea7584169179ef8a2d5d1971d8be1007ff93a50 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 93a780da0b042e4e9a535d3990f74ab416da376c Author: Paul Cercueil <pa...@cr...> Date: Wed Oct 2 16:31:11 2024 +0200 thread: Add priority boosting system Introduce a new 'real_prio' field into the thread structure, which contains the static priority set during the thread creation or with thd_set_prio(). The 'prio' field now represents the dynamic priority. When a low-priority thread A holds a lock, and a high-priority thread B requests it, the dynamic priority of A will be temporarily raised to the dynamic priority of B, until A releases the lock, in which case it falls back to its static priority. The point of this setup is to avoid starvation, where a low-priority thread holds a resource that is needed by a high-priority thread, and won't release it because it rarely gets preempted. This is not yet perfect, as we can imagine a setup where a low-priority thread A holds two locks, each one requested by different high-priority tasts B and C; A would get boosted to B's dynamic priority, and when releasing the lock, reset to its original low priority, causing thread C to starve. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG.md | 1 + include/kos/thread.h | 5 ++++- kernel/thread/mutex.c | 12 ++++++++++++ kernel/thread/thread.c | 2 ++ utils/pvrtex/Makefile | 2 +- utils/pvrtex/mem.c | 2 +- utils/pvrtex/pvr_texture_encoder.c | 6 ++---- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index fad4dd20..83a7aed1 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -7,6 +7,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha - Added . & .. directories to filesystems that lack it [AB] - Replaced previous implementation of realpath() to remove license from AUTHORS [AB] - Enabled hybrid PVR DR/DMA vertex submission in driver + sped up pvr_prim() [FG] +- Add thread priority boosting system [Paul Cercueil = PC] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/include/kos/thread.h b/include/kos/thread.h index e5c80a3a..f78d5b81 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -182,9 +182,12 @@ typedef __attribute__((aligned(32))) struct kthread { /** \brief Kernel thread id. */ tid_t tid; - /** \brief Static priority: 0..PRIO_MAX (higher means lower priority). */ + /** \brief Dynamic priority */ prio_t prio; + /** \brief Static priority: 0..PRIO_MAX (higher means lower priority). */ + prio_t real_prio; + /** \brief Thread flags. */ kthread_flags_t flags; diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c index 38abc2ed..afcd680c 100644 --- a/kernel/thread/mutex.c +++ b/kernel/thread/mutex.c @@ -133,6 +133,15 @@ int mutex_lock_timed(mutex_t *m, int timeout) { deadline = timer_ms_gettime64() + timeout; for(;;) { + 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, 0); + } + rv = genwait_wait(m, timeout ? "mutex_lock_timed" : "mutex_lock", timeout, NULL); if(rv < 0) { @@ -253,6 +262,9 @@ 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) genwait_wake_one(m); diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c index 69c1e8b7..9297d0a1 100644 --- a/kernel/thread/thread.c +++ b/kernel/thread/thread.c @@ -516,6 +516,7 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr, /* Set Thread Pointer */ nt->context.gbr = (uint32_t)nt->tcbhead; nt->tid = tid; + nt->real_prio = real_attr.prio; nt->prio = real_attr.prio; nt->state = STATE_READY; @@ -627,6 +628,7 @@ int thd_set_prio(kthread_t *thd, prio_t prio) { /* Set the new priority */ thd->prio = prio; + thd->real_prio = prio; return 0; } diff --git a/utils/pvrtex/Makefile b/utils/pvrtex/Makefile index f68f5576..87586755 100644 --- a/utils/pvrtex/Makefile +++ b/utils/pvrtex/Makefile @@ -16,7 +16,7 @@ else CXXFLAGS += -O3 endif -CFLAGS := $(CXXFLAGS) -Wno-pointer-sign +CFLAGS := $(CXXFLAGS) -Wno-pointer-sign -std=gnu17 define textSegment2Header mkdir -p info diff --git a/utils/pvrtex/mem.c b/utils/pvrtex/mem.c index 84f3796d..a8357cfe 100644 --- a/utils/pvrtex/mem.c +++ b/utils/pvrtex/mem.c @@ -67,7 +67,7 @@ void free(void *ptr); * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags. * Note that this will cost performance. */ -static atomic_size_t max_alloc_size = ATOMIC_VAR_INIT(INT_MAX); +static atomic_size_t max_alloc_size = INT_MAX; void av_max_alloc(size_t max){ atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed); diff --git a/utils/pvrtex/pvr_texture_encoder.c b/utils/pvrtex/pvr_texture_encoder.c index d101eeb7..c3656068 100644 --- a/utils/pvrtex/pvr_texture_encoder.c +++ b/utils/pvrtex/pvr_texture_encoder.c @@ -837,7 +837,7 @@ void pteAutoSelectPixelFormat(PvrTexEncoder *pte) { assert(pte); assert(pte->src_img_cnt); - unsigned clearpix = 0, halfpix = 0, opaquepix = 0; + unsigned clearpix = 0, halfpix = 0; for(int j = 0; j < pte->src_img_cnt; j++) { pteImage *img = pte->src_imgs + j; @@ -846,9 +846,7 @@ void pteAutoSelectPixelFormat(PvrTexEncoder *pte) { int a = img->pixels[i].a; if (a == 0) clearpix++; - else if (a == 0xff) - opaquepix++; - else + else if (a != 0xff) halfpix++; } } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-08 07:26:47
|
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 dab8d5dbaed1e6820e6eb037fed87c6263351ed6 (commit) via 651612b9681a91ac823b64ae022fab115e804c0e (commit) via 0fa45d13b934fad0392e9841ec7850e813b863d2 (commit) from feec65c7081b946d143399aa71d4f1ce61a3fd94 (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 dab8d5dbaed1e6820e6eb037fed87c6263351ed6 Author: Paul Cercueil <pa...@cr...> Date: Tue Oct 8 09:26:10 2024 +0200 Speed up building KOS and examples (#573) * examples: Allow building all examples in parallel Instead of building all the examples sequentially in a single thread, build all of them in parallel. The Makefile will first generate a list of all the sub-folders that contain a Makefile, and all of them will be added to the list of phony rules. The default target will then depend on that sub-directory list, running Make recursively on each of those subdirectories, also using the special $(MAKE) variable so that the same jobserver is used. Because of that, all the Makefiles used only for recursion are useless now and can be dropped. On my PC (i7-10850H 12-core), when building with LTO running 'time make -j12 -C examples/dreamcast/' used to take about 8min 15s, and now takes about 1min 24s, while compiling more examples, as previously the gldc/ examples were not compiled. Signed-off-by: Paul Cercueil <pa...@cr...> * utils: Use top-level Makefile rules for subdirs Instead of rolling our own rules for handling the sub-directories, include the top-level Makefile.rules and add a dependency on the "subdirs" rule. This actually speeds up the build quite a bit, as the default rule uses $(MAKE) instead of $(KOS_MAKE), which means that the "make" program will be able to use its jobserver. Signed-off-by: Paul Cercueil <pa...@cr...> * addons: Allow building all addons in parallel Just like for the examples, generate the list of sub-directories using a Makefile rule; and build the sub-directories using the general "subdirs" rule, which will be much faster as the "make" program will be able to use its jobserver. Signed-off-by: Paul Cercueil <pa...@cr...> * Makefile: Allow building in parallel Build the sub-directories using the general "subdirs" rule, which will be much faster as the "make" program will be able to use its jobserver. Signed-off-by: Paul Cercueil <pa...@cr...> * examples: Allow examples to override the compatible KOS subarchs The examples can override KOS_BUILD_SUBARCHS in their Makefile, to override the list of compatible subarchs. Signed-off-by: Paul Cercueil <pa...@cr...> * examples: Override build subarchs for examples not Naomi-compatible Some examples are not compatible with the Naomi, because they try to use hardware that the Naomi does not have (e.g. the modem). For those examples, set KOS_BUILD_SUBARCHS to "pristine", so that they will only build for the "pristine" (aka. "dreamcast") sub-architecture. Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> commit 651612b9681a91ac823b64ae022fab115e804c0e 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 0fa45d13b934fad0392e9841ec7850e813b863d2 Author: Donald Haase <qu...@ya...> Date: Tue Oct 8 01:04:10 2024 -0400 Adjust example for lack of 'valid' member of dev (#796) Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: Makefile | 17 +++-- Makefile.rules | 9 +++ addons/Makefile | 12 ++-- examples/Makefile | 41 ++++++++++-- examples/dreamcast/Makefile | 82 ------------------------ examples/dreamcast/basic/Makefile | 41 ------------ examples/dreamcast/basic/fpu/Makefile | 16 ----- examples/dreamcast/basic/mmu/Makefile | 19 ------ examples/dreamcast/basic/threading/Makefile | 38 ----------- examples/dreamcast/conio/Makefile | 25 -------- examples/dreamcast/cpp/Makefile | 31 --------- examples/dreamcast/dev/Makefile | 25 -------- examples/dreamcast/dreameye/Makefile | 18 ------ examples/dreamcast/filesystem/Makefile | 22 ------- examples/dreamcast/filesystem/sd/Makefile | 20 ------ examples/dreamcast/g1ata/Makefile | 14 ---- examples/dreamcast/g1ata/atatest/Makefile | 1 + examples/dreamcast/gldc/Makefile | 22 ------- examples/dreamcast/gldc/basic/Makefile | 27 -------- examples/dreamcast/gldc/benchmarks/Makefile | 21 ------ examples/dreamcast/gldc/nehe/Makefile | 25 -------- examples/dreamcast/keyboard/Makefile | 14 ---- examples/dreamcast/kgl/Makefile | 25 -------- examples/dreamcast/kgl/basic/Makefile | 27 -------- examples/dreamcast/kgl/benchmarks/Makefile | 21 ------ examples/dreamcast/kgl/demos/Makefile | 29 --------- examples/dreamcast/kgl/nehe/Makefile | 25 -------- examples/dreamcast/libdream/Makefile | 28 -------- examples/dreamcast/lightgun/Makefile | 13 ---- examples/dreamcast/lua/Makefile | 16 ----- examples/dreamcast/modem/Makefile | 15 ----- examples/dreamcast/modem/basic/Makefile | 2 + examples/dreamcast/modem/ppp/Makefile | 2 + examples/dreamcast/mruby/Makefile | 17 ----- examples/dreamcast/network/Makefile | 38 ----------- examples/dreamcast/network/basic/Makefile | 3 + examples/dreamcast/network/dns-client/Makefile | 3 + examples/dreamcast/network/httpd/Makefile | 3 + examples/dreamcast/network/isp-settings/Makefile | 1 + examples/dreamcast/network/ntp/Makefile | 3 + examples/dreamcast/network/ping/Makefile | 3 + examples/dreamcast/network/ping6/Makefile | 3 + examples/dreamcast/network/speedtest/Makefile | 1 + examples/dreamcast/network/udpecho6/Makefile | 3 + examples/dreamcast/objc/Makefile | 14 ---- examples/dreamcast/parallax/Makefile | 18 ------ examples/dreamcast/pvr/Makefile | 44 ------------- examples/dreamcast/pvr/yuv_converter/Makefile | 17 ----- examples/dreamcast/rumble/rumble.c | 6 +- examples/dreamcast/sdl/Makefile | 22 ------- examples/dreamcast/sound/Makefile | 31 --------- examples/dreamcast/sound/cdda/Makefile | 16 ----- examples/dreamcast/tsunami/Makefile | 22 ------- examples/dreamcast/video/Makefile | 26 -------- examples/dreamcast/vmu/Makefile | 23 ------- kernel/arch/dreamcast/include/dc/matrix.h | 4 +- utils/Makefile | 12 ++-- 57 files changed, 97 insertions(+), 979 deletions(-) delete mode 100644 examples/dreamcast/Makefile delete mode 100644 examples/dreamcast/basic/Makefile delete mode 100644 examples/dreamcast/basic/fpu/Makefile delete mode 100644 examples/dreamcast/basic/mmu/Makefile delete mode 100644 examples/dreamcast/basic/threading/Makefile delete mode 100644 examples/dreamcast/conio/Makefile delete mode 100644 examples/dreamcast/cpp/Makefile delete mode 100644 examples/dreamcast/dev/Makefile delete mode 100644 examples/dreamcast/dreameye/Makefile delete mode 100644 examples/dreamcast/filesystem/Makefile delete mode 100644 examples/dreamcast/filesystem/sd/Makefile delete mode 100644 examples/dreamcast/g1ata/Makefile delete mode 100644 examples/dreamcast/gldc/Makefile delete mode 100644 examples/dreamcast/gldc/basic/Makefile delete mode 100644 examples/dreamcast/gldc/benchmarks/Makefile delete mode 100644 examples/dreamcast/gldc/nehe/Makefile delete mode 100644 examples/dreamcast/keyboard/Makefile delete mode 100644 examples/dreamcast/kgl/Makefile delete mode 100644 examples/dreamcast/kgl/basic/Makefile delete mode 100644 examples/dreamcast/kgl/benchmarks/Makefile delete mode 100644 examples/dreamcast/kgl/demos/Makefile delete mode 100644 examples/dreamcast/kgl/nehe/Makefile delete mode 100644 examples/dreamcast/libdream/Makefile delete mode 100644 examples/dreamcast/lightgun/Makefile delete mode 100644 examples/dreamcast/lua/Makefile delete mode 100644 examples/dreamcast/modem/Makefile delete mode 100644 examples/dreamcast/mruby/Makefile delete mode 100644 examples/dreamcast/network/Makefile delete mode 100644 examples/dreamcast/objc/Makefile delete mode 100644 examples/dreamcast/parallax/Makefile delete mode 100644 examples/dreamcast/pvr/Makefile delete mode 100644 examples/dreamcast/pvr/yuv_converter/Makefile delete mode 100644 examples/dreamcast/sdl/Makefile delete mode 100644 examples/dreamcast/sound/Makefile delete mode 100644 examples/dreamcast/sound/cdda/Makefile delete mode 100644 examples/dreamcast/tsunami/Makefile delete mode 100644 examples/dreamcast/video/Makefile delete mode 100644 examples/dreamcast/vmu/Makefile diff --git a/Makefile b/Makefile index 584de843..adb02749 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,8 @@ # here too. ;-) KOS_CFLAGS += -Wextra -Wno-deprecated -# Add stuff to DIRS to auto-compile it with the big tree. -DIRS = utils -DIRS += kernel addons # examples +# Add stuff to SUBDIRS to auto-compile it with the big tree. +SUBDIRS = utils kernel addons # examples # Detect a non-working or missing environ.sh file. ifndef KOS_BASE @@ -24,11 +23,9 @@ error: @exit 0 endif -all: - for i in $(DIRS); do $(KOS_MAKE) -C $$i || exit -1; done +all: subdirs -clean: - for i in $(DIRS); do $(KOS_MAKE) -C $$i clean || exit -1; done +clean: clean_subdirs distclean: clean -rm -f lib/$(KOS_ARCH)/* @@ -53,7 +50,9 @@ kos-ports_distclean: kos-ports_clean $(KOS_PORTS)/utils/uninstall-all.sh all_auto_kos_base: - $(KOS_MAKE) all KOS_BASE=$(CURDIR) + $(MAKE) all KOS_BASE=$(CURDIR) clean_auto_kos_base: - $(KOS_MAKE) clean KOS_BASE=$(CURDIR) + $(MAKE) clean KOS_BASE=$(CURDIR) + +include $(KOS_BASE)/Makefile.rules diff --git a/Makefile.rules b/Makefile.rules index bcd35e88..678c882a 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -7,6 +7,9 @@ # Global KallistiOS Makefile include +# Default build archs +KOS_BUILD_SUBARCHS ?= naomi pristine + # Build rules ifndef KOS_DEPDIR @@ -46,6 +49,12 @@ else endif +.PHONY: all_naomi all_pristine + +all_naomi: $(if $(filter $(KOS_BUILD_SUBARCHS),naomi),all) + +all_pristine: $(if $(filter $(KOS_BUILD_SUBARCHS),pristine),all) + %.o: %.s kos-as $< -o $@ diff --git a/addons/Makefile b/addons/Makefile index ff1ac628..5534cc54 100644 --- a/addons/Makefile +++ b/addons/Makefile @@ -23,10 +23,12 @@ # Get our list of dirs to build/clean. You must have sed installed for this # to work (GNU textutils). -BUILD_LIST := `ls */kos/$(KOS_ARCH).cnf | sed -e "s%/kos/$(KOS_ARCH).cnf%%g"` +get_subdirs=$(foreach each,$(wildcard $(1)/*),$(if $(wildcard $(each)/kos/$(KOS_ARCH).cnf),$(each),) $(call get_subdirs,$(each))) -all: - for i in $(BUILD_LIST); do $(KOS_MAKE) -C $$i || exit -1; done +SUBDIRS := $(call get_subdirs, $(shell pwd)) -clean: - for i in $(BUILD_LIST); do $(KOS_MAKE) -C $$i clean || exit -1; done +all: subdirs + +clean: clean_subdirs + +include $(KOS_BASE)/Makefile.rules diff --git a/examples/Makefile b/examples/Makefile index 4dbfc468..b64be788 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,13 +1,42 @@ # KallistiOS ##version## # -# examples/Makefile -# (c)2001 Megan Potter +# examples/dreamcast/Makefile +# Copyright (C) 2003 Megan Potter +# Copyright (C) 2024 Andy Barajas +# Copyright (C) 2024 Paul Cercueil # -all: - $(KOS_MAKE) -C $(KOS_ARCH) +# Get a list of the sub-directories that contain a Makefile +get_subdirs=$(foreach each,$(wildcard $(1)/*),$(if $(wildcard $(each)/Makefile),$(each),) $(call get_subdirs,$(each))) + +DIRS := $(call get_subdirs, $(shell pwd)) + +.PHONY: all $(DIRS) + +all: $(DIRS) + @error_count=$$(cat error_count.txt 2>/dev/null || echo 0); \ + if [ -f errors.txt ]; then \ + echo "\n-------------------------------------------------"; \ + echo "$$error_count error(s) occurred during the build process:"; \ + cat errors.txt; \ + fi; \ + rm -f errors.txt error_count.txt; \ + exit $$error_count + +$(DIRS): + @$(MAKE) -C $@ all_$(KOS_SUBARCH) ; \ + rv=$$? ; \ + if [ "$$rv" -ne 0 ]; then \ + echo "$(subst $(shell pwd)/,,$@): Build failed with return code $$rv" >> errors.txt; \ + echo $$(($$(cat error_count.txt 2>/dev/null || echo 0) + 1)) > error_count.txt; \ + fi clean: - $(KOS_MAKE) -C $(KOS_ARCH) clean - + @for dir in $(DIRS); do \ + $(MAKE) -C $$dir clean; \ + done +dist: + @for dir in $(DIRS); do \ + $(MAKE) -C $$dir dist; \ + done diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile deleted file mode 100644 index fb58d7e8..00000000 --- a/examples/dreamcast/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/Makefile -# Copyright (C) 2003 Megan Potter -# Copyright (C) 2024 Andy Barajas -# - -DIRS = 2ndmix basic libdream kgl hello sound png vmu conio pvr video \ - lua parallax dreameye filesystem lightgun keyboard sdl dev rumble \ - micropython - -ifneq ($(KOS_SUBARCH), naomi) - DIRS += network modem g1ata -endif - -ifdef KOS_CCPLUS - DIRS += cpp tsunami -endif - -.PHONY: all - -all: - @for dir in $(DIRS); do \ - $(KOS_MAKE) check-dir DIR=$$dir; \ - done; - - @error_count=$$(cat error_count.txt 2>/dev/null || echo 0); \ - if [ -f errors.txt ]; then \ - echo "\n-------------------------------------------------"; \ - echo "$$error_count error(s) occurred during the build process:"; \ - cat errors.txt; \ - fi; \ - rm -f errors.txt error_count.txt; \ - exit $$error_count - -# ALGORITHM EXPLANATION: -# This script recursively checks each directory to determine if it should -# execute its Makefile based on the presence of Makefiles in its subdirectories. -# -# Steps: -# 1. For each directory, identify all direct subdirectories. -# 2. Check each subdirectory for the existence of a Makefile. -# 3. If any subdirectory contains a Makefile, recursively perform this check on -# that subdirectory and do not execute the Makefile in the current directory. -# 4. If no subdirectories contain a Makefile, execute the Makefile in the -# current directory. -# -# Purpose: -# - This approach ensures that Makefiles are only executed in the most specific -# (deepest) directories that do not contain further subdirectories with -# Makefiles. -# - This prevents redundant builds in parent directories and ensures errors are -# logged with specific directory paths, providing clear visibility into which -# particular build process failed without aggregating errors at a higher -# directory level. -check-dir: - @should_make="yes"; \ - for subdir in $(DIR)/*; do \ - if [ -e "$$subdir/Makefile" ]; then \ - should_make="no"; \ - $(KOS_MAKE) check-dir DIR=$$subdir; \ - fi; \ - done; \ - if [ "$$should_make" = "yes" ]; then \ - $(KOS_MAKE) -C $(DIR); \ - rv=$$?; \ - if [ "$$rv" -ne 0 ]; then \ - echo "$(DIR): Build failed with return code $$rv" >> errors.txt; \ - echo $$(($$(cat error_count.txt 2>/dev/null || echo 0) + 1)) > error_count.txt; \ - fi; \ - fi; - -clean: - @for dir in $(DIRS); do \ - $(KOS_MAKE) -C $$dir clean; \ - done - -dist: - @for dir in $(DIRS); do \ - $(KOS_MAKE) -C $$dir dist; \ - done - diff --git a/examples/dreamcast/basic/Makefile b/examples/dreamcast/basic/Makefile deleted file mode 100644 index 8c9132b7..00000000 --- a/examples/dreamcast/basic/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/basic/Makefile -# Copyright (C) 2002 Megan Potter -# - -all: - $(KOS_MAKE) -C exec - $(KOS_MAKE) -C threading - $(KOS_MAKE) -C fpu - $(KOS_MAKE) -C asserthnd - $(KOS_MAKE) -C stacktrace - $(KOS_MAKE) -C mmu - $(KOS_MAKE) -C stackprotector - $(KOS_MAKE) -C memtest32 - $(KOS_MAKE) -C watchdog - $(KOS_MAKE) -C breaking - -clean: - $(KOS_MAKE) -C exec clean - $(KOS_MAKE) -C threading clean - $(KOS_MAKE) -C fpu clean - $(KOS_MAKE) -C asserthnd clean - $(KOS_MAKE) -C stacktrace clean - $(KOS_MAKE) -C mmu clean - $(KOS_MAKE) -C stackprotector clean - $(KOS_MAKE) -C memtest32 clean - $(KOS_MAKE) -C watchdog clean - $(KOS_MAKE) -C breaking clean - -dist: - $(KOS_MAKE) -C exec dist - $(KOS_MAKE) -C threading dist - $(KOS_MAKE) -C fpu dist - $(KOS_MAKE) -C asserthnd dist - $(KOS_MAKE) -C stacktrace dist - $(KOS_MAKE) -C mmu dist - $(KOS_MAKE) -C stackprotector dist - $(KOS_MAKE) -C memtest32 dist - $(KOS_MAKE) -C watchdog dist - $(KOS_MAKE) -C breaking dist diff --git a/examples/dreamcast/basic/fpu/Makefile b/examples/dreamcast/basic/fpu/Makefile deleted file mode 100644 index 4d0c7ee5..00000000 --- a/examples/dreamcast/basic/fpu/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/basic/fpu/Makefile -# (c)2002 Megan Potter -# - -all: - $(KOS_MAKE) -C exc - -clean: - $(KOS_MAKE) -C exc clean - -dist: - $(KOS_MAKE) -C exc dist - - diff --git a/examples/dreamcast/basic/mmu/Makefile b/examples/dreamcast/basic/mmu/Makefile deleted file mode 100644 index 6479f3ae..00000000 --- a/examples/dreamcast/basic/mmu/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/basic/mmu/Makefile -# (c)2002 Megan Potter -# - -all: - $(KOS_MAKE) -C pvrmap - $(KOS_MAKE) -C nullptr - -clean: - $(KOS_MAKE) -C pvrmap clean - $(KOS_MAKE) -C nullptr clean - -dist: - $(KOS_MAKE) -C pvrmap dist - $(KOS_MAKE) -C nullptr dist - - diff --git a/examples/dreamcast/basic/threading/Makefile b/examples/dreamcast/basic/threading/Makefile deleted file mode 100644 index ba062f4b..00000000 --- a/examples/dreamcast/basic/threading/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/basic/threading/Makefile -# Copyright (C) 2002 Megan Potter -# - -all: - $(KOS_MAKE) -C compiler_tls - $(KOS_MAKE) -C general - $(KOS_MAKE) -C rwsem - $(KOS_MAKE) -C recursive_lock - $(KOS_MAKE) -C once - $(KOS_MAKE) -C tls - $(KOS_MAKE) -C spinlock_test - $(KOS_MAKE) -C atomics - $(KOS_MAKE) -C reentrant_mutex - -clean: - $(KOS_MAKE) -C compiler_tls clean - $(KOS_MAKE) -C general clean - $(KOS_MAKE) -C rwsem clean - $(KOS_MAKE) -C recursive_lock clean - $(KOS_MAKE) -C once clean - $(KOS_MAKE) -C tls clean - $(KOS_MAKE) -C spinlock_test clean - $(KOS_MAKE) -C atomics clean - $(KOS_MAKE) -C reentrant_mutex clean - -dist: - $(KOS_MAKE) -C compiler_tls dist - $(KOS_MAKE) -C general dist - $(KOS_MAKE) -C rwsem dist - $(KOS_MAKE) -C recursive_lock dist - $(KOS_MAKE) -C once dist - $(KOS_MAKE) -C tls dist - $(KOS_MAKE) -C spinlock_test dist - $(KOS_MAKE) -C atomics dist - $(KOS_MAKE) -C reentrant_mutex dist diff --git a/examples/dreamcast/conio/Makefile b/examples/dreamcast/conio/Makefile deleted file mode 100644 index f650a903..00000000 --- a/examples/dreamcast/conio/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/conio/Makefile -# (c)2002 Megan Potter -# - -all: - $(KOS_MAKE) -C basic - $(KOS_MAKE) -C wump - $(KOS_MAKE) -C adventure - $(KOS_MAKE) -C kosh - -clean: - $(KOS_MAKE) -C basic clean - $(KOS_MAKE) -C wump clean - $(KOS_MAKE) -C adventure clean - $(KOS_MAKE) -C kosh clean - -dist: - $(KOS_MAKE) -C basic dist - $(KOS_MAKE) -C wump dist - $(KOS_MAKE) -C adventure dist - $(KOS_MAKE) -C kosh dist - - diff --git a/examples/dreamcast/cpp/Makefile b/examples/dreamcast/cpp/Makefile deleted file mode 100644 index 135a4275..00000000 --- a/examples/dreamcast/cpp/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -# KallistiOS ##version## -# -# examples/dreamcast/cpp/Makefile -# Copyright (C) 2001-2002 Megan Potter -# - -all: - $(KOS_MAKE) -C gltest ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-08 05:04:31
|
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, falco/vmufb_font_export has been created at a4cfbae17f1844ec725587e7879aa4ac827f4f62 (commit) - Log ----------------------------------------------------------------- commit a4cfbae17f1844ec725587e7879aa4ac827f4f62 Author: Falco Girgis <gyr...@gm...> Date: Mon Oct 7 23:51:14 2024 -0500 Cleanup + addressed code review comments. commit ba9a1952c6448989b11099308c86f34b531ff65b Author: Falco Girgis <gyr...@gm...> Date: Sat Oct 5 17:30:13 2024 -0500 Made builitn font used by vmu_printf() public. - Needa quick font without external dependencies to use with the extended font-drawing methods in the vmufb API? Sweet. We already haev one used by vmu_printf() - Simply remove the static keyword from the font definition and then declare it extern in the vmu_fb.h header file for others to use and profit from. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-10-08 03:33: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 feec65c7081b946d143399aa71d4f1ce61a3fd94 (commit) via fcd8e05b461efe6e5ecf742256a3becb4ac1541b (commit) via 0d1ac90ce1699d0c803d15df72174aa4098044e5 (commit) via 377a013ed3c9041af472a3bd669dd93a2255145b (commit) via 20c1927e9b862bdf9e8a661f5a71b61dd44a4c05 (commit) via 0025b088d3298c72aa40906cea7682463ab2db1f (commit) via 66b8e9066e1725be97bb537e4e67e74b0cd84941 (commit) via 96571d557ad3b7fa20222718574cbbe57db9ae4e (commit) via a3287d7b0501c30c7e91f2b5da265f4b28bc8f97 (commit) via 0e35b995bafb921af3b1f85240533fe9c95c52e3 (commit) from 33b84c21775d2fc1431558fbc9bc6c0294d93d72 (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 feec65c7081b946d143399aa71d4f1ce61a3fd94 Author: Andy Barajas <and...@gm...> Date: Mon Oct 7 20:22:24 2024 -0700 Filesystem Stat fixes (#775) * Fixed fs_vmu stat(). Added stat() to fs_romdisk. Code style changes. Fixed browser example to use fs_normalize_path instead of realpath because lstat opens and closes if a fs does not provide lstat(). * Implement/fix _stat() for used filesystems. Code cleaning/matching. commit fcd8e05b461efe6e5ecf742256a3becb4ac1541b Merge: a3287d7b 0d1ac90c Author: Donald Haase <qu...@ya...> Date: Mon Oct 7 23:19:10 2024 -0400 Merge pull request #552 from pcercuei/maple-nomem * maple: Allocate smaller status buffers Instead of unconditionally allocating one kilobyte for each possible device located in one of the 6 units of the 4 ports, for a total of 24 KiB, only allocate the status buffer to a proper size when the devices are attached to their corresponding driver. Signed-off-by: Paul Cercueil <pa...@cr...> * maple: Rework device detection mechanism Instead of having 6x4 different frames (one for each unit of each port) that are used for device detection, modify the code so that it will use one single frame for the unit 0 detection, and use unit 0's frame for sub-device detection. This will later allow to allocate devices on-demand instead of having a static array of devices. Signed-off-by: Paul Cercueil <pa...@cr...> * maple: Detach devices on shutdown Attaching the devices may have allocated memory, which we want to be reclaimed on shutdown. Signed-off-by: Paul Cercueil <pa...@cr...> * maple: Protect against allocation in IRQ context It is not always safe to call malloc() or free() in an IRQ context. Before creating a new device, make sure that memory allocation is possible. If it is not, then simply fail silently; the device will be discovered again the next time the periodic IRQ runs. * maple: Dynamically allocate devices Instead of having a huge array of 24 devices, each one with a huge DMA buffer, allocate devices dynamically when they are detected as plugged, and free them when they are detected as unplugged. * maple: driver: Alloc devices and status buffer in one allocation Instead of doing two separate allocations for one maple device and its status buffer, allocate them at once. Signed-off-by: Paul Cercueil <pa...@cr...> commit 0d1ac90ce1699d0c803d15df72174aa4098044e5 Author: Paul Cercueil <pa...@cr...> Date: Thu May 9 16:42:05 2024 +0200 maple: driver: Alloc devices and status buffer in one allocation Instead of doing two separate allocations for one maple device and its status buffer, allocate them at once. Signed-off-by: Paul Cercueil <pa...@cr...> commit 377a013ed3c9041af472a3bd669dd93a2255145b Author: Paul Cercueil <pa...@cr...> Date: Wed May 8 14:11:21 2024 +0200 maple: Dynamically allocate devices Instead of having a huge array of 24 devices, each one with a huge DMA buffer, allocate devices dynamically when they are detected as plugged, and free them when they are detected as unplugged. Signed-off-by: Paul Cercueil <pa...@cr...> commit 20c1927e9b862bdf9e8a661f5a71b61dd44a4c05 Author: Paul Cercueil <pa...@cr...> Date: Thu May 9 11:01:08 2024 +0200 maple: Protect against allocation in IRQ context It is not always safe to call malloc() or free() in an IRQ context. Before creating a new device, make sure that memory allocation is possible. If it is not, then simply fail silently; the device will be discovered again the next time the periodic IRQ runs. Signed-off-by: Paul Cercueil <pa...@cr...> commit 0025b088d3298c72aa40906cea7682463ab2db1f Author: Paul Cercueil <pa...@cr...> Date: Wed May 8 14:03:33 2024 +0200 maple: Detach devices on shutdown Attaching the devices may have allocated memory, which we want to be reclaimed on shutdown. Signed-off-by: Paul Cercueil <pa...@cr...> commit 66b8e9066e1725be97bb537e4e67e74b0cd84941 Author: Paul Cercueil <pa...@cr...> Date: Wed May 8 13:57:31 2024 +0200 maple: Rework device detection mechanism Instead of having 6x4 different frames (one for each unit of each port) that are used for device detection, modify the code so that it will use one single frame for the unit 0 detection, and use unit 0's frame for sub-device detection. This will later allow to allocate devices on-demand instead of having a static array of devices. Signed-off-by: Paul Cercueil <pa...@cr...> commit 96571d557ad3b7fa20222718574cbbe57db9ae4e Author: Paul Cercueil <pa...@cr...> Date: Wed May 1 16:46:14 2024 +0200 maple: Allocate smaller status buffers Instead of unconditionally allocating one kilobyte for each possible device located in one of the 6 units of the 4 ports, for a total of 24 KiB, only allocate the status buffer to a proper size when the devices are attached to their corresponding driver. Signed-off-by: Paul Cercueil <pa...@cr...> commit a3287d7b0501c30c7e91f2b5da265f4b28bc8f97 Author: Falco Girgis <gyr...@gm...> Date: Sat Oct 5 16:51:25 2024 -0500 Made macros for HZ and THD stack sizes overridable (#790) * Made macros for HZ and THD stack sizes overridable - Many people are starting to overrun the main kernel thread stack - We may want to eventually arrive at a better solution for providing a thread size for the kernel stack eventually, but until we get there, I think this will suffice, as it's in-line with our other overridable macros. - Added #ifdefs around HZ, THD_STACK_SIZE, and THD_KERNEL_STACK_SIZE in arch.h to only define them if they weren't already provided by the build system or externally. - Deprecated HZ, renamed to THD_SCHED_HZ. commit 0e35b995bafb921af3b1f85240533fe9c95c52e3 Author: Donald Haase <qu...@ya...> Date: Sat Oct 5 14:50:46 2024 -0400 Make the Store Queue mutex recursive (#784) * Make the Store Queue (SQ) mutex recursive. This allows for disjointed SQ locks within a single thread, which helps reduce the requirement of repeated locks/unlocks in certain paths and simplify managing the use of SQs. A static cache is used to track the data that allows a recursion depth of SQ_STATE_CACHE_SIZE which defaults to 8 and may be adjusted if needed. * It would help if I knew how asserts worked * Add name to copyright, and remove unused includes. --------- Co-authored-by: QuzarDC <qu...@co...> ----------------------------------------------------------------------- Summary of changes: addons/libkosext2fs/fs_ext2.c | 110 ++++++++------- addons/libkosfat/fs_fat.c | 49 ++++--- examples/dreamcast/filesystem/browse/browse.c | 2 +- kernel/arch/dreamcast/fs/fs_dcload.c | 44 +++--- kernel/arch/dreamcast/fs/fs_iso9660.c | 72 +++++++--- kernel/arch/dreamcast/fs/fs_vmu.c | 63 ++++----- kernel/arch/dreamcast/hardware/maple/controller.c | 1 + kernel/arch/dreamcast/hardware/maple/dreameye.c | 1 + kernel/arch/dreamcast/hardware/maple/keyboard.c | 1 + .../arch/dreamcast/hardware/maple/maple_driver.c | 64 +++++---- kernel/arch/dreamcast/hardware/maple/maple_enum.c | 9 +- .../dreamcast/hardware/maple/maple_init_shutdown.c | 29 +--- kernel/arch/dreamcast/hardware/maple/maple_irq.c | 149 ++++++++++++--------- kernel/arch/dreamcast/hardware/maple/maple_queue.c | 2 +- kernel/arch/dreamcast/hardware/maple/maple_utils.c | 2 +- kernel/arch/dreamcast/hardware/maple/mouse.c | 1 + kernel/arch/dreamcast/hardware/maple/sip.c | 1 + kernel/arch/dreamcast/hardware/maple/vmu.c | 1 + kernel/arch/dreamcast/hardware/sq.c | 67 +++++++-- kernel/arch/dreamcast/include/arch/arch.h | 15 ++- kernel/arch/dreamcast/include/dc/maple.h | 23 ++-- kernel/exports.txt | 11 ++ kernel/fs/fs_dev.c | 28 +++- kernel/fs/fs_null.c | 4 +- kernel/fs/fs_pty.c | 77 +++++++++-- kernel/fs/fs_ramdisk.c | 74 +++++----- kernel/fs/fs_random.c | 6 +- kernel/fs/fs_romdisk.c | 73 ++++++++-- kernel/fs/fs_utils.c | 11 +- kernel/libc/koslib/realpath.c | 11 +- kernel/thread/thread.c | 2 +- 31 files changed, 648 insertions(+), 355 deletions(-) diff --git a/addons/libkosext2fs/fs_ext2.c b/addons/libkosext2fs/fs_ext2.c index e3d004f0..a3388a54 100644 --- a/addons/libkosext2fs/fs_ext2.c +++ b/addons/libkosext2fs/fs_ext2.c @@ -1685,21 +1685,33 @@ static ssize_t fs_ext2_readlink(vfs_handler_t *vfs, const char *path, char *buf, return len; } -int fs_ext2_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, +int fs_ext2_stat(vfs_handler_t *vfs, const char *path, struct stat *st, int flag) { - fs_ext2_fs_t *fs = (fs_ext2_fs_t *)vfs->privdata; int irv; ext2_inode_t *inode; uint32_t inode_num; int rl = 1; uint64_t sz; + size_t len = strlen(path); /* Do we want the status of a symlink or of the thing it points at if we end up with a symlink at the end of path resolution? */ if(flag & AT_SYMLINK_NOFOLLOW) rl = 2; + /* Root directory ext2 device */ + if(len == 0 || (len == 1 && *path == '/')) { + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)((ptr_t)vfs); + st->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | + S_IXGRP | S_IXOTH | S_IWUSR | S_IWGRP | S_IWOTH; + st->st_size = -1; + st->st_nlink = 2; + + return 0; + } + mutex_lock(&ext2_mutex); /* Find the object in question */ @@ -1710,29 +1722,29 @@ int fs_ext2_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, } /* Fill in the structure */ - memset(buf, 0, sizeof(struct stat)); - buf->st_dev = (dev_t)((ptr_t)vfs); - buf->st_ino = inode_num; - buf->st_mode = inode->i_mode & 0x0FFF; - buf->st_nlink = inode->i_links_count; - buf->st_uid = inode->i_uid; - buf->st_gid = inode->i_gid; - - buf->st_atime = inode->i_atime; - buf->st_mtime = inode->i_mtime; - buf->st_ctime = inode->i_ctime; - buf->st_blksize = 512; - buf->st_blocks = inode->i_blocks; + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)((ptr_t)vfs); + st->st_ino = inode_num; + st->st_mode = inode->i_mode & 0x0FFF; + st->st_nlink = inode->i_links_count; + st->st_uid = inode->i_uid; + st->st_gid = inode->i_gid; + + st->st_atime = inode->i_atime; + st->st_mtime = inode->i_mtime; + st->st_ctime = inode->i_ctime; + st->st_blksize = 512; + st->st_blocks = inode->i_blocks; /* The rest depends on what type of inode this is... */ switch(inode->i_mode & 0xF000) { case EXT2_S_IFLNK: - buf->st_mode |= S_IFLNK; - buf->st_size = inode->i_size; + st->st_mode |= S_IFLNK; + st->st_size = inode->i_size; break; case EXT2_S_IFREG: - buf->st_mode |= S_IFREG; + st->st_mode |= S_IFREG; sz = ext2_inode_size(inode); if(sz > LONG_MAX) { @@ -1740,28 +1752,28 @@ int fs_ext2_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, irv = -1; } - buf->st_size = sz; + st->st_size = sz; break; case EXT2_S_IFDIR: - buf->st_mode |= S_IFDIR; - buf->st_size = inode->i_size; + st->st_mode |= S_IFDIR; + st->st_size = inode->i_size; break; case EXT2_S_IFSOCK: - buf->st_mode |= S_IFSOCK; + st->st_mode |= S_IFSOCK; break; case EXT2_S_IFIFO: - buf->st_mode |= S_IFIFO; + st->st_mode |= S_IFIFO; break; case EXT2_S_IFBLK: - buf->st_mode |= S_IFBLK; + st->st_mode |= S_IFBLK; break; case EXT2_S_IFCHR: - buf->st_mode |= S_IFCHR; + st->st_mode |= S_IFCHR; break; } @@ -1790,7 +1802,7 @@ static int fs_ext2_rewinddir(void *h) { return 0; } -static int fs_ext2_fstat(void *h, struct stat *buf) { +static int fs_ext2_fstat(void *h, struct stat *st) { fs_ext2_fs_t *fs; ext2_inode_t *inode; uint64_t sz; @@ -1810,29 +1822,29 @@ static int fs_ext2_fstat(void *h, struct stat *buf) { fs = fh[fd].fs; /* Fill in the structure */ - memset(buf, 0, sizeof(struct stat)); - buf->st_dev = (dev_t)((ptr_t)fs->vfsh); - buf->st_ino = fh[fd].inode_num; - buf->st_mode = inode->i_mode & 0x0FFF; - buf->st_nlink = inode->i_links_count; - buf->st_uid = inode->i_uid; - buf->st_gid = inode->i_gid; - - buf->st_atime = inode->i_atime; - buf->st_mtime = inode->i_mtime; - buf->st_ctime = inode->i_ctime; - buf->st_blksize = 512; - buf->st_blocks = inode->i_blocks; + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)((ptr_t)fs->vfsh); + st->st_ino = fh[fd].inode_num; + st->st_mode = inode->i_mode & 0x0FFF; + st->st_nlink = inode->i_links_count; + st->st_uid = inode->i_uid; + st->st_gid = inode->i_gid; + + st->st_atime = inode->i_atime; + st->st_mtime = inode->i_mtime; + st->st_ctime = inode->i_ctime; + st->st_blksize = 512; + st->st_blocks = inode->i_blocks; /* The rest depends on what type of inode this is... */ switch(inode->i_mode & 0xF000) { case EXT2_S_IFLNK: - buf->st_mode |= S_IFLNK; - buf->st_size = inode->i_size; + st->st_mode |= S_IFLNK; + st->st_size = inode->i_size; break; case EXT2_S_IFREG: - buf->st_mode |= S_IFREG; + st->st_mode |= S_IFREG; sz = ext2_inode_size(inode); if(sz > LONG_MAX) { @@ -1840,28 +1852,28 @@ static int fs_ext2_fstat(void *h, struct stat *buf) { irv = -1; } - buf->st_size = sz; + st->st_size = sz; break; case EXT2_S_IFDIR: - buf->st_mode |= S_IFDIR; - buf->st_size = inode->i_size; + st->st_mode |= S_IFDIR; + st->st_size = inode->i_size; break; case EXT2_S_IFSOCK: - buf->st_mode |= S_IFSOCK; + st->st_mode |= S_IFSOCK; break; case EXT2_S_IFIFO: - buf->st_mode |= S_IFIFO; + st->st_mode |= S_IFIFO; break; case EXT2_S_IFBLK: - buf->st_mode |= S_IFBLK; + st->st_mode |= S_IFBLK; break; case EXT2_S_IFCHR: - buf->st_mode |= S_IFCHR; + st->st_mode |= S_IFCHR; break; } diff --git a/addons/libkosfat/fs_fat.c b/addons/libkosfat/fs_fat.c index 55732379..636a7132 100644 --- a/addons/libkosfat/fs_fat.c +++ b/addons/libkosfat/fs_fat.c @@ -1038,16 +1038,29 @@ static int fs_fat_unlink(vfs_handler_t *vfs, const char *fn) { return irv; } -static int fs_fat_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, +static int fs_fat_stat(vfs_handler_t *vfs, const char *path, struct stat *st, int flag) { fs_fat_fs_t *fs = (fs_fat_fs_t *)vfs->privdata; uint32_t sz, bs; int irv = 0; fat_dentry_t ent; uint32_t cl, off, lcl, loff; + size_t len = strlen(path); (void)flag; + /* Root directory fat device */ + if(len == 0 || (len == 1 && *path == '/')) { + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)((ptr_t)fs->vfsh); + st->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | + S_IXGRP | S_IXOTH | S_IWUSR | S_IWGRP | S_IWOTH; + st->st_size = -1; + st->st_nlink = 2; + + return 0; + } + mutex_lock(&fat_mutex); /* Find the object in question */ @@ -1059,32 +1072,32 @@ static int fs_fat_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, } /* Fill in the structure */ - memset(buf, 0, sizeof(struct stat)); + memset(st, 0, sizeof(struct stat)); irv = 0; - buf->st_dev = (dev_t)((ptr_t)fs->vfsh); - buf->st_ino = ent.cluster_low | (ent.cluster_high << 16); - buf->st_nlink = 1; - buf->st_uid = 0; - buf->st_gid = 0; - buf->st_blksize = fat_cluster_size(fs->fs); + st->st_dev = (dev_t)((ptr_t)fs->vfsh); + st->st_ino = ent.cluster_low | (ent.cluster_high << 16); + st->st_nlink = 1; + st->st_uid = 0; + st->st_gid = 0; + st->st_blksize = fat_cluster_size(fs->fs); /* Read the mode bits... */ - buf->st_mode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; + st->st_mode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; if(!(ent.attr & FAT_ATTR_READ_ONLY)) { - buf->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; + st->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; } /* Fill in the timestamps... */ - fill_stat_timestamps(&ent, buf); + fill_stat_timestamps(&ent, st); /* The rest depends on what type of object this is... */ if(ent.attr & FAT_ATTR_DIRECTORY) { - buf->st_mode |= S_IFDIR; - buf->st_size = 0; - buf->st_blocks = 0; + st->st_mode |= S_IFDIR; + st->st_size = 0; + st->st_blocks = 0; } else { - buf->st_mode |= S_IFREG; + st->st_mode |= S_IFREG; sz = ent.size; if(sz > LONG_MAX) { @@ -1092,12 +1105,12 @@ static int fs_fat_stat(vfs_handler_t *vfs, const char *path, struct stat *buf, irv = -1; } - buf->st_size = sz; + st->st_size = sz; bs = fat_cluster_size(fs->fs); - buf->st_blocks = sz / bs; + st->st_blocks = sz / bs; if(sz & (bs - 1)) - ++buf->st_blocks; + ++st->st_blocks; } mutex_unlock(&fat_mutex); diff --git a/examples/dreamcast/filesystem/browse/browse.c b/examples/dreamcast/filesystem/browse/browse.c index 80f681d6..ccd3bf29 100644 --- a/examples/dreamcast/filesystem/browse/browse.c +++ b/examples/dreamcast/filesystem/browse/browse.c @@ -268,7 +268,7 @@ static int browse_directory(char *directory, directory_file_t *directory_content /* Open the directory */ if (!(d = opendir(directory))) { - fprintf(stderr, "browse_directory: opendir failed\n"); + fprintf(stderr, "browse_directory: opendir failed for %s\n", directory); return 0; } diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index 891e6fa9..949952ab 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -364,9 +364,10 @@ int dcload_unlink(vfs_handler_t * vfs, const char *fn) { return ret; } -static int dcload_stat(vfs_handler_t *vfs, const char *fn, struct stat *rv, +static int dcload_stat(vfs_handler_t *vfs, const char *path, struct stat *st, int flag) { dcload_stat_t filestat; + size_t len = strlen(path); int retval; (void)flag; @@ -374,25 +375,36 @@ static int dcload_stat(vfs_handler_t *vfs, const char *fn, struct stat *rv, if(lwip_dclsc && irq_inside_int()) return 0; + /* Root directory '/pc' */ + if(len == 0 || (len == 1 && *path == '/')) { + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)((ptr_t)vfs); + st->st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO; + st->st_size = -1; + st->st_nlink = 2; + + return 0; + } + spinlock_lock(&mutex); - retval = dclsc(DCLOAD_STAT, fn, &filestat); + retval = dclsc(DCLOAD_STAT, path, &filestat); spinlock_unlock(&mutex); if(!retval) { - memset(rv, 0, sizeof(struct stat)); - rv->st_dev = (dev_t)((ptr_t)vfs); - rv->st_ino = filestat.st_ino; - rv->st_mode = filestat.st_mode; - rv->st_nlink = filestat.st_nlink; - rv->st_uid = filestat.st_uid; - rv->st_gid = filestat.st_gid; - rv->st_rdev = filestat.st_rdev; - rv->st_size = filestat.st_size; - rv->st_atime = filestat.atime; - rv->st_mtime = filestat.mtime; - rv->st_ctime = filestat.ctime; - rv->st_blksize = filestat.st_blksize; - rv->st_blocks = filestat.st_blocks; + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)((ptr_t)vfs); + st->st_ino = filestat.st_ino; + st->st_mode = filestat.st_mode; + st->st_nlink = filestat.st_nlink; + st->st_uid = filestat.st_uid; + st->st_gid = filestat.st_gid; + st->st_rdev = filestat.st_rdev; + st->st_size = filestat.st_size; + st->st_atime = filestat.atime; + st->st_mtime = filestat.mtime; + st->st_ctime = filestat.ctime; + st->st_blksize = filestat.st_blksize; + st->st_blocks = filestat.st_blocks; return 0; } diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index 6f3f5273..03e2930a 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -968,6 +968,53 @@ static void iso_vblank(uint32 evt, void *data) { } } +static int iso_stat(vfs_handler_t *vfs, const char *path, struct stat *st, + int flag) { + mode_t md; + iso_dirent_t *de; + size_t len = strlen(path); + + (void)vfs; + (void)flag; + + /* Root directory of cd */ + if(len == 0 || (len == 1 && *path == '/')) { + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)('c' | ('d' << 8)); + st->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | + S_IXGRP | S_IXOTH; + st->st_size = -1; + st->st_nlink = 2; + + return 0; + } + + /* First try opening as a file */ + de = find_object_path(path, 0, &root_dirent); + md = S_IFREG; + + /* If we couldn't get it as a file, try as a directory */ + if(!de) { + de = find_object_path(path, 1, &root_dirent); + md = S_IFDIR; + } + + /* If we still don't have it, then we're not going to get it. */ + if(!de) { + errno = ENOENT; + return -1; + } + + memset(st, 0, sizeof(struct stat)); + st->st_dev = (dev_t)('c' | ('d' << 8)); + st->st_mode = md | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; + st->st_size = (md == S_IFDIR) ? -1 : (int)iso_733(de->size); + st->st_nlink = (md == S_IFDIR) ? 2 : 1; + st->st_blksize = 512; + + return 0; +} + static int iso_fcntl(void *h, int cmd, va_list ap) { file_t fd = (file_t)h; int rv = -1; @@ -1010,23 +1057,12 @@ static int iso_fstat(void *h, struct stat *st) { } memset(st, 0, sizeof(struct stat)); - - if(fh[fd].dir) { - st->st_size = 0; - st->st_dev = 'c' | ('d' << 8); - st->st_mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | - S_IXGRP | S_IXOTH; - st->st_nlink = 1; - st->st_blksize = 512; - } - else { - st->st_size = fh[fd].size; - st->st_dev = 'c' | ('d' << 8); - st->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | - S_IXGRP | S_IXOTH; - st->st_nlink = 1; - st->st_blksize = 512; - } + st->st_dev = 'c' | ('d' << 8); + st->st_mode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; + st->st_mode |= fh[fd].dir ? S_IFDIR : S_IFREG; + st->st_size = fh[fd].dir ? -1 : (int)fh[fd].size; + st->st_nlink = fh[fd].dir ? 2 : 1; + st->st_blksize = 512; return 0; ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-05 18:51: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, falco/pvrtex_warnings_fixes has been created at 20458582752546c80ff8245d31525a5b57bb8549 (commit) - Log ----------------------------------------------------------------- commit 20458582752546c80ff8245d31525a5b57bb8549 Author: Falco Girgis <gyr...@gm...> Date: Sat Oct 5 09:53:19 2024 -0500 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... Simply told the compiler to shut up by marking it (void). ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-05 14:17: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, master has been updated via 33b84c21775d2fc1431558fbc9bc6c0294d93d72 (commit) from 0482d86c883088f482cfa86855efe0c390a93a3b (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 33b84c21775d2fc1431558fbc9bc6c0294d93d72 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. ----------------------------------------------------------------------- Summary of changes: environ_base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environ_base.sh b/environ_base.sh index bf754d4b..a4d98cf0 100644 --- a/environ_base.sh +++ b/environ_base.sh @@ -48,7 +48,7 @@ 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_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} -fno-operator-names" +export KOS_CPPFLAGS="${KOS_CPPFLAGS} ${KOS_INC_PATHS_CPP}" # Which standards modes we want to compile for # Note that this only covers KOS itself, not necessarily anything else compiled hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-10-05 13:56: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 0482d86c883088f482cfa86855efe0c390a93a3b (commit) from 495e77fd60d5b09a1ad52a26cd4a7e73cd0d9d51 (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 0482d86c883088f482cfa86855efe0c390a93a3b 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) ----------------------------------------------------------------------- Summary of changes: utils/pvrtex/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/pvrtex/Makefile b/utils/pvrtex/Makefile index a581f382..f68f5576 100644 --- a/utils/pvrtex/Makefile +++ b/utils/pvrtex/Makefile @@ -8,12 +8,12 @@ OBJS = elbg.o mem.o log.o bprint.o avstring.o lfg.o crc.o md5.o stb_image_impl.o file_pvr.o file_tex.o file_dctex.o pvr_texture_encoder.o main.o CPPFLAGS = -Ilibavutil -I. -DCONFIG_MEMORY_POISONING=0 -DHAVE_FAST_UNALIGNED=0 -CXXFLAGS = -flto=auto -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare +CXXFLAGS = -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare ifdef $(DEBUGBUILD) CXXFLAGS += -Og -pg -g else - CXXFLAGS += -O3 -flto + CXXFLAGS += -O3 endif CFLAGS := $(CXXFLAGS) -Wno-pointer-sign hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-09-30 23:11: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 495e77fd60d5b09a1ad52a26cd4a7e73cd0d9d51 (commit) via 91f5e7a55233f7b3daa01db68a169f20faa586ad (commit) from f9786ba4a0532de4ccf53635319993c9d643e97a (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 495e77fd60d5b09a1ad52a26cd4a7e73cd0d9d51 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 91f5e7a55233f7b3daa01db68a169f20faa586ad 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...> ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/network/Makefile | 3 + .../{2ndmix => network/speedtest}/Makefile | 13 +- .../dreamcast/network/speedtest/handle_request.c | 307 +++++++++++++++++++++ .../dreamcast/network/speedtest/romdisk/index.html | 118 ++++++++ examples/dreamcast/network/speedtest/server.c | 71 +++++ examples/dreamcast/network/speedtest/speedtest.c | 47 ++++ examples/dreamcast/network/speedtest/speedtest.h | 29 ++ utils/cmake/dreamcast.toolchain.cmake | 2 +- 8 files changed, 582 insertions(+), 8 deletions(-) copy examples/dreamcast/{2ndmix => network/speedtest}/Makefile (61%) create mode 100644 examples/dreamcast/network/speedtest/handle_request.c create mode 100644 examples/dreamcast/network/speedtest/romdisk/index.html create mode 100644 examples/dreamcast/network/speedtest/server.c create mode 100644 examples/dreamcast/network/speedtest/speedtest.c create mode 100644 examples/dreamcast/network/speedtest/speedtest.h diff --git a/examples/dreamcast/network/Makefile b/examples/dreamcast/network/Makefile index b9627dcb..7d200aa3 100644 --- a/examples/dreamcast/network/Makefile +++ b/examples/dreamcast/network/Makefile @@ -13,6 +13,7 @@ all: $(KOS_MAKE) -C httpd $(KOS_MAKE) -C isp-settings $(KOS_MAKE) -C ntp + $(KOS_MAKE) -C speedtest clean: $(KOS_MAKE) -C basic clean @@ -23,6 +24,7 @@ clean: $(KOS_MAKE) -C httpd clean $(KOS_MAKE) -C isp-settings clean $(KOS_MAKE) -C ntp clean + $(KOS_MAKE) -C speedtest clean dist: $(KOS_MAKE) -C basic dist @@ -33,3 +35,4 @@ dist: $(KOS_MAKE) -C httpd dist $(KOS_MAKE) -C isp-settings dist $(KOS_MAKE) -C ntp dist + $(KOS_MAKE) -C speedtest dist diff --git a/examples/dreamcast/2ndmix/Makefile b/examples/dreamcast/network/speedtest/Makefile similarity index 61% copy from examples/dreamcast/2ndmix/Makefile copy to examples/dreamcast/network/speedtest/Makefile index 0e3b214d..9fa00bee 100644 --- a/examples/dreamcast/2ndmix/Makefile +++ b/examples/dreamcast/network/speedtest/Makefile @@ -1,11 +1,11 @@ -# KallistiOS ##version## # -# 2ndmix/Makefile -# Copyright (C)2003 Megan Potter +# KallistiOS network/speedtest example +# +# Copyright (C) 2024 Andress Barajas # -TARGET = 2ndmix.elf -OBJS = 2ndmix.o romdisk.o +TARGET = speedtest.elf +OBJS = speedtest.o server.o handle_request.o romdisk.o KOS_ROMDISK_DIR = romdisk all: rm-elf $(TARGET) @@ -22,9 +22,8 @@ $(TARGET): $(OBJS) kos-cc -o $(TARGET) $(OBJS) run: $(TARGET) - $(KOS_LOADER) $(TARGET) + $(KOS_LOADER) $(TARGET) -n dist: $(TARGET) -rm -f $(OBJS) romdisk.img $(KOS_STRIP) $(TARGET) - diff --git a/examples/dreamcast/network/speedtest/handle_request.c b/examples/dreamcast/network/speedtest/handle_request.c new file mode 100644 index 00000000..b64c5638 --- /dev/null +++ b/examples/dreamcast/network/speedtest/handle_request.c @@ -0,0 +1,307 @@ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "speedtest.h" + +/* + This file defines the handle_request function, which processes HTTP requests + received by the speed test server. It parses the request, determines the HTTP + method (GET or POST), and routes the request to the appropriate handler based + on the requested path. It supports GET requests to serve files such as + index.html and handles download and upload test endpoints to measure network + speed. + + Key paths: + - "/": serves the speed test HTML page (index.html). + - "/download-test?size=": initiates a download test of the requested size. + - "/upload-test": handles data uploads during an upload test. + */ + + +bool exact_match(const char *path, const char *pattern); +bool prefix_match(const char *path, const char *pattern); + +int send_ok(http_state_t *h, const char *ct); +void send_code(int socket, uint16_t code, const char *message); + +#define BUFSIZE 1024 +#define REQUEST_LINE_SIZE 160 +#define HEADER_BUF_SIZE 512 + +void *handle_request(void *p) { + char request_line[REQUEST_LINE_SIZE] = {0}; + char *buf_ptr = request_line; + char *path_end; + size_t total_bytes = 0; + http_state_t *hr = (http_state_t *)p; + + /* Read the max we expect the request line to be */ + total_bytes = recv(hr->socket, request_line, REQUEST_LINE_SIZE-1, MSG_NONE); + if(total_bytes <= 0) { + send_code(hr->socket, 400, "Bad Request."); + goto process_request_out; + } + request_line[total_bytes] = '\0'; + + /* If first byte is 'G' we have GET */ + if(*buf_ptr == 'G') { + hr->method = METHOD_GET; + buf_ptr += 4; /* Move to the start of path */ + } else if(*buf_ptr == 'P' && *(buf_ptr+1) == 'O') { + hr->method = METHOD_POST; + buf_ptr += 5; /* Move to the start of path */ + } else { + send_code(hr->socket, 501, "Method not implemented."); + goto process_request_out; + } + + /* Find the end of path and put \0. */ + path_end = strchr(buf_ptr, ' '); + if(!path_end) { + send_code(hr->socket, 414, "Request-URI Too Long."); + goto process_request_out; + } + *path_end = '\0'; /* Replace space with terminator */ + hr->path = buf_ptr; + buf_ptr = path_end + 1; + + printf("%s\n", hr->path); + + if(hr->method == METHOD_POST) { + char *content_length_key = "Content-Length: "; + char *cl_key_ptr = content_length_key; + + char *body_start_key = "\r\n\r\n"; + char *bs_key_ptr = body_start_key; + + char buf[HEADER_BUF_SIZE] = {0}; + + char *found; + char *buf_start = request_line; + bool got_content_length = false; + size_t bytes_left = total_bytes - (buf_ptr - buf_start); + + printf("RL: %s\n", buf_ptr); + + /* Look for Content-Length header(optional) and start of the body */ + while(true) { + /* Iterate over each byte trying to match */ + while(bytes_left > 0) { + /* Look for optional Content-Length header */ + if(!got_content_length) { +find_length: + if(*buf_ptr == *cl_key_ptr) { + while(bytes_left-- && *cl_key_ptr != '\0' && *buf_ptr++ == *cl_key_ptr++); + if(*cl_key_ptr == '\0') { /* We found Content-Length key */ + /* Get the count */ + hr->rem_content_length = atoi(buf_ptr); + /* Check that we grabbed the full number */ + found = strstr(buf_ptr, "\r\n"); + if(found) { + buf_ptr = found; + got_content_length = true; + + goto find_body; + } + } + else if(bytes_left > 0) { /* Start over */ + cl_key_ptr = content_length_key; + + /* Rewind back one char */ + buf_ptr--; + bytes_left++; + /* Fall through to find_body */ + } + else /* bytes_left == 0 */ + goto refresh_buffer; + } + } +find_body: + /* Look for body start */ + if(*buf_ptr == *bs_key_ptr) { + while(bytes_left-- && *bs_key_ptr != '\0' && *buf_ptr++ == *bs_key_ptr++); + if(*bs_key_ptr == '\0') { /* We found body start key */ + hr->body = buf_ptr; + /* How much of the body do we already have? */ + hr->read_content_length = total_bytes - (hr->body - buf_start); + if(got_content_length) + hr->rem_content_length -= hr->read_content_length; + + goto done_parsing; + } + else if(bytes_left > 0) /* Start over */ { + bs_key_ptr = body_start_key; + + if(!got_content_length) { + /* Rewind back one char */ + buf_ptr--; + bytes_left++; + goto find_length; + } + } + else /* bytes_left == 0 */ + goto refresh_buffer; + } + + /* Should only hit here if neither matched at the starting character */ + buf_ptr++; + bytes_left--; + } + +refresh_buffer: + /* We get here when we are done searching through current buffer */ + total_bytes = recv(hr->socket, buf, HEADER_BUF_SIZE-1, MSG_NONE); + if(total_bytes <= 0) { + send_code(hr->socket, 400, "Bad Request."); + goto process_request_out; + } + buf[total_bytes] = '\0'; + buf_start = buf; + buf_ptr = buf; + bytes_left = total_bytes; + + /* If we have already found Content-Length, skip searching it again */ + if(got_content_length) + goto find_body; + } + } + +done_parsing: + char response_buf[BUFSIZE]; + if(hr->method == METHOD_GET) { + file_t file = -1; + uint32_t offset; + int cnt; + int wrote; + + /* index.html */ + if(exact_match(hr->path, "") || exact_match(hr->path, "/")) { + file = fs_open("/rd/index.html", O_RDONLY); + + send_ok(hr, "text/html"); + while((cnt = fs_read(file, response_buf, BUFSIZE)) != 0) { + offset = 0; + + while(cnt > 0) { + wrote = send(hr->socket, response_buf + offset, cnt, MSG_NONE); + + if(wrote <= 0) + break; + + cnt -= wrote; + offset += wrote; + } + } + + fs_close(file); + goto process_request_out; + } + else if(prefix_match(hr->path, "/download-test")) { + char *size_str; + size_t size; + + /* Extract size parameter from path */ + size_str = strstr(hr->path, "size="); + if(size_str) { + size = strtoul(size_str + 5, NULL, 10); + if(size <= 0 || size > 16*1024*1024) { + /* Send ERROR Code with reason */ + send_code(hr->socket, 400, "GET download: 'size' is out of range (1 - 16*1024*1024)"); + } + + send_ok(hr, "application/octet-stream"); + uintptr_t data = 0x8000000; + offset = 0; + while(size > 0) { + wrote = send(hr->socket, (uint8_t *)data + offset, size, MSG_NONE); + + if(wrote <= 0) + break; + + size -= wrote; + offset += wrote; + } + + goto process_request_out; + } else { + /* Send ERROR Code with reason */ + send_code(hr->socket, 400, "GET download: Missing required params (size)"); + } + } + } + else { /* POST */ + if(exact_match(hr->path, "/upload-test")) { + while(hr->rem_content_length) { + total_bytes = recv(hr->socket, response_buf, HEADER_BUF_SIZE - 1, MSG_NONE); + + hr->rem_content_length -= total_bytes; + } + send_code(hr->socket, 204, ""); + + goto process_request_out; + } + } + + /* If no handler was found */ + send_code(hr->socket, 404, "Invalid request or file not found."); + +process_request_out: + /* Clean up our http state and all associated allocated memory */ + close(hr->socket); + free(hr); + + /* We're now done with this thread. */ + return NULL; +} + +bool exact_match(const char *path, const char *pattern) { + if (strlen(path) != strlen(pattern)) + return false; + + return strcmp(path, pattern) == 0; +} + +bool prefix_match(const char *path, const char *pattern) { + return strncmp(path, pattern, strlen(pattern)) == 0; +} + +int send_ok(http_state_t *h, const char *ct) { + char buffer[512]; + + sprintf(buffer, "HTTP/1.0 200 OK\r\nContent-type: %s\r\nConnection: close\r\n\r\n", ct); + send(h->socket, buffer, strlen(buffer), MSG_NONE); + + return 0; +} + +void send_code(int socket, uint16_t code, const char *message) { + /* Send HTTP response header */ + char *buf; + size_t buf_size; + + /* Calculate size of message */ + buf_size = snprintf(NULL, 0, + "HTTP/1.1 %d %s\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: %zu\r\n" + "Connection: close\r\n" + "\r\n" + "%s", + code, message, strlen(message), message); + + /* Allocate buf on the stack */ + buf = (char *)alloca(buf_size + 1); /* Null terminator */ + + buf_size = snprintf(buf, buf_size + 1, + "HTTP/1.1 %d %s\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: %zu\r\n" + "Connection: close\r\n" + "\r\n" + "%s", + code, message, strlen(message), message); + + send(socket, buf, buf_size, MSG_NONE); +} diff --git a/examples/dreamcast/network/speedtest/romdisk/index.html b/examples/dreamcast/network/speedtest/romdisk/index.html new file mode 100644 index 00000000..288f6667 --- /dev/null +++ b/examples/dreamcast/network/speedtest/romdisk/index.html @@ -0,0 +1,118 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Dreamcast Network Speed Test</title> + <style> + body { + font-family: Arial, sans-serif; + background-color: #1d1e21; + color: white; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + } + .speed-test-container { + width: 300px; + text-align: center; + background-color: #2a2b2e; + padding: 20px; + border-radius: 10px; + } + .speed-text { + font-size: 24px; + font-weight: bold; + margin: 10px 0; + } + .test-type { + font-size: 14px; + margin-top: 10px; + opacity: 0.7; + } + button { + margin-top: 20px; + padding: 10px 20px; + font-size: 16px; + background-color: #007bff; + color: white; + border: none; + border-radius: 5px; + cursor: pointer; + } + </style> +</head> +<body> + <div class="speed-test-container"> + <h2>Dreamcast Network Speed Test</h2> + <div class="speed-text" id="download-speed">Download: -- MB/s</div> + <div class="speed-text" id="upload-speed">Upload: -- KB/s</div> + <div class="test-type" id="test-status">Ready</div> + <button onclick="startTest()">Start Test</button> + </div> + + <script> + const downloadUrl = '/download-test?size=1048576'; // 1 MB + const uploadUrl = '/upload-test'; + const numRuns = 5; + + async function measureDownloadSpeed() { + const startTime = Date.now(); + const response = await fetch(downloadUrl); + const data = await response.blob(); + const endTime = Date.now(); + const duration = (endTime - startTime) / 1000; // time in seconds + const fileSize = data.size / (1024 * 1024); // size in MB + const speed = fileSize / duration; // speed in MB/s + return speed; + } + + async function measureUploadSpeed() { + const data = new ArrayBuffer(10 * 1024); // 10 KB + const startTime = Date.now(); + await fetch(uploadUrl, { method: 'POST', body: data }); + const endTime = Date.now(); + const duration = (endTime - startTime) / 1000; // time in seconds + const fileSize = data.byteLength / 1024; // size in KB + const speed = fileSize / duration; // speed in KB/s + return speed; + } + + async function runTests() { + let downloadTotal = 0; + let uploadTotal = 0; + + for (let i = 0; i < numRuns; i++) { + document.getElementById('test-status').textContent = `Download test ${i + 1}/${numRuns}`; + const downloadSpeed = await measureDownloadSpeed(); + downloadTotal += downloadSpeed; + console.log(`Download test ${i + 1}: ${downloadSpeed.toFixed(2)} MB/s`); + } + + const avgDownload = (downloadTotal / numRuns).toFixed(2); + document.getElementById('download-speed').textContent = `Download: ${avgDownload} MB/s`; + + for (let i = 0; i < numRuns; i++) { + document.getElementById('test-status').textContent = `Upload test ${i + 1}/${numRuns}`; + const uploadSpeed = await measureUploadSpeed(); + uploadTotal += uploadSpeed; + console.log(`Upload test ${i + 1}: ${uploadSpeed.toFixed(2)} KB/s`); + } + + const avgUpload = (uploadTotal / numRuns).toFixed(2); + document.getElementById('upload-speed').textContent = `Upload: ${avgUpload} KB/s`; + + document.getElementById('test-status').textContent = 'Test complete'; + } + + async function startTest() { + document.getElementById('download-speed').textContent = 'Download: -- MB/s'; + document.getElementById('upload-speed').textContent = 'Upload: -- KB/s'; + document.getElementById('test-status').textContent = 'Starting tests...'; + await runTests(); + } + </script> +</body> ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-09-30 10:02: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, gcc_14.2.0_stable has been created at 2e2a84cb62032003432cd5be3df997ff19b3bf31 (commit) - Log ----------------------------------------------------------------- commit 2e2a84cb62032003432cd5be3df997ff19b3bf31 Author: Falco Girgis <gyr...@gm...> Date: Mon Sep 30 02:35:40 2024 -0500 Blessing GCC14.2.0 as the new "stable" toolchain. GCC14.2.0 has been previewed by at least half of us KOS devs, plus a substantial proportion of our users ever since it has released. I've only ever seen *fewer* ICEs and issues than with the current "stable" toolchain, plus it has nice new C++ language features. I think the time has come to mark it as stable, as many users are already having to rebuild toolchains manually to get this version anyway... - Updated "stable" and "13.2.0" toolchain descriptions in Makefile.default.cfg - Added profile.13.2.0.mk. - Renamed profile.14.2.0 -> profile.stable.mk - Updated CHANGELOG.md. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-09-28 18:16:37
|
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 f9786ba4a0532de4ccf53635319993c9d643e97a (commit) via e63b693fd53647cba334b1aba1acc593e5439dd0 (commit) from 9726ac31349d72eb0af754f473799a398e1ab69a (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 f9786ba4a0532de4ccf53635319993c9d643e97a Author: Falco Girgis <gyr...@gm...> Date: Sat Sep 28 13:14:47 2024 -0500 Cleaned up + optimized pvrmark_strips_direct bench (#707) * Cleaned up + optimized pvrmark_strips_direct bench - The pvrmark_strips_direct benchmark is an EXTREMELY important example, both for our ability to benchmark the PVR API's absolute fastest render path, AND as the only example we have given to users for how to use it. - The benchmark happens to do a bunch of dumb things that are artifically limiting performance here and are making runs inconstistent. - Removed branch from critical path - Stopped clearing out unused vertex attributes like u, v, and oargb - Stopped performing printf logic witin the timed sections - Cleaned up benchmark - Increased the rate at which the INCREMENT phase increased poly count (because it takes forever to normalize, atm) - Added brief description * Addressed code review feedback. commit e63b693fd53647cba334b1aba1acc593e5439dd0 Author: Falco Girgis <gyr...@gm...> Date: Sat Sep 28 13:03:30 2024 -0500 pvr_prim() Performance Improvement + PVR Hybrid Submission Model (#740) * Initial implementation of a "hybrid" vertex submission strategy using the existing PVR APIs. To use this method: 1) Enable DMA mode when initializing the PVR 2) Set the in-RAM vertex buffers for each list type to be deferred with the DMA (pvr_set_vertbuf()). 3) For the list type to be immediately submitted: - pvr_list_begin(LIST_TYPE); - pvr_dr_begin(dr_state); - /* COMMIT POLYGONS */ - pvr_list_end(); //!!!! NOTICE YOU DO NOT CALL PVR_DR_END()!!! * pvr_prim()'s performance was destroyed previously when making it have to lock/unlock a mutex for SQ ownership every call. Fixed the regression and then optimized further, by forwarding directly to sq_fast_cpy() (when DMA isn't active), which is now okay, since every vertex and header has a 32-byte alignment. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG.md | 1 + examples/dreamcast/pvr/pvrmark/pvrmark.c | 38 +++++-- .../pvrmark_strips_direct/pvrmark_strips_direct.c | 115 ++++++++++++--------- kernel/arch/dreamcast/hardware/pvr/pvr_internal.h | 1 + kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 10 ++ kernel/arch/dreamcast/hardware/pvr/pvr_scene.c | 63 ++++++++--- kernel/arch/dreamcast/include/dc/pvr.h | 3 + 7 files changed, 158 insertions(+), 73 deletions(-) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 107191f2..fad4dd20 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -6,6 +6,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha - Added pvrtex utility by TapamN to utils [DF == Daniel Fairchild] - Added . & .. directories to filesystems that lack it [AB] - Replaced previous implementation of realpath() to remove license from AUTHORS [AB] +- Enabled hybrid PVR DR/DMA vertex submission in driver + sped up pvr_prim() [FG] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/examples/dreamcast/pvr/pvrmark/pvrmark.c b/examples/dreamcast/pvr/pvrmark/pvrmark.c index c2edb7a1..8d0eccd6 100644 --- a/examples/dreamcast/pvr/pvrmark/pvrmark.c +++ b/examples/dreamcast/pvr/pvrmark/pvrmark.c @@ -10,7 +10,7 @@ pvr_init_params_t pvr_params = { { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0 }, - 512 * 1024 + 1024 * 1024 }; enum { PHASE_HALVE, PHASE_INCR, PHASE_DECR, PHASE_FINAL }; @@ -69,11 +69,16 @@ void setup(void) { pvr_poly_compile(&hdr, &cxt); } +int oldseed = 0xdeadbeef; void do_frame(void) { pvr_vertex_t vert; int x, y, z; int size; int i, col; + int seed = oldseed; + +#define nextnum() seed = seed * 1164525 + 1013904223; +#define getnum(mn) (seed & ((mn) - 1)) vid_border_color(0, 0, 0); pvr_wait_ready(); @@ -82,20 +87,32 @@ void do_frame(void) { pvr_list_begin(PVR_LIST_OP_POLY); pvr_prim(&hdr, sizeof(hdr)); + x = getnum(1024); + nextnum(); + y = getnum(512); + nextnum(); + z = getnum(128) + 1; + nextnum(); + size = getnum(64) + 1; + nextnum(); + col = getnum(256); + nextnum(); + for(i = 0; i < polycnt; i++) { - x = rand() % 640; - y = rand() % 480; - z = rand() % 100 + 1; - size = rand() % 50; - col = rand() % 256; + x = (x + ((getnum(128)) - 64)) & 1023; + nextnum(); + y = (y + ((getnum(128)) - 64)) % 511; + nextnum(); + size = getnum(64) + 1; + nextnum(); + col = getnum(256); + nextnum(); vert.flags = PVR_CMD_VERTEX; vert.x = x - size; vert.y = y + size; vert.z = z; - vert.u = vert.v = 0.0f; vert.argb = col | (col << 8) | (col << 16) | 0xff000000; - vert.oargb = 0; pvr_prim(&vert, sizeof(vert)); vert.y = y - size; @@ -110,6 +127,7 @@ void do_frame(void) { pvr_list_finish(); pvr_scene_finish(); vid_border_color(0, 255, 0); + oldseed = seed; } time_t begin; @@ -126,9 +144,9 @@ void check_switch(void) { now = time(NULL); if(now >= (begin + 5)) { - begin = time(NULL); printf(" Average Frame Rate: ~%f fps (%d pps)\n", (double)avgfps, (int)(polycnt * avgfps)); - + begin = time(NULL); + switch(phase) { case PHASE_HALVE: diff --git a/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c b/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c index df3e1d73..6f0bd3ad 100644 --- a/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c +++ b/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c @@ -1,25 +1,34 @@ /* KallistiOS ##version## pvrmark_strips_direct.c - (c)2002 Megan Potter + Copyright (C) 2002 Megan Potter + Copyright (C) 2024 Falco Girgis +*/ + +/* + This file serves as both an example of and benchmark for KOS's + rendering fast path: the PVR direct rendering API. */ #include <kos.h> #include <stdlib.h> #include <time.h> +#include <limits.h> + +enum { PHASE_HALVE, PHASE_INCR, PHASE_DECR, PHASE_FINAL }; -pvr_init_params_t pvr_params = { +static pvr_init_params_t pvr_params = { { PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0 }, 512 * 1024 }; -enum { PHASE_HALVE, PHASE_INCR, PHASE_DECR, PHASE_FINAL }; - -int polycnt; -int phase = PHASE_HALVE; -float avgfps = -1; +static int polycnt; +static int phase = PHASE_HALVE; +static float avgfps = -1; +static pvr_poly_hdr_t hdr; +static time_t begin; -void running_stats(void) { +static void running_stats(void) { pvr_stats_t stats; pvr_get_stats(&stats); @@ -29,7 +38,7 @@ void running_stats(void) { avgfps = (avgfps + stats.frame_rate) / 2.0f; } -void stats(void) { +static void stats(void) { pvr_stats_t stats; pvr_get_stats(&stats); @@ -38,7 +47,7 @@ void stats(void) { } -int check_start(void) { +static int check_start(void) { maple_device_t *cont; cont_state_t *state; @@ -56,9 +65,7 @@ int check_start(void) { return 0; } -pvr_poly_hdr_t hdr; - -void setup(void) { +static void setup(void) { pvr_poly_cxt_t cxt; pvr_init(&pvr_params); @@ -69,17 +76,26 @@ void setup(void) { pvr_poly_compile(&hdr, &cxt); } -int oldseed = 0xdeadbeef; -void do_frame(void) { - pvr_vertex_t * vert; - int x, y, z; - int i, col; +inline static int getnum(int *seed, int mn) { + int num = (*seed & ((mn) - 1)); + *seed = *seed * 1164525 + 1013904223; + return num; +} + +inline static void get_vert(int *seed, int *x, int *y, int *col) { + *x = (*x + ((getnum(seed, 64)) - 32)) & 1023; + *y = (*y + ((getnum(seed, 64)) - 32)) & 511; + *col = getnum(seed, INT32_MAX); +} + +static void do_frame(void) { + pvr_vertex_t *vert; + int x=0, y=0, z=0, col=0; + int i; + static int oldseed = 0xdeadbeef; int seed = oldseed; pvr_dr_state_t dr_state; -#define nextnum() seed = seed * 1164525 + 1013904223; -#define getnum(mn) (seed & ((mn) - 1)) - vid_border_color(0, 0, 0); pvr_wait_ready(); vid_border_color(255, 0, 0); @@ -89,54 +105,45 @@ void do_frame(void) { pvr_dr_init(&dr_state); - x = getnum(1024); - nextnum(); - y = getnum(512); - nextnum(); - z = getnum(128) + 1; - nextnum(); - col = getnum(256); - nextnum(); + get_vert(&seed, &x, &y, &col); + z = getnum(&seed, 128) + 1; vert = pvr_dr_target(dr_state); vert->flags = PVR_CMD_VERTEX; vert->x = x; vert->y = y; vert->z = z; - vert->u = vert->v = 0.0f; - vert->argb = col | (col << 8) | (col << 16) | 0xff000000; - vert->oargb = 0; + vert->argb = 0xff000000 | col; pvr_dr_commit(vert); for(i = 0; i < polycnt; i++) { - x = (x + ((getnum(64)) - 32)) & 1023; - nextnum(); - y = (y + ((getnum(64)) - 32)) % 511; - nextnum(); - col = getnum(256); - nextnum(); + get_vert(&seed, &x, &y, &col); + vert = pvr_dr_target(dr_state); vert->flags = PVR_CMD_VERTEX; vert->x = x; vert->y = y; vert->z = z; - vert->u = vert->v = 0.0f; - vert->argb = col | (col << 8) | (col << 16) | 0xff000000; - vert->oargb = 0; - - if(i == (polycnt - 1)) - vert->flags = PVR_CMD_VERTEX_EOL; - + vert->argb = 0xff000000 | col; pvr_dr_commit(vert); } + get_vert(&seed, &x, &y, &col); + + vert = pvr_dr_target(dr_state); + vert->flags = PVR_CMD_VERTEX_EOL; + vert->x = x; + vert->y = y; + vert->z = z; + vert->argb = 0xff000000 | col; + pvr_dr_commit(vert); + pvr_list_finish(); pvr_scene_finish(); vid_border_color(0, 255, 0); oldseed = seed; } -time_t begin; void switch_tests(int ppf) { printf("Beginning new test: %d polys per frame (%d per second at 60fps)\n", ppf, ppf * 60); @@ -146,50 +153,58 @@ void switch_tests(int ppf) { void check_switch(void) { time_t now; + int new_polycnt = polycnt; now = time(NULL); if(now >= (begin + 5)) { - begin = time(NULL); printf(" Average Frame Rate: ~%f fps (%d pps)\n", (double)avgfps, (int)(polycnt * avgfps)); switch(phase) { case PHASE_HALVE: if(avgfps < 55) { - switch_tests(polycnt / 2); + new_polycnt = polycnt / 2; } else { printf(" Entering PHASE_INCR\n"); phase = PHASE_INCR; + break; } break; case PHASE_INCR: if(avgfps >= 55) { - switch_tests(polycnt + 500); + new_polycnt = polycnt + 2500; } else { printf(" Entering PHASE_DECR\n"); phase = PHASE_DECR; + break; } break; case PHASE_DECR: if(avgfps < 55) { - switch_tests(polycnt - 200); + new_polycnt = polycnt - 200; } else { printf(" Entering PHASE_FINAL\n"); phase = PHASE_FINAL; + break; } break; case PHASE_FINAL: break; } + + begin = time(NULL); + + if(new_polycnt != polycnt) + switch_tests(new_polycnt); } } diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h b/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h index f7846232..3db2278d 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_internal.h @@ -223,6 +223,7 @@ typedef struct { // Output address for to-texture mode uint32 to_txr_addr[2]; + // Whether direct rendering is active or not uint32 dr_used; } pvr_state_t; diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c index 11cb2045..8e72fb94 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_irq.c @@ -40,6 +40,16 @@ static void dma_next_list(void *data) { // Get the buffers for this frame. b = pvr_state.dma_buffers + (pvr_state.ram_target ^ 1); + /* If we are in PVR DMA mode, yet we haven't associated a + RAM-residing vertex buffer with the current list + (because we submitted it directly, for example), + 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; + } + // Flush the last 32 bytes out of dcache, just in case. // dcache_flush_range((ptr_t)(b->base[i] + b->ptr[i] - 32), 32); dcache_flush_range((ptr_t)(b->base[i]), b->ptr[i] + 32); diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c b/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c index 0b897bae..922c6500 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c @@ -1,13 +1,15 @@ /* KallistiOS ##version## pvr_scene.c - Copyright (C)2002,2004 Megan Potter + Copyright (C) 2002,2004 Megan Potter + Copyright (C) 2024 Falco Girgis */ #include <assert.h> #include <stdio.h> #include <string.h> +#include <kos/string.h> #include <kos/thread.h> #include <dc/pvr.h> #include <dc/sq.h> @@ -135,6 +137,13 @@ void pvr_scene_begin_txr(pvr_ptr_t txr, uint32 *rx, uint32 *ry) { pvr_scene_begin(); } +static bool pvr_list_dma; + +inline static bool pvr_list_uses_dma(pvr_list_t list) { + return pvr_state.dma_mode && + pvr_state.dma_buffers[pvr_state.ram_target].base[list]; +} + /* Begin collecting data for the given list type. Lists do not have to be submitted in any particular order, but all types of a list must be submitted at once. If the given list has already been closed, then an @@ -153,6 +162,11 @@ int pvr_list_begin(pvr_list_t list) { if(pvr_state.list_reg_open != -1 && pvr_state.list_reg_open != (int)list) pvr_list_finish(); + pvr_list_dma = pvr_list_uses_dma(list); + + if(!pvr_list_dma) + sq_lock((void *)PVR_TA_INPUT); + /* Ok, set the flag */ pvr_state.list_reg_open = list; @@ -175,7 +189,13 @@ int pvr_list_finish(void) { #endif /* !NDEBUG */ - if(!pvr_state.dma_mode) { + /* Check for immediate submission: + A. If we are not in DMA mode, we must be submitting polygons + immediately. + B. If we are in DMA mode, yet there's no vertex buffer associated + with the list type, assume we're doing hybrid drawing and + are directly submitting this list type. */ + if(!pvr_list_dma) { /* Release Store Queues if they are used */ if(pvr_state.dr_used) { pvr_dr_finish(); @@ -184,6 +204,8 @@ int pvr_list_finish(void) { /* In case we haven't sent anything in this list, send a dummy */ pvr_blank_polyhdr(pvr_state.list_reg_open); + sq_unlock(); + /* Set the flags */ pvr_state.lists_closed |= (1 << pvr_state.list_reg_open); @@ -203,16 +225,22 @@ int pvr_prim(void * data, int size) { dbglog(DBG_WARNING, "pvr_prim: attempt to submit to unopened list\n"); return -1; } +#endif /* !NDEBUG */ + if(!pvr_list_dma) { +#ifndef NDEBUG + if((uintptr_t)data & 0x7) { + dbglog(DBG_WARNING, "pvr_prim: attempt to submit data unaligned " + "to 8 bytes.\n"); + return -1; + } #endif /* !NDEBUG */ - if(!pvr_state.dma_mode) { - /* Send the data */ - pvr_sq_load((void *)0, data, size, PVR_DMA_TA); - } - else { - return pvr_list_prim(pvr_state.list_reg_open, data, size); + /* Immediately send data via SQs. */ + sq_fast_cpy(SQ_MASK_DEST(PVR_TA_INPUT), data, size >> 5); } + /* Defer data to RAM buffer for DMA-ing later. */ + else return pvr_list_prim(pvr_state.list_reg_open, data, size); return 0; } @@ -221,12 +249,19 @@ int pvr_list_prim(pvr_list_t list, void * data, int size) { volatile pvr_dma_buffers_t * b; b = pvr_state.dma_buffers + pvr_state.ram_target; + + /* Ensure we associated a DMA vertex buffer with this list type. */ assert(b->base[list]); + /* Ensure data size is multiple of 32-bytes. */ assert(!(size & 31)); + /* Ensure at least 4-byte alignment. */ + assert(!((uintptr_t)data & 0x3)); memcpy(b->base[list] + b->ptr[list], data, size); b->ptr[list] += size; + + /* Ensure we didn't overflow the vertex buffer. */ assert(b->ptr[list] <= b->size[list]); return 0; @@ -234,13 +269,11 @@ int pvr_list_prim(pvr_list_t list, void * data, int size) { void pvr_dr_init(pvr_dr_state_t *vtx_buf_ptr) { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-09-28 01:09:16
|
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 9726ac31349d72eb0af754f473799a398e1ab69a (commit) via 1da9acd4c88143627615d28dd72d2453f8ade567 (commit) from 411641379d6ebd2f5c77a0c72b56473bfe27c37d (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 9726ac31349d72eb0af754f473799a398e1ab69a Author: Twada <166...@us...> Date: Sat Sep 28 10:08:58 2024 +0900 Helper functions and examples for modifier volumes and Z clipping (#675) * Initial commit * romdisk fix * modified: Makefile modified: example.c * modified: pvr_zclip.c modified: pvr_zclip.h * modified: example.c modified: pvr_zclip.c * Apply suggestions from code review Co-authored-by: Falco Girgis <gyr...@gm...> * modified: example.c * Update examples/dreamcast/pvr/modifier_volume_zclip/example.c Co-authored-by: Falco Girgis <gyr...@gm...> --------- Co-authored-by: Twada2004 <Twa...@us...> Co-authored-by: Falco Girgis <gyr...@gm...> Co-authored-by: Donald Haase <qu...@ya...> commit 1da9acd4c88143627615d28dd72d2453f8ade567 Author: Cole Hall <col...@gm...> Date: Fri Sep 27 07:55:12 2024 +0100 Fix license link in README.md (#776) ----------------------------------------------------------------------- Summary of changes: README.md | 2 +- .../modifier_volume_zclip}/Makefile | 6 +- .../dreamcast/pvr/modifier_volume_zclip/example.c | 306 +++++++++ .../pvr/modifier_volume_zclip/pvr_zclip.c | 747 +++++++++++++++++++++ .../pvr/modifier_volume_zclip/pvr_zclip.h | 20 + .../pvr/modifier_volume_zclip/romdisk/blocks.png | Bin 0 -> 86075 bytes 6 files changed, 1077 insertions(+), 4 deletions(-) copy examples/dreamcast/{cpp/modplug_test => pvr/modifier_volume_zclip}/Makefile (75%) create mode 100644 examples/dreamcast/pvr/modifier_volume_zclip/example.c create mode 100644 examples/dreamcast/pvr/modifier_volume_zclip/pvr_zclip.c create mode 100644 examples/dreamcast/pvr/modifier_volume_zclip/pvr_zclip.h create mode 100644 examples/dreamcast/pvr/modifier_volume_zclip/romdisk/blocks.png diff --git a/README.md b/README.md index c0f154f5..10618ec6 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ A beginner's guide to development for the Sega Dreamcast along with detailed ins # Licensing KallistiOS itself is licensed under the BSD-like **KOS License**. **Attribution is not optional**. Additionally, this distribution contains code licensed under various free software licenses. -See [LICENSE.md](doc/LICENSE.md) for more information on licensing, as well as [LICENSE.KOS](doc/LICENSE.KOS) for the actual **KOS License** text. +See [LICENSE.md](doc/LICENSE.md) for more information on licensing, as well as [LICENSE.KOS](doc/license/LICENSE.KOS) for the actual **KOS License** text. # Examples Once you've set up the environment and are ready to begin developing, a good place to start learning is the examples directory, which provides demos for the various KOS APIs and for interacting with the Dreamcast's hardware. Examples include: diff --git a/examples/dreamcast/cpp/modplug_test/Makefile b/examples/dreamcast/pvr/modifier_volume_zclip/Makefile similarity index 75% copy from examples/dreamcast/cpp/modplug_test/Makefile copy to examples/dreamcast/pvr/modifier_volume_zclip/Makefile index bb417eb7..49e7e523 100644 --- a/examples/dreamcast/cpp/modplug_test/Makefile +++ b/examples/dreamcast/pvr/modifier_volume_zclip/Makefile @@ -1,5 +1,5 @@ TARGET = example.elf -OBJS = example.o romdisk.o +OBJS = example.o pvr_zclip.o romdisk.o KOS_ROMDISK_DIR = romdisk all: rm-elf $(TARGET) @@ -7,13 +7,13 @@ all: rm-elf $(TARGET) include $(KOS_BASE)/Makefile.rules clean: rm-elf - -rm -f $(OBJS) + -rm -f $(OBJS) rm-elf: -rm -f $(TARGET) romdisk.* $(TARGET): $(OBJS) - kos-c++ -o $(TARGET) $(OBJS) -lmodplug + kos-cc -o $(TARGET) $(OBJS) -lpng -lz run: $(TARGET) $(KOS_LOADER) $(TARGET) diff --git a/examples/dreamcast/pvr/modifier_volume_zclip/example.c b/examples/dreamcast/pvr/modifier_volume_zclip/example.c new file mode 100644 index 00000000..564137bc --- /dev/null +++ b/examples/dreamcast/pvr/modifier_volume_zclip/example.c @@ -0,0 +1,306 @@ +/* + * KallistiOS ##version## + * + * examples/dreamcast/pvr/modifier_volume_zclip/example.c + * Copyright (C) 2024 Twada + * + * This example demonstrates how to perform Z-clipping on modifier volumes. + * + * by Twada + */ +#include <kos.h> +#include <png/png.h> +#include <zlib/zlib.h> +#include "pvr_zclip.h" + +/* textures */ +static pvr_ptr_t box_tex; + +static void mul_screen(float width, float height) +{ + matrix_t d = { + {1.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 1.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 1.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 1.0f}}; + d[0][0] = width * 0.5f; + d[1][1] = -height * 0.5f; + d[3][0] = width * 0.5f; + d[3][1] = height * 0.5f; + mat_apply(&d); +} + +static void mul_projection(float fov, float aspect, float znear) +{ + matrix_t d = { + {1.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 1.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 1.0f, 0.0f}, + {0.0f, 0.0f, 0.0f, 1.0f}}; + float s = 1.0f / ftan(fov * 0.5f); + d[0][0] = s / aspect; + d[1][1] = s; + d[2][2] = 0.0f; + d[2][3] = -1.0f; + d[3][2] = znear; + d[3][3] = 0.0f; + mat_apply(&d); +} + +static void draw_modifier(matrix_t *pvm) +{ + pvr_modifier_vol_t vol[12] = { + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0, 0, 0}, + }; + float vert[8][3] = { + {-1.0f, -1.0f, 1.0f}, + {-1.0f, -1.0f, -1.0f}, + {1.0f, -1.0f, 1.0f}, + {1.0f, -1.0f, -1.0f}, + {-1.0f, 1.0f, 1.0f}, + {-1.0f, 1.0f, -1.0f}, + {1.0f, 1.0f, 1.0f}, + {1.0f, 1.0f, -1.0f}, + }; + float transform[8][3]; + int index[12][3] = { + {1, 0, 3}, /* Bottom */ + {0, 3, 2}, + {4, 5, 6}, /* Top */ + {5, 6, 7}, + {0, 4, 2}, /* Front */ + {4, 2, 6}, + {2, 6, 3}, /* Right */ + {6, 3, 7}, + {3, 7, 1}, /* Back */ + {7, 1, 5}, + {1, 5, 0}, /* Left */ + {5, 0, 4}}; + pvr_mod_hdr_t hdr; + static float ry = 0.0f; + /* Vertex transform */ + ry += 0.01; + mat_identity(); + mat_apply(pvm); + mat_translate(-1.0f, 0.25f, 1.0f); + mat_rotate(0.0f, ry, 0.0f); + mat_scale(2.0f, 2.0f, 2.0f); + for (int i = 0; i < 8; i++) + { + transform[i][0] = vert[i][0]; + transform[i][1] = vert[i][1]; + transform[i][2] = vert[i][2]; + mat_trans_single3(transform[i][0], transform[i][1], transform[i][2]); + } + /* Face set */ + for (int i = 0; i < 12; i++) + { + vol[i].ax = transform[index[i][0]][0]; + vol[i].ay = transform[index[i][0]][1]; + vol[i].az = transform[index[i][0]][2]; + vol[i].bx = transform[index[i][1]][0]; + vol[i].by = transform[index[i][1]][1]; + vol[i].bz = transform[index[i][1]][2]; + vol[i].cx = transform[index[i][2]][0]; + vol[i].cy = transform[index[i][2]][1]; + vol[i].cz = transform[index[i][2]][2]; + } + pvr_mod_compile(&hdr, PVR_LIST_OP_MOD, PVR_MODIFIER_INCLUDE_LAST_POLY, PVR_CULLING_SMALL); + hdr.cmd |= (1 << 6); /* Last poly */ + pvr_modifier_commit_zclip(&hdr, vol, 12); +} + +static void draw_box(matrix_t *pvm) +{ + pvr_vertex_t poly[18] = { + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0xffffffff, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0xffffffff, 0x00000000}, + }; + float vert[8][3] = { + {-1.0f, -1.0f, 1.0f}, + {-1.0f, -1.0f, -1.0f}, + {1.0f, -1.0f, 1.0f}, + {1.0f, -1.0f, -1.0f}, + {-1.0f, 1.0f, 1.0f}, + {-1.0f, 1.0f, -1.0f}, + {1.0f, 1.0f, 1.0f}, + {1.0f, 1.0f, -1.0f}, + }; + float transform[8][3]; + int index[18] = { + 1, 0, 3, -2, + 4, 5, 6, -7, + 0, 4, 2, 6, 3, 7, 1, 5, 0, -4}; + pvr_poly_cxt_t cxt; + pvr_poly_hdr_t hdr; + /* Vertex transform */ + mat_identity(); + mat_apply(pvm); + mat_translate(1.0f, 2.0f, -1.0f); + mat_scale(2.0f, 2.0f, 2.0f); + for (int i = 0; i < 8; i++) + { + transform[i][0] = vert[i][0]; + transform[i][1] = vert[i][1]; + transform[i][2] = vert[i][2]; + mat_trans_single3(transform[i][0], transform[i][1], transform[i][2]); + } + /* Face set */ + for (int i = 0; i < 18; i++) + { + int idx = index[i]; + if (idx < 0) + { + poly[i].flags = PVR_CMD_VERTEX_EOL; + idx = -idx; + } + else + { + poly[i].flags = PVR_CMD_VERTEX; + } + poly[i].x = transform[idx][0]; + poly[i].y = transform[idx][1]; + poly[i].z = transform[idx][2]; + } + pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565, 256, 256, box_tex, PVR_FILTER_BILINEAR); + pvr_poly_compile(&hdr, &cxt); + hdr.cmd |= (1 << 7); /* PVR_MODIFIER_CHEAP_SHADOW */ + pvr_prim(&hdr, sizeof(hdr)); + pvr_vertex_commit_zclip(poly, 18); +} + +static void draw_plane(matrix_t *pvm) +{ + pvr_poly_cxt_t cxt; + pvr_poly_hdr_t hdr; + pvr_vertex_t poly[4] = { + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0xffff0000, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0xff00ff00, 0x00000000}, + {PVR_CMD_VERTEX, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0xff0000ff, 0x00000000}, + {PVR_CMD_VERTEX_EOL, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0xffffffff, 0x00000000}, + }; + float vert[4][3] = { + {-5.0f, 0.0f, 5.0f}, + {-5.0f, 0.0f, -5.0f}, + {5.0f, 0.0f, 5.0f}, + {5.0f, 0.0f, -5.0f}}; + int i; + mat_identity(); + mat_apply(pvm); + for (i = 0; i < 4; i++) + { + poly[i].x = vert[i][0]; + poly[i].y = vert[i][1]; + poly[i].z = vert[i][2]; + mat_trans_single3(poly[i].x, poly[i].y, poly[i].z); + } + pvr_poly_cxt_col(&cxt, PVR_LIST_OP_POLY); + pvr_poly_compile(&hdr, &cxt); + hdr.cmd |= (1 << 7); /* PVR_MODIFIER_CHEAP_SHADOW */ + pvr_prim(&hdr, sizeof(hdr)); + pvr_vertex_commit_zclip(poly, 4); +} + +int main(int argc, char* argv[]) +{ + pvr_init_params_t params = { + /* Enable opaque and translucent polygons with size 16 */ + .opb_sizes = {PVR_BINSIZE_16, PVR_BINSIZE_16, PVR_BINSIZE_0, PVR_BINSIZE_0, PVR_BINSIZE_0}, + .vertex_buf_size = 512 * 1024, /* Vertex buffer size 512K */ + .dma_enabled = 0, /* No DMA */ + .fsaa_enabled = 0, /* No FSAA */ + .autosort_disabled = 0, /* Translucent Autosort enabled. */ + .opb_overflow_count = 3 /* Extra OPBs */ + }; + matrix_t cam_pvm; + point_t cam_pos = {0.0f, 0.0f, 1.0f, 1.0f}; + point_t cam_tar = {0.0f, 0.0f, 0.0f, 1.0f}; + point_t cam_up = {0.0f, 1.0f, 0.0f, 1.0f}; + int done = 0; + float dy = 0.0f; + float dis = 5.0f; + float high = 2.0f; + + /* init kos */ + pvr_init(¶ms); + pvr_set_bg_color(0, 0.5f, 1.0f); + /* Enable cheap shadow */ + pvr_set_shadow_scale(1, 0.5f); + + /* init plane */ + box_tex = pvr_mem_malloc(256 * 256 * 2); + png_to_texture("/rd/blocks.png", box_tex, PNG_NO_ALPHA); + + /* keep drawing frames until start is pressed */ + while (!done) + { + maple_device_t *dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (dev) + { + + cont_state_t *st = (cont_state_t *)maple_dev_status(dev); + dy += (float)st->joyx * (0.1f / 127.0f); + high -= (float)st->joyy * (0.25f / 127.0f); + if (st->rtrig) + dis -= (float)st->rtrig * 0.001f; + if (st->ltrig) + dis += (float)st->ltrig * 0.001f; + cam_pos.x = fsin(dy) * dis; + cam_pos.y = high; + cam_pos.z = fcos(dy) * dis; + + if (st->buttons & CONT_START) + done = 1; + } + /* set camera */ + mat_identity(); + mul_screen(640.0f, 480.0f); + mul_projection((3.14159265f / 3.0f), (640.0f / 480.0f), 0.125f); + mat_lookat(&cam_pos, &cam_tar, &cam_up); + mat_store(&cam_pvm); + + pvr_wait_ready(); + pvr_scene_begin(); + + pvr_list_begin(PVR_LIST_OP_POLY); + draw_plane(&cam_pvm); + draw_box(&cam_pvm); + pvr_list_finish(); + + pvr_list_begin(PVR_LIST_OP_MOD); + draw_modifier(&cam_pvm); + pvr_list_finish(); + + pvr_scene_finish(); + } + pvr_mem_free(box_tex); + + return 0; +} diff --git a/examples/dreamcast/pvr/modifier_volume_zclip/pvr_zclip.c b/examples/dreamcast/pvr/modifier_volume_zclip/pvr_zclip.c new file mode 100644 index 00000000..796ede85 --- /dev/null +++ b/examples/dreamcast/pvr/modifier_volume_zclip/pvr_zclip.c @@ -0,0 +1,747 @@ +#include "pvr_zclip.h" + +static void vert_commit(pvr_vertex_t *dest, pvr_vertex_t *src, int eos) +{ + asm volatile( + "fschg\n\t" + "add #14, %[e]\n\t" + "fmov @%[s]+, dr0\n\t" + "shld %[shift], %[e]\n\t" + "fmov @%[s]+, dr2\n\t" + "lds %[e], fpul\n\t" + "fmov @%[s]+, dr4\n\t" + "add #32, %[d]\n\t" + "fmov @%[s]+, dr6\n\t" + "fsts fpul, fr0\n\t" + "fmov dr6,@-%[d]\n\t" + "fmov dr4,@-%[d]\n\t" + "fmov dr2,@-%[d]\n\t" + "fmov dr0,@-%[d]\n\t" + "pref @%[d]\n\t" + "fschg\n" + : [d] "+&r"(dest), [s] "+&r"(src), [e] "+r"(eos) + : [shift] "r"(28) + : "fpul", "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7"); +} + +static void inter_vert_commit(pvr_vertex_t *dest, pvr_vertex_t *inside, pvr_vertex_t *outside, int eos) +{ + unsigned int in_rb; + unsigned int in_ag; + unsigned int out_rb; + unsigned int out_ag; + asm volatile( + "fschg\n\t" + + "fmov.d @%[i]+, dr2\n\t" + "fmov.d @%[i]+, dr4\n\t" + "fmov.d @%[o]+, dr6\n\t" + "fmov.d @%[o]+, dr8\n\t" + + "fcmp/gt fr5, fr9\n\t" + "add #32, %[d]\n\t" + "fmul fr5, fr5\n\t" + "mov #28, %[rb0]\n\t" + "fsrra fr5\n\t" + "add #14, %[e]\n\t" + "fmul fr9, fr9\n\t" + "shld %[rb0], %[e]\n\t" + "fsrra fr9\n\t" + "lds %[e], fpul\n\t" + "bt/s 1f\n\t" + "fsts fpul, fr2\n\t" + "fneg fr9\n\t" + "1:\n\t" + + "fmul fr5, fr3\n\t" + "fmul fr5, fr4\n\t" + "fmul fr9, fr7\n\t" + "fmul fr9, fr8\n\t" + + "fneg fr9\n\t" + "fadd fr5, fr9\n\t" + "fldi1 fr0\n\t" + "fmul fr9, fr9\n\t" + "fneg fr0\n\t" + "fsrra fr9\n\t" + "fadd fr5, fr0\n\t" + "fmul fr9, fr0\n\t" + + "fsub fr3, fr7\n\t" + "fsub fr4, fr8\n\t" + "fmac fr0, fr7, fr3\n\t" + "fmac fr0, fr8, fr4\n\t" + "fldi1 fr5\n\t" + + "fmov.d @%[i]+, dr6\n\t" + "fmov.d @%[o]+, dr8\n\t" + "fsub fr6, fr8\n\t" + "fsub fr7, fr9\n\t" + "fmac fr0, fr8, fr6\n\t" + "fmac fr0, fr9, fr7\n\t" + + "mov #-1, %[e]\n\t" + "extu.b %[e], %[e]\n\t" + "lds %[e], fpul\n\t" + "float fpul, fr1\n\t" + "fmul fr0, fr1\n\t" + "ftrc fr1, fpul\n\t" + "sts fpul, %[e]\n\t" + + "mov.l @(4, %[i]), %[rb0]\n\t" + "mov %[rb0], %[ag0]\n\t" + "and %[m], %[rb0]\n\t" + "shlr8 %[ag0]\n\t" + "mov.l @(4, %[o]), %[rb1]\n\t" + "and %[m], %[ag0]\n\t" + "mov %[rb1], %[ag1]\n\t" + "and %[m], %[rb1]\n\t" + "shlr8 %[ag1]\n\t" + "and %[m], %[ag1]\n\t" + + "sub %[ag0], %[ag1]\n\t" + "mul.l %[e], %[ag1]\n\t" + "sub %[rb0], %[rb1]\n\t" + "sts macl, %[ag1]\n\t" + "shlr8 %[ag1]\n\t" + "add %[ag1], %[ag0]\n\t" + "mul.l %[e], %[rb1]\n\t" + "and %[m], %[ag0]\n\t" + "shll8 %[ag0]\n\t" + "sts macl, %[rb1]\n\t" + "shlr8 %[rb1]\n\t" + "add %[rb1], %[rb0]\n\t" + "and %[m], %[rb0]\n\t" + "or %[ag0], %[rb0]\n" + "mov.l %[rb0], @-%[d]\n\t" + + "mov.l @%[i], %[rb0]\n\t" + "mov %[rb0], %[ag0]\n\t" + "and %[m], %[rb0]\n\t" + "shlr8 %[ag0]\n\t" + "mov.l @%[o], %[rb1]\n\t" + "and %[m], %[ag0]\n\t" + "mov %[rb1], %[ag1]\n\t" + "and %[m], %[rb1]\n\t" + "shlr8 %[ag1]\n\t" + "and %[m], %[ag1]\n\t" + + "sub %[ag0], %[ag1]\n\t" + "mul.l %[e], %[ag1]\n\t" + "sub %[rb0], %[rb1]\n\t" + "sts macl, %[ag1]\n\t" + "shlr8 %[ag1]\n\t" + "add %[ag1], %[ag0]\n\t" + "mul.l %[e], %[rb1]\n\t" + "and %[m], %[ag0]\n\t" + "shll8 %[ag0]\n\t" + "sts macl, %[rb1]\n\t" ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-09-27 03:46: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 411641379d6ebd2f5c77a0c72b56473bfe27c37d (commit) from d1fd7dc7b7de15950eb8db99e2831a10cb872f7e (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 411641379d6ebd2f5c77a0c72b56473bfe27c37d 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...> ----------------------------------------------------------------------- Summary of changes: utils/dcbumpgen/Makefile | 2 +- utils/kmgenc/Makefile | 4 ++-- utils/vqenc/Makefile | 11 +++-------- utils/vqenc/vq_internal.h | 22 +++++++++------------- utils/vqenc/vqenc.c | 2 +- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/utils/dcbumpgen/Makefile b/utils/dcbumpgen/Makefile index a681a912..33a7d7c4 100644 --- a/utils/dcbumpgen/Makefile +++ b/utils/dcbumpgen/Makefile @@ -1,7 +1,7 @@ # Makefile stolen from the kmgenc program. -CFLAGS = -O2 -Wall -DINLINE=inline -I/usr/local/include +CFLAGS = -O2 -Wall -I/usr/local/include LDFLAGS = -s -lpng -ljpeg -lm -lz -L/usr/local/lib all: dcbumpgen diff --git a/utils/kmgenc/Makefile b/utils/kmgenc/Makefile index 4f1c6ee1..53c68cae 100644 --- a/utils/kmgenc/Makefile +++ b/utils/kmgenc/Makefile @@ -1,8 +1,8 @@ # Makefile for the kmgenc program. -CFLAGS = -O2 -Wall -DINLINE=inline -I/usr/local/include #-g# -LDFLAGS = -s -lpng -ljpeg -lz -L/usr/local/lib #-g +CFLAGS = -O2 -Wall -I/usr/local/include +LDFLAGS = -s -lpng -ljpeg -lz -L/usr/local/lib all: kmgenc diff --git a/utils/vqenc/Makefile b/utils/vqenc/Makefile index 449c560f..5a0a6686 100644 --- a/utils/vqenc/Makefile +++ b/utils/vqenc/Makefile @@ -1,13 +1,8 @@ -# Makefile for the genromfs program. +# Makefile for the vqenc program. -# Use for OSX w/Fink -#CFLAGS = -O2 -Wall -DINLINE=inline -I/sw/include #-g# -#LDFLAGS = -s -L/sw/lib -lpng -ljpeg -lz #-g - -# Use for other systems -CFLAGS = -O2 -Wall -DINLINE=inline -I/usr/local/include #-g# -LDFLAGS = -lpng -ljpeg -lz -lm -L/usr/local/lib #-s -g +CFLAGS = -O2 -Wall -I/usr/local/include +LDFLAGS = -lpng -ljpeg -lz -lm -L/usr/local/lib all: vqenc diff --git a/utils/vqenc/vq_internal.h b/utils/vqenc/vq_internal.h index d633b1d3..8a82cecd 100644 --- a/utils/vqenc/vq_internal.h +++ b/utils/vqenc/vq_internal.h @@ -4,43 +4,39 @@ #include "vq_types.h" -#ifndef INLINE -#define INLINE -#endif - -static void INLINE get_color(fcolor_t *c, uint8 *pixels) { +static void inline get_color(fcolor_t *c, uint8 *pixels) { c->a = pixels[0]; c->r = pixels[1]; c->g = pixels[2]; c->b = pixels[3]; } -static void INLINE sum_colors(fcolor_t *out, fcolor_t *in) { +static void inline sum_colors(fcolor_t *out, fcolor_t *in) { out->a += in->a; out->r += in->r; out->g += in->g; out->b += in->b; } -static void INLINE div_colors(fcolor_t *out, float v) { +static void inline div_colors(fcolor_t *out, float v) { out->a /= v; out->r /= v; out->g /= v; out->b /= v; } -static void INLINE clear_quad(fquad_t *q) { +static void inline clear_quad(fquad_t *q) { memset(q, '\0', sizeof(*q)); } -static void INLINE add_quad(fquad_t *out, fquad_t *in) { +static void inline add_quad(fquad_t *out, fquad_t *in) { sum_colors(&out->p[0], &in->p[0]); sum_colors(&out->p[1], &in->p[1]); sum_colors(&out->p[2], &in->p[2]); sum_colors(&out->p[3], &in->p[3]); } -static void INLINE sub_quad(fquad_t *out, fquad_t *a, fquad_t *b) { +static void inline sub_quad(fquad_t *out, fquad_t *a, fquad_t *b) { int i; for(i = 0; i < 4; i++) { @@ -51,7 +47,7 @@ static void INLINE sub_quad(fquad_t *out, fquad_t *a, fquad_t *b) { } } -static void INLINE div_quad(fquad_t *q, float v) { +static void inline div_quad(fquad_t *q, float v) { if(v < 1.0f) { clear_quad(q); } @@ -63,8 +59,8 @@ static void INLINE div_quad(fquad_t *q, float v) { } } -static void INLINE copy_quad(fquad_t *out, fquad_t *in) { +static void inline copy_quad(fquad_t *out, fquad_t *in) { *out = *in; } -#endif +#endif /* __VQ_INTERNAL_H */ diff --git a/utils/vqenc/vqenc.c b/utils/vqenc/vqenc.c index f88933c0..5924da41 100644 --- a/utils/vqenc/vqenc.c +++ b/utils/vqenc/vqenc.c @@ -265,7 +265,7 @@ static uint16 pack(fcolor_t *c) { return PACK565(r, g, b); } -static int INLINE le16(int x) { +static int inline le16(int x) { /* Endian test added by Megan. This is probably not too efficient but it's portable and will get the job done. */ unsigned long test = 0x12345678; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2024-09-27 03:45:11
|
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 d1fd7dc7b7de15950eb8db99e2831a10cb872f7e (commit) from f842d4b3c8a391f2793c20e58f8f031f0c316043 (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 d1fd7dc7b7de15950eb8db99e2831a10cb872f7e 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) ----------------------------------------------------------------------- Summary of changes: utils/bin2c/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/bin2c/Makefile b/utils/bin2c/Makefile index a6ec3d9e..a8c57ee6 100644 --- a/utils/bin2c/Makefile +++ b/utils/bin2c/Makefile @@ -3,9 +3,8 @@ all: bin2c -bin2c: - gcc -o bin2c bin2c.c +bin2c: bin2c.c + gcc -o $@ $^ clean: -rm -f bin2c - hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-09-24 22:50:38
|
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 f842d4b3c8a391f2793c20e58f8f031f0c316043 (commit) from 0bdb5c9d7c490a7f2d3fb9f8d991e9559bf3e1b3 (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 f842d4b3c8a391f2793c20e58f8f031f0c316043 Author: Falco Girgis <gyr...@gm...> Date: Tue Sep 24 16:00:30 2024 -0500 Downsized stack sizes for idle and reaper threads (#706) - Both the idle and reaper threads are constructed with the default, 32KB stack size. - Neither one of these need 32KB, and both of them are doing deterministic things... - Created static buffers for both of their stacks. - Idle thread gets 64 bytes of stack space. - Reaper gets 512 bytes of stack space. - Total space saved: 63.4375KB. ----------------------------------------------------------------------- Summary of changes: kernel/thread/thread.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c index d2792c13..f4010257 100644 --- a/kernel/thread/thread.c +++ b/kernel/thread/thread.c @@ -16,6 +16,8 @@ #include <assert.h> #include <reent.h> #include <errno.h> +#include <stdalign.h> + #include <kos/thread.h> #include <kos/dbgio.h> #include <kos/sem.h> @@ -50,6 +52,10 @@ static inline size_t align_to(size_t address, size_t alignment) { return (address + (alignment - 1)) & ~(alignment - 1); } +/* Builtin background thread data */ +static alignas(8) uint8_t thd_reaper_stack[512]; +static alignas(8) uint8_t thd_idle_stack[64]; + /*****************************************************************************/ /* Thread scheduler data */ @@ -514,7 +520,7 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr, nt->state = STATE_READY; if(!real_attr.label) { - strcpy(nt->label, "[un-named kernel thread]"); + strcpy(nt->label, "unnamed"); } else { strncpy(nt->label, real_attr.label, 255); @@ -1041,7 +1047,22 @@ int thd_init(void) { .stack_ptr = (void *)_arch_mem_top - THD_KERNEL_STACK_SIZE, .label = "[kernel]" }; - kthread_t *kern, *reaper; + + const kthread_attr_t reaper_attr = { + .stack_size = sizeof(thd_reaper_stack), + .stack_ptr = thd_reaper_stack, + .prio = 1, + .label = "[reaper]" + }; + + const kthread_attr_t idle_attr = { + .stack_size = sizeof(thd_idle_stack), + .stack_ptr = thd_idle_stack, + .prio = PRIO_MAX, + .label = "[idle]" + }; + + kthread_t *kern; /* Make sure we're not already running */ if(thd_mode != THD_MODE_NONE) @@ -1080,16 +1101,12 @@ int thd_init(void) { /* Setup an idle task that is always ready to run, in case everyone else is blocked on something. */ - thd_idle_thd = thd_create(0, thd_idle_task, NULL); - strcpy(thd_idle_thd->label, "[idle]"); - thd_set_prio(thd_idle_thd, PRIO_MAX); + thd_idle_thd = thd_create_ex(&idle_attr, thd_idle_task, NULL); thd_idle_thd->state = STATE_READY; /* Set up a thread to reap old zombies */ sem_init(&thd_reap_sem, 0); - reaper = thd_create(0, thd_reaper, NULL); - strcpy(reaper->label, "[reaper]"); - thd_set_prio(reaper, 1); + thd_create_ex(&reaper_attr, thd_reaper, NULL); /* Main thread -- the kern thread */ thd_current = kern; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-09-24 03:34:16
|
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 0bdb5c9d7c490a7f2d3fb9f8d991e9559bf3e1b3 (commit) from d2d7863864bec6707bd8d440fbdaa2b90014ba8a (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 0bdb5c9d7c490a7f2d3fb9f8d991e9559bf3e1b3 Author: Andy Barajas <and...@gm...> Date: Mon Sep 23 20:19:02 2024 -0700 Fix example/filesystem Makefile to compile all examples inside folder. (#773) ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/filesystem/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/dreamcast/filesystem/Makefile b/examples/dreamcast/filesystem/Makefile index 3233a746..c76766a0 100644 --- a/examples/dreamcast/filesystem/Makefile +++ b/examples/dreamcast/filesystem/Makefile @@ -6,11 +6,17 @@ all: $(KOS_MAKE) -C pty + $(KOS_MAKE) -C browse + $(KOS_MAKE) -C sd clean: $(KOS_MAKE) -C pty clean + $(KOS_MAKE) -C browse clean + $(KOS_MAKE) -C sd clean dist: $(KOS_MAKE) -C pty dist + $(KOS_MAKE) -C browse dist + $(KOS_MAKE) -C sd dist hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-09-23 16:58:04
|
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 d2d7863864bec6707bd8d440fbdaa2b90014ba8a (commit) via 89b29990c8865f09afe9b7724db3a9a91d8666aa (commit) via a58f25d6ade6d4b7567bcadc4c68e05b1dbe5d1b (commit) via 167288f028c5ad7a8bc5fe57472a89eed2f07b21 (commit) via 3a950dcd33ce6bb850bd2ff3378c05db516229a8 (commit) from 63545378b55b22f02d865ba68617095050fe7b5a (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 d2d7863864bec6707bd8d440fbdaa2b90014ba8a Author: Andy Barajas <and...@gm...> Date: Mon Sep 23 09:55:06 2024 -0700 Replace realpath() for a better license. Added fs_normalize_path() (#648) commit 89b29990c8865f09afe9b7724db3a9a91d8666aa Merge: 63545378 a58f25d6 Author: Donald Haase <qu...@ya...> Date: Mon Sep 23 12:53:42 2024 -0400 Merge pull request #725 from pcercuei/pvr-api * pvr: Constify data source pointers Functions that take one data source pointer and one data destination pointer should have their source pointer const, to explicit that the data pointed to is not modified. This in turn allows calling functions to use const pointers. * pvr: Add and use enum pvr_palfmt Instead of using an opaque 'int' type, which gives zero information about the possible values that can be passed, use an enum. This should not break ABI nor API. * pvr: Add and use enum pvr_dma_type Instead of using an opaque 'int' type, which gives zero information about the possible values that can be passed, use an enum. This should not break ABI nor API. --------- Signed-off-by: Paul Cercueil <pa...@cr...> commit a58f25d6ade6d4b7567bcadc4c68e05b1dbe5d1b Author: Paul Cercueil <pa...@cr...> Date: Thu Aug 22 18:21:51 2024 +0200 pvr: Add and use enum pvr_dma_type Instead of using an opaque 'int' type, which gives zero information about the possible values that can be passed, use an enum. This should not break ABI nor API. Signed-off-by: Paul Cercueil <pa...@cr...> commit 167288f028c5ad7a8bc5fe57472a89eed2f07b21 Author: Paul Cercueil <pa...@cr...> Date: Thu Aug 22 18:18:32 2024 +0200 pvr: Add and use enum pvr_palfmt Instead of using an opaque 'int' type, which gives zero information about the possible values that can be passed, use an enum. This should not break ABI nor API. Signed-off-by: Paul Cercueil <pa...@cr...> commit 3a950dcd33ce6bb850bd2ff3378c05db516229a8 Author: Paul Cercueil <pa...@cr...> Date: Thu Aug 22 18:14:39 2024 +0200 pvr: Constify data source pointers Functions that take one data source pointer and one data destination pointer should have their source pointer const, to explicit that the data pointed to is not modified. This in turn allows calling functions to use const pointers. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: AUTHORS | 29 --- doc/CHANGELOG.md | 1 + include/kos/fs.h | 17 ++ kernel/arch/dreamcast/hardware/pvr/pvr_dma.c | 13 +- kernel/arch/dreamcast/hardware/pvr/pvr_palette.c | 2 +- kernel/arch/dreamcast/hardware/pvr/pvr_prim.c | 6 +- kernel/arch/dreamcast/hardware/pvr/pvr_texture.c | 8 +- kernel/arch/dreamcast/include/dc/pvr.h | 73 ++++--- kernel/fs/fs.c | 16 +- kernel/fs/fs_utils.c | 78 +++++++ kernel/libc/koslib/realpath.c | 258 +++++++++++------------ 11 files changed, 277 insertions(+), 224 deletions(-) diff --git a/AUTHORS b/AUTHORS index 1fcace82..5f886980 100644 --- a/AUTHORS +++ b/AUTHORS @@ -71,35 +71,6 @@ include/pthread.h: * */ -kernel/libc/koslib/realpath.c: -/* - * Copyright (c) 2003 Constantin S. Svintsoff <ko...@ic...> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The names of the authors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - kernel/arch/dreamcast/kernel/gdb_stub.c: /* This is originally based on an m68k software stub written by Glenn Engel at HP, but has changed quite a bit. diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index dd111ecd..107191f2 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -5,6 +5,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha ## KallistiOS version 2.2.0 - Added pvrtex utility by TapamN to utils [DF == Daniel Fairchild] - Added . & .. directories to filesystems that lack it [AB] +- Replaced previous implementation of realpath() to remove license from AUTHORS [AB] ## KallistiOS version 2.1.0 - Cleaned up generated stubs files on a make clean [Lawrence Sebald == LS] diff --git a/include/kos/fs.h b/include/kos/fs.h index 2cc3924d..a892eac7 100644 --- a/include/kos/fs.h +++ b/include/kos/fs.h @@ -735,6 +735,23 @@ ssize_t fs_load(const char *src, void **out_ptr); */ ssize_t fs_path_append(char *dst, const char *src, size_t len); +/** \brief Normalize the specified path. + This function acts mostly like the function realpath() but it only simplifies + a path by resolving . and .. components and removing redundant slashes. It + doesn't check if the path exists or resolve symbolic links. + \param path The path to normalize. + \param resolved The buffer to store resolved normalized path. It has + to be PATH_MAX bytes in size. + + \return A pointer to the normalized path on success, + or NULL on failure, in which case the path which + caused trouble is left in resolved. + \par Error Conditions: + \em EINVAL - path or resolved is a NULL pointer \n + \em ENAMETOOLONG - the resulting path would be longer than PATH_MAX bytes \n +*/ +char *fs_normalize_path(const char *__RESTRICT path, char *__RESTRICT resolved); + /** \brief Initialize the virtual filesystem. This is normally done for you by default when KOS starts. In general, there diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c b/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c index c841ae7a..521a5215 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_dma.c @@ -66,7 +66,7 @@ static void pvr_dma_irq_hnd(uint32_t code, void *data) { } } -static uintptr_t pvr_dest_addr(uintptr_t dest, int type) { +static uintptr_t pvr_dest_addr(uintptr_t dest, pvr_dma_type_t type) { uintptr_t dest_addr; /* Send the data to the right place */ @@ -95,8 +95,9 @@ static uintptr_t pvr_dest_addr(uintptr_t dest, int type) { return dest_addr; } -int pvr_dma_transfer(void *src, uintptr_t dest, size_t count, int type, - int block, pvr_dma_callback_t callback, void *cbdata) { +int pvr_dma_transfer(const void *src, uintptr_t dest, size_t count, + pvr_dma_type_t type, int block, + pvr_dma_callback_t callback, void *cbdata) { uintptr_t src_addr = ((uintptr_t)src); /* Check for 32-byte alignment */ @@ -196,7 +197,7 @@ void pvr_dma_shutdown(void) { } /* Copies n bytes from src to PVR dest, dest must be 32-byte aligned */ -void *pvr_sq_load(void *dest, const void *src, size_t n, int type) { +void *pvr_sq_load(void *dest, const void *src, size_t n, pvr_dma_type_t type) { void *dma_area_ptr; if(pvr_dma[PVR_DST] != 0) { @@ -212,7 +213,7 @@ void *pvr_sq_load(void *dest, const void *src, size_t n, int type) { } /* Fills n bytes at PVR dest with 16-bit c, dest must be 32-byte aligned */ -void *pvr_sq_set16(void *dest, uint32_t c, size_t n, int type) { +void *pvr_sq_set16(void *dest, uint32_t c, size_t n, pvr_dma_type_t type) { void *dma_area_ptr; if(pvr_dma[PVR_DST] != 0) { @@ -228,7 +229,7 @@ void *pvr_sq_set16(void *dest, uint32_t c, size_t n, int type) { } /* Fills n bytes at PVR dest with 32-bit c, dest must be 32-byte aligned */ -void *pvr_sq_set32(void *dest, uint32_t c, size_t n, int type) { +void *pvr_sq_set32(void *dest, uint32_t c, size_t n, pvr_dma_type_t type) { void *dma_area_ptr; if(pvr_dma[PVR_DST] != 0) { diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_palette.c b/kernel/arch/dreamcast/hardware/pvr/pvr_palette.c index 6d2bce10..15b77e31 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_palette.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_palette.c @@ -17,7 +17,7 @@ */ /* Set the palette format */ -void pvr_set_pal_format(int fmt) { +void pvr_set_pal_format(pvr_palfmt_t fmt) { PVR_SET(PVR_PALETTE_CFG, fmt); } diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c index 7f9385e7..55952e5e 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c @@ -20,7 +20,7 @@ */ /* Compile a polygon context into a polygon header */ -void pvr_poly_compile(pvr_poly_hdr_t *dst, pvr_poly_cxt_t *src) { +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 @@ -337,7 +337,7 @@ void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, dst->txr.format = textureformat; } -void pvr_sprite_compile(pvr_sprite_hdr_t *dst, pvr_sprite_cxt_t *src) { +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]; @@ -483,7 +483,7 @@ void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode, /* Compile a polygon context into a polygon header that is affected by modifier volumes */ -void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, pvr_poly_cxt_t *src) { +void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src) { int u, v; uint32_t txr_base; uint32_t cmd, mode1, mode2[2], mode3[2]; diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c b/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c index 0b5506dc..49ea049e 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c @@ -20,12 +20,12 @@ */ /* Load raw texture data from an SH-4 buffer into PVR RAM */ -void pvr_txr_load(void * src, pvr_ptr_t dst, uint32 count) { +void pvr_txr_load(const void *src, pvr_ptr_t dst, uint32 count) { if(count & 3) { count = (count + 4) & ~3; } - pvr_sq_load((uint32 *)dst, (uint32 *)src, count, PVR_DMA_VRAM64); + pvr_sq_load((uint32 *)dst, (const uint32 *)src, count, PVR_DMA_VRAM64); } /* Linear/iterative twiddling algorithm from Marcus' tatest */ @@ -52,7 +52,7 @@ void pvr_txr_load(void * src, pvr_ptr_t dst, uint32 count) { PVR_TXRLOAD_INVERT */ -void pvr_txr_load_ex(void * src, pvr_ptr_t dst, uint32 w, uint32 h, +void pvr_txr_load_ex(const void *src, pvr_ptr_t dst, uint32 w, uint32 h, uint32 flags) { uint32 x, y, yout, min, mask, bpp, invert; @@ -143,7 +143,7 @@ void pvr_txr_load_ex(void * src, pvr_ptr_t dst, uint32 w, uint32 h, } /* Load a KOS Platform Independent Image (subject to restraint checking) */ -void pvr_txr_load_kimg(kos_img_t *img, pvr_ptr_t dst, uint32 flags) { +void pvr_txr_load_kimg(const kos_img_t *img, pvr_ptr_t dst, uint32 flags) { uint32 fmt, w, h; /* First check and make sure it's a format we can use */ diff --git a/kernel/arch/dreamcast/include/dc/pvr.h b/kernel/arch/dreamcast/include/dc/pvr.h index ecc37286..d925b8e6 100644 --- a/kernel/arch/dreamcast/include/dc/pvr.h +++ b/kernel/arch/dreamcast/include/dc/pvr.h @@ -1537,7 +1537,7 @@ int pvr_get_stats(pvr_stats_t *stat); like the old cheap "worm hole". */ -/** \defgroup pvr_palfmts Formats +/** \defgroup pvr_palfmt Formats \brief Color palette formats of the PowerVR \ingroup pvr_pal_mgmt @@ -1546,10 +1546,12 @@ int pvr_get_stats(pvr_stats_t *stat); @{ */ -#define PVR_PAL_ARGB1555 0 /**< \brief 16-bit ARGB1555 palette format */ -#define PVR_PAL_RGB565 1 /**< \brief 16-bit RGB565 palette format */ -#define PVR_PAL_ARGB4444 2 /**< \brief 16-bit ARGB4444 palette format */ -#define PVR_PAL_ARGB8888 3 /**< \brief 32-bit ARGB8888 palette format */ +typedef enum pvr_palfmt { + PVR_PAL_ARGB1555, /**< \brief 16-bit ARGB1555 palette format */ + PVR_PAL_RGB565, /**< \brief 16-bit RGB565 palette format */ + PVR_PAL_ARGB4444, /**< \brief 16-bit ARGB4444 palette format */ + PVR_PAL_ARGB8888, /**< \brief 32-bit ARGB8888 palette format */ +} pvr_palfmt_t; /** @} */ /** \brief Set the palette format. @@ -1564,9 +1566,9 @@ int pvr_get_stats(pvr_stats_t *stat); paletted textures with ARGB8888 entries in the palette. \param fmt The format to use - \see pvr_palfmts + \see pvr_palfmt_t */ -void pvr_set_pal_format(int fmt); +void pvr_set_pal_format(pvr_palfmt_t fmt); /** \brief Set a palette value. \ingroup pvr_pal_mgmt @@ -2088,7 +2090,7 @@ int pvr_check_ready(void); \param dst Where to store the compiled header. \param src The context to compile. */ -void pvr_poly_compile(pvr_poly_hdr_t *dst, pvr_poly_cxt_t *src); +void pvr_poly_compile(pvr_poly_hdr_t *dst, const pvr_poly_cxt_t *src); /** \defgroup pvr_ctx_init Initialization \brief Functions for initializing PVR polygon contexts @@ -2137,7 +2139,7 @@ void pvr_poly_cxt_txr(pvr_poly_cxt_t *dst, pvr_list_t list, \param src The context to compile. */ void pvr_sprite_compile(pvr_sprite_hdr_t *dst, - pvr_sprite_cxt_t *src); + const pvr_sprite_cxt_t *src); /** \brief Fill in a sprite context for non-textured sprites. \ingroup pvr_ctx_init @@ -2201,7 +2203,7 @@ void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32_t mode, \param dst Where to store the compiled header. \param src The context to compile. */ -void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, pvr_poly_cxt_t *src); +void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src); /** \brief Fill in a polygon context for non-textured polygons affected by a modifier volume. @@ -2265,7 +2267,7 @@ void pvr_poly_cxt_txr_mod(pvr_poly_cxt_t *dst, pvr_list_t list, \param count The size of the texture in bytes (must be a multiple of 32). */ -void pvr_txr_load(void *src, pvr_ptr_t dst, uint32_t count); +void pvr_txr_load(const void *src, pvr_ptr_t dst, uint32_t count); /** \defgroup pvr_txrload_constants Flags \brief Texture loading constants @@ -2313,7 +2315,8 @@ void pvr_txr_load(void *src, pvr_ptr_t dst, uint32_t count); \see pvr_txrload_constants */ -void pvr_txr_load_ex(void *src, pvr_ptr_t dst, uint32_t w, uint32_t h, uint32_t flags); +void pvr_txr_load_ex(const void *src, pvr_ptr_t dst, + uint32_t w, uint32_t h, uint32_t flags); /** \brief Load a KOS Platform Independent Image (subject to constraint checking). @@ -2344,7 +2347,7 @@ void pvr_txr_load_ex(void *src, pvr_ptr_t dst, uint32_t w, uint32_t h, uint32_t from this function if it twiddles the texture while loading. */ -void pvr_txr_load_kimg(kos_img_t *img, pvr_ptr_t dst, uint32_t flags); +void pvr_txr_load_kimg(const kos_img_t *img, pvr_ptr_t dst, uint32_t flags); /* PVR DMA ***********************************************************/ @@ -2365,6 +2368,22 @@ void pvr_txr_load_kimg(kos_img_t *img, pvr_ptr_t dst, uint32_t flags); */ typedef void (*pvr_dma_callback_t)(void *data); +/** \defgroup pvr_dma_type Transfer Modes + \brief Transfer modes with TA/PVR DMA and Store Queues + \ingroup pvr_dma + + @{ +*/ +typedef enum pvr_dma_type { + PVR_DMA_VRAM64, /**< \brief Transfer to VRAM using TA bus */ + PVR_DMA_VRAM32, /**< \brief Transfer to VRAM using TA bus */ + PVR_DMA_TA, /**< \brief Transfer to the tile accelerator */ + PVR_DMA_YUV, /**< \brief Transfer to the YUV converter (TA) */ + PVR_DMA_VRAM32_SB, /**< \brief Transfer to/from VRAM using PVR i/f */ + PVR_DMA_VRAM64_SB, /**< \brief Transfer to/from VRAM using PVR i/f */ +} pvr_dma_type_t; +/** @} */ + /** \brief Perform a DMA transfer to the PVR RAM over 64-bit TA bus. \ingroup pvr_dma @@ -2392,24 +2411,11 @@ typedef void (*pvr_dma_callback_t)(void *data); \em EFAULT - dest is not 32-byte aligned \n \em EIO - I/O error - \see pvr_dma_modes + \see pvr_dma_type_t */ -int pvr_dma_transfer(void *src, uintptr_t dest, size_t count, int type, - int block, pvr_dma_callback_t callback, void *cbdata); - -/** \defgroup pvr_dma_modes Transfer Modes - \brief Transfer modes with TA/PVR DMA and Store Queues - \ingroup pvr_dma - - @{ -*/ -#define PVR_DMA_VRAM64 0 /**< \brief Transfer to VRAM using TA bus */ -#define PVR_DMA_VRAM32 1 /**< \brief Transfer to VRAM using TA bus */ -#define PVR_DMA_TA 2 /**< \brief Transfer to the tile accelerator */ -#define PVR_DMA_YUV 3 /**< \brief Transfer to the YUV converter (TA) */ -#define PVR_DMA_VRAM32_SB 4 /**< \brief Transfer to/from VRAM using PVR i/f */ -#define PVR_DMA_VRAM64_SB 5 /**< \brief Transfer to/from VRAM using PVR i/f */ -/** @} */ +int pvr_dma_transfer(const void *src, uintptr_t dest, size_t count, + pvr_dma_type_t type, int block, + pvr_dma_callback_t callback, void *cbdata); /** \brief Load a texture using TA DMA. \ingroup pvr_dma @@ -2522,7 +2528,8 @@ void pvr_dma_shutdown(void); \sa pvr_sq_set32() */ -void *pvr_sq_load(void *dest, const void *src, size_t n, int type); +void *pvr_sq_load(void *dest, const void *src, + size_t n, pvr_dma_type_t type); /** \brief Set a block of PVR memory to a 16-bit value. \ingroup store_queues @@ -2545,7 +2552,7 @@ void *pvr_sq_load(void *dest, const void *src, size_t n, int type); \sa pvr_sq_set32() */ -void *pvr_sq_set16(void *dest, uint32_t c, size_t n, int type); +void *pvr_sq_set16(void *dest, uint32_t c, size_t n, pvr_dma_type_t type); /** \brief Set a block of PVR memory to a 32-bit value. \ingroup store_queues @@ -2567,7 +2574,7 @@ void *pvr_sq_set16(void *dest, uint32_t c, size_t n, int type); \sa pvr_sq_set16 */ -void *pvr_sq_set32(void *dest, uint32_t c, size_t n, int type); +void *pvr_sq_set32(void *dest, uint32_t c, size_t n, pvr_dma_type_t type); /*********************************************************************/ diff --git a/kernel/fs/fs.c b/kernel/fs/fs.c index da97e840..5969b251 100644 --- a/kernel/fs/fs.c +++ b/kernel/fs/fs.c @@ -106,7 +106,7 @@ static fs_hnd_t * fs_hnd_open(const char *fn, int mode) { fs_hnd_t *hnd; char rfn[PATH_MAX]; - if(!realpath(fn, rfn)) + if(!fs_normalize_path(fn, rfn)) return NULL; /* Are they trying to open the root? */ @@ -609,7 +609,7 @@ int fs_rename(const char *fn1, const char *fn2) { vfs_handler_t *fh1, *fh2; char rfn1[PATH_MAX], rfn2[PATH_MAX]; - if(!realpath(fn1, rfn1) || !realpath(fn2, rfn2)) + if(!fs_normalize_path(fn1, rfn1) || !fs_normalize_path(fn2, rfn2)) return -1; /* Look for handlers */ @@ -645,7 +645,7 @@ int fs_unlink(const char *fn) { vfs_handler_t *cur; char rfn[PATH_MAX]; - if(!realpath(fn, rfn)) + if(!fs_normalize_path(fn, rfn)) return -1; /* Look for a handler */ @@ -664,7 +664,7 @@ int fs_unlink(const char *fn) { int fs_chdir(const char *fn) { char rfn[PATH_MAX]; - if(!realpath(fn, rfn)) + if(!fs_normalize_path(fn, rfn)) return -1; thd_set_pwd(thd_get_current(), rfn); @@ -705,7 +705,7 @@ int fs_mkdir(const char * fn) { vfs_handler_t *cur; char rfn[PATH_MAX]; - if(!realpath(fn, rfn)) + if(!fs_normalize_path(fn, rfn)) return -1; /* Look for a handler */ @@ -725,7 +725,7 @@ int fs_rmdir(const char * fn) { vfs_handler_t *cur; char rfn[PATH_MAX]; - if(!realpath(fn, rfn)) + if(!fs_normalize_path(fn, rfn)) return -1; /* Look for a handler */ @@ -774,7 +774,7 @@ int fs_link(const char *path1, const char *path2) { vfs_handler_t *fh1, *fh2; char rfn1[PATH_MAX], rfn2[PATH_MAX]; - if(!realpath(path1, rfn1) || !realpath(path2, rfn2)) + if(!fs_normalize_path(path1, rfn1) || !fs_normalize_path(path2, rfn2)) return -1; /* Look for handlers */ @@ -811,7 +811,7 @@ int fs_symlink(const char *path1, const char *path2) { vfs_handler_t *vfs; char rfn[PATH_MAX]; - if(!realpath(path2, rfn)) + if(!fs_normalize_path(path2, rfn)) return -1; /* Look for the handler */ diff --git a/kernel/fs/fs_utils.c b/kernel/fs/fs_utils.c index 9ec83def..12ac71b9 100644 --- a/kernel/fs/fs_utils.c +++ b/kernel/fs/fs_utils.c @@ -180,3 +180,81 @@ ssize_t fs_path_append(char *dst, const char *src, size_t len) { /* Return the current length of the string, including the NUL terminator. */ return (ssize_t)(dlen + slen + 1); } + +char *fs_normalize_path(const char *__restrict path, char *__restrict resolved) { + char temp_path[PATH_MAX]; + char *token; + char *last_slash; + ssize_t len; + + /* Check for invalid params. */ + if(path == NULL || resolved == NULL) { + errno = EINVAL; + return NULL; + } + + /* Too big of a path? */ + len = strlen(path); + if(len >= PATH_MAX) { + errno = ENAMETOOLONG; + return NULL; + } + + /* Handle absolute path. */ + if(path[0] == '/') { + strncpy(temp_path, path, len); + temp_path[len] = '\0'; + } else { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: quzar <qu...@us...> - 2024-09-23 16:46:04
|
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 63545378b55b22f02d865ba68617095050fe7b5a (commit) via 573461f60107d3711c67872c0f13c287f57d644c (commit) via 703643ecfc4c1e16858e402f62fc0161239e849c (commit) from 93519b5546411b0d6a723f74884753056212ff97 (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 63545378b55b22f02d865ba68617095050fe7b5a 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 573461f60107d3711c67872c0f13c287f57d644c Author: Donald Haase <qu...@ya...> Date: Mon Sep 23 12:43:58 2024 -0400 Remove sd from the list of examples folders (#769) commit 703643ecfc4c1e16858e402f62fc0161239e849c 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) ----------------------------------------------------------------------- Summary of changes: Makefile.rules | 20 ++++++++++---------- examples/dreamcast/Makefile | 2 +- include/kos/cdefs.h | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Makefile.rules b/Makefile.rules index a62b1a5a..bcd35e88 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -11,36 +11,36 @@ ifndef KOS_DEPDIR %.o: %.c - kos-cc $(CFLAGS) -c $< -o $@ + kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@ %.o: %.cc - kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ + kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ %.o: %.cpp - kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ + kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ %.o: %.m - kos-cc $(CFLAGS) -c $< -o $@ + kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@ %.o: %.mm - kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ + kos-c++ $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ else %.o: %.c - kos-cc $(CFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) + kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) %.o: %.cc - kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) + kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) %.o: %.cpp - kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) + kos-c++ $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.c,%.md,$(subst /,__,$(subst ..,,$<))) %.o: %.m - kos-cc $(CFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.m,%.md,$(subst /,__,$(subst ..,,$<))) + kos-cc $(CFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.m,%.md,$(subst /,__,$(subst ..,,$<))) %.o: %.mm - kos-c++ $(CFLAGS) $(CXXFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.mm,%.md,$(subst /,__,$(subst ..,,$<))) + kos-c++ $(CFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MD -MF $(KOS_DEPDIR)/$(patsubst %.mm,%.md,$(subst /,__,$(subst ..,,$<))) -include $(wildcard $(KOS_DEPDIR)/*.md) diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile index 221b371c..fb58d7e8 100644 --- a/examples/dreamcast/Makefile +++ b/examples/dreamcast/Makefile @@ -6,7 +6,7 @@ # DIRS = 2ndmix basic libdream kgl hello sound png vmu conio pvr video \ - lua parallax dreameye filesystem sd lightgun keyboard sdl dev rumble \ + lua parallax dreameye filesystem lightgun keyboard sdl dev rumble \ micropython ifneq ($(KOS_SUBARCH), naomi) diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h index 9e34f13a..0aa77349 100644 --- a/include/kos/cdefs.h +++ b/include/kos/cdefs.h @@ -181,6 +181,10 @@ #define __extension__ #endif +#ifndef __GNUC_STDC_INLINE__ +#define inline __inline__ +#endif + /** @} */ #endif /* __KOS_CDEFS_H */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |