fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
1/*****************************************************************************
2 * pce *
3 *****************************************************************************/
4
5/*****************************************************************************
6 * File name: src/arch/sim405/sim405.h *
7 * Created: 2004-06-01 by Hampa Hug <hampa@hampa.ch> *
8 * Copyright: (C) 2004-2018 Hampa Hug <hampa@hampa.ch> *
9 * Copyright: (C) 2004-2006 Lukas Ruf <ruf@lpr.ch> *
10 *****************************************************************************/
11
12/*****************************************************************************
13 * This program is free software. You can redistribute it and / or modify it *
14 * under the terms of the GNU General Public License version 2 as published *
15 * by the Free Software Foundation. *
16 * *
17 * This program is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY, without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
20 * Public License for more details. *
21 *****************************************************************************/
22
23/*****************************************************************************
24 * This software was developed at the Computer Engineering and Networks *
25 * Laboratory (TIK), Swiss Federal Institute of Technology (ETH) Zurich. *
26 *****************************************************************************/
27
28
29#ifndef PCE_SIM405_SIM405_H
30#define PCE_SIM405_SIM405_H 1
31
32
33#include <stdio.h>
34#include <string.h>
35#include <time.h>
36
37#ifdef HAVE_LIMITS_H
38#include <limits.h>
39#endif
40
41#include "pci.h"
42
43#include <chipset/clock/ds1743.h>
44#include <chipset/ppc405/uic.h>
45
46#include <cpu/ppc405/ppc405.h>
47
48#include <devices/device.h>
49#include <devices/ata.h>
50#include <devices/clock/ds1743.h>
51#include <devices/memory.h>
52#include <devices/nvram.h>
53#include <devices/pci.h>
54#include <devices/pci-ata.h>
55#include <devices/serport.h>
56#include <devices/slip.h>
57
58#include <lib/brkpt.h>
59#include <lib/log.h>
60#include <lib/inidsk.h>
61#include <lib/load.h>
62
63#include <libini/libini.h>
64
65
66#define PCE_BRK_STOP 1
67#define PCE_BRK_ABORT 2
68#define PCE_BRK_SNAP 3
69
70
71struct sim405_t;
72
73
74void pce_dump_hex (FILE *fp, void *buf, unsigned long n,
75 unsigned long addr, unsigned cols, char *prefix, int ascii
76);
77
78
79#define SIM405_DCRN_OCM0_ISARC 0x18
80#define SIM405_DCRN_OCM0_ISCNTL 0x19
81#define SIM405_DCRN_OCM0_DSARC 0x1a
82#define SIM405_DCRN_OCM0_DSCNTL 0x1b
83
84#define SIM405_DCRN_CPC0_CR0 0xb1
85#define SIM405_DCRN_CPC0_CR1 0xb2
86#define SIM405_DCRN_CPC0_PSR 0xb4
87#define SIM405_DCRN_CPC0_PSR_PAE 0x00000400UL
88
89#define SIM405_DCRN_UIC0_SR 0xc0
90#define SIM405_DCRN_UIC0_ER 0xc2
91#define SIM405_DCRN_UIC0_CR 0xc3
92#define SIM405_DCRN_UIC0_PR 0xc4
93#define SIM405_DCRN_UIC0_TR 0xc5
94#define SIM405_DCRN_UIC0_MSR 0xc6
95#define SIM405_DCRN_UIC0_VR 0xc7
96#define SIM405_DCRN_UIC0_VCR 0xc8
97
98#define SIM405_DCRN_MAL0_CFG 0x180
99#define SIM405_DCRN_MAL0_ESR 0x181
100
101
102/*****************************************************************************
103 * @short The sim405 context struct
104 *****************************************************************************/
105typedef struct sim405_s {
106 p405_t *ppc;
107 p405_uic_t uic;
108
109 memory_t *mem;
110 mem_blk_t *ram;
111
112 dev_list_t devlst;
113
114 disks_t *dsks;
115
116 pci_405_t *pci;
117 pci_ata_t pciata;
118
119 serport_t *serport[2];
120 unsigned sercons;
121
122 slip_t *slip;
123
124 bp_set_t bps;
125
126 /* OCM DCRs */
127 uint32_t ocm0_iscntl;
128 uint32_t ocm0_isarc;
129 uint32_t ocm0_dscntl;
130 uint32_t ocm0_dsarc;
131
132 uint32_t cpc0_cr0;
133 uint32_t cpc0_cr1;
134 uint32_t cpc0_psr;
135
136 unsigned long long clk_cnt;
137 unsigned long clk_div[4];
138
139 clock_t real_clk;
140
141 char sync_time_base;
142
143 unsigned long sync_clock_sim;
144 unsigned long sync_clock_real;
145 unsigned long sync_interval;
146
147 unsigned long serial_clock;
148 unsigned long serial_clock_count;
149
150 unsigned hook_idx;
151 unsigned hook_cnt;
152 unsigned char hook_buf[256];
153
154 FILE *hook_read;
155 FILE *hook_write;
156
157 unsigned brk;
158} sim405_t;
159
160
161extern sim405_t *par_sim;
162
163
164/*****************************************************************************
165 * @short Create a new sim405 context
166 * @param ini A libini sim405 section. Can be NULL.
167 *****************************************************************************/
168sim405_t *s405_new (ini_sct_t *ini);
169
170/*****************************************************************************
171 * @short Delete a sim405 context
172 *****************************************************************************/
173void s405_del (sim405_t *sim);
174
175/*****************************************************************************
176 * @short Get the number of clock cycles
177 * @return The number of clock cycles the SIM405GS3 went through since the last
178 * initialization
179 *****************************************************************************/
180unsigned long long s405_get_clkcnt (sim405_t *sim);
181
182/*****************************************************************************
183 * @short Reset the simulator
184 *****************************************************************************/
185void s405_reset (sim405_t *sim);
186
187void s405_clock_discontinuity (sim405_t *sim);
188
189/*****************************************************************************
190 * @short Clock the simulator
191 * @param n The number of clock cycles. Must not be 0.
192 *****************************************************************************/
193void s405_clock (sim405_t *sim, unsigned n);
194
195/*****************************************************************************
196 * @short Interrupt the emulator
197 * @param val The type of break (see PCE_BRK_* constants)
198 *
199 * This is a hack
200 *****************************************************************************/
201void s405_break (sim405_t *sim, unsigned char val);
202
203/*****************************************************************************
204 * Don't use.
205 *****************************************************************************/
206void s405_set_keycode (sim405_t *sim, unsigned char val);
207
208
209#endif