filename | src/modules.h |
changeset | 30:89b30313d757 |
prev | 27:1ef09a52cd1e |
author | nkeynes |
date | Sun Dec 25 05:57:00 2005 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Change timeslice to nanoseconds (was microseconds) Generize single step (now steps through active CPU) Add lots of header blocks |
view | annotate | diff | log | raw |
1 /**
2 * $Id: modules.h,v 1.5 2005-12-25 05:56:55 nkeynes Exp $
3 *
4 * Internal dreamcast module structure definition and associated variables.
5 * Included by all module implementations
6 *
7 * Copyright (c) 2005 Nathan Keynes.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
20 #ifndef dreamcast_modules_H
21 #define dreamcast_modules_H 1
23 #include <stdint.h>
24 #include <stdlib.h>
25 #include <stdio.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
31 /**
32 * Basic module structure defining the common operations across all
33 * modules, ie start, stop, reset, etc. Nothing here is time-sensitive.
34 */
35 typedef struct dreamcast_module {
36 char *name;
37 /**
38 * Perform all initial module setup (ie register / allocate any
39 * memory required, etc). Only called once during DreamOn startup
40 */
41 void (*init)();
42 /**
43 * Reset the module into it's initial system boot state. Will be called
44 * once after init(), as well as whenever the user requests a reset.
45 */
46 void (*reset)();
47 /**
48 * Set the module into a running state (may be NULL)
49 */
50 void (*start)();
51 /**
52 * Execute one time-slice worth of operations, for the given number of
53 * nanoseconds.
54 * @return Number of nanoseconds actually executed
55 */
56 uint32_t (*run_time_slice)( uint32_t nanosecs );
57 /**
58 * Set the module into a stopped state (may be NULL)
59 */
60 void (*stop)();
61 /**
62 * Save the module state to the FILE stream. May be NULL, in which case
63 * the module is considered to have no state.
64 */
65 void (*save)(FILE *);
66 /**
67 * Load the saved module state from the FILE stream. May be NULL, in which
68 * case reset() will be called instead.
69 * @return 0 on success, nonzero on failure.
70 */
71 int (*load)(FILE *);
72 } *dreamcast_module_t;
74 void dreamcast_register_module( dreamcast_module_t );
76 extern struct dreamcast_module mem_module;
77 extern struct dreamcast_module sh4_module;
78 extern struct dreamcast_module asic_module;
79 extern struct dreamcast_module pvr2_module;
80 extern struct dreamcast_module aica_module;
81 extern struct dreamcast_module ide_module;
82 extern struct dreamcast_module maple_module;
83 extern struct dreamcast_module pvr2_module;
84 extern struct dreamcast_module gui_module;
86 void fwrite_string( char *s, FILE *f );
87 int fread_string( char *s, int maxlen, FILE *f );
89 #ifdef __cplusplus
90 }
91 #endif
93 #endif /* !dreamcast_modules_H */
.