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
(26) |
Aug
(48) |
Sep
(30) |
Oct
(8) |
Nov
(9) |
Dec
|
|
From: kosmirror <kos...@us...> - 2025-09-25 15:39:47
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via d8f7df2599dc3e147ae585855f396d74e8a28ef4 (commit)
via 183f3caa980500ee5ef4386920befd0ba2077fb9 (commit)
via 57eac6bf98c1b549df19e81efd433161f846f24c (commit)
via b8ca37df81ce110ef6156c118fc04d9a0b236b6e (commit)
via be56dc0eef09b433f6bb50f260c482c865b6c382 (commit)
via dc2f7b2e5524557dbb03f676d296c680edc31bb1 (commit)
via 8a0b8d10df3819988dfb1495a2cb1ea3af7e6bc3 (commit)
via 43b0ab08ef9cd8b51a060d2cec0c5598394d05c6 (commit)
via 5eaa446f8e63def5a245b011d2418e306f1e36af (commit)
via 4d71ba186d4a9ca2a7fa5f375841dcdb6578ccc9 (commit)
via 583490490f4c194821c95aec365d1a65635be9ac (commit)
via 1cf3ca4c592700e1799a057a1d9076caa646e3fd (commit)
via 946586d1ad3349e1381dde236990d1bae986cb3e (commit)
via 530af522581825b4ae9152e68357bb5a168079eb (commit)
via ab38ca87b30f641d50fdf5b35ad357b370b1c469 (commit)
via 4837c4b9b8a3481ba5f02c6f66b904e629007fa2 (commit)
via b62400ea86be0266c095fa80a72aefe1caa06f2d (commit)
via 4daa9835b384abe87fbeef274a5e434e43d5207a (commit)
via 826789b2574552848bdd0b1b4160f96da2947805 (commit)
from 2babea38ec32a10203c373a9d77b53cf3d1a8d53 (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 d8f7df2599dc3e147ae585855f396d74e8a28ef4
Author: QuzarDC <qu...@co...>
Date: Sun Sep 21 19:50:18 2025 -0400
fs_dcload: Drop dir list.
The dir list was a means to track which handles were
dirs or not. Instead use the `path` member of the object
to do the same and return an opaque token to that object
rather than the `hnd` used by the host-side.
commit 183f3caa980500ee5ef4386920befd0ba2077fb9
Author: QuzarDC <qu...@co...>
Date: Sun Sep 21 18:41:10 2025 -0400
fs_dcload: Set errno on not finding a file.
`ENOENT` to match the `ENOTDIR` set by the dir path.
commit 57eac6bf98c1b549df19e81efd433161f846f24c
Author: QuzarDC <qu...@co...>
Date: Wed Jun 25 04:11:50 2025 -0400
Update filebrowser example to show file stats.
Simple addition to draw the Filesize and modification
time as provided by stat. Was updated in order to help
validate functionality of stat over `/pc/` after updating
to use a standardized stat rather than custom dcload one.
commit b8ca37df81ce110ef6156c118fc04d9a0b236b6e
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 20:18:55 2025 -0400
fs_dcload: Protect against possible buffer overflow in readdir.
commit be56dc0eef09b433f6bb50f260c482c865b6c382
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 17:17:12 2025 -0400
dcload: Replace dcload_dirent with our standard one.
The sizes and defined types match. The risk in doing this
is only in if the host side needs to change its data types.
In that case though, there would have to be changes on the KOS
side as well.
commit dc2f7b2e5524557dbb03f676d296c680edc31bb1
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 15:52:46 2025 -0400
dcload: Implement each unimplemented dcload command.
chdir, chmod, fstat, time, utime, and exit had never been
implemented in KOS. utime has been left as a commented out
stub to note how there would likely need to be updates to
the tool in order for it to work.
commit 8a0b8d10df3819988dfb1495a2cb1ea3af7e6bc3
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 03:58:05 2025 -0400
dcload: Whitespace and junk cleanup.
Mostly moving stars, but also some lining up of comments and
removal of a prototype that had no function.
commit 43b0ab08ef9cd8b51a060d2cec0c5598394d05c6
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 02:11:44 2025 -0400
dcload: Add assignwrkmem function.
commit 5eaa446f8e63def5a245b011d2418e306f1e36af
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 03:50:02 2025 -0400
dcload: Add dir related functions.
Open, close, read, and rewind. Additionally move the dirent
type over.
commit 4d71ba186d4a9ca2a7fa5f375841dcdb6578ccc9
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 03:28:47 2025 -0400
dcload: Create function for stat.
Bigger than others as the bespoke stat type was moved.
commit 583490490f4c194821c95aec365d1a65635be9ac
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 03:19:16 2025 -0400
dcload: Create functions for link, unlink, and lseek.
commit 1cf3ca4c592700e1799a057a1d9076caa646e3fd
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 03:04:36 2025 -0400
dcload: Create functions for read, write, open, and close commands.
commit 946586d1ad3349e1381dde236990d1bae986cb3e
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 02:53:30 2025 -0400
dcload: Create function for `gethostinfo` command.
commit 530af522581825b4ae9152e68357bb5a168079eb
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 02:43:34 2025 -0400
dcload: Move gdb packet function to new file.
commit ab38ca87b30f641d50fdf5b35ad357b370b1c469
Author: QuzarDC <qu...@co...>
Date: Tue Jun 24 02:04:31 2025 -0400
dcload: Rename internal vfs functions.
To follow our standard naming convention as well as
`dcloadgetgdbpacket` a lot of the syscall functions
for the file ops would overlap with these names. So
renaming in order to get the conflict out of the way.
commit 4837c4b9b8a3481ba5f02c6f66b904e629007fa2
Author: QuzarDC <qu...@co...>
Date: Mon Jun 23 20:33:07 2025 -0400
fs_dcload: Reduce scope and severity of locking.
Currently `fs_dcload` uses fairly broad spinlocks over most of
each function. From the history it looks as though these are
spinlocks simply because we didn't have other sorts of locks
when this was originally written. It can't have to do with the
actual operations as the syscall has always been called with
irqs disabled.
So here I make three changes:
First: Implement a rwsem to protect the shared dir list. This is
specifically for protecting access to that data structure.
Second: Reduce the scope of the 'mutex' locks. Leave them only in
cases where multiple dcload commands must be issued and
we should expect that others wouldn't be issued between them.
It may be that these can be shrunken down slightly more.
Third: Change the spinlocks to mutexes.
commit b62400ea86be0266c095fa80a72aefe1caa06f2d
Author: QuzarDC <qu...@co...>
Date: Mon Jun 23 15:06:27 2025 -0400
dcload: Change last remaining arch/types to stdint
commit 4daa9835b384abe87fbeef274a5e434e43d5207a
Author: QuzarDC <qu...@co...>
Date: Sun Jun 22 23:36:56 2025 -0400
dcload: Migrate syscall into our BIOS syscalls file.
Create a proper C function for dcload's syscall to match
the way we do for other syscalls rather than as a macro wrapper
around an asm file.
Additionally move the definitions of the commands for the syscall
to accompany it. I had considered whether this might be better as
its own `syscalls-custom` since it does operate differently, including
having a function to detect whether it's present or not. It may be that
this could represent a defining pattern for the use of other custom
syscalls from modded BIOS or alternative loaders (dcload NG/3).
commit 826789b2574552848bdd0b1b4160f96da2947805
Author: QuzarDC <qu...@co...>
Date: Sun May 11 01:50:52 2025 -0400
Rename and expose if the dcload syscall is installed.
Removed two usages that were redundant. There is no
condition where `dcload_type` could be set to `TYPE_SER`
while dcload is not detected.
Renamed to indicate that it's not a part of the dcload vfs.
-----------------------------------------------------------------------
Summary of changes:
addons/libppp/ppp_scif.c | 2 +-
examples/dreamcast/filesystem/browse/browse.c | 44 +++-
examples/dreamcast/filesystem/browse/browse.h | 2 +
kernel/arch/dreamcast/fs/Makefile | 3 +-
kernel/arch/dreamcast/fs/dcload-syscall.s | 19 --
kernel/arch/dreamcast/fs/fs_dcload.c | 296 +++++++++++---------------
kernel/arch/dreamcast/fs/fs_dclsocket.c | 15 +-
kernel/arch/dreamcast/hardware/Makefile | 2 +-
kernel/arch/dreamcast/hardware/dcload.c | 134 ++++++++++++
kernel/arch/dreamcast/hardware/scif-spi.c | 2 +-
kernel/arch/dreamcast/include/dc/dcload.h | 114 ++++++++++
kernel/arch/dreamcast/include/dc/fs_dcload.h | 74 +------
kernel/arch/dreamcast/kernel/gdb_stub.c | 2 +-
kernel/arch/dreamcast/kernel/init.c | 3 +-
14 files changed, 427 insertions(+), 285 deletions(-)
delete mode 100644 kernel/arch/dreamcast/fs/dcload-syscall.s
create mode 100644 kernel/arch/dreamcast/hardware/dcload.c
create mode 100644 kernel/arch/dreamcast/include/dc/dcload.h
diff --git a/addons/libppp/ppp_scif.c b/addons/libppp/ppp_scif.c
index c22aacca..ed57902d 100644
--- a/addons/libppp/ppp_scif.c
+++ b/addons/libppp/ppp_scif.c
@@ -80,7 +80,7 @@ static ppp_device_t scif_dev = {
int ppp_scif_init(int bps) {
/* Make sure we're not using dcload-serial. If we are, we really shouldn't
take over the serial port from it. */
- if(*DCLOADMAGICADDR == DCLOADMAGICVALUE && dcload_type == DCLOAD_TYPE_SER) {
+ if(dcload_type == DCLOAD_TYPE_SER) {
dbglog(DBG_KDEBUG, "ppp_scif_init: aborting -- using dcload-serial.\n");
return -1;
}
diff --git a/examples/dreamcast/filesystem/browse/browse.c b/examples/dreamcast/filesystem/browse/browse.c
index ccd3bf29..35552ffc 100644
--- a/examples/dreamcast/filesystem/browse/browse.c
+++ b/examples/dreamcast/filesystem/browse/browse.c
@@ -51,6 +51,7 @@ int main(int argc, char **argv) {
directory_file_t directory_contents[100];
bool prompting = false;
+ bool statting = false;
bool highlight_yes = true;
bool mounted_sd = false;
bool changed_directory = true;
@@ -74,8 +75,14 @@ int main(int argc, char **argv) {
changed_buttons = current_buttons ^ previous_buttons;
previous_buttons = current_buttons;
+ /* Clear the stat if any button is pressed */
+ if(statting && button_pressed(current_buttons, changed_buttons, 0)) {
+ statting = false; /* Get us out of captivity */
+ changed_directory = true; /* Force redraw of the screen to clear stat */
+ }
+
/* Enter a directory */
- if(button_pressed(current_buttons, changed_buttons, CONT_A)) {
+ else if(button_pressed(current_buttons, changed_buttons, CONT_A)) {
if(prompting) {
prompting = false;
changed_directory = true;
@@ -134,7 +141,7 @@ int main(int argc, char **argv) {
}
/* Exit a directory */
- if(button_pressed(current_buttons, changed_buttons, CONT_B)) {
+ else if(button_pressed(current_buttons, changed_buttons, CONT_B)) {
if(prompting) {
prompting = false;
changed_directory = true;
@@ -156,9 +163,19 @@ int main(int argc, char **argv) {
}
}
}
+
+ /* Stat an entry */
+ else if(button_pressed(current_buttons, changed_buttons, CONT_Y)) {
+ if(!prompting) {
+ memset(directory_temp, 0, BUFFER_LENGTH);
+ fs_path_append(directory_temp, current_directory, BUFFER_LENGTH);
+ fs_path_append(directory_temp, directory_contents[selector_index].filename, BUFFER_LENGTH);
+ statting = draw_stat(directory_temp);
+ }
+ }
/* Navigate the directory */
- if(button_pressed(current_buttons, changed_buttons, CONT_DPAD_DOWN)) {
+ else if(button_pressed(current_buttons, changed_buttons, CONT_DPAD_DOWN)) {
if(prompting) {
highlight_yes = !highlight_yes;
show_prompt(current_directory, mounted_sd, highlight_yes);
@@ -170,7 +187,7 @@ int main(int argc, char **argv) {
}
}
}
- if(button_pressed(current_buttons, changed_buttons, CONT_DPAD_UP)) {
+ else if(button_pressed(current_buttons, changed_buttons, CONT_DPAD_UP)) {
if(prompting) {
highlight_yes = !highlight_yes;
show_prompt(current_directory, mounted_sd, highlight_yes);
@@ -184,7 +201,7 @@ int main(int argc, char **argv) {
}
/* Exit Program */
- if(button_pressed(current_buttons, changed_buttons, CONT_START))
+ else if(button_pressed(current_buttons, changed_buttons, CONT_START))
break;
/* Update the screen if we navigate a directory */
@@ -353,6 +370,23 @@ static void draw_directory_contents(directory_file_t *directory_contents, int nu
}
}
+static bool draw_stat(const char *path) {
+ int x = 20 + BFONT_HEIGHT, y = 350;
+ struct stat path_stat;
+
+ /* If stat fails */
+ if(stat(path, &path_stat) < 0)
+ return false;
+
+ /* We got a stat, so lets draw it */
+ bfont_draw_str_fmt(vram_s + y*SCREEN_WIDTH+x, SCREEN_WIDTH, true,
+ "Stat succeeded:\n\tFile size: %lu\n\tLast Modified: %s\n",
+ S_ISDIR(path_stat.st_mode) ? 0 : path_stat.st_size,
+ asctime(gmtime(&path_stat.st_mtime)));
+
+ return true;
+}
+
static cont_state_t *get_cont_state() {
maple_device_t *cont;
cont_state_t *state;
diff --git a/examples/dreamcast/filesystem/browse/browse.h b/examples/dreamcast/filesystem/browse/browse.h
index 2aa62012..506c39db 100644
--- a/examples/dreamcast/filesystem/browse/browse.h
+++ b/examples/dreamcast/filesystem/browse/browse.h
@@ -17,6 +17,8 @@ static void delete_file(char *filename, bool mounted_sd);
static void prompt_message(char *message, bool highlight_yes);
+static bool draw_stat(const char *path);
+
static void draw_directory_selector(int index);
static void draw_directory_contents(directory_file_t *directory_contents, int num);
diff --git a/kernel/arch/dreamcast/fs/Makefile b/kernel/arch/dreamcast/fs/Makefile
index 2fbcde5c..0e080ec3 100644
--- a/kernel/arch/dreamcast/fs/Makefile
+++ b/kernel/arch/dreamcast/fs/Makefile
@@ -6,8 +6,7 @@
# Dreamcast-specific file systems
-OBJS = fs_iso9660.o fs_vmu.o fs_dcload.o dcload-syscall.o vmufs.o \
- fs_dclsocket.o
+OBJS = fs_iso9660.o fs_vmu.o fs_dcload.o vmufs.o fs_dclsocket.o
SUBDIRS =
include $(KOS_BASE)/Makefile.prefab
diff --git a/kernel/arch/dreamcast/fs/dcload-syscall.s b/kernel/arch/dreamcast/fs/dcload-syscall.s
deleted file mode 100644
index 80976acb..00000000
--- a/kernel/arch/dreamcast/fs/dcload-syscall.s
+++ /dev/null
@@ -1,19 +0,0 @@
-! KallistiOS ##version##
-!
-! dcload-syscall.s
-! (c)2000-2001 Andrew Kieschnick
-!
-
- .section .text
- .global _dcloadsyscall
-
-_dcloadsyscall:
- mov.l dcloadsyscall_k,r0
- mov.l @r0,r0
- jmp @r0
- nop
-
-.align 4
-dcloadsyscall_k:
- .long 0x8c004008
-
diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c
index 93e7ca5e..fb17f46c 100644
--- a/kernel/arch/dreamcast/fs/fs_dcload.c
+++ b/kernel/arch/dreamcast/fs/fs_dcload.c
@@ -18,62 +18,35 @@ printf goes to the dc-tool console
*/
-#include <dc/fifo.h>
+#include <dc/dcload.h>
#include <dc/fs_dcload.h>
-#include <arch/spinlock.h>
#include <kos/dbgio.h>
#include <kos/dbglog.h>
#include <kos/fs.h>
#include <kos/init.h>
+#include <kos/mutex.h>
+#include <kos/rwsem.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/dirent.h>
#include <sys/queue.h>
-/* A linked list of dir entries. */
-typedef struct dcl_dir {
- LIST_ENTRY(dcl_dir) fhlist;
+typedef struct dcl_obj {
int hnd;
char *path;
dirent_t dirent;
-} dcl_dir_t;
+} dcl_obj_t;
-LIST_HEAD(dcl_de, dcl_dir);
+static mutex_t mutex = MUTEX_INITIALIZER;
-static struct dcl_de dir_head = LIST_HEAD_INITIALIZER(0);
-
-static dcl_dir_t *hnd_is_dir(int hnd) {
- dcl_dir_t *i;
-
- if(!hnd) return NULL;
-
- LIST_FOREACH(i, &dir_head, fhlist) {
- if(i->hnd == (int)hnd)
- break;
- }
-
- return i;
-}
-
-static spinlock_t mutex = SPINLOCK_INITIALIZER;
-
-#define dclsc(...) ({ \
- irq_disable_scoped(); \
- while(FIFO_STATUS & FIFO_SH4) \
- ; \
- dcloadsyscall(__VA_ARGS__); \
- })
-
-/* Printk replacement */
-
-int dcload_write_buffer(const uint8 *data, int len, int xlat) {
+int dcload_write_buffer(const uint8_t *data, int len, int xlat) {
(void)xlat;
- spinlock_lock_scoped(&mutex);
- dclsc(DCLOAD_WRITE, 1, data, len);
+ dcload_write(STDOUT_FILENO, data, len);
return len;
}
@@ -82,18 +55,8 @@ int dcload_read_cons(void) {
return -1;
}
-size_t dcload_gdbpacket(const char* in_buf, size_t in_size, char* out_buf, size_t out_size) {
-
- spinlock_lock_scoped(&mutex);
-
- /* we have to pack the sizes together because the dcloadsyscall handler
- can only take 4 parameters */
- return dclsc(DCLOAD_GDBPACKET, in_buf, (in_size << 16) | (out_size & 0xffff), out_buf);
-}
-
-static void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
- char *dcload_path = NULL;
- dcl_dir_t *entry;
+static void *fs_dcload_open(vfs_handler_t *vfs, const char *fn, int mode) {
+ dcl_obj_t *entry;
int hnd = 0;
int dcload_mode = 0;
int mm = (mode & O_MODE_MASK);
@@ -101,14 +64,18 @@ static void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
(void)vfs;
- spinlock_lock_scoped(&mutex);
+ entry = calloc(1, sizeof(dcl_obj_t));
+ if(!entry) {
+ errno = ENOMEM;
+ return (void *)NULL;
+ }
if(mode & O_DIR) {
if(fn[0] == '\0') {
fn = "/";
}
- hnd = dclsc(DCLOAD_OPENDIR, fn);
+ hnd = dcload_opendir(fn);
if(!hnd) {
/* It could be caused by other issues, such as
@@ -116,34 +83,23 @@ static void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
ENOTDIR seems to be the best generic and we should
set something */
errno = ENOTDIR;
- return (void *)NULL;
- }
-
- /* We got something back so create an dir list entry for it */
- entry = malloc(sizeof(dcl_dir_t));
- if(!entry) {
- errno = ENOMEM;
+ free(entry);
return (void *)NULL;
}
fn_len = strlen(fn);
if(fn[fn_len - 1] == '/') fn_len--;
- dcload_path = malloc(fn_len + 2);
- if(!dcload_path) {
+ entry->path = malloc(fn_len + 2);
+ if(!entry->path) {
errno = ENOMEM;
free(entry);
return (void *)NULL;
}
- memcpy(dcload_path, fn, fn_len);
- dcload_path[fn_len] = '/';
- dcload_path[fn_len+1] = '\0';
-
- /* Now that everything is ready, add to list */
- entry->hnd = hnd;
- entry->path = dcload_path;
- LIST_INSERT_HEAD(&dir_head, entry, fhlist);
+ memcpy(entry->path, fn, fn_len);
+ entry->path[fn_len] = '/';
+ entry->path[fn_len+1] = '\0';
}
else {
if(mm == O_RDONLY)
@@ -159,131 +115,121 @@ static void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
if(mode & O_TRUNC)
dcload_mode |= 0x0400;
- hnd = dclsc(DCLOAD_OPEN, fn, dcload_mode, 0644);
- hnd++; /* KOS uses 0 for error, not -1 */
+ hnd = dcload_open(fn, dcload_mode, 0644);
+
+ if(hnd == -1) {
+ errno = ENOENT;
+ free(entry);
+ return (void *)NULL;
+ }
}
- return (void *)hnd;
+ entry->hnd = hnd;
+ return (void *)entry;
}
-static int dcload_close(void * h) {
- uint32 hnd = (uint32)h;
- dcl_dir_t *i;
+static int fs_dcload_close(void *h) {
+ dcl_obj_t *obj = h;
- spinlock_lock_scoped(&mutex);
+ if(!obj) return 0;
- if(hnd) {
- /* Check if it's a dir */
- i = hnd_is_dir(hnd);
+ /* It has a path so it's a dir */
+ if(obj->path) {
+ dcload_closedir(obj->hnd);
- /* We found it in the list, so it's a dir */
- if(i) {
- dclsc(DCLOAD_CLOSEDIR, hnd);
- LIST_REMOVE(i, fhlist);
- free(i->path);
- free(i);
- }
- else {
- hnd--; /* KOS uses 0 for error, not -1 */
- dclsc(DCLOAD_CLOSE, hnd);
- }
+ free(obj->path);
}
+ else
+ dcload_close(obj->hnd);
+ free(obj);
return 0;
}
-static ssize_t dcload_read(void * h, void *buf, size_t cnt) {
+static ssize_t fs_dcload_read(void *h, void *buf, size_t cnt) {
ssize_t ret = -1;
- uint32 hnd = (uint32)h;
-
- spinlock_lock_scoped(&mutex);
+ dcl_obj_t *obj = h;
- if(hnd) {
- hnd--; /* KOS uses 0 for error, not -1 */
- ret = dclsc(DCLOAD_READ, hnd, buf, cnt);
- }
+ if(obj)
+ ret = dcload_read(obj->hnd, buf, cnt);
return ret;
}
-static ssize_t dcload_write(void * h, const void *buf, size_t cnt) {
+static ssize_t fs_dcload_write(void *h, const void *buf, size_t cnt) {
ssize_t ret = -1;
- uint32 hnd = (uint32)h;
+ dcl_obj_t *obj = h;
- spinlock_lock_scoped(&mutex);
-
- if(hnd) {
- hnd--; /* KOS uses 0 for error, not -1 */
- ret = dclsc(DCLOAD_WRITE, hnd, buf, cnt);
- }
+ if(obj)
+ ret = dcload_write(obj->hnd, buf, cnt);
return ret;
}
-static off_t dcload_seek(void * h, off_t offset, int whence) {
+static off_t fs_dcload_seek(void *h, off_t offset, int whence) {
off_t ret = -1;
- uint32 hnd = (uint32)h;
+ dcl_obj_t *obj = h;
- spinlock_lock_scoped(&mutex);
-
- if(hnd) {
- hnd--; /* KOS uses 0 for error, not -1 */
- ret = dclsc(DCLOAD_LSEEK, hnd, offset, whence);
- }
+ if(obj)
+ ret = dcload_lseek(obj->hnd, offset, whence);
return ret;
}
-static off_t dcload_tell(void * h) {
+static off_t fs_dcload_tell(void *h) {
off_t ret = -1;
- uint32 hnd = (uint32)h;
+ dcl_obj_t *obj = h;
- spinlock_lock_scoped(&mutex);
-
- if(hnd) {
- hnd--; /* KOS uses 0 for error, not -1 */
- ret = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_CUR);
- }
+ if(obj)
+ ret = dcload_lseek(obj->hnd, 0, SEEK_CUR);
return ret;
}
-static size_t dcload_total(void * h) {
+static size_t fs_dcload_total(void *h) {
size_t ret = -1;
- size_t cur;
- uint32 hnd = (uint32)h;
+ off_t cur;
+ dcl_obj_t *obj = h;
- spinlock_lock_scoped(&mutex);
+ if(obj) {
+ /* Lock to ensure commands are sent sequentially. */
+ mutex_lock_scoped(&mutex);
- if(hnd) {
- hnd--; /* KOS uses 0 for error, not -1 */
- cur = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_CUR);
- ret = dclsc(DCLOAD_LSEEK, hnd, 0, SEEK_END);
- dclsc(DCLOAD_LSEEK, hnd, cur, SEEK_SET);
+ cur = dcload_lseek(obj->hnd, 0, SEEK_CUR);
+ ret = dcload_lseek(obj->hnd, 0, SEEK_END);
+ dcload_lseek(obj->hnd, cur, SEEK_SET);
}
return ret;
}
-static dirent_t *dcload_readdir(void * h) {
+static dirent_t *fs_dcload_readdir(void *h) {
dirent_t *rv = NULL;
- dcload_dirent_t *dcld;
+ struct dirent *dcld;
dcload_stat_t filestat;
char *fn;
- uint32 hnd = (uint32)h;
- dcl_dir_t *entry;
+ dcl_obj_t *entry = h;
- spinlock_lock_scoped(&mutex);
+ /* Lock to ensure commands are sent sequentially. */
+ mutex_lock_scoped(&mutex);
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-21 21:32:46
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 2babea38ec32a10203c373a9d77b53cf3d1a8d53 (commit)
from 6db4a90398c1bdec72c24c76e68f334de8f1ab02 (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 2babea38ec32a10203c373a9d77b53cf3d1a8d53
Author: QuzarDC <qu...@co...>
Date: Sun Sep 21 17:24:40 2025 -0400
`.gitignore`: Ignore generated authors and banner files.
These got left behind accidentally after the changes for #1153
-----------------------------------------------------------------------
Summary of changes:
kernel/{arch/dreamcast/kernel => }/.gitignore | 1 -
kernel/arch/dreamcast/kernel/.gitignore | 2 --
2 files changed, 3 deletions(-)
copy kernel/{arch/dreamcast/kernel => }/.gitignore (55%)
diff --git a/kernel/arch/dreamcast/kernel/.gitignore b/kernel/.gitignore
similarity index 55%
copy from kernel/arch/dreamcast/kernel/.gitignore
copy to kernel/.gitignore
index 96d28f98..19ce7979 100644
--- a/kernel/arch/dreamcast/kernel/.gitignore
+++ b/kernel/.gitignore
@@ -1,3 +1,2 @@
-arch_exports.c
authors.h
banner.h
diff --git a/kernel/arch/dreamcast/kernel/.gitignore b/kernel/arch/dreamcast/kernel/.gitignore
index 96d28f98..100d6f1a 100644
--- a/kernel/arch/dreamcast/kernel/.gitignore
+++ b/kernel/arch/dreamcast/kernel/.gitignore
@@ -1,3 +1 @@
arch_exports.c
-authors.h
-banner.h
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-21 01:19:21
|
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 6db4a90398c1bdec72c24c76e68f334de8f1ab02 (commit)
from afedb3ac510ddaafb8780adfc9f8435c12a651cf (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 6db4a90398c1bdec72c24c76e68f334de8f1ab02
Author: QuzarDC <qu...@co...>
Date: Sat Sep 20 21:15:20 2025 -0400
Update version number for current master (v2.2.2)
-----------------------------------------------------------------------
Summary of changes:
include/kos/version.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/kos/version.h b/include/kos/version.h
index 19f28f34..11372be6 100644
--- a/include/kos/version.h
+++ b/include/kos/version.h
@@ -99,7 +99,7 @@
#define KOS_VERSION_MAJOR 2 /**< KOS's current major revision number. */
#define KOS_VERSION_MINOR 2 /**< KOS's current minor revision number. */
-#define KOS_VERSION_PATCH 1 /**< KOS's current patch revision number. */
+#define KOS_VERSION_PATCH 2 /**< KOS's current patch revision number. */
/** KOS's current version as an integer ID. */
#define KOS_VERSION \
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-21 01:12: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 afedb3ac510ddaafb8780adfc9f8435c12a651cf (commit)
from 1675181e4460d44b9d03d5f7123d4074826029e7 (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 afedb3ac510ddaafb8780adfc9f8435c12a651cf
Author: darc <da...@pr...>
Date: Sat Sep 20 14:03:37 2025 -0500
Ignore .cache/, .clangd, .envrc and compile_commands.json
For users of language servers, these files are used to specify compilation
parameters or are generated for use by the language server. They should be
ignored by git as they are not relevant to the repo itself.
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.gitignore b/.gitignore
index a4e8474b..fc95a5a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,7 +9,11 @@
*~
.*.swp
.DS_Store
+.cache/
.vscode/
+.clangd
+.envrc
+compile_commands.json
environ.sh
romdisk.img
/doc/reference/
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-21 01:12:34
|
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 1675181e4460d44b9d03d5f7123d4074826029e7 (commit)
from bf083e62190e1aaf20a66095ee265b0b721cc34c (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 1675181e4460d44b9d03d5f7123d4074826029e7
Author: QuzarDC <qu...@co...>
Date: Sat Sep 20 13:06:43 2025 -0400
environ: Move default setting of SUBARCH to `environ_dreamcast.sh`
All the other default setting tests happen at this level. Now the
value can more clearly be simply set in environ or by IDE.
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 8 +++-----
environ_dreamcast.sh | 5 +++++
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index abfb4733..efccb33d 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -23,15 +23,13 @@ export KOS_ARCH="dreamcast"
# is targeting or uses an existing value that
# can be set externally via your IDE.
#
+# Only needs to be set if not using default.
+#
# Valid values:
# "pristine" - Dreamcast console or HKT-0120 devkit (default)
# "naomi" - NAOMI or NAOMI 2 arcade board
#
-if [ -z "${KOS_SUBARCH}" ] ; then
- export KOS_SUBARCH="pristine"
-else
- export KOS_SUBARCH
-fi
+#export KOS_SUBARCH="naomi"
# KOS Root Path
#
diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh
index e947323b..43454ac7 100644
--- a/environ_dreamcast.sh
+++ b/environ_dreamcast.sh
@@ -1,6 +1,11 @@
# KallistiOS environment variable settings. These are the shared pieces
# for the Dreamcast(tm) platform.
+# Add the default subarch (DC) if one hasn't already been set.
+if [ -z "${KOS_SUBARCH}" ] ; then
+ export KOS_SUBARCH="pristine"
+fi
+
# Add the default external DC tools path if it isn't already set.
if [ -z "${DC_TOOLS_BASE}" ] ; then
export DC_TOOLS_BASE="${KOS_CC_BASE}/../bin"
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-20 13:00:15
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via bf083e62190e1aaf20a66095ee265b0b721cc34c (commit)
from 29147166323bb4cd5d5279c8b6fb17cc4128f65c (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 bf083e62190e1aaf20a66095ee265b0b721cc34c
Author: QuzarDC <qu...@co...>
Date: Fri Sep 19 00:17:10 2025 -0400
cmake: Add compatibility cmake files.
We've recently changed the old `Dreamcast` to
`kallistios` files. Providing passthrough
wrappers + warning to aid compatibility.
-----------------------------------------------------------------------
Summary of changes:
utils/cmake/dreamcast.cmake | 2 ++
utils/cmake/dreamcast.toolchain.cmake | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 utils/cmake/dreamcast.cmake
create mode 100644 utils/cmake/dreamcast.toolchain.cmake
diff --git a/utils/cmake/dreamcast.cmake b/utils/cmake/dreamcast.cmake
new file mode 100644
index 00000000..9c378737
--- /dev/null
+++ b/utils/cmake/dreamcast.cmake
@@ -0,0 +1,2 @@
+message(AUTHOR_WARNING "dreamcast.cmake is deprecated, please use kallistios.cmake")
+include(kallistios)
diff --git a/utils/cmake/dreamcast.toolchain.cmake b/utils/cmake/dreamcast.toolchain.cmake
new file mode 100644
index 00000000..7fd78404
--- /dev/null
+++ b/utils/cmake/dreamcast.toolchain.cmake
@@ -0,0 +1,2 @@
+message(AUTHOR_WARNING "dreamcast.toolchain.cmake is deprecated, please use kallistios.toolchain.cmake")
+include($ENV{KOS_BASE}/utils/cmake/kallistios.toolchain.cmake)
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-20 03:52:07
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 29147166323bb4cd5d5279c8b6fb17cc4128f65c (commit)
via 1b25ccf992b01266c136f7f4cabd9e43499867ee (commit)
via a155e806a420b66d61365d858c93be9e3394f8ce (commit)
via a01ed5dcc9a79efcd7acbb9184ef518fcbc5484c (commit)
via d039cafaaee08ded731c1f74cbf397fb62fe0d34 (commit)
via 4327aaf000f39cc31d42a42099da79a2c7f3081e (commit)
via 527e0fdc516739e44a76651e93359b25f70bebf8 (commit)
via 228ccc0014fb99dc24095bc0d11501328c0d8ae1 (commit)
via 399d89a0b27d473033b62fab4784afd1aff63c51 (commit)
via 0b5e4c8939f9bd58061bd04542060699a99bb3d6 (commit)
via 9e77aa19ba54c31ffd336386c253494e879d7797 (commit)
via c3779fa61906deb0255211f7913e62df69e121e8 (commit)
via 40e8394ae4d1c0a38ffe608917b1de49b04a199e (commit)
from 7346fd704ba489b7d9cf1234282b85957e7625dc (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 29147166323bb4cd5d5279c8b6fb17cc4128f65c
Author: Paul Cercueil <pa...@cr...>
Date: Fri Sep 19 12:08:00 2025 +0200
treewide: Include <kos/timer.h> instead of <arch/timer.h>
Use the top-level API file <kos/timer.h> everywhere where it makes
sense.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 1b25ccf992b01266c136f7f4cabd9e43499867ee
Author: Paul Cercueil <pa...@cr...>
Date: Fri Sep 19 12:00:15 2025 +0200
timer: Re-introduce timer_spin_sleep() as a deprecated API function
Maintain compatibility with old code by re-introducing
timer_spin_sleep(), but in the top-level API this time, and implemented
on top of the arch API.
Tag is as deprecated, since thd_sleep() should really be used instead.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit a155e806a420b66d61365d858c93be9e3394f8ce
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 23:12:46 2025 +0200
timer: Move older API functions to arch-agnostic header
Move the timer_XX_gettime() and timer_XX_gettime64() functions from the
SH4-specific timer code, to be arch-agnostic inline wrappers around the
new timer_gettime() function.
Also move timer_spin_delay_XX() functions to be arch-agnostic inline
functions that just use the other ones above.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit a01ed5dcc9a79efcd7acbb9184ef518fcbc5484c
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jul 22 20:44:09 2025 +0200
timer: Add new arch-agnostic API function timer_gettime()
Add API function timer_gettime(). This function will simply call
arch_timer_gettime(), which has to be implemented by all the platforms
supported by KallistiOS.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit d039cafaaee08ded731c1f74cbf397fb62fe0d34
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 14:32:06 2025 +0200
timer: Add function arch_timer_gettime()
This function can be used to return the time since KOS was started, in a
standard timespec format (number of seconds + number of nanoseconds).
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 4327aaf000f39cc31d42a42099da79a2c7f3081e
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 14:30:10 2025 +0200
timer: Add arch function __dreamcast_get_ticks()
This function returns the number of seconds since boot, and the number
of ticks in the current second. It will later be used to implement the
Dreamcast-specific implementation of the generic timer functions.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 527e0fdc516739e44a76651e93359b25f70bebf8
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 14:59:25 2025 +0200
timer: Use compile-time-known offset for TNS array
Instead of reading back the scaling factor (TPSC value) from the
hardware registers and use it as the offset into the TNS array, use the
compile-time-known TIMER_TPSC macro as the offset, because we know for
sure this is the same value.
The compiler will then be able to optimize the code better.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 228ccc0014fb99dc24095bc0d11501328c0d8ae1
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jul 29 18:17:24 2025 +0200
timer: Drop timer_ms_{enable,disable}
Those functions serve no purpose and don't belong in the public API.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 399d89a0b27d473033b62fab4784afd1aff63c51
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 15:13:48 2025 +0200
timer: Remove timer_spin_sleep()
Nobody needs to busy-wait for that long and it'd be a terrible idea
anyway.
Remove this function as it is not used anywhere anymore, and to prevent
people from having the bad idea of using it.
This frees up the TMU1 to be used by applications.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 0b5e4c8939f9bd58061bd04542060699a99bb3d6
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 23:23:08 2025 +0200
sound: Use thd_sleep() instead of timer_spin_sleep()
One millisecond is about 6% of the time we have to render a frame.
As such, it does not make sense to busy-wait for such long times,
especially when we can avoid it.
Update the sound code to sleep instead of busy-waiting.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 9e77aa19ba54c31ffd336386c253494e879d7797
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 23:22:35 2025 +0200
modem: Use thd_sleep() instead of timer_spin_sleep()
One millisecond is about 6% of the time we have to render a frame.
As such, it does not make sense to busy-wait for such long times,
especially when we can avoid it.
Update the modem code to sleep instead of busy-waiting.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit c3779fa61906deb0255211f7913e62df69e121e8
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 23:19:59 2025 +0200
g1ata: Use thd_sleep() instead of timer_spin_sleep()
One millisecond is about 6% of the time we have to render a frame.
As such, it does not make sense to busy-wait for such long times,
especially when we can avoid it.
Update the g1ata code to sleep instead of busy-waiting.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 40e8394ae4d1c0a38ffe608917b1de49b04a199e
Author: Paul Cercueil <pa...@cr...>
Date: Tue Aug 26 16:32:22 2025 +0200
thread: Make thd_sleep() fail if not using threading
thd_sleep() (or any threading function for that matter) should not be
called when the threading system is disabled.
Also drop an extra <assert.h> include, we don't need two.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
include/kos/timer.h | 211 ++++++++++++++++++++++++
kernel/arch/dreamcast/hardware/cdrom.c | 2 +-
kernel/arch/dreamcast/hardware/g1ata.c | 12 +-
kernel/arch/dreamcast/hardware/maple/keyboard.c | 3 +-
kernel/arch/dreamcast/hardware/maple/vmu.c | 2 +-
kernel/arch/dreamcast/hardware/modem/modem.c | 10 +-
kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 2 +-
kernel/arch/dreamcast/hardware/sci.c | 2 +-
kernel/arch/dreamcast/hardware/scif-spi.c | 2 +-
kernel/arch/dreamcast/hardware/spu.c | 4 +-
kernel/arch/dreamcast/include/arch/timer.h | 159 +++---------------
kernel/arch/dreamcast/kernel/init.c | 3 +-
kernel/arch/dreamcast/kernel/initall_hdrs.h | 2 +-
kernel/arch/dreamcast/kernel/irq.c | 2 +-
kernel/arch/dreamcast/kernel/perf_monitor.c | 2 +-
kernel/arch/dreamcast/kernel/perfctr.c | 2 +-
kernel/arch/dreamcast/kernel/rtc.c | 2 +-
kernel/arch/dreamcast/kernel/timer.c | 124 +-------------
kernel/arch/dreamcast/sound/snd_iface.c | 4 +-
kernel/arch/dreamcast/sound/snd_stream.c | 2 +-
kernel/arch/dreamcast/util/screenshot.c | 2 +-
kernel/exports.txt | 1 -
kernel/libc/newlib/newlib_gettimeofday.c | 2 +-
kernel/libc/newlib/newlib_times.c | 2 +-
kernel/libc/posix/clock_gettime.c | 2 +-
kernel/net/net_arp.c | 2 +-
kernel/net/net_dhcp.c | 2 +-
kernel/net/net_icmp.c | 2 +-
kernel/net/net_icmp6.c | 2 +-
kernel/net/net_ipv4.c | 2 +-
kernel/net/net_ipv4_frag.c | 2 +-
kernel/net/net_ndp.c | 2 +-
kernel/net/net_tcp.c | 2 +-
kernel/net/net_thd.c | 2 +-
kernel/thread/genwait.c | 2 +-
kernel/thread/mutex.c | 2 +-
kernel/thread/thread.c | 10 +-
37 files changed, 292 insertions(+), 301 deletions(-)
create mode 100644 include/kos/timer.h
diff --git a/include/kos/timer.h b/include/kos/timer.h
new file mode 100644
index 00000000..fba1db59
--- /dev/null
+++ b/include/kos/timer.h
@@ -0,0 +1,211 @@
+/* KallistiOS ##version##
+
+ include/kos/timer.h
+ Copyright (C) 2025 Paul Cercueil
+*/
+
+/** \file kos/timer.h
+ \brief Timer functionality.
+ \ingroup timers
+
+ This file contains functions for reading the internal timer provided
+ by the architecture.
+
+ \sa arch/timer.h
+
+ \author Paul Cercueil
+*/
+#ifndef __KOS_TIMER_H
+#define __KOS_TIMER_H
+
+#include <sys/cdefs.h>
+__BEGIN_DECLS
+
+#include <arch/timer.h>
+#include <stdint.h>
+#include <time.h>
+
+typedef struct timespec timespec_t;
+
+/** \brief Get the current uptime of the system.
+ \ingroup timers
+
+ This function retrieves the number of seconds and nanoseconds since KOS was
+ started.
+
+ \return The current uptime of the system as a timespec struct.
+*/
+static inline timespec_t timer_gettime(void) {
+ return arch_timer_gettime();
+}
+
+/** \brief Get the current uptime of the system (in milliseconds).
+ \ingroup timers
+
+ This function retrieves the number of milliseconds since KOS was started. It
+ is equivalent to calling timer_ms_gettime() and combining the number of
+ seconds and milliseconds into one 64-bit value.
+
+ \return The number of milliseconds since KOS started.
+*/
+static inline uint64_t timer_ms_gettime64(void) {
+ timespec_t time = timer_gettime();
+
+ return (uint64_t)time.tv_sec * 1000 + time.tv_nsec / 1000000;
+}
+
+/** \brief Get the current uptime of the system (in microseconds).
+ \ingroup timers
+
+ This function retrieves the number of microseconds since KOS was started.
+
+ \return The uptime in microseconds.
+*/
+static inline uint64_t timer_us_gettime64(void) {
+ timespec_t time = timer_gettime();
+
+ return (uint64_t)time.tv_sec * 1000000 + time.tv_nsec / 1000;
+}
+
+/** \brief Get the current uptime of the system (in nanoseconds).
+ \ingroup timers
+
+ This function retrieves the number of nanoseconds since KOS was started.
+
+ \return The uptime in nanoseconds.
+*/
+static inline uint64_t timer_ns_gettime64(void) {
+ timespec_t time = timer_gettime();
+
+ return (uint64_t)time.tv_sec * 1000000000 + time.tv_nsec;
+}
+
+/** \brief Get the current uptime of the system (in secs and millisecs).
+ \ingroup timers
+
+ This function retrieves the number of seconds and milliseconds since KOS was
+ started.
+
+ \param secs A pointer to store the number of seconds since boot
+ into.
+ \param msecs A pointer to store the number of milliseconds past
+ a second since boot.
+ \note To get the total number of milliseconds since boot,
+ calculate (*secs * 1000) + *msecs, or use the
+ timer_ms_gettime64() function.
+*/
+static inline void timer_ms_gettime(uint32_t *secs, uint32_t *msecs) {
+ timespec_t time = timer_gettime();
+
+ if(secs) *secs = time.tv_sec;
+ if(msecs) *msecs = time.tv_nsec / 1000000;
+}
+
+/** \brief Get the current uptime of the system (in secs and microsecs).
+ \ingroup timers
+
+ This function retrieves the number of seconds and microseconds since KOS was
+ started.
+
+ \note To get the total number of microseconds since boot,
+ calculate (*secs * 1000000) + *usecs, or use the
+ timer_us_gettime64() function.
+
+ \param secs A pointer to store the number of seconds since boot
+ into.
+ \param usecs A pointer to store the number of microseconds past
+ a second since boot.
+*/
+static inline void timer_us_gettime(uint32_t *secs, uint32_t *usecs) {
+ timespec_t time = timer_gettime();
+
+ if(secs) *secs = time.tv_sec;
+ if(usecs) *usecs = time.tv_nsec / 1000;
+}
+
+/** \brief Get the current uptime of the system (in secs and nanosecs).
+ \ingroup timers
+
+ This function retrieves the number of seconds and nanoseconds since KOS was
+ started.
+
+ \note To get the total number of nanoseconds since boot,
+ calculate (*secs * 1000000000) + *nsecs, or use the
+ timer_ns_gettime64() function.
+
+ \param secs A pointer to store the number of seconds since boot
+ into.
+ \param nsecs A pointer to store the number of nanoseconds past
+ a second since boot.
+*/
+static inline void timer_ns_gettime(uint32_t *secs, uint32_t *nsecs) {
+ timespec_t time = timer_gettime();
+
+ if(secs) *secs = time.tv_sec;
+ if(nsecs) *nsecs = time.tv_nsec;
+}
+
+/** \brief Spin-loop delay function with microsecond granularity
+ \ingroup timers
+
+ This function is meant as a very accurate delay function, even if threading
+ and interrupts are disabled. It is a delay and not a sleep, which means that
+ the CPU will be busy-looping during that time frame. For any time frame
+ bigger than a few hundred microseconds, it is recommended to sleep instead.
+
+ Note that the parameter is 16-bit, which means that the maximum acceptable
+ value is 65535 microseconds.
+
+ \param us The number of microseconds to wait for.
+ \sa timer_spin_delay_ns, thd_sleep
+*/
+static inline void timer_spin_delay_us(unsigned short us) {
+ uint64_t timeout = timer_us_gettime64() + us;
+
+ /* Note that we don't actually care about the counter overflowing.
+ Nobody will run their Dreamcast straight for 584942 years. */
+ while(timer_us_gettime64() < timeout);
+}
+
+
+/** \brief Spin-loop delay function with nanosecond granularity
+ \ingroup timers
+
+ This function is meant as a very accurate delay function, even if threading
+ and interrupts are disabled. It is a delay and not a sleep, which means that
+ the CPU will be busy-looping during that time frame.
+
+ Note that the parameter is 16-bit, which means that the maximum acceptable
+ value is 65535 nanoseconds.
+
+ \param ns The number of nanoseconds to wait for.
+ \sa timer_spin_delay_us, thd_sleep
+*/
+static inline void timer_spin_delay_ns(unsigned short ns) {
+ uint64_t timeout = timer_ns_gettime64() + ns;
+
+ /* Note that we don't actually care about the counter overflowing.
+ Nobody will run their Dreamcast straight for 585 years. */
+ while(timer_ns_gettime64() < timeout);
+}
+
+/** \brief Spin-loop delay function with millisecond granularity
+ \ingroup timers
+
+ This function should never be used, and is only used for compatibility with
+ older code. It makes no sense to busy-wait for that long.
+
+ \param ms The number of microseconds to wait for.
+ \sa thd_sleep
+*/
+
+__depr("Do not use timer_spin_sleep(), use thd_sleep() instead")
+static inline void timer_spin_sleep(unsigned int ms) {
+ uint64_t timeout = timer_ms_gettime64() + ms;
+
+ while(timer_ms_gettime64() < timeout);
+}
+
+__END_DECLS
+
+#endif /* __KOS_TIMER_H */
diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c
index 7b0766a9..c4c21ed1 100644
--- a/kernel/arch/dreamcast/hardware/cdrom.c
+++ b/kernel/arch/dreamcast/hardware/cdrom.c
@@ -12,7 +12,7 @@
#include <assert.h>
#include <arch/cache.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#include <arch/memory.h>
#include <arch/irq.h>
diff --git a/kernel/arch/dreamcast/hardware/g1ata.c b/kernel/arch/dreamcast/hardware/g1ata.c
index c447fee1..b6716b80 100644
--- a/kernel/arch/dreamcast/hardware/g1ata.c
+++ b/kernel/arch/dreamcast/hardware/g1ata.c
@@ -17,7 +17,7 @@
#include <kos/mutex.h>
#include <kos/thread.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#include <arch/cache.h>
#include <arch/irq.h>
#include <arch/memory.h>
@@ -965,7 +965,7 @@ int g1_ata_flush(void) {
/* Select the slave device. */
g1_ata_select_device(G1_ATA_SLAVE | G1_ATA_LBA_MODE);
- timer_spin_sleep(1);
+ thd_sleep(1);
/* Flush the disk's write cache to make sure everything gets written out. */
if(CAN_USE_LBA48())
@@ -973,7 +973,7 @@ int g1_ata_flush(void) {
else
OUT8(G1_ATA_COMMAND_REG, ATA_CMD_FLUSH_CACHE);
- timer_spin_sleep(1);
+ thd_sleep(1);
g1_ata_wait_bsydrq();
g1_ata_mutex_unlock();
@@ -1006,7 +1006,7 @@ static int g1_ata_set_transfer_mode(uint8_t mode) {
/* Send the SET FEATURES command. */
OUT8(G1_ATA_COMMAND_REG, ATA_CMD_SET_FEATURES);
- timer_spin_sleep(1);
+ thd_sleep(1);
/* Wait for command completion. */
g1_ata_wait_nbsy();
@@ -1034,7 +1034,7 @@ static int g1_ata_scan(void) {
/* For now, just check if there's a slave device. We don't care about the
primary device, since it should always be the GD-ROM drive. */
OUT8(G1_ATA_DEVICE_SELECT, 0xF0);
- timer_spin_sleep(1);
+ thd_sleep(1);
OUT8(G1_ATA_SECTOR_COUNT, 0);
OUT8(G1_ATA_LBA_LOW, 0);
@@ -1043,7 +1043,7 @@ static int g1_ata_scan(void) {
/* Send the IDENTIFY command. */
OUT8(G1_ATA_COMMAND_REG, ATA_CMD_IDENTIFY);
- timer_spin_sleep(1);
+ thd_sleep(1);
st = IN8(G1_ATA_STATUS_REG);
/* Check if there's anything on the bus. */
diff --git a/kernel/arch/dreamcast/hardware/maple/keyboard.c b/kernel/arch/dreamcast/hardware/maple/keyboard.c
index 8599f774..4ecfe5c5 100644
--- a/kernel/arch/dreamcast/hardware/maple/keyboard.c
+++ b/kernel/arch/dreamcast/hardware/maple/keyboard.c
@@ -15,7 +15,8 @@
#include <kos/dbglog.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
+#include <arch/irq.h>
#include <dc/maple.h>
#include <dc/maple/keyboard.h>
diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c
index 922f1754..86fa12eb 100644
--- a/kernel/arch/dreamcast/hardware/maple/vmu.c
+++ b/kernel/arch/dreamcast/hardware/maple/vmu.c
@@ -25,7 +25,7 @@
#include <dc/math.h>
#include <dc/biosfont.h>
#include <dc/vmufs.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#define VMU_BLOCK_WRITE_RETRY_TIME 100 /* time to sleep until retrying a failed write */
diff --git a/kernel/arch/dreamcast/hardware/modem/modem.c b/kernel/arch/dreamcast/hardware/modem/modem.c
index 940a02b2..f71146d6 100644
--- a/kernel/arch/dreamcast/hardware/modem/modem.c
+++ b/kernel/arch/dreamcast/hardware/modem/modem.c
@@ -448,14 +448,14 @@ void modemHardReset(void) {
/* This zeroes out all of the modem's registers */
modemWrite(G2_8BP_RST, 0);
- timer_spin_sleep(25); /* A slight delay just to be safe */
+ thd_sleep(25); /* A slight delay just to be safe */
/* This sets the modem's registers to their default settings */
modemWrite(G2_8BP_RST, 1);
/* Wait for a little while so the modem has time to reset itself
completely */
- timer_spin_sleep(150);
+ thd_sleep(150);
}
void modemSoftReset(void) {
@@ -465,7 +465,7 @@ void modemSoftReset(void) {
while(modemRead(REGLOC(0x1F)) & 0x1); /* Wait for NEWC to clear */
/* Wait a minimum of 10ms before using the MDP again */
- timer_spin_sleep(100);
+ thd_sleep(100);
}
void modemConfigurationReset(void) {
@@ -600,7 +600,7 @@ int modem_set_mode(int mode, modem_speed_t speed) {
modemSetBits(REGLOC(0x1F), 0x1); /* Set NEWC */
/* Delay at least 4ms */
- timer_spin_sleep(10);
+ thd_sleep(10);
/* Dial using DTMF tones, and set the modem in origination
mode */
@@ -801,7 +801,7 @@ void modemEstablishConnection(void) {
can be answered */
if(!(modemCfg.flags & MODEM_CFG_FLAG_ORIGINATE)) {
modemSetBits(REGLOC(0x7), 0x2); /* Set RA */
- timer_spin_sleep(10);
+ thd_sleep(10);
}
/* Note that in all modes of operation RTS will be turned on as soon
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c
index 8e814195..e9ebf611 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c
@@ -10,7 +10,7 @@
#include <string.h>
#include <float.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#include <dc/pvr.h>
#include <dc/video.h>
#include <kos/regfield.h>
diff --git a/kernel/arch/dreamcast/hardware/sci.c b/kernel/arch/dreamcast/hardware/sci.c
index 82322412..8b839880 100644
--- a/kernel/arch/dreamcast/hardware/sci.c
+++ b/kernel/arch/dreamcast/hardware/sci.c
@@ -8,7 +8,7 @@
#include <dc/math.h>
#include <arch/cache.h>
#include <arch/dmac.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#include <kos/dbglog.h>
#include <kos/regfield.h>
diff --git a/kernel/arch/dreamcast/hardware/scif-spi.c b/kernel/arch/dreamcast/hardware/scif-spi.c
index 0485a9e5..171e3ea1 100644
--- a/kernel/arch/dreamcast/hardware/scif-spi.c
+++ b/kernel/arch/dreamcast/hardware/scif-spi.c
@@ -8,7 +8,7 @@
#include <dc/scif.h>
#include <dc/fs_dcload.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#include <kos/dbglog.h>
#include <kos/regfield.h>
diff --git a/kernel/arch/dreamcast/hardware/spu.c b/kernel/arch/dreamcast/hardware/spu.c
index 21136e39..78de2315 100644
--- a/kernel/arch/dreamcast/hardware/spu.c
+++ b/kernel/arch/dreamcast/hardware/spu.c
@@ -9,7 +9,7 @@
#include <dc/spu.h>
#include <dc/g2bus.h>
#include <dc/sq.h>
-#include <arch/timer.h>
+#include <kos/timer.h>
#include <errno.h>
/*
@@ -355,7 +355,7 @@ int spu_init(void) {
spu_enable();
/* Wait a few clocks */
- timer_spin_sleep(10);
+ thd_sleep(10);
/* Initialize CDDA channels */
spu_cdda_init();
diff --git a/kernel/arch/dreamcast/include/arch/timer.h b/kernel/arch/dreamcast/include/arch/timer.h
index caf1290c..99694a32 100644
--- a/kernel/arch/dreamcast/include/arch/timer.h
+++ b/kernel/arch/dreamcast/include/arch/timer.h
@@ -34,6 +34,8 @@ __BEGIN_DECLS
#include <arch/irq.h>
+#include <time.h>
+
/** \defgroup timers Timer Unit
\brief SH4 CPU peripheral providing timers and counters
\ingroup timing
@@ -82,8 +84,7 @@ __BEGIN_DECLS
/** \brief SH4 Timer Channel 1.
\warning
- This timer channel is used for the timer_spin_sleep() function, which also
- backs the kthread, C, C++, and POSIX sleep functions.
+ This timer channel is free to use.
*/
#define TMU1 1
@@ -231,148 +232,39 @@ int timer_ints_enabled(int channel);
The highest actual tick resolution of \ref TMU2 is 80ns.
*/
-/** \brief Enable the millisecond timer.
- \ingroup tmu_uptime
-
- This function enables the timer used for the gettime functions. This is on
- by default. These functions use \ref TMU2 to do their work.
-*/
-void timer_ms_enable(void);
-
-/** \brief Disable the millisecond timer.
- \ingroup tmu_uptime
-
- This function disables the timer used for the gettime functions. Generally,
- you will not want to do this, unless you have some need to use the timer
- \ref TMU2 for something else.
-*/
-void timer_ms_disable(void);
-
-/** \brief Get the current uptime of the system (in secs and millisecs).
- \ingroup tmu_uptime
-
- This function retrieves the number of seconds and milliseconds since KOS was
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-19 17:42: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 7346fd704ba489b7d9cf1234282b85957e7625dc (commit)
from 3348accdbc8a4869ef6eeaf7799067d84af64466 (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 7346fd704ba489b7d9cf1234282b85957e7625dc
Author: Paul Cercueil <pa...@cr...>
Date: Fri Sep 19 15:55:36 2025 +0200
Add C11's static_assert() to <assert.h>
C11 adds the _Static_assert keyword, and a static_assert macro in
<assert.h>.
Add the static_assert() macro to our <assert.h> copy.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
include/assert.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/assert.h b/include/assert.h
index fc7e78ec..a818cdc7 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -40,6 +40,10 @@ __BEGIN_DECLS
error message. */
/** \cond */
#define _assert(e) assert(e)
+
+#if __STDC_VERSION__ >= 201112L && !defined __cplusplus
+#define static_assert _Static_assert
+#endif
/** \endcond */
#ifdef NDEBUG
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-16 18:58:19
|
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 3348accdbc8a4869ef6eeaf7799067d84af64466 (commit)
from 0e0205c10c910340bb9c31cced19ba4cb24fb51a (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 3348accdbc8a4869ef6eeaf7799067d84af64466
Author: Paul Cercueil <pa...@cr...>
Date: Mon Sep 15 19:11:08 2025 +0200
maple: Fix race between driver attach and vblank irq
The device at unit 0 is probed using a shared frame dedicated to device
detection; devices at unit > 0 are probed using the frame of the unit 0.
This means that as soon as a unit 0 device is registered, its frame can
be used to auto-detect itself (if previously unplugged) or its children.
Therefore, prior to registering a unit 0 device into the device table,
we must ensure that all fields have been properly initialized, or we
will race with the vblank interrupt handler.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/maple/maple_driver.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/kernel/arch/dreamcast/hardware/maple/maple_driver.c b/kernel/arch/dreamcast/hardware/maple/maple_driver.c
index 00b9ba0b..f84468d6 100644
--- a/kernel/arch/dreamcast/hardware/maple/maple_driver.c
+++ b/kernel/arch/dreamcast/hardware/maple/maple_driver.c
@@ -73,6 +73,7 @@ int maple_driver_attach(maple_frame_t *det) {
maple_devinfo_t *devinfo;
maple_device_t *dev = maple_state.ports[det->dst_port].units[det->dst_unit];
bool attached = false;
+ bool dev_allocated = false;
/* Resolve some pointers first */
resp = (maple_response_t *)det->recv_buf;
@@ -89,12 +90,11 @@ int maple_driver_attach(maple_frame_t *det) {
if(!dev)
return 1;
- maple_state.ports[det->dst_port].units[det->dst_unit] = dev;
-
/* Add the basics for the initial version of the struct */
dev->port = det->dst_port;
dev->unit = det->dst_unit;
dev->frame.state = MAPLE_FRAME_VACANT;
+ dev_allocated = true;
}
memcpy(&dev->info, devinfo, sizeof(maple_devinfo_t));
@@ -102,10 +102,16 @@ int maple_driver_attach(maple_frame_t *det) {
/* Now lets allocate a new status buffer */
if(i->status_size && !dev->status) {
dev->status = calloc(1, i->status_size);
- if(!dev->status)
+ if(!dev->status) {
+ if(dev_allocated)
+ free(dev);
return 1;
+ }
}
+ if(dev_allocated)
+ maple_state.ports[det->dst_port].units[det->dst_unit] = dev;
+
if(!i->status_size || dev->status) {
/* Try to attach if we need to then break out. */
if(!(i->attach) || (i->attach(i, dev) >= 0)) {
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-10 16:45:08
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 0e0205c10c910340bb9c31cced19ba4cb24fb51a (commit)
from 60ef57f4c1a55b1e515b9c577527b07a3a0ed971 (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 0e0205c10c910340bb9c31cced19ba4cb24fb51a
Author: QuzarDC <qu...@co...>
Date: Wed Sep 10 11:02:18 2025 -0400
romdisk: Have romdisk building use our standard `kos-cc`
This brings it in-line with the rest of the build system in not
echoing the block of args being passed to gcc unless verbose mode
is being set.
-----------------------------------------------------------------------
Summary of changes:
Makefile.rules | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.rules b/Makefile.rules
index 6c34c9ed..f125a25f 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -82,7 +82,7 @@ romdisk.img:
romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2c/bin2c romdisk.img romdisk_tmp.c romdisk
- $(KOS_CC) $(KOS_CFLAGS) -o romdisk_tmp.o -c romdisk_tmp.c
+ kos-cc -o romdisk_tmp.o -c romdisk_tmp.c
$(KOS_CC) -o romdisk.o -r romdisk_tmp.o $(KOS_LIB_PATHS) -Wl,--whole-archive -lromdiskbase
rm romdisk_tmp.c romdisk_tmp.o
endif
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-08 15:33:48
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 60ef57f4c1a55b1e515b9c577527b07a3a0ed971 (commit)
from c2350046b3111d6550a8ccb583a0f21fc15b0c29 (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 60ef57f4c1a55b1e515b9c577527b07a3a0ed971
Author: dfchil <dan...@gm...>
Date: Mon Sep 8 17:33:30 2025 +0200
pvr: Modifier volume header texture address fix (#1189)
The inside texture in modifier volumes was erroneously getting the texture address of the outside texture
Co-authored-by: Daniel Fairchild <da...@vi...>
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/pvr/pvr_prim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c
index 904c0511..7909c111 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_prim.c
@@ -446,7 +446,7 @@ void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, const pvr_poly_cxt_t *src) {
| FIELD_PREP(PVR_TA_PM2_VSIZE, __builtin_ctz(src->txr2.height) - 3);
/* Convert the texture address */
- txr_base = to_pvr_txr_ptr(src->txr.base);
+ txr_base = to_pvr_txr_ptr(src->txr2.base);
/* Polygon mode 3 */
mode3 = FIELD_PREP(PVR_TA_PM3_MIPMAP, src->txr2.mipmap)
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-06 17:33:25
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via c2350046b3111d6550a8ccb583a0f21fc15b0c29 (commit)
from 05037ccd3d7318d9f2c1cd8e436adea24501e759 (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 c2350046b3111d6550a8ccb583a0f21fc15b0c29
Author: QuzarDC <qu...@co...>
Date: Fri Sep 5 01:49:39 2025 -0400
genwait: Keep queues in order by thread priority.
Currently, new waiting threads are always added to the end
of their genwait tailq and the first thread in the tailq is
the first woken. This means that unless a thread is being woken
and readded (like can happen with a `genwait_wake_all`) they will
always be awoken based on how long they have been waiting.
The downside to this method is that it ignores thread priorities,
which should be the controlling factor in which thread gets woken
first. By inserting into the queue by priority order, wakes will now
happen based on priority rather than time waiting.
The mild overhead of seeking through the waiting queues should be
outweighed greatly by allowing priority management via thread priorities.
-----------------------------------------------------------------------
Summary of changes:
kernel/thread/genwait.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/kernel/thread/genwait.c b/kernel/thread/genwait.c
index 3653edf5..bc874c2c 100644
--- a/kernel/thread/genwait.c
+++ b/kernel/thread/genwait.c
@@ -69,7 +69,7 @@ static kthread_t *tq_next(void) {
}
int genwait_wait(void *obj, const char *mesg, int timeout, void (*callback)(void *)) {
- kthread_t *me;
+ kthread_t *me, *t;
/* Twiddle interrupt state */
if(irq_inside_int()) {
@@ -95,8 +95,17 @@ int genwait_wait(void *obj, const char *mesg, int timeout, void (*callback)(void
me->wait_callback = callback;
- /* Insert us on the appropriate wait queue */
- TAILQ_INSERT_TAIL(&slpque[LOOKUP(obj)], me, thdq);
+ /* Go through and find where to insert */
+ TAILQ_FOREACH(t, &slpque[LOOKUP(obj)], thdq) {
+ if(me->prio < t->prio) {
+ TAILQ_INSERT_BEFORE(t, me, thdq);
+ break;
+ }
+ }
+
+ /* We got to the end of the list, so insert at end */
+ if(!t)
+ TAILQ_INSERT_TAIL(&slpque[LOOKUP(obj)], me, thdq);
/* Block us until we're signaled */
return thd_block_now(&me->context);
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 19:43:12
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 05037ccd3d7318d9f2c1cd8e436adea24501e759 (commit)
from 0db67b99b154ec06dda311ce8a91615cd4654729 (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 05037ccd3d7318d9f2c1cd8e436adea24501e759
Author: QuzarDC <qu...@co...>
Date: Fri Sep 5 15:40:41 2025 -0400
irq.c: Replace old `__unlikely` with newlib standard macro
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/kernel/irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c
index 3e3be5a8..00e8a4a4 100644
--- a/kernel/arch/dreamcast/kernel/irq.c
+++ b/kernel/arch/dreamcast/kernel/irq.c
@@ -217,7 +217,7 @@ void irq_handle_exception(int code) {
int handled = 0;
if(__is_defined(__SH_ATOMIC_MODEL_SOFT_GUSA__)
- && __unlikely((int32_t)irq_srt_addr->r[15] >= -128
+ && __predict_false((int32_t)irq_srt_addr->r[15] >= -128
&& irq_srt_addr->pc != irq_srt_addr->r[0])) {
/* The stack pointer has been altered: it means we are in the middle of
an atomic section, and we need to roll-back.
@@ -458,4 +458,4 @@ void irq_set_priority(irq_src_t src, unsigned int prio) {
unsigned int irq_get_priority(irq_src_t src) {
return (REG_IPR(src / 4) >> (src % 4) * 4) & 0xf;
-}
\ No newline at end of file
+}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 19:36:04
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 0db67b99b154ec06dda311ce8a91615cd4654729 (commit)
from a337be07e09bd884d224d39b0b4c7034ac681b97 (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 0db67b99b154ec06dda311ce8a91615cd4654729
Author: QuzarDC <qu...@co...>
Date: Fri Sep 5 15:32:45 2025 -0400
sys/_types: Readd `_TIME_T_` define.
Seems it is required and can throw complaints in some gcc
versions/settings.
-----------------------------------------------------------------------
Summary of changes:
include/sys/_types.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/sys/_types.h b/include/sys/_types.h
index 0be7feae..3110877d 100644
--- a/include/sys/_types.h
+++ b/include/sys/_types.h
@@ -137,7 +137,8 @@ typedef unsigned long __mode_t;
typedef unsigned short __nlink_t;
typedef long __suseconds_t; /* microseconds (signed) */
typedef unsigned long __useconds_t; /* microseconds (unsigned) */
-typedef long long __time_t;
+#define _TIME_T_ long long
+typedef _TIME_T_ __time_t;
#ifndef __clockid_t_defined
#define _CLOCKID_T_ unsigned long
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 19:22:55
|
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 a337be07e09bd884d224d39b0b4c7034ac681b97 (commit)
via afbd2ca8687d9d2d0d54eb7af0aec2f42b593e92 (commit)
via 96836a655e65739e3a0ae594f57ff371ef284530 (commit)
via 3f407f7982e29fcddf7e5e1a5e3876a3de585e21 (commit)
via 8186790920ee0c6d39ece114fdf2588ca6e8f770 (commit)
via 1a934355e0002f51a8600099c3b8f73c5ef0e532 (commit)
via 8be032ef211aa8993e3748f96f9cf7b8b4491138 (commit)
via a34e545bd0337970cc61a5eaae74dac608639450 (commit)
from d77b00786bec441e4e08dfadbc2fa1b46ff086af (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 a337be07e09bd884d224d39b0b4c7034ac681b97
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:44:26 2025 -0400
Remove patches for newlib < 4.
The only newlib patch left after this is in `newlib_getentropy`
which tests for functionality added in the newest minor version
4.4.0, so it seems to make sense to keep that. The rest simply
aren't needed/supported anymore.
commit afbd2ca8687d9d2d0d54eb7af0aec2f42b593e92
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:29:10 2025 -0400
cdefs: Replace `__no_inline` with newlib equivalent.
commit 96836a655e65739e3a0ae594f57ff371ef284530
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:22:31 2025 -0400
cdefs: Replace `__{un}likely()` with newlib equivalent
Newlib already provides wrappers for gcc's `__builtin_expect`.
Additionally minor whitespace cleanups.
commit 3f407f7982e29fcddf7e5e1a5e3876a3de585e21
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:14:25 2025 -0400
cdefs: Replace `__weak` with newlib equivalent.
Newlib is already providing a define to wrap the attribute
weak, which is `__weak_symbol`.
commit 8186790920ee0c6d39ece114fdf2588ca6e8f770
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 14:08:56 2025 -0400
cdefs: Remove duplicated cdefs.
As with previous ones that have been removed, each of these
were already being provided by newlib. We don't have a path
to function without `<sys/cdefs.h>` anyways.
While there, added myself to the header as I've made so many
changes to it.
commit 1a934355e0002f51a8600099c3b8f73c5ef0e532
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 13:03:26 2025 -0400
cdefs: Increase minimum GCC version to reflect current standard.
commit 8be032ef211aa8993e3748f96f9cf7b8b4491138
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 12:52:47 2025 -0400
cdefs: Remove broken functionality checks.
I had cargo-culted these checks out of a source that
was presuming the use of autotools that would provide
the defines. `__builtin_types_compatible_p` and `typeof`
have been available in GCC since at least v4.9.4, so we
shouldn't need to verify that we have the extensions.
commit a34e545bd0337970cc61a5eaae74dac608639450
Author: QuzarDC <qu...@co...>
Date: Wed Aug 6 11:19:35 2025 -0400
dc/fmath: Remove custom `static inline` wrapper.
We already have protection for these cases via cdefs,
and don't perform this same kind of older wrapping for
any other static inline functions we provide.
-----------------------------------------------------------------------
Summary of changes:
include/kos/cdefs.h | 97 +-------------------------------
include/kos/init_base.h | 2 +-
include/sys/_types.h | 8 +--
include/sys/select.h | 6 --
kernel/arch/dreamcast/hardware/sq.c | 2 +-
kernel/arch/dreamcast/include/dc/fmath.h | 37 +++++-------
kernel/arch/dreamcast/kernel/init.c | 4 +-
kernel/arch/dreamcast/kernel/perfctr.c | 16 +++---
kernel/arch/dreamcast/kernel/timer.c | 20 +++----
kernel/fs/fs_random.c | 10 ----
10 files changed, 39 insertions(+), 163 deletions(-)
diff --git a/include/kos/cdefs.h b/include/kos/cdefs.h
index 87ddcaa2..055118e8 100644
--- a/include/kos/cdefs.h
+++ b/include/kos/cdefs.h
@@ -4,6 +4,7 @@
Copyright (C) 2002, 2004 Megan Potter
Copyright (C) 2020, 2023 Lawrence Sebald
Copyright (C) 2023 Falco Girgis
+ Copyright (C) 2024, 2025 Donald Haase
Based loosely around some stuff in BSD's sys/cdefs.h
*/
@@ -19,6 +20,7 @@
\author Megan Potter
\author Lawrence Sebald
\author Falco Girgis
+ \author Donald Haase
*/
#ifndef __KOS_CDEFS_H
@@ -27,7 +29,7 @@
#include <sys/cdefs.h>
/* Check GCC version */
-#if __GNUC__ <= 3
+#if __GNUC__ < 9
# warning Your GCC is too old. This will probably not work right.
#endif
@@ -47,57 +49,6 @@
#define __noreturn __attribute__((__noreturn__))
#endif
-#ifndef __unused
-/** \brief Identify a function or variable that may be unused. */
-#define __unused __attribute__((__unused__))
-#endif
-
-#ifndef __used
-/** \brief Prevent a symbol from being removed from the binary. */
-#define __used __attribute__((used))
-#endif
-
-#ifndef __weak
-/** \brief Identify a function or variable that may be overridden by another symbol. */
-#define __weak __attribute__((weak))
-#endif
-
-#ifndef __packed
-/** \brief Force a structure, enum, or other type to be packed as small as possible. */
-#define __packed __attribute__((packed))
-#endif
-
-#ifndef __dead2
-/** \brief Alias for \ref __noreturn. For BSD compatibility. */
-#define __dead2 __noreturn /* BSD compat */
-#endif
-
-#ifndef __likely
-/** \brief Directive to inform the compiler the condition is in the likely path.
-
- This can be used around conditionals or loops to help inform the
- compiler which path to optimize for as the common-case.
-
- \param exp Boolean expression which expected to be true.
-
- \sa __unlikely()
-*/
-#define __likely(exp) __builtin_expect(!!(exp), 1)
-#endif
-
-#ifndef __unlikely
-/** \brief Directive to inform the compiler the condition is in the unlikely path.
-
- This can be used around conditionals or loops to help inform the
- compiler which path to optimize against as the infrequent-case.
-
- \param exp Boolean expression which is expected to be false.
-
- \sa __likely()
-*/
-#define __unlikely(exp) __builtin_expect(!!(exp), 0)
-#endif
-
#ifndef __deprecated
/** \brief Mark something as deprecated.
This should be used to warn users that a function/type/etc will be removed
@@ -115,33 +66,6 @@
#define __depr(m) __attribute__((deprecated(m)))
#endif
-/* Printf/Scanf-like declaration */
-#ifndef __printflike
-/** \brief Identify a function as accepting formatting like printf().
-
- Using this macro allows GCC to typecheck calls to printf-like functions,
- which can aid in finding mistakes.
-
- \param fmtarg The argument number (1-based) of the format string.
- \param firstvararg The argument number of the first vararg (the ...).
-*/
-#define __printflike(fmtarg, firstvararg) \
- __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
-#endif
-
-#ifndef __scanflike
-/** \brief Identify a function as accepting formatting like scanf().
-
- Using this macro allows GCC to typecheck calls to scanf-like functions,
- which can aid in finding mistakes.
-
- \param fmtarg The argument number (1-based) of the format string.
- \param firstvararg The argument number of the first vararg (the ...).
-*/
-#define __scanflike(fmtarg, firstvararg) \
- __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
-#endif
-
#if __GNUC__ >= 7
/** \brief Identify a case statement that is expected to fall through to the
statement underneath it. */
@@ -150,16 +74,6 @@
#define __fallthrough /* Fall through */
#endif
-#ifndef __always_inline
-/** \brief Ask the compiler to \a always inline a given function. */
-#define __always_inline inline __attribute__((__always_inline__))
-#endif
-
-#ifndef __no_inline
-/** \brief Ask the compiler to \a never inline a given function. */
-#define __no_inline __attribute__((__noinline__))
-#endif
-
/** @} */
/** \defgroup system_compat Language Compatibility Defines
@@ -255,16 +169,11 @@
*/
#define __array_size(arr) (sizeof(arr) / sizeof((arr)[0]) + _array_size_chk(arr))
-/* Helper for __array_size's type check */
-#if HAVE_BUILTIN_TYPES_COMPATIBLE_P && HAVE_TYPEOF
/* Two gcc extensions.
* &a[0] degrades to a pointer: a different type from an array */
#define _array_size_chk(arr) \
__build_assert_or_zero(!__builtin_types_compatible_p(typeof(arr), \
typeof(&(arr)[0])))
-#else
-#define _array_size_chk(arr) 0
-#endif
/** \brief Create a string from the argument.
diff --git a/include/kos/init_base.h b/include/kos/init_base.h
index 0ae35d2b..662535bc 100644
--- a/include/kos/init_base.h
+++ b/include/kos/init_base.h
@@ -30,7 +30,7 @@ __BEGIN_DECLS
/* Declares a weak function pointer which can be optionally
overridden and given a value later. */
#define KOS_INIT_FLAG_WEAK(func, dft_on) \
- void (*func##_weak)(void) __weak = (dft_on) ? func : NULL
+ void (*func##_weak)(void) __weak_symbol = (dft_on) ? func : NULL
/* Invokes the given function if its weak function pointer
has been overridden to point to a valid function. */
diff --git a/include/sys/_types.h b/include/sys/_types.h
index 5e7a4247..0be7feae 100644
--- a/include/sys/_types.h
+++ b/include/sys/_types.h
@@ -137,13 +137,7 @@ typedef unsigned long __mode_t;
typedef unsigned short __nlink_t;
typedef long __suseconds_t; /* microseconds (signed) */
typedef unsigned long __useconds_t; /* microseconds (unsigned) */
-
-#if __NEWLIB__ >= 3
-#define _TIME_T_ long long
-#else
-#define _TIME_T_ long
-#endif
-typedef _TIME_T_ __time_t;
+typedef long long __time_t;
#ifndef __clockid_t_defined
#define _CLOCKID_T_ unsigned long
diff --git a/include/sys/select.h b/include/sys/select.h
index 9d12ed14..e2d94561 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -27,13 +27,7 @@ __BEGIN_DECLS
#include <newlib.h>
#include <kos/opts.h>
-
-#if __NEWLIB__ > 2 || (__NEWLIB__ == 2 && __NEWLIB_MINOR__ > 2)
#include <sys/_timeval.h>
-#else
-#include <time.h>
-#include <sys/time.h>
-#endif
/* Newlib used to define fd_set and friends in <sys/types.h>, but at some point
that stopped being the case... This should tell us whether we need to define
diff --git a/kernel/arch/dreamcast/hardware/sq.c b/kernel/arch/dreamcast/hardware/sq.c
index 8fac7c6c..51bbfa70 100644
--- a/kernel/arch/dreamcast/hardware/sq.c
+++ b/kernel/arch/dreamcast/hardware/sq.c
@@ -121,7 +121,7 @@ void sq_wait(void) {
}
/* Copies n bytes from src to dest, dest must be 32-byte aligned */
-__no_inline void *sq_cpy(void *dest, const void *src, size_t n) {
+__noinline void *sq_cpy(void *dest, const void *src, size_t n) {
const uint32_t *s = src;
void *curr_dest = dest;
uint32_t *d;
diff --git a/kernel/arch/dreamcast/include/dc/fmath.h b/kernel/arch/dreamcast/include/dc/fmath.h
index b61aa967..febe1881 100644
--- a/kernel/arch/dreamcast/include/dc/fmath.h
+++ b/kernel/arch/dreamcast/include/dc/fmath.h
@@ -31,22 +31,11 @@ __BEGIN_DECLS
@{
*/
-/* Sigh... C99 treats inline stuff a lot differently than traditional GCC did,
- so we need to take care of that... */
-#if __STDC_VERSION__ >= 199901L
-#define __FMINLINE static inline
-#elif __GNUC__
-#define __FMINLINE extern inline
-#else
-/* Uhm... I guess this is the best we can do? */
-#define __FMINLINE static
-#endif
-
/**
\brief Floating point inner product.
\return v1 dot v2 (inner product)
*/
-__FMINLINE float __pure fipr(float x, float y, float z, float w,
+static inline float __pure fipr(float x, float y, float z, float w,
float a, float b, float c, float d) {
return __fipr(x, y, z, w, a, b, c, d);
}
@@ -55,7 +44,7 @@ __FMINLINE float __pure fipr(float x, float y, float z, float w,
\brief Floating point inner product w/self (square of vector magnitude)
\return v1 dot v1 (square of magnitude)
*/
-__FMINLINE float __pure fipr_magnitude_sqr(float x, float y, float z, float w) {
+static inline float __pure fipr_magnitude_sqr(float x, float y, float z, float w) {
return __fipr_magnitude_sqr(x, y, z, w);
}
@@ -64,7 +53,7 @@ __FMINLINE float __pure fipr_magnitude_sqr(float x, float y, float z, float w) {
\param r a floating point number between 0 and 2*PI
\return sin(r), where r is [0..2*PI]
*/
-__FMINLINE float __pure fsin(float r) {
+static inline float __pure fsin(float r) {
return __fsin(r);
}
@@ -73,7 +62,7 @@ __FMINLINE float __pure fsin(float r) {
\param r a floating point number between 0 and 2*PI
\return cos(r), where r is [0..2*PI]
*/
-__FMINLINE __pure float fcos(float r) {
+static inline __pure float fcos(float r) {
return __fcos(r);
}
@@ -82,7 +71,7 @@ __FMINLINE __pure float fcos(float r) {
\param r a floating point number between 0 and 2*PI
\return tan(r), where r is [0..2*PI]
*/
-__FMINLINE __pure float ftan(float r) {
+static inline __pure float ftan(float r) {
return __ftan(r);
}
@@ -91,7 +80,7 @@ __FMINLINE __pure float ftan(float r) {
\param d an integer between 0 and 65535
\return sin(d), where d is [0..65535]
*/
-__FMINLINE __pure float fisin(int d) {
+static inline __pure float fisin(int d) {
return __fisin(d);
}
@@ -100,7 +89,7 @@ __FMINLINE __pure float fisin(int d) {
\param d an integer between 0 and 65535
\return cos(d), where d is [0..65535]
*/
-__FMINLINE __pure float ficos(int d) {
+static inline __pure float ficos(int d) {
return __ficos(d);
}
@@ -109,7 +98,7 @@ __FMINLINE __pure float ficos(int d) {
\param d an integer between 0 and 65535
\return tan(d), where d is [0..65535]
*/
-__FMINLINE float __pure fitan(int d) {
+static inline float __pure fitan(int d) {
return __fitan(d);
}
@@ -117,14 +106,14 @@ __FMINLINE float __pure fitan(int d) {
\brief Floating point square root
\return sqrt(f)
*/
-__FMINLINE float __pure fsqrt(float f) {
+static inline float __pure fsqrt(float f) {
return __fsqrt(f);
}
/**
\return 1.0f / sqrt(f)
*/
-__FMINLINE float __pure frsqrt(float f) {
+static inline float __pure frsqrt(float f) {
return __frsqrt(f);
}
@@ -137,7 +126,7 @@ __FMINLINE float __pure frsqrt(float f) {
\param s Storage for the returned sine value.
\param c Storage for the returned cosine value.
*/
-__FMINLINE void fsincos(float f, float *s, float *c) {
+static inline void fsincos(float f, float *s, float *c) {
__fsincos(f, *s, *c);
}
@@ -150,7 +139,7 @@ __FMINLINE void fsincos(float f, float *s, float *c) {
\param s Storage for the returned sine value.
\param c Storage for the returned cosine value.
*/
-__FMINLINE void fsincosr(float f, float *s, float *c) {
+static inline void fsincosr(float f, float *s, float *c) {
__fsincosr(f, *s, *c);
}
@@ -178,7 +167,7 @@ __FMINLINE void fsincosr(float f, float *s, float *c) {
\note Thanks to Fredrik Ehnbom for figuring this stuff out and posting it
to the mailing list back in 2005!
*/
-__FMINLINE uint32_t __pure pvr_pack_bump(float h, float t, float q) {
+static inline uint32_t __pure pvr_pack_bump(float h, float t, float q) {
uint8_t hp = (uint8_t)(h * 255.0f);
uint8_t k1 = ~hp;
uint8_t k2 = (uint8_t)(hp * __fsin(t));
diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c
index d80385a4..af5a99ec 100644
--- a/kernel/arch/dreamcast/kernel/init.c
+++ b/kernel/arch/dreamcast/kernel/init.c
@@ -154,7 +154,7 @@ KOS_INIT_FLAG_WEAK(library_shutdown, true);
/* Auto-init stuff: override with a non-weak symbol if you don't want all of
this to be linked into your code (and do the same with the
arch_auto_shutdown function too). */
-int __weak arch_auto_init(void) {
+int __weak_symbol arch_auto_init(void) {
/* Initialize memory management */
mm_init();
@@ -235,7 +235,7 @@ int __weak arch_auto_init(void) {
return 0;
}
-void __weak arch_auto_shutdown(void) {
+void __weak_symbol arch_auto_shutdown(void) {
KOS_INIT_FLAG_CALL(fs_dclsocket_shutdown);
if (!KOS_PLATFORM_IS_NAOMI)
KOS_INIT_FLAG_CALL(net_shutdown);
diff --git a/kernel/arch/dreamcast/kernel/perfctr.c b/kernel/arch/dreamcast/kernel/perfctr.c
index c97d6eee..b253d107 100644
--- a/kernel/arch/dreamcast/kernel/perfctr.c
+++ b/kernel/arch/dreamcast/kernel/perfctr.c
@@ -29,7 +29,7 @@
#define NS_PER_CYCLE 5
/* Get a counter's current configuration. */
-bool perf_cntr_config(perf_cntr_t counter,
+bool perf_cntr_config(perf_cntr_t counter,
perf_cntr_event_t *event,
perf_cntr_clock_t *clock) {
@@ -42,14 +42,14 @@ bool perf_cntr_config(perf_cntr_t counter,
}
/* Start a performance counter. */
-void perf_cntr_start(perf_cntr_t counter,
- perf_cntr_event_t event,
+void perf_cntr_start(perf_cntr_t counter,
+ perf_cntr_event_t event,
perf_cntr_clock_t clock) {
-
+
perf_cntr_clear(counter);
- PMCR_CTRL(counter) = PMCR_RUN |
- (clock << PMCR_PMCLK_SHIFT) |
+ PMCR_CTRL(counter) = PMCR_RUN |
+ (clock << PMCR_PMCLK_SHIFT) |
event;
}
@@ -81,7 +81,7 @@ uint64_t perf_cntr_count(perf_cntr_t counter) {
hi = PMCTR_HIGH(counter);
lo = PMCTR_LOW(counter);
hi2 = PMCTR_HIGH(counter);
- } while(__unlikely(hi != hi2));
+ } while (__predict_false(hi != hi2));
return (uint64_t)hi << 32 | lo;
}
@@ -90,7 +90,7 @@ void perf_cntr_timer_enable(void) {
perf_cntr_start(PRFC0, PMCR_ELAPSED_TIME_MODE, PMCR_COUNT_CPU_CYCLES);
}
-bool perf_cntr_timer_enabled(void) {
+bool perf_cntr_timer_enabled(void) {
perf_cntr_event_t event;
perf_cntr_clock_t clock;
diff --git a/kernel/arch/dreamcast/kernel/timer.c b/kernel/arch/dreamcast/kernel/timer.c
index b1cfc7df..d8a5fef6 100644
--- a/kernel/arch/dreamcast/kernel/timer.c
+++ b/kernel/arch/dreamcast/kernel/timer.c
@@ -20,7 +20,7 @@
#define TIMER32(o) ( *((volatile uint32_t *)(TIMER_BASE + (o))) )
/* Register base address */
-#define TIMER_BASE 0xffd80000
+#define TIMER_BASE 0xffd80000
/* Register offsets */
#define TOCR 0x00 /* Timer Output Control Register */
@@ -53,7 +53,7 @@
#define TDIV(div) (4 << (2 * div))
/* Timer Prescalar TPSC values (Peripheral clock divided by N) */
-typedef enum PCK_DIV {
+typedef enum PCK_DIV {
PCK_DIV_4, /* Pck/4 => 80ns */
PCK_DIV_16, /* Pck/16 => 320ns*/
PCK_DIV_64, /* Pck/64 => 1280ns*/
@@ -77,11 +77,11 @@ static const unsigned tcnts[] = { TCNT0, TCNT1, TCNT2 };
static const unsigned tcrs[] = { TCR0, TCR1, TCR2 };
/* Apply timer configuration to registers. */
-static int timer_prime_apply(int which, uint32_t count, int interrupts) {
+static int timer_prime_apply(int which, uint32_t count, int interrupts) {
assert(which <= TMU2);
TIMER32(tcnts[which]) = count;
- TIMER32(tcors[which]) = count;
+ TIMER32(tcors[which]) = count;
TIMER16(tcrs[which]) = TIMER_TPSC;
@@ -207,9 +207,9 @@ int timer_ints_enabled(int which) {
}
/* Seconds elapsed (since KOS startup), updated from the TMU2 underflow ISR */
-static volatile uint32_t timer_ms_counter = 0;
+static volatile uint32_t timer_ms_counter = 0;
/* Max counter value (used as TMU2 reload), to target a 1 second interval */
-static uint32_t timer_ms_countdown;
+static uint32_t timer_ms_countdown;
/* TMU2 interrupt handler, called every second. Simply updates our
running second counter and clears the underflow flag. */
@@ -249,7 +249,7 @@ typedef struct timer_value {
static timer_val_t timer_getticks(const uint32_t *tns, uint32_t shift) {
uint32_t secs, unf1, unf2, counter1, counter2, delta, ticks;
uint16_t tmu2;
-
+
do {
/* Read the underflow flag twice, and the counter twice.
- If both flags are set, it's just unrealistic that one
@@ -278,7 +278,7 @@ static timer_val_t timer_getticks(const uint32_t *tns, uint32_t shift) {
counter2 = TIMER32(tcnts[TMU2]);
tmu2 = TIMER16(tcrs[TMU2]);
unf2 = !!(tmu2 & UNF);
- } while(__unlikely(unf1 != unf2 || counter1 < counter2));
+ } while(__predict_false(unf1 != unf2 || counter1 < counter2));
delta = timer_ms_countdown - counter2;
@@ -371,7 +371,7 @@ static void tp_handler(irq_t src, irq_context_t *cxt, void *data) {
/* Call the callback, if any */
if(tp_callback)
tp_callback(cxt);
- }
+ }
/* Do we have less than a second remaining? */
else if(tp_ms_remaining < 1000) {
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 19:22:36
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via d77b00786bec441e4e08dfadbc2fa1b46ff086af (commit)
from 3dcb6c7507d2c1a6a0e07dbe9841c000354b70f0 (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 d77b00786bec441e4e08dfadbc2fa1b46ff086af
Author: darc <da...@pr...>
Date: Tue Aug 19 12:28:41 2025 -0500
Move banner, license, author, uname functions from arch
- Create kos/banner.h header for banner, license, author functions
- Move banner/authors generation scripts from arch/dreamcast/kernel/ to kernel/
- Add arch/subarch description to the banner
- Add ARCH_NAME define, representing an arch's full name, to arch.h
- Move arch/dreamcast/kernel/uname.c to kernel/libc/koslib/
-----------------------------------------------------------------------
Summary of changes:
include/kos/banner.h | 66 ++++++++++++++++++++++
kernel/Makefile | 18 +++++-
kernel/arch/dreamcast/include/arch/arch.h | 53 ++++-------------
kernel/arch/dreamcast/kernel/Makefile | 21 +------
kernel/arch/dreamcast/kernel/init.c | 1 +
kernel/{arch/dreamcast/kernel => }/banner.c | 0
kernel/libc/koslib/Makefile | 2 +-
.../{arch/dreamcast/kernel => libc/koslib}/uname.c | 6 +-
.../{arch/dreamcast/kernel => }/make_authors.awk | 0
kernel/{arch/dreamcast/kernel => }/make_banner.sh | 6 ++
10 files changed, 106 insertions(+), 67 deletions(-)
create mode 100644 include/kos/banner.h
rename kernel/{arch/dreamcast/kernel => }/banner.c (100%)
rename kernel/{arch/dreamcast/kernel => libc/koslib}/uname.c (84%)
rename kernel/{arch/dreamcast/kernel => }/make_authors.awk (100%)
rename kernel/{arch/dreamcast/kernel => }/make_banner.sh (89%)
diff --git a/include/kos/banner.h b/include/kos/banner.h
new file mode 100644
index 00000000..659d74e6
--- /dev/null
+++ b/include/kos/banner.h
@@ -0,0 +1,66 @@
+/* KallistiOS ##version##
+
+ kos/banner.h
+ Copyright (C) 2013 Lawrence Sebald
+ Copyright (C) 2025 Eric Fradella
+*/
+
+#ifndef __KOS_BANNER_H
+#define __KOS_BANNER_H
+
+#include <kos/cdefs.h>
+__BEGIN_DECLS
+
+/** \file kos/banner.h
+ \defgroup attribution Attribution
+ \brief KOS banner, license, and authors
+
+ This API can be used to query for and display information
+ on KOS, its license, and its authors at runtime.
+
+ \remark
+ The authors list can be used for credits screens in games
+ and applications to acknowledge KOS and its contributors. :)
+*/
+
+/** \brief Retrieve the banner printed at program initialization.
+ \ingroup attribution
+
+ This function retrieves the banner string that is printed at initialization
+ time by the kernel. This contains the version of KOS in use and basic
+ information about the environment in which it was compiled.
+
+ \return A pointer to the banner string.
+*/
+const char * __pure2 kos_get_banner(void);
+
+/** \brief Retrieve the license information for the compiled copy of KOS.
+ \ingroup attribution
+
+ This function retrieves a string containing the license terms that the
+ version of KOS in use is distributed under. This can be used to easily add
+ information to your program to be displayed at runtime.
+
+ \return A pointer to the license terms.
+*/
+const char * __pure2 kos_get_license(void);
+
+/** \brief Retrieve a list of authors and the dates of their contributions.
+ \ingroup attribution
+
+ This function retrieves the copyright information for the version of KOS in
+ use. This function can be used to add such information to the credits of
+ programs using KOS to give the appropriate credit to those that have worked
+ on KOS.
+
+ \remark
+ Remember, you do need to give credit where credit is due, and this is an
+ easy way to do so. ;-)
+
+ \return A pointer to the authors' copyright information.
+*/
+const char *__pure2 kos_get_authors(void);
+
+__END_DECLS
+
+#endif /* !__KOS_BANNER_H */
diff --git a/kernel/Makefile b/kernel/Makefile
index 85902e32..252ac663 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -5,18 +5,29 @@
# Copyright (C) 2024 Falco Girgis
#
-OBJS = version.o
+OBJS = banner.o version.o
SUBDIRS = arch debug fs thread net libc exports romdisk
STUBS = stubs/kernel_export_stubs.o stubs/arch_export_stubs.o
# Everything from here up should be plain old C.
KOS_CFLAGS += $(KOS_CSTD)
-all: defaultall $(STUBS)
+all: banner.h defaultall $(STUBS)
rm -f $(KOS_BASE)/lib/$(KOS_ARCH)/libkallisti.a
kos-ar rcs $(KOS_BASE)/lib/$(KOS_ARCH)/libromdiskbase.a romdisk/*.o
kos-ar rcs $(KOS_BASE)/lib/$(KOS_ARCH)/libkallisti.a build/*.o
kos-ar rcs $(KOS_BASE)/lib/$(KOS_ARCH)/libkallisti_exports.a stubs/*.o
+ rm -f authors.h banner.h
+
+authors.h: make_authors.awk
+ awk -f make_authors.awk < ../AUTHORS > authors.h
+
+banner.o: banner.c
+
+banner.c: banner.h authors.h
+
+banner.h: make_banner.sh
+ ./make_banner.sh
stubs/kernel_export_stubs.c: exports.txt
$(KOS_BASE)/utils/genexports/genexportstubs.sh $< stubs/kernel_export_stubs.c
@@ -31,5 +42,8 @@ clean: defaultclean
rm -f build/libc/*.o
rm -f romdisk/*.o
rm -f stubs/*.o stubs/kernel_export_stubs.c stubs/arch_export_stubs.c
+ rm -f banner.h authors.h
run:
+
+.PHONY: banner.h authors.h
diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h
index dd51f245..2fd7981e 100644
--- a/kernel/arch/dreamcast/include/arch/arch.h
+++ b/kernel/arch/dreamcast/include/arch/arch.h
@@ -85,6 +85,9 @@ unsigned HZ __depr("Please use the new THD_SCHED_HZ macro.") = THD_SCHED_HZ;
/** \brief Length of global symbol prefix in ELF files. */
#define ELF_SYM_PREFIX_LEN 1
+/** \brief Standard name for this arch. */
+#define ARCH_NAME "Dreamcast"
+
/** \brief ELF class for this architecture. */
#define ARCH_ELFCLASS ELFCLASS32
@@ -300,47 +303,6 @@ void hardware_shutdown(void);
*/
int hardware_sys_mode(int *region);
-/* These three aught to be in their own header file at some point, but for now,
- they'll stay here. */
-
-/** \brief Retrieve the banner printed at program initialization.
- \ingroup attribution
-
- This function retrieves the banner string that is printed at initialization
- time by the kernel. This contains the version of KOS in use and basic
- information about the environment in which it was compiled.
-
- \return A pointer to the banner string.
-*/
-const char * __pure2 kos_get_banner(void);
-
-/** \brief Retrieve the license information for the compiled copy of KOS.
- \ingroup attribution
-
- This function retrieves a string containing the license terms that the
- version of KOS in use is distributed under. This can be used to easily add
- information to your program to be displayed at runtime.
-
- \return A pointer to the license terms.
-*/
-const char * __pure2 kos_get_license(void);
-
-/** \brief Retrieve a list of authors and the dates of their contributions.
- \ingroup attribution
-
- This function retrieves the copyright information for the version of KOS in
- use. This function can be used to add such information to the credits of
- programs using KOS to give the appropriate credit to those that have worked
- on KOS.
-
- \remark
- Remember, you do need to give credit where credit is due, and this is an
- easy way to do so. ;-)
-
- \return A pointer to the authors' copyright information.
-*/
-const char *__pure2 kos_get_authors(void);
-
/** \brief Dreamcast specific sleep mode function.
\ingroup arch
*/
@@ -370,6 +332,15 @@ static inline bool arch_valid_text_address(uintptr_t ptr) {
return ptr >= (uintptr_t)&_executable_start && ptr < (uintptr_t)&_etext;
}
+/* The following functions are moved out of this header and are only provided for
+ compatibility reasons. Including any of them via this header is deprecated.
+*/
+
+/* Moved to <kos/banner.h> */
+const char * __pure2 kos_get_banner(void);
+const char * __pure2 kos_get_license(void);
+const char *__pure2 kos_get_authors(void);
+
__END_DECLS
#endif /* __ARCH_ARCH_H */
diff --git a/kernel/arch/dreamcast/kernel/Makefile b/kernel/arch/dreamcast/kernel/Makefile
index d6c3da9f..018752ed 100644
--- a/kernel/arch/dreamcast/kernel/Makefile
+++ b/kernel/arch/dreamcast/kernel/Makefile
@@ -9,45 +9,26 @@
# target processor. Other routines may be present as well, but
# that minimum set must be present.
-COPYOBJS = banner.o cache.o entry.o irq.o init.o mm.o panic.o
+COPYOBJS = cache.o entry.o irq.o init.o mm.o panic.o
COPYOBJS += rtc.o timer.o perfctr.o perf_monitor.o
COPYOBJS += init_flags_default.o
COPYOBJS += mmu.o itlb.o
COPYOBJS += exec.o execasm.o stack.o gdb_stub.o thdswitch.o tls_static.o arch_exports.o
-COPYOBJS += uname.o
OBJS = $(COPYOBJS) startup.o
SUBDIRS =
myall: $(OBJS)
-cp $(COPYOBJS) $(KOS_BASE)/kernel/build/
-cp startup.o $(KOS_BASE)/lib/$(KOS_ARCH)/_kos_startup.o
- -rm banner.h authors.h banner.o uname.o
include $(KOS_BASE)/Makefile.prefab
-uname.o: uname.c
-
-uname.c: banner.h
-
-banner.o: banner.c
-
-banner.c: banner.h authors.h
-
-banner.h: make_banner.sh
- ./make_banner.sh
-
-authors.h: make_authors.awk
- awk -f make_authors.awk < ../../../../AUTHORS > authors.h
-
arch_exports.o: arch_exports.c
arch_exports.c: ../exports-$(KOS_SUBARCH).txt
$(KOS_BASE)/utils/genexports/genexports.sh ../exports-$(KOS_SUBARCH).txt arch_exports.c arch_symtab
clean:
- -rm -f banner.h authors.h
-rm -f $(OBJS)
-rm -f arch_exports.c
-rm -f arch_exports.c
-
-.PHONY: banner.h authors.h
diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c
index 4c05733f..d80385a4 100644
--- a/kernel/arch/dreamcast/kernel/init.c
+++ b/kernel/arch/dreamcast/kernel/init.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
+#include <kos/banner.h>
#include <kos/dbgio.h>
#include <kos/dbglog.h>
#include <kos/init.h>
diff --git a/kernel/arch/dreamcast/kernel/banner.c b/kernel/banner.c
similarity index 100%
rename from kernel/arch/dreamcast/kernel/banner.c
rename to kernel/banner.c
diff --git a/kernel/libc/koslib/Makefile b/kernel/libc/koslib/Makefile
index 1b39491d..625beae2 100644
--- a/kernel/libc/koslib/Makefile
+++ b/kernel/libc/koslib/Makefile
@@ -14,6 +14,6 @@ OBJS = abort.o memset2.o memset4.o memcpy2.o memcpy4.o \
creat.o sleep.o rmdir.o rename.o inet_pton.o inet_ntop.o \
inet_ntoa.o inet_aton.o poll.o select.o symlink.o readlink.o \
gethostbyname.o getaddrinfo.o dirfd.o nanosleep.o basename.o dirname.o \
- sched_yield.o dup.o dup2.o pipe.o
+ sched_yield.o dup.o dup2.o pipe.o uname.o
include $(KOS_BASE)/Makefile.prefab
diff --git a/kernel/arch/dreamcast/kernel/uname.c b/kernel/libc/koslib/uname.c
similarity index 84%
rename from kernel/arch/dreamcast/kernel/uname.c
rename to kernel/libc/koslib/uname.c
index aa0ef75b..2a2c9e0d 100644
--- a/kernel/arch/dreamcast/kernel/uname.c
+++ b/kernel/libc/koslib/uname.c
@@ -10,10 +10,10 @@
#include <string.h>
#include <sys/utsname.h>
-#include "banner.h"
+#include <arch/arch.h>
+#include "../../banner.h"
#define UNAME_KERNEL "KallistiOS"
-#define UNAME_MACHINE "Dreamcast"
int uname(struct utsname *n) {
if(!n) {
@@ -25,7 +25,7 @@ int uname(struct utsname *n) {
strcpy(n->sysname, UNAME_KERNEL);
strcpy(n->release, kern_version);
snprintf(n->version, 64, "%s %s", UNAME_KERNEL, kern_version);
- strcpy(n->machine, UNAME_MACHINE);
+ strcpy(n->machine, ARCH_NAME);
return 0;
}
diff --git a/kernel/arch/dreamcast/kernel/make_authors.awk b/kernel/make_authors.awk
similarity index 100%
rename from kernel/arch/dreamcast/kernel/make_authors.awk
rename to kernel/make_authors.awk
diff --git a/kernel/arch/dreamcast/kernel/make_banner.sh b/kernel/make_banner.sh
similarity index 89%
rename from kernel/arch/dreamcast/kernel/make_banner.sh
rename to kernel/make_banner.sh
index 4bc60754..cf9b5620 100755
--- a/kernel/arch/dreamcast/kernel/make_banner.sh
+++ b/kernel/make_banner.sh
@@ -9,6 +9,11 @@ relver="$KOS_VERSION"
printf '"KallistiOS ' >> banner.h
printf "v$relver" >> banner.h
+printf ' [' >> banner.h
+printf "$KOS_ARCH" >> banner.h
+printf '/' >> banner.h
+printf "$KOS_SUBARCH" >> banner.h
+printf ']' >> banner.h
printf '\\n"\n' >> banner.h
if [ -d "$KOS_BASE/.git" ]; then
printf '" Git revision: ' >> banner.h
@@ -54,3 +59,4 @@ else
fi
printf '";\n' >> banner.h
+
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 10:06:23
|
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 3dcb6c7507d2c1a6a0e07dbe9841c000354b70f0 (commit)
via 07bb4a1b70358db900c06b8771a78f4d9dfbc517 (commit)
via 1cf6345122f9fcdd0ccf2b82466ac279842aad02 (commit)
via e4e50b1e7ac9b1dbf461824c18f6911767618484 (commit)
via 05167610e60b1bb4e46e180dee4206cce15b7e44 (commit)
via cdcf919eea5181434647804101d04c748914a3c9 (commit)
via 7e2e257c47ed28ff3e69aca19a5ae83c02f8d34d (commit)
from 3a34e9a1c7fcee85e39b4b48f8472ecbd36e536e (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 3dcb6c7507d2c1a6a0e07dbe9841c000354b70f0
Author: QuzarDC <qu...@co...>
Date: Fri Aug 8 10:48:42 2025 -0400
rumble: Update example to use new effect members and a safe stop effect.
Primarily just adjusting the printouts and data members to use the new
struct types, which allowed getting rid of the custom defined ones.
Additionally changing the 'stop' baked in effect to define stopping the
default motor 1. Sending a 0 in `motor` is now disallowed by the driver
as it will cause official hardware rumble to throw errors and stop working.
commit 07bb4a1b70358db900c06b8771a78f4d9dfbc517
Author: QuzarDC <qu...@co...>
Date: Thu Aug 14 00:55:52 2025 -0400
puru: constify `purupuru_rumble` param.
We were never intending to modify the data, but lets guarntee it.
commit 1cf6345122f9fcdd0ccf2b82466ac279842aad02
Author: QuzarDC <qu...@co...>
Date: Thu Aug 14 00:00:03 2025 -0400
puru: Deprecate old effect struct members and macros.
The new specified members of `purupuru_effect_t` should be used
instead.
commit e4e50b1e7ac9b1dbf461824c18f6911767618484
Author: QuzarDC <qu...@co...>
Date: Wed Aug 13 23:34:08 2025 -0400
puru: Add new field accessors for rumble effect and error checking.
These fields match data provided by megavolt in a few github comments
with modifications to (hopefully) improve readability.
The new fields are then leveraged to test for error conditions. This
helps support for the official pack that will throw a hardware error
(`MAPLE_RESPONSE_BADFUNC`) when invalid conditions are sent. Specifically
we have been using `0x00000000` for 'stop rumbling' but the motor select
field must be non-zero. I have additionally added a check for another
invalid condition which is for both convergent and divergent vibration
to be set at once.
commit 05167610e60b1bb4e46e180dee4206cce15b7e44
Author: QuzarDC <qu...@co...>
Date: Thu Aug 7 17:24:30 2025 -0400
maple_irq: Enhanced error reporting.
This allows for clear signalling if an unexpected response
is coming back from the autocheck and testing a specific error
response that is related to the puru not functioning.
With the new dbglog settings these shouldn't cause spamming,
but if they do then that should indicate something that needs
fixing.
commit cdcf919eea5181434647804101d04c748914a3c9
Author: QuzarDC <qu...@co...>
Date: Thu Aug 7 17:20:09 2025 -0400
puru: Restructure `purupuru_effect_t`
For no good reason that I can see the members of the struct
were in reverse order and relied on being shuffled back. This
does break the ABI but anyone who was using the type should not
have been casting a `uint32` to it.
These struct members will end up being deprecated, but this will
allow for better compatibility.
commit 7e2e257c47ed28ff3e69aca19a5ae83c02f8d34d
Author: QuzarDC <qu...@co...>
Date: Thu Aug 7 13:21:29 2025 -0400
puru: Switch to stdint types.
Additionally drop the unnecessary include of genwait.
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/rumble/rumble.c | 154 ++++----------------
kernel/arch/dreamcast/hardware/maple/maple_irq.c | 10 +-
kernel/arch/dreamcast/hardware/maple/purupuru.c | 26 ++--
kernel/arch/dreamcast/include/dc/maple/purupuru.h | 164 ++++++++--------------
4 files changed, 107 insertions(+), 247 deletions(-)
diff --git a/examples/dreamcast/rumble/rumble.c b/examples/dreamcast/rumble/rumble.c
index f08f7755..f75a23d7 100644
--- a/examples/dreamcast/rumble/rumble.c
+++ b/examples/dreamcast/rumble/rumble.c
@@ -2,7 +2,7 @@
rumble.c
Copyright (C) 2004 SinisterTengu
- Copyright (C) 2008, 2023 Donald Haase
+ Copyright (C) 2008, 2023, 2025 Donald Haase
Copyright (C) 2024 Daniel Fairchild
*/
@@ -37,120 +37,19 @@ KOS_INIT_FLAGS(INIT_DEFAULT);
plx_fcxt_t *cxt;
+void print_rumble_fields(purupuru_effect_t fields) {
-typedef union rumble_fields {
- uint32_t raw;
- struct {
- /* Special Effects and motor select. The normal purupuru packs will
-only have one motor. Selecting MOTOR2 for these is probably not
-a good idea. The PULSE setting here supposably creates a sharp
-pulse effect, when ORed with the special field. */
-
- /** \brief Yet another pulse effect.
- This supposedly creates a sharp pulse effect.
- */
- uint32_t special_pulse : 1;
- uint32_t : 3; // unused
-
- /** \brief Select motor #1.
-
- Most jump packs only have one motor, but on things that do have more
- than one motor (like PS1->Dreamcast controller adapters that support
- rumble), this selects the first motor.
- */
- uint32_t special_motor1 : 1;
- uint32_t : 2; // unused
-
- /** \brief Select motor #2.
-
- Most jump packs only have one motor, but on things that do have more
- than one motor (like PS1->Dreamcast controller adapters that support
- rumble), this selects the second motor.
- */
- uint32_t special_motor2 : 1;
-
- /** \brief Ignore this command.
-
- Valid value 15 (0xF).
-
- Most jump packs will ignore commands with this set in effect1,
- apparently.
- */
- uint32_t fx1_powersave : 4;
-
- /** \brief Upper nibble of effect1.
-
- This value works with the lower nibble of the effect2 field to
- increase the intensity of the rumble effect.
- Valid values are 0-7.
-
- \see rumble_fields_t.fx2_lintensity
- */
- uint32_t fx1_intensity : 3;
-
- /** \brief Give a pulse effect to the rumble.
-
- This probably should be used with rumble_fields_t.fx1_pulse as well.
-
- \see rumble_fields_t.fx2_pulse
- */
- uint32_t fx1_pulse : 1;
-
- /** \brief Lower-nibble of effect2.
-
- This value works with the upper nibble of the effect1
- field to increase the intensity of the rumble effect.
- Valid values are 0-7.
-
- \see rumble_fields_t.fx1_intensity
- */
- uint32_t fx2_lintensity : 3;
-
- /** \brief Give a pulse effect to the rumble.
-
- This probably should be used with rumble_fields_t.fx1_pulse as well.
-
- \see rumble_fields_t.fx1_intensity
- */
- uint32_t fx2_pulse : 1;
-
- /** \brief Upper-nibble of effect2.
-
- This apparently lowers the rumble's intensity somewhat.
- Valid values are 0-7.
- */
- uint32_t fx2_uintensity : 3;
-
- /* OR these in with your effect2 value if you feel so inclined.
- if you or the PULSE effect in here, you probably should also
- do so with the effect1 one below. */
-
- /** \brief Give a decay effect to the rumble on some packs. */
- uint32_t fx2_decay : 1;
-
- /** \brief The duration of the effect. No idea on units... */
- uint32_t duration : 8;
- };
-} rumble_fields_t;
-
-
-void print_rumble_fields(uint32_t raw) {
- rumble_fields_t fields = {.raw = raw};
printf("Rumble Fields:\n");
- printf(" .special_pulse = %u,\n", fields.special_pulse);
- printf(" .special_motor1 = %u,\n", fields.special_motor1);
- printf(" .special_motor2 = %u,\n", fields.special_motor2);
-
- printf(" .fx1_pulse = %u,\n", fields.fx1_pulse);
- printf(" .fx1_powersave = %u,\n", fields.fx1_powersave);
- printf(" .fx1_intensity = %u,\n", fields.fx1_intensity);
+ printf(" .cont = %s,\n", fields.cont ? "true" : "false");
+ printf(" .motor = %u,\n", fields.motor);
- printf(" .fx2_lintensity = %u,\n", fields.fx2_lintensity);
- printf(" .fx2_pulse = %u,\n", fields.fx2_pulse);
- printf(" .fx2_uintensity = %u,\n", fields.fx2_uintensity);
- printf(" .fx2_decay = %u,\n", fields.fx2_decay);
+ printf(" .bpow = %u,\n", fields.bpow);
+ printf(" .fpow = %u,\n", fields.fpow);
+ printf(" .div = %s,\n", fields.div ? "true" : "false");
+ printf(" .conv = %s,\n", fields.conv ? "true" : "false");
- printf(" .duration = %u,\n", fields.duration);
+ printf(" .freq = %u,\n", fields.freq);
+ printf(" .inc = %u,\n", fields.inc);
}
/* This blocks waiting for a specified device to be present and valid */
void wait_for_dev_attach(maple_device_t **dev_ptr, unsigned int func) {
@@ -189,18 +88,21 @@ void wait_for_dev_attach(maple_device_t **dev_ptr, unsigned int func) {
typedef struct {
- uint32_t pattern;
+ purupuru_effect_t effect;
const char *description;
} baked_pattern_t;
+/* motor cannot be 0 (will generate error on official hardware), but we can set everything else to 0 for stopping */
+static const purupuru_effect_t rumble_stop = {.motor = 1};
+
static size_t catalog_index = 0;
static const baked_pattern_t catalog[] = {
- {.pattern = 0x011A7010, .description = "Basic Thud (simple .5s jolt)"},
- {.pattern = 0x31071011, .description = "Car Idle (69 Mustang)"},
- {.pattern = 0x2615F010, .description = "Car Idle (VW beetle)"},
- {.pattern = 0x3339F010, .description = "Eathquake (Vibrate, and fade out)"},
- {.pattern = 0x05281011, .description = "Helicopter"},
- {.pattern = 0x00072010, .description = "Ship's Thrust (as in AAC)"},
+ {.effect = {.cont = false, .motor = 1, .fpow = 7, .freq = 26, .inc = 1}, .description = "Basic Thud (simple .5s jolt)"},
+ {.effect = {.cont = true, .motor = 1, .fpow = 1, .freq = 7, .inc = 49}, .description = "Car Idle (69 Mustang)"},
+ {.effect = {.cont = false, .motor = 1, .fpow = 7, .conv = true, .freq = 21, .inc = 38}, .description = "Car Idle (VW beetle)"},
+ {.effect = {.cont = false, .motor = 1, .fpow = 7, .conv = true, .freq = 57, .inc = 51}, .description = "Eathquake (Vibrate, and fade out)"},
+ {.effect = {.cont = true, .motor = 1, .fpow = 1, .freq = 40, .inc = 5}, .description = "Helicopter"},
+ {.effect = {.cont = false, .motor = 1, .fpow = 2, .freq = 7, .inc = 0}, .description = "Ship's Thrust (as in AAC)"},
};
static inline void word2hexbytes(uint32_t word, uint8_t *bytes) {
@@ -218,7 +120,7 @@ int main(int argc, char *argv[]) {
point_t w;
int i = 0, count = 0;
uint16_t old_buttons = 0, rel_buttons = 0;
- uint32_t effect = 0;
+ purupuru_effect_t effect = {.raw = 0};
uint8_t n[8];
char s[8][2] = { "", "", "", "", "", "", "", "" };
word2hexbytes(0, n);
@@ -295,8 +197,8 @@ int main(int argc, char *argv[]) {
}
if ((state->buttons & CONT_X) && (rel_buttons & CONT_X)) {
- printf("Setting baked pattern:\n\t'%s'\n", catalog[catalog_index].description);
- word2hexbytes(catalog[catalog_index].pattern, n);
+ printf("Setting baked effect:\n\t'%s'\n", catalog[catalog_index].description);
+ word2hexbytes(catalog[catalog_index].effect.raw, n);
catalog_index++;
if (catalog_index >= sizeof(catalog) / sizeof(baked_pattern_t)) {
catalog_index = 0;
@@ -305,17 +207,17 @@ int main(int argc, char *argv[]) {
if((state->buttons & CONT_A) && (rel_buttons & CONT_A)) {
- effect = (n[0] << 28) + (n[1] << 24) + (n[2] << 20) + (n[3] << 16) +
+ effect.raw = (n[0] << 28) + (n[1] << 24) + (n[2] << 20) + (n[3] << 16) +
(n[4] << 12) + (n[5] << 8) + (n[6] << 4) + (n[7] << 0);
- purupuru_rumble_raw(purudev, effect);
+ purupuru_rumble(purudev, &effect);
/* We print these out to make it easier to track the options chosen */
- printf("Rumble: 0x%lx!\n", effect);
+ printf("Rumble: 0x%lx!\n", effect.raw);
print_rumble_fields(effect);
}
if((state->buttons & CONT_B) && (rel_buttons & CONT_B)) {
- purupuru_rumble_raw(purudev, 0x00000000);
+ purupuru_rumble(purudev, &rumble_stop);
printf("Rumble Stopped!\n");
}
@@ -355,7 +257,7 @@ int main(int argc, char *argv[]) {
/* Stop rumbling before exiting, if it still exists. */
if((purudev != NULL) && purudev->valid)
- purupuru_rumble_raw(purudev, 0x00000000);
+ purupuru_rumble(purudev, &rumble_stop);
plx_font_destroy(fnt);
plx_fcxt_destroy(cxt);
diff --git a/kernel/arch/dreamcast/hardware/maple/maple_irq.c b/kernel/arch/dreamcast/hardware/maple/maple_irq.c
index f5d02e41..6a0d481a 100644
--- a/kernel/arch/dreamcast/hardware/maple/maple_irq.c
+++ b/kernel/arch/dreamcast/hardware/maple/maple_irq.c
@@ -183,8 +183,8 @@ static void vbl_autodet_callback(maple_state_t *state, maple_frame_t *frm) {
vbl_chk_next_subdev(state, frm, p);
}
else {
- /* dbglog(DBG_KDEBUG, "maple: unknown response %d on device %c%c\n",
- resp->response, 'A'+p, '0'+u); */
+ dbglog(DBG_DEBUG, "maple: unknown response %d on device %c%c\n",
+ resp->response, 'A'+p, '0'+u);
state->scan_ready_mask |= 1 << p;
maple_frame_unlock(frm);
}
@@ -275,6 +275,12 @@ void maple_dma_irq_hnd(uint32 code, void *data) {
i->state = MAPLE_FRAME_UNSENT;
continue;
}
+ /* This error is generated in the case where bad input is sent to the purupuru.
+ For instance, when setting motor selection to '0' rather than '1'. */
+ else if(resp == MAPLE_RESPONSE_BADFUNC) {
+ dbglog(DBG_ERROR, "maple_irq: error EBADFUNC on %c%i when sending command: %i\n",
+ ('A' - i->dst_port), i->dst_unit, i->cmd);
+ }
if(__is_defined(MAPLE_DMA_DEBUG))
maple_sentinel_verify("i->recv_buf", i->recv_buf, 1024);
diff --git a/kernel/arch/dreamcast/hardware/maple/purupuru.c b/kernel/arch/dreamcast/hardware/maple/purupuru.c
index 29255721..a458df2d 100644
--- a/kernel/arch/dreamcast/hardware/maple/purupuru.c
+++ b/kernel/arch/dreamcast/hardware/maple/purupuru.c
@@ -3,19 +3,19 @@
purupuru.c
Copyright (C) 2003 Megan Potter
Copyright (C) 2005 Lawrence Sebald
+ Copyright (C) 2025 Donald Haase
*/
#include <assert.h>
#include <kos/dbglog.h>
-#include <kos/genwait.h>
#include <dc/maple.h>
#include <dc/maple/purupuru.h>
/* Be warned, not all purus are created equal, in fact, most of
them act different for just about everything you feed to them. */
-int purupuru_rumble_raw(maple_device_t *dev, uint32 effect) {
- uint32 *send_buf;
+int purupuru_rumble_raw(maple_device_t *dev, uint32_t effect) {
+ uint32_t *send_buf;
assert(dev != NULL);
@@ -25,7 +25,7 @@ int purupuru_rumble_raw(maple_device_t *dev, uint32 effect) {
/* 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_PURUPURU;
send_buf[1] = effect;
dev->frame.cmd = MAPLE_COMMAND_SETCOND;
@@ -39,16 +39,20 @@ int purupuru_rumble_raw(maple_device_t *dev, uint32 effect) {
return MAPLE_EOK;
}
-int purupuru_rumble(maple_device_t *dev, purupuru_effect_t *effect) {
- uint32 comp_effect;
+int purupuru_rumble(maple_device_t *dev, const purupuru_effect_t *effect) {
- assert(dev != NULL);
+ /* Error checking to prevent hardware-level errors */
+ if(!effect->motor) {
+ dbglog(DBG_WARNING, "puru: invalid rumble effect sent. motor must be nonzero.\n");
+ return MAPLE_EINVALID;
+ }
- /* "Compile" the effect */
- comp_effect = (effect->duration << 24) | (effect->effect2 << 16) |
- (effect->effect1 << 8) | (effect->special);
+ if(effect->conv && effect->div) {
+ dbglog(DBG_WARNING, "puru: invalid rumble effect sent. Divergent and Convergent rumble cannot be set together.\n");
+ return MAPLE_EINVALID;
+ }
- return purupuru_rumble_raw(dev, comp_effect);
+ return purupuru_rumble_raw(dev, effect->raw);
}
diff --git a/kernel/arch/dreamcast/include/dc/maple/purupuru.h b/kernel/arch/dreamcast/include/dc/maple/purupuru.h
index a88bb9c4..90191502 100644
--- a/kernel/arch/dreamcast/include/dc/maple/purupuru.h
+++ b/kernel/arch/dreamcast/include/dc/maple/purupuru.h
@@ -3,6 +3,7 @@
dc/maple/purupuru.h
Copyright (C) 2003 Megan Potter
Copyright (C) 2005, 2010 Lawrence Sebald
+ Copyright (C) 2025 Donald Haase
*/
@@ -28,6 +29,7 @@
that does absolutely nothing on the first try.
\author Lawrence Sebald
+ \author Donald Haase
*/
#ifndef __DC_MAPLE_PURUPURU_H
@@ -36,7 +38,8 @@
#include <kos/cdefs.h>
__BEGIN_DECLS
-#include <arch/types.h>
+#include <stdbool.h>
+#include <stdint.h>
#include <dc/maple.h>
/** \defgroup peripherals_rumble Rumble Pack
@@ -49,114 +52,58 @@ __BEGIN_DECLS
/** \brief Effect generation structure.
This structure is used for convenience to send an effect to the jump pack.
- This, along with the various macros in this file can give a slightly better
- idea of the effect being generated than using the raw values.
+ The members in the structure note general explanations of their use as well
+ as some limitations and suggestions. There shouldn't be a need to use the
+ raw accessor with the new fully specified members.
*/
-typedef struct purupuru_effect {
- /** \brief The duration of the effect. No idea on units... */
- uint8 duration;
-
- /** \brief 2nd effect field. */
- uint8 effect2;
-
- /** \brief 1st effect field. */
- uint8 effect1;
-
- /** \brief Special effects field. */
- uint8 special;
+typedef union purupuru_effect {
+ /** \brief Access the raw 32-bit value to be sent to the puru */
+ uint32_t raw;
+ /** \brief Deprecated old structure which has been inverted now to union with raw. */
+ struct {
+ uint8_t special __depr("Please see purupuru_effect_t which has new members.");
+ uint8_t effect1 __depr("Please see purupuru_effect_t which has new members.");
+ uint8_t effect2 __depr("Please see purupuru_effect_t which has new members.");
+ uint8_t duration __depr("Please see purupuru_effect_t which has new members.");
+ };
+ struct {
+ /** \brief Continuous Vibration. When set vibration will continue until stopped */
+ bool cont : 1;
+ /** \brief Reserved. Always 0s */
+ uint32_t res : 3;
+ /** \brief Motor number. 0 will cause an error. 1 is the typical setting. */
+ uint32_t motor : 4;
+
+ /** \brief Backward direction (- direction) intensity setting bits. 0 stops vibration. */
+ uint32_t bpow : 3;
+ /** \brief Divergent vibration. The rumble will get stronger until it stops. */
+ bool div : 1;
+ /** \brief Forward direction (+ direction) intensity setting bits. 0 stops vibration. */
+ uint32_t fpow : 3;
+ /** \brief Convergent vibration. The rumble will get weaker until it stops. */
+ bool conv : 1;
+
+ /** \brief Vibration frequency. for most purupuru 4-59. */
+ uint8_t freq;
+ /** \brief Vibration inclination period. */
+ uint8_t inc;
+ };
} purupuru_effect_t;
-/* Set one of each of the following in the effect2 field of the
- purupuru_effect_t. Valid values for each are 0-7. The LINTENSITY
- value works with the INTENSITY of effect1 to increase the intensity
- of the rumble, where UINTENSITY apparently lowers the rumble's
- intensity somewhat. */
+_Static_assert(sizeof(purupuru_effect_t) == 4, "Invalid effect size");
-/** \brief Upper-nibble of effect2 convenience macro.
-
- This macro is for setting the upper nibble of the effect2 field of the
- purupuru_effect_t. This apparently lowers the rumble's intensity somewhat.
- Valid values are 0-7.
-*/
-#define PURUPURU_EFFECT2_UINTENSITY(x) (x << 4)
-
-/** \brief Lower-nibble of effect2 convenience macro.
-
- This macro is for setting the lower nibble of the effect2 field of the
- purupuru_effect_t. This value works with the upper nibble of the effect1
- field to increase the intensity of the rumble effect. Valid values are 0-7.
-
- \see PURUPURU_EFFECT1_INTENSITY
-*/
-#define PURUPURU_EFFECT2_LINTENSITY(x) (x)
+ /* Compat */
+static inline uint32_t __depr("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT2_UINTENSITY(uint8_t x) {return (x << 4);}
+static inline uint32_t __depr("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT2_LINTENSITY(uint8_t x) {return (x);}
+static inline uint32_t __depr("Please see purupuru_effect_t for modern equivalent.") PURUPURU_EFFECT1_INTENSITY(uint8_t x) {return (x << 4);}
-/* OR these in with your effect2 value if you feel so inclined.
- if you or the PULSE effect in here, you probably should also
- do so with the effect1 one below. */
-/** \brief Give a decay effect to the rumble on some packs. */
-#define PURUPURU_EFFECT2_DECAY (8 << 4)
-
-/** \brief Give a pulse effect to the rumble.
-
- This probably should be used with PURUPURU_EFFECT1_PULSE as well.
-
- \see PURUPURU_EFFECT1_PULSE
-*/
-#define PURUPURU_EFFECT2_PULSE (8)
-
-/* Set one value for this in the effect1 field of the effect structure. */
-/** \brief Upper nibble of effect1 convenience macro.
-
- This macro is for setting the upper nibble of the effect1 field of the
- purupuru_effect_t. This value works with the lower nibble of the effect2
- field to increase the intensity of the rumble effect. Valid values are 0-7.
-
- \see PURUPURU_EFFECT2_LINTENSITY
-*/
-#define PURUPURU_EFFECT1_INTENSITY(x) (x << 4)
-
-/* OR these in with your effect1 value, if you need them. PULSE
- should probably be used with the PULSE in effect2, as well.
- POWERSAVE will probably make your purupuru ignore that command. */
-/** \brief Give a pulse effect to the rumble.
-
- This probably should be used with PURUPURU_EFFECT2_PULSE as well.
-
- \see PURUPURU_EFFECT2_PULSE
-*/
-#define PURUPURU_EFFECT1_PULSE (8 << 4)
-
-/** \brief Ignore this command.
-
- Most jump packs will ignore commands with this set in effect1, apparently.
-*/
-#define PURUPURU_EFFECT1_POWERSAVE (15)
-
-/* Special Effects and motor select. The normal purupuru packs will
- only have one motor. Selecting MOTOR2 for these is probably not
- a good idea. The PULSE setting here supposably creates a sharp
- pulse effect, when ORed with the special field. */
-/** \brief Select motor #1.
-
- Most jump packs only have one motor, but on things that do have more than
- one motor (like PS1->Dreamcast controller adapters that support rumble),
- this selects the first motor.
-*/
-#define PURUPURU_SPECIAL_MOTOR1 (1 << 4)
-
-/** \brief Select motor #2.
-
- Most jump packs only have one motor, but on things that do have more than
- one motor (like PS1->Dreamcast controller adapters that support rumble),
- this selects the second motor.
-*/
-#define PURUPURU_SPECIAL_MOTOR2 (1 << 7)
-
-/** \brief Yet another pulse effect.
-
- This supposedly creates a sharp pulse effect.
-*/
-#define PURUPURU_SPECIAL_PULSE (1)
+static const uint8_t PURUPURU_EFFECT2_DECAY __depr("Please see purupuru_effect_t for modern equivalent.") = (8 << 4);
+static const uint8_t PURUPURU_EFFECT2_PULSE __depr("Please see purupuru_effect_t for modern equivalent.") = (8);
+static const uint8_t PURUPURU_EFFECT1_PULSE __depr("Please see purupuru_effect_t for modern equivalent.") = (8 << 4);
+static const uint8_t PURUPURU_EFFECT1_POWERSAVE __depr("Please see purupuru_effect_t for modern equivalent.") = (15);
+static const uint8_t PURUPURU_SPECIAL_MOTOR1 __depr("Please see purupuru_effect_t for modern equivalent.") = (1 << 4);
+static const uint8_t PURUPURU_SPECIAL_MOTOR2 __depr("Please see purupuru_effect_t for modern equivalent.") = (1 << 7);
+static const uint8_t PURUPURU_SPECIAL_PULSE __depr("Please see purupuru_effect_t for modern equivalent.") = (1);
/** \brief Send an effect to a jump pack.
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 10:03:46
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 3a34e9a1c7fcee85e39b4b48f8472ecbd36e536e (commit)
via fddc6395b0c44c127d1144326bf286dd42eb134e (commit)
via 60cf12b9bfd3db31bd17e9fe9201a643e2baf4c3 (commit)
via 66efbf093368c9cdbf0e550c4c5201c4b70040c0 (commit)
via 547b84227269323a9d31850d4c33432401ba2851 (commit)
via 761d8ae1d2bf51840288a9518d326478a131595a (commit)
via c59c45ca4536a5c48eecd35630bb638fd18427fc (commit)
from ab8b89e33c5e6ccb9e9c898554f10460e9019330 (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 3a34e9a1c7fcee85e39b4b48f8472ecbd36e536e
Author: Paul Cercueil <pa...@cr...>
Date: Wed May 21 13:39:51 2025 +0200
mutex: Unlock without disabling interrupts
To unlock a mutex, all we need to do is to set its holder pointer to
NULL. Since it can be done with a single 32-bit write, this is by
definition an atomic operation, and does not need locking.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit fddc6395b0c44c127d1144326bf286dd42eb134e
Author: Paul Cercueil <pa...@cr...>
Date: Wed May 21 12:15:52 2025 +0200
mutex: Try to lock without disabling interrupts
Use an atomic compare-and-swap to set the current thread as the lock
owner, instead of going through disabling interrupts.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 60cf12b9bfd3db31bd17e9fe9201a643e2baf4c3
Author: Paul Cercueil <pa...@cr...>
Date: Wed May 21 12:13:01 2025 +0200
mutex: Move recursive/errcheck tests outside critical section
When the lock's holder is the current thread, we do not need IRQs to be
disabled to update the lock's counter, because a thread is not going to
race with itself.
Note how mutex_lock() now calls mutex_trylock() to factorize the code
(including the assert() call).
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 66efbf093368c9cdbf0e550c4c5201c4b70040c0
Author: Paul Cercueil <pa...@cr...>
Date: Wed Sep 3 12:09:08 2025 +0200
mutex: Forbid recursive mutexes with mutex_unlock_as_thread()
Recursive mutexes are never used with mutex_unlock_as_thread(), and we
want to enforce that now with an assert().
Forbiding recursive mutexes with this function will allow further
optimizations later.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 547b84227269323a9d31850d4c33432401ba2851
Author: Paul Cercueil <pa...@cr...>
Date: Wed May 21 12:11:10 2025 +0200
mutex: Check mutex type using assert()
The case where the mutex type is not supported is never supposed to
happen. Therefore it makes sense to use an assert() call, so that this
code can be dropped on release builds.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 761d8ae1d2bf51840288a9518d326478a131595a
Author: Paul Cercueil <pa...@cr...>
Date: Mon Sep 1 12:22:10 2025 +0200
pthreads: Runtime-check mutex type before locking
The KOS mutexes will use an assert() to verify that the mutex type is
supported. To keep compatibility with the pthreads ABI, we need to move
the checks there.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit c59c45ca4536a5c48eecd35630bb638fd18427fc
Author: Paul Cercueil <pa...@cr...>
Date: Mon Sep 1 12:17:13 2025 +0200
libc: Runtime-check mutex type before locking
The KOS mutexes will use an assert() to verify that the mutex type is
supported. To keep compatibility with the C11 ABI, we need to move the
checks there.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
addons/libpthread/pthread_mutex_lock.c | 3 +
addons/libpthread/pthread_mutex_timedlock.c | 3 +
addons/libpthread/pthread_mutex_trylock.c | 3 +
include/kos/mutex.h | 7 +-
kernel/libc/c11/mtx_lock.c | 6 ++
kernel/libc/c11/mtx_timedlock.c | 5 ++
kernel/libc/c11/mtx_trylock.c | 5 ++
kernel/thread/mutex.c | 120 ++++++++++------------------
8 files changed, 71 insertions(+), 81 deletions(-)
diff --git a/addons/libpthread/pthread_mutex_lock.c b/addons/libpthread/pthread_mutex_lock.c
index c9996982..89ea42ba 100644
--- a/addons/libpthread/pthread_mutex_lock.c
+++ b/addons/libpthread/pthread_mutex_lock.c
@@ -13,6 +13,9 @@
int pthread_mutex_lock(pthread_mutex_t *mutex) {
int old, rv = 0;
+ if(mutex->mutex.type > MUTEX_TYPE_RECURSIVE)
+ return EINVAL;
+
old = errno;
if(mutex_lock(&mutex->mutex))
rv = errno;
diff --git a/addons/libpthread/pthread_mutex_timedlock.c b/addons/libpthread/pthread_mutex_timedlock.c
index 26dc5061..b1ee3561 100644
--- a/addons/libpthread/pthread_mutex_timedlock.c
+++ b/addons/libpthread/pthread_mutex_timedlock.c
@@ -21,6 +21,9 @@ int pthread_mutex_timedlock(pthread_mutex_t *__RESTRICT mutex,
if(!mutex || !abstime)
return EFAULT;
+ if(mutex->mutex.type > MUTEX_TYPE_RECURSIVE)
+ return EINVAL;
+
if(abstime->tv_nsec < 0 || abstime->tv_nsec > 1000000000L)
return EINVAL;
diff --git a/addons/libpthread/pthread_mutex_trylock.c b/addons/libpthread/pthread_mutex_trylock.c
index 2af75c23..4271483f 100644
--- a/addons/libpthread/pthread_mutex_trylock.c
+++ b/addons/libpthread/pthread_mutex_trylock.c
@@ -13,6 +13,9 @@
int pthread_mutex_trylock(pthread_mutex_t *mutex) {
int old, rv = 0;
+ if(mutex->mutex.type > MUTEX_TYPE_RECURSIVE)
+ return EINVAL;
+
old = errno;
if(mutex_trylock(&mutex->mutex))
rv = errno;
diff --git a/include/kos/mutex.h b/include/kos/mutex.h
index c2f467e9..1f5529e7 100644
--- a/include/kos/mutex.h
+++ b/include/kos/mutex.h
@@ -148,7 +148,6 @@ int mutex_destroy(mutex_t *m) __nonnull_all;
\par Error Conditions:
\em EPERM - called inside an interrupt \n
- \em EINVAL - the mutex has not been initialized properly \n
\em EAGAIN - lock has been acquired too many times (recursive) \n
\em EDEADLK - would deadlock (error-checking)
*/
@@ -169,7 +168,6 @@ int mutex_lock(mutex_t *m) __nonnull_all;
\retval -1 On error, sets errno as appropriate
\par Error Conditions:
- \em EINVAL - the mutex has not been initialized properly \n
\em EAGAIN - lock has been acquired too many times (recursive), or the
function was called inside an interrupt and the mutex was
already locked \n
@@ -192,7 +190,6 @@ int mutex_lock_irqsafe(mutex_t *m) __nonnull_all;
\par Error Conditions:
\em EPERM - called inside an interrupt \n
- \em EINVAL - the mutex has not been initialized properly \n
\em EINVAL - the timeout value was invalid (less than 0) \n
\em ETIMEDOUT - the timeout expired \n
\em EAGAIN - lock has been acquired too many times (recursive) \n
@@ -227,7 +224,6 @@ int __pure mutex_is_locked(const mutex_t *m) __nonnull_all;
\par Error Conditions:
\em EBUSY - the mutex is already locked (mutex_lock() would block) \n
- \em EINVAL - the mutex has not been initialized properly \n
\em EAGAIN - lock has been acquired too many times (recursive) \n
\em EDEADLK - would deadlock (error-checking)
*/
@@ -252,7 +248,8 @@ int mutex_unlock(mutex_t *m) __nonnull_all;
This function allows an IRQ handler to unlock a mutex that was locked by a
normal kernel thread. This function is only for use in IRQ handlers, so it
- will generally not be of much use outside of the kernel itself.
+ will generally not be of much use outside of the kernel itself. It cannot
+ be used with recursive mutexes.
\param m The mutex to unlock
\param thd The thread owning the mutex
diff --git a/kernel/libc/c11/mtx_lock.c b/kernel/libc/c11/mtx_lock.c
index 6e478cd4..a496f455 100644
--- a/kernel/libc/c11/mtx_lock.c
+++ b/kernel/libc/c11/mtx_lock.c
@@ -4,8 +4,14 @@
Copyright (C) 2014 Lawrence Sebald
*/
+#include <errno.h>
#include <threads.h>
int mtx_lock(mtx_t *mtx) {
+ if(mtx->type > MUTEX_TYPE_RECURSIVE) {
+ errno = EINVAL;
+ return -1;
+ }
+
return mutex_lock(mtx);
}
diff --git a/kernel/libc/c11/mtx_timedlock.c b/kernel/libc/c11/mtx_timedlock.c
index 1939bc7d..4fba4b4b 100644
--- a/kernel/libc/c11/mtx_timedlock.c
+++ b/kernel/libc/c11/mtx_timedlock.c
@@ -10,6 +10,11 @@
int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts) {
int ms = 0;
+ if(mtx->type > MUTEX_TYPE_RECURSIVE) {
+ errno = EINVAL;
+ return -1;
+ }
+
/* Calculate the number of milliseconds to sleep for. No, you don't get
anywhere near nanosecond precision here. */
ms = ts->tv_sec * 1000 + ts->tv_nsec / 1000000;
diff --git a/kernel/libc/c11/mtx_trylock.c b/kernel/libc/c11/mtx_trylock.c
index eead66a0..7567d024 100644
--- a/kernel/libc/c11/mtx_trylock.c
+++ b/kernel/libc/c11/mtx_trylock.c
@@ -8,6 +8,11 @@
#include <errno.h>
int mtx_trylock(mtx_t *mtx) {
+ if(mtx->type > MUTEX_TYPE_RECURSIVE) {
+ errno = EINVAL;
+ return -1;
+ }
+
if(mutex_trylock(mtx)) {
if(errno == EBUSY)
return thrd_busy;
diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c
index 30772ade..617b0760 100644
--- a/kernel/thread/mutex.c
+++ b/kernel/thread/mutex.c
@@ -6,6 +6,8 @@
*/
+#include <assert.h>
+#include <stdatomic.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
@@ -84,28 +86,16 @@ int mutex_lock_timed(mutex_t *m, int timeout) {
return -1;
}
+ rv = mutex_trylock(m);
+ if(!rv || errno != EBUSY)
+ return rv;
+
irq_disable_scoped();
- if(m->type > MUTEX_TYPE_RECURSIVE) {
- errno = EINVAL;
- rv = -1;
- }
- else if(!m->count) {
+ if(!m->holder) {
m->count = 1;
m->holder = thd_current;
- }
- else if(m->type == MUTEX_TYPE_RECURSIVE && m->holder == thd_current) {
- if(m->count == INT_MAX) {
- errno = EAGAIN;
- rv = -1;
- }
- else {
- ++m->count;
- }
- }
- else if(m->type == MUTEX_TYPE_ERRORCHECK && m->holder == thd_current) {
- errno = EDEADLK;
- rv = -1;
+ rv = 0;
}
else {
if(timeout)
@@ -153,79 +143,59 @@ int mutex_lock_timed(mutex_t *m, int timeout) {
}
int __pure mutex_is_locked(const mutex_t *m) {
- return !!m->count;
+ return !!m->holder;
}
int mutex_trylock(mutex_t *m) {
- kthread_t *thd = thd_current;
+ kthread_t *thd = thd_current, *thd_none = NULL;
- irq_disable_scoped();
+ assert(m->type <= MUTEX_TYPE_RECURSIVE);
/* If we're inside of an interrupt, pick a special value for the thread that
would otherwise be impossible... */
if(irq_inside_int())
thd = IRQ_THREAD;
- if(m->type > MUTEX_TYPE_RECURSIVE) {
- errno = EINVAL;
- return -1;
- }
-
- /* Check if the lock is held by some other thread already */
- if(m->count && m->holder != thd) {
- errno = EBUSY;
- return -1;
- }
-
- m->holder = thd;
-
- switch(m->type) {
- case MUTEX_TYPE_NORMAL:
- case MUTEX_TYPE_OLDNORMAL:
- case MUTEX_TYPE_ERRORCHECK:
- if(m->count) {
- errno = EDEADLK;
- return -1;
- }
-
- m->count = 1;
- break;
+ if(m->holder == thd) {
+ if(m->type == MUTEX_TYPE_ERRORCHECK) {
+ errno = EDEADLK;
+ return -1;
+ }
- case MUTEX_TYPE_RECURSIVE:
+ if(m->type == MUTEX_TYPE_RECURSIVE) {
if(m->count == INT_MAX) {
errno = EAGAIN;
return -1;
}
++m->count;
- break;
+ return 0;
+ }
}
- return 0;
+ if(atomic_compare_exchange_strong(&m->holder, &thd_none, thd)) {
+ m->count = 1;
+ return 0;
+ }
+
+ /* We did not get the lock */
+ errno = EBUSY;
+ return -1;
}
static int __nonnull_all mutex_unlock_common(mutex_t *m, kthread_t *thd) {
- int wakeup = 0;
-
- irq_disable_scoped();
-
switch(m->type) {
- case MUTEX_TYPE_NORMAL:
- case MUTEX_TYPE_OLDNORMAL:
- m->count = 0;
- m->holder = NULL;
- wakeup = 1;
- break;
-
case MUTEX_TYPE_ERRORCHECK:
if(m->holder != thd) {
errno = EPERM;
return -1;
}
-
+ __fallthrough;
+ default:
+ case MUTEX_TYPE_NORMAL:
+ case MUTEX_TYPE_OLDNORMAL:
m->count = 0;
m->holder = NULL;
- wakeup = 1;
break;
case MUTEX_TYPE_RECURSIVE:
@@ -234,25 +204,19 @@ static int __nonnull_all mutex_unlock_common(mutex_t *m, kthread_t *thd) {
return -1;
}
- if(!--m->count) {
- m->holder = NULL;
- wakeup = 1;
- }
- break;
+ if(--m->count)
+ return 0;
- default:
- errno = EINVAL;
- return -1;
+ m->holder = NULL;
+ break;
}
- /* If we need to wake up a thread, do so. */
- if(wakeup) {
- /* Restore real priority in case we were dynamically boosted. */
- if (thd != IRQ_THREAD)
- thd->prio = thd->real_prio;
+ /* Restore real priority in case we were dynamically boosted. */
+ if (thd != IRQ_THREAD)
+ thd->prio = thd->real_prio;
- genwait_wake_one(m);
- }
+ /* If we need to wake up a thread, do so. */
+ genwait_wake_one(m);
return 0;
}
@@ -260,6 +224,8 @@ static int __nonnull_all mutex_unlock_common(mutex_t *m, kthread_t *thd) {
int mutex_unlock(mutex_t *m) {
kthread_t *thd = thd_current;
+ assert(m->type <= MUTEX_TYPE_RECURSIVE);
+
/* If we're inside of an interrupt, use the special value for the thread
from mutex_trylock(). */
if(irq_inside_int())
@@ -269,6 +235,8 @@ int mutex_unlock(mutex_t *m) {
}
int mutex_unlock_as_thread(mutex_t *m, kthread_t *thd) {
+ assert(m->type < MUTEX_TYPE_RECURSIVE); /* Unsafe with recursive mutexes */
+
/* Make sure we're in an IRQ handler */
if(!irq_inside_int()) {
errno = EACCES;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-05 03:28:04
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via ab8b89e33c5e6ccb9e9c898554f10460e9019330 (commit)
from b4c45a947548022020173b1621efe4fe6a9ccb71 (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 ab8b89e33c5e6ccb9e9c898554f10460e9019330
Author: darc <da...@pr...>
Date: Thu Sep 4 15:52:37 2025 -0500
Fix kos_blockdev_t created by sd_blockdev_for_device()
The kos_blockdev_t created by sd_blockdev_for_device() is not filled
in with the template block device information, leading to all of the
data and pointers (besides dev_data) being uninitialized.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/sd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/arch/dreamcast/hardware/sd.c b/kernel/arch/dreamcast/hardware/sd.c
index 45c6b866..dc09e757 100644
--- a/kernel/arch/dreamcast/hardware/sd.c
+++ b/kernel/arch/dreamcast/hardware/sd.c
@@ -832,6 +832,8 @@ int sd_blockdev_for_device(kos_blockdev_t *rv) {
return -1;
}
+ /* Copy in the template block device and fill it in */
+ memcpy(rv, &sd_blockdev, sizeof(kos_blockdev_t));
ddata->start_block = 0;
ddata->block_count = (sd_get_size() / 512);
rv->dev_data = ddata;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-03 14:48:12
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via b4c45a947548022020173b1621efe4fe6a9ccb71 (commit)
via a42a8a5d84142ebd92825bd889c59bb3179a9db1 (commit)
from 1bd27cd8e7c8e65d7de3fbb21a02cee305cf6814 (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 b4c45a947548022020173b1621efe4fe6a9ccb71
Author: Paul Cercueil <pa...@cr...>
Date: Wed May 21 12:23:59 2025 +0200
environ: Switch to gUSA atomic model
Switch to the gUSA atomic model, which allows atomics to work without
having to mask interrupts.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit a42a8a5d84142ebd92825bd889c59bb3179a9db1
Author: Paul Cercueil <pa...@cr...>
Date: Sun May 19 13:33:46 2024 +0200
Add support for gUSA atomic model
Add support for the gUSA atomic model, which is what is used in the
Linux kernel. By specifying -matomic-model=soft-gusa, the gUSA atomic
model can now be used.
Instead of creating critical sections by masking interrupts, gUSA relies
on the scheduler detecting atomic sections, identified by the stack
pointer going negative, and rolling back to the beginning of the atomic
section if interrupted in the middle.
The minimal overhead added to the scheduler is balanced by the gains
recovered by not masking interrupts for every single atomic access.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
environ_dreamcast.sh | 2 +-
kernel/arch/dreamcast/kernel/irq.c | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh
index 7dd3e872..e947323b 100644
--- a/environ_dreamcast.sh
+++ b/environ_dreamcast.sh
@@ -24,7 +24,7 @@ if [ -z "${KOS_SH4_PRECISION}" ] || [ "${KOS_SH4_PRECISION}" = "-m4-single" ]; t
fi
fi
-export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_SH4_PRECISION} -ml -mfsrra -mfsca -ffunction-sections -fdata-sections -matomic-model=soft-imask -ftls-model=local-exec"
+export KOS_CFLAGS="${KOS_CFLAGS} ${KOS_SH4_PRECISION} -ml -mfsrra -mfsca -ffunction-sections -fdata-sections -matomic-model=soft-gusa -ftls-model=local-exec"
export KOS_AFLAGS="${KOS_AFLAGS} -little"
export KOS_LDFLAGS="${KOS_LDFLAGS} ${KOS_SH4_PRECISION} -ml -Wl,--gc-sections"
export KOS_LD_SCRIPT="-T${KOS_BASE}/utils/ldscripts/shlelf.xc"
diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c
index c8a23011..3e3be5a8 100644
--- a/kernel/arch/dreamcast/kernel/irq.c
+++ b/kernel/arch/dreamcast/kernel/irq.c
@@ -216,6 +216,16 @@ void irq_handle_exception(int code) {
uint32_t evt = 0;
int handled = 0;
+ if(__is_defined(__SH_ATOMIC_MODEL_SOFT_GUSA__)
+ && __unlikely((int32_t)irq_srt_addr->r[15] >= -128
+ && irq_srt_addr->pc != irq_srt_addr->r[0])) {
+ /* The stack pointer has been altered: it means we are in the middle of
+ an atomic section, and we need to roll-back.
+ The r0 register contains the address of the end of the section,
+ and the stack pointer contains the negated section size. */
+ irq_srt_addr->pc = irq_srt_addr->r[0] + irq_srt_addr->r[15];
+ }
+
switch(code) {
/* If it's a code 3, grab the event from intevt. */
case 3:
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-02 19:15: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 1bd27cd8e7c8e65d7de3fbb21a02cee305cf6814 (commit)
from 36687707d91a7e99cc2a71b6ffc86f861be5e1d9 (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 1bd27cd8e7c8e65d7de3fbb21a02cee305cf6814
Author: Paul Cercueil <pa...@cr...>
Date: Mon Sep 1 16:40:06 2025 +0200
dc-chain: Remove fake-kos.o from all libgcc.a
When building a multilib toolchain, for instance to support
-m4-single-only and -m4-single, multiple variants of libgcc.a are built.
We need to remove the fake-kos.o object from all of them.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
utils/dc-chain/scripts/gcc-pass2.mk | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/utils/dc-chain/scripts/gcc-pass2.mk b/utils/dc-chain/scripts/gcc-pass2.mk
index 6c6750a3..23be6b12 100644
--- a/utils/dc-chain/scripts/gcc-pass2.mk
+++ b/utils/dc-chain/scripts/gcc-pass2.mk
@@ -1,6 +1,9 @@
# Sega Dreamcast Toolchains Maker (dc-chain)
# This file is part of KallistiOS.
+__comma:=,
+__libgcc=$(foreach item,$(addprefix -,$(subst $(__comma), ,$(precision_modes))) "",$(shell $(toolchain_path)/bin/$(target)-gcc $(item) -print-file-name=libgcc.a))
+
$(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver)-pass2
$(build_gcc_pass2): logdir
@echo "+++ Building $(src_dir) to $(build) (pass 2)..."
@@ -32,7 +35,7 @@ ifdef enable_ada
endif
endif
$(MAKE) -C $(build) $(install_mode) DESTDIR=$(DESTDIR) $(to_log)
- $(toolchain_path)/bin/$(target)-gcc-ar d \
- $(shell $(toolchain_path)/bin/$(target)-gcc -print-file-name=libgcc.a) \
- fake-kos.o $(to_log)
+ for each in $(__libgcc) ; do \
+ $(toolchain_path)/bin/$(target)-gcc-ar d $$each fake-kos.o $(to_log) ; \
+ done
$(clean_up)
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-09-02 06:37:49
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 36687707d91a7e99cc2a71b6ffc86f861be5e1d9 (commit)
via e670f29becfa28d289e8651702fe88f579825a23 (commit)
via 2f8991c0157fca007a6335b2aaaccd2820da25d9 (commit)
from 1d3584ab7c0bcdc90a92ef0058a9554cd203d428 (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 36687707d91a7e99cc2a71b6ffc86f861be5e1d9
Author: Paul Cercueil <pa...@cr...>
Date: Wed Aug 27 19:14:50 2025 +0200
Deprecate <arch/byteorder.h>
Deprecate the <arch/byteorder.h> header, and all its contents.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit e670f29becfa28d289e8651702fe88f579825a23
Author: Paul Cercueil <pa...@cr...>
Date: Wed Aug 27 15:02:28 2025 +0200
Make htons/htonl/ntohs/ntohl static inline in <arpa/inet.h>
Inline their implementation in <arpa/inet.h> instead of having their
implementation in a different C file.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 2f8991c0157fca007a6335b2aaaccd2820da25d9
Author: Paul Cercueil <pa...@cr...>
Date: Mon Aug 18 23:16:07 2025 +0200
Drop endian stuff from <arch/types.h>
This is not used anywhere.
The argument to add it was to fix a libtremor build issue; however the
current libtremor in kos-ports will build just fine with those removed.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
include/arpa/inet.h | 16 +++++++++----
kernel/arch/dreamcast/include/arch/byteorder.h | 6 +++++
kernel/arch/dreamcast/include/arch/types.h | 10 ---------
kernel/libc/koslib/Makefile | 2 +-
kernel/libc/koslib/byteorder.c | 31 --------------------------
5 files changed, 19 insertions(+), 46 deletions(-)
delete mode 100644 kernel/libc/koslib/byteorder.c
diff --git a/include/arpa/inet.h b/include/arpa/inet.h
index 7653b2ad..48b50115 100644
--- a/include/arpa/inet.h
+++ b/include/arpa/inet.h
@@ -40,25 +40,33 @@ __BEGIN_DECLS
\param value The value to convert.
\return value converted to network byte order.
*/
-uint32_t htonl(uint32_t value);
+static inline uint32_t htonl(uint32_t value) {
+ return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? value : __builtin_bswap32(value);
+}
/** \brief Convert a 32-bit value from network byte order to host byte order.
\param value The value to convert.
\return value converted to host byte order.
*/
-uint32_t ntohl(uint32_t value);
+static inline uint32_t ntohl(uint32_t value) {
+ return htonl(value);
+}
/** \brief Convert a 16-bit value from host byte order to network byte order.
\param value The value to convert.
\return value converted to network byte order.
*/
-uint16_t htons(uint16_t value);
+static inline uint16_t htons(uint16_t value) {
+ return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ? value : __builtin_bswap16(value);
+}
/** \brief Convert a 16-bit value from network byte order to host byte order.
\param value The value to convert.
\return value converted to host byte order.
*/
-uint16_t ntohs(uint16_t value);
+static inline uint16_t ntohs(uint16_t value) {
+ return htons(value);
+}
/** \brief Convert a string representation of an IPv4 address to an in_addr_t.
diff --git a/kernel/arch/dreamcast/include/arch/byteorder.h b/kernel/arch/dreamcast/include/arch/byteorder.h
index ebfc03d4..2d352621 100644
--- a/kernel/arch/dreamcast/include/arch/byteorder.h
+++ b/kernel/arch/dreamcast/include/arch/byteorder.h
@@ -49,6 +49,7 @@ __BEGIN_DECLS
or equivalent.
\return The swapped value.
*/
+__depr("arch_swap16() is deprecated, use __builtin_bswap16().")
static inline uint16_t arch_swap16(uint16_t x) {
return __builtin_bswap16(x);
}
@@ -62,6 +63,7 @@ static inline uint16_t arch_swap16(uint16_t x) {
or equivalent.
\return The swapped value.
*/
+__depr("arch_swap32() is deprecated, use __builtin_bswap32().")
static inline uint32_t arch_swap32(uint32_t x) {
return __builtin_bswap32(x);
}
@@ -77,6 +79,7 @@ static inline uint32_t arch_swap32(uint32_t x) {
or equivalent.
\return The converted value.
*/
+__depr("arch_ntohs() is deprecated, use ntohs() from <arpa/inet.h>")
static inline uint16_t arch_ntohs(uint16_t x) {
return __builtin_bswap16(x);
}
@@ -92,6 +95,7 @@ static inline uint16_t arch_ntohs(uint16_t x) {
or equivalent.
\return The converted value.
*/
+__depr("arch_ntohl() is deprecated, use ntohl() from <arpa/inet.h>")
static inline uint32_t arch_ntohl(uint32_t x) {
return __builtin_bswap32(x);
}
@@ -107,6 +111,7 @@ static inline uint32_t arch_ntohl(uint32_t x) {
or equivalent.
\return The converted value.
*/
+__depr("arch_htons() is deprecated, use htons() from <arpa/inet.h>")
static inline uint16_t arch_htons(uint16_t x) {
return __builtin_bswap16(x);
}
@@ -122,6 +127,7 @@ static inline uint16_t arch_htons(uint16_t x) {
or equivalent.
\return The converted value.
*/
+__depr("arch_htonl() is deprecated, use htonl() from <arpa/inet.h>")
static inline uint32_t arch_htonl(uint32_t x) {
return __builtin_bswap32(x);
}
diff --git a/kernel/arch/dreamcast/include/arch/types.h b/kernel/arch/dreamcast/include/arch/types.h
index d9065fba..295bc031 100644
--- a/kernel/arch/dreamcast/include/arch/types.h
+++ b/kernel/arch/dreamcast/include/arch/types.h
@@ -57,16 +57,6 @@ typedef int handle_t; /**< \brief Generic "handle" type */
typedef handle_t tid_t; /**< \brief Thread ID type */
typedef handle_t prio_t; /**< \brief Priority value type */
-#ifndef BYTE_ORDER
-/* Make sure to pull in the base endianness defines... */
-#ifndef LITTLE_ENDIAN
-#include <sys/_types.h>
-#endif
-
-/** \brief Endianness definition -- Little Endian */
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
/** @} */
__END_DECLS
diff --git a/kernel/libc/koslib/Makefile b/kernel/libc/koslib/Makefile
index 081d0102..1b39491d 100644
--- a/kernel/libc/koslib/Makefile
+++ b/kernel/libc/koslib/Makefile
@@ -7,7 +7,7 @@
# In here we have pieces of the KOS libc that are either too custom or too
# useful in the context of KOS to go with the Newlib defaults.
-OBJS = abort.o byteorder.o memset2.o memset4.o memcpy2.o memcpy4.o \
+OBJS = abort.o memset2.o memset4.o memcpy2.o memcpy4.o \
assert.o dbglog.o malloc.o \
opendir.o readdir.o closedir.o rewinddir.o scandir.o seekdir.o \
telldir.o usleep.o inet_addr.o realpath.o getcwd.o chdir.o mkdir.o \
diff --git a/kernel/libc/koslib/byteorder.c b/kernel/libc/koslib/byteorder.c
deleted file mode 100644
index 3e00a4e9..00000000
--- a/kernel/libc/koslib/byteorder.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* KallistiOS ##version##
-
- byteorder.c
- Copyright (C) 2001 Megan Potter
- Copyright (C) 2016 Lawrence Sebald
-
-*/
-
-/* Byte-order translation functions */
-#include <stdint.h>
-#include <arch/byteorder.h>
-
-/* Network to Host short */
-uint16_t ntohs(uint16_t value) {
- return arch_ntohs(value);
-}
-
-/* Network to Host long */
-uint32_t ntohl(uint32_t value) {
- return arch_ntohl(value);
-}
-
-/* Host to Network short */
-uint16_t htons(uint16_t value) {
- return arch_htons(value);
-}
-
-/* Host to Network long */
-uint32_t htonl(uint32_t value) {
- return arch_htonl(value);
-}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-31 21:15: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 pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 1d3584ab7c0bcdc90a92ef0058a9554cd203d428 (commit)
from e36c93953498011fd1216ddd5a951be6452167a7 (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 1d3584ab7c0bcdc90a92ef0058a9554cd203d428
Author: Ruslan Rostovtsev <sw...@21...>
Date: Mon Sep 1 04:15:22 2025 +0700
iso9660: Fix streaming DMA alignment and data corruption. (#1173)
- Fixed DMA Crash: Replaced `malloc` with `aligned_alloc` in `iso_open` to ensure the
file handle's internal DMA buffer is always 32-byte aligned, preventing
"Unaligned memory" errors.
- Fixed Data Corruption: Corrected the logic in `iso_read` to properly handle leftover
data in the stream buffer between reads. This prevents data from being skipped
when a small read is followed by a larger one.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/fs/fs_iso9660.c | 46 +++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c
index 7c745482..67642e9d 100644
--- a/kernel/arch/dreamcast/fs/fs_iso9660.c
+++ b/kernel/arch/dreamcast/fs/fs_iso9660.c
@@ -616,6 +616,7 @@ static inline void iso_abort_stream(bool lock) {
mutex_lock(&fh_mutex);
cdrom_stream_stop(false);
+ stream_fd->stream_part = 0;
stream_fd = NULL;
if(lock)
@@ -652,7 +653,7 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
return 0;
}
- fd = malloc(sizeof(*fd));
+ fd = aligned_alloc(32, sizeof(*fd));
if(!fd) {
errno = ENOMEM;
return 0;
@@ -694,7 +695,8 @@ static int iso_close(void * h) {
/* Read from a file */
static ssize_t iso_read(void * h, void *buf, size_t bytes) {
- int rv, toread, thissect, c;
+ int rv, c;
+ size_t toread, thissect;
uint8 * outbuf;
size_t remain_size = 0, req_size;
uint32_t sector;
@@ -717,6 +719,23 @@ static ssize_t iso_read(void * h, void *buf, size_t bytes) {
if(toread == 0) break;
+ /* If we have partial data from a stream, use it */
+ if(fd->stream_part > 0) {
+ size_t avail = 32 - fd->stream_part;
+ size_t given = (toread > avail) ? avail : toread;
+
+ memcpy(outbuf, &fd->stream_data[fd->stream_part], given);
+ fd->stream_part = (fd->stream_part + given) & 31;
+
+ outbuf += given;
+ fd->ptr += given;
+ bytes -= given;
+ rv += given;
+ toread -= given;
+
+ if(toread == 0) continue;
+ }
+
/* How much more can we read in the current sector? */
thissect = 2048 - (fd->ptr % 2048);
sector = fd->first_extent + (fd->ptr / 2048);
@@ -778,21 +797,18 @@ static ssize_t iso_read(void * h, void *buf, size_t bytes) {
toread = (toread > thissect) ? thissect : toread;
- if(fd->stream_part > 0) {
- memcpy(outbuf, &fd->stream_data[fd->stream_part - 1], toread);
- fd->stream_part = 0;
+ c = cdrom_stream_request(fd->stream_data, 32, 0);
+ if(c) {
+ goto read_error;
}
- else {
- c = cdrom_stream_request(fd->stream_data, 32, 0);
- if(c) {
- goto read_error;
- }
- fd->stream_part = toread;
- while(cdrom_stream_progress(&remain_size) == 1) {
- thd_pass();
- }
- memcpy(outbuf, fd->stream_data, toread);
+
+ while(cdrom_stream_progress(&remain_size) == 1) {
+ thd_pass();
}
+
+ memcpy(outbuf, fd->stream_data, toread);
+ fd->stream_part = toread & 31;
+
// dbglog(DBG_DEBUG, "Stream request: read=%d remain=%d part=%d out=%p fd=%p\n",
// toread, remain_size, fd->stream_part, outbuf, fd);
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-30 20:35:10
|
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 e36c93953498011fd1216ddd5a951be6452167a7 (commit)
from 857e4e69bd02f6df827a339cb0260c90c746d566 (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 e36c93953498011fd1216ddd5a951be6452167a7
Author: Paul Cercueil <pa...@cr...>
Date: Sat Aug 30 14:14:23 2025 +0200
CI: Fix overzealous whitespace check
The previous check would quite often cause false positives. Reduce the
scope of the check, now it only verifies that no spaces are added at the
end of lines.
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
.github/workflows/whitespace.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/whitespace.yml b/.github/workflows/whitespace.yml
index 79027b72..a4a5b2d9 100644
--- a/.github/workflows/whitespace.yml
+++ b/.github/workflows/whitespace.yml
@@ -14,5 +14,5 @@ jobs:
run: |
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
git diff ${{ github.base_ref }} >/tmp/diff1.txt
- git diff -w ${{ github.base_ref }} >/tmp/diff2.txt
+ git diff --ignore-space-at-eol ${{ github.base_ref }} >/tmp/diff2.txt
diff /tmp/diff1.txt /tmp/diff2.txt >/dev/null
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: kosmirror <kos...@us...> - 2025-08-29 15:08:44
|
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 857e4e69bd02f6df827a339cb0260c90c746d566 (commit)
from b2f9efc31f65b43f52d9db9d474685f386beef2e (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 857e4e69bd02f6df827a339cb0260c90c746d566
Author: darc <da...@pr...>
Date: Thu Aug 28 14:48:00 2025 -0500
Remove deprecated cdrom_change_dataype function
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/cdrom.c | 5 -----
kernel/arch/dreamcast/include/dc/cdrom.h | 11 -----------
2 files changed, 16 deletions(-)
diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c
index 9d6c0922..7b0766a9 100644
--- a/kernel/arch/dreamcast/hardware/cdrom.c
+++ b/kernel/arch/dreamcast/hardware/cdrom.c
@@ -311,11 +311,6 @@ int cdrom_get_status(int *status, int *disc_type) {
return rv;
}
-/* Helper function to account for long-standing typo */
-int cdrom_change_dataype(int sector_part, int cdxa, int sector_size) {
- return cdrom_change_datatype(sector_part, cdxa, sector_size);
-}
-
/* Wrapper for the change datatype syscall */
int cdrom_change_datatype(int sector_part, int cdxa, int sector_size) {
uint32_t params[4];
diff --git a/kernel/arch/dreamcast/include/dc/cdrom.h b/kernel/arch/dreamcast/include/dc/cdrom.h
index 370cc35d..93702202 100644
--- a/kernel/arch/dreamcast/include/dc/cdrom.h
+++ b/kernel/arch/dreamcast/include/dc/cdrom.h
@@ -347,17 +347,6 @@ int cdrom_abort_cmd(uint32_t timeout, bool abort_dma);
*/
int cdrom_get_status(int *status, int *disc_type);
-/** \brief Change the datatype of disc.
- \ingroup gdrom
-
- \note This function is formally deprecated. It should not
- be used in any future code, and may be removed in
- the future. You should instead use
- cdrom_change_datatype.
-*/
-int cdrom_change_dataype(int sector_part, int cdxa, int sector_size)
- __depr("Use cdrom_change_datatype instead.");
-
/** \brief Change the datatype of disc.
\ingroup gdrom
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|