ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/basilisk_glue.cpp
Revision: 1.9
Committed: 2001-03-20T17:35:45Z (23 years, 8 months ago) by gbeauche
Branch: MAIN
CVS Tags: snapshot-29052001, release-0_9-1
Changes since 1.8: +0 -4 lines
Log Message:
- removed old JIT compiler, its related support functions and files
  (compiler.{h,cpp})

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * basilisk_glue.cpp - Glue UAE CPU to Basilisk II CPU engine interface
3     *
4 cebix 1.8 * Basilisk II (C) 1997-2001 Christian Bauer
5 cebix 1.1 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include "sysdeps.h"
22 cebix 1.4
23 cebix 1.1 #include "cpu_emulation.h"
24     #include "main.h"
25     #include "emul_op.h"
26     #include "rom_patches.h"
27     #include "m68k.h"
28     #include "memory.h"
29     #include "readcpu.h"
30     #include "newcpu.h"
31    
32    
33     // RAM and ROM pointers
34 gbeauche 1.7 uint32 RAMBaseMac = 0; // RAM base (Mac address space) gb-- init is important
35 cebix 1.1 uint8 *RAMBaseHost; // RAM base (host address space)
36     uint32 RAMSize; // Size of RAM
37     uint32 ROMBaseMac; // ROM base (Mac address space)
38     uint8 *ROMBaseHost; // ROM base (host address space)
39     uint32 ROMSize; // Size of ROM
40    
41     #if !REAL_ADDRESSING
42     // Mac frame buffer
43     uint8 *MacFrameBaseHost; // Frame buffer base (host address space)
44     uint32 MacFrameSize; // Size of frame buffer
45     int MacFrameLayout; // Frame buffer layout
46     #endif
47    
48 gbeauche 1.7 #if DIRECT_ADDRESSING
49     uintptr MEMBaseDiff; // Global offset between a Mac address and its Host equivalent
50     #endif
51    
52 cebix 1.1 // From newcpu.cpp
53     extern int quit_program;
54    
55    
56     /*
57     * Initialize 680x0 emulation, CheckROM() must have been called first
58     */
59    
60     bool Init680x0(void)
61     {
62     #if REAL_ADDRESSING
63     // Mac address space = host address space
64     RAMBaseMac = (uint32)RAMBaseHost;
65     ROMBaseMac = (uint32)ROMBaseHost;
66 gbeauche 1.7 #elif DIRECT_ADDRESSING
67     InitMEMBaseDiff(RAMBaseHost, RAMBaseMac);
68 cebix 1.1 #else
69     // Initialize UAE memory banks
70     RAMBaseMac = 0;
71     switch (ROMVersion) {
72     case ROM_VERSION_64K:
73     case ROM_VERSION_PLUS:
74     case ROM_VERSION_CLASSIC:
75     ROMBaseMac = 0x00400000;
76     break;
77     case ROM_VERSION_II:
78     ROMBaseMac = 0x00a00000;
79     break;
80     case ROM_VERSION_32:
81     ROMBaseMac = 0x40800000;
82     break;
83     default:
84     return false;
85     }
86     memory_init();
87     #endif
88    
89     init_m68k();
90     return true;
91     }
92    
93    
94     /*
95     * Deinitialize 680x0 emulation
96     */
97    
98     void Exit680x0(void)
99     {
100 gbeauche 1.6 exit_m68k();
101 cebix 1.1 }
102    
103    
104     /*
105     * Reset and start 680x0 emulation (doesn't return)
106     */
107    
108     void Start680x0(void)
109     {
110     m68k_reset();
111     m68k_go(true);
112     }
113    
114    
115     /*
116     * Trigger interrupt
117     */
118    
119     void TriggerInterrupt(void)
120     {
121     regs.spcflags |= SPCFLAG_INT;
122     }
123    
124 cebix 1.5 void TriggerNMI(void)
125     {
126     //!! not implemented yet
127     }
128    
129 cebix 1.1
130     /*
131     * Get 68k interrupt level
132     */
133    
134     int intlev(void)
135     {
136     return InterruptFlags ? 1 : 0;
137     }
138    
139    
140     /*
141     * Execute MacOS 68k trap
142     * r->a[7] and r->sr are unused!
143     */
144    
145     void Execute68kTrap(uint16 trap, struct M68kRegisters *r)
146     {
147     int i;
148    
149     // Save old PC
150     uaecptr oldpc = m68k_getpc();
151    
152     // Set registers
153     for (i=0; i<8; i++)
154     m68k_dreg(regs, i) = r->d[i];
155     for (i=0; i<7; i++)
156     m68k_areg(regs, i) = r->a[i];
157    
158     // Push trap and EXEC_RETURN on stack
159     m68k_areg(regs, 7) -= 2;
160     put_word(m68k_areg(regs, 7), M68K_EXEC_RETURN);
161     m68k_areg(regs, 7) -= 2;
162     put_word(m68k_areg(regs, 7), trap);
163    
164     // Execute trap
165     m68k_setpc(m68k_areg(regs, 7));
166     fill_prefetch_0();
167     quit_program = 0;
168     m68k_go(true);
169    
170     // Clean up stack
171     m68k_areg(regs, 7) += 4;
172    
173     // Restore old PC
174     m68k_setpc(oldpc);
175     fill_prefetch_0();
176    
177     // Get registers
178     for (i=0; i<8; i++)
179     r->d[i] = m68k_dreg(regs, i);
180     for (i=0; i<7; i++)
181     r->a[i] = m68k_areg(regs, i);
182     quit_program = 0;
183     }
184    
185    
186     /*
187     * Execute 68k subroutine
188     * The executed routine must reside in UAE memory!
189     * r->a[7] and r->sr are unused!
190     */
191    
192     void Execute68k(uint32 addr, struct M68kRegisters *r)
193     {
194     int i;
195    
196     // Save old PC
197     uaecptr oldpc = m68k_getpc();
198    
199     // Set registers
200     for (i=0; i<8; i++)
201     m68k_dreg(regs, i) = r->d[i];
202     for (i=0; i<7; i++)
203     m68k_areg(regs, i) = r->a[i];
204    
205     // Push EXEC_RETURN and faked return address (points to EXEC_RETURN) on stack
206     m68k_areg(regs, 7) -= 2;
207     put_word(m68k_areg(regs, 7), M68K_EXEC_RETURN);
208     m68k_areg(regs, 7) -= 4;
209     put_long(m68k_areg(regs, 7), m68k_areg(regs, 7) + 4);
210    
211     // Execute routine
212     m68k_setpc(addr);
213     fill_prefetch_0();
214     quit_program = 0;
215     m68k_go(true);
216    
217     // Clean up stack
218     m68k_areg(regs, 7) += 2;
219    
220     // Restore old PC
221     m68k_setpc(oldpc);
222     fill_prefetch_0();
223    
224     // Get registers
225     for (i=0; i<8; i++)
226     r->d[i] = m68k_dreg(regs, i);
227     for (i=0; i<7; i++)
228     r->a[i] = m68k_areg(regs, i);
229     quit_program = 0;
230     }