Skip to content

Commit

Permalink
Merge pull request #37 from KallistiOSUnchained/remove_lwip
Browse files Browse the repository at this point in the history
Remove lwip references
  • Loading branch information
andressbarajas authored Nov 21, 2024
2 parents 3fafb83 + 0493af5 commit 9a8979a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 105 deletions.
2 changes: 1 addition & 1 deletion examples/dreamcast/mruby/dreampresent/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/dreamcast/mruby/mrbtris/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
105 changes: 11 additions & 94 deletions kernel/arch/dreamcast/fs/fs_dcload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
Expand All @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
4 changes: 1 addition & 3 deletions kernel/arch/dreamcast/hardware/network/broadband_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions kernel/arch/dreamcast/include/dc/fs_dcload.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

/** @} */
Expand Down
3 changes: 0 additions & 3 deletions kernel/libc/koslib/getaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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...
*/

Expand Down

0 comments on commit 9a8979a

Please sign in to comment.