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: quzar <qu...@us...> - 2024-07-05 06:57:22
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 4de3b94311fcff91f860c62cf565dd56dece209f (commit)
via dd953d2dcb233506f7292ce84a4e2cd2559ab913 (commit)
from d604fc0f7d2b5cbe181d940451592fd280b88caf (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 4de3b94311fcff91f860c62cf565dd56dece209f
Author: Andy Barajas <and...@gm...>
Date: Thu Jul 4 23:56:04 2024 -0700
Returned to some old ways of checking ref counts (#660)
* Roll back the behavior of fs_fdtbl_destroy to how it was, before PR #599. This ensures that both all fds are cleaned up and that it's safe for use with dup'd files.
* Have fs_shutdown run before shutting down any of the vfses.
* Rearrange fs_hnd_unref to ensure that it frees handles even if they have no handler.
commit dd953d2dcb233506f7292ce84a4e2cd2559ab913
Author: UnknownShadow200 <unk...@gm...>
Date: Thu Jul 4 12:50:21 2024 +1000
CDFS: Set errno on error (#652)
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/fs/fs_iso9660.c | 34 ++++++++++++++++++++++++++--------
kernel/arch/dreamcast/kernel/init.c | 2 +-
kernel/fs/fs.c | 30 ++++++++++--------------------
kernel/fs/fs_pty.c | 10 +++++-----
4 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c
index ce8e2cb8..f8445cad 100644
--- a/kernel/arch/dreamcast/fs/fs_iso9660.c
+++ b/kernel/arch/dreamcast/fs/fs_iso9660.c
@@ -603,19 +603,26 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
(void)vfs;
/* Make sure they don't want to open things as writeable */
- if((mode & O_MODE_MASK) != O_RDONLY)
+ if((mode & O_MODE_MASK) != O_RDONLY) {
+ errno = EROFS;
return 0;
+ }
/* Do this only when we need to (this is still imperfect) */
- if(!percd_done && init_percd() < 0)
+ if(!percd_done && init_percd() < 0) {
+ errno = ENODEV;
return 0;
+ }
percd_done = 1;
/* Find the file we want */
de = find_object_path(fn, (mode & O_DIR) ? 1 : 0, &root_dirent);
- if(!de) return 0;
+ if(!de) {
+ errno = ENOENT;
+ return 0;
+ }
/* Find a free file handle */
mutex_lock(&fh_mutex);
@@ -628,8 +635,10 @@ static void * iso_open(vfs_handler_t * vfs, const char *fn, int mode) {
mutex_unlock(&fh_mutex);
- if(fd >= FS_CD_MAX_FILES)
+ if(fd >= FS_CD_MAX_FILES) {
+ errno = ENFILE;
return 0;
+ }
/* Fill in the file handle and return the fd */
fh[fd].first_extent = iso_733(de->extent);
@@ -660,8 +669,10 @@ static ssize_t iso_read(void * h, void *buf, size_t bytes) {
file_t fd = (file_t)h;
/* Check that the fd is valid */
- if(fd >= FS_CD_MAX_FILES || fh[fd].first_extent == 0 || fh[fd].broken)
+ if(fd >= FS_CD_MAX_FILES || fh[fd].first_extent == 0 || fh[fd].broken) {
+ errno = EBADF;
return -1;
+ }
rv = 0;
outbuf = (uint8 *)buf;
@@ -707,7 +718,10 @@ static ssize_t iso_read(void * h, void *buf, size_t bytes) {
/* Do the read */
c = bdread(fh[fd].first_extent + fh[fd].ptr / 2048);
- if(c < 0) return -1;
+ if(c < 0) {
+ errno = EIO;
+ return -1;
+ }
memcpy(outbuf, dcache[c]->data + (fh[fd].ptr % 2048), toread);
/* } */
@@ -776,8 +790,10 @@ static off_t iso_seek(void * h, off_t offset, int whence) {
static off_t iso_tell(void * h) {
file_t fd = (file_t)h;
- if(fd >= FS_CD_MAX_FILES || fh[fd].first_extent == 0 || fh[fd].broken)
+ if(fd >= FS_CD_MAX_FILES || fh[fd].first_extent == 0 || fh[fd].broken) {
+ errno = EBADF;
return -1;
+ }
return fh[fd].ptr;
}
@@ -786,8 +802,10 @@ static off_t iso_tell(void * h) {
static size_t iso_total(void * h) {
file_t fd = (file_t)h;
- if(fd >= FS_CD_MAX_FILES || fh[fd].first_extent == 0 || fh[fd].broken)
+ if(fd >= FS_CD_MAX_FILES || fh[fd].first_extent == 0 || fh[fd].broken) {
+ errno = EBADF;
return -1;
+ }
return fh[fd].size;
}
diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c
index 1c6bbd4d..6c71b278 100644
--- a/kernel/arch/dreamcast/kernel/init.c
+++ b/kernel/arch/dreamcast/kernel/init.c
@@ -246,12 +246,12 @@ void __weak arch_auto_shutdown(void) {
#if defined(__NEWLIB__) && !(__NEWLIB__ < 2 && __NEWLIB_MINOR__ < 4)
fs_rnd_shutdown();
#endif
+ fs_shutdown();
fs_ramdisk_shutdown();
KOS_INIT_FLAG_CALL(fs_romdisk_shutdown);
fs_pty_shutdown();
fs_null_shutdown();
fs_dev_shutdown();
- fs_shutdown();
thd_shutdown();
rtc_shutdown();
}
diff --git a/kernel/fs/fs.c b/kernel/fs/fs.c
index a4e745b1..ee9b7e51 100644
--- a/kernel/fs/fs.c
+++ b/kernel/fs/fs.c
@@ -169,22 +169,18 @@ static void fs_hnd_ref(fs_hnd_t * ref) {
to a raw handle is no longer applicable. This function may destroy the
file handle, so under no circumstances should you presume that it will
still exist later. */
-static int fs_hnd_unref(fs_hnd_t * ref) {
+static int fs_hnd_unref(fs_hnd_t *ref) {
int retval = 0;
assert(ref);
assert(ref->refcnt > 0);
- ref->refcnt--;
- if(ref->refcnt == 0) {
- if(ref->handler != NULL) {
- if(ref->handler->close == NULL) return retval;
+ if(--ref->refcnt > 0)
+ return retval; /* Still references left, nothing to do */
- retval = ref->handler->close(ref->hnd);
- }
-
- free(ref);
- }
+ if(ref->handler && ref->handler->close)
+ retval = ref->handler->close(ref->hnd);
+ free(ref);
return retval;
}
@@ -214,17 +210,11 @@ static int fs_hnd_assign(fs_hnd_t * hnd) {
int fs_fdtbl_destroy(void) {
int i;
- for (i = 0; i < FD_SETSIZE; i++) {
- fs_hnd_t *handle = fd_table[i];
+ for(i = 0; i < FD_SETSIZE; i++) {
+ if(fd_table[i])
+ fs_hnd_unref(fd_table[i]);
- if(handle) {
- if(handle->handler && handle->handler->close) {
- handle->handler->close(handle->hnd);
- }
-
- free(handle);
- fd_table[i] = NULL;
- }
+ fd_table[i] = NULL;
}
return 0;
diff --git a/kernel/fs/fs_pty.c b/kernel/fs/fs_pty.c
index 55147fe4..27028ed1 100644
--- a/kernel/fs/fs_pty.c
+++ b/kernel/fs/fs_pty.c
@@ -108,7 +108,7 @@ static void pty_destroy_unused(void);
#define PF_DIR 1
/* Creates a pty pair */
-int fs_pty_create(char * buffer, int maxbuflen, file_t * master_out, file_t * slave_out) {
+int fs_pty_create(char *buffer, int maxbuflen, file_t *master_out, file_t *slave_out) {
ptyhalf_t *master, *slave;
int boot;
char mname[16], sname[16];
@@ -208,7 +208,7 @@ cleanup:
/* Autoclean totally unreferenced PTYs (zero refcnt). */
/* XXX This is a kinda nasty piece of code... goto!! */
static void pty_destroy_unused(void) {
- ptyhalf_t * c, * n;
+ ptyhalf_t *c, *n;
int old;
/* Make sure no one else is messing with the list and then disable
@@ -427,8 +427,8 @@ static void * pty_open(vfs_handler_t * vfs, const char * fn, int mode) {
}
/* Close pty or dirlist */
-static int pty_close(void * h) {
- pipefd_t * fdobj;
+static int pty_close(void *h) {
+ pipefd_t *fdobj;
assert(h);
fdobj = (pipefd_t *)h;
@@ -699,7 +699,7 @@ static int pty_ioctl(void *h, int cmd, va_list ap) {
switch (cmd) {
case TIOCGETA:
- if (arg == NULL) {
+ if(arg == NULL) {
errno = EINVAL;
return -1;
}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-07-04 00:04: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 d604fc0f7d2b5cbe181d940451592fd280b88caf (commit)
from 23ffc3ab18812cf77888bd079ad061de6e02c430 (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 d604fc0f7d2b5cbe181d940451592fd280b88caf
Author: Andy Barajas <and...@gm...>
Date: Wed Jul 3 17:04:02 2024 -0700
Fix pty compile errors and warnings (#657)
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/filesystem/pty/pty.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/examples/dreamcast/filesystem/pty/pty.c b/examples/dreamcast/filesystem/pty/pty.c
index 3ab0168a..56d9ed7e 100644
--- a/examples/dreamcast/filesystem/pty/pty.c
+++ b/examples/dreamcast/filesystem/pty/pty.c
@@ -15,10 +15,11 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
int main(int argc, char* argv[]) {
/* Create a PTY pair */
- file_t master_fd = NULL, slave_fd = NULL;
+ file_t master_fd = -1, slave_fd = -1;
int retval = EXIT_SUCCESS;
if(fs_pty_create(NULL, 0, &master_fd, &slave_fd) < 0) {
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-07-03 23:49:00
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 23ffc3ab18812cf77888bd079ad061de6e02c430 (commit)
from eb3ed416c8ddf2038376e362a15939b057b37628 (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 23ffc3ab18812cf77888bd079ad061de6e02c430
Author: Andy Barajas <and...@gm...>
Date: Wed Jul 3 16:48:38 2024 -0700
Replace redefined regs with dmac.h definitions (#655)
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/kernel/init.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c
index a19b13f8..1c6bbd4d 100644
--- a/kernel/arch/dreamcast/kernel/init.c
+++ b/kernel/arch/dreamcast/kernel/init.c
@@ -24,6 +24,7 @@
#include <dc/pvr.h>
#include <dc/vmufs.h>
#include <dc/syscalls.h>
+#include <dc/dmac.h>
#include "initall_hdrs.h"
@@ -44,10 +45,6 @@ void (*__kos_init_early_fn)(void) __attribute__((weak,section(".data"))) = NULL;
int main(int argc, char **argv);
uint32 _fs_dclsocket_get_ip(void);
-#define SAR2 ((vuint32 *)0xFFA00020)
-#define CHCR2 ((vuint32 *)0xFFA0002C)
-#define DMAOR ((vuint32 *)0xFFA00040)
-
/* We have to put this here so we can include plat-specific devices */
dbgio_handler_t * dbgio_handlers[] = {
&dbgio_dcload,
@@ -268,9 +265,9 @@ void arch_main(void) {
if (KOS_PLATFORM_IS_NAOMI) {
/* Ugh. I'm really not sure why we have to set up these DMA registers this
way on boot, but failing to do so breaks maple... */
- *SAR2 = 0;
- *CHCR2 = 0x1201;
- *DMAOR = 0x8201;
+ DMAC_SAR2 = 0;
+ DMAC_CHCR2 = 0x1201;
+ DMAC_DMAOR = 0x8201;
}
/* Ensure the WDT is not enabled from a previous session */
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-07-02 04:06:00
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via eb3ed416c8ddf2038376e362a15939b057b37628 (commit)
via 4bccb15070aacb448110b35839265a7bd4ce3db4 (commit)
via 8420766f5fee798a1e35c0f0cfd17e2094606ebd (commit)
via f7ca4fc012173af8d4f0ed0ea992a485463624e2 (commit)
via 96eb72d476bd6c09badd205f9dd79c8f37ba1f0c (commit)
via d847f9262cb80c3977707331dd6908fe4c8be337 (commit)
from d74baddec77b6b00535e065982bf2a80b0ed0ec0 (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 eb3ed416c8ddf2038376e362a15939b057b37628
Author: Donald Haase <qu...@ya...>
Date: Tue Jul 2 00:05:19 2024 -0400
Threaded Controller Callbacks v2 (#608)
* Install cont callbacks as worker threads
* Avoid deadlock when cleaning up workers
* Switch to TAILQ to allow prefering individual controllers
* Have worker free itself after being signaled to quit by destroy.
* Prevent thd_join(thd_current) deadlock. Update documentation.
* Patch race in thd_worker_destroy
* Ensure that destroyed threads are removed from the genwait queue
* Ensure that a worker can't start waiting on itself after it was signaled to quit
* Fix typo
* Cache the value of worker->thd in case the worker manages to quit and free itself prior to getting to us calling thd_join. [UAF]
* Prevent iterating through the callback list in an irq in case the irq was triggered while the list was being modified.
* Disable irqs later in the process of shutting down the system. This specifically allows maple_shutdown to gracefully shut down the threads it has set up for button callbacks. This has the effect of also enabling irqs during the other chained shutdowns in snd_shutdown and hardware_shutdown generally.
* Add the matching mutex_unlock for the trylock, as that's how mutexes work. Without this it will deadlock on any callback add or remove including shutdown.
---------
Co-authored-by: QuzarDC <qu...@co...>
Co-authored-by: Falco Girgis <gyr...@gm...>
commit 4bccb15070aacb448110b35839265a7bd4ce3db4
Author: Falco Girgis <gyr...@gm...>
Date: Mon Jul 1 22:34:07 2024 -0500
Added Reentrant Mutex Example (#644)
* Added darc's "reentrant_mutex" example
- This is a reimagining of rustc's "ReentrantLock" which is used
internally by the stdlib to implement println!().
- This code originally exposed a horrible race condition in the kernel
with multiple threads being able to acquire a single mutex.
- Cleaned up the example, commented the hell out of it, turned it into
essentially a regression test as well as a general threading
demonstration.
---------
Co-authored-by: darcagn <da...@pr...>
commit 8420766f5fee798a1e35c0f0cfd17e2094606ebd
Author: Falco Girgis <gyr...@gm...>
Date: Mon Jul 1 22:26:32 2024 -0500
Fixed vmu_beep example to gracefully exit (#650)
* Fixed vmu_beep example to gracefully exit
- We were previously freeing the font resources within a callback
registered as an atexit() handler.
- When we deferred the controller button callback mechanism into another
thread, our call to arch_exit() went from happening in the main thread
to happening in the deferred thread.
- This caused a race condition when resources that the main thread was
still using were ripped away and shut down within the deferred thread
which was the one exiting (and calling the atexit() chain).
- Changed the reset button callback handler to simply set an atomic
boolean which signals for the main thread to exit its run loop.
- Moved shutdown logic to after the run loop in main().
- Added logic to stop playing any active effect upon exit.
- Added #defines for two effects, so they wouldn't be magic numbers.
a. VMU_STOP_EFFECT
b. VMU_DEFAULT_EFFECT
- Added VMU_DEFAULT_EFFECT to initialize the starting effect to a known
good value, so a user (or KOS developer testing) doesn't have to do a
bunch of button presses to get a beep to work. Also less confusing on
the user to have a known good default, so pressing A to beep will
immediately work.
commit f7ca4fc012173af8d4f0ed0ea992a485463624e2
Author: Andy Barajas <and...@gm...>
Date: Mon Jul 1 01:52:53 2024 -0700
Fix pty (#636)
* 'Fixed' pty. Added dup,dup2 and pipe to koslib
* Added pty example to fix issue #224
* Fix the error handling gap in fs_pty_create()
* Implement alternative method to see if fd is a PTY
---------
Co-authored-by: Falco Girgis <gyr...@gm...>
commit 96eb72d476bd6c09badd205f9dd79c8f37ba1f0c
Author: Andy Barajas <and...@gm...>
Date: Sun Jun 30 23:02:58 2024 -0700
/dev rewinddir on close (#645)
commit d847f9262cb80c3977707331dd6908fe4c8be337
Author: Andy Barajas <and...@gm...>
Date: Sun Jun 30 22:07:51 2024 -0700
/rd . & .. are now recognized as directories (#646)
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/Makefile | 2 +-
examples/dreamcast/basic/threading/Makefile | 3 +
.../{general => reentrant_mutex}/Makefile | 6 +-
.../threading/reentrant_mutex/reentrant_mutex.c | 206 +++++++++++++++++++++
examples/dreamcast/filesystem/Makefile | 16 ++
.../cdda/basic_cdda => filesystem/pty}/Makefile | 11 +-
examples/dreamcast/filesystem/pty/pty.c | 91 +++++++++
examples/dreamcast/vmu/vmu_beep/beep.c | 51 +++--
include/sys/ioctl.h | 43 +++++
include/sys/termios.h | 48 +++++
kernel/arch/dreamcast/hardware/maple/controller.c | 125 +++++++++++--
.../arch/dreamcast/include/dc/maple/controller.h | 21 +--
kernel/arch/dreamcast/kernel/init.c | 9 +-
kernel/fs/fs.c | 24 ++-
kernel/fs/fs_dev.c | 5 +
kernel/fs/fs_pty.c | 116 +++++++++---
kernel/fs/fs_romdisk.c | 9 +-
kernel/libc/koslib/Makefile | 2 +-
kernel/libc/koslib/dbglog.c | 11 +-
kernel/libc/koslib/dup.c | 13 ++
kernel/libc/koslib/dup2.c | 13 ++
kernel/libc/koslib/pipe.c | 29 +++
kernel/libc/newlib/Makefile | 2 +-
kernel/libc/newlib/newlib_isatty.c | 29 +--
kernel/libc/newlib/newlib_tcgetattr.c | 12 ++
kernel/thread/thread.c | 4 +
kernel/thread/worker.c | 14 +-
27 files changed, 793 insertions(+), 122 deletions(-)
copy examples/dreamcast/basic/threading/{general => reentrant_mutex}/Makefile (77%)
create mode 100644 examples/dreamcast/basic/threading/reentrant_mutex/reentrant_mutex.c
create mode 100644 examples/dreamcast/filesystem/Makefile
copy examples/dreamcast/{sound/cdda/basic_cdda => filesystem/pty}/Makefile (75%)
create mode 100644 examples/dreamcast/filesystem/pty/pty.c
create mode 100644 include/sys/ioctl.h
create mode 100644 include/sys/termios.h
create mode 100644 kernel/libc/koslib/dup.c
create mode 100644 kernel/libc/koslib/dup2.c
create mode 100644 kernel/libc/koslib/pipe.c
create mode 100644 kernel/libc/newlib/newlib_tcgetattr.c
diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile
index 546a2f86..8afe9ad9 100644
--- a/examples/dreamcast/Makefile
+++ b/examples/dreamcast/Makefile
@@ -6,7 +6,7 @@
#
DIRS = 2ndmix basic libdream kgl hello sound png network vmu conio pvr video \
- lua parallax modem dreameye sd g1ata lightgun keyboard sdl dev rumble \
+ lua parallax modem dreameye filesystem sd g1ata lightgun keyboard sdl dev rumble \
micropython
ifdef KOS_CCPLUS
diff --git a/examples/dreamcast/basic/threading/Makefile b/examples/dreamcast/basic/threading/Makefile
index e76cb63b..ba062f4b 100644
--- a/examples/dreamcast/basic/threading/Makefile
+++ b/examples/dreamcast/basic/threading/Makefile
@@ -13,6 +13,7 @@ all:
$(KOS_MAKE) -C tls
$(KOS_MAKE) -C spinlock_test
$(KOS_MAKE) -C atomics
+ $(KOS_MAKE) -C reentrant_mutex
clean:
$(KOS_MAKE) -C compiler_tls clean
@@ -23,6 +24,7 @@ clean:
$(KOS_MAKE) -C tls clean
$(KOS_MAKE) -C spinlock_test clean
$(KOS_MAKE) -C atomics clean
+ $(KOS_MAKE) -C reentrant_mutex clean
dist:
$(KOS_MAKE) -C compiler_tls dist
@@ -33,3 +35,4 @@ dist:
$(KOS_MAKE) -C tls dist
$(KOS_MAKE) -C spinlock_test dist
$(KOS_MAKE) -C atomics dist
+ $(KOS_MAKE) -C reentrant_mutex dist
diff --git a/examples/dreamcast/basic/threading/general/Makefile b/examples/dreamcast/basic/threading/reentrant_mutex/Makefile
similarity index 77%
copy from examples/dreamcast/basic/threading/general/Makefile
copy to examples/dreamcast/basic/threading/reentrant_mutex/Makefile
index 360dea07..b73332f4 100644
--- a/examples/dreamcast/basic/threading/general/Makefile
+++ b/examples/dreamcast/basic/threading/reentrant_mutex/Makefile
@@ -1,11 +1,11 @@
# KallistiOS ##version##
#
# basic/threading/Makefile
-# (c)2001 Megan Potter
+# Copyright (C) 2024 Eric Fradella
#
-TARGET = general_threading_test.elf
-OBJS = general_threading_test.o
+TARGET = reentrant_mutex.elf
+OBJS = reentrant_mutex.o
all: rm-elf $(TARGET)
diff --git a/examples/dreamcast/basic/threading/reentrant_mutex/reentrant_mutex.c b/examples/dreamcast/basic/threading/reentrant_mutex/reentrant_mutex.c
new file mode 100644
index 00000000..29a3d93f
--- /dev/null
+++ b/examples/dreamcast/basic/threading/reentrant_mutex/reentrant_mutex.c
@@ -0,0 +1,206 @@
+/* KallistiOS ##version##
+
+ reentrant_mutex.c
+
+ Copyright (C) 2024 Eric Fradella
+ Copyright (C) 2024 Falco Girgis
+
+ Concurrency example that creates a "reentrant mutex" (aka recursive mutex)
+ on top of KOS's basic mutex.
+
+ Normally, you would not want to do this, as KOS mutexes can simply be used
+ with "MUTEX_TYPE_RECURSIVE" to achieve the same behavior with less work;
+ however, this is actually the exact mechanism currently used by the Rust
+ standard library to implement such functionality, so it's still a useful
+ demonstration and serves as a validation test for the behavior of KOS's
+ mutexes.
+
+ The referenced Rust implementation is available at
+ https://github.com/rust-lang/rust/blob/4bc39f02/library/std/src/sync/reentrant_lock.rs
+
+ */
+
+#include <kos.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdatomic.h>
+#include <stdnoreturn.h>
+
+/* Number of threads to spawn */
+#define THREAD_COUNT (DBL_MEM? 600 : 300)
+
+/* % chance thread will pass when maybe_pass() called */
+#define THREAD_PASS_CHANCE 75
+
+/* Reentrant mutex we're implementing on top of KOS's normal mutex. */
+typedef struct {
+ mutex_t mutex; /* Regular mutex */
+ _Atomic kthread_t *owner; /* Current mutex owner */
+ unsigned count; /* Reentrant count */
+} reentrant_mutex_t;
+
+/* Initializes our reentrant_mutex structure. */
+static void reentrant_mutex_init(reentrant_mutex_t *rmutex) {
+ mutex_init(&rmutex->mutex, MUTEX_TYPE_NORMAL);
+ atomic_store(&rmutex->owner, NULL);
+ rmutex->count = 0;
+}
+
+/* Uninitializes our reentrant_mutex structure. */
+static void reentrant_mutex_uninit(reentrant_mutex_t *rmutex) {
+ mutex_destroy(&rmutex->mutex);
+}
+
+/* Reports an error for the current thread and exits with failure value. */
+noreturn static void failure(const char *fmt, ...) {
+ char buffer[1024];
+ va_list args;
+
+ va_start(args, fmt);
+ vsnprintf(buffer, sizeof(buffer), fmt, args);
+ va_end(args);
+
+ fprintf(stderr, "* * * FAILURE * * *\n");
+ fprintf(stderr, "thread %s: %s\n", thd_get_label(thd_current), buffer);
+
+ exit(EXIT_FAILURE);
+}
+
+/* Locks our reentrant_mutex structure. */
+static void reentrant_mutex_lock(reentrant_mutex_t *rmutex) {
+ /* If we are the owning thread, we must have already acquired the mutex. */
+ if(atomic_load(&rmutex->owner) == (_Atomic kthread_t *)thd_current) {
+ /* Increment the lock count. */
+ rmutex->count++;
+
+ /* Sanity check: mutex better be locked! */
+ if(!mutex_is_locked(&rmutex->mutex))
+ failure("Owns rmutex->mutex but it isn't locked!");
+ }
+ else {
+ kthread_t *expected = NULL;
+
+ /* Attempt to acquire the mutex, since we are not the owning thread. */
+ if(mutex_lock(&rmutex->mutex) < 0)
+ failure("Failed to lock mutex: %s", strerror(errno));
+
+ /* Set the owning thread to this thread. */
+ atomic_compare_exchange_strong(&rmutex->owner,
+ &expected,
+ (_Atomic kthread_t *)thd_current);
+
+ /* This should be impossible if our threading system is working properly. */
+ if(rmutex->count)
+ failure("rmutex->count was %u when it MUST be zero!", rmutex->count);
+
+ rmutex->count++;
+ }
+}
+
+/* Unlocks our reentrant_mutex structure. */
+static void reentrant_mutex_unlock(reentrant_mutex_t *rmutex) {
+ /* We better currently be the owning thread if we're attempting to unlock it! */
+ if(atomic_load(&rmutex->owner) == (_Atomic kthread_t *)thd_current) {
+ /* Decrement the lock counter. */
+ if(atomic_fetch_sub(&rmutex->count, 1) == 1) {
+ /* Clear the owning thread and release the mutex if counter hits 0. */
+ atomic_store(&rmutex->owner, NULL);
+
+ /* Unlock the mutex. */
+ if(mutex_unlock(&rmutex->mutex) < 0)
+ failure("Failed to unlock mutex: %s", strerror(errno));
+ }
+
+ } else {
+ fprintf(stderr, "Error: Thread does not own the mutex\n");
+ }
+}
+
+/* Use the provided probability to determine whether the current thread
+ should pass/yield execution to another thread. */
+static void maybe_pass(void) {
+ unsigned value;
+
+ getentropy(&value, sizeof(value));
+
+ value %= 100;
+ if(value < THREAD_PASS_CHANCE)
+ thd_pass();
+}
+
+/* Mutex controlling access to "shared_variable." */
+static reentrant_mutex_t rmutex;
+/* Variable all threads are fighting over modifying. */
+static int shared_variable = 0;
+
+/* Exec function for each thread. Attempts to acquire the reentrant_mutex
+ multiple times, potentially yielding in between each acquisition,
+ and incrementing the shared variable once while the thread owns the lock. */
+static void *thread_func(void *arg) {
+ printf("Hello from thread %s!\n",
+ thd_get_label(thd_current));
+
+ maybe_pass();
+ reentrant_mutex_lock(&rmutex); /* lock count = 1 */
+
+ maybe_pass();
+ reentrant_mutex_lock(&rmutex); /* lock count = 2 */
+
+ shared_variable++;
+
+ maybe_pass();
+ reentrant_mutex_unlock(&rmutex); /* lock count = 1 */
+
+ maybe_pass();
+ reentrant_mutex_lock(&rmutex); /* lock count = 2 */
+
+ maybe_pass();
+ reentrant_mutex_unlock(&rmutex); /* lock count = 1 */
+
+ maybe_pass();
+ reentrant_mutex_unlock(&rmutex); /* unlocked */
+
+ return NULL;
+}
+
+int main(int argc, const char* argv[]) {
+ kthread_t *threads[THREAD_COUNT];
+
+ /* Initialize our mutex */
+ reentrant_mutex_init(&rmutex);
+
+ /* Spawn a bunch of threads, potentially yielding the main thread after
+ each one gets spawned. */
+ for(size_t i = 0; i < THREAD_COUNT; ++i) {
+ threads[i] = thd_create(false, thread_func, NULL);
+
+ char thd_label[16];
+ snprintf(thd_label, sizeof(thd_label), "%u", i);
+ thd_set_label(threads[i], thd_label);
+
+ maybe_pass();
+ }
+
+ /* Wait for each thread to complete. */
+ for(size_t i = 0; i < THREAD_COUNT; ++i)
+ thd_join(threads[i], NULL);
+
+ /* Ensure our mutex is left in the expected state. */
+ if(rmutex.count || rmutex.owner || mutex_is_locked(&rmutex.mutex))
+ failure("Recursive mutex was left in unexpected state!");
+
+ /* Clean up our mutex. */
+ reentrant_mutex_uninit(&rmutex);
+
+ printf("Shared variable is %d!\n", shared_variable);
+
+ if(shared_variable == THREAD_COUNT)
+ printf("Reentrant lock test completed successfully!\n");
+ else
+ failure("Shared variable != THREAD_COUNT!");
+
+ return EXIT_SUCCESS;
+}
diff --git a/examples/dreamcast/filesystem/Makefile b/examples/dreamcast/filesystem/Makefile
new file mode 100644
index 00000000..3233a746
--- /dev/null
+++ b/examples/dreamcast/filesystem/Makefile
@@ -0,0 +1,16 @@
+# KallistiOS ##version##
+#
+# examples/dreamcast/filesystem/Makefile
+# Copyright (C) 2024 Andress Barajas
+#
+
+all:
+ $(KOS_MAKE) -C pty
+
+clean:
+ $(KOS_MAKE) -C pty clean
+
+dist:
+ $(KOS_MAKE) -C pty dist
+
+
diff --git a/examples/dreamcast/sound/cdda/basic_cdda/Makefile b/examples/dreamcast/filesystem/pty/Makefile
similarity index 75%
copy from examples/dreamcast/sound/cdda/basic_cdda/Makefile
copy to examples/dreamcast/filesystem/pty/Makefile
index 22038245..4b6182d5 100644
--- a/examples/dreamcast/sound/cdda/basic_cdda/Makefile
+++ b/examples/dreamcast/filesystem/pty/Makefile
@@ -1,10 +1,12 @@
#
-# Basic CDDA program
-# (c)2002 Megan Potter
+# fs_pty test program
+#
+# Copyright (C) 2024 Andress Barajas
#
-TARGET = basic_cdda.elf
-OBJS = basic_cdda.o
+TARGET = pty.elf
+
+OBJS = pty.o
all: rm-elf $(TARGET)
@@ -25,4 +27,3 @@ run: $(TARGET)
dist: $(TARGET)
-rm -f $(OBJS)
$(KOS_STRIP) $(TARGET)
-
diff --git a/examples/dreamcast/filesystem/pty/pty.c b/examples/dreamcast/filesystem/pty/pty.c
new file mode 100644
index 00000000..3ab0168a
--- /dev/null
+++ b/examples/dreamcast/filesystem/pty/pty.c
@@ -0,0 +1,91 @@
+/* KallistiOS ##version##
+
+ pty.c
+ Copyright (C) 2024 Andress Barajas
+
+ This program demonstrates the creation and usage of a pseudo-terminal (PTY)
+ pair. It involves creating a master and a slave PTY, writing a message to
+ the master PTY, and reading the message from the slave PTY. It also
+ demonstrates handling non-blocking read operations and performs clean-up of
+ resources before exiting.
+*/
+
+#include <kos/fs_pty.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+int main(int argc, char* argv[]) {
+ /* Create a PTY pair */
+ file_t master_fd = NULL, slave_fd = NULL;
+ int retval = EXIT_SUCCESS;
+
+ if(fs_pty_create(NULL, 0, &master_fd, &slave_fd) < 0) {
+ fprintf(stderr, "Error creating PTY pair");
+ goto failure;
+ }
+
+ /* Set non-blocking mode on the slave_fd for testing */
+ int flags = fcntl(slave_fd, F_GETFL, 0);
+ if(fcntl(slave_fd, F_SETFL, flags | O_NONBLOCK) < 0) {
+ fprintf(stderr, "Error setting O_NONBLOCK");
+ goto failure;
+ }
+
+ /* Write to the master end of the PTY */
+ const char *msg = "Hello from master!";
+ if(write(master_fd, msg, strlen(msg)) < 0) {
+ fprintf(stderr, "Error writing to master PTY");
+ goto failure;
+ }
+
+ /* Read from the slave end of the PTY */
+ char buffer[128];
+ ssize_t bytes_read = read(slave_fd, buffer, sizeof(buffer) - 1);
+ if(bytes_read < 0) {
+ if(errno == EAGAIN) {
+ printf("No data available (non-blocking mode)\n");
+ } else {
+ fprintf(stderr, "Error reading from slave PTY");
+ goto failure;
+ }
+ } else {
+ /* Null-terminate and print the received message */
+ buffer[bytes_read] = '\0';
+ printf("Received message: %s\n", buffer);
+ }
+
+ /* Try and read again */
+ bytes_read = read(slave_fd, buffer, sizeof(buffer) - 1);
+ if(bytes_read < 0) {
+ if(errno == EAGAIN) {
+ printf("No more data available (non-blocking mode)\n");
+ } else {
+ fprintf(stderr, "Error reading from slave PTY");
+ goto failure;
+ }
+ } else if (bytes_read == 0) {
+ printf("No more data to read (EOF)\n");
+ } else {
+ /* Null-terminate and print the received message */
+ buffer[bytes_read] = '\0';
+ printf("Received 2nd message: %s\n", buffer);
+ }
+
+ /* Jump over failure and only do clean-up */
+ goto cleanup;
+
+ /* Set exit code and clean up */
+failure:
+ retval = EXIT_FAILURE;
+
+ /* Clean up resources */
+cleanup:
+ if(master_fd) fs_close(master_fd);
+ if(slave_fd) fs_close(slave_fd);
+
+ printf("DONE!\n");
+
+ return retval;
+}
diff --git a/examples/dreamcast/vmu/vmu_beep/beep.c b/examples/dreamcast/vmu/vmu_beep/beep.c
index ea600717..666eef77 100644
--- a/examples/dreamcast/vmu/vmu_beep/beep.c
+++ b/examples/dreamcast/vmu/vmu_beep/beep.c
@@ -2,8 +2,8 @@
beep.c
Copyright (C) 2004 SinisterTengu
- Copyright (C) 2008 Donald Haase
-
+ Copyright (C) 2008, 2024 Donald Haase
+ Copyright (C) 2024 Falco Girgis
*/
/*
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <stdatomic.h>
#include <kos/init.h>
@@ -38,29 +39,39 @@
#include <plx/font.h>
+#define VMU_DEFAULT_EFFECT 0x000065F0
+#define VMU_STOP_EFFECT 0x00000000
-static plx_font_t *fnt;
-static plx_fcxt_t *cxt;
+static atomic_bool quit = false;
-static void cleanup(void) {
- plx_font_destroy(fnt);
- plx_fcxt_destroy(cxt);
+static void on_reset(uint8_t addr, uint32_t btns) {
+ (void)addr; (void)btns;
+ quit = true;
}
int main(int argc, char *argv[]) {
maple_device_t *dev, *vmudev;
cont_state_t *state;
point_t w;
+ plx_font_t *fnt;
+ plx_fcxt_t *cxt;
int i = 0, count = 0;
uint16_t old_buttons = 0, rel_buttons = 0;
uint32_t effect = 0;
- uint8_t n[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; //nibbles
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-07-01 05:06:17
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via d74baddec77b6b00535e065982bf2a80b0ed0ec0 (commit)
from ac4210b0617eecf8e808fe2da217b5ee5f389fb4 (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 d74baddec77b6b00535e065982bf2a80b0ed0ec0
Author: Falco Girgis <gyr...@gm...>
Date: Mon Jul 1 00:00:19 2024 -0500
Added Versioning to KOS (#565)
* Added versioning to KOS.
-----------------------------------------------------------------------
Summary of changes:
doc/CHANGELOG | 1 +
doc/Doxyfile | 2 +-
environ_base.sh | 5 +
include/kos.h | 1 +
include/kos/version.h | 550 ++++++++++++++++++++++++++++
kernel/Makefile | 7 +-
kernel/arch/dreamcast/kernel/make_banner.sh | 11 +-
kernel/version.c | 39 ++
utils/version/version.sh | 20 +-
9 files changed, 622 insertions(+), 14 deletions(-)
create mode 100644 include/kos/version.h
create mode 100644 kernel/version.c
diff --git a/doc/CHANGELOG b/doc/CHANGELOG
index 0755a8e5..251ed0bf 100644
--- a/doc/CHANGELOG
+++ b/doc/CHANGELOG
@@ -232,6 +232,7 @@ KallistiOS version 2.1.0 -----------------------------------------------
- *** Fixes mutexes not working properly [PC]
- DC fs_dcload: Set errno on error in dcload_stat() [PC]
- *** Create romdisks with bin2c instead of bin2o [PC]
+- *** Implemented versioning scheme for KOS API [FG && DH && LB]
KallistiOS version 2.0.0 -----------------------------------------------
- DC Broadband Adapter driver fixes [Megan Potter == MP]
diff --git a/doc/Doxyfile b/doc/Doxyfile
index 08b4359e..74abf0bf 100644
--- a/doc/Doxyfile
+++ b/doc/Doxyfile
@@ -199,7 +199,7 @@ SHORT_NAMES = NO
# description.)
# The default value is: NO.
-JAVADOC_AUTOBRIEF = NO
+JAVADOC_AUTOBRIEF = YES
# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line
# such as
diff --git a/environ_base.sh b/environ_base.sh
index 017446da..bf754d4b 100644
--- a/environ_base.sh
+++ b/environ_base.sh
@@ -1,6 +1,11 @@
# KallistiOS environment variable settings. These are the shared pieces
# that are generated from the user config. Configure if you like.
+export KOS_VERSION_MAJOR=`awk '$2 == "KOS_VERSION_MAJOR"{print $3; exit}' ${KOS_BASE}/include/kos/version.h`
+export KOS_VERSION_MINOR=`awk '$2 == "KOS_VERSION_MINOR"{print $3; exit}' ${KOS_BASE}/include/kos/version.h`
+export KOS_VERSION_PATCH=`awk '$2 == "KOS_VERSION_PATCH"{print $3; exit}' ${KOS_BASE}/include/kos/version.h`
+export KOS_VERSION="${KOS_VERSION_MAJOR}.${KOS_VERSION_MINOR}.${KOS_VERSION_PATCH}"
+
# Default the kos-ports path if it isn't already set.
if [ -z "${KOS_PORTS}" ] ; then
export KOS_PORTS="${KOS_BASE}/../kos-ports"
diff --git a/include/kos.h b/include/kos.h
index 32d905c7..4731e25f 100644
--- a/include/kos.h
+++ b/include/kos.h
@@ -32,6 +32,7 @@ __BEGIN_DECLS
#include <string.h>
#include <unistd.h>
+#include <kos/version.h>
#include <kos/fs.h>
#include <kos/fs_romdisk.h>
#include <kos/fs_ramdisk.h>
diff --git a/include/kos/version.h b/include/kos/version.h
new file mode 100644
index 00000000..286f342a
--- /dev/null
+++ b/include/kos/version.h
@@ -0,0 +1,550 @@
+
+/* KallistiOS ##version##
+
+ include/kos/version.h
+ Copyright (C) 2024 Falco Girgis
+ Copyright (C) 2024 Donald Haase
+ Copyright (C) 2024 Luke Benstead
+
+*/
+
+/** \file
+ \brief API versioning and requirements checks.
+ \ingroup version
+
+ This file contains the current KOS version information as well as utilities
+ for enforcing and checking for certain version ranges.
+
+ \author Falco Girgis
+ \author Donald Haase
+ \author Luke Benstead
+*/
+
+#ifndef __KOS_VERSION_H
+#define __KOS_VERSION_H
+
+/** \defgroup version Versioning
+ \brief KOS version information and utility API
+
+ This API provides both access to the current KOS version as well as
+ utilities that can be used to check for or require a particular version.
+
+ ## Format
+ KOS's versioning scheme follows the following format: `major.minor.patch`
+ where a change in the revision number of any component typically suggests:
+
+ |Component|Description
+ |---------|-----------
+ |Major |Massive, sweeping changes to major APIs and subsystems.
+ |Minor |Small, incremental updates and new features.
+ |Patch |Usually simply bugfixes.
+
+ ## Version Types
+ The versioning information is split into two different groups:
+
+ |Version Type|Description
+ |------------|-----------
+ |\ref version_comptime|The version of KOS your code is being compiled against.
+ |\ref version_runtime |The version of KOS your code has been linked against.
+
+ Ideally, these two versions would be the same; however, it is possible for
+ them to differ in certain circumstances:
+
+ - You pulled down a new version of KOS, rebuilt your code, but did not
+ rebuild the KOS library.
+ - You use dynamically loaded libraries which may have been built
+ against different versions of KOS than what you are currently
+ linking against.
+
+ ## Version Checking
+ Version checks are handled differently depending on whether you want to use
+ the version at compile-time or run-time.
+
+ |Version Type|Mechanism
+ |------------|-----------
+ |\ref version_comptime_check "Compile-Time"|Preprocessor directives, conditional compilation.
+ |\ref version_runtime_check "Run-Time"|if statements, conditional branches
+
+ \warning
+ It is very important that you use the provided version-check mechanisms when
+ comparing two different versions together, as no assurance is made that
+ versions can be correctly compared as integers.
+
+ ## App Versioning
+ The same \ref version_utils used to implement the KOS versioning
+ API are available as part of the public API so that they may be used to
+ implement your own similar versioning scheme at the app-level.
+
+ @{
+*/
+
+/** \defgroup version_comptime Compile-Time
+ \brief API providing compile-time KOS version and utilties.
+
+ This API is is specifically for the compile-time versioning. As such,
+ its API is implemented via C macros, which can easily be used with the
+ preprocessor for conditional compilation.
+
+ @{
+*/
+
+/** \defgroup version_comptime_current Current
+ \brief Current compile-time version of KOS
+
+ These macros provide information about the current version of KOS at
+ compile-time.
+
+ @{
+*/
+
+#define KOS_VERSION_MAJOR 2 /**< KOS's current major revision number. */
+#define KOS_VERSION_MINOR 0 /**< KOS's current minor revision number. */
+#define KOS_VERSION_PATCH 0 /**< KOS's current patch revision number. */
+
+/** KOS's current version as an integer ID. */
+#define KOS_VERSION \
+ KOS_VERSION_MAKE(KOS_VERSION_MAJOR, KOS_VERSION_MINOR, KOS_VERSION_PATCH)
+
+/** KOS's current version as a string literal. */
+#define KOS_VERSION_STRING \
+ KOS_VERSION_MAKE_STRING(KOS_VERSION_MAJOR, \
+ KOS_VERSION_MINOR, \
+ KOS_VERSION_PATCH)
+/** @} */
+
+/** \defgroup version_comptime_check Checks
+ \brief Compile-time checks against KOS's current version.
+
+ This API provides several utility macros to check for a particular
+ exact, min, or max compile-time version for KOS.
+
+ They are meant to be used with the preprocessor like so:
+
+ \code{.c}
+ #if KOS_VERSION_MIN(2, 0, 0)
+ // Do something requiring at least KOS 2.0.0 to compile.
+ #elif KOS_VERSION_BELOW(2, 5, 1)
+ // Do something that was deprecated in KOS 2.5.1.
+ #elif KOS_VERSION_IS(3, 1, 2)
+ // Do something for an exact version match.
+ #endif
+ \endcode
+
+ @{
+*/
+
+/** Compile-time check for being above a given KOS version.
+
+ Checks to see whether the current KOS version is higher than the given
+ version.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+
+ \retval true KOS's version is higher.
+ \retval false KOS's version is the same or lower.
+
+*/
+#define KOS_VERSION_ABOVE(major, minor, patch) \
+ KOS_VERSION_MAKE_ABOVE(major, minor, patch, KOS_VERSION)
+
+/** Compile-time check for a minimum KOS version.
+
+ Checks to see whether the current KOS version is the same or higher than
+ the given version.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+
+ \retval true KOS's version is the same or higher.
+ \retval false KOS's version is lower.
+
+*/
+#define KOS_VERSION_MIN(major, minor, patch) \
+ KOS_VERSION_MAKE_MIN(major, minor, patch, KOS_VERSION)
+
+/** Compile-time check for an exact KOS version.
+
+ Checks to see whether the current KOS version matches the given version.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+
+ \retval true KOS's version is the same.
+ \retval false KOS's version is different.
+*/
+#define KOS_VERSION_IS(major, minor, patch) \
+ KOS_VERSION_MAKE_IS(major, minor, patch, KOS_VERSION)
+
+/** Compile-time check for a maximum KOS version.
+
+ Checks to see whether the current KOS version is the same or lower than the
+ given version.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+
+ \retval true KOS's version is the the same or lower.
+ \retval false KOS's version is higher.
+*/
+#define KOS_VERSION_MAX(major, minor, patch) \
+ KOS_VERSION_MAKE_MAX(major, minor, patch, KOS_VERSION)
+
+/** Compile-time check for being below a given KOS version.
+
+ Checks to see whether the current KOS version is lower than the given
+ version.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+
+ \retval true KOS's version is lower.
+ \retval false KOS's version is the same or higher.
+
+*/
+#define KOS_VERSION_BELOW(major, minor, patch) \
+ KOS_VERSION_MAKE_BELOW(major, minor, patch, KOS_VERSION)
+
+/** @} */
+
+/** @} */
+
+/** \defgroup version_utils Utilities
+ \brief Utilities for creating version info and checks.
+
+ These are generalized utilities for construction of version info at
+ compile-time. They are what KOS uses internally, but they can also
+ be used externally to generate version info and version check utilities
+ for your application.
+
+ \note
+ The ranges for the components of a version ID are as follows:
+
+ |Component|Bits|Range
+ |---------|----|------
+ |Major |8 |0-255
+ |Minor |8 |0-255
+ |Patch |8 |0-255
+
+ @{
+*/
+
+/** \name Version Encoding
+ \brief Utilities for encoding a version from its components.
+ @{
+*/
+/** Creates a version identifier from its constituents.
+
+ Used to create a version identifier at compile-time from its components.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+
+ \returns Packed version identifier.
+*/
+#define KOS_VERSION_MAKE(major, minor, patch) \
+ ((kos_version_t)((major) << 16) | ((minor) << 8) | (patch))
+
+/** Creates a version string from its constituents.
+
+ Used to create a compile-time string literal from version components.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch patch versoin component.
+
+ \returns `NULL`-terminated C string literal in the format
+ `major.minor.patch`
+*/
+#define KOS_VERSION_MAKE_STRING(major, minor, patch) \
+ KOS_STRINGIFY(major) "." \
+ KOS_STRINGIFY(minor) "." \
+ KOS_STRINGIFY(patch)
+/** @} */
+
+/** \name Version Checking
+ \brief Utilities for creating version checks.
+ @{
+*/
+/** Creates a generic check against a given version.
+
+ Bottom-level macro used to create all compile-time comparison checks against
+ other versions.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+ \param op Integer comparison operator (`<=`, `>=`, `!=`, `==`, etc)/
+ \param version Encoded version to compare against.
+
+ \returns Boolean value for the given version compared against
+ \p version using \p op.
+*/
+#define KOS_VERSION_MAKE_COMPARISON(major, minor, patch, op, version) \
+ (KOS_VERSION_MAKE(major, minor, patch) op (version & 0xffffff))
+
+/** Creates a check for being above a given version.
+
+ Used to create a compile-time greater-than check against another version.
+
+ \note
+ Simply wrap this in a function to implement a runtime check.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+ \param version The reference version ID.
+
+ \retval true The given version is above \p version.
+ \retval false The given version is at or below \p version.
+*/
+#define KOS_VERSION_MAKE_ABOVE(major, minor, patch, version) \
+ (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >, version))
+
+/** Creates a minimum version check.
+
+ Used to create a compile-time minimum version check.
+
+ \note
+ Simply wrap this in a function to implement a runtime check.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+ \param version The minimum version ID.
+
+ \retval true The given version is at or above \p version.
+ \retval false The given version is below \p version.
+*/
+#define KOS_VERSION_MAKE_MIN(major, minor, patch, version) \
+ (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, >=, version))
+
+/** Creates an exact version check.
+
+ Used to create a compile-time exact version check.
+
+ \note
+ Simply wrap this in a function to implement a runtime check.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+ \param version The exact version ID to match.
+
+ \retval true The given version matches \p version exactly.
+ \retval false The given version does not match \p version.
+*/
+#define KOS_VERSION_MAKE_IS(major, minor, patch, version) \
+ (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, ==, version))
+
+/** Creates a maximum version check.
+
+ Used to create a compile-time maximum version check.
+
+ \note
+ Simply wrap this in a function to implement a runtime check.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+ \param version The maximum version ID.
+
+ \retval true The given version is at or below \p version.
+ \retval false The given version is above \p version.
+
+*/
+#define KOS_VERSION_MAKE_MAX(major, minor, patch, version) \
+ (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <=, version))
+
+/** Creates a check for being below a given version.
+
+ Used to create a compile-time less-than check against another version.
+
+ \note
+ Simply wrap this in a function to implement a runtime check.
+
+ \param major Major version component.
+ \param minor Minor version component.
+ \param patch Patch version component.
+ \param version The reference version ID.
+
+ \retval true The given version is below \p version.
+ \retval false The given version is at or above \p version.
+*/
+#define KOS_VERSION_MAKE_BELOW(major, minor, patch, version) \
+ (KOS_VERSION_MAKE_COMPARISON(major, minor, patch, <, version))
+/** @} */
+
+/** \cond INTERNAL */
+#define KOS_STRINGIFY(str) #str
+/** \endcond */
+
+/** @} */
+
+#include <kos/cdefs.h>
+__BEGIN_DECLS
+
+#include <stdint.h>
+#include <stdbool.h>
+
+/** \defgroup version_runtime Run-Time
+ \brief API providing run-time KOS version and utilties.
+
+ This API is is specifically for the run-time versioning. As such this
+ API operates on the KOS version that was linked against and is not suited
+ for use at the preprocessor level.
+
+ @{
+*/
+
+/** Type of a KOS version identifier.
+
+ This identifier packs the 3 version components into a single opaque ID.
+
+ \warning
+ It is not safe to compare two different versions together as if they were
+ regular integral types. You must use the Run-time
+ \ref version_runtime_check API.
+*/
+typedef uint32_t kos_version_t;
+
+/** \defgroup version_runtime_current Current
+ \brief Current run-time version of KOS
+
+ These functions provide information about the current version of KOS at
+ run-time (ie the version you have linked against).
+
+ @{
+*/
+
+/** Returns the current KOS version ID at run-time.
+
+ This function is used to fetch the current KOS version ID at run-time,
+ meaning it will return the version of KOS you have \e linked to, rather
+ than the one you were necessarily compiling against.
+
+ \returns KOS's current version identifier
+*/
+kos_version_t kos_version(void);
+
+/** Returns the string representation of the current KOS version at run-time
+
+ This function fetches the current run-time version of KOS as a string.
+
+ \note
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-06-30 16:48:00
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via ac4210b0617eecf8e808fe2da217b5ee5f389fb4 (commit)
via 408d021de11f64b46024deeece6c6efd8ec3d40e (commit)
via bc278be5facf916d1bff2e05f6bdbe9092acc078 (commit)
via c956a2f5eeae51a6991ed58a8d74e8cefa544ad9 (commit)
from f3e270e97b3fb71da3c7b2da2d9b6fd9965b6813 (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 ac4210b0617eecf8e808fe2da217b5ee5f389fb4
Author: Andy Barajas <and...@gm...>
Date: Sun Jun 30 09:47:09 2024 -0700
/sd directories viewed as files (#647)
* All directories read as files even with attr O_DIR set because the size wasnt set to -1
* No need to set time to 0
commit 408d021de11f64b46024deeece6c6efd8ec3d40e
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jun 27 15:19:47 2024 +0200
pthread: Add dummy pthread_atfork() for CMake detection (#611)
Add a stub for pthread_atfork(), whose purpose is only for CMake's
FindThreads to detect threading support in KallistiOS properly.
Signed-off-by: Paul Cercueil <pa...@cr...>
Co-authored-by: Falco Girgis <gyr...@gm...>
commit bc278be5facf916d1bff2e05f6bdbe9092acc078
Author: Donald Haase <qu...@ya...>
Date: Thu Jun 27 09:13:41 2024 -0400
Clean up after the allocation of the sphere texture data and font data. (#630)
Co-authored-by: QuzarDC <qu...@co...>
commit c956a2f5eeae51a6991ed58a8d74e8cefa544ad9
Author: Donald Haase <qu...@ya...>
Date: Thu Jun 27 09:12:31 2024 -0400
Properly free assets at exit. (#633)
Co-authored-by: QuzarDC <qu...@co...>
-----------------------------------------------------------------------
Summary of changes:
addons/libkosfat/fs_fat.c | 4 +++-
examples/dreamcast/parallax/raster_melt/raster_melt.c | 1 +
examples/dreamcast/parallax/serpent_dma/perfmeter.c | 7 +++++++
examples/dreamcast/parallax/serpent_dma/serpent.c | 8 ++++++--
kernel/libc/pthreads/pthread_thd.c | 5 +++++
5 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/addons/libkosfat/fs_fat.c b/addons/libkosfat/fs_fat.c
index 7c25bd41..55732379 100644
--- a/addons/libkosfat/fs_fat.c
+++ b/addons/libkosfat/fs_fat.c
@@ -936,8 +936,10 @@ static dirent_t *fs_fat_readdir(void *h) {
fh[fd].dent.size = dent->size;
fh[fd].dent.time = fat_time_to_stat(dent->mdate, dent->mtime);
- if(dent->attr & FAT_ATTR_DIRECTORY)
+ if(dent->attr & FAT_ATTR_DIRECTORY) {
fh[fd].dent.attr = O_DIR;
+ fh[fd].dent.size = -1;
+ }
/* We're done. Return the static dirent_t. */
mutex_unlock(&fat_mutex);
diff --git a/examples/dreamcast/parallax/raster_melt/raster_melt.c b/examples/dreamcast/parallax/raster_melt/raster_melt.c
index 09f069e0..37e3a82f 100644
--- a/examples/dreamcast/parallax/raster_melt/raster_melt.c
+++ b/examples/dreamcast/parallax/raster_melt/raster_melt.c
@@ -83,6 +83,7 @@ int main(int argc, char **argv) {
y += 2.0f;
}
+ plx_txr_destroy(txr);
return 0;
}
diff --git a/examples/dreamcast/parallax/serpent_dma/perfmeter.c b/examples/dreamcast/parallax/serpent_dma/perfmeter.c
index 8934e7e7..5c67f13a 100644
--- a/examples/dreamcast/parallax/serpent_dma/perfmeter.c
+++ b/examples/dreamcast/parallax/serpent_dma/perfmeter.c
@@ -7,6 +7,7 @@
/* Adapted from FoF/Tryptonite */
#include <kos.h>
+#include <stdlib.h>
#include <plx/font.h>
#include <plx/prim.h>
#include <plx/context.h>
@@ -14,9 +15,15 @@
plx_font_t * font;
plx_fcxt_t * fcxt;
+void pm_shutdown(void) {
+ plx_fcxt_destroy(fcxt);
+ plx_font_destroy(font);
+}
+
void pm_init(void) {
font = plx_font_load("/rd/font.txf");
fcxt = plx_fcxt_create(font, PVR_LIST_TR_POLY);
+ atexit(pm_shutdown);
}
void pm_drawbar(float pct, float posx, float posy, float posz,
diff --git a/examples/dreamcast/parallax/serpent_dma/serpent.c b/examples/dreamcast/parallax/serpent_dma/serpent.c
index 8f5cdcfe..11c3924c 100644
--- a/examples/dreamcast/parallax/serpent_dma/serpent.c
+++ b/examples/dreamcast/parallax/serpent_dma/serpent.c
@@ -44,6 +44,9 @@ typedef struct {
pvr_vertex_t *data;
} sphere_t;
+static sphere_t big_sphere = { 1.2f, 20, 20, NULL };
+static sphere_t small_sphere = { 0.8f, 20, 20, NULL };
+
static void sphere(sphere_t *s) { /* {{{ */
int i, j;
float pitch, pitch2;
@@ -153,8 +156,6 @@ static float r = 0;
static void sphere_frame(void) {
int i;
//uint64 start;
- static sphere_t big_sphere = { 1.2f, 20, 20, NULL };
- static sphere_t small_sphere = { 0.8f, 20, 20, NULL };
if(!big_sphere.data)
sphere(&big_sphere);
@@ -294,6 +295,9 @@ int main(int argc, char **argv) {
dbglog(DBG_DEBUG, "3D Stats: %u vblanks, frame rate ~%f fps, max vertex used %u bytes\n",
stats.vbl_count, stats.frame_rate, stats.vtx_buffer_used_max);
+ free(big_sphere.data);
+ free(small_sphere.data);
+
return 0;
}
diff --git a/kernel/libc/pthreads/pthread_thd.c b/kernel/libc/pthreads/pthread_thd.c
index ff65ecb9..9217c9e8 100644
--- a/kernel/libc/pthreads/pthread_thd.c
+++ b/kernel/libc/pthreads/pthread_thd.c
@@ -70,3 +70,8 @@ pthread_t pthread_self(void) {
int pthread_equal(pthread_t t1, pthread_t t2) {
return t1 == t2;
}
+
+int pthread_atfork(void (*)(void), void (*)(void), void (*)(void))
+{
+ return 0;
+}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-27 04:46: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 f3e270e97b3fb71da3c7b2da2d9b6fd9965b6813 (commit)
via 2da0522fd5b03419d93de29822ddb052e9ba2bb4 (commit)
via 420be8d196d4f96bf08fc50c65b77b70725cf747 (commit)
via 1279aa2ab78042ab51c71845e4b57f37761e0cff (commit)
via 1b813ec79f479ec47dbffef8632ef81fb549f52a (commit)
via f34c9f30ac28fdae651da16cbc3618192f96626b (commit)
via 6d4b1146be8f2813fa84f0197ae359f4f649724d (commit)
via d035be9fd2f2d06e8bdf263e06bb6ff5966f424e (commit)
via c64b160e296fe925d2dc9eee00d2626e03133638 (commit)
via 8514b10c11b01ec6c8b63e0136ce91c2fa53c1c4 (commit)
from 738b3274a85bab21a3ea81489ec2fe5ebb75158a (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 f3e270e97b3fb71da3c7b2da2d9b6fd9965b6813
Author: darcagn <da...@pr...>
Date: Wed Jun 26 22:45:30 2024 -0600
dc-chain: Update 12.x profile to 12.4 (#640)
commit 2da0522fd5b03419d93de29822ddb052e9ba2bb4
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jun 27 05:12:50 2024 +0200
Create romdisks with bin2c instead of bin2o (#641)
* bin2c: Fix invalid generated code
The generated C was not valid as it was missing a semicolon on one of
its lines.
Signed-off-by: Paul Cercueil <pa...@cr...>
* romdisks: Constify __kos_romdisk
The romdisk data isn't supposed to be modified, so modify the
__kos_romdisk pointer to add the "const" specifier.
Signed-off-by: Paul Cercueil <pa...@cr...>
* romdisks: Create romdisks using bin2c instead of bin2o
bin2o creates a romdisk.o from a romdisk.img using the linker. On the
other hand, bin2c creates a C file with a char array that contains the
whole romdisk.img.
The problem with the first approach is that the romdisk.o generated has
technically not been compiled. This is a problem when building a project
with LTO, as the linker will refuse to perform whole-program
optimizations if some of the object files haven't been compiled with
LTO.
It then issues the following warning:
ld: warning: incremental linking of LTO and non-LTO objects; using
-flinker-output=nolto-rel which will bypass whole program optimization
Creating romdisks with bin2c then allows the linker to perform
whole-program optimizations.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 420be8d196d4f96bf08fc50c65b77b70725cf747
Author: Paul Cercueil <pa...@cr...>
Date: Thu Jun 27 05:10:12 2024 +0200
fs_dcload: Set errno on error in dcload_stat() (#642)
The fs_dcload code doesn't seem to set errno anywhere. It means that on
error, the calling code will get whatever errno value was set by
anything that came before it.
In dcload_stat(), if the PC communication could not be done, set errno
to ENOENT - "No such file or directory". This will cause the upper
layers to not attempt to open the directory.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 1279aa2ab78042ab51c71845e4b57f37761e0cff
Merge: f34c9f30 1b813ec7
Author: Lawrence Sebald <ljs...@us...>
Date: Wed Jun 26 23:08:01 2024 -0400
Merge pull request #643 from pcercuei/fix-mutexes
mutex: Fix mutexes not mutexing
commit 1b813ec79f479ec47dbffef8632ef81fb549f52a
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jun 26 20:22:25 2024 +0200
mutex: Fix mutexes not mutexing
Imagine a scenario where thread #0 holds a lock. Thread #1 attempts to
lock it, doesn't get it, and is put to sleep with genwait_wait().
Thread #0 wakes up, releases the lock, which triggers
genwait_wake_one(), placing thread #1 back into the running queue.
However, before leaving hand, thread #0 gets the lock once again.
Thread #1 would then wake up, and incorrectly set itself as the lock
owner, without checking first that the lock was free.
Address this issue by checking that the lock is indeed free after being
awaken, and if not, go back to sleep.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit f34c9f30ac28fdae651da16cbc3618192f96626b
Author: Paul Cercueil <pa...@cr...>
Date: Wed Jun 26 07:34:15 2024 +0200
Some CMake stuff (#624)
* CMake: Set CMAKE_SIZEOF_VOID_P
For some reason this variable is expected to be set in the
GNUInstallDirs CMake module, which is pretty common.
Signed-off-by: Paul Cercueil <pa...@cr...>
* CMake: Don't remove intermediate object
Removing the temporary object means it will have to be re-generated
from romdisk.img every time a new build is done.
Signed-off-by: Paul Cercueil <pa...@cr...>
---------
Signed-off-by: Paul Cercueil <pa...@cr...>
Co-authored-by: Falco Girgis <gyr...@gm...>
commit 6d4b1146be8f2813fa84f0197ae359f4f649724d
Author: darcagn <da...@pr...>
Date: Fri Jun 21 12:21:56 2024 -0600
dc-chain: Remove default-jit patch from rustc-dev profile as it has now been upstreamed (#639)
commit d035be9fd2f2d06e8bdf263e06bb6ff5966f424e
Author: Andy Barajas <and...@gm...>
Date: Tue Jun 18 23:38:23 2024 -0700
Update startup (#621)
* Update crt1.o when startup.o is rebuilt
* Add hyphen
* Update kernel/arch/dreamcast/kernel/Makefile
Co-authored-by: darcagn <da...@pr...>
commit c64b160e296fe925d2dc9eee00d2626e03133638
Author: Andy Barajas <and...@gm...>
Date: Mon Jun 17 22:45:59 2024 -0700
Fix texturing and closing opened files (#607)
* Fix texturing and closing opened files
commit 8514b10c11b01ec6c8b63e0136ce91c2fa53c1c4
Author: Falco Girgis <gyr...@gm...>
Date: Tue Jun 18 00:41:22 2024 -0500
Thread bugfixes: Stack ownership, Genwait object release upon death (#622)
* Thread bugfixes: stack ownership, genwait on death
1) Stack ownership
- We were previously creating a thread for the main kernel thread
using thd_create() which gave it a duplicated, default-initialized
32KB stack rather than having it utilize its static 64KB stack range.
- To utilize its own stack, we have to internally maintain whether
or not we are the owner of the stack (ie we allocated it), so that
we know not to free it.
- This model also fixes issues created by supporting POSIX threads
via the pthread API which assign their own stacks.
- The new model/rule: you allocate and provide your own stack, you
clean up your own stack too!
2) Genwait cleanup upon thread death
- We were properly notifying other threads waiting upon the dying
thread that they should wake up.
- We were NOT properly cancelling any pending genwait objects that the
dying thread was awaiting! So it could potentially later try to
wake up + notify a dead thread when the object becomes available.
- We now remove the thread's genwait object (if it has one) upon its
death.
-----------------------------------------------------------------------
Summary of changes:
Makefile.rules | 5 +-
doc/CHANGELOG | 3 +
examples/dreamcast/cpp/gltest/gltest.cpp | 124 ++++++++-------------
examples/dreamcast/gldc/basic/gl/pvr-texture.c | 1 +
examples/dreamcast/gldc/nehe/nehe06/pvr-texture.c | 1 +
examples/dreamcast/gldc/nehe/nehe08/pvr-texture.c | 1 +
examples/dreamcast/gldc/nehe/nehe09/pvr-texture.c | 1 +
examples/dreamcast/gldc/nehe/nehe16/pvr-texture.c | 1 +
examples/dreamcast/png/example.c | 2 +-
examples/dreamcast/video/screenshot/screenshot.c | 3 +-
include/kos/init.h | 4 +-
include/kos/thread.h | 1 +
kernel/arch/dreamcast/fs/fs_dcload.c | 1 +
kernel/arch/dreamcast/include/arch/arch.h | 3 +
kernel/arch/dreamcast/kernel/Makefile | 3 +
kernel/arch/dreamcast/kernel/mm.c | 2 +-
kernel/romdisk/romdiskbase.c | 4 +-
kernel/thread/mutex.c | 35 ++++--
kernel/thread/thread.c | 40 +++++--
utils/bin2c/bin2c.c | 2 +-
utils/cmake/dreamcast.cmake | 17 ++-
utils/cmake/dreamcast.toolchain.cmake | 1 +
utils/dc-chain/Makefile.default.cfg | 2 +-
.../{gcc-12.3.0-kos.diff => gcc-12.4.0-kos.diff} | 58 +++++-----
utils/dc-chain/patches/gcc-rustc-kos.diff | 16 ---
.../patches/{ => historical}/gcc-12.3.0-kos.diff | 0
.../{profile.12.3.0.mk => profile.12.4.0.mk} | 2 +-
utils/dc-chain/profiles/profile.rustc-dev.mk | 2 +-
28 files changed, 171 insertions(+), 164 deletions(-)
copy utils/dc-chain/patches/{gcc-12.3.0-kos.diff => gcc-12.4.0-kos.diff} (73%)
rename utils/dc-chain/patches/{ => historical}/gcc-12.3.0-kos.diff (100%)
rename utils/dc-chain/profiles/{profile.12.3.0.mk => profile.12.4.0.mk} (98%)
diff --git a/Makefile.rules b/Makefile.rules
index 329413f3..487b9028 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -71,9 +71,10 @@ romdisk.img:
$(KOS_GENROMFS) -f romdisk.img -d $(KOS_ROMDISK_DIR) -v -x .svn -x .keepme
romdisk.o: romdisk.img
- $(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk_tmp.o
+ $(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.o -r romdisk_tmp.o $(KOS_LIB_PATHS) -Wl,--whole-archive -lromdiskbase
- rm romdisk_tmp.o
+ rm romdisk_tmp.c romdisk_tmp.o
endif
# Define KOS_GCCVER_MIN in your Makefile if you want to enforce a minimum GCC version.
diff --git a/doc/CHANGELOG b/doc/CHANGELOG
index d7e1e4c5..0755a8e5 100644
--- a/doc/CHANGELOG
+++ b/doc/CHANGELOG
@@ -229,6 +229,9 @@ KallistiOS version 2.1.0 -----------------------------------------------
- *** Added support for one-shot timers [PC]
- DC Use one-shot timers for timeout and a proper polling mechanism in modem [PC]
- *** Added full support for <time.h> additions from C23 standard. [FG]
+- *** Fixes mutexes not working properly [PC]
+- DC fs_dcload: Set errno on error in dcload_stat() [PC]
+- *** Create romdisks with bin2c instead of bin2o [PC]
KallistiOS version 2.0.0 -----------------------------------------------
- DC Broadband Adapter driver fixes [Megan Potter == MP]
diff --git a/examples/dreamcast/cpp/gltest/gltest.cpp b/examples/dreamcast/cpp/gltest/gltest.cpp
index 56f167c3..0dc6d9ed 100644
--- a/examples/dreamcast/cpp/gltest/gltest.cpp
+++ b/examples/dreamcast/cpp/gltest/gltest.cpp
@@ -11,6 +11,8 @@
#include <GL/glext.h>
#include <GL/glkos.h>
+#define PVR_HDR_SIZE 0x20
+
/*
This is a really simple KallistiGL example. It shows off several things:
@@ -157,93 +159,65 @@ public:
/* Load a PVR texture using glTexImage2D */
void loadtxr(const char *fname, GLuint *txr) {
-#define PVR_HDR_SIZE 0x20
FILE *tex = NULL;
unsigned char *texBuf;
+ uint8_t HDR[PVR_HDR_SIZE];
unsigned int texSize;
-
+
tex = fopen(fname, "rb");
if(tex == NULL) {
- printf("FILE READ ERROR: %s\n", fname);
-
+ fprintf(stderr, "FILE READ ERROR: %s\n", fname);
while(1);
}
fseek(tex, 0, SEEK_END);
- texSize = ftell(tex);
-
- texBuf = (unsigned char*)malloc(texSize);
+ texSize = ftell(tex) - PVR_HDR_SIZE;
fseek(tex, 0, SEEK_SET);
- fread(texBuf, 1, texSize, tex);
- fclose(tex);
-
- int texW = texBuf[PVR_HDR_SIZE - 4] | texBuf[PVR_HDR_SIZE - 3] << 8;
- int texH = texBuf[PVR_HDR_SIZE - 2] | texBuf[PVR_HDR_SIZE - 1] << 8;
- int texFormat, texColor;
-
- switch((unsigned int)texBuf[PVR_HDR_SIZE - 8]) {
- case 0x00:
- texColor = PVR_TXRFMT_ARGB1555;
- break; //(bilevel translucent alpha 0,255)
-
- case 0x01:
- texColor = PVR_TXRFMT_RGB565;
- break; //(non translucent RGB565 )
-
- case 0x02:
- texColor = PVR_TXRFMT_ARGB4444;
- break; //(translucent alpha 0-255)
-
- case 0x03:
- texColor = PVR_TXRFMT_YUV422;
- break; //(non translucent UYVY )
-
- case 0x04:
- texColor = PVR_TXRFMT_BUMP;
- break; //(special bump-mapping format)
-
- case 0x05:
- texColor = PVR_TXRFMT_PAL4BPP;
- break; //(4-bit palleted texture)
- case 0x06:
- texColor = PVR_TXRFMT_PAL8BPP;
- break; //(8-bit palleted texture)
+ /* Read in the PVR texture file header */
+ fread(HDR, 1, PVR_HDR_SIZE, tex);
- default:
- texColor = PVR_TXRFMT_RGB565;
- break;
- }
-
- switch((unsigned int)texBuf[PVR_HDR_SIZE - 7]) {
- case 0x01:
- texFormat = PVR_TXRFMT_TWIDDLED;
- break;//SQUARE TWIDDLED
-
- case 0x03:
- texFormat = PVR_TXRFMT_VQ_ENABLE;
- break;//VQ TWIDDLED
-
- case 0x09:
- texFormat = PVR_TXRFMT_NONTWIDDLED;
- break;//RECTANGLE
-
- case 0x0B:
- texFormat = PVR_TXRFMT_STRIDE | PVR_TXRFMT_NONTWIDDLED;
- break;//RECTANGULAR STRIDE
-
- case 0x0D:
- texFormat = PVR_TXRFMT_TWIDDLED;
- break;//RECTANGULAR TWIDDLED
-
- case 0x10:
- texFormat = PVR_TXRFMT_VQ_ENABLE | PVR_TXRFMT_NONTWIDDLED;
- break;//SMALL VQ
+ texBuf = (unsigned char*)malloc(texSize);
+ fread(texBuf, 1, texSize, tex); /* Read in the PVR texture data */
+ fclose(tex);
- default:
- texFormat = PVR_TXRFMT_NONE;
- break;
+ int texW = HDR[PVR_HDR_SIZE - 4] | HDR[PVR_HDR_SIZE - 3] << 8;
+ int texH = HDR[PVR_HDR_SIZE - 2] | HDR[PVR_HDR_SIZE - 1] << 8;
+ uint32_t color = (uint32_t)HDR[PVR_HDR_SIZE - 8];
+ uint32_t format = (uint32_t)HDR[PVR_HDR_SIZE - 7];
+ bool twiddled = format == 0x01;
+ bool compressed = (format == 0x10 || format == 0x03);
+ int texFormat = GL_UNSIGNED_SHORT_5_6_5;
+
+ if(compressed) {
+ if(twiddled) {
+ switch(color) {
+ case 0x0:
+ texFormat = GL_COMPRESSED_ARGB_1555_VQ_TWID_KOS;
+ break;
+ case 0x01:
+ texFormat = GL_COMPRESSED_RGB_565_VQ_TWID_KOS;
+ break;
+ case 0x02:
+ texFormat = GL_COMPRESSED_ARGB_4444_VQ_TWID_KOS;
+ break;
+ }
+ } else {
+ switch(color) {
+ case 0:
+ texFormat = GL_COMPRESSED_ARGB_1555_VQ_KOS;
+ break;
+ case 1:
+ texFormat = GL_COMPRESSED_RGB_565_VQ_KOS;
+ break;
+ case 2:
+ texFormat = GL_COMPRESSED_ARGB_4444_VQ_KOS;
+ break;
+ }
+ }
+ } else if(color == 1) {
+ texFormat = GL_UNSIGNED_SHORT_5_6_5;
}
printf("TEXTURE Resolution: %ix%i\n", texW, texH);
@@ -254,7 +228,7 @@ void loadtxr(const char *fname, GLuint *txr) {
if(texFormat & PVR_TXRFMT_VQ_ENABLE)
glCompressedTexImage2D(GL_TEXTURE_2D,
0,
- texFormat | texColor,
+ texFormat,
texW,
texH,
0,
@@ -267,7 +241,7 @@ void loadtxr(const char *fname, GLuint *txr) {
texW, texH,
0,
GL_RGB,
- texFormat | texColor,
+ texFormat,
texBuf);
}
diff --git a/examples/dreamcast/gldc/basic/gl/pvr-texture.c b/examples/dreamcast/gldc/basic/gl/pvr-texture.c
index 05c5af77..829ba721 100644
--- a/examples/dreamcast/gldc/basic/gl/pvr-texture.c
+++ b/examples/dreamcast/gldc/basic/gl/pvr-texture.c
@@ -85,6 +85,7 @@ GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char gl
TEX0 = malloc(texSize);
fread(TEX0, 1, texSize, tex); /* Read in the PVR texture data */
+ fclose(tex);
/* Generate and bind a texture as normal for Open GL */
glGenTextures(1, &texID);
diff --git a/examples/dreamcast/gldc/nehe/nehe06/pvr-texture.c b/examples/dreamcast/gldc/nehe/nehe06/pvr-texture.c
index 05c5af77..829ba721 100644
--- a/examples/dreamcast/gldc/nehe/nehe06/pvr-texture.c
+++ b/examples/dreamcast/gldc/nehe/nehe06/pvr-texture.c
@@ -85,6 +85,7 @@ GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char gl
TEX0 = malloc(texSize);
fread(TEX0, 1, texSize, tex); /* Read in the PVR texture data */
+ fclose(tex);
/* Generate and bind a texture as normal for Open GL */
glGenTextures(1, &texID);
diff --git a/examples/dreamcast/gldc/nehe/nehe08/pvr-texture.c b/examples/dreamcast/gldc/nehe/nehe08/pvr-texture.c
index 05c5af77..829ba721 100644
--- a/examples/dreamcast/gldc/nehe/nehe08/pvr-texture.c
+++ b/examples/dreamcast/gldc/nehe/nehe08/pvr-texture.c
@@ -85,6 +85,7 @@ GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char gl
TEX0 = malloc(texSize);
fread(TEX0, 1, texSize, tex); /* Read in the PVR texture data */
+ fclose(tex);
/* Generate and bind a texture as normal for Open GL */
glGenTextures(1, &texID);
diff --git a/examples/dreamcast/gldc/nehe/nehe09/pvr-texture.c b/examples/dreamcast/gldc/nehe/nehe09/pvr-texture.c
index 05c5af77..829ba721 100644
--- a/examples/dreamcast/gldc/nehe/nehe09/pvr-texture.c
+++ b/examples/dreamcast/gldc/nehe/nehe09/pvr-texture.c
@@ -85,6 +85,7 @@ GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char gl
TEX0 = malloc(texSize);
fread(TEX0, 1, texSize, tex); /* Read in the PVR texture data */
+ fclose(tex);
/* Generate and bind a texture as normal for Open GL */
glGenTextures(1, &texID);
diff --git a/examples/dreamcast/gldc/nehe/nehe16/pvr-texture.c b/examples/dreamcast/gldc/nehe/nehe16/pvr-texture.c
index 05c5af77..829ba721 100644
--- a/examples/dreamcast/gldc/nehe/nehe16/pvr-texture.c
+++ b/examples/dreamcast/gldc/nehe/nehe16/pvr-texture.c
@@ -85,6 +85,7 @@ GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char gl
TEX0 = malloc(texSize);
fread(TEX0, 1, texSize, tex); /* Read in the PVR texture data */
+ fclose(tex);
/* Generate and bind a texture as normal for Open GL */
glGenTextures(1, &texID);
diff --git a/examples/dreamcast/png/example.c b/examples/dreamcast/png/example.c
index e9115610..4b3a9896 100644
--- a/examples/dreamcast/png/example.c
+++ b/examples/dreamcast/png/example.c
@@ -97,7 +97,7 @@ void draw_back(void) {
vert.v = 0.0f;
pvr_prim(&vert, sizeof(vert));
- vert.x = 1.0f;
+ vert.x = 0.0f;
vert.y = 480.0f;
vert.z = 1.0f;
vert.u = 0.0f;
diff --git a/examples/dreamcast/video/screenshot/screenshot.c b/examples/dreamcast/video/screenshot/screenshot.c
index 51074b34..1f77d807 100644
--- a/examples/dreamcast/video/screenshot/screenshot.c
+++ b/examples/dreamcast/video/screenshot/screenshot.c
@@ -90,8 +90,7 @@ int main(int argc, char **argv) {
bfont_draw_str(vram_s + font_height_offset, 640, SHOW_BLACK_BG,
"Press A to take a screen shot");
- /* Without this the bfont wont show on the screen */
- thd_sleep(10);
+ vid_flip(-1);
}
return 0;
diff --git a/include/kos/init.h b/include/kos/init.h
index bb14f069..de199b9e 100644
--- a/include/kos/init.h
+++ b/include/kos/init.h
@@ -96,13 +96,13 @@ extern const uint32_t __kos_init_flags;
/** \brief Deprecated and not useful anymore. */
#define KOS_INIT_ROMDISK(rd) \
- void *__kos_romdisk = (rd); \
+ const void *__kos_romdisk = (rd); \
extern void fs_romdisk_mount_builtin_legacy(void); \
void (*fs_romdisk_mount_builtin_legacy_weak)(void) = fs_romdisk_mount_builtin_legacy
/** \brief Built-in romdisk. Do not modify this directly! */
-extern void * __kos_romdisk;
+extern const void * __kos_romdisk;
/** \brief State that you don't want a romdisk. */
#define KOS_INIT_ROMDISK_NONE NULL
diff --git a/include/kos/thread.h b/include/kos/thread.h
index d8cfba6c..e5c80a3a 100644
--- a/include/kos/thread.h
+++ b/include/kos/thread.h
@@ -131,6 +131,7 @@ LIST_HEAD(ktlist, kthread);
#define THD_USER 1 /**< \brief Thread runs in user mode */
#define THD_QUEUED 2 /**< \brief Thread is in the run queue */
#define THD_DETACHED 4 /**< \brief Thread is detached */
+#define THD_OWNS_STACK 8 /**< \brief Thread manages stack lifetime */
/** @} */
/** \brief Kernel thread flags type */
diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c
index a937f125..891e6fa9 100644
--- a/kernel/arch/dreamcast/fs/fs_dcload.c
+++ b/kernel/arch/dreamcast/fs/fs_dcload.c
@@ -397,6 +397,7 @@ static int dcload_stat(vfs_handler_t *vfs, const char *fn, struct stat *rv,
return 0;
}
+ errno = ENOENT;
return -1;
}
diff --git a/kernel/arch/dreamcast/include/arch/arch.h b/kernel/arch/dreamcast/include/arch/arch.h
index 0562fc36..7f19655d 100644
--- a/kernel/arch/dreamcast/include/arch/arch.h
+++ b/kernel/arch/dreamcast/include/arch/arch.h
@@ -67,6 +67,9 @@ extern uint32 _arch_mem_top;
/** \brief Default thread stack size. */
#define THD_STACK_SIZE 32768
+/** \brief Main/kernel thread's stack size. */
+#define THD_KERNEL_STACK_SIZE (64 * 1024)
+
/** \brief Default video mode. */
#define DEFAULT_VID_MODE DM_640x480
diff --git a/kernel/arch/dreamcast/kernel/Makefile b/kernel/arch/dreamcast/kernel/Makefile
index 95db3e42..566efc80 100644
--- a/kernel/arch/dreamcast/kernel/Makefile
+++ b/kernel/arch/dreamcast/kernel/Makefile
@@ -18,9 +18,12 @@ COPYOBJS += uname.o
OBJS = $(COPYOBJS) startup.o
SUBDIRS =
+CRT1_PATH = $(shell $(KOS_CC) $(KOS_CFLAGS) -print-file-name=crt1.o)
+
myall: $(OBJS)
-cp $(COPYOBJS) $(KOS_BASE)/kernel/build/
-rm banner.h authors.h banner.o uname.o
+ -cp startup.o $(CRT1_PATH)
include $(KOS_BASE)/Makefile.prefab
diff --git a/kernel/arch/dreamcast/kernel/mm.c b/kernel/arch/dreamcast/kernel/mm.c
index ebb0a16d..cce8885b 100644
--- a/kernel/arch/dreamcast/kernel/mm.c
+++ b/kernel/arch/dreamcast/kernel/mm.c
@@ -47,7 +47,7 @@ void* mm_sbrk(unsigned long increment) {
sbrk_base = (void *)(increment + (unsigned long)sbrk_base);
- if(((uint32)sbrk_base) >= (_arch_mem_top - 65536)) {
+ if(((uint32)sbrk_base) >= (_arch_mem_top - THD_KERNEL_STACK_SIZE)) {
dbglog(DBG_CRITICAL, "Out of memory. Requested sbrk_base %p, was %p, diff %lu\n",
sbrk_base, base, increment);
sbrk_base = base; /* Restore old value and mark failed */
diff --git a/kernel/romdisk/romdiskbase.c b/kernel/romdisk/romdiskbase.c
index d5f28f51..254e0545 100644
--- a/kernel/romdisk/romdiskbase.c
+++ b/kernel/romdisk/romdiskbase.c
@@ -6,9 +6,9 @@
#include <kos/fs_romdisk.h>
-extern unsigned char romdisk[];
+extern const unsigned char romdisk_data[];
-void *__kos_romdisk = romdisk;
+const void *__kos_romdisk = romdisk_data;
extern void fs_romdisk_mount_builtin(void);
diff --git a/kernel/thread/mutex.c b/kernel/thread/mutex.c
index 14a60bb9..1b38196d 100644
--- a/kernel/thread/mutex.c
+++ b/kernel/thread/mutex.c
@@ -14,6 +14,7 @@
#include <kos/dbglog.h>
#include <arch/irq.h>
+#include <arch/timer.h>
mutex_t *mutex_create(void) {
mutex_t *rv;
@@ -83,6 +84,7 @@ int mutex_lock(mutex_t *m) {
}
int mutex_lock_timed(mutex_t *m, int timeout) {
+ uint64_t deadline = 0;
int old, rv = 0;
if((rv = irq_inside_int())) {
@@ -123,14 +125,31 @@ int mutex_lock_timed(mutex_t *m, int timeout) {
rv = -1;
}
else {
- if(!(rv = genwait_wait(m, timeout ? "mutex_lock_timed" : "mutex_lock",
- timeout, NULL))) {
- m->holder = thd_current;
- m->count = 1;
- }
- else {
- errno = ETIMEDOUT;
- rv = -1;
+ if(timeout)
+ deadline = timer_ms_gettime64() + timeout;
+
+ for(;;) {
+ rv = genwait_wait(m, timeout ? "mutex_lock_timed" : "mutex_lock",
+ timeout, NULL);
+ if(rv < 0) {
+ errno = ETIMEDOUT;
+ break;
+ }
+
+ if(!m->holder) {
+ m->holder = thd_current;
+ m->count = 1;
+ break;
+ }
+
+ if(timeout) {
+ timeout = deadline - timer_ms_gettime64();
+ if(timeout <= 0) {
+ errno = ETIMEDOUT;
+ rv = -1;
+ break;
+ }
+ }
}
}
diff --git a/kernel/thread/thread.c b/kernel/thread/thread.c
index dbe5075d..2ed74191 100644
--- a/kernel/thread/thread.c
+++ b/kernel/thread/thread.c
@@ -407,7 +407,7 @@ static void *thd_create_tls_data(void) {
assert(!((uintptr_t)tcbhead % 8));
/* Since we aren't using either member within it, zero out tcbhead. */
- memset(tcbhead, 0, sizeof(tcbhead_t));
+ memset(tcbhead, 0, sizeof(tcbhead_t));
/* Initialize .TDATA */
if(tdata_size) {
@@ -444,7 +444,7 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr,
tid_t tid;
uint32_t params[4];
int oldirq = 0;
- kthread_attr_t real_attr = { 0, THD_STACK_SIZE, NULL, PRIO_DEFAULT, NULL };
+ kthread_attr_t real_attr = { false, THD_STACK_SIZE, NULL, PRIO_DEFAULT, NULL };
if(attr)
real_attr = *attr;
@@ -475,6 +475,9 @@ kthread_t *thd_create_ex(const kthread_attr_t *restrict attr,
/* Clear out potentially unused stuff */
memset(nt, 0, sizeof(kthread_t));
+ /* Initialize the flags to defaults immediately. */
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: ljsebald <ljs...@us...> - 2024-06-13 03:24:41
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 738b3274a85bab21a3ea81489ec2fe5ebb75158a (commit)
from 9b1cc962e8188704c7724ab62004fc5a45d85915 (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 738b3274a85bab21a3ea81489ec2fe5ebb75158a
Author: darcagn <da...@pr...>
Date: Wed Jun 12 21:09:45 2024 -0600
Add DC_TOOLS_BASE env variable for external tools (#613)
* Add DC_TOOLS_BASE env variable for external tools
* Update environ_dreamcast.sh
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 19 +++++++++----------
environ_base.sh | 7 ++++++-
environ_dreamcast.sh | 10 ++++++++++
3 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index 58fc084e..f1a0989d 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -61,6 +61,15 @@ export KOS_CC_PREFIX="sh-elf"
export DC_ARM_BASE="/opt/toolchains/dc/arm-eabi"
export DC_ARM_PREFIX="arm-eabi"
+# External Dreamcast Tools Path
+#
+# Specifies the path where Dreamcast tools that are not part of KOS are to be
+# installed. This includes, for example, dc-tool-ip, dc-tool-serial, and the
+# mrbc bytecode compiler. This directory, along with SH and ARM compiler
+# toolchains, will be added to your PATH environment variable.
+#
+export DC_TOOLS_BASE="/opt/toolchains/dc/bin"
+
# CMake Toolchain Path
#
# Specifies the path to the toolchain file used to target
@@ -198,16 +207,6 @@ export KOS_SH4_PRECISION="-m4-single-only"
#
#export KOS_CFLAGS="${KOS_CFLAGS} -mlra"
-# Additional Tools Path
-#
-# If not already set, add "bin" directory to PATH variable, which is where
-# additional tools such as dc-tool-ip and dc-tool-serial are typically
-# installed. Comment this out if you don't want this included within your PATH.
-#
-if [[ ":$PATH:" != *":${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin"* ]]; then
- export PATH="${PATH}:${KOS_CC_BASE}/bin:/opt/toolchains/dc/bin"
-fi
-
# Shared Compiler Configuration
#
# Include sub architecture-independent configuration file for shared
diff --git a/environ_base.sh b/environ_base.sh
index 446e3b3a..017446da 100644
--- a/environ_base.sh
+++ b/environ_base.sh
@@ -12,7 +12,12 @@ export KOS_ARCH_DIR="${KOS_BASE}/kernel/arch/${KOS_ARCH}"
# Pull in the arch environ file
. ${KOS_BASE}/environ_${KOS_ARCH}.sh
-# Add the gnu wrappers dir to the path if it is not already
+# Add the compiler bins dir to the path if it is not already
+if [[ ":$PATH:" != *":${KOS_CC_BASE}/bin:"* ]]; then
+ export PATH="${PATH}:${KOS_CC_BASE}/bin"
+fi
+
+# Add the build wrappers dir to the path if it is not already
if [[ ":$PATH:" != *":${KOS_BASE}/utils/build_wrappers:"* ]]; then
export PATH="${PATH}:${KOS_BASE}/utils/build_wrappers"
fi
diff --git a/environ_dreamcast.sh b/environ_dreamcast.sh
index 50551209..cc5d3700 100644
--- a/environ_dreamcast.sh
+++ b/environ_dreamcast.sh
@@ -1,6 +1,16 @@
# KallistiOS environment variable settings. These are the shared pieces
# for the Dreamcast(tm) platform.
+# 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"
+fi
+
+# Add the external DC tools dir to the path if it is not already.
+if [[ ":$PATH:" != *":${DC_TOOLS_BASE}:"* ]]; then
+ export PATH="${PATH}:${DC_TOOLS_BASE}"
+fi
+
# Default the SH4 floating point precision if it isn't already set.
if [ -z "${KOS_SH4_PRECISION}" ] ; then
export KOS_SH4_PRECISION="-m4-single-only"
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-12 14:40: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 9b1cc962e8188704c7724ab62004fc5a45d85915 (commit)
from 395d99a9421aed367d7d277065080301c1a1d54d (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 9b1cc962e8188704c7724ab62004fc5a45d85915
Author: Donald Haase <qu...@ya...>
Date: Wed Jun 12 10:39:10 2024 -0400
Revert "Update KOS_PORTS path so its prettier in error messages (#556)" (#627)
This reverts commit e6608bb5ff7506b95b3d38df70aa91d70f668c07.
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index c61e2481..58fc084e 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -43,7 +43,7 @@ export KOS_BASE="/opt/toolchains/dc/kos"
#
# Specifies the path to the KOS-ports directory
#
-export KOS_PORTS="/opt/toolchains/dc/kos-ports"
+export KOS_PORTS="${KOS_BASE}/../kos-ports"
# SH Compiler Prefixes
#
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-09 01:52:38
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 395d99a9421aed367d7d277065080301c1a1d54d (commit)
from f92103258b6d0943bc657de1199eb9a5d8b4087d (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 395d99a9421aed367d7d277065080301c1a1d54d
Author: Falco Girgis <gyr...@gm...>
Date: Sat Jun 8 20:51:49 2024 -0500
Fixed a MASSIVE screw-up with enabling OCRAM. (#620)
- OCRAM was being enabled by default now which was halving the size of
the O-cache.
- The init flag that was previously reserved for OCRAM was changed,
moving OCRAM over by a mile and replacing it with INIT_VMU.
- Damn startup.s was hardcoding the precise bit position of INIT_OCRAM
and wasn't actually looking at the #define from the C-side, making the
change unsafe... and as a result... RIP.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/kernel/startup.s | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/kernel/arch/dreamcast/kernel/startup.s b/kernel/arch/dreamcast/kernel/startup.s
index bff92c50..0c7b3fa4 100644
--- a/kernel/arch/dreamcast/kernel/startup.s
+++ b/kernel/arch/dreamcast/kernel/startup.s
@@ -45,9 +45,8 @@ setup_cache:
! Now that we are in P2, it's safe to enable the cache
! Check to see if we should enable OCRAM.
mov.l kos_init_flags_addr, r0
- add #2, r0
- mov.w @r0, r0
- tst #1, r0
+ mov.b @(3,r0),r0
+ tst #0x10,r0
bf .L_setup_cache_L0
mov.w ccr_data,r1
bra .L_setup_cache_L1
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-06-06 23:12:53
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via f92103258b6d0943bc657de1199eb9a5d8b4087d (commit)
from acff17b672272e5faa55e363b55bb5ff1e949c15 (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 f92103258b6d0943bc657de1199eb9a5d8b4087d
Author: Colton Pawielski <cep...@us...>
Date: Thu Jun 6 18:12:39 2024 -0500
Fix cpp/clock example (#616)
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/cpp/clock/Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/examples/dreamcast/cpp/clock/Makefile b/examples/dreamcast/cpp/clock/Makefile
index bd0eb4e2..e9839821 100644
--- a/examples/dreamcast/cpp/clock/Makefile
+++ b/examples/dreamcast/cpp/clock/Makefile
@@ -8,6 +8,8 @@ TARGET = clock.elf
OBJS = clock.o romdisk.o
KOS_ROMDISK_DIR = romdisk
+KOS_CPPFLAGS += -std=gnu++17
+
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-06-06 23:11:51
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via acff17b672272e5faa55e363b55bb5ff1e949c15 (commit)
from 91669fdcbd01cbc0b79babee21cd3727262d7396 (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 acff17b672272e5faa55e363b55bb5ff1e949c15
Author: Colton Pawielski <cep...@us...>
Date: Thu Jun 6 18:11:30 2024 -0500
Fix libstunami Examples (#615)
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/tsunami/banner/Makefile | 4 ++++
examples/dreamcast/tsunami/font/Makefile | 4 ++++
examples/dreamcast/tsunami/genmenu/Makefile | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/examples/dreamcast/tsunami/banner/Makefile b/examples/dreamcast/tsunami/banner/Makefile
index 7fd0748c..caeb0381 100644
--- a/examples/dreamcast/tsunami/banner/Makefile
+++ b/examples/dreamcast/tsunami/banner/Makefile
@@ -7,6 +7,10 @@ TARGET = banner.elf
OBJS = banner.o romdisk.o
KOS_ROMDISK_DIR = romdisk
+# GCC versions prior to 11.0 have incomplete C++17 support and need
+# to be forced to use the GNU dialect for std::filesystem support
+KOS_CPPFLAGS += -std=gnu++17
+
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
diff --git a/examples/dreamcast/tsunami/font/Makefile b/examples/dreamcast/tsunami/font/Makefile
index f7a68a0a..2047a881 100644
--- a/examples/dreamcast/tsunami/font/Makefile
+++ b/examples/dreamcast/tsunami/font/Makefile
@@ -7,6 +7,10 @@ TARGET = font.elf
OBJS = font.o romdisk.o
KOS_ROMDISK_DIR = romdisk
+# GCC versions prior to 11.0 have incomplete C++17 support and need
+# to be forced to use the GNU dialect for std::filesystem support
+KOS_CPPFLAGS += -std=gnu++17
+
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
diff --git a/examples/dreamcast/tsunami/genmenu/Makefile b/examples/dreamcast/tsunami/genmenu/Makefile
index c45a9133..8a23a92b 100644
--- a/examples/dreamcast/tsunami/genmenu/Makefile
+++ b/examples/dreamcast/tsunami/genmenu/Makefile
@@ -7,6 +7,10 @@ TARGET = genmenu.elf
OBJS = genmenu.o romdisk.o
KOS_ROMDISK_DIR = romdisk
+# GCC versions prior to 11.0 have incomplete C++17 support and need
+# to be forced to use the GNU dialect for std::filesystem support
+KOS_CPPFLAGS += -std=gnu++17
+
all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-06 20:36:59
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The KallistiOS port of PLIB.".
The branch, master has been updated
via 90fa6bf24baa61a0c3022a3d4d72d1ab6217ff76 (commit)
via dbf63bae1f23c07729bc7257d1f9c29411ff8c62 (commit)
from 42d6f0596079c818e156feff7f77adb11a640302 (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 90fa6bf24baa61a0c3022a3d4d72d1ab6217ff76
Merge: 42d6f05 dbf63ba
Author: Donald Haase <qu...@ya...>
Date: Tue Jun 4 21:15:39 2024 -0400
Merge pull request #1 from cepawiel/delete_fix
Fix delete warning
commit dbf63bae1f23c07729bc7257d1f9c29411ff8c62
Author: Colton Pawielski <cep...@mt...>
Date: Tue May 28 00:41:30 2024 -0500
Fix delete warning
-----------------------------------------------------------------------
Summary of changes:
fntTXF.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fntTXF.cc b/fntTXF.cc
index 5acc652..396a00a 100644
--- a/fntTXF.cc
+++ b/fntTXF.cc
@@ -297,7 +297,7 @@ bool fntTexFont::loadTXF (const char *fname)
if ( (int)fread (bitmap, 1, bitmapSize, fd) != (int)bitmapSize)
{
- delete bitmap;
+ delete[] bitmap;
ulSetError (UL_WARNING, "fntLoadTXF: Premature EOF in '%s'.", fname);
return false;
}
@@ -305,7 +305,7 @@ bool fntTexFont::loadTXF (const char *fname)
texture = pvr_mem_malloc (2048 + (w * h) / 2);
txr_load_twiddle_vq_bitmap (bitmap, texture, w, h, 0x0000, 0xFFFF);
- delete bitmap;
+ delete[] bitmap;
}
break;
hooks/post-receive
--
The KallistiOS port of PLIB.
|
|
From: darcagn <da...@us...> - 2024-06-06 04:39:37
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 91669fdcbd01cbc0b79babee21cd3727262d7396 (commit)
from 6e29d295e92995fda1fb2213d43b35bb168fef71 (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 91669fdcbd01cbc0b79babee21cd3727262d7396
Author: Colton Pawielski <cep...@us...>
Date: Wed Jun 5 23:38:48 2024 -0500
Return error code on example build failure (#606)
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/Makefile | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/examples/dreamcast/Makefile b/examples/dreamcast/Makefile
index 1b36dc2f..546a2f86 100644
--- a/examples/dreamcast/Makefile
+++ b/examples/dreamcast/Makefile
@@ -20,12 +20,14 @@ all:
$(KOS_MAKE) check-dir DIR=$$dir; \
done;
- @if [ -f errors.txt ]; then \
+ @error_count=$$(cat error_count.txt 2>/dev/null || echo 0); \
+ if [ -f errors.txt ]; then \
echo "\n-------------------------------------------------"; \
- echo "$$(cat error_count.txt 2>/dev/null || echo 0) error(s) occurred during the build process:"; \
+ echo "$$error_count error(s) occurred during the build process:"; \
cat errors.txt; \
- fi;
- @rm -f errors.txt error_count.txt
+ fi; \
+ rm -f errors.txt error_count.txt; \
+ exit $$error_count
# ALGORITHM EXPLANATION:
# This script recursively checks each directory to determine if it should
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: ljsebald <ljs...@us...> - 2024-06-06 00:53:56
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 6e29d295e92995fda1fb2213d43b35bb168fef71 (commit)
from c86818033aa60180853d8006de031093a26be37f (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 6e29d295e92995fda1fb2213d43b35bb168fef71
Author: Falco Girgis <gyr...@gm...>
Date: Wed Jun 5 19:53:15 2024 -0500
Implemented C23 stdlib features for <time.h> (#550)
* Implemented C23 stdlib features for <time.h>
- New macro for C23 compliance of the file
- Macros were redone to check for existence of C and C++ macros before
"dereferencing"
- New C23 time base types
- asctime() and ctime() are now deprecated in C23
- C23 added timespec_getres() for getting resolution of a time base
- C23 added gmtime_r() and localtime_r() reentrant time converters
- Implemented timespec API by mapping it directly to POSIX clock API
- Removed clock_gettime()'s reliance on timespec_get() for
CLOCK_REALTIME, so that the dependency could be reversed.
- Removed whitespace from RTC
* Implemented timegm() for UTC tm to unix timestamp.
* Updated CHANGELOG.
* Update include/kos/time.h
* Addressed review feedback.
-----------------------------------------------------------------------
Summary of changes:
doc/CHANGELOG | 1 +
include/kos/time.h | 73 ++++++++++++++++++++++++++++++--------
kernel/arch/dreamcast/kernel/rtc.c | 1 -
kernel/libc/c11/Makefile | 4 +--
kernel/libc/c11/timegm.c | 19 ++++++++++
kernel/libc/c11/timespec_get.c | 64 +++++++++++++++++++++++++++------
kernel/libc/posix/clock_gettime.c | 10 +++---
7 files changed, 140 insertions(+), 32 deletions(-)
create mode 100644 kernel/libc/c11/timegm.c
diff --git a/doc/CHANGELOG b/doc/CHANGELOG
index 3b15b50d..d7e1e4c5 100644
--- a/doc/CHANGELOG
+++ b/doc/CHANGELOG
@@ -228,6 +228,7 @@ KallistiOS version 2.1.0 -----------------------------------------------
- *** Added thread support for tracking CPU time + updated clock_gettime() [FG]
- *** Added support for one-shot timers [PC]
- DC Use one-shot timers for timeout and a proper polling mechanism in modem [PC]
+- *** Added full support for <time.h> additions from C23 standard. [FG]
KallistiOS version 2.0.0 -----------------------------------------------
- DC Broadband Adapter driver fixes [Megan Potter == MP]
diff --git a/include/kos/time.h b/include/kos/time.h
index 717f4daf..fe6f2ddc 100644
--- a/include/kos/time.h
+++ b/include/kos/time.h
@@ -8,7 +8,7 @@
/** \file kos/time.h
\brief KOS-implementation of select C11 and POSIX extensions
- Add select POSIX extensions and C11 functionality to time.h which are not
+ Add select POSIX extensions, C11, and C23 functionality to time.h which are not
present within Newlib.
\remark
@@ -23,9 +23,8 @@
\author Falco Girgis
*/
-
#ifndef _TIME_H_
-#error "Do not include this file directly. Use <time.h> instead."
+ #error "Do not include this file directly. Use <time.h> instead."
#endif /* !_TIME_H_ */
#ifndef __KOS_TIME_H
@@ -35,22 +34,66 @@
__BEGIN_DECLS
-#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L)
+/** \cond */
-/* Forward declaration. */
-struct timespec;
+/* Required definition for a fully C23-compliant <time.h> */
+#define __STDC_VERSION_TIME_H__ 202311L
-#define TIME_UTC 1
+/* Microsecond resolution for clock(), per POSIX standard.. */
+#define CLOCKS_PER_SEC 1000000
-/* Microsecond resolution for clock(), per POSIX standard */
-#define CLOCKS_PER_SEC 1000000
+/* =============== Enable the following for >=c11, >=c++17 =================== */
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
+ (defined(__cplusplus) && (__cplusplus >= 201703L))
+
+/* Only supported base time in C11. */
+#define TIME_UTC 1
/* C11 nanosecond-resolution timing. */
+struct timespec;
extern int timespec_get(struct timespec *ts, int base);
+#endif
+
+/* ============ Enable the following for >=C2x, >C++20+, KOS ============== */
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202000L)) || \
+ (defined(__cplusplus) && (__cplusplus > 202002L)) || \
+ defined(__KOS_LIBC)
+
+/* New POSIX-equivalent base times in C23. */
+#define TIME_MONOTONIC 2
+#define TIME_ACTIVE 3
+#define TIME_THREAD_ACTIVE 4
+
+/* Query for the resolution of a time base. */
+extern int timespec_getres(struct timespec *ts, int base);
+#endif
+
+/* ===================== Enable the following for >=c2y ================== */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202300L)
+
+/* Deprecate legacy time formatters with static internal state. */
+struct tm;
+[[deprecated]] extern char *asctime(const struct tm *timeptr);
+[[deprecated]] extern char *ctime(const __time_t *timer);
+#endif
+
+/* =========== Enable the following for >=c2y, >c++20, KOS ============== */
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202300L)) || \
+ (defined(__cplusplus) && (__cplusplus > 202002L)) || \
+ defined(__KOS_LIBC)
-#endif /* !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L) || (__cplusplus >= 201703L) */
+/* POSIX reentrant equivalents of gmtime and localtime added to C23. */
+struct tm;
+extern struct tm *gmtime_r(const __time_t *timer, struct tm *timeptr);
+extern struct tm *localtime_r(const __time_t *timer, struct tm *timeptr);
-#if !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 199309L)
+/* C23 added POSIX gmtime() for UTC broken-down time to a Unix timestamp. */
+extern __time_t timegm(struct tm *timeptr);
+
+#endif
+
+/* =========== Enable the following for POSIX POSIX.1b (1993) =========== */
+#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199309L)
/* We do not support POSIX timers!
#ifndef _POSIX_TIMERS
@@ -70,13 +113,15 @@ extern int timespec_get(struct timespec *ts, int base);
#endif
/* Explicitly provided function declarations for POSIX clock API, since
- getting them from Newlib requires supporting the rest of the _POSIX_TIMERS
- API, which is not implemented yet. */
+getting them from Newlib requires supporting the rest of the _POSIX_TIMERS
+API, which is not implemented yet. */
extern int clock_settime(__clockid_t clock_id, const struct timespec *ts);
extern int clock_gettime(__clockid_t clock_id, struct timespec *ts);
extern int clock_getres(__clockid_t clock_id, struct timespec *res);
-#endif /* !defined(__STRICT_ANSI__) || (_POSIX_C_SOURCE >= 199309L) */
+#endif
+
+/** \endcond */
__END_DECLS
diff --git a/kernel/arch/dreamcast/kernel/rtc.c b/kernel/arch/dreamcast/kernel/rtc.c
index db836943..d18c8f18 100644
--- a/kernel/arch/dreamcast/kernel/rtc.c
+++ b/kernel/arch/dreamcast/kernel/rtc.c
@@ -128,7 +128,6 @@ int rtc_set_unix_secs(time_t secs) {
if(adjusted_time < 0 || adjusted_time > UINT32_MAX)
return -1;
-
/* Enable writing by setting LSB of control */
g2_write_32(RTC_CTRL_ADDR, RTC_CTRL_WRITE_EN);
diff --git a/kernel/libc/c11/Makefile b/kernel/libc/c11/Makefile
index 460e5bc1..2c42f70c 100644
--- a/kernel/libc/c11/Makefile
+++ b/kernel/libc/c11/Makefile
@@ -4,13 +4,13 @@
# Copyright (C) 2014, 2015, 2023 Lawrence Sebald
#
-KOS_CFLAGS += -std=c11
+KOS_CFLAGS += -std=gnu11 -D__KOS_LIBC
OBJS = call_once.o cnd_broadcast.o cnd_destroy.o cnd_init.o cnd_signal.o \
cnd_timedwait.o cnd_wait.o mtx_destroy.o mtx_init.o mtx_lock.o \
mtx_timedlock.o mtx_trylock.o mtx_unlock.o thrd_create.o thrd_current.o \
thrd_detach.o thrd_equal.o thrd_exit.o thrd_join.o thrd_sleep.o \
thrd_yield.o tss_create.o tss_delete.o tss_get.o tss_set.o \
- aligned_alloc.o timespec_get.o atomics.o
+ aligned_alloc.o timespec_get.o timegm.o atomics.o
include $(KOS_BASE)/Makefile.prefab
diff --git a/kernel/libc/c11/timegm.c b/kernel/libc/c11/timegm.c
new file mode 100644
index 00000000..63153ed5
--- /dev/null
+++ b/kernel/libc/c11/timegm.c
@@ -0,0 +1,19 @@
+/* KallistiOS ##version##
+
+ timegm.c
+ Copyright (C) 2024 Falco Girgis
+*/
+
+#include <time.h>
+#include <errno.h>
+#include <stdbool.h>
+
+/* C23/POSIX timegm() converts a UTC-based broken-down time to a unix
+ timestamp... and since we have no timezone on the Dreamcast (yet),
+ our local time is already UTC, which means this is going to be
+ equivalent to using mktime()!
+*/
+time_t timegm(struct tm *timeptr) {
+ return mktime(timeptr);
+}
+
diff --git a/kernel/libc/c11/timespec_get.c b/kernel/libc/c11/timespec_get.c
index b913002e..1678ce1f 100644
--- a/kernel/libc/c11/timespec_get.c
+++ b/kernel/libc/c11/timespec_get.c
@@ -2,23 +2,65 @@
timespec_get.c
Copyright (C) 2023 Lawrence Sebald
- Copyright (C) 2023 Falco Girgis
+ Copyright (C) 2023, 2024 Falco Girgis
*/
#include <time.h>
-#include <arch/timer.h>
-#include <arch/rtc.h>
+#include <errno.h>
+#include <stdbool.h>
-int timespec_get(struct timespec *ts, int base) {
- if(base == TIME_UTC && ts) {
- uint32_t s, ns;
+/* Convert a C11 time base into a POSIX Clock ID. */
+static inline bool posix_clk_id(int base, clockid_t *id) {
+ switch(base) {
+ case TIME_UTC:
+ *id = CLOCK_REALTIME;
+ return true;
+
+ case TIME_MONOTONIC:
+ *id = CLOCK_MONOTONIC;
+ return true;
+
+ case TIME_ACTIVE:
+ *id = CLOCK_PROCESS_CPUTIME_ID;
+ return true;
+
+ case TIME_THREAD_ACTIVE:
+ *id = CLOCK_THREAD_CPUTIME_ID;
+ return true;
+
+ default:
+ return false;
+ }
+}
- timer_ns_gettime(&s, &ns);
- ts->tv_sec = rtc_boot_time() + s;
- ts->tv_nsec = ns;
+/* Proxy a call to a C11/C23 timespec function to a POSIX clock function. */
+static int timespec_posix_adapter(struct timespec *ts,
+ int base,
+ int (*clockfn)(clock_t, struct timespec *)) {
+ clockid_t clk_id;
- return base;
+ if(!posix_clk_id(base, &clk_id))
+ return 0;
+
+ if(!ts)
+ return 0;
+
+ /* errno is not modified from the C11/C23 timespec API! */
+ const int old_errno = errno;
+ if(clockfn(clk_id, ts) == -1) {
+ errno = old_errno;
+ return 0;
}
- return 0;
+ return base;
+}
+
+/* C11 timespec_get() -> POSIX clock_gettime(). */
+int timespec_get(struct timespec *ts, int base) {
+ return timespec_posix_adapter(ts, base, clock_gettime);
+}
+
+/* C23 timespec_getres() -> POSIX clock_getres(). */
+int timespec_getres(struct timespec *ts, int base) {
+ return timespec_posix_adapter(ts, base, clock_getres);
}
diff --git a/kernel/libc/posix/clock_gettime.c b/kernel/libc/posix/clock_gettime.c
index 5e389461..f3ea0d64 100644
--- a/kernel/libc/posix/clock_gettime.c
+++ b/kernel/libc/posix/clock_gettime.c
@@ -53,7 +53,7 @@ int clock_getres(clockid_t clk_id, struct timespec *ts) {
int clock_gettime(clockid_t clk_id, struct timespec *ts) {
lldiv_t div_result;
uint64_t ns64;
- uint32_t secs, nsecs;
+ uint32_t secs, nsecs, secs_offset=0;
if(!ts) {
errno = EFAULT;
@@ -61,14 +61,16 @@ int clock_gettime(clockid_t clk_id, struct timespec *ts) {
}
switch(clk_id) {
- /* Use C11's nanosecond-resolution timestamp */
+ /* Use the nanosecond resolution boot time
+ + RTC bios time */
case CLOCK_REALTIME:
- return timespec_get(ts, TIME_UTC) == TIME_UTC ? 0 : -1;
+ secs_offset = rtc_boot_time();
+ /* fall through */
/* Use the nanosecond resolution boot time */
case CLOCK_MONOTONIC:
timer_ns_gettime(&secs, &nsecs);
- ts->tv_sec = secs;
+ ts->tv_sec = secs + secs_offset;
ts->tv_nsec = nsecs;
return 0;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-05 20:44:22
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via c86818033aa60180853d8006de031093a26be37f (commit)
from ecbde5de56c6f7260afcaab0ad10b92295ba6bc7 (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 c86818033aa60180853d8006de031093a26be37f
Author: Falco Girgis <gyr...@gm...>
Date: Wed Jun 5 15:43:38 2024 -0500
Fixed broken build. (#612)
- Accidentally marked kos_shutdown() static and didn't realize I had
screwed up an external symbol, because I didn't test linking an
example. My bad.
-----------------------------------------------------------------------
Summary of changes:
kernel/libc/newlib/newlib_exit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/libc/newlib/newlib_exit.c b/kernel/libc/newlib/newlib_exit.c
index a2d8a56c..b44c1438 100644
--- a/kernel/libc/newlib/newlib_exit.c
+++ b/kernel/libc/newlib/newlib_exit.c
@@ -13,7 +13,7 @@ extern void arch_exit_handler(int ret_code) __noreturn;
static int ret_code;
-static void kos_shutdown(void) {
+void kos_shutdown(void) {
arch_exit_handler(ret_code);
__builtin_unreachable();
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-05 19:10:20
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via ecbde5de56c6f7260afcaab0ad10b92295ba6bc7 (commit)
from 58f0f53e14c8df0c025385c49dd02ef63bd9bba6 (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 ecbde5de56c6f7260afcaab0ad10b92295ba6bc7
Author: Falco Girgis <gyr...@gm...>
Date: Wed Jun 5 14:09:56 2024 -0500
Resolved symbols when using LTO w/o -fno-builtins (#560)
- LTO without -fno-builtins in the environ.sh has been broken for awhile
- A slew of unresolved symbol errors are reported at linker time
- Had to manually include them within libkallisti.a via adding the
__used pragma to their definitions.
- Confirmed to resolve the issue with GCC-14.1.0.
-----------------------------------------------------------------------
Summary of changes:
kernel/libc/koslib/assert.c | 4 ++--
kernel/libc/newlib/newlib_exit.c | 2 +-
kernel/libc/newlib/newlib_malloc.c | 13 ++++++++-----
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/kernel/libc/koslib/assert.c b/kernel/libc/koslib/assert.c
index 5bf4f618..f566e4be 100644
--- a/kernel/libc/koslib/assert.c
+++ b/kernel/libc/koslib/assert.c
@@ -45,11 +45,11 @@ assert_handler_t assert_set_handler(assert_handler_t hnd) {
return rv;
}
-void __assert(const char *file, int line, const char *expr, const char *msg, const char *func) {
+__used void __assert(const char *file, int line, const char *expr, const char *msg, const char *func) {
if(a_hnd != NULL)
a_hnd(file, line, expr, msg, func);
}
-void __assert_func(const char *file, int line, const char *func, const char *expr) {
+__used void __assert_func(const char *file, int line, const char *func, const char *expr) {
__assert(file, line, expr, NULL, func);
}
diff --git a/kernel/libc/newlib/newlib_exit.c b/kernel/libc/newlib/newlib_exit.c
index c8379532..a2d8a56c 100644
--- a/kernel/libc/newlib/newlib_exit.c
+++ b/kernel/libc/newlib/newlib_exit.c
@@ -21,7 +21,7 @@ static void kos_shutdown(void) {
KOS_INIT_FLAG_WEAK(kos_shutdown, true);
-void _exit(int code) {
+__used void _exit(int code) {
ret_code = code;
KOS_INIT_FLAG_CALL(kos_shutdown);
diff --git a/kernel/libc/newlib/newlib_malloc.c b/kernel/libc/newlib/newlib_malloc.c
index e97bc2a9..ec16315b 100644
--- a/kernel/libc/newlib/newlib_malloc.c
+++ b/kernel/libc/newlib/newlib_malloc.c
@@ -1,7 +1,7 @@
/* KallistiOS ##version##
newlib_malloc.c
- Copyright (C)2004 Megan Potter
+ Copyright (C) 2004 Megan Potter
*/
@@ -10,19 +10,22 @@
// We have to provide these for Newlib's reent pieces.
-void _free_r(struct _reent * re, void *ptr) {
+__used void _free_r(struct _reent *re, void *ptr) {
(void)re;
free(ptr);
}
-void * _malloc_r(struct _reent * re, size_t amt) {
+
+__used void *_malloc_r(struct _reent *re, size_t amt) {
(void)re;
return malloc(amt);
}
-void * _calloc_r(struct _reent * re, size_t nmemb, size_t size) {
+
+__used void *_calloc_r(struct _reent *re, size_t nmemb, size_t size) {
(void)re;
return calloc(nmemb, size);
}
-void * _realloc_r(struct _reent * re, void * ptr, size_t size) {
+
+__used void *_realloc_r(struct _reent *re, void *ptr, size_t size) {
(void)re;
return realloc(ptr, size);
}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-05 18:45: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 58f0f53e14c8df0c025385c49dd02ef63bd9bba6 (commit)
from 52e760a535aa7cf17ae5b417cc938d3e55850bdd (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 58f0f53e14c8df0c025385c49dd02ef63bd9bba6
Author: Falco Girgis <gyr...@gm...>
Date: Wed Jun 5 13:45:20 2024 -0500
Fixed false failure in once_test on 16MB RAM. (#605)
- Accidentally allocated too many goddamn threads only testing on 32MB
units
- Somehow allocation was failing gracefully on 16MB, the program never
crashed, and it just returned a real failure code...
- Running out of memory allocating a thread then trying to join on a
NULL later is apparently pristinely protected against. Impressive.
- Modified test to allocate 475 threads on 16MB and 950 on 32MB.
- Fixed the error code assignment when failing to join the thread, as it
was printing "1" rather than "-1."
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/basic/threading/once/once_test.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/examples/dreamcast/basic/threading/once/once_test.c b/examples/dreamcast/basic/threading/once/once_test.c
index 451e550f..c3c835c4 100644
--- a/examples/dreamcast/basic/threading/once/once_test.c
+++ b/examples/dreamcast/basic/threading/once/once_test.c
@@ -23,7 +23,7 @@
#include <dc/maple/controller.h>
#define UNUSED __attribute__((unused))
-#define THD_COUNT 600
+#define THD_COUNT (475 * (DBL_MEM? 2 : 1))
static kthread_once_t once = KTHREAD_ONCE_INIT;
static spinlock_t lock = SPINLOCK_INITIALIZER;
@@ -64,7 +64,7 @@ static void *thd_func(void *param UNUSED) {
return NULL;
}
-KOS_INIT_FLAGS(INIT_DEFAULT);
+KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
int main(int argc, char *argv[]) {
int i, retval, success = 1;
@@ -91,7 +91,7 @@ int main(int argc, char *argv[]) {
printf("Waiting for the threads to finish\n");
for(i = 0; i < THD_COUNT; ++i) {
- if((retval = thd_join(thds[i], NULL) < 0)) {
+ if((retval = thd_join(thds[i], NULL)) < 0) {
fprintf(stderr, "Failed to join thread[%d]: %d\n",
i, retval);
success = 0;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-05 18:34: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 52e760a535aa7cf17ae5b417cc938d3e55850bdd (commit)
from 8430b8571f0510733e1a7ed0f17aa2c25be68e63 (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 52e760a535aa7cf17ae5b417cc938d3e55850bdd
Author: darcagn <da...@pr...>
Date: Wed Jun 5 12:33:50 2024 -0600
Improve environ.sh handling of built-in flag for fast math (#609)
-----------------------------------------------------------------------
Summary of changes:
doc/environ.sh.sample | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/environ.sh.sample b/doc/environ.sh.sample
index 0c6347b1..c61e2481 100644
--- a/doc/environ.sh.sample
+++ b/doc/environ.sh.sample
@@ -170,9 +170,9 @@ export KOS_CFLAGS="${KOS_CFLAGS} -fno-builtin"
# FSCA, and FSQRT) for calculating sin/cos, inverse square root, and square roots.
# These can result in substantial performance gains for these kinds of operations;
# however, they do so at the price of accuracy and are not IEEE compliant.
-# NOTE: This also requires -fno-builtin be removed from KOS_CFLAGS to take effect!
+# NOTE: Enabling this option will also override -fno-builtin!
#
-#export KOS_CFLAGS="${KOS_CFLAGS} -ffast-math -ffp-contract=fast -mfsrra -mfsca"
+#export KOS_CFLAGS="${KOS_CFLAGS} -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca"
# SH4 Floating Point Arithmetic Precision
#
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: darcagn <da...@us...> - 2024-06-05 18:30: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 8430b8571f0510733e1a7ed0f17aa2c25be68e63 (commit)
via 5fc21196104b589ccf4e32222ea1f9650a5612f5 (commit)
via 90097309419e9a6fc2c9fd095ec8df7aad209ef9 (commit)
via 92b4ca2550b298303e74e9e494de2e8736c07227 (commit)
via 3552b8579c11fb9a47d8b8d62dab299c20af5c66 (commit)
via 66777dacbeb62b259807b6cb565a08f71d52a6df (commit)
via 5fc1d90b03f27f18143cf5ff708d0bcc74fc0c76 (commit)
from 8a8b56a03bade40fffb3fc36e9c0d4ff971a20d5 (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 8430b8571f0510733e1a7ed0f17aa2c25be68e63
Author: Falco Girgis <gyr...@gm...>
Date: Wed Jun 5 13:28:53 2024 -0500
Fixed warnings when compiling with builtins. (#610)
- First warning was about using the string-length of the source of a
strncpy() operation as its length... but its a bullshit, because we
were correctly doing a range check afterwards... oh well, using
strnlen() for the length seemed to appese the gumpy compiler.
- Second warning was legit. _exit(int) without building with
INIT_SHUTDOWN was still returning from a function maked __noreturn.
Added code following the conditional regular shutdown path for when it's
not present to simply log a warning then return back to the BIOS menu.
commit 5fc21196104b589ccf4e32222ea1f9650a5612f5
Merge: 90097309 66777dac
Author: Lawrence Sebald <ljs...@us...>
Date: Tue Jun 4 23:40:46 2024 -0400
Merge pull request #591 from KallistiOS/mingccver
Add Makefile rule to check minimum GCC version
commit 90097309419e9a6fc2c9fd095ec8df7aad209ef9
Author: Donald Haase <qu...@ya...>
Date: Tue Jun 4 23:03:19 2024 -0400
Some cleanups in Maple (#551)
* Standardize maple locking. Don't force status_valid for devices that don't have statuses.
* Refactor driver double registration check.
* Don't truncate devinfo strings, just notify dbglog of the max length of the string
* Change debug level of 'final stats' report to debug
* Standardize polling functions. Invert frame device check logic. Mouse to stdint.
* Add vmu button cond dummy data to normalize the verification of the response size
* Fix corruption in maple frame queue
* Remove message saying that remove inside TAILQ_FOREACH is safe
commit 92b4ca2550b298303e74e9e494de2e8736c07227
Author: Donald Haase <qu...@ya...>
Date: Tue Jun 4 22:51:40 2024 -0400
Malloc leak and debug fixes (#599)
* Cleanups to malloc_debug to get it building and address some warnings.
* Set current thread tid to 0 if threading hasn't been initialized yet
* Ensure that all thread data is freed on shutdown and threads are entirely removed.
* Use LIST_FOREACH_SAFE in places where the items are being removed/freed
* Swap vsprintf for vsnprintf to ensure we don't overrun our buffers. Don't try to output if it failed.
* Correct failure checking on vsnprintf
* Replace debug printfs for dblog. Additionally create static allocations for the function name strings.
* Remove redirect to fs_write(1, str) as that just redirects to the same thing anyways
* Prevent leaking root name
* Free the file table at shutdown even if the user was bad and didn't. Encode the pty exception from fs_write here too.
* Clean up comment about fh exceptions in fs_fdtbl_destroy
* Adjusting dcload type detection to only malloc if needed
* Replace printf in malloc with malloc-less dbgio
* Reduce scope of variable
* Apply suggestions from code review
commit 3552b8579c11fb9a47d8b8d62dab299c20af5c66
Author: Falco Girgis <gyr...@gm...>
Date: Tue Jun 4 18:17:44 2024 -0500
Updated OS-Level TLS Example (#603)
* Updated tls_test.c example.
- Wrote it in a manner so that it can be used for automated testing in
the future with proper exit success/failure codes.
- Spawning way the hell more threads.
- Doing way more with the TLS data to exercise it.
- Actually validating the expected values and correctness rather than
just printing what it should be.
* Addressed review feedback.
commit 66777dacbeb62b259807b6cb565a08f71d52a6df
Author: Falco Girgis <gyr...@gm...>
Date: Thu May 23 19:33:11 2024 -0500
Added a bunch of GCC version checks to examples.
1) UBC "Breaking" example
2) FPU Exception example
3) Stack Protector example
4) C++20 Concurrency example
commit 5fc1d90b03f27f18143cf5ff708d0bcc74fc0c76
Author: darcagn <da...@pr...>
Date: Thu May 23 18:17:47 2024 -0600
Add Makefile rule to check minimum GCC version
-----------------------------------------------------------------------
Summary of changes:
Makefile.rules | 21 +-
examples/dreamcast/basic/breaking/Makefile | 1 +
examples/dreamcast/basic/fpu/exc/Makefile | 6 +-
examples/dreamcast/basic/stackprotector/Makefile | 17 +-
examples/dreamcast/basic/threading/tls/tls_test.c | 116 ++++++--
examples/dreamcast/cpp/concurrency/Makefile | 7 +-
kernel/arch/dreamcast/fs/fs_dcload.c | 23 +-
kernel/arch/dreamcast/hardware/maple/controller.c | 55 ++--
kernel/arch/dreamcast/hardware/maple/dreameye.c | 3 +-
kernel/arch/dreamcast/hardware/maple/keyboard.c | 21 +-
kernel/arch/dreamcast/hardware/maple/lightgun.c | 11 +-
.../arch/dreamcast/hardware/maple/maple_driver.c | 6 +-
kernel/arch/dreamcast/hardware/maple/maple_enum.c | 4 +-
.../dreamcast/hardware/maple/maple_init_shutdown.c | 4 +-
kernel/arch/dreamcast/hardware/maple/maple_irq.c | 6 +-
kernel/arch/dreamcast/hardware/maple/mouse.c | 31 +--
kernel/arch/dreamcast/hardware/maple/purupuru.c | 17 +-
kernel/arch/dreamcast/hardware/maple/sip.c | 18 +-
kernel/arch/dreamcast/hardware/maple/vmu.c | 75 +++--
kernel/arch/dreamcast/hardware/pvr/pvr_mem.c | 4 +-
kernel/arch/dreamcast/include/dc/maple.h | 2 +
kernel/arch/dreamcast/include/dc/maple/mouse.h | 20 +-
kernel/arch/dreamcast/include/dc/maple/vmu.h | 5 +-
kernel/debug/dbgio.c | 5 +-
kernel/exports/nmmgr.c | 4 +-
kernel/fs/fs.c | 5 +-
kernel/fs/fs_ramdisk.c | 1 +
kernel/libc/koslib/dbglog.c | 7 +-
kernel/libc/koslib/malloc.c | 307 +++++++++------------
kernel/libc/koslib/readdir.c | 4 +-
kernel/libc/newlib/newlib_exit.c | 10 +-
kernel/mm/malloc_debug.c | 29 +-
kernel/thread/thread.c | 19 +-
kernel/thread/tls.c | 4 +-
34 files changed, 454 insertions(+), 414 deletions(-)
diff --git a/Makefile.rules b/Makefile.rules
index aafeb9bf..329413f3 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -1,7 +1,8 @@
# KallistiOS ##version##
#
# Makefile.rules
-# (c)2000-2001 Megan Potter
+# Copyright (c) 2000, 2001 Megan Potter
+# Copyright (c) 2024 Eric Fradella
#
# Global KallistiOS Makefile include
@@ -74,3 +75,21 @@ romdisk.o: romdisk.img
$(KOS_CC) -o romdisk.o -r romdisk_tmp.o $(KOS_LIB_PATHS) -Wl,--whole-archive -lromdiskbase
rm romdisk_tmp.o
endif
+
+# Define KOS_GCCVER_MIN in your Makefile if you want to enforce a minimum GCC version.
+ifdef KOS_GCCVER_MIN
+ ifeq ($(shell \
+ awk 'BEGIN { \
+ split("$(KOS_GCCVER_MIN)", min, "."); \
+ split("$(KOS_GCCVER)", cur, "."); \
+ if (cur[1] > min[1] || \
+ (cur[1] == min[1] && cur[2] > min[2]) || \
+ (cur[1] == min[1] && cur[2] == min[2] && cur[3] >= min[3])) { \
+ print 1; \
+ } else { \
+ print 0; \
+ } \
+ }'), 0)
+ $(error A minimum GCC version of $(KOS_GCCVER_MIN) is required, but $(KOS_GCCVER) is currently in use.)
+ endif
+endif
diff --git a/examples/dreamcast/basic/breaking/Makefile b/examples/dreamcast/basic/breaking/Makefile
index 7dfd29be..362230d6 100644
--- a/examples/dreamcast/basic/breaking/Makefile
+++ b/examples/dreamcast/basic/breaking/Makefile
@@ -7,6 +7,7 @@
TARGET = breaking.elf
OBJS = breaking.o
KOS_CFLAGS += -std=gnu2x -Wno-strict-aliasing
+KOS_GCCVER_MIN = 13.0.0
all: rm-elf $(TARGET)
diff --git a/examples/dreamcast/basic/fpu/exc/Makefile b/examples/dreamcast/basic/fpu/exc/Makefile
index c8d46ad9..f6bbb8e7 100644
--- a/examples/dreamcast/basic/fpu/exc/Makefile
+++ b/examples/dreamcast/basic/fpu/exc/Makefile
@@ -1,10 +1,12 @@
#
# FPU Exception Tests
-# (c)2002 Megan Potter
-#
+# Copyright (C) 2002 Megan Potter
+# Copyright (C) 2024 Falco Girgis
+#
TARGET = fpu_exc.elf
OBJS = fpu_exc.o
+KOS_GCCVER_MIN = 5.0.0
all: rm-elf $(TARGET)
diff --git a/examples/dreamcast/basic/stackprotector/Makefile b/examples/dreamcast/basic/stackprotector/Makefile
index 6e4ec0e7..a898d5d2 100644
--- a/examples/dreamcast/basic/stackprotector/Makefile
+++ b/examples/dreamcast/basic/stackprotector/Makefile
@@ -1,15 +1,13 @@
+#
+# Stack Protector Test/Example
+# Copyright (C) 2021 Lawrence Sebald
+# Copyright (C) 2024 Falco Girgis
+#
+
TARGET = stackprotector.elf
OBJS = stackprotector.o
KOS_CFLAGS += -fstack-protector-all
-
-GCC_MAJOR = $(basename $(basename $(KOS_GCCVER)))
-
-ifeq ($(GCC_MAJOR), 4)
-
-all dist clean:
- $(warning GCC4 missing stackprotector patch, skipping)
-
-else
+KOS_GCCVER_MIN = 4.0.0
all: rm-elf $(TARGET)
@@ -34,4 +32,3 @@ dist: $(TARGET)
.PHONY: run dist clean rm-elf
-endif
diff --git a/examples/dreamcast/basic/threading/tls/tls_test.c b/examples/dreamcast/basic/threading/tls/tls_test.c
index 2bf89976..e4db75ec 100644
--- a/examples/dreamcast/basic/threading/tls/tls_test.c
+++ b/examples/dreamcast/basic/threading/tls/tls_test.c
@@ -2,6 +2,7 @@
tls_test.c
Copyright (C) 2009 Lawrence Sebald
+ Copyright (C) 2024 Falco Girgis
*/
@@ -9,6 +10,12 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdatomic.h>
+#include <errno.h>
+#include <string.h>
+
#include <kos/thread.h>
#include <kos/once.h>
#include <kos/tls.h>
@@ -17,38 +24,53 @@
#include <dc/maple.h>
#include <dc/maple/controller.h>
+#define THREAD_COUNT 100
+
#define UNUSED __attribute__((unused))
-kthread_once_t once = KTHREAD_ONCE_INIT;
-kthread_key_t key1, key2;
+static kthread_once_t once = KTHREAD_ONCE_INIT;
+static kthread_key_t key1, key2;
+static atomic_uint dtor_counter;
-void destructor(void *data) {
+static void destructor(void *data) {
printf("Destroying %d\n", (int)data);
+ ++dtor_counter;
}
-void once_func(void) {
+static void once_func(void) {
if(kthread_key_create(&key2, &destructor)) {
- printf("Error in calling kthread_key_create\n");
+ fprintf(stderr, "Error in calling kthread_key_create\n");
}
}
-void *thd_func(void *param UNUSED) {
+static void *thd_func(void *param UNUSED) {
kthread_t *cur = thd_get_current();
void *data;
+ int retval;
printf("Thd %d: Reading key 1\n", cur->tid);
data = kthread_getspecific(key1);
+
printf("Thd %d: kthread_getspecific returned %p (should be NULL)\n",
cur->tid, data);
+ if(data) {
+ fprintf(stderr, "Unexpected key 1 value: %p\n", data);
+ thd_exit((void *)false);
+ }
+
printf("Thd %d: Will create key 2, if its not created\n", cur->tid);
- kthread_once(&once, &once_func);
+
+ if((retval = kthread_once(&once, &once_func))) {
+ fprintf(stderr, "kthread_once failed with %s!\n", strerror(errno));
+ thd_exit((void *)false);
+ }
printf("Thd %d: Writing to key 2\n", cur->tid);
if(kthread_setspecific(key2, (void *)cur->tid)) {
- printf("Error in kthread_setspecific!!!\n");
- thd_exit(NULL);
+ fprintf(stderr, "Error in kthread_setspecific!!!\n");
+ thd_exit((void *)false);
}
if(cur->tid & 0x01) {
@@ -60,49 +82,93 @@ void *thd_func(void *param UNUSED) {
data = kthread_getspecific(key2);
printf("Thd %d: kthread_getspecific returned %d (should be %d)\n", cur->tid,
(int)data, cur->tid);
- return NULL;
+
+ if((int)data != cur->tid) {
+ fprintf(stderr, "Invalid value for key2: %p\n", data);
+ thd_exit((void *)false);
+ }
+
+ return (void *)true;
}
-KOS_INIT_FLAGS(INIT_DEFAULT);
+KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
int main(int argc, char *argv[]) {
- kthread_t *thds[2];
+ kthread_t *thds[THREAD_COUNT];
void *data;
+ bool success = true;
+ int retval;
cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y,
(cont_btn_callback_t)arch_exit);
- printf("KallistiOS TLS test program\n");
+ printf("KallistiOS TLS test program\n\n");
printf("Main thread: Creating key 1\n");
if(kthread_key_create(&key1, NULL)) {
- printf("Error in creating key 1\n");
- exit(-1);
+ fprintf(stderr, "Error in creating key 1\n");
+ exit(EXIT_FAILURE);
}
printf("Main thread: Setting key 1 to 0xDEADBEEF\n");
- kthread_setspecific(key1, (void *)0xDEADBEEF);
+
+ if((retval = kthread_setspecific(key1, (void *)0xDEADBEEF))) {
+ fprintf(stderr, "kthread_setspecific() failed: %d\n", retval);
+ exit(EXIT_FAILURE);
+ }
+
data = kthread_getspecific(key1);
printf("Main thread: Key 1 value: %p\n", data);
+ if(data != (void *)0xDEADBEEF) {
+ fprintf(stderr, "Unexpected kthread_getspecific() value: %p\n", data);
+ exit(EXIT_FAILURE);
+ }
+
/* Create the threads. */
- printf("Main therad: Creating 2 threads\n");
- thds[0] = thd_create(0, &thd_func, NULL);
- thds[1] = thd_create(0, &thd_func, NULL);
+ printf("Main thread: Creating %d threads\n", THREAD_COUNT);
+ for(int t = 0; t < THREAD_COUNT; ++t)
+ thds[t] = thd_create(0, &thd_func, NULL);
printf("Main thread: Waiting for the threads to finish\n");
- thd_join(thds[0], NULL);
- thd_join(thds[1], NULL);
+ for(int t = 0; t < THREAD_COUNT; ++t) {
+ thd_join(thds[t], &data);
+ success &= (bool)data;
+ }
+
+ if(!success) {
+ fprintf(stderr, "Test failed!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(dtor_counter != THREAD_COUNT) {
+ fprintf(stderr, "Incorrect destructor counter value: %u\n",
+ dtor_counter);
+ exit(EXIT_FAILURE);
+ } else {
+ printf("Correct destructor counter value: %u\n", dtor_counter);
+ }
data = kthread_getspecific(key1);
printf("Main thread: Key 1 value: %p\n", data);
+ if(data != (void *)0xDEADBEEF) {
+ fprintf(stderr, "Unexpected final kthread_getspecific() value: %p\n", data);
+ exit(EXIT_FAILURE);
+ }
+
printf("Main thread: Removing keys\n");
- kthread_key_delete(key1);
- kthread_key_delete(key2);
- printf("Test finished\n");
+ success &= !kthread_key_delete(key1);
+ success &= !kthread_key_delete(key2);
+
+ if(!success) {
+ fprintf(stderr, "Failed to delete kthread keys!\n");
+ exit(EXIT_FAILURE);
+ }
+
+ printf("\n===== TLS TEST SUCCESS =====\n");
- return 0;
+ return EXIT_SUCCESS;
}
diff --git a/examples/dreamcast/cpp/concurrency/Makefile b/examples/dreamcast/cpp/concurrency/Makefile
index 36ab65b0..16eac365 100644
--- a/examples/dreamcast/cpp/concurrency/Makefile
+++ b/examples/dreamcast/cpp/concurrency/Makefile
@@ -1,11 +1,12 @@
#
# C++ Concurrency Test/Example
-# (c) 2023 Falco Girgis
-#
+# Copyright (C) 2023, 2024 Falco Girgis
+#
TARGET = concurrency.elf
OBJS = concurrency.o
-KOS_CPPFLAGS += -std=c++20
+KOS_CPPFLAGS += -std=c++20
+KOS_GCCVER_MIN = 12.0.0
all: rm-elf $(TARGET)
diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c
index f43b2082..a937f125 100644
--- a/kernel/arch/dreamcast/fs/fs_dcload.c
+++ b/kernel/arch/dreamcast/fs/fs_dcload.c
@@ -513,17 +513,20 @@ void fs_dcload_init_console(void) {
if(*DCLOADMAGICADDR != DCLOADMAGICVALUE)
return;
- /* Give dcload the 64k it needs to compress data (if on serial) */
- dcload_wrkmem = malloc(65536);
- if(dcload_wrkmem) {
- if(dclsc(DCLOAD_ASSIGNWRKMEM, dcload_wrkmem) == -1) {
- free(dcload_wrkmem);
- dcload_type = DCLOAD_TYPE_IP;
- dcload_wrkmem = NULL;
- }
- else {
- dcload_type = DCLOAD_TYPE_SER;
+ /* dcload IP will always return -1 here. Serial will return 0 and make
+ no change since it already holds 0 as 'no mem assigned */
+ if(dclsc(DCLOAD_ASSIGNWRKMEM, 0) == -1) {
+ dcload_type = DCLOAD_TYPE_IP;
+ }
+ else {
+ dcload_type = DCLOAD_TYPE_SER;
+
+ /* Give dcload the 64k it needs to compress data (if on serial) */
+ dcload_wrkmem = malloc(65536);
+ if(dcload_wrkmem) {
+ if(dclsc(DCLOAD_ASSIGNWRKMEM, dcload_wrkmem) == -1)
+ free(dcload_wrkmem);
}
}
}
diff --git a/kernel/arch/dreamcast/hardware/maple/controller.c b/kernel/arch/dreamcast/hardware/maple/controller.c
index 1db9bfa0..02139d9a 100644
--- a/kernel/arch/dreamcast/hardware/maple/controller.c
+++ b/kernel/arch/dreamcast/hardware/maple/controller.c
@@ -71,32 +71,32 @@ static void cont_reply(maple_state_t *st, maple_frame_t *frm) {
if(respbuf[0] != MAPLE_FUNC_CONTROLLER)
return;
- /* Update the status area from the response */
- if(frm->dev) {
- /* Verify the size of the frame and grab a pointer to it */
- assert(sizeof(cont_cond_t) == ((resp->data_len - 1) * sizeof(uint32_t)));
- raw = (cont_cond_t *)(respbuf + 1);
-
- /* Fill the "nice" struct from the raw data */
- cooked = (cont_state_t *)(frm->dev->status);
- cooked->buttons = (~raw->buttons) & 0xffff;
- cooked->ltrig = raw->ltrig;
- cooked->rtrig = raw->rtrig;
- cooked->joyx = ((int)raw->joyx) - 128;
- cooked->joyy = ((int)raw->joyy) - 128;
- cooked->joy2x = ((int)raw->joy2x) - 128;
- cooked->joy2y = ((int)raw->joy2y) - 128;
- frm->dev->status_valid = 1;
-
- /* Check for magic button sequences */
- if(btn_callback) {
- if(!btn_callback_addr ||
- (btn_callback_addr &&
- btn_callback_addr == maple_addr(frm->dev->port, frm->dev->unit))) {
- if((cooked->buttons & btn_callback_btns) == btn_callback_btns) {
- btn_callback(maple_addr(frm->dev->port, frm->dev->unit),
- cooked->buttons);
- }
+ if(!frm->dev)
+ return;
+
+ /* Verify the size of the frame and grab a pointer to it */
+ assert(sizeof(cont_cond_t) == ((resp->data_len - 1) * sizeof(uint32_t)));
+ raw = (cont_cond_t *)(respbuf + 1);
+
+ /* Fill the "nice" struct from the raw data */
+ cooked = (cont_state_t *)(frm->dev->status);
+ cooked->buttons = (~raw->buttons) & 0xffff;
+ cooked->ltrig = raw->ltrig;
+ cooked->rtrig = raw->rtrig;
+ cooked->joyx = ((int)raw->joyx) - 128;
+ cooked->joyy = ((int)raw->joyy) - 128;
+ cooked->joy2x = ((int)raw->joy2x) - 128;
+ cooked->joy2y = ((int)raw->joy2y) - 128;
+ frm->dev->status_valid = 1;
+
+ /* Check for magic button sequences */
+ if(btn_callback) {
+ if(!btn_callback_addr ||
+ (btn_callback_addr &&
+ btn_callback_addr == maple_addr(frm->dev->port, frm->dev->unit))) {
+ if((cooked->buttons & btn_callback_btns) == btn_callback_btns) {
+ btn_callback(maple_addr(frm->dev->port, frm->dev->unit),
+ cooked->buttons);
}
}
}
@@ -137,8 +137,7 @@ static maple_driver_t controller_drv = {
/* Add the controller to the driver chain */
void cont_init(void) {
- if(!controller_drv.drv_list.le_prev)
- maple_driver_reg(&controller_drv);
+ maple_driver_reg(&controller_drv);
}
void cont_shutdown(void) {
diff --git a/kernel/arch/dreamcast/hardware/maple/dreameye.c b/kernel/arch/dreamcast/hardware/maple/dreameye.c
index 94c9cde8..41363ff6 100644
--- a/kernel/arch/dreamcast/hardware/maple/dreameye.c
+++ b/kernel/arch/dreamcast/hardware/maple/dreameye.c
@@ -439,8 +439,7 @@ static maple_driver_t dreameye_drv = {
/* Add the Dreameye to the driver chain */
void dreameye_init(void) {
- if(!dreameye_drv.drv_list.le_prev)
- maple_driver_reg(&dreameye_drv);
+ maple_driver_reg(&dreameye_drv);
}
void dreameye_shutdown(void) {
diff --git a/kernel/arch/dreamcast/hardware/maple/keyboard.c b/kernel/arch/dreamcast/hardware/maple/keyboard.c
index 9fdb04aa..6ee49dc3 100644
--- a/kernel/arch/dreamcast/hardware/maple/keyboard.c
+++ b/kernel/arch/dreamcast/hardware/maple/keyboard.c
@@ -602,14 +602,18 @@ static void kbd_reply(maple_state_t *st, maple_frame_t *frm) {
if(respbuf[0] != MAPLE_FUNC_KEYBOARD)
return;
+ if(!frm->dev)
+ return;
+
+ /* Verify the size of the frame */
+ assert(sizeof(kbd_cond_t) == ((resp->data_len - 1) * sizeof(uint32_t)));
+
/* Update the status area from the response */
- if(frm->dev) {
- state = (kbd_state_t *)frm->dev->status;
- cond = (kbd_cond_t *)&state->cond;
- memcpy(cond, respbuf + 1, (resp->data_len - 1) * sizeof(*respbuf));
- frm->dev->status_valid = 1;
- kbd_check_poll(frm);
- }
+ state = (kbd_state_t *)frm->dev->status;
+ cond = (kbd_cond_t *)&state->cond;
+ memcpy(cond, respbuf + 1, (resp->data_len - 1) * sizeof(uint32_t));
+ frm->dev->status_valid = 1;
+ kbd_check_poll(frm);
}
static int kbd_poll_intern(maple_device_t *dev) {
@@ -674,8 +678,7 @@ static maple_driver_t kbd_drv = {
/* Add the keyboard to the driver chain */
void kbd_init(void) {
- if(!kbd_drv.drv_list.le_prev)
- maple_driver_reg(&kbd_drv);
+ maple_driver_reg(&kbd_drv);
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-06-04 13:38: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 8a8b56a03bade40fffb3fc36e9c0d4ff971a20d5 (commit)
from 7f261a396099cfd4cbbd771108bf670914568ed6 (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 8a8b56a03bade40fffb3fc36e9c0d4ff971a20d5
Author: Donald Haase <qu...@ya...>
Date: Tue Jun 4 09:38:10 2024 -0400
Avoid infinite loop. (#604)
Co-authored-by: QuzarDC <qu...@co...>
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/libdream/mouse/mouse.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/examples/dreamcast/libdream/mouse/mouse.c b/examples/dreamcast/libdream/mouse/mouse.c
index b033ba8a..13be6577 100644
--- a/examples/dreamcast/libdream/mouse/mouse.c
+++ b/examples/dreamcast/libdream/mouse/mouse.c
@@ -13,10 +13,6 @@ void mouse_test(void) {
if(!cont) continue;
- mouse = maple_enum_type(0, MAPLE_FUNC_MOUSE);
-
- if(!mouse) continue;
-
/* Check for start on the controller */
cstate = (cont_state_t *)maple_dev_status(cont);
@@ -32,11 +28,14 @@ void mouse_test(void) {
thd_sleep(10);
+ mouse = maple_enum_type(0, MAPLE_FUNC_MOUSE);
+
+ if(!mouse) continue;
+
/* Check for mouse input */
mstate = (mouse_state_t *)maple_dev_status(mouse);
- if(!mstate)
- continue;
+ if(!mstate) continue;
/* Move the cursor if applicable */
if(mstate->dx || mstate->dy || mstate->dz) {
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-06-03 02:34:03
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 7f261a396099cfd4cbbd771108bf670914568ed6 (commit)
from cfcd40fd57bab6de70c181e48b0eea1db4b263a6 (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 7f261a396099cfd4cbbd771108bf670914568ed6
Author: Donald Haase <qu...@ya...>
Date: Sun Jun 2 22:33:50 2024 -0400
Better error/warning handling in some examples (#589)
* Correcting possible null derefs and similar from fanalyzer
* Notify gcc that we are going to be doing the bad things and not worry
* Prevent fanalyzer warning for intentional null deref
* Idiomatic typing
* Prevent null deref
* Prevent null deref
* Static allocate the temp beffer, it was being leaked anyways
* Rollback pointless check
* Resolve conflict due to other changes
* Properly free memory and close stuff
* Make sure to free used allocations
* Protect string printing from buffer overflow and expand the buffer to fit the longer ns text.
* Apply suggestions from code review
Co-authored-by: Falco Girgis <gyr...@gm...>
---------
Co-authored-by: QuzarDC <qu...@co...>
Co-authored-by: Falco Girgis <gyr...@gm...>
-----------------------------------------------------------------------
Summary of changes:
examples/dreamcast/2ndmix/2ndmix.c | 11 +++++++++++
examples/dreamcast/basic/mmu/nullptr/nullptr.c | 12 +++++++++---
examples/dreamcast/basic/mmu/pvrmap/pvrmap.c | 17 +++++++++++++----
.../dreamcast/basic/stackprotector/stackprotector.c | 8 ++++++++
examples/dreamcast/dev/devroot/devroot.c | 4 +++-
examples/dreamcast/network/httpd/httpd.c | 16 ++++++++++++++--
examples/dreamcast/parallax/serpent_dma/perfmeter.c | 2 +-
examples/dreamcast/parallax/serpent_dma/serpent.c | 7 ++++---
examples/dreamcast/png/example.c | 9 +++++----
examples/dreamcast/rumble/rumble.c | 4 ++++
examples/dreamcast/sound/multi-stream/main.c | 3 ++-
examples/dreamcast/sound/sfx/main.c | 3 ++-
examples/dreamcast/vmu/vmu_beep/beep.c | 13 ++++++++++---
13 files changed, 86 insertions(+), 23 deletions(-)
diff --git a/examples/dreamcast/2ndmix/2ndmix.c b/examples/dreamcast/2ndmix/2ndmix.c
index 3c6470c6..4a4089a8 100644
--- a/examples/dreamcast/2ndmix/2ndmix.c
+++ b/examples/dreamcast/2ndmix/2ndmix.c
@@ -398,6 +398,11 @@ int load_pcx(char *pcxdata) {
int num_bytes;
struct pcx_hdr pcxh;
+ if(image == NULL) {
+ printf("Image not allocated\r\n");
+ return 0;
+ }
+
bytes = 0;
memcpy(&pcxh, pcxdata, sizeof(pcxh));
@@ -857,6 +862,12 @@ int main() {
draw_one_frame();
}
+ /* Clean up what we allocated */
+ free(charmap);
+ free(star_x);
+ free(star_y);
+ free(star_z);
+
printf("Done, returning\n");
return 0;
}
diff --git a/examples/dreamcast/basic/mmu/nullptr/nullptr.c b/examples/dreamcast/basic/mmu/nullptr/nullptr.c
index fbb0cf44..861570fd 100644
--- a/examples/dreamcast/basic/mmu/nullptr/nullptr.c
+++ b/examples/dreamcast/basic/mmu/nullptr/nullptr.c
@@ -29,10 +29,18 @@ int main(int argc, char **argv) {
/* Set our handler */
mmu_map_set_callback(catchnull);
+/* Make sure the compiler doesn't complain about the bad thing
+we are doing intentionally */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
+
/* Do something naughty; note that this will actually work
for both reads and writes in this case, but we can only
really effectively test one ;) */
- *((uint16*)NULL) = 0;
+ *((uint16_t *)NULL) = 0;
+
+/* Turn the warning back on */
+#pragma GCC diagnostic pop
/* We shouldn't get here... */
@@ -41,5 +49,3 @@ int main(int argc, char **argv) {
return 0;
}
-
-
diff --git a/examples/dreamcast/basic/mmu/pvrmap/pvrmap.c b/examples/dreamcast/basic/mmu/pvrmap/pvrmap.c
index f24ff5c8..656b0196 100644
--- a/examples/dreamcast/basic/mmu/pvrmap/pvrmap.c
+++ b/examples/dreamcast/basic/mmu/pvrmap/pvrmap.c
@@ -15,8 +15,9 @@ KOS_INIT_FLAGS(INIT_DEFAULT | INIT_MALLOCSTATS);
int main(int argc, char **argv) {
mmucontext_t * cxt;
- uint16 * vr;
- int x, y, done = 0;
+ uint16_t * vr;
+ bool done = false;
+ uint16_t x, y = 0;
/* Initialize MMU support */
mmu_init();
@@ -33,9 +34,14 @@ int main(int argc, char **argv) {
/* Draw a nice pattern to the NULL space */
vr = NULL;
+/* Make sure the compiler doesn't complain about the bad thing
+we are doing intentionally */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
+
for(y = 0; y < 480; y++) {
for(x = 0; x < 640; x++) {
- int v = ((x * x + y * y) & 255);
+ uint8_t v = ((x * x + y * y) & 0xff);
if(v >= 128)
v = 127 - (v - 128);
@@ -46,6 +52,9 @@ int main(int argc, char **argv) {
}
}
+/* Turn the warning back on */
+#pragma GCC diagnostic pop
+
/* Draw some text */
bfont_draw_str(vr + 20 * 640 + 20, 640, 0, "Press START!");
@@ -54,7 +63,7 @@ int main(int argc, char **argv) {
MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
if(st->buttons & CONT_START)
- done = 1;
+ done = true;
MAPLE_FOREACH_END()
}
diff --git a/examples/dreamcast/basic/stackprotector/stackprotector.c b/examples/dreamcast/basic/stackprotector/stackprotector.c
index ca89b594..235840fc 100644
--- a/examples/dreamcast/basic/stackprotector/stackprotector.c
+++ b/examples/dreamcast/basic/stackprotector/stackprotector.c
@@ -49,11 +49,19 @@ __used void __stack_chk_fail(void) {
exit(EXIT_SUCCESS);
}
+/* Make sure the compiler doesn't complain about the bad thing
+we are doing intentionally */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds"
+
__noinline void badfunc(void) {
char buffer[8];
strcpy(buffer, "This string is entirely too long and will overflow.");
}
+/* Turn the warning back on */
+#pragma GCC diagnostic pop
+
int main(int argc, char **argv) {
printf("Stack protector test....\n");
printf("About to call badfunc()...\n");
diff --git a/examples/dreamcast/dev/devroot/devroot.c b/examples/dreamcast/dev/devroot/devroot.c
index 8e4ea5e1..34b00439 100644
--- a/examples/dreamcast/dev/devroot/devroot.c
+++ b/examples/dreamcast/dev/devroot/devroot.c
@@ -2,7 +2,7 @@
devroot.c
Copyright (C) 2024 Donald Haase
-
+
This example demonstrates the expected behavior of reading from the
/ and /dev dirs, as well as attempting to open a non-existant device
for the same.
@@ -43,6 +43,8 @@ void printdir(char* fn) {
}
else
printf("FAIL: Counted %i entries the first time and %i the second.\n", cnt1, cnt2);
+
+ closedir(d);
}
}
diff --git a/examples/dreamcast/network/httpd/httpd.c b/examples/dreamcast/network/httpd/httpd.c
index 6d848afb..311bb984 100644
--- a/examples/dreamcast/network/httpd/httpd.c
+++ b/examples/dreamcast/network/httpd/httpd.c
@@ -104,6 +104,9 @@ int read_headers(http_state_t * hs, char * buffer, int bufsize) {
char fn[256];
int i, j;
+ if(buffer == NULL)
+ return -2;
+
for(i = 0; ; i++) {
if(readline(hs->socket, buffer, bufsize) < 0) {
if(i > 0)
@@ -143,6 +146,9 @@ static const char * errmsg3 = "</h4>\n<hr>\nKOSHttp/1.0 server\n</body></html>";
int send_error(http_state_t * hs, int errcode, const char * str) {
char * buffer = malloc(65536);
+ if(buffer == NULL)
+ return -1;
+
sprintf(buffer, "HTTP/1.0 %d %s\r\nContent-type: text/html\r\n\r\n", errcode, str);
write(hs->socket, buffer, strlen(buffer));
@@ -181,6 +187,9 @@ int do_dirlist(const char * name, http_state_t * hs, file_t f) {
dl = malloc(65536);
dlout = dl;
+
+ if(dl == NULL)
+ return -1;
sprintf(dlout, "<html><head><title>Listing of %s</title></head></html>\n<body bgcolor=\"white\">\n", name);
dlout += strlen(dlout);
@@ -210,8 +219,10 @@ int do_dirlist(const char * name, http_state_t * hs, file_t f) {
while(dlsize > 0) {
r = write(hs->socket, dlout, dlsize);
- if(r <= 0)
+ if(r <= 0) {
+ free(dl);
return -1;
+ }
dlsize -= r;
dlout += r;
@@ -253,7 +264,8 @@ void *client_thread(void *p) {
f = fs_open(buf, O_RDONLY);
if(f < 0) {
- send_error(hs, 404, "File not found or unreadable");
+ if(send_error(hs, 404, "File not found or unreadable") < 0)
+ printf("Error sending 404\n");
goto out;
}
diff --git a/examples/dreamcast/parallax/serpent_dma/perfmeter.c b/examples/dreamcast/parallax/serpent_dma/perfmeter.c
index 8eeca655..8934e7e7 100644
--- a/examples/dreamcast/parallax/serpent_dma/perfmeter.c
+++ b/examples/dreamcast/parallax/serpent_dma/perfmeter.c
@@ -35,7 +35,7 @@ void pm_drawbar(float pct, float posx, float posy, float posz,
}
void pm_draw(void) {
- char str[64];
+ char str[128];
float pct;
float posx = 64, posy = 96, posz = 4500;
diff --git a/examples/dreamcast/parallax/serpent_dma/serpent.c b/examples/dreamcast/parallax/serpent_dma/serpent.c
index 4d3fa65a..8f5cdcfe 100644
--- a/examples/dreamcast/parallax/serpent_dma/serpent.c
+++ b/examples/dreamcast/parallax/serpent_dma/serpent.c
@@ -51,9 +51,10 @@ static void sphere(sphere_t *s) { /* {{{ */
float yaw;
pvr_vertex_t *v;
- v = (pvr_vertex_t *)malloc(s->stacks * (s->slices + 2) * sizeof(pvr_vertex_t) + 32);
- v = (pvr_vertex_t *)(((uint32)v & ~31) + 32); /* align to 32 bytes */
- s->data = v;
+ s->data = (pvr_vertex_t *)memalign(32, s->stacks * (s->slices + 2) * sizeof(pvr_vertex_t));
+ if(s->data == NULL) return;
+
+ v = s->data;
// s->data_trans = (pvr_vertex_t *)malloc(s->stacks * (s->slices+2) * sizeof(pvr_vertex_t));
/* transformed data -- for testing mat_transform */
printf("allocated %d bytes for %d stacks, %d + 2 slices, and %d-byte pvr_vertex_t\n",
diff --git a/examples/dreamcast/png/example.c b/examples/dreamcast/png/example.c
index 130ba422..e9115610 100644
--- a/examples/dreamcast/png/example.c
+++ b/examples/dreamcast/png/example.c
@@ -30,10 +30,9 @@ void back_init(void) {
/* init font */
void font_init(void) {
int i, x, y, c;
- unsigned short * temp_tex;
+ unsigned short temp_tex[256 * 128 * 2];
font_tex = pvr_mem_malloc(256 * 256 * 2);
- temp_tex = (unsigned short *)malloc(256 * 128 * 2);
c = 0;
@@ -53,14 +52,14 @@ void font_init(void) {
c += 16;
}
- pvr_txr_load_ex(temp_tex, font_tex, 256, 256, PVR_TXRLOAD_16BPP);
+ pvr_txr_load_ex(&temp_tex, font_tex, 256, 256, PVR_TXRLOAD_16BPP);
}
void text_init(void) {
int length = zlib_getlength("/rd/text.gz");
gzFile f;
- data = (char *)malloc(length + 1); // I am not currently freeing it
+ data = (char *)malloc(length + 1);
f = gzopen("/rd/text.gz", "r");
gzread(f, data, length);
@@ -234,6 +233,8 @@ int main(int argc, char **argv) {
draw_frame();
}
+ free(data);
+
return 0;
}
diff --git a/examples/dreamcast/rumble/rumble.c b/examples/dreamcast/rumble/rumble.c
index 391e8836..74d6aa32 100644
--- a/examples/dreamcast/rumble/rumble.c
+++ b/examples/dreamcast/rumble/rumble.c
@@ -195,5 +195,9 @@ int main(int argc, char *argv[]) {
/* Stop rumbling before exiting, if it still exists. */
if((purudev != NULL) && (purudev->valid != 0))
purupuru_rumble_raw(purudev, 0x00000000);
+
+ plx_font_destroy(fnt);
+ plx_fcxt_destroy(cxt);
+
return 0;
}
diff --git a/examples/dreamcast/sound/multi-stream/main.c b/examples/dreamcast/sound/multi-stream/main.c
index 2a99c086..474c725f 100644
--- a/examples/dreamcast/sound/multi-stream/main.c
+++ b/examples/dreamcast/sound/multi-stream/main.c
@@ -42,7 +42,8 @@ int main(int argc, char **argv) {
for(;;) {
- cond = get_cont_state();
+ if(!(cond = get_cont_state()))
+ continue;
current_buttons = cond->buttons;
changed_buttons = current_buttons ^ previous_buttons;
previous_buttons = current_buttons;
diff --git a/examples/dreamcast/sound/sfx/main.c b/examples/dreamcast/sound/sfx/main.c
index 043566ee..7a4cf1a8 100644
--- a/examples/dreamcast/sound/sfx/main.c
+++ b/examples/dreamcast/sound/sfx/main.c
@@ -48,7 +48,8 @@ int main(int argc, char **argv) {
uint32_t previous_buttons = 0;
for(;;) {
- cond = get_cont_state();
+ if(!(cond = get_cont_state()))
+ continue;
current_buttons = cond->buttons;
changed_buttons = current_buttons ^ previous_buttons;
previous_buttons = current_buttons;
diff --git a/examples/dreamcast/vmu/vmu_beep/beep.c b/examples/dreamcast/vmu/vmu_beep/beep.c
index 79f50eee..ea600717 100644
--- a/examples/dreamcast/vmu/vmu_beep/beep.c
+++ b/examples/dreamcast/vmu/vmu_beep/beep.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <stdint.h>
+#include <stdlib.h>
#include <kos/init.h>
@@ -37,13 +38,18 @@
#include <plx/font.h>
-KOS_INIT_FLAGS(INIT_DEFAULT);
+
+static plx_font_t *fnt;
+static plx_fcxt_t *cxt;
+
+static void cleanup(void) {
+ plx_font_destroy(fnt);
+ plx_fcxt_destroy(cxt);
+}
int main(int argc, char *argv[]) {
maple_device_t *dev, *vmudev;
cont_state_t *state;
- plx_font_t *fnt;
- plx_fcxt_t *cxt;
point_t w;
int i = 0, count = 0;
uint16_t old_buttons = 0, rel_buttons = 0;
@@ -51,6 +57,7 @@ int main(int argc, char *argv[]) {
uint8_t n[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; //nibbles
char s[8][2] = { "", "", "", "", "", "", "", "" };
+ atexit(cleanup);
/* If the face buttons are all pressed, exit the app */
cont_btn_callback(0, CONT_START | CONT_A | CONT_B | CONT_X | CONT_Y,
(cont_btn_callback_t)arch_exit);
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-06-03 02:32:24
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via cfcd40fd57bab6de70c181e48b0eea1db4b263a6 (commit)
via e6a50173d1a7c94a633bceffe1d30b37038fb676 (commit)
from 34f7e943d311cd0105eb012571e7fcda41d3370d (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 cfcd40fd57bab6de70c181e48b0eea1db4b263a6
Author: Donald Haase <qu...@ya...>
Date: Sun Jun 2 22:31:52 2024 -0400
Correct bitmasks in fpu_exc stringify (#601)
Co-authored-by: QuzarDC <qu...@co...>
commit e6a50173d1a7c94a633bceffe1d30b37038fb676
Author: Andy Barajas <and...@gm...>
Date: Sun Jun 2 19:23:12 2024 -0700
Diagnose help on reg dumps (#600)
* Print out command to help diagnose kernal panic reg dump
-----------------------------------------------------------------------
Summary of changes:
environ_base.sh | 1 +
examples/dreamcast/basic/fpu/exc/fpu_exc.c | 4 +-
kernel/arch/dreamcast/include/arch/stack.h | 2 +-
kernel/arch/dreamcast/kernel/irq.c | 73 +++++++++++++++++++++++++++---
kernel/arch/dreamcast/kernel/panic.c | 2 +-
kernel/arch/dreamcast/kernel/stack.c | 15 ++++--
6 files changed, 84 insertions(+), 13 deletions(-)
diff --git a/environ_base.sh b/environ_base.sh
index ada69c13..446e3b3a 100644
--- a/environ_base.sh
+++ b/environ_base.sh
@@ -33,6 +33,7 @@ export KOS_AS="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-as"
export KOS_AR="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-gcc-ar"
export KOS_OBJCOPY="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-objcopy"
export KOS_OBJDUMP="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-objdump"
+export KOS_ADDR2LINE="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-addr2line"
export KOS_LD="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-ld"
export KOS_RANLIB="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-gcc-ranlib"
export KOS_STRIP="${KOS_CC_BASE}/bin/${KOS_CC_PREFIX}-strip"
diff --git a/examples/dreamcast/basic/fpu/exc/fpu_exc.c b/examples/dreamcast/basic/fpu/exc/fpu_exc.c
index 718d5e0d..3f42cfaf 100644
--- a/examples/dreamcast/basic/fpu/exc/fpu_exc.c
+++ b/examples/dreamcast/basic/fpu/exc/fpu_exc.c
@@ -42,8 +42,8 @@ fpscr_stringify(unsigned int value, char* buffer, size_t bytes) {
!!(value & (1 << 19)),
!!(value & (1 << 18)),
(value >> 12) & 0x3f,
- (value >> 7) & 0x3f,
- (value >> 2) & 0x3f,
+ (value >> 7) & 0x1f,
+ (value >> 2) & 0x1f,
value & 0x3);
return buffer;
diff --git a/kernel/arch/dreamcast/include/arch/stack.h b/kernel/arch/dreamcast/include/arch/stack.h
index 38f1b0be..d3f5062b 100644
--- a/kernel/arch/dreamcast/include/arch/stack.h
+++ b/kernel/arch/dreamcast/include/arch/stack.h
@@ -53,7 +53,7 @@ void arch_stk_trace(int n);
\param fp The frame pointer to start from.
\param n The number of frames to leave off.
*/
-void arch_stk_trace_at(uint32 fp, int n);
+void arch_stk_trace_at(uint32_t fp, size_t n);
/** @} */
diff --git a/kernel/arch/dreamcast/kernel/irq.c b/kernel/arch/dreamcast/kernel/irq.c
index e4840ac1..dbb75e01 100644
--- a/kernel/arch/dreamcast/kernel/irq.c
+++ b/kernel/arch/dreamcast/kernel/irq.c
@@ -83,10 +83,48 @@ int trapa_set_handler(irq_t code, irq_handler hnd, void *data) {
return 0;
}
+/* Get a string description of the exception */
+static char *irq_exception_string(int evt) {
+ switch(evt) {
+ case EXC_ILLEGAL_INSTR:
+ return "Illegal instruction";
+ case EXC_SLOT_ILLEGAL_INSTR:
+ return "Slot illegal instruction";
+ case EXC_GENERAL_FPU:
+ return "General FPU exception";
+ case EXC_SLOT_FPU:
+ return "Slot FPU exception";
+ case EXC_DATA_ADDRESS_READ:
+ return "Data address error (read)";
+ case EXC_DATA_ADDRESS_WRITE:
+ return "Data address error (write)";
+ case EXC_DTLB_MISS_READ: /* or EXC_ITLB_MISS */
+ return "Instruction or Data(read) TLB miss";
+ case EXC_DTLB_MISS_WRITE:
+ return "Data(write) TLB miss";
+ case EXC_DTLB_PV_READ: /* or EXC_ITLB_PV */
+ return "Instruction or Data(read) TLB protection violation";
+ case EXC_DTLB_PV_WRITE:
+ return "Data TLB protection violation (write)";
+ case EXC_FPU:
+ return "FPU exception";
+ case EXC_INITIAL_PAGE_WRITE:
+ return "Initial page write exception";
+ case EXC_TRAPA:
+ return "Unconditional trap (trapa)";
+ case EXC_USER_BREAK_POST: /* or EXC_USER_BREAK_PRE */
+ return "User break";
+ default:
+ return "Unknown exception";
+ }
+}
+
/* Print a kernel panic reg dump */
extern irq_context_t *irq_srt_addr;
-void irq_dump_regs(int code, int evt) {
+static void irq_dump_regs(int code, int evt) {
+ uint32_t fp;
uint32_t *regs = irq_srt_addr->r;
+
dbglog(DBG_DEAD, "Unhandled exception: PC %08lx, code %d, evt %04x\n",
irq_srt_addr->pc, code, (uint16)evt);
dbglog(DBG_DEAD, " R0-R7: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
@@ -94,11 +132,34 @@ void irq_dump_regs(int code, int evt) {
dbglog(DBG_DEAD, " R8-R15: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
regs[8], regs[9], regs[10], regs[11], regs[12], regs[13], regs[14], regs[15]);
dbglog(DBG_DEAD, " SR %08lx PR %08lx\n", irq_srt_addr->sr, irq_srt_addr->pr);
- arch_stk_trace_at(regs[14], 0);
- /* dbgio_printf(" Vicinity code ");
- dbgio_printf(" @%08lx: %04x %04x %04x %04x %04x\n",
- srt_addr->pc-4, *((uint16*)(srt_addr->pc-4)), *((uint16*)(srt_addr->pc-2)),
- *((uint16*)(srt_addr->pc)), *((uint16*)(srt_addr->pc+2)), *((uint16*)(srt_addr->pc+4))); */
+ fp = regs[14];
+ arch_stk_trace_at(fp, 0);
+
+ if(code == 1) {
+ dbglog(DBG_DEAD, "Encountered %s. Use this terminal command to help"
+ " diagnose:\n\n\t$KOS_ADDR2LINE -e your_program.elf %08lx %08lx",
+ irq_exception_string(evt), irq_srt_addr->pc, irq_srt_addr->pr);
+
+#ifdef FRAME_POINTERS
+ while(fp != 0xffffffff) {
+ /* Validate the function pointer (fp) */
+ if((fp & 3) || (fp < 0x8c000000) || (fp > _arch_mem_top))
+ break;
+
+ /* Get the return address from the function pointer */
+ fp = arch_fptr_ret_addr(fp);
+
+ /* Validate the return address */
+ if(!arch_valid_address(fp))
+ break;
+
+ dbglog(DBG_DEAD, " %08lx", fp);
+ fp = arch_fptr_next(fp);
+ }
+#endif
+
+ dbglog(DBG_DEAD, "\n");
+ }
}
/* The C-level routine that processes context switching and other
diff --git a/kernel/arch/dreamcast/kernel/panic.c b/kernel/arch/dreamcast/kernel/panic.c
index 09c18d06..97c255ec 100644
--- a/kernel/arch/dreamcast/kernel/panic.c
+++ b/kernel/arch/dreamcast/kernel/panic.c
@@ -12,6 +12,6 @@
can recover, call this. This is a pretty standard tactic from *nixy
kernels which ought to be avoided if at all possible. */
void arch_panic(const char *msg) {
- printf("kernel panic: %s\r\n", msg);
+ printf("\nkernel panic: %s\r\n", msg);
arch_abort();
}
diff --git a/kernel/arch/dreamcast/kernel/stack.c b/kernel/arch/dreamcast/kernel/stack.c
index 2a2fe7c1..a57140d6 100644
--- a/kernel/arch/dreamcast/kernel/stack.c
+++ b/kernel/arch/dreamcast/kernel/stack.c
@@ -31,18 +31,27 @@ void arch_stk_trace(int n) {
/* Do a stack trace from the given frame pointer (useful for things like
tracing from an ISR); leave off the first n frames. */
-void arch_stk_trace_at(uint32 fp, int n) {
+void arch_stk_trace_at(uint32_t fp, size_t n) {
#ifdef FRAME_POINTERS
dbgio_printf("-------- Stack Trace (innermost first) ---------\n");
while(fp != 0xffffffff) {
+ /* Validate the function pointer (fp) */
if((fp & 3) || (fp < 0x8c000000) || (fp > _arch_mem_top)) {
dbgio_printf(" (invalid frame pointer)\n");
break;
}
+
+ if(n == 0) {
+ /* Get the return address from the function pointer */
+ fp = arch_fptr_ret_addr(fp);
- if(n <= 0) {
- dbgio_printf(" %08lx\n", arch_fptr_ret_addr(fp));
+ /* Validate the return address */
+ if(!arch_valid_address(fp)) {
+ dbgio_printf(" %08lx (invalid return address)\n", fp);
+ break;
+ } else
+ dbgio_printf(" %08lx\n", fp);
}
else n--;
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|
|
From: <ap...@us...> - 2024-05-31 15:24:56
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "An ethernet program loader for the Dreamcast.".
The branch, master has been updated
via f72d699af8910f0761a916c4a61b257497400046 (commit)
via 202004c2a60c88992215af92c12a35971d412773 (commit)
via da74440abb0bc6621a6f4f29b32027e226b3ce71 (commit)
via 0a58ce95f1196326186bd4b5d98a2b6c9295d588 (commit)
via 6962ada68202f114fb13f52c48936179422f6d26 (commit)
via 11d5c8eea1395f9acfe8b1d9841a3a0d97b6b039 (commit)
via e1ab0cd1fce9142370095f977790ed2babc4e39b (commit)
from 42808da661163387f678ddb99819f27c5b11b95c (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 f72d699af8910f0761a916c4a61b257497400046
Merge: 42808da 202004c
Author: Falco Girgis <gyr...@gm...>
Date: Fri May 31 10:21:49 2024 -0500
Merge pull request #5 from andressbarajas/MoopOverhaul
#4 Moop overhaul
commit 202004c2a60c88992215af92c12a35971d412773
Author: Andress Barajas <and...@gm...>
Date: Mon Jun 5 21:20:54 2023 -0700
Spacing once more
commit da74440abb0bc6621a6f4f29b32027e226b3ce71
Author: Andress Barajas <and...@gm...>
Date: Mon Jun 5 21:19:21 2023 -0700
Spacing
commit 0a58ce95f1196326186bd4b5d98a2b6c9295d588
Author: Andress Barajas <and...@gm...>
Date: Mon Jun 5 21:13:57 2023 -0700
Spacing and ignore .map files
commit 6962ada68202f114fb13f52c48936179422f6d26
Merge: 11d5c8e 42808da
Author: Andress Barajas <and...@gm...>
Date: Mon Jun 5 21:07:05 2023 -0700
Merge branch 'master' into MoopOverhaul
commit 11d5c8eea1395f9acfe8b1d9841a3a0d97b6b039
Author: Andress Barajas <and...@gm...>
Date: Mon Jun 5 20:52:27 2023 -0700
Some style changes
commit e1ab0cd1fce9142370095f977790ed2babc4e39b
Author: Andress Barajas <and...@gm...>
Date: Mon Jun 5 19:56:00 2023 -0700
Initial dump of Moop changes
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 2 +
CHANGES | 5 +-
Makefile.cfg | 73 +++-
example-src/gethostinfo.c | 3 +-
host-src/tool/Makefile | 26 +-
host-src/tool/commands.h | 4 +-
host-src/tool/dc-tool.c | 453 +++++++++++----------
host-src/tool/utils.c | 69 +++-
host-src/tool/utils.h | 3 +-
target-inc/string.h | 20 +-
target-src/1st_read/Makefile | 6 +-
target-src/1st_read/loader.s | 17 +
target-src/dcload/Makefile | 18 +-
target-src/dcload/adapter.c | 4 +-
target-src/dcload/adapter.h | 8 +-
target-src/dcload/cdfs_redir.s | 7 +
target-src/dcload/cdfs_syscalls.c | 6 +-
target-src/dcload/commands.c | 269 +++++++++++--
target-src/dcload/commands.h | 23 +-
target-src/dcload/dcload-crt0.s | 35 ++
target-src/dcload/dcload.c | 614 ++++++++++++++++++++++++++---
target-src/dcload/dcload.h | 93 ++++-
target-src/dcload/{dcload.c => dcload.old} | 2 +-
target-src/dcload/dcload.x | 41 +-
target-src/dcload/dhcp.c | 517 ++++++++++++++++++++++++
target-src/dcload/dhcp.h | 170 ++++++++
target-src/dcload/go.h | 2 +-
target-src/dcload/lan_adapter.c | 52 ++-
target-src/dcload/maple.c | 9 +-
target-src/dcload/memcmp.c | 4 +-
target-src/dcload/net.c | 424 ++++++++++----------
target-src/dcload/net.h | 23 +-
target-src/dcload/packet.c | 90 +++--
target-src/dcload/packet.h | 7 +-
target-src/dcload/perfctr.c | 244 ++++++++++++
target-src/dcload/perfctr.h | 316 +++++++++++++++
target-src/dcload/rtl8139.c | 99 +++--
target-src/dcload/rtl8139.h | 3 +-
target-src/dcload/syscalls.c | 75 ++--
39 files changed, 3127 insertions(+), 709 deletions(-)
copy target-src/dcload/{dcload.c => dcload.old} (99%)
create mode 100644 target-src/dcload/dhcp.c
create mode 100644 target-src/dcload/dhcp.h
create mode 100644 target-src/dcload/perfctr.c
create mode 100644 target-src/dcload/perfctr.h
diff --git a/.gitignore b/.gitignore
index 932cb01..a1a97ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,8 @@
*.srec
*.exe
*.elf
+*.asm
+*.map
.DS_Store
example-src/console-test
example-src/exception-test
diff --git a/CHANGES b/CHANGES
index 0e5dd3d..cab13c6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,6 @@
WHATS NEW IN 1.0.4
-* Maintenance versions of dcload moved into the CA CVS repository on
+* Maintenance versions of dcload moved into the CA CVS repository on
SourceForge with the blessings of adk. Please send future bug reports and
patches to ba...@al.... If there is sufficient demand, we'll setup
a separate mailing list for it, but you can also join the KOS mailing
@@ -20,7 +20,7 @@ WHATS NEW IN 1.0.4
WHATS NEW IN 1.0.3
* actually seems to be working right, unlike 1.0.1 and 1.0.2, which were both
- buggy as hell under many (most?) conditions. If 1.0.1 and 1.0.2 locked up,
+ buggy as hell under many (most?) conditions. If 1.0.1 and 1.0.2 locked up,
went berzerk, or did other strange and horrible things when you used them,
try 1.0.3.
* dc-tool should now be able to recover from dropped packets in nearly all
@@ -47,4 +47,3 @@ WHATS NEW IN 1.0.1
WHATS NEW IN 1.0.0
* initial release of dcload-ip
-
diff --git a/Makefile.cfg b/Makefile.cfg
index 4402d1c..46e62d7 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -1,5 +1,8 @@
# dcload-ip Makefile Configuration
+# Uncomment this if using KOS
+USING_KOS_GCC = 1
+
# Detect the host
ROOTDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(ROOTDIR)/Makefile.hostdetect
@@ -16,8 +19,17 @@ ifdef WINDOWS
endif
# dc compiler prefix -- this is usually what you used for --prefix when
-# building your compiler.
-TARGETPREFIX = /opt/toolchains/dc/sh-elf
+# building your compiler. Note: BINTARGETPREFIX is just binutils.
+
+ifdef USING_KOS_GCC
+ # Use these for GCC 4.x (for KOS)
+ TARGETPREFIX = /opt/toolchains/dc/sh-elf
+ BINTARGETPREFIX = $(TARGETPREFIX)
+else
+ # This is for portable sh4-elf-gcc GCC 9.2.0
+ TARGETPREFIX = /mnt/c/DreamcastKOS/gcc-sh4
+ BINTARGETPREFIX = /mnt/c/DreamcastKOS/binutils-sh4
+endif
# dir to install dc-tool in
TOOLINSTALLDIR = /opt/toolchains/dc/bin
@@ -33,41 +45,70 @@ ifdef MINGW
WITH_BFD = 1
endif
-# You may have to change the paths for BFDLIB and BFDINCLUDE to the correct
+# You may have to change the paths for BFDLIB and BFDINCLUDE to the correct
# ones for your system. These must point to your sh-elf bfd, not the system one!
# If you built the dc-chain with the v0.4, you'll have it installed in the
# correct location.
-BFDLIB = $(TARGETPREFIX)/lib
-BFDINCLUDE = $(TARGETPREFIX)/include
+BFDLIB = $(TARGETPREFIX)/lib
+BFDINCLUDE = $(TARGETPREFIX)/include
# When using libelf instead of BFD, these must point to your
# libelf installation (leave empty or undefined if libelf is part of the system)
-ELFLIB = $(TARGETPREFIX)/lib
-ELFINCLUDE = $(TARGETPREFIX)/include
+ELFLIB = $(TARGETPREFIX)/lib
+ELFINCLUDE = $(TARGETPREFIX)/include
# For macOS, libelf is here when installed through Homebrew
ifdef MACOS
- ELFINCLUDE = /usr/local/include/libelf
+ ELFINCLUDE = /usr/local/include/libelf
endif
# sh-elf-stuff
# You don't need to change these
-TARGETCC = $(TARGETPREFIX)/bin/sh-elf-gcc
-TARGETCFLAGS = -O2 -ml -m4-single-only
-TARGETOBJCOPY = $(TARGETPREFIX)/bin/sh-elf-objcopy -R .stack
-TARGETLD = $(TARGETPREFIX)/bin/sh-elf-ld
+
+ifdef USING_KOS_GCC
+ # Use these for GCC 4.x (for KOS)
+ TARGETCC = $(TARGETPREFIX)/bin/sh-elf-gcc
+ TARGETCFLAGS = -Os -ml -m4-single-only
+ TARGETOBJCOPY = $(BINTARGETPREFIX)/bin/sh-elf-objcopy -R .stack
+ TARGETLD = $(BINTARGETPREFIX)/bin/sh-elf-ld
+else
+ # This is for portable sh4-elf-gcc GCC 9.2.0
+ TARGETCC = $(TARGETPREFIX)/bin/sh4-elf-gcc
+ TARGETCFLAGS = -O2 -ml -m4-single-only -Wpedantic -Wno-address-of-packed-member
+ TARGETOBJCOPY = $(BINTARGETPREFIX)/bin/sh4-elf-objcopy -R .stack
+ TARGETLD = $(BINTARGETPREFIX)/bin/sh4-elf-ld
+endif
# set TARGETCCVER to 3 or 4, depending on your SH compiler version (gcc 3.x or gcc 4.x)
# this line tries to detect the version automatically
-TARGETCCVER = $(shell $(TARGETCC) --version | head -1 | sed "s/.* \([[:digit:]][[:digit:]]*\)\.[[:digit:]][[:digit:]]*.*/\1/")
+#TARGETCCVER = $(shell $(TARGETCC) --version | head -1 | sed "s/.* \([[:digit:]][[:digit:]]*\)\.[[:digit:]][[:digit:]]*.*/\1/")
+TARGETCCVER = 4
# You generally shouldn't change this unless you are making forked
# versions (or test versions)
-VERSION = 1.0.5
+VERSION = 1.0.5
# Define this if you want a standalone, statically linked, no dependency binary
# This is on by default for MinGW/MSYS
#STANDALONE_BINARY = 1
-# The IP of your dreamcast - set to 000.000.000.000 if you want to use arp on pc
-DREAMCAST_IP = 000.000.000.000
+# On a laptop and dc-tool's got your fans running too high?
+# Enable this. It will slow dc-tool's network console down a teeny bit, but it'll
+# drastically reduce CPU usage. Not necessary if on something like an 8-core desktop.
+# Set to 1 to enable, 0 to disable.
+SAVE_MY_FANS = 0
+
+#
+# IMPORTANT IP ADDRESS INFORMATION:
+#
+# Note that with the addition of DHCP, each octet here must be 3 numbers long.
+# That means use leading zeroes like this when specifying an IP address:
+# 192.168.001.058 or 010.000.076.002, etc. Prior versions of this program could
+# not handle addresses like 192.168.0.x, and the fix for that means leading
+# zeroes are now required when specifying an IP address below.
+#
+# Any IP in the 0.0.0.0/8 range, meaning 000.xxx.xxx.xxx, will enable DHCP mode.
+# If in doubt, just use 000.000.000.000. Some routers may not accept other IPs.
+#
+# The IP of your dreamcast - set to 169.254.xxx.xxx if you want to use arp on pc
+DREAMCAST_IP = 000.000.000.000
diff --git a/example-src/gethostinfo.c b/example-src/gethostinfo.c
index fd98f20..57b3847 100644
--- a/example-src/gethostinfo.c
+++ b/example-src/gethostinfo.c
@@ -2,7 +2,7 @@
void uint_to_string(unsigned int foo, unsigned char *bar)
{
- char hexdigit[16] = "0123456789abcdef";
+ char hexdigit[17] = "0123456789abcdef";
int i;
for(i=7; i>=0; i--) {
@@ -43,4 +43,3 @@ int main(void)
exit(0);
}
-
diff --git a/host-src/tool/Makefile b/host-src/tool/Makefile
index 418d4c7..befc6cd 100644
--- a/host-src/tool/Makefile
+++ b/host-src/tool/Makefile
@@ -1,26 +1,26 @@
include ../../Makefile.cfg
CC = $(HOSTCC)
-CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDREAMCAST_IP=\"$(DREAMCAST_IP)\" -DHAVE_GETOPT
+CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDREAMCAST_IP=\"$(DREAMCAST_IP)\" -DHAVE_GETOPT -DSAVE_MY_FANS=$(SAVE_MY_FANS)
LDFLAGS = $(HOSTLDFLAGS)
INCLUDE =
ifeq ($(WITH_BFD),1)
- CFLAGS += -DWITH_BFD
- LDFLAGS = -L$(BFDLIB) -lbfd -liberty -lintl -lz
- INCLUDE += -I$(BFDINCLUDE)
+ CFLAGS += -DWITH_BFD
+ LDFLAGS = -L$(BFDLIB) -lbfd -liberty -lintl -lz
+ INCLUDE += -I$(BFDINCLUDE)
else
- LDFLAGS = -L$(ELFLIB) -lelf
- INCLUDE += -I$(ELFINCLUDE)
+ LDFLAGS = -L$(ELFLIB) -lelf
+ INCLUDE += -I$(ELFINCLUDE)
endif
# Additional libraries for MinGW/MSYS
ifdef MINGW32
- LDFLAGS += -lws2_32 -lwsock32 -liconv
+ LDFLAGS += -lws2_32 -lwsock32 -liconv
endif
ifdef STANDALONE_BINARY
- LDFLAGS += -static
+ LDFLAGS += -static
endif
DCTOOL = dc-tool-ip$(EXECUTABLEEXTENSION)
@@ -28,7 +28,7 @@ DCTOOL = dc-tool-ip$(EXECUTABLEEXTENSION)
OBJECTS = dc-tool.o syscalls.o unlink.o utils.o
.c.o:
- $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
+ $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $<
all: $(DCTOOL)
@@ -36,15 +36,15 @@ $(DCTOOL): $(OBJECTS)
$(CC) -o $@ $(OBJECTS) $(LDFLAGS)
.PHONY : install
-install: $(DCTOOL) | $(TOOLINSTALLDIR)
+install: $(DCTOOL) | $(TOOLINSTALLDIR)
cp $(DCTOOL) $(TOOLINSTALLDIR)
$(TOOLINSTALLDIR):
-mkdir $(TOOLINSTALLDIR)
.PHONY : clean
clean:
- rm -f $(OBJECTS)
+ -rm -f $(OBJECTS)
.PHONY : distclean
-distclean: clean
- rm -f $(DCTOOL)
+distclean: clean
+ -rm -f $(DCTOOL)
diff --git a/host-src/tool/commands.h b/host-src/tool/commands.h
index f058252..a429558 100644
--- a/host-src/tool/commands.h
+++ b/host-src/tool/commands.h
@@ -22,7 +22,9 @@ typedef struct _command_t command_t;
#define CMD_REBOOT "RBOT" /* reboot */
+#define CMD_MAPLE "MAPL" /* Maple packet */
+#define CMD_PMCR "PMCR" /* Performance counter packet */
+
#define COMMAND_LEN 12
#endif
-
diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c
index 198ab6d..84049f1 100644
--- a/host-src/tool/dc-tool.c
+++ b/host-src/tool/dc-tool.c
@@ -19,8 +19,8 @@
*
*/
-#include "config.h" // needed for newer BFD library
-
+#include "config.h"
+
#ifdef WITH_BFD
#include <bfd.h>
#else
@@ -127,56 +127,54 @@ char *__progname=PACKAGE;
/*
* getopt -- Parse argc/argv argument vector.
*/
-int getopt(int nargc, char * const *nargv, const char *ostr)
-{
+int getopt(int nargc, char * const *nargv, const char *ostr) {
extern char *__progname;
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
int ret;
- if (optreset || !*place) { /* update scanning pointer */
+ if(optreset || !*place) { /* update scanning pointer */
optreset = 0;
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ if(optind >= nargc || *(place = nargv[optind]) != '-') {
place = EMSG;
return (-1);
}
- if (place[1] && *++place == '-') { /* found "--" */
+ if(place[1] && *++place == '-') { /* found "--" */
++optind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
- if ((optopt = (int)*place++) == (int)':' ||
+ if((optopt = (int)*place++) == (int)':' ||
!(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
- if (optopt == (int)'-')
+ if(optopt == (int)'-')
return (-1);
- if (!*place)
+ if(!*place)
++optind;
- if (opterr && *ostr != ':')
+ if(opterr && *ostr != ':')
(void)fprintf(stderr,
"%s: illegal option -- %c\n", __progname, optopt);
-
return (BADCH);
}
- if (*++oli != ':') { /* don't need argument */
+ if(*++oli != ':') { /* don't need argument */
optarg = NULL;
- if (!*place)
- ++optind;
+ if(!*place)
+ ++optind;
}
else { /* need an argument */
- if (*place) /* no white space */
+ if(*place) /* no white space */
optarg = place;
- else if (nargc <= ++optind) { /* no arg */
+ else if(nargc <= ++optind) { /* no arg */
place = EMSG;
- if (*ostr == ':')
+ if(*ostr == ':')
ret = BADARG;
else
ret = BADCH;
- if (opterr)
+ if(opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
__progname, optopt);
@@ -209,49 +207,76 @@ void cleanup(char **fnames)
{
int counter;
- for(counter = 0; counter < 4; counter++)
- {
+ for(counter = 0; counter < 4; counter++) {
if(fnames[counter] != 0)
free(fnames[counter]);
}
+ for(; counter < 4; counter++)
+ if(fnames[counter] != 0)
+ free(fnames[counter]);
+
if(dcsocket)
#ifndef __MINGW32__
close(dcsocket);
#else
- closesocket(dcsocket);
+ closesocket(dcsocket);
+#endif
+
+ // Handle GDB
+ if(gdb_socket_started) {
+ gdb_socket_started = 0;
+
+ // Send SIGTERM to the GDB Client, telling remote DC program has ended
+ char gdb_buf[16];
+ strcpy(gdb_buf, "+$X0f#ee\0");
+
+#ifdef __MINGW32__
+ send(socket_fd, gdb_buf, strlen(gdb_buf), 0);
+ sleep(1);
+ closesocket(socket_fd);
+ closesocket(gdb_server_socket);
+#else
+ write(socket_fd, gdb_buf, strlen(gdb_buf));
+ sleep(1);
+ close(socket_fd);
+ close(gdb_server_socket);
+#endif
+ }
+
+#ifdef __MINGW32__
+ WSACleanup();
#endif
// Handle GDB
- if (gdb_socket_started) {
- gdb_socket_started = 0;
-
- // Send SIGTERM to the GDB Client, telling remote DC program has ended
- char gdb_buf[16];
- strcpy(gdb_buf, "+$X0f#ee\0");
+ if(gdb_socket_started) {
+ gdb_socket_started = 0;
+ // Send SIGTERM to the GDB Client, telling remote DC program has ended
+ char gdb_buf[16];
+ strcpy(gdb_buf, "+$X0f#ee\0");
+
#ifdef __MINGW32__
- send(socket_fd, gdb_buf, strlen(gdb_buf), 0);
- sleep(1);
- closesocket(socket_fd);
- closesocket(gdb_server_socket);
+ send(socket_fd, gdb_buf, strlen(gdb_buf), 0);
+ sleep(1);
+ closesocket(socket_fd);
+ closesocket(gdb_server_socket);
#else
- write(socket_fd, gdb_buf, strlen(gdb_buf));
- sleep(1);
- close(socket_fd);
- close(gdb_server_socket);
+ write(socket_fd, gdb_buf, strlen(gdb_buf));
+ sleep(1);
+ close(socket_fd);
+ close(gdb_server_socket);
#endif
- }
-
+ }
+
#ifdef __MINGW32__
- WSACleanup();
+ WSACleanup();
#endif
}
extern char *optarg;
-unsigned int time_in_usec()
-{
+unsigned int time_in_usec() {
struct timeval thetime;
gettimeofday(&thetime, NULL);
@@ -263,8 +288,7 @@ unsigned int time_in_usec()
#define PACKET_TIMEOUT 250000
/* receive total bytes from dc and store in data */
-int recv_data(void *data, unsigned int dcaddr, unsigned int total, unsigned int quiet)
-{
+int recv_data(void *data, unsigned int dcaddr, unsigned int total, unsigned int quiet) {
unsigned char buffer[2048];
unsigned char *i;
int c;
@@ -275,24 +299,26 @@ int recv_data(void *data, unsigned int dcaddr, unsigned int total, unsigned int
memset(map, 0, (total+1023)/1024);
- if (!quiet) {
- send_cmd(CMD_SENDBIN, dcaddr, total, NULL, 0);
+ if(!quiet) {
+ send_cmd(CMD_SENDBIN, dcaddr, total, NULL, 0);
}
else {
- send_cmd(CMD_SENDBINQ, dcaddr, total, NULL, 0);
+ send_cmd(CMD_SENDBINQ, dcaddr, total, NULL, 0);
...<truncated>...
hooks/post-receive
--
An ethernet program loader for the Dreamcast.
|
|
From: falcovorbis <fal...@us...> - 2024-05-30 19:06:31
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 34f7e943d311cd0105eb012571e7fcda41d3370d (commit)
from edcd7615c1d7ef0c88f8c0e601b9e11668b010e8 (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 34f7e943d311cd0105eb012571e7fcda41d3370d
Author: Paul Cercueil <pa...@cr...>
Date: Thu May 30 21:06:02 2024 +0200
Work around MMU issue with SQs (#598)
* mmu: Add functions mmu_disable() and mmu_restore()
These functions can be used to temporarily disable MMU address
translation.
Signed-off-by: Paul Cercueil <pa...@cr...>
* sq: Work around MMU issue by... disabling MMU
This change makes it possible to use SQs in a program that uses the MMU,
by disabling the MMU in sq_lock(), and re-enable it again in
mmu_restore().
This means that memory-mapped data must not be accessed while the SQ is
locked. This should be fine, as it wasn't working properly before, so
it's not a regression.
Signed-off-by: Paul Cercueil <pa...@cr...>
---------
Signed-off-by: Paul Cercueil <pa...@cr...>
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/sq.c | 9 +++++++++
kernel/arch/dreamcast/include/arch/mmu.h | 17 +++++++++++++++++
kernel/arch/dreamcast/kernel/mmu.c | 12 ++++++++++++
3 files changed, 38 insertions(+)
diff --git a/kernel/arch/dreamcast/hardware/sq.c b/kernel/arch/dreamcast/hardware/sq.c
index 7f34633a..10ef13bd 100644
--- a/kernel/arch/dreamcast/hardware/sq.c
+++ b/kernel/arch/dreamcast/hardware/sq.c
@@ -8,6 +8,7 @@
*/
#include <arch/cache.h>
+#include <arch/mmu.h>
#include <dc/sq.h>
#include <kos/dbglog.h>
#include <kos/mutex.h>
@@ -40,12 +41,20 @@
static mutex_t sq_mutex = MUTEX_INITIALIZER;
+static mmu_token_t mmu_token;
+
void sq_lock(void *dest) {
mutex_lock(&sq_mutex);
+
+ /* Disable MMU, because SQs work differently when it's enabled, and we
+ * don't support it. */
+ mmu_token = mmu_disable();
+
SET_QACR_REGS(dest, dest);
}
void sq_unlock(void) {
+ mmu_restore(mmu_token);
mutex_unlock(&sq_mutex);
}
diff --git a/kernel/arch/dreamcast/include/arch/mmu.h b/kernel/arch/dreamcast/include/arch/mmu.h
index ad0c3aca..5b4a6cf8 100644
--- a/kernel/arch/dreamcast/include/arch/mmu.h
+++ b/kernel/arch/dreamcast/include/arch/mmu.h
@@ -195,6 +195,9 @@ typedef struct mmucontext {
to do so.
*/
extern mmucontext_t *mmu_cxt_current;
+
+struct mmu_token;
+typedef struct mmu_token *mmu_token_t;
/** \endcond */
/** \brief Set the "current" page tables for TLB handling.
@@ -370,6 +373,20 @@ void mmu_shutdown(void);
*/
void mmu_reset_itlb(void);
+/** \brief Temporarily disable MMU address translation.
+ \ingroup mmu
+
+ \return An opaque token to be passed to mmu_restore()
+ */
+mmu_token_t mmu_disable(void);
+
+/** \brief Restore MMU address translation.
+ \ingroup mmu
+
+ \param token The opaque token obtained from mmu_disable()
+ */
+void mmu_restore(mmu_token_t token);
+
__END_DECLS
#endif /* __ARCH_MMU_H */
diff --git a/kernel/arch/dreamcast/kernel/mmu.c b/kernel/arch/dreamcast/kernel/mmu.c
index 8d81fdef..466a1561 100644
--- a/kernel/arch/dreamcast/kernel/mmu.c
+++ b/kernel/arch/dreamcast/kernel/mmu.c
@@ -766,3 +766,15 @@ void mmu_shutdown(void) {
irq_set_handler(EXC_DTLB_PV_WRITE, NULL, NULL);
irq_set_handler(EXC_INITIAL_PAGE_WRITE, NULL, NULL);
}
+
+mmu_token_t mmu_disable(void) {
+ mmu_token_t token = (mmu_token_t)*mmucr;
+
+ *mmucr &= ~0x1;
+
+ return token;
+}
+
+void mmu_restore(mmu_token_t token) {
+ *mmucr = (uint32)token;
+}
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|