/[gxemul]/upstream/0.3.5/src/yamon.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/0.3.5/src/yamon.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (show annotations)
Mon Oct 8 16:18:43 2007 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 3100 byte(s)
0.3.5
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: yamon.c,v 1.4 2005/08/09 22:24:47 debug Exp $
29 *
30 * YAMON 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 "cpu_mips.h"
41 #include "machine.h"
42 #include "memory.h"
43 #include "misc.h"
44
45
46 #ifdef ENABLE_MIPS
47
48 /*
49 * mem_readchar():
50 *
51 * Reads a byte from emulated RAM, using a MIPS register as a base address.
52 * (Helper function.)
53 */
54 static unsigned char mem_readchar(struct cpu *cpu, int regbase, int offset)
55 {
56 unsigned char ch;
57 cpu->memory_rw(cpu, cpu->mem, cpu->cd.mips.gpr[regbase] + offset,
58 &ch, sizeof(ch), MEM_READ, CACHE_DATA | NO_EXCEPTIONS);
59 return ch;
60 }
61
62
63 /*
64 * yamon_emul():
65 *
66 * YAMON emulation (for evbmips).
67 */
68 int yamon_emul(struct cpu *cpu)
69 {
70 int ofs = cpu->pc & 0xfff;
71 int n;
72
73 switch (ofs) {
74 case 0x804: /* "print count": string at a1, count at a2 */
75 n = 0;
76 while (n < cpu->cd.mips.gpr[MIPS_GPR_A2]) {
77 char ch = mem_readchar(cpu, MIPS_GPR_A1, n);
78 console_putchar(cpu->machine->main_console_handle,
79 ch);
80 n++;
81 }
82 break;
83 case 0x820: /* "exit" */
84 debug("[ yamon_emul(): exit ]\n");
85 cpu->running = 0;
86 break;
87 case 0x854: /* "syscon" */
88 fatal("[ yamon_emul(): syscon: TODO ]\n");
89 /* TODO. For now, return some kind of "failure": */
90 cpu->cd.mips.gpr[MIPS_GPR_V0] = 1;
91 break;
92 default:cpu_register_dump(cpu->machine, cpu, 1, 0);
93 printf("\n");
94 fatal("[ yamon_emul(): unimplemented ofs 0x%x ]\n", ofs);
95 cpu->running = 0;
96 cpu->dead = 1;
97 }
98
99 return 1;
100 }
101
102 #endif /* ENABLE_MIPS */

  ViewVC Help
Powered by ViewVC 1.1.26