40 |
|
#include "ether.h" |
41 |
|
|
42 |
|
#include <stdio.h> |
43 |
+ |
#include <stdlib.h> |
44 |
|
|
45 |
|
#if ENABLE_MON |
46 |
|
#include "mon.h" |
159 |
|
void interrupt(uint32 entry); |
160 |
|
void handle_interrupt(); |
161 |
|
|
161 |
– |
// Lazy memory allocator (one item at a time) |
162 |
– |
void *operator new(size_t size) |
163 |
– |
{ return allocator_helper< sheepshaver_cpu, lazy_allocator >::allocate(); } |
164 |
– |
void operator delete(void *p) |
165 |
– |
{ allocator_helper< sheepshaver_cpu, lazy_allocator >::deallocate(p); } |
166 |
– |
// FIXME: really make surre array allocation fail at link time? |
167 |
– |
void *operator new[](size_t); |
168 |
– |
void operator delete[](void *p); |
169 |
– |
|
162 |
|
// Make sure the SIGSEGV handler can access CPU registers |
163 |
|
friend sigsegv_return_t sigsegv_handler(sigsegv_address_t, sigsegv_address_t); |
164 |
|
}; |
165 |
|
|
166 |
< |
lazy_allocator< sheepshaver_cpu > allocator_helper< sheepshaver_cpu, lazy_allocator >::allocator; |
166 |
> |
// Memory allocator returning areas aligned on 16-byte boundaries |
167 |
> |
void *operator new(size_t size) |
168 |
> |
{ |
169 |
> |
void *p; |
170 |
> |
|
171 |
> |
#if defined(HAVE_POSIX_MEMALIGN) |
172 |
> |
if (posix_memalign(&p, 16, size) != 0) |
173 |
> |
throw std::bad_alloc(); |
174 |
> |
#elif defined(HAVE_MEMALIGN) |
175 |
> |
p = memalign(16, size); |
176 |
> |
#elif defined(HAVE_VALLOC) |
177 |
> |
p = valloc(size); // page-aligned! |
178 |
> |
#else |
179 |
> |
/* XXX: handle padding ourselves */ |
180 |
> |
p = malloc(size); |
181 |
> |
#endif |
182 |
> |
|
183 |
> |
return p; |
184 |
> |
} |
185 |
> |
|
186 |
> |
void operator delete(void *p) |
187 |
> |
{ |
188 |
> |
#if defined(HAVE_MEMALIGN) || defined(HAVE_VALLOC) |
189 |
> |
#if defined(__GLIBC__) |
190 |
> |
// this is known to work only with GNU libc |
191 |
> |
free(p); |
192 |
> |
#endif |
193 |
> |
#else |
194 |
> |
free(p); |
195 |
> |
#endif |
196 |
> |
} |
197 |
|
|
198 |
|
sheepshaver_cpu::sheepshaver_cpu() |
199 |
|
: powerpc_cpu(enable_jit_p()) |
203 |
|
|
204 |
|
void sheepshaver_cpu::init_decoder() |
205 |
|
{ |
184 |
– |
#ifndef PPC_NO_STATIC_II_INDEX_TABLE |
185 |
– |
static bool initialized = false; |
186 |
– |
if (initialized) |
187 |
– |
return; |
188 |
– |
initialized = true; |
189 |
– |
#endif |
190 |
– |
|
206 |
|
static const instr_info_t sheep_ii_table[] = { |
207 |
|
{ "sheep", |
208 |
|
(execute_pmf)&sheepshaver_cpu::execute_sheep, |
731 |
|
else if (pc == ROM_BASE + 0x4a10a0 && (cpu->gpr(20) == 0xf3012002 || cpu->gpr(20) == 0xf3012000)) |
732 |
|
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
733 |
|
|
734 |
+ |
// Ignore writes to the zero page |
735 |
+ |
else if ((uint32)(addr - SheepMem::ZeroPage()) < (uint32)SheepMem::PageSize()) |
736 |
+ |
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
737 |
+ |
|
738 |
|
// Ignore all other faults, if requested |
739 |
|
if (PrefsFindBool("ignoresegv")) |
740 |
|
return SIGSEGV_RETURN_SKIP_INSTRUCTION; |
991 |
|
GPR(3) = false; |
992 |
|
break; |
993 |
|
#endif |
994 |
+ |
case NATIVE_SYNC_HOOK: |
995 |
+ |
GPR(3) = NQD_sync_hook(GPR(3)); |
996 |
+ |
break; |
997 |
+ |
case NATIVE_BITBLT_HOOK: |
998 |
+ |
GPR(3) = NQD_bitblt_hook(GPR(3)); |
999 |
+ |
break; |
1000 |
+ |
case NATIVE_BITBLT: |
1001 |
+ |
NQD_bitblt(GPR(3)); |
1002 |
+ |
break; |
1003 |
+ |
case NATIVE_FILLRECT_HOOK: |
1004 |
+ |
GPR(3) = NQD_fillrect_hook(GPR(3)); |
1005 |
+ |
break; |
1006 |
+ |
case NATIVE_INVRECT: |
1007 |
+ |
NQD_invrect(GPR(3)); |
1008 |
+ |
break; |
1009 |
+ |
case NATIVE_FILLRECT: |
1010 |
+ |
NQD_fillrect(GPR(3)); |
1011 |
+ |
break; |
1012 |
|
case NATIVE_SERIAL_NOTHING: |
1013 |
|
case NATIVE_SERIAL_OPEN: |
1014 |
|
case NATIVE_SERIAL_PRIME_IN: |