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
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: ljsebald <ljs...@us...> - 2023-10-23 02:11:12
|
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 1526b24db29723634ae096a139f70a918eb428fd (commit) via 9a4aa4d69b7af66eb7835fc32cacbc2035b340e9 (commit) from 8bce82fca68ebfcba54214a1122197b7464dd2d3 (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 1526b24db29723634ae096a139f70a918eb428fd Author: Falco Girgis <gyr...@gm...> Date: Sun Oct 22 21:09:35 2023 -0500 Watchdog Timer Driver (#324) * Added Watchdog driver files wdt.h and wdt.c. * Initial attempt at driver API + example 1) Initial API for driver is done 2) Initial implementation is mostly done, partially tested 3) added an example to the "basic" directory for demonstrating its usage 4) Watchdog timer mode seems to work fine 5) Interval timer mode doesn't seem to be firing interrupts as expected, WIP * Interval timer mode and example are working * usec configurable interval timer working - User can now request an arbitrary interval in microseconds for their callback to get invoked after in interval mode (and it'll do the best it can at the given resolution) - Began documenting a bunch of the API - Fixed wdt_disable() which was still leaving the watchdog running when using interval timer mode. * Driver implementation and documentation complete - Finished Doxygen documentation and commenting driver - Added extra parameter to wdt_enable_timer() for specifying interval timer interupt priority - Got rid of all magic numbers/values - Reset initialized flag to 0 in irq_shutdown() - Fixed compilation of watchdog timer example (still need to finish it, though) * Finished example/test scenario - Completed an example demonstrating usage of the WDT in both modes. - Commented the thing thoroughly to explain what's happening. * Typo fixes + comment clarification. * Apply suggestions from code review Co-authored-by: Andress Barajas <and...@gm...> * Updated CHANGELOG --------- Co-authored-by: Andress Barajas <and...@gm...> commit 9a4aa4d69b7af66eb7835fc32cacbc2035b340e9 Author: Andress Barajas <and...@gm...> Date: Sun Oct 22 18:58:20 2023 -0700 Examples refresh (#328) * Added press start to exit to some examples. Removed -n from pvr examples to make it easier to profile ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + examples/dreamcast/basic/Makefile | 3 + .../basic/threading/compiler_tls/Makefile | 25 ++- .../basic/{threading/once => watchdog}/Makefile | 9 +- examples/dreamcast/basic/watchdog/watchdog.c | 161 +++++++++++++++++++ .../dreamcast/kgl/basic/elements/gl-elements.c | 19 +++ .../dreamcast/kgl/basic/zclip_arrays/gl-arrays.c | 19 +++ examples/dreamcast/kgl/demos/blur/radial_blur.c | 20 ++- .../demos/multitexture-arrays/gl-multitex-arrays.c | 19 +++ .../multitexture-elements/gl-multitex-elements.c | 19 +++ examples/dreamcast/libdream/cdfs/cdfs.c | 1 + examples/dreamcast/pvr/bumpmap/Makefile | 2 +- examples/dreamcast/pvr/cheap_shadow/Makefile | 2 +- examples/dreamcast/pvr/modifier_volume/Makefile | 2 +- .../dreamcast/pvr/modifier_volume_tex/Makefile | 2 +- examples/dreamcast/pvr/plasma/Makefile | 2 +- examples/dreamcast/pvr/pvrmark/Makefile | 2 +- examples/dreamcast/pvr/pvrmark_strips/Makefile | 2 +- .../dreamcast/pvr/pvrmark_strips_direct/Makefile | 2 +- .../dreamcast/pvr/yuv_converter/YUV420/Makefile | 2 +- .../dreamcast/pvr/yuv_converter/YUV422/Makefile | 2 +- examples/dreamcast/sound/hello-mp3/Makefile | 1 - include/kos.h | 1 + kernel/arch/dreamcast/include/arch/timer.h | 6 - kernel/arch/dreamcast/include/arch/wdt.h | 172 +++++++++++++++++++++ kernel/arch/dreamcast/kernel/Makefile | 2 +- kernel/arch/dreamcast/kernel/irq.c | 2 + kernel/arch/dreamcast/kernel/wdt.c | 154 ++++++++++++++++++ 28 files changed, 617 insertions(+), 37 deletions(-) copy examples/dreamcast/basic/{threading/once => watchdog}/Makefile (71%) create mode 100644 examples/dreamcast/basic/watchdog/watchdog.c create mode 100644 kernel/arch/dreamcast/include/arch/wdt.h create mode 100644 kernel/arch/dreamcast/kernel/wdt.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index d051ba0..b52310c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -191,6 +191,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Added GCC builtin functions for supporting all of C11 atomics [FG] - *** Added toolchain and KOS support for C/C++ compiler-level TLS [CP && FG] - DC Added vmu functions to check/enable/disable the extra 41 blocks [AB] +- *** Added driver for the SH4's Watchdog Timer peripheral [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/basic/Makefile b/examples/dreamcast/basic/Makefile index 4224e29..45715c8 100644 --- a/examples/dreamcast/basic/Makefile +++ b/examples/dreamcast/basic/Makefile @@ -13,6 +13,7 @@ all: $(KOS_MAKE) -C mmu $(KOS_MAKE) -C stackprotector $(KOS_MAKE) -C memtest32 + $(KOS_MAKE) -C watchdog clean: $(KOS_MAKE) -C exec clean @@ -23,6 +24,7 @@ clean: $(KOS_MAKE) -C mmu clean $(KOS_MAKE) -C stackprotector clean $(KOS_MAKE) -C memtest32 clean + $(KOS_MAKE) -C watchdog clean dist: $(KOS_MAKE) -C exec dist @@ -33,3 +35,4 @@ dist: $(KOS_MAKE) -C mmu dist $(KOS_MAKE) -C stackprotector dist $(KOS_MAKE) -C memtest32 dist + $(KOS_MAKE) -C watchdog dist diff --git a/examples/dreamcast/basic/threading/compiler_tls/Makefile b/examples/dreamcast/basic/threading/compiler_tls/Makefile index 6e3e692..356a853 100644 --- a/examples/dreamcast/basic/threading/compiler_tls/Makefile +++ b/examples/dreamcast/basic/threading/compiler_tls/Makefile @@ -6,26 +6,25 @@ # Copyright (C) 2023 Colton Pawielski # -EXAMPLE_NAME=compiler_tls +TARGET = compiler_tls.elf +OBJS = compiler_tls.o -all: rm-elf $(EXAMPLE_NAME).elf +all: rm-elf $(TARGET) include $(KOS_BASE)/Makefile.rules -OBJS = $(EXAMPLE_NAME).o - -clean: - -rm -f $(EXAMPLE_NAME).elf $(OBJS) +clean: rm-elf + -rm -f $(OBJS) rm-elf: - -rm -f $(EXAMPLE_NAME).elf + -rm -f $(TARGET) -$(EXAMPLE_NAME).elf: $(OBJS) - $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(EXAMPLE_NAME).elf -ftls-model=local-exec $(KOS_START) $(OBJS) $(DATAOBJS) $(OBJEXTRA) $(KOS_LIBS) -Wl,-Map=$(EXAMPLE_NAME).map +$(TARGET): $(OBJS) + kos-cc -o $(TARGET) -ftls-model=local-exec $(OBJS) -Wl,-Map=compiler_tls.map -run: $(EXAMPLE_NAME).elf - $(KOS_LOADER) $(EXAMPLE_NAME).elf +run: $(TARGET) + $(KOS_LOADER) $(TARGET) -dist: +dist: $(TARGET) -rm -f $(OBJS) - $(KOS_STRIP) $(EXAMPLE_NAME).elf + $(KOS_STRIP) $(TARGET) diff --git a/examples/dreamcast/basic/threading/once/Makefile b/examples/dreamcast/basic/watchdog/Makefile similarity index 71% copy from examples/dreamcast/basic/threading/once/Makefile copy to examples/dreamcast/basic/watchdog/Makefile index 52d83b3..54ac0b2 100644 --- a/examples/dreamcast/basic/threading/once/Makefile +++ b/examples/dreamcast/basic/watchdog/Makefile @@ -1,11 +1,11 @@ # KallistiOS ##version## # -# basic/threading/once/Makefile -# Copyright (C) 2009 Lawrence Sebald +# examples/dreamcast/basic/watchdog/Makefile +# Copyright (c) 2023 Falco Girgis # -TARGET = once_test.elf -OBJS = once_test.o +TARGET = watchdog.elf +OBJS = watchdog.o all: rm-elf $(TARGET) @@ -26,4 +26,3 @@ run: $(TARGET) dist: $(TARGET) -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) - diff --git a/examples/dreamcast/basic/watchdog/watchdog.c b/examples/dreamcast/basic/watchdog/watchdog.c new file mode 100644 index 0000000..9a72812 --- /dev/null +++ b/examples/dreamcast/basic/watchdog/watchdog.c @@ -0,0 +1,161 @@ +/* KallistiOS ##version## + + watchdog.c + Copyright (C) 2023 Falco Girgis + +*/ + +/* This program serves as both an example of using the Watchdog Timer + peripheral on the Dreamcast's SH4 CPU as well as a test to validate + the behavior of its driver in KOS. + + NOTE: + At the time this is being written, there are no Dreamcast emulators + out there which are bothering to emulate the SH4 WDT, since apparently + no commercial games actually used it. Special care has been taken to + fail the tests gracefully when there is no functioning WDT. +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> +#include <stdatomic.h> +#include <time.h> + +#include <arch/wdt.h> +#include <dc/maple/controller.h> + +/* Microsecond-based units */ +#define MSEC 1000 +#define SEC (1000 * MSEC) + +/* Test configuration constants */ +#define WDT_PET_COUNT 2000 +#define WDT_INTERVAL (500 * MSEC) +#define WDT_SECONDS 10 +#define WDT_COUNT_MAX ((WDT_SECONDS * SEC) / WDT_INTERVAL) + +/* User callback to be invoked from the WDT's interval timer + interrupt when the requested microsecond period has elapsed. + Our generic userdata pointer is passed back to us as void*. + We use it to store our atomic counter to count the number + of times this callback has been invoked. + + NOTE: Since we're accessing both from within and outside + of the interrupt, we make it atomic to ensure that it + doesn't get updated while it's being read or vice-versa. */ +static void wdt_timeout(void *user_data) { + ++(*(atomic_uint *)user_data); +} + +/* Main entry point */ +int main(int argc, char *argv[]) { + bool success = true; + + /* Press all buttons simultaneously to exit early. */ + cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, + (cont_btn_callback_t)exit); + + /* Note that is EXTREMELY important that the WDT gets disabled + when it is done being used, otherwise it can continue running + after the application exits and can interfere with DC-Load + operation. Since we have multiple exit points (one from returning + from main and one from the button callback), the safest thing to do + is to register wdt_disable() to be called automatically upon exit. */ + atexit(wdt_disable); + + printf("\nEnabling WDT in watchdog mode!\n"); + + /* Enable watchdog mode with a period of 5.25ms, causing a manual + reset interrupt signal to be raised upon timeout. This will + cause your Dreamcast to reboot immediately. */ + wdt_enable_watchdog(0, WDT_CLK_DIV_4096, WDT_RST_MANUAL); + + /* Continually "pet" the watchdog timer in a loop, resetting its + counter value and preventing a timeout (and reboot). We also + store its max value as we're iterating. */ + uint8_t max_count = 0; + for(int p = 0; p < WDT_PET_COUNT; ++p) { + const uint8_t current_count = wdt_get_counter(); + + if(current_count > max_count) + max_count = current_count; + + wdt_pet(); + } + + /* Immediately disable the WDT once we're done with it. */ + wdt_disable(); + + /* Ensure that the WDT's counter wasn't stuck at zero the whole + time and that it was actually updating as expected. */ + if(!max_count) { + fprintf(stderr, "The WDT counter never even incremented!\n\n"); + success = false; + } + else { + printf("Pet it %d times! Maximum counter value was %u.\n\n", + WDT_PET_COUNT, max_count); + } + + printf("Enabling WDT timer with interval: %uus.\n", WDT_INTERVAL); + printf("Expecting %u callbacks over %u seconds.\n", + WDT_COUNT_MAX, WDT_SECONDS); + + /* Enable the WDT in interval counter mode, with a period of 500ms, + an interrupt priority level of 15 (highest), and give it our + timeout callback plus pass it our counter as its userdata pointer. */ + atomic_uint counter = 0; + wdt_enable_timer(0, WDT_INTERVAL, 15, wdt_timeout, &counter); + + /* Begin spinning in a loop until either condition is met: + 1) The counter becomes greater than or equal to the expected value + (meaning our callback has been called the expected number of times + from the Watchdog timer's interval interrupt). + 2) The elapsed time becomes greater than twice the expected number of + seconds, meaning the watchdog interval timer is not behaving as we + expected it to behave (probably running on emulator). + */ + const time_t start_time = time(NULL); + time_t current_time = start_time; + time_t elapsed_time = 0; + while(1) { + /* Measure our current time (using the C standard library, + which internally uses the TMU2 peripheral). */ + current_time = time(NULL); + elapsed_time = current_time - start_time; + + /* Check whether the WDT timer has incremented our counter the + expected number of times and exit if so. */ + if(counter >= WDT_COUNT_MAX) { + break; + } + /* Check whether we should just give up on the WDT. */ + else if(elapsed_time > WDT_SECONDS * 2) { + fprintf(stderr, "Test is taking too long... timing out!\n"); + success = false; + break; + } + } + + printf("%u callbacks in %llu seconds!\n", counter, elapsed_time); + + /* Ensure that the amount of time elapsed based on WDT callbacks agrees + with the amount of time elapsed as reported by TMU2. */ + const unsigned diff_seconds = abs((int)elapsed_time - (int)WDT_SECONDS); + if(diff_seconds > 1) { + printf("Watchdog timing did not match system timing!\n" + "\t[%u sec delta]\n", diff_seconds); + success = false; + } + + /* Report results and return status code. */ + if(success) { + printf("\n\n***** WATCHDOG TIMER TEST SUCCEEDED! *****\n\n"); + return EXIT_SUCCESS; + } + else { + fprintf(stderr, "\n\nXXXXX WATCHDOG TIMER TEST FAILED! XXXXX\n\n"); + return EXIT_FAILURE; + } +} diff --git a/examples/dreamcast/kgl/basic/elements/gl-elements.c b/examples/dreamcast/kgl/basic/elements/gl-elements.c index 9a76148..2a2fd2e 100644 --- a/examples/dreamcast/kgl/basic/elements/gl-elements.c +++ b/examples/dreamcast/kgl/basic/elements/gl-elements.c @@ -78,6 +78,22 @@ void RenderCallback(GLuint texID) { glDisable(GL_KOS_NEARZ_CLIPPING); } +static int check_start(void) { + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state) + return state->buttons & CONT_START; + } + + return 0; +} + extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); @@ -98,6 +114,9 @@ int main(int argc, char **argv) { GLuint texID = glTextureLoadPVR("/rd/wp001vq.pvr", 0, 0); while(1) { + if(check_start()) + break; + /* Draw the "scene" */ RenderCallback(texID); diff --git a/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c b/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c index 5da5f66..a18e829 100644 --- a/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c +++ b/examples/dreamcast/kgl/basic/zclip_arrays/gl-arrays.c @@ -86,6 +86,22 @@ void RenderCallback(GLuint texID) { glDisable(GL_KOS_NEARZ_CLIPPING); } +static int check_start(void) { + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state) + return state->buttons & CONT_START; + } + + return 0; +} + extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); @@ -105,6 +121,9 @@ int main(int argc, char **argv) { buildDemoArray(); while(1) { + if(check_start()) + break; + /* Draw the "scene" */ RenderCallback(texID); diff --git a/examples/dreamcast/kgl/demos/blur/radial_blur.c b/examples/dreamcast/kgl/demos/blur/radial_blur.c index 5479974..5b136c3 100644 --- a/examples/dreamcast/kgl/demos/blur/radial_blur.c +++ b/examples/dreamcast/kgl/demos/blur/radial_blur.c @@ -290,10 +290,25 @@ int InputCallback(void) { return 1; } +static int check_start(void) { + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state) + return state->buttons & CONT_START; + } + + return 0; +} + extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); - int main(int argc, char **argv) { printf("glRadialBlur beginning\n"); @@ -328,6 +343,9 @@ int main(int argc, char **argv) { while(1) { + if(check_start()) + break; + /* Draw the GL "scene" */ if(enable_radial) { /* Bind the Frame Buffer Object to GL, for render-to-texture */ diff --git a/examples/dreamcast/kgl/demos/multitexture-arrays/gl-multitex-arrays.c b/examples/dreamcast/kgl/demos/multitexture-arrays/gl-multitex-arrays.c index ffd18a8..4129812 100644 --- a/examples/dreamcast/kgl/demos/multitexture-arrays/gl-multitex-arrays.c +++ b/examples/dreamcast/kgl/demos/multitexture-arrays/gl-multitex-arrays.c @@ -90,6 +90,22 @@ void RenderCallback(GLuint texID0, GLuint texID1) { glDisableClientState(GL_VERTEX_ARRAY); } +static int check_start(void) { + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state) + return state->buttons & CONT_START; + } + + return 0; +} + extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); @@ -108,6 +124,9 @@ int main(int argc, char **argv) { GLuint texID1 = glTextureLoadPVR("/rd/FlareWS_256.pvr", 0, 0); while(1) { + if(check_start()) + break; + /* Draw the "scene" */ RenderCallback(texID0, texID1); diff --git a/examples/dreamcast/kgl/demos/multitexture-elements/gl-multitex-elements.c b/examples/dreamcast/kgl/demos/multitexture-elements/gl-multitex-elements.c index c64caa0..89dd481 100644 --- a/examples/dreamcast/kgl/demos/multitexture-elements/gl-multitex-elements.c +++ b/examples/dreamcast/kgl/demos/multitexture-elements/gl-multitex-elements.c @@ -93,6 +93,22 @@ void RenderCallback(GLuint texID0, GLuint texID1) { glDisableClientState(GL_VERTEX_ARRAY); } +static int check_start(void) { + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state) + return state->buttons & CONT_START; + } + + return 0; +} + extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); @@ -111,6 +127,9 @@ int main(int argc, char **argv) { GLuint texID1 = glTextureLoadPVR("/rd/FlareWS_256.pvr", 0, 0); while(1) { + if(check_start()) + break; + /* Draw the "scene" */ RenderCallback(texID0, texID1); diff --git a/examples/dreamcast/libdream/cdfs/cdfs.c b/examples/dreamcast/libdream/cdfs/cdfs.c index 2277e3a..a482a28 100644 --- a/examples/dreamcast/libdream/cdfs/cdfs.c +++ b/examples/dreamcast/libdream/cdfs/cdfs.c @@ -3,6 +3,7 @@ #include <kos.h> + char buffer[2048]; void cdfs_test(void) { file_t fd; diff --git a/examples/dreamcast/pvr/bumpmap/Makefile b/examples/dreamcast/pvr/bumpmap/Makefile index 7b91855..442f390 100644 ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-10-16 03:13:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 8bce82fca68ebfcba54214a1122197b7464dd2d3 (commit) via 0fd20ba7903f0c8349135715f456af744bf38ae0 (commit) via 4277fc0ed0e1e2a637a5f717903a8f9dbd234559 (commit) from 3e3b43cf757098c84cf4e67681a02ef3901c6cc8 (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 8bce82fca68ebfcba54214a1122197b7464dd2d3 Author: Falco Girgis <gyr...@gm...> Date: Sun Oct 15 22:12:07 2023 -0500 Doxygen Cleanup/Centralization for Threading APIs (#319) * Doxygen cleanup for threading APIs - Cleaned up Doxygen documentation for a. kthreads b. C11 threads c. pthreads - Put everything relating to concurrency within a top-level "threading" module/group, which is located in doc/pages/threading.dox - Changed groups of related #defines from "modules" to just anonymous groups which keeps them under their respective headers - Marked everything with the _depr() attribute as deprecated within Doxygen * Addressed code review feedback commit 0fd20ba7903f0c8349135715f456af744bf38ae0 Merge: 3e3b43c 4277fc0 Author: Lawrence Sebald <ljs...@us...> Date: Sun Oct 15 23:10:18 2023 -0400 Merge pull request #322 from KallistiOS/matrix_alignment Enforced matrix alignment, matrix ASM cleanup commit 4277fc0ed0e1e2a637a5f717903a8f9dbd234559 Author: Falco Girgis <gyr...@gm...> Date: Wed Oct 11 12:04:18 2023 -0500 Enforced matrix alignment, matrix ASM cleanup 1) Enforcing alignment for matrix_t types, so we stop getting unaligned access crashes (at least for things not on the heap) 2) Minor formatting and stylistic changes to vector and matrix assembly routines - consistent spacing between operands - normalized spaces vs tabs 3) Added doxygen warnings and notes for required and optimal alignments ----------------------------------------------------------------------- Summary of changes: doc/Doxyfile | 5 +- doc/pages/threading.dox | 23 + include/kos/cond.h | 4 +- include/kos/genwait.h | 1 + include/kos/mutex.h | 5 +- include/kos/once.h | 1 + include/kos/recursive_lock.h | 13 +- include/kos/rwsem.h | 2 + include/kos/sem.h | 2 + include/kos/thread.h | 62 +- include/kos/tls.h | 1 + include/pthread.h | 1 + include/threads.h | 9 +- kernel/arch/dreamcast/include/dc/matrix.h | 18 + kernel/arch/dreamcast/include/dc/vec3f.h | 2 +- kernel/arch/dreamcast/include/dc/vector.h | 8 +- kernel/arch/dreamcast/math/matrix.s | 910 +++++++++++++++--------------- kernel/arch/dreamcast/math/matrix3d.c | 2 +- 18 files changed, 555 insertions(+), 514 deletions(-) create mode 100644 doc/pages/threading.dox diff --git a/doc/Doxyfile b/doc/Doxyfile index 35a0a9f..21baf29 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -475,7 +475,7 @@ LOOKUP_CACHE_SIZE = 0 # DOT_NUM_THREADS setting. # Minimum value: 0, maximum value: 32, default value: 1. -NUM_PROC_THREADS = 1 +NUM_PROC_THREADS = 0 #--------------------------------------------------------------------------- # Build related configuration options @@ -910,7 +910,8 @@ WARN_LOGFILE = INPUT = $(KOS_BASE)/include \ $(KOS_BASE)/kernel/arch/$(KOS_ARCH)/include \ $(KOS_BASE)/addons/include \ - $(KOS_BASE)/README.md + $(KOS_BASE)/README.md \ + $(KOS_BASE)/doc/pages # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/doc/pages/threading.dox b/doc/pages/threading.dox new file mode 100644 index 0000000..4fdcbe2 --- /dev/null +++ b/doc/pages/threading.dox @@ -0,0 +1,23 @@ +/** \defgroup threading Threading + \brief Threading and Concurrency + + KOS offers a variety of different threading APIs, ranging from low-level + and platform-specific to high-level and cross-platform. Which you should + choose to interface with depends on the needs of your particular + application. + + API |Description + -------------|----------------------------------------- + kthreads |Dreamcast-specific direct threading API + C11 threads |Cross-platform builtin C threading API + C++11 threads|Cross-platform builtin C++ threading API + pthreads |Cross-platform POSIX threading API + + KOS's kthreads are the lowest-level threading back-end, with C11, C++11, + and POSIX threading APIs being thin layers of abstraction built upon + them. If you're writing a Dreamcast-specific application, kthreads + will give you the least indirection; however, if you're writing a + cross-platform application or simply want to use an API that you're + familiar with, one of the other cross-platform APIs may be preferable. + +*/ diff --git a/include/kos/cond.h b/include/kos/cond.h index 5bccfa5..9a4df11 100644 --- a/include/kos/cond.h +++ b/include/kos/cond.h @@ -1,12 +1,13 @@ /* KallistiOS ##version## include/kos/cond.h - Copyright (C)2001,2003 Megan Potter + Copyright (C) 2001, 2003 Megan Potter */ /** \file kos/cond.h \brief Condition variables. + \ingroup kthreads This file contains the definition of a Condition Variable. Condition Variables (or condvars for short) are used with a mutex to act as a lock and @@ -70,6 +71,7 @@ typedef struct condvar { This function allocates and initializes a new condition variable for use. + \deprecated This function is formally deprecated and should not be used in new code. Instead you should use either the static initializer or the cond_init() function. diff --git a/include/kos/genwait.h b/include/kos/genwait.h index 720f0d7..e7462ad 100644 --- a/include/kos/genwait.h +++ b/include/kos/genwait.h @@ -8,6 +8,7 @@ /** \file kos/genwait.h \brief Generic wait system. + \ingroup kthreads The generic wait system in KOS, like many other portions of KOS, is based on an idea from the BSD kernel. It allows you to sleep on any random object and diff --git a/include/kos/mutex.h b/include/kos/mutex.h index 5a2f936..d0ba5ce 100644 --- a/include/kos/mutex.h +++ b/include/kos/mutex.h @@ -8,6 +8,7 @@ /** \file kos/mutex.h \brief Mutual exclusion locks. + \ingroup kthreads This file defines mutual exclusion locks (or mutexes for short). The concept of a mutex is one of the most common types of locks in a multi-threaded @@ -71,7 +72,8 @@ typedef struct kos_mutex { int count; } mutex_t; -/** \defgroup mutex_types Mutex types +/** \name Mutex types + \brief Types of Mutexes supported by KOS The values defined in here are the various types of mutexes that KallistiOS supports. @@ -98,6 +100,7 @@ typedef struct kos_mutex { /** \brief Allocate a new mutex. + \deprecated This function allocates and initializes a new mutex for use. This function will always create mutexes of the type MUTEX_TYPE_NORMAL. diff --git a/include/kos/once.h b/include/kos/once.h index 5bdcc9f..a0f2585 100644 --- a/include/kos/once.h +++ b/include/kos/once.h @@ -10,6 +10,7 @@ /** \file kos/once.h \brief Dynamic package initialization. + \ingroup kthreads This file provides definitions for an object that functions the same way as the pthread_once_t function does from the POSIX specification. This object diff --git a/include/kos/recursive_lock.h b/include/kos/recursive_lock.h index e22d982..bace334 100644 --- a/include/kos/recursive_lock.h +++ b/include/kos/recursive_lock.h @@ -7,12 +7,14 @@ /** \file kos/recursive_lock.h \brief Definitions for a recursive mutex. + \ingroup kthreads This file defines a recursive lock mechanism, similar to a mutex, but that a single thread can obtain as many times as it wants. A single thread is still limited to holding the lock at a time, but it can hold it an "unlimited" number of times (actually limited to INT_MAX, but who's counting). + \deprecated These are now just wrappers around the MUTEX_TYPE_RECURSIVE that is now provided and will be removed at some point in the future. Please update your code to use that type instead. @@ -40,6 +42,7 @@ typedef mutex_t recursive_lock_t; /** \brief Allocate a new recursive lock. + \deprecated This function allocates a new recurisve lock that is initially not locked. \return The created lock, or NULL on failure (errno will be set to ENOMEM to @@ -49,6 +52,7 @@ recursive_lock_t *rlock_create(void) __depr("Use mutexes instead."); /** \brief Destroy a recursive lock. + \deprecated This function cleans up a recursive lock. It is an error to attempt to destroy a locked recursive lock. @@ -57,7 +61,8 @@ recursive_lock_t *rlock_create(void) __depr("Use mutexes instead."); void rlock_destroy(recursive_lock_t *l) __depr("Use mutexes instead."); /** \brief Lock a recursive lock. - + + \deprecated This function attempts to lock the requested lock, and if it cannot it will block until that is possible. @@ -72,6 +77,7 @@ int rlock_lock(recursive_lock_t *l) __depr("Use mutexes instead."); /** \brief Lock a recursive lock (with a timeout). + \deprecated This function attempts to lock the requested lock, and if it cannot it will block until either it is possible to acquire the lock or timeout milliseconds have elapsed. @@ -91,6 +97,7 @@ int rlock_lock_timed(recursive_lock_t *l, int timeout) /** \brief Unlock a recursive lock. + \deprecated This function releases the lock one time from the current thread. \param l The recursive lock to unlock. @@ -102,6 +109,7 @@ int rlock_unlock(recursive_lock_t *l) __depr("Use mutexes instead."); /** \brief Attempt to lock a recursive lock without blocking. + \deprecated This function attempts to lock a recursive lock without blocking. This function, unlike rlock_lock and rlock_lock_timed is safe to call inside an interrupt. @@ -116,7 +124,8 @@ int rlock_unlock(recursive_lock_t *l) __depr("Use mutexes instead."); int rlock_trylock(recursive_lock_t *l) __depr("Use mutexes instead."); /** \brief Check if a recursive lock is currently held by any thread. - + + \deprecated This function checks whether or not a lock is currently held by any thread, including the calling thread. Note that this is <b>NOT</b> a safe way to check if a lock <em>will</em> be held by the time you get around to locking diff --git a/include/kos/rwsem.h b/include/kos/rwsem.h index 0995375..471a5c4 100644 --- a/include/kos/rwsem.h +++ b/include/kos/rwsem.h @@ -7,6 +7,7 @@ /** \file kos/rwsem.h \brief Definition for a reader/writer semaphore. + \ingroup kthreads This file defines a concept of reader/writer semaphores. Basically, this type of lock allows an unlimited number of "readers" to acquire the lock at @@ -61,6 +62,7 @@ typedef struct rw_semaphore { This function allocates a new reader/writer lock that is initially not locked either for reading or writing. + \deprecated This function is formally deprecated, and should not be used in newly written code. Instead, please use rwsem_init(). diff --git a/include/kos/sem.h b/include/kos/sem.h index 19705a6..f88135b 100644 --- a/include/kos/sem.h +++ b/include/kos/sem.h @@ -8,6 +8,7 @@ /** \file kos/sem.h \brief Semaphores. + \ingroup kthreads This file defines semaphores. A semaphore is a synchronization primitive that allows a spcified number of threads to be in its critical section at a @@ -46,6 +47,7 @@ typedef struct semaphore { This function allocates and initializes a new semaphore for use. + \deprecated This function is formally deprecated. Please update your code to use sem_init() or static initialization with SEM_INITIALIZER instead. diff --git a/include/kos/thread.h b/include/kos/thread.h index 6a74ecb..c57004f 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -23,7 +23,7 @@ __BEGIN_DECLS /** \file kos/thread.h \brief Threading support. - \ingroup threads + \ingroup kthreads This file contains the interface to the threading system of KOS. Timer interrupts are used to reschedule threads within the system. @@ -41,8 +41,9 @@ __BEGIN_DECLS \see kos/tls.h */ -/** \defgroup threads Threads - \brief Threading API +/** \defgroup kthreads KThreads + \brief KOS Native Threading API + \ingroup threading The thread scheduler itself is a relatively simplistic priority scheduler. There is no provision for priorities to erode over time, so keep that in @@ -68,7 +69,6 @@ __BEGIN_DECLS */ /** \brief Maximal thread priority. - \ingroup threads This macro defines the maximum value for a thread's priority. Note that the larger this number, the lower the priority of the thread. @@ -76,14 +76,12 @@ __BEGIN_DECLS #define PRIO_MAX 4096 /** \brief Default thread priority. - \ingroup threads Threads are created by default with the priority specified. */ #define PRIO_DEFAULT 10 /** \brief Size of a kthread's label - \ingroup threads Maximum number of characters in a thread's label or name (including NULL terminator). @@ -91,7 +89,6 @@ __BEGIN_DECLS #define KTHREAD_LABEL_SIZE 256 /** \brief Size of a kthread's current directory - \ingroup threads Maximum number of characters in a thread's current working directory (including NULL terminator). @@ -107,7 +104,6 @@ LIST_HEAD(ktlist, kthread); /* \endcond */ /** \brief Control Block Header - \ingroup threads Header preceeding the static TLS data segments as defined by the SH-ELF TLS ABI (version 1). This is what the thread pointer @@ -119,7 +115,6 @@ typedef struct tcbhead { } tcbhead_t; /** \brief Structure describing one running thread. - \ingroup threads Each thread has one of these structures assigned to it, which holds all the data associated with the thread. There are various functions to manipulate @@ -209,8 +204,8 @@ typedef struct kthread { void *rv; } kthread_t; -/** \defgroup thd_flags Thread flag values - \ingroup threads +/** \name Thread flag values + \brief kthread_t::flags values These are possible values for the flags field on the kthread_t structure. These can be ORed together. @@ -223,8 +218,8 @@ typedef struct kthread { #define THD_DETACHED 4 /**< \brief Thread is detached */ /** @} */ -/** \defgroup thd_states Thread states - \ingroup threads +/** \name Thread states + \brief kthread_t::state values Each thread in the system is in exactly one of this set of states. @@ -238,7 +233,6 @@ typedef struct kthread { /** @} */ /** \brief Thread creation attributes. - \ingroup threads This structure allows you to specify the various attributes for a thread to have when it is created. These can only be modified (in general) at thread @@ -268,8 +262,8 @@ typedef struct kthread_attr { const char *label; } kthread_attr_t; -/** \defgroup thd_modes Threading system modes - \ingroup threads +/** \name Threading system modes + \brief kthread mode values The threading system will always be in one of the following modes. This represents either pre-emptive scheduling or an un-initialized state. @@ -282,7 +276,6 @@ typedef struct kthread_attr { /** @} */ /** \brief The currently executing thread. - \ingroup threads \warning Do not manipulate this variable directly! @@ -292,7 +285,6 @@ typedef struct kthread_attr { extern kthread_t *thd_current; /** \brief Block the current thread. - \ingroup threads Blocks the calling thread and performs a reschedule as if a context switch timer had been executed. This is useful for, e.g., blocking on sync @@ -309,7 +301,6 @@ extern kthread_t *thd_current; int thd_block_now(irq_context_t *mycxt); /** \brief Find a new thread to swap in. - \ingroup threads This function looks at the state of the system and returns a new thread context to swap in. This is called from thd_block_now() and from the @@ -324,7 +315,6 @@ int thd_block_now(irq_context_t *mycxt); irq_context_t *thd_choose_new(void); /** \brief Given a thread ID, locates the thread structure. - \ingroup threads \relatesalso kthread_t \param tid The thread ID to retrieve. @@ -334,7 +324,6 @@ irq_context_t *thd_choose_new(void); kthread_t *thd_by_tid(tid_t tid); /** \brief Enqueue a process in the runnable queue. - \ingroup threads \relatesalso kthread_t This function adds a thread to the runnable queue after the process group of @@ -351,7 +340,6 @@ kthread_t *thd_by_tid(tid_t tid); void thd_add_to_runnable(kthread_t *t, int front_of_line); /** \brief Removes a thread from the runnable queue, if it's there. - \ingroup threads \relatesalso kthread_t This function removes a thread from the runnable queue, if it is currently @@ -367,7 +355,6 @@ void thd_add_to_runnable(kthread_t *t, int front_of_line); int thd_remove_from_runnable(kthread_t *thd); /** \brief Create a new thread. - \ingroup threads \relatesalso kthread_t This function creates a new kernel thread with default parameters to run the @@ -387,7 +374,7 @@ int thd_remove_from_runnable(kthread_t *thd); kthread_t *thd_create(int detach, void *(*routine)(void *param), void *param); /** \brief Create a new thread with the specified set of attributes. - \ingroup threads + \relatesalso kthread_t This function creates a new kernel thread with the specified set of parameters to run the given routine. @@ -406,7 +393,6 @@ kthread_t *thd_create_ex(const kthread_attr_t *__RESTRICT attr, void *(*routine)(void *param), void *param); /** \brief Brutally kill the given thread. - \ingroup threads \relatesalso kthread_t This function kills the given thread, removing it from the execution chain, @@ -424,7 +410,6 @@ kthread_t *thd_create_ex(const kthread_attr_t *__RESTRICT attr, int thd_destroy(kthread_t *thd); /** \brief Exit the current thread. - \ingroup threads This function ends the execution of the current thread, removing it from all execution queues. This function will never return to the thread. Returning @@ -435,7 +420,6 @@ int thd_destroy(kthread_t *thd); void thd_exit(void *rv) __noreturn; /** \brief Force a thread reschedule. - \ingroup threads This function is the thread scheduler, and is generally called from a timer interrupt. You will most likely never have a reason to call this function @@ -455,7 +439,6 @@ void thd_exit(void *rv) __noreturn; void thd_schedule(int front_of_line, uint64_t now); /** \brief Force a given thread to the front of the queue. - \ingroup threads \relatesalso kthread_t This function promotes the given thread to be the next one that will be @@ -465,7 +448,6 @@ void thd_schedule(int front_of_line, uint64_t now); void thd_schedule_next(kthread_t *thd); /** \brief Throw away the current thread's timeslice. - \ingroup threads This function manually yields the current thread's timeslice to the system, forcing a reschedule to occur. @@ -473,7 +455,6 @@ void thd_schedule_next(kthread_t *thd); void thd_pass(void); /** \brief Sleep for a given number of milliseconds. - \ingroup threads This function puts the current thread to sleep for the specified amount of time. The thread will be removed from the runnable queue until the given @@ -486,7 +467,6 @@ void thd_pass(void); void thd_sleep(int ms); /** \brief Set a thread's priority value. - \ingroup threads \relatesalso kthread_t This function is used to change the priority value of a thread. If the @@ -503,7 +483,6 @@ void thd_sleep(int ms); int thd_set_prio(kthread_t *thd, prio_t prio); /** \brief Retrieve the current thread's kthread struct. - \ingroup threads ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-10-07 00:48:35
|
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 3e3b43cf757098c84cf4e67681a02ef3901c6cc8 (commit) via 36930c633381a6289247c33427ad67eea1ed3ea3 (commit) via 580cc829436cbb9d025dac308add2ffe9c14a80b (commit) from 0b93371d65163e8fb9e5a1902d5ec45be3e0df0f (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 3e3b43cf757098c84cf4e67681a02ef3901c6cc8 Merge: 580cc82 36930c6 Author: Lawrence Sebald <ljs...@us...> Date: Fri Oct 6 18:03:07 2023 -0400 Merge pull request #318 from Tchan0/LAN_adapter_dont_register_if_not_present la_init(): early exit if LAN adapter not detected commit 36930c633381a6289247c33427ad67eea1ed3ea3 Author: Tchan0 <617...@us...> Date: Sun Oct 1 07:51:27 2023 +0200 la_init: early exit if not detected Align LAN's la_init() with the BBA code: if not present, do not register, and do not read flashrom commit 580cc829436cbb9d025dac308add2ffe9c14a80b Author: Tchan0 <617...@us...> Date: Sat Sep 30 18:58:00 2023 +0200 maple_dev_status: check for nullptr input (#317) maple_dev_status() does not check for NULL passed as input parameter, crashing eg nehe06 when no controller was detected ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/maple/maple_enum.c | 2 +- kernel/arch/dreamcast/hardware/network/lan_adapter.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/maple/maple_enum.c b/kernel/arch/dreamcast/hardware/maple/maple_enum.c index 618e08d..a0f9c5b 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_enum.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_enum.c @@ -103,7 +103,7 @@ maple_device_t * maple_enum_type_ex(int n, uint32 func, uint32 cap) { valid before returning. Cast to the appropriate type you're expecting. */ void * maple_dev_status(maple_device_t *dev) { /* Is the device valid? */ - if(!dev->valid) + if(!dev || !dev->valid) return NULL; /* Waits until the first DMA happens: crude but effective (replace me later) */ diff --git a/kernel/arch/dreamcast/hardware/network/lan_adapter.c b/kernel/arch/dreamcast/hardware/network/lan_adapter.c index 53bdca2..fb8703a 100644 --- a/kernel/arch/dreamcast/hardware/network/lan_adapter.c +++ b/kernel/arch/dreamcast/hardware/network/lan_adapter.c @@ -330,7 +330,6 @@ static int la_detect(void) { type = DLCR7_IDENT(la_read(DLCR7)); if(type != DLCR7_ID_MB86967) { - dbglog(DBG_KDEBUG, "lan_adapter: no device detected (wrong type = %d)\n", type); return -1; } @@ -746,6 +745,14 @@ int la_init(void) { la_if.index = 0; la_if.dev_id = 0; la_if.flags = NETIF_NO_FLAGS; + la_if.if_detect = la_if_detect; + + /* Short circuit if no lan is detected */ + if(la_if.if_detect(&la_if) < 0) { + dbglog(DBG_KDEBUG, "lan: no device detected\n"); + return -1; + } + memset(la_if.ip_addr, 0, sizeof(la_if.ip_addr)); memset(la_if.netmask, 0, sizeof(la_if.netmask)); memset(la_if.gateway, 0, sizeof(la_if.gateway)); @@ -758,7 +765,7 @@ int la_init(void) { memset(&la_if.ip6_gateway, 0, sizeof(la_if.ip6_gateway)); la_if.mtu6 = 0; la_if.hop_limit = 0; - la_if.if_detect = la_if_detect; + la_if.if_init = la_if_init; la_if.if_shutdown = la_if_shutdown; la_if.if_start = la_if_start; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-24 04:10: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 0b93371d65163e8fb9e5a1902d5ec45be3e0df0f (commit) from c52cd74ec56837fe9b10119651be3661311458c3 (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 0b93371d65163e8fb9e5a1902d5ec45be3e0df0f Author: Falco Girgis <gyr...@gm...> Date: Sat Sep 23 23:10:02 2023 -0500 Extended once_test to repro/verify deadlock issue (#312) - C++11's "std::async()" exposed an issue with the current implementation of kthread_once: it deadlocks when two separate threads attempt to use kthread_once on separate functions concurrently - I've extended the "once_test" to reproduce the issue with the kernel-level C API - The updated test simply spawns and joins another thread from within a "kthread_once" call, which also makes a "kthread_once" call ----------------------------------------------------------------------- Summary of changes: .../dreamcast/basic/threading/once/once_test.c | 61 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/examples/dreamcast/basic/threading/once/once_test.c b/examples/dreamcast/basic/threading/once/once_test.c index 3029894..451e550 100644 --- a/examples/dreamcast/basic/threading/once/once_test.c +++ b/examples/dreamcast/basic/threading/once/once_test.c @@ -11,6 +11,9 @@ the function. */ #include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> #include <kos/thread.h> #include <kos/once.h> @@ -22,18 +25,38 @@ #define UNUSED __attribute__((unused)) #define THD_COUNT 600 -kthread_once_t once = KTHREAD_ONCE_INIT; -spinlock_t lock = SPINLOCK_INITIALIZER; -int counter = 0; +static kthread_once_t once = KTHREAD_ONCE_INIT; +static spinlock_t lock = SPINLOCK_INITIALIZER; +static int counter = 0; -void once_func(void) { +static void inner_once_func(void) { spinlock_lock(&lock); ++counter; spinlock_unlock(&lock); } -void *thd_func(void *param UNUSED) { - kthread_t *cur = thd_get_current(); +static void *inner_thd_func(void *param UNUSED) { + static kthread_once_t inner_once = KTHREAD_ONCE_INIT; + const kthread_t *cur = thd_get_current(); + + printf("Thd %d: Attempting to call inner kthread_once\n", cur->tid); + kthread_once(&inner_once, &inner_once_func); + printf("Thd %d: inner kthread_once returned\n", cur->tid); + + return NULL; +} + +static void once_func(void) { + const kthread_t *cur = thd_get_current(); + + printf("Thd %d: Spawning subthread\n", cur->tid); + kthread_t *subthd = thd_create(0, &inner_thd_func, NULL); + thd_join(subthd, NULL); + printf("Thd %d: Joined subthread\n", cur->tid); +} + +static void *thd_func(void *param UNUSED) { + const kthread_t *cur = thd_get_current(); printf("Thd %d: Attempting to call kthread_once\n", cur->tid); kthread_once(&once, &once_func); @@ -44,7 +67,7 @@ void *thd_func(void *param UNUSED) { KOS_INIT_FLAGS(INIT_DEFAULT); int main(int argc, char *argv[]) { - int i; + int i, retval, success = 1; kthread_t *thds[THD_COUNT]; cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y, @@ -57,16 +80,32 @@ int main(int argc, char *argv[]) { for(i = 0; i < THD_COUNT; ++i) { thds[i] = thd_create(0, &thd_func, NULL); + + if(!thds[i]) { + fprintf(stderr, "Failed to spawn thread[%d]: %s\n", + i, strerror(errno)); + success = 0; + } } printf("Waiting for the threads to finish\n"); for(i = 0; i < THD_COUNT; ++i) { - thd_join(thds[i], NULL); + if((retval = thd_join(thds[i], NULL) < 0)) { + fprintf(stderr, "Failed to join thread[%d]: %d\n", + i, retval); + success = 0; + } } - printf("Final counter value: %d (expected 1)\n", counter); - printf("Test finished\n"); + printf("Final counter value: %d (expected 1)\n\n", counter); - return 0; + if(success && counter == 1) { + printf("***** ONCE_TEST PASSED *****\n"); + return EXIT_SUCCESS; + } + else { + fprintf(stderr, "***** ONCE_TEST FAILED *****\n"); + return EXIT_FAILURE; + } } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-09-23 18:48:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c52cd74ec56837fe9b10119651be3661311458c3 (commit) via 22597655b336a1570d641f9fa739b56cca00a047 (commit) from a8e11c4bcc9c74b2d2ff6069a221106e2465fbda (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 c52cd74ec56837fe9b10119651be3661311458c3 Merge: a8e11c4 2259765 Author: Falco Girgis <gyr...@gm...> Date: Sat Sep 23 13:47:56 2023 -0500 Merge pull request #313 from KallistiOS/once-again Rework once controls, once again. commit 22597655b336a1570d641f9fa739b56cca00a047 Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 23 09:36:19 2023 -0400 Rework once controls, once again. 1. Make them into a tristate value: not done, in progress, and done. 2. Use a condvar to wake up any threads that try to use the same once control before the first caller's function finishes. 3. Make sure another once control can be used while one's init routine is being run. Even if that is done in another thread that the init routine from the first is waiting on somehow (looking at you libstdc++). ----------------------------------------------------------------------- Summary of changes: kernel/thread/once.c | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/kernel/thread/once.c b/kernel/thread/once.c index 1d3f29c..b244782 100644 --- a/kernel/thread/once.c +++ b/kernel/thread/once.c @@ -4,39 +4,66 @@ Copyright (C) 2009, 2023 Lawrence Sebald */ -#include <malloc.h> -#include <stdio.h> -#include <assert.h> #include <errno.h> #include <kos/once.h> #include <kos/mutex.h> -#include <arch/irq.h> +#include <kos/cond.h> /* The lock used to make sure multiple threads don't try to run the same routine at the same time. */ -static mutex_t lock = RECURSIVE_MUTEX_INITIALIZER; +static mutex_t lock = MUTEX_INITIALIZER; +static condvar_t cond = COND_INITIALIZER; + +#define ONCE_COMPLETE 1 +#define ONCE_INPROGRESS -1 int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)) { - if(!once_control || *once_control < 0 || *once_control > 1) { + if(!once_control) { errno = EINVAL; return -1; } /* Lock the lock. */ - if(mutex_lock(&lock) == -1) { + if(mutex_lock(&lock)) { return -1; } /* If the function has already been run, unlock the lock and return. */ - if(*once_control) { + if(*once_control == ONCE_COMPLETE) { mutex_unlock(&lock); return 0; } - /* Run the function, set the control, and unlock the lock. */ - *once_control = 1; + /* If the function is in progress in another thread, wait for it to finish. + We share one mutex/condvar across all once controls, so we have to do + this in a loop to prevent spurious wakeups. */ + if(*once_control == ONCE_INPROGRESS) { + while(*once_control == ONCE_INPROGRESS) { + if(cond_wait(&cond, &lock)) { + mutex_unlock(&lock); + return -1; + } + } + + /* We'll only get here once the once control has been set to 1, so + return success. */ + mutex_unlock(&lock); + return 0; + } + + /* Set that we're in progress and unlock the lock (so other once controls + can be used). Once that's done, run the function, re-obtain the lock, + set that the function has been run and wake all threads waiting on this + particular once control. */ + *once_control = ONCE_INPROGRESS; + mutex_unlock(&lock); + init_routine(); + + mutex_lock(&lock); + *once_control = ONCE_COMPLETE; + cond_broadcast(&cond); mutex_unlock(&lock); return 0; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-22 21:02:46
|
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 a8e11c4bcc9c74b2d2ff6069a221106e2465fbda (commit) from 75c3000f32ab287f3e1a6442a56968abd4e41fe2 (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 a8e11c4bcc9c74b2d2ff6069a221106e2465fbda Author: Andress Barajas <and...@gm...> Date: Fri Sep 22 14:02:11 2023 -0700 Add functionality to enable/disable extra 41 unused blocks on VMU (#307) * Add ability to enable/disable/check the status of VMUs extra blocks * Updated changelog ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + kernel/arch/dreamcast/hardware/maple/vmu.c | 26 +++++++++++++++++++++ kernel/arch/dreamcast/include/dc/maple/vmu.h | 34 ++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 6ec3a10..d051ba0 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -190,6 +190,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- Added yuv examples [AB] - *** Added GCC builtin functions for supporting all of C11 atomics [FG] - *** Added toolchain and KOS support for C/C++ compiler-level TLS [CP && FG] +- DC Added vmu functions to check/enable/disable the extra 41 blocks [AB] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c index 784d050..0226b0e 100644 --- a/kernel/arch/dreamcast/hardware/maple/vmu.c +++ b/kernel/arch/dreamcast/hardware/maple/vmu.c @@ -170,6 +170,32 @@ int vmu_get_buttons_enabled(void) { return !!vmu_drv.periodic; } +int vmu_has_241_blocks(maple_device_t *dev) { + vmu_root_t root; + + if(vmufs_root_read(dev, &root) < 0) + return -1; + + if(root.blk_cnt == 241) + return 1; + + return 0; +} + +int vmu_toggle_241_blocks(maple_device_t *dev, int enable) { + vmu_root_t root; + + if(vmufs_root_read(dev, &root) < 0) + return -1; + + root.blk_cnt = (enable != 0) ? 241 : 200; + + if(vmufs_root_write(dev, &root) < 0) + return -1; + + return 0; +} + int vmu_use_custom_color(maple_device_t *dev, int enable) { vmu_root_t root; diff --git a/kernel/arch/dreamcast/include/dc/maple/vmu.h b/kernel/arch/dreamcast/include/dc/maple/vmu.h index da333b4..3a6f9f7 100644 --- a/kernel/arch/dreamcast/include/dc/maple/vmu.h +++ b/kernel/arch/dreamcast/include/dc/maple/vmu.h @@ -3,7 +3,7 @@ dc/maple/vmu.h Copyright (C) 2000-2002 Jordan DeLong, Megan Potter Copyright (C) 2008 Donald Haase - Copyright (C) 2023 Falco Girgis + Copyright (C) 2023 Falco Girgis, Andy Barajas */ @@ -87,13 +87,43 @@ __BEGIN_DECLS a VMU has been formatted. */ +/** \brief Get the status of a VMUs extra 41 blocks + \ingroup vmu_settings + + This function checks if the extra 41 blocks of a VMU have been + enabled. + + \param dev The device to check the status of. + + \retval 1 On success: extra blocks are enabled + \retval 0 On success: extra blocks are disabled + \retval -1 On failure +*/ +int vmu_has_241_blocks(maple_device_t *dev); + +/** \brief Enable the extra 41 blocks of a VMU + \ingroup vmu_settings + + This function enables/disables the extra 41 blocks of a specific VMU. + + \warning Enabling the extra blocks of a VMU may render it unusable + for a very few commercial games. + + \param dev The device to enable/disable 41 blocks. + \param enable Values other than 0 enables. Equal to 0 disables. + + \retval 0 On success + \retval -1 On failure +*/ +int vmu_toggle_241_blocks(maple_device_t *dev, int enable); + /** \brief Enable custom color of a VMU \ingroup vmu_settings This function enables/disables the custom color of a specific VMU. This color is only displayed in the Dreamcast's file manager. - \param dev The device to enable custom color. + \param dev The device to enable/disable custom color. \param enable Values other than 0 enables. Equal to 0 disables. \retval 0 On success hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-22 03:26:54
|
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 75c3000f32ab287f3e1a6442a56968abd4e41fe2 (commit) via 11940f2bce73e82efebcd6bb70a77cf40e630de1 (commit) from 087000153fe2186d2cc274a4559c89f6fa849876 (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 75c3000f32ab287f3e1a6442a56968abd4e41fe2 Merge: 0870001 11940f2 Author: Lawrence Sebald <ljs...@us...> Date: Thu Sep 21 23:24:28 2023 -0400 Merge pull request #311 from cepawiel/make_fix Fix Addons Makefile Deps commit 11940f2bce73e82efebcd6bb70a77cf40e630de1 Author: Colton Pawielski <cep...@mt...> Date: Mon Sep 18 21:07:48 2023 -0500 Fix Addons Makefile Deps ----------------------------------------------------------------------- Summary of changes: addons/Makefile.prefab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/Makefile.prefab b/addons/Makefile.prefab index 131d6b4..f313440 100644 --- a/addons/Makefile.prefab +++ b/addons/Makefile.prefab @@ -18,7 +18,7 @@ defaultall: $(OBJS) subdirs linklib -linklib: +linklib: $(OBJS) $(LIB_OBJS) rm -f $(KOS_BASE)/addons/lib/$(KOS_ARCH)/$(TARGET) $(KOS_AR) rcs $(KOS_BASE)/addons/lib/$(KOS_ARCH)/$(TARGET) $(OBJS) $(LIB_OBJS) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-18 02:31: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 087000153fe2186d2cc274a4559c89f6fa849876 (commit) via 11f8d921fe0cf85ad08b2dd9b7574f1e2d1b11d3 (commit) via 039f8cd5727b9158feb74159579af059ee6245d4 (commit) via 25aaa77e5b97bb638d09ccf78e931acda56d4f0b (commit) via 5d25b0b8e3795ab1ba4edabc707f604c7756ad44 (commit) via 57b82b67fe5fdfe9d4e55b647b4918a7c6d54bc6 (commit) from 468b40885ea409f01bc5eab897f55a0f8c11b5c6 (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 087000153fe2186d2cc274a4559c89f6fa849876 Merge: 11f8d92 25aaa77 Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 17 22:28:26 2023 -0400 Merge pull request #309 from KallistiOS/kos-w-9.5.0 Add new "WinXP-Latest" toolchain configuration commit 11f8d921fe0cf85ad08b2dd9b7574f1e2d1b11d3 Merge: 468b408 039f8cd Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 17 22:26:48 2023 -0400 Merge pull request #310 from KallistiOS/cmake_atomics CMake toolchain support for C11/C++11 atomics commit 039f8cd5727b9158feb74159579af059ee6245d4 Author: Falco Girgis <gyr...@gm...> Date: Sun Sep 17 15:47:26 2023 -0500 CMake toolchain support for C11/C++11 atomics - Forgot to add the -matomic-model=soft-imask flag to our CMake toolchain to enable atomics there too. commit 25aaa77e5b97bb638d09ccf78e931acda56d4f0b Author: darc <da...@pr...> Date: Sun Sep 17 15:20:49 2023 -0500 Adjust GCC 9.5.0 support as WinXP-Latest commit 5d25b0b8e3795ab1ba4edabc707f604c7756ad44 Author: darcagn <da...@pr...> Date: Wed Aug 9 13:00:16 2023 -0500 Make GCC custom dependencies for 9.5.0 config match the download_prerequisites versions commit 57b82b67fe5fdfe9d4e55b647b4918a7c6d54bc6 Author: darc <da...@pr...> Date: Wed Aug 9 08:28:50 2023 -0500 Add up-to-date GCC 9.5.0 config/patch for DreamSDK ----------------------------------------------------------------------- Summary of changes: utils/cmake/dreamcast.toolchain.cmake | 2 +- utils/dc-chain/config/README.md | 1 + ....9.3.0.sample => config.mk.winxp-latest.sample} | 8 ++-- .../{gcc-8.4.0-kos.diff => gcc-9.5.0-kos.diff} | 12 +++--- .../{gcc-9.3.0-kos.diff => gcc-9.5.0-kos.diff} | 46 +++++++++++----------- 5 files changed, 35 insertions(+), 34 deletions(-) copy utils/dc-chain/config/{config.mk.9.3.0.sample => config.mk.winxp-latest.sample} (98%) copy utils/dc-chain/patches/arm-Darwin/{gcc-8.4.0-kos.diff => gcc-9.5.0-kos.diff} (65%) copy utils/dc-chain/patches/{gcc-9.3.0-kos.diff => gcc-9.5.0-kos.diff} (72%) diff --git a/utils/cmake/dreamcast.toolchain.cmake b/utils/cmake/dreamcast.toolchain.cmake index 21b4cd1..f0a44f0 100644 --- a/utils/cmake/dreamcast.toolchain.cmake +++ b/utils/cmake/dreamcast.toolchain.cmake @@ -83,7 +83,7 @@ else() endif() ##### Configure Build Flags ##### -add_compile_options(-ml -m4-single-only -ffunction-sections -fdata-sections -ftls-model=local-exec) +add_compile_options(-ml -m4-single-only -ffunction-sections -fdata-sections -matomic-model=soft-imask -ftls-model=local-exec) set(ENABLE_DEBUG_FLAGS $<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>) set(ENABLE_RELEASE_FLAGS $<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>) diff --git a/utils/dc-chain/config/README.md b/utils/dc-chain/config/README.md index f4e6ee1..8674b15 100644 --- a/utils/dc-chain/config/README.md +++ b/utils/dc-chain/config/README.md @@ -4,6 +4,7 @@ The available templates include the following configurations: |---------:|:-------:|:----------:|:------------:|:-------:|:----------------:|:------| | config.mk.legacy.sample | 4.7.4 | 2.0.0 | 2.34 | 4.7.4 | 2.34 | older toolchain based on GCC 4<br />former "stable" / "legacy" configuration<br /> [some issues may happen in C++](https://dcemulation.org/phpBB/viewtopic.php?f=29&t=104724) | | config.mk.9.3.0.sample | 9.3.0 | 3.3.0 | 2.34 | 8.4.0 | 2.34 | older toolchain based on GCC 9<br />former "stable" configuration | +| config.mk.winxp-latest.sample | 9.5.0 | 4.3.0 | 2.34 | 8.5.0 | 2.34 | latest WinXP-compatible toolchain with GCC 9 | | config.mk.10.5.0.sample | 10.5.0 | 4.3.0 | 2.41 | 8.5.0 | 2.41 | modern toolchain with GCC 10 | | config.mk.11.4.0.sample | 11.4.0 | 4.3.0 | 2.41 | 8.5.0 | 2.41 | modern toolchain with GCC 11 | | config.mk.12.3.0.sample | 12.3.0 | 4.3.0 | 2.41 | 8.5.0 | 2.41 | modern toolchain with GCC 12 | diff --git a/utils/dc-chain/config/config.mk.9.3.0.sample b/utils/dc-chain/config/config.mk.winxp-latest.sample similarity index 98% copy from utils/dc-chain/config/config.mk.9.3.0.sample copy to utils/dc-chain/config/config.mk.winxp-latest.sample index 4b2866c..50a638b 100644 --- a/utils/dc-chain/config/config.mk.9.3.0.sample +++ b/utils/dc-chain/config/config.mk.winxp-latest.sample @@ -7,9 +7,9 @@ # Toolchain versions for SH sh_binutils_ver=2.34 -sh_gcc_ver=9.3.0 -newlib_ver=3.3.0 -gdb_ver=9.2 +sh_gcc_ver=9.5.0 +newlib_ver=4.3.0.20230120 +gdb_ver=13.2 # Tarball extensions to download for SH sh_binutils_download_type=xz @@ -21,7 +21,7 @@ gdb_download_type=xz # The ARM version of gcc/binutils is separated as support for the ARM7DI core # used in the Dreamcast's AICA is not available in versions of GCC beyond 8.5.0. arm_binutils_ver=2.34 -arm_gcc_ver=8.4.0 +arm_gcc_ver=8.5.0 # Tarball extensions to download for ARM arm_binutils_download_type=xz diff --git a/utils/dc-chain/patches/arm-Darwin/gcc-8.4.0-kos.diff b/utils/dc-chain/patches/arm-Darwin/gcc-9.5.0-kos.diff similarity index 65% copy from utils/dc-chain/patches/arm-Darwin/gcc-8.4.0-kos.diff copy to utils/dc-chain/patches/arm-Darwin/gcc-9.5.0-kos.diff index 8e48e13..f396b6d 100644 --- a/utils/dc-chain/patches/arm-Darwin/gcc-8.4.0-kos.diff +++ b/utils/dc-chain/patches/arm-Darwin/gcc-9.5.0-kos.diff @@ -1,6 +1,6 @@ -diff --color -ruN gcc-8.4.0/gcc/config/host-darwin.c gcc-8.4.0-kos/gcc/config/host-darwin.c ---- gcc-8.4.0/gcc/config/host-darwin.c 2023-03-11 14:18:43 -+++ gcc-8.4.0-kos/gcc/config/host-darwin.c 2023-03-11 14:20:47 +diff --color -ruN gcc-9.5.0/gcc/config/host-darwin.c gcc-9.5.0-kos/gcc/config/host-darwin.c +--- gcc-9.5.0/gcc/config/host-darwin.c 2023-03-11 14:28:07 ++++ gcc-9.5.0-kos/gcc/config/host-darwin.c 2023-03-11 14:28:57 @@ -22,6 +22,10 @@ #include "coretypes.h" #include "diagnostic-core.h" @@ -12,9 +12,9 @@ diff --color -ruN gcc-8.4.0/gcc/config/host-darwin.c gcc-8.4.0-kos/gcc/config/ho /* Yes, this is really supposed to work. */ static char pch_address_space[1024*1024*1024] __attribute__((aligned (4096))); -diff --color -ruN gcc-8.4.0/gcc/config.host gcc-8.4.0-kos/gcc/config.host ---- gcc-8.4.0/gcc/config.host 2023-03-11 14:18:55 -+++ gcc-8.4.0-kos/gcc/config.host 2023-03-11 14:21:25 +diff --color -ruN gcc-9.5.0/gcc/config.host gcc-9.5.0-kos/gcc/config.host +--- gcc-9.5.0/gcc/config.host 2023-03-11 14:28:19 ++++ gcc-9.5.0-kos/gcc/config.host 2023-03-11 14:29:14 @@ -93,8 +93,8 @@ case ${host} in *-darwin*) diff --git a/utils/dc-chain/patches/gcc-9.3.0-kos.diff b/utils/dc-chain/patches/gcc-9.5.0-kos.diff similarity index 72% copy from utils/dc-chain/patches/gcc-9.3.0-kos.diff copy to utils/dc-chain/patches/gcc-9.5.0-kos.diff index c1e49bd..7f322d9 100644 --- a/utils/dc-chain/patches/gcc-9.3.0-kos.diff +++ b/utils/dc-chain/patches/gcc-9.5.0-kos.diff @@ -1,6 +1,6 @@ -diff --color -ruN gcc-9.3.0/gcc/config/sh/sh-c.c gcc-9.3.0-kos/gcc/config/sh/sh-c.c ---- gcc-9.3.0/gcc/config/sh/sh-c.c 2023-06-04 20:52:27.261256884 -0500 -+++ gcc-9.3.0-kos/gcc/config/sh/sh-c.c 2023-06-04 20:52:36.936287786 -0500 +diff --color -ruN gcc-9.5.0/gcc/config/sh/sh-c.c gcc-9.5.0-kos/gcc/config/sh/sh-c.c +--- gcc-9.5.0/gcc/config/sh/sh-c.c 2023-06-05 16:31:29.396332076 -0500 ++++ gcc-9.5.0-kos/gcc/config/sh/sh-c.c 2023-06-05 16:31:31.707339829 -0500 @@ -141,4 +141,11 @@ cpp_define_formatted (pfile, "__SH_ATOMIC_MODEL_%s__", @@ -13,9 +13,9 @@ diff --color -ruN gcc-9.3.0/gcc/config/sh/sh-c.c gcc-9.3.0-kos/gcc/config/sh/sh- + /* Toolchain supports setting up stack for 32MB */ + builtin_define ("__KOS_GCC_32MB__"); } -diff --color -ruN gcc-9.3.0/gcc/configure gcc-9.3.0-kos/gcc/configure ---- gcc-9.3.0/gcc/configure 2023-06-04 20:52:27.441257459 -0500 -+++ gcc-9.3.0-kos/gcc/configure 2023-06-04 20:52:36.938287792 -0500 +diff --color -ruN gcc-9.5.0/gcc/configure gcc-9.5.0-kos/gcc/configure +--- gcc-9.5.0/gcc/configure 2023-06-05 16:31:31.219338192 -0500 ++++ gcc-9.5.0-kos/gcc/configure 2023-06-05 16:31:31.712339846 -0500 @@ -11862,7 +11862,7 @@ target_thread_file='single' ;; @@ -25,9 +25,9 @@ diff --color -ruN gcc-9.3.0/gcc/configure gcc-9.3.0-kos/gcc/configure target_thread_file=${enable_threads} ;; *) -diff --color -ruN gcc-9.3.0/libgcc/config/sh/t-sh gcc-9.3.0-kos/libgcc/config/sh/t-sh ---- gcc-9.3.0/libgcc/config/sh/t-sh 2023-06-04 20:52:26.518254511 -0500 -+++ gcc-9.3.0-kos/libgcc/config/sh/t-sh 2023-06-04 20:52:36.938287792 -0500 +diff --color -ruN gcc-9.5.0/libgcc/config/sh/t-sh gcc-9.5.0-kos/libgcc/config/sh/t-sh +--- gcc-9.5.0/libgcc/config/sh/t-sh 2023-06-05 16:31:31.318338524 -0500 ++++ gcc-9.5.0-kos/libgcc/config/sh/t-sh 2023-06-05 16:31:31.712339846 -0500 @@ -23,6 +23,8 @@ $(LIB1ASMFUNCS_CACHE) LIB1ASMFUNCS_CACHE = _ic_invalidate _ic_invalidate_array @@ -37,10 +37,10 @@ diff --color -ruN gcc-9.3.0/libgcc/config/sh/t-sh gcc-9.3.0-kos/libgcc/config/sh crt1.o: $(srcdir)/config/sh/crt1.S $(gcc_compile) -c $< -diff --color -ruN gcc-9.3.0/libgcc/configure gcc-9.3.0-kos/libgcc/configure ---- gcc-9.3.0/libgcc/configure 2023-06-04 20:52:26.562254651 -0500 -+++ gcc-9.3.0-kos/libgcc/configure 2023-06-04 20:52:36.939287795 -0500 -@@ -5550,6 +5550,7 @@ +diff --color -ruN gcc-9.5.0/libgcc/configure gcc-9.5.0-kos/libgcc/configure +--- gcc-9.5.0/libgcc/configure 2023-06-05 16:31:31.323338541 -0500 ++++ gcc-9.5.0-kos/libgcc/configure 2023-06-05 16:31:31.713339849 -0500 +@@ -5602,6 +5602,7 @@ tpf) thread_header=config/s390/gthr-tpf.h ;; vxworks) thread_header=config/gthr-vxworks.h ;; win32) thread_header=config/i386/gthr-win32.h ;; @@ -48,9 +48,9 @@ diff --color -ruN gcc-9.3.0/libgcc/configure gcc-9.3.0-kos/libgcc/configure esac -diff --color -ruN gcc-9.3.0/libobjc/Makefile.in gcc-9.3.0-kos/libobjc/Makefile.in ---- gcc-9.3.0/libobjc/Makefile.in 2023-06-04 20:52:26.580254709 -0500 -+++ gcc-9.3.0-kos/libobjc/Makefile.in 2023-06-04 20:52:36.939287795 -0500 +diff --color -ruN gcc-9.5.0/libobjc/Makefile.in gcc-9.5.0-kos/libobjc/Makefile.in +--- gcc-9.5.0/libobjc/Makefile.in 2023-06-05 16:31:29.138331210 -0500 ++++ gcc-9.5.0-kos/libobjc/Makefile.in 2023-06-05 16:31:31.713339849 -0500 @@ -307,14 +307,16 @@ $(srcdir)/aclocal.m4: @MAINT@ $(aclocal_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) @@ -81,9 +81,9 @@ diff --color -ruN gcc-9.3.0/libobjc/Makefile.in gcc-9.3.0-kos/libobjc/Makefile.i mostlyclean: -$(LIBTOOL_CLEAN) rm -f libobjc$(libsuffix).la libobjc_gc$(libsuffix).la *.lo -diff --color -ruN gcc-9.3.0/libstdc++-v3/config/cpu/sh/atomicity.h gcc-9.3.0-kos/libstdc++-v3/config/cpu/sh/atomicity.h ---- gcc-9.3.0/libstdc++-v3/config/cpu/sh/atomicity.h 2023-06-04 20:52:26.780255348 -0500 -+++ gcc-9.3.0-kos/libstdc++-v3/config/cpu/sh/atomicity.h 2023-06-04 20:52:36.939287795 -0500 +diff --color -ruN gcc-9.5.0/libstdc++-v3/config/cpu/sh/atomicity.h gcc-9.5.0-kos/libstdc++-v3/config/cpu/sh/atomicity.h +--- gcc-9.5.0/libstdc++-v3/config/cpu/sh/atomicity.h 2023-06-05 16:31:31.373338708 -0500 ++++ gcc-9.5.0-kos/libstdc++-v3/config/cpu/sh/atomicity.h 2023-06-05 16:31:31.714339853 -0500 @@ -22,14 +22,40 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. @@ -134,10 +134,10 @@ diff --color -ruN gcc-9.3.0/libstdc++-v3/config/cpu/sh/atomicity.h gcc-9.3.0-kos + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace -diff --color -ruN gcc-9.3.0/libstdc++-v3/configure gcc-9.3.0-kos/libstdc++-v3/configure ---- gcc-9.3.0/libstdc++-v3/configure 2023-06-04 20:52:27.100256370 -0500 -+++ gcc-9.3.0-kos/libstdc++-v3/configure 2023-06-04 20:52:36.943287808 -0500 -@@ -15629,6 +15629,7 @@ +diff --color -ruN gcc-9.5.0/libstdc++-v3/configure gcc-9.5.0-kos/libstdc++-v3/configure +--- gcc-9.5.0/libstdc++-v3/configure 2023-06-05 16:31:31.657339661 -0500 ++++ gcc-9.5.0-kos/libstdc++-v3/configure 2023-06-05 16:31:31.720339873 -0500 +@@ -15631,6 +15631,7 @@ tpf) thread_header=config/s390/gthr-tpf.h ;; vxworks) thread_header=config/gthr-vxworks.h ;; win32) thread_header=config/i386/gthr-win32.h ;; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-16 02:24:01
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 468b40885ea409f01bc5eab897f55a0f8c11b5c6 (commit) from f4ccdacf521f130f7daddc488d7e81b1ed1a5a48 (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 468b40885ea409f01bc5eab897f55a0f8c11b5c6 Author: Falco Girgis <gyr...@gm...> Date: Fri Sep 15 21:22:34 2023 -0500 Enable TLS Support for C/C++ (#111) * Enable TLS Support * Minor fixes for TLS Support Added an include causing the toolchain to fail to build Fixed a copy/paste error in the example Makefile Changed example to use printf Added cast to GBR pointer to remove warning * Change printf() to dbglog() in thread.c * Modify compiler_tls.c example to work with GCC4 * Add CFLAG to specify tls-model * Initialize Thread Control Block * Added more test coverage to C/C++ TLS example - Added coverage for main thread's TLS data getting flexed - Added arbitary alignments for flexing tdata and tbss alignment * Enable TLS Support * Minor fixes for TLS Support Added an include causing the toolchain to fail to build Fixed a copy/paste error in the example Makefile Changed example to use printf Added cast to GBR pointer to remove warning * Modify compiler_tls.c example to work with GCC4 * Add CFLAG to specify tls-model * Initialize Thread Control Block * Fix issue with TLS on main thread GBR register needed to be initialized after setting up the thread control block for the main thread. * Added alignment check to compiler_tls example * Made every thread run TLS alignment tests * Got aligned TLS partway working - added TLS exec model (local) to CMake toolchain - added .tdata and .tbss alignment variables to .rodata in DC linker script - made KOS threads *attempt* to create TLS storage with proper alignment (still WIP) - updated compiler_tls example to reproduce issues with aligned TLS that still need to be resolved * C/C++ TLS FINALLY WORKS!!! - Finally figured out how to align the segments properly based on ELF TLS data segment information given through the DC linker script - Finished and fleshed out the compiler_tls test to reproduce all of the issues and serve as a potentially automatable test suite. * Added linker script alignment for NAOMI - Added the same update to the NAOMI linker script that the DC got for .TDATA and .TBSS alignment - Updated CHANGELOG with Colton and my TLS work * EMERGENCY bugfix for when .tdata/.tbss are empty! Holy crap, the optimizer in non-release builds will totally optimize away zero-size checks, because the source of the check is the memory address of a linker-script exported variable... and why would the compiler think an address could be NULL? Had to make sizes volatile to circumvent this in release builds. * Cleaned up example, buffed up threads - Cleaned up some styling issues with example - Noticed I wasn't properly getting return values from thd_join() nor was I checking its return code properly - Noticed BlueCrab was spawning 600(!!!!) threads in his "once_init" threading test, so I figured I should stress this one with 200. * Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> * Fixed formatting for tls segment alloc kernel code * Swapped aligned_alloc() out for memalign() * Removed extra space in assignment --------- Co-authored-by: Colton Pawielski <cep...@mt...> Co-authored-by: Lawrence Sebald <ljs...@us...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + environ_dreamcast.sh | 2 +- examples/dreamcast/basic/threading/Makefile | 3 + .../basic/threading/compiler_tls/Makefile | 31 ++++ .../basic/threading/compiler_tls/compiler_tls.c | 203 +++++++++++++++++++++ include/kos/thread.h | 18 +- kernel/thread/thread.c | 105 +++++++++++ utils/cmake/dreamcast.toolchain.cmake | 2 +- utils/dc-chain/scripts/gcc-pass1.mk | 1 - utils/dc-chain/scripts/gcc-pass2.mk | 1 - utils/ldscripts/shlelf-naomi.xc | 26 ++- utils/ldscripts/shlelf.xc | 26 ++- 12 files changed, 408 insertions(+), 11 deletions(-) create mode 100644 examples/dreamcast/basic/threading/compiler_tls/Makefile create mode 100644 examples/dreamcast/basic/threading/compiler_tls/compiler_tls.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index d00c6d1..6ec3a10 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -189,6 +189,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Added DMA YUV converter path. Adjust some name of related #defines. Added yuv examples [AB] - *** Added GCC builtin functions for supporting all of C11 atomics [FG] +- *** Added toolchain and KOS support for C/C++ compiler-level TLS [CP && FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh index ec68262..cb092da 100644 --- a/environ_dreamcast.sh +++ b/environ_dreamcast.sh @@ -1,7 +1,7 @@ # KallistiOS environment variable settings. These are the shared pieces # for the Dreamcast(tm) platform. -export KOS_CFLAGS="${KOS_CFLAGS} -ml -m4-single-only -ffunction-sections -fdata-sections -matomic-model=soft-imask" +export KOS_CFLAGS="${KOS_CFLAGS} -ml -m4-single-only -ffunction-sections -fdata-sections -matomic-model=soft-imask -ftls-model=local-exec" export KOS_AFLAGS="${KOS_AFLAGS} -little" if [ x${KOS_SUBARCH} = xnaomi ]; then diff --git a/examples/dreamcast/basic/threading/Makefile b/examples/dreamcast/basic/threading/Makefile index 91f63df..e76cb63 100644 --- a/examples/dreamcast/basic/threading/Makefile +++ b/examples/dreamcast/basic/threading/Makefile @@ -5,6 +5,7 @@ # all: + $(KOS_MAKE) -C compiler_tls $(KOS_MAKE) -C general $(KOS_MAKE) -C rwsem $(KOS_MAKE) -C recursive_lock @@ -14,6 +15,7 @@ all: $(KOS_MAKE) -C atomics clean: + $(KOS_MAKE) -C compiler_tls clean $(KOS_MAKE) -C general clean $(KOS_MAKE) -C rwsem clean $(KOS_MAKE) -C recursive_lock clean @@ -23,6 +25,7 @@ clean: $(KOS_MAKE) -C atomics clean dist: + $(KOS_MAKE) -C compiler_tls dist $(KOS_MAKE) -C general dist $(KOS_MAKE) -C rwsem dist $(KOS_MAKE) -C recursive_lock dist diff --git a/examples/dreamcast/basic/threading/compiler_tls/Makefile b/examples/dreamcast/basic/threading/compiler_tls/Makefile new file mode 100644 index 0000000..6e3e692 --- /dev/null +++ b/examples/dreamcast/basic/threading/compiler_tls/Makefile @@ -0,0 +1,31 @@ +# KallistiOS ##version## +# +# basic/threading/compiler_tls/Makefile +# +# Copyright (C) 2001 Megan Potter +# Copyright (C) 2023 Colton Pawielski +# + +EXAMPLE_NAME=compiler_tls + +all: rm-elf $(EXAMPLE_NAME).elf + +include $(KOS_BASE)/Makefile.rules + +OBJS = $(EXAMPLE_NAME).o + +clean: + -rm -f $(EXAMPLE_NAME).elf $(OBJS) + +rm-elf: + -rm -f $(EXAMPLE_NAME).elf + +$(EXAMPLE_NAME).elf: $(OBJS) + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(EXAMPLE_NAME).elf -ftls-model=local-exec $(KOS_START) $(OBJS) $(DATAOBJS) $(OBJEXTRA) $(KOS_LIBS) -Wl,-Map=$(EXAMPLE_NAME).map + +run: $(EXAMPLE_NAME).elf + $(KOS_LOADER) $(EXAMPLE_NAME).elf + +dist: + -rm -f $(OBJS) + $(KOS_STRIP) $(EXAMPLE_NAME).elf diff --git a/examples/dreamcast/basic/threading/compiler_tls/compiler_tls.c b/examples/dreamcast/basic/threading/compiler_tls/compiler_tls.c new file mode 100644 index 0000000..25be21a --- /dev/null +++ b/examples/dreamcast/basic/threading/compiler_tls/compiler_tls.c @@ -0,0 +1,203 @@ +/* KallistiOS ##version## + + compiler_tls.c + + Copyright (C) 2023 Colton Pawielski + Copyright (C) 2023 Falco Girgis + + A simple example showing off thread local variables + + This example launches several threads that access variables + placed in the TLS segment by the compiler. The compiler + is then able to generate trivial lookups based on the GBR + register which holds the address to the current threads's + control block. + + This example also doubles as a validator for KOS and the + toolchain's TLS implementation by verifying proper behavior + of each TLS segment with various different kinds of data + and alignment requirements. + + */ + +#include <kos.h> +#include <stdbool.h> +#include <stdlib.h> + +#if (__GNUC__ <= 4) +/* GCC4 only supports using TLS with the __thread identifier, + even when passed the -std=c99 flag */ +#define thread_local __thread +#else +/* Newer versions of GCC use C11's _Thread_local to specify TLS */ +#define thread_local _Thread_local +#endif + +typedef struct { + uint8_t inner[3]; +} Align4; + +typedef struct { + uint8_t inner[3]; +} Align16; + +/* Various types of thread-local variables, coming from both the .TDATA and .TBSS + segments with both manual over-alignment and default alignment. + + NOTE: For the sake of validation, these must be declared volatile, otherwise the + compiler will optimize away conditionals checking for values that it knows should be + constant! +*/ +static thread_local volatile _Alignas(4) Align4 tls_buff4 = {.inner = {2, 2, 2}}; +static thread_local volatile _Alignas(16) Align16 tls_buff16 = {.inner = {1, 1, 1}}; +static thread_local volatile uint16_t tls_uint16[256] = { 0 }; +static thread_local volatile _Alignas(32) uint32_t tbss_test = 0; +static thread_local volatile _Alignas(32) char tls_string[] = { "abcdefghijklmnopqrstuvwxyz012345" }; +static thread_local volatile uint32_t tdata_test = 0x5A; + +/* + Main thread function. Puts each thread through an array of + tests on its own set of thread-local data to ensure proper + initialization, alignment, and uniqueness. + */ +void *thd(void *v) { + int i; + int id = (int)v; + int ret = 0; + + printf("Started Thread %d\n", id); + + /* Ensure zero-initialized .TBSS data have the correct initial + values and are unique to each thread. */ + for(i = 0; i < 5; i++) { + printf("Thread[%d]\tbss_test = 0x%lX\n", id, tbss_test); + tbss_test++; + thd_sleep(50); + } + + if(tbss_test != 5) { + fprintf(stderr, "TBSS data check failed!\n"); + ret = -1; + } + + /* Ensure value-initialized .TDATA data have the correct initial + values and are unique to each thread. */ + for(i = 0; i < 5; i++) { + printf("Thread[%d]\ttdata_test = 0x%lX\n", id, tdata_test); + tdata_test++; + thd_sleep(50); + } + + if(tdata_test != 0x5F) { + fprintf(stderr, "TDATA data check failed!\n"); + ret = -1; + } + + /* Ensure default-aligned .TBSS data is initialized properly. */ + for(i = 0; i < 256; ++i) { + if(tls_uint16[i] != 0) { + fprintf(stderr, "tls_uint16[%d] failed!\n", i); + ret = -1; + break; + } + } + + /* Ensure manually over-aligned .TDATA data is initialized properly. */ + if(strcmp((const char *)tls_string, "abcdefghijklmnopqrstuvwxyz012345")) { + fprintf(stderr, "tls_string check failed: %s\n", (const char *)tls_string); + ret = -1; + } + + /* Check if at least one byte has been offset improperly + within either of these two oddly-sized structures which could + be potentially misaligned. + + Thanks to the DevkitPro 3DS guys for creating this test case + to flex their own TLS implementation. + */ + + bool reproduced = false; + + printf("["); + for(i = 0; i < 3; i++) { + if(tls_buff4.inner[i] != 2) + reproduced = true; + + printf("%d, ", tls_buff4.inner[i]); + } + + printf("]\n"); + + printf("["); + for(i = 0; i < 3; i++) { + if(tls_buff16.inner[i] != 1) + reproduced = true; + + printf("%d, ", tls_buff16.inner[i]); + } + + printf("]\n"); + + if(reproduced) { + fprintf(stderr, "Bug has been reproduced!\n"); + ret = -1; + } + else { + printf("There has been no issue!\n"); + } + + printf("Finished Thread %d\n", id); + + /* Return the result back to the main function. */ + return (void *)ret; +} + +int main(int argc, char **argv) { + /* This is ridiculous, but lets do it anyway. */ + const int thread_count = 200; + kthread_t *threads[thread_count]; + int i, ret, result = 0; + + printf("Starting Threads\n"); + + /* Create a bunch of threads and put each through + the same series of tests on their own (hopefully) + independent set of thread-local variables. */ + for(i = 0; i < thread_count; i++) { + threads[i] = thd_create(0, thd, (void *)i + 1); + } + + /* Put the main thread through the same tests as thread 0. */ + ret = (int)thd((void *)0); + printf("Thread[0] returned: %d\n", ret); + + if(ret == -1) + result = -1; + + /* Wait for each thread to return with its test result. */ + for(i = 0; i < thread_count; i++) { + int res = thd_join(threads[i], (void**)&ret); + + if(res < 0) { + fprintf(stderr, "Thread[%d] failed to join: %d\n", i + 1, res); + result = -1; + } + else { + printf("Thread[%d] returned: %d\n", i + 1, ret); + + if(ret == -1) + result = -1; + } + } + + printf("Threads Finished!\n"); + + if(result == -1) { + fprintf(stderr, "\n\n***** TLS TEST FAILED! *****\n\n"); + return EXIT_FAILURE; + } + else { + printf("\n\n***** TLS TEST SUCCESS! *****\n\n"); + return EXIT_SUCCESS; + } +} diff --git a/include/kos/thread.h b/include/kos/thread.h index 83dbba0..6a74ecb 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -17,6 +17,7 @@ __BEGIN_DECLS #include <arch/irq.h> #include <sys/queue.h> #include <sys/reent.h> +#include <stdint.h> #include <stdint.h> @@ -105,6 +106,18 @@ TAILQ_HEAD(ktqueue, kthread); LIST_HEAD(ktlist, kthread); /* \endcond */ +/** \brief Control Block Header + \ingroup threads + + Header preceeding the static TLS data segments as defined by + the SH-ELF TLS ABI (version 1). This is what the thread pointer + (GBR) points to for compiler access to thread-local data. +*/ +typedef struct tcbhead { + void *dtv; /**< \brief Dynamic TLS vector (unused) */ + uintptr_t pointer_guard; /**< \brief Pointer guard (unused) */ +} tcbhead_t; + /** \brief Structure describing one running thread. \ingroup threads @@ -184,10 +197,13 @@ typedef struct kthread { /** \brief Our reent struct for newlib. */ struct _reent thd_reent; - /** \brief Thread-local storage. + /** \brief OS-level thread-local storage. \see kos/tls.h */ struct kthread_tls_kv_list tls_list; + /** \brief Compiler-level thread-local storage. */ + tcbhead_t* tcbhead; + /** \brief Return value of the thread function. This is only used in joinable threads. */ void *rv; diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c index 18843ba..d134e04 100644 --- a/kernel/thread/thread.c +++ b/kernel/thread/thread.c @@ -10,6 +10,7 @@ #include <string.h> #include <malloc.h> #include <stdio.h> +#include <stdlib.h> #include <reent.h> #include <errno.h> #include <kos/thread.h> @@ -21,6 +22,7 @@ #include <arch/irq.h> #include <arch/timer.h> #include <arch/arch.h> +#include <assert.h> /* @@ -35,6 +37,16 @@ also using their queue library verbatim (sys/queue.h). */ +/* TLS Section ELF data - exported from linker script. */ +extern int _tdata_start, _tdata_size; +extern int _tbss_size; +extern long _tdata_align, _tbss_align; + +/* Utility function for aligning an address or offset. */ +static inline size_t align_to(size_t address, size_t alignment) { + return (address + (alignment - 1)) & ~(alignment - 1); +} + /*****************************************************************************/ /* Thread scheduler data */ @@ -327,6 +339,88 @@ int thd_remove_from_runnable(kthread_t *thd) { return 0; } +/* Creates and initializes the static TLS segment for a thread, + composed of a Thread Control Block (TCB), followed by .TDATA, + followed by .TBSS, very carefully ensuring alignment of each + subchunk. +*/ +static void *thd_create_tls_data(void) { + size_t align, tdata_offset, tdata_end, tbss_offset, + tbss_end, align_rem, tls_size; + + tcbhead_t *tcbhead; + void *tdata_segment, *tbss_segment; + + /* Cached and typed local copies of TLS segment data for sizes, + alignments, and initial value data pointer, exported by the + linker script. + + SIZES MUST BE VOLATILE or the optimizer on non-debug builds will + optimize zero-check conditionals away, since why would the + address of a variable be NULL? (Linker script magic, it can be.) + */ + const volatile size_t tdata_size = (size_t)(&_tdata_size); + const volatile size_t tbss_size = (size_t)(&_tbss_size); + const size_t tdata_align = tdata_size ? (size_t)_tdata_align : 1; + const size_t tbss_align = tbss_size ? (size_t)_tbss_align : 1; + const uint8_t *tdata_start = (const uint8_t *)(&_tdata_start); + + /* Each subsegment of the requested memory chunk must be aligned + by the largest segment's memory alignment requirements. + */ + align = 8; /* tcbhead_t has to be aligned by 8. */ + if(tdata_align > align) + align = tdata_align; /* .TDATA segment's alignment */ + if(tbss_align > align) + align = tbss_align; /* .TBSS segment's alignment */ + + /* Calculate the sizing and offset location of each subsegment. */ + tdata_offset = align_to(sizeof(tcbhead_t), align); + tdata_end = tdata_offset + tdata_size; + tbss_offset = align_to(tdata_end, tbss_align); + tbss_end = tbss_offset + tbss_size; + + /* Calculate final aligned size requirement. */ + align_rem = tbss_end % align; + tls_size = tbss_end; + + if(align_rem) + tls_size += (align - align_rem); + + /* Allocate combined chunk with calculated size and alignment. */ + tcbhead = memalign(align, tls_size); + assert(tcbhead); + assert(!((uintptr_t)tcbhead % 8)); + + /* Since we aren't using either member within it, zero out tcbhead. */ + memset(tcbhead, 0, sizeof(tcbhead_t)); + + /* Initialize .TDATA */ + if(tdata_size) { + tdata_segment = (uint8_t *)tcbhead + tdata_offset; + + /* Verify proper alignment. */ + assert(!((uintptr_t)tdata_segment % tdata_align)); + + /* Initialize tdata_segment with .tdata bytes from ELF. */ + memcpy(tdata_segment, tdata_start, tdata_size); + } + + /* Initialize .TBSS */ + if(tbss_size) { + tbss_segment = (uint8_t *)tcbhead + tbss_offset; + + /* Verify proper alignment. */ + assert(!((uintptr_t)tbss_segment % tbss_align)); + + /* Zero-initialize tbss_segment. */ + memset(tbss_segment, 0, tbss_size); + } + + /* Return segment head: this is what GBR points to. */ + return tcbhead; +} + /* New thread function; given a routine address, it will create a new kernel thread with the given attributes. When the routine returns, the thread will exit. Returns the new thread struct. */ @@ -383,6 +477,9 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr, nt->stack_size = real_attr.stack_size; + /* Create static TLS data */ + nt->tcbhead = thd_create_tls_data(); + /* Populate the context */ params[0] = (uint32_t)routine; params[1] = (uint32_t)param; @@ -392,6 +489,8 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr, ((uint32_t)nt->stack) + nt->stack_size, (uint32_t)thd_birth, params, 0); + /* Set Thread Pointer */ + nt->context.gbr = (uint32_t)nt->tcbhead; nt->tid = tid; nt->prio = real_attr.prio; nt->flags = THD_DEFAULTS; @@ -475,6 +574,9 @@ int thd_destroy(kthread_t *thd) { /* Free its stack */ free(thd->stack); + /* Free static TLS segment */ + free(thd->tcbhead); ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-15 19:41:15
|
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 f4ccdacf521f130f7daddc488d7e81b1ed1a5a48 (commit) via 949ae95e0ce73195006a220dd9859da485fe8ed3 (commit) from ad6524dbf2e6094933dd8fd81a044dc42dca2efe (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 f4ccdacf521f130f7daddc488d7e81b1ed1a5a48 Author: Falco Girgis <gyr...@gm...> Date: Fri Sep 15 14:40:22 2023 -0500 Initial C11 libatomic GCC builtin implementation (#301) * Initial C99 libatomic GCC builtin implementation - Initial implementation should cover everything C99 atomics entail, located at kernel/libc/c11/atomics.c * Update CHANGELOG Typo. C99 atomics => C11 atomics. * Began work on C11 atomics example/test. - Added /kos/examples/dreamcast/basic/threading/atomic - Currently have compile-time sanity checks, thread spawning, and atomics declaration - Still have to do actual atomic operations * Fleshed out atomics test more, reporting lockless - Exercising every major atomic and operation type in unit tests - Actively yielding and sleeping threads in the middle of messing with atomics, to encourage preemption for testing - Modified __atomic_is_lock_free() to return TRUE, as the builtin atomics from -matomic-model=soft-imask are all reporting at compile-time as lock-free... meaning this implementation of C11 atomics (interrupt toggling) is considered to be lock-free. * Finalized atomics tests. All passing. * Spinlock used for generic atomics, testbed update - Swapped generic atomics to use spinlocks * created a hash table of spinlocks mapping the atomic pointers to specific locks based on their address range - Updated example * doing a lot more operations on the atomic buffer to ensure the scheduler gets a chance to preempt and screw things up if the implmentation is broken * More comments, final code cleanup. - Added more comments around the atomics back-end - Removed a few comments from the example which were no longer relevant * Fixed atomic_is_lock_free() for generic case - Since we're using spinlocks to implement it, the generic atomics case is no longer considered lock-free. Updated the back-end and example to reflect this. - Fixed a warning due to not making the pointer arg to atomic_is_lock_free() volatile. * Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> * Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> * Tiny formatting change missed in review. * Update atomics.c Forgot to make the thread function static. :) --------- Co-authored-by: Lawrence Sebald <ljs...@us...> commit 949ae95e0ce73195006a220dd9859da485fe8ed3 Author: Falco Girgis <gyr...@gm...> Date: Fri Sep 15 14:39:03 2023 -0500 Added posix/sysconf.c to implement sysconf() (#306) * Added posix/sysconf.c to implement sysconf() - Implemented very basic functionality for POSIX function, sysconf(), located within kos/kernel/libc/posix/sysconf.c - Handling the following: 1. host name size 2. clock tick rate 3. maximum open files 4. page size + physical page count 5. available physical pages (approximate) 6. # of processors available/configured * Added newline character * Fixed #define used for maximum file descriptors - Also reversed the sign of the EINVAL value returned for invalid name parameters. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + examples/dreamcast/basic/threading/Makefile | 6 +- .../threading/{spinlock_test => atomics}/Makefile | 11 +- .../dreamcast/basic/threading/atomics/atomics.c | 401 +++++++++++++++++++++ kernel/libc/c11/Makefile | 2 +- kernel/libc/c11/atomics.c | 221 ++++++++++++ kernel/libc/posix/Makefile | 2 +- kernel/libc/posix/sysconf.c | 43 +++ 8 files changed, 678 insertions(+), 9 deletions(-) copy examples/dreamcast/basic/threading/{spinlock_test => atomics}/Makefile (72%) create mode 100644 examples/dreamcast/basic/threading/atomics/atomics.c create mode 100644 kernel/libc/c11/atomics.c create mode 100644 kernel/libc/posix/sysconf.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 9072e76..d00c6d1 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -188,6 +188,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Move definition of __RESTRICT from <sys/_types.h> to <kos/cdefs.h> [LS] - DC Added DMA YUV converter path. Adjust some name of related #defines. Added yuv examples [AB] +- *** Added GCC builtin functions for supporting all of C11 atomics [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/basic/threading/Makefile b/examples/dreamcast/basic/threading/Makefile index fd7482f..91f63df 100644 --- a/examples/dreamcast/basic/threading/Makefile +++ b/examples/dreamcast/basic/threading/Makefile @@ -1,7 +1,7 @@ # KallistiOS ##version## # # examples/dreamcast/basic/threading/Makefile -# (c)2002 Megan Potter +# Copyright (C) 2002 Megan Potter # all: @@ -11,6 +11,7 @@ all: $(KOS_MAKE) -C once $(KOS_MAKE) -C tls $(KOS_MAKE) -C spinlock_test + $(KOS_MAKE) -C atomics clean: $(KOS_MAKE) -C general clean @@ -19,6 +20,7 @@ clean: $(KOS_MAKE) -C once clean $(KOS_MAKE) -C tls clean $(KOS_MAKE) -C spinlock_test clean + $(KOS_MAKE) -C atomics clean dist: $(KOS_MAKE) -C general dist @@ -27,4 +29,4 @@ dist: $(KOS_MAKE) -C once dist $(KOS_MAKE) -C tls dist $(KOS_MAKE) -C spinlock_test dist - + $(KOS_MAKE) -C atomics dist diff --git a/examples/dreamcast/basic/threading/spinlock_test/Makefile b/examples/dreamcast/basic/threading/atomics/Makefile similarity index 72% copy from examples/dreamcast/basic/threading/spinlock_test/Makefile copy to examples/dreamcast/basic/threading/atomics/Makefile index 403f45f..abc5d02 100644 --- a/examples/dreamcast/basic/threading/spinlock_test/Makefile +++ b/examples/dreamcast/basic/threading/atomics/Makefile @@ -1,12 +1,12 @@ # KallistiOS ##version## # -# basic/threading/spinlock_test/Makefile -# +# basic/threading/atomics/Makefile # Copyright (C) 2023 Falco Girgis # -TARGET = spinlock_test.elf -OBJS = spinlock_test.o +TARGET = atomics.elf +OBJS = atomics.o +KOS_CFLAGS += -std=c11 all: rm-elf $(TARGET) @@ -18,7 +18,7 @@ clean: rm-elf rm-elf: -rm -f $(TARGET) -$(TARGET): $(OBJS) +$(TARGET): $(OBJS) kos-cc -o $(TARGET) $(OBJS) run: $(TARGET) @@ -27,3 +27,4 @@ run: $(TARGET) dist: $(TARGET) -rm -f $(OBJS) $(KOS_STRIP) $(TARGET) + diff --git a/examples/dreamcast/basic/threading/atomics/atomics.c b/examples/dreamcast/basic/threading/atomics/atomics.c new file mode 100644 index 0000000..156638e --- /dev/null +++ b/examples/dreamcast/basic/threading/atomics/atomics.c @@ -0,0 +1,401 @@ +/* KallistiOS ##version## + + examples/dreamcast/basic/threading/atomics.c + + Copyright (C) 2023 Falco Girgis + + This file serves as both an example of and a validation test for the + C11 atomics support provided by the SH-GCC toolchain and KOS. It + demonstrates advanced compiler-aware concurrency in pure standard C. + + C11 atomics are an extremely convenient, easy-to-use concurrency + primitive supported at the language-level. They allow for thread-safe + access to and manipulation of variables without requiring an external + mutex or synchronization primitive to prevent multiple threads from + trying to modify the data simultaneously. + + Atomics are also more efficient spatially on Dreamcast, because there is + no extra memory used for such additional mutexes to confer thread-safety + around such variables. In terms of runtime, they are implemented similarly + to mutexes, where interrupts are disabled around load/store/fetch operations. + + Most of the back-end for atomics is provided by the compiler when using the + "-matomic-model=soft-imask" flag; however, KOS has to implement some of the + back-end for primitive types (64-bit types in particular) and generic structs. + +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <stdbool.h> +#include <limits.h> +#include <threads.h> +#include <stdatomic.h> + +/* Test that the standard library advertises that we even have atomics. */ +#ifdef __STDC_NO_ATOMICS__ +# error "The standard lib claims we don't support atomics!" +#endif + +/* Test our compile-time macros for sanity. These can be used to detect + atomic locking characteristics at compile-time for your platform. + 0: The atomic type is never lock-free + 1: the atomic type is sometimes lock-free + 2: The atomic type is always lock-free +*/ +_Static_assert(ATOMIC_BOOL_LOCK_FREE == 2, + "Our booleans are expected to be lock free!"); +_Static_assert(ATOMIC_CHAR_LOCK_FREE == 2, + "Our chars are expected to be lock free!"); +_Static_assert(ATOMIC_SHORT_LOCK_FREE == 2, + "Our shorts are expected to be lock free!"); +_Static_assert(ATOMIC_INT_LOCK_FREE == 2, + "Our ints are expected to be lock free!"); +_Static_assert(ATOMIC_LONG_LOCK_FREE == 2, + "Our longs are expected to be lock free!"); +_Static_assert(ATOMIC_POINTER_LOCK_FREE == 2, + "Our pointers are expected to be lock free!"); +_Static_assert(ATOMIC_LLONG_LOCK_FREE == 1, + "Our long longs are expected to sometimes be lock free!"); + +#define THREAD_COUNT 20 /* # of threads to spawn */ +#define ITERATION_COUNT 5 /* # of times to iterate over each atomic */ +#define BUFFER_SIZE 4096 /* # of bytes in atomic buffer */ +#define BUFFER_UPDATE_COUNT 100 /* # of times to update atomic buffer */ + +_Static_assert(THREAD_COUNT * ITERATION_COUNT <= UINT8_MAX, + "Threads * iterations would overflow uint8_t counters!"); + +/* Generic buffer structure we will use with atomics. */ +typedef struct { + uint8_t values[BUFFER_SIZE]; +} Buffer; + +/* Atomic data our threads will be competing over accessing. */ +static atomic_flag flag_atomic = ATOMIC_FLAG_INIT; +static atomic_bool bool_atomic = false; +static atomic_int int_atomic = INT_MAX; +static _Atomic uint64_t longlong_atomic = 0; +static _Atomic(uint8_t) byte_atomic = 0; +static atomic_short short_atomic = 0; +static atomic_ptrdiff_t ptrdiff_atomic = 0; +static _Atomic(Buffer) buffer_atomic = { {0} }; + +/* Utility function to do an "atomic" fetch + add operation on our + massive buffer. */ +static void atomic_add_buffer(unsigned tid, int delta) { + /* Preload the initial value of the buffer. */ + Buffer desired, expected = atomic_load(&buffer_atomic); + + /* Attempt to update the value of our buffer to the "desired" + value. If another thread has preempted our "atomic" operation + and has modified the value first, atomic_compare_exchange() + will return false, updating the "expected" value. We increment + the new value and try again. */ + do { + printf("Thread[%2u]: Attempting to add to buffer: [%u]\n", + tid, + expected.values[0]); + + for(unsigned v = 0; v < sizeof(desired.values); ++v) + desired.values[v] = expected.values[v] + delta; + + } while(!atomic_compare_exchange_strong(&buffer_atomic, + &expected, + desired)); + + printf("Thread[%2u]: Successfully incremented buffer.\n", tid); +} + +/* Per-thread entry point. */ +static int thread(void *arg) { + unsigned tid = (unsigned)arg; + int retval = 0; + + /* Do several iterations worth of atomic operations for each thread. */ + for(unsigned i = 0; i < ITERATION_COUNT; ++i) { + /* Create a spin-lock out of "flag_atomic" by repeatedly testing + and setting its value, while its previous value was not false + (our initial "unlocked" state). */ + while(atomic_flag_test_and_set(&flag_atomic)) + printf("Thread[%2u]: Waiting to atomic flag lock.\n", tid); + + printf("Thread[%2u]: Acquired atomic flag lock.\n", tid); + + /* Yield thread execution within our "critical section" to see + that other threads aren't able to set "flag_atomic" and enter + it as well. */ + thrd_yield(); + + /* Increment the longlong_atomic as a regular counter. */ + atomic_fetch_add(&longlong_atomic, 1); + + /* Release the ghetto flag_atomic spinlock. */ + atomic_flag_clear(&flag_atomic); + printf("Thread[%2u]: Released atomic flag lock.\n", tid); + + /* Attempt to atomically add a value to our huge buffer structure a + few times, to ensure the scheduler isn't able to preempt and break + its atomicity. */ + for(int i = 0; i < BUFFER_UPDATE_COUNT; ++i) { + atomic_add_buffer(tid, i); + atomic_add_buffer(tid, -i); + } + + /* Create a second type of spinlock out of an atomic + boolean, doing the same thing as before: attempting + to set "bool_atomic" to true if it was previously false + to claim the lock. */ + bool expected = false; + while(!atomic_compare_exchange_weak(&bool_atomic, + &expected, + true)) { + printf("Thread[%2u]: Waiting to acquire atomic bool lock.\n", tid); + /* This time we won't hog all of the CPU time waiting. */ + thrd_yield(); + expected = false; + } + + printf("Thread[%2u]: Acquired atomic bool lock.\n", tid); + + /* This time lets give other threads a chance to mess + with us by sleeping for 1ms rather than yielding. */ + static const struct timespec time = { .tv_nsec = 100000000 }; + thrd_sleep(&time, NULL); + + /* Decrement "short_atomic," treating it as a negative counter. */ + atomic_fetch_sub(&short_atomic, 1); + + printf("Thread[%2u]: Releasing atomic bool lock.\n", tid); + + /* Do the reverse compare + exchange operation to release the lock, this + time expecting it to be previously owned (true) and setting it to + false to release. */ + expected = true; + if(!atomic_compare_exchange_strong(&bool_atomic, + &expected, + false)) { + fprintf(stderr, + "Thread[%2u]: Unexpected value for atomic bool lock!\n", + tid); + retval = -1; + } + + /* Ensure atomic bitwise operations work on various primitive types. */ + printf("Thread[%2u]: Performing bitwise operations.\n", tid); + + atomic_fetch_or(&byte_atomic, tid); + atomic_fetch_xor(&ptrdiff_atomic, tid); + atomic_fetch_and(&int_atomic, tid); + } + + /* Return any errors back to the main thread. */ + return retval; +} + +/* Main thread entry point. */ +int main(int arg, char* argv[]) { + int retval = 0; + /* Array containing our spawned threads. */ + thrd_t threads[THREAD_COUNT - 1]; + + /* First lets ensure that our atomics report the proper + runtime values for being lock-free. */ + printf("Checking locking characteristics.\n"); + + if(!atomic_is_lock_free(&bool_atomic)) { + fprintf(stderr, "Bool atomics are not lock free!\n"); + retval = -1; + } + + if(!atomic_is_lock_free(&byte_atomic)) { + fprintf(stderr, "Byte atomics are not lock free!\n"); + retval = -1; + } + + if(!atomic_is_lock_free(&short_atomic)) { + fprintf(stderr, "Short atomics are not lock free!\n"); + retval = -1; + } + + if(!atomic_is_lock_free(&int_atomic)) { + fprintf(stderr, "Int atomics are not lock free!\n"); + retval = -1; + } + + if(!atomic_is_lock_free(&longlong_atomic)) { + fprintf(stderr, "Long long atomics are not lock free!\n"); + retval = -1; + } + + if(!atomic_is_lock_free(&ptrdiff_atomic)) { + fprintf(stderr, "Ptrdiff atomics are not lock free!\n"); + retval = -1; + } + + if(atomic_is_lock_free(&buffer_atomic)) { + fprintf(stderr, "Struct atomics are lock free!\n"); + retval = -1; + } + + printf("Running threads: [%u]\n", THREAD_COUNT); + + /* Create N-1 threads running the "thread()" function to + manipulate and fight over various atomic data. */ + for(unsigned t = 0; t < THREAD_COUNT - 1; ++t) { + if(thrd_create(&threads[t], thread, + (void *)t + 1) != thrd_success) { + fprintf(stderr, "Failed to create thread: [%u]\n", t + 1); + retval = -1; + } + } + + /* Run the same logic for the main thread as the last one (Thread 0). */ + if(thread((void *)0) == -1) + retval = -1; + + /* Await for each thread to complete its tasks and return its + satus code. */ + printf("Joining threads: [%u]\n", THREAD_COUNT); + + for(unsigned t = 0; t < THREAD_COUNT - 1; ++t) { + int res; + if(thrd_join(threads[t], &res) == thrd_error) { + fprintf(stderr, "Failed to join thread: [%u]\n", t + 1); + retval = -1; + continue; + } + + if(res == -1) + retval = -1; + } + + /* Validate that all of our atomics have their expected final values. */ + printf("\nValidating results:\n"); + + /* Verify atomic_flag state. */ + if(atomic_flag_test_and_set(&flag_atomic)) { + fprintf(stderr, "flag_atomic left in unexpected state: [true]\n"); + retval = -1; + } + else { + printf("\tFlag atomics work.\n"); + } + + /* Verify atomic bool state. */ + bool expected = false; + if(!atomic_compare_exchange_weak(&bool_atomic, + &expected, + true)) { + fprintf(stderr, "bool_atomic left in unexpected state: [true]\n"); + retval = -1; + } + else { + printf("\tBool atomics work.\n"); + } + + /* Verify atomic byte state. */ + uint8_t byte_value, byte_expected_value = 0; + for(unsigned i = 0; i < THREAD_COUNT; ++i) { + byte_expected_value |= i; + } + + if((byte_value = atomic_load(&byte_atomic)) != byte_expected_value) { + fprintf(stderr, + "byte_atomic left in unexpected state: [%u]\n", + byte_value); + retval = -1; + } + else { + printf("\t8-bit atomics work.\n"); + } + + /* Verify atomic short state. */ + short short_value; + /* Note that memory order shouldn't do anything for our platform, just testing. */ + if((short_value = atomic_load(&short_atomic)) != + -(THREAD_COUNT * ITERATION_COUNT)) { + fprintf(stderr, + "short_atomic left in unexpected state: [%i]\n", + short_value); + retval = -1; + } + else { + printf("\t16-bit atomics work.\n"); + } + + /* Verify atomic int state. */ + int int_value, int_expected_value = INT_MAX; + for(int i = 0; i < THREAD_COUNT; ++i) { + int_expected_value &= i; + } + + if((int_value = atomic_load(&int_atomic)) != int_expected_value) { + fprintf(stderr, + "int_atomic left in unexpected state: [%d]\n", + int_value); + retval = -1; + } + else { + printf("\t32-bit atomics work.\n"); + } + + /* Verify atomic long long state. */ + uint64_t longlong_value; + if((longlong_value = atomic_load(&longlong_atomic)) != + THREAD_COUNT * ITERATION_COUNT) { + fprintf(stderr, + "longlong_atomic left in unexpected state: [%llu]\n", + longlong_value); + retval = -1; + } + else { + printf("\t64-bit atomics work.\n"); + } + + /* Verify atomic ptrdiff_t state. */ + ptrdiff_t ptrdiff_value, ptrdiff_expected_value = 0; + for(unsigned i = 0; i < THREAD_COUNT; ++i) + ptrdiff_expected_value ^= i; + + if((ptrdiff_value = atomic_load(&ptrdiff_atomic)) + != ptrdiff_expected_value) + { + fprintf(stderr, + "ptrdiff_atomic left in unexpected state: [%d]\n", + ptrdiff_value); + retval = -1; + } + else { + printf("\tptrdiff_t atomics work.\n"); + } + + /* Verify atomic buffer state. */ + Buffer buff_value = atomic_load(&buffer_atomic); + bool buffer_works = true; + for(unsigned v = 0; v < sizeof(buff_value.values); ++v) { + if(buff_value.values[v]) { + fprintf(stderr, + "buffer_atomic[%u] left in unexpected state: [%d]\n", + v, + buff_value.values[v]); + buffer_works = false; + retval = -1; + } + } + + if(buffer_works) + printf("\tGeneric atomics work.\n"); + + /* Print final test results and return status code. */ + if(retval == -1) { + fprintf(stderr, "\n***** C11 ATOMICS TEST FAILED! *****\n\n"); + return EXIT_FAILURE; + } + else { + printf("\n***** C11 ATOMICS TEST PASSED! *****\n\n"); + return EXIT_SUCCESS; + } +} + diff --git a/kernel/libc/c11/Makefile b/kernel/libc/c11/Makefile index 4328d16..460e5bc 100644 --- a/kernel/libc/c11/Makefile +++ b/kernel/libc/c11/Makefile @@ -11,6 +11,6 @@ OBJS = call_once.o cnd_broadcast.o cnd_destroy.o cnd_init.o cnd_signal.o \ mtx_timedlock.o mtx_trylock.o mtx_unlock.o thrd_create.o thrd_current.o \ ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-09-10 23:55: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 ad6524dbf2e6094933dd8fd81a044dc42dca2efe (commit) via 43369fd37723099ba92065c9d65d55ae4f3782df (commit) from 1b08ce456b0f33324221ff1ea691f7ef2068d357 (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 ad6524dbf2e6094933dd8fd81a044dc42dca2efe Merge: 1b08ce4 43369fd Author: Falco Girgis <gyr...@gm...> Date: Sun Sep 10 18:55:07 2023 -0500 Merge pull request #304 from KallistiOS/doxyupdate Fix all warnings generating documentation with Doxygen 1.9.8 commit 43369fd37723099ba92065c9d65d55ae4f3782df Author: darc <da...@pr...> Date: Sun Sep 10 15:15:15 2023 -0500 Fix all warnings generating documentation with Doxygen 1.9.8 ----------------------------------------------------------------------- Summary of changes: README.md | 10 ++++----- doc/Doxyfile | 17 --------------- kernel/arch/dreamcast/include/arch/memory.h | 34 ++++++++++++++--------------- kernel/arch/dreamcast/include/dc/pvr.h | 2 +- 4 files changed, 23 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index cebaf0c..2a2ac24 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ # KallistiOS -KOS is an unofficial development environment for the SEGA Dreamcast game console with some support for the NAOMI and NAOMI 2 arcade boards. +KOS is an unofficial development environment for the SEGA Dreamcast game console with some support for the NAOMI and NAOMI 2 arcade boards. KOS was developed from scratch over the internet by a group of free software developers and has no relation to the official Sega Katana or Microsoft Windows CE Dreamcast development kits. This has allowed it to fuel a thriving Dreamcast homebrew scene, powering many commercial releases for the platform over the years. It supports a signficiant portion of the Dreamcast's hardware capabilities and a wide variety of peripherals, accessories, and add-ons for the console, including custom hardware modifications that have been created by the scene. Despite the console's age, KOS offers an extremely modern, programmer-friendly development environment, supporting portions of C23 and C++23, with the majority of their standard libraries fully supported and additional support for many POSIX APIs. Additionally, KOS-ports offers a rich set of add-on libraries such as SDL, OpenGL, and Lua for the platform. ## Features -##### Core Functionality +### Core Functionality * Concurrency with Kernel Threads, C11 Threads, C++11 `std::thread`, Pthreads * Virtual filesystem abstraction * IPv4/IPv6 Network stack * Dynamically loading libraries/modules * GDB Debug stubs -##### Dreamcast Hardware Support +### Dreamcast Hardware Support * GD-Rom driver * Low-level 3D PowerVR Graphics * SH4 ASM-Optimized Math Routines @@ -27,7 +27,7 @@ Despite the console's age, KOS offers an extremely modern, programmer-friendly d * MMU Management API * BIOS Font Rendering -##### Peripherals and Accessory Support +### Peripherals and Accessory Support * Visual Memory Unit * Puru Puru Vibration Pack * Seaman Microphone @@ -41,7 +41,7 @@ Despite the console's age, KOS offers an extremely modern, programmer-friendly d * VGA Adapter * SD Card Reader -##### Hardware Modification Support +### Hardware Modification Support * IDE Hard Drive * 32MB RAM Upgrade * Custom BIOS Flashroms diff --git a/doc/Doxyfile b/doc/Doxyfile index fcff64c..35a0a9f 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1333,15 +1333,6 @@ HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting this -# to YES can help to show when doxygen was last run and thus if the -# documentation is up to date. -# The default value is: NO. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_TIMESTAMP = NO - # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that # are dynamically created via JavaScript. If disabled, the navigation index will @@ -2002,14 +1993,6 @@ LATEX_HIDE_INDICES = NO LATEX_BIB_STYLE = plain -# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated -# page will contain the date and time when the page was generated. Setting this -# to NO can help when comparing the output of multiple runs. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_TIMESTAMP = NO - # The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) # path from which the emoji images will be read. If a relative path is entered, # it will be relative to the LATEX_OUTPUT directory. If left blank the diff --git a/kernel/arch/dreamcast/include/arch/memory.h b/kernel/arch/dreamcast/include/arch/memory.h index 9a19124..5b1d82b 100644 --- a/kernel/arch/dreamcast/include/arch/memory.h +++ b/kernel/arch/dreamcast/include/arch/memory.h @@ -8,7 +8,7 @@ /** \file arch/memory.h \brief Constants for areas of the system memory map. - Various addresses and masks that are set by the SH7750. None of the values + Various addresses and masks that are set by the SH7750. None of the values here are Dreamcast-specific. These values are drawn from the Hitatchi SH7750 Series Hardware Manual rev 6.0. @@ -25,9 +25,9 @@ __BEGIN_DECLS /** \defgroup memory Memory \brief Basics of the SH4 Memory Map - The SH7750 Series physical address space is mapped onto a 29-bit external - memory space, with the upper 3 bits of the address indicating which memory - region will be used. The P0/U0 memory region spans a 2GB space with the + The SH7750 Series physical address space is mapped onto a 29-bit external + memory space, with the upper 3 bits of the address indicating which memory + region will be used. The P0/U0 memory region spans a 2GB space with the bottom 512MB mirrored to the P1, P2, and P3 regions. */ @@ -35,8 +35,8 @@ __BEGIN_DECLS /** \brief Mask a cache-agnostic address. \ingroup memory - This masks out the upper 3 bits of an address. This is used when it is - necssary to access memory with a specified caching mode. This is needed for + This masks out the upper 3 bits of an address. This is used when it is + necssary to access memory with a specified caching mode. This is needed for DMA and SQ usage as well as various MMU functions. */ @@ -45,8 +45,8 @@ __BEGIN_DECLS /** \brief U0 memory region (cachable). \ingroup memory - This is the base user mode memory address. It is cacheable as determined - by the WT bit of the cache control register. By default KOS sets this to + This is the base user mode memory address. It is cacheable as determined + by the WT bit of the cache control register. By default KOS sets this to copy-back mode. KOS runs in privileged mode, so this is here merely for completeness. @@ -57,8 +57,8 @@ __BEGIN_DECLS /** \brief P0 memory region (cachable). \ingroup memory - This is the base privileged mode memory address. It is cacheable as determined - by the WT bit of the cache control register. By default KOS sets this to + This is the base privileged mode memory address. It is cacheable as determined + by the WT bit of the cache control register. By default KOS sets this to copy-back mode. */ @@ -67,10 +67,10 @@ __BEGIN_DECLS /** \brief P1 memory region (cachable). \ingroup memory - This is a modularly cachable memory region. It is cacheable as determined by - the CB bit of the cache control register. That allows it to function in a - different caching mode (copy-back v write-through) than the U0, P0, and P3 - regions, whose cache mode are governed by the WT bit. By default KOS sets this + This is a modularly cachable memory region. It is cacheable as determined by + the CB bit of the cache control register. That allows it to function in a + different caching mode (copy-back v write-through) than the U0, P0, and P3 + regions, whose cache mode are governed by the WT bit. By default KOS sets this to the same copy-back mode as the other cachable regions. */ @@ -79,7 +79,7 @@ __BEGIN_DECLS /** \brief P2 memory region (non-cachable). \ingroup memory - This is the non-cachable memory region. It is most frequently for DMA + This is the non-cachable memory region. It is most frequently for DMA transactions to ensure reads are not cached. */ @@ -94,7 +94,7 @@ __BEGIN_DECLS #define MEM_AREA_P3_BASE 0xc0000000 /** \brief P4 SH-internal memory region (non-cachable). - \defgroup p4mem + \defgroup p4mem P4 memory region \ingroup memory This offset maps to on-chip I/O channels. @@ -105,7 +105,7 @@ __BEGIN_DECLS /** \brief Store Queue (SQ) memory base. \ingroup p4mem - This offset maps to the SQ memory region. RW to addresses from + This offset maps to the SQ memory region. RW to addresses from 0xe0000000-0xe3ffffff follow SQ rules. \see dc\sq.h diff --git a/kernel/arch/dreamcast/include/dc/pvr.h b/kernel/arch/dreamcast/include/dc/pvr.h index 847db72..616e17b 100644 --- a/kernel/arch/dreamcast/include/dc/pvr.h +++ b/kernel/arch/dreamcast/include/dc/pvr.h @@ -1060,7 +1060,7 @@ Striplength set to 2 */ #define PVR_TA_INIT 0x0144 /**< \brief Initialize vertex reg. params */ #define PVR_YUV_ADDR 0x0148 /**< \brief YUV conversion destination */ #define PVR_YUV_CFG 0x014c /**< \brief YUV configuration */ -#define PVR_YUV_STAT 0x0150 /**< \bried The number of YUV macroblocks converted */ +#define PVR_YUV_STAT 0x0150 /**< \brief The number of YUV macroblocks converted */ #define PVR_UNK_0160 0x0160 /**< \brief ?? */ #define PVR_TA_OPB_INIT 0x0164 /**< \brief Object pointer buffer position init */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-10 18:41:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 1b08ce456b0f33324221ff1ea691f7ef2068d357 (commit) from 0f3b4d559a693ff6144272bf75bd98f09a849be5 (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 1b08ce456b0f33324221ff1ea691f7ef2068d357 Author: Falco Girgis <gyr...@gm...> Date: Sun Sep 10 13:39:56 2023 -0500 Added Makefile for YUV PVR demos (#299) * Added Makefile for YUV PVR demos - Looks like we forgot to make a directory-level Makefile for the new YUV PVR examples - Added directory-level Makefile to top-level PVR example Makefile * Apply suggestions from code review ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/pvr/Makefile | 5 ++++- examples/dreamcast/pvr/yuv_converter/Makefile | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 examples/dreamcast/pvr/yuv_converter/Makefile diff --git a/examples/dreamcast/pvr/Makefile b/examples/dreamcast/pvr/Makefile index ea69a20..24812cf 100644 --- a/examples/dreamcast/pvr/Makefile +++ b/examples/dreamcast/pvr/Makefile @@ -1,7 +1,7 @@ # KallistiOS ##version## # # examples/dreamcast/pvr/Makefile -# (c)2002 Megan Potter +# Copyright (C) 2002 Megan Potter # all: @@ -14,6 +14,7 @@ all: $(KOS_MAKE) -C modifier_volume_tex $(KOS_MAKE) -C cheap_shadow $(KOS_MAKE) -C bumpmap + $(KOS_MAKE) -C yuv_converter clean: $(KOS_MAKE) -C plasma clean @@ -25,6 +26,7 @@ clean: $(KOS_MAKE) -C modifier_volume_tex clean $(KOS_MAKE) -C cheap_shadow clean $(KOS_MAKE) -C bumpmap clean + $(KOS_MAKE) -C yuv_converter clean dist: $(KOS_MAKE) -C plasma dist @@ -36,3 +38,4 @@ dist: $(KOS_MAKE) -C modifier_volume_tex dist $(KOS_MAKE) -C cheap_shadow dist $(KOS_MAKE) -C bumpmap dist + $(KOS_MAKE) -C yuv_converter dist diff --git a/examples/dreamcast/pvr/yuv_converter/Makefile b/examples/dreamcast/pvr/yuv_converter/Makefile new file mode 100644 index 0000000..6f23bc9 --- /dev/null +++ b/examples/dreamcast/pvr/yuv_converter/Makefile @@ -0,0 +1,17 @@ +# KallistiOS ##version## +# +# examples/dreamcast/pvr/yuv_converter/Makefile +# Copyright (C) 2023 Falco Girgis +# + +all: + $(KOS_MAKE) -C YUV420 + $(KOS_MAKE) -C YUV422 + +clean: + $(KOS_MAKE) -C YUV420 clean + $(KOS_MAKE) -C YUV422 clean + +dist: + $(KOS_MAKE) -C YUV420 dist + $(KOS_MAKE) -C YUV422 dist hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-10 16:42: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 0f3b4d559a693ff6144272bf75bd98f09a849be5 (commit) via 5817cc42b7d7148fef6f796e4ef9cac3fc19c8fd (commit) via 4465add7249f76c027db209d06c09bddfa8d9a57 (commit) via 3c150f183684879573bf48f0a5c22df5ff489b40 (commit) via 77ad50af334469644b4514fdb48bbec94963ee30 (commit) via bd55ad32452e34df1e927cf131a1e1b09b7e4e06 (commit) via f3fa9d3c047873389289f1ec1cd32cfc713a90cc (commit) via 27ca4d99ca5f4a09596fa1fbc52d6f663f25a78a (commit) from 0974fbe0bc8701012e4f5a2896265109104ca394 (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 0f3b4d559a693ff6144272bf75bd98f09a849be5 Merge: 5817cc4 27ca4d9 Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 10 12:41:35 2023 -0400 Merge pull request #298 from KallistiOS/c99_atomics Enabled atomics support in environ_dreamcast.h commit 5817cc42b7d7148fef6f796e4ef9cac3fc19c8fd Merge: 4465add f3fa9d3 Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 10 12:40:55 2023 -0400 Merge pull request #300 from KallistiOS/thd_each_retval Modified thd_each() to support early exit + retval commit 4465add7249f76c027db209d06c09bddfa8d9a57 Merge: 3c150f1 bd55ad3 Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 10 12:38:41 2023 -0400 Merge pull request #302 from KallistiOS/wav_warnings wav2adpcm: Fixed 2 warnings, WAV verification errors mapped to stderr commit 3c150f183684879573bf48f0a5c22df5ff489b40 Merge: 0974fbe 77ad50a Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 10 12:35:21 2023 -0400 Merge pull request #303 from pcercuei/update-libtsunami-examples examples: tsunami: Update examples to latest API commit 77ad50af334469644b4514fdb48bbec94963ee30 Author: Paul Cercueil <pa...@cr...> Date: Sun Sep 3 12:15:16 2023 +0200 examples: tsunami: Update examples to latest API Signed-off-by: Paul Cercueil <pa...@cr...> commit bd55ad32452e34df1e927cf131a1e1b09b7e4e06 Author: Falco Girgis <gyr...@gm...> Date: Sat Sep 9 14:57:27 2023 -0500 wav2adpcm: Fixed 2 warnings, error logs to stderr - Fixed two warnings which popped up about not using the return value from fread() when reading the next wave chunk and its sizes - Noticed while validating the wav header, we were writing error messagse to stdout instead of stderr commit f3fa9d3c047873389289f1ec1cd32cfc713a90cc Author: Falco Girgis <gyr...@gm...> Date: Fri Sep 8 12:06:26 2023 -0500 Modified thd_each() to support early exit + retval It is often the case that iteration over a thread is doing a search for a particular thread or group of threads, allowing iteration to halt early. It is also the case that frequently the user may wish to return different values from their callback depending on the results. Presently we take a user callback whose return value is simply ignored and we return a "result code" that is hardcoded to always be zero. - Modified thd_each() to cease iteration early upon encountering a non-zero return value from the user's callback - Modified thd_each() to return the callback's return value commit 27ca4d99ca5f4a09596fa1fbc52d6f663f25a78a Author: Falco Girgis <gyr...@gm...> Date: Fri Sep 8 09:27:16 2023 -0500 Enabled atomics support in environ_dreamcast.h - Using the soft-imask model for SH, which essentially does "atomic" operations between disabling and reenabling interrupts - This gives us basic C99 atomic support and C++11 atomics support for types of size byte, short, or word, but additional libatomics back-end implementation is required for generic types and for dwords. ----------------------------------------------------------------------- Summary of changes: environ_dreamcast.sh | 2 +- examples/dreamcast/tsunami/banner/banner.cpp | 38 ++++++++++++++------------ examples/dreamcast/tsunami/font/font.cpp | 6 ++-- examples/dreamcast/tsunami/genmenu/genmenu.cpp | 38 ++++++++++++++------------ include/kos/thread.h | 6 ++-- kernel/thread/thread.c | 4 ++- utils/wav2adpcm/wav2adpcm.c | 27 ++++++++++++------ 7 files changed, 70 insertions(+), 51 deletions(-) diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh index 3182bc6..ec68262 100644 --- a/environ_dreamcast.sh +++ b/environ_dreamcast.sh @@ -1,7 +1,7 @@ # KallistiOS environment variable settings. These are the shared pieces # for the Dreamcast(tm) platform. -export KOS_CFLAGS="${KOS_CFLAGS} -ml -m4-single-only -ffunction-sections -fdata-sections" +export KOS_CFLAGS="${KOS_CFLAGS} -ml -m4-single-only -ffunction-sections -fdata-sections -matomic-model=soft-imask" export KOS_AFLAGS="${KOS_AFLAGS} -little" if [ x${KOS_SUBARCH} = xnaomi ]; then diff --git a/examples/dreamcast/tsunami/banner/banner.cpp b/examples/dreamcast/tsunami/banner/banner.cpp index d46425c..514aef9 100644 --- a/examples/dreamcast/tsunami/banner/banner.cpp +++ b/examples/dreamcast/tsunami/banner/banner.cpp @@ -42,6 +42,8 @@ even the main loop and user input eventually. #include <tsu/triggers/chainanim.h> #include <tsu/triggers/death.h> +#include <memory> + extern uint8 romdisk[]; KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS); KOS_INIT_ROMDISK(romdisk); @@ -117,34 +119,34 @@ int main(int argc, char **argv) { pvr_init_defaults(); // Load a texture for our banner - RefPtr<Texture> txr = new Texture("/rd/logo.png", true); + auto txr = std::make_shared<Texture>("/rd/logo.png", true); // Setup a scene and place a banner in it - RefPtr<Scene> sc = new Scene(); - RefPtr<Banner> b = new Banner(PVR_LIST_TR_POLY, txr); + auto sc = std::make_shared<Scene>(); + auto b = std::make_shared<Banner>(PVR_LIST_TR_POLY, txr); sc->subAdd(b); // Put the banner off-screen to begin with, and attach a LogXYMover // animation to move it to 320,240 b->setTranslate(Vector(800, 600, 10)); - RefPtr<LogXYMover> mover = new LogXYMover(320, 240); + auto mover = std::make_shared<LogXYMover>(320, 240); b->animAdd(mover); // Add a trigger to the LogXYMover to chain to our Circler animation. - RefPtr<Circler> circ = new Circler(320, 240, 10, 75, 30); - mover->triggerAdd(new ChainAnimation(circ)); + auto circ = std::make_shared<Circler>(320, 240, 10, 75, 30); + mover->triggerAdd(std::make_shared<ChainAnimation>(circ)); // Add a couple of labels with explanation. Set each one's // initial alpha to 0 and fade them in over 30 frames. - RefPtr<Font> fnt = new Font("/rd/typewriter.txf"); - RefPtr<Label> lbl1 = new Label(fnt, "Use the joystick to control the size", 24, true, true); + auto fnt = std::make_shared<Font>("/rd/typewriter.txf"); + auto lbl1 = std::make_shared<Label>(fnt, "Use the joystick to control the size", 24, true, true); lbl1->setTranslate(Vector(320, 360, 20)); sc->subAdd(lbl1); lbl1->setAlpha(0.0f); - RefPtr<AlphaFader> fader = new AlphaFader(1.0f, 1.0f / 30.0f); + auto fader = std::make_shared<AlphaFader>(1.0f, 1.0f / 30.0f); lbl1->animAdd(fader); - RefPtr<Label> lbl2 = new Label(fnt, "of the circle. Press START to quit.", 24, true, true); + auto lbl2 = std::make_shared<Label>(fnt, "of the circle. Press START to quit.", 24, true, true); lbl2->setTranslate(Vector(320, 360 + 24, 20)); sc->subAdd(lbl2); lbl2->setAlpha(0.0f); @@ -193,21 +195,21 @@ int main(int argc, char **argv) { printf("Starting exodus...\n"); // Create an ExpXYMover heading off-screen and chain it to the Circler - RefPtr<ExpXYMover> mover2 = new ExpXYMover(-1.0f, -1.0f, 320 - 800, 240 - 600); - circ->triggerAdd(new ChainAnimation(mover2)); + auto mover2 = std::make_shared<ExpXYMover>(-1.0f, -1.0f, 320 - 800, 240 - 600); + circ->triggerAdd(std::make_shared<ChainAnimation>(mover2)); // Add a trigger to the ExpXYMover that will signal that the banner // is finished once it reaches the animation endpoint. - mover2->triggerAdd(new Death()); + mover2->triggerAdd(std::make_shared<Death>()); // Add faders with triggers; note we use two separate alpha faders // this time so we have two triggers (one per label) - fader = new AlphaFader(0.0f, -1.0f / 30.0f); - fader->triggerAdd(new Death()); + fader = std::make_shared<AlphaFader>(0.0f, -1.0f / 30.0f); + fader->triggerAdd(std::make_shared<Death>()); lbl1->animAdd(fader); - fader = new AlphaFader(0.0f, -1.0f / 30.0f); - fader->triggerAdd(new Death()); + fader = std::make_shared<AlphaFader>(0.0f, -1.0f / 30.0f); + fader->triggerAdd(std::make_shared<Death>()); lbl2->animAdd(fader); // Tell the circler we're about to finish up @@ -243,7 +245,7 @@ int main(int argc, char **argv) { MAPLE_FOREACH_END() } - // Ok, we're all done! The RefPtrs will take care of mem cleanup. + // Ok, we're all done! The std::shared_ptrs will take care of mem cleanup. return 0; } diff --git a/examples/dreamcast/tsunami/font/font.cpp b/examples/dreamcast/tsunami/font/font.cpp index 8adcc29..b77935f 100644 --- a/examples/dreamcast/tsunami/font/font.cpp +++ b/examples/dreamcast/tsunami/font/font.cpp @@ -13,6 +13,8 @@ #include <tsu/texture.h> #include <plx/sprite.h> +#include <memory> + /* Shows off some very basic usage of the font and texture objects with Parallax as the vertex system rather than the Tsunami scene @@ -31,10 +33,10 @@ int main(int argc, char **argv) { pvr_init_defaults(); - RefPtr<Font> fnt = new Font("/rd/axaxax.txf"); + auto fnt = std::make_shared<Font>("/rd/axaxax.txf"); fnt->setSize(24.0f); - RefPtr<Texture> txr = new Texture("/rd/logo.png", true); + auto txr = std::make_shared<Texture>("/rd/logo.png", true); pvr_set_bg_color(0.2f, 0.0f, 0.4f); diff --git a/examples/dreamcast/tsunami/genmenu/genmenu.cpp b/examples/dreamcast/tsunami/genmenu/genmenu.cpp index faa3b1a..d6f18c3 100644 --- a/examples/dreamcast/tsunami/genmenu/genmenu.cpp +++ b/examples/dreamcast/tsunami/genmenu/genmenu.cpp @@ -27,13 +27,15 @@ basics. #include <tsu/anims/alphafader.h> #include <tsu/triggers/death.h> +#include <memory> + extern uint8 romdisk[]; KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS); KOS_INIT_ROMDISK(romdisk); -class MyMenu : public GenericMenu, public RefCnt { +class MyMenu : public GenericMenu { public: - MyMenu(Font * fnt) { + MyMenu(std::shared_ptr<Font> fnt) { // Offset our scene so 0,0,0 is the screen center with Z +10 m_scene->setTranslate(Vector(320, 240, 10)); @@ -44,21 +46,21 @@ public: m_gray = Color(1, 0.7f, 0.7f, 0.7f); // Setup three labels and have them zoom in. - m_options[0] = new Label(fnt, "Do Thing 1", 24, true, true); + m_options[0] = std::make_shared<Label>(fnt, "Do Thing 1", 24, true, true); m_options[0]->setTranslate(Vector(0, 400, 0)); - m_options[0]->animAdd(new LogXYMover(0, 0)); + m_options[0]->animAdd(std::make_shared<LogXYMover>(0, 0)); m_options[0]->setTint(m_white); m_scene->subAdd(m_options[0]); - m_options[1] = new Label(fnt, "Do Thing 2", 24, true, true); + m_options[1] = std::make_shared<Label>(fnt, "Do Thing 2", 24, true, true); m_options[1]->setTranslate(Vector(0, 400 + 400, 0)); - m_options[1]->animAdd(new LogXYMover(0, 24)); + m_options[1]->animAdd(std::make_shared<LogXYMover>(0, 24)); m_options[1]->setTint(m_gray); m_scene->subAdd(m_options[1]); - m_options[2] = new Label(fnt, "Quit", 24, true, true); + m_options[2] = std::make_shared<Label>(fnt, "Quit", 24, true, true); m_options[2]->setTranslate(Vector(0, 400 + 400 + 400, 0)); - m_options[2]->animAdd(new LogXYMover(0, 48)); + m_options[2]->animAdd(std::make_shared<LogXYMover>(0, 48)); m_options[2]->setTint(m_gray); m_scene->subAdd(m_options[2]); @@ -109,16 +111,16 @@ public: virtual void startExit() { // Apply some expmovers to the options. - ExpXYMover * m = new ExpXYMover(0, 1, 0, 400); - m->triggerAdd(new Death()); + auto m = std::make_shared<ExpXYMover>(0, 1, 0, 400); + m->triggerAdd(std::make_shared<Death>()); m_options[0]->animAdd(m); - m = new ExpXYMover(0, 1.2, 0, 400); - m->triggerAdd(new Death()); + m = std::make_shared<ExpXYMover>(0, 1.2, 0, 400); + m->triggerAdd(std::make_shared<Death>()); m_options[1]->animAdd(m); - m = new ExpXYMover(0, 1.4, 0, 400); - m->triggerAdd(new Death()); + m = std::make_shared<ExpXYMover>(0, 1.4, 0, 400); + m->triggerAdd(std::make_shared<Death>()); m_options[2]->animAdd(m); GenericMenu::startExit(); @@ -126,7 +128,7 @@ public: Color m_white, m_gray; - RefPtr<Label> m_options[3]; + std::shared_ptr<Label> m_options[3]; int m_cursel; }; @@ -140,16 +142,16 @@ int main(int argc, char **argv) { pvr_init_defaults(); // Load a font - RefPtr<Font> fnt = new Font("/rd/typewriter.txf"); + auto fnt = std::make_shared<Font>("/rd/typewriter.txf"); // Create a menu - RefPtr<MyMenu> mm = new MyMenu(fnt); + auto mm = std::make_shared<MyMenu>(fnt); // Do the menu mm->doMenu(); - // Ok, we're all done! The RefPtrs will take care of mem cleanup. + // Ok, we're all done! The std::shared_ptrs will take care of mem cleanup. return 0; } diff --git a/include/kos/thread.h b/include/kos/thread.h index d61a4cd..83dbba0 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -650,10 +650,12 @@ int thd_detach(kthread_t *thd); \ingroup threads \relatesalso kthread_t - \param cb The callback to call for each thread + \param cb The callback to call for each thread. + If a nonzero value is returned, iteration + ceases immediately. \param data User data to be passed to the callback - \retval 0 On success. + \retval 0 or the first nonzero value returned by \p cb. \sa thd_pslist */ diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c index a0fa789..18843ba 100644 --- a/kernel/thread/thread.c +++ b/kernel/thread/thread.c @@ -92,9 +92,11 @@ static const char *thd_state_to_str(kthread_t *thd) { int thd_each(int (*cb)(kthread_t *thd, void *user_data), void *data) { kthread_t *cur; + int retval; LIST_FOREACH(cur, &thd_list, t_list) { - cb(cur, data); + if((retval = cb(cur, data))) + return retval; } return 0; diff --git a/utils/wav2adpcm/wav2adpcm.c b/utils/wav2adpcm/wav2adpcm.c index 2b4252d..13adf7e 100644 --- a/utils/wav2adpcm/wav2adpcm.c +++ b/utils/wav2adpcm/wav2adpcm.c @@ -186,32 +186,32 @@ int validate_wav_header(wavhdr_t *wavhdr, int format, int bits, FILE *in) { int result = 0; if(memcmp(wavhdr->hdr1, "RIFF", 4)) { - printf("Invalid RIFF header.\n"); + fprintf(stderr, "Invalid RIFF header.\n"); result = -1; } if(memcmp(wavhdr->hdr2, "WAVEfmt ", 8)) { - printf("Invalid WAVEfmt header.\n"); + fprintf(stderr, "Invalid WAVEfmt header.\n"); result = -1; } if(wavhdr->hdrsize != 0x10) { - printf("Invalid header size.\n"); + fprintf(stderr, "Invalid header size.\n"); result = -1; } if(wavhdr->format != format) { - printf("Unsupported format.\n"); + fprintf(stderr, "Unsupported format.\n"); result = -1; } if(wavhdr->channels != 1 && wavhdr->channels != 2) { - printf("Unsupported number of channels.\n"); + fprintf(stderr, "Unsupported number of channels.\n"); result = -1; } if(wavhdr->bits != bits) { - printf("Unsupported bit depth.\n"); + fprintf(stderr, "Unsupported bit depth.\n"); result = -1; } @@ -224,10 +224,18 @@ int validate_wav_header(wavhdr_t *wavhdr, int format, int bits, FILE *in) { do { /* Read the next chunk header */ - fread(wavhdr->hdr3, 1, 4, in); + if(fread(wavhdr->hdr3, 1, 4, in) != 4) { + fprintf(stderr, "Failed to read next chunk header!\n"); + result = -1; + break; + } /* Read the chunk size */ - fread(&wavhdr->datasize, 1, 4, in); + if(fread(&wavhdr->datasize, 1, 4, in) != 4) { + fprintf(stderr, "Failed to read chunk size!\n"); + result = -1; + break; + } /* Skip the chunk if it's not the "data" chunk. */ if(memcmp(wavhdr->hdr3, "data", 4)) @@ -294,11 +302,12 @@ int wav2adpcm(const char *infile, const char *outfile) { out = fopen(outfile, "wb"); if(fwrite(&wavhdr, sizeof(wavhdr), 1, out) != 1 || - fwrite(adpcmbuf, adpcmsize, 1, out) != 1) { + fwrite(adpcmbuf, adpcmsize, 1, out) != 1) { fprintf(stderr, "Cannot write ADPCM data.\n"); fclose(out); return -1; } + fclose(out); return 0; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-10 16:37:14
|
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 "UNNAMED PROJECT". The branch, master has been updated via a9469557bddda8bc37a77935b770dbcfb5dc4203 (commit) via 07f410dc0165c7ca65da2505f1ea9e1acd76a69d (commit) via 5cff9720de671e0674407c9124882f217c14acc9 (commit) via b11b146dce5a9c8abcda71caf2447452132c610e (commit) via 015ffe2f5b1c50227e0b8268b39fee8a1dd0de1a (commit) via b6bf4a27edf71895d8ada7addd23cf9e3ec8550a (commit) via 280a443d13a609784acbebc6c387657c204278e8 (commit) via ef8ca14fb2fdb04106287b76d11d4b0143744f41 (commit) via 942067f13775fe656ff127d9f530ebf0ea676bb8 (commit) via 5ab9325d1cc938107417d1a5d597147ec4662888 (commit) via 06cf8d4511b914ebfc2a97a3811aa52c4201ee6a (commit) from 9771d16b0a91c7b1745ef61e792197eac70ef541 (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 a9469557bddda8bc37a77935b770dbcfb5dc4203 Merge: 9771d16 07f410d Author: Lawrence Sebald <ljs...@us...> Date: Sun Sep 10 12:34:25 2023 -0400 Merge pull request #1 from pcercuei/c++17 Rework to use C++17 commit 07f410dc0165c7ca65da2505f1ea9e1acd76a69d Author: Paul Cercueil <pa...@cr...> Date: Sun Sep 3 00:07:32 2023 +0200 Remove custom reference counting This code is not needed / useful anymore, since everything has been switched to use C++11 std::shared_ptr<>. Signed-off-by: Paul Cercueil <pa...@cr...> commit 5cff9720de671e0674407c9124882f217c14acc9 Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:55:34 2023 +0200 genmenu: Use shared pointers Use shared pointers instead of the custom RefCnt class. Signed-off-by: Paul Cercueil <pa...@cr...> commit b11b146dce5a9c8abcda71caf2447452132c610e Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:54:56 2023 +0200 triggers: Use shared pointers Use shared pointers instead of the custom RefCnt class. Signed-off-by: Paul Cercueil <pa...@cr...> commit 015ffe2f5b1c50227e0b8268b39fee8a1dd0de1a Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:45:44 2023 +0200 drawable: Use shared pointers Use shared pointers instead of the custom RefCnt class. Signed-off-by: Paul Cercueil <pa...@cr...> commit b6bf4a27edf71895d8ada7addd23cf9e3ec8550a Author: Paul Cercueil <pa...@cr...> Date: Sun Sep 3 00:05:45 2023 +0200 animations: Use shared pointers Use shared pointers instead of the custom RefCnt class. Signed-off-by: Paul Cercueil <pa...@cr...> commit 280a443d13a609784acbebc6c387657c204278e8 Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:22:58 2023 +0200 Remove custom List<>, use std::depre instead There is no need to use a custom list object in favour of the ones provided by the standard C++ library. Use std::depre which allows us to queue pointers from the front, while still being able to loop front to back, to retain the old behaviour. Signed-off-by: Paul Cercueil <pa...@cr...> [gyrovorbis: quick bugfix for crash on erasing from std::deque] Signed-off-by: Falco Girgis <gyr...@gm...> commit ef8ca14fb2fdb04106287b76d11d4b0143744f41 Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:17:46 2023 +0200 Add missing includes Some source files needed extra includes to compile properly. Signed-off-by: Paul Cercueil <pa...@cr...> commit 942067f13775fe656ff127d9f530ebf0ea676bb8 Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:47:19 2023 +0200 Use C++ strings when applicable Use std::string instead of the C "const char *" where strings are used in the API. Signed-off-by: Paul Cercueil <pa...@cr...> commit 5ab9325d1cc938107417d1a5d597147ec4662888 Author: Paul Cercueil <pa...@cr...> Date: Sat Sep 2 23:16:16 2023 +0200 Use C++17 filesystem paths when applicable Use C++17 std::filesystem and in particular std::filesystem::path instead of using "const char *" for paths. Signed-off-by: Paul Cercueil <pa...@cr...> commit 06cf8d4511b914ebfc2a97a3811aa52c4201ee6a Author: Paul Cercueil <pa...@cr...> Date: Sun Sep 3 00:04:10 2023 +0200 Change NULL -> nullptr NULL is a C thing. Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: include/animation.h | 10 +-- include/drawable.h | 14 ++-- include/drawables/banner.h | 8 ++- include/drawables/label.h | 13 ++-- include/font.h | 24 ++++--- include/genmenu.h | 9 +-- include/list.h | 168 ------------------------------------------- include/refcnt.h | 133 ---------------------------------- include/sound.h | 10 +-- include/texture.h | 11 +-- include/trigger.h | 5 +- include/triggers/birth.h | 9 ++- include/triggers/chainanim.h | 6 +- include/triggers/death.h | 6 +- include/triggers/oneshot.h | 7 +- src/animation.cpp | 29 ++++---- src/drawable.cpp | 121 ++++++++++++++----------------- src/drawables/banner.cpp | 4 +- src/drawables/label.cpp | 15 ++-- src/font.cpp | 58 +++++++-------- src/genmenu.cpp | 11 +-- src/sound.cpp | 10 +-- src/texture.cpp | 22 +++--- src/triggers/birth.cpp | 3 +- src/triggers/death.cpp | 2 +- 25 files changed, 210 insertions(+), 498 deletions(-) delete mode 100644 include/list.h delete mode 100644 include/refcnt.h diff --git a/include/animation.h b/include/animation.h index 6523759..4dae8d1 100644 --- a/include/animation.h +++ b/include/animation.h @@ -12,17 +12,19 @@ class Drawable; -#include "list.h" #include "trigger.h" -class Animation : virtual public RefCnt { +#include <memory> +#include <deque> + +class Animation { public: /// Constructor / Destructor Animation(); virtual ~Animation(); /// Add a trigger to our list of triggers - void triggerAdd(Trigger *t); + void triggerAdd(std::shared_ptr<Trigger> t); /// Remove a trigger from our list of triggers void triggerRemove(Trigger *t); @@ -41,7 +43,7 @@ protected: virtual void complete(Drawable *t); private: - List<Trigger> m_triggers; // Animation triggers + std::deque<std::shared_ptr<Trigger>> m_triggers; // Animation triggers }; #endif /* __TSUNAMI_ANIMATION_H */ diff --git a/include/drawable.h b/include/drawable.h index be71c3c..edf36ba 100644 --- a/include/drawable.h +++ b/include/drawable.h @@ -12,18 +12,20 @@ #include "animation.h" -#include "list.h" #include "vector.h" #include "color.h" -class Drawable : virtual public RefCnt { +#include <deque> +#include <memory> + +class Drawable { public: /// Constructor / Destructor Drawable(); virtual ~Drawable(); /// Add an animation object to us - void animAdd(Animation * ani); + void animAdd(std::shared_ptr<Animation> ani); /// Remove an animation object from us void animRemove(Animation * ani); @@ -46,7 +48,7 @@ public: void subNextFrame(); /// Add a new object to our sub-drawables - void subAdd(Drawable *t); + void subAdd(std::shared_ptr<Drawable> t); /// Remove an object from our sub-drawables void subRemove(Drawable * t); @@ -132,8 +134,8 @@ private: Drawable * m_parent; ///< Our parent object - List<Animation> m_anims; ///< Animation objects - List<Drawable> m_subs; ///< Our sub-drawable list + std::deque<std::shared_ptr<Animation>> m_anims; ///< Animation objects + std::deque<std::shared_ptr<Drawable>> m_subs; ///< Our sub-drawable list }; #endif /* __TSUNAMI_DRAWABLE_H */ diff --git a/include/drawables/banner.h b/include/drawables/banner.h index 20277ea..fa23c69 100644 --- a/include/drawables/banner.h +++ b/include/drawables/banner.h @@ -16,14 +16,16 @@ #include "../texture.h" #include "../color.h" +#include <memory> + /** Banner -- a texture banner drawable. This drawable takes a texture (and optional UV coordinates) and draws a banner. */ class Banner : public Drawable { public: - Banner(int list, Texture * texture); + Banner(int list, std::shared_ptr<Texture> texture); virtual ~Banner(); - void setTexture(Texture * txr); + void setTexture(std::shared_ptr<Texture> txr); // Points are: 2 4 // 1 3 @@ -35,7 +37,7 @@ public: private: int m_list; - RefPtr<Texture> m_texture; + std::shared_ptr<Texture> m_texture; float m_u1, m_v1, m_u2, m_v2; float m_u3, m_v3, m_u4, m_v4; diff --git a/include/drawables/label.h b/include/drawables/label.h index 4444dd5..3405642 100644 --- a/include/drawables/label.h +++ b/include/drawables/label.h @@ -13,19 +13,22 @@ #include "../drawable.h" #include "../font.h" +#include <string> + class Label : public Drawable { public: - Label(Font * fh, const char *text, int size, bool centered, bool smear); + Label(std::shared_ptr<Font> fh, const std::string &text, + int size, bool centered, bool smear); virtual ~Label(); - void setText(const char * text); - void setFont(Font * f); + void setText(const std::string &text); + void setFont(std::shared_ptr<Font> f); virtual void draw(int list); private: - RefPtr<Font> m_fh; - const char * m_text; + std::shared_ptr<Font> m_fh; + std::string m_text; int m_size; bool m_centered; bool m_smear; diff --git a/include/font.h b/include/font.h index a5b5ba3..4de54d7 100644 --- a/include/font.h +++ b/include/font.h @@ -11,15 +11,17 @@ #define __TSUNAMI_FONT_H #include <plx/font.h> -#include "refcnt.h" #include "vector.h" -class Font : virtual public RefCnt { +#include <filesystem> +#include <string> + +class Font { public: - Font(const char *fn = NULL, int list = PVR_LIST_TR_POLY); + Font(const std::filesystem::path &path, int list = PVR_LIST_TR_POLY); virtual ~Font(); - bool loadFromFile(const char * fn); + bool loadFromFile(const std::filesystem::path &path); void setFilter(int type); @@ -27,10 +29,10 @@ public: void setAlpha(float a); void setSize(float size); - void draw(float x, float y, float z, const char *text); - void drawCentered(float x, float y, float z, const char *text); - void smearDraw(float x, float y, float z, const char *text); - void smearDrawCentered(float x, float y, float z, const char *text); + void draw(float x, float y, float z, const std::string &text); + void drawCentered(float x, float y, float z, const std::string &text); + void smearDraw(float x, float y, float z, const std::string &text); + void smearDrawCentered(float x, float y, float z, const std::string &text); void drawCharBegin(float x, float y, float z); Vector drawCharGetPos(); @@ -39,9 +41,9 @@ public: void drawCharEnd(); void getCharExtents(int c, float * l, float * u, float * r, float * d); - void getTextSize(const char *text, float * w, float * h); - void upperleftCoords(const char * text, float *x, float *y); - void centerCoords(const char * text, float *x, float *y); + void getTextSize(const std::string &text, float * w, float * h); + void upperleftCoords(const std::string &text, float *x, float *y); + void centerCoords(const std::string &text, float *x, float *y); operator plx_font_t * () const { return m_font; } operator plx_fcxt_t * () const { return m_cxt; } diff --git a/include/genmenu.h b/include/genmenu.h index 4d32b87..1442fcb 100644 --- a/include/genmenu.h +++ b/include/genmenu.h @@ -9,9 +9,10 @@ #ifndef __TSUNAMI_GENMENU_H #define __TSUNAMI_GENMENU_H -#include "refcnt.h" #include "drawables/scene.h" +#include <filesystem> + /* This defines a fully generic menu system. Basically what you do is derive from this class and then implement the constructor (which adds things to the internal scene object) and the inputEvent method (which @@ -116,7 +117,7 @@ protected: // Call this method to setup a background song to be played during the // menu. You should do this before calling doMenu(). The song will // be started with the menu and faded out on exit. - virtual void setBgm(const char * fn, bool cache = false); + virtual void setBgm(const std::filesystem::path &fn, bool cache = false); // This method should be called any time the user does something that // would cancel the menu's timeout. @@ -138,7 +139,7 @@ protected: // Name of the song we'll use for background music (if any). If this // is an empty string, we'll not use a song. - char m_bgmFn[256]; + std::filesystem::path m_bgmFn; bool m_usebgm, m_cachebgm; // Background plane color @@ -156,7 +157,7 @@ protected: uint32 m_timeout; // Our scene object - RefPtr<Scene> m_scene; + std::shared_ptr<Scene> m_scene; // Allow one "main" controller in each port. We'll track what's in // each port and what buttons are currently held. diff --git a/include/list.h b/include/list.h deleted file mode 100644 index b9a9281..0000000 --- a/include/list.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - Tsunami for KallistiOS ##version## - - list.h - - Copyright (C) 2002 Megan Potter - -*/ - -#ifndef __TSUNAMI_LIST_H -#define __TSUNAMI_LIST_H - -/// \file A basic linked-list class. The only real constraint here -/// is that the type T must be a subclass of RefCnt or something that -/// provides similar methods. This cheats a little by implementing -/// all the core functionality via the BSD queue macros, but it provides -/// a much nicer C++ interface. - -#include <assert.h> -#include <string.h> -#include <sys/queue.h> -#include "refcnt.h" - -template <class T> -class List; - -template <class T> -struct ListNode { -public: - ListNode<T>(List<T> * head, T * d) - : m_head(head), m_data(d), m_inlist(false) - { } - - virtual ~ListNode<T>() { - assert( !m_inlist ); - } - - /// Get the next list item - ListNode<T> * getNext() const { - assert( m_inlist ); - if ( !m_inlist ) - return NULL; - - return TAILQ_NEXT(this, m_listptr); - } - - /// Get this list item's data - T * getData() const { return m_data; } - - /// Perform an operation on this list item's data - T * operator->() const { - assert( m_data != NULL ); - return (T*)m_data; - } - - /// Remove this item from the list (doesn't delete it) - void remove() { - assert( m_inlist ); - if (!m_inlist) return; - - TAILQ_REMOVE(&m_head->m_list, this, m_listptr); - m_inlist = false; - } - - /// Insert another element before us - void insertBefore(ListNode<T> * other) { - assert( !m_inlist ); - if (m_inlist) return; - - TAILQ_INSERT_BEFORE(other, this, m_listptr); - m_inlist = true; - } - - /// Insert another element after us - void insertAfter(ListNode<T> * other) { - assert( !m_inlist ); - if (m_inlist) return; - - TAILQ_INSERT_AFTER(&m_head->m_list, other, this, m_listptr); - m_inlist = true; - } - -private: - List<T> * m_head; - RefPtr<T> m_data; - bool m_inlist; - - friend class List<T>; - TAILQ_ENTRY(ListNode<T>) m_listptr; -}; - - -template <class T> -class List { -public: - List() { - TAILQ_INIT(&m_list); - } - - virtual ~List() { - delAll(); - } - - /// Insert an item at the head of the list. A reference will be added. - void insertHead(T * item) { - ListNode<T> * ni = new ListNode<T>(this, item); - TAILQ_INSERT_HEAD(&m_list, ni, m_listptr); - ni->m_inlist = true; - } - - /// Insert an item at the tail of the list. A reference will be added. - void insertTail(T * item) { - ListNode<T> * ni = new ListNode<T>(this, item); - TAILQ_INSERT_TAIL(&m_list, ni, m_listptr); - ni->m_inlist = true; - } - - /// Delete the named item. Return true if we actually had it. Its - /// reference will be removed if it is found. - bool del(T * item) { - ListNode<T> * n; - - TAILQ_FOREACH(n, &m_list, m_listptr) { - if (n->getData() == item) { - n->remove(); - delete n; - return true; - } - } - - return false; - } - - /// Remove all items from the list. - void delAll() { - ListNode<T> * n, * t; - - // Pull each item from the list and destroy it - t = TAILQ_FIRST(&m_list); - while (t) { - n = t->getNext(); - t->m_inlist = false; - delete t; - t = n; - } - - // Re-init the list - TAILQ_INIT(&m_list); - } - - /// Return the element at the head of the list - ListNode<T> * getHead() const { - return TAILQ_FIRST(&m_list); - } - -private: - friend class ListNode<T>; - - TAILQ_HEAD(listnodehead, ListNode<T>) m_list; - -public: - /// Return the element at the end of the list - ListNode<T> * getTail() const { - return TAILQ_LAST(&m_list, listnodehead); - } -}; - -#endif // __TSUNAMI_LIST_H diff --git a/include/refcnt.h b/include/refcnt.h deleted file mode 100644 index 0b6bf0f..0000000 --- a/include/refcnt.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - Tsunami for KallistiOS ##version## - - refcnt.h - - Copyright (C) 2002 Megan Potter - -*/ - -#ifndef __TSUNAMI_REFCNT_H -#define __TSUNAMI_REFCNT_H - -/// \file A simple reference counting system for managing shared -/// data objects. - -#include <arch/arch.h> -#include <stdio.h> -#include <assert.h> - -/// The reference count base class itself. Any class you want handled -/// by reference counting should add this as a public base class. -class RefCnt { -public: - RefCnt() { - m_refcnt = 0; - } - virtual ~RefCnt() { - if (m_refcnt != 0) { - dbglog(DBG_WARNING, "RefCnt::~RefCnt: **WARNING** My (%08lx), refcount isn't zero! It's %d.\n", - (uint32)this, m_refcnt); - } - assert( m_refcnt == 0 ); - } - - // Add a reference to the object - virtual void ref() { - m_refcnt++; - } - - // Remove a reference to the object; if we hit - // zero then delete it - virtual void unref() { - m_refcnt--; - if (m_refcnt < 0) { - dbglog(DBG_WARNING, "RefCnt::unref() refcount underflow! this=%08lx, caller=%08lx\n", - (uint32)this, arch_get_ret_addr()); - assert( false ); - } else if (m_refcnt == 0) { - delete this; - } - } - -private: - int m_refcnt; -}; - - -/// A "smart pointer" to handle the RefCnt objects. ...<truncated>... hooks/post-receive -- UNNAMED PROJECT |
From: ljsebald <ljs...@us...> - 2023-09-08 00:54:24
|
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 269160a8056325dda09163a433ab3756c88cfd50 (commit) from cc16fee4d4ebbe969a65bf3cc220deeb924de8f2 (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 269160a8056325dda09163a433ab3756c88cfd50 Author: Falco Girgis <gyr...@gm...> Date: Thu Sep 7 19:49:51 2023 -0500 environ.sh.sample cleanup + documentation + optimizations (#288) * Cleaned up environ.sh.sample to more closely reflect the model we're using for the dc-chain config files. * more optimization flags added * more detailed descriptions added * legacy comments removed * Beautified pvr_mem.c with 80 character columns * Address review feedback. ----------------------------------------------------------------------- Summary of changes: doc/environ.sh.sample | 184 +++++++++++++++------- include/kos/opts.h | 9 ++ kernel/arch/dreamcast/hardware/pvr/pvr_mem.c | 23 ++- kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c | 6 +- kernel/libc/koslib/malloc.c | 6 +- 5 files changed, 158 insertions(+), 70 deletions(-) diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample index 9ed3aae..fe55a61 100644 --- a/doc/environ.sh.sample +++ b/doc/environ.sh.sample @@ -1,69 +1,107 @@ -# KallistiOS environment variable settings +# KallistiOS Environment Settings # -# This is a sample script. Configure to suit your setup. Some possible -# alternatives for the values below are included as an example. +# This is a sample script for configuring and customizing your +# KOS build environment. Modify it to suit your setup. Several +# settings may be enabled optionally or are provided with +# alternative values. # -# This script should be sourced in your current shell environment (probably -# by bashrc or something similar). +# This script is typically sourced in your current shell environment +# (probably by .bashrc, .bash_profile, or something similar), so that +# the KOS environment is set up automatically for each shell session. # -# Build architecture. Set the major architecture you'll be building for. +# Build Architecture +# +# Set the major architecture you'll be building for. # The only option here is "dreamcast" as of KOS 2.0.0. +# export KOS_ARCH="dreamcast" -# Build sub-architecture. If you need a particular sub-architecture, then set -# that here; otherwise use "pristine". -# Possible subarch options include: -# "pristine" - a normal Dreamcast console or HKT-0120 devkit -# "naomi" - a NAOMI or NAOMI 2 arcade board -# You can also pre-define it in eg the build config of your IDE +# Build Sub-Architecture +# +# Defines the sub architecture your configuration +# is targeting or uses an existing value that +# can be set externally via your IDE. +# +# Valid values: +# "pristine" - Dreamcast console or HKT-0120 devkit (default) +# "naomi" - NAOMI or NAOMI 2 arcade board +# if [ -z "${KOS_SUBARCH}" ] ; then export KOS_SUBARCH="pristine" else export KOS_SUBARCH fi -# KOS main base path +# KOS Root Path +# +# Specifies the path to the KOS root directory +# export KOS_BASE="/opt/toolchains/dc/kos" + +# KOS-Ports Path +# +# Specifies the path to the KOS-ports directory +# export KOS_PORTS="${KOS_BASE}/../kos-ports" -# Make utility -export KOS_MAKE="make" -#export KOS_MAKE="gmake" +# SH Compiler Prefixes +# +# Specifies the path to and prefix for the main SH +# GCC toolchain used to target the Dreamcast's SH4 CPU. +# +export KOS_CC_BASE="/opt/toolchains/dc/sh-elf" +export KOS_CC_PREFIX="sh-elf" -# CMake toolchain -export KOS_CMAKE_TOOLCHAIN="${KOS_BASE}/utils/cmake/dreamcast.toolchain.cmake" +# ARM Compiler Prefixes +# +# Specifies the path to and prefix for the additional ARM +# GCC toolchain used to target the Dreamcast's AICA SPU. +# +export DC_ARM_BASE="/opt/toolchains/dc/arm-eabi" +export DC_ARM_PREFIX="arm-eabi" -# Load utility -export KOS_LOADER="dc-tool -x" # dcload, preconfigured -# export KOS_LOADER="dc-tool-ser -t /dev/ttyS0 -x" # dcload-serial +# CMake Toolchain Path +# +# Specifies the path to the toolchain file used to target +# KOS with the "cmake" build utility. +# +export KOS_CMAKE_TOOLCHAIN="${KOS_BASE}/utils/cmake/dreamcast.toolchain.cmake" -# Genromfs utility +# Genromfs Utility Path +# +# Specifies the path to the utility which is used by KOS +# to create romdisk filesystem images. +# export KOS_GENROMFS="${KOS_BASE}/utils/genromfs/genromfs" -#export KOS_GENROMFS="genromfs" - -# Compiler prefixes -#export KOS_CC_BASE="/usr/local/dc/dc-elf" -#export KOS_CC_PREFIX="dc" -export KOS_CC_BASE="/opt/toolchains/dc/sh-elf" # DC -export KOS_CC_PREFIX="sh-elf" -# If you are compiling for DC and have an ARM compiler, use these too. -# If you're using a newer compiler (GCC 4.7.0 and newer), you should probably be -# using arm-eabi as the target, rather than arm-elf. dc-chain now defaults to -# arm-eabi, so that's the default here. -#export DC_ARM_BASE="/usr/local/dc/arm-elf" -#export DC_ARM_PREFIX="arm-elf" -export DC_ARM_BASE="/opt/toolchains/dc/arm-eabi" -export DC_ARM_PREFIX="arm-eabi" +# Make Utility +# +# Configures the tool to be used as the main "make" utility +# for building GNU Makefiles. On a platform such as BSD, +# the default can be changed to "gmake," for the GNU +# implementation. +# +export KOS_MAKE="make" +#export KOS_MAKE="gmake" -# Expand PATH if not already set (comment out if you don't want this done here) -if [[ ":$PATH:" != *":${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin"* ]]; then - export PATH="${PATH}:${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin" -fi +# Loader Utility +# +# Specifies the loader to be used with the "make run" targets +# in the KOS examples. Defaults to using a preconfigured version +# of dc-tool. Use one of the other options for a manual dc-tool-ip +# or dc-tool-serial configuration, remembering to change the values +# for the Dreamcast's IP address or the serial port interface. +# +export KOS_LOADER="dc-tool -x" +#export KOS_LOADER="dc-tool-ip -t 192.168.1.100 -x" +#export KOS_LOADER="dc-tool-ser -t /dev/ttyS0 -x" -# reset some options because there's no reason for them to persist across -# multiple sourcing of this +# Default Compiler Flags +# +# Resets build flags. You can also initialize them to some preset +# default values here if you wish. +# export KOS_INC_PATHS="" export KOS_CFLAGS="" export KOS_CPPFLAGS="" @@ -71,32 +109,66 @@ export KOS_LDFLAGS="" export KOS_AFLAGS="" export DC_ARM_LDFLAGS="" -# Setup some default CFLAGS for compilation. The things that will go here -# are user specifyable, like optimization level and whether you want stack -# traces enabled. Some platforms may have optimization restrictions, -# please check README. -# GCC seems to have made -fomit-frame-pointer the default on many targets, so -# hence you may need -fno-omit-frame-pointer to actually have GCC spit out frame -# pointers. It won't hurt to have it in there either way. -# Link-time optimizations can be enabled by adding -flto. It however requires a -# recent toolchain (GCC 10+), and has not been thoroughly tested. -export KOS_CFLAGS="-O2 -fomit-frame-pointer" -# export KOS_CFLAGS="-O2 -DFRAME_POINTERS -fno-omit-frame-pointer" +# Optimization Level +# +# Controls the baseline optimization level to use when building. +# Typically this is -Og (debugging), -O0, -01, -02, or -03. +# NOTE: For our target, -O4 is a valid optimization level that has +# been seen to have some performance impact as well. +# +export KOS_CFLAGS="${KOS_CFLAGS} -O2" + +# Additional Optimizations +# +# Uncomment this to enable what has been found emperically to be +# the optimal set of additional flags for release build performance +# on the current stable toolchain. NOTE: Certain KOS-ports and examples +# do not work properly with "-flto=auto"! +# +#export KOS_CFLAGS="${KOS_CFLAGS} -freorder-blocks-algorithm=simple -flto=auto" + +# Frame Pointers +# +# Controls whether frame pointers are emitted or not. Disabled by +# default. Enable them if you plan to use GDB for debugging. +# +export KOS_CFLAGS="${KOS_CFLAGS} -fomit-frame-pointer" +#export KOS_CFLAGS="${KOS_CFLAGS} -fno-omit-frame-pointer -DFRAME_POINTERS" +# GCC Builtin Functions +# # Comment out this line to enable GCC to use its own builtin implementations of # certain standard library functions. Under certain conditions, this can allow # compiler-optimized implementations to replace standard function invocations. # The downside of this is that it COULD interfere with Newlib or KOS implementations # of these functions, and it has not been tested thoroughly to ensure compatibility. +# export KOS_CFLAGS="${KOS_CFLAGS} -fno-builtin" +# Fast Math Instructions +# # Uncomment this line to enable the optimized fast-math instructions (FSSRA, # FSCA, and FSQRT) for calculating sin/cos, inverse square root, and square roots. # These can result in substantial performance gains for these kinds of operations; # however, they do so at the price of accuracy and are not IEEE compliant. # NOTE: This also requires -fno-builtin be removed from KOS_CFLAGS to take effect! +# # export KOS_CFLAGS="${KOS_CFLAGS} -ffast-math -ffp-contract=fast -mfsrra -mfsca" -# Everything else is pretty much shared. If you want to configure compiler -# options or other such things, look at this file. +# Additional Tools Path +# +# If not already set, add "bin" directory to PATH variable, which is where +# additional tools such as dc-tool-ip and dc-tool-serial are typically +# installed. Comment this out if you don't want this included within your PATH. +# +if [[ ":$PATH:" != *":${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin"* ]]; then + export PATH="${PATH}:${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin" +fi + +# Shared Compiler Configuration +# +# Include sub architecture-independent configuration file for shared +# environment settings. If you want to configure additional compiler +# options or see where other build flags are set, look at this file. +# . ${KOS_BASE}/environ_base.sh diff --git a/include/kos/opts.h b/include/kos/opts.h index 8b27c41..8287c24 100644 --- a/include/kos/opts.h +++ b/include/kos/opts.h @@ -83,6 +83,9 @@ __BEGIN_DECLS malloc, as well as everything in level 2. */ /* #define KOS_DEBUG 3 */ +#ifndef KOS_DEBUG +#define KOS_DEBUG 0 +#endif #if KOS_DEBUG >= 1 #define MALLOC_DEBUG 1 @@ -101,13 +104,19 @@ __BEGIN_DECLS #endif /** \brief The maximum number of cd files that can be open at a time. */ +#ifndef FS_CD_MAX_FILES #define FS_CD_MAX_FILES 8 +#endif /** \brief The maximum number of romdisk files that can be open at a time. */ +#ifndef FS_ROMDISK_MAX_FILES #define FS_ROMDISK_MAX_FILES 16 +#endif /** \brief The maximum number of ramdisk files that can be open at a time. */ +#ifndef FS_RAMDISK_MAX_FILES #define FS_RAMDISK_MAX_FILES 8 +#endif __END_DECLS diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c b/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c index 56c9162..7207581 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_mem.c @@ -58,8 +58,9 @@ static LIST_HEAD(memctl_list, memctl) block_list; /* PVR RAM base; NULL is considered invalid */ static pvr_ptr_t pvr_mem_base = NULL; -#define CHECK_MEM_BASE assert_msg(pvr_mem_base != NULL, \ - "pvr_mem_* used, but PVR hasn't been initialized yet") +#define CHECK_MEM_BASE \ + assert_msg(pvr_mem_base != NULL, \ + "pvr_mem_* used, but PVR hasn't been initialized yet") /* Used in pvr_mem_core.c */ void * pvr_int_sbrk(size_t amt) { @@ -94,7 +95,8 @@ pvr_ptr_t pvr_mem_malloc(size_t size) { rv32 = (uint32)pvr_int_malloc(size); assert_msg((rv32 & 0x1f) == 0, - "dlmalloc's alignment is broken; please make a bug report"); + "dlmalloc's alignment is broken; " + "please make a bug report"); #ifdef PVR_KM_DBG ctl = malloc(sizeof(memctl_t)); @@ -106,7 +108,7 @@ pvr_ptr_t pvr_mem_malloc(size_t size) { #endif /* PVR_KM_DBG */ #ifdef PVR_KM_DBG_VERBOSE - printf("Thread %d/%08lx allocated %d bytes at %08lx\n", + printf("Thread %d/%08lx allocated %lu bytes at %08lx\n", ctl->thread, ctl->addr, ctl->size, rv32); #endif @@ -141,7 +143,9 @@ void pvr_mem_free(pvr_ptr_t chunk) { } if(!found) { - dbglog(DBG_ERROR, "pvr_mem_free: trying to free non-alloc'd block %08lx (called from %d/%08lx\n", + dbglog(DBG_ERROR, + "pvr_mem_free: trying to free non-alloc'd block " + "%08lx (called from %d/%08lx\n", (uint32)chunk, thd_current->tid, ra); } @@ -157,8 +161,10 @@ void pvr_mem_print_list(void) { printf("pvr_mem_print_list block list:\n"); LIST_FOREACH(ctl, &block_list, list) { - printf(" unfreed block at %08lx size %d, allocated by thread %d/%08lx\n", - ctl->block, ctl->size, ctl->thread, ctl->addr); + printf(" unfreed block at %08lx size %lu, " + "allocated by thread %d/%08lx\n", + (unsigned long)ctl->block, ctl->size, + ctl->thread, (unsigned long)ctl->addr); } printf("pvr_mem_print_list end block list\n"); #endif /* PVR_KM_DBG */ @@ -175,7 +181,8 @@ static uint32 pvr_mem_available_int(void) { uint32 pvr_mem_available(void) { CHECK_MEM_BASE; - return pvr_mem_available_int() + (PVR_RAM_INT_TOP - (uint32)pvr_mem_base); + return pvr_mem_available_int() + + (PVR_RAM_INT_TOP - (uint32)pvr_mem_base); } /* Reset the memory pool, equivalent to freeing all textures currently diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c b/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c index fcc449b..6859b09 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_mem_core.c @@ -1333,7 +1333,7 @@ static void do_check_malloc_state(void) { max_fast_bin = fastbin_index(av->max_fast); - for(i = 0; i < NFASTBINS; ++i) { + for(i = 0; i < (int)NFASTBINS; ++i) { p = av->fastbins[i]; /* all bins past max_fast are empty */ @@ -1345,7 +1345,7 @@ static void do_check_malloc_state(void) { do_check_inuse_chunk(p); total += chunksize(p); /* chunk belongs in this bin */ - assert(fastbin_index(chunksize(p)) == i); + assert(fastbin_index(chunksize(p)) == (unsigned)i); p = p->fd; } } @@ -1379,7 +1379,7 @@ static void do_check_malloc_state(void) { if(i >= 2) { /* chunk belongs in bin */ idx = bin_index(size); - assert(idx == i); + assert(idx == (unsigned)i); /* lists are sorted */ assert(p->bk == b || (unsigned long)chunksize(p->bk) >= (unsigned long)chunksize(p)); diff --git a/kernel/libc/koslib/malloc.c b/kernel/libc/koslib/malloc.c index c4e1f15..7ed6233 100644 --- a/kernel/libc/koslib/malloc.c +++ b/kernel/libc/koslib/malloc.c @@ -1719,7 +1719,7 @@ Void_t* public_mALLOc(size_t bytes) { m = (void *)(nt1 + BUFFER_SIZE / 4); #ifdef KM_DBG_VERBOSE - printf("Thread %d/%08lx allocated %d bytes at %08lx\n", + printf("Thread %d/%08lx allocated %lu bytes at %08lx\n", ctl->thread, ctl->addr, ctl->size, (uint32)m); #endif @@ -2070,7 +2070,7 @@ Void_t* public_mEMALIGn(size_t alignment, size_t bytes) { assert(!((uint32)m % alignment)); #ifdef KM_DBG_VERBOSE - printf("Thread %d/%08lx memalign allocated %d bytes at %08lx\n", + printf("Thread %d/%08lx memalign allocated %lu bytes at %08lx\n", ctl->thread, ctl->addr, ctl->size, (uint32)m); #endif @@ -2145,7 +2145,7 @@ Void_t* public_cALLOc(size_t n, size_t elem_size) { memset(m, 0, bytes); #ifdef KM_DBG_VERBOSE - printf("Thread %d/%08lx calloc allocated %d bytes at %08lx\n", + printf("Thread %d/%08lx calloc allocated %lu bytes at %08lx\n", ctl->thread, ctl->addr, ctl->size, (uint32)m); #endif hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-07 16:22:56
|
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 cc16fee4d4ebbe969a65bf3cc220deeb924de8f2 (commit) from eb1376e3e9c270c3bb893322d7aff95fdd48cfb6 (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 cc16fee4d4ebbe969a65bf3cc220deeb924de8f2 Author: Andress Barajas <and...@gm...> Date: Thu Sep 7 07:28:04 2023 -0700 Fix wav2adpcm (#296) * Can now handle meta data ----------------------------------------------------------------------- Summary of changes: utils/wav2adpcm/wav2adpcm.c | 94 +++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/utils/wav2adpcm/wav2adpcm.c b/utils/wav2adpcm/wav2adpcm.c index 2b8c671..2b4252d 100644 --- a/utils/wav2adpcm/wav2adpcm.c +++ b/utils/wav2adpcm/wav2adpcm.c @@ -165,7 +165,7 @@ void interleave(void *buffer, size_t size) { free(buf); } -struct wavhdr_t { +typedef struct wavhdr_t { char hdr1[4]; int32_t totalsize; @@ -180,10 +180,66 @@ struct wavhdr_t { char hdr3[4]; int32_t datasize; -}; +} wavhdr_t; + +int validate_wav_header(wavhdr_t *wavhdr, int format, int bits, FILE *in) { + int result = 0; + + if(memcmp(wavhdr->hdr1, "RIFF", 4)) { + printf("Invalid RIFF header.\n"); + result = -1; + } + + if(memcmp(wavhdr->hdr2, "WAVEfmt ", 8)) { + printf("Invalid WAVEfmt header.\n"); + result = -1; + } + + if(wavhdr->hdrsize != 0x10) { + printf("Invalid header size.\n"); + result = -1; + } + + if(wavhdr->format != format) { + printf("Unsupported format.\n"); + result = -1; + } + + if(wavhdr->channels != 1 && wavhdr->channels != 2) { + printf("Unsupported number of channels.\n"); + result = -1; + } + + if(wavhdr->bits != bits) { + printf("Unsupported bit depth.\n"); + result = -1; + } + + if(memcmp(wavhdr->hdr3, "data", 4)) + { + /* File contains meta data that we want to skip. + Keep reading until we find the "data" header. */ + fseek(in, wavhdr->datasize, SEEK_CUR); + + do + { + /* Read the next chunk header */ + fread(wavhdr->hdr3, 1, 4, in); + + /* Read the chunk size */ + fread(&wavhdr->datasize, 1, 4, in); + + /* Skip the chunk if it's not the "data" chunk. */ + if(memcmp(wavhdr->hdr3, "data", 4)) + fseek(in, wavhdr->datasize, SEEK_CUR); + } while(memcmp(wavhdr->hdr3, "data", 4)); + } + + return result; +} int wav2adpcm(const char *infile, const char *outfile) { - struct wavhdr_t wavhdr; + wavhdr_t wavhdr; FILE *in, *out; size_t pcmsize, adpcmsize; short *pcmbuf; @@ -202,14 +258,7 @@ int wav2adpcm(const char *infile, const char *outfile) { return -1; } - if(memcmp(wavhdr.hdr1, "RIFF", 4) - || memcmp(wavhdr.hdr2, "WAVEfmt ", 8) - || memcmp(wavhdr.hdr3, "data", 4) - || wavhdr.hdrsize != 0x10 - || wavhdr.format != 1 - || (wavhdr.channels != 1 && wavhdr.channels != 2) - || wavhdr.bits != 16) { - fprintf(stderr, "Unsupported format.\n"); + if(validate_wav_header(&wavhdr, 1, 16, in)) { fclose(in); return -1; } @@ -244,8 +293,8 @@ int wav2adpcm(const char *infile, const char *outfile) { wavhdr.totalsize = wavhdr.datasize + sizeof(wavhdr) - 8; out = fopen(outfile, "wb"); - if(fwrite(&wavhdr, sizeof(wavhdr), 1, out) != 1 - || fwrite(adpcmbuf, adpcmsize, 1, out) != 1) { + if(fwrite(&wavhdr, sizeof(wavhdr), 1, out) != 1 || + fwrite(adpcmbuf, adpcmsize, 1, out) != 1) { fprintf(stderr, "Cannot write ADPCM data.\n"); fclose(out); return -1; @@ -256,7 +305,7 @@ int wav2adpcm(const char *infile, const char *outfile) { } int adpcm2wav(const char *infile, const char *outfile) { - struct wavhdr_t wavhdr; + wavhdr_t wavhdr; FILE *in, *out; size_t pcmsize, adpcmsize; short *pcmbuf; @@ -275,14 +324,7 @@ int adpcm2wav(const char *infile, const char *outfile) { return -1; } - if(memcmp(wavhdr.hdr1, "RIFF", 4) - || memcmp(wavhdr.hdr2, "WAVEfmt ", 8) - || memcmp(wavhdr.hdr3, "data", 4) - || wavhdr.hdrsize != 0x10 - || wavhdr.format != 20 - || (wavhdr.channels != 1 && wavhdr.channels != 2) - || wavhdr.bits != 4) { - fprintf(stderr, "Unsupported format.\n"); + if(validate_wav_header(&wavhdr, 20, 4, in)) { fclose(in); return -1; } @@ -316,8 +358,8 @@ int adpcm2wav(const char *infile, const char *outfile) { wavhdr.bits = 16; out = fopen(outfile, "wb"); - if(fwrite(&wavhdr, sizeof(wavhdr), 1, out) != 1 - || fwrite(pcmbuf, pcmsize, 1, out) != 1) { + if(fwrite(&wavhdr, sizeof(wavhdr), 1, out) != 1 || + fwrite(pcmbuf, pcmsize, 1, out) != 1) { fprintf(stderr, "Cannot write WAV data.\n"); fclose(out); return -1; @@ -332,6 +374,10 @@ void usage() { printf("wav2adpcm: 16bit mono wav to aica adpcm and vice-versa (c)2002 BERO\n" " wav2adpcm -t <infile.wav> <outfile.wav> (To adpcm)\n" " wav2adpcm -f <infile.wav> <outfile.wav> (From adpcm)\n" + "\n" + "If you are having trouble with your input wav file you can run it" + "through ffmpeg first and then run wav2adpcm on output.wav:\n" + " ffmpeg -i input.wav -ac 1 -acodec pcm_s16le output.wav" ); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-09-05 13:45:29
|
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 eb1376e3e9c270c3bb893322d7aff95fdd48cfb6 (commit) via ddb904d814e2bafab974847d9df5facf3c4db2aa (commit) via c3a61fe6f59dcbf2c3af7e8ff7bd7d5fdf01dae7 (commit) from c456ff0960fd19306241ecb8dab30148afb1f592 (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 eb1376e3e9c270c3bb893322d7aff95fdd48cfb6 Author: darcagn <da...@pr...> Date: Tue Sep 5 08:33:34 2023 -0500 Fix vmu_set_icon_shape omitted on DC instead of NAOMI (#293) commit ddb904d814e2bafab974847d9df5facf3c4db2aa Merge: c456ff0 c3a61fe Author: Luke Benstead <ka...@gm...> Date: Sun Sep 3 09:44:27 2023 +0100 Merge pull request #291 from KallistiOS/kazade_authors_update Kazade's Authorship Update (2022 + 2023 Edition) commit c3a61fe6f59dcbf2c3af7e8ff7bd7d5fdf01dae7 Author: Falco Girgis <gyr...@gm...> Date: Sun Sep 3 00:28:26 2023 -0500 Kazade's authorship should include 2022 and 2023 - Just realized it hasn't been updated in awhile, and checked to see that he most definitely does have KOS repo commits for 2022 and 2023. ----------------------------------------------------------------------- Summary of changes: AUTHORS | 2 +- kernel/arch/dreamcast/hardware/maple/vmu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index d4fc8fc..8e8923d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -41,7 +41,7 @@ Brian Paul: 1999, 2000, 2001 Josh Pearson: 2013, 2014, 2015, 2016 Joe Fenton: 2016 Stefan Galowicz: 2016, 2017 -Luke Benstead: 2020, 2021 +Luke Benstead: 2020, 2021, 2022, 2023 Eric Fradella: 2023 Falco Girgis: 2023 Ruslan Rostovtsev: 2014, 2016, 2023 diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c index 6abdb59..784d050 100644 --- a/kernel/arch/dreamcast/hardware/maple/vmu.c +++ b/kernel/arch/dreamcast/hardware/maple/vmu.c @@ -210,7 +210,7 @@ int vmu_set_custom_color(maple_device_t *dev, uint8_t red, uint8_t green, uint8_ for icon_shape are listed in the biosfont.h and start with BFONT_ICON_VMUICON. */ int vmu_set_icon_shape(maple_device_t *dev, uint8_t icon_shape) { -#ifdef _arch_sub_naomi +#ifndef _arch_sub_naomi vmu_root_t root; if(icon_shape < BFONT_ICON_VMUICON || icon_shape > BFONT_ICON_EMBROIDERY) hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-05 02:10: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 serial program loader for the Dreamcast.". The branch, master has been updated via da35b5992eda1330497aec78192bdd0400c239f9 (commit) from a588add704d8d271b4c729043d829733db139aa9 (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 da35b5992eda1330497aec78192bdd0400c239f9 Author: Tchan0 <617...@us...> Date: Mon Sep 4 22:21:16 2023 +0200 Add termios2 for linux, explain SH-4 custom baudrates in README (#21) * Addition of termios2, allowing custom baudrates on Linux systems. Adaptation of README to soften the recommendation for FTDI chips, and talke about the SH-4 specific baudrates. Signed-off-by: T_chan <t_c...@ho...> * Update dc-tool.c fix identation * Reverting the MacOS part of the README Reverting the MacOS part of the README, since MacOS does not support custom baudrates after all, against our assumptions. Doesn't affect the rest of the Merge Request, as that only modifies behavior on Linux systems. --------- Signed-off-by: T_chan <t_c...@ho...> ----------------------------------------------------------------------- Summary of changes: README.md | 20 +++++++-------- host-src/tool/dc-tool.c | 68 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 82e0c32..d458a42 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ Dreamcast in order to run and debug them. To be used, you must have a way to connect your Dreamcast console to your computer, it can be one of the following: * A **Coders Cable** (a serial cable, the historical way to do that). It can be - a cable with the classical `RS-232`/`DE-9` connector or with the - `FT232RL USB-Serial` module. + a cable with the classical `RS-232`/`DE-9` connector or with a + `USB-Serial` module. * A **Broadband Adapter**, ref. `HIT-400`, often shortened as **BBA**, a `10/100Mbits` Ethernet network card. * A **LAN Adapter**, ref. `HIT-300`, a `10Mbits` Ethernet network card. @@ -95,20 +95,20 @@ To run a GNU debugger session over the **dcload** connection: * Tested systems: Debian GNU/Linux 2.2; Gentoo/Linux 2.6.7; Cygwin; Mac OSX 10.3.5 (Panther); macOS 10.15.2 (Catalina), MinGW/MSYS, [DreamSDK](https://www.dreamsdk.org), MinGW-w64/MSYS2. -* `1.56M` and `500K` baud now supported with the **FTDI USB-Serial** driver, - including the driver built into macOS 10.12 and above. - **Note:** Works with the cheap and commonly available **FT232RL USB-Serial** - boards as well as the (outdated) **FT232BM USB-Serial** chip running at - `6.144Mhz`, e.g.: - - Linux: `dc-tool-ser -t /dev/usb/tts/0 -b 1500000 -x <sh-executable>` - - Windows: `dc-tool-ser -t COM4 -b 500000 -x <sh-executable>` - - macOS: `dc-tool-ser -t /dev/cu.usbserial-A50285BI -b 1500000 -x <sh-executable>` +* To attain the highest speeds with `dcload-serial`, you need to select a `USB-Serial` module that matches the baudrates that the Dreamcast's SH-4 cpu can generate. Above `115200`, the SH-4 cpu generates the following baudrates: `223214`, `260416`, `312500`, `390625`, `520833`, `781250`, `1562500`. + * **Silicon Labs CP2102N**-based chips have a good match with the SH-4, so you're pretty much guaranteed to attain the highest speed, `1562500`. + * **FTDI FT232***-based chips do no match the SH-4 baudrates closely enough, so `781250` will work, but `1.56M` will depend on your specific chip (ie, chip luck) +* Examples of how to launch a program: + * Linux: `dc-tool-ser -t /dev/usb/tts/0 -b 1500000 -x <sh-executable>` + * Windows: `dc-tool-ser -t COM4 -b 500000 -x <sh-executable>` + * macOS: `dc-tool-ser -t /dev/cu.usbserial-A50285BI -b 1500000 -x <sh-executable>` * As of `1.0.4`, little-endian byte order is enforced in the host so dc-tool now runs on big-endian systems like a Mac. * As of `1.0.3`, serial speed is changed at runtime rather than compile time. * `115200` works fine in most cases but `57600` baud is the standard baud. There is an `-e` option that will enable an alternate `115200` which may work better in some rare cases. Use this only if the regular `115200` is unstable. +* `234000` will probably only work with the `-e` option enabled. * Patches and improvements are welcome. ## Modern macOS Notes diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index f27e72b..2f6c416 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -33,11 +33,18 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> + #ifdef _WIN32 #include <windows.h> #else +#ifdef __linux__ +#include <asm/termbits.h> +#include <sys/ioctl.h> +#else #include <termios.h> #endif +#endif + #include <sys/time.h> #include <unistd.h> #include <utime.h> @@ -220,7 +227,12 @@ int getopt(int nargc, char * const *nargv, const char *ostr) { extern char *optarg; #ifndef _WIN32 int dcfd; -struct termios oldtio; +#ifdef BOTHER +typedef struct termios2 termiosx_t ; +#else +typedef struct termios termiosx_t; +#endif +termiosx_t oldtio; #else HANDLE hCommPort; BOOL bDebugSocketStarted = FALSE; @@ -517,6 +529,9 @@ void get_supported_speed (unsigned int *speed, speed_t *baudconst){ speed_t tmpbaud; unsigned int tmpspeed = *speed; +#ifdef BOTHER + *baudconst = BOTHER; //with BOTHER, any custom speed can be chosen +#else for (tmpbaud = B0; tmpbaud == B0;) { switch(tmpspeed) { #ifdef B1500000 @@ -560,12 +575,37 @@ void get_supported_speed (unsigned int *speed, speed_t *baudconst){ } *baudconst = tmpbaud; *speed = tmpspeed; +#endif +} + +void tc_close (int fd) { +#ifndef BOTHER + tcflush(fd, TCIOFLUSH); +#endif + close(fd); +} + +int tc_get_attr(int fd, termiosx_t *tio) { +#ifdef BOTHER + return ioctl(dcfd, TCGETS2, tio); +#else + return tcgetattr(dcfd, tio); +#endif +} + +int tc_set_attr (int fd, termiosx_t *tio) { +#ifdef BOTHER + return ioctl(fd, TCSETS2, tio); +#else + tcflush(fd, TCIOFLUSH); + return tcsetattr(fd, TCSANOW, tio); +#endif } void set_io_speed (unsigned int speed, speed_t baudconst) { - struct termios newtio; + termiosx_t newtio; - tcgetattr(dcfd, &oldtio); // save current serial port settings + tc_get_attr(dcfd, &oldtio); // save current serial port settings memset(&newtio, 0, sizeof(newtio)); // clear struct for new port settings newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD; @@ -575,16 +615,18 @@ void set_io_speed (unsigned int speed, speed_t baudconst) { newtio.c_cc[VTIME] = 0; // inter-character timer unused newtio.c_cc[VMIN] = 1; // blocking read until 1 character arrives +#ifdef BOTHER + newtio.c_cflag |= BOTHER; + newtio.c_ospeed = speed; + newtio.c_cflag |= BOTHER << IBSHIFT; + newtio.c_ispeed = speed; +#else cfsetispeed(&newtio, baudconst); cfsetospeed(&newtio, baudconst); +#endif - // we don't error on these because it *may* still work - if(tcflush(dcfd, TCIFLUSH) < 0) { - perror("tcflush"); - } - - if(tcsetattr(dcfd, TCSANOW, &newtio) < 0) { - perror("tcsetattr"); + if(tc_set_attr(dcfd, &newtio) < 0) { + perror("tc_set_attr"); printf("warning: your baud rate is likely set incorrectly\n"); } @@ -672,8 +714,7 @@ void finish_serial(void) { #ifdef _WIN32 FlushFileBuffers(hCommPort); #else - tcflush(dcfd, TCIOFLUSH); - tcsetattr(dcfd, TCSANOW, &oldtio); + tc_set_attr(dcfd, &oldtio); #endif cleanup(); } @@ -684,8 +725,7 @@ void close_serial(void) { FlushFileBuffers(hCommPort); CloseHandle(hCommPort); #else - tcflush(dcfd, TCIOFLUSH); - close(dcfd); + tc_close(dcfd); #endif } hooks/post-receive -- A serial program loader for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-03 02:03:24
|
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 c456ff0960fd19306241ecb8dab30148afb1f592 (commit) via 00bfacfb7b083e41cccabe553d695e516d94b716 (commit) from 44b00171ed98a48dce83a640af9eae66e5fe7454 (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 c456ff0960fd19306241ecb8dab30148afb1f592 Merge: 44b0017 00bfacf Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 2 22:03:06 2023 -0400 Merge pull request #286 from KallistiOS/kos_cmake Added KOS wrapper bash script for cmake commit 00bfacfb7b083e41cccabe553d695e516d94b716 Author: Falco Girgis <gyr...@gm...> Date: Fri Sep 1 08:18:51 2023 -0500 Added KOS wrapper bash script for cmake - Based on what the PSP SDK does, we simply automatically select the DC toolchain file for the user, using their KOS_BASE path - Needed to modify the message() output from dreamcast.toolchain.cmake to be VERBOSE level, because it was spamming regular configuration output ----------------------------------------------------------------------- Summary of changes: utils/cmake/dreamcast.toolchain.cmake | 8 ++++---- utils/gnu_wrappers/kos-cmake | 13 +++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100755 utils/gnu_wrappers/kos-cmake diff --git a/utils/cmake/dreamcast.toolchain.cmake b/utils/cmake/dreamcast.toolchain.cmake index c3dd71f..e4ee358 100644 --- a/utils/cmake/dreamcast.toolchain.cmake +++ b/utils/cmake/dreamcast.toolchain.cmake @@ -24,7 +24,7 @@ if(NOT DEFINED KOS_BASE) message(FATAL_ERROR "Variable KOS_BASE not set and was not found in the environment") endif() set(KOS_BASE $ENV{KOS_BASE}) - message("KOS_BASE: ${KOS_BASE}") + message(VERBOSE "KOS_BASE: ${KOS_BASE}") endif() if(NOT DEFINED KOS_CC_BASE) @@ -32,7 +32,7 @@ if(NOT DEFINED KOS_CC_BASE) message(FATAL_ERROR "Variable KOS_CC_BASE not set and was not found in the environment") endif() set(KOS_CC_BASE $ENV{KOS_CC_BASE}) - message("KOS_CC_BASE: ${KOS_CC_BASE}") + message(VERBOSE "KOS_CC_BASE: ${KOS_CC_BASE}") endif() if(NOT DEFINED KOS_SUBARCH) @@ -40,7 +40,7 @@ if(NOT DEFINED KOS_SUBARCH) message(FATAL_ERROR "Variable KOS_SUBARCH not set and was not found in the environment") endif() set(KOS_SUBARCH $ENV{KOS_SUBARCH}) - message("KOS_SUBARCH: ${KOS_SUBARCH}") + message(VERBOSE "KOS_SUBARCH: ${KOS_SUBARCH}") endif() if(NOT DEFINED KOS_PORTS) @@ -48,7 +48,7 @@ if(NOT DEFINED KOS_PORTS) message(FATAL_ERROR "Variable KOS_PORTS not set and was not found in the environment") endif() set(KOS_PORTS $ENV{KOS_PORTS}) - message("KOS_PORTS: ${KOS_PORTS}") + message(VERBOSE "KOS_PORTS: ${KOS_PORTS}") endif() ##### Configure CMake System ##### diff --git a/utils/gnu_wrappers/kos-cmake b/utils/gnu_wrappers/kos-cmake new file mode 100755 index 0000000..120174a --- /dev/null +++ b/utils/gnu_wrappers/kos-cmake @@ -0,0 +1,13 @@ +#!/bin/bash + +## Make sure KOS_BASE is set +if [ -z "${KOS_BASE}" ]; then + echo "The KOS_BASE environment variable has not been set!" + echo "\tDid you source your environ.sh file?" + exit 1 +fi + +cmake \ + -DCMAKE_TOOLCHAIN_FILE="${KOS_BASE}/utils/cmake/dreamcast.toolchain.cmake" \ + "$@" + hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-03 02:01:42
|
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 44b00171ed98a48dce83a640af9eae66e5fe7454 (commit) via dd6971aeb1e58be17bba560474c1cc8ee8734b42 (commit) from 7b0304a5462a93cdbb247b05d5652fe8cf65d290 (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 44b00171ed98a48dce83a640af9eae66e5fe7454 Merge: 7b0304a dd6971a Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 2 22:01:02 2023 -0400 Merge pull request #289 from snickerbockers/master bba: don't shut it down if it hasnt been initialized commit dd6971aeb1e58be17bba560474c1cc8ee8734b42 Author: snickerbockers <sni...@wa...> Date: Sat Sep 2 20:46:24 2023 -0400 bba: don't shut it down if it hasnt been initialized KOS crashes during shutdown if there isn't a BBA plugged in because bba_if.if_stop and bba_if.if_shutdown will both be NULL. This is a problem if you don't have one plugged in and you're trying to debug using dcload-serial because it will reboot the dreamcast instead of returning to the bootloader. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/network/broadband_adapter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c index 0347231..6cc387a 100644 --- a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c +++ b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c @@ -1310,8 +1310,10 @@ int bba_init(void) { /* Shutdown */ int bba_shutdown(void) { /* Shutdown hardware */ - bba_if.if_stop(&bba_if); - bba_if.if_shutdown(&bba_if); + if(bba_if.flags & NETIF_RUNNING) + bba_if.if_stop(&bba_if); + if(bba_if.flags & NETIF_INITIALIZED) + bba_if.if_shutdown(&bba_if); #ifdef TX_SEMA sem_destroy(&tx_sema); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-02 20:40:20
|
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 "UNNAMED PROJECT". The branch, master has been updated via 9771d16b0a91c7b1745ef61e792197eac70ef541 (commit) via 875f6a6ba3a698bb6a7b17bb757e5fb403cdf2ca (commit) from 2d197a40eb0844df1c19a472bc6b039d2a98f09d (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 9771d16b0a91c7b1745ef61e792197eac70ef541 Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 2 16:39:43 2023 -0400 Update copyright notices. commit 875f6a6ba3a698bb6a7b17bb757e5fb403cdf2ca Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 2 16:39:18 2023 -0400 Update Makefile for building outside kos-ports. ----------------------------------------------------------------------- Summary of changes: Makefile | 18 ++++++------------ doc/readme.txt | 7 +++---- include/animation.h | 9 ++++----- include/anims/alphafader.h | 2 +- include/anims/expxymover.h | 2 +- include/anims/logxymover.h | 2 +- include/anims/tintfader.h | 2 +- include/color.h | 7 +++---- include/color3.h | 7 +++---- include/drawable.h | 3 +-- include/drawables/banner.h | 5 ++--- include/drawables/label.h | 5 ++--- include/drawables/scene.h | 7 +++---- include/font.h | 11 +++++------ include/genmenu.h | 9 ++++----- include/list.h | 10 +++++----- include/matrix.h | 7 +++---- include/matrixdouble.h | 7 +++---- include/refcnt.h | 7 +++---- include/sound.h | 6 +++--- include/texture.h | 8 ++++---- include/trigger.h | 7 +++---- include/triggers/birth.h | 7 +++---- include/triggers/chainanim.h | 7 +++---- include/triggers/death.h | 7 +++---- include/triggers/oneshot.h | 7 +++---- include/vector.h | 7 +++---- include/vector3.h | 7 +++---- include/vectordouble.h | 7 +++---- src/animation.cpp | 2 +- src/anims/alphafader.cpp | 2 +- src/anims/expxymover.cpp | 2 +- src/anims/logxymover.cpp | 2 +- src/anims/tintfader.cpp | 2 +- src/drawable.cpp | 2 +- src/drawables/banner.cpp | 2 +- src/drawables/label.cpp | 2 +- src/font.cpp | 2 +- src/genmenu.cpp | 2 +- src/matrix.cpp | 4 ++-- src/matrixdouble.cpp | 4 ++-- src/sound.cpp | 2 +- src/texture.cpp | 2 +- src/trigger.cpp | 2 +- src/triggers/birth.cpp | 2 +- src/triggers/death.cpp | 2 +- src/vector.cpp | 2 +- src/vector3.cpp | 2 +- src/vectordouble.cpp | 2 +- 49 files changed, 107 insertions(+), 134 deletions(-) diff --git a/Makefile b/Makefile index d5489a4..4156267 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,16 @@ # Tsunami for KallistiOS ##version## # # Makefile -# (c)2002 Dan Potter +# Copyright (C) 2002 Megan Potter -TARGET := libtsunami.a +TARGET := libtsunami.a +KOS_CFLAGS += -Iinclude # Main sources -OBJS_MAIN := $(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) +OBJS_MAIN := $(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) # Drawables -OBJS_DRW := $(patsubst %.cpp,%.o,$(wildcard src/drawables/*.cpp)) +OBJS_DRW := $(patsubst %.cpp,%.o,$(wildcard src/drawables/*.cpp)) # Animations OBJS_ANIMS := $(patsubst %.cpp,%.o,$(wildcard src/anims/*.cpp)) @@ -17,14 +18,7 @@ OBJS_ANIMS := $(patsubst %.cpp,%.o,$(wildcard src/anims/*.cpp)) # Triggers OBJS_TRIGS := $(patsubst %.cpp,%.o,$(wildcard src/triggers/*.cpp)) -OBJS := $(OBJS_MAIN) $(OBJS_DRW) $(OBJS_ANIMS) $(OBJS_TRIGS) - -defaultall: create_kos_link $(OBJS) subdirs linklib - -# creates the kos link to the headers -create_kos_link: - rm -f ../include/tsu - ln -s ../libtsunami/include ../include/tsu +OBJS := $(OBJS_MAIN) $(OBJS_DRW) $(OBJS_ANIMS) $(OBJS_TRIGS) # Grab the shared Makefile pieces include $(KOS_BASE)/addons/Makefile.prefab diff --git a/doc/readme.txt b/doc/readme.txt index 36488ec..6d55e23 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,5 +1,5 @@ Tsunami for KOS ##version## -(c)2002 Dan Potter +Copyright (C) 2002 Megan Potter What is it? @@ -18,7 +18,7 @@ itself". Tsunami provides a high level way to describe what a scene looks like, and then you simply call into it to have it manage everything each frame. Each scene is composed of one or more "drawables" (one of which is the whole scene -container). Each of these drawables has a screen position and other +container). Each of these drawables has a screen position and other attributes that describe its state. Additionally, each drawable can contain sub-drawables which can be positioned, rotated, etc, relative to its parents. Furthermore, each drawable knows how to draw itself in position @@ -41,7 +41,7 @@ of the object to some new value. Of course, all of these can be done at once and in tandem with the object's intrinsic animation(s), if any. Triggers provide a simple mechanism to have a multi-legged animation. The -current trigger mechanism allows for you to do things like switch out an +current trigger mechanism allows for you to do things like switch out an animation or signal that a drawable is dead in the scene upon the completion of another animation, but I'm also planning to add triggers based on time and other events (like controller inputs). @@ -58,4 +58,3 @@ with the reference counted objects pervasively, dodging the bullet that things like CComPtr setup in the MS world (i.e. mixing of raw pointers and auto_ptrs, causing the programmer to have to defacto manually reference count anyway). - diff --git a/include/animation.h b/include/animation.h index 4cad42f..6523759 100644 --- a/include/animation.h +++ b/include/animation.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + animation.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -33,7 +33,7 @@ public: // Move to the next frame of animation virtual void nextFrame(Drawable *t); -protected: +protected: /// Trigger any triggers virtual void trigger(Drawable *d); @@ -45,4 +45,3 @@ private: }; #endif /* __TSUNAMI_ANIMATION_H */ - diff --git a/include/anims/alphafader.h b/include/anims/alphafader.h index fa4bd5b..703474b 100644 --- a/include/anims/alphafader.h +++ b/include/anims/alphafader.h @@ -3,7 +3,7 @@ alphafader.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ diff --git a/include/anims/expxymover.h b/include/anims/expxymover.h index 277371d..aabf8c5 100644 --- a/include/anims/expxymover.h +++ b/include/anims/expxymover.h @@ -3,7 +3,7 @@ expxymover.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ diff --git a/include/anims/logxymover.h b/include/anims/logxymover.h index 7d2a15a..dce45ad 100644 --- a/include/anims/logxymover.h +++ b/include/anims/logxymover.h @@ -3,7 +3,7 @@ logxymover.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ diff --git a/include/anims/tintfader.h b/include/anims/tintfader.h index 0a241d5..1202515 100644 --- a/include/anims/tintfader.h +++ b/include/anims/tintfader.h @@ -3,7 +3,7 @@ tintfader.h - Copyright (C)2003 Dan Potter + Copyright (C) 2003 Megan Potter */ diff --git a/include/color.h b/include/color.h index 4bd6c96..d82a51b 100644 --- a/include/color.h +++ b/include/color.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + color.h - Copyright (C)2003 Dan Potter + Copyright (C) 2003 Megan Potter */ @@ -81,4 +81,3 @@ struct Color { }; #endif /* __TSUNAMI_COLOR_H */ - diff --git a/include/color3.h b/include/color3.h index 3a8281f..5e369c5 100644 --- a/include/color3.h +++ b/include/color3.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + color3.h - Copyright (C)2003,2004 Dan Potter + Copyright (C) 2003, 2004 Megan Potter */ @@ -56,4 +56,3 @@ struct Color3 { }; #endif /* __TSUNAMI_COLOR3_H */ - diff --git a/include/drawable.h b/include/drawable.h index 468dcc6..be71c3c 100644 --- a/include/drawable.h +++ b/include/drawable.h @@ -3,7 +3,7 @@ drawable.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -137,4 +137,3 @@ private: }; #endif /* __TSUNAMI_DRAWABLE_H */ - diff --git a/include/drawables/banner.h b/include/drawables/banner.h index df5d61c..20277ea 100644 --- a/include/drawables/banner.h +++ b/include/drawables/banner.h @@ -1,9 +1,9 @@ /* Tsunami for KallistiOS ##version## - + banner.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -43,4 +43,3 @@ private: }; #endif /* __TSUNAMI_DRW_BANNER_H */ - diff --git a/include/drawables/label.h b/include/drawables/label.h index 26a2051..4444dd5 100644 --- a/include/drawables/label.h +++ b/include/drawables/label.h @@ -1,9 +1,9 @@ /* Tsunami for KallistiOS ##version## - + label.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -32,4 +32,3 @@ private: }; #endif /* __TSUNAMI_DRW_LABEL_H */ - diff --git a/include/drawables/scene.h b/include/drawables/scene.h index 7d5dcab..dd9c5aa 100644 --- a/include/drawables/scene.h +++ b/include/drawables/scene.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + scene.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -30,4 +30,3 @@ public: }; #endif /* __TSUNAMI_DRW_SCENE_H */ - diff --git a/include/font.h b/include/font.h index d798945..a5b5ba3 100644 --- a/include/font.h +++ b/include/font.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + font.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -22,7 +22,7 @@ public: bool loadFromFile(const char * fn); void setFilter(int type); - + void setColor(float r, float g, float b); void setAlpha(float a); void setSize(float size); @@ -37,7 +37,7 @@ public: void drawCharSetPos(const Vector &v); float drawChar(int ch); void drawCharEnd(); - + void getCharExtents(int c, float * l, float * u, float * r, float * d); void getTextSize(const char *text, float * w, float * h); void upperleftCoords(const char * text, float *x, float *y); @@ -55,4 +55,3 @@ private: }; #endif /* __FONTHELPER_H */ - diff --git a/include/genmenu.h b/include/genmenu.h index 9163285..4d32b87 100644 --- a/include/genmenu.h +++ b/include/genmenu.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + genmenu.h - Copyright (C)2003 Dan Potter + Copyright (C) 2003 Megan Potter */ #ifndef __TSUNAMI_GENMENU_H @@ -79,7 +79,7 @@ public: // Set a post-doMenu delay in case sounds may still be playing void setPostDelay(int ms); - + protected: // Called once per frame to update the screen. Generally no need // to override this method. @@ -171,4 +171,3 @@ protected: }; #endif /* __GENMENU_H */ - diff --git a/include/list.h b/include/list.h index 4b54a12..b9a9281 100644 --- a/include/list.h +++ b/include/list.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## list.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -96,7 +96,7 @@ public: List() { TAILQ_INIT(&m_list); } - + virtual ~List() { delAll(); } @@ -119,7 +119,7 @@ public: /// reference will be removed if it is found. bool del(T * item) { ListNode<T> * n; - + TAILQ_FOREACH(n, &m_list, m_listptr) { if (n->getData() == item) { n->remove(); @@ -155,7 +155,7 @@ public: private: friend class ListNode<T>; - + TAILQ_HEAD(listnodehead, ListNode<T>) m_list; public: diff --git a/include/matrix.h b/include/matrix.h index e163746..d09cddc 100644 --- a/include/matrix.h +++ b/include/matrix.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + matrix.h - Copyright (C)2003 Dan Potter + Copyright (C) 2003 Megan Potter */ @@ -80,4 +80,3 @@ public: }; #endif /* __TSUNAMI_MATRIX_H */ - diff --git a/include/matrixdouble.h b/include/matrixdouble.h index 180ab61..d7b4d68 100644 --- a/include/matrixdouble.h +++ b/include/matrixdouble.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + matrixdouble.h - Copyright (C)2003,2004 Dan Potter + Copyright (C) 2003, 2004 Megan Potter */ @@ -80,4 +80,3 @@ public: }; #endif /* __TSUNAMI_MATRIXDOUBLE_H */ - diff --git a/include/refcnt.h b/include/refcnt.h index bd0f11b..0b6bf0f 100644 --- a/include/refcnt.h +++ b/include/refcnt.h @@ -1,9 +1,9 @@ -/* +/* Tsunami for KallistiOS ##version## - + refcnt.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -131,4 +131,3 @@ private: ...<truncated>... hooks/post-receive -- UNNAMED PROJECT |
From: ljsebald <ljs...@us...> - 2023-09-02 20:24: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 "UNNAMED PROJECT". The branch, master has been updated via 81329435db6b2c747ee1bde2d3359e78344e0b63 (commit) via 3b708ec4bff95a6c52bf31409c00136e6a65b81d (commit) from ab4993aa4ff611690f777fdf29e5747392c13482 (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 81329435db6b2c747ee1bde2d3359e78344e0b63 Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 2 16:23:42 2023 -0400 Clean up Makefile for building outside of kos-ports. commit 3b708ec4bff95a6c52bf31409c00136e6a65b81d Author: Lawrence Sebald <ljs...@us...> Date: Sat Sep 2 16:23:25 2023 -0400 Update copyrights ----------------------------------------------------------------------- Summary of changes: Makefile | 14 ++++---------- doc/readme.txt | 7 +++---- include/color.h | 3 +-- include/context.h | 2 +- include/dr.h | 3 +-- include/font.h | 5 ++--- include/list.h | 3 +-- include/matrix.h | 3 +-- include/prim.h | 19 +++++++++---------- include/sprite.h | 3 +-- include/texture.h | 3 +-- src/context.c | 2 +- src/font.c | 2 +- src/mat3d.c | 4 ++-- src/texture.c | 2 +- 15 files changed, 30 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index da1a372..119bc55 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,11 @@ # Parallax for KallistiOS ##version## # # Makefile -# (c)2002 Dan Potter +# Copyright (C) 2002 Megan Potter -TARGET = libparallax.a -OBJS := $(patsubst %.c,%.o,$(wildcard src/*.c)) - -defaultall: create_kos_link $(OBJS) subdirs linklib - -# creates the kos link to the headers -create_kos_link: - rm -f ../include/plx - ln -s ../libparallax/include ../include/plx +TARGET = libparallax.a +OBJS := $(patsubst %.c,%.o,$(wildcard src/*.c)) +KOS_CFLAGS += -Iinclude # Grab the shared Makefile pieces include $(KOS_BASE)/addons/Makefile.prefab diff --git a/doc/readme.txt b/doc/readme.txt index 584f492..6c44430 100644 --- a/doc/readme.txt +++ b/doc/readme.txt @@ -1,5 +1,5 @@ Parallax for KOS ##version## -(c)2002 Dan Potter +Copyright (C) 2002 Megan Potter What is it? @@ -8,7 +8,7 @@ What is it? Parallax is my answer to wanting a nice, simple API with which to write mostly-2D games for KOS. Brian Peek and I both needed something like this which is faster (and cuts around much of the properness of things like KGL) -for our projects, and so we sat down and came up with a basic list of +for our projects, and so we sat down and came up with a basic list of requirements and specs, and I got to coding. @@ -23,7 +23,7 @@ These are the basic requirements we shared: - Speed is an essential priority for things like submitting sprites and vertices; thus anything in the main code path needs to be inlined or made into macros if at all possible, and even use DR where possible. - + - Everything should be based around supporting and enhancing the native libraries rather than replacing them. Thus Parallax can be used with the PVR API or inside a KGL program as if it were all straight PVR calls. @@ -44,4 +44,3 @@ License Parallax is licensed under the same license as KOS (BSD-style). See README.KOS for more specific information. - diff --git a/include/color.h b/include/color.h index fe89f43..41c7380 100644 --- a/include/color.h +++ b/include/color.h @@ -2,7 +2,7 @@ color.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -26,4 +26,3 @@ static inline uint32 plx_pack_color(float a, float r, float g, float b) { __END_DECLS #endif /* __PARALLAX_COLOR */ - diff --git a/include/context.h b/include/context.h index 844b310..6e5d101 100644 --- a/include/context.h +++ b/include/context.h @@ -2,7 +2,7 @@ context.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ diff --git a/include/dr.h b/include/dr.h index 7b0a45e..538e34b 100644 --- a/include/dr.h +++ b/include/dr.h @@ -2,7 +2,7 @@ dr.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -49,4 +49,3 @@ static inline void plx_scene_end() { __END_DECLS #endif /* __PARALLAX_DR */ - diff --git a/include/font.h b/include/font.h index 98e5c87..e4ee548 100644 --- a/include/font.h +++ b/include/font.h @@ -2,7 +2,7 @@ font.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -15,7 +15,7 @@ __BEGIN_DECLS /** \file Texture-based font routines. These are equivalent to DCPLIB's - fntTxf routines, but are written entirely in C. + fntTxf routines, but are written entirely in C. */ #include <kos/vector.h> @@ -197,4 +197,3 @@ void plx_fcxt_end(plx_fcxt_t * cxt); __END_DECLS #endif /* __PARALLAX_FONT */ - diff --git a/include/list.h b/include/list.h index a0384b8..fc412a5 100644 --- a/include/list.h +++ b/include/list.h @@ -2,7 +2,7 @@ list.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -31,4 +31,3 @@ __BEGIN_DECLS __END_DECLS #endif /* __PARALLAX_LIST */ - diff --git a/include/matrix.h b/include/matrix.h index c5f12e9..9f6baaf 100644 --- a/include/matrix.h +++ b/include/matrix.h @@ -2,7 +2,7 @@ matrix.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -116,4 +116,3 @@ void plx_mat3d_apply_all(); __END_DECLS #endif /* __PARALLAX_MATRIX */ - diff --git a/include/prim.h b/include/prim.h index bac70a2..6b87564 100644 --- a/include/prim.h +++ b/include/prim.h @@ -2,7 +2,7 @@ prim.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -105,7 +105,7 @@ static inline void plx_vert_fnd(plx_dr_state_t * state, int flags, float x, floa float a, float r, float g, float b) { plx_vertex_t * vert = plx_dr_target(state); - + vert->flags = flags; vert->x = x; vert->y = y; @@ -124,7 +124,7 @@ static inline void plx_vert_ind(plx_dr_state_t * state, int flags, float x, floa uint32 color) { plx_vertex_t * vert = plx_dr_target(state); - + vert->flags = flags; vert->x = x; vert->y = y; @@ -143,7 +143,7 @@ static inline void plx_vert_ffd(plx_dr_state_t * state, int flags, float x, floa float a, float r, float g, float b, float u, float v) { plx_vertex_t * vert = plx_dr_target(state); - + vert->flags = flags; vert->x = x; vert->y = y; @@ -163,7 +163,7 @@ static inline void plx_vert_ifd(plx_dr_state_t * state, int flags, float x, floa uint32 color, float u, float v) { plx_vertex_t * vert = plx_dr_target(state); - + vert->flags = flags; vert->x = x; vert->y = y; @@ -206,7 +206,7 @@ static inline void plx_vert_fnp(int flags, float x, float y, float z, float a, float r, float g, float b) { plx_vertex_t vert; - + vert.flags = flags; vert.x = x; vert.y = y; @@ -223,7 +223,7 @@ static inline void plx_vert_fnp(int flags, float x, float y, float z, */ static inline void plx_vert_inp(int flags, float x, float y, float z, uint32 color) { plx_vertex_t vert; - + vert.flags = flags; vert.x = x; vert.y = y; @@ -250,7 +250,7 @@ static inline void plx_vert_ffp(int flags, float x, float y, float z, float a, float r, float g, float b, float u, float v) { plx_vertex_t vert; - + vert.flags = flags; vert.x = x; vert.y = y; @@ -270,7 +270,7 @@ static inline void plx_vert_ifp(int flags, float x, float y, float z, uint32 color, float u, float v) { plx_vertex_t vert; - + vert.flags = flags; vert.x = x; vert.y = y; @@ -286,4 +286,3 @@ static inline void plx_vert_ifp(int flags, float x, float y, float z, __END_DECLS #endif /* __PARALLAX_PRIM */ - diff --git a/include/sprite.h b/include/sprite.h index 2803ffb..24ecf62 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -2,7 +2,7 @@ sprite.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -329,4 +329,3 @@ static inline void plx_spr_imp( __END_DECLS #endif /* __PARALLAX_SPRITE */ - diff --git a/include/texture.h b/include/texture.h index 4266b2d..7acd51c 100644 --- a/include/texture.h +++ b/include/texture.h @@ -2,7 +2,7 @@ texture.h - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ @@ -103,4 +103,3 @@ void plx_txr_send_hdr(plx_texture_t * txr, int list, int flush); __END_DECLS #endif /* __PARALLAX_TEXTURE */ - diff --git a/src/context.c b/src/context.c index cdefc15..1cb5724 100644 --- a/src/context.c +++ b/src/context.c @@ -2,7 +2,7 @@ context.c - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ diff --git a/src/font.c b/src/font.c index 6ae612f..8cdde08 100644 --- a/src/font.c +++ b/src/font.c @@ -2,7 +2,7 @@ font.c - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ diff --git a/src/mat3d.c b/src/mat3d.c index 240c03f..f674e7a 100644 --- a/src/mat3d.c +++ b/src/mat3d.c @@ -1,8 +1,8 @@ /* Parallax for KallistiOS ##version## mat3d.c - (c)2001-2002 Dan Potter - (c)2002 Benoit Miller and Paul Boese + Copyright (C) 2001-2002 Megan Potter + Copyright (C) 2002 Benoit Miller and Paul Boese */ #include <assert.h> diff --git a/src/texture.c b/src/texture.c index db09bae..59be19e 100644 --- a/src/texture.c +++ b/src/texture.c @@ -2,7 +2,7 @@ texture.c - (c)2002 Dan Potter + Copyright (C) 2002 Megan Potter */ hooks/post-receive -- UNNAMED PROJECT |
From: darcagn <da...@us...> - 2023-09-02 16:05:54
|
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 7b0304a5462a93cdbb247b05d5652fe8cf65d290 (commit) via 6a427e8ec7f4131f95d4bd12fa48f849ac3de3ca (commit) from a98b02e22ee448b3d3f82193dbf3ed11f5616244 (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 7b0304a5462a93cdbb247b05d5652fe8cf65d290 Merge: a98b02e 6a427e8 Author: darcagn <da...@pr...> Date: Sat Sep 2 11:05:12 2023 -0500 Merge pull request #287 from KallistiOS/vmu_beep_fix Fixing missing vmu_beep_waveform() symbol commit 6a427e8ec7f4131f95d4bd12fa48f849ac3de3ca Author: Falco Girgis <gyr...@gm...> Date: Sat Sep 2 01:45:43 2023 -0500 Fixing missing vmu_beep_waveform() symbol - Big VMU driver update accidentally had a name mismatch between the header and source file - vmu_beep_waveform() would've been an unresolved symbol if used - changed vmu_beep() in vmu.c to vmu_beep_waveform(), as advertised in the header ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/maple/vmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c index fb6a0f0..6abdb59 100644 --- a/kernel/arch/dreamcast/hardware/maple/vmu.c +++ b/kernel/arch/dreamcast/hardware/maple/vmu.c @@ -287,8 +287,10 @@ int vmu_beep_raw(maple_device_t *dev, uint32_t beep) { return MAPLE_EOK; } -int vmu_beep(maple_device_t *dev, uint8_t period, uint8_t duty) { - const uint32_t raw_beep = ((period << 24) | ((period - duty)) << 16); +int vmu_beep_waveform(maple_device_t *dev, uint8_t period1, uint8_t duty_cycle1, uint8_t period2, uint8_t duty_cycle2) { + const uint32_t raw_beep = (((period2 - duty_cycle2) << 24) | (period2 << 16) | + ((period1 - duty_cycle1) << 8) | (period1)); + return vmu_beep_raw(dev, raw_beep); } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-01 20:19: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, libpthread has been deleted was c9876ca63ce171bfc585e11f132a536e432e92db ----------------------------------------------------------------------- c9876ca63ce171bfc585e11f132a536e432e92db Update _pthread.h for older newlib versions and ensure it gets copied over too. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-09-01 20:18:52
|
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, libpthread has been created at c9876ca63ce171bfc585e11f132a536e432e92db (commit) - Log ----------------------------------------------------------------- commit c9876ca63ce171bfc585e11f132a536e432e92db Author: Lawrence Sebald <ljs...@us...> Date: Fri Sep 1 16:18:23 2023 -0400 Update _pthread.h for older newlib versions and ensure it gets copied over too. commit 545e1c72006b0fcdf7b611a8d845ca7a27b8f9ef Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 22:06:53 2023 -0400 Update newlib include fixup for _pthreadtypes.h instead of _pthread.h. commit 743f0336115444cd6e9f253f7816b8f71cdde6bc Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 22:05:56 2023 -0400 Use <sys/cdefs.h> in <sys/sched.h>, not <kos/cdefs.h>. commit b6c3c7295d05df6ca3aa83d64cfb80396b5231df Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 22:04:26 2023 -0400 Remove include of <sys/_pthread.h> commit 4151273f59aad2d80eaef5a7542dab08cade242e Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 22:02:31 2023 -0400 Move pthread.h to main include directory and rename _pthread_types.h to _pthreadtypes.h. commit 0ddee26679d528fa99caa75e40fbfa8214825b42 Merge: 481f331 a98b02e Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 17:49:36 2023 -0400 Merge branch 'master' into libpthread commit 481f331245528499298ffa596d6f6deb46e9451b Author: Lawrence Sebald <ljs...@us...> Date: Wed Aug 30 00:21:39 2023 -0400 Add in call to pthread_attr_destroy that should be there... commit b1785f382fe022f7a7916c6587f4c8f26eb211fb Author: Lawrence Sebald <ljs...@us...> Date: Wed Aug 30 00:18:43 2023 -0400 Add detached thread to fill left half of screen to pthread example. commit 1a3377ffd37d6ef1e30b80d9415e49d68de334ba Author: Lawrence Sebald <ljs...@us...> Date: Tue Aug 29 21:54:30 2023 -0400 Add basic mutex test and rwlock test commit 019047c59fae3673c977fbfc459d2dd27109fe20 Author: darc <da...@pr...> Date: Tue Aug 29 17:41:58 2023 -0500 Fix dns-client and hello-opus needing kos/threads header to build commit 54c2d74485042e664e2636d2fde4dcd6e16092d6 Author: Lawrence Sebald <ljs...@us...> Date: Tue Aug 29 18:17:49 2023 -0400 Add start of a simple test program for pthreads. commit a00b2270ddfd02f5d1529042b033181923a68bc6 Author: Lawrence Sebald <ljs...@us...> Date: Tue Aug 29 18:13:40 2023 -0400 Add missing pthread_mutex_unlock function. commit 6101c0728d74f0fedeb497195d6d591b874c267f Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 23:42:52 2023 -0400 Update RELNOTES to include information about libpthread and remove pthread.h stuff from AUTHORS. commit f8f9d84eb3a2d5ba7a2ad760270579b463ccdcd8 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 23:29:34 2023 -0400 Initial commit of new libpthread. Also, remove all of the old pthreads implementation. ----------------------------------------------------------------------- hooks/post-receive -- A pseudo Operating System for the Dreamcast. |