Search
lxdream.org :: lxdream/src/dream.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/dream.h
changeset 35:21a4be098304
prev31:495e480360d7
next119:cef4d880123c
author nkeynes
date Mon Dec 26 03:54:55 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Remove modules.h - move definitions into dream.h
Add source string to output list (taken from module name)
ARM Work in progress
file annotate diff log raw
1.1 --- a/src/dream.h Sun Dec 25 08:24:11 2005 +0000
1.2 +++ b/src/dream.h Mon Dec 26 03:54:55 2005 +0000
1.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_H
1.12 #define dream_H 1
1.13
1.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.19
1.20 #ifdef __cplusplus
1.21 extern "C" {
1.22 -#if 0
1.23 -}
1.24 #endif
1.25 -#endif
1.26 +
1.27 +/************************ Modules ********************************/
1.28 +/**
1.29 + * Basic module structure defining the common operations across all
1.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 any
1.36 + * memory required, etc). Only called once during DreamOn startup
1.37 + */
1.38 + void (*init)();
1.39 + /**
1.40 + * Reset the module into it's initial system boot state. Will be called
1.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 of
1.50 + * nanoseconds.
1.51 + * @return Number of nanoseconds actually executed
1.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 case
1.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 which
1.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.85
1.86 #define EMIT_FATAL 0
1.87 #define EMIT_ERR 1
1.88 @@ -38,21 +95,24 @@
1.89 #define EMIT_DEBUG 4
1.90 #define EMIT_TRACE 5
1.91
1.92 -#ifndef MODULE_ID
1.93 -#define MODULE_ID 0
1.94 +#ifndef MODULE
1.95 +#define MODULE unknown_module
1.96 #endif
1.97
1.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.100
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.113
1.114 #define BIOS_PATH "../bios"
1.115
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 __cplusplus
1.120 }
1.121 #endif
.