1 |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
3 |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
6 |
* |
7 |
* 1. Redistributions of source code must retain the above copyright |
8 |
* notice, this list of conditions and the following disclaimer. |
9 |
* 2. Redistributions in binary form must reproduce the above copyright |
10 |
* notice, this list of conditions and the following disclaimer in the |
11 |
* documentation and/or other materials provided with the distribution. |
12 |
* 3. The name of the author may not be used to endorse or promote products |
13 |
* derived from this software without specific prior written permission. |
14 |
* |
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
16 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
21 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
23 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
24 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
25 |
* SUCH DAMAGE. |
26 |
* |
27 |
* |
28 |
* $Id: cpu_alpha.c,v 1.4 2005/06/01 22:09:40 debug Exp $ |
29 |
* |
30 |
* Alpha CPU emulation. |
31 |
* |
32 |
* TODO: This is just a dummy so far. |
33 |
*/ |
34 |
|
35 |
#include <stdio.h> |
36 |
#include <stdlib.h> |
37 |
#include <string.h> |
38 |
#include <ctype.h> |
39 |
|
40 |
#include "misc.h" |
41 |
|
42 |
|
43 |
#ifndef ENABLE_ALPHA |
44 |
|
45 |
|
46 |
#include "cpu_alpha.h" |
47 |
|
48 |
|
49 |
/* |
50 |
* alpha_cpu_family_init(): |
51 |
* |
52 |
* Bogus, when ENABLE_ALPHA isn't defined. |
53 |
*/ |
54 |
int alpha_cpu_family_init(struct cpu_family *fp) |
55 |
{ |
56 |
return 0; |
57 |
} |
58 |
|
59 |
|
60 |
#else /* ENABLE_ALPHA */ |
61 |
|
62 |
|
63 |
#include "cpu.h" |
64 |
#include "cpu_alpha.h" |
65 |
#include "machine.h" |
66 |
#include "memory.h" |
67 |
#include "symbol.h" |
68 |
|
69 |
|
70 |
extern volatile int single_step; |
71 |
extern int old_show_trace_tree; |
72 |
extern int old_instruction_trace; |
73 |
extern int old_quiet_mode; |
74 |
extern int quiet_mode; |
75 |
|
76 |
|
77 |
/* |
78 |
* alpha_cpu_new(): |
79 |
* |
80 |
* Create a new Alpha cpu object. |
81 |
*/ |
82 |
struct cpu *alpha_cpu_new(struct memory *mem, struct machine *machine, |
83 |
int cpu_id, char *cpu_type_name) |
84 |
{ |
85 |
struct cpu *cpu; |
86 |
|
87 |
if (cpu_type_name == NULL || ( |
88 |
strcasecmp(cpu_type_name, "ev4") != 0 && |
89 |
strcasecmp(cpu_type_name, "ev5") != 0 && |
90 |
strcasecmp(cpu_type_name, "ev6") != 0 && |
91 |
strcasecmp(cpu_type_name, "ev7") != 0 && |
92 |
strcasecmp(cpu_type_name, "pca56") != 0) ) |
93 |
return NULL; |
94 |
|
95 |
cpu = malloc(sizeof(struct cpu)); |
96 |
if (cpu == NULL) { |
97 |
fprintf(stderr, "out of memory\n"); |
98 |
exit(1); |
99 |
} |
100 |
|
101 |
memset(cpu, 0, sizeof(struct cpu)); |
102 |
cpu->memory_rw = alpha_memory_rw; |
103 |
cpu->name = cpu_type_name; |
104 |
cpu->mem = mem; |
105 |
cpu->machine = machine; |
106 |
cpu->cpu_id = cpu_id; |
107 |
cpu->byte_order = EMUL_BIG_ENDIAN; |
108 |
cpu->bootstrap_cpu_flag = 0; |
109 |
cpu->running = 0; |
110 |
|
111 |
/* Only show name and caches etc for CPU nr 0 (in SMP machines): */ |
112 |
if (cpu_id == 0) { |
113 |
debug("%s", cpu->name); |
114 |
} |
115 |
|
116 |
return cpu; |
117 |
} |
118 |
|
119 |
|
120 |
/* |
121 |
* alpha_cpu_dumpinfo(): |
122 |
*/ |
123 |
void alpha_cpu_dumpinfo(struct cpu *cpu) |
124 |
{ |
125 |
debug("\n"); |
126 |
|
127 |
/* TODO */ |
128 |
} |
129 |
|
130 |
|
131 |
/* |
132 |
* alpha_cpu_list_available_types(): |
133 |
* |
134 |
* Print a list of available Alpha CPU types. |
135 |
*/ |
136 |
void alpha_cpu_list_available_types(void) |
137 |
{ |
138 |
/* TODO */ |
139 |
|
140 |
debug("EV4 EV5 EV6 EV7 PCA56\n"); |
141 |
} |
142 |
|
143 |
|
144 |
/* |
145 |
* alpha_cpu_register_match(): |
146 |
*/ |
147 |
void alpha_cpu_register_match(struct machine *m, char *name, |
148 |
int writeflag, uint64_t *valuep, int *match_register) |
149 |
{ |
150 |
int cpunr = 0; |
151 |
|
152 |
/* CPU number: */ |
153 |
|
154 |
/* TODO */ |
155 |
|
156 |
/* Register name: */ |
157 |
if (strcasecmp(name, "pc") == 0) { |
158 |
if (writeflag) { |
159 |
m->cpus[cpunr]->pc = *valuep; |
160 |
} else |
161 |
*valuep = m->cpus[cpunr]->pc; |
162 |
*match_register = 1; |
163 |
} |
164 |
|
165 |
/* TODO: _LOTS_ of stuff. */ |
166 |
} |
167 |
|
168 |
|
169 |
#define MEMORY_RW alpha_memory_rw |
170 |
#define MEM_ALPHA |
171 |
#include "memory_rw.c" |
172 |
#undef MEM_ALPHA |
173 |
#undef MEMORY_RW |
174 |
|
175 |
|
176 |
/* |
177 |
* alpha_cpu_family_init(): |
178 |
* |
179 |
* Fill in the cpu_family struct for Alpha. |
180 |
*/ |
181 |
int alpha_cpu_family_init(struct cpu_family *fp) |
182 |
{ |
183 |
fp->name = "Alpha"; |
184 |
fp->cpu_new = alpha_cpu_new; |
185 |
fp->list_available_types = alpha_cpu_list_available_types; |
186 |
fp->register_match = alpha_cpu_register_match; |
187 |
/* fp->disassemble_instr = alpha_cpu_disassemble_instr; */ |
188 |
/* fp->register_dump = alpha_cpu_register_dump; */ |
189 |
/* fp->run = alpha_cpu_run; */ |
190 |
fp->dumpinfo = alpha_cpu_dumpinfo; |
191 |
/* fp->show_full_statistics = alpha_cpu_show_full_statistics; */ |
192 |
/* fp->tlbdump = alpha_cpu_tlbdump; */ |
193 |
/* fp->interrupt = alpha_cpu_interrupt; */ |
194 |
/* fp->interrupt_ack = alpha_cpu_interrupt_ack; */ |
195 |
return 1; |
196 |
} |
197 |
|
198 |
#endif /* ENABLE_ALPHA */ |