mvmeprom.cc Source File

Back to the index.

mvmeprom.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2009 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  * COMMENT: MVME PROM emulation
29  *
30  * For mvme88k emulation.
31  *
32  * TODO: Perhaps this could be reused for mvme68k emulation too?
33  */
34 
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <sys/types.h>
39 
40 #include "console.h"
41 #include "cpu.h"
42 #include "machine.h"
43 #include "memory.h"
44 #include "misc.h"
45 
46 #include "thirdparty/mvmeprom.h"
47 
48 
49 #define MVMEPROM_BRDID_ADDR 0x1100
50 
51 
52 /*
53  * mvmeprom_init():
54  */
56 {
57  struct cpu *cpu = machine->cpus[0];
59  uint32_t vbr = 0x00000000;
60  int model = 0x187;
61 
62  switch (machine->machine_subtype) {
63  case MACHINE_MVME88K_187: model = 0x187; break;
64  case MACHINE_MVME88K_188: model = 0x188; break;
65  case MACHINE_MVME88K_197: model = 0x197; break;
66  }
67 
68  cpu->cd.m88k.cr[M88K_CR_VBR] = vbr;
69 
70  /* A magic prom call instruction, followed by an 'rte': */
72  store_32bit_word(cpu, vbr + 8 * MVMEPROM_VECTOR + 4, 0xf400fc00);
73 
74  /* brdid struct: */
75  memset(&mvmeprom_brdid, 0, sizeof(mvmeprom_brdid));
76  store_16bit_word_in_host(cpu, (unsigned char *)
78  mvmeprom_brdid.speed[0] = '3'; /* 33 MHz, for now */
79  mvmeprom_brdid.speed[1] = '3';
80  mvmeprom_brdid.speed[2] = '0';
81  mvmeprom_brdid.speed[3] = '0';
83  (char *)&mvmeprom_brdid, sizeof(struct mvmeprom_brdid));
84 }
85 
86 
87 /*
88  * mvmeprom_emul():
89  *
90  * For MVME88K:
91  *
92  * Input:
93  * r9 = requested function number
94  * r2 = first argument (for functions that take arguments)
95  *
96  * Output:
97  * r2 = result
98  */
99 int mvmeprom_emul(struct cpu *cpu)
100 {
101  int func = cpu->cd.m88k.r[9];
102 
103  switch (func) {
104 
105  case MVMEPROM_OUTCHR:
107  cpu->cd.m88k.r[2]);
108  break;
109 
110  case MVMEPROM_OUTCRLF:
112  break;
113 
114  case MVMEPROM_EXIT:
115  fatal("[ MVME PROM: exit ]\n");
116  cpu->running = 0;
117  break;
118 
119  case MVMEPROM_GETBRDID:
120  /* Return a pointer in r2 to a mvmeprom_brdid struct. */
122  break;
123 
124  default:
125  cpu_register_dump(cpu->machine, cpu, 1, 0);
126  cpu_register_dump(cpu->machine, cpu, 0, 1);
127  fatal("[ MVME PROM emulation: unimplemented function 0x%"
128  PRIx32" ]\n", func);
129  cpu->running = 0;
130  return 0;
131  }
132 
133  return 1;
134 }
135 
cpu_register_dump
void cpu_register_dump(struct machine *m, struct cpu *cpu, int gprs, int coprocs)
Definition: cpu.cc:203
machine::machine_subtype
int machine_subtype
Definition: machine.h:112
MVMEPROM_OUTCHR
#define MVMEPROM_OUTCHR
Definition: mvmeprom.h:49
console_putchar
void console_putchar(int handle, int ch)
Definition: console.cc:405
cpu::running
uint8_t running
Definition: cpu.h:353
store_buf
void store_buf(struct cpu *cpu, uint64_t addr, const char *s, size_t len)
Definition: memory.cc:826
machine::cpus
struct cpu ** cpus
Definition: machine.h:140
mvmeprom_brdid::speed
uint8_t speed[4]
Definition: mvmeprom.h:131
mvmeprom_brdid
Definition: mvmeprom.h:109
console.h
MVMEPROM_OUTCRLF
#define MVMEPROM_OUTCRLF
Definition: mvmeprom.h:54
cpu::m88k
struct m88k_cpu m88k
Definition: cpu.h:442
MACHINE_MVME88K_187
#define MACHINE_MVME88K_187
Definition: machine.h:328
M88K_CR_VBR
#define M88K_CR_VBR
Definition: M88K_CPUComponent.h:189
fatal
void fatal(const char *fmt,...)
Definition: main.cc:152
MVMEPROM_GETBRDID
#define MVMEPROM_GETBRDID
Definition: mvmeprom.h:58
misc.h
MVMEPROM_BRDID_ADDR
#define MVMEPROM_BRDID_ADDR
Definition: mvmeprom.cc:49
cpu::cd
union cpu::@1 cd
machine.h
machine
Definition: machine.h:97
machine::main_console_handle
int main_console_handle
Definition: machine.h:128
MVMEPROM_VECTOR
#define MVMEPROM_VECTOR
Definition: mvmeprom.h:34
store_16bit_word_in_host
void store_16bit_word_in_host(struct cpu *cpu, unsigned char *data, uint16_t data16)
Definition: memory.cc:992
cpu.h
m88k_cpu::cr
uint32_t cr[N_M88K_CONTROL_REGS]
Definition: cpu_m88k.h:241
MACHINE_MVME88K_188
#define MACHINE_MVME88K_188
Definition: machine.h:329
MVMEPROM_EXIT
#define MVMEPROM_EXIT
Definition: mvmeprom.h:57
cpu::machine
struct machine * machine
Definition: cpu.h:328
mvmeprom.h
store_32bit_word
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
mvmeprom_brdid::model
uint16_t model
Definition: mvmeprom.h:117
mvmeprom_emul
int mvmeprom_emul(struct cpu *cpu)
Definition: mvmeprom.cc:99
m88k_cpu::r
uint32_t r[N_M88K_REGS+1]
Definition: cpu_m88k.h:235
mvmeprom_init
void mvmeprom_init(struct machine *machine)
Definition: mvmeprom.cc:55
cpu
Definition: cpu.h:326
memory.h
MACHINE_MVME88K_197
#define MACHINE_MVME88K_197
Definition: machine.h:330
M88K_PROM_INSTR
#define M88K_PROM_INSTR
Definition: M88K_CPUComponent.h:304

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17