aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/drv/ps1/cd/src/getstat.c6
-rw-r--r--src/drv/ps1/cd/src/update.c4
-rw-r--r--src/drv/ps1/irq/CMakeLists.txt3
-rw-r--r--src/drv/ps1/sio/src/update.c5
-rw-r--r--src/kprintf/CMakeLists.txt2
-rw-r--r--src/kprintf/src/nwp_log.c12
-rw-r--r--src/loop/CMakeLists.txt2
-rw-r--r--src/loop/src/run.c27
-rw-r--r--src/net/CMakeLists.txt3
10 files changed, 67 insertions, 4 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 05c73c4..9fb2cb4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,7 +51,12 @@ endif()
target_compile_options(${PROJECT_NAME} PUBLIC ${cflags})
target_compile_options(nanowasm PUBLIC ${cflags})
# Dependencies for main.c
-target_link_libraries(${PROJECT_NAME} PRIVATE gfx init loop)
+target_link_libraries(${PROJECT_NAME} PRIVATE gfx init loop
+
+ drv_ps1_bios
+ drv_ps1_sio
+
+)
foreach(c ${components})
add_subdirectory(${c})
diff --git a/src/drv/ps1/cd/src/getstat.c b/src/drv/ps1/cd/src/getstat.c
index 34bdaf5..714238b 100644
--- a/src/drv/ps1/cd/src/getstat.c
+++ b/src/drv/ps1/cd/src/getstat.c
@@ -26,12 +26,16 @@ static int wait_event(void)
struct cd_prv *const p = &drv_ps1_cd_prv;
struct cd_prv_getstat *const g = &p->u.getstat;
+ p->available = true;
+ p->next = NULL;
+ return 0;
+
if (drv_ps1_event_test(p->event))
{
p->available = !g->status.bits.shell_open;
if (!p->head)
- return drv_ps1_cd_getstat();
+ return 0;
return p->head->f();
}
diff --git a/src/drv/ps1/cd/src/update.c b/src/drv/ps1/cd/src/update.c
index 148dd87..022a678 100644
--- a/src/drv/ps1/cd/src/update.c
+++ b/src/drv/ps1/cd/src/update.c
@@ -26,7 +26,9 @@ int drv_ps1_cd_update(struct drv_ps1_cd *const cd)
{
struct cd_prv *const p = &drv_ps1_cd_prv;
- if (p->next())
+ if (!p->next && p->head)
+ return p->head->f();
+ if (p->next && p->next())
return -1;
else if (p->available ^ cd->available)
{
diff --git a/src/drv/ps1/irq/CMakeLists.txt b/src/drv/ps1/irq/CMakeLists.txt
index 8327cd5..ee807a0 100644
--- a/src/drv/ps1/irq/CMakeLists.txt
+++ b/src/drv/ps1/irq/CMakeLists.txt
@@ -18,3 +18,6 @@ add_library(drv_ps1_irq)
add_subdirectory(src)
target_include_directories(drv_ps1_irq PUBLIC include PRIVATE private_include)
target_link_libraries(drv_ps1_irq PUBLIC c PRIVATE drv_ps1_bios)
+
+
+target_link_libraries(drv_ps1_irq PRIVATE kprintf)
diff --git a/src/drv/ps1/sio/src/update.c b/src/drv/ps1/sio/src/update.c
index eac875c..85797df 100644
--- a/src/drv/ps1/sio/src/update.c
+++ b/src/drv/ps1/sio/src/update.c
@@ -86,10 +86,15 @@ static int tx(struct drv_ps1_sio *const s)
return 0;
}
+int sio_stat_overrun;
+
int drv_ps1_sio_update(struct drv_ps1_sio *const s)
{
if (SIO_STAT->bits.rx_fifo_overrun)
+ {
+ sio_stat_overrun = 1;
SIO_CTRL->bits.ack = 1;
+ }
if (init(s) || rx(s) || tx(s))
return -1;
diff --git a/src/kprintf/CMakeLists.txt b/src/kprintf/CMakeLists.txt
index fcc53c9..9164d14 100644
--- a/src/kprintf/CMakeLists.txt
+++ b/src/kprintf/CMakeLists.txt
@@ -18,3 +18,5 @@ add_library(kprintf)
add_subdirectory(src)
target_include_directories(kprintf PUBLIC include PRIVATE private_include)
target_link_libraries(kprintf PUBLIC c PRIVATE io nanowasm)
+
+target_link_libraries(kprintf PRIVATE drv_ps1_bios dynstr)
diff --git a/src/kprintf/src/nwp_log.c b/src/kprintf/src/nwp_log.c
index 2db9969..392ea83 100644
--- a/src/kprintf/src/nwp_log.c
+++ b/src/kprintf/src/nwp_log.c
@@ -20,13 +20,25 @@
#include <nanowasm/nw.h>
#include <stdarg.h>
+
+#include <drv/ps1/bios.h>
+#include <dynstr.h>
int nwp_log(const char *const fmt, ...)
{
int ret;
va_list ap;
va_start(ap, fmt);
+#if 0
ret = ktvprintf(false, fmt, ap);
+#else
+ struct dynstr d;
+ dynstr_init(&d);
+ if (dynstr_vappend(&d, fmt, ap)) ret = -1;
+ else
+ ret = Printf("%s", d.str);
+ dynstr_free(&d);
+#endif
va_end(ap);
return ret;
}
diff --git a/src/loop/CMakeLists.txt b/src/loop/CMakeLists.txt
index 5d1e3e2..32b6179 100644
--- a/src/loop/CMakeLists.txt
+++ b/src/loop/CMakeLists.txt
@@ -18,3 +18,5 @@ add_library(loop)
add_subdirectory(src)
target_include_directories(loop PUBLIC include PRIVATE private_include)
target_link_libraries(loop PUBLIC aio PRIVATE bin fs gfx init net)
+
+target_link_libraries(loop PRIVATE kprintf drv_ps1_bios)
diff --git a/src/loop/src/run.c b/src/loop/src/run.c
index ea3ef26..6c23365 100644
--- a/src/loop/src/run.c
+++ b/src/loop/src/run.c
@@ -25,15 +25,40 @@
#include <init.h>
#include <net.h>
+
+#include <kprintf.h>
+#include <time.h>
+#include <drv/ps1/bios.h>
int loop_run(void)
{
+ static unsigned iterations;
+
if (fs_update()
|| aio_poll(loop_aio_head, 0) < 0
|| init_run()
- || net_update()
+ /*|| net_update()*/
|| bin_update()
|| gfx_update())
return -1;
+ iterations++;
+
+ static struct timespec ts;
+ struct timespec now;
+
+ if (clock_gettime(CLOCK_REALTIME, &now))
+ return -1;
+
+ if (now.tv_sec - ts.tv_sec)
+ {
+ extern unsigned sio_read, valid_packets;
+ extern int sio_stat_overrun, sw_overrun;
+
+ kprintf("%u ticks, read=%u, SIO=%d, SOV=%d, OK=%u\n", iterations,
+ sio_read, sio_stat_overrun, sw_overrun, valid_packets);
+ ts = now;
+ iterations = 0;
+ }
+
return 0;
}
diff --git a/src/net/CMakeLists.txt b/src/net/CMakeLists.txt
index e0822e7..4dce8b5 100644
--- a/src/net/CMakeLists.txt
+++ b/src/net/CMakeLists.txt
@@ -18,3 +18,6 @@ add_library(net)
add_subdirectory(src)
target_include_directories(net PUBLIC include PRIVATE private_include)
target_link_libraries(net PRIVATE aio loop state wip)
+
+
+target_link_libraries(net PRIVATE kprintf)