diff options
| -rw-r--r-- | programs/initd/initd.c | 15 | ||||
| -rw-r--r-- | src/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/drv/ps1/cd/src/getstat.c | 3 | ||||
| -rw-r--r-- | src/drv/ps1/cd/src/update.c | 2 | ||||
| -rw-r--r-- | src/drv/ps1/irq/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/drv/ps1/sio/src/update.c | 5 | ||||
| -rw-r--r-- | src/init/ps1/src/boot.c | 5 | ||||
| -rw-r--r-- | src/kprintf/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/kprintf/src/nwp_log.c | 12 | ||||
| -rw-r--r-- | src/loop/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/loop/src/run.c | 25 | ||||
| -rw-r--r-- | src/net/CMakeLists.txt | 3 |
12 files changed, 81 insertions, 3 deletions
diff --git a/programs/initd/initd.c b/programs/initd/initd.c index 1568995..1be1a9c 100644 --- a/programs/initd/initd.c +++ b/programs/initd/initd.c @@ -16,15 +16,28 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ +#if 0 #include <sys/mount.h> +#endif +#include <sys/stat.h> #include <errno.h> #include <stddef.h> +#include <stdio.h> #include <stdlib.h> int main(void) { - if (mount("/dev/mc0", "/home", "ps1mcfs", 0, NULL)) +#if 1 + puts("hi from wasm!"); +#endif +#if 0 + if (mkdir("/home", 0755)) return errno; +#endif +#if 0 + if (mount("/dev/mc0", "/home", NULL, 0, NULL)) + return errno; +#endif return 1; } 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..d3e862a 100644 --- a/src/drv/ps1/cd/src/getstat.c +++ b/src/drv/ps1/cd/src/getstat.c @@ -26,6 +26,9 @@ 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; + return 0; + if (drv_ps1_event_test(p->event)) { p->available = !g->status.bits.shell_open; diff --git a/src/drv/ps1/cd/src/update.c b/src/drv/ps1/cd/src/update.c index 148dd87..cda44c3 100644 --- a/src/drv/ps1/cd/src/update.c +++ b/src/drv/ps1/cd/src/update.c @@ -26,7 +26,7 @@ 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->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/init/ps1/src/boot.c b/src/init/ps1/src/boot.c index 54b96e9..5f741f2 100644 --- a/src/init/ps1/src/boot.c +++ b/src/init/ps1/src/boot.c @@ -194,7 +194,12 @@ static int init_net(struct init_ps1 *const p) if (net_init(serial)) return -1; +#if 1 p->next = retry_cd; +#else + p->next = NULL; +#endif + return 0; } 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..3247a6f 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 1 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..9979fa5 100644 --- a/src/loop/src/run.c +++ b/src/loop/src/run.c @@ -25,8 +25,14 @@ #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() @@ -35,5 +41,24 @@ int loop_run(void) || 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) |
