ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/kpx_cpu/include/basic-cpu.hpp
Revision: 1.2
Committed: 2006-01-28T22:00:10Z (18 years, 4 months ago) by gbeauche
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +14 -2 lines
Log Message:
Merge from KPX: new exit() handling code

File Contents

# Content
1 /*
2 * basic-cpu.hpp - Basic CPU definitions
3 *
4 * Kheperix (C) 2003 Gwenole Beauchesne
5 *
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 */
20
21 #ifndef BASIC_CPU_H
22 #define BASIC_CPU_H
23
24 #include "sysdeps.h"
25 #include <setjmp.h>
26 #include "task-plugin.hpp"
27
28 /**
29 * Generic register value
30 **/
31
32 union any_register
33 {
34 uint32 i;
35 uint64 j;
36 float f;
37 double d;
38
39 // Explicit casts may be required to use those constructors
40 any_register(uint32 v = 0) : i(v) { }
41 any_register(uint64 v) : j(v) { }
42 any_register(float v) : f(v) { }
43 any_register(double v) : d(v) { }
44 };
45
46 /**
47 * Basic CPU model
48 **/
49
50 struct task_struct;
51
52 struct basic_cpu
53 : public task_plugin
54 {
55 // Basic register set
56 struct registers
57 {
58 enum {
59 PC = -1, // Program Counter
60 SP = -2, // Stack Pointer
61 };
62 };
63
64 // Constructor & destructor
65 basic_cpu(task_struct * parent_task);
66 virtual ~basic_cpu();
67
68 // Execute code at current address
69 virtual void execute() = 0;
70
71 // Set VALUE to register ID
72 virtual void set_register(int id, any_register const & value) = 0;
73
74 // Get register ID
75 virtual any_register get_register(int id) = 0;
76
77 // Start emulation, returns exit status
78 int run();
79
80 // Stop emulation
81 void exit(int status);
82
83 private:
84 jmp_buf env;
85 int exit_status;
86 };
87
88 // Alias basic register set
89 typedef basic_cpu::registers basic_registers;
90
91 #endif /* BASIC_CPU_H */