From 0493af53be76af314e1ee1b30c384ac6aa1286b2 Mon Sep 17 00:00:00 2001 From: Andress Barajas Date: Wed, 20 Nov 2024 21:49:42 -0800 Subject: [PATCH] Remove lwip references Removed lwip code/references where unneeded. --- examples/dreamcast/mruby/dreampresent/main.c | 2 +- examples/dreamcast/mruby/mrbtris/main.c | 2 +- kernel/arch/dreamcast/fs/fs_dcload.c | 105 ++---------------- .../hardware/network/broadband_adapter.c | 4 +- kernel/arch/dreamcast/include/dc/fs_dcload.h | 3 - kernel/libc/koslib/getaddrinfo.c | 3 - 6 files changed, 14 insertions(+), 105 deletions(-) diff --git a/examples/dreamcast/mruby/dreampresent/main.c b/examples/dreamcast/mruby/dreampresent/main.c index 5169c8ba3..4ca02f06d 100644 --- a/examples/dreamcast/mruby/dreampresent/main.c +++ b/examples/dreamcast/mruby/dreampresent/main.c @@ -38,7 +38,7 @@ INIT_NONE -- don't do any auto init INIT_IRQ -- knable IRQs INIT_THD_PREEMPT -- Enable pre-emptive threading - INIT_NET -- Enable networking (doesn't imply lwIP!) + INIT_NET -- Enable networking INIT_MALLOCSTATS -- Enable a call to malloc_stats() right before shutdown You can OR any or all of those together. If you want to start out with diff --git a/examples/dreamcast/mruby/mrbtris/main.c b/examples/dreamcast/mruby/mrbtris/main.c index a8edf4a41..c522821ce 100644 --- a/examples/dreamcast/mruby/mrbtris/main.c +++ b/examples/dreamcast/mruby/mrbtris/main.c @@ -38,7 +38,7 @@ INIT_NONE -- don't do any auto init INIT_IRQ -- knable IRQs INIT_THD_PREEMPT -- Enable pre-emptive threading - INIT_NET -- Enable networking (doesn't imply lwIP!) + INIT_NET -- Enable networking INIT_MALLOCSTATS -- Enable a call to malloc_stats() right before shutdown You can OR any or all of those together. If you want to start out with diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index 949952ab7..0f0ce09c9 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -34,42 +34,23 @@ printf goes to the dc-tool console static spinlock_t mutex = SPINLOCK_INITIALIZER; -#define plain_dclsc(...) ({ \ - int old = 0, rv; \ - if(!irq_inside_int()) { \ - old = irq_disable(); \ - } \ - while(FIFO_STATUS & FIFO_SH4) \ - ; \ - rv = dcloadsyscall(__VA_ARGS__); \ - if(!irq_inside_int()) \ - irq_restore(old); \ - rv; \ - }) - -// #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; \ - }) + int old = 0, rv; \ + if(!irq_inside_int()) { \ + old = irq_disable(); \ + } \ + while(FIFO_STATUS & FIFO_SH4) \ + ; \ + rv = dcloadsyscall(__VA_ARGS__); \ + if(!irq_inside_int()) \ + irq_restore(old); \ + 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(&mutex); dclsc(DCLOAD_WRITE, 1, data, len); spinlock_unlock(&mutex); @@ -84,9 +65,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) { size_t ret = -1; - if(lwip_dclsc && irq_inside_int()) - return 0; - spinlock_lock(&mutex); /* we have to pack the sizes together because the dcloadsyscall handler @@ -106,9 +84,6 @@ void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) { (void)vfs; - if(lwip_dclsc && irq_inside_int()) - return (void *)0; - spinlock_lock(&mutex); if(mode & O_DIR) { @@ -161,11 +136,6 @@ void *dcload_open(vfs_handler_t * vfs, const char *fn, int mode) { int dcload_close(void * h) { uint32 hnd = (uint32)h; - if(lwip_dclsc && irq_inside_int()) { - errno = EINTR; - return -1; - } - spinlock_lock(&mutex); if(hnd) { @@ -185,9 +155,6 @@ 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(&mutex); if(hnd) { @@ -203,9 +170,6 @@ 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(&mutex); if(hnd) { @@ -221,9 +185,6 @@ 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(&mutex); if(hnd) { @@ -239,9 +200,6 @@ off_t dcload_tell(void * h) { off_t ret = -1; uint32 hnd = (uint32)h; - if(lwip_dclsc && irq_inside_int()) - return 0; - spinlock_lock(&mutex); if(hnd) { @@ -258,9 +216,6 @@ size_t dcload_total(void * h) { size_t cur; uint32 hnd = (uint32)h; - if(lwip_dclsc && irq_inside_int()) - return 0; - spinlock_lock(&mutex); if(hnd) { @@ -283,11 +238,6 @@ dirent_t *dcload_readdir(void * h) { char *fn; uint32 hnd = (uint32)h; - if(lwip_dclsc && irq_inside_int()) { - errno = EAGAIN; - return NULL; - } - if(hnd < 100) { errno = EBADF; return NULL; @@ -332,9 +282,6 @@ int dcload_rename(vfs_handler_t * vfs, const char *fn1, const char *fn2) { (void)vfs; - if(lwip_dclsc && irq_inside_int()) - return 0; - spinlock_lock(&mutex); /* really stupid hack, since I didn't put rename() in dcload */ @@ -353,9 +300,6 @@ int dcload_unlink(vfs_handler_t * vfs, const char *fn) { (void)vfs; - if(lwip_dclsc && irq_inside_int()) - return 0; - spinlock_lock(&mutex); ret = dclsc(DCLOAD_UNLINK, fn); @@ -372,9 +316,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)); @@ -526,7 +467,6 @@ void fs_dcload_init_console(void) { if(*DCLOADMAGICADDR != DCLOADMAGICVALUE) return; - /* 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) { @@ -576,28 +516,5 @@ void fs_dcload_shutdown(void) { free(dcload_wrkmem); } - /* If we're not on lwIP, we can continue using the debug channel */ - if(lwip_dclsc) { - dcload_type = DCLOAD_TYPE_NONE; - dbgio_dev_select("scif"); - } - nmmgr_handler_remove(&vh.nmmgr); } - -/* used for dcload-ip + lwIP - * assumes fs_dcload_init() was previously called - */ -int fs_dcload_init_lwip(void *p) { - /* Check for combination of KOS networking and dcload-ip */ - if((dcload_type == DCLOAD_TYPE_IP) && (__kos_init_flags & INIT_NET)) { - lwip_dclsc = p; - - dbglog(DBG_INFO, "dc-load console support enabled (lwIP)\n"); - } - else - return -1; - - /* Register with VFS */ - return nmmgr_handler_add(&vh.nmmgr); -} diff --git a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c index 36df6dada..1e2382687 100644 --- a/kernel/arch/dreamcast/hardware/network/broadband_adapter.c +++ b/kernel/arch/dreamcast/hardware/network/broadband_adapter.c @@ -49,9 +49,7 @@ #define DMA_THRESHOLD 128 // looks like a good value /* Since callbacks will be running with interrupts enabled, - it might be a good idea to protect bba_tx with a semaphore from inside. - I'm not sure lwip needs that, but dcplaya does when using both lwip and its - own dcload syscalls emulation.*/ + it might be a good idea to protect bba_tx with a semaphore from inside. */ #define TX_SEMA /* If this is defined, the dma buffer will be located in P2 area, and no call to diff --git a/kernel/arch/dreamcast/include/dc/fs_dcload.h b/kernel/arch/dreamcast/include/dc/fs_dcload.h index 5810e043c..460d79069 100644 --- a/kernel/arch/dreamcast/include/dc/fs_dcload.h +++ b/kernel/arch/dreamcast/include/dc/fs_dcload.h @@ -143,9 +143,6 @@ void fs_dcload_init_console(void); void fs_dcload_init(void); void fs_dcload_shutdown(void); -/* Init func for dcload-ip + lwIP */ -int fs_dcload_init_lwip(void *p); - /* \endcond */ /** @} */ diff --git a/kernel/libc/koslib/getaddrinfo.c b/kernel/libc/koslib/getaddrinfo.c index 3288268d4..77cb78dca 100644 --- a/kernel/libc/koslib/getaddrinfo.c +++ b/kernel/libc/koslib/getaddrinfo.c @@ -48,9 +48,6 @@ This performs a simple DNS A-record query. It hasn't been tested extensively but so far it seems to work fine. - This relies on the really sketchy UDP support in the KOS lwIP port, so it - can be cleaned up later once that's improved. - We really need to be setting errno in here too... */