1 /* startup_manager.h: handle Fuse's startup routines 2 Copyright (c) 2016-2018 Philip Kendall, Alistair Cree 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 18 Author contact information: 19 20 E-mail: philip-fuse@shadowmagic.org.uk 21 22 */ 23 24 #ifndef FUSE_STARTUP_MANAGER_H 25 #define FUSE_STARTUP_MANAGER_H 26 27 /* The modules the startup manager knows about */ 28 typedef enum startup_manager_module { 29 30 STARTUP_MANAGER_MODULE_AY, 31 STARTUP_MANAGER_MODULE_BETA, 32 STARTUP_MANAGER_MODULE_COVOX, 33 STARTUP_MANAGER_MODULE_CREATOR, 34 STARTUP_MANAGER_MODULE_DEBUGGER, 35 STARTUP_MANAGER_MODULE_DIDAKTIK, 36 STARTUP_MANAGER_MODULE_DISCIPLE, 37 STARTUP_MANAGER_MODULE_DISPLAY, 38 STARTUP_MANAGER_MODULE_DIVIDE, 39 STARTUP_MANAGER_MODULE_DIVMMC, 40 STARTUP_MANAGER_MODULE_EVENT, 41 STARTUP_MANAGER_MODULE_FDD, 42 STARTUP_MANAGER_MODULE_FULLER, 43 STARTUP_MANAGER_MODULE_IF1, 44 STARTUP_MANAGER_MODULE_IF2, 45 STARTUP_MANAGER_MODULE_JOYSTICK, 46 STARTUP_MANAGER_MODULE_KEMPMOUSE, 47 STARTUP_MANAGER_MODULE_KEYBOARD, 48 STARTUP_MANAGER_MODULE_LIBSPECTRUM, 49 STARTUP_MANAGER_MODULE_LIBXML2, 50 STARTUP_MANAGER_MODULE_MACHINE, 51 STARTUP_MANAGER_MODULE_MACHINES_PERIPH, 52 STARTUP_MANAGER_MODULE_MELODIK, 53 STARTUP_MANAGER_MODULE_MEMORY, 54 STARTUP_MANAGER_MODULE_MEMPOOL, 55 STARTUP_MANAGER_MODULE_MULTIFACE, 56 STARTUP_MANAGER_MODULE_OPUS, 57 STARTUP_MANAGER_MODULE_PHANTOM_TYPIST, 58 STARTUP_MANAGER_MODULE_PLUSD, 59 STARTUP_MANAGER_MODULE_PRINTER, 60 STARTUP_MANAGER_MODULE_PROFILE, 61 STARTUP_MANAGER_MODULE_PSG, 62 STARTUP_MANAGER_MODULE_RZX, 63 STARTUP_MANAGER_MODULE_SCLD, 64 STARTUP_MANAGER_MODULE_SCREENSHOT, 65 STARTUP_MANAGER_MODULE_SETTINGS_END, 66 STARTUP_MANAGER_MODULE_SETUID, 67 STARTUP_MANAGER_MODULE_SIMPLEIDE, 68 STARTUP_MANAGER_MODULE_SLT, 69 STARTUP_MANAGER_MODULE_SOUND, 70 STARTUP_MANAGER_MODULE_SPECCYBOOT, 71 STARTUP_MANAGER_MODULE_SPECDRUM, 72 STARTUP_MANAGER_MODULE_SPECTRANET, 73 STARTUP_MANAGER_MODULE_SPECTRUM, 74 STARTUP_MANAGER_MODULE_TAPE, 75 STARTUP_MANAGER_MODULE_TTX2000S, 76 STARTUP_MANAGER_MODULE_TIMER, 77 STARTUP_MANAGER_MODULE_ULA, 78 STARTUP_MANAGER_MODULE_USOURCE, 79 STARTUP_MANAGER_MODULE_Z80, 80 STARTUP_MANAGER_MODULE_ZXATASP, 81 STARTUP_MANAGER_MODULE_ZXCF, 82 STARTUP_MANAGER_MODULE_ZXMMC, 83 84 } startup_manager_module; 85 86 /* Callback for each module's init function */ 87 typedef int (*startup_manager_init_fn)( void *context ); 88 89 /* Callback for each module's end function */ 90 typedef void (*startup_manager_end_fn)( void ); 91 92 /* Initialise the startup manager itself */ 93 void startup_manager_init( void ); 94 95 /* Register an module with the startup manager */ 96 void startup_manager_register( 97 startup_manager_module module, startup_manager_module *dependencies, 98 size_t dependency_count, startup_manager_init_fn init_fn, 99 void *init_context, startup_manager_end_fn end_fn ); 100 101 /* Register an module with no dependencies with the startup manager */ 102 void startup_manager_register_no_dependencies( 103 startup_manager_module module, startup_manager_init_fn init_fn, 104 void *init_context, startup_manager_end_fn end_fn ); 105 106 /* Run all the registered init functions in the right order */ 107 int startup_manager_run( void ); 108 109 /* Run all the end functions in inverse order of the init functions */ 110 void startup_manager_run_end( void ); 111 112 #endif /* #ifndef FUSE_STARTUP_MANAGER_H */ 113