filename | src/dream.h |
changeset | 35:21a4be098304 |
prev | 31:495e480360d7 |
next | 119:cef4d880123c |
author | nkeynes |
date | Tue Jan 10 13:58:35 2006 +0000 (18 years ago) |
permissions | -rw-r--r-- |
last change | Force redisasm when switching cpus Handle emits when gui hasn't been created yet (dump to stderr) |
file | annotate | diff | log | raw |
1.1 --- a/src/dream.h Sun Dec 25 08:24:11 2005 +00001.2 +++ b/src/dream.h Tue Jan 10 13:58:35 2006 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: dream.h,v 1.6 2005-12-25 08:24:07 nkeynes Exp $1.6 + * $Id: dream.h,v 1.7 2005-12-26 03:54:52 nkeynes Exp $1.7 *1.8 * Miscellaneous application-wide declarations (mainly logging atm)1.9 *1.10 @@ -19,6 +19,7 @@1.11 #ifndef dream_H1.12 #define dream_H 11.14 +#include <stdio.h>1.15 #include <stdlib.h>1.16 #include <stdint.h>1.17 #include <string.h>1.18 @@ -26,10 +27,66 @@1.20 #ifdef __cplusplus1.21 extern "C" {1.22 -#if 01.23 -}1.24 #endif1.25 -#endif1.26 +1.27 +/************************ Modules ********************************/1.28 +/**1.29 + * Basic module structure defining the common operations across all1.30 + * modules, ie start, stop, reset, etc.1.31 + */1.32 +typedef struct dreamcast_module {1.33 + char *name;1.34 + /**1.35 + * Perform all initial module setup (ie register / allocate any1.36 + * memory required, etc). Only called once during DreamOn startup1.37 + */1.38 + void (*init)();1.39 + /**1.40 + * Reset the module into it's initial system boot state. Will be called1.41 + * once after init(), as well as whenever the user requests a reset.1.42 + */1.43 + void (*reset)();1.44 + /**1.45 + * Set the module into a running state (may be NULL)1.46 + */1.47 + void (*start)();1.48 + /**1.49 + * Execute one time-slice worth of operations, for the given number of1.50 + * nanoseconds.1.51 + * @return Number of nanoseconds actually executed1.52 + */1.53 + uint32_t (*run_time_slice)( uint32_t nanosecs );1.54 + /**1.55 + * Set the module into a stopped state (may be NULL)1.56 + */1.57 + void (*stop)();1.58 + /**1.59 + * Save the module state to the FILE stream. May be NULL, in which case1.60 + * the module is considered to have no state.1.61 + */1.62 + void (*save)(FILE *);1.63 + /**1.64 + * Load the saved module state from the FILE stream. May be NULL, in which1.65 + * case reset() will be called instead.1.66 + * @return 0 on success, nonzero on failure.1.67 + */1.68 + int (*load)(FILE *);1.69 +} *dreamcast_module_t;1.70 +1.71 +void dreamcast_register_module( dreamcast_module_t );1.72 +1.73 +extern struct dreamcast_module mem_module;1.74 +extern struct dreamcast_module sh4_module;1.75 +extern struct dreamcast_module asic_module;1.76 +extern struct dreamcast_module pvr2_module;1.77 +extern struct dreamcast_module aica_module;1.78 +extern struct dreamcast_module ide_module;1.79 +extern struct dreamcast_module maple_module;1.80 +extern struct dreamcast_module pvr2_module;1.81 +extern struct dreamcast_module gui_module;1.82 +extern struct dreamcast_module unknown_module;1.83 +1.84 +/*************************** Logging **************************/1.86 #define EMIT_FATAL 01.87 #define EMIT_ERR 11.88 @@ -38,21 +95,24 @@1.89 #define EMIT_DEBUG 41.90 #define EMIT_TRACE 51.92 -#ifndef MODULE_ID1.93 -#define MODULE_ID 01.94 +#ifndef MODULE1.95 +#define MODULE unknown_module1.96 #endif1.98 -void emit( void *, int level, int source, const char *msg, ... );1.99 +void emit( void *, int level, const char *source, const char *msg, ... );1.101 -#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE_ID, __VA_ARGS__ )1.102 -#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE_ID, __VA_ARGS__ )1.103 -#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE_ID, __VA_ARGS__ )1.104 -#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE_ID, __VA_ARGS__ )1.105 -#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE_ID, __VA_ARGS__ )1.106 -#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE_ID, __VA_ARGS__ )1.107 +#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )1.108 +#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )1.109 +#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )1.110 +#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )1.111 +#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )1.112 +#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )1.114 #define BIOS_PATH "../bios"1.116 +void fwrite_string( char *s, FILE *f );1.117 +int fread_string( char *s, int maxlen, FILE *f );1.118 +1.119 #ifdef __cplusplus1.120 }1.121 #endif
.