1 #ifndef _MACHINE_H 2 #define _MACHINE_H 3 4 #include <stdbool.h> 5 #include <list.h> 6 #include <util.h> 7 8 #define MACHINE_START(_name, _description) \ 9 static struct machine _machine = { \ 10 .name = #_name, \ 11 .description = _description, 12 #define MACHINE_END \ 13 }; \ 14 static void _unregister(void) \ 15 { \ 16 list_remove(&machines, &_machine); \ 17 } \ 18 INITIALIZER(_register) \ 19 { \ 20 list_insert(&machines, &_machine); \ 21 atexit(_unregister); \ 22 } 23 24 typedef void machine_priv_data_t; 25 26 struct machine { 27 char *name; 28 char *description; 29 machine_priv_data_t *priv_data; 30 bool running; 31 bool (*init)(struct machine *machine); 32 void (*reset)(struct machine *machine); 33 void (*deinit)(struct machine *machine); 34 }; 35 36 bool machine_init(); 37 void machine_reset(); 38 void machine_run(); 39 void machine_step(); 40 void machine_deinit(); 41 42 extern struct list_link *machines; 43 extern uint8_t *g_ram_data ; 44 extern unsigned int g_ram_size ; 45 46 #endif 47 48