2 * $Id: dream.h,v 1.9 2006-04-30 01:48:38 nkeynes Exp $
4 * Miscellaneous application-wide declarations (mainly logging atm)
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
26 #include <glib/gtypes.h>
32 /************************ Modules ********************************/
34 * Basic module structure defining the common operations across all
35 * modules, ie start, stop, reset, etc.
37 typedef struct dreamcast_module {
40 * Perform all initial module setup (ie register / allocate any
41 * memory required, etc). Only called once during DreamOn startup
45 * Reset the module into it's initial system boot state. Will be called
46 * once after init(), as well as whenever the user requests a reset.
50 * Set the module into a running state (may be NULL)
54 * Execute one time-slice worth of operations, for the given number of
56 * @return Number of nanoseconds actually executed
58 uint32_t (*run_time_slice)( uint32_t nanosecs );
60 * Set the module into a stopped state (may be NULL)
64 * Save the module state to the FILE stream. May be NULL, in which case
65 * the module is considered to have no state.
69 * Load the saved module state from the FILE stream. May be NULL, in which
70 * case reset() will be called instead.
71 * @return 0 on success, nonzero on failure.
74 } *dreamcast_module_t;
76 void dreamcast_register_module( dreamcast_module_t );
78 extern struct dreamcast_module mem_module;
79 extern struct dreamcast_module sh4_module;
80 extern struct dreamcast_module asic_module;
81 extern struct dreamcast_module pvr2_module;
82 extern struct dreamcast_module aica_module;
83 extern struct dreamcast_module ide_module;
84 extern struct dreamcast_module maple_module;
85 extern struct dreamcast_module pvr2_module;
86 extern struct dreamcast_module gui_module;
87 extern struct dreamcast_module unknown_module;
89 /*************************** Logging **************************/
99 #define MODULE unknown_module
102 void emit( void *, int level, const char *source, const char *msg, ... );
104 #define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )
105 #define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )
106 #define WARN( ... ) emit( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )
107 #define INFO( ... ) emit( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )
108 #define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )
109 #define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )
111 #define BIOS_PATH "../bios"
113 void fwrite_string( char *s, FILE *f );
114 int fread_string( char *s, int maxlen, FILE *f );
115 void fwrite_dump( unsigned char *buf, unsigned int length, FILE *f );
118 #define max(a,b) ( (a) > (b) ? (a) : (b) )
.