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
(22) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
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. |
From: ljsebald <ljs...@us...> - 2023-08-31 20:47:57
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via a98b02e22ee448b3d3f82193dbf3ed11f5616244 (commit) via 4b9c3824461bb5a91a2fc7ab1411d3156ad16208 (commit) from df51ca01ed93f7c291538e1c7097e1eb24c41770 (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 a98b02e22ee448b3d3f82193dbf3ed11f5616244 Merge: df51ca0 4b9c382 Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 16:47:16 2023 -0400 Merge pull request #285 from KallistiOS/sq-formatting Formatting cleanup of store queue code commit 4b9c3824461bb5a91a2fc7ab1411d3156ad16208 Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 31 16:46:00 2023 -0400 Formatting cleanup of store queue code. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/sq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/sq.c b/kernel/arch/dreamcast/hardware/sq.c index 4ec7be3..263074a 100644 --- a/kernel/arch/dreamcast/hardware/sq.c +++ b/kernel/arch/dreamcast/hardware/sq.c @@ -24,7 +24,7 @@ void sq_clr(void *dest, int n) { /* Fill both store queues with zeroes */ d[0] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = - d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = 0; + d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = 0; /* Write them as many times necessary */ n >>= 5; @@ -53,7 +53,7 @@ void * sq_cpy(void *dest, const void *src, int n) { n >>= 5; while(n--) { - __asm__("pref @%0" : : "r"(s + 8)); /* prefetch 32 bytes for next loop */ + __asm__("pref @%0" : : "r"(s + 8)); /* prefetch 32 bytes */ d[0] = *(s++); d[1] = *(s++); d[2] = *(s++); @@ -88,7 +88,7 @@ void * sq_set(void *s, uint32 c, int n) { /* Fill both store queues with c */ d[0] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = - d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = c; + d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = c; /* Write them as many times necessary */ n >>= 5; @@ -120,7 +120,7 @@ void * sq_set16(void *s, uint32 c, int n) { /* Fill both store queues with c */ d[0] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = - d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = c; + d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = c; /* Write them as many times necessary */ n >>= 5; @@ -148,7 +148,7 @@ void * sq_set32(void *s, uint32 c, int n) { /* Fill both store queues with c */ d[0] = d[1] = d[2] = d[3] = d[4] = d[5] = d[6] = d[7] = - d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = c; + d[8] = d[9] = d[10] = d[11] = d[12] = d[13] = d[14] = d[15] = c; /* Write them as many times necessary */ n >>= 5; hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-30 21:52: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 df51ca01ed93f7c291538e1c7097e1eb24c41770 (commit) via 6a7dee98f39d5a4876f625430ad7ad631b5f2287 (commit) from 7094048da2d2c90301611fb963473702f281ef8e (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 df51ca01ed93f7c291538e1c7097e1eb24c41770 Author: darcagn <da...@pr...> Date: Wed Aug 30 16:50:58 2023 -0500 Fix warnings when building examples with -flto (#284) * Fix warning in png example when compiling with -flto * Fix maybe uninitialized warning in dreameye-sd example when compiling with -flto * Fix warning in keytest example when compiling with -flto commit 6a7dee98f39d5a4876f625430ad7ad631b5f2287 Author: Falco Girgis <gyr...@gm...> Date: Wed Aug 30 16:50:20 2023 -0500 Added Spinlock Example/Test (#275) * Added spinlock_test example/test for spinlocks - Created a new example that also flexes the spinlock implementation, demonstrating both gaining control of a lock by "trying" until successful or locking until it becomes available. * Update spinlock_test.c Missing space after { for fib(). * Update spinlock_test.c Logic mistake in checking for issues at the end. * Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/basic/threading/Makefile | 3 + .../threading/spinlock_test}/Makefile | 9 +- .../basic/threading/spinlock_test/spinlock_test.c | 152 +++++++++++++++++++++ examples/dreamcast/dreameye/sd/dreameye-sd.c | 2 +- examples/dreamcast/keyboard/keytest/keytest.c | 24 ++-- examples/dreamcast/png/example.c | 2 +- 6 files changed, 174 insertions(+), 18 deletions(-) copy examples/dreamcast/{video/bfont => basic/threading/spinlock_test}/Makefile (69%) create mode 100644 examples/dreamcast/basic/threading/spinlock_test/spinlock_test.c diff --git a/examples/dreamcast/basic/threading/Makefile b/examples/dreamcast/basic/threading/Makefile index 7e7dd2d..fd7482f 100644 --- a/examples/dreamcast/basic/threading/Makefile +++ b/examples/dreamcast/basic/threading/Makefile @@ -10,6 +10,7 @@ all: $(KOS_MAKE) -C recursive_lock $(KOS_MAKE) -C once $(KOS_MAKE) -C tls + $(KOS_MAKE) -C spinlock_test clean: $(KOS_MAKE) -C general clean @@ -17,6 +18,7 @@ clean: $(KOS_MAKE) -C recursive_lock clean $(KOS_MAKE) -C once clean $(KOS_MAKE) -C tls clean + $(KOS_MAKE) -C spinlock_test clean dist: $(KOS_MAKE) -C general dist @@ -24,4 +26,5 @@ dist: $(KOS_MAKE) -C recursive_lock dist $(KOS_MAKE) -C once dist $(KOS_MAKE) -C tls dist + $(KOS_MAKE) -C spinlock_test dist diff --git a/examples/dreamcast/video/bfont/Makefile b/examples/dreamcast/basic/threading/spinlock_test/Makefile similarity index 69% copy from examples/dreamcast/video/bfont/Makefile copy to examples/dreamcast/basic/threading/spinlock_test/Makefile index 67462af..403f45f 100644 --- a/examples/dreamcast/video/bfont/Makefile +++ b/examples/dreamcast/basic/threading/spinlock_test/Makefile @@ -1,11 +1,12 @@ # KallistiOS ##version## # -# basic/bfont/Makefile -# (c)2002 Megan Potter +# basic/threading/spinlock_test/Makefile +# +# Copyright (C) 2023 Falco Girgis # -TARGET = bfont.elf -OBJS = bfont.o +TARGET = spinlock_test.elf +OBJS = spinlock_test.o all: rm-elf $(TARGET) diff --git a/examples/dreamcast/basic/threading/spinlock_test/spinlock_test.c b/examples/dreamcast/basic/threading/spinlock_test/spinlock_test.c new file mode 100644 index 0000000..372d9ee --- /dev/null +++ b/examples/dreamcast/basic/threading/spinlock_test/spinlock_test.c @@ -0,0 +1,152 @@ +/* KallistiOS ##version## + + spinlock_test.c + + Copyright (C) 2023 Falco Girgis + + This file is a simple example of the different + ways in which to use a spinlock. It serves two + purposes: + + 1) To demonstrate their usage + 2) To serve as a test for KOS's implementation + + Multiple threads are spawned and then take turns + waiting for the spinlock to become available, using + two different methods of waiting. + */ + +#include <kos.h> +#include <stdlib.h> +#include <arch/spinlock.h> + +/* + Simple macro that calls printf and immediately flushes its + buffer so we don't have to wait for it to fill before seeing + a thread's output. +*/ +#define print(...) \ + do { \ + printf(__VA_ARGS__); \ + fflush(stdout); \ + } while(0) + + +/* The counter out threads will be competing for access to */ +static uint32_t lock_counter = 0; +/* The spinlock our threads will use to manage access to the counter */ +static spinlock_t lock = SPINLOCK_INITIALIZER; + +/* + Calculates the Nth Fibonacci number. + Lets give the threads something to do while they wait! +*/ +static int fib(int n) { + if (n <= 1) + return n; + + return fib(n - 1) + fib(n - 2); +} + +/* + Main execution path for each thread, demonstrating the following + with a spinlock: + + 1) Doing something useful while waiting for the lock + 2) Simply locking normally and waiting for it +*/ +void *thd(void *v) { + unsigned tid = (unsigned)v; + unsigned fibres = 0, fibn = 0; + + /* Continue calling spinlock_trylock() until eventually + locking succeeds. */ + while(!spinlock_trylock(&lock)) { + print("Thread[%u] still trying the lock!\n", tid); + /* We can do something else while we wait! */ + fibres = fib(fibn++); + /* Let the other threads have some time too. */ + thd_pass(); + } + + print("Thread[%u] trylock succeeded!\n", tid); + print("Thread[%u] calculated the %uth fibonacci number " + "while waiting: %u\n", tid, fibn - 1, fibres); + + /* Increment our counter once now that we have the lock. */ + ++lock_counter; + sleep(1); + + print("Thread[%u] yielding the lock\n", tid); + + /* Release the lock so the other threads can have it. */ + spinlock_unlock(&lock); + + sleep(1); + + /* Attempt to gain the lock again, this time by + locking it. Program execution will not proceed + until the lock is in the thread's possession. */ + print("Thread[%u] locking the lock\n", tid); + spinlock_lock(&lock); + print("Thread[%u] locked the lock\n", tid); + + /* Increment out counter again to show we got the lock + a second time. */ + ++lock_counter; + sleep(1); + + print("Thread[%u] unlocking the lock\n", tid); + spinlock_unlock(&lock); + + /* Return how far we got into the Fibonacci sequence + while we waited for the lock. */ + return (void *)(fibn - 1); +} + +int main(int argc, char **argv) { + const int thread_count = 10; + kthread_t *threads[thread_count]; + int i, join_error = 0; + unsigned fibcount = 0; + + print("Starting Threads\n"); + + /* Kick off a number of threads to all compete for our spinlock. */ + for (i = 0; i < thread_count; i++) { + threads[i] = thd_create(0, thd, (void *)(i + 1)); + } + + /* Perform the same logic for the main thread. */ + thd((void*)0); + + /* Wait for each thread to return. */ + for(i = 0; i < thread_count; i++) { + void* result; + + if(thd_join(threads[i], &result) != 0) { + /* Mark the test as failed if the thread failed to join gracefully. */ + fprintf(stderr, "Thread[%i] failed to complete properly!\n", i + 1); + join_error = 1; + } else { + print("Thread[%d] returned.\n", i + 1); + /* Add the number of Fibonacci numbers it calculated to our total. */ + fibcount += (unsigned)result; + } + } + + print("Threads finished and calculated %u fibonacci numbers while they waited!\n", fibcount); + + /* Ensure there were no issues with threads exiting gracefully, + and that the lock_counter was incremented twice for every + thread, plus 2 more for the main thread. + */ + if(join_error || lock_counter != (thread_count + 1) * 2) { + fprintf(stderr, "\n\n***** SPINLOCK TEST FAILED! *****\n\n"); + return EXIT_FAILURE; + } + else { + print("\n\n***** SPINLOCK TEST SUCCESS! *****\n\n"); + return EXIT_SUCCESS; + } +} diff --git a/examples/dreamcast/dreameye/sd/dreameye-sd.c b/examples/dreamcast/dreameye/sd/dreameye-sd.c index 86344b2..423ebf5 100644 --- a/examples/dreamcast/dreameye/sd/dreameye-sd.c +++ b/examples/dreamcast/dreameye/sd/dreameye-sd.c @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { maple_device_t *dreameye; dreameye_state_t *state; - uint8 *buf; + uint8 *buf = NULL; int size, err; FILE *fp; int img_count, i; diff --git a/examples/dreamcast/keyboard/keytest/keytest.c b/examples/dreamcast/keyboard/keytest/keytest.c index 3a3d92a..9863c8e 100644 --- a/examples/dreamcast/keyboard/keytest/keytest.c +++ b/examples/dreamcast/keyboard/keytest/keytest.c @@ -2,10 +2,10 @@ keytest.c Copyright (C) 2018 Donald Haase - + The Purpose of this program is to provide some testing of the basic keyboard functionality. -Currently it merely takes in a preset number of printable test characters. This allows for the testing +Currently it merely takes in a preset number of printable test characters. This allows for the testing of basic US keyboard functionality, appropriate shift handling, and the newer key repeating feature. Room has been explicitly left open for further tests. It might be useful to include: @@ -28,7 +28,7 @@ Room has been explicitly left open for further tests. It might be useful to incl KOS_INIT_FLAGS(INIT_DEFAULT); extern uint16 *vram_s; -cont_state_t* first_kbd_state; +cont_state_t* first_kbd_state; maple_device_t* first_kbd_dev = NULL; /* Track how many times we try to find a keyboard before just quitting. */ @@ -37,7 +37,7 @@ uint8 no_kbd_loop = 0; uint8 test_phase = 0; -void basic_typing (void) +void basic_typing (void) { int charcount = 0; int rv; @@ -45,21 +45,21 @@ void basic_typing (void) uint32 offset = ((STARTLINE+(lines*BFONT_HEIGHT)) * WIDTH); bfont_draw_str(vram_s + offset, WIDTH, 1, "Test of basic typing. Enter 120 characters: "); offset = ((STARTLINE+((++lines)*BFONT_HEIGHT)) * WIDTH); - + while (charcount < CHARSPERTEST) { rv = kbd_queue_pop(first_kbd_dev, 1); if(rv<0) continue; - + bfont_draw(vram_s + offset, WIDTH, 1, (char)rv); offset += BFONT_THIN_WIDTH; charcount++; - if(!(charcount%CHARSPERLINE)) offset = ((STARTLINE+((++lines)*BFONT_HEIGHT)) * WIDTH); + if(!(charcount%CHARSPERLINE)) offset = ((STARTLINE+((++lines)*BFONT_HEIGHT)) * WIDTH); } return; } -int main(void) +int main(int argc, char **argv) { for(;;) { /* If the dev is null, refresh it. */ @@ -74,16 +74,16 @@ int main(void) } /* Reset the timeout counter */ no_kbd_loop = 0; - + first_kbd_state = (cont_state_t *) maple_dev_status(first_kbd_dev); if(first_kbd_state == NULL) assert_msg(0, "Invalid Keyboard state returned"); - + if(test_phase == 0) basic_typing(); else break; - - test_phase++; + + test_phase++; } return 0; } diff --git a/examples/dreamcast/png/example.c b/examples/dreamcast/png/example.c index ee48614..4c90994 100644 --- a/examples/dreamcast/png/example.c +++ b/examples/dreamcast/png/example.c @@ -211,7 +211,7 @@ void draw_frame(void) { extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); -int main(void) { +int main(int argc, char **argv) { int done = 0; /* init kos */ hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-08-30 16:51: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 serial program loader for the Dreamcast.". The branch, master has been updated via a588add704d8d271b4c729043d829733db139aa9 (commit) via 8cae12c2eee6d5859898524ff08f87bd615dcb83 (commit) from 9d0777ed7d74e809c314fb10c3c8cf3d694f1085 (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 a588add704d8d271b4c729043d829733db139aa9 Merge: 9d0777e 8cae12c Author: darcagn <da...@pr...> Date: Wed Aug 30 11:50:24 2023 -0500 Merge pull request #20 from Tchan0/fix_missing_oldspeed dc-tool.c: add variable declaration for new variable "oldspeed" commit 8cae12c2eee6d5859898524ff08f87bd615dcb83 Author: Tchan0 <617...@us...> Date: Wed Aug 30 18:21:00 2023 +0200 Update dc-tool.c fix for missing variable that was added in previous merge request ----------------------------------------------------------------------- Summary of changes: host-src/tool/dc-tool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index fe21d45..f27e72b 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -605,6 +605,7 @@ int open_serial(char *devicename, unsigned int speed, unsigned int *speedtest) { *speedtest = speed; #ifndef _WIN32 speed_t baudconst; + unsigned int oldspeed; dcfd = open(devicename, O_RDWR | O_NOCTTY); if(dcfd < 0) { hooks/post-receive -- A serial program loader for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-29 21: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 serial program loader for the Dreamcast.". The branch, master has been updated via 9d0777ed7d74e809c314fb10c3c8cf3d694f1085 (commit) from 9ff1c322d00cfc861514faa2188b2007ee8ab44a (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 9d0777ed7d74e809c314fb10c3c8cf3d694f1085 Author: SiZiOUS <si...@gm...> Date: Tue Aug 29 23:55:06 2023 +0200 `dc-tool`: Updating compatibility layer (shim) for MinGW/MSYS (#19) * `dc-tool`: Updating compatibility layer (shim) for MinGW/MSYS This shim will be required if dc-tool is compiled on MinGW/MSYS while using a toolchain built on MinGW-w64/MSYS2. The shim has been updated for GCC 13.2. * `dc-tool`: Removing outdated comment. * `dc-tool`: Improving comments in shim. * Update host-src/tool/shim.c ----------------------------------------------------------------------- Summary of changes: host-src/tool/Makefile | 2 +- host-src/tool/shim.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++ host-src/tool/utils.c | 78 ----------------------------------- 3 files changed, 109 insertions(+), 79 deletions(-) create mode 100644 host-src/tool/shim.c delete mode 100644 host-src/tool/utils.c diff --git a/host-src/tool/Makefile b/host-src/tool/Makefile index edc894e..763557e 100644 --- a/host-src/tool/Makefile +++ b/host-src/tool/Makefile @@ -48,7 +48,7 @@ endif DCTOOL = dc-tool-ser$(EXECUTABLEEXTENSION) -OBJECTS = dc-tool.o minilzo.o syscalls.o unlink.o utils.o +OBJECTS = dc-tool.o minilzo.o syscalls.o unlink.o shim.o LZOFILES = $(LZOPATH)/minilzo.c $(LZOPATH)/minilzo.h $(LZOPATH)/lzoconf.h .c.o: diff --git a/host-src/tool/shim.c b/host-src/tool/shim.c new file mode 100644 index 0000000..0596a4e --- /dev/null +++ b/host-src/tool/shim.c @@ -0,0 +1,108 @@ +/* + * This file is part of the dcload Dreamcast serial loader + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#ifdef __MINGW32__ +#include <_mingw.h> +#include <windows.h> + +/* Detect MinGW/MSYS vs. MinGW-w64/MSYS2 */ +# ifdef __MINGW64_VERSION_MAJOR +# define __RT_MINGW_W64__ +# else +# define __RT_MINGW_ORG__ +# endif + +#endif /* __MINGW32__ */ + +/* + * Compatibility layer ('shim') for the original, legacy MinGW/MSYS environment. + * This allow toolchains built on MinGW-w64/MSYS2 to be usable with MinGW/MSYS. + * Mainly, this is for linking 'dc-tool' with 'libbfd'. Declaring these + * functions will let us to build 'dc-tool' even if 'sh-elf' toolchain was built + * on MinGW-w64/MSYS2. + * + * Of course this will work if the compiler used on MinGW-w64/MSYS2 and + * MinGW/MSYS are in the same family (e.g., GCC 9.x on both environments). + */ +#ifdef __RT_MINGW_ORG__ + +// See: https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-crt/stdio/mingw_vasprintf.c +int vasprintf(char ** __restrict__ ret, + const char * __restrict__ format, + va_list ap) { + int len; + /* Get Length */ + len = __mingw_vsnprintf(NULL,0,format,ap); + if (len < 0) return -1; + /* +1 for \0 terminator. */ + *ret = malloc(len + 1); + /* Check malloc fail*/ + if (!*ret) return -1; + /* Write String */ + __mingw_vsnprintf(*ret,len+1,format,ap); + /* Terminate explicitly */ + (*ret)[len] = '\0'; + return len; +} + +// Thanks to Dietrich Epp +// See: https://stackoverflow.com/a/40160038 +int __cdecl __MINGW_NOTHROW libintl_asprintf(char **strp, + const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + + int r = vasprintf(strp, fmt, ap); + va_end(ap); + + return r; +} + +int __cdecl __MINGW_NOTHROW libintl_vasprintf(char **restrict strp, + const char *restrict fmt, + va_list arg ) { + return vasprintf(strp, fmt, arg); +} + +// See: https://stackoverflow.com/a/60380005 +int __cdecl __MINGW_NOTHROW __ms_vsnprintf(char *buffer, + size_t count, + const char *format, + va_list argptr) { + return __mingw_vsnprintf(buffer, count, format, argptr); +} + +// Thanks to Kenji Uno and god +// See: https://github.com/HiraokaHyperTools/libacrt_iob_func +// See: https://stackoverflow.com/a/30894349 +FILE * __cdecl __MINGW_NOTHROW _imp____acrt_iob_func(int handle) { + switch (handle) { + case 0: return stdin; + case 1: return stdout; + case 2: return stderr; + } + + return NULL; +} + +#endif /* __RT_MINGW_ORG__ */ diff --git a/host-src/tool/utils.c b/host-src/tool/utils.c deleted file mode 100644 index 645fb49..0000000 --- a/host-src/tool/utils.c +++ /dev/null @@ -1,78 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> - -/* Detect MinGW/MSYS vs. MinGW-w64/MSYS2 */ -#ifdef __MINGW32__ -#include <_mingw.h> -# ifdef __MINGW64_VERSION_MAJOR -# define __RT_MINGW_W64__ -# else -# define __RT_MINGW_ORG__ -# endif -#endif /* __MINGW32__ */ - -#ifdef __RT_MINGW_ORG__ - -/* - * Compatibility layer for original, legacy MinGW/MSYS environment. - * This allow toolchains built on MinGW-w64/MSYS2 to be usable with MinGW/MSYS. - * Mainly, this is for linking 'dc-tool' with 'libbfd'. Declaring these - * functions will let us to build 'dc-tool' even if 'sh-elf' toolchain was built - * on MinGW-w64/MSYS2. - */ - -// Thanks to Dietrich Epp -// See: https://stackoverflow.com/a/40160038 -int vasprintf(char **strp, const char *fmt, va_list ap) { - int len = _vscprintf(fmt, ap); - if(len == -1) { - return -1; - } - - size_t size = (size_t)len + 1; - char *str = malloc(size); - if(!str) { - return -1; - } - - int r = __mingw_vsnprintf(str, len + 1, fmt, ap); - if(r == -1) { - free(str); - return -1; - } - *strp = str; - return r; -} - -// Thanks to Dietrich Epp -// See: https://stackoverflow.com/a/40160038 -int __cdecl __MINGW_NOTHROW libintl_asprintf(char **strp, const char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - - int r = vasprintf(strp, fmt, ap); - va_end(ap); - - return r; -} - -// See: https://stackoverflow.com/a/60380005 -int __cdecl __MINGW_NOTHROW __ms_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) { - return __mingw_vsnprintf(buffer, count, format, argptr); -} - -// Thanks to Kenji Uno and god -// See: https://github.com/HiraokaHyperTools/libacrt_iob_func -// See: https://stackoverflow.com/a/30894349 -FILE * __cdecl __MINGW_NOTHROW _imp____acrt_iob_func(int handle) { - switch (handle) { - case 0: return stdin; - case 1: return stdout; - case 2: return stderr; - } - - return NULL; -} - -#endif /* __RT_MINGW_ORG__ */ hooks/post-receive -- A serial program loader for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-29 21:53:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A KallistiOS implementation of conio. ". The branch, master has been updated via 95323837e6b19ed78a965d24e29a0720105e3967 (commit) from 63be6e2616ddb99807003645639b85e96de2e4ab (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 95323837e6b19ed78a965d24e29a0720105e3967 Author: Lawrence Sebald <ljs...@us...> Date: Tue Aug 29 17:52:53 2023 -0400 Clean up warnings and update copyright. ----------------------------------------------------------------------- Summary of changes: Makefile | 4 ++-- conio.c | 13 +++++++------ draw.c | 11 +++++------ input.c | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index a170ecc..af6c197 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # KallistiOS ##version## # -# addons/libconio Makefile -# (c)2002 Dan Potter +# libconio Makefile +# Copyright (C) 2002 Megan Potter TARGET = libconio.a OBJS = conio.o input.o draw.o diff --git a/conio.c b/conio.c index e8d5dca..7a0757c 100644 --- a/conio.c +++ b/conio.c @@ -1,19 +1,20 @@ /* KallistiOS ##version## - conio.c + conio.c + Copyright (C) 2002 Megan Potter - (c)2002 Dan Potter - - Adapted from Kosh, (c)2000 Jordan DeLong + Adapted from Kosh, Copyright (C) 2000 Jordan DeLong */ #include <stdio.h> #include <string.h> #include <assert.h> +#include <kos/thread.h> #include <kos/sem.h> #include <dc/maple/keyboard.h> #include <dc/scif.h> +#include <arch/arch.h> #include "conio.h" /* the cursor */ @@ -119,7 +120,7 @@ void conio_gotoxy(int x, int y) { case CONIO_TTY_SERIAL: { char tmp[256]; sprintf(tmp, "\x1b[%d;%df", x, y); - scif_write_buffer(tmp, strlen(tmp), 1); + scif_write_buffer((unsigned char *)tmp, strlen(tmp), 1); break; } case CONIO_TTY_STDIO: { @@ -131,7 +132,7 @@ void conio_gotoxy(int x, int y) { case CONIO_TTY_DBGIO: { char tmp[256]; sprintf(tmp, "\x1b[%d;%df", x, y); - dbgio_write_buffer(tmp, strlen(tmp)); + dbgio_write_buffer((unsigned char *)tmp, strlen(tmp)); break; } } diff --git a/draw.c b/draw.c index c7eb38c..cc7c9b5 100644 --- a/draw.c +++ b/draw.c @@ -1,10 +1,9 @@ /* KallistiOS ##version## - conio.c + draw.c + Copyright (C) 2002 Megan Potter - (c)2002 Dan Potter - - Adapted from Kosh, (c)2000 Jordan DeLong + Adapted from Kosh, Copyright (C) 2000 Jordan DeLong */ @@ -40,8 +39,8 @@ void conio_draw_shutdown() { /* Draw one font character (6x12) */ static void draw_char(float x1, float y1, float z1, float a, float r, - float g, float b, int c) { - pvr_vertex_t vert; + float g, float b, int c) { + pvr_vertex_t vert; int ix, iy; float u1, v1, u2, v2; diff --git a/input.c b/input.c index 22295d0..a61a0ae 100644 --- a/input.c +++ b/input.c @@ -1,10 +1,9 @@ /* KallistiOS ##version## - input.c + input.c + Copyright (C) 2002 Megan Potter - (c)2002 Dan Potter - - Adapted from Kosh, (c)2000 Jordan DeLong + Adapted from Kosh, Copyright (C) 2000 Jordan DeLong */ @@ -13,6 +12,7 @@ #include <stdlib.h> #include <assert.h> #include <kos/limits.h> +#include <kos/thread.h> #include <kos/sem.h> #include <dc/maple/keyboard.h> #include "conio.h" hooks/post-receive -- A KallistiOS implementation of conio. |
From: ljsebald <ljs...@us...> - 2023-08-29 21:43:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A serial program loader for the Dreamcast.". The branch, master has been updated via 9ff1c322d00cfc861514faa2188b2007ee8ab44a (commit) via af4ccc8a4b839c6a8c5ff954c06ffc0544f8600b (commit) via 5cf66a2fb0c626fee68b113de8846f28cf163a21 (commit) from be68a319e519c2da4bf9ff2b3a33914799dcb6b0 (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 9ff1c322d00cfc861514faa2188b2007ee8ab44a Merge: be68a31 af4ccc8 Author: Lawrence Sebald <ljs...@us...> Date: Tue Aug 29 17:42:21 2023 -0400 Merge pull request #18 from Tchan0/refactor_termios Refactor termios in preparation of termios2 commit af4ccc8a4b839c6a8c5ff954c06ffc0544f8600b Author: Tchan0 <617...@us...> Date: Fri Aug 25 19:08:49 2023 +0200 Removal of -DB compiler defines Removal of -DB1500000 -DB500000 -DB230400, since the #ifdefs should be enough commit 5cf66a2fb0c626fee68b113de8846f28cf163a21 Author: Tchan0 <617...@us...> Date: Fri Aug 25 19:07:47 2023 +0200 refactor termios stuff in preparation of termios2 Small refactoring of the termios baudrate constants selection: - to eliminate the possibility of an endless loop if speed & INITIAL_SPEED are not part of the available constants - default to 38400 (the highest POSIX value) if no match was found with speed & INITIAL_SPEED - put 57600 and 115200 inside ifdefs as they in fact do not seem to be part of POSIX - code moved to separate functions to facilitate future integration of termios2 - changed variable name speedsel to baudconst, as there are already so many variables containing "speed", which ends up being confusing ----------------------------------------------------------------------- Summary of changes: host-src/tool/Makefile | 2 +- host-src/tool/dc-tool.c | 94 +++++++++++++++++++++++++++++++------------------ 2 files changed, 60 insertions(+), 36 deletions(-) diff --git a/host-src/tool/Makefile b/host-src/tool/Makefile index 5a206e8..edc894e 100644 --- a/host-src/tool/Makefile +++ b/host-src/tool/Makefile @@ -3,7 +3,7 @@ include ../../Makefile.cfg LZOPATH = ../../minilzo-2.10 CC = $(HOSTCC) -CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDEFAULT_SPEED=$(TOOL_DEFAULT_SPEED) -DSERIALDEVICE="\"$(SERIALDEVICE)\"" -DHAVE_GETOPT -DB1500000 -DB500000 -DB230400 +CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDEFAULT_SPEED=$(TOOL_DEFAULT_SPEED) -DSERIALDEVICE="\"$(SERIALDEVICE)\"" -DHAVE_GETOPT LDFLAGS = $(HOSTLDFLAGS) INCLUDE = -I$(LZOPATH) -I/usr/local/include diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index e1b8ff9..fe21d45 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -512,70 +512,71 @@ void output_error(void) { } #endif -/* setup serial port */ -int open_serial(char *devicename, unsigned int speed, unsigned int *speedtest) { - *speedtest = speed; #ifndef _WIN32 - struct termios newtio; - speed_t speedsel; - - dcfd = open(devicename, O_RDWR | O_NOCTTY); - if(dcfd < 0) { - perror(devicename); - exit(-1); - } - - tcgetattr(dcfd, &oldtio); // save current serial port settings - memset(&newtio, 0, sizeof(newtio)); // clear struct for new port settings +void get_supported_speed (unsigned int *speed, speed_t *baudconst){ + speed_t tmpbaud; + unsigned int tmpspeed = *speed; - newtio.c_cflag = CRTSCTS | CS8 | CLOCAL | CREAD; - newtio.c_iflag = IGNPAR; - newtio.c_oflag = 0; - newtio.c_lflag = 0; - newtio.c_cc[VTIME] = 0; // inter-character timer unused - newtio.c_cc[VMIN] = 1; // blocking read until 1 character arrives - - for(speedsel=0; !speedsel;) { - switch(speed) { + for (tmpbaud = B0; tmpbaud == B0;) { + switch(tmpspeed) { #ifdef B1500000 case 1500000: - speedsel = B1500000; + tmpbaud = B1500000; break; #endif #ifdef B500000 case 500000: - speedsel = B500000; + tmpbaud = B500000; break; #endif #ifdef B230400 case 230400: - speedsel = B230400; + tmpbaud = B230400; break; #endif +#ifdef B115200 case 115200: - speedsel = B115200; + tmpbaud = B115200; break; +#endif +#ifdef B57600 case 57600: - speedsel = B57600; + tmpbaud = B57600; break; +#endif case 38400: - speedsel = B38400; + tmpbaud = B38400; break; case 19200: - speedsel = B19200; + tmpbaud = B19200; break; case 9600: - speedsel = B9600; + tmpbaud = B9600; break; default: - printf("Unsupported baudrate (%d) - falling back to initial baudrate (%d)\n", speed, INITIAL_SPEED); - *speedtest = speed = INITIAL_SPEED; + tmpspeed = (tmpspeed == INITIAL_SPEED ? 38400 : INITIAL_SPEED); break; } } + *baudconst = tmpbaud; + *speed = tmpspeed; +} - cfsetispeed(&newtio, speedsel); - cfsetospeed(&newtio, speedsel); +void set_io_speed (unsigned int speed, speed_t baudconst) { + struct termios newtio; + + tcgetattr(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; + newtio.c_iflag = IGNPAR; + newtio.c_oflag = 0; + newtio.c_lflag = 0; + newtio.c_cc[VTIME] = 0; // inter-character timer unused + newtio.c_cc[VMIN] = 1; // blocking read until 1 character arrives + + cfsetispeed(&newtio, baudconst); + cfsetospeed(&newtio, baudconst); // we don't error on these because it *may* still work if(tcflush(dcfd, TCIFLUSH) < 0) { @@ -596,6 +597,29 @@ int open_serial(char *devicename, unsigned int speed, unsigned int *speedtest) { } } #endif +} +#endif + +/* setup serial port */ +int open_serial(char *devicename, unsigned int speed, unsigned int *speedtest) { + *speedtest = speed; +#ifndef _WIN32 + speed_t baudconst; + + dcfd = open(devicename, O_RDWR | O_NOCTTY); + if(dcfd < 0) { + perror(devicename); + exit(-1); + } + + oldspeed = speed; + get_supported_speed (&speed, &baudconst); + if (speed != oldspeed){ + printf("Unsupported baudrate (%d) - falling back to baudrate (%d)\n", oldspeed, speed); + *speedtest = speed; + } + + set_io_speed (speed, baudconst); #else BOOL fSuccess; hooks/post-receive -- A serial program loader for the Dreamcast. |
From: Allura u. <al...@so...> - 2023-08-29 21:35:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "UNNAMED PROJECT". The branch, master has been updated via f1af175dd23f233460f5b7aad16d41d46b52b5e9 (commit) via 71e1364d343214101644c2ebcc962958f945deef (commit) from 86bc85d765b6a288e8c6f35c3442801da1b164b8 (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 f1af175dd23f233460f5b7aad16d41d46b52b5e9 Author: darc <da...@pr...> Date: Tue Aug 29 11:51:49 2023 -0500 Fix compiler warnings commit 71e1364d343214101644c2ebcc962958f945deef Author: darc <da...@pr...> Date: Tue Aug 29 11:10:18 2023 -0500 Replace pthreads with KOS threads ----------------------------------------------------------------------- Summary of changes: builtin.c | 26 +++++++++++--------------- kosh.c | 6 +++--- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/builtin.c b/builtin.c index 21dc6df..c577883 100644 --- a/builtin.c +++ b/builtin.c @@ -25,7 +25,6 @@ static SLIST_HEAD(builtin_list, builtin) builtins; /* print command list/desc */ static void builtin_help(int argc, char *argv[]) { - int i; builtin_t * b; if (argc > 1) { @@ -37,13 +36,13 @@ static void builtin_help(int argc, char *argv[]) { } } else { conio_printf("KOSH commands:\n "); - + SLIST_FOREACH(b, &builtins, list) { conio_printf("%s ", b->command); } conio_printf("\nType 'help command' for a description.\n"); - } + } } /* exit the shell */ @@ -165,7 +164,7 @@ static void builtin_hd(int argc, char *argv[]) { char buff[10]; uint32 hnd; int cnt; - + if (argc != 2) { conio_printf("usage: hd file\n"); return; @@ -182,14 +181,14 @@ static void builtin_hd(int argc, char *argv[]) { /* do the hexdump */ while ((cnt = fs_read(hnd, buff, 10)) != 0) { int i; - + for (i = 0; i < cnt; i++) conio_printf("%02x ", (unsigned char) buff[i]); conio_deadvance_cursor(); //cursor.col = 10 * 3 + 2; conio_putch('|'); for (i = 0; i < cnt; i++) { - if (isprint(buff[i])) + if (isprint((int)buff[i])) conio_putch(buff[i]); else conio_putch('.'); @@ -250,7 +249,7 @@ static void builtin_rm(int argc, char *argv[]) { /* create a directory */ static void builtin_mkdir(int argc, char *argv[]) { char fn[NAME_MAX]; - + if (argc != 2) { conio_printf("usage: mkdir dirname\n"); return; @@ -266,7 +265,7 @@ static void builtin_mkdir(int argc, char *argv[]) { /* delete a directory */ static void builtin_rmdir(int argc, char *argv[]) { char fn[NAME_MAX]; - + if (argc != 2) { conio_printf("usage: rmdir dirname\n"); return; @@ -292,7 +291,7 @@ static void builtin_theme(int argc, char *argv[]) { conio_set_theme(CONIO_THEME_C64); else if (strcmp(argv[1], "plain") == 0) conio_set_theme(CONIO_THEME_PLAIN); - else + else conio_printf("unknown theme\n"); } @@ -305,7 +304,7 @@ static void builtin_menu(int argc, char *argv[]) { /* Mount a romdisk image */ static void builtin_mount_romdisk(int argc, char *argv[]) { void * data; - + if (argc != 3) { conio_printf("usage: mount_romdisk srcimg mountpoint\n"); return; @@ -334,15 +333,13 @@ static void builtin_mount_romdisk(int argc, char *argv[]) { /* Print out a list of running threads */ static void builtin_threads(int argc, char *argv[]) { - kthread_t * cur; - thd_pslist(conio_printf); } /* Print out memory usage statistics */ static void builtin_mstats(int argc, char *argv[]) { struct mallinfo mi = mallinfo(); - + conio_printf("Memory usage:\n"); conio_printf(" Max system bytes = %10lu\n", (unsigned long)(mi.usmblks)); @@ -369,7 +366,7 @@ static void builtin_sshot(int argc, char *argv[]) { conio_printf("usage: sshot outfile.ppm\n"); return; } - + /* get the abs path for the dir to create */ makeabspath(fn, argv[1], NAME_MAX); @@ -382,7 +379,6 @@ static void builtin_sshot(int argc, char *argv[]) { /* try to run a builtin command, return 0 if there is no such builtin */ int kosh_builtin_command(int argc, char *argv[]) { - int i; builtin_t * b; SLIST_FOREACH(b, &builtins, list) { diff --git a/kosh.c b/kosh.c index 7e52103..adb118f 100644 --- a/kosh.c +++ b/kosh.c @@ -19,7 +19,7 @@ volatile int kosh_exit = KE_JOINED; /* Our exit semaphore - signaled when the thread exits */ -static pthread_t thd; +static kthread_t *thd; static void * kosh_thread(void *p) { conio_printf(" **** KOSH, The KallistiOS Shell ****\n"); @@ -34,7 +34,7 @@ static void * kosh_thread(void *p) { void kosh_join() { assert( kosh_exit != KE_JOINED ); - pthread_join(thd, NULL); + thd_join(thd, NULL); kosh_exit = KE_JOINED; } @@ -44,7 +44,7 @@ int kosh_init() { kosh_exit = KE_NO; kosh_builtins_init(); - pthread_create(&thd, NULL, kosh_thread, NULL); + thd = thd_create(0, kosh_thread, NULL); return 0; } hooks/post-receive -- UNNAMED PROJECT |
From: ljsebald <ljs...@us...> - 2023-08-28 23:00: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 7094048da2d2c90301611fb963473702f281ef8e (commit) from 2c79c740e9fb3809158076ded9efd25b50b3b32e (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 7094048da2d2c90301611fb963473702f281ef8e Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 18:59:28 2023 -0400 Simplify the structures of some sync primitives. (#281) * Simplify the structures of some sync primitives. Mostly, this removes the useless "initialized" member of structs. * Update CHANGELOG * Fix spelling ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/cond.h | 4 +-- include/kos/mutex.h | 3 ++- include/kos/rwsem.h | 6 ++--- kernel/thread/cond.c | 34 ++++++-------------------- kernel/thread/mutex.c | 8 ++++-- kernel/thread/rwsem.c | 68 +++++++++------------------------------------------ 7 files changed, 32 insertions(+), 92 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index fc8e1a7..c9c8bf5 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -184,6 +184,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC VMU driver update for date/time, buttons, buzzer, and docs [FG] - DC Add spinlock_trylock macro [LS] - *** Simplify kthread_once_t into a simple variable rather than a struct [LS] +- *** Simplify sync primitive structures to remove initialized member [LS] - *** Move definition of __RESTRICT from <sys/_types.h> to <kos/cdefs.h> [LS] KallistiOS version 2.0.0 ----------------------------------------------- diff --git a/include/kos/cond.h b/include/kos/cond.h index aa50a19..5bccfa5 100644 --- a/include/kos/cond.h +++ b/include/kos/cond.h @@ -59,12 +59,12 @@ __BEGIN_DECLS \headerfile kos/cond.h */ typedef struct condvar { - int initialized; + int dummy; int dynamic; } condvar_t; /** \brief Initializer for a transient condvar. */ -#define COND_INITIALIZER { 1, 0 } +#define COND_INITIALIZER { 0, 0 } /** \brief Allocate a new condition variable. diff --git a/include/kos/mutex.h b/include/kos/mutex.h index 088f894..5a2f936 100644 --- a/include/kos/mutex.h +++ b/include/kos/mutex.h @@ -78,7 +78,8 @@ typedef struct kos_mutex { @{ */ -#define MUTEX_TYPE_NORMAL 1 /**< \brief Normal mutex type */ +#define MUTEX_TYPE_NORMAL 0 /**< \brief Normal mutex type */ +#define MUTEX_TYPE_OLDNORMAL 1 /**< \brief Alias for MUTEX_TYPE_NORMAL */ #define MUTEX_TYPE_ERRORCHECK 2 /**< \brief Error-checking mutex type */ #define MUTEX_TYPE_RECURSIVE 3 /**< \brief Recursive mutex type */ diff --git a/include/kos/rwsem.h b/include/kos/rwsem.h index dea6925..0995375 100644 --- a/include/kos/rwsem.h +++ b/include/kos/rwsem.h @@ -40,8 +40,8 @@ __BEGIN_DECLS \headerfile kos/rwsem.h */ typedef struct rw_semaphore { - /** \brief Are we initialized? */ - int initialized; + /** \brief Was this structure created with rwsem_create()? */ + int dynamic; /** \brief The number of readers that are currently holding the lock. */ int read_count; @@ -54,7 +54,7 @@ typedef struct rw_semaphore { } rw_semaphore_t; /** \brief Initializer for a transient reader/writer semaphore */ -#define RWSEM_INITIALIZER { 1, 0, NULL, NULL } +#define RWSEM_INITIALIZER { 0, 0, NULL, NULL } /** \brief Allocate a reader/writer semaphore. diff --git a/kernel/thread/cond.c b/kernel/thread/cond.c index 89600fa..979b317 100644 --- a/kernel/thread/cond.c +++ b/kernel/thread/cond.c @@ -34,14 +34,13 @@ condvar_t *cond_create(void) { return NULL; } - cv->initialized = 1; cv->dynamic = 1; return cv; } int cond_init(condvar_t *cv) { - cv->initialized = 1; + cv->dummy = 0; cv->dynamic = 0; return 0; } @@ -51,8 +50,6 @@ int cond_destroy(condvar_t *cv) { /* Give all sleeping threads a timed out error */ genwait_wake_all_err(cv, ENOTRECOVERABLE); - cv->initialized = 0; - /* Free the memory */ if(cv->dynamic) free(cv); @@ -71,13 +68,8 @@ int cond_wait_timed(condvar_t *cv, mutex_t *m, int timeout) { old = irq_disable(); - if(!cv->initialized) { - errno = EINVAL; - irq_restore(old); - return -1; - } - else if(m->type < MUTEX_TYPE_NORMAL || m->type > MUTEX_TYPE_RECURSIVE || - !mutex_is_locked(m)) { + if(m->type < MUTEX_TYPE_NORMAL || m->type > MUTEX_TYPE_RECURSIVE || + !mutex_is_locked(m)) { errno = EINVAL; irq_restore(old); return -1; @@ -111,14 +103,8 @@ int cond_signal(condvar_t *cv) { old = irq_disable(); - if(!cv->initialized) { - errno = EINVAL; - rv = -1; - } - else { - /* Wake one thread who's waiting */ - genwait_wake_one(cv); - } + /* Wake one thread who's waiting, if any */ + genwait_wake_one(cv); irq_restore(old); @@ -130,14 +116,8 @@ int cond_broadcast(condvar_t *cv) { old = irq_disable(); - if(!cv->initialized) { - errno = EINVAL; - rv = -1; - } - else { - /* Wake all threads who are waiting */ - genwait_wake_all(cv); - } + /* Wake all threads who are waiting */ + genwait_wake_all(cv); irq_restore(old); diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c index 04022bd..14a60bb 100644 --- a/kernel/thread/mutex.c +++ b/kernel/thread/mutex.c @@ -86,8 +86,10 @@ int mutex_lock_timed(mutex_t *m, int timeout) { int old, rv = 0; if((rv = irq_inside_int())) { - dbglog(DBG_WARNING, "%s: called inside an interrupt with code: %x evt: %.4x\n", - timeout ? "mutex_lock_timed" : "mutex_lock", ((rv>>16) & 0xf), (rv & 0xffff)); + dbglog(DBG_WARNING, "%s: called inside an interrupt with code: " + "%x evt: %.4x\n", + timeout ? "mutex_lock_timed" : "mutex_lock", + ((rv >> 16) & 0xf), (rv & 0xffff)); errno = EPERM; return -1; } @@ -165,6 +167,7 @@ int mutex_trylock(mutex_t *m) { switch(m->type) { case MUTEX_TYPE_NORMAL: + case MUTEX_TYPE_OLDNORMAL: case MUTEX_TYPE_ERRORCHECK: if(m->count) { errno = EDEADLK; @@ -198,6 +201,7 @@ static int mutex_unlock_common(mutex_t *m, kthread_t *thd) { switch(m->type) { case MUTEX_TYPE_NORMAL: + case MUTEX_TYPE_OLDNORMAL: m->count = 0; m->holder = NULL; wakeup = 1; diff --git a/kernel/thread/rwsem.c b/kernel/thread/rwsem.c index e917f92..e1b5875 100644 --- a/kernel/thread/rwsem.c +++ b/kernel/thread/rwsem.c @@ -25,7 +25,7 @@ rw_semaphore_t *rwsem_create(void) { return NULL; } - s->initialized = 2; + s->dynamic = 1; s->read_count = 0; s->write_lock = NULL; s->reader_waiting = NULL; @@ -34,7 +34,7 @@ rw_semaphore_t *rwsem_create(void) { } int rwsem_init(rw_semaphore_t *s) { - s->initialized = 1; + s->dynamic = 0; s->read_count = 0; s->write_lock = NULL; s->reader_waiting = NULL; @@ -52,12 +52,9 @@ int rwsem_destroy(rw_semaphore_t *s) { errno = EBUSY; rv = -1; } - else if(s->initialized == 2) { + else if(s->dynamic) { free(s); } - else { - s->initialized = 0; - } irq_restore(old); return rv; @@ -68,9 +65,10 @@ int rwsem_read_lock_timed(rw_semaphore_t *s, int timeout) { int old, rv = 0; if((rv = irq_inside_int())) { - dbglog(DBG_WARNING, "%s: called inside an interrupt with code: %x evt: %.4x\n", + dbglog(DBG_WARNING, "%s: called inside an interrupt with code: " + "%x evt: %.4x\n", timeout ? "rwsem_read_lock_timed" : "rwsem_read_lock", - ((rv>>16) & 0xf), (rv & 0xffff)); + ((rv >> 16) & 0xf), (rv & 0xffff)); errno = EPERM; return -1; } @@ -82,12 +80,6 @@ int rwsem_read_lock_timed(rw_semaphore_t *s, int timeout) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - irq_restore(old); - errno = EINVAL; - return -1; - } - /* If the write lock is not held, let the thread proceed */ if(!s->write_lock) { ++s->read_count; @@ -133,12 +125,6 @@ int rwsem_write_lock_timed(rw_semaphore_t *s, int timeout) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - irq_restore(old); - errno = EINVAL; - return -1; - } - /* If the write lock is not held and there are no readers in their critical sections, let the thread proceed. */ if(!s->write_lock && !s->read_count) { @@ -174,12 +160,6 @@ int rwsem_read_unlock(rw_semaphore_t *s) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - irq_restore(old); - errno = EINVAL; - return -1; - } - if(!s->read_count) { irq_restore(old); errno = EPERM; @@ -210,12 +190,6 @@ int rwsem_write_unlock(rw_semaphore_t *s) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - irq_restore(old); - errno = EINVAL; - return -1; - } - if(s->write_lock != thd_current) { irq_restore(old); errno = EPERM; @@ -242,11 +216,7 @@ int rwsem_unlock(rw_semaphore_t *s) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - errno = EINVAL; - rv = -1; - } - else if(!s->write_lock && !s->read_count) { + if(!s->write_lock && !s->read_count) { errno = EPERM; rv = -1; } @@ -269,12 +239,8 @@ int rwsem_read_trylock(rw_semaphore_t *s) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - rv = -1; - errno = EINVAL; - } /* Is the write lock held? */ - else if(s->write_lock) { + if(s->write_lock) { rv = -1; errno = EWOULDBLOCK; } @@ -293,13 +259,9 @@ int rwsem_write_trylock(rw_semaphore_t *s) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - rv = -1; - errno = EINVAL; - } /* Are there any readers in their critical sections, or is the write lock already held, if so we can't do anything about that now. */ - else if(s->read_count || s->write_lock) { + if(s->read_count || s->write_lock) { rv = -1; errno = EWOULDBLOCK; } @@ -330,13 +292,9 @@ int rwsem_read_upgrade_timed(rw_semaphore_t *s, int timeout) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - rv = -1; - errno = EINVAL; - } /* If there are still other readers, see if any other readers have tried to upgrade or not... */ - else if(s->read_count > 1) { + if(s->read_count > 1) { if(s->reader_waiting) { /* We've got someone ahead of us, so there's really not anything that can be done at this point... */ @@ -383,11 +341,7 @@ int rwsem_read_tryupgrade(rw_semaphore_t *s) { old = irq_disable(); - if(s->initialized != 1 && s->initialized != 2) { - rv = -1; - errno = EINVAL; - } - else if(s->reader_waiting) { + if(s->reader_waiting) { rv = -1; errno = EBUSY; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-28 22:42:03
|
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 2c79c740e9fb3809158076ded9efd25b50b3b32e (commit) via 4405103f6b9e4773adddf281c4f81f4044dcc44b (commit) via b7732a0c831573fd3f525af18b3040a11e051664 (commit) via b19e2dfd133235754b431819fa9a8b812247ec75 (commit) via 2107fca51b5974f2d8349aee0ae0b19836bb1e0e (commit) via 6619915118201759ef6d98bccc3957e306c1c83c (commit) from d8c5c508c5283f0bc28c81b92b8e253d6716cc35 (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 2c79c740e9fb3809158076ded9efd25b50b3b32e Merge: d8c5c50 4405103 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 18:40:06 2023 -0400 Merge pull request #282 from KallistiOS/cplusplus-apparently-hates-optimizations-based-on-pointers C++ apparently hates aliasing-related pointer optimizations. commit 4405103f6b9e4773adddf281c4f81f4044dcc44b Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 17:17:24 2023 -0400 Update CHANGELOG again commit b7732a0c831573fd3f525af18b3040a11e051664 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 17:13:37 2023 -0400 Oops... We already have __RESTRICT. Move it to a more appropriate place and use it. commit b19e2dfd133235754b431819fa9a8b812247ec75 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 17:05:00 2023 -0400 Might as well make this work if you ask for c89/c90/ansi-c as well... commit 2107fca51b5974f2d8349aee0ae0b19836bb1e0e Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 16:50:30 2023 -0400 Update CHANGELOG commit 6619915118201759ef6d98bccc3957e306c1c83c Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 16:48:45 2023 -0400 Add definition of restrict to <kos/cdefs.h> for C++. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/cdefs.h | 14 ++++++++++++++ include/kos/thread.h | 6 +++--- include/sys/_types.h | 11 ----------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index df01c9b..fc8e1a7 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -184,6 +184,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC VMU driver update for date/time, buttons, buzzer, and docs [FG] - DC Add spinlock_trylock macro [LS] - *** Simplify kthread_once_t into a simple variable rather than a struct [LS] +- *** Move definition of __RESTRICT from <sys/_types.h> to <kos/cdefs.h> [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h index a253679..a2f222d 100644 --- a/include/kos/cdefs.h +++ b/include/kos/cdefs.h @@ -115,4 +115,18 @@ /* GCC macros for special cases */ /* #if __GNUC__ == */ +#ifndef __RESTRICT +#if (__STDC_VERSION__ >= 199901L) +#define __RESTRICT restrict +#elif defined(__GNUC__) || defined(__GNUG__) +#define __RESTRICT __restrict__ +#else /* < C99 and not GCC */ +#define __RESTRICT +#endif +#endif /* !__RESTRICT */ + +#ifndef __GNUC__ +#define __extension__ +#endif + #endif /* __KOS_CDEFS_H */ diff --git a/include/kos/thread.h b/include/kos/thread.h index 8464c7d..d61a4cd 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -386,7 +386,7 @@ kthread_t *thd_create(int detach, void *(*routine)(void *param), void *param); \sa thd_create, thd_destroy */ -kthread_t *thd_create_ex(const kthread_attr_t *restrict attr, +kthread_t *thd_create_ex(const kthread_attr_t *__RESTRICT attr, void *(*routine)(void *param), void *param); /** \brief Brutally kill the given thread. @@ -520,7 +520,7 @@ const char *thd_get_label(kthread_t *thd); \sa thd_get_label */ -void thd_set_label(kthread_t *thd, const char *restrict label); +void thd_set_label(kthread_t *thd, const char *__RESTRICT label); /** \brief Retrieve the thread's current working directory. \ingroup threads @@ -553,7 +553,7 @@ const char *thd_get_pwd(kthread_t *thd); \sa thd_get_pwd */ -void thd_set_pwd(kthread_t *thd, const char *restrict pwd); +void thd_set_pwd(kthread_t *thd, const char *__RESTRICT pwd); /** \brief Retrieve a pointer to the thread errno. \ingroup threads diff --git a/include/sys/_types.h b/include/sys/_types.h index 42ab393..bf26c23 100644 --- a/include/sys/_types.h +++ b/include/sys/_types.h @@ -203,16 +203,6 @@ typedef _CLOCK_T_ __clock_t; /* Include stuff to make pthreads work as well. */ #include <sys/_pthread.h> -#ifndef __RESTRICT -#if (__STDC_VERSION__ >= 199901L) -#define __RESTRICT restrict -#elif defined(__GNUC__) || defined(__GNUG__) -#define __RESTRICT __restrict -#else /* < C99 and not GCC */ -#define __RESTRICT -#endif -#endif /* !__RESTRICT */ - #if __GNUC_MINOR__ > 95 || __GNUC__ >= 3 typedef __builtin_va_list __va_list; #else @@ -231,4 +221,3 @@ __END_DECLS #ifdef _STDLIB_H_ #include <kos/stdlib.h> #endif - hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-28 04:16:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via d8c5c508c5283f0bc28c81b92b8e253d6716cc35 (commit) via 4be12632b66d2c4d83cc93703aa1fc33a5e95e3d (commit) from 76e04eac072c41936ed4ce088a1903ff62af533a (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 d8c5c508c5283f0bc28c81b92b8e253d6716cc35 Merge: 76e04ea 4be1263 Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 00:12:57 2023 -0400 Merge pull request #280 from KallistiOS/add-more-missing-includes Add missing includes to a few more more files commit 4be12632b66d2c4d83cc93703aa1fc33a5e95e3d Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 00:11:18 2023 -0400 Add missing includes to a few more more files. ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/hardware/modem/mdata.c | 3 ++- kernel/arch/dreamcast/hardware/network/lan_adapter.c | 2 +- kernel/arch/dreamcast/hardware/spudma.c | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/arch/dreamcast/hardware/modem/mdata.c b/kernel/arch/dreamcast/hardware/modem/mdata.c index f576627..35d7f03 100644 --- a/kernel/arch/dreamcast/hardware/modem/mdata.c +++ b/kernel/arch/dreamcast/hardware/modem/mdata.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## mdata.c - Copyright (C)2002, 2004 Nick Kochakian + Copyright (C) 2002, 2004 Nick Kochakian Distributed under the terms of the KOS license. */ @@ -22,6 +22,7 @@ #include <stdlib.h> #include <string.h> #include <kos/dbglog.h> +#include <kos/thread.h> #include <assert.h> #include <dc/modem/modem.h> #include "mintern.h" diff --git a/kernel/arch/dreamcast/hardware/network/lan_adapter.c b/kernel/arch/dreamcast/hardware/network/lan_adapter.c index 73ced6e..53bdca2 100644 --- a/kernel/arch/dreamcast/hardware/network/lan_adapter.c +++ b/kernel/arch/dreamcast/hardware/network/lan_adapter.c @@ -16,6 +16,7 @@ #include <dc/net/lan_adapter.h> #include <arch/irq.h> #include <kos/net.h> +#include <kos/thread.h> /* @@ -780,4 +781,3 @@ int la_shutdown(void) { la_if_shutdown(&la_if); return 0; } - diff --git a/kernel/arch/dreamcast/hardware/spudma.c b/kernel/arch/dreamcast/hardware/spudma.c index d0d3c13..a1d92f1 100644 --- a/kernel/arch/dreamcast/hardware/spudma.c +++ b/kernel/arch/dreamcast/hardware/spudma.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## spudma.c - Copyright (C)2001,2002,2004 Megan Potter + Copyright (C) 2001, 2002, 2004 Megan Potter */ #include <assert.h> @@ -10,6 +10,7 @@ #include <dc/spu.h> #include <dc/asic.h> #include <kos/sem.h> +#include <kos/thread.h> /* testing */ #define ASIC_IRQ ASIC_IRQB @@ -283,4 +284,3 @@ void spu_dma_shutdown(void) { dma_disable(i); } } - hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-28 04:08: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 "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 76e04eac072c41936ed4ce088a1903ff62af533a (commit) via a3ab86d6b4b54f2c27e354131600f904767a325a (commit) from 742e9a0888b4a7f340e8d23635ee681582a2c9d1 (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 76e04eac072c41936ed4ce088a1903ff62af533a Merge: 742e9a0 a3ab86d Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 28 00:07:14 2023 -0400 Merge pull request #277 from KallistiOS/tiny-thread-cleanups Small cleanups to thread.h and thread.c commit a3ab86d6b4b54f2c27e354131600f904767a325a Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 25 19:46:19 2023 -0400 Small cleanups to thread.h and thread.c. - Normalized a bunch of formatting. - Added restrict to two pointers. ----------------------------------------------------------------------- Summary of changes: include/kos/thread.h | 38 +++++++++++++++++++------------------- kernel/thread/thread.c | 38 +++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/kos/thread.h b/include/kos/thread.h index 197c941..8464c7d 100644 --- a/include/kos/thread.h +++ b/include/kos/thread.h @@ -63,7 +63,7 @@ __BEGIN_DECLS thd_detach()). The old KOS threading system only had what would be considered detached threads. - \sa semaphore_t, mutex_t, kthread_once_t, kthread_key_t + \sa semaphore_t, mutex_t, kthread_once_t, kthread_key_t, rw_semaphore_t */ /** \brief Maximal thread priority. @@ -140,11 +140,11 @@ typedef struct kthread { /** \brief Generic wait target, if waiting. \see kos/genwait.h */ - void * wait_obj; + void *wait_obj; /** \brief Generic wait message, if waiting. \see kos/genwait.h */ - const char * wait_msg; + const char *wait_msg; /** \brief Wait timeout callback. @@ -153,7 +153,7 @@ typedef struct kthread { \param obj The object that we were waiting on. */ - void (*wait_callback)(void * obj); + void (*wait_callback)(void *obj); /** \brief Next scheduled time. This value is used for sleep and timed block operations. This value is @@ -255,7 +255,7 @@ typedef struct kthread_attr { /** \defgroup thd_modes Threading system modes \ingroup threads - The threading system will always be in one of the following modes. This + The threading system will always be in one of the following modes. This represents either pre-emptive scheduling or an un-initialized state. @{ @@ -290,7 +290,7 @@ extern kthread_t *thd_current; \return Whatever the unblocker deems necessary to return. */ -int thd_block_now(irq_context_t * mycxt); +int thd_block_now(irq_context_t *mycxt); /** \brief Find a new thread to swap in. \ingroup threads @@ -305,7 +305,7 @@ int thd_block_now(irq_context_t * mycxt); \return The IRQ context of the thread selected. */ -irq_context_t * thd_choose_new(void); +irq_context_t *thd_choose_new(void); /** \brief Given a thread ID, locates the thread structure. \ingroup threads @@ -368,7 +368,7 @@ int thd_remove_from_runnable(kthread_t *thd); \sa thd_create_ex, thd_destroy */ -kthread_t *thd_create(int detach, void * (*routine)(void *param), void *param); +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 @@ -386,8 +386,8 @@ kthread_t *thd_create(int detach, void * (*routine)(void *param), void *param); \sa thd_create, thd_destroy */ -kthread_t *thd_create_ex(kthread_attr_t *attr, void *(*routine)(void *), - void *param); +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 @@ -422,7 +422,7 @@ void thd_exit(void *rv) __noreturn; \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 + interrupt. You will most likely never have a reason to call this function directly. For most cases, you'll want to set front_of_line to zero, but read the @@ -520,7 +520,7 @@ const char *thd_get_label(kthread_t *thd); \sa thd_get_label */ -void thd_set_label(kthread_t *thd, const char *label); +void thd_set_label(kthread_t *thd, const char *restrict label); /** \brief Retrieve the thread's current working directory. \ingroup threads @@ -553,7 +553,7 @@ const char *thd_get_pwd(kthread_t *thd); \sa thd_get_pwd */ -void thd_set_pwd(kthread_t *thd, const char *pwd); +void thd_set_pwd(kthread_t *thd, const char *restrict pwd); /** \brief Retrieve a pointer to the thread errno. \ingroup threads @@ -566,7 +566,7 @@ void thd_set_pwd(kthread_t *thd, const char *pwd); \return A pointer to the thread's errno. */ -int * thd_get_errno(kthread_t *thd); +int *thd_get_errno(kthread_t *thd); /** \brief Retrieve a pointer to the thread reent struct. \ingroup threads @@ -579,7 +579,7 @@ int * thd_get_errno(kthread_t *thd); \return The thread's reent struct. */ -struct _reent * thd_get_reent(kthread_t *thd); +struct _reent *thd_get_reent(kthread_t *thd); /** \brief Change threading modes. \ingroup threads @@ -595,7 +595,7 @@ struct _reent * thd_get_reent(kthread_t *thd); \sa thd_get_mode */ -int thd_set_mode(int mode) __attribute__((deprecated)); +int thd_set_mode(int mode) __deprecated; /** \brief Fetch the current threading mode. \ingroup threads @@ -609,7 +609,7 @@ int thd_set_mode(int mode) __attribute__((deprecated)); \sa thd_set_mode */ -int thd_get_mode(void) __attribute__((deprecated)); +int thd_get_mode(void) __deprecated; /** \brief Wait for a thread to exit. \ingroup threads @@ -628,7 +628,7 @@ int thd_get_mode(void) __attribute__((deprecated)); \sa thd_detach */ -int thd_join(kthread_t * thd, void **value_ptr); +int thd_join(kthread_t *thd, void **value_ptr); /** \brief Detach a joinable thread. \ingroup threads @@ -657,7 +657,7 @@ int thd_detach(kthread_t *thd); \sa thd_pslist */ -int thd_each(int (*cb)(kthread_t* thd, void* user_data), void* data); +int thd_each(int (*cb)(kthread_t *thd, void *user_data), void *data); /** \brief Print a list of all threads using the given print function. \ingroup threads diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c index bec84ab..a0fa789 100644 --- a/kernel/thread/thread.c +++ b/kernel/thread/thread.c @@ -68,7 +68,7 @@ static kthread_t *thd_idle_thd = NULL; /*****************************************************************************/ /* Debug */ -static const char *thd_state_to_str(kthread_t * thd) { +static const char *thd_state_to_str(kthread_t *thd) { switch(thd->state) { case STATE_ZOMBIE: return "zombie"; @@ -90,7 +90,7 @@ static const char *thd_state_to_str(kthread_t * thd) { } } -int thd_each(int (*cb)(kthread_t* thd, void* user_data), void* data) { +int thd_each(int (*cb)(kthread_t *thd, void *user_data), void *data) { kthread_t *cur; LIST_FOREACH(cur, &thd_list, t_list) { @@ -226,7 +226,7 @@ static void *thd_reaper(void *param) { /* Thread execution wrapper; when the thd_create function below adds a new thread to the thread chain, this function is the one that gets called in the new context. */ -static void thd_birth(void * (*routine)(void *param), void *param) { +static void thd_birth(void *(*routine)(void *param), void *param) { /* Call the thread function */ void *rv = routine(param); @@ -328,8 +328,8 @@ int thd_remove_from_runnable(kthread_t *thd) { /* 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. */ -kthread_t *thd_create_ex(kthread_attr_t *attr, void * (*routine)(void *param), - void *param) { +kthread_t *thd_create_ex(const kthread_attr_t *restrict attr, + void *(*routine)(void *param), void *param) { kthread_t *nt = NULL; tid_t tid; uint32_t params[4]; @@ -625,7 +625,7 @@ void thd_schedule_next(kthread_t *thd) { } /* See kos/thread.h for description */ -irq_context_t * thd_choose_new(void) { +irq_context_t *thd_choose_new(void) { uint64_t now = timer_ms_gettime64(); //printf("thd_choose_new() woken at %d\n", (uint32_t)now); @@ -663,7 +663,8 @@ static void thd_timer_hnd(irq_context_t *context) { void thd_sleep(int ms) { /* This should never happen. This should, perhaps, assert. */ if(thd_mode == THD_MODE_NONE) { - dbglog(DBG_WARNING, "thd_sleep called when threading not initialized.\n"); + dbglog(DBG_WARNING, "thd_sleep called when threading not " + "initialized.\n"); timer_spin_sleep(ms); return; } @@ -693,7 +694,7 @@ void thd_pass(void) { } /* Wait for a thread to exit */ -int thd_join(kthread_t * thd, void **value_ptr) { +int thd_join(kthread_t *thd, void **value_ptr) { int old, rv; kthread_t * t = NULL; @@ -702,9 +703,9 @@ int thd_join(kthread_t * thd, void **value_ptr) { return -1; if((rv = irq_inside_int())) { - dbglog(DBG_WARNING, "thd_join(%p) called inside an interrupt with code: %x evt: %.4x\n", - (void *)thd, - ((rv>>16) & 0xf), (rv & 0xffff)); + dbglog(DBG_WARNING, "thd_join(%p) called inside an interrupt with " + "code: %x evt: %.4x\n", (void *)thd, ((rv >> 16) & 0xf), + (rv & 0xffff)); return -1; } @@ -721,7 +722,7 @@ int thd_join(kthread_t * thd, void **value_ptr) { if(t != thd) { rv = -2; } - else if(thd->flags & THD_DETACHED) { + else if((thd->flags & THD_DETACHED)) { /* Can't join a detached thread */ rv = -3; } @@ -791,7 +792,7 @@ const char *thd_get_label(kthread_t *thd) { return thd->label; } -void thd_set_label(kthread_t *thd, const char *label) { +void thd_set_label(kthread_t *thd, const char *restrict label) { strncpy(thd->label, label, sizeof(thd->label) - 1); } @@ -805,15 +806,15 @@ const char *thd_get_pwd(kthread_t *thd) { return thd->pwd; } -void thd_set_pwd(kthread_t *thd, const char *pwd) { +void thd_set_pwd(kthread_t *thd, const char *restrict pwd) { strncpy(thd->pwd, pwd, sizeof(thd->pwd) - 1); } -int * thd_get_errno(kthread_t * thd) { +int *thd_get_errno(kthread_t *thd) { return &thd->thd_errno; } -struct _reent * thd_get_reent(kthread_t *thd) { +struct _reent *thd_get_reent(kthread_t *thd) { return &thd->thd_reent; } @@ -821,9 +822,8 @@ struct _reent * thd_get_reent(kthread_t *thd) { /* Change threading modes */ int thd_set_mode(int mode) { - - dbglog(DBG_WARNING, "thd_set_mode has no effect. Cooperative threading \ - mode is deprecated. KOS is always in pre-emptive threading mode. \n"); + dbglog(DBG_WARNING, "thd_set_mode() has no effect. Cooperative threading " + "mode is deprecated. Threading is always in preemptive mode.\n"); return mode; } hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-27 21:06: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 742e9a0888b4a7f340e8d23635ee681582a2c9d1 (commit) via 0097eedacfd1338af58fa5c816473767efcc7689 (commit) from 44a00891dbb947f17d34fcc9cf66cc0aa67f37e1 (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 742e9a0888b4a7f340e8d23635ee681582a2c9d1 Merge: 44a0089 0097eed Author: Lawrence Sebald <ljs...@us...> Date: Sun Aug 27 17:05:32 2023 -0400 Merge pull request #279 from KallistiOS/libppp-missing-include Add missing #include <kos/thread.h> to libppp/ppp_modem.c commit 0097eedacfd1338af58fa5c816473767efcc7689 Author: Lawrence Sebald <ljs...@us...> Date: Sun Aug 27 17:04:01 2023 -0400 Add missing #include <kos/thread.h> to libppp/ppp_modem.c ----------------------------------------------------------------------- Summary of changes: addons/libppp/ppp_modem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/libppp/ppp_modem.c b/addons/libppp/ppp_modem.c index 3d9a2e8..3556321 100644 --- a/addons/libppp/ppp_modem.c +++ b/addons/libppp/ppp_modem.c @@ -8,6 +8,7 @@ #include <stdint.h> #include <kos/dbglog.h> +#include <kos/thread.h> #include <arch/timer.h> hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-08-25 05:00:27
|
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 44a00891dbb947f17d34fcc9cf66cc0aa67f37e1 (commit) via 8cb450f8bdb86995faa78d6b8245f7dca2f16361 (commit) from f848bf2b1e89a10fc7c5a097e81f28a7ab39ea03 (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 44a00891dbb947f17d34fcc9cf66cc0aa67f37e1 Merge: f848bf2 8cb450f Author: Falco Girgis <gyr...@gm...> Date: Thu Aug 24 23:58:47 2023 -0500 Merge pull request #276 from KallistiOS/simple-once Simplify kthread_once_t into a simple variable rather than a struct commit 8cb450f8bdb86995faa78d6b8245f7dca2f16361 Author: Lawrence Sebald <ljs...@us...> Date: Fri Aug 25 00:23:00 2023 -0400 Simplify kthread_once_t into a simple variable rather than a struct. ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + examples/dreamcast/basic/threading/once/once_test.c | 8 ++++++-- include/kos/once.h | 15 ++++++--------- kernel/thread/once.c | 11 +++++++---- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 2d163c9..df01c9b 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -183,6 +183,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Refactored controller API, added capability groups and types [FG] - DC VMU driver update for date/time, buttons, buzzer, and docs [FG] - DC Add spinlock_trylock macro [LS] +- *** Simplify kthread_once_t into a simple variable rather than a struct [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/examples/dreamcast/basic/threading/once/once_test.c b/examples/dreamcast/basic/threading/once/once_test.c index da3a77e..3029894 100644 --- a/examples/dreamcast/basic/threading/once/once_test.c +++ b/examples/dreamcast/basic/threading/once/once_test.c @@ -1,11 +1,11 @@ /* KallistiOS ##version## once_test.c - Copyright (C) 2009 Lawrence Sebald + Copyright (C) 2009, 2023 Lawrence Sebald */ -/* This program is a test for the kthread_once_t type added in KOS 1.3.0. A once +/* This program is a test for the kthread_once_t type added in KOS 2.0.0. A once object is used with the kthread_once function to ensure that an initializer function is only run once in a program (meaning multiple threads will not run the function. */ @@ -15,6 +15,7 @@ #include <kos/once.h> #include <arch/arch.h> +#include <arch/spinlock.h> #include <dc/maple.h> #include <dc/maple/controller.h> @@ -22,10 +23,13 @@ #define THD_COUNT 600 kthread_once_t once = KTHREAD_ONCE_INIT; +spinlock_t lock = SPINLOCK_INITIALIZER; int counter = 0; void once_func(void) { + spinlock_lock(&lock); ++counter; + spinlock_unlock(&lock); } void *thd_func(void *param UNUSED) { diff --git a/include/kos/once.h b/include/kos/once.h index b303b37..5bdcc9f 100644 --- a/include/kos/once.h +++ b/include/kos/once.h @@ -1,7 +1,7 @@ /* KallistiOS ##version## include/kos/once.h - Copyright (C) 2009, 2010 Lawrence Sebald + Copyright (C) 2009, 2010, 2023 Lawrence Sebald */ @@ -31,13 +31,10 @@ __BEGIN_DECLS \headerfile kos/once.h */ -typedef struct { - int initialized; - int run; -} kthread_once_t; +typedef volatile int kthread_once_t; /** \brief Initializer for a kthread_once_t object. */ -#define KTHREAD_ONCE_INIT { 1, 0 } +#define KTHREAD_ONCE_INIT 0 /** \brief Run a function once. @@ -48,9 +45,9 @@ typedef struct { \param once_control The kthread_once_t object to run against. \param init_routine The function to call. - \retval -1 On failure, and sets errno to one of the following: ENOMEM - if out of memory, EPERM if called inside an interrupt, or - EINTR if interrupted. + \retval -1 On failure, and sets errno to one of the following: EPERM if + called inside an interrupt or EINVAL if *once_control is not + valid or was not initialized with KTHREAD_ONCE_INIT. \retval 0 On success. */ int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)); diff --git a/kernel/thread/once.c b/kernel/thread/once.c index 953ac27..1d3f29c 100644 --- a/kernel/thread/once.c +++ b/kernel/thread/once.c @@ -1,7 +1,7 @@ /* KallistiOS ##version## once.c - Copyright (C) 2009 Lawrence Sebald + Copyright (C) 2009, 2023 Lawrence Sebald */ #include <malloc.h> @@ -18,7 +18,10 @@ static mutex_t lock = RECURSIVE_MUTEX_INITIALIZER; int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)) { - assert(once_control); + if(!once_control || *once_control < 0 || *once_control > 1) { + errno = EINVAL; + return -1; + } /* Lock the lock. */ if(mutex_lock(&lock) == -1) { @@ -26,13 +29,13 @@ int kthread_once(kthread_once_t *once_control, void (*init_routine)(void)) { } /* If the function has already been run, unlock the lock and return. */ - if(once_control->run) { + if(*once_control) { mutex_unlock(&lock); return 0; } /* Run the function, set the control, and unlock the lock. */ - once_control->run = 1; + *once_control = 1; init_routine(); mutex_unlock(&lock); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-08-25 04:01:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via f848bf2b1e89a10fc7c5a097e81f28a7ab39ea03 (commit) via e5ed50edcc5e95d2bc94a29fe558d0a9d754dd35 (commit) via d89cf26c3d9b61f0e846e1d27dff3a6f9e747329 (commit) via e3de4ae4b21298bfd7ec6eaa23174cf9e441ec9d (commit) from a3fc2fe314f2ed27e177a2404a071367bb2cb92b (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 f848bf2b1e89a10fc7c5a097e81f28a7ab39ea03 Merge: d89cf26 e5ed50e Author: Falco Girgis <gyr...@gm...> Date: Thu Aug 24 23:00:49 2023 -0500 Merge pull request #274 from KallistiOS/spinlock-trylock Add spinlock_trylock macro commit e5ed50edcc5e95d2bc94a29fe558d0a9d754dd35 Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 24 22:05:59 2023 -0400 Add spinlock_trylock macro. commit d89cf26c3d9b61f0e846e1d27dff3a6f9e747329 Merge: a3fc2fe e3de4ae Author: darcagn <da...@pr...> Date: Wed Aug 23 21:27:34 2023 -0500 Merge pull request #273 from KallistiOS/changelog_update Updated CHANGELOG to reflect VMU driver update commit e3de4ae4b21298bfd7ec6eaa23174cf9e441ec9d Author: Falco Girgis <gyr...@gm...> Date: Wed Aug 23 16:39:02 2023 -0500 Updated CHANGELOG to reflect VMU driver update ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 2 ++ kernel/arch/dreamcast/include/arch/spinlock.h | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 203eaed..2d163c9 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -181,6 +181,8 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Implemented posix_memalign() from stdlib.h [FG] - *** Added clock_gettime(), clock_settime(), clock_getres() [FG] - DC Refactored controller API, added capability groups and types [FG] +- DC VMU driver update for date/time, buttons, buzzer, and docs [FG] +- DC Add spinlock_trylock macro [LS] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/kernel/arch/dreamcast/include/arch/spinlock.h b/kernel/arch/dreamcast/include/arch/spinlock.h index 8f87eb3..baee820 100644 --- a/kernel/arch/dreamcast/include/arch/spinlock.h +++ b/kernel/arch/dreamcast/include/arch/spinlock.h @@ -76,6 +76,28 @@ typedef volatile int spinlock_t; } \ } while(0) +/** \brief Try to lock, without spinning. + + This macro will attempt to lock the lock, but will not spin. Instead, it + will return whether the lock was obtained or not. + + \param A A pointer to the spinlock to be locked. + \return 0 if the lock is held by another thread. Non-zero if + the lock was successfully obtained. +*/ +#define spinlock_trylock(A) ({ \ + int __gotlock = 0; \ + do { \ + spinlock_t *__lock = A; \ + __asm__ __volatile__("tas.b @%1\n\t" \ + "movt %0\n\t" \ + : "=r" (__gotlock) \ + : "r" (__lock) \ + : "t", "memory"); \ + } while(0); \ + __gotlock; \ + }) + /** \brief Free a lock. This macro will unlock the lock that is currently held by the calling @@ -100,4 +122,3 @@ typedef volatile int spinlock_t; __END_DECLS #endif /* __ARCH_SPINLOCK_H */ - hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-23 04:36:32
|
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 a3fc2fe314f2ed27e177a2404a071367bb2cb92b (commit) via e3fcd675a1cdc1cf85404c7d206be23855a40921 (commit) from 2e1153d508fe7f7fbf9ed6d2746d50792e2373d2 (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 a3fc2fe314f2ed27e177a2404a071367bb2cb92b Author: Falco Girgis <gyr...@gm...> Date: Tue Aug 22 23:34:45 2023 -0500 VMU driver support for date/time and buttons + documentation update (#207) * Added support for VMU time, buttons, and buzzer. 1) vmu_beep(): convenience high-level buzzer API - This function is provided for convenience around vmu_beep_raw(), and actually understands the alarm values represented by the arguments, ignoring unsupported values, naming them appropriately and then delegating back to vmu_beep_raw(). - We should keep vmu_beep_raw(), though, in case some 3rd party controller comes around which does have support for two sets of alarms. 2) vmu_get_time(), vmu_set_time(): time management - These two functions along with a corresponding structure were added for querying and setting the times and dates on the VMU. The structure's format and expected value ranges were commented. 3) vmu_get_btns(): query for button states - The VMU's button states are actually still accessible via the Maple BUS while attached to the controller. The "Retro Fighters" Dreamcast controller is currently the only known controller that allows you to leverage this, but being able to support a few extra buttons could be a nice thing to have in a game or app. * Cleanup + periodic driver polling for button state - Cleaned up VMU button macros to match controller buttons - Implemented periodic polling mechanism for querying button state * conditional: disabled by default, enabled via vmu_set_buttons_enabled(..) * only queries for button input on first unit, which should be the front-facing one to save maple frames * Stylistic fixes for VMU driver additions - BlueCrab pointed out a variety of ways in which the code was not adhering to the coding standards already established by KOS. Fixed. * Added (void) to empty arg lists in API * VMU Cleanup, documentation, beep waveform diagram - added top-level VMU module - fleshed out function documentation - added documentation + ACII diagram for new beep routine - changed VMU time functions from taking custom VMU-centric date/time struct to taking standard C time_t types - fixed some styling to be consistent - fixed const-correctness on 1 or 2 function args - added documentation for VMU icons in bios font - renamed vmu_set/get_date to vmu_set/get_datetime - reorganized functions by Maple function type - fixed a bunch of formatting - changed everything from uints to uint_ts - Removed magic numbers for VMU screen sizes and added public #define to API - Added #define for # of ms to sleep before retrying when writing a block fails * Docs work, vmu_get_icon_color, vmu_get_icon_shape - Minor formatting changes - Continued adding documentation - Added prototypes and header documetnation for - vmu_get_custom_color - vmu_get_icon_shape * More API + Documentation work on buzzer waveforms - Tweaked new, high-level buzzer API - Documented the living crap out of the buzzer's characteristics based on all of our analysis of the VMU BIOS and buzzer hardware testing. - Added todo list to keep myself on-track and make notes for driver additions/changes that are needed for full feature coverage and complete documentation * SOOOO much documenting for Maple feature modules. * Tiny bit more documentation update. * VMU date/time support fully tested and working * VMU button input support is done and tested! - Finished up VMU button input querying - Had one bug that was an assertion that had to be removed - Tested it with multiple controller types - Had to implement the intelligence to automatically reorient dpad buttons based on connector direction - The standard VMUs apparently do not query for MODE or SLEEP presses * Entire module's Doxygen documentation done! * Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> * Resolved beep/settime issues with lots of traffic - Under a high load with button polling, the calls to vmu_set_datetime() and vmu_beep_raw() were failing intermittently with MAPLE_EAGAIN. It looks like this same issue must've been seen and resolved with vmu_block_read(), as it contains the fix, which is to yield the thread until the frame is unlocked - Removed a few trailing spaces introduced into biosfont.h --------- Co-authored-by: Lawrence Sebald <ljs...@us...> commit e3fcd675a1cdc1cf85404c7d206be23855a40921 Author: Falco Girgis <gyr...@gm...> Date: Tue Aug 22 23:30:12 2023 -0500 Controller refactor, documentation, capability queries (#212) * Controller cleanup, docs, capability categories - moved cont_cond_t to .c file as a private structure, since nothing is using it publically, and it just confuses people - added top-level "Controller" doxygen module for grouping everything related to the API - added an anonymous union with button state bitfields to the cont_state_t structure, to simplify checking button states while also maintaining backwards compatibility - fixed miscellaneous formatting issues - reorganized controller.h to group things logically - created "capability category" #defines (pending definitions) for grouping together button capability masks into logical units - added prototypes for high-level API used to check for 1) right analog stick support 2) right dpad support 3) any extended buttons 4) standard controller configuration - changed uintN types to uintN_t types * More Controller API documentation cleanup * Revert cb userdata, controller capabilities, types - Changed Doxyfile to alphabetize modules - Added queryable aggregate controller capability groups - Added queryable controller types - Removed userdata pointer from callbacks, because it was argued a bad idea for a context in which interrupts are disabled - Added a warning to the controller button callback mechanism to clearly describe this side effect - Modified a few C++ examples which were doing raw casts on the button callback to the expected type, not even matching exact arguments, which is sketchy... Better example which is more robust is to teach people to use the typedef provided by KOS. * More API documentation, maple connector_dir * Finished documenting and testing API * Fixed a typo in racing controller type macro * Added final comments to aggregate capabilities. * Forgot to update the changelog! * Tiny typo in documentation. * Fixed comment for maple_devinfo's connector_dir * Undid joystick axis translation change - UINT8_MAX != 128, accidentally screwed that up. * Controller cleanup, docs, capability categories - moved cont_cond_t to .c file as a private structure, since nothing is using it publically, and it just confuses people - added top-level "Controller" doxygen module for grouping everything related to the API - added an anonymous union with button state bitfields to the cont_state_t structure, to simplify checking button states while also maintaining backwards compatibility - fixed miscellaneous formatting issues - reorganized controller.h to group things logically - created "capability category" #defines (pending definitions) for grouping together button capability masks into logical units - added prototypes for high-level API used to check for 1) right analog stick support 2) right dpad support 3) any extended buttons 4) standard controller configuration - changed uintN types to uintN_t types * More Controller API documentation cleanup * Revert cb userdata, controller capabilities, types - Changed Doxyfile to alphabetize modules - Added queryable aggregate controller capability groups - Added queryable controller types - Removed userdata pointer from callbacks, because it was argued a bad idea for a context in which interrupts are disabled - Added a warning to the controller button callback mechanism to clearly describe this side effect - Modified a few C++ examples which were doing raw casts on the button callback to the expected type, not even matching exact arguments, which is sketchy... Better example which is more robust is to teach people to use the typedef provided by KOS. * More API documentation, maple connector_dir * Finished documenting and testing API * Fixed a typo in racing controller type macro * Added final comments to aggregate capabilities. * Master rebase, CHANGELOG update, cont state update - Rebased on mast to pick up everybody's changes - Added zcrc's VMU FB stuff to CHANGELOG cuz he forgot - changed the padding in the cont_state struct to be unnamed, because apparently that's a thing I never knew you could do in C * Tiny typo in documentation. * Fixed comment for maple_devinfo's connector_dir * Undid joystick axis translation change - UINT8_MAX != 128, accidentally screwed that up. * Clean up Makefiles (#220) Clean up Makefiles for examples. * Move vector.h from addons to core. (#218) * Move vector.h from addons to core. The core matrix API depends on the typedefs in vector.h, which currently lives in the addons tree. This change moves these typed back to the core kernel tree so that we don't have a dependency from addons back to the kernel. Signed-off-by: James Peach <jp...@ap...> * Update Doxygen comments for dc/vector.h. Signed-off-by: James Peach <jp...@ap...> --------- Signed-off-by: James Peach <jp...@ap...> * Update AUTHORS (#221) Add Paul Cercueil, aka "zcrc" to AUTHORS. * Added fast math CFlags to environ.sh.sample - Added fasth math KOS_CFLAGS to environ.sh.sample, defaulting to commented out, with a description of when and why you'd want to enable them - Removed -fno-builtin from the environ_base.sh script * Added -fno-builtin to environ.sh.sample - Removed -fno-builtin from environ_base.sh - Added it back to environ.sh.sample with a comment on how to disable it and an explanation of the implications of doing so * Add optimized ASM bit-reverse function This function can be used to bit-reverse a 32-bit value (where the MSB becomes the LSB and vice-versa). Signed-off-by: Paul Cercueil <pa...@cr...> * vmu: constify bitmap argument to vmu_draw_lcd() The data pointed by the bitmap argument is never modified by the function. Therefore, it should be marked const. Signed-off-by: Paul Cercueil <pa...@cr...> * vmu: Add function vmu_draw_lcd_rotated() This function is equivalent to vmu_draw_lcd, but the image is rotated 180° so that the first byte of the bitmap corresponds to the top-left corner, instead of the bottom-right one. Signed-off-by: Paul Cercueil <pa...@cr...> * Update kernel/arch/dreamcast/include/dc/maple/controller.h Quzarifying ASCII art Co-authored-by: Donald Haase <qu...@ya...> * Added a bunch of controller types. Thanks TChan0! * Addressed a few points from code review (Quzar's) * Update kernel/arch/dreamcast/include/dc/maple/controller.h Co-authored-by: Donald Haase <qu...@ya...> * Addressing more review feedback from Quzar * Fixed changelog: DC-specific changes, not common. * Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> --------- Signed-off-by: James Peach <jp...@ap...> Signed-off-by: Paul Cercueil <pa...@cr...> Co-authored-by: Andress Barajas <and...@gm...> Co-authored-by: James Peach <jp...@ap...> Co-authored-by: Paul Cercueil <pa...@cr...> Co-authored-by: Donald Haase <qu...@ya...> Co-authored-by: Lawrence Sebald <ljs...@us...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + doc/Doxyfile | 4 +- kernel/arch/dreamcast/hardware/maple/controller.c | 49 +- kernel/arch/dreamcast/hardware/maple/vmu.c | 363 ++++++++++--- kernel/arch/dreamcast/include/dc/biosfont.h | 14 +- kernel/arch/dreamcast/include/dc/maple.h | 2 +- .../arch/dreamcast/include/dc/maple/controller.h | 566 +++++++++++++++++---- kernel/arch/dreamcast/include/dc/maple/vmu.h | 528 ++++++++++++++++--- 8 files changed, 1282 insertions(+), 245 deletions(-) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 70f838c..203eaed 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -180,6 +180,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - *** Split init flags from <arch/arch.h> into <kos/init.h> [LS] - *** Implemented posix_memalign() from stdlib.h [FG] - *** Added clock_gettime(), clock_settime(), clock_getres() [FG] +- DC Refactored controller API, added capability groups and types [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/doc/Doxyfile b/doc/Doxyfile index 7df6ccd..fcff64c 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -679,7 +679,7 @@ SORT_MEMBERS_CTORS_1ST = NO # appear in their defined order. # The default value is: NO. -SORT_GROUP_NAMES = NO +SORT_GROUP_NAMES = YES # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by # fully-qualified names, including namespaces. If set to NO, the class list will @@ -2303,7 +2303,7 @@ EXPAND_AS_DEFINED = __BEGIN_DECLS \ # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -SKIP_FUNCTION_MACROS = YES +SKIP_FUNCTION_MACROS = NO #--------------------------------------------------------------------------- # Configuration options related to external references diff --git a/kernel/arch/dreamcast/hardware/maple/controller.c b/kernel/arch/dreamcast/hardware/maple/controller.c index 8d92c1d..02a677d 100644 --- a/kernel/arch/dreamcast/hardware/maple/controller.c +++ b/kernel/arch/dreamcast/hardware/maple/controller.c @@ -11,22 +11,49 @@ #include <string.h> #include <assert.h> +/* Location of controller capabilities within function_data array */ +#define CONT_FUNCTION_DATA_INDEX 0 + +/* Raw controller condition structure */ +typedef struct cont_cond { + uint16_t buttons; /* buttons bitfield */ + uint8_t rtrig; /* right trigger */ + uint8_t ltrig; /* left trigger */ + uint8_t joyx; /* joystick X */ + uint8_t joyy; /* joystick Y */ + uint8_t joy2x; /* second joystick X */ + uint8_t joy2y; /* second joystick Y */ +} cont_cond_t; + static cont_btn_callback_t btn_callback = NULL; -static uint8 btn_callback_addr = 0; -static uint32 btn_callback_btns = 0; +static uint8_t btn_callback_addr = 0; +static uint32_t btn_callback_btns = 0; + +/* Check whether the controller has EXACTLY the given capabilties. */ +int cont_is_type(const maple_device_t *cont, uint32_t type) { + return cont ? cont->info.function_data[CONT_FUNCTION_DATA_INDEX] == type : + -1; +} + +/* Check whether the controller has at LEAST the given capabilities. */ +int cont_has_capabilities(const maple_device_t *cont, uint32_t capabilities) { + return cont ? ((cont->info.function_data[CONT_FUNCTION_DATA_INDEX] + & capabilities) == capabilities) : -1; +} /* Set a controller callback for a button combo; set addr=0 for any controller */ -void cont_btn_callback(uint8 addr, uint32 btns, cont_btn_callback_t cb) { +void cont_btn_callback(uint8_t addr, uint32_t btns, cont_btn_callback_t cb) { btn_callback_addr = addr; btn_callback_btns = btns; btn_callback = cb; } +/* Response callback for the GETCOND Maple command. */ static void cont_reply(maple_frame_t *frm) { - maple_response_t *resp; - uint32 *respbuf; - cont_cond_t *raw; - cont_state_t *cooked; + maple_response_t *resp; + uint32_t *respbuf; + cont_cond_t *raw; + cont_state_t *cooked; /* Unlock the frame now (it's ok, we're in an IRQ) */ maple_frame_unlock(frm); @@ -37,7 +64,7 @@ static void cont_reply(maple_frame_t *frm) { if(resp->response != MAPLE_RESPONSE_DATATRF) return; - respbuf = (uint32 *)resp->data; + respbuf = (uint32_t *)resp->data; if(respbuf[0] != MAPLE_FUNC_CONTROLLER) return; @@ -45,7 +72,7 @@ static void cont_reply(maple_frame_t *frm) { /* Update the status area from the response */ if(frm->dev) { /* Verify the size of the frame and grab a pointer to it */ - assert(sizeof(cont_cond_t) == ((resp->data_len - 1) * 4)); + assert(sizeof(cont_cond_t) == ((resp->data_len - 1) * sizeof(uint32_t))); raw = (cont_cond_t *)(respbuf + 1); /* Fill the "nice" struct from the raw data */ @@ -74,13 +101,13 @@ static void cont_reply(maple_frame_t *frm) { } static int cont_poll(maple_device_t *dev) { - uint32 * send_buf; + uint32_t *send_buf; if(maple_frame_lock(&dev->frame) < 0) return 0; maple_frame_init(&dev->frame); - send_buf = (uint32 *)dev->frame.recv_buf; + send_buf = (uint32_t *)dev->frame.recv_buf; send_buf[0] = MAPLE_FUNC_CONTROLLER; dev->frame.cmd = MAPLE_COMMAND_GETCOND; dev->frame.dst_port = dev->port; diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c index 3267479..fb6a0f0 100644 --- a/kernel/arch/dreamcast/hardware/maple/vmu.c +++ b/kernel/arch/dreamcast/hardware/maple/vmu.c @@ -1,8 +1,16 @@ /* KallistiOS ##version## vmu.c - Copyright (C)2002,2003 Megan Potter - Copyright (C)2008 Donald Haase + Copyright (C) 2002, 2003 Megan Potter + Copyright (C) 2008 Donald Haase + Copyright (C) 2023 Falco Girgis + */ + +/* + This module deals with the VMU. It provides functionality for + filesystem, LCD screen, buzzer, and date/time access. + + Thanks to Marcus Comstedt for VMU/Maple information. */ #include <assert.h> @@ -17,12 +25,37 @@ #include <dc/vmufs.h> #include <arch/timer.h> -/* - This module deals with the VMU. It provides functionality for - memorycard access, and for access to the lcd screen. +#define VMU_BLOCK_WRITE_RETRY_TIME 100 /* time to sleep until retrying a failed write */ + +typedef struct vmu_datetime { + uint16_t year; /* 0 - 9999 */ + uint8_t month; /* 1 - 12 */ + uint8_t day; /* 1 - 31 */ + uint8_t hour; /* 0 - 23 */ + uint8_t minute; /* 0 - 59 */ + uint8_t second; /* 0 - 59 */ + uint8_t weekday; /* 0 - 6 (Starting with Monday) */ +} vmu_datetime_t; + +static void vmu_datetime_to_tm(const vmu_datetime_t *dt, struct tm *bt) { + bt->tm_sec = dt->second; + bt->tm_min = dt->minute; + bt->tm_hour = dt->hour; + bt->tm_mday = dt->day; + bt->tm_mon = dt->month - 1; + bt->tm_year = dt->year - 1900; + bt->tm_wday = dt->weekday != 6? dt->weekday + 1 : 0; +} - Thanks to Marcus Comstedt for VMU/Maple information. - */ +static void vmu_datetime_from_tm(vmu_datetime_t *dt, const struct tm *bt) { + dt->second = bt->tm_sec; + dt->minute = bt->tm_min; + dt->hour = bt->tm_hour; + dt->day = bt->tm_mday; + dt->month = bt->tm_mon + 1; + dt->year = bt->tm_year + 1900; + dt->weekday = bt->tm_wday? dt->weekday - 1 : 6; +} static int vmu_attach(maple_driver_t *drv, maple_device_t *dev) { (void)drv; @@ -30,6 +63,83 @@ static int vmu_attach(maple_driver_t *drv, maple_device_t *dev) { return 0; } +static void vmu_poll_reply(maple_frame_t *frm) { + maple_response_t *resp; + uint32_t *respbuf; + vmu_cond_t *raw; + vmu_state_t *cooked; + + /* Unlock the frame now (it's ok, we're in an IRQ) */ + maple_frame_unlock(frm); + + /* Make sure we got a valid response */ + resp = (maple_response_t *)frm->recv_buf; + + if(resp->response != MAPLE_RESPONSE_DATATRF) + return; + + respbuf = (uint32_t *)resp->data; + + if(respbuf[0] != MAPLE_FUNC_CLOCK) + return; + + /* Update the status area from the response */ + if(frm->dev) { + const maple_device_t *cont = maple_enum_dev(frm->dev->port, 0); + + /* Verify the size of the frame and grab a pointer to it */ + //assert(resp->data_len == 7); + raw = (vmu_cond_t *)(respbuf + 1); + + /* Fill the "nice" struct from the raw data */ + cooked = (vmu_state_t *)(frm->dev->status); + /* Invert raw struct as nice struct */ + cooked->buttons = ~(*raw); + + /* Check to see if the VMU is upside-down in the controller and readjust + its directional buttons accordingly. */ + if(cont && (cont->info.functions & MAPLE_FUNC_CONTROLLER) && + (frm->dev->info.connector_direction == cont->info.connector_direction)) { + cooked->buttons = (cooked->buttons & 0xf0) | + (cooked->dpad_up << 1) | /* down */ + (cooked->dpad_down << 0) | /* up */ + (cooked->dpad_left << 3) | /* right */ + (cooked->dpad_right << 2); /* left */ + + } + + frm->dev->status_valid = 1; + } +} + +static int vmu_poll(maple_device_t *dev) { + uint32_t *send_buf; + + /* Only query for button input on the front VMU of each controller. */ + if(dev->unit == 1) { + if(maple_frame_lock(&dev->frame) < 0) + return 0; + + maple_frame_init(&dev->frame); + send_buf = (uint32_t *)dev->frame.recv_buf; + send_buf[0] = MAPLE_FUNC_CLOCK; + dev->frame.cmd = MAPLE_COMMAND_GETCOND; + dev->frame.dst_port = dev->port; + dev->frame.dst_unit = dev->unit; + dev->frame.length = 1; + dev->frame.callback = vmu_poll_reply; + dev->frame.send_buf = send_buf; + maple_queue_frame(&dev->frame); + + } + + return 0; +} + +static void vmu_periodic(maple_driver_t *drv) { + maple_driver_foreach(drv, vmu_poll); +} + /* Device Driver Struct */ static maple_driver_t vmu_drv = { .functions = MAPLE_FUNC_MEMCARD | MAPLE_FUNC_LCD | MAPLE_FUNC_CLOCK, @@ -50,7 +160,17 @@ void vmu_shutdown(void) { maple_driver_unreg(&vmu_drv); } -int vmu_use_custom_color(maple_device_t * dev, int enable) { +/* Dynamically add the periodic polling callback to the driver when button input is enabled. */ +void vmu_set_buttons_enabled(int enable) { + vmu_drv.periodic = enable ? vmu_periodic : NULL; +} + +/* Determine whether polling for button input is enabled or not by presence of periodic callback. */ +int vmu_get_buttons_enabled(void) { + return !!vmu_drv.periodic; +} + +int vmu_use_custom_color(maple_device_t *dev, int enable) { vmu_root_t root; if(vmufs_root_read(dev, &root) < 0) @@ -67,7 +187,7 @@ int vmu_use_custom_color(maple_device_t * dev, int enable) { /* The custom color is used while navigating the Dreamcast's file manager. You set the RGBA parameters, each with valid range of 0-255 */ -int vmu_set_custom_color(maple_device_t * dev, uint8 red, uint8 green, uint8 blue, uint8 alpha) { +int vmu_set_custom_color(maple_device_t *dev, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) { vmu_root_t root; if(vmufs_root_read(dev, &root) < 0) @@ -89,7 +209,7 @@ int vmu_set_custom_color(maple_device_t * dev, uint8 red, uint8 green, uint8 blu /* The icon shape is used while navigating the BIOS menu. The values 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 icon_shape) { +int vmu_set_icon_shape(maple_device_t *dev, uint8_t icon_shape) { #ifdef _arch_sub_naomi vmu_root_t root; @@ -119,7 +239,7 @@ int vmu_set_icon_shape(maple_device_t * dev, uint8 icon_shape) { can stay the same */ /* Callback that unlocks the frame, general use */ -static void vmu_gen_callback(maple_frame_t * frame) { +static void vmu_gen_callback(maple_frame_t *frame) { /* Unlock the frame for the next usage */ maple_frame_unlock(frame); @@ -128,22 +248,21 @@ static void vmu_gen_callback(maple_frame_t * frame) { } /* Set the tone to be generated by the VMU's speaker. - Only last two bytes are used. Actual parameters unknown - except that the last byte must be larger than the second - to last byte. This might necessitate refactoring as the - clock is a seperate device from the screen and storage. */ -int vmu_beep_raw(maple_device_t * dev, uint32 beep) { - uint32 * send_buf; + Only last two bytes are used. This might necessitate + refactoring as the clock is a seperate device from + the screen and storage. */ +int vmu_beep_raw(maple_device_t *dev, uint32_t beep) { + uint32_t *send_buf; - assert(dev != NULL); + assert(dev); - /* Lock the frame */ - if(maple_frame_lock(&dev->frame) < 0) - return MAPLE_EAGAIN; + /* Lock the frame. XXX: Priority inversion issues here. */ + while(maple_frame_lock(&dev->frame) < 0) + thd_pass(); /* Reset the frame */ maple_frame_init(&dev->frame); - send_buf = (uint32 *)dev->frame.recv_buf; + send_buf = (uint32_t *)dev->frame.recv_buf; send_buf[0] = MAPLE_FUNC_CLOCK; send_buf[1] = beep; dev->frame.cmd = MAPLE_COMMAND_SETCOND; @@ -168,10 +287,15 @@ int vmu_beep_raw(maple_device_t * dev, uint32 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); + return vmu_beep_raw(dev, raw_beep); +} + /* Draw a 1-bit bitmap on the LCD screen (48x32). return a -1 if an error occurs */ -int vmu_draw_lcd(maple_device_t * dev, const void *bitmap) { - uint32 * send_buf; +int vmu_draw_lcd(maple_device_t *dev, const void *bitmap) { + uint32_t *send_buf; assert(dev != NULL); @@ -181,14 +305,14 @@ int vmu_draw_lcd(maple_device_t * dev, const void *bitmap) { /* Reset the frame */ maple_frame_init(&dev->frame); - send_buf = (uint32 *)dev->frame.recv_buf; + send_buf = (uint32_t *)dev->frame.recv_buf; send_buf[0] = MAPLE_FUNC_LCD; send_buf[1] = 0; /* Block / phase / partition */ - memcpy(send_buf + 2, bitmap, 48 * 4); + memcpy(send_buf + 2, bitmap, VMU_SCREEN_WIDTH * 4); dev->frame.cmd = MAPLE_COMMAND_BWRITE; dev->frame.dst_port = dev->port; dev->frame.dst_unit = dev->unit; - dev->frame.length = 2 + 48; + dev->frame.length = 2 + VMU_SCREEN_WIDTH; dev->frame.callback = vmu_gen_callback; dev->frame.send_buf = send_buf; maple_queue_frame(&dev->frame); @@ -208,7 +332,7 @@ int vmu_draw_lcd(maple_device_t * dev, const void *bitmap) { } int vmu_draw_lcd_rotated(maple_device_t *dev, const void *bitmap) { - uint32 bitmap_inverted[48]; + uint32_t bitmap_inverted[48]; unsigned int i; for (i = 0; i < 48; i++) { @@ -220,29 +344,44 @@ int vmu_draw_lcd_rotated(maple_device_t *dev, const void *bitmap) { /* This function converts a xbm image to a 1-bit bitmap that can be displayed on LCD screen of VMU */ -static void vmu_xbm_to_bitmap(uint8 *bitmap, const char *vmu_icon) { +static void vmu_xbm_to_bitmap(uint8_t *bitmap, const char *vmu_icon) { int x, y, xi, xb; - memset(bitmap, 0, 48 * 32 / 8); + memset(bitmap, 0, VMU_SCREEN_WIDTH * VMU_SCREEN_HEIGHT / 8); if(vmu_icon) { - for(y = 0; y < 32; y++) - for(x = 0; x < 48; x++) { + for(y = 0; y < VMU_SCREEN_HEIGHT; y++) + for(x = 0; x < VMU_SCREEN_WIDTH; x++) { xi = x / 8; xb = 0x80 >> (x % 8); - if(vmu_icon[(31 - y) * 48 + (47 - x)] == '.') - bitmap[y * (48 / 8) + xi] |= xb; + if(vmu_icon[((VMU_SCREEN_HEIGHT - 1) - y) * VMU_SCREEN_WIDTH + + ((VMU_SCREEN_WIDTH - 1) - x)] == '.') + bitmap[y * (VMU_SCREEN_WIDTH / 8) + xi] |= xb; } } } -int vmu_draw_lcd_xbm(maple_device_t * dev, const char *vmu_icon) { - uint8 bitmap[48 * 32 / 8]; +int vmu_draw_lcd_xbm(maple_device_t *dev, const char *vmu_icon) { + uint8_t bitmap[VMU_SCREEN_WIDTH * VMU_SCREEN_HEIGHT / 8]; vmu_xbm_to_bitmap(bitmap, vmu_icon); return vmu_draw_lcd(dev, bitmap); } +/* Utility function which sets the icon on all available VMUs + from an Xwindows XBM. Imported from libdcutils. */ +void vmu_set_icon(const char *vmu_icon) { + int i = 0; + maple_device_t *dev; + uint8_t bitmap[VMU_SCREEN_WIDTH * VMU_SCREEN_HEIGHT / 8]; + + vmu_xbm_to_bitmap(bitmap, vmu_icon); + + while((dev = maple_enum_type(i++, MAPLE_FUNC_LCD))) { + vmu_draw_lcd(dev, bitmap); + } +} + /* Read the data in block blocknum into buffer, return a -1 if an error occurs, for now we ignore MAPLE_RESPONSE_FILEERR, which will be changed shortly */ @@ -251,11 +390,11 @@ static void vmu_block_read_callback(maple_frame_t *frm) { genwait_wake_all(frm); } -int vmu_block_read(maple_device_t * dev, uint16 blocknum, uint8 *buffer) { - maple_response_t *resp; - int rv; - uint32 *send_buf; - uint32 blkid; +int vmu_block_read(maple_device_t *dev, uint16_t blocknum, uint8_t *buffer) { + maple_response_t *resp; + int rv; + uint32_t *send_buf; + uint32_t blkid; assert(dev != NULL); @@ -268,7 +407,7 @@ int vmu_block_read(maple_device_t * dev, uint16 blocknum, uint8 *buffer) { /* Reset the frame */ maple_frame_init(&dev->frame); - send_buf = (uint32 *)dev->frame.recv_buf; + send_buf = (uint32_t *)dev->frame.recv_buf; send_buf[0] = MAPLE_FUNC_MEMCARD; send_buf[1] = blkid; dev->frame.cmd = MAPLE_COMMAND_BREAD; @@ -299,7 +438,7 @@ int vmu_block_read(maple_device_t * dev, uint16 blocknum, uint8 *buffer) { /* Copy out the response */ resp = (maple_response_t *)dev->frame.recv_buf; - send_buf = (uint32 *)resp->data; + send_buf = (uint32_t *)resp->data; if(resp->response != MAPLE_RESPONSE_DATATRF || send_buf[0] != MAPLE_FUNC_MEMCARD @@ -327,11 +466,12 @@ static void vmu_block_write_callback(maple_frame_t *frm) { /* Wakey, wakey! */ genwait_wake_all(frm); } -static int vmu_block_write_internal(maple_device_t * dev, uint16 blocknum, uint8 *buffer) { - maple_response_t *resp; - int rv, phase, r; - uint32 *send_buf; - uint32 blkid; + +static int vmu_block_write_internal(maple_device_t *dev, uint16_t blocknum, const uint8_t *buffer) { ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-22 01:12:50
|
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 2e1153d508fe7f7fbf9ed6d2746d50792e2373d2 (commit) via f02614bb16a2fd7a95ebb605a8ed8e8ee92a05ba (commit) from 8d040105fd922addf4c5853be4cafcf3c9bf093e (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 2e1153d508fe7f7fbf9ed6d2746d50792e2373d2 Merge: 8d04010 f02614b Author: Lawrence Sebald <ljs...@us...> Date: Mon Aug 21 20:28:27 2023 -0400 Merge pull request #272 from sizious/dc-chain-mingw-gdb-10.2 `dc-chain`: MinGW: Adding Win32 patch for GDB 10.2 commit f02614bb16a2fd7a95ebb605a8ed8e8ee92a05ba Author: SiZiOUS <si...@gm...> Date: Mon Aug 21 15:07:22 2023 +0100 `dc-chain`: MinGW: Adding Win32 patch for GDB 10.2 ----------------------------------------------------------------------- Summary of changes: .../patches/i686-pc-mingw32/{gdb-9.2.diff => gdb-10.2.diff} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) copy utils/dc-chain/patches/i686-pc-mingw32/{gdb-9.2.diff => gdb-10.2.diff} (60%) diff --git a/utils/dc-chain/patches/i686-pc-mingw32/gdb-9.2.diff b/utils/dc-chain/patches/i686-pc-mingw32/gdb-10.2.diff similarity index 60% copy from utils/dc-chain/patches/i686-pc-mingw32/gdb-9.2.diff copy to utils/dc-chain/patches/i686-pc-mingw32/gdb-10.2.diff index e535fa0..f70ff89 100644 --- a/utils/dc-chain/patches/i686-pc-mingw32/gdb-9.2.diff +++ b/utils/dc-chain/patches/i686-pc-mingw32/gdb-10.2.diff @@ -1,6 +1,6 @@ -diff -ruN gdb-9.2/gdb/gdbsupport/pathstuff.c gdb-9.2-mingw/gdb/gdbsupport/pathstuff.c ---- gdb-9.2/gdb/gdbsupport/pathstuff.c 2020-05-23 21:10:29 +0000 -+++ gdb-9.2-mingw/gdb/gdbsupport/pathstuff.c 2020-08-26 14:10:06 +0000 +diff -ruN gdb-10.2/gdbsupport/pathstuff.cc gdb-10.2-mingw/gdbsupport/pathstuff.cc +--- gdb-10.2/gdbsupport/pathstuff.cc 2021-04-25 05:06:26 +0100 ++++ gdb-10.2-mingw/gdbsupport/pathstuff.cc 2023-08-21 14:40:43 +0100 @@ -231,6 +231,15 @@ #endif hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: falcovorbis <fal...@us...> - 2023-08-20 22:49: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 8d040105fd922addf4c5853be4cafcf3c9bf093e (commit) via 6f2fe1e4b99f63ab3f878daf1031e7f7093e15e0 (commit) from c6ddbb13e8bb9d5feb8f992a992845c9500a4eea (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 8d040105fd922addf4c5853be4cafcf3c9bf093e Merge: c6ddbb1 6f2fe1e Author: Falco Girgis <gyr...@gm...> Date: Sun Aug 20 17:49:03 2023 -0500 Merge pull request #271 from KallistiOS/clock_gettime_fix Fixing opusfile build issues after clock_gettime() commit 6f2fe1e4b99f63ab3f878daf1031e7f7093e15e0 Author: Falco Girgis <gyr...@gm...> Date: Sun Aug 20 17:42:07 2023 -0500 Fixing opusfile build issues after clock_gettime() - Somehow Newlib's prototype is conflicting with the one we were providing... But if Newlib is providing the prototype, doesn't look like we need it anyway. ----------------------------------------------------------------------- Summary of changes: include/kos/time.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/kos/time.h b/include/kos/time.h index 738230c..1c5c79d 100644 --- a/include/kos/time.h +++ b/include/kos/time.h @@ -48,10 +48,6 @@ extern int timespec_get(struct timespec *ts, int base); #define CLOCK_PROCESS_CPUTIME_ID (CLOCK_REALTIME + 2) #define CLOCK_THREAD_CPUTIME_ID (CLOCK_REALTIME + 3) -extern int clock_getres(__clockid_t clk_id, struct timespec *res); -extern int clock_gettime(__clockid_t clk_id, struct timespec *tp); -extern int clock_settime(__clockid_t clk_id, const struct timespec *tp); - #endif /* !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 199309L) */ __END_DECLS hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-19 19:24:45
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via c6ddbb13e8bb9d5feb8f992a992845c9500a4eea (commit) via 76d520850f13b77fef2ccfa45c4cd357d1214349 (commit) from 89148902083e680415afe1976458551d3ed321a7 (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 c6ddbb13e8bb9d5feb8f992a992845c9500a4eea Author: Falco Girgis <gyr...@gm...> Date: Sat Aug 19 14:21:43 2023 -0500 Removing NULL check warning from posix_memalign (#270) Removing NULL check warning from posix_memalign commit 76d520850f13b77fef2ccfa45c4cd357d1214349 Author: Falco Girgis <gyr...@gm...> Date: Sat Aug 19 14:20:39 2023 -0500 Implement POSIX clock_gettime() and friends (#266) * Initial impl of POSIX clock_gettime() and friends - added POSIX preprocessor defines to time.h for compile-time feature checks - added undefined clock types to time.h - added clock_gettime(), clock_settime(), and clock_getres() to time.h - created subdirectory for POSIX-related functionality - added clock_gettime.c * Corrected file path in Makefile heading * Fixed incorrect filename in clock_gettime.c header * Updated changelog * Removed C11 version check - Removed C11 verson check, and am only checking for !ANSI - This means the implementation, clock_gettime.c, must now be compiled with gnu extendsions in the Makefile (duh). - Changed parameter names to match timespec_get() * Update include/kos/time.h Co-authored-by: Lawrence Sebald <ljs...@us...> * Update include/kos/time.h Co-authored-by: Lawrence Sebald <ljs...@us...> * Update kernel/libc/posix/clock_gettime.c Co-authored-by: Lawrence Sebald <ljs...@us...> * Addressed code review requests - Spacing/indentation fixed - Move inner switch/case scope variables to main function scope * Rearranged #ifdefs in time.h, addressing feedback --------- Co-authored-by: Lawrence Sebald <ljs...@us...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/time.h | 32 +++++++++++++++-- kernel/libc/posix/Makefile | 4 +-- kernel/libc/posix/clock_gettime.c | 71 ++++++++++++++++++++++++++++++++++++++ kernel/libc/posix/posix_memalign.c | 5 +++ 5 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 kernel/libc/posix/clock_gettime.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 68bd32c..70f838c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -179,6 +179,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Add example for rumble accessory use [DH] - *** Split init flags from <arch/arch.h> into <kos/init.h> [LS] - *** Implemented posix_memalign() from stdlib.h [FG] +- *** Added clock_gettime(), clock_settime(), clock_getres() [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/kos/time.h b/include/kos/time.h index d32da92..738230c 100644 --- a/include/kos/time.h +++ b/include/kos/time.h @@ -14,12 +14,12 @@ #ifndef __KOS_TIME_H #define __KOS_TIME_H -#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) - #include <kos/cdefs.h> __BEGIN_DECLS +#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) + /* Forward declaration. */ struct timespec; @@ -27,7 +27,33 @@ struct timespec; extern int timespec_get(struct timespec *ts, int base); +#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) */ + +#if !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 199309L) + +#ifndef _POSIX_TIMERS +#define _POSIX_TIMERS 1 +#endif +#ifdef _POSIX_MONOTONIC_CLOCK +#define _POSIX_MONOTONIC_CLOCK 1 +#endif +#ifdef _POSIX_CPUTIME +#define _POSIX_CPUTIME 1 +#endif +#ifdef _POSIX_THREAD_CPU_TIME +#define _POSIX_THREAD_CPUTIME 1 +#endif + +#define CLOCK_MONOTONIC (CLOCK_REALTIME + 1) +#define CLOCK_PROCESS_CPUTIME_ID (CLOCK_REALTIME + 2) +#define CLOCK_THREAD_CPUTIME_ID (CLOCK_REALTIME + 3) + +extern int clock_getres(__clockid_t clk_id, struct timespec *res); +extern int clock_gettime(__clockid_t clk_id, struct timespec *tp); +extern int clock_settime(__clockid_t clk_id, const struct timespec *tp); + +#endif /* !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 199309L) */ + __END_DECLS -#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) */ #endif /* !__KOS_TIME_H */ diff --git a/kernel/libc/posix/Makefile b/kernel/libc/posix/Makefile index 8e07e19..24587fa 100644 --- a/kernel/libc/posix/Makefile +++ b/kernel/libc/posix/Makefile @@ -10,7 +10,7 @@ # are not provided as part of Newlib. # -CFLAGS += -std=c11 -OBJS = posix_memalign.o +CFLAGS += -std=gnu11 +OBJS = posix_memalign.o clock_gettime.o include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/libc/posix/clock_gettime.c b/kernel/libc/posix/clock_gettime.c new file mode 100644 index 0000000..c76eba8 --- /dev/null +++ b/kernel/libc/posix/clock_gettime.c @@ -0,0 +1,71 @@ +/* KallistiOS ##version## + + clock_gettime.c + Copyright (C) 2023 Falco Girgis +*/ + +#include <time.h> +#include <arch/timer.h> +#include <arch/rtc.h> +#include <errno.h> + +int clock_getres(clockid_t clk_id, struct timespec *ts) { + switch(clk_id) { + case CLOCK_REALTIME: + case CLOCK_MONOTONIC: + case CLOCK_PROCESS_CPUTIME_ID: + case CLOCK_THREAD_CPUTIME_ID: + if(!ts) { + errno = EFAULT; + return -1; + } + ts->tv_sec = 0; + ts->tv_nsec = 1000 * 1000; + return 0; + + default: + errno = EINVAL; + return -1; + } +} + +int clock_gettime(clockid_t clk_id, struct timespec *ts) { + uint32_t secs, msecs; + + if(!ts) { + errno = EFAULT; + return -1; + } + + switch(clk_id) { + case CLOCK_REALTIME: + return timespec_get(ts, TIME_UTC) == TIME_UTC ? 0 : -1; + + case CLOCK_MONOTONIC: + case CLOCK_PROCESS_CPUTIME_ID: + case CLOCK_THREAD_CPUTIME_ID: + timer_ms_gettime(&secs, &msecs); + ts->tv_sec = secs; + ts->tv_nsec = msecs * 1000 * 1000; + return 0; + + default: + errno = EINVAL; + return -1; + } +} + +int clock_settime(clockid_t clk_id, const struct timespec *ts) { + switch(clk_id) { + case CLOCK_REALTIME: + if(!ts) { + errno = EFAULT; + return -1; + } + return rtc_set_unix_secs(ts->tv_sec); + + default: + errno = EINVAL; + return -1; + } +} diff --git a/kernel/libc/posix/posix_memalign.c b/kernel/libc/posix/posix_memalign.c index a5b2591..8a5b6c4 100644 --- a/kernel/libc/posix/posix_memalign.c +++ b/kernel/libc/posix/posix_memalign.c @@ -9,6 +9,9 @@ #include <stdlib.h> #include <assert.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnonnull-compare" + static inline int is_power_of_two(size_t x) { return (x & (x - 1)) == 0; } @@ -43,3 +46,5 @@ int posix_memalign(void **memptr, size_t alignment, size_t size) { return *memptr ? 0 : ENOMEM; } + +#pragma GCC diagnostic pop hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-19 03:14:05
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 89148902083e680415afe1976458551d3ed321a7 (commit) from ff68b986d96786cadf25838d77f651989033b9c4 (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 89148902083e680415afe1976458551d3ed321a7 Author: Falco Girgis <gyr...@gm...> Date: Fri Aug 18 22:06:58 2023 -0500 Implemented posix_memalign() addition to stdlib.h (#268) * Implemented posix_memalign() addition to stdlib.h - created kos/stdlib.h as the KOS stdlib private include/extension - modified sys/_types.h to conditionally include kos/stdlib.h when including the regular stdlib.h (following the pattern established with kos/time.h) - added POSIX directory and Makefile - added posix_memalign.c with the implementation - updated CHANGELOG * Fixed a typo in kos/stdlib.h header. * Removed C11 check, fixed warnings and indentation - No longer checking for a particular C or C++ version before including posix_memalign - Fixed warnings in posix_memalign.c arising from missing includes and not building with C11 for aligned_alloc() - Fixed indentation in posix_memalign.c * Update include/kos/stdlib.h Co-authored-by: Lawrence Sebald <ljs...@us...> * Update kernel/libc/posix/posix_memalign.c Co-authored-by: Lawrence Sebald <ljs...@us...> * Update kernel/libc/posix/posix_memalign.c Co-authored-by: Lawrence Sebald <ljs...@us...> --------- Co-authored-by: Lawrence Sebald <ljs...@us...> ----------------------------------------------------------------------- Summary of changes: doc/CHANGELOG | 1 + include/kos/stdlib.h | 31 ++++++++++++++++++++++++++ include/sys/_types.h | 5 +++++ kernel/libc/Makefile | 2 +- kernel/libc/posix/Makefile | 16 ++++++++++++++ kernel/libc/posix/posix_memalign.c | 45 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 include/kos/stdlib.h create mode 100644 kernel/libc/posix/Makefile create mode 100644 kernel/libc/posix/posix_memalign.c diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 20bd0bd..68bd32c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -178,6 +178,7 @@ KallistiOS version 2.1.0 ----------------------------------------------- - DC Add example for VMU speaker use [DH && FG] - DC Add example for rumble accessory use [DH] - *** Split init flags from <arch/arch.h> into <kos/init.h> [LS] +- *** Implemented posix_memalign() from stdlib.h [FG] KallistiOS version 2.0.0 ----------------------------------------------- - DC Broadband Adapter driver fixes [Megan Potter == MP] diff --git a/include/kos/stdlib.h b/include/kos/stdlib.h new file mode 100644 index 0000000..9d5562f --- /dev/null +++ b/include/kos/stdlib.h @@ -0,0 +1,31 @@ +/* KallistiOS ##version## + + kos/stdlib.h + Copyright (C) 2023 Falco Girgis +*/ + +/* + Add select POSIX extensions to stdlib.h which are not present within Newlib. +*/ + +#ifndef _STDLIB_H_ +#error "Do not include this file directly. Use <stdlib.h> instead." +#endif /* !_STDLIB_H_ */ + +#ifndef __KOS_STDLIB_H +#define __KOS_STDLIB_H + +#if !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 200112L) || \ + (_XOPEN_SOURCE >= 600) + +#include <kos/cdefs.h> + +__BEGIN_DECLS + +extern int posix_memalign(void **memptr, size_t alignment, size_t size); + +__END_DECLS + +#endif /* !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 200112L) || + (_XOPEN_SOURCE >= 600) */ +#endif /* !__KOS_STDLIB_H */ diff --git a/include/sys/_types.h b/include/sys/_types.h index 664907a..42ab393 100644 --- a/include/sys/_types.h +++ b/include/sys/_types.h @@ -227,3 +227,8 @@ __END_DECLS #ifdef _TIME_H_ #include <kos/time.h> #endif + +#ifdef _STDLIB_H_ +#include <kos/stdlib.h> +#endif + diff --git a/kernel/libc/Makefile b/kernel/libc/Makefile index 3078b9d..e20fcff 100644 --- a/kernel/libc/Makefile +++ b/kernel/libc/Makefile @@ -4,7 +4,7 @@ # Copyright (C)2004 Megan Potter # -SUBDIRS = koslib newlib pthreads c11 +SUBDIRS = koslib newlib pthreads c11 posix all: subdirs clean: clean_subdirs diff --git a/kernel/libc/posix/Makefile b/kernel/libc/posix/Makefile new file mode 100644 index 0000000..8e07e19 --- /dev/null +++ b/kernel/libc/posix/Makefile @@ -0,0 +1,16 @@ +# KallistiOS ##version## +# +# kernel/libc/posix/Makefile +# Copyright (C) 2023 Falco Girgis +# + +# +# This dir contains the implementation of POSIX-specific +# C and C++ extensions which are implemented by KOS and +# are not provided as part of Newlib. +# + +CFLAGS += -std=c11 +OBJS = posix_memalign.o + +include $(KOS_BASE)/Makefile.prefab diff --git a/kernel/libc/posix/posix_memalign.c b/kernel/libc/posix/posix_memalign.c new file mode 100644 index 0000000..a5b2591 --- /dev/null +++ b/kernel/libc/posix/posix_memalign.c @@ -0,0 +1,45 @@ +/* KallistiOS ##version## + + posix_memalign.c + Copyright (C) 2023 Falco Girgis +*/ + +#include <stdlib.h> +#include <errno.h> +#include <stdlib.h> +#include <assert.h> + +static inline int is_power_of_two(size_t x) { + return (x & (x - 1)) == 0; +} + +static inline size_t aligned_size(size_t size, size_t alignment) { + const size_t align_rem = size % alignment; + size_t new_size = size; + + if(align_rem) + new_size += (alignment - align_rem); + + return new_size; +} + +int posix_memalign(void **memptr, size_t alignment, size_t size) { + if(!memptr) { + return EFAULT; + } + + if(!alignment || !is_power_of_two(alignment) || alignment % sizeof(void*)) { + *memptr = NULL; + return EINVAL; + } + + if(!size) { + *memptr = NULL; + return 0; + } + + size = aligned_size(size, alignment); + *memptr = aligned_alloc(alignment, size); + + return *memptr ? 0 : ENOMEM; +} hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-08-17 21:16:39
|
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 be68a319e519c2da4bf9ff2b3a33914799dcb6b0 (commit) from 910f91df523a433891efc3ffd7c95853a45d08e2 (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 be68a319e519c2da4bf9ff2b3a33914799dcb6b0 Author: Tchan0 <617...@us...> Date: Thu Aug 17 23:09:21 2023 +0200 Update dc-tool.c (#17) correcting N=13 value of the SH-4. ----------------------------------------------------------------------- Summary of changes: host-src/tool/dc-tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index fbface1..e1b8ff9 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -682,7 +682,7 @@ int change_speed(char *device_name, unsigned int speed) { blread(&c, 1); if(speedhack && (speed == 115200)) - send_uint(111600); /* get dcload to pick N=13 rather than N=12 */ + send_uint(111607); /* get dcload to pick N=13 rather than N=12 */ else if(speedhack && (speed == 230400)) send_uint(223214); /* get dcload to pick N=6 rather than N=5 */ else if(use_extclk) hooks/post-receive -- A serial program loader for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-17 20:25:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A serial program loader for the Dreamcast.". The branch, master has been updated via 910f91df523a433891efc3ffd7c95853a45d08e2 (commit) from 4d28558a2c09c7abb2678c12e9957aa4dad53ca3 (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 910f91df523a433891efc3ffd7c95853a45d08e2 Author: Tchan0 <617...@us...> Date: Thu Aug 17 22:24:56 2023 +0200 Add baudrate 230400 and its speedhack. (#16) * Add baudrate 230400 and its speedhack. * Update dc-tool.c cleaned up explanation about speedhack ----------------------------------------------------------------------- Summary of changes: Makefile.cfg | 2 +- host-src/tool/Makefile | 2 +- host-src/tool/dc-tool.c | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile.cfg b/Makefile.cfg index 56bc457..01da995 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -98,7 +98,7 @@ endif # default speed for dc-tool - after initial connection is established, connection # speed will change to this value, same as using the -b argument -# value must be one of 9600, 19200, 38400, 57600, 115200, 500000, or 1500000 +# value must be one of 9600, 19200, 38400, 57600, 115200, 230400, 500000, or 1500000 TOOL_DEFAULT_SPEED = 57600 # USB-based serial devices can potentially achieve speeds of 500000 or 1500000 baud #TOOL_DEFAULT_SPEED = 500000 diff --git a/host-src/tool/Makefile b/host-src/tool/Makefile index 75eb877..5a206e8 100644 --- a/host-src/tool/Makefile +++ b/host-src/tool/Makefile @@ -3,7 +3,7 @@ include ../../Makefile.cfg LZOPATH = ../../minilzo-2.10 CC = $(HOSTCC) -CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDEFAULT_SPEED=$(TOOL_DEFAULT_SPEED) -DSERIALDEVICE="\"$(SERIALDEVICE)\"" -DHAVE_GETOPT -DB1500000 -DB500000 +CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDEFAULT_SPEED=$(TOOL_DEFAULT_SPEED) -DSERIALDEVICE="\"$(SERIALDEVICE)\"" -DHAVE_GETOPT -DB1500000 -DB500000 -DB230400 LDFLAGS = $(HOSTLDFLAGS) INCLUDE = -I$(LZOPATH) -I/usr/local/include diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index ff3e047..fbface1 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -546,6 +546,11 @@ int open_serial(char *devicename, unsigned int speed, unsigned int *speedtest) { case 500000: speedsel = B500000; break; +#endif +#ifdef B230400 + case 230400: + speedsel = B230400; + break; #endif case 115200: speedsel = B115200; @@ -660,8 +665,9 @@ void close_serial(void) { } int speedhack = 0; -/* speedhack controls whether dcload will use N=12 (normal, 4.3% error) or - * N=13 (alternate, -3.1% error) for 115200 +/* speedhack controls whether dcload will use + * - N=13 (alternate, -3.0% error) instead of N=12 (normal, 4.3% error) for 115200 + * - N=6 (alternate, -2.8% error) instead of N=5 (normal, 11.5% error) for 230400 */ /* use_extclk controls whether the DC's serial port will use an external clock */ @@ -677,6 +683,8 @@ int change_speed(char *device_name, unsigned int speed) { if(speedhack && (speed == 115200)) send_uint(111600); /* get dcload to pick N=13 rather than N=12 */ + else if(speedhack && (speed == 230400)) + send_uint(223214); /* get dcload to pick N=6 rather than N=5 */ else if(use_extclk) send_uint(0); else @@ -744,7 +752,7 @@ void usage(void) { printf("-s <size> Set size to <size>\n"); printf("-t <device> Use <device> to communicate with dc (default: %s)\n", SERIALDEVICE); printf("-b <baudrate> Use <baudrate> (default: %d)\n", DEFAULT_SPEED); - printf("-e Try alternate 115200 (must also use -b 115200)\n"); + printf("-e Try alternate 115200/230400 (must also use -b 115200 or -b 230400)\n"); printf("-E Use an external clock for the DC's serial port\n"); printf("-n Do not attach console and fileserver\n"); printf("-p Use dumb terminal rather than console/fileserver\n"); @@ -1279,7 +1287,7 @@ int main(int argc, char *argv[]) { printf("Cdfs redirection enabled\n"); if(speedhack) - printf("Alternate 115200 enabled\n"); + printf("Alternate 115200/230400 enabled\n"); if(use_extclk) printf("External clock usage enabled\n"); hooks/post-receive -- A serial program loader for the Dreamcast. |
From: ljsebald <ljs...@us...> - 2023-08-17 14:52:27
|
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 ff68b986d96786cadf25838d77f651989033b9c4 (commit) via 5e09d94fc3caa18c3eba211181ef1d30810d6522 (commit) via 26ee38ad5ce64fc48b235a399d3ed743a6e40335 (commit) via 47e128fffc7af1b65efcc24fae9a11c58fb4a1f4 (commit) from efc5a3e4cb7c90b03449abc5572e08b1bcf84895 (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 ff68b986d96786cadf25838d77f651989033b9c4 Merge: 5e09d94 47e128f Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 17 10:43:08 2023 -0400 Merge pull request #258 from KallistiOS/matching_prereqs Alter 10.5.0 and 11.4.0 configs so custom dependencies match GCC's download_prerequisites commit 5e09d94fc3caa18c3eba211181ef1d30810d6522 Merge: efc5a3e 26ee38a Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 17 10:42:23 2023 -0400 Merge pull request #269 from KallistiOS/timer-macro-comments Add comments clarifying quick macro definitions in timer.c commit 26ee38ad5ce64fc48b235a399d3ed743a6e40335 Author: darc <da...@pr...> Date: Tue Aug 15 17:07:12 2023 -0500 Add comments clarifying quick macro definitions in timer.c commit 47e128fffc7af1b65efcc24fae9a11c58fb4a1f4 Author: darcagn <da...@pr...> Date: Wed Aug 9 13:05:15 2023 -0500 Alter 10.5.0 and 11.4.0 configs so custom dependencies match GCC's download_prerequisites ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/kernel/timer.c | 24 ++++++++++++------------ utils/dc-chain/config/config.mk.10.5.0.sample | 8 ++++---- utils/dc-chain/config/config.mk.11.4.0.sample | 8 ++++---- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c index b88905b..b9276d8 100644 --- a/kernel/arch/dreamcast/kernel/timer.c +++ b/kernel/arch/dreamcast/kernel/timer.c @@ -15,18 +15,18 @@ #define TIMER8(o) ( *((volatile uint8*)(0xffd80000 + (o))) ) #define TIMER16(o) ( *((volatile uint16*)(0xffd80000 + (o))) ) #define TIMER32(o) ( *((volatile uint32*)(0xffd80000 + (o))) ) -#define TOCR 0x00 -#define TSTR 0x04 -#define TCOR0 0x08 -#define TCNT0 0x0c -#define TCR0 0x10 -#define TCOR1 0x14 -#define TCNT1 0x18 -#define TCR1 0x1c -#define TCOR2 0x20 -#define TCNT2 0x24 -#define TCR2 0x28 -#define TCPR2 0x2c +#define TOCR 0x00 /* Timer Output Control Register */ +#define TSTR 0x04 /* Timer Start Register */ +#define TCOR0 0x08 /* Timer Constant Register 0 */ +#define TCNT0 0x0c /* Timer Counter Register 0 */ +#define TCR0 0x10 /* Timer Control Register 0 */ +#define TCOR1 0x14 /* Timer Constant Register 1 */ +#define TCNT1 0x18 /* Timer Counter Register 1 */ +#define TCR1 0x1c /* Timer Control Register 1 */ +#define TCOR2 0x20 /* Timer Constant Register 2 */ +#define TCNT2 0x24 /* Timer Counter Register 2 */ +#define TCR2 0x28 /* Timer Control Register 2 */ +#define TCPR2 0x2c /* Timer Input Capture */ static int tcors[] = { TCOR0, TCOR1, TCOR2 }; static int tcnts[] = { TCNT0, TCNT1, TCNT2 }; diff --git a/utils/dc-chain/config/config.mk.10.5.0.sample b/utils/dc-chain/config/config.mk.10.5.0.sample index 0e90373..da52ff1 100644 --- a/utils/dc-chain/config/config.mk.10.5.0.sample +++ b/utils/dc-chain/config/config.mk.10.5.0.sample @@ -37,10 +37,10 @@ arm_gcc_download_type=xz #use_custom_dependencies=1 # GCC dependencies for SH -sh_gmp_ver=6.2.1 -sh_mpfr_ver=4.1.0 -sh_mpc_ver=1.2.1 -sh_isl_ver=0.24 +sh_gmp_ver=6.1.0 +sh_mpfr_ver=3.1.6 +sh_mpc_ver=1.0.3 +sh_isl_ver=0.18 # Tarball extensions to download for GCC dependencies for SH sh_gmp_download_type=bz2 diff --git a/utils/dc-chain/config/config.mk.11.4.0.sample b/utils/dc-chain/config/config.mk.11.4.0.sample index 731fe34..0132602 100644 --- a/utils/dc-chain/config/config.mk.11.4.0.sample +++ b/utils/dc-chain/config/config.mk.11.4.0.sample @@ -37,10 +37,10 @@ arm_gcc_download_type=xz #use_custom_dependencies=1 # GCC dependencies for SH -sh_gmp_ver=6.2.1 -sh_mpfr_ver=4.1.0 -sh_mpc_ver=1.2.1 -sh_isl_ver=0.24 +sh_gmp_ver=6.1.0 +sh_mpfr_ver=3.1.6 +sh_mpc_ver=1.0.3 +sh_isl_ver=0.18 # Tarball extensions to download for GCC dependencies for SH sh_gmp_download_type=bz2 hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-08-10 18:28:27
|
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 efc5a3e4cb7c90b03449abc5572e08b1bcf84895 (commit) via 1bbf0d1a7186498ff787cfbc3ef0de742ef54b60 (commit) from 90e09d81d7c1f9dc3f31290a8fff94e4d5ff304a (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 efc5a3e4cb7c90b03449abc5572e08b1bcf84895 Merge: 90e09d8 1bbf0d1 Author: Donald Haase <qu...@ya...> Date: Thu Aug 10 14:22:31 2023 -0400 Merge pull request #265 from KallistiOS/fix-p4-macro Fix: MEM_AREA_P4_MASK should be MEM_AREA_P4_BASE commit 1bbf0d1a7186498ff787cfbc3ef0de742ef54b60 Author: darc <da...@pr...> Date: Thu Aug 10 10:42:46 2023 -0500 Fix: MEM_AREA_P4_MASK should be MEM_AREA_P4_BASE ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/include/dc/pvr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/arch/dreamcast/include/dc/pvr.h b/kernel/arch/dreamcast/include/dc/pvr.h index d3efe2d..090923d 100644 --- a/kernel/arch/dreamcast/include/dc/pvr.h +++ b/kernel/arch/dreamcast/include/dc/pvr.h @@ -1663,7 +1663,7 @@ typedef uint32 pvr_dr_state_t; */ #define pvr_dr_target(vtx_buf_ptr) \ ({ (vtx_buf_ptr) ^= 32; \ - (pvr_vertex_t *)(MEM_AREA_P4_MASK | (vtx_buf_ptr)); \ + (pvr_vertex_t *)(MEM_AREA_P4_BASE | (vtx_buf_ptr)); \ }) /** \brief Commit a primitive written into the Direct Rendering target address. hooks/post-receive -- A pseudo Operating System for the Dreamcast. |
From: darcagn <da...@us...> - 2023-08-03 20:35:17
|
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 90e09d81d7c1f9dc3f31290a8fff94e4d5ff304a (commit) via f5d4472052a62ae1b6f4a3a7c280426a8c49f4a4 (commit) via 6bac3d533e86fc05a6ecd6356d3e8af95d498f6b (commit) via d95d2668c8c520cb5782a136c2c4615eb332a985 (commit) via d521b5d751ed282861acf95c72bcdc86cd4482fb (commit) via aae7c86cf74794ac62649ba561339bd26c49108f (commit) via 5c3056cc35bae9c3d9a1995a40f4017043f6324b (commit) via aabf6aff6323133b866e2ef6f2bdb58f0ffdc270 (commit) via f86a371c1c3914c051b7fbfb153ef3b500063cdf (commit) via 46916200b63805cecbe11bf4d71be96d2957edec (commit) via 1dc4d3ceca30cb38e25eed13f04acadcdc495732 (commit) via bce717cedbb90835d235e77045a887aa68ed0c06 (commit) via 4b5f505678db224d321119b2c76c6f6dbdd86699 (commit) via 4c603aeda21453af1429951cfe9a74e639aec7fb (commit) via bac9fcdfbab18a2ec8166c0f2b803a17bcb6f224 (commit) via c5dd226e2d16c95c3576c221867d9858dfe7db65 (commit) from cddc9555d0895bfc940b151f4572c7c3019fee5f (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 90e09d81d7c1f9dc3f31290a8fff94e4d5ff304a Merge: f5d4472 d95d266 Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 3 16:08:31 2023 -0400 Merge pull request #246 from KallistiOS/non-magical_map Defines for memory areas commit f5d4472052a62ae1b6f4a3a7c280426a8c49f4a4 Merge: cddc955 6bac3d5 Author: Lawrence Sebald <ljs...@us...> Date: Thu Aug 3 16:06:44 2023 -0400 Merge pull request #257 from KallistiOS/newstable Stabilize 13.2; update binutils to 2.41; revise documentation, configs, and Dockerfile commit 6bac3d533e86fc05a6ecd6356d3e8af95d498f6b Author: darc <da...@pr...> Date: Sun Jul 30 22:08:19 2023 -0500 Stabilize 13.2; update binutils to 2.41; revise documentation, configs, and Dockerfile commit d95d2668c8c520cb5782a136c2c4615eb332a985 Author: Donald Haase <qu...@co...> Date: Sun Jul 9 14:01:48 2023 -0400 Final cleanup commit d521b5d751ed282861acf95c72bcdc86cd4482fb Author: Donald Haase <qu...@ya...> Date: Sun Jul 9 13:16:33 2023 -0400 Apply suggestions from code review Co-authored-by: Lawrence Sebald <ljs...@us...> commit aae7c86cf74794ac62649ba561339bd26c49108f Author: Donald Haase <qu...@ya...> Date: Sun Jul 9 13:10:06 2023 -0400 Update kernel/arch/dreamcast/include/arch/memory.h Co-authored-by: Lawrence Sebald <ljs...@us...> commit 5c3056cc35bae9c3d9a1995a40f4017043f6324b Author: Donald Haase <qu...@co...> Date: Sun Jun 25 06:19:27 2023 -0400 Add changes to the maple file defines commit aabf6aff6323133b866e2ef6f2bdb58f0ffdc270 Author: Donald Haase <qu...@co...> Date: Sun Jun 25 05:46:16 2023 -0400 Update define name to the more descriptive SQ_BASE commit f86a371c1c3914c051b7fbfb153ef3b500063cdf Author: Donald Haase <qu...@co...> Date: Sun Jun 25 05:45:06 2023 -0400 Move and rename memory header, adjust names, and expand contents. commit 46916200b63805cecbe11bf4d71be96d2957edec Author: Donald Haase <qu...@ya...> Date: Tue Jun 20 11:42:36 2023 -0400 Update kernel/arch/dreamcast/include/dc/memmap.h Co-authored-by: Lawrence Sebald <ljs...@us...> commit 1dc4d3ceca30cb38e25eed13f04acadcdc495732 Author: Donald Haase <qu...@ya...> Date: Tue Jun 20 11:42:30 2023 -0400 Update kernel/arch/dreamcast/include/dc/memmap.h Co-authored-by: Lawrence Sebald <ljs...@us...> commit bce717cedbb90835d235e77045a887aa68ed0c06 Author: Donald Haase <qu...@ya...> Date: Tue Jun 20 11:42:13 2023 -0400 Update kernel/arch/dreamcast/include/dc/memmap.h Co-authored-by: Lawrence Sebald <ljs...@us...> commit 4b5f505678db224d321119b2c76c6f6dbdd86699 Author: Donald Haase <qu...@ya...> Date: Tue Jun 20 11:42:00 2023 -0400 Update kernel/arch/dreamcast/include/dc/memmap.h Co-authored-by: Lawrence Sebald <ljs...@us...> commit 4c603aeda21453af1429951cfe9a74e639aec7fb Author: Donald Haase <qu...@co...> Date: Sat Jun 10 00:33:11 2023 -0400 kos/thd WAS being used commit bac9fcdfbab18a2ec8166c0f2b803a17bcb6f224 Author: Donald Haase <qu...@co...> Date: Sat Jun 10 00:25:13 2023 -0400 A few more mem defines I'd missed commit c5dd226e2d16c95c3576c221867d9858dfe7db65 Author: Donald Haase <qu...@co...> Date: Sat Jun 10 00:21:02 2023 -0400 Adding a header for defines related to memory regions, then applying them ----------------------------------------------------------------------- Summary of changes: include/kos.h | 1 + .../dreamcast/hardware/maple/maple_init_shutdown.c | 5 +- kernel/arch/dreamcast/hardware/maple/maple_queue.c | 5 +- kernel/arch/dreamcast/hardware/maple/maple_utils.c | 3 +- kernel/arch/dreamcast/hardware/sq.c | 21 +- kernel/arch/dreamcast/include/arch/memory.h | 206 ++++++++++ kernel/arch/dreamcast/include/dc/pvr.h | 3 +- kernel/arch/dreamcast/kernel/init.c | 5 +- utils/dc-chain/README.md | 435 ++++++++++----------- utils/dc-chain/config/README.md | 16 + .../config.mk.10.5.0.sample} | 109 +++--- .../config.mk.11.4.0.sample} | 109 +++--- .../config.mk.12.3.0.sample} | 109 +++--- .../config.mk.9.3.0.sample} | 103 +++-- .../config.mk.devel.sample} | 129 +++--- .../dc-chain/{ => config}/config.mk.legacy.sample | 102 +++-- .../config.mk.stable.sample} | 107 +++-- utils/dc-chain/doc/CONTRIBUTORS.md | 1 + utils/dc-chain/doc/changelog.txt | 175 +++++++++ utils/dc-chain/docker/Dockerfile | 10 +- .../{gcc-13.2.0-kos.diff => gcc-10.5.0-kos.diff} | 90 +++-- .../{gcc-13.1.0-kos.diff => gcc-11.4.0-kos.diff} | 90 +++-- .../{gcc-13.2.0-kos.diff => gcc-12.3.0-kos.diff} | 90 +++-- .../{gcc-13.1.0-kos.diff => gcc-devel-kos.diff} | 50 +-- 24 files changed, 1170 insertions(+), 804 deletions(-) create mode 100644 kernel/arch/dreamcast/include/arch/memory.h create mode 100644 utils/dc-chain/config/README.md copy utils/dc-chain/{config.mk.testing.sample => config/config.mk.10.5.0.sample} (81%) copy utils/dc-chain/{config.mk.testing.sample => config/config.mk.11.4.0.sample} (81%) copy utils/dc-chain/{config.mk.testing.sample => config/config.mk.12.3.0.sample} (81%) rename utils/dc-chain/{config.mk.stable.sample => config/config.mk.9.3.0.sample} (82%) copy utils/dc-chain/{config.mk.testing.sample => config/config.mk.devel.sample} (77%) rename utils/dc-chain/{ => config}/config.mk.legacy.sample (80%) rename utils/dc-chain/{config.mk.testing.sample => config/config.mk.stable.sample} (82%) create mode 100644 utils/dc-chain/doc/changelog.txt copy utils/dc-chain/patches/{gcc-13.2.0-kos.diff => gcc-10.5.0-kos.diff} (59%) copy utils/dc-chain/patches/{gcc-13.1.0-kos.diff => gcc-11.4.0-kos.diff} (59%) copy utils/dc-chain/patches/{gcc-13.2.0-kos.diff => gcc-12.3.0-kos.diff} (59%) copy utils/dc-chain/patches/{gcc-13.1.0-kos.diff => gcc-devel-kos.diff} (69%) diff --git a/include/kos.h b/include/kos.h index cc072b5..9df1bbd 100644 --- a/include/kos.h +++ b/include/kos.h @@ -72,6 +72,7 @@ __BEGIN_DECLS #ifdef _arch_dreamcast # include <arch/gdb.h> # include <arch/mmu.h> +# include <arch/memory.h> # include <dc/asic.h> # include <dc/biosfont.h> diff --git a/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c b/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c index 11dc8f4..d8aab34 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_init_shutdown.c @@ -7,6 +7,7 @@ #include <malloc.h> #include <stdio.h> #include <assert.h> +#include <arch/memory.h> #include <dc/maple.h> #include <dc/asic.h> #include <dc/vblank.h> @@ -69,7 +70,7 @@ int maple_hw_init(void) { assert_msg((((uint32)maple_state.dma_buffer) & 0x1f) == 0, "DMA buffer was unaligned; bug in dlmalloc; please report!"); /* Force it into the P2 area */ - maple_state.dma_buffer = (uint8*)((((uint32)maple_state.dma_buffer) & 0x1fffffff) | 0xa0000000); + maple_state.dma_buffer = (uint8*)((((uint32)maple_state.dma_buffer) & MEM_AREA_CACHE_MASK) | MEM_AREA_P2_BASE); #if MAPLE_DMA_DEBUG maple_state.dma_buffer += 512; maple_sentinel_setup(maple_state.dma_buffer - 512, MAPLE_DMA_SIZE + 1024); @@ -124,7 +125,7 @@ void maple_hw_shutdown(void) { #if MAPLE_DMA_DEBUG ptr -= 512; #endif - ptr = (ptr & 0x1fffffff) | 0x80000000; + ptr = (ptr & MEM_AREA_CACHE_MASK) | MEM_AREA_P1_BASE; free((void *)ptr); maple_state.dma_buffer = NULL; } diff --git a/kernel/arch/dreamcast/hardware/maple/maple_queue.c b/kernel/arch/dreamcast/hardware/maple/maple_queue.c index 0712f8e..6566a75 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_queue.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_queue.c @@ -10,6 +10,7 @@ #include <string.h> #include <dc/maple.h> #include <arch/irq.h> +#include <arch/memory.h> /* Send all queued frames */ void maple_queue_flush(void) { @@ -44,7 +45,7 @@ void maple_queue_flush(void) { *out++ = i->length | (i->dst_port << 16); /* Second word: receive buffer physical address */ - *out++ = ((uint32)i->recv_buf) & 0x1fffffff; + *out++ = ((uint32)i->recv_buf) & MEM_AREA_CACHE_MASK; /* Third word: command, addressing, packet length */ *out++ = (i->cmd & 0xff) | (maple_addr(i->dst_port, i->dst_unit) << 8) @@ -157,7 +158,7 @@ void maple_frame_init(maple_frame_t *frame) { #if MAPLE_DMA_DEBUG buf_ptr += 512; #endif - buf_ptr = (buf_ptr & 0x1fffffff) | 0xa0000000; + buf_ptr = (buf_ptr & MEM_AREA_CACHE_MASK) | MEM_AREA_P2_BASE; frame->recv_buf = (uint8*)buf_ptr; /* Clear out the receive buffer */ diff --git a/kernel/arch/dreamcast/hardware/maple/maple_utils.c b/kernel/arch/dreamcast/hardware/maple/maple_utils.c index da38c2a..a720404 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_utils.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_utils.c @@ -8,6 +8,7 @@ #include <assert.h> #include <stdio.h> #include <string.h> +#include <arch/memory.h> #include <dc/maple.h> /* Enable / Disable the bus */ @@ -32,7 +33,7 @@ int maple_dma_in_progress(void) { /* Set the DMA Address */ void maple_dma_addr(void *ptr) { - maple_write(MAPLE_DMAADDR, ((uint32) ptr) & 0x1fffffff); + maple_write(MAPLE_DMAADDR, ((uint32) ptr) & MEM_AREA_CACHE_MASK); } /* Return a "maple address" for a port,unit pair */ diff --git a/kernel/arch/dreamcast/hardware/sq.c b/kernel/arch/dreamcast/hardware/sq.c index c6c89d4..4ec7be3 100644 --- a/kernel/arch/dreamcast/hardware/sq.c +++ b/kernel/arch/dreamcast/hardware/sq.c @@ -4,6 +4,7 @@ Copyright (C) 2001 Andrew Kieschnick */ +#include <arch/memory.h> #include <dc/sq.h> /* @@ -15,7 +16,7 @@ /* clears n bytes at dest, dest must be 32-byte aligned */ void sq_clr(void *dest, int n) { unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)dest) & 0x03ffffe0)); + (MEM_AREA_SQ_BASE | (((unsigned long)dest) & 0x03ffffe0)); /* Set store queue memory area as desired */ QACR0 = ((((unsigned int)dest) >> 26) << 2) & 0x1c; @@ -34,14 +35,14 @@ void sq_clr(void *dest, int n) { } /* Wait for both store queues to complete */ - d = (unsigned int *)0xe0000000; + d = (unsigned int *)MEM_AREA_SQ_BASE; d[0] = d[8] = 0; } /* copies n bytes from src to dest, dest must be 32-byte aligned */ void * sq_cpy(void *dest, const void *src, int n) { unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)dest) & 0x03ffffe0)); + (MEM_AREA_SQ_BASE | (((unsigned long)dest) & 0x03ffffe0)); const unsigned int *s = src; /* Set store queue memory area as desired */ @@ -66,7 +67,7 @@ void * sq_cpy(void *dest, const void *src, int n) { } /* Wait for both store queues to complete */ - d = (unsigned int *)0xe0000000; + d = (unsigned int *)MEM_AREA_SQ_BASE; d[0] = d[8] = 0; return dest; @@ -75,7 +76,7 @@ void * sq_cpy(void *dest, const void *src, int n) { /* fills n bytes at s with byte c, s must be 32-byte aligned */ void * sq_set(void *s, uint32 c, int n) { unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)s) & 0x03ffffe0)); + (MEM_AREA_SQ_BASE | (((unsigned long)s) & 0x03ffffe0)); /* Set store queue memory area as desired */ QACR0 = ((((unsigned int)s) >> 26) << 2) & 0x1c; @@ -98,7 +99,7 @@ void * sq_set(void *s, uint32 c, int n) { } /* Wait for both store queues to complete */ - d = (unsigned int *)0xe0000000; + d = (unsigned int *)MEM_AREA_SQ_BASE; d[0] = d[8] = 0; return s; @@ -107,7 +108,7 @@ void * sq_set(void *s, uint32 c, int n) { /* fills n bytes at s with short c, s must be 32-byte aligned */ void * sq_set16(void *s, uint32 c, int n) { unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)s) & 0x03ffffe0)); + (MEM_AREA_SQ_BASE | (((unsigned long)s) & 0x03ffffe0)); /* Set store queue memory area as desired */ QACR0 = ((((unsigned int)s) >> 26) << 2) & 0x1c; @@ -130,7 +131,7 @@ void * sq_set16(void *s, uint32 c, int n) { } /* Wait for both store queues to complete */ - d = (unsigned int *)0xe0000000; + d = (unsigned int *)MEM_AREA_SQ_BASE; d[0] = d[8] = 0; return s; @@ -139,7 +140,7 @@ void * sq_set16(void *s, uint32 c, int n) { /* fills n bytes at s with int c, s must be 32-byte aligned */ void * sq_set32(void *s, uint32 c, int n) { unsigned int *d = (unsigned int *)(void *) - (0xe0000000 | (((unsigned long)s) & 0x03ffffe0)); + (MEM_AREA_SQ_BASE | (((unsigned long)s) & 0x03ffffe0)); /* Set store queue memory area as desired */ QACR0 = ((((unsigned int)s) >> 26) << 2) & 0x1c; @@ -158,7 +159,7 @@ void * sq_set32(void *s, uint32 c, int n) { } /* Wait for both store queues to complete */ - d = (unsigned int *)0xe0000000; + d = (unsigned int *)MEM_AREA_SQ_BASE; d[0] = d[8] = 0; return s; diff --git a/kernel/arch/dreamcast/include/arch/memory.h b/kernel/arch/dreamcast/include/arch/memory.h new file mode 100644 index 0000000..9a19124 --- /dev/null +++ b/kernel/arch/dreamcast/include/arch/memory.h @@ -0,0 +1,206 @@ +/* KallistiOS ##version## + + kernel/arch/dreamcast/include/arch/memory.h + Copyright (C) 2023 Donald Haase + +*/ + +/** \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 + here are Dreamcast-specific. + + These values are drawn from the Hitatchi SH7750 Series Hardware Manual rev 6.0. + + \author Donald Haase +*/ + +#ifndef __ARCH_MEMORY_H +#define __ARCH_MEMORY_H + +#include <sys/cdefs.h> +__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 + bottom 512MB mirrored to the P1, P2, and P3 regions. + +*/ + +/** \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 + DMA and SQ usage as well as various MMU functions. + +*/ +#define MEM_AREA_CACHE_MASK 0x1fffffff + +/** \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 + copy-back mode. + + KOS runs in privileged mode, so this is here merely for completeness. + +*/ +#define MEM_AREA_U0_BASE 0x00000000 + +/** \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 + copy-back mode. + +*/ +#define MEM_AREA_P0_BASE 0x00000000 + +/** \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 + to the same copy-back mode as the other cachable regions. + +*/ +#define MEM_AREA_P1_BASE 0x80000000 + +/** \brief P2 memory region (non-cachable). + \ingroup memory + + This is the non-cachable memory region. It is most frequently for DMA + transactions to ensure reads are not cached. + +*/ +#define MEM_AREA_P2_BASE 0xa0000000 + +/** \brief P3 memory region (cachable). + \ingroup memory + + This functions as the lower 512MB of P0. + +*/ +#define MEM_AREA_P3_BASE 0xc0000000 + +/** \brief P4 SH-internal memory region (non-cachable). + \defgroup p4mem + \ingroup memory + + This offset maps to on-chip I/O channels. + +*/ +#define MEM_AREA_P4_BASE 0xe0000000 + +/** \brief Store Queue (SQ) memory base. + \ingroup p4mem + + This offset maps to the SQ memory region. RW to addresses from + 0xe0000000-0xe3ffffff follow SQ rules. + + \see dc\sq.h + +*/ +#define MEM_AREA_SQ_BASE 0xe0000000 + +/** \brief Instruction cache address array base. + \ingroup p4mem + + This offset is used for direct access to the instruction cache address array. + +*/ +#define MEM_AREA_ICACHE_ADDRESS_ARRAY_BASE 0xf0000000 + +/** \brief Instruction cache data array base. + \ingroup p4mem + + This offset is used for direct access to the instruction cache data array. + +*/ +#define MEM_AREA_ICACHE_DATA_ARRAY_BASE 0xf1000000 + +/** \brief Instruction TLB address array base. + \ingroup p4mem + + This offset is used for direct access to the instruction TLB address array. + +*/ +#define MEM_AREA_ITLB_ADDRESS_ARRAY_BASE 0xf2000000 + +/** \brief Instruction TLB data array 1 base. + \ingroup p4mem + + This offset is used for direct access to the instruction TLB data array 1. + +*/ +#define MEM_AREA_ITLB_DATA_ARRAY1_BASE 0xf3000000 + +/** \brief Instruction TLB data array 2 base. + \ingroup p4mem + + This offset is used for direct access to the instruction TLB data array 2. + +*/ +#define MEM_AREA_ITLB_DATA_ARRAY2_BASE 0xf3800000 + +/** \brief Operand cache address array base. + \ingroup p4mem + + This offset is used for direct access to the operand cache address array. + +*/ +#define MEM_AREA_OCACHE_ADDRESS_ARRAY_BASE 0xf4000000 + +/** \brief Instruction cache data array base. + \ingroup p4mem + + This offset is used for direct access to the operand cache data array. + +*/ +#define MEM_AREA_OCACHE_DATA_ARRAY_BASE 0xf5000000 + +/** \brief Unified TLB address array base. + \ingroup p4mem + + This offset is used for direct access to the unified TLB address array. + +*/ +#define MEM_AREA_UTLB_ADDRESS_ARRAY_BASE 0xf6000000 + +/** \brief Unified TLB data array 1 base. + \ingroup p4mem + + This offset is used for direct access to the unified TLB data array 1. + +*/ +#define MEM_AREA_UTLB_DATA_ARRAY1_BASE 0xf7000000 + +/** \brief Unified TLB data array 2 base. + \ingroup p4mem + + This offset is used for direct access to the unified TLB data array 2. + +*/ +#define MEM_AREA_UTLB_DATA_ARRAY2_BASE 0xf7800000 + +/** \brief Control Register base. + \ingroup p4mem + + This is the base address of all control registers + +*/ +#define MEM_AREA_CTRL_REG_BASE 0xff000000 + +__END_DECLS + +#endif /* __ARCH_MEMORY_H */ diff --git a/kernel/arch/dreamcast/include/dc/pvr.h b/kernel/arch/dreamcast/include/dc/pvr.h index e332ab1..d3efe2d 100644 --- a/kernel/arch/dreamcast/include/dc/pvr.h +++ b/kernel/arch/dreamcast/include/dc/pvr.h @@ -34,6 +34,7 @@ #include <sys/cdefs.h> __BEGIN_DECLS +#include <arch/memory.h> #include <arch/types.h> #include <dc/sq.h> #include <kos/img.h> @@ -1662,7 +1663,7 @@ typedef uint32 pvr_dr_state_t; */ #define pvr_dr_target(vtx_buf_ptr) \ ({ (vtx_buf_ptr) ^= 32; \ - (pvr_vertex_t *)(0xe0000000 | (vtx_buf_ptr)); \ + (pvr_vertex_t *)(MEM_AREA_P4_MASK | (vtx_buf_ptr)); \ }) /** \brief Commit a primitive written into the Direct Rendering target address. diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index 86badbe..82373b5 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -10,10 +10,11 @@ #include <string.h> #include <stdlib.h> #include <kos/dbgio.h> -#include <arch/timer.h> #include <arch/arch.h> #include <arch/irq.h> +#include <arch/memory.h> #include <arch/rtc.h> +#include <arch/timer.h> #include <dc/ubc.h> #include <dc/pvr.h> #include <dc/vmufs.h> @@ -378,6 +379,6 @@ void arch_reboot(void) { irq_disable(); /* Reboot */ - rb = (reboot_func)0xa0000000; + rb = (reboot_func)(MEM_AREA_P2_BASE | 0x00000000); rb(); } diff --git a/utils/dc-chain/README.md b/utils/dc-chain/README.md index d627b98..6a8b897 100644 --- a/utils/dc-chain/README.md +++ b/utils/dc-chain/README.md @@ -1,88 +1,87 @@ # Sega Dreamcast Toolchains Maker (`dc-chain`) -The **Sega Dreamcast Toolchains Maker** (`dc-chain`) utility is a set of files -made for building all the needed toolchains used in **Sega Dreamcast** -programming under the **KallistiOS** environment. It was first released by -*Jim Ursetto* back in 2004 and was initially adapted from *Stalin*'s build -script v0.3. This utility is part of **KallistiOS** (**KOS**). - -By using this utility, 2 toolchains will be built for **Dreamcast** development: - -- A `sh-elf` toolchain, which is the main toolchain as it targets the CPU of the - **Dreamcast**, i.e. the **Hitachi SH-4 CPU** (a.k.a. **SuperH**). -- An `arm-eabi` toolchain, which is the toolchain used only for the **Yamaha - Super Intelligent Sound Processor** (**AICA**). This processor is based - on an **ARM7** core. Under **KallistiOS**, only the sound driver is compiled ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |