1 |
cebix |
1.1 |
/* |
2 |
cebix |
1.2 |
* mon.h - mon main program |
3 |
cebix |
1.1 |
* |
4 |
cebix |
1.4 |
* mon (C) 1997-2000 Christian Bauer, Marc Hellwig |
5 |
cebix |
1.2 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
cebix |
1.1 |
*/ |
20 |
|
|
|
21 |
cebix |
1.2 |
#ifndef MON_H |
22 |
|
|
#define MON_H |
23 |
cebix |
1.1 |
|
24 |
cebix |
1.3 |
#include <stdio.h> |
25 |
|
|
|
26 |
cebix |
1.1 |
|
27 |
cebix |
1.2 |
/* |
28 |
|
|
* Initialization, deinitialization and invocation |
29 |
|
|
*/ |
30 |
cebix |
1.1 |
|
31 |
|
|
void mon_init(void); |
32 |
|
|
void mon_exit(void); |
33 |
|
|
void mon(int argc, char **argv); |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/* |
37 |
|
|
* Definitions for adding commands to mon |
38 |
|
|
*/ |
39 |
|
|
|
40 |
|
|
// Maximum input length |
41 |
|
|
const int INPUT_LENGTH = 256; |
42 |
|
|
|
43 |
|
|
// Input tokens |
44 |
|
|
enum Token { |
45 |
|
|
T_NULL, // Invalid token |
46 |
|
|
T_END, // End of line |
47 |
|
|
T_NUMBER, // Hexadecimal/decimal number (uint32) |
48 |
|
|
T_STRING, // String enclosed in "" |
49 |
|
|
T_NAME, // Variable name |
50 |
|
|
T_DOT, // '.' |
51 |
|
|
T_COLON, // ':' |
52 |
|
|
T_COMMA, // ',' |
53 |
|
|
T_LPAREN, // '(' |
54 |
|
|
T_RPAREN, // ')' |
55 |
|
|
T_PLUS, // '+' |
56 |
|
|
T_MINUS, // '-' |
57 |
|
|
T_MUL, // '*' |
58 |
|
|
T_DIV, // '/' |
59 |
|
|
T_MOD, // '%' |
60 |
|
|
T_AND, // '&' |
61 |
|
|
T_OR, // '|' |
62 |
|
|
T_EOR, // '^' |
63 |
|
|
T_SHIFTL, // '<<' |
64 |
|
|
T_SHIFTR, // '>>' |
65 |
|
|
T_NOT, // '~' |
66 |
|
|
T_ASSIGN // '=' |
67 |
|
|
}; |
68 |
|
|
|
69 |
|
|
// Scanner variables |
70 |
|
|
extern enum Token mon_token; // Last token read |
71 |
|
|
extern uint32 mon_number; // Contains the number if mon_token==T_NUMBER |
72 |
|
|
extern char mon_string[INPUT_LENGTH]; // Contains the string if mon_token==T_STRING |
73 |
|
|
extern char mon_name[INPUT_LENGTH]; // Contains the variable name if mon_token==T_NAME |
74 |
|
|
|
75 |
|
|
// Streams for input, output and error messages |
76 |
|
|
extern FILE *monin, *monout, *monerr; |
77 |
|
|
|
78 |
|
|
// Current address, value of '.' in expressions |
79 |
|
|
extern uint32 mon_dot_address; |
80 |
|
|
|
81 |
|
|
extern bool mon_use_real_mem; // Flag: mon is using real memory |
82 |
|
|
extern uint32 mon_mem_size; // Size of mon buffer (if mon_use_real_mem = false) |
83 |
|
|
|
84 |
|
|
// Add command to mon |
85 |
|
|
extern void mon_add_command(const char *name, void (*func)(void), const char *help_text); |
86 |
|
|
|
87 |
|
|
// Functions for commands |
88 |
|
|
extern void mon_error(const char *s); // Print error message |
89 |
|
|
extern enum Token mon_get_token(void); // Get next token |
90 |
|
|
extern bool mon_expression(uint32 *number); // Parse expression |
91 |
|
|
extern bool mon_aborted(void); // Check if Ctrl-C was pressed |
92 |
cebix |
1.3 |
|
93 |
|
|
// Memory access |
94 |
|
|
extern uint32 (*mon_read_byte)(uint32 adr); |
95 |
|
|
extern void (*mon_write_byte)(uint32 adr, uint32 b); |
96 |
cebix |
1.1 |
extern uint32 mon_read_half(uint32 adr); |
97 |
|
|
extern void mon_write_half(uint32 adr, uint32 w); |
98 |
|
|
extern uint32 mon_read_word(uint32 adr); |
99 |
|
|
extern void mon_write_word(uint32 adr, uint32 l); |
100 |
|
|
|
101 |
|
|
#endif |