aboutsummaryrefslogtreecommitdiff
path: root/sim/example-synacor/sim-main.h
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2020-12-09 22:26:30 -0500
committerMike Frysinger <vapier@gentoo.org>2021-04-03 16:19:16 -0400
commit26da232cbd6dd920da9521e508e42d1a46180ab4 (patch)
tree76451bdc21196c61c8c36787c74239660437b777 /sim/example-synacor/sim-main.h
parenta389375f5b5fb67acdda6be028526ac44df2fbff (diff)
downloadfsf-binutils-gdb-26da232cbd6dd920da9521e508e42d1a46180ab4.zip
fsf-binutils-gdb-26da232cbd6dd920da9521e508e42d1a46180ab4.tar.gz
fsf-binutils-gdb-26da232cbd6dd920da9521e508e42d1a46180ab4.tar.bz2
sim: example-synacor: a simple implementation for reference
Provide a simple example simulator for people porting to new targets to use as a reference. This one has the advantage of being used by people and having a fun program available for it. It doesn't require a special target -- the example simulators can be built for any existing port.
Diffstat (limited to 'sim/example-synacor/sim-main.h')
-rw-r--r--sim/example-synacor/sim-main.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/sim/example-synacor/sim-main.h b/sim/example-synacor/sim-main.h
new file mode 100644
index 0000000..ba0e4ef
--- /dev/null
+++ b/sim/example-synacor/sim-main.h
@@ -0,0 +1,49 @@
+/* Example synacor simulator.
+
+ Copyright (C) 2005-2021 Free Software Foundation, Inc.
+ Contributed by Mike Frysinger.
+
+ This file is part of simulators.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef SIM_MAIN_H
+#define SIM_MAIN_H
+
+#include "sim-basics.h"
+#include "sim-base.h"
+
+struct _sim_cpu {
+ /* ... simulator specific members ... */
+ unsigned16 regs[8];
+ sim_cia pc;
+
+ /* This isn't a real register, and the stack is not directly addressable,
+ so use memory outside of the 16-bit address space. */
+ unsigned32 sp;
+
+ sim_cpu_base base;
+};
+
+struct sim_state {
+ sim_cpu *cpu[MAX_NR_PROCESSORS];
+
+ /* ... simulator specific members ... */
+ sim_state_base base;
+};
+
+extern void step_once (SIM_CPU *);
+extern void initialize_cpu (SIM_DESC, SIM_CPU *);
+
+#endif