1 1.1 christos /* Module support. 2 1.11 christos Copyright (C) 1996-2024 Free Software Foundation, Inc. 3 1.1 christos Contributed by Cygnus Support. 4 1.1 christos 5 1.1 christos This file is part of GDB, the GNU debugger. 6 1.1 christos 7 1.1 christos This program is free software; you can redistribute it and/or modify 8 1.1 christos it under the terms of the GNU General Public License as published by 9 1.1 christos the Free Software Foundation; either version 3 of the License, or 10 1.1 christos (at your option) any later version. 11 1.1 christos 12 1.1 christos This program is distributed in the hope that it will be useful, 13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 1.1 christos GNU General Public License for more details. 16 1.1 christos 17 1.1 christos You should have received a copy of the GNU General Public License 18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 1.1 christos 20 1.1 christos /* This file is intended to be included by sim-base.h. */ 21 1.1 christos 22 1.1 christos #ifndef SIM_MODULES_H 23 1.1 christos #define SIM_MODULES_H 24 1.1 christos 25 1.1 christos /* Modules are addons to the simulator that perform a specific function 26 1.1 christos (e.g. tracing, profiling, memory subsystem, etc.). Some modules are 27 1.1 christos builtin, and others are added at configure time. The intent is to 28 1.1 christos provide a uniform framework for all of the pieces that make up the 29 1.1 christos simulator. 30 1.1 christos 31 1.1 christos TODO: Add facilities for saving/restoring state to/from a file. */ 32 1.1 christos 33 1.10 christos #include "sim/sim.h" 34 1.1 christos 35 1.1 christos /* Various function types. */ 36 1.1 christos 37 1.1 christos typedef SIM_RC (MODULE_INSTALL_FN) (SIM_DESC); 38 1.1 christos typedef SIM_RC (MODULE_INIT_FN) (SIM_DESC); 39 1.1 christos typedef SIM_RC (MODULE_RESUME_FN) (SIM_DESC); 40 1.1 christos typedef SIM_RC (MODULE_SUSPEND_FN) (SIM_DESC); 41 1.1 christos typedef void (MODULE_UNINSTALL_FN) (SIM_DESC); 42 1.11 christos typedef void (MODULE_INFO_FN) (SIM_DESC, bool); 43 1.1 christos 44 1.1 christos 45 1.1 christos /* Lists of installed handlers. */ 46 1.1 christos 47 1.1 christos typedef struct module_init_list { 48 1.1 christos struct module_init_list *next; 49 1.1 christos MODULE_INIT_FN *fn; 50 1.1 christos } MODULE_INIT_LIST; 51 1.1 christos 52 1.1 christos typedef struct module_resume_list { 53 1.1 christos struct module_resume_list *next; 54 1.1 christos MODULE_RESUME_FN *fn; 55 1.1 christos } MODULE_RESUME_LIST; 56 1.1 christos 57 1.1 christos typedef struct module_suspend_list { 58 1.1 christos struct module_suspend_list *next; 59 1.1 christos MODULE_SUSPEND_FN *fn; 60 1.1 christos } MODULE_SUSPEND_LIST; 61 1.1 christos 62 1.1 christos typedef struct module_uninstall_list { 63 1.1 christos struct module_uninstall_list *next; 64 1.1 christos MODULE_UNINSTALL_FN *fn; 65 1.1 christos } MODULE_UNINSTALL_LIST; 66 1.1 christos 67 1.1 christos typedef struct module_info_list { 68 1.1 christos struct module_info_list *next; 69 1.1 christos MODULE_INFO_FN *fn; 70 1.1 christos } MODULE_INFO_LIST; 71 1.1 christos 72 1.1 christos 73 1.1 christos /* Functions to register module with various handler lists */ 74 1.1 christos 75 1.1 christos SIM_RC sim_module_install (SIM_DESC); 76 1.10 christos SIM_RC sim_module_install_list (SIM_DESC, MODULE_INSTALL_FN * const[], size_t); 77 1.1 christos void sim_module_uninstall (SIM_DESC); 78 1.1 christos void sim_module_add_init_fn (SIM_DESC sd, MODULE_INIT_FN fn); 79 1.1 christos void sim_module_add_resume_fn (SIM_DESC sd, MODULE_RESUME_FN fn); 80 1.1 christos void sim_module_add_suspend_fn (SIM_DESC sd, MODULE_SUSPEND_FN fn); 81 1.1 christos void sim_module_add_uninstall_fn (SIM_DESC sd, MODULE_UNINSTALL_FN fn); 82 1.1 christos void sim_module_add_info_fn (SIM_DESC sd, MODULE_INFO_FN fn); 83 1.1 christos 84 1.1 christos 85 1.1 christos /* Initialize installed modules before argument processing. 86 1.1 christos Called by sim_open. */ 87 1.1 christos SIM_RC sim_pre_argv_init (SIM_DESC sd, const char *myname); 88 1.1 christos 89 1.1 christos /* Initialize installed modules after argument processing. 90 1.1 christos Called by sim_open. */ 91 1.1 christos SIM_RC sim_post_argv_init (SIM_DESC sd); 92 1.1 christos 93 1.1 christos /* Re-initialize the module. Called by sim_create_inferior. */ 94 1.1 christos SIM_RC sim_module_init (SIM_DESC sd); 95 1.1 christos 96 1.1 christos /* Suspend/resume modules. Called by sim_run or sim_resume */ 97 1.1 christos SIM_RC sim_module_suspend (SIM_DESC sd); 98 1.1 christos SIM_RC sim_module_resume (SIM_DESC sd); 99 1.1 christos 100 1.1 christos /* Report general information on module */ 101 1.11 christos void sim_module_info (SIM_DESC sd, bool verbose); 102 1.1 christos 103 1.1 christos 104 1.1 christos /* Module private data */ 105 1.1 christos 106 1.1 christos struct module_list { 107 1.1 christos 108 1.1 christos /* List of installed module `init' handlers */ 109 1.1 christos MODULE_INIT_LIST *init_list; 110 1.1 christos 111 1.1 christos /* List of installed module `uninstall' handlers. */ 112 1.1 christos MODULE_UNINSTALL_LIST *uninstall_list; 113 1.1 christos 114 1.1 christos /* List of installed module `resume' handlers. */ 115 1.1 christos MODULE_RESUME_LIST *resume_list; 116 1.1 christos 117 1.1 christos /* List of installed module `suspend' handlers. */ 118 1.1 christos MODULE_SUSPEND_LIST *suspend_list; 119 1.1 christos 120 1.1 christos /* List of installed module `info' handlers. */ 121 1.1 christos MODULE_INFO_LIST *info_list; 122 1.1 christos 123 1.1 christos }; 124 1.1 christos 125 1.1 christos 126 1.1 christos #endif /* SIM_MODULES_H */ 127