From: falcovorbis <fal...@us...> - 2024-04-21 17:14:18
|
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 b7b8522fe822ee527715109ddd55470d727ddfb9 (commit) from dc96eb1d8de0dc77818ab6817ea473e3433239c4 (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 b7b8522fe822ee527715109ddd55470d727ddfb9 Author: Paul Cercueil <pa...@cr...> Date: Sun Apr 21 19:14:02 2024 +0200 init: Add init flags to enable/disable DCLOAD, CDROM (#516) * init: Add INIT_CDROM flag to init flags This flag, enabled by default, tells KallistiOS to initialize the CD-ROM subsystem as well as the ISO-9660 filesystem code. Some init functions had their prototype modified to be used with the init-flags mechanism. Signed-off-by: Paul Cercueil <pa...@cr...> * init: Garbage-collect dcload code when INIT_NO_DCLOAD flag is set When the INIT_NO_DCLOAD flag is set to the init flags, all the code that handles init, processing and shutdown of dcload can be garbage-collected. Signed-off-by: Paul Cercueil <pa...@cr...> --------- Signed-off-by: Paul Cercueil <pa...@cr...> ----------------------------------------------------------------------- Summary of changes: kernel/arch/dreamcast/fs/fs_dcload.c | 14 +++---- kernel/arch/dreamcast/fs/fs_dclsocket.c | 6 +-- kernel/arch/dreamcast/fs/fs_iso9660.c | 8 ++-- kernel/arch/dreamcast/hardware/cdrom.c | 4 +- kernel/arch/dreamcast/hardware/hardware.c | 11 ++++-- kernel/arch/dreamcast/include/arch/init_flags.h | 13 ++++++- kernel/arch/dreamcast/include/dc/cdrom.h | 5 +-- kernel/arch/dreamcast/include/dc/fs_dcload.h | 4 +- kernel/arch/dreamcast/include/dc/fs_dclsocket.h | 2 +- kernel/arch/dreamcast/include/dc/fs_iso9660.h | 4 +- kernel/arch/dreamcast/kernel/init.c | 52 ++++++++++++++++++------- 11 files changed, 80 insertions(+), 43 deletions(-) diff --git a/kernel/arch/dreamcast/fs/fs_dcload.c b/kernel/arch/dreamcast/fs/fs_dcload.c index 38946ab5..f43b2082 100644 --- a/kernel/arch/dreamcast/fs/fs_dcload.c +++ b/kernel/arch/dreamcast/fs/fs_dcload.c @@ -529,15 +529,15 @@ void fs_dcload_init_console(void) { } /* Call fs_dcload_init_console() before calling fs_dcload_init() */ -int fs_dcload_init(void) { +void fs_dcload_init(void) { // This was already done in init_console. if(dcload_type == DCLOAD_TYPE_NONE) - return -1; + return; /* Check for combination of KOS networking and dcload-ip */ if((dcload_type == DCLOAD_TYPE_IP) && (__kos_init_flags & INIT_NET)) { dbglog(DBG_INFO, "dc-load console+kosnet, will switch to internal ethernet\n"); - return -1; + return; /* if(old_printk) { dbgio_set_printk(old_printk); old_printk = 0; @@ -546,13 +546,13 @@ int fs_dcload_init(void) { } /* Register with VFS */ - return nmmgr_handler_add(&vh.nmmgr); + nmmgr_handler_add(&vh.nmmgr); } -int fs_dcload_shutdown(void) { +void fs_dcload_shutdown(void) { /* Check for dcload */ if(*DCLOADMAGICADDR != DCLOADMAGICVALUE) - return -1; + return; /* Free dcload wrkram */ if(dcload_wrkmem) { @@ -566,7 +566,7 @@ int fs_dcload_shutdown(void) { dbgio_dev_select("scif"); } - return nmmgr_handler_remove(&vh.nmmgr); + nmmgr_handler_remove(&vh.nmmgr); } /* used for dcload-ip + lwIP diff --git a/kernel/arch/dreamcast/fs/fs_dclsocket.c b/kernel/arch/dreamcast/fs/fs_dclsocket.c index 943a56d0..a965d39c 100644 --- a/kernel/arch/dreamcast/fs/fs_dclsocket.c +++ b/kernel/arch/dreamcast/fs/fs_dclsocket.c @@ -837,12 +837,12 @@ error: return -1; } -int fs_dclsocket_shutdown(void) { +void fs_dclsocket_shutdown(void) { int old; command_t cmd; if(initted != 2) - return -1; + return; dbglog(DBG_INFO, "fs_dclsocket: About to disable console\n"); @@ -869,5 +869,5 @@ int fs_dclsocket_shutdown(void) { /* Finally, clean up the socket */ close(dcls_socket); - return nmmgr_handler_remove(&vh.nmmgr); + nmmgr_handler_remove(&vh.nmmgr); } diff --git a/kernel/arch/dreamcast/fs/fs_iso9660.c b/kernel/arch/dreamcast/fs/fs_iso9660.c index 20d6f766..ce8e2cb8 100644 --- a/kernel/arch/dreamcast/fs/fs_iso9660.c +++ b/kernel/arch/dreamcast/fs/fs_iso9660.c @@ -1053,7 +1053,7 @@ static vfs_handler_t vh = { }; /* Initialize the file system */ -int fs_iso9660_init(void) { +void fs_iso9660_init(void) { int i; /* Reset fd's */ @@ -1081,11 +1081,11 @@ int fs_iso9660_init(void) { iso_vblank_hnd = vblank_handler_add(iso_vblank, NULL); /* Register with VFS */ - return nmmgr_handler_add(&vh.nmmgr); + nmmgr_handler_add(&vh.nmmgr); } /* De-init the file system */ -int fs_iso9660_shutdown(void) { +void fs_iso9660_shutdown(void) { int i; /* De-register with vblank */ @@ -1101,5 +1101,5 @@ int fs_iso9660_shutdown(void) { mutex_destroy(&cache_mutex); mutex_destroy(&fh_mutex); - return nmmgr_handler_remove(&vh.nmmgr); + nmmgr_handler_remove(&vh.nmmgr); } diff --git a/kernel/arch/dreamcast/hardware/cdrom.c b/kernel/arch/dreamcast/hardware/cdrom.c index d645dc68..abb4b028 100644 --- a/kernel/arch/dreamcast/hardware/cdrom.c +++ b/kernel/arch/dreamcast/hardware/cdrom.c @@ -470,7 +470,7 @@ int cdrom_spin_down(void) { } /* Initialize: assume no threading issues */ -int cdrom_init(void) { +void cdrom_init(void) { uint32_t p; volatile uint32_t *react = (uint32_t *)(0x005f74e4 | MEM_AREA_P2_BASE); volatile uint32_t *bios = (uint32_t *)MEM_AREA_P2_BASE; @@ -500,7 +500,7 @@ int cdrom_init(void) { gdc_init_system(); mutex_unlock(&_g1_ata_mutex); - return cdrom_reinit(); + cdrom_reinit(); } void cdrom_shutdown(void) { diff --git a/kernel/arch/dreamcast/hardware/hardware.c b/kernel/arch/dreamcast/hardware/hardware.c index c37066cc..a91a0ba6 100644 --- a/kernel/arch/dreamcast/hardware/hardware.c +++ b/kernel/arch/dreamcast/hardware/hardware.c @@ -58,6 +58,11 @@ KOS_INIT_FLAG_WEAK(bba_la_init, false); KOS_INIT_FLAG_WEAK(bba_la_shutdown, false); KOS_INIT_FLAG_WEAK(maple_init, true); +#ifndef _arch_sub_naomi +KOS_INIT_FLAG_WEAK(cdrom_init, true); +KOS_INIT_FLAG_WEAK(cdrom_shutdown, true); +#endif + int hardware_periph_init(void) { /* Init sound */ spu_init(); @@ -65,7 +70,7 @@ int hardware_periph_init(void) { #ifndef _arch_sub_naomi /* Init CD-ROM.. NOTE: NO GD-ROM SUPPORT. ONLY CDs/CDRs. */ - cdrom_init(); + KOS_INIT_FLAG_CALL(cdrom_init); #endif /* Setup maple bus */ @@ -92,9 +97,7 @@ void hardware_shutdown(void) { KOS_INIT_FLAG_CALL(bba_la_shutdown); #endif KOS_INIT_FLAG_CALL(maple_shutdown); -#if 0 - cdrom_shutdown(); -#endif + KOS_INIT_FLAG_CALL(cdrom_shutdown); g2_dma_shutdown(); spu_shutdown(); vid_shutdown(); diff --git a/kernel/arch/dreamcast/include/arch/init_flags.h b/kernel/arch/dreamcast/include/arch/init_flags.h index f22c3bed..3a1d053c 100644 --- a/kernel/arch/dreamcast/include/arch/init_flags.h +++ b/kernel/arch/dreamcast/include/arch/init_flags.h @@ -44,6 +44,15 @@ __BEGIN_DECLS \sa KOS_INIT_FLAGS() */ #define KOS_INIT_FLAGS_ARCH(flags) \ + KOS_INIT_FLAG_NONE(flags, INIT_NO_DCLOAD, dcload_init); \ + KOS_INIT_FLAG_NONE(flags, INIT_NO_DCLOAD, fs_dcload_init_console); \ + KOS_INIT_FLAG_NONE(flags, INIT_NO_DCLOAD, fs_dcload_shutdown); \ + KOS_INIT_FLAG_NONE(flags, INIT_NO_DCLOAD, arch_init_net_dcload_ip); \ + KOS_INIT_FLAG(flags, INIT_NO_DCLOAD, arch_init_net_no_dcload); \ + KOS_INIT_FLAG(flags, INIT_CDROM, cdrom_init); \ + KOS_INIT_FLAG(flags, INIT_CDROM, cdrom_shutdown); \ + KOS_INIT_FLAG(flags, INIT_CDROM, fs_iso9660_init); \ + KOS_INIT_FLAG(flags, INIT_CDROM, fs_iso9660_shutdown); \ KOS_INIT_FLAG(flags, INIT_CONTROLLER, cont_init); \ KOS_INIT_FLAG(flags, INIT_CONTROLLER, cont_shutdown); \ KOS_INIT_FLAG(flags, INIT_KEYBOARD, kbd_init); \ @@ -79,7 +88,7 @@ __BEGIN_DECLS */ /** \brief Default init flags for the Dreamcast. */ -#define INIT_DEFAULT_ARCH (INIT_MAPLE_ALL) +#define INIT_DEFAULT_ARCH (INIT_MAPLE_ALL | INIT_CDROM) #define INIT_CONTROLLER 0x00001000 /**< \brief Enable Controller maple driver */ #define INIT_KEYBOARD 0x00002000 /**< \brief Enable Keyboard maple driver */ @@ -91,6 +100,8 @@ __BEGIN_DECLS #define INIT_DREAMEYE 0x00080000 /**< \brief Enable DreamEye maple driver */ #define INIT_MAPLE_ALL 0x000ff000 /**< \brief Enable all Maple drivers */ +#define INIT_CDROM 0x00100000 /**< \brief Enable CD-ROM support */ + #define INIT_OCRAM 0x10000000 /**< \brief Use half of the dcache as RAM */ #define INIT_NO_DCLOAD 0x20000000 /**< \brief Disable dcload */ diff --git a/kernel/arch/dreamcast/include/dc/cdrom.h b/kernel/arch/dreamcast/include/dc/cdrom.h index d8480b86..32d216d4 100644 --- a/kernel/arch/dreamcast/include/dc/cdrom.h +++ b/kernel/arch/dreamcast/include/dc/cdrom.h @@ -493,11 +493,8 @@ int cdrom_spin_down(void); This initializes the CD-ROM reading system, reactivating the drive and handling initial setup of the disc. - - \retval 0 On success. - \retval -1 Already initted, shutdown before initting again. */ -int cdrom_init(void); +void cdrom_init(void); /** \brief Shutdown the CD reading system. \ingroup gdrom diff --git a/kernel/arch/dreamcast/include/dc/fs_dcload.h b/kernel/arch/dreamcast/include/dc/fs_dcload.h index 0f0c27e2..5810e043 100644 --- a/kernel/arch/dreamcast/include/dc/fs_dcload.h +++ b/kernel/arch/dreamcast/include/dc/fs_dcload.h @@ -140,8 +140,8 @@ int dcload_unlink(vfs_handler_t * vfs, const char *fn); /* Init func */ void fs_dcload_init_console(void); -int fs_dcload_init(void); -int fs_dcload_shutdown(void); +void fs_dcload_init(void); +void fs_dcload_shutdown(void); /* Init func for dcload-ip + lwIP */ int fs_dcload_init_lwip(void *p); diff --git a/kernel/arch/dreamcast/include/dc/fs_dclsocket.h b/kernel/arch/dreamcast/include/dc/fs_dclsocket.h index adb6dc8b..310837b9 100644 --- a/kernel/arch/dreamcast/include/dc/fs_dclsocket.h +++ b/kernel/arch/dreamcast/include/dc/fs_dclsocket.h @@ -36,7 +36,7 @@ extern dbgio_handler_t dbgio_dcls; void fs_dclsocket_init_console(void); int fs_dclsocket_init(void); -int fs_dclsocket_shutdown(void); +void fs_dclsocket_shutdown(void); /* \endcond */ /** @} */ diff --git a/kernel/arch/dreamcast/include/dc/fs_iso9660.h b/kernel/arch/dreamcast/include/dc/fs_iso9660.h index 489b08bf..e2f245b7 100644 --- a/kernel/arch/dreamcast/include/dc/fs_iso9660.h +++ b/kernel/arch/dreamcast/include/dc/fs_iso9660.h @@ -48,8 +48,8 @@ __BEGIN_DECLS int iso_reset(void); /* \cond */ -int fs_iso9660_init(void); -int fs_iso9660_shutdown(void); +void fs_iso9660_init(void); +void fs_iso9660_shutdown(void); /* \endcond */ /** @} */ diff --git a/kernel/arch/dreamcast/kernel/init.c b/kernel/arch/dreamcast/kernel/init.c index ee6ecf89..eaff1d5f 100644 --- a/kernel/arch/dreamcast/kernel/init.c +++ b/kernel/arch/dreamcast/kernel/init.c @@ -58,13 +58,13 @@ dbgio_handler_t * dbgio_handlers[] = { }; int dbgio_handler_cnt = sizeof(dbgio_handlers) / sizeof(dbgio_handler_t *); -void arch_init_net(void) { +void arch_init_net_dcload_ip(void) { union { uint32 ipl; uint8 ipb[4]; } ip = { 0 }; - if(!(__kos_init_flags & INIT_NO_DCLOAD) && dcload_type == DCLOAD_TYPE_IP) { + if(dcload_type == DCLOAD_TYPE_IP) { /* Grab the IP address from dcload before we disable dbgio... */ ip.ipl = _fs_dclsocket_get_ip(); dbglog(DBG_INFO, "dc-load says our IP is %d.%d.%d.%d\n", ip.ipb[3], @@ -74,7 +74,7 @@ void arch_init_net(void) { net_init(ip.ipl); /* Enable networking (and drivers) */ - if(!(__kos_init_flags & INIT_NO_DCLOAD) && dcload_type == DCLOAD_TYPE_IP) { + if(dcload_type == DCLOAD_TYPE_IP) { fs_dclsocket_init_console(); if(!fs_dclsocket_init()) { @@ -85,6 +85,18 @@ void arch_init_net(void) { } } +void arch_init_net_no_dcload(void) { + net_init(0); +} + +KOS_INIT_FLAG_WEAK(arch_init_net_dcload_ip, true); +KOS_INIT_FLAG_WEAK(arch_init_net_no_dcload, false); + +void arch_init_net(void) { + KOS_INIT_FLAG_CALL(arch_init_net_dcload_ip); + KOS_INIT_FLAG_CALL(arch_init_net_no_dcload); +} + void vmu_fs_init(void) { fs_vmu_init(); vmufs_init(); @@ -114,6 +126,23 @@ KOS_INIT_FLAG_WEAK(fs_romdisk_mount_builtin_legacy, false); KOS_INIT_FLAG_WEAK(vmu_fs_init, true); KOS_INIT_FLAG_WEAK(vmu_fs_shutdown, true); +#ifndef _arch_sub_naomi +KOS_INIT_FLAG_WEAK(fs_iso9660_init, true); +KOS_INIT_FLAG_WEAK(fs_iso9660_shutdown, true); +#endif + +void dcload_init(void) { + if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) { + dbglog(DBG_INFO, "dc-load console support enabled\n"); + fs_dcload_init(); + } +} + +KOS_INIT_FLAG_WEAK(dcload_init, true); +KOS_INIT_FLAG_WEAK(fs_dcload_init_console, true); +KOS_INIT_FLAG_WEAK(fs_dcload_shutdown, true); +KOS_INIT_FLAG_WEAK(fs_dclsocket_shutdown, true); + /* Auto-init stuff: override with a non-weak symbol if you don't want all of this to be linked into your code (and do the same with the arch_auto_shutdown function too). */ @@ -128,8 +157,8 @@ int __weak arch_auto_init(void) { ubc_init(); - if(!(__kos_init_flags & INIT_NO_DCLOAD)) - fs_dcload_init_console(); /* Init dc-load console, if applicable */ + /* Init dc-load console, if applicable */ + KOS_INIT_FLAG_CALL(fs_dcload_init_console); /* Init SCIF for debug stuff (maybe) */ scif_init(); @@ -176,13 +205,10 @@ int __weak arch_auto_init(void) { if(!KOS_INIT_FLAG_CALL(fs_romdisk_mount_builtin)) KOS_INIT_FLAG_CALL(fs_romdisk_mount_builtin_legacy); - if(!(__kos_init_flags & INIT_NO_DCLOAD) && *DCLOADMAGICADDR == DCLOADMAGICVALUE) { - dbglog(DBG_INFO, "dc-load console support enabled\n"); - fs_dcload_init(); - } + KOS_INIT_FLAG_CALL(dcload_init); #ifndef _arch_sub_naomi - fs_iso9660_init(); + KOS_INIT_FLAG_CALL(fs_iso9660_init); #endif KOS_INIT_FLAG_CALL(vmu_fs_init); @@ -204,7 +230,7 @@ int __weak arch_auto_init(void) { } void __weak arch_auto_shutdown(void) { - fs_dclsocket_shutdown(); + KOS_INIT_FLAG_CALL(fs_dclsocket_shutdown); #ifndef _arch_sub_naomi KOS_INIT_FLAG_CALL(net_shutdown); #endif @@ -215,10 +241,10 @@ void __weak arch_auto_shutdown(void) { hardware_shutdown(); pvr_shutdown(); library_shutdown(); - fs_dcload_shutdown(); + KOS_INIT_FLAG_CALL(fs_dcload_shutdown); KOS_INIT_FLAG_CALL(vmu_fs_shutdown); #ifndef _arch_sub_naomi - fs_iso9660_shutdown(); + KOS_INIT_FLAG_CALL(fs_iso9660_shutdown); #endif #if defined(__NEWLIB__) && !(__NEWLIB__ < 2 && __NEWLIB_MINOR__ < 4) fs_dev_shutdown(); hooks/post-receive -- A pseudo Operating System for the Dreamcast. |