ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/kpx_cpu/include/basic-cpu.hpp
Revision: 1.1
Committed: 2003-09-07T14:25:03Z (21 years, 2 months ago) by gbeauche
Branch: MAIN
Log Message:
Merge in old kpx_cpu snapshot for debugging

File Contents

# User Rev Content
1 gbeauche 1.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 "task-plugin.hpp"
26    
27     /**
28     * Generic register value
29     **/
30    
31     union any_register
32     {
33     uint32 i;
34     uint64 j;
35     float f;
36     double d;
37    
38     // Explicit casts may be required to use those constructors
39     any_register(uint32 v = 0) : i(v) { }
40     any_register(uint64 v) : j(v) { }
41     any_register(float v) : f(v) { }
42     any_register(double v) : d(v) { }
43     };
44    
45     /**
46     * Basic CPU model
47     **/
48    
49     struct task_struct;
50    
51     struct basic_cpu
52     : public task_plugin
53     {
54     // Basic register set
55     struct registers
56     {
57     enum {
58     PC = -1, // Program Counter
59     SP = -2, // Stack Pointer
60     };
61     };
62    
63     // Constructor & destructor
64     basic_cpu(task_struct * parent_task) : task_plugin(parent_task) { }
65    
66     // Start emulation loop
67     virtual void execute() = 0;
68    
69     // Set VALUE to register ID
70     virtual void set_register(int id, any_register const & value) = 0;
71    
72     // Get register ID
73     virtual any_register get_register(int id) = 0;
74     };
75    
76     // Alias basic register set
77     typedef basic_cpu::registers basic_registers;
78    
79     #endif /* BASIC_CPU_H */