luna88kprom.cc Source File

Back to the index.

luna88kprom.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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: LUNA 88K PROM emulation
29  *
30  * For LUNA 88K emulation.
31  */
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <sys/types.h>
37 
38 #include "console.h"
39 #include "cpu.h"
40 #include "machine.h"
41 #include "memory.h"
42 #include "misc.h"
43 
45 
46 
47 /*
48  * luna88kprom_init():
49  */
51 {
52  struct cpu *cpu = machine->cpus[0];
53 
54  /*
55  * Memory layout according to OpenBSD's locore0.S:
56  *
57  * 0x00000 - 0x00fff = trap vectors
58  * 0x01000 - 0x1ffff = ROM monitor work area
59  * 0x20000 - ... = Boot loader jumps here
60  *
61  * The boot loader stage before loading OpenBSD's kernel seems
62  * to be loaded at 0x00700000.
63  */
64 
65  /* 0x00001100: ROM function table. See OpenBSD's machdep.c */
66  store_32bit_word(cpu, 0x1100 + sizeof(uint32_t) * 3, 0x2030); /* ROM console getch */
67  store_32bit_word(cpu, 0x1100 + sizeof(uint32_t) * 4, 0x2040); /* ROM console putch */
68 
69  store_32bit_word(cpu, 0x2030, M88K_PROM_INSTR);
70  store_32bit_word(cpu, 0x2034, 0xf400c001); /* jmp (r1) */
71 
72  store_32bit_word(cpu, 0x2040, M88K_PROM_INSTR);
73  store_32bit_word(cpu, 0x2044, 0xf400c001); /* jmp (r1) */
74 
75  /* 0x00001114: Framebuffer depth */
76  store_32bit_word(cpu, 0x1114, machine->x11_md.in_use ? 8 : 0);
77 }
78 
79 
80 /*
81  * luna88kprom_emul():
82  *
83  * Input:
84  * pc is used to figure out function number
85  * r2 = first argument (for functions that take arguments)
86  *
87  * Output:
88  * r2 = result
89  */
90 int luna88kprom_emul(struct cpu *cpu)
91 {
92  int func = (cpu->pc & 0xf0) >> 4;
93 
94  switch (func) {
95 
96  case 4:
98  break;
99 
100  default:
101  cpu_register_dump(cpu->machine, cpu, 1, 0);
102  cpu_register_dump(cpu->machine, cpu, 0, 1);
103  fatal("[ LUNA88K PROM emulation: unimplemented function 0x%" PRIx32" ]\n", func);
104  cpu->running = 0;
105  return 0;
106  }
107 
108  return 1;
109 }
110 
void fatal(const char *fmt,...)
Definition: main.cc:152
int main_console_handle
Definition: machine.h:128
int store_32bit_word(struct cpu *cpu, uint64_t addr, uint64_t data32)
Definition: memory.cc:783
union cpu::@1 cd
struct machine * machine
Definition: cpu.h:328
void luna88kprom_init(struct machine *machine)
Definition: luna88kprom.cc:50
uint32_t r[N_M88K_REGS+1]
Definition: cpu_m88k.h:235
void console_putchar(int handle, int ch)
Definition: console.cc:405
struct cpu ** cpus
Definition: machine.h:140
#define M88K_PROM_INSTR
uint64_t pc
Definition: cpu.h:383
uint8_t running
Definition: cpu.h:353
void cpu_register_dump(struct machine *m, struct cpu *cpu, int gprs, int coprocs)
Definition: cpu.cc:203
struct x11_md x11_md
Definition: machine.h:179
Definition: cpu.h:326
int in_use
Definition: machine.h:82
struct m88k_cpu m88k
Definition: cpu.h:442
int luna88kprom_emul(struct cpu *cpu)
Definition: luna88kprom.cc:90

Generated on Sun Sep 30 2018 16:05:18 for GXemul by doxygen 1.8.13