1 |
#ifndef CPU_RCA180X_H |
2 |
#define CPU_RCA180X_H |
3 |
|
4 |
/* |
5 |
* Copyright (C) 2006-2007 Anders Gavare. All rights reserved. |
6 |
* |
7 |
* Redistribution and use in source and binary forms, with or without |
8 |
* modification, are permitted provided that the following conditions are met: |
9 |
* |
10 |
* 1. Redistributions of source code must retain the above copyright |
11 |
* notice, this list of conditions and the following disclaimer. |
12 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
* notice, this list of conditions and the following disclaimer in the |
14 |
* documentation and/or other materials provided with the distribution. |
15 |
* 3. The name of the author may not be used to endorse or promote products |
16 |
* derived from this software without specific prior written permission. |
17 |
* |
18 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
19 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
22 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 |
* SUCH DAMAGE. |
29 |
* |
30 |
* |
31 |
* $Id: cpu_rca180x.h,v 1.3 2006/12/30 13:31:00 debug Exp $ |
32 |
*/ |
33 |
|
34 |
#include "misc.h" |
35 |
|
36 |
|
37 |
struct cpu_family; |
38 |
|
39 |
#define N_RCA180X_REGS 16 |
40 |
|
41 |
#define RCA180X_N_IC_ARGS 3 |
42 |
#define RCA180X_INSTR_ALIGNMENT_SHIFT 0 |
43 |
#define RCA180X_IC_ENTRIES_SHIFT 7 |
44 |
#define RCA180X_IC_ENTRIES_PER_PAGE (1 << RCA180X_IC_ENTRIES_SHIFT) |
45 |
#define RCA180X_PC_TO_IC_ENTRY(a) (((a)>>RCA180X_INSTR_ALIGNMENT_SHIFT) \ |
46 |
& (RCA180X_IC_ENTRIES_PER_PAGE-1)) |
47 |
#define RCA180X_ADDR_TO_PAGENR(a) ((a) >> (RCA180X_IC_ENTRIES_SHIFT \ |
48 |
+ RCA180X_INSTR_ALIGNMENT_SHIFT)) |
49 |
|
50 |
DYNTRANS_MISC_DECLARATIONS(rca180x,RCA180X,uint64_t) |
51 |
|
52 |
#define RCA180X_MAX_VPH_TLB_ENTRIES 64 |
53 |
|
54 |
|
55 |
/* CHIP8 stuff: */ |
56 |
#define N_CHIP8_REGS 16 |
57 |
#define CHIP8_FB_ADDR 0x10000000 |
58 |
|
59 |
/* Default font address: */ |
60 |
#define CHIP8_FONT_ADDR 8110 |
61 |
|
62 |
|
63 |
struct rca180x_cpu { |
64 |
uint16_t r[N_RCA180X_REGS]; /* GPRs */ |
65 |
uint8_t d; /* Data register */ |
66 |
|
67 |
int8_t df; /* Data flag (1 bit) */ |
68 |
int8_t ie; /* Interrupt enable (1 bit) */ |
69 |
int8_t q; /* Output bit (1 bit) */ |
70 |
int8_t p; /* PC select (4 bits) */ |
71 |
int8_t x; /* Data pointer select (4 bits) */ |
72 |
int8_t t_x; /* X during interrupt */ |
73 |
int8_t t_p; /* P during interrupt */ |
74 |
|
75 |
/*********************** CHIP8 EMULATION **************************/ |
76 |
|
77 |
int8_t chip8_mode; |
78 |
|
79 |
/* |
80 |
* General Purpose Registers, and the Index register: |
81 |
*/ |
82 |
uint8_t v[N_CHIP8_REGS]; |
83 |
uint16_t index; /* only 12 bits used */ |
84 |
|
85 |
/* Stack pointer (not user accessible): */ |
86 |
uint16_t sp; |
87 |
|
88 |
/* 64x32 framebuffer (or 128x64 for SCHIP48) */ |
89 |
int xres, yres; |
90 |
uint8_t *framebuffer_cache; |
91 |
|
92 |
/* 54.6 Hz (or new mode 60 Hz) timer */ |
93 |
struct timer *timer; |
94 |
int timer_mode_new; |
95 |
int delay_timer_value; |
96 |
int sound_timer_value; |
97 |
|
98 |
|
99 |
/* |
100 |
* Instruction translation cache: |
101 |
*/ |
102 |
DYNTRANS_ITC(rca180x) |
103 |
|
104 |
/* |
105 |
* 32-bit virtual -> physical -> host address translation: |
106 |
* |
107 |
* (All 32 bits are not really needed on RCA180Xs.) |
108 |
*/ |
109 |
VPH_TLBS(rca180x,RCA180X) |
110 |
VPH32(rca180x,RCA180X,uint32_t,uint8_t) |
111 |
}; |
112 |
|
113 |
|
114 |
/* cpu_rca180x.c: */ |
115 |
int rca180x_run_instr(struct cpu *cpu); |
116 |
void rca180x_update_translation_table(struct cpu *cpu, uint64_t vaddr_page, |
117 |
unsigned char *host_page, int writeflag, uint64_t paddr_page); |
118 |
void rca180x_invalidate_translation_caches(struct cpu *cpu, uint64_t, int); |
119 |
void rca180x_invalidate_code_translation(struct cpu *cpu, uint64_t, int); |
120 |
int rca180x_memory_rw(struct cpu *cpu, struct memory *mem, uint64_t vaddr, |
121 |
unsigned char *data, size_t len, int writeflag, int cache_flags); |
122 |
int rca180x_cpu_family_init(struct cpu_family *); |
123 |
|
124 |
|
125 |
#endif /* CPU_RCA180X_H */ |