|
From: quzar <qu...@us...> - 2025-01-15 04:38:29
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via 949af4bbfdcf42bec68d87d265fa59d831f1b21b (commit)
via e96a0dd35653657b5172b95bf89712d4a583453e (commit)
via b01c03a8f263c5df01fb73e1ec7e6563a06c06de (commit)
via 8ca42961e97bad2f3c64e6b29b14f8d1cc8a978e (commit)
via 88232c248ded7795a849a82017a06327b7ca3e5c (commit)
via 9aa41bb15afa4f2e15763b7b4fd8b8eab0248f97 (commit)
via e23732f16e28f02813e2cbdba36a5bca50c2d687 (commit)
via db865c58dfd8d1dbf4ec3f58757f658e8fe3309f (commit)
via 9643f03cb7aaee1b77f4f49663f0100f00334746 (commit)
via 443bcc39c75e1cf5b96fe9f1f9661ddf68221006 (commit)
via 86465e336cded75236a53c0e05f096d062b5ffba (commit)
via 4c987a727496a0bb97aff31381fdd791377e2ea5 (commit)
via 7193f1ca344ccaa0741383875e50aa0c2146f133 (commit)
via 78f450ff297c3b4d18dbe8ed61fc7975fc153edf (commit)
via 2666394e823ee53e4715aad4bafec44ad20f7dcd (commit)
via dd287228e3e06eeaa59da99bd23e99a17840079f (commit)
via 9165f26d65c9a22e5a45b8fb510bf9fb1d8fec04 (commit)
via 5ea0ac6175979e5cf5a8b13407a2b3066bbb2be2 (commit)
via 0637a90dbeae8f87728fa06ac45d7b6324625b29 (commit)
via 95592bccdd52c730025a60e1b636daf4fc835192 (commit)
via de21e057c3a41488553b61db4d2fef7ad8e145ba (commit)
via 8e25a1930ba5ca9f8825e1e381ee54229245d685 (commit)
via 6c9f5f632dfffbc5b7a7f1e26da59a2bf9871efb (commit)
via b147382890f551e88ef7e1ba9b61c363d49b3bd5 (commit)
via 0f171547e2411d62f8c02c77423025776a4e0e6a (commit)
via ccec1cc36977acce789ed7b36ce066ce9ec15399 (commit)
via ae9083924dd643a277efca80294879042f5a770c (commit)
via 01ece409a12ae43643c593da266b71fed6dc0278 (commit)
via ba9abe5eba98c7075f8670cfcdcb7d92c74b7340 (commit)
via 721a210503b46cbaa14d2a1e03024a55375e4c4b (commit)
from 4120477f4344f89a5bcc121ced62ff751901db17 (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 949af4bbfdcf42bec68d87d265fa59d831f1b21b
Merge: e96a0dd3 e23732f1
Author: Donald Haase <qu...@ya...>
Date: Tue Jan 14 23:19:11 2025 -0500
Merge pull request #896 from pcercuei/perf-counters
Fix and improve performance counters
commit e96a0dd35653657b5172b95bf89712d4a583453e
Merge: b01c03a8 7193f1ca
Author: Donald Haase <qu...@ya...>
Date: Tue Jan 14 23:14:00 2025 -0500
Merge pull request #893 from KallistiOS/unhack_fs_dcload
Unhack fs dcload
commit b01c03a8f263c5df01fb73e1ec7e6563a06c06de
Merge: 8ca42961 443bcc39
Author: Donald Haase <qu...@ya...>
Date: Tue Jan 14 23:13:37 2025 -0500
Merge pull request #895 from darcagn/update-changelogs
Update changelogs and AUTHORS
commit 8ca42961e97bad2f3c64e6b29b14f8d1cc8a978e
Merge: 88232c24 8e25a193
Author: Donald Haase <qu...@ya...>
Date: Tue Jan 14 23:09:11 2025 -0500
Merge pull request #890 from pcercuei/pvr-fix-mutex-unlock
pvr: Fix dma_next_list() incorrectly unlocking mutex
commit 88232c248ded7795a849a82017a06327b7ca3e5c
Merge: 9aa41bb1 6c9f5f63
Author: Donald Haase <qu...@ya...>
Date: Tue Jan 14 23:06:58 2025 -0500
Merge pull request #889 from KallistiOS/sfxbuf_lto
Fix undefined references to free with lto.
commit 9aa41bb15afa4f2e15763b7b4fd8b8eab0248f97
Merge: 4120477f 4c987a72
Author: Donald Haase <qu...@ya...>
Date: Tue Jan 14 23:06:41 2025 -0500
Merge pull request #837 from DC-SWAT/aica_iface_fix
Speedup and fix AICA cmd iface. Protect SQs on G2 bus.
commit e23732f16e28f02813e2cbdba36a5bca50c2d687
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jan 14 19:27:07 2025 +0100
perfcntr: Slightly reduce latency of perf_cntr_timer_ns()
To reduce the latency of perf_cntr_timer_ns(), perform the
perf_cntr_timer_enabled() check *before* reading the counter.
The argument that the counter should be read first as to not "record
overhead" is bogus; the reason being, if you use these timers to
measure the time taken between points A and B, you will always end up
measuring the "perf_cntr_timer_enabled()" overhead, just at a different
extremity.
Therefore, if we "record overhead" in both cases, it's better to use the
case where we have slightly lower latency.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit db865c58dfd8d1dbf4ec3f58757f658e8fe3309f
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jan 14 19:16:49 2025 +0100
perfcntr: Handle counter overflow while reading values
Read the high part twice, before and after reading the high part,
to make sure that the low counter didn't overflow. We can detect an
overflow by the two reads of the high part returning different
values.
Note that we don't mask the low 16 bits anymore, as the upper 16 bits
are zero anyway.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 9643f03cb7aaee1b77f4f49663f0100f00334746
Author: Paul Cercueil <pa...@cr...>
Date: Tue Jan 14 19:31:51 2025 +0100
timer: Mark timer reading loop condition as unlikely
The timer reading loop condition is extremely unlikely; therefore we can
make the function slightly better by tagging it as such.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 443bcc39c75e1cf5b96fe9f1f9661ddf68221006
Author: darc <da...@pr...>
Date: Mon Jan 13 17:10:49 2025 -0600
Update dc-chain changelog for recent changes
commit 86465e336cded75236a53c0e05f096d062b5ffba
Author: darc <da...@pr...>
Date: Mon Jan 13 17:11:19 2025 -0600
Update dates in AUTHORS
commit 4c987a727496a0bb97aff31381fdd791377e2ea5
Author: DC-SWAT <sw...@21...>
Date: Sun Jan 12 11:30:07 2025 +0700
Moving g2_fifo_wait() after g2_lock()
commit 7193f1ca344ccaa0741383875e50aa0c2146f133
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 14:26:51 2025 -0500
Cleanups of includes, comments, and whitespace.
commit 78f450ff297c3b4d18dbe8ed61fc7975fc153edf
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 13:16:09 2025 -0500
Track a dirent per dir.
Previously it was a static dirent object which was not only
not 'thread-safe' but meant that one could not be calling
readdir against two different dirs in the same thread.
commit 2666394e823ee53e4715aad4bafec44ad20f7dcd
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 13:14:23 2025 -0500
Ensure the fs_dcload dir table is always behind the mutex.
Help prevent possible racing between dir ops.
commit dd287228e3e06eeaa59da99bd23e99a17840079f
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 13:12:56 2025 -0500
Add rewwinddir to fs_dcload
This was added to ip and ser versions of dcload ages ago
but for some reason never to KOS.
commit 9165f26d65c9a22e5a45b8fb510bf9fb1d8fec04
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 12:07:21 2025 -0500
Make fs functions static.
No other vfs driver exposes its internal functions like fs_dcload
does. Additionally newer functions that were added like fcntl were
already static.
commit 5ea0ac6175979e5cf5a8b13407a2b3066bbb2be2
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 11:41:16 2025 -0500
Remove lwip compatibility functions.
We have not supported this in over a decade. dcls
is meant to take this role.
commit 0637a90dbeae8f87728fa06ac45d7b6324625b29
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 02:52:11 2025 -0500
Cache dir paths for readdir.
Now that we are caching dirs generally, lets add
the path string. This allows the removal of the
static dcload_path, which had the drawback of
preventing arbitrary use of `readdir`.
commit 95592bccdd52c730025a60e1b636daf4fc835192
Author: QuzarDC <qu...@co...>
Date: Sat Jan 11 02:38:18 2025 -0500
Refactor to add error checking for oom.
commit de21e057c3a41488553b61db4d2fef7ad8e145ba
Author: QuzarDC <qu...@co...>
Date: Fri Jan 10 21:09:49 2025 -0500
Remove hack of detecting a dir as fd > 100
It seems this awful hack was possible due to dcload returning
the host-side `DIR *` as the fd for dirs. The problem is that
it's absolute bunk as there's no guarantee that the fds for
non-dirs from the host side returned by `open` will be less
than 100. This could mean that a file gets opened and not be
able to be closed properly. This also clears the way to remove
the hack from the host-side dc-loads, and to correct readdir
behavior.
commit 8e25a1930ba5ca9f8825e1e381ee54229245d685
Author: Paul Cercueil <pa...@cr...>
Date: Fri Jan 10 14:53:45 2025 +0100
pvr: Fix dma_next_list() incorrectly unlocking mutex
Only the first call of dma_next_list() is done by the calling thread;
the function is registered as the DMA complete callback, so the
following calls are done in interrupt context. In that case, the mutex
should be unlocked differently by passing a pointer to the thread that
locked it.
This was detected by defaulting all mutexes to error-checking.
Signed-off-by: Paul Cercueil <pa...@cr...>
commit 6c9f5f632dfffbc5b7a7f1e26da59a2bf9871efb
Author: QuzarDC <qu...@co...>
Date: Fri Jan 10 00:25:41 2025 -0500
Fix undefined references to free with lto.
I can only presume that the strict include list in this
(as opposed to kos.h) meant that there happened to be no
references to stdlib in its includes.
commit b147382890f551e88ef7e1ba9b61c363d49b3bd5
Author: DC-SWAT <sw...@21...>
Date: Sun Jan 5 23:39:32 2025 +0700
Cosmetic fixes from suggestions.
commit 0f171547e2411d62f8c02c77423025776a4e0e6a
Author: DC-SWAT <sw...@21...>
Date: Sat Nov 9 16:15:45 2024 +0700
Change spinlock to mutex, doc and style fixes.
commit ccec1cc36977acce789ed7b36ce066ce9ec15399
Author: DC-SWAT <sw...@21...>
Date: Tue Nov 5 18:25:13 2024 +0700
Added snd_get_pos() and snd_is_playing().
commit ae9083924dd643a277efca80294879042f5a770c
Author: DC-SWAT <sw...@21...>
Date: Tue Nov 5 10:25:47 2024 +0700
Fixed aligning for AICA cmd channel buffer.
commit 01ece409a12ae43643c593da266b71fed6dc0278
Author: DC-SWAT <sw...@21...>
Date: Tue Nov 5 10:24:22 2024 +0700
Added spinlock for start/stop the queue.
commit ba9abe5eba98c7075f8670cfcdcb7d92c74b7340
Author: DC-SWAT <sw...@21...>
Date: Wed Oct 30 11:05:12 2024 +0700
Protect the SQs on G2 bus.
Also speedup spu_reset_chans().
commit 721a210503b46cbaa14d2a1e03024a55375e4c4b
Author: DC-SWAT <sw...@21...>
Date: Wed Oct 30 10:54:15 2024 +0700
Speedup and fix AICA cmd iface
-----------------------------------------------------------------------
Summary of changes:
AUTHORS | 6 +-
doc/CHANGELOG.md | 1 +
examples/dreamcast/sound/sfxbuf/main.c | 1 +
kernel/arch/dreamcast/exports-naomi.txt | 2 +
kernel/arch/dreamcast/exports-pristine.txt | 2 +
kernel/arch/dreamcast/fs/fs_dcload.c | 238 ++++++++++-----------
kernel/arch/dreamcast/hardware/pvr/pvr_irq.c | 13 +-
kernel/arch/dreamcast/hardware/spu.c | 45 +++-
kernel/arch/dreamcast/include/dc/fs_dcload.h | 56 ++---
kernel/arch/dreamcast/include/dc/g2bus.h | 25 +++
kernel/arch/dreamcast/include/dc/sound/aica_comm.h | 2 +-
kernel/arch/dreamcast/include/dc/sound/sound.h | 26 ++-
kernel/arch/dreamcast/kernel/perfctr.c | 22 +-
kernel/arch/dreamcast/kernel/timer.c | 2 +-
kernel/arch/dreamcast/sound/arm/aica_cmd_iface.h | 4 +
kernel/arch/dreamcast/sound/snd_iface.c | 96 +++++----
kernel/arch/dreamcast/sound/snd_stream.c | 11 +-
utils/dc-chain/doc/CHANGELOG.md | 1 +
18 files changed, 313 insertions(+), 240 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 5f886980..f476c351 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -27,7 +27,7 @@ Sam Steele: 2004
Gil Megidish: 2002
Florian Schulze: 2002
Walter van Niftrik: 2005
-Donald Haase: 2008, 2014, 2023, 2024
+Donald Haase: 2008, 2014, 2023, 2024, 2025
Andrew Kieschnick: 2000, 2001, 2002, 2003
Jordan DeLong: 2000, 2001, 2002
Bero: 2002
@@ -42,12 +42,12 @@ Josh Pearson: 2013, 2014, 2015, 2016
Joe Fenton: 2016
Stefan Galowicz: 2016, 2017
Luke Benstead: 2020, 2021, 2022, 2023
-Eric Fradella: 2023, 2024
+Eric Fradella: 2023, 2024, 2025
Falco Girgis: 2023, 2024
Ruslan Rostovtsev: 2014, 2016, 2023, 2024
Colton Pawielski: 2023
Andy Barajas: 2023, 2024
-Paul Cercueil: 2023, 2024
+Paul Cercueil: 2023, 2024, 2025
Files with Specific licenses:
-----------------------------
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 5dea7cd1..3f7bccac 100644
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -12,6 +12,7 @@ Platform-specific changes are prefixed with the platform name, otherwise the cha
- **Dreamcast**: Add pvr palette example [AB]
- **Dreamcast**: Cleaned up, documented, and enhanced BIOS font API [FG]
- Rework PVR hybrid mode + IRQ handling [PC]
+- **Dreamcast**: Add support and update toolchain profiles for Newlib 4.5.0, Binutils 2.43.1, and GDB 15.2 [EF]
## KallistiOS version 2.1.1
- Added pvrtex utility by TapamN to utils [Daniel Fairchild == DF]
diff --git a/examples/dreamcast/sound/sfxbuf/main.c b/examples/dreamcast/sound/sfxbuf/main.c
index df7d8016..4d42ba2a 100644
--- a/examples/dreamcast/sound/sfxbuf/main.c
+++ b/examples/dreamcast/sound/sfxbuf/main.c
@@ -8,6 +8,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <kos/init.h>
#include <dc/biosfont.h>
diff --git a/kernel/arch/dreamcast/exports-naomi.txt b/kernel/arch/dreamcast/exports-naomi.txt
index 4e3c4615..20fac7bb 100644
--- a/kernel/arch/dreamcast/exports-naomi.txt
+++ b/kernel/arch/dreamcast/exports-naomi.txt
@@ -146,6 +146,8 @@ snd_pcm16_split
snd_pcm16_split_sq
snd_pcm8_split
snd_adpcm_split
+snd_get_pos
+snd_is_playing
# Video
vid_mode
diff --git a/kernel/arch/dreamcast/exports-pristine.txt b/kernel/arch/dreamcast/exports-pristine.txt
index 89750ed6..829d112d 100644
--- a/kernel/arch/dreamcast/exports-pristine.txt
+++ b/kernel/arch/dreamcast/exports-pristine.txt
@@ -202,6 +202,8 @@ snd_pcm16_split
snd_pcm16_split_sq
snd_pcm8_split
snd_adpcm_split
+snd_get_pos
+snd_is_playing
# Video
vid_mode
diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c
index c40e21f3..b27c935e 100644
--- a/kernel/arch/dreamcast/fs/fs_dcload.c
+++ b/kernel/arch/dreamcast/fs/fs_dcload.c
@@ -4,6 +4,7 @@
Copyright (C) 2002 Andrew Kieschnick
Copyright (C) 2004 Megan Potter
Copyright (C) 2012 Lawrence Sebald
+ Copyright (C) 2025 Donald Haase
*/
@@ -19,51 +20,56 @@ printf goes to the dc-tool console
#include <dc/fifo.h>
#include <dc/fs_dcload.h>
-#include <kos/thread.h>
#include <arch/spinlock.h>
-#include <arch/arch.h>
#include <kos/dbgio.h>
#include <kos/fs.h>
+#include <kos/init.h>
#include <errno.h>
#include <stdio.h>
-#include <ctype.h>
#include <string.h>
#include <malloc.h>
-#include <errno.h>
+#include <sys/queue.h>
+
+/* A linked list of dir entries. */
+typedef struct dcl_dir {
+ LIST_ENTRY(dcl_dir) fhlist;
+ int hnd;
+ char *path;
+ dirent_t dirent;
+} dcl_dir_t;
+
+LIST_HEAD(dcl_de, dcl_dir);
+
+static struct dcl_de dir_head = LIST_HEAD_INITIALIZER(0);
+
+static dcl_dir_t *hnd_is_dir(int hnd) {
+ dcl_dir_t *i;
+
+ if(!hnd) return NULL;
+
+ LIST_FOREACH(i, &dir_head, fhlist) {
+ if(i->hnd == (int)hnd)
+ break;
+ }
+
+ return i;
+}
static spinlock_t mutex = SPINLOCK_INITIALIZER;
-#define plain_dclsc(...) ({ \
+#define dclsc(...) ({ \
irq_disable_scoped(); \
while(FIFO_STATUS & FIFO_SH4) \
; \
dcloadsyscall(__VA_ARGS__); \
})
-// #define plain_dclsc(...) dcloadsyscall(__VA_ARGS__)
-
-static void * lwip_dclsc = 0;
-
-#define dclsc(...) ({ \
- int rv; \
- if(lwip_dclsc) \
- rv = (*(int (*)()) lwip_dclsc)(__VA_ARGS__); \
- else \
- rv = plain_dclsc(__VA_ARGS__); \
- rv; \
- })
-
/* Printk replacement */
int dcload_write_buffer(const uint8 *data, int len, int xlat) {
(void)xlat;
- if(lwip_dclsc && irq_inside_int()) {
- errno = EAGAIN;
- return -1;
- }
-
spinlock_lock_scoped(&mutex);
dclsc(DCLOAD_WRITE, 1, data, len);
@@ -75,8 +81,6 @@ int dcload_read_cons(void) {
}
size_t dcload_gdbpacket(const char* in_buf, size_t in_size, char* out_buf, size_t out_size) {
- if(lwip_dclsc && irq_inside_int())
- return 0;
spinlock_lock_scoped(&mutex);
@@ -85,17 +89,16 @@ size_t dcload_gdbpacket(const char* in_buf, size_t in_size, char* out_buf, size_
return dclsc(DCLOAD_GDBPACKET, in_buf, (in_size << 16) | (out_size & 0xffff), out_buf);
}
-static char *dcload_path = NULL;
-void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
+static void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
+ char *dcload_path = NULL;
+ dcl_dir_t *entry;
int hnd = 0;
int dcload_mode = 0;
int mm = (mode & O_MODE_MASK);
+ size_t fn_len = 0;
(void)vfs;
- if(lwip_dclsc && irq_inside_int())
- return (void *)0;
-
spinlock_lock_scoped(&mutex);
if(mode & O_DIR) {
@@ -105,22 +108,42 @@ void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
hnd = dclsc(DCLOAD_OPENDIR, fn);
- if(hnd) {
- if(dcload_path)
- free(dcload_path);
+ if(!hnd) {
+ /* It could be caused by other issues, such as
+ pathname being too long or symlink loops, but
+ ENOTDIR seems to be the best generic and we should
+ set something */
+ errno = ENOTDIR;
+ return (void *)NULL;
+ }
- if(fn[strlen(fn) - 1] == '/') {
- dcload_path = malloc(strlen(fn) + 1);
- strcpy(dcload_path, fn);
- }
- else {
- dcload_path = malloc(strlen(fn) + 2);
- strcpy(dcload_path, fn);
- strcat(dcload_path, "/");
- }
+ /* We got something back so create an dir list entry for it */
+ entry = malloc(sizeof(dcl_dir_t));
+ if(!entry) {
+ errno = ENOMEM;
+ return (void *)NULL;
}
+
+ fn_len = strlen(fn);
+ if(fn[fn_len - 1] == '/') fn_len--;
+
+ dcload_path = malloc(fn_len + 2);
+ if(!dcload_path) {
+ errno = ENOMEM;
+ free(entry);
+ return (void *)NULL;
+ }
+
+ memcpy(dcload_path, fn, fn_len);
+ dcload_path[fn_len] = '/';
+ dcload_path[fn_len+1] = '\0';
+
+ /* Now that everything is ready, add to list */
+ entry->hnd = hnd;
+ entry->path = dcload_path;
+ LIST_INSERT_HEAD(&dir_head, entry, fhlist);
}
- else { /* hack */
+ else {
if(mm == O_RDONLY)
dcload_mode = 0;
else if((mm & O_RDWR) == O_RDWR)
@@ -141,19 +164,23 @@ void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) {
return (void *)hnd;
}
-int dcload_close(void * h) {
+static int dcload_close(void * h) {
uint32 hnd = (uint32)h;
-
- if(lwip_dclsc && irq_inside_int()) {
- errno = EINTR;
- return -1;
- }
+ dcl_dir_t *i;
spinlock_lock_scoped(&mutex);
if(hnd) {
- if(hnd > 100) /* hack */
+ /* Check if it's a dir */
+ i = hnd_is_dir(hnd);
+
+ /* We found it in the list, so it's a dir */
+ if(!i) {
dclsc(DCLOAD_CLOSEDIR, hnd);
+ LIST_REMOVE(i, fhlist);
+ free(i->path);
+ free(i);
+ }
else {
hnd--; /* KOS uses 0 for error, not -1 */
dclsc(DCLOAD_CLOSE, hnd);
@@ -163,13 +190,10 @@ int dcload_close(void * h) {
return 0;
}
-ssize_t dcload_read(void * h, void *buf, size_t cnt) {
+static ssize_t dcload_read(void * h, void *buf, size_t cnt) {
ssize_t ret = -1;
uint32 hnd = (uint32)h;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
if(hnd) {
@@ -180,13 +204,10 @@ ssize_t dcload_read(void * h, void *buf, size_t cnt) {
return ret;
}
-ssize_t dcload_write(void * h, const void *buf, size_t cnt) {
+static ssize_t dcload_write(void * h, const void *buf, size_t cnt) {
ssize_t ret = -1;
uint32 hnd = (uint32)h;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
if(hnd) {
@@ -197,13 +218,10 @@ ssize_t dcload_write(void * h, const void *buf, size_t cnt) {
return ret;
}
-off_t dcload_seek(void * h, off_t offset, int whence) {
+static off_t dcload_seek(void * h, off_t offset, int whence) {
off_t ret = -1;
uint32 hnd = (uint32)h;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
if(hnd) {
@@ -214,13 +232,10 @@ off_t dcload_seek(void * h, off_t offset, int whence) {
return ret;
}
-off_t dcload_tell(void * h) {
+static off_t dcload_tell(void * h) {
off_t ret = -1;
uint32 hnd = (uint32)h;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
if(hnd) {
@@ -231,14 +246,11 @@ off_t dcload_tell(void * h) {
return ret;
}
-size_t dcload_total(void * h) {
+static size_t dcload_total(void * h) {
size_t ret = -1;
size_t cur;
uint32 hnd = (uint32)h;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
if(hnd) {
@@ -251,38 +263,32 @@ size_t dcload_total(void * h) {
return ret;
}
-/* Not thread-safe, but that's ok because neither is the FS */
-static dirent_t dirent;
-dirent_t *dcload_readdir(void * h) {
+static dirent_t *dcload_readdir(void * h) {
dirent_t *rv = NULL;
dcload_dirent_t *dcld;
dcload_stat_t filestat;
char *fn;
uint32 hnd = (uint32)h;
+ dcl_dir_t *entry;
- if(lwip_dclsc && irq_inside_int()) {
- errno = EAGAIN;
- return NULL;
- }
+ spinlock_lock_scoped(&mutex);
- if(hnd < 100) {
+ if(!(entry = hnd_is_dir(hnd))) {
errno = EBADF;
return NULL;
}
- spinlock_lock_scoped(&mutex);
-
dcld = (dcload_dirent_t *)dclsc(DCLOAD_READDIR, hnd);
if(dcld) {
- rv = &dirent;
+ rv = &(entry->dirent);
strcpy(rv->name, dcld->d_name);
rv->size = 0;
rv->time = 0;
rv->attr = 0; /* what the hell is attr supposed to be anyways? */
- fn = malloc(strlen(dcload_path) + strlen(dcld->d_name) + 1);
- strcpy(fn, dcload_path);
+ fn = malloc(strlen(entry->path) + strlen(dcld->d_name) + 1);
+ strcpy(fn, entry->path);
strcat(fn, dcld->d_name);
if(!dclsc(DCLOAD_STAT, fn, &filestat)) {
@@ -303,14 +309,11 @@ dirent_t *dcload_readdir(void * h) {
return rv;
}
-int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2) {
+static int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2) {
int ret;
(void)vfs;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
/* really stupid hack, since I didn't put rename() in dcload */
@@ -323,12 +326,9 @@ int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2) {
return ret;
}
-int dcload_unlink(vfs_handler_t * vfs, const char *fn) {
+static int dcload_unlink(vfs_handler_t * vfs, const char *fn) {
(void)vfs;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
spinlock_lock_scoped(&mutex);
return dclsc(DCLOAD_UNLINK, fn);
@@ -342,9 +342,6 @@ static int dcload_stat(vfs_handler_t *vfs, const char *path, struct stat *st,
(void)flag;
- if(lwip_dclsc && irq_inside_int())
- return 0;
-
/* Root directory '/pc' */
if(len == 0 || (len == 1 && *path == '/')) {
memset(st, 0, sizeof(struct stat));
@@ -408,6 +405,17 @@ static int dcload_fcntl(void *h, int cmd, va_list ap) {
return rv;
}
+static int dcload_rewinddir(void *h) {
+ uint32_t hnd = (uint32_t)h;
+
+ spinlock_lock_scoped(&mutex);
+
+ if(!hnd_is_dir(hnd))
+ return -1;
+
+ return dclsc(DCLOAD_REWINDDIR, hnd);
+}
+
/* Pull all that together */
static vfs_handler_t vh = {
/* Name handler */
@@ -446,12 +454,12 @@ static vfs_handler_t vh = {
NULL, /* tell64 */
NULL, /* total64 */
NULL, /* readlink */
- NULL, /* rewinddir */
+ dcload_rewinddir,
NULL /* fstat */
};
-// We have to provide a minimal interface in case dcload usage is
-// disabled through init flags.
+/* We have to provide a minimal interface in case dcload usage is
+ disabled through init flags. */
static int never_detected(void) {
return 0;
}
@@ -491,8 +499,8 @@ void fs_dcload_init_console(void) {
dbgio_dcload.write_buffer = dcload_write_buffer;
// dbgio_dcload.read = dcload_read_cons;
- // We actually need to detect here to make sure we're not on
- // dcload-serial, or scif_init must not proceed.
+ /* We actually need to detect here to make sure we're not on
+ dcload-serial, or scif_init must not proceed. */
...<truncated>...
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|