#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
-#include "uae.h"
#include "memory.h"
#include "events.h"
#include "savestate.h"
gui_cd_led (1);
cdrom_run_read ();
framecounter = 1000000 / (74 * 75 * cdrom_speed);
- framecounter = 1000000 / (74 * 75 * cdrom_speed);
cdrom_status1 |= CDSTATUS_FRAME;
}
akiko_internal ();
return 0;
}
-static uae_u8 akiko_get_long (uae_u32 v, int offset)
+STATIC_INLINE uae_u8 akiko_get_long (uae_u32 v, int offset)
{
return v >> ((3 - offset) * 8);
}
-static void akiko_put_long (uae_u32 *p, int offset, int v)
+STATIC_INLINE void akiko_put_long (uae_u32 *p, int offset, int v)
{
*p &= ~(0xff << ((3 - offset) * 8));
*p |= v << ((3 - offset) * 8);
return v;
}
-uae_u32 akiko_bget (uaecptr addr)
+uae_u32 REGPARAM2 akiko_bget (uaecptr addr)
{
return akiko_bget2 (addr, 1);
}
-uae_u32 akiko_wget (uaecptr addr)
+uae_u32 REGPARAM2 akiko_wget (uaecptr addr)
{
uae_u16 v;
addr &= 0xffff;
return v;
}
-uae_u32 akiko_lget (uaecptr addr)
+uae_u32 REGPARAM2 akiko_lget (uaecptr addr)
{
uae_u32 v;
uae_sem_post (&akiko_sem);
}
-void akiko_bput (uaecptr addr, uae_u32 v)
+void REGPARAM2 akiko_bput (uaecptr addr, uae_u32 v)
{
akiko_bput2 (addr, v, 1);
}
-void akiko_wput (uaecptr addr, uae_u32 v)
+void REGPARAM2 akiko_wput (uaecptr addr, uae_u32 v)
{
addr &= 0xfff;
if((addr < 0x30 && AKIKO_DEBUG_IO))
akiko_bput2 (addr + 0, v >> 8, 0);
}
-void akiko_lput (uaecptr addr, uae_u32 v)
+void REGPARAM2 akiko_lput (uaecptr addr, uae_u32 v)
{
addr &= 0xffff;
if(addr < 0x30 && AKIKO_DEBUG_IO)
return 1;
}
+#ifdef SAVESTATE
+
uae_u8 *save_akiko(int *len)
{
uae_u8 *dstbak, *dst;
sys_command_cd_play (DF_IOCTL, unitnum, last_play_pos, last_play_end, 0);
}
+#endif
void akiko_entergui (void)
{
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
return (addr + size) <= hrtmem_size;
}
-static uae_u8 REGPARAM2 *hrtmem_xlate (uaecptr addr)
+static uae_u8 *REGPARAM2 hrtmem_xlate (uaecptr addr)
{
addr -= hrtmem_start & hrtmem_mask;
addr &= hrtmem_mask;
/* returns true if the Program counter is currently in the AR rom. */
int is_ar_pc_in_rom()
{
- uaecptr pc = m68k_getpc() & 0xFFFFFF;
+ uaecptr pc = m68k_getpc(®s) & 0xFFFFFF;
return pc >= arrom_start && pc < arrom_start+arrom_size;
}
/* returns true if the Program counter is currently in the AR RAM. */
int is_ar_pc_in_ram()
{
- uaecptr pc = m68k_getpc() & 0xFFFFFF;
+ uaecptr pc = m68k_getpc(®s) & 0xFFFFFF;
return pc >= arram_start && pc < arram_start+arram_size;
}
ar_wait_pop = 0;
/* We get (SP+2) here, as the first word on the stack is the status register. */
/* We want the following long, which is the return program counter. */
- wait_for_pc = longget(m68k_areg(regs,7)+2); /* Get (SP+2) */
- set_special (SPCFLAG_ACTION_REPLAY);
+ wait_for_pc = longget(m68k_areg(®s,7)+2); /* Get (SP+2) */
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
- pc = m68k_getpc();
+ pc = m68k_getpc(®s);
/* write_log_debug("Action Replay marked as ACTION_REPLAY_WAIT_PC, PC=%p\n",pc);*/
}
else
{
- uaecptr pc = m68k_getpc();
+ uaecptr pc = m68k_getpc(®s);
/* write_log_debug("Action Replay marked as IDLE, PC=%p\n",pc);*/
action_replay_flag = ACTION_REPLAY_IDLE;
}
} else {
write_log("AR: exit with armode(%d)\n", armode);
}
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
action_replay_flag = ACTION_REPLAY_HIDE;
} else if (addr == 6) {
copytoamiga (regs.vbr + 0x7c, artemp, 4);
}
-static uae_u32 arram_lget (uaecptr) REGPARAM;
-static uae_u32 arram_wget (uaecptr) REGPARAM;
-static uae_u32 arram_bget (uaecptr) REGPARAM;
-static void arram_lput (uaecptr, uae_u32) REGPARAM;
-static void arram_wput (uaecptr, uae_u32) REGPARAM;
-static void arram_bput (uaecptr, uae_u32) REGPARAM;
-static int arram_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *arram_xlate (uaecptr addr) REGPARAM;
-
-static uae_u32 arrom_lget (uaecptr) REGPARAM;
-static uae_u32 arrom_wget (uaecptr) REGPARAM;
-static uae_u32 arrom_bget (uaecptr) REGPARAM;
-static void arrom_lput (uaecptr, uae_u32) REGPARAM;
-static void arrom_wput (uaecptr, uae_u32) REGPARAM;
-static void arrom_bput (uaecptr, uae_u32) REGPARAM;
-static int arrom_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *arrom_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 arram_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 arram_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 arram_bget (uaecptr) REGPARAM;
+static void REGPARAM3 arram_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 arram_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 arram_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 arram_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 arram_xlate (uaecptr addr) REGPARAM;
+
+static uae_u32 REGPARAM3 arrom_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 arrom_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 arrom_bget (uaecptr) REGPARAM;
+static void REGPARAM3 arrom_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 arrom_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 arrom_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 arrom_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 arrom_xlate (uaecptr addr) REGPARAM;
static void action_replay_unmap_banks(void);
static uae_u32 action_replay_calculate_checksum(void);
addr &= arram_mask;
m = (uae_u32 *)(armemory_ram + addr);
if (strncmp("T8", (char*)m, 2) == 0)
- write_log_debug("Reading T8 from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading T8 from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("LAME", (char*)m, 4) == 0)
- write_log_debug("Reading LAME from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading LAME from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("RES1", (char*)m, 4) == 0)
- write_log_debug("Reading RES1 from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading RES1 from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("ARON", (char*)m, 4) == 0)
- write_log_debug("Reading ARON from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading ARON from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("KILL", (char*)m, 4) == 0)
- write_log_debug("Reading KILL from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading KILL from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("BRON", (char*)m, 4) == 0)
- write_log_debug("Reading BRON from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading BRON from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("PRIN", (char*)m, 4) == 0)
- write_log_debug("Reading PRIN from addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Reading PRIN from addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
return do_get_mem_long (m);
}
addr &= arram_mask;
m = (uae_u32 *)(armemory_ram + addr);
if (strncmp("T8", (char*)m, 2) == 0)
- write_log_debug("Writing T8 to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing T8 to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("LAME", (char*)m, 4) == 0)
- write_log_debug("Writing LAME to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing LAME to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("RES1", (char*)m, 4) == 0)
- write_log_debug("Writing RES1 to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing RES1 to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("ARON", (char*)m, 4) == 0)
- write_log_debug("Writing ARON to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing ARON to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("KILL", (char*)m, 4) == 0)
- write_log_debug("Writing KILL to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing KILL to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("BRON", (char*)m, 4) == 0)
- write_log_debug("Writing BRON to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing BRON to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
if (strncmp("PRIN", (char*)m, 4) == 0)
- write_log_debug("Writing PRIN to addr %08.08x PC=%p\n", addr, m68k_getpc());
+ write_log_debug("Writing PRIN to addr %08.08x PC=%p\n", addr, m68k_getpc(®s));
do_put_mem_long (m, l);
}
return (addr + size) <= arram_size;
}
-static uae_u8 REGPARAM2 *arram_xlate (uaecptr addr)
+static uae_u8 *REGPARAM2 arram_xlate (uaecptr addr)
{
addr -= arram_start;
addr &= arram_mask;
return (addr + size) <= arrom_size;
}
-static uae_u8 REGPARAM2 *arrom_xlate (uaecptr addr)
+static uae_u8 *REGPARAM2 arrom_xlate (uaecptr addr)
{
addr -= arrom_start;
addr &= arrom_mask;
hide_cart (0);
memcpy (armemory_ram + 0xf000, ar_custom, 2 * 256);
action_replay_flag = ACTION_REPLAY_ACTIVE;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
copyfromamiga (artemp, regs.vbr + 0x7c, 4);
copytoamiga (regs.vbr+0x7c, armemory_rom + 0x7c, 4);
Interrupt (7);
triggered_once = 1;
cartridge_enter();
hrtmon_flag = ACTION_REPLAY_ACTIVE;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
memcpy (hrtmon_custom, ar_custom, 2 * 256);
for (i = 0; i < 16; i++) {
if (hrtmon_ciaa)
old = get_long((uaecptr)(regs.vbr + 0x8));
put_word (hrtmem_start + 0xc0000, 4);
put_long ((uaecptr)(regs.vbr + 8), get_long (hrtmem_start + 8));
- Exception (2, 0);
+ Exception (2, ®s, 0);
put_long ((uaecptr)(regs.vbr + 8), old);
} else {
old = get_long((uaecptr)(regs.vbr + 0x7c));
return;
triggered_once = 1;
if (armodel == 1) {
- write_log("AR1: Enter PC:%p\n", m68k_getpc());
+ write_log("AR1: Enter PC:%p\n", m68k_getpc(®s));
action_replay_go1 (7);
- unset_special (SPCFLAG_ACTION_REPLAY);
+ unset_special (®s, SPCFLAG_ACTION_REPLAY);
return;
}
if (action_replay_flag == ACTION_REPLAY_DORESET) {
{
if (hrtmemory) {
if (savestate_state == STATE_RESTORE) {
- if (m68k_getpc() >= hrtmem_start && m68k_getpc() <= hrtmem_start + hrtmem_size)
+ if (m68k_getpc(®s) >= hrtmem_start && m68k_getpc(®s) <= hrtmem_start + hrtmem_size)
hrtmon_map_banks();
else
hrtmon_unmap_banks();
return;
if (savestate_state == STATE_RESTORE) {
- if (m68k_getpc() >= arrom_start && m68k_getpc() <= arrom_start + arrom_size) {
+ if (m68k_getpc(®s) >= arrom_start && m68k_getpc(®s) <= arrom_start + arrom_size) {
action_replay_flag = ACTION_REPLAY_ACTIVE;
hide_cart (0);
} else {
return;
if (armode < 2) /* If there are no active breakpoints*/
return;
- if (m68k_getpc() >= 0x200)
+ if (m68k_getpc(®s) >= 0x200)
return;
action_replay_flag = ACTION_REPLAY_ACTIVATE;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
}
int action_replay_freeze(void)
action_replay_chipwrite();
} else {
action_replay_flag = ACTION_REPLAY_ACTIVATE;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
armode = ARMODE_FREEZE;
}
return 1;
} else {
hrtmon_flag = ACTION_REPLAY_ACTIVATE;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
return 1;
}
return 0;
{
if (armodel == 2 || armodel == 3) {
action_replay_flag = ACTION_REPLAY_DORESET;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
} else if (armodel == 1) {
/* copy 0x60 addr info to level 7 */
/* This is to emulate the 0x60 interrupt. */
ar_wait_pop = 1; /* Wait for stack to pop. */
action_replay_flag = ACTION_REPLAY_ACTIVATE;
- set_special (SPCFLAG_ACTION_REPLAY);
+ set_special (®s, SPCFLAG_ACTION_REPLAY);
}
}
return;
hrtmon_flag = ACTION_REPLAY_IDLE;
cartridge_exit();
- unset_special (SPCFLAG_ACTION_REPLAY);
+ unset_special (®s, SPCFLAG_ACTION_REPLAY);
//write_log ("HRTMON: Exit\n");
}
}
}
- unset_special(SPCFLAG_ACTION_REPLAY); /* This shouldn't be necessary here, but just in case. */
+ unset_special(®s, SPCFLAG_ACTION_REPLAY); /* This shouldn't be necessary here, but just in case. */
action_replay_flag = ACTION_REPLAY_INACTIVE;
hrtmon_flag = ACTION_REPLAY_INACTIVE;
action_replay_unsetbanks();
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
#ifdef AVIOUTPUT
#include "avioutput.h"
#endif
+#ifdef AHI
+#include "traps.h"
+#include "ahidsound.h"
+#endif
#include <math.h>
{
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
- write_log ("SETIRQ %d %08.8X (%d)\n", nr, m68k_getpc(), debug);
+ write_log ("SETIRQ %d %08.8X (%d)\n", nr, M68K_GETPC, debug);
#endif
INTREQ (0x8000 | (0x80 << nr));
}
if (currprefs.produce_sound == 0)
cdp->per = PERIOD_MAX;
- if (!cdp->dmaen && isirq (nr) && ((cdp->per <= 30 ) || (evtime == 0 || evtime == MAX_EV || evtime == cdp->per))) {
+ if (!cdp->dmaen && isirq (nr) && (evtime == 0 || evtime == MAX_EV || evtime == cdp->per)) {
zerostate (cdp);
return;
}
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
write_log ("AUD%dDMA %d->%d (%d) LEN=%d/%d %08.8X\n", nr, cdp->dmaen, chan_ena,
- cdp->state, cdp->wlen, cdp->len, m68k_getpc());
+ cdp->state, cdp->wlen, cdp->len, M68K_GETPC);
#endif
cdp->dmaen = chan_ena;
if (cdp->dmaen)
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
write_log ("AUD%dDAT: %04.4X STATE=%d IRQ=%d %08.8X\n", nr,
- v, cdp->state, isirq(nr) ? 1 : 0, m68k_getpc());
+ v, cdp->state, isirq(nr) ? 1 : 0, M68K_GETPC);
#endif
update_audio ();
cdp->dat2 = v;
audio_channel[nr].lc = (audio_channel[nr].lc & 0xffff) | ((uae_u32)v << 16);
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
- write_log ("AUD%dLCH: %04.4X %08.8X\n", nr, v, m68k_getpc());
+ write_log ("AUD%dLCH: %04.4X %08.8X\n", nr, v, M68K_GETPC);
#endif
}
audio_channel[nr].lc = (audio_channel[nr].lc & ~0xffff) | (v & 0xFFFE);
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
- write_log ("AUD%dLCL: %04.4X %08.8X\n", nr, v, m68k_getpc());
+ write_log ("AUD%dLCL: %04.4X %08.8X\n", nr, v, M68K_GETPC);
#endif
}
audio_channel[nr].per = per;
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
- write_log ("AUD%dPER: %d %08.8X\n", nr, v, m68k_getpc());
+ write_log ("AUD%dPER: %d %08.8X\n", nr, v, M68K_GETPC);
#endif
}
audio_channel[nr].len = v;
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
- write_log ("AUD%dLEN: %d %08.8X\n", nr, v, m68k_getpc());
+ write_log ("AUD%dLEN: %d %08.8X\n", nr, v, M68K_GETPC);
#endif
}
#endif
#ifdef DEBUG_AUDIO
if (debugchannel (nr))
- write_log ("AUD%dVOL: %d %08.8X\n", nr, v2, m68k_getpc());
+ write_log ("AUD%dVOL: %d %08.8X\n", nr, v2, M68K_GETPC);
#endif
}
if ((1 << i) & DEBUG_CHANNEL_MASK) {
uae_u16 mask = 0x80 << i;
if ((v2 & mask) != (v3 & mask))
- write_log("AUD%dINTREQ %d->%d %08.8X\n", i, !!(v3 & mask), !!(v2 & mask), m68k_getpc());
+ write_log("AUD%dINTREQ %d->%d %08.8X\n", i, !!(v3 & mask), !!(v2 & mask), M68K_GETPC);
}
}
#endif
{
static int prevcon = -1;
if ((prevcon & 0xff) != (adkcon & 0xff)) {
- write_log("ADKCON=%02.2x %08.8X\n", adkcon & 0xff, m68k_getpc());
+ write_log("ADKCON=%02.2x %08.8X\n", adkcon & 0xff, M68K_GETPC);
prevcon = adkcon;
}
}
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "events.h"
#include "newcpu.h"
#include "autoconf.h"
-#include "osdep/exectasks.h"
-
-/* We'll need a lot of these. */
-#define MAX_TRAPS 4096
-static TrapFunction traps[MAX_TRAPS];
-static int trapmode[MAX_TRAPS];
-static const char *trapstr[MAX_TRAPS];
-static uaecptr trapoldfunc[MAX_TRAPS];
-
-static int max_trap;
-int lasttrap;
-
-//#define sm_log write_log
-#define sm_log
-
-#ifdef CAN_DO_STACK_MAGIC
-
-/* Stack management */
-
-/* The mechanism for doing m68k calls from native code is as follows:
- *
- * m68k code executes, stack is main
- * calltrap to execute_fn_on_extra_stack. new stack is allocated
- * do_stack_magic is called for the first time
- * current context is saved with setjmp [0]
- * transfer_control is done
- * native code executes on new stack
- * native code calls call_m68k
- * setjmp saves current context [1]
- * longjmp back to execute_fn_on_extra_stack [0]
- * pointer to new stack is saved on m68k stack. m68k return address set
- * to RTAREA_BASE + 0xFF00. m68k PC set to called function
- * m68k function executes, stack is main
- * m68k function returns to RTAREA_BASE + 0xFF00
- * calltrap to m68k_mode_return
- * do_stack_magic is called again
- * current context is saved again with setjmp [0]
- * this time, transfer_control is _not_ done, instead a longjmp[1]
- * to the previously saved context
- * native code executes again on temp stack
- * native function returns to stack_stub
- * longjmp[0] back to old context
- * back again!
- *
- * A bearded man enters the room, carrying a bowl of spaghetti.
- */
-
-/* This _shouldn't_ crash with a stack size of 4096, but it does...
- * might be a bug */
-#ifndef EXTRA_STACK_SIZE
-#define EXTRA_STACK_SIZE 32768
-#endif
-#ifdef _WIN32
-#define WIN32_EXTRA_STACKS 30
-static void *win32_freestack[WIN32_EXTRA_STACKS]; //EXTRA_STACK_SIZE
-#endif
-
-struct extra_stack
-{
- jmp_buf stackswap_env;
- jmp_buf m68kcall_env;
- uaecptr m68kcall_addr;
- void *stack[EXTRA_STACK_SIZE - 2*sizeof(jmp_buf) - sizeof(uaecptr)];
-};
-
-
-static struct extra_stack *get_extra_stack (void)
-{
- struct extra_stack *s;
-
-#ifdef _WIN32
- {
- extern uae_u8 *win32_stackbase;
- int i;
- for (i = 0;i < WIN32_EXTRA_STACKS; i++) { //0 to MAX_SELECT_THREADS
- if(!win32_freestack[i])
- break; //get a free block
- }
- if (i == WIN32_EXTRA_STACKS) {
- gui_message("run out of extra stacks. this shouldn't happen.");
- i = 0;
- }
- s = (struct extra_stack*)(win32_stackbase + (i * EXTRA_STACK_SIZE));
- win32_freestack[i] = s;
- }
-#else
- s = xmalloc (sizeof (struct extra_stack));
-#endif
- return s;
-}
-
-static void free_extra_stack (struct extra_stack *s)
-{
-#ifdef _WIN32
- int i;
- for (i = 0; i < WIN32_EXTRA_STACKS; i++) {//0 to MAX_SELECT_THREADS
- if(win32_freestack[i] == s)
- break; //got a free block
- }
- win32_freestack[i] = 0;
-#else
- free (s);
-#endif
-}
-
-static void stack_stub (struct extra_stack *s, TrapFunction f, uae_u32 *retval)
-{
- sm_log("in stack_stub: %p %p %p %x\n", s, f, retval, (int)*retval);
- *retval = f ();
- sm_log("returning from stack_stub\n");
- longjmp (s->stackswap_env, 1);
-}
-
-static struct extra_stack *current_extra_stack = NULL;
-
-static void do_stack_magic (TrapFunction f, struct extra_stack *s, int has_retval)
-{
- switch (setjmp (s->stackswap_env)) {
- case 0:
- /* Returning directly */
- current_extra_stack = s;
- if (has_retval == -1) {
- sm_log("finishing m68k mode return\n");
- longjmp (s->m68kcall_env, 1);
- }
- sm_log("calling native function\n");
- transfer_control (s, EXTRA_STACK_SIZE, stack_stub, f, has_retval);
- /* not reached */
- abort ();
-
- case 1:
- sm_log("native function complete\n");
- /* Returning normally. */
- if (stack_has_retval (s, EXTRA_STACK_SIZE))
- m68k_dreg (regs, 0) = get_retval_from_stack (s, EXTRA_STACK_SIZE);
- free_extra_stack (s);
- break;
-
- case 2: {
- /* Returning to do a m68k call. We're now back on the main stack. */
- uaecptr a7 = m68k_areg (regs, 7) -= (sizeof (void *) + 7) & ~3;
- /* Save stack to restore */
- *((void **)get_real_address (a7 + 4)) = s;
- /* Save special return address: this address contains a
- * calltrap that will longjmp to the right stack. */
- put_long (m68k_areg (regs, 7), RTAREA_BASE + 0xFF00);
- m68k_setpc (s->m68kcall_addr);
- fill_prefetch_slow ();
- sm_log("native function calls m68k\n");
- break;
- }
- }
- current_extra_stack = 0;
-}
-
-static uae_u32 execute_fn_on_extra_stack (TrapFunction f, int has_retval)
-{
- struct extra_stack *s = get_extra_stack ();
- do_stack_magic (f, s, has_retval);
- return 0;
-}
-
-static uae_u32 m68k_mode_return (void)
-{
- uaecptr a7 = m68k_areg (regs, 7);
- struct extra_stack *s = *(struct extra_stack **)get_real_address (a7);
- m68k_areg (regs, 7) += (sizeof (void *) + 3) & ~3;
- sm_log("doing m68k mode return\n");
- do_stack_magic (NULL, s, -1);
- return 0;
-}
-
-static uae_u32 call_m68k (uaecptr addr, int saveregs)
-{
- volatile uae_u32 retval = 0;
- volatile int do_save = saveregs;
-
- sm_log("\nDoing call_m68k (addr=%08x, savereg=%d) extra_stack=%p\n",
- addr,saveregs,current_extra_stack);
-
- if (current_extra_stack != NULL)
- {
- volatile struct regstruct saved_regs;
- struct extra_stack *s = current_extra_stack;
-
- if (do_save)
- saved_regs = regs;
-
- s->m68kcall_addr = addr;
-
- switch (setjmp (s->m68kcall_env)) {
- case 0:
- /*write_log ("doing call\n");*/
- /* Returning directly: now switch to main stack and do the call */
- longjmp (s->stackswap_env, 2);
- case 1:
- /*write_log ("returning from call\n");*/
- retval = m68k_dreg (regs, 0);
- if (do_save)
- regs = saved_regs;
- /* Returning after the call. */
- break;
- }
- } else
- abort ();
-
- return retval;
-}
-
-uae_u32 CallLib (uaecptr base, uae_s16 offset)
-{
- int i;
- uaecptr olda6 = m68k_areg (regs, 6);
- uae_u32 retval;
-#if 0
- for (i = 0; i < n_libpatches; i++) {
- if (libpatches[i].libbase == base && libpatches[i].functions[-offset/6] != NULL)
- return (*libpatches[i].functions[-offset/6])();
- }
-#endif
- m68k_areg (regs, 6) = base;
- retval = call_m68k (base + offset, 1);
- m68k_areg (regs, 6) = olda6;
- return retval;
-}
-
-#else
-
-/*
- * Stubs for when building without stack magic
- */
-static uae_u32 m68k_mode_return (void)
-{
- return 0;
-}
-
-uae_u32 CallLib (uaecptr base, uae_s16 offset)
-{
- /* Shouldn't be necessary */
- write_log ("WARNING: Calling 68k code from UAE is not supported in this version.\n");
- return 0;
-}
-
-#endif
+#include "traps.h"
/* Commonly used autoconfig strings */
uaecptr EXPANSION_explibname, EXPANSION_doslibname, EXPANSION_uaeversion;
-uaecptr EXPANSION_uaedevname, EXPANSION_explibbase = 0, EXPANSION_haveV36;
+uaecptr EXPANSION_uaedevname, EXPANSION_explibbase = 0;
uaecptr EXPANSION_bootcode, EXPANSION_nullfunc;
-uaecptr EXPANSION_cddevice;
/* ROM tag area memory access */
uae_u8 *rtarea;
-static uae_u32 rtarea_lget (uaecptr) REGPARAM;
-static uae_u32 rtarea_wget (uaecptr) REGPARAM;
-static uae_u32 rtarea_bget (uaecptr) REGPARAM;
-static void rtarea_lput (uaecptr, uae_u32) REGPARAM;
-static void rtarea_wput (uaecptr, uae_u32) REGPARAM;
-static void rtarea_bput (uaecptr, uae_u32) REGPARAM;
-static uae_u8 *rtarea_xlate (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 rtarea_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 rtarea_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 rtarea_bget (uaecptr) REGPARAM;
+static void REGPARAM3 rtarea_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 rtarea_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 rtarea_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u8 *REGPARAM3 rtarea_xlate (uaecptr) REGPARAM;
addrbank rtarea_bank = {
rtarea_lget, rtarea_wget, rtarea_bget,
rtarea_xlate, default_check, NULL, "UAE Boot ROM"
};
-uae_u8 REGPARAM2 *rtarea_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 rtarea_xlate (uaecptr addr)
{
addr &= 0xFFFF;
return rtarea + addr;
#endif
}
-static const int trace_traps = 1;
-
-void REGPARAM2 call_calltrap (int func)
-{
- uae_u32 retval = 0;
- int has_retval = (trapmode[func] & TRAPFLAG_NO_RETVAL) == 0;
- int implicit_rts = (trapmode[func] & TRAPFLAG_DORET) != 0;
-
- if (trapstr[func] && *trapstr[func] != 0 && trace_traps)
- write_log ("TRAP: %s\n", trapstr[func]);
-
- /* For monitoring only? */
- if (traps[func] == NULL) {
- m68k_setpc (trapoldfunc[func]);
- fill_prefetch_slow ();
- return;
- }
-
- if (func < max_trap) {
-#ifdef CAN_DO_STACK_MAGIC
- if (trapmode[func] & TRAPFLAG_EXTRA_STACK) {
- execute_fn_on_extra_stack(traps[func], has_retval);
- return;
- }
-#endif
- retval = (*traps[func])();
- } else
- write_log ("illegal emulator trap\n");
-
- if (has_retval)
- m68k_dreg (regs, 0) = retval;
- if (implicit_rts) {
- m68k_do_rts ();
- fill_prefetch_slow ();
- }
-}
-
-#ifdef CAN_DO_STACK_MAGIC
-/* @$%& compiler bugs */
-static volatile int four = 4;
-
-uaecptr libemu_InstallFunctionFlags (TrapFunction f, uaecptr libbase, int offset,
- int flags, const char *tracename)
-{
- int i;
- uaecptr retval;
- uaecptr execbase = get_long (four);
- int trnum;
- uaecptr addr = here ();
- calltrap (trnum = deftrap2 (f, flags, tracename));
- dw (RTS);
-
- m68k_areg (regs, 1) = libbase;
- m68k_areg (regs, 0) = offset;
- m68k_dreg (regs, 0) = addr;
- retval = CallLib (execbase, -420);
-
- trapoldfunc[trnum] = retval;
-#if 0
- for (i = 0; i < n_libpatches; i++) {
- if (libpatches[i].libbase == libbase)
- break;
- }
- if (i == n_libpatches) {
- int j;
- libpatches[i].libbase = libbase;
- for (j = 0; j < 300; j++)
- libpatches[i].functions[j] = NULL;
- n_libpatches++;
- }
- libpatches[i].functions[-offset/6] = f;
-#endif
- return retval;
-}
-#endif
-
/* some quick & dirty code to fill in the rt area and save me a lot of
* scratch paper
*/
* backward. store pointer at current address
*/
-uae_u32 ds (char *str)
+uae_u32 ds (const char *str)
{
int len = strlen (str) + 1;
return addr (rt_addr);
}
-int deftrap2 (TrapFunction func, int mode, const char *str)
-{
- int num = max_trap++;
- traps[num] = func;
- trapstr[num] = str;
- trapmode[num] = mode;
- return num;
-}
-
-int deftrap (TrapFunction func)
-{
- return deftrap2 (func, 0, "");
-}
-
void align (int b)
{
rt_addr = (rt_addr + b - 1) & ~(b - 1);
}
-static uae_u32 nullfunc (void)
+static uae_u32 REGPARAM2 nullfunc (TrapContext *context)
{
write_log ("Null function called\n");
return 0;
}
-static uae_u32 getchipmemsize (void)
+static uae_u32 REGPARAM2 getchipmemsize (TrapContext *context)
{
return allocated_chipmem;
}
-static uae_u32 uae_puts (void)
+static uae_u32 REGPARAM2 uae_puts (TrapContext *context)
{
- puts (get_real_address (m68k_areg (regs, 0)));
+ puts ((char *)get_real_address (m68k_areg (&context->regs, 0)));
return 0;
}
rt_straddr = 0xFF00 - 2;
rt_addr = 0;
- max_trap = 0;
+
+ init_traps ();
rtarea_init_mem ();
EXPANSION_uaedevname = ds ("uae.device");
deftrap (NULL); /* Generic emulator trap */
- lasttrap = 0;
EXPANSION_nullfunc = here ();
calltrap (deftrap (nullfunc));
dw (RTS);
a = here();
- /* Standard "return from 68k mode" trap */
+ /* Dummy trap - removing this breaks the filesys emulation. */
org (RTAREA_BASE + 0xFF00);
- calltrap (deftrap2 (m68k_mode_return, TRAPFLAG_NO_RETVAL, ""));
+ calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, ""));
org (RTAREA_BASE + 0xFF80);
calltrap (deftrap2 (getchipmemsize, TRAPFLAG_DORET, ""));
#ifdef FILESYS
filesys_install_code ();
#endif
+
+ init_extended_traps();
}
volatile int uae_int_requested = 0;
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
/* we must not change ce-mode while blitter is running.. */
static int blitter_cycle_exact;
-uae_u16 oldvblts;
uae_u16 bltcon0,bltcon1;
uae_u32 bltapt,bltbpt,bltcpt,bltdpt;
static uae_u8 blit_filltable[256][4][2];
uae_u32 blit_masktable[BLITTER_MAX_WORDS];
-static uae_u16 blit_trashtable[BLITTER_MAX_WORDS];
enum blitter_states bltstate;
static int blit_cyclecounter, blit_maxcyclecounter, blit_slowdown;
static long blit_first_cycle;
static int blit_last_cycle, blit_dmacount, blit_dmacount2;
static int blit_linecycles, blit_extracycles, blit_nod;
-static int *blit_diag;
+static const int *blit_diag;
static uae_u16 ddat1, ddat2;
static int ddat1use, ddat2use;
/* -1 = idle cycle and allocate bus */
-static int blit_cycle_diagram[][10] =
+static const int blit_cycle_diagram[][10] =
{
{ 0, 2, 0,0 }, /* 0 */
{ 0, 2, 0,4 }, /* 1 */
/* 5 = fill mode idle cycle ("real" idle cycle) */
-static int blit_cycle_diagram_fill[][10] =
+static const int blit_cycle_diagram_fill[][10] =
{
{ 0, 3, 0,5,0 }, /* 0 */
{ 0, 3, 3,5,4 }, /* 1 */
*/
-static int blit_cycle_diagram_line[] =
+static const int blit_cycle_diagram_line[] =
{
0, 4, 0,3,0,4, 0,0,0,0,0,0,0,0,0,0 /* guessed */
};
-static int blit_cycle_diagram_finald[] =
+static const int blit_cycle_diagram_finald[] =
{ 0, 2, 0,4 };
void build_blitfilltable(void)
blitter_done_notify ();
INTREQ(0x8040);
eventtab[ev_blitter].active = 0;
- unset_special (SPCFLAG_BLTNASTY);
+ unset_special (®s, SPCFLAG_BLTNASTY);
#ifdef BLITTER_DEBUG
write_log ("vpos=%d, cycles %d, missed %d, total %d\n",
vpos, blit_cyclecounter, blit_misscyclecounter, blit_cyclecounter + blit_misscyclecounter);
if (blitline) {
if (blt_info.hblitsize != 2)
- write_log ("weird hblitsize in linemode: %d vsize=%d PC%=%x\n", blt_info.hblitsize, blt_info.vblitsize, m68k_getpc());
+ write_log ("weird hblitsize in linemode: %d vsize=%d PC%=%x\n",
+ blt_info.hblitsize, blt_info.vblitsize, m68k_getpc(®s));
blit_diag = blit_cycle_diagram_line;
} else {
if (con & 2) {
* negative effects. */
static int warn = 1;
if (warn)
- write_log ("warning: weird fill mode (further messages suppressed) PC=%x\n", m68k_getpc());
+ write_log ("warning: weird fill mode (further messages suppressed) PC=%x\n",
+ m68k_getpc(®s));
warn = 0;
blitife = 0;
}
if (blitfill && !blitdesc) {
static int warn = 1;
if (warn)
- write_log ("warning: blitter fill without desc (further messages suppressed) PC=%x\n", m68k_getpc());
+ write_log ("warning: blitter fill without desc (further messages suppressed) PC=%x\n",
+ m68k_getpc(®s));
warn = 0;
}
blit_diag = blitfill ? blit_cycle_diagram_fill[blit_ch] : blit_cycle_diagram[blit_ch];
#endif
blit_slowdown = 0;
- unset_special (SPCFLAG_BLTNASTY);
+ unset_special (®s, SPCFLAG_BLTNASTY);
if (dmaen(DMA_BLITPRI))
- set_special (SPCFLAG_BLTNASTY);
+ set_special (®s, SPCFLAG_BLTNASTY);
if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) {
blitter_done ();
#ifndef BLITTER_DEBUG
warned = 1;
#endif
- if (m68k_getpc() < 0xe0000 || m68k_getpc() >= 0x10000000)
+ if (m68k_getpc(®s) < 0xe0000 || m68k_getpc(®s) >= 0x10000000)
write_log ("warning: Program does not wait for blitter %p vpos=%d tc=%d\n",
- m68k_getpc(), vpos, blit_cyclecounter);
+ m68k_getpc(®s), vpos, blit_cyclecounter);
}
if (blitter_cycle_exact) {
blit_misscyclecounter += slow;
}
+#ifdef SAVESTATE
+
uae_u8 *restore_blitter (uae_u8 *src)
{
uae_u32 flags = restore_u32();
return dstbak;
}
+
+#endif /* SAVESTATE */
#include "options.h"
#include "memory.h"
-#include "config.h"
-
#include "blkdev.h"
#include "scsidev.h"
static struct device_functions *device_func[2];
-static int ioctl;
+static int have_ioctl;
#ifdef WIN32
int sys_command_open (int mode, int unitnum)
{
- if (mode == DF_SCSI || !ioctl)
+ if (mode == DF_SCSI || !have_ioctl)
return device_func[DF_SCSI]->opendev (unitnum);
else
return device_func[DF_IOCTL]->opendev (unitnum);
void sys_command_close (int mode, int unitnum)
{
- if (mode == DF_SCSI || !ioctl)
+ if (mode == DF_SCSI || !have_ioctl)
device_func[DF_SCSI]->closedev (unitnum);
else
device_func[DF_IOCTL]->closedev (unitnum);
return initialized;
install_driver (flags);
if (device_func[DF_IOCTL])
- ioctl = 1;
+ have_ioctl = 1;
else
- ioctl = 0;
+ have_ioctl = 0;
support_scsi = device_func[DF_SCSI]->openbus (oflags) ? 1 : 0;
- if (ioctl)
+ if (have_ioctl)
support_ioctl = device_func[DF_IOCTL]->openbus (1 << INQ_ROMD) ? 1 : 0;
initialized = 1;
write_log ("support_scsi = %d support_ioctl = %d\n", support_scsi, support_ioctl);
/* pause/unpause CD audio */
void sys_command_cd_pause (int mode, int unitnum, int paused)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
int as = audiostatus (unitnum);
if ((paused && as == 0x11) && (!paused && as == 0x12)) {
uae_u8 cmd[10] = {0x4b,0,0,0,0,0,0,0,paused?0:1,0};
/* stop CD audio */
void sys_command_cd_stop (int mode, int unitnum)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
int as = audiostatus (unitnum);
if (as == 0x11) {
uae_u8 cmd[6] = {0x4e,0,0,0,0,0};
/* play CD audio */
int sys_command_cd_play (int mode, int unitnum,uae_u32 startmsf, uae_u32 endmsf, int scan)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
uae_u8 cmd[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
#if 0
if (scan) {
/* read qcode */
uae_u8 *sys_command_cd_qcode (int mode, int unitnum)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
uae_u8 cmd[10] = {0x42,2,0x40,1,0,0,0,DEVICE_SCSI_BUFSIZE>>8,DEVICE_SCSI_BUFSIZE&0xff,0};
return device_func[DF_SCSI]->exec_in (unitnum, cmd, sizeof (cmd), 0);
}
/* read table of contents */
uae_u8 *sys_command_cd_toc (int mode, int unitnum)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
uae_u8 cmd [10] = { 0x43,0,2,0,0,0,1,DEVICE_SCSI_BUFSIZE>>8,DEVICE_SCSI_BUFSIZE&0xFF,0};
return device_func[DF_SCSI]->exec_in (unitnum, cmd, sizeof(cmd), 0);
}
/* read one cd sector */
uae_u8 *sys_command_cd_read (int mode, int unitnum, int offset)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
uae_u8 cmd[12] = { 0xbe, 0, 0, 0, 0, 0, 0, 0, 1, 0x10, 0, 0 };
cmd[3] = (uae_u8)(offset >> 16);
cmd[4] = (uae_u8)(offset >> 8);
/* read block */
uae_u8 *sys_command_read (int mode, int unitnum, int offset)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
uae_u8 cmd[10] = { 0x28, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
cmd[2] = (uae_u8)(offset >> 24);
cmd[3] = (uae_u8)(offset >> 16);
/* write block */
int sys_command_write (int mode, int unitnum, int offset)
{
- if (mode == DF_SCSI || !ioctl) {
+ if (mode == DF_SCSI || !have_ioctl) {
uae_u8 cmd[10] = { 0x2a, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
cmd[2] = (uae_u8)(offset >> 24);
cmd[3] = (uae_u8)(offset >> 16);
struct device_info *sys_command_info (int mode, int unitnum, struct device_info *di)
{
- if (mode == DF_SCSI || !ioctl)
+ if (mode == DF_SCSI || !have_ioctl)
return device_func[DF_SCSI]->info (unitnum, di);
else
return device_func[DF_IOCTL]->info (unitnum, di);
struct device_scsi_info *sys_command_scsi_info (int mode, int unitnum, struct device_scsi_info *dsi)
{
- if (mode == DF_SCSI || !ioctl)
+ if (mode == DF_SCSI || !have_ioctl)
return device_func[DF_SCSI]->scsiinfo (unitnum, dsi);
else
return device_func[DF_IOCTL]->scsiinfo (unitnum, dsi);
#include <assert.h>
#include <stddef.h>
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
#include "autoconf.h"
+#include "traps.h"
#include "bsdsocket.h"
-#include "osdep/exectasks.h"
#ifdef BSDSOCKET
long curruniqid = 65536;
/* Memory-related helper functions */
-static void memcpyha (uae_u32 dst, char *src, int size)
+STATIC_INLINE void memcpyha (uae_u32 dst, const char *src, int size)
{
while (size--)
put_byte (dst++, *src++);
return res;
}
-uae_u32 strcpyha (uae_u32 dst, char *src)
+uae_u32 strcpyha (uae_u32 dst, const char *src)
{
uae_u32 res = dst;
return res;
}
-uae_u32 strncpyha (uae_u32 dst, char *src, int size)
+uae_u32 strncpyha (uae_u32 dst, const char *src, int size)
{
uae_u32 res = dst;
while (size--) {
return res;
}
-uae_u32 addstr (uae_u32 * dst, char *src)
+uae_u32 addstr (uae_u32 * dst, const char *src)
{
uae_u32 res = *dst;
int len;
return res;
}
-uae_u32 addmem (uae_u32 * dst, char *src, int len)
+uae_u32 addmem (uae_u32 * dst, const char *src, int len)
{
uae_u32 res = *dst;
}
/* Get current task */
-static uae_u32 gettask (void)
+static uae_u32 gettask (TrapContext *context)
{
- uae_u32 currtask, a1 = m68k_areg (regs, 1);
+ uae_u32 currtask, a1 = m68k_areg (&context->regs, 1);
- m68k_areg (regs, 1) = 0;
- currtask = CallLib (get_long (4), -0x126); /* FindTask */
+ m68k_areg (&context->regs, 1) = 0;
+ currtask = CallLib (context, get_long (4), -0x126); /* FindTask */
- m68k_areg (regs, 1) = a1;
+ m68k_areg (&context->regs, 1) = a1;
TRACE (("[%s] ", get_real_address (get_long (currtask + 10))));
return currtask;
}
/* errno/herrno setting */
-void seterrno (SB, int sb_errno)
+void bsdsocklib_seterrno (SB, int sb_errno)
{
sb->sb_errno = sb_errno;
if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005)
- setherrno(sb,sb->sb_errno-1000);
+ bsdsocklib_setherrno(sb,sb->sb_errno-1000);
if (sb->errnoptr) {
switch (sb->errnosize) {
case 1:
}
}
-void setherrno (SB, int sb_herrno)
+void bsdsocklib_setherrno (SB, int sb_herrno)
{
sb->sb_herrno = sb_herrno;
return i + 1;
}
/* descriptor table full. */
- seterrno (sb, 24); /* EMFILE */
+ bsdsocklib_seterrno (sb, 24); /* EMFILE */
return -1;
}
{
if ((unsigned int) (sd - 1) >= (unsigned int) sb->dtablesize) {
TRACE (("Invalid Socket Descriptor (%d)\n", sd));
- seterrno (sb, 38); /* ENOTSOCK */
+ bsdsocklib_seterrno (sb, 38); /* ENOTSOCK */
return -1;
}
INTREQ (0xA000);
}
-static uae_u32 bsdsock_int_handler (void)
+static uae_u32 REGPARAM2 bsdsock_int_handler (TrapContext *context)
{
SB;
for (sb = sbsigqueue; sb; sb = sb->nextsig) {
if (sb->dosignal == 1) {
- struct regstruct sbved_regs = regs;
- m68k_areg (regs, 1) = sb->ownertask;
- m68k_dreg (regs, 0) = sb->sigstosend;
- CallLib (get_long (4), -0x144); /* Signal() */
+ struct regstruct sbved_regs = context->regs;
+ m68k_areg (&context->regs, 1) = sb->ownertask;
+ m68k_dreg (&context->regs, 0) = sb->sigstosend;
+ CallLib (context, get_long (4), -0x144); /* Signal() */
regs = sbved_regs;
return 0;
}
-void waitsig (SB)
+void waitsig (TrapContext *context, SB)
{
long sigs;
- m68k_dreg (regs, 0) = (((uae_u32) 1) << sb->signal) | sb->eintrsigs;
- if ((sigs = CallLib (get_long (4), -0x13e)) & sb->eintrsigs) {
+ m68k_dreg (&context->regs, 0) = (((uae_u32) 1) << sb->signal) | sb->eintrsigs;
+ if ((sigs = CallLib (context, get_long (4), -0x13e)) & sb->eintrsigs) {
sockabort (sb);
- seterrno (sb, 4); /* EINTR */
+ bsdsocklib_seterrno (sb, 4); /* EINTR */
// Set signal
- m68k_dreg (regs, 0) = sigs;
- m68k_dreg (regs, 1) = sb->eintrsigs;
- sigs = CallLib (get_long (4), -0x132); /* SetSignal() */
+ m68k_dreg (&context->regs, 0) = sigs;
+ m68k_dreg (&context->regs, 1) = sb->eintrsigs;
+ sigs = CallLib (context, get_long (4), -0x132); /* SetSignal() */
sb->eintr = 1;
} else
sb->eintr = 0;
}
-void cancelsig (SB)
+void cancelsig (TrapContext *context, SB)
{
locksigqueue ();
if (sb->dosignal)
sb->dosignal = 2;
unlocksigqueue ();
- m68k_dreg (regs, 0) = 0;
- m68k_dreg (regs, 1) = ((uae_u32) 1) << sb->signal;
- CallLib (get_long (4), -0x132); /* SetSignal() */
+ m68k_dreg (&context->regs, 0) = 0;
+ m68k_dreg (&context->regs, 1) = ((uae_u32) 1) << sb->signal;
+ CallLib (context, get_long (4), -0x132); /* SetSignal() */
}
/* Allocate and initialize per-task state structure */
-static struct socketbase *alloc_socketbase (void)
+static struct socketbase *alloc_socketbase (TrapContext *context)
{
SB;
int i;
if ((sb = calloc (sizeof (struct socketbase), 1)) != NULL) {
- sb->ownertask = gettask ();
+ sb->ownertask = gettask (context);
- m68k_dreg (regs, 0) = -1;
- sb->signal = CallLib (get_long (4), -0x14A); /* AllocSignal */
+ m68k_dreg (&context->regs, 0) = -1;
+ sb->signal = CallLib (context, get_long (4), -0x14A); /* AllocSignal */
if (sb->signal == -1) {
write_log ("bsdsocket: ERROR: Couldn't allocate signal for task 0x%lx.\n", sb->ownertask);
free (sb);
return NULL;
}
- m68k_dreg (regs, 0) = SCRATCHBUFSIZE;
- m68k_dreg (regs, 1) = 0;
+ m68k_dreg (&context->regs, 0) = SCRATCHBUFSIZE;
+ m68k_dreg (&context->regs, 1) = 0;
sb->dtablesize = DEFAULT_DTABLE_SIZE;
/* @@@ check malloc() result */
sb->eintrsigs = 0x1000; /* SIGBREAKF_CTRL_C */
- if (!host_sbinit (sb)) {
+ if (!host_sbinit (context, sb)) {
/* @@@ free everything */
}
+
+ locksigqueue();
+
if (socketbases)
sb->next = socketbases;
socketbases = sb;
+ unlocksigqueue();
+
return sb;
}
return NULL;
}
-struct socketbase *get_socketbase (void)
+STATIC_INLINE struct socketbase *get_socketbase (TrapContext *context)
{
- int i;
- uae_u32 p[sizeof(void*) / 4];
-
- for (i = 0; i < (sizeof p) / 4; i++)
- p[i] = get_long (m68k_areg (regs, 6) + offsetof (struct UAEBSDBase, sb) + i * 4);
- return *((struct socketbase**)p);
+ return get_pointer (m68k_areg (&context->regs, 6) + offsetof (struct UAEBSDBase, sb));
}
-static void free_socketbase (void)
+static void free_socketbase (TrapContext *context)
{
struct socketbase *sb, *nsb;
- if ((sb = get_socketbase ()) != NULL) {
- m68k_dreg (regs, 0) = sb->signal;
- CallLib (get_long (4), -0x150); /* FreeSignal */
+ if ((sb = get_socketbase (context)) != NULL) {
+ m68k_dreg (&context->regs, 0) = sb->signal;
+ CallLib (context, get_long (4), -0x150); /* FreeSignal */
if (sb->hostent) {
- m68k_areg (regs, 1) = sb->hostent;
- m68k_dreg (regs, 0) = sb->hostentsize;
- CallLib (get_long (4), -0xD2); /* FreeMem */
+ m68k_areg (&context->regs, 1) = sb->hostent;
+ m68k_dreg (&context->regs, 0) = sb->hostentsize;
+ CallLib (context, get_long (4), -0xD2); /* FreeMem */
}
if (sb->protoent) {
- m68k_areg (regs, 1) = sb->protoent;
- m68k_dreg (regs, 0) = sb->protoentsize;
- CallLib (get_long (4), -0xD2); /* FreeMem */
+ m68k_areg (&context->regs, 1) = sb->protoent;
+ m68k_dreg (&context->regs, 0) = sb->protoentsize;
+ CallLib (context, get_long (4), -0xD2); /* FreeMem */
}
if (sb->servent) {
- m68k_areg (regs, 1) = sb->servent;
- m68k_dreg (regs, 0) = sb->serventsize;
- CallLib (get_long (4), -0xD2); /* FreeMem */
+ m68k_areg (&context->regs, 1) = sb->servent;
+ m68k_dreg (&context->regs, 0) = sb->serventsize;
+ CallLib (context, get_long (4), -0xD2); /* FreeMem */
}
host_sbcleanup (sb);
}
}
-static uae_u32 bsdsocklib_Expunge (void)
+static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *context)
{
TRACE (("Expunge() -> [ignored]\n"));
return 0;
static uae_u32 functable, datatable, inittable;
-#define SOCKETBASE get_socketbase()
-
-static uae_u32 bsdsocklib_Open (void)
+static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context)
{
uae_u32 result = 0;
- int opencount, i;
+ int opencount;
SB;
- uae_u32 p[sizeof (void*) / 4];
-
- locksigqueue ();
TRACE (("OpenLibrary() -> "));
- if ((sb = alloc_socketbase ()) != NULL) {
+ if ((sb = alloc_socketbase (context)) != NULL) {
put_word (SockLibBase + 32, opencount = get_word (SockLibBase + 32) + 1);
- m68k_areg (regs, 0) = functable;
- m68k_areg (regs, 1) = datatable;
- m68k_areg (regs, 2) = 0;
- m68k_dreg (regs, 0) = sizeof (struct UAEBSDBase);
- m68k_dreg (regs, 1) = 0;
- result = CallLib (get_long (4), -0x54); /* MakeLibrary */
+ m68k_areg (&context->regs, 0) = functable;
+ m68k_areg (&context->regs, 1) = datatable;
+ m68k_areg (&context->regs, 2) = 0;
+ m68k_dreg (&context->regs, 0) = sizeof (struct UAEBSDBase);
+ m68k_dreg (&context->regs, 1) = 0;
+ result = CallLib (context, get_long (4), -0x54); /* MakeLibrary */
- *((struct socketbase**)p) = sb;
- for (i = 0; i < (sizeof p) / 4; i++)
- put_long(result + offsetof (struct UAEBSDBase, sb) + i * 4, p[i]);
+ put_pointer (result + offsetof (struct UAEBSDBase, sb), sb);
TRACE (("%0lx [%d]\n", result, opencount));
} else
TRACE (("failed (out of memory)\n"));
- unlocksigqueue ();
-
return result;
}
-static uae_u32 bsdsocklib_Close (void)
+static uae_u32 REGPARAM2 bsdsocklib_Close (TrapContext *context)
{
int opencount;
- uae_u32 base = m68k_areg (regs, 6);
+ uae_u32 base = m68k_areg (&context->regs, 6);
uae_u32 negsize = get_word (base + 16);
- free_socketbase ();
+ free_socketbase (context);
put_word (SockLibBase + 32, opencount = get_word (SockLibBase + 32) - 1);
- m68k_areg (regs, 1) = base - negsize;
- m68k_dreg (regs, 0) = negsize + get_word (base + 18);
- CallLib (get_long (4), -0xD2); /* FreeMem */
+ m68k_areg (&context->regs, 1) = base - negsize;
+ m68k_dreg (&context->regs, 0) = negsize + get_word (base + 18);
+ CallLib (context, get_long (4), -0xD2); /* FreeMem */
TRACE (("CloseLibrary() -> [%d]\n", opencount));
}
/* socket(domain, type, protocol)(d0/d1/d2) */
-static uae_u32 bsdsocklib_socket (void)
+static uae_u32 REGPARAM2 bsdsocklib_socket (TrapContext *context)
{
- return host_socket (SOCKETBASE, m68k_dreg (regs, 0), m68k_dreg (regs, 1),
- m68k_dreg (regs, 2));
+ struct socketbase *sb = get_socketbase (context);
+ return host_socket (sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1),
+ m68k_dreg (&context->regs, 2));
}
/* bind(s, name, namelen)(d0/a0/d1) */
-static uae_u32 bsdsocklib_bind (void)
+static uae_u32 REGPARAM2 bsdsocklib_bind (TrapContext *context)
{
- return host_bind (SOCKETBASE, m68k_dreg (regs, 0), m68k_areg (regs, 0),
- m68k_dreg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_bind (sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0),
+ m68k_dreg (&context->regs, 1));
}
/* listen(s, backlog)(d0/d1) */
-static uae_u32 bsdsocklib_listen (void)
+static uae_u32 REGPARAM2 bsdsocklib_listen (TrapContext *context)
{
- return host_listen (SOCKETBASE, m68k_dreg (regs, 0), m68k_dreg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_listen (sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1));
}
/* accept(s, addr, addrlen)(d0/a0/a1) */
-static uae_u32 bsdsocklib_accept (void)
+static uae_u32 REGPARAM2 bsdsocklib_accept (TrapContext *context)
{
- SB = get_socketbase ();
- host_accept (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ host_accept (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_areg (&context->regs, 1));
return sb->resultval;
}
/* connect(s, name, namelen)(d0/a0/d1) */
-static uae_u32 bsdsocklib_connect (void)
+static uae_u32 REGPARAM2 bsdsocklib_connect (TrapContext *context)
{
- SB = get_socketbase ();
- host_connect (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ host_connect (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 1));
return sb->sb_errno ? -1 : 0;
}
/* sendto(s, msg, len, flags, to, tolen)(d0/a0/d1/d2/a1/d3) */
-static uae_u32 bsdsocklib_sendto (void)
+static uae_u32 REGPARAM2 bsdsocklib_sendto (TrapContext *context)
{
- SB = get_socketbase ();
- host_sendto (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1),
- m68k_dreg (regs, 2), m68k_areg (regs, 1), m68k_dreg (regs, 3));
+ struct socketbase *sb = get_socketbase (context);
+ host_sendto (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 1),
+ m68k_dreg (&context->regs, 2), m68k_areg (&context->regs, 1), m68k_dreg (&context->regs, 3));
return sb->resultval;
}
/* send(s, msg, len, flags)(d0/a0/d1/d2) */
-static uae_u32 bsdsocklib_send (void)
+static uae_u32 REGPARAM2 bsdsocklib_send (TrapContext *context)
{
- SB = get_socketbase ();
- host_sendto (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1),
- m68k_dreg (regs, 2), 0, 0);
+ struct socketbase *sb = get_socketbase (context);
+ host_sendto (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 1),
+ m68k_dreg (&context->regs, 2), 0, 0);
return sb->resultval;
}
/* recvfrom(s, buf, len, flags, from, fromlen)(d0/a0/d1/d2/a1/a2) */
-static uae_u32 bsdsocklib_recvfrom (void)
+static uae_u32 REGPARAM2 bsdsocklib_recvfrom (TrapContext *context)
{
- SB = get_socketbase ();
- host_recvfrom (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1),
- m68k_dreg (regs, 2), m68k_areg (regs, 1), m68k_areg (regs, 2));
+ struct socketbase *sb = get_socketbase (context);
+ host_recvfrom (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 1),
+ m68k_dreg (&context->regs, 2), m68k_areg (&context->regs, 1), m68k_areg (&context->regs, 2));
return sb->resultval;
}
/* recv(s, buf, len, flags)(d0/a0/d1/d2) */
-static uae_u32 bsdsocklib_recv (void)
+static uae_u32 REGPARAM2 bsdsocklib_recv (TrapContext *context)
{
- SB = get_socketbase ();
- host_recvfrom (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_dreg (regs, 1),
- m68k_dreg (regs, 2), 0, 0);
+ struct socketbase *sb = get_socketbase (context);
+ host_recvfrom (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 1),
+ m68k_dreg (&context->regs, 2), 0, 0);
return sb->resultval;
}
/* shutdown(s, how)(d0/d1) */
-static uae_u32 bsdsocklib_shutdown (void)
+static uae_u32 REGPARAM2 bsdsocklib_shutdown (TrapContext *context)
{
- return host_shutdown (SOCKETBASE, m68k_dreg (regs, 0), m68k_dreg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_shutdown (sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1));
}
/* setsockopt(s, level, optname, optval, optlen)(d0/d1/d2/a0/d3) */
-static uae_u32 bsdsocklib_setsockopt (void)
+static uae_u32 REGPARAM2 bsdsocklib_setsockopt (TrapContext *context)
{
- SB = get_socketbase ();
- host_setsockopt (sb, m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2),
- m68k_areg (regs, 0), m68k_dreg (regs, 3));
+ struct socketbase *sb = get_socketbase (context);
+ host_setsockopt (sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2),
+ m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 3));
return sb->resultval;
}
/* getsockopt(s, level, optname, optval, optlen)(d0/d1/d2/a0/a1) */
-static uae_u32 bsdsocklib_getsockopt (void)
+static uae_u32 REGPARAM2 bsdsocklib_getsockopt (TrapContext *context)
{
- return host_getsockopt (SOCKETBASE, m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2),
- m68k_areg (regs, 0), m68k_areg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_getsockopt (sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2),
+ m68k_areg (&context->regs, 0), m68k_areg (&context->regs, 1));
}
/* getsockname(s, hostname, namelen)(d0/a0/a1) */
-static uae_u32 bsdsocklib_getsockname (void)
+static uae_u32 REGPARAM2 bsdsocklib_getsockname (TrapContext *context)
{
- return host_getsockname (SOCKETBASE, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_getsockname (sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_areg (&context->regs, 1));
}
/* getpeername(s, hostname, namelen)(d0/a0/a1) */
-static uae_u32 bsdsocklib_getpeername (void)
+static uae_u32 REGPARAM2 bsdsocklib_getpeername (TrapContext *context)
{
- return host_getpeername (SOCKETBASE, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_getpeername (sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_areg (&context->regs, 1));
}
/* *------ generic system calls related to sockets */
/* IoctlSocket(d, request, argp)(d0/d1/a0) */
-static uae_u32 bsdsocklib_IoctlSocket (void)
+static uae_u32 REGPARAM2 bsdsocklib_IoctlSocket (TrapContext *context)
{
- return host_IoctlSocket (SOCKETBASE, m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_areg (regs, 0));
+ struct socketbase *sb = get_socketbase (context);
+ return host_IoctlSocket (context, sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1), m68k_areg (&context->regs, 0));
}
/* *------ AmiTCP/IP specific stuff */
/* CloseSocket(d)(d0) */
-static uae_u32 bsdsocklib_CloseSocket (void)
+static uae_u32 REGPARAM2 bsdsocklib_CloseSocket (TrapContext *context)
{
- return host_CloseSocket (SOCKETBASE, m68k_dreg (regs, 0));
+ struct socketbase *sb = get_socketbase (context);
+ return host_CloseSocket (context, sb, m68k_dreg (&context->regs, 0));
}
/* WaitSelect(nfds, readfds, writefds, execptfds, timeout, maskp)(d0/a0/a1/a2/a3/d1) */
-static uae_u32 bsdsocklib_WaitSelect (void)
+static uae_u32 REGPARAM2 bsdsocklib_WaitSelect (TrapContext *context)
{
- SB = get_socketbase ();
- host_WaitSelect (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), m68k_areg (regs, 1),
- m68k_areg (regs, 2), m68k_areg (regs, 3), m68k_dreg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ host_WaitSelect (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), m68k_areg (&context->regs, 1),
+ m68k_areg (&context->regs, 2), m68k_areg (&context->regs, 3), m68k_dreg (&context->regs, 1));
return sb->resultval;
}
/* SetSocketSignals(SIGINTR, SIGIO, SIGURG)(d0/d1/d2) */
-static uae_u32 bsdsocklib_SetSocketSignals (void)
+static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals (TrapContext *context)
{
- SB = get_socketbase ();
+ struct socketbase *sb = get_socketbase (context);
- TRACE (("SetSocketSignals(0x%08lx,0x%08lx,0x%08lx) -> ", m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2)));
- sb->eintrsigs = m68k_dreg (regs, 0);
- sb->eventsigs = m68k_dreg (regs, 1);
+ TRACE (("SetSocketSignals(0x%08lx,0x%08lx,0x%08lx) -> ", m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2)));
+ sb->eintrsigs = m68k_dreg (&context->regs, 0);
+ sb->eventsigs = m68k_dreg (&context->regs, 1);
return 0;
}
/* SetDTableSize(size)(d0) */
-static uae_u32 bsdsocklib_SetDTableSize (void)
+static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize)
{
- write_log ("bsdsocket: UNSUPPORTED: SetDTableSize()\n");
+ int *newdtable;
+ int *newftable;
+ int i;
+
+ if (newSize < sb->dtablesize) {
+ /* I don't support lowering the size */
+ return 0;
+ }
+
+ newdtable = (int *)malloc(newSize * sizeof(*sb->dtable));
+ newftable = (int *)malloc(newSize * sizeof(*sb->ftable));
+
+ if (newdtable == NULL || newftable == NULL) {
+ sb->resultval = -1;
+ bsdsocklib_seterrno(sb, ENOMEM);
+ return -1;
+ }
+
+ memcpy(newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable));
+ memcpy(newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable));
+ for (i = sb->dtablesize + 1; i < newSize; i++)
+ newdtable[i] = -1;
+
+ sb->dtablesize = newSize;
+ free(sb->dtable);
+ free(sb->ftable);
+ sb->dtable = newdtable;
+ sb->ftable = newftable;
+ sb->resultval = 0;
return 0;
}
}
/* ObtainSocket(id, domain, type, protocol)(d0/d1/d2/d3) */
-static uae_u32 bsdsocklib_ObtainSocket (void)
+static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *context)
{
- SB = SOCKETBASE;
+ struct socketbase *sb = get_socketbase (context);
int sd;
long id;
SOCKET_TYPE s;
int i;
- id = m68k_dreg (regs, 0);
+ id = m68k_dreg (&context->regs, 0);
- TRACE (("ObtainSocket(%d,%d,%d,%d) -> ", id, m68k_dreg (regs, 1), m68k_dreg (regs, 2), m68k_dreg (regs, 3)));
+ TRACE (("ObtainSocket(%d,%d,%d,%d) -> ", id, m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2), m68k_dreg (&context->regs, 3)));
i = sockpoolindex (id);
sd = getsd (sb, s);
- sb->ftable[sd - 1] = sockpoolflags[i];
-
TRACE (("%d\n", sd));
- sockpoolids[i] = UNIQUE_ID;
+ if (sd != -1) {
+ sb->ftable[sd - 1] = sockpoolflags[i];
+ sockpoolids[i] = UNIQUE_ID;
+ return sd - 1;
+ }
- return sd-1;
+ return -1;
}
/* ReleaseSocket(fd, id)(d0/d1) */
-static uae_u32 bsdsocklib_ReleaseSocket (void)
+static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context)
{
- SB = SOCKETBASE;
+ struct socketbase *sb = get_socketbase (context);
int sd;
long id;
SOCKET_TYPE s;
int i;
uae_u32 flags;
- sd = m68k_dreg (regs, 0);
- id = m68k_dreg (regs, 1);
+ sd = m68k_dreg (&context->regs, 0);
+ id = m68k_dreg (&context->regs, 1);
sd++;
TRACE (("ReleaseSocket(%d,%d) -> ", sd, id));
}
/* ReleaseCopyOfSocket(fd, id)(d0/d1) */
-static uae_u32 bsdsocklib_ReleaseCopyOfSocket (void)
+static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: ReleaseCopyOfSocket()\n");
return 0;
}
/* Errno()() */
-static uae_u32 bsdsocklib_Errno (void)
+static uae_u32 REGPARAM2 bsdsocklib_Errno (TrapContext *context)
{
- SB = get_socketbase ();
+ struct socketbase *sb = get_socketbase (context);
TRACE (("Errno() -> %d\n", sb->sb_errno));
return sb->sb_errno;
}
/* SetErrnoPtr(errno_p, size)(a0/d0) */
-static uae_u32 bsdsocklib_SetErrnoPtr (void)
+static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *context)
{
- SB = get_socketbase ();
- uae_u32 errnoptr = m68k_areg (regs, 0), size = m68k_dreg (regs, 0);
+ struct socketbase *sb = get_socketbase (context);
+ uae_u32 errnoptr = m68k_areg (&context->regs, 0), size = m68k_dreg (&context->regs, 0);
TRACE (("SetErrnoPtr(0x%lx,%d) -> ", errnoptr, size));
TRACE (("OK\n"));
return 0;
}
- seterrno (sb, 22); /* EINVAL */
+ bsdsocklib_seterrno (sb, 22); /* EINVAL */
return -1;
}
/* *------ inet library calls related to inet address manipulation */
/* Inet_NtoA(in)(d0) */
-static uae_u32 bsdsocklib_Inet_NtoA (void)
+static uae_u32 REGPARAM2 bsdsocklib_Inet_NtoA (TrapContext *context)
{
- return host_Inet_NtoA (SOCKETBASE, m68k_dreg (regs, 0));
+ struct socketbase *sb = get_socketbase (context);
+ return host_Inet_NtoA (context, sb, m68k_dreg (&context->regs, 0));
}
/* inet_addr(cp)(a0) */
-static uae_u32 bsdsocklib_inet_addr (void)
+static uae_u32 REGPARAM2 bsdsocklib_inet_addr (TrapContext *context)
{
- return host_inet_addr (m68k_areg (regs, 0));
+ return host_inet_addr (m68k_areg (&context->regs, 0));
}
/* Inet_LnaOf(in)(d0) */
-static uae_u32 bsdsocklib_Inet_LnaOf (void)
+static uae_u32 REGPARAM2 bsdsocklib_Inet_LnaOf (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: Inet_LnaOf()\n");
return 0;
}
/* Inet_NetOf(in)(d0) */
-static uae_u32 bsdsocklib_Inet_NetOf (void)
+static uae_u32 REGPARAM2 bsdsocklib_Inet_NetOf (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: Inet_NetOf()\n");
return 0;
}
/* Inet_MakeAddr(net, host)(d0/d1) */
-static uae_u32 bsdsocklib_Inet_MakeAddr (void)
+static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: Inet_MakeAddr()\n");
return 0;
}
/* inet_network(cp)(a0) */
-static uae_u32 bsdsocklib_inet_network (void)
+static uae_u32 REGPARAM2 bsdsocklib_inet_network (TrapContext *context)
{
- return host_inet_addr (m68k_areg (regs, 0));
+ return host_inet_addr (m68k_areg (&context->regs, 0));
}
/* *------ gethostbyname etc */
/* gethostbyname(name)(a0) */
-static uae_u32 bsdsocklib_gethostbyname (void)
+static uae_u32 REGPARAM2 bsdsocklib_gethostbyname (TrapContext *context)
{
- SB = get_socketbase ();
- host_gethostbynameaddr (sb, m68k_areg (regs, 0), 0, -1);
- return sb->sb_errno ? 0 : sb->hostent;
+ struct socketbase *sb = get_socketbase (context);
+ host_gethostbynameaddr (context, sb, m68k_areg (&context->regs, 0), 0, -1);
+ return sb->sb_herrno ? 0 : sb->hostent;
}
/* gethostbyaddr(addr, len, type)(a0/d0/d1) */
-static uae_u32 bsdsocklib_gethostbyaddr (void)
+static uae_u32 REGPARAM2 bsdsocklib_gethostbyaddr (TrapContext *context)
{
- SB = get_socketbase ();
- host_gethostbynameaddr (sb, m68k_areg (regs, 0), m68k_dreg (regs, 0), m68k_dreg (regs, 1));
- return sb->sb_errno ? 0 : sb->hostent;
+ struct socketbase *sb = get_socketbase (context);
+ host_gethostbynameaddr (context, sb, m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1));
+ return sb->sb_herrno ? 0 : sb->hostent;
}
/* getnetbyname(name)(a0) */
-static uae_u32 bsdsocklib_getnetbyname (void)
+static uae_u32 REGPARAM2 bsdsocklib_getnetbyname (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: getnetbyname()\n");
return 0;
}
/* getnetbyaddr(net, type)(d0/d1) */
-static uae_u32 bsdsocklib_getnetbyaddr (void)
+static uae_u32 REGPARAM2 bsdsocklib_getnetbyaddr (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: getnetbyaddr()\n");
return 0;
}
/* getservbyname(name, proto)(a0/a1) */
-static uae_u32 bsdsocklib_getservbyname (void)
+static uae_u32 REGPARAM2 bsdsocklib_getservbyname (TrapContext *context)
{
- SB = get_socketbase ();
- host_getservbynameport (sb, m68k_areg (regs, 0), m68k_areg (regs, 1), 0);
+ struct socketbase *sb = get_socketbase (context);
+ host_getservbynameport (context, sb, m68k_areg (&context->regs, 0), m68k_areg (&context->regs, 1), 0);
return sb->sb_errno ? 0 : sb->servent;
}
/* getservbyport(port, proto)(d0/a0) */
-static uae_u32 bsdsocklib_getservbyport (void)
+static uae_u32 REGPARAM2 bsdsocklib_getservbyport (TrapContext *context)
{
- SB = get_socketbase ();
- host_getservbynameport (sb, m68k_dreg (regs, 0), m68k_areg (regs, 0), 1);
+ struct socketbase *sb = get_socketbase (context);
+ host_getservbynameport (context, sb, m68k_dreg (&context->regs, 0), m68k_areg (&context->regs, 0), 1);
return sb->sb_errno ? 0 : sb->servent;
}
/* getprotobyname(name)(a0) */
-static uae_u32 bsdsocklib_getprotobyname (void)
+static uae_u32 REGPARAM2 bsdsocklib_getprotobyname (TrapContext *context)
{
- SB = get_socketbase ();
- host_getprotobyname (sb, m68k_areg (regs, 0));
+ struct socketbase *sb = get_socketbase (context);
+ host_getprotobyname (context, sb, m68k_areg (&context->regs, 0));
return sb->sb_errno ? 0 : sb->protoent;
}
-/* getprotobynumber(proto)(d0) */
-static uae_u32 bsdsocklib_getprotobynumber (void)
+/* getprotobynumber(proto)(d0) */
+static uae_u32 REGPARAM2 bsdsocklib_getprotobynumber (TrapContext *context)
{
- write_log ("bsdsocket: UNSUPPORTED: getprotobynumber()\n");
- return 0;
+ struct socketbase *sb = get_socketbase (context);
+ host_getprotobynumber (context, sb, m68k_dreg (&context->regs, 0));
+ return sb->sb_errno ? 0 : sb->protoent;
}
/* *------ syslog functions */
/* Syslog(level, format, ap)(d0/a0/a1) */
-static uae_u32 bsdsocklib_vsyslog (void)
+static uae_u32 REGPARAM2 bsdsocklib_vsyslog (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: vsyslog()\n");
return 0;
/* *------ AmiTCP/IP 1.1 extensions */
/* Dup2Socket(fd1, fd2)(d0/d1) */
-static uae_u32 bsdsocklib_Dup2Socket (void)
+static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket (TrapContext *context)
{
- return host_dup2socket (SOCKETBASE, m68k_dreg (regs, 0), m68k_dreg (regs, 1));
+ struct socketbase *sb = get_socketbase (context);
+ return host_dup2socket (sb, m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1));
}
-static uae_u32 bsdsocklib_sendmsg (void)
+static uae_u32 REGPARAM2 bsdsocklib_sendmsg (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: sendmsg()\n");
return 0;
}
-static uae_u32 bsdsocklib_recvmsg (void)
+static uae_u32 REGPARAM2 bsdsocklib_recvmsg (TrapContext *context)
{
write_log ("bsdsocket: UNSUPPORTED: recvmsg()\n");
return 0;
}
-static uae_u32 bsdsocklib_gethostname (void)
+static uae_u32 REGPARAM2 bsdsocklib_gethostname (TrapContext *context)
{
- return host_gethostname (m68k_areg (regs, 0), m68k_dreg (regs, 0));
+ return host_gethostname (m68k_areg (&context->regs, 0), m68k_dreg (&context->regs, 0));
}
-static uae_u32 bsdsocklib_gethostid (void)
+static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *context)
{
- write_log ("bsdsocket: WARNING: Process '%s' calls deprecated function gethostid() - returning 127.0.0.1\n", get_real_address (get_long (gettask () + 10)));
+ write_log ("bsdsocket: WARNING: Process '%s' calls deprecated function gethostid() - returning 127.0.0.1\n", get_real_address (get_long (gettask (context) + 10)));
return 0x7f000001;
}
-char *errortexts[] =
+const char *errortexts[] =
{"No error", "Operation not permitted", "No such file or directory",
"No such process", "Interrupted system call", "Input/output error", "Device not configured",
"Argument list too long", "Exec format error", "Bad file descriptor", "No child processes",
uae_u32 number_sys_error = sizeof (errortexts) / sizeof (*errortexts);
-char *herrortexts[] =
+const char *herrortexts[] =
{"No error", "Unknown host", "Host name lookup failure", "Unknown server error",
"No address associated with name"};
}
}
-static uae_u32 bsdsocklib_SocketBaseTagList (void)
+static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
{
- SB = SOCKETBASE;
- uae_u32 tagptr = m68k_areg (regs, 0);
+ struct socketbase *sb = get_socketbase (context);
+ uae_u32 tagptr = m68k_areg (&context->regs, 0);
uae_u32 tagsprocessed = 1;
uae_u32 currtag;
uae_u32 currval;
TRACE (("SBTC_HERRNO),%d", currval));
tagcopy (currtag, currval, tagptr, &sb->sb_herrno);
break;
+ case SBTC_DTABLESIZE:
+ TRACE (("SBTC_DTABLESIZE),0x%lx", currval));
+ if (currtag & 1) {
+ bsdsocklib_SetDTableSize(sb, currval);
+ } else {
+ put_long(tagptr + 4, sb->dtablesize);
+ }
+ break;
case SBTC_ERRNOSTRPTR:
if (currtag & 1) {
TRACE (("ERRNOSTRPTR),invalid"));
return tagsprocessed;
}
-static uae_u32 bsdsocklib_GetSocketEvents (void)
+static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context)
{
- SB = SOCKETBASE;
+#ifdef _WIN32
+ struct socketbase *sb = get_socketbase (context);
int i;
int flags;
- uae_u32 ptr = m68k_areg (regs, 0);
+ uae_u32 ptr = m68k_areg (&context->regs, 0);
TRACE (("GetSocketEvents(0x%x) -> ", ptr));
flags = sb->ftable[sb->eventindex] & SET_ALL;
if (flags) {
sb->ftable[sb->eventindex] &= ~SET_ALL;
- put_long (m68k_areg (regs, 0), flags >> 8);
+ put_long (m68k_areg (&context->regs, 0), flags >> 8);
TRACE (("%d (0x%x)\n", sb->eventindex + 1, flags >> 8));
return sb->eventindex; // xxx
}
}
}
-
+#endif
TRACE (("-1\n"));
return -1;
}
-static uae_u32 bsdsocklib_getdtablesize (void)
+static uae_u32 REGPARAM2 bsdsocklib_getdtablesize (TrapContext *context)
{
- return get_socketbase ()->dtablesize;
+ return get_socketbase (context)->dtablesize;
}
-static uae_u32 bsdsocklib_null (void)
+static uae_u32 REGPARAM2 bsdsocklib_null (TrapContext *context)
{
return 0;
}
-extern uae_u32 sockfuncvecs[];
-
-static uae_u32 bsdsocklib_init (void)
+static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context)
{
uae_u32 tmp1;
int i;
if (SockLibBase)
bsdlib_reset ();
- m68k_areg (regs, 0) = functable;
- m68k_areg (regs, 1) = datatable;
- m68k_areg (regs, 2) = 0;
- m68k_dreg (regs, 0) = sizeof (struct UAEBSDBase);
- m68k_dreg (regs, 1) = 0;
- tmp1 = CallLib (m68k_areg (regs, 6), -0x54); /* MakeLibrary */
+ m68k_areg (&context->regs, 0) = functable;
+ m68k_areg (&context->regs, 1) = datatable;
+ m68k_areg (&context->regs, 2) = 0;
+ m68k_dreg (&context->regs, 0) = LIBRARY_SIZEOF;
+ m68k_dreg (&context->regs, 1) = 0;
+ tmp1 = CallLib (context, m68k_areg (&context->regs, 6), -0x54); /* MakeLibrary */
if (!tmp1) {
write_log ("bsdoscket: FATAL: Cannot create bsdsocket.library!\n");
return 0;
}
- m68k_areg (regs, 1) = tmp1;
- CallLib (m68k_areg (regs, 6), -0x18c); /* AddLibrary */
+ m68k_areg (&context->regs, 1) = tmp1;
+ CallLib (context, m68k_areg (&context->regs, 6), -0x18c); /* AddLibrary */
SockLibBase = tmp1;
/* Install error strings in Amiga memory */
tmp1 += strlen(strErr)+1;
- m68k_dreg (regs, 0) = tmp1;
- m68k_dreg (regs, 1) = 0;
- tmp1 = CallLib (get_long (4), -0xC6); /* AllocMem */
+ m68k_dreg (&context->regs, 0) = tmp1;
+ m68k_dreg (&context->regs, 1) = 0;
+ tmp1 = CallLib (context, get_long (4), -0xC6); /* AllocMem */
if (!tmp1) {
write_log ("bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n");
/* @@@ someone please implement a proper interrupt handler setup here :) */
tmp1 = here ();
- calltrap (deftrap2 (bsdsock_int_handler, TRAPFLAG_EXTRA_STACK | TRAPFLAG_NO_RETVAL, ""));
+ calltrap (deftrap2 (bsdsock_int_handler, TRAPFLAG_EXTRA_STACK | TRAPFLAG_NO_RETVAL, "bsdsock_int_handler"));
dw (0x4ef9);
- dl (get_long (regs.vbr + 0x78));
- put_long (regs.vbr + 0x78, tmp1);
+ dl (get_long (context->regs.vbr + 0x78));
+ put_long (context->regs.vbr + 0x78, tmp1);
- m68k_dreg (regs, 0) = 1;
+ m68k_dreg (&context->regs, 0) = 1;
return 0;
}
host_sbreset ();
}
-uae_u32 (*sockfuncs[])(void) = {
+static const TrapHandler sockfuncs[] = {
bsdsocklib_init, bsdsocklib_Open, bsdsocklib_Close, bsdsocklib_Expunge,
bsdsocklib_socket, bsdsocklib_bind, bsdsocklib_listen, bsdsocklib_accept,
bsdsocklib_connect, bsdsocklib_sendto, bsdsocklib_send, bsdsocklib_recvfrom, bsdsocklib_recv,
bsdsocklib_shutdown, bsdsocklib_setsockopt, bsdsocklib_getsockopt, bsdsocklib_getsockname,
bsdsocklib_getpeername, bsdsocklib_IoctlSocket, bsdsocklib_CloseSocket, bsdsocklib_WaitSelect,
- bsdsocklib_SetSocketSignals, bsdsocklib_SetDTableSize, bsdsocklib_ObtainSocket, bsdsocklib_ReleaseSocket,
+ bsdsocklib_SetSocketSignals, bsdsocklib_getdtablesize, bsdsocklib_ObtainSocket, bsdsocklib_ReleaseSocket,
bsdsocklib_ReleaseCopyOfSocket, bsdsocklib_Errno, bsdsocklib_SetErrnoPtr, bsdsocklib_Inet_NtoA,
bsdsocklib_inet_addr, bsdsocklib_Inet_LnaOf, bsdsocklib_Inet_NetOf, bsdsocklib_Inet_MakeAddr,
bsdsocklib_inet_network, bsdsocklib_gethostbyname, bsdsocklib_gethostbyaddr, bsdsocklib_getnetbyname,
bsdsocklib_GetSocketEvents
};
-uae_u32 sockfuncvecs[sizeof (sockfuncs) / sizeof (*sockfuncs)];
+static const char * const funcnames[] = {
+ "bsdsocklib_init", "bsdsocklib_Open", "bsdsocklib_Close", "bsdsocklib_Expunge",
+ "bsdsocklib_socket", "bsdsocklib_bind", "bsdsocklib_listen", "bsdsocklib_accept",
+ "bsdsocklib_connect", "bsdsocklib_sendto", "bsdsocklib_send", "bsdsocklib_recvfrom", "bsdsocklib_recv",
+ "bsdsocklib_shutdown", "bsdsocklib_setsockopt", "bsdsocklib_getsockopt", "bsdsocklib_getsockname",
+ "bsdsocklib_getpeername", "bsdsocklib_IoctlSocket", "bsdsocklib_CloseSocket", "bsdsocklib_WaitSelect",
+ "bsdsocklib_SetSocketSignals", "bsdsocklib_getdtablesize", "bsdsocklib_ObtainSocket", "bsdsocklib_ReleaseSocket",
+ "bsdsocklib_ReleaseCopyOfSocket", "bsdsocklib_Errno", "bsdsocklib_SetErrnoPtr", "bsdsocklib_Inet_NtoA",
+ "bsdsocklib_inet_addr", "bsdsocklib_Inet_LnaOf", "bsdsocklib_Inet_NetOf", "bsdsocklib_Inet_MakeAddr",
+ "bsdsocklib_inet_network", "bsdsocklib_gethostbyname", "bsdsocklib_gethostbyaddr", "bsdsocklib_getnetbyname",
+ "bsdsocklib_getnetbyaddr", "bsdsocklib_getservbyname", "bsdsocklib_getservbyport", "bsdsocklib_getprotobyname",
+ "bsdsocklib_getprotobynumber", "bsdsocklib_vsyslog", "bsdsocklib_Dup2Socket", "bsdsocklib_sendmsg",
+ "bsdsocklib_recvmsg", "bsdsocklib_gethostname", "bsdsocklib_gethostid", "bsdsocklib_SocketBaseTagList",
+ "bsdsocklib_GetSocketEvents"
+};
+
+static uae_u32 sockfuncvecs[sizeof (sockfuncs) / sizeof (*sockfuncs)];
void bsdlib_install (void)
{
for (i = 0; i < (int) (sizeof (sockfuncs) / sizeof (sockfuncs[0])); i++) {
sockfuncvecs[i] = here ();
- calltrap (deftrap2 (sockfuncs[i], TRAPFLAG_EXTRA_STACK, ""));
+ calltrap (deftrap2 (sockfuncs[i], TRAPFLAG_EXTRA_STACK, funcnames[i]));
dw (RTS);
}
#ifdef CATWEASEL
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "ioport.h"
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
-
/* CDROM MODE 1 EDC/ECC code (from Reed-Solomon library by Heiko Eissfeldt) */
/*****************************************************************/
/* */
/*****************************************************************/
-static uae_u32 EDC_crctable[256] =
+static const uae_u32 EDC_crctable[256] =
{
0x00000000L, 0x90910101L, 0x91210201L, 0x01B00300L,
0x92410401L, 0x02D00500L, 0x03600600L, 0x93F10701L,
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "debug.h"
#include "cdtv.h"
-static uae_u32 dmac_lget (uaecptr) REGPARAM;
-static uae_u32 dmac_wget (uaecptr) REGPARAM;
-static uae_u32 dmac_bget (uaecptr) REGPARAM;
-static void dmac_lput (uaecptr, uae_u32) REGPARAM;
-static void dmac_wput (uaecptr, uae_u32) REGPARAM;
-static void dmac_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 dmac_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 dmac_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 dmac_bget (uaecptr) REGPARAM;
+static void REGPARAM3 dmac_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 dmac_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 dmac_bput (uaecptr, uae_u32) REGPARAM;
static uae_u8 dmacmemory[0x100];
static uae_u8 wd[0x1f];
v = (dmac_bget2 (addr) << 24) | (dmac_bget2 (addr + 1) << 16) |
(dmac_bget2 (addr + 2) << 8) | (dmac_bget2 (addr + 3));
#ifdef CDTV_DEBUG
- write_log ("dmac_lget %08.8X=%08.8X PC=%08.8X\n", addr, v, m68k_getpc());
+ write_log ("dmac_lget %08.8X=%08.8X PC=%08.8X\n", addr, v, M68K_GETPC);
#endif
return v;
}
#endif
v = (dmac_bget2 (addr) << 8) | dmac_bget2 (addr + 1);
#ifdef CDTV_DEBUG
- write_log ("dmac_wget %08.8X=%04.4X PC=%08.8X\n", addr, v, m68k_getpc());
+ write_log ("dmac_wget %08.8X=%04.4X PC=%08.8X\n", addr, v, M68K_GETPC);
#endif
return v;
}
#endif
v = dmac_bget2 (addr);
#ifdef CDTV_DEBUG
- write_log ("dmac_bget %08.8X=%02.2X PC=%08.8X\n", addr, v, m68k_getpc());
+ write_log ("dmac_bget %08.8X=%02.2X PC=%08.8X\n", addr, v, M68K_GETPC);
#endif
return v;
}
special_mem |= S_WRITE;
#endif
#ifdef CDTV_DEBUG
- write_log ("dmac_lput %08.8X=%08.8X PC=%08.8X\n", addr, l, m68k_getpc());
+ write_log ("dmac_lput %08.8X=%08.8X PC=%08.8X\n", addr, l, M68K_GETPC);
#endif
dmac_bput2 (addr, l >> 24);
dmac_bput2 (addr + 1, l >> 16);
special_mem |= S_WRITE;
#endif
#ifdef CDTV_DEBUG
- write_log ("dmac_wput %04.4X=%04.4X PC=%08.8X\n", addr, w & 65535, m68k_getpc());
+ write_log ("dmac_wput %04.4X=%04.4X PC=%08.8X\n", addr, w & 65535, M68K_GETPC);
#endif
dmac_bput2 (addr, w >> 8);
dmac_bput2 (addr + 1, w);
special_mem |= S_WRITE;
#endif
#ifdef CDTV_DEBUG
- write_log ("dmac_bput %08.8X=%02.2X PC=%08.8X\n", addr, b & 255, m68k_getpc());
+ write_log ("dmac_bput %08.8X=%02.2X PC=%08.8X\n", addr, b & 255, M68K_GETPC);
#endif
dmac_bput2 (addr, b);
}
#include <ctype.h>
-#include "config.h"
#include "options.h"
-#include "threaddep/thread.h"
#include "uae.h"
#include "autoconf.h"
#include "events.h"
const char *config_label, *config_help;
};
-static struct cfg_lines opttable[] =
+static const struct cfg_lines opttable[] =
{
{"help", "Prints this help" },
{"config_description", "" },
break;
}
}
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
i++;
}
}
#include "sysdeps.h"
#include <assert.h>
-#include "config.h"
#include "options.h"
-#include "threaddep/thread.h"
#include "events.h"
#include "memory.h"
#include "custom.h"
/* CIA memory access */
-static uae_u32 cia_lget (uaecptr) REGPARAM;
-static uae_u32 cia_wget (uaecptr) REGPARAM;
-static uae_u32 cia_bget (uaecptr) REGPARAM;
-static void cia_lput (uaecptr, uae_u32) REGPARAM;
-static void cia_wput (uaecptr, uae_u32) REGPARAM;
-static void cia_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 cia_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 cia_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 cia_bget (uaecptr) REGPARAM;
+static void REGPARAM3 cia_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 cia_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 cia_bput (uaecptr, uae_u32) REGPARAM;
addrbank cia_bank = {
cia_lget, cia_wget, cia_bget,
};
-#ifdef CD32
-extern uae_u32 akiko_lget (uaecptr addr);
-extern uae_u32 akiko_wget (uaecptr addr);
-extern uae_u32 akiko_bget (uaecptr addr);
-extern void akiko_bput (uaecptr addr, uae_u32 value);
-extern void akiko_wput (uaecptr addr, uae_u32 value);
-extern void akiko_lput (uaecptr addr, uae_u32 value);
-#endif
-
/* e-clock is 10 CPU cycles, 6 cycles low, 4 high
* data transfer happens during 4 high cycles
*/
-
#define ECLOCK_DATA_CYCLE 4
static void cia_wait_pre (void)
if (currprefs.cpu_level == 0 && currprefs.cpu_compatible)
v = (addr & 1) ? regs.irc : regs.irc >> 8;
if (warned > 0) {
- write_log ("cia_bget: unknown CIA address %x PC=%x\n", addr, m68k_getpc());
+ write_log ("cia_bget: unknown CIA address %x PC=%x\n", addr, m68k_getpc(®s));
warned--;
}
break;
if (currprefs.cpu_level == 0 && currprefs.cpu_compatible)
v = regs.irc;
if (warned > 0) {
- write_log ("cia_wget: unknown CIA address %x PC=%x\n", addr, m68k_getpc());
+ write_log ("cia_wget: unknown CIA address %x PC=%x\n", addr, m68k_getpc(®s));
warned--;
}
break;
/* battclock memory access */
-static uae_u32 clock_lget (uaecptr) REGPARAM;
-static uae_u32 clock_wget (uaecptr) REGPARAM;
-static uae_u32 clock_bget (uaecptr) REGPARAM;
-static void clock_lput (uaecptr, uae_u32) REGPARAM;
-static void clock_wput (uaecptr, uae_u32) REGPARAM;
-static void clock_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 clock_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 clock_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 clock_bget (uaecptr) REGPARAM;
+static void REGPARAM3 clock_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 clock_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 clock_bput (uaecptr, uae_u32) REGPARAM;
addrbank clock_bank = {
clock_lget, clock_wget, clock_bget,
}
}
+#ifdef SAVESTATE
+
/* CIA-A and CIA-B save/restore code */
uae_u8 *restore_cia (int num, uae_u8 *src)
*len = dst - dstbak;
return dstbak;
}
+
+#endif /* SAVESTATE */
\ No newline at end of file
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
uae_u32 temp_fp[] = {0,0,0}; /* To convert between FP and <EA> */
/* 128 words, indexed through the low byte of the 68k fpu control word */
-static uae_u16 x86_fpucw[]={
+static const uae_u16 x86_fpucw[]={
0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, 0x137f, /* E-RN */
0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, 0x1f7f, /* E-RZ */
0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, /* E-RD */
0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, 0x177f, /* ?-RD */
0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f, 0x1b7f /* ?-RU */
};
-static int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 };
-static int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 };
+static const int sz1[8] = { 4, 4, 12, 12, 2, 8, 1, 0 };
+static const int sz2[8] = { 4, 4, 12, 12, 2, 8, 2, 0 };
/* return the required floating point precision or -1 for failure, 0=E, 1=S, 2=D */
STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg)
}
#if DEBUG_FPP
- printf ("fscc_opp at %08lx\n", m68k_getpc ());
- fflush (stdout);
+ write_log ("JIT: fscc_opp at %08lx\n", M68K_GETPC);
#endif
-
if (extra&0x20) { /* only cc from 00 to 1f are defined */
FAIL(1);
return;
else {
abort();
if (!comp_fp_adr (opcode)) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (®s, m68k_getpc (®s) - 4);
+ op_illg (opcode, ®s);
}
else
put_byte (ad, cc ? 0xff : 0x00);
}
#if DEBUG_FPP
- printf ("fsave_opp at %08lx\n", m68k_getpc ());
- fflush (stdout);
+ write_log ("JIT: fsave_opp at %08lx\n", M68K_GETPC);
#endif
if (!comp_fp_adr (opcode)) {
- m68k_setpc (m68k_getpc () - 2);
- op_illg (opcode);
+ m68k_setpc (®s, m68k_getpc (®s) - 2);
+ op_illg (opcode, ®s);
return;
}
}
}
if ((opcode & 0x38) == 0x18)
- m68k_areg (regs, opcode & 7) = ad;
+ m68k_areg (®s, opcode & 7) = ad;
if ((opcode & 0x38) == 0x20)
- m68k_areg (regs, opcode & 7) = ad;
+ m68k_areg (®s, opcode & 7) = ad;
}
void comp_frestore_opp (uae_u32 opcode)
}
#if DEBUG_FPP
- printf ("frestore_opp at %08lx\n", m68k_getpc ());
- fflush (stdout);
+ write_log ("frestore_opp at %08lx\n", M68K_GETPC);
#endif
if (!comp_fp_adr (opcode)) {
- m68k_setpc (m68k_getpc () - 2);
- op_illg (opcode);
+ m68k_setpc (®s, m68k_getpc (®s) - 2);
+ op_illg (opcode, ®s);
return;
}
if (currprefs.cpu_level >= 4) {
}
}
if ((opcode & 0x38) == 0x18)
- m68k_areg (regs, opcode & 7) = ad;
+ m68k_areg (®s, opcode & 7) = ad;
if ((opcode & 0x38) == 0x20)
- m68k_areg (regs, opcode & 7) = ad;
+ m68k_areg (®s, opcode & 7) = ad;
}
extern uae_u32 xhex_pi, xhex_exp_1, xhex_l2_e, xhex_ln_2, xhex_ln_10;
#undef LENDFUNC
#define LOWFUNC(flags,mem,nargs,func,args) \
- static __inline__ void do_##func args
+ STATIC_INLINE void do_##func args
#define LENDFUNC(flags,mem,nargs,func,args) \
- static __inline__ void func args \
+ STATIC_INLINE void func args \
{ \
if (LDECISION) { \
lopt_op##nargs##args do_##func, mem, flags); \
static lopt_inst linst[MAXLOPTINST];
static int lopt_index=0;
-static __inline__ int argsize(int type)
+STATIC_INLINE int argsize(int type)
{
return type&SIZEMASK;
}
-static __inline__ int reads_mem(int i) {
+STATIC_INLINE int reads_mem(int i) {
return linst[i].mem & READ;
}
-static __inline__ int access_reg(int i, int r, int mode)
+STATIC_INLINE int access_reg(int i, int r, int mode)
{
int k;
for (k=0;k<linst[i].nargs;k++)
return 0;
}
-static __inline__ int writes_reg(int i, int r)
+STATIC_INLINE_ int writes_reg(int i, int r)
{
return access_reg(i,r,WRITE);
}
-static __inline__ int reads_reg(int i, int r)
+STATIC_INLINE int reads_reg(int i, int r)
{
return access_reg(i,r,READ);
}
-static __inline__ int uses_reg(int i, int r)
+STATIC_INLINE int uses_reg(int i, int r)
{
return access_reg(i,r,RMW);
}
-static __inline__ int writes_mem(int i) {
+STATIC_INLINE int writes_mem(int i) {
return linst[i].mem & WRITE;
}
-static __inline__ int uses_mem(int i)
+STATIC_INLINE int uses_mem(int i)
{
return linst[i].mem & RMW;
}
-static __inline__ int reads_flags(int i) {
+STATIC_INLINE int reads_flags(int i) {
return linst[i].flags & READ;
}
-static __inline__ int writes_flags(int i) {
+STATIC_INLINE int writes_flags(int i) {
return linst[i].flags & WRITE;
}
-static __inline__ int uses_flags(int i)
+STATIC_INLINE int uses_flags(int i)
{
return linst[i].flags & RMW;
}
/* Whether i depends on j */
-static __inline__ int depends_on(int i, int j)
+STATIC_INLINE int depends_on(int i, int j)
{
int n;
static void do_raw_mov_l_rm(W4 d, MEMR s);
-static __inline__ void low_peephole(void)
+STATIC_INLINE void low_peephole(void)
{
int i;
inemit=0;
}
-static __inline__ void low_advance(void)
+STATIC_INLINE void low_advance(void)
{
lopt_index++;
if (lopt_index==MAXLOPTINST)
lopt_emit_all();
}
-static __inline__ void lopt_store_op0(void* lfuncptr, uae_u32 lmem,
+STATIC_INLINE void lopt_store_op0(void* lfuncptr, uae_u32 lmem,
uae_u32 lflags)
{
linst[lopt_index].func=lfuncptr;
low_advance();
}
-static __inline__ void lopt_store_op1(uae_u8 t1, uae_u32 a1,
+STATIC_INLINE void lopt_store_op1(uae_u8 t1, uae_u32 a1,
void* lfuncptr, uae_u32 lmem,
uae_u32 lflags)
{
low_advance();
}
-static __inline__ void lopt_store_op2(uae_u8 t1, uae_u32 a1,
+STATIC_INLINE void lopt_store_op2(uae_u8 t1, uae_u32 a1,
uae_u8 t2, uae_u32 a2,
void* lfuncptr, uae_u32 lmem,
uae_u32 lflags)
low_advance();
}
-static __inline__ void lopt_store_op3(uae_u8 t1, uae_u32 a1,
+STATIC_INLINE void lopt_store_op3(uae_u8 t1, uae_u32 a1,
uae_u8 t2, uae_u32 a2,
uae_u8 t3, uae_u32 a3,
void* lfuncptr, uae_u32 lmem,
low_advance();
}
-static __inline__ void lopt_store_op4(uae_u8 t1, uae_u32 a1,
+STATIC_INLINE void lopt_store_op4(uae_u8 t1, uae_u32 a1,
uae_u8 t2, uae_u32 a2,
uae_u8 t3, uae_u32 a3,
uae_u8 t4, uae_u32 a4,
low_advance();
}
-static __inline__ void lopt_store_op5(uae_u8 t1, uae_u32 a1,
+STATIC_INLINE void lopt_store_op5(uae_u8 t1, uae_u32 a1,
uae_u8 t2, uae_u32 a2,
uae_u8 t3, uae_u32 a3,
uae_u8 t4, uae_u32 a4,
low_advance();
}
-static __inline__ void empty_low_optimizer(void)
+STATIC_INLINE void empty_low_optimizer(void)
{
lopt_emit_all();
}
#else
-static __inline__ void lopt_emit_all(void) {}
-static __inline__ void empty_low_optimizer(void) {}
+#define lopt_emit_all()
+#define empty_low_optimizer()
#endif
#define EBX 3
/* The register in which subroutines return an integer return value */
-#define REG_RESULT 0
+#define REG_RESULT EAX
/* The registers subroutines take their first and second argument in */
-#define REG_PAR1 0
-#define REG_PAR2 2
+#ifdef _WIN32
+/* MSVC __fastcall registers are ECX and EDX */
+#define REG_PAR1 ECX
+#define REG_PAR2 EDX
+#else
+#define REG_PAR1 EAX
+#define REG_PAR2 EDX
+#endif
/* Three registers that are not used for any of the above */
#define REG_NOPAR1 6
#include "compemu_optimizer_x86.c"
-static uae_u16 swap16(uae_u16 x)
+STATIC_INLINE uae_u16 swap16(uae_u16 x)
{
return ((x&0xff00)>>8)|((x&0x00ff)<<8);
}
-static uae_u32 swap32(uae_u32 x)
+STATIC_INLINE uae_u32 swap32(uae_u32 x)
{
return ((x&0xff00)<<8)|((x&0x00ff)<<24)|((x&0xff0000)>>8)|((x&0xff000000)>>24);
}
-static __inline__ int isbyte(uae_s32 x)
+STATIC_INLINE int isbyte(uae_s32 x)
{
return (x>=-128 && x<=127);
}
{
#ifdef JIT_DEBUG
if (d!=MUL_NREG1 || s!=MUL_NREG2) {
- printf("Bad register in IMUL: d=%d, s=%d\n",d,s);
+ write_log("JIT: Bad register in IMUL: d=%d, s=%d\n",d,s);
abort();
}
#endif
{
#ifdef JIT_DEBUG
if (d!=MUL_NREG1 || s!=MUL_NREG2) {
- printf("Bad register in MUL: d=%d, s=%d\n",d,s);
+ write_log("JIT: Bad register in MUL: d=%d, s=%d\n",d,s);
abort();
}
#endif
* Unoptimizable stuff --- jump *
*************************************************************************/
-static __inline__ void raw_call_r(R4 r)
+STATIC_INLINE void raw_call_r(R4 r)
{
lopt_emit_all();
emit_byte(0xff);
emit_byte(0xd0+r);
}
-static __inline__ void raw_jmp_r(R4 r)
+STATIC_INLINE void raw_jmp_r(R4 r)
{
lopt_emit_all();
emit_byte(0xff);
emit_byte(0xe0+r);
}
-static __inline__ void raw_jmp_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m)
+STATIC_INLINE void raw_jmp_m_indexed(uae_u32 base, uae_u32 r, uae_u32 m)
{
int sib;
emit_long(base);
}
-static __inline__ void raw_jmp_m(uae_u32 base)
+STATIC_INLINE void raw_jmp_m(uae_u32 base)
{
lopt_emit_all();
emit_byte(0xff);
emit_long(base);
}
-static __inline__ void raw_call(uae_u32 t)
+STATIC_INLINE void raw_call(uae_u32 t)
{
lopt_emit_all();
emit_byte(0xe8);
emit_long(t-(uae_u32)target-4);
}
-static __inline__ void raw_jmp(uae_u32 t)
+STATIC_INLINE void raw_jmp(uae_u32 t)
{
lopt_emit_all();
emit_byte(0xe9);
emit_long(t-(uae_u32)target-4);
}
-static __inline__ void raw_jl(uae_u32 t)
+STATIC_INLINE void raw_jl(uae_u32 t)
{
lopt_emit_all();
emit_byte(0x0f);
emit_long(t-(uae_u32)target-4);
}
-static __inline__ void raw_jz(uae_u32 t)
+STATIC_INLINE void raw_jz(uae_u32 t)
{
lopt_emit_all();
emit_byte(0x0f);
emit_long(t-(uae_u32)target-4);
}
-static __inline__ void raw_jnz(uae_u32 t)
+STATIC_INLINE void raw_jnz(uae_u32 t)
{
lopt_emit_all();
emit_byte(0x0f);
emit_long(t-(uae_u32)target-4);
}
-static __inline__ void raw_jnz_l_oponly(void)
+STATIC_INLINE void raw_jnz_l_oponly(void)
{
lopt_emit_all();
emit_byte(0x0f);
emit_byte(0x85);
}
-static __inline__ void raw_jcc_l_oponly(int cc)
+STATIC_INLINE void raw_jcc_l_oponly(int cc)
{
lopt_emit_all();
emit_byte(0x0f);
emit_byte(0x80+cc);
}
-static __inline__ void raw_jnz_b_oponly(void)
+STATIC_INLINE void raw_jnz_b_oponly(void)
{
lopt_emit_all();
emit_byte(0x75);
}
-static __inline__ void raw_jz_b_oponly(void)
+STATIC_INLINE void raw_jz_b_oponly(void)
{
lopt_emit_all();
emit_byte(0x74);
}
-static __inline__ void raw_jmp_l_oponly(void)
+STATIC_INLINE void raw_jmp_l_oponly(void)
{
lopt_emit_all();
emit_byte(0xe9);
}
-static __inline__ void raw_jmp_b_oponly(void)
+STATIC_INLINE void raw_jmp_b_oponly(void)
{
lopt_emit_all();
emit_byte(0xeb);
}
-static __inline__ void raw_ret(void)
+STATIC_INLINE void raw_ret(void)
{
lopt_emit_all();
emit_byte(0xc3);
}
-static __inline__ void raw_nop(void)
+STATIC_INLINE void raw_nop(void)
{
lopt_emit_all();
emit_byte(0x90);
#define FLAG_NREG1 0 /* Set to -1 if any register will do */
-static __inline__ void raw_flags_to_reg(int r)
+STATIC_INLINE void raw_flags_to_reg(int r)
{
raw_lahf(0); /* Most flags in AH */
//raw_setcc(r,0); /* V flag in AL */
}
#define FLAG_NREG2 0 /* Set to -1 if any register will do */
-static __inline__ void raw_reg_to_flags(int r)
+STATIC_INLINE void raw_reg_to_flags(int r)
{
raw_cmp_b_ri(r,-127); /* set V */
raw_sahf(0);
/* Apparently, there are enough instructions between flag store and
flag reload to avoid the partial memory stall */
-static __inline__ void raw_load_flagreg(uae_u32 target, uae_u32 r)
+STATIC_INLINE void raw_load_flagreg(uae_u32 target, uae_u32 r)
{
#if 1
raw_mov_l_rm(target,(uae_u32)live.state[r].mem);
#endif
}
-/* FLAGX is byte sized, and we *do* write it at that size */
-static __inline__ void raw_load_flagx(uae_u32 target, uae_u32 r)
+/* FLAGX is word-sized */
+STATIC_INLINE void raw_load_flagx(uae_u32 target, uae_u32 r)
{
- if (live.nat[target].canbyte)
- raw_mov_b_rm(target,(uae_u32)live.state[r].mem);
- else if (live.nat[target].canword)
+ if (live.nat[target].canword)
raw_mov_w_rm(target,(uae_u32)live.state[r].mem);
else
raw_mov_l_rm(target,(uae_u32)live.state[r].mem);
#define NATIVE_FLAG_Z 0x40
#define NATIVE_CC_EQ 4
-static __inline__ void raw_flags_set_zero(int f, int r, int t)
+STATIC_INLINE void raw_flags_set_zero(int f, int r, int t)
{
// FIXME: this is really suboptimal
raw_pushfl();
raw_popfl();
}
-static __inline__ void raw_inc_sp(int off)
+STATIC_INLINE void raw_inc_sp(int off)
{
raw_add_l_ri(4,off);
}
if (r!=-1) {
void* pr=NULL;
#ifdef JIT_DEBUG
- write_log("register was %d, direction was %d, size was %d\n",r,dir,size);
+ write_log("JIT: register was %d, direction was %d, size was %d\n",r,dir,size);
#endif
switch(r) {
#ifdef JIT_DEBUG
if ((addr>=0x10000000 && addr<0x40000000) ||
(addr>=0x50000000)) {
- write_log("Suspicious address 0x%x in SEGV handler.\n",addr);
+ write_log("JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
}
#endif
if (dir==SIG_READ) {
}
}
#ifdef JIT_DEBUG
- write_log("Handled one access!\n");
+ write_log("JIT: Handled one access!\n");
#endif
fflush(stdout);
segvcount++;
#ifdef JIT_DEBUG
if ((addr>=0x10000000 && addr<0x40000000) ||
(addr>=0x50000000)) {
- write_log("Suspicious address 0x%x in SEGV handler.\n",addr);
+ write_log("JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
}
#endif
emit_long((uae_u32)veccode-(uae_u32)target-4);
#ifdef JIT_DEBUG
- write_log("Create jump to %p\n",veccode);
- write_log("Handled one access!\n");
+ write_log("JIT: Create jump to %p\n",veccode);
+ write_log("JIT: Handled one access!\n");
#endif
segvcount++;
(uae_u8*)bi->direct_handler<=i &&
(uae_u8*)bi->nexthandler>i) {
#ifdef JIT_DEBUG
- write_log("deleted trigger (%p<%p<%p) %p\n",
+ write_log("JIT: deleted trigger (%p<%p<%p) %p\n",
bi->handler,
i,
bi->nexthandler,
#endif
invalidate_block(bi);
raise_in_cl_list(bi);
- set_special(0);
+ set_special(®s, 0);
return EXCEPTION_CONTINUE_EXECUTION;
}
bi=bi->next;
(uae_u8*)bi->direct_handler<=i &&
(uae_u8*)bi->nexthandler>i) {
#ifdef JIT_DEBUG
- write_log("deleted trigger (%p<%p<%p) %p\n",
+ write_log("JIT: deleted trigger (%p<%p<%p) %p\n",
bi->handler,
i,
bi->nexthandler,
#endif
invalidate_block(bi);
raise_in_cl_list(bi);
- set_special(0);
+ set_special(®s, 0);
return EXCEPTION_CONTINUE_EXECUTION;
}
bi=bi->next;
}
#ifdef JIT_DEBUG
- write_log("Huh? Could not find trigger!\n");
+ write_log("JIT: Huh? Could not find trigger!\n");
#endif
return EXCEPTION_CONTINUE_EXECUTION;
}
int len=0;
int j;
- write_log("fault address is %08x at %08x\n",sc.cr2,sc.eip);
+ write_log("JIT: fault address is %08x at %08x\n",sc.cr2,sc.eip);
if (!canbang)
- write_log("Not happy! Canbang is 0 in SIGSEGV handler!\n");
+ write_log("JIT: Not happy! Canbang is 0 in SIGSEGV handler!\n");
if (in_handler)
- write_log("Argh --- Am already in a handler. Shouldn't happen!\n");
+ write_log("JIT: Argh --- Am already in a handler. Shouldn't happen!\n");
if (canbang && i>=compiled_code && i<=current_compile_p) {
if (*i==0x66) {
if (r!=-1) {
void* pr=NULL;
- write_log("register was %d, direction was %d, size was %d\n",r,dir,size);
+ write_log("JIT: register was %d, direction was %d, size was %d\n",r,dir,size);
switch(r) {
case 0: pr=&(sc.eax); break;
if ((addr>=0x10000000 && addr<0x40000000) ||
(addr>=0x50000000)) {
- write_log("Suspicious address in %x SEGV handler.\n",addr);
+ write_log("JIT: Suspicious address in %x SEGV handler.\n",addr);
}
if (dir==SIG_READ) {
switch(size) {
default: abort();
}
}
- write_log("Handled one access!\n");
+ write_log("JIT: Handled one access!\n");
fflush(stdout);
segvcount++;
sc.eip+=len;
if ((addr>=0x10000000 && addr<0x40000000) ||
(addr>=0x50000000)) {
- write_log("Suspicious address 0x%x in SEGV handler.\n",addr);
+ write_log("JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
}
target=(uae_u8*)sc.eip;
vecbuf[i]=target[i];
emit_byte(0xe9);
emit_long((uae_u32)veccode-(uae_u32)target-4);
- write_log("Create jump to %p\n",veccode);
+ write_log("JIT: Create jump to %p\n",veccode);
- write_log("Handled one access!\n");
- fflush(stdout);
+ write_log("JIT: Handled one access!\n");
segvcount++;
target=veccode;
if (bi->handler &&
(uae_u8*)bi->direct_handler<=i &&
(uae_u8*)bi->nexthandler>i) {
- write_log("deleted trigger (%p<%p<%p) %p\n",
+ write_log("JIT: deleted trigger (%p<%p<%p) %p\n",
bi->handler,
i,
bi->nexthandler,
bi->pc_p);
invalidate_block(bi);
raise_in_cl_list(bi);
- set_special(0);
+ set_special(®s, 0);
return;
}
bi=bi->next;
if (bi->handler &&
(uae_u8*)bi->direct_handler<=i &&
(uae_u8*)bi->nexthandler>i) {
- write_log("deleted trigger (%p<%p<%p) %p\n",
+ write_log("JIT: deleted trigger (%p<%p<%p) %p\n",
bi->handler,
i,
bi->nexthandler,
bi->pc_p);
invalidate_block(bi);
raise_in_cl_list(bi);
- set_special(0);
+ set_special(®s, 0);
return;
}
bi=bi->next;
}
- write_log("Huh? Could not find trigger!\n");
+ write_log("JIT: Huh? Could not find trigger!\n");
return;
}
}
- write_log("Can't handle access!\n");
+ write_log("JIT: Can't handle access!\n");
for (j=0;j<10;j++) {
- write_log("instruction byte %2d is %02x\n",j,i[j]);
+ write_log("JIT: instruction byte %2d is %02x\n",j,i[j]);
}
#if 0
write_log("Please send the above info (starting at \"fault address\") to\n"
raw_ret();
set_target(tmp);
- ((cpuop_func*)cpuid_space)(0);
+ ((compop_func*)cpuid_space)(0);
if (eax != NULL) *eax = s_eax;
if (ebx != NULL) *ebx = s_ebx;
if (ecx != NULL) *ecx = s_ecx;
*************************************************************************/
-static __inline__ void raw_fp_init(void)
+STATIC_INLINE void raw_fp_init(void)
{
int i;
live.tos=-1; /* Stack is empty */
}
-static __inline__ void raw_fp_cleanup_drop(void)
+STATIC_INLINE void raw_fp_cleanup_drop(void)
{
#if 0
/* using FINIT instead of popping all the entries.
raw_fp_init();
}
-static __inline__ void make_tos(int r)
+STATIC_INLINE void make_tos(int r)
{
int p,q;
live.spos[q]=p;
}
-static __inline__ int stackpos(int r)
+STATIC_INLINE int stackpos(int r)
{
if (live.spos[r]<0)
abort();
if (live.tos<live.spos[r]) {
- printf("Looking for spos for fnreg %d\n",r);
+ write_log("JIT: Looking for spos for fnreg %d\n",r);
abort();
}
return live.tos-live.spos[r];
an argument, because I would expect all arguments to be on the stack already, won't they?
Thus, usereg(s) is always useless and also for every FRW d it's too late here now. PeterK
*/
-static __inline__ void usereg(int r)
+STATIC_INLINE void usereg(int r)
{
if (live.spos[r]<0) {
/* This is called with one FP value in a reg *above* tos,
which it will pop off the stack if necessary */
-static __inline__ void tos_make(int r)
+STATIC_INLINE void tos_make(int r)
{
if (live.spos[r]<0) {
live.tos++;
}
LENDFUNC(NONE,NONE,1,raw_ftst_r,(FR r))
-static __inline__ void raw_fflags_into_flags(int r)
+STATIC_INLINE void raw_fflags_into_flags(int r)
{
int p;
#define USE_MATCHSTATE 0
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "events.h"
#include "include/memory.h"
// %%% BRIAN KING WAS HERE %%%
extern int canbang;
#include <sys/mman.h>
-#include <limits.h> /* for PAGESIZE */
-cpuop_func *compfunctbl[65536];
-cpuop_func *nfcompfunctbl[65536];
+compop_func *compfunctbl[65536];
+compop_func *nfcompfunctbl[65536];
#ifdef NOFLAGS_SUPPORT
-cpuop_func *nfcpufunctbl[65536];
+compop_func *nfcpufunctbl[65536];
#endif
uae_u8* comp_pc_p;
#ifdef NOFLAGS_SUPPORT
/* 68040 */
-extern struct cputbl op_smalltbl_0_nf[];
+extern const struct comptbl op_smalltbl_0_nf[];
#endif
-extern struct cputbl op_smalltbl_0_comp_nf[];
-extern struct cputbl op_smalltbl_0_comp_ff[];
+extern const struct comptbl op_smalltbl_0_comp_nf[];
+extern const struct comptbl op_smalltbl_0_comp_ff[];
#ifdef NOFLAGS_SUPPORT
/* 68020 + 68881 */
-extern struct cputbl op_smalltbl_1_nf[];
+extern const struct cputbl op_smalltbl_1_nf[];
/* 68020 */
-extern struct cputbl op_smalltbl_2_nf[];
+extern const struct cputbl op_smalltbl_2_nf[];
/* 68010 */
-extern struct cputbl op_smalltbl_3_nf[];
+extern const struct cputbl op_smalltbl_3_nf[];
/* 68000 */
-extern struct cputbl op_smalltbl_4_nf[];
+extern const struct cputbl op_smalltbl_4_nf[];
/* 68000 slow but compatible. */
-extern struct cputbl op_smalltbl_5_nf[];
+extern const struct cputbl op_smalltbl_5_nf[];
#endif
static void flush_icache_hard(int n);
*/
-static __inline__ blockinfo* get_blockinfo(uae_u32 cl)
+STATIC_INLINE blockinfo* get_blockinfo(uae_u32 cl)
{
return cache_tags[cl+1].bi;
}
-static __inline__ blockinfo* get_blockinfo_addr(void* addr)
+STATIC_INLINE blockinfo* get_blockinfo_addr(void* addr)
{
blockinfo* bi=get_blockinfo(cacheline(addr));
* All sorts of list related functions for all of the lists *
*******************************************************************/
-static __inline__ void remove_from_cl_list(blockinfo* bi)
+STATIC_INLINE void remove_from_cl_list(blockinfo* bi)
{
uae_u32 cl=cacheline(bi->pc_p);
cache_tags[cl].handler=popall_execute_normal;
}
-static __inline__ void remove_from_list(blockinfo* bi)
+STATIC_INLINE void remove_from_list(blockinfo* bi)
{
if (bi->prev_p)
*(bi->prev_p)=bi->next;
bi->next->prev_p=bi->prev_p;
}
-static __inline__ void remove_from_lists(blockinfo* bi)
+STATIC_INLINE void remove_from_lists(blockinfo* bi)
{
remove_from_list(bi);
remove_from_cl_list(bi);
}
-static __inline__ void add_to_cl_list(blockinfo* bi)
+STATIC_INLINE void add_to_cl_list(blockinfo* bi)
{
uae_u32 cl=cacheline(bi->pc_p);
cache_tags[cl].handler=bi->handler_to_use;
}
-static __inline__ void raise_in_cl_list(blockinfo* bi)
+STATIC_INLINE void raise_in_cl_list(blockinfo* bi)
{
remove_from_cl_list(bi);
add_to_cl_list(bi);
}
-static __inline__ void add_to_active(blockinfo* bi)
+STATIC_INLINE void add_to_active(blockinfo* bi)
{
if (active)
active->prev_p=&(bi->next);
bi->prev_p=&active;
}
-static __inline__ void add_to_dormant(blockinfo* bi)
+STATIC_INLINE void add_to_dormant(blockinfo* bi)
{
if (dormant)
dormant->prev_p=&(bi->next);
bi->prev_p=&dormant;
}
-static __inline__ void remove_dep(dependency* d)
+STATIC_INLINE void remove_dep(dependency* d)
{
if (d->prev_p)
*(d->prev_p)=d->next;
/* This block's code is about to be thrown away, so it no longer
depends on anything else */
-static __inline__ void remove_deps(blockinfo* bi)
+STATIC_INLINE void remove_deps(blockinfo* bi)
{
remove_dep(&(bi->dep[0]));
remove_dep(&(bi->dep[1]));
}
-static __inline__ void adjust_jmpdep(dependency* d, void* a)
+STATIC_INLINE void adjust_jmpdep(dependency* d, void* a)
{
*(d->jmp_off)=(uae_u32)a-((uae_u32)d->jmp_off+4);
}
* Soft flush handling support functions *
********************************************************************/
-static __inline__ void set_dhtu(blockinfo* bi, void* dh)
+STATIC_INLINE void set_dhtu(blockinfo* bi, void* dh)
{
- //printf("bi is %p\n",bi);
+ //write_log("JIT: bi is %p\n",bi);
if (dh!=bi->direct_handler_to_use) {
dependency* x=bi->deplist;
- //printf("bi->deplist=%p\n",bi->deplist);
+ //write_log("JIT: bi->deplist=%p\n",bi->deplist);
while (x) {
- //printf("x is %p\n",x);
- //printf("x->next is %p\n",x->next);
- //printf("x->prev_p is %p\n",x->prev_p);
+ //write_log("JIT: x is %p\n",x);
+ //write_log("JIT: x->next is %p\n",x->next);
+ //write_log("JIT: x->prev_p is %p\n",x->prev_p);
if (x->jmp_off) {
adjust_jmpdep(x,dh);
}
}
-static __inline__ void invalidate_block(blockinfo* bi)
+STATIC_INLINE void invalidate_block(blockinfo* bi)
{
int i;
remove_deps(bi);
}
-static __inline__ void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
+STATIC_INLINE void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
{
blockinfo* tbi=get_blockinfo_addr((void*)target);
Dif(!tbi) {
- printf("Could not create jmpdep!\n");
+ write_log("JIT: Could not create jmpdep!\n");
abort();
}
bi->dep[i].jmp_off=jmpaddr;
tbi->deplist=&(bi->dep[i]);
}
-static __inline__ void big_to_small_state(bigstate* b, smallstate* s)
+STATIC_INLINE void big_to_small_state(bigstate* b, smallstate* s)
{
int i;
int count=0;
count++;
}
}
- printf("count=%d\n",count);
+ write_log("JIT: count=%d\n",count);
for (i=0;i<N_REGS;i++) { // FIXME --- don't do dirty yet
s->nat[i].dirtysize=0;
}
}
-static __inline__ void attached_state(blockinfo* bi)
+STATIC_INLINE void attached_state(blockinfo* bi)
{
bi->havestate=1;
if (bi->direct_handler_to_use==bi->direct_handler)
bi->status=BI_TARGETTED;
}
-static __inline__ blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
+STATIC_INLINE blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
{
blockinfo* bi=get_blockinfo_addr(addr);
int i;
}
}
if (!bi) {
- write_log ("Looking for blockinfo, can't find free one\n");
+ write_log ("JIT: Looking for blockinfo, can't find free one\n");
abort();
}
static void prepare_block(blockinfo* bi);
-static __inline__ void alloc_blockinfos(void)
+STATIC_INLINE void alloc_blockinfos(void)
{
int i;
blockinfo* bi;
if (!currprefs.compforcesettings && !have_done_picasso) {
int stop=0;
if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3)
- stop = 1, write_log("<JIT compiler> : comptrustbyte is not 'direct' or 'afterpic'\n");
+ stop = 1, write_log("JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3)
- stop = 1, write_log("<JIT compiler> : comptrustword is not 'direct' or 'afterpic'\n");
+ stop = 1, write_log("JIT: comptrustword is not 'direct' or 'afterpic'\n");
if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3)
- stop = 1, write_log("<JIT compiler> : comptrustlong is not 'direct' or 'afterpic'\n");
+ stop = 1, write_log("JIT: comptrustlong is not 'direct' or 'afterpic'\n");
if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3)
- stop = 1, write_log("<JIT compiler> : comptrustnaddr is not 'direct' or 'afterpic'\n");
+ stop = 1, write_log("JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
if (currprefs.compnf!=1)
- stop = 1, write_log("<JIT compiler> : compnf is not 'yes'\n");
+ stop = 1, write_log("JIT: compnf is not 'yes'\n");
if (currprefs.cachesize<1024)
- stop = 1, write_log("<JIT compiler> : cachesize is less than 1024\n");
+ stop = 1, write_log("JIT: cachesize is less than 1024\n");
if (currprefs.comp_hardflush)
- stop = 1, write_log("<JIT compiler> : comp_flushmode is 'hard'\n");
+ stop = 1, write_log("JIT: comp_flushmode is 'hard'\n");
if (!canbang)
- stop = 1, write_log("<JIT compiler> : Cannot use most direct memory access,\n"
- " and unable to recover from failed guess!\n");
+ stop = 1, write_log("JIT: Cannot use most direct memory access,\n"
+ " and unable to recover from failed guess!\n");
#if 0
if (stop) {
gui_message("JIT: Configuration problems were detected!\n"
********************************************************************/
#include "compemu_optimizer.c"
+#include "compemu_optimizer_x86.c"
/********************************************************************
* Functions to emit data into memory, and other general support *
{
}
-static __inline__ void emit_byte(uae_u8 x)
+STATIC_INLINE void emit_byte(uae_u8 x)
{
*target++=x;
}
-static __inline__ void emit_word(uae_u16 x)
+STATIC_INLINE void emit_word(uae_u16 x)
{
*((uae_u16*)target)=x;
target+=2;
}
-static __inline__ void emit_long(uae_u32 x)
+STATIC_INLINE void emit_long(uae_u32 x)
{
*((uae_u32*)target)=x;
target+=4;
}
-static __inline__ uae_u32 reverse32(uae_u32 oldv)
+STATIC_INLINE uae_u32 reverse32(uae_u32 oldv)
{
return ((oldv>>24)&0xff) | ((oldv>>8)&0xff00) |
((oldv<<8)&0xff0000) | ((oldv<<24)&0xff000000);
target=t;
}
-static __inline__ uae_u8* get_target_noopt(void)
+STATIC_INLINE uae_u8* get_target_noopt(void)
{
return target;
}
-__inline__ uae_u8* get_target(void)
+STATIC_INLINE uae_u8* get_target(void)
{
lopt_emit_all();
return get_target_noopt();
if (live.flags_in_flags==VALID)
return;
Dif (live.flags_on_stack==TRASH) {
- printf("Want flags, got something on stack, but it is TRASH\n");
+ write_log("JIT: Want flags, got something on stack, but it is TRASH\n");
abort();
}
if (live.flags_on_stack==VALID) {
live.flags_in_flags=VALID;
return;
}
- printf("Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n",
+ write_log("JIT: Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n",
live.flags_in_flags,live.flags_on_stack);
abort();
}
live.flags_on_stack=VALID;
}
-static __inline__ void clobber_flags(void)
+STATIC_INLINE void clobber_flags(void)
{
if (live.flags_in_flags==VALID && live.flags_on_stack!=VALID)
flags_to_stack();
}
/* Prepare for leaving the compiled stuff */
-static __inline__ void flush_flags(void)
+STATIC_INLINE void flush_flags(void)
{
flags_to_stack();
return;
#define L_NEEDED -2
#define L_UNNEEDED -3
-static __inline__ void log_startblock(void)
+STATIC_INLINE void log_startblock(void)
{
int i;
for (i=0;i<VREGS;i++)
nstate[i]=L_UNKNOWN;
}
-static __inline__ void log_isused(int n)
+STATIC_INLINE void log_isused(int n)
{
if (nstate[n]==L_UNKNOWN)
nstate[n]=L_UNAVAIL;
}
-static __inline__ void log_isreg(int n, int r)
+STATIC_INLINE void log_isreg(int n, int r)
{
if (nstate[n]==L_UNKNOWN)
nstate[n]=r;
vstate[r]=L_NEEDED;
}
-static __inline__ void log_clobberreg(int r)
+STATIC_INLINE void log_clobberreg(int r)
{
if (vstate[r]==L_UNKNOWN)
vstate[r]=L_UNNEEDED;
/* This ends all possibility of clever register allocation */
-static __inline__ void log_flush(void)
+STATIC_INLINE void log_flush(void)
{
int i;
for (i=0;i<VREGS;i++)
nstate[i]=L_UNAVAIL;
}
-static __inline__ void log_dump(void)
+STATIC_INLINE void log_dump(void)
{
int i;
* register status handling. EMIT TIME! *
********************************************************************/
-static __inline__ void set_status(int r, int status)
+STATIC_INLINE void set_status(int r, int status)
{
if (status==ISCONST)
log_clobberreg(r);
}
-static __inline__ int isinreg(int r)
+STATIC_INLINE int isinreg(int r)
{
return live.state[r].status==CLEAN || live.state[r].status==DIRTY;
}
-static __inline__ void adjust_nreg(int r, uae_u32 val)
+STATIC_INLINE void adjust_nreg(int r, uae_u32 val)
{
if (!val)
return;
if (live.state[r].val &&
live.nat[rr].nholds==1 &&
!live.nat[rr].locked) {
- // printf("RemovingA offset %x from reg %d (%d) at %p\n",
+ // write_log("JIT: RemovingA offset %x from reg %d (%d) at %p\n",
// live.state[r].val,r,rr,target);
adjust_nreg(rr,live.state[r].val);
live.state[r].val=0;
}
}
-static __inline__ int isconst(int r)
+STATIC_INLINE int isconst(int r)
{
return live.state[r].status==ISCONST;
}
return isconst(r);
}
-static __inline__ void writeback_const(int r)
+STATIC_INLINE void writeback_const(int r)
{
if (!isconst(r))
return;
Dif (live.state[r].needflush==NF_HANDLER) {
- write_log ("Trying to write back constant NF_HANDLER!\n");
+ write_log ("JIT: Trying to write back constant NF_HANDLER!\n");
abort();
}
set_status(r,INMEM);
}
-static __inline__ void tomem_c(int r)
+STATIC_INLINE void tomem_c(int r)
{
if (isconst(r)) {
writeback_const(r);
Dif (live.nat[rr].locked &&
live.nat[rr].nholds==1) {
- write_log ("register %d in nreg %d is locked!\n",r,live.state[r].realreg);
+ write_log ("JIT: register %d in nreg %d is locked!\n",r,live.state[r].realreg);
abort();
}
set_status(r,INMEM);
}
-static __inline__ void free_nreg(int r)
+STATIC_INLINE void free_nreg(int r)
{
int i=live.nat[r].nholds;
evict(vr);
}
Dif (live.nat[r].nholds!=0) {
- printf("Failed to free nreg %d, nholds is %d\n",r,live.nat[r].nholds);
+ write_log("JIT: Failed to free nreg %d, nholds is %d\n",r,live.nat[r].nholds);
abort();
}
}
/* Use with care! */
-static __inline__ void isclean(int r)
+STATIC_INLINE void isclean(int r)
{
if (!isinreg(r))
return;
set_status(r,CLEAN);
}
-static __inline__ void disassociate(int r)
+STATIC_INLINE void disassociate(int r)
{
isclean(r);
evict(r);
}
-static __inline__ void set_const(int r, uae_u32 val)
+STATIC_INLINE void set_const(int r, uae_u32 val)
{
disassociate(r);
live.state[r].val=val;
set_status(r,ISCONST);
}
-static __inline__ uae_u32 get_offset(int r)
+STATIC_INLINE uae_u32 get_offset(int r)
{
return live.state[r].val;
}
}
-static __inline__ void make_exclusive(int r, int size, int spec)
+STATIC_INLINE void make_exclusive(int r, int size, int spec)
{
reg_status oldstate;
int rr=live.state[r].realreg;
}
}
Dif (live.nat[rr].nholds!=1) {
- printf("natreg %d holds %d vregs, %d not exclusive\n",
+ write_log("JIT: natreg %d holds %d vregs, %d not exclusive\n",
rr,live.nat[rr].nholds,r);
abort();
}
unlock(rr);
}
-static __inline__ void add_offset(int r, uae_u32 off)
+STATIC_INLINE void add_offset(int r, uae_u32 off)
{
live.state[r].val+=off;
}
-static __inline__ void remove_offset(int r, int spec)
+STATIC_INLINE void remove_offset(int r, int spec)
{
int rr;
alloc_reg_hinted(r,4,0,spec);
Dif (live.state[r].validsize!=4) {
- printf("Validsize=%d in remove_offset\n",live.state[r].validsize);
+ write_log("JIT: Validsize=%d in remove_offset\n",live.state[r].validsize);
abort();
}
make_exclusive(r,0,-1);
rr=live.state[r].realreg;
if (live.nat[rr].nholds==1) {
- //printf("RemovingB offset %x from reg %d (%d) at %p\n",
+ //write_log("JIT: RemovingB offset %x from reg %d (%d) at %p\n",
// live.state[r].val,r,rr,target);
adjust_nreg(rr,live.state[r].val);
live.state[r].dirtysize=4;
set_status(r,DIRTY);
return;
}
- printf("Failed in remove_offset\n");
+ write_log("JIT: Failed in remove_offset\n");
abort();
}
remove_offset(i,-1);
}
-static __inline__ int readreg_general(int r, int size, int spec, int can_offset)
+STATIC_INLINE int readreg_general(int r, int size, int spec, int can_offset)
{
int n;
int answer=-1;
if (live.state[r].status==UNDEF) {
- printf("WARNING: Unexpected read of undefined register %d\n",r);
+ write_log("JIT: WARNING: Unexpected read of undefined register %d\n",r);
}
if (!can_offset)
remove_offset(r,spec);
}
-static __inline__ int writereg_general(int r, int size, int spec)
+STATIC_INLINE int writereg_general(int r, int size, int spec)
{
int n;
int answer=-1;
}
else {
Dif (live.state[r].val) {
- printf("Problem with val\n");
+ write_log("JIT: Problem with val\n");
abort();
}
}
return writereg_general(r,size,spec);
}
-static __inline__ int rmw_general(int r, int wsize, int rsize, int spec)
+STATIC_INLINE int rmw_general(int r, int wsize, int rsize, int spec)
{
int n;
int answer=-1;
if (live.state[r].status==UNDEF) {
- printf("WARNING: Unexpected read of undefined register %d\n",r);
+ write_log("JIT: WARNING: Unexpected read of undefined register %d\n",r);
}
remove_offset(r,spec);
make_exclusive(r,0,spec);
Dif (wsize<rsize) {
- printf("Cannot handle wsize<rsize in rmw_general()\n");
+ write_log("JIT: Cannot handle wsize<rsize in rmw_general()\n");
abort();
}
if (isinreg(r) && live.state[r].validsize>=rsize) {
live.nat[answer].touched=touchcnt++;
Dif (live.state[r].val) {
- printf("Problem with val(rmw)\n");
+ write_log("JIT: Problem with val(rmw)\n");
abort();
}
return answer;
}
-static __inline__ int f_isinreg(int r)
+STATIC_INLINE int f_isinreg(int r)
{
return live.fate[r].status==CLEAN || live.fate[r].status==DIRTY;
}
Dif (live.fat[rr].locked &&
live.fat[rr].nholds==1) {
- write_log ("FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg);
+ write_log ("JIT: FPU register %d in nreg %d is locked!\n",r,live.fate[r].realreg);
abort();
}
live.fate[r].realreg=-1;
}
-static __inline__ void f_free_nreg(int r)
+STATIC_INLINE void f_free_nreg(int r)
{
int i=live.fat[r].nholds;
f_evict(vr);
}
Dif (live.fat[r].nholds!=0) {
- printf("Failed to free nreg %d, nholds is %d\n",r,live.fat[r].nholds);
+ write_log("JIT: Failed to free nreg %d, nholds is %d\n",r,live.fat[r].nholds);
abort();
}
}
/* Use with care! */
-static __inline__ void f_isclean(int r)
+STATIC_INLINE void f_isclean(int r)
{
if (!f_isinreg(r))
return;
live.fate[r].status=CLEAN;
}
-static __inline__ void f_disassociate(int r)
+STATIC_INLINE void f_disassociate(int r)
{
f_isclean(r);
f_evict(r);
live.fat[r].locked++;
}
-static __inline__ int f_readreg(int r)
+STATIC_INLINE int f_readreg(int r)
{
int n;
int answer=-1;
return answer;
}
-static __inline__ void f_make_exclusive(int r, int clobber)
+STATIC_INLINE void f_make_exclusive(int r, int clobber)
{
freg_status oldstate;
int rr=live.fate[r].realreg;
}
}
Dif (live.fat[rr].nholds!=1) {
- printf("realreg %d holds %d (",rr,live.fat[rr].nholds);
+ write_log("JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
for (i=0;i<live.fat[rr].nholds;i++) {
- printf(" %d(%d,%d)",live.fat[rr].holds[i],
+ write_log("JIT: %d(%d,%d)",live.fat[rr].holds[i],
live.fate[live.fat[rr].holds[i]].realreg,
live.fate[live.fat[rr].holds[i]].realind);
}
- printf("\n");
+ write_log("\n");
abort();
}
return;
}
-static __inline__ int f_writereg(int r)
+STATIC_INLINE int f_writereg(int r)
{
int n;
int answer=-1;
MENDFUNC(0,dont_care_flags,(void))
+/*
+ * Copy m68k C flag into m68k X flag
+ *
+ * FIXME: This needs to be moved into the machdep
+ * part of the source because it depends on what bit
+ * is used to hold X.
+ */
MIDFUNC(0,duplicate_carry,(void))
{
evict(FLAGX);
make_flags_live_internal();
- COMPCALL(setcc_m)((uae_u32)live.state[FLAGX].mem,2);
+ COMPCALL(setcc_m)((uae_u32)live.state[FLAGX].mem + 1,2);
}
MENDFUNC(0,duplicate_carry,(void))
+/*
+ * Set host C flag from m68k X flag.
+ *
+ * FIXME: This needs to be moved into the machdep
+ * part of the source because it depends on what bit
+ * is used to hold X.
+ */
MIDFUNC(0,restore_carry,(void))
{
if (!have_rat_stall) { /* Not a P6 core, i.e. no partial stalls */
- bt_l_ri_noclobber(FLAGX,0);
+ bt_l_ri_noclobber(FLAGX, 8);
}
else { /* Avoid the stall the above creates.
This is slow on non-P6, though.
*/
- COMPCALL(rol_b_ri(FLAGX,8));
+ COMPCALL(rol_w_ri(FLAGX, 8));
isclean(FLAGX);
/* Why is the above faster than the below? */
//raw_rol_b_mi((uae_u32)live.state[FLAGX].mem,8);
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,4,4);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_rol_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_rol_b\n",r);
abort();
}
raw_rol_l_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,2,2);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_rol_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_rol_b\n",r);
abort();
}
raw_rol_w_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,1,1);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_rol_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_rol_b\n",r);
abort();
}
raw_rol_b_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,4,4);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_rol_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_rol_b\n",r);
abort();
}
raw_shll_l_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,2,2);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_shll_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_shll_b\n",r);
abort();
}
raw_shll_w_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,1,1);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_shll_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_shll_b\n",r);
abort();
}
raw_shll_b_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,4,4);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_rol_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_rol_b\n",r);
abort();
}
raw_shrl_l_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,2,2);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_shrl_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_shrl_b\n",r);
abort();
}
raw_shrl_w_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,1,1);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_shrl_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_shrl_b\n",r);
abort();
}
raw_shrl_b_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,4,4);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_rol_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_rol_b\n",r);
abort();
}
raw_shra_l_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,2,2);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_shra_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_shra_b\n",r);
abort();
}
raw_shra_w_rr(d,r) ;
r=readreg_specific(r,1,SHIFTCOUNT_NREG);
d=rmw(d,1,1);
Dif (r!=1) {
- write_log ("Illegal register %d in raw_shra_b\n",r);
+ write_log ("JIT: Illegal register %d in raw_shra_b\n",r);
abort();
}
raw_shra_b_rr(d,r) ;
}
else {
Dif (live.flags_in_flags!=VALID) {
- write_log("setzflg() wanted flags in native flags, they are %d\n",
- live.flags_in_flags);
+ write_log("JIT: setzflg() wanted flags in native flags, they are %d\n",
+ live.flags_in_flags);
abort();
}
r=readreg(r,4);
}
MENDFUNC(3,mov_b_bRr,(R4 d, R1 s, IMM offset))
-MIDFUNC(1,bswap_32,(RW4 r))
+MIDFUNC(1,gen_bswap_32,(RW4 r))
{
int reg=r;
raw_bswap_32(r);
unlock(r);
}
-MENDFUNC(1,bswap_32,(RW4 r))
+MENDFUNC(1,gen_bswap_32,(RW4 r))
-MIDFUNC(1,bswap_16,(RW2 r))
+MIDFUNC(1,gen_bswap_16,(RW2 r))
{
if (isconst(r)) {
uae_u32 oldv=live.state[r].val;
raw_bswap_16(r);
unlock(r);
}
-MENDFUNC(1,bswap_16,(RW2 r))
+MENDFUNC(1,gen_bswap_16,(RW2 r))
live.nat[s].nholds++;
log_clobberreg(d);
- /* printf("Added %d to nreg %d(%d), now holds %d regs\n",
+ /* write_log("JIT: Added %d to nreg %d(%d), now holds %d regs\n",
d,s,live.state[d].realind,live.nat[s].nholds); */
unlock(s);
#else
if (!reg_alloc_run)
#endif
Dif (!isconst(r)) {
- printf("Register %d should be constant, but isn't\n",r);
+ write_log("JIT: Register %d should be constant, but isn't\n",r);
abort();
}
return live.state[r].val;
live.state[PC_P].needflush=NF_TOMEM;
set_const(PC_P,(uae_u32)comp_pc_p);
- live.state[FLAGX].mem=&(regflags.x);
+ live.state[FLAGX].mem=&(regs.ccrflags.x);
live.state[FLAGX].needflush=NF_TOMEM;
set_status(FLAGX,INMEM);
- live.state[FLAGTMP].mem=&(regflags.cznv);
+ live.state[FLAGTMP].mem=&(regs.ccrflags.cznv);
live.state[FLAGTMP].needflush=NF_TOMEM;
set_status(FLAGTMP,INMEM);
int rr;
Dif (vton[i]==-1) {
- printf("Asked to load register %d, but nowhere to go\n",i);
+ write_log("JIT: Asked to load register %d, but nowhere to go\n",i);
abort();
}
n=vton[i];
#if USE_MATCHSTATE
/* This is going to be, amongst other things, a more elaborate version of
flush() */
-static __inline__ void match_states(smallstate* s)
+STATIC_INLINE void match_states(smallstate* s)
{
uae_s8 vton[VREGS];
uae_s8 ndone[N_REGS];
case UNDEF:
break;
default:
- printf("Weird status: %d\n",live.state[i].status);
+ write_log("JIT: Weird status: %d\n",live.state[i].status);
abort();
}
}
int n=live.state[i].realreg;
if (live.nat[n].nholds!=1) {
- printf("Register %d isn't alone in nreg %d\n",
+ write_log("JIT: Register %d isn't alone in nreg %d\n",
i,n);
abort();
}
if (vton[i]==-1) {
- printf("Register %d is still in register, shouldn't be\n",
+ write_log("JIT: Register %d is still in register, shouldn't be\n",
i);
abort();
}
int n=vton[i];
if (n==-1) {
Dif (isinreg(i)) {
- printf("Register %d unexpectedly in nreg %d\n",
+ write_log("JIT: Register %d unexpectedly in nreg %d\n",
i,live.state[i].realreg);
abort();
}
break;
case INMEM:
Dif (live.nat[n].nholds) {
- printf("natreg %d holds %d vregs, should be empty\n",
+ write_log("JIT: natreg %d holds %d vregs, should be empty\n",
n,live.nat[n].nholds);
}
raw_mov_l_rm(n,(uae_u32)live.state[i].mem);
break;
case ISCONST:
if (i!=PC_P) {
- printf("Got constant in matchstate for reg %d. Bad!\n",i);
+ write_log("JIT: Got constant in matchstate for reg %d. Bad!\n",i);
abort();
}
break;
}
}
#else
-static __inline__ void match_states(smallstate* s)
+STATIC_INLINE void match_states(smallstate* s)
{
flush(1);
}
default: break;
}
Dif (live.state[i].val && i!=PC_P) {
- printf("Register %d still has val %x\n",
+ write_log("JIT: Register %d still has val %x\n",
i,live.state[i].val);
}
}
raw_fp_cleanup_drop();
}
if (needflags) {
- printf("Warning! flush with needflags=1!\n");
+ write_log("JIT: Warning! flush with needflags=1!\n");
}
lopt_emit_all();
int i;
for (i=0;i<N_REGS;i++)
if (live.nat[i].locked && i!=4)
- printf("Warning! %d is locked\n",i);
+ write_log("JIT: Warning! %d is locked\n",i);
for (i=0;i<VREGS;i++)
if (live.state[i].needflush==NF_SCRATCH) {
}
extern uae_u8* kickmemory;
-static __inline__ int isinrom(uae_u32 addr)
+STATIC_INLINE int isinrom(uae_u32 addr)
{
return (addr>=(uae_u32)kickmemory &&
addr<(uae_u32)kickmemory+8*65536);
f=source;
switch(size) {
case 1: mov_b_bRr(address,source,NATMEM_OFFSETX); break;
- case 2: mov_w_rr(f,source); bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break;
- case 4: mov_l_rr(f,source); bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break;
+ case 2: mov_w_rr(f,source); gen_bswap_16(f); mov_w_bRr(address,f,NATMEM_OFFSETX); break;
+ case 4: mov_l_rr(f,source); gen_bswap_32(f); mov_l_bRr(address,f,NATMEM_OFFSETX); break;
}
forget_about(tmp);
forget_about(f);
if (size > 1) {
add_l(f,address); /* f now holds the final address */
switch (size) {
- case 2: bswap_16(source); mov_w_Rr(f,source,0);
- bswap_16(source); return;
- case 4: bswap_32(source); mov_l_Rr(f,source,0);
- bswap_32(source); return;
+ case 2: gen_bswap_16(source); mov_w_Rr(f,source,0);
+ gen_bswap_16(source); return;
+ case 4: gen_bswap_32(source); mov_l_Rr(f,source,0);
+ gen_bswap_32(source); return;
}
}
}
switch (size) { /* f now holds the offset */
case 1: mov_b_mrr_indexed(address,f,source); break;
- case 2: bswap_16(source); mov_w_mrr_indexed(address,f,source);
- bswap_16(source); break; /* base, index, source */
- case 4: bswap_32(source); mov_l_mrr_indexed(address,f,source);
- bswap_32(source); break;
+ case 2: gen_bswap_16(source); mov_w_mrr_indexed(address,f,source);
+ gen_bswap_16(source); break; /* base, index, source */
+ case 4: gen_bswap_32(source); mov_l_mrr_indexed(address,f,source);
+ gen_bswap_32(source); break;
}
}
-static __inline__ void writemem(int address, int source, int offset, int size, int tmp)
+STATIC_INLINE void writemem(int address, int source, int offset, int size, int tmp)
{
int f=tmp;
writemem_real(address,source,20,1,tmp,0);
}
-static __inline__ void writeword_general(int address, int source, int tmp,
+STATIC_INLINE void writeword_general(int address, int source, int tmp,
int clobber)
{
int distrust;
writeword_general(address,source,tmp,0);
}
-static __inline__ void writelong_general(int address, int source, int tmp,
+STATIC_INLINE void writelong_general(int address, int source, int tmp,
int clobber)
{
int distrust;
if (canbang) { /* Woohoo! go directly at the memory! */
switch(size) {
case 1: mov_b_brR(dest,address,NATMEM_OFFSETX); break;
- case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); bswap_16(dest); break;
- case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); bswap_32(dest); break;
+ case 2: mov_w_brR(dest,address,NATMEM_OFFSETX); gen_bswap_16(dest); break;
+ case 4: mov_l_brR(dest,address,NATMEM_OFFSETX); gen_bswap_32(dest); break;
}
forget_about(tmp);
return;
switch(size) {
case 1: mov_b_rrm_indexed(dest,address,f); break;
- case 2: mov_w_rrm_indexed(dest,address,f); bswap_16(dest); break;
- case 4: mov_l_rrm_indexed(dest,address,f); bswap_32(dest); break;
+ case 2: mov_w_rrm_indexed(dest,address,f); gen_bswap_16(dest); break;
+ case 4: mov_l_rrm_indexed(dest,address,f); gen_bswap_32(dest); break;
}
forget_about(tmp);
}
-static __inline__ void readmem(int address, int dest, int offset, int size, int tmp)
+STATIC_INLINE void readmem(int address, int dest, int offset, int size, int tmp)
{
int f=tmp;
/* This one might appear a bit odd... */
-static __inline__ void get_n_addr_old(int address, int dest, int tmp)
+STATIC_INLINE void get_n_addr_old(int address, int dest, int tmp)
{
readmem(address,dest,24,4,tmp);
}
-static __inline__ void get_n_addr_real(int address, int dest, int tmp)
+STATIC_INLINE void get_n_addr_real(int address, int dest, int tmp)
{
int f=tmp;
if (address!=dest)
forget_about(tmp);
}
-static __inline__ unsigned int cft_map (unsigned int f)
+STATIC_INLINE unsigned int cft_map (unsigned int f)
{
return ((f >> 8) & 255) | ((f & 255) << 8);
}
}
}
-extern unsigned long op_illg_1 (uae_u32 opcode) REGPARAM;
-
static void calc_checksum(blockinfo* bi, uae_u32* c1, uae_u32* c2)
{
uae_u32 k1=0;
}
else {
while (len>0) {
- printf("%08x ",*pos);
+ write_log("%08x ",*pos);
pos++;
len-=4;
}
- printf(" bla\n");
+ write_log(" bla\n");
}
}
bi->handler_to_use=bi->handler;
set_dhtu(bi,bi->direct_handler);
- /* printf("reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+ /* write_log("JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
c1,c2,bi->c1,bi->c2);*/
remove_from_list(bi);
add_to_active(bi);
else {
/* This block actually changed. We need to invalidate it,
and set it up to be recompiled */
- /* printf("discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+ /* write_log("JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
c1,c2,bi->c1,bi->c2); */
invalidate_block(bi);
raise_in_cl_list(bi);
}
-static __inline__ void create_popalls(void)
+STATIC_INLINE void create_popalls(void)
{
int i,r;
raw_jmp_m_indexed((uae_u32)cache_tags,r,4);
}
-static __inline__ void reset_lists(void)
+STATIC_INLINE void reset_lists(void)
{
int i;
int i;
int jumpcount=0;
unsigned long opcode;
- struct cputbl* tbl=op_smalltbl_0_comp_ff;
- struct cputbl* nftbl=op_smalltbl_0_comp_nf;
+ const struct comptbl* tbl=op_smalltbl_0_comp_ff;
+ const struct comptbl* nftbl=op_smalltbl_0_comp_nf;
int count;
#ifdef NOFLAGS_SUPPORT
- struct cputbl *nfctbl = (currprefs.cpu_level >= 4 ? op_smalltbl_0_nf
+ struct comptbl *nfctbl = (currprefs.cpu_level >= 4 ? op_smalltbl_0_nf
: currprefs.cpu_level == 3 ? op_smalltbl_1_nf
: currprefs.cpu_level == 2 ? op_smalltbl_2_nf
: currprefs.cpu_level == 1 ? op_smalltbl_3_nf
write_log ("JIT: Building Compiler function table\n");
for (opcode = 0; opcode < 65536; opcode++) {
#ifdef NOFLAGS_SUPPORT
- nfcpufunctbl[opcode] = op_illg_1;
+ nfcpufunctbl[opcode] = op_illg;
#endif
compfunctbl[opcode] = NULL;
nfcompfunctbl[opcode] = NULL;
#endif
for (opcode = 0; opcode < 65536; opcode++) {
- cpuop_func *f;
- cpuop_func *nff;
+ compop_func *f;
+ compop_func *nff;
#ifdef NOFLAGS_SUPPORT
- cpuop_func *nfcf;
+ compop_func *nfcf;
#endif
int isjmp,isaddx,iscjmp;
compfunctbl[opcode] = f;
nfcompfunctbl[opcode] = nff;
#ifdef NOFLAGS_SUPPORT
- Dif (nfcf == op_illg_1)
+ Dif (nfcf == op_illg)
abort();
nfcpufunctbl[opcode] = nfcf;
#endif
if (compfunctbl[opcode])
count++;
}
- write_log ("Supposedly %d compileable opcodes!\n",count);
+ write_log ("JIT: Supposedly %d compileable opcodes!\n",count);
/* Initialise state */
alloc_cache();
hard_flush_count++;
#if 0
- printf("Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
+ write_log("JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
n,regs.pc,regs.pc_p,current_compile_p-compiled_code);
#endif
bi=active;
if (!compiled_code)
return;
current_compile_p=compiled_code;
- set_special(0); /* To get out of compiled code */
+ set_special(®s, 0); /* To get out of compiled code */
}
Dif (bi!=bi2) {
/* I don't think it can happen anymore. Shouldn't, in
any case. So let's make sure... */
- printf("WOOOWOO count=%d, ol=%d %p %p\n",
+ write_log("JIT: WOOOWOO count=%d, ol=%d %p %p\n",
bi->count,bi->optlevel,bi->handler_to_use,
cache_tags[cl].handler);
abort();
for (i=0;i<blocklen &&
get_target_noopt()<max_compile_start;i++) {
cpuop_func **cputbl;
- cpuop_func **comptbl;
+ compop_func **comptbl;
uae_u16 opcode;
opcode=cft_map((uae_u16)*pc_hist[i].location);
was_comp=0;
}
raw_mov_l_ri(REG_PAR1,(uae_u32)opcode);
+ raw_mov_l_ri(REG_PAR2,(uae_u32)®s);
#if USE_NORMAL_CALLING_CONVENTION
+ raw_push_l_r(REG_PAR2);
raw_push_l_r(REG_PAR1);
#endif
raw_mov_l_mi((uae_u32)®s.pc_p,
raw_call((uae_u32)cputbl[opcode]);
//raw_add_l_mi((uae_u32)&oink,1); // FIXME
#if USE_NORMAL_CALLING_CONVENTION
- raw_inc_sp(4);
+ raw_inc_sp(8);
#endif
/*if (needed_flags)
raw_mov_l_mi((uae_u32)&foink3,(uae_u32)opcode+65536);
#include <ctype.h>
#include <assert.h>
-#include "config.h"
#include "options.h"
-#include "threaddep/thread.h"
#include "uae.h"
#include "gensound.h"
#include "sounddep/sound.h"
#include "serial.h"
#include "osemu.h"
#include "autoconf.h"
+#include "traps.h"
#include "gui.h"
#include "picasso96.h"
#include "drawing.h"
#include "savestate.h"
#include "ar.h"
+#ifdef AVIOUTPUT
#include "avioutput.h"
+#endif
#include "debug.h"
#include "akiko.h"
#if defined(ENFORCER)
* Hardware registers of all sorts.
*/
-static int custom_wput_1 (int, uaecptr, uae_u32, int) REGPARAM;
+static int REGPARAM3 custom_wput_1 (int, uaecptr, uae_u32, int) REGPARAM;
static uae_u16 cregs[256];
int maxvpos = MAXVPOS_PAL;
int minfirstline = VBLANK_ENDLINE_PAL;
int vblank_hz = VBLANK_HZ_PAL, fake_vblank_hz, vblank_skip;
-unsigned long syncbase;
+frame_time_t syncbase;
static int fmode;
unsigned int beamcon0, new_beamcon0;
uae_u16 vtotal = MAXVPOS_PAL, htotal = MAXHPOS_PAL;
static int fm_maxplane, fm_maxplane_shift;
/* The corresponding values, by fetchmode and display resolution. */
-static int fetchunits[] = { 8,8,8,0, 16,8,8,0, 32,16,8,0 };
-static int fetchstarts[] = { 3,2,1,0, 4,3,2,0, 5,4,3,0 };
-static int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 };
+static const int fetchunits[] = { 8,8,8,0, 16,8,8,0, 32,16,8,0 };
+static const int fetchstarts[] = { 3,2,1,0, 4,3,2,0, 5,4,3,0 };
+static const int fm_maxplanes[] = { 3,2,1,0, 3,3,2,0, 3,3,3,0 };
static int cycle_diagram_table[3][3][9][32];
static int cycle_diagram_free_cycles[3][3][9];
static int cycle_diagram_total_cycles[3][3][9];
static int *curr_diagram;
-static int cycle_sequences[3 * 8] = { 2,1,2,1,2,1,2,1, 4,2,3,1,4,2,3,1, 8,4,6,2,7,3,5,1 };
+static const int cycle_sequences[3 * 8] = { 2,1,2,1,2,1,2,1, 4,2,3,1,4,2,3,1, 8,4,6,2,7,3,5,1 };
static void debug_cycle_diagram(void)
{
{
int fm, res, cycle, planes, rplanes, v;
int fetch_start, max_planes, freecycles;
- int *cycle_sequence;
+ const int *cycle_sequence;
for (fm = 0; fm <= 2; fm++) {
for (res = 0; res <= 2; res++) {
return;
}
#endif
- if (regno < 0)
- write_log("%d\n", regno);
curr_color_changes[next_color_change].linepos = hpos;
curr_color_changes[next_color_change].regno = regno;
curr_color_changes[next_color_change++].value = value;
curr_drawinfo[next_lineno].first_sprite_entry = next_sprite_entry;
next_sprite_forced = 1;
- /* memset(sprite_last_drawn_at, 0, sizeof sprite_last_drawn_at); */
last_sprite_point = 0;
fetch_state = fetch_not_started;
passed_plfstop = 0;
thisline_decision.bplcon3 = bplcon3;
thisline_decision.bplcon4 = bplcon4;
#endif
-
-
}
static int isvsync (void)
if (cnt < 0)
return;
cnt--;
- write_log ("BEAMCON0 = %04.4X VTOTAL=%04.4X HTOTAL=%04.4X\n", new_beamcon0, vtotal, htotal);
+ write_log ("BEAMCON0=%04.4X VTOTAL=%04.4X HTOTAL=%04.4X\n", new_beamcon0, vtotal, htotal);
write_log ("HSSTOP=%04.4X HBSTRT=%04.4X HBSTOP=%04.4X\n", hsstop, hbstrt, hbstop);
write_log ("VSSTOP=%04.4X VBSTRT=%04.4X VBSTOP=%04.4X\n", vsstop, vbstrt, vbstop);
write_log ("HSSTRT=%04.4X VSSTRT=%04.4X HCENTER=%04.4X\n", hsstrt, vsstrt, hcenter);
static int timehack_alive = 0;
-static uae_u32 timehack_helper (void)
+static uae_u32 REGPARAM2 timehack_helper (TrapContext *context)
{
#ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
- if (m68k_dreg (regs, 0) == 0)
+ if (m68k_dreg (&context->regs, 0) == 0)
return timehack_alive;
timehack_alive = 10;
gettimeofday (&tv, NULL);
- put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60));
- put_long (m68k_areg (regs, 0) + 4, tv.tv_usec);
+ put_long (m68k_areg (&context->regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60));
+ put_long (m68k_areg (&context->regs, 0) + 4, tv.tv_usec);
return 0;
#else
return 2;
decide_blitter (current_hpos ());
v = dmacon | (bltstate == BLT_done ? 0 : 0x4000)
| (blt_info.blitzero ? 0x2000 : 0);
-#if 0
- if (!dmaen (DMA_BLITTER))
- v &= ~0x4000;
-#endif
return v;
}
STATIC_INLINE uae_u16 INTENAR (void)
return adkcon;
}
-STATIC_INLINE GETVPOS(void)
+STATIC_INLINE int GETVPOS(void)
{
return vpos_lpen > 0 ? vpos_lpen : (((bplcon0 & 2) && !currprefs.genlock) ? vpos_previous : vpos);
}
-STATIC_INLINE GETHPOS(void)
+STATIC_INLINE int GETHPOS(void)
{
return vpos_lpen > 0 ? hpos_lpen : (((bplcon0 & 2) && !currprefs.genlock) ? hpos_previous : current_hpos ());
}
if (was_active)
events_schedule ();
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
cop_state.ignore_next = 0;
if (!oldstrobe)
cop_state.state_prev = cop_state.state;
if (dmaen (DMA_COPPER)) {
copper_enabled_thisline = 1;
- set_special (SPCFLAG_COPPER);
+ set_special (®s, SPCFLAG_COPPER);
} else if (oldstrobe > 0 && oldstrobe != num && cop_state.state_prev == COP_wait) {
/* dma disabled, copper idle and accessing both COPxJMPs -> copper stops! */
cop_state.state = COP_stop;
compute_spcflag_copper ();
} else if (!newcop) {
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
}
}
if ((dmacon & DMA_BLITPRI) > (oldcon & DMA_BLITPRI) && bltstate != BLT_done) {
count = 1;
write_log ("warning: program is doing blitpri hacks.\n");
}
- set_special (SPCFLAG_BLTNASTY);
+ set_special (®s, SPCFLAG_BLTNASTY);
decide_blitter (hpos);
}
if (dmaen (DMA_BLITTER) && bltstate == BLT_init)
bltstate = BLT_work;
if ((dmacon & (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) != (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) {
- unset_special (SPCFLAG_BLTNASTY);
+ unset_special (®s, SPCFLAG_BLTNASTY);
decide_blitter (hpos);
}
if (changed & (DMA_MASTER | 0x0f))
int i;
if (!(imask && (intena & 0x4000))) {
- unset_special (SPCFLAG_INT);
+ unset_special (®s, SPCFLAG_INT);
return -1;
}
for (i = 14; i >= 0; i--) {
#endif
il = intlev_2 ();
if (il >= 0 && il <= regs.intmask)
- unset_special (SPCFLAG_INT);
+ unset_special (®s, SPCFLAG_INT);
#ifdef JIT
}
#endif
int i;
uae_u16 imask;
- set_special (SPCFLAG_INT);
+ set_special (®s, SPCFLAG_INT);
#ifdef JIT
if (currprefs.cachesize)
return;
maybe_first_bpl1dat (hpos);
}
-#if 0
-/* We could do as well without those... */
-STATIC_INLINE void BPL2DAT (uae_u16 v) { bpl2dat = v; }
-STATIC_INLINE void BPL3DAT (uae_u16 v) { bpl3dat = v; }
-STATIC_INLINE void BPL4DAT (uae_u16 v) { bpl4dat = v; }
-STATIC_INLINE void BPL5DAT (uae_u16 v) { bpl5dat = v; }
-STATIC_INLINE void BPL6DAT (uae_u16 v) { bpl6dat = v; }
-STATIC_INLINE void BPL7DAT (uae_u16 v) { bpl7dat = v; }
-STATIC_INLINE void BPL8DAT (uae_u16 v) { bpl8dat = v; }
-#endif
-
static void DIWSTRT (int hpos, uae_u16 v)
{
if (diwstrt == v && ! diwhigh_written)
clxcon = v;
clxcon_bpl_enable = (v >> 6) & 63;
clxcon_bpl_match = v & 63;
- //write_log("CLXCON: %04.4X PC=%x\n", v, m68k_getpc());
}
static void CLXCON2 (uae_u16 v)
clxcon2 = v;
clxcon_bpl_enable |= v & (0x40|0x80);
clxcon_bpl_match |= (v & (0x01|0x02)) << 6;
- //write_log("CLXCON2: %04.4X\n", v);
}
static uae_u16 CLXDAT (void)
{
uae_u16 v = clxdat | 0x8000;
- //write_log("%d:CLXDAT %04.4X PC=%x\n", vpos, v, m68k_getpc());
clxdat = 0;
return v;
}
if ((address & 0x1fe) < (copcon & 2 ? ((currprefs.chipset_mask & CSMASK_AGA) ? 0 : 0x40u) : 0x80u)) {
cop_state.state = COP_stop;
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
return 1;
}
return 0;
{
unsigned int address = cop_state.saved_i1 & 0x1FE;
+#ifdef DEBUGGER
if (debug_copper)
record_copper (cop_state.saved_ip - 4, old_hpos, vpos);
+#endif
if (test_copper_dangerous (address))
return;
if (cop_state.saved_i1 == 0xFFFF && cop_state.saved_i2 == 0xFFFE) {
cop_state.state = COP_stop;
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
goto out;
}
if (vp < cop_state.vcmp) {
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
goto out;
}
/* We need to wait for the blitter. */
cop_state.state = COP_bltwait;
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
goto out;
}
+#ifdef DEBUGGER
if (debug_copper)
record_copper (cop_state.ip - 4, old_hpos, vpos);
+#endif
cop_state.state = COP_read1;
break;
test_copper_dangerous (chipmem_agnus_wget(cop_state.ip));
}
+#ifdef DEBUGGER
if (debug_copper)
record_copper (cop_state.ip - 4, old_hpos, vpos);
+#endif
break;
}
static void compute_spcflag_copper (void)
{
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special (®s, SPCFLAG_COPPER);
if (!dmaen (DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_bltwait || nocustom())
return;
copper_enabled_thisline = 1;
if (! eventtab[ev_copper].active)
- set_special (SPCFLAG_COPPER);
+ set_special (®s, SPCFLAG_COPPER);
}
static void copper_handler (void)
{
/* This will take effect immediately, within the same cycle. */
- set_special (SPCFLAG_COPPER);
+ set_special (®s, SPCFLAG_COPPER);
if (! copper_enabled_thisline)
uae_abort ("copper_handler");
eventtab[ev_copper].active = 0;
if (do_schedule)
events_schedule ();
- set_special (SPCFLAG_COPPER);
+ set_special (®s, SPCFLAG_COPPER);
}
if (copper_enabled_thisline)
update_copper (hpos);
memset (sprctl, 0, sizeof sprctl);
}
+/*
+ * On systems without virtual memory or with low memory, we allocate the
+ * sprite_entries and color_changes tables dynamically rather than having
+ * them declared static. We don't initially allocate at their maximum sizes;
+ * we start the tables off small and grow them as required.
+ *
+ * This function expands the tables if necessary.
+ */
static void adjust_array_sizes (void)
{
#ifdef OS_WITHOUT_MEMORY_MANAGEMENT
if (delta_sprite_entry) {
- void *p1,*p2;
- int mcc = max_sprite_entry + 50 + delta_sprite_entry;
+ void *p1;
+ void *p2;
+ int mcc = max_sprite_entry + 50 + delta_sprite_entry;
+
delta_sprite_entry = 0;
+
p1 = realloc (sprite_entries[0], mcc * sizeof (struct sprite_entry));
p2 = realloc (sprite_entries[1], mcc * sizeof (struct sprite_entry));
- if (p1) sprite_entries[0] = p1;
- if (p2) sprite_entries[1] = p2;
+
if (p1 && p2) {
- write_log ("new max_sprite_entry=%d\n",mcc);
+ sprite_entries[0] = p1;
+ sprite_entries[1] = p2;
+
+ memset (&sprite_entries[0][max_sprite_entry], (mcc - max_sprite_entry) * sizeof(struct sprite_entry), 0);
+ memset (&sprite_entries[1][max_sprite_entry], (mcc - max_sprite_entry) * sizeof(struct sprite_entry), 0);
+
+ write_log ("New max_sprite_entry=%d\n", mcc);
+
max_sprite_entry = mcc;
- }
+ } else
+ write_log ("WARNING: Failed to enlarge sprite_entries table\n");
}
if (delta_color_change) {
- void *p1,*p2;
- int mcc = max_color_change + 200 + delta_color_change;
+ void *p1;
+ void *p2;
+ int mcc = max_color_change + 200 + delta_color_change;
+
delta_color_change = 0;
+
p1 = realloc (color_changes[0], mcc * sizeof (struct color_change));
p2 = realloc (color_changes[1], mcc * sizeof (struct color_change));
- if (p1) color_changes[0] = p1;
- if (p2) color_changes[1] = p2;
+
if (p1 && p2) {
- write_log ("new max_color_change=%d\n",mcc);
+ color_changes[0] = p1;
+ color_changes[1] = p2;
+
+ write_log ("New max_color_change=%d\n", mcc);
+
max_color_change = mcc;
- }
+ } else
+ write_log ("WARNING: Failed to enlarge color_changes table\n");
}
#endif
}
void init_hardware_for_drawing_frame (void)
{
- adjust_array_sizes ();
-
/* Avoid this code in the first frame after a customreset. */
if (prev_sprite_entries) {
int first_pixel = prev_sprite_entries[0].first_pixel;
next_color_entry = 0;
remembered_color_entry = -1;
+ adjust_array_sizes ();
+
prev_sprite_entries = sprite_entries[current_change_set];
curr_sprite_entries = sprite_entries[current_change_set ^ 1];
prev_color_changes = color_changes[current_change_set];
static void framewait (void)
{
frame_time_t curr_time;
- int start;
+ frame_time_t start;
for (;;) {
double v = rpt_vsync () / (syncbase / 1000.0);
idletime += read_processor_time() - start;
}
-static int frametime2;
+static frame_time_t frametime2;
void fpscounter_reset (void)
{
static void fpscounter (void)
{
- int now, last;
+ frame_time_t now, last;
now = read_processor_time ();
last = now - lastframetime;
return (v & (N_LINES - 1)) == 0;
}
-extern int gonebad;
-
static long int diff32(frame_time_t x, frame_time_t y)
{
return (long int)(x-y);
/* Allow this to be one frame's worth of cycles out */
while (diff32 (curr_time, vsyncmintime + vsynctime) > 0) {
vsyncmintime += vsynctime * N_LINES / maxvpos;
- gonebad++;
if (turbo_emulation)
break;
}
int i;
int zero = 0;
- write_log ("reset at %x\n", m68k_getpc());
+ write_log ("reset at %x\n", m68k_getpc(®s));
hsync_counter = 0;
if (! savestate_state) {
currprefs.chipset_mask = changed_prefs.chipset_mask;
#ifdef JIT
compemu_reset ();
#endif
- unset_special (~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE));
+ unset_special (®s, ~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE));
vpos = 0;
sprite_entries[1][0].first_pixel = MAX_SPR_PIXELS;
sprite_entries[0][1].first_pixel = 0;
sprite_entries[1][1].first_pixel = MAX_SPR_PIXELS;
- memset (spixels, 0, sizeof spixels);
+ memset (spixels, 0, 2 * MAX_SPR_PIXELS * sizeof *spixels);
memset (&spixstate, 0, sizeof spixstate);
bltstate = BLT_done;
}
/* mousehack is now in "filesys boot rom" */
-static uae_u32 mousehack_helper_old (void)
+static uae_u32 REGPARAM2 mousehack_helper_old (struct TrapContext *ctx)
{
return 0;
}
-void custom_init (void)
+static int allocate_sprite_tables (void)
{
-
#ifdef OS_WITHOUT_MEMORY_MANAGEMENT
int num;
- for (num = 0; num < 2; num++) {
- sprite_entries[num] = xmalloc (max_sprite_entry * sizeof (struct sprite_entry));
- color_changes[num] = xmalloc (max_color_change * sizeof (struct color_change));
+ delta_sprite_entry = 0;
+ delta_color_change = 0;
+
+ if (!sprite_entries[0]) {
+ max_sprite_entry = DEFAULT_MAX_SPRITE_ENTRY;
+ max_color_change = DEFAULT_MAX_COLOR_CHANGE;
+
+ for (num = 0; num < 2; num++) {
+ sprite_entries[num] = xmalloc (max_sprite_entry * sizeof (struct sprite_entry));
+ color_changes[num] = xmalloc (max_color_change * sizeof (struct color_change));
+
+ if (sprite_entries[num] && color_changes[num]) {
+ memset (sprite_entries[num], 0, max_sprite_entry * sizeof (struct sprite_entry));
+ memset (color_changes[num], 0, max_color_change * sizeof (struct color_change));
+ } else
+ return 0;
+ }
+ }
+
+ if (!spixels) {
+ spixels = xmalloc (2 * MAX_SPR_PIXELS * sizeof *spixels);
+ if (!spixels)
+ return 0;
}
#endif
+ return 1;
+}
+
+int custom_init (void)
+{
+
+ if (!allocate_sprite_tables())
+ return 0;
#ifdef AUTOCONFIG
{
drawing_init ();
create_cycle_diagram_table ();
+
+ return 1;
}
/* Custom chip memory bank */
-static uae_u32 custom_lget (uaecptr) REGPARAM;
-static uae_u32 custom_wget (uaecptr) REGPARAM;
-static uae_u32 custom_bget (uaecptr) REGPARAM;
-static uae_u32 custom_lgeti (uaecptr) REGPARAM;
-static uae_u32 custom_wgeti (uaecptr) REGPARAM;
-static void custom_lput (uaecptr, uae_u32) REGPARAM;
-static void custom_wput (uaecptr, uae_u32) REGPARAM;
-static void custom_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 custom_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_bget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_lgeti (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_wgeti (uaecptr) REGPARAM;
+static void REGPARAM3 custom_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 custom_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 custom_bput (uaecptr, uae_u32) REGPARAM;
addrbank custom_bank = {
custom_lget, custom_wget, custom_bget,
#endif
case 0x110: BPL1DAT (hpos, value); break;
-#if 0 /* no point */
- case 0x112: BPL2DAT (value); break;
- case 0x114: BPL3DAT (value); break;
- case 0x116: BPL4DAT (value); break;
- case 0x118: BPL5DAT (value); break;
- case 0x11A: BPL6DAT (value); break;
- case 0x11C: BPL7DAT (value); break;
- case 0x11E: BPL8DAT (value); break;
-#endif
case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
#endif
custom_wput (addr & ~1, rval);
if (warned < 10) {
- if (m68k_getpc() < 0xe00000 || m68k_getpc() >= 0x10000000) {
- write_log ("Byte put to custom register %04.4X PC=%08.8X\n", addr, m68k_getpc());
+ if (m68k_getpc(®s) < 0xe00000 || m68k_getpc(®s) >= 0x10000000) {
+ write_log ("Byte put to custom register %04.4X PC=%08.8X\n", addr, m68k_getpc(®s));
warned++;
}
}
custom_wput ((addr + 2) & 0xfffe, (uae_u16)value);
}
+#ifdef SAVESTATE
+
void custom_prepare_savestate (void)
{
}
return src;
}
+#endif /* SAVESTATE */
+
+#if defined SAVESTATE || defined DEBUGGER
+
#define SB save_u8
#define SW save_u16
#define SL save_u32
return dstbak;
}
+#endif /* SAVESTATE || DEBUGGER */
+
+#ifdef SAVESTATE
+
uae_u8 *restore_custom_agacolors (uae_u8 *src)
{
int i;
return dstbak;
}
+#endif /* SAVESTATE */
+
void check_prefs_changed_custom (void)
{
currprefs.gfx_framerate = changed_prefs.gfx_framerate;
}
init_custom ();
}
+#ifdef GFXFILTER
currprefs.gfx_filter_horiz_zoom = changed_prefs.gfx_filter_horiz_zoom;
currprefs.gfx_filter_vert_zoom = changed_prefs.gfx_filter_vert_zoom;
currprefs.gfx_filter_horiz_offset = changed_prefs.gfx_filter_horiz_offset;
currprefs.gfx_filter_vert_offset = changed_prefs.gfx_filter_vert_offset;
currprefs.gfx_filter_scanlines = changed_prefs.gfx_filter_scanlines;
currprefs.gfx_filter_filtermode = changed_prefs.gfx_filter_filtermode;
+#endif
}
#ifdef CPUEMU_6
#include <ctype.h>
#include <signal.h>
-#include "config.h"
#include "options.h"
-#include "threaddep/thread.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "debug.h"
#include "cia.h"
#include "xwin.h"
-#include "gui.h"
#include "identify.h"
#include "sound.h"
#include "disk.h"
if (debugger_active)
return;
debugger_active = 1;
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
debugging = 1;
mmu_triggered = 0;
}
int firsthist = 0;
int lasthist = 0;
static struct regstruct history[MAX_HIST];
-static struct flag_struct historyf[MAX_HIST];
static char help[] = {
" HELP for UAE Debugger\n"
" Cl List currently found trainer addresses\n"
" D Deep trainer\n"
" W <address> <value> Write into Amiga memory\n"
- " w <num> <address> <length> <R/W/RW> [<value>]\n"
+ " w <num> <address> <length> <R/W/RW/F> [<value>]\n"
" Add/remove memory watchpoints\n"
" wd Enable illegal access logger\n"
" S <file> <addr> <n> Save a block of Amiga memory\n"
static void ignore_ws (char **c)
{
- while (**c && isspace(**c)) (*c)++;
+ while (**c && isspace(**c))
+ (*c)++;
}
static uae_u32 readint (char **c);
int val_enabled;
uae_u32 modval;
int modval_written;
+ int frozen;
};
static struct memwatch_node mwnodes[MEMWATCH_TOTAL];
static struct memwatch_node mwhit;
static void illg_debug_do (uaecptr addr, int rw, int size, uae_u32 val)
{
uae_u8 mask;
- uae_u32 pc = m68k_getpc ();
+ uae_u32 pc = m68k_getpc (®s);
char rws = rw ? 'W' : 'R';
int i;
return munge24 (addr) >> 16;
}
-static void memwatch_func (uaecptr addr, int rw, int size, uae_u32 val)
+static int memwatch_func (uaecptr addr, int rw, int size, uae_u32 val)
{
int i, brk;
illg_debug_do (addr, rw, size, val);
addr = munge24 (addr);
for (i = 0; i < MEMWATCH_TOTAL; i++) {
- uaecptr addr2 = mwnodes[i].addr;
- uaecptr addr3 = addr2 + mwnodes[i].size;
- int rw2 = mwnodes[i].rw;
+ struct memwatch_node *m = &mwnodes[i];
+ uaecptr addr2 = m->addr;
+ uaecptr addr3 = addr2 + m->size;
+ int rw2 = m->rw;
brk = 0;
- if (mwnodes[i].size == 0)
+ if (m->size == 0)
continue;
- if (mwnodes[i].val_enabled && mwnodes[i].val != val)
+ if (m->val_enabled && m->val != val)
continue;
if (rw != rw2 && rw2 < 2)
continue;
brk = 1;
if (!brk && size == 4 && ((addr + 2 >= addr2 && addr + 2 < addr3) || (addr + 3 >= addr2 && addr + 3 < addr3)))
brk = 1;
- if (brk && mwnodes[i].modval_written) {
+ if (brk && m->modval_written) {
if (!rw) {
brk = 0;
- } else if (mwnodes[i].modval_written == 1) {
- mwnodes[i].modval_written = 2;
- mwnodes[i].modval = val;
+ } else if (m->modval_written == 1) {
+ m->modval_written = 2;
+ m->modval = val;
brk = 0;
- } else if (mwnodes[i].modval == val) {
+ } else if (m->modval == val) {
brk = 0;
}
}
if (brk) {
+ if (m->frozen)
+ return 0;
mwhit.addr = addr;
mwhit.rw = rw;
mwhit.size = size;
mwhit.val = val;
memwatch_triggered = i + 1;
debugging = 1;
- set_special (SPCFLAG_BRK);
- break;
+ set_special (®s, SPCFLAG_BRK);
+ return 1;
}
}
+ return 1;
}
static int mmu_hit (uaecptr addr, int size, int rw, uae_u32 *v);
-static uae_u32 REGPARAM mmu_lget (uaecptr addr)
+static uae_u32 REGPARAM2 mmu_lget (uaecptr addr)
{
int off = debug_mem_off (addr);
uae_u32 v = 0;
v = debug_mem_banks[off]->lget(addr);
return v;
}
-static uae_u32 REGPARAM mmu_wget (uaecptr addr)
+static uae_u32 REGPARAM2 mmu_wget (uaecptr addr)
{
int off = debug_mem_off (addr);
uae_u32 v = 0;
v = debug_mem_banks[off]->wget(addr);
return v;
}
-static uae_u32 REGPARAM mmu_bget (uaecptr addr)
+static uae_u32 REGPARAM2 mmu_bget (uaecptr addr)
{
int off = debug_mem_off (addr);
uae_u32 v = 0;
debug_mem_banks[off]->bput(addr, v);
}
-static uae_u32 REGPARAM debug_lget (uaecptr addr)
+static uae_u32 REGPARAM2 debug_lget (uaecptr addr)
{
int off = debug_mem_off (addr);
uae_u32 v;
static void REGPARAM2 debug_lput (uaecptr addr, uae_u32 v)
{
int off = debug_mem_off (addr);
- memwatch_func (addr, 1, 4, v);
- debug_mem_banks[off]->lput(addr, v);
+ if (memwatch_func (addr, 1, 4, v))
+ debug_mem_banks[off]->lput(addr, v);
}
static void REGPARAM2 debug_wput (uaecptr addr, uae_u32 v)
{
int off = debug_mem_off (addr);
- memwatch_func (addr, 1, 2, v);
- debug_mem_banks[off]->wput(addr, v);
+ if (memwatch_func (addr, 1, 2, v))
+ debug_mem_banks[off]->wput(addr, v);
}
static void REGPARAM2 debug_bput (uaecptr addr, uae_u32 v)
{
int off = debug_mem_off (addr);
- memwatch_func (addr, 1, 1, v);
- debug_mem_banks[off]->bput(addr, v);
+ if (memwatch_func (addr, 1, 1, v))
+ debug_mem_banks[off]->bput(addr, v);
}
static int REGPARAM2 debug_check (uaecptr addr, uae_u32 size)
continue;
console_out ("%d: %08.8X - %08.8X (%d) %s",
i, mwn->addr, mwn->addr + (mwn->size - 1), mwn->size,
- mwn->rw == 0 ? "R" : (mwn->rw == 1 ? "W" : "RW"));
+ mwn->frozen ? "F" : (mwn->rw == 0 ? "R" : (mwn->rw == 1 ? "W" : "RW")));
if (mwn->val_enabled)
console_out (" =%X", mwn->val);
if (mwn->modval_written)
mwn->size = 1;
mwn->rw = 2;
mwn->val_enabled = 0;
+ mwn->frozen = 0;
mwn->modval_written = 0;
ignore_ws (c);
if (more_params (c)) {
ignore_ws (c);
if (more_params (c)) {
char nc = toupper (next_char (c));
- if (nc == 'W')
+ if (nc == 'F')
+ mwn->frozen = 1;
+ else if (nc == 'W')
mwn->rw = 1;
else if (nc == 'R' && toupper(**c) != 'W')
mwn->rw = 0;
regs.vbr = v;
else if (!strcmp (parm, "USP")) {
regs.usp = v;
- MakeFromSR ();
+ MakeFromSR (®s);
} else if (!strcmp (parm, "ISP")) {
regs.isp = v;
- MakeFromSR ();
+ MakeFromSR (®s);
} else if (!strcmp (parm, "MSP")) {
regs.msp = v;
- MakeFromSR ();
+ MakeFromSR (®s);
} else if (!strcmp (parm, "SR")) {
regs.sr = v;
- MakeFromSR ();
+ MakeFromSR (®s);
} else if (!strcmp (parm, "CCR")) {
regs.sr = (regs.sr & ~15) | (v & 15);
- MakeFromSR ();
+ MakeFromSR (®s);
}
}
skipaddr_doskip = readint (&inptr);
if (skipaddr_doskip <= 0 || skipaddr_doskip > 10000)
skipaddr_doskip = 1;
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
exception_debugging = 1;
return;
case 'z':
case 'g':
if (more_params (&inptr)) {
- m68k_setpc (readhex (&inptr));
- fill_prefetch_slow ();
+ m68k_setpc (®s, readhex (&inptr));
+ fill_prefetch_slow (®s);
}
debugger_active = 0;
debugging = 0;
case 'H':
{
int count, temp, badly;
- uae_u32 oldpc = m68k_getpc();
+ uae_u32 oldpc = m68k_getpc(®s);
struct regstruct save_regs = regs;
- struct flag_struct save_flags = regflags;
badly = 0;
if (inptr[0] == 'H') {
}
while (temp != lasthist) {
regs = history[temp];
- regflags = historyf[temp];
- m68k_setpc(history[temp].pc);
+ m68k_setpc(®s, history[temp].pc);
if (badly) {
m68k_dumpstate(stdout, NULL);
} else {
temp = 0;
}
regs = save_regs;
- regflags = save_flags;
- m68k_setpc(oldpc);
+ m68k_setpc(®s, oldpc);
}
break;
case 'm':
static void addhistory(void)
{
history[lasthist] = regs;
- history[lasthist].pc = m68k_getpc();
- historyf[lasthist] = regflags;
+ history[lasthist].pc = m68k_getpc(®s);
if (++lasthist == MAX_HIST)
lasthist = 0;
if (lasthist == firsthist) {
if (!memwatch_triggered) {
if (do_skip) {
- uae_u32 pc = munge24 (m68k_getpc());
+ uae_u32 pc = munge24 (m68k_getpc(®s));
uae_u16 opcode = (currprefs.cpu_compatible || currprefs.cpu_cycle_exact) ? regs.ir : get_word (pc);
int bp = 0;
}
}
if (!bp) {
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
return;
}
}
if (skipaddr_doskip > 0) {
skipaddr_doskip--;
if (skipaddr_doskip > 0) {
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
return;
}
}
do_skip = 1;
}
if (do_skip) {
- set_special (SPCFLAG_BRK);
- unset_special (SPCFLAG_STOP);
+ set_special (®s, SPCFLAG_BRK);
+ unset_special (®s, SPCFLAG_STOP);
debugging = 1;
}
resume_sound ();
int notinrom (void)
{
- if (munge24 (m68k_getpc()) < 0xe0000)
+ if (munge24 (m68k_getpc(®s)) < 0xe0000)
return 1;
return 0;
}
#define MMU_WRITE_U (1 << 1)
#define MMU_READ_S (1 << 2)
#define MMU_WRITE_S (1 << 3)
-#define MMU_MAP_READ_U (1 << 4)
-#define MMU_MAP_WRITE_U (1 << 5)
-#define MMU_MAP_READ_S (1 << 6)
-#define MMU_MAP_WRITE_S (1 << 7)
+#define MMU_READI_U (1 << 4)
+#define MMU_READI_S (1 << 5)
+
+#define MMU_MAP_READ_U (1 << 8)
+#define MMU_MAP_WRITE_U (1 << 9)
+#define MMU_MAP_READ_S (1 << 10)
+#define MMU_MAP_WRITE_S (1 << 11)
+#define MMU_MAP_READI_U (1 << 12)
+#define MMU_MAP_READI_S (1 << 13)
void mmu_do_hit(void)
{
uae_u32 pc;
mmu_triggered = 0;
- pc = m68k_getpc();
+ pc = m68k_getpc(®s);
p = mmu_regs + 18 * 4;
put_long (p, pc);
regs = mmu_backup_regs;
regs.intmask = 7;
regs.t0 = regs.t1 = 0;
if (!regs.s) {
- regs.usp = m68k_areg(regs, 7);
+ regs.usp = m68k_areg(®s, 7);
if (currprefs.cpu_level >= 2)
- m68k_areg(regs, 7) = regs.m ? regs.msp : regs.isp;
+ m68k_areg(®s, 7) = regs.m ? regs.msp : regs.isp;
else
- m68k_areg(regs, 7) = regs.isp;
+ m68k_areg(®s, 7) = regs.isp;
regs.s = 1;
}
- MakeSR();
- m68k_setpc(mmu_callback);
- fill_prefetch_slow ();
+ MakeSR (®s);
+ m68k_setpc (®s, mmu_callback);
+ fill_prefetch_slow (®s);
if (currprefs.cpu_level > 0) {
for (i = 0 ; i < 9; i++) {
- m68k_areg(regs, 7) -= 4;
- put_long (m68k_areg(regs, 7), 0);
+ m68k_areg(®s, 7) -= 4;
+ put_long (m68k_areg(®s, 7), 0);
}
- m68k_areg(regs, 7) -= 4;
- put_long (m68k_areg(regs, 7), mmu_fault_addr);
- m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), 0); /* WB1S */
- m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), 0); /* WB2S */
- m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), 0); /* WB3S */
- m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7),
+ m68k_areg(®s, 7) -= 4;
+ put_long (m68k_areg(®s, 7), mmu_fault_addr);
+ m68k_areg(®s, 7) -= 2;
+ put_word (m68k_areg(®s, 7), 0); /* WB1S */
+ m68k_areg(®s, 7) -= 2;
+ put_word (m68k_areg(®s, 7), 0); /* WB2S */
+ m68k_areg(®s, 7) -= 2;
+ put_word (m68k_areg(®s, 7), 0); /* WB3S */
+ m68k_areg(®s, 7) -= 2;
+ put_word (m68k_areg(®s, 7),
(mmu_fault_rw ? 0 : 0x100) | (mmu_fault_size << 5)); /* SSW */
- m68k_areg(regs, 7) -= 4;
- put_long (m68k_areg(regs, 7), mmu_fault_bank_addr);
- m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), 0x7002);
+ m68k_areg(®s, 7) -= 4;
+ put_long (m68k_areg(®s, 7), mmu_fault_bank_addr);
+ m68k_areg(®s, 7) -= 2;
+ put_word (m68k_areg(®s, 7), 0x7002);
}
- m68k_areg(regs, 7) -= 4;
- put_long (m68k_areg(regs, 7), get_long (p - 4));
- m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), mmur.sr);
+ m68k_areg(®s, 7) -= 4;
+ put_long (m68k_areg(®s, 7), get_long (p - 4));
+ m68k_areg(®s, 7) -= 2;
+ put_word (m68k_areg(®s, 7), mmur.sr);
- set_special(SPCFLAG_END_COMPILE);
+ set_special(®s, SPCFLAG_END_COMPILE);
}
-static void mmu_do_hit_pre (struct mmudata *md, uaecptr addr, int size, int rw, uae_u32 v)
+static void mmu_do_hit_pre (struct mmudata *md, uaecptr addr, int size, int rwi, uae_u32 v)
{
uae_u32 p, pc;
int i;
mmur = regs;
- pc = m68k_getpc();
+ pc = m68k_getpc(®s);
if (mmu_logging)
- console_out ("MMU: hit %08.8X SZ=%d RW=%d V=%08.8X PC=%08.8X\n", addr, size, rw, v, pc);
+ console_out ("MMU: hit %08.8X SZ=%d RW=%d V=%08.8X PC=%08.8X\n", addr, size, rwi, v, pc);
p = mmu_regs;
put_long (p, 0); p += 4;
put_long (p, regs.isp); p += 4;
put_long (p, regs.msp); p += 4;
put_word (p, regs.sr); p += 2;
- put_word (p, (size << 1) | (rw ? 1 : 0)); /* size and rw */ p += 2;
+ put_word (p, (size << 1) | ((rwi & 2) ? 1 : 0)); /* size and rw */ p += 2;
put_long (p, addr); /* fault address */ p += 4;
put_long (p, md->p_addr); /* bank address */ p += 4;
put_long (p, v); p += 4;
mmu_fault_addr = addr;
mmu_fault_bank_addr = md->p_addr;
mmu_fault_size = size;
- mmu_fault_rw = rw;
+ mmu_fault_rw = rwi;
mmu_triggered = 1;
}
-static int mmu_hit (uaecptr addr, int size, int rw, uae_u32 *v)
+static int mmu_hit (uaecptr addr, int size, int rwi, uae_u32 *v)
{
int s, trig;
uae_u32 flags;
md = mn->mmubank;
if (addr >= md->addr && addr < md->addr + md->len) {
flags = md->flags;
- if (flags & (MMU_MAP_READ_U | MMU_MAP_WRITE_U | MMU_MAP_READ_S | MMU_MAP_WRITE_S)) {
+ if (flags & (MMU_MAP_READ_U | MMU_MAP_WRITE_U | MMU_MAP_READ_S | MMU_MAP_WRITE_S | MMU_MAP_READI_U | MMU_MAP_READI_S)) {
trig = 0;
- if (!s && (flags & MMU_MAP_READ_U) && !rw)
+ if (!s && (flags & MMU_MAP_READ_U) && (rwi & 1))
+ trig = 1;
+ if (!s && (flags & MMU_MAP_WRITE_U) && (rwi & 2))
trig = 1;
- if (!s && (flags & MMU_MAP_WRITE_U) && rw)
+ if (s && (flags & MMU_MAP_READ_S) && (rwi & 1))
trig = 1;
- if (s && (flags & MMU_MAP_READ_S) && !rw)
+ if (s && (flags & MMU_MAP_WRITE_S) && (rwi & 2))
trig = 1;
- if (s && (flags & MMU_MAP_WRITE_S) && rw)
+ if (!s && (flags & MMU_MAP_READI_U) && (rwi & 4))
+ trig = 1;
+ if (s && (flags & MMU_MAP_READI_S) && (rwi & 4))
trig = 1;
if (trig) {
uaecptr maddr = md->remap + (addr - md->addr);
if (maddr == addr) /* infinite mmu hit loop? no thanks.. */
return 1;
if (mmu_logging)
- console_out ("MMU: remap %08.8X -> %08.8X SZ=%d RW=%d\n", addr, maddr, size, rw);
- if (rw) {
+ console_out ("MMU: remap %08.8X -> %08.8X SZ=%d RW=%d\n", addr, maddr, size, rwi);
+ if ((rwi & 2)) {
switch (size)
{
case 4:
return 1;
}
}
- if (flags & (MMU_READ_U | MMU_WRITE_U | MMU_READ_S | MMU_WRITE_S)) {
+ if (flags & (MMU_READ_U | MMU_WRITE_U | MMU_READ_S | MMU_WRITE_S | MMU_READI_U | MMU_READI_S)) {
trig = 0;
- if (!s && (flags & MMU_READ_U) && !rw)
+ if (!s && (flags & MMU_READ_U) && (rwi & 1))
+ trig = 1;
+ if (!s && (flags & MMU_WRITE_U) && (rwi & 2))
+ trig = 1;
+ if (s && (flags & MMU_READ_S) && (rwi & 1))
trig = 1;
- if (!s && (flags & MMU_WRITE_U) && rw)
+ if (s && (flags & MMU_WRITE_S) && (rwi & 2))
trig = 1;
- if (s && (flags & MMU_READ_S) && !rw)
+ if (!s && (flags & MMU_READI_U) && (rwi & 4))
trig = 1;
- if (s && (flags & MMU_WRITE_S) && rw)
+ if (s && (flags & MMU_READI_S) && (rwi & 4))
trig = 1;
if (trig) {
- mmu_do_hit_pre (md, addr, size, rw, *v);
+ mmu_do_hit_pre (md, addr, size, rwi, *v);
return 1;
}
}
initialize_memwatch(1);
console_out ("MMU: enabled, %d banks, CB=%08.8X S=%08.8X BNK=%08.8X SF=%08.8X, %d*%d\n",
size - 1, mmu_callback, parm, banks, mmu_regs, mmu_slots, 1 << MMU_PAGE_SHIFT);
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
return 1;
}
#include "sysdeps.h"
#include "uae.h"
-#include "config.h"
#include "options.h"
-#include "threaddep/thread.h"
#include "memory.h"
#include "events.h"
#include "custom.h"
#include "disk.h"
#include "gui.h"
#include "zfile.h"
-#include "autoconf.h"
#include "newcpu.h"
-#include "xwin.h"
#include "osemu.h"
#include "execlib.h"
#include "savestate.h"
static int get_floppy_speed (void)
{
int m = currprefs.floppy_speed;
- if (m <= 10) m = 100;
+ if (m <= 10)
+ m = 100;
m = NORMAL_FLOPPY_SPEED * 100 / m;
return m;
}
static int step;
if (disk_debug_logging > 1)
- write_log ("%08.8X %02.2X %s", m68k_getpc(), data, tobin(data));
+ write_log ("%08.8X %02.2X %s", M68K_GETPC, data, tobin(data));
lastselected = selected;
selected = (data >> 3) & 15;
st &= ~0x20;
/* dskrdy needs some cycles after switching the motor off.. (Pro Tennis Tour) */
if (drv->motordelay) {
- write_log ("MOTORDELAY! %x\n", m68k_getpc());
+ write_log ("MOTORDELAY! %x\n", M68K_GETPC);
st &= ~0x20;
drv->motordelay = 0;
}
static void disk_dma_debugmsg(void)
{
write_log ("LEN=%04.4X (%d) SYNC=%04.4X PT=%08.8X ADKCON=%04.4X PC=%08.8X\n",
- dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, m68k_getpc());
+ dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, M68K_GETPC);
}
#if 0
if (dskdmaen) {
/* Megalomania and Knightmare does this */
if (disk_debug_logging > 0 && dskdmaen == 2)
- write_log ("warning: Disk read DMA aborted, %d words left PC=%x\n", dsklength, m68k_getpc());
+ write_log ("warning: Disk read DMA aborted, %d words left PC=%x\n", dsklength, M68K_GETPC);
if (dskdmaen == 3)
- write_log ("warning: Disk write DMA aborted, %d words left PC=%x\n", dsklength, m68k_getpc());
+ write_log ("warning: Disk write DMA aborted, %d words left PC=%x\n", dsklength, M68K_GETPC);
dskdmaen = 0;
}
}
#endif
if (count < 5) {
count++;
- write_log ("%04.4X written to DSKDAT. Not good. PC=%08.8X", v, m68k_getpc());
+ write_log ("%04.4X written to DSKDAT. Not good. PC=%08.8X", v, M68K_GETPC);
if (count == 5)
write_log ("(further messages suppressed)");
/* Disk save/restore code */
+#if defined SAVESTATE || defined DEBUGGER
+
void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklength, uae_u16 *pdsksync, uae_u16 *pdskbytr)
{
if(pdskpt) *pdskpt = dskpt;
if(pdskbytr) *pdskbytr = dskbytr_val;
}
+#endif /* SAVESTATE || DEBUGGER */
+
+#ifdef SAVESTATE
+
void DISK_restore_custom (uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr)
{
dskpt = pdskpt;
return dstbak;
}
-
+#endif /* SAVESTATE */
static USHORT Process_Track(struct zfile *, struct zfile *, UCHAR *, UCHAR *, USHORT, USHORT, USHORT);
-static USHORT Unpack_Track(UCHAR *, UCHAR *, USHORT, USHORT, UCHAR, UCHAR);
+static USHORT Unpack_Track(UCHAR *, UCHAR *, USHORT, USHORT, UCHAR, UCHAR, USHORT, USHORT, USHORT);
static void printbandiz(UCHAR *, USHORT);
-static void dms_decrypt(UCHAR *, USHORT);
+static int passfound, passretries;
static char modes[7][7]={"NOCOMP","SIMPLE","QUICK ","MEDIUM","DEEP ","HEAVY1","HEAVY2"};
static USHORT PWDCRC;
UCHAR *text;
-
+static void log_error(int track)
+{
+ write_log ("DMS: Ignored error on track %d!\n", track);
+}
USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT opt, USHORT PCRC, USHORT pwd){
USHORT from, to, geninfo, c_version, cmode, hcrc, disktype, pv, ret;
time_t date;
+ passfound = 0;
+ passretries = 2;
b1 = (UCHAR *)calloc((size_t)TRACK_BUFFER_LEN,1);
if (!b1) return ERR_NOMEMORY;
b2 = (UCHAR *)calloc((size_t)TRACK_BUFFER_LEN,1);
write_log(" ------ ------- ------- ------ ---- ---- ---- -----\n");
}
- if (((cmd==CMD_UNPACK) || (cmd==CMD_SHOWBANNER)) && (geninfo & 2) && (!pwd))
- return ERR_NOPASSWD;
+// if (((cmd==CMD_UNPACK) || (cmd==CMD_SHOWBANNER)) && (geninfo & 2) && (!pwd))
+// return ERR_NOPASSWD;
ret=NO_PROBLEM;
static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR *b2, USHORT cmd, USHORT opt, USHORT pwd){
- USHORT hcrc, dcrc, usum, number, pklen1, pklen2, unpklen, l, r;
+ USHORT hcrc, dcrc, usum, number, pklen1, pklen2, unpklen, l;
UCHAR cmode, flags;
if (zfile_fread(b1,1,(size_t)pklen1,fi) != pklen1) return ERR_SREAD;
- if (CreateCRC(b1,(ULONG)pklen1) != dcrc) return ERR_TDCRC;
-
+ if (CreateCRC(b1,(ULONG)pklen1) != dcrc) {
+ log_error (number);
+ //return ERR_TDCRC;
+ }
/* track 80 is FILEID.DIZ, track 0xffff (-1) is Banner */
/* and track 0 with 1024 bytes only is a fake boot block with more advertising */
/* FILE_ID.DIZ is never encrypted */
- if (pwd && (number!=80)) dms_decrypt(b1,pklen1);
+ //if (pwd && (number!=80)) dms_decrypt(b1,pklen1);
if ((cmd == CMD_UNPACK) && (number<80) && (unpklen>2048)) {
- r = Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags);
- if (r != NO_PROBLEM)
- if (pwd)
- return ERR_BADPASSWD;
- else
- return r;
- if (usum != Calc_CheckSum(b2,(ULONG)unpklen))
- if (pwd)
- return ERR_BADPASSWD;
- else
- return ERR_CSUM;
+ Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum);
if (zfile_fwrite(b2,1,(size_t)unpklen,fo) != unpklen) return ERR_CANTWRITE;
}
if ((cmd == CMD_SHOWBANNER) && (number == 0xffff)){
- r = Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags);
- if (r != NO_PROBLEM)
- if (pwd)
- return ERR_BADPASSWD;
- else
- return r;
- if (usum != Calc_CheckSum(b2,(ULONG)unpklen))
- if (pwd)
- return ERR_BADPASSWD;
- else
- return ERR_CSUM;
+ Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum);
printbandiz(b2,unpklen);
}
if ((cmd == CMD_SHOWDIZ) && (number == 80)) {
- r = Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags);
- if (r != NO_PROBLEM) return r;
- if (usum != Calc_CheckSum(b2,(ULONG)unpklen)) return ERR_CSUM;
+ Unpack_Track(b1, b2, pklen2, unpklen, cmode, flags, number, pklen1, usum);
printbandiz(b2,unpklen);
}
-static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen, UCHAR cmode, UCHAR flags){
+static USHORT Unpack_Track_2(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen, UCHAR cmode, UCHAR flags){
switch (cmode){
case 0:
/* No Compression */
}
-
/* DMS uses a lame encryption */
-static void dms_decrypt(UCHAR *p, USHORT len){
+static void dms_decrypt(UCHAR *p, USHORT len, UCHAR *src){
USHORT t;
while (len--){
- t = (USHORT) *p;
- *p++ ^= (UCHAR)PWDCRC;
+ t = (USHORT) *src++;
+ *p++ = t ^ (UCHAR)PWDCRC;
PWDCRC = (USHORT)((PWDCRC >> 1) + t);
}
}
+static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen, UCHAR cmode, UCHAR flags, USHORT number, USHORT pklen1, USHORT usum1)
+{
+ USHORT r, err = NO_PROBLEM, prevpass;
+ static USHORT pass;
+ int maybeencrypted;
+ int pwrounds;
+ UCHAR *tmp;
+
+ if (passfound) {
+ if (number != 80)
+ dms_decrypt(b1, pklen1, b1);
+ r = Unpack_Track_2(b1, b2, pklen2, unpklen, cmode, flags);
+ if (r == NO_PROBLEM) {
+ if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen))
+ return NO_PROBLEM;
+ }
+ log_error(number);
+ if (passretries <= 0)
+ return ERR_CSUM;
+ }
+
+ passretries--;
+ pwrounds = 0;
+ maybeencrypted = 0;
+ tmp = malloc (pklen1);
+ memcpy (tmp, b1, pklen1);
+ for (;;) {
+ r = Unpack_Track_2(b1, b2, pklen2, unpklen, cmode, flags);
+ if (r == NO_PROBLEM) {
+ if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen)) {
+ passfound = maybeencrypted;
+ if (passfound)
+ write_log("DMS: decryption key = 0x%04.4X\n", pass);
+ err = NO_PROBLEM;
+ pass = prevpass;
+ break;
+ }
+ }
+ if (number == 80) {
+ err = ERR_CSUM;
+ break;
+ }
+ maybeencrypted = 1;
+ prevpass = pass;
+ PWDCRC = pass;
+ pass++;
+ dms_decrypt(b1, pklen1, tmp);
+ pwrounds++;
+ if (pwrounds == 65536) {
+ err = ERR_CSUM;
+ passfound = 0;
+ break;
+ }
+ }
+ free (tmp);
+ return err;
+}
static void printbandiz(UCHAR *m, USHORT len){
- UCHAR *i,*j;
+ UCHAR *i,*j;
i=j=m;
while (i<m+len) {
}
i++;
}
-
}
#include <ctype.h>
#include <assert.h>
-#include "config.h"
#include "options.h"
#include "threaddep/thread.h"
#include "uae.h"
#include "gui.h"
#include "picasso96.h"
#include "drawing.h"
+#ifdef JIT
#include "compemu.h"
+#endif
#include "savestate.h"
int lores_factor, lores_shift;
uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / 4];
} pixdata;
+#ifdef OS_WITHOUT_MEMORY_MANAGEMENT
+uae_u16 *spixels;
+#else
uae_u16 spixels[2 * MAX_SPR_PIXELS];
+#endif
+
/* Eight bits for every pixel. */
union sps_union spixstate;
static uae_u32 ham_linebuf[MAX_PIXELS_PER_LINE * 2];
-char *xlinebuffer;
+uae_u8 *xlinebuffer;
#ifdef XLINECHECK
char *xlinebuffer_start, *xlinebuffer_end;
static void xlinecheck (int start, int end)
#endif
static int *amiga2aspect_line_map, *native2amiga_line_map;
-static char *row_map[MAX_VIDHEIGHT + 1];
+static uae_u8 *row_map[MAX_VIDHEIGHT + 1];
static int max_drawn_amiga_line;
/* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */
static int first_drawn_line, last_drawn_line;
static int first_block_line, last_block_line;
+#define NO_BLOCK -3
+
/* These are generated by the drawing code from the line_decisions array for
each line that needs to be drawn. These are basically extracted out of
bit fields in the hardware registers. */
return v;
}
-/* If C++ compilers didn't suck, we'd use templates. */
-
-#define TYPE uae_u8
-#define PMERGE merge_2pixel8
-
-#define LNAME linetoscr_8
-#define SRC_INC 1
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_8_stretch1
-#define SRC_INC 1
-#define HDOUBLE 1
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_8_shrink1
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_8_shrink2
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 1
-#include "linetoscr.c"
-
-#ifdef AGA
-#define LNAME linetoscr_8_aga
-#define SRC_INC 1
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_8_stretch1_aga
-#define SRC_INC 1
-#define HDOUBLE 1
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_8_shrink1_aga
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_8_shrink2_aga
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 1
-#include "linetoscr.c"
-#endif
-
-#undef TYPE
-#undef PMERGE
-#define TYPE uae_u16
-#define PMERGE merge_2pixel16
-
-#define LNAME linetoscr_16
-#define SRC_INC 1
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_16_stretch1
-#define SRC_INC 1
-#define HDOUBLE 1
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_16_shrink1
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_16_shrink2
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 1
-#include "linetoscr.c"
-
-#ifdef AGA
-#define LNAME linetoscr_16_aga
-#define SRC_INC 1
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_16_stretch1_aga
-#define SRC_INC 1
-#define HDOUBLE 1
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_16_shrink1_aga
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_16_shrink2_aga
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 1
-#include "linetoscr.c"
-#endif
-
-#undef TYPE
-#undef PMERGE
-#define TYPE uae_u32
-#define PMERGE merge_2pixel32
-
-#define LNAME linetoscr_32
-#define SRC_INC 1
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_32_stretch1
-#define SRC_INC 1
-#define HDOUBLE 1
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_32_shrink1
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_32_shrink2
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 0
-#define HMERGE 1
-#include "linetoscr.c"
-
-#ifdef AGA
-#define LNAME linetoscr_32_aga
-#define SRC_INC 1
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_32_stretch1_aga
-#define SRC_INC 1
-#define HDOUBLE 1
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_32_shrink1_aga
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 0
-#include "linetoscr.c"
-#define LNAME linetoscr_32_shrink2_aga
-#define SRC_INC 2
-#define HDOUBLE 0
-#define AGAC 1
-#define HMERGE 1
-#include "linetoscr.c"
-#endif
-
-#undef TYPE
-
-static void fill_line_8 (char *buf, int start, int stop)
+static void fill_line_8 (uae_u8 *buf, unsigned int start, unsigned int stop)
{
uae_u8 *b = (uae_u8 *)buf;
- int i;
+ unsigned int i;
+ unsigned int rem = 0;
xcolnr col = brdblank ? 0 : colors_for_drawing.acolors[0];
- for (i = start; i < stop; i++)
- b[i] = (uae_u8)col;
+ while (((long)&b[start]) & 3) {
+ b[start++] = (uae_u8)col;
+ if (start == stop)
+ return;
+ }
+ if (((long)&b[stop]) & 3) {
+ rem = ((long)&b[stop]) & 3;
+ stop -= rem;
+ }
+ for (i = start; i < stop; i += 4) {
+ uae_u32 *b2 = (uae_u32 *)&b[i];
+ *b2 = col;
+ }
+ while (rem--)
+ b[stop++] = (uae_u8) col;
}
-static void fill_line_16 (char *buf, int start, int stop)
+
+static void fill_line_16 (uae_u8 *buf, unsigned int start, unsigned int stop)
{
uae_u16 *b = (uae_u16 *)buf;
- int i;
+ unsigned int i;
+ unsigned int rem = 0;
xcolnr col = brdblank ? 0 : colors_for_drawing.acolors[0];
- for (i = start; i < stop; i++)
- b[i] = (uae_u16)col;
+ if (((long)&b[start]) & 1)
+ b[start++] = (uae_u16) col;
+ if (start >= stop)
+ return;
+ if (((long)&b[stop]) & 1) {
+ rem++;
+ stop--;
+ }
+ for (i = start; i < stop; i += 2) {
+ uae_u32 *b2 = (uae_u32 *)&b[i];
+ *b2 = col;
+ }
+ if (rem)
+ b[stop] = (uae_u16)col;
}
-static void fill_line_32 (char *buf, int start, int stop)
+
+static void fill_line_32 (uae_u8 *buf, unsigned int start, unsigned int stop)
{
uae_u32 *b = (uae_u32 *)buf;
- int i;
+ unsigned int i;
xcolnr col = brdblank ? 0 : colors_for_drawing.acolors[0];
for (i = start; i < stop; i++)
b[i] = col;
#else
val = colors_for_drawing.acolors[0];
#endif
- if (gfxvidinfo.pixbytes == 2)
- val |= val << 16;
for (; nints > 0; nints -= 8, start += 8) {
*start = val;
*(start+1) = val;
static int linetoscr_double_offset;
+#include "linetoscr.c"
+
static void pfield_do_linetoscr (int start, int stop)
{
#ifdef AGA
}
}
-static void pfield_do_linetoscr_full (int double_line)
-{
- char *oldxlb = (char *)xlinebuffer;
- int old_src_pixel = src_pixel;
-
- xlinecheck(playfield_start, playfield_end);
- pfield_do_linetoscr (playfield_start, playfield_end);
- xlinebuffer = oldxlb + linetoscr_double_offset;
- src_pixel = old_src_pixel;
- pfield_do_linetoscr (playfield_start, playfield_end);
-}
-
static void dummy_worker (int start, int stop)
{
}
int i, maxl;
double native_lines_per_amiga_line;
+ if (gfxvidinfo.height == 0)
+ /* Do nothing if the gfx driver hasn't initialized the screen yet */
+ return;
+
if (native2amiga_line_map)
free (native2amiga_line_map);
if (amiga2aspect_line_map)
if (gfxvidinfo.maxblocklines == 0)
flush_line (lineno);
else {
- if ((last_block_line+1) != lineno) {
- if (first_block_line != -2)
+ if ((last_block_line + 2) < lineno) {
+ if (first_block_line != NO_BLOCK)
flush_block (first_block_line, last_block_line);
first_block_line = lineno;
}
last_block_line = lineno;
if (last_block_line - first_block_line >= gfxvidinfo.maxblocklines) {
flush_block (first_block_line, last_block_line);
- first_block_line = last_block_line = -2;
+ first_block_line = last_block_line = NO_BLOCK;
}
}
}
Should be corrected.
(sjo 26.9.99) */
- if (gfxvidinfo.maxblocklines != 0 && first_block_line != -2) {
+ if (gfxvidinfo.maxblocklines != 0 && first_block_line != NO_BLOCK) {
flush_block (first_block_line, last_block_line);
}
unlockscr ();
last_drawn_line = 0;
first_drawn_line = 32767;
- first_block_line = last_block_line = -2;
+ first_block_line = last_block_line = NO_BLOCK;
if (currprefs.test_drawing_speed)
frame_redraw_necessary = 1;
else if (frame_redraw_necessary)
#define TD_BORDER 0x333
-static char *numbers = { /* ugly 0123456789CHD% */
+static const char *numbers = { /* ugly 0123456789CHD% */
"+++++++--++++-+++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++-++++++-++++----++---+"
"+xxxxx+--+xx+-+xxxxx++xxxxx++x+-+x++xxxxx++xxxxx++xxxxx++xxxxx++xxxxx++xxxx+-+x++x+-+xxx++-+xx+-+x"
"+x+++x+--++x+-+++++x++++++x++x+++x++x++++++x++++++++++x++x+++x++x+++x++x++++-+x++x+-+x++x+--+x++x+"
static void write_tdnumber (int x, int y, int num)
{
int j;
- uae_u8 *numptr;
+ const char *numptr;
numptr = numbers + num * TD_NUM_WIDTH + NUMBERS_NUM * TD_NUM_WIDTH * y;
for (j = 0; j < TD_NUM_WIDTH; j++) {
* done at other times.
*/
+#ifdef SAVESTATE
if (savestate_state == STATE_DORESTORE) {
savestate_state = STATE_RESTORE;
reset_drawing ();
reset_drawing ();
uae_reset (0);
}
+#endif
if (quit_program < 0) {
quit_program = -quit_program;
set_inhibit_frame (IHF_QUIT_PROGRAM);
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
#ifdef FILESYS
filesys_prepare_reset ();
#endif
return;
}
+#ifdef SAVESTATE
savestate_capture (0);
+#endif
count_frame ();
check_picasso ();
}
check_prefs_changed_audio ();
+#ifdef JIT
check_prefs_changed_comp ();
+#endif
check_prefs_changed_custom ();
check_prefs_changed_cpu ();
}
}
+static void dummy_flush_line (struct vidbuf_description *gfxinfo, int line_no)
+{
+}
+
+static void dummy_flush_block (struct vidbuf_description *gfxinfo, int first_line, int last_line)
+{
+}
+
+static void dummy_flush_screen (struct vidbuf_description *gfxinfo, int first_line, int last_line)
+{
+}
+
+static void dummy_flush_clear_screen (struct vidbuf_description *gfxinfo)
+{
+}
+
+static int dummy_lock (struct vidbuf_description *gfxinfo)
+{
+ return 1;
+}
+
+static void dummy_unlock (struct vidbuf_description *gfxinfo)
+{
+}
+
+static void gfxbuffer_reset (void)
+{
+ gfxvidinfo.flush_line = dummy_flush_line;
+ gfxvidinfo.flush_block = dummy_flush_block;
+ gfxvidinfo.flush_screen = dummy_flush_screen;
+ gfxvidinfo.flush_clear_screen = dummy_flush_clear_screen;
+ gfxvidinfo.lockscr = dummy_lock;
+ gfxvidinfo.unlockscr = dummy_unlock;
+}
+
void notice_interlace_seen (void)
{
interlace_seen = 1;
void reset_drawing (void)
{
- int i;
+ unsigned int i;
max_diwstop = 0;
xlinebuffer = gfxvidinfo.bufmem;
inhibit_frame = 0;
+ gfxbuffer_reset ();
reset_drawing ();
}
#ifdef DRIVESOUND
#include "uae.h"
-#include "config.h"
#include "options.h"
#include "sounddep/sound.h"
#include "zfile.h"
#define ENFORCER_BUF_SIZE 4096
static char enforcer_buf[ENFORCER_BUF_SIZE];
-uae_u32 REGPARAM2 (*saved_chipmem_lget) (uaecptr addr);
-uae_u32 REGPARAM2 (*saved_chipmem_wget) (uaecptr addr);
-uae_u32 REGPARAM2 (*saved_chipmem_bget) (uaecptr addr);
-void REGPARAM2 (*saved_chipmem_lput) (uaecptr addr, uae_u32 l);
-void REGPARAM2 (*saved_chipmem_wput) (uaecptr addr, uae_u32 w);
-void REGPARAM2 (*saved_chipmem_bput) (uaecptr addr, uae_u32 b);
-int REGPARAM2 (*saved_chipmem_check) (uaecptr addr, uae_u32 size);
-uae_u8 * REGPARAM2 (*saved_chipmem_xlate) (uaecptr addr);
-uae_u32 REGPARAM2 (*saved_dummy_lget) (uaecptr addr);
-uae_u32 REGPARAM2 (*saved_dummy_wget) (uaecptr addr);
-uae_u32 REGPARAM2 (*saved_dummy_bget) (uaecptr addr);
-void REGPARAM2 (*saved_dummy_lput) (uaecptr addr, uae_u32 l);
-void REGPARAM2 (*saved_dummy_wput) (uaecptr addr, uae_u32 w);
-void REGPARAM2 (*saved_dummy_bput) (uaecptr addr, uae_u32 b);
-int REGPARAM2 (*saved_dummy_check) (uaecptr addr, uae_u32 size);
+uae_u32 (REGPARAM3 *saved_chipmem_lget) (uaecptr addr);
+uae_u32 (REGPARAM3 *saved_chipmem_wget) (uaecptr addr);
+uae_u32 (REGPARAM3 *saved_chipmem_bget) (uaecptr addr);
+void (REGPARAM3 *saved_chipmem_lput) (uaecptr addr, uae_u32 l);
+void (REGPARAM3 *saved_chipmem_wput) (uaecptr addr, uae_u32 w);
+void (REGPARAM3 *saved_chipmem_bput) (uaecptr addr, uae_u32 b);
+int (REGPARAM3 *saved_chipmem_check) (uaecptr addr, uae_u32 size);
+uae_u8 *(REGPARAM3 *saved_chipmem_xlate) (uaecptr addr);
+uae_u32 (REGPARAM3 *saved_dummy_lget) (uaecptr addr);
+uae_u32 (REGPARAM3 *saved_dummy_wget) (uaecptr addr);
+uae_u32 (REGPARAM3 *saved_dummy_bget) (uaecptr addr);
+void (REGPARAM3 *saved_dummy_lput) (uaecptr addr, uae_u32 l);
+void (REGPARAM3 *saved_dummy_wput) (uaecptr addr, uae_u32 w);
+void (REGPARAM3 *saved_dummy_bput) (uaecptr addr, uae_u32 b);
+int (REGPARAM3 *saved_dummy_check) (uaecptr addr, uae_u32 size);
/*************************************************************
Returns the first node entry of an exec list or 0 if
/* Data registers */
sprintf(enforcer_buf_ptr,"Data: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
- m68k_dreg (regs, 0), m68k_dreg (regs, 1), m68k_dreg (regs, 2), m68k_dreg (regs, 3),
- m68k_dreg (regs, 4), m68k_dreg (regs, 5), m68k_dreg (regs, 6), m68k_dreg (regs, 7));
+ m68k_dreg (®s, 0), m68k_dreg (®s, 1), m68k_dreg (®s, 2), m68k_dreg (®s, 3),
+ m68k_dreg (®s, 4), m68k_dreg (®s, 5), m68k_dreg (®s, 6), m68k_dreg (®s, 7));
enforcer_buf_ptr += strlen(enforcer_buf_ptr);
/* Address registers */
sprintf(enforcer_buf_ptr,"Addr: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
- m68k_areg (regs, 0), m68k_areg (regs, 1), m68k_areg (regs, 2), m68k_areg (regs, 3),
- m68k_areg (regs, 4), m68k_areg (regs, 5), m68k_areg (regs, 6), m68k_areg (regs, 7));
+ m68k_areg (®s, 0), m68k_areg (®s, 1), m68k_areg (®s, 2), m68k_areg (®s, 3),
+ m68k_areg (®s, 4), m68k_areg (®s, 5), m68k_areg (®s, 6), m68k_areg (®s, 7));
enforcer_buf_ptr += strlen(enforcer_buf_ptr);
/* Stack */
- a7 = m68k_areg(regs,7);
+ a7 = m68k_areg(®s,7);
for (i = 0; i < 8 * STACKLINES; i++)
{
a7 -= 4;
}
/* Segtracker output */
- a7 = m68k_areg(regs,7);
+ a7 = m68k_areg(®s,7);
if (get_long(a7-4) != pc)
{
if (enforcer_decode_hunk_and_offset(buf,pc))
enforcer_display_hit("LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
}
}
return do_get_mem_long (m);
enforcer_display_hit("WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
}
}
return do_get_mem_word (m);
enforcer_display_hit("BYTE READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
}
}
enforcer_display_hit("LONG WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- if ( addr!=0x100 ) set_special (SPCFLAG_TRAP);
+ if ( addr!=0x100 ) set_special (®s, SPCFLAG_TRAP);
}
}
do_put_mem_long (m, l);
enforcer_display_hit("WORD WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
}
}
do_put_mem_word (m, w);
enforcer_display_hit("BYTE WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
}
}
chipmemory[addr] = b;
enforcer_display_hit("LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET), addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
return 0;
}
return 0xbadedeef;
enforcer_display_hit("WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
return 0;
}
return 0xbadf;
enforcer_display_hit("BYTE READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
return 0;
}
return 0xbadedeef;
enforcer_display_hit("LONG WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
return;
}
}
enforcer_display_hit("WORD WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
return;
}
}
enforcer_display_hit("BYTE WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
if (enforcermode & 1)
{
- set_special (SPCFLAG_TRAP);
+ set_special (®s, SPCFLAG_TRAP);
return;
}
}
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
static void ersatz_doio (void)
{
- uaecptr request = m68k_areg(regs, 1);
+ uaecptr request = m68k_areg(®s, 1);
switch (get_word (request + 0x1C)) {
case 9: /* TD_MOTOR is harmless */
case 2: case 0x8002: /* READ commands */
put_long (a, 0xF8001A);
}
regs.isp = regs.msp = regs.usp = 0x800;
- m68k_areg(regs, 7) = 0x80000;
+ m68k_areg(®s, 7) = 0x80000;
regs.intmask = 0;
/* Build a dummy execbase */
- put_long (4, m68k_areg(regs, 6) = 0x676);
+ put_long (4, m68k_areg(®s, 6) = 0x676);
put_byte (0x676 + 0x129, 0);
for (f = 1; f < 105; f++) {
put_word (0x676 - 6*f, 0x4EF9);
put_long (request + 0x28, 0x4000);
put_long (request + 0x2C, 0);
put_long (request + 0x24, 0x200 * 4);
- m68k_areg(regs, 1) = request;
+ m68k_areg(®s, 1) = request;
ersatz_doio ();
/* kickstart disk loader */
if (get_long(0x4000) == 0x4b49434b) {
put_long (request + 0x28, 0xF80000);
put_long (request + 0x2C, 0x200);
put_long (request + 0x24, 0x200 * 512);
- m68k_areg(regs, 1) = request;
+ m68k_areg(®s, 1) = request;
ersatz_doio ();
/* read rom image once again to mirror address space.
put_long (request + 0x28, 0xFC0000);
put_long (request + 0x2C, 0x200);
put_long (request + 0x24, 0x200 * 512);
- m68k_areg(regs, 1) = request;
+ m68k_areg(®s, 1) = request;
ersatz_doio ();
disk_eject (0);
- m68k_setpc (0xFC0002);
- fill_prefetch_slow ();
+ m68k_setpc (®s, 0xFC0002);
+ fill_prefetch_slow (®s);
uae_reset (0);
ersatzkickfile = 0;
return;
}
- m68k_setpc (0x400C);
- fill_prefetch_slow ();
+ m68k_setpc (®s, 0x400C);
+ fill_prefetch_slow (®s);
/* Init the hardware */
put_long (0x3000, 0xFFFFFFFEul);
break;
case EOP_AVAILMEM:
- m68k_dreg(regs, 0) = m68k_dreg(regs, 1) & 4 ? 0 : 0x70000;
+ m68k_dreg(®s, 0) = m68k_dreg(®s, 1) & 4 ? 0 : 0x70000;
break;
case EOP_ALLOCMEM:
- m68k_dreg(regs, 0) = m68k_dreg(regs, 1) & 4 ? 0 : 0x0F000;
+ m68k_dreg(®s, 0) = m68k_dreg(®s, 1) & 4 ? 0 : 0x0F000;
break;
case EOP_ALLOCABS:
- m68k_dreg(regs, 0) = m68k_areg(regs, 1);
+ m68k_dreg(®s, 0) = m68k_areg(®s, 1);
break;
case EOP_NIMP:
/* fall through */
case EOP_LOOP:
- m68k_setpc (0xF80010);
+ m68k_setpc (®s, 0xF80010);
break;
case EOP_OPENLIB:
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "autoconf.h"
-#include "picasso96.h"
#include "custom.h"
#include "newcpu.h"
#include "savestate.h"
ecard = MAX_EXPANSION_BOARDS - 1;
}
-static uae_u32 expamem_lget (uaecptr) REGPARAM;
-static uae_u32 expamem_wget (uaecptr) REGPARAM;
-static uae_u32 expamem_bget (uaecptr) REGPARAM;
-static void expamem_lput (uaecptr, uae_u32) REGPARAM;
-static void expamem_wput (uaecptr, uae_u32) REGPARAM;
-static void expamem_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 expamem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 expamem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 expamem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 expamem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 expamem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 expamem_bput (uaecptr, uae_u32) REGPARAM;
addrbank expamem_bank = {
expamem_lget, expamem_wget, expamem_bget,
case 0x44:
if (expamem_type() == zorroIII) {
// +Bernd Roesch
- value = (value - 0x4000) + (z3fastmem_start >> 16); /* hack address */
+ value = (value - 0x4000) + (z3fastmem_start >> 16); /* hack address (TW) */
chipmem_wput (regs.regs[11] + 0x20, value);
chipmem_wput (regs.regs[11] + 0x28, value);
// -Bernd Roesch
static uae_u32 fastmem_mask;
-static uae_u32 fastmem_lget (uaecptr) REGPARAM;
-static uae_u32 fastmem_wget (uaecptr) REGPARAM;
-static uae_u32 fastmem_bget (uaecptr) REGPARAM;
-static void fastmem_lput (uaecptr, uae_u32) REGPARAM;
-static void fastmem_wput (uaecptr, uae_u32) REGPARAM;
-static void fastmem_bput (uaecptr, uae_u32) REGPARAM;
-static int fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *fastmem_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 fastmem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 fastmem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 fastmem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 fastmem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 fastmem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 fastmem_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 fastmem_xlate (uaecptr addr) REGPARAM;
uaecptr fastmem_start; /* Determined by the OS */
static uae_u8 *fastmemory;
return (addr + size) <= allocated_fastmem;
}
-static uae_u8 REGPARAM2 *fastmem_xlate (uaecptr addr)
+static uae_u8 *REGPARAM2 fastmem_xlate (uaecptr addr)
{
addr -= fastmem_start & fastmem_mask;
addr &= fastmem_mask;
* Catweasel ZorroII
*/
-static uae_u32 catweasel_lget (uaecptr) REGPARAM;
-static uae_u32 catweasel_wget (uaecptr) REGPARAM;
-static uae_u32 catweasel_bget (uaecptr) REGPARAM;
-static void catweasel_lput (uaecptr, uae_u32) REGPARAM;
-static void catweasel_wput (uaecptr, uae_u32) REGPARAM;
-static void catweasel_bput (uaecptr, uae_u32) REGPARAM;
-static int catweasel_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *catweasel_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 catweasel_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 catweasel_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 catweasel_bget (uaecptr) REGPARAM;
+static void REGPARAM3 catweasel_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 catweasel_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 catweasel_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 catweasel_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 catweasel_xlate (uaecptr addr) REGPARAM;
static uae_u32 catweasel_mask;
static uae_u32 catweasel_start;
return 0;
}
-static uae_u8 REGPARAM2 *catweasel_xlate (uaecptr addr)
+static uae_u8 *REGPARAM2 catweasel_xlate (uaecptr addr)
{
write_log ("catweasel_xlate @%08.8X size %08.8X\n", addr);
return 0;
#endif
+#ifdef FILESYS
+
/*
* Filesystem device ROM
* This is very simple, the Amiga shouldn't be doing things with it.
*/
-static uae_u32 filesys_lget (uaecptr) REGPARAM;
-static uae_u32 filesys_wget (uaecptr) REGPARAM;
-static uae_u32 filesys_bget (uaecptr) REGPARAM;
-static void filesys_lput (uaecptr, uae_u32) REGPARAM;
-static void filesys_wput (uaecptr, uae_u32) REGPARAM;
-static void filesys_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 filesys_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 filesys_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 filesys_bget (uaecptr) REGPARAM;
+static void REGPARAM3 filesys_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 filesys_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 filesys_bput (uaecptr, uae_u32) REGPARAM;
static uae_u32 filesys_start; /* Determined by the OS */
uae_u8 *filesysory;
#ifdef JIT
special_mem |= S_WRITE;
#endif
- write_log ("filesys_lput called PC=%p\n", m68k_getpc());
+ write_log ("filesys_lput called PC=%p\n", M68K_GETPC);
}
static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
#ifdef JIT
special_mem |= S_WRITE;
#endif
- write_log ("filesys_wput called PC=%p\n", m68k_getpc());
+ write_log ("filesys_wput called PC=%p\n", M68K_GETPC);
}
static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
default_xlate, default_check, NULL, "Filesystem Autoconfig Area"
};
+#endif /* FILESYS */
+
/*
* Z3fastmem Memory
*/
static uae_u32 z3fastmem_mask;
-static uae_u32 z3fastmem_lget (uaecptr) REGPARAM;
-static uae_u32 z3fastmem_wget (uaecptr) REGPARAM;
-static uae_u32 z3fastmem_bget (uaecptr) REGPARAM;
-static void z3fastmem_lput (uaecptr, uae_u32) REGPARAM;
-static void z3fastmem_wput (uaecptr, uae_u32) REGPARAM;
-static void z3fastmem_bput (uaecptr, uae_u32) REGPARAM;
-static int z3fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *z3fastmem_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 z3fastmem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 z3fastmem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 z3fastmem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 z3fastmem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 z3fastmem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 z3fastmem_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 z3fastmem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 z3fastmem_xlate (uaecptr addr) REGPARAM;
uaecptr z3fastmem_start; /* Determined by the OS */
static uae_u8 *z3fastmem;
return (addr + size) <= allocated_z3fastmem;
}
-static uae_u8 REGPARAM2 *z3fastmem_xlate (uaecptr addr)
+static uae_u8 *REGPARAM2 z3fastmem_xlate (uaecptr addr)
{
addr -= z3fastmem_start & z3fastmem_mask;
addr &= z3fastmem_mask;
/* ********************************************************** */
+#ifdef FILESYS
+
/*
* Filesystem device
*/
memcpy (filesysory, expamem, 0x3000);
}
+#endif
+
/*
* Zorro III expansion memory
*/
}
-#if defined(PICASSO96)
+#ifdef PICASSO96
/*
* Fake Graphics Card (ZORRO III) - BDK
*/
}
#endif
-static long fast_filepos, z3_filepos, p96_filepos;
+#ifdef SAVESTATE
+static size_t fast_filepos, z3_filepos, p96_filepos;
+#endif
static void allocate_expamem (void)
{
}
clearexec ();
}
-#if defined(PICASSO96)
+#ifdef PICASSO96
if (allocated_gfxmem != currprefs.gfxmem_size) {
if (gfxmemory)
mapped_free (gfxmemory);
z3fastmem_bank.baseaddr = z3fastmem;
fastmem_bank.baseaddr = fastmemory;
+#ifdef SAVESTATE
if (savestate_state == STATE_RESTORE) {
if (allocated_fastmem > 0) {
restore_ram (fast_filepos, fastmemory);
map_banks (&z3fastmem_bank, z3fastmem_start >> 16, currprefs.z3fastmem_size >> 16,
allocated_z3fastmem);
}
-#if defined(PICASSO96)
+#ifdef PICASSO96
if (allocated_gfxmem > 0 && gfxmem_start > 0) {
restore_ram (p96_filepos, gfxmemory);
map_banks (&gfxmem_bank, gfxmem_start >> 16, currprefs.gfxmem_size >> 16,
}
#endif
}
+#endif /* SAVESTATE */
}
extern int cdtv_enabled;
write_log ("Kickstart version is below 1.3! Disabling autoconfig devices.\n");
do_mount = 0;
}
+#ifdef FILESYS
/* No need for filesystem stuff if there aren't any mounted. */
if (nr_units (currprefs.mountinfo) == 0)
do_mount = 0;
-
+#endif
if (fastmemory != NULL) {
card_init[cardno] = expamem_init_fastcard;
card_map[cardno++] = expamem_map_fastcard;
}
- if (z3fastmem != NULL && kickstart_version >= 36) {
+ if (z3fastmem != NULL) {
card_init[cardno] = expamem_init_z3fastmem;
card_map[cardno++] = expamem_map_z3fastmem;
}
#ifdef PICASSO96
- if (gfxmemory != NULL && kickstart_version >= 36) {
+ if (gfxmemory != NULL) {
card_init[cardno] = expamem_init_gfxcard;
card_map[cardno++] = expamem_map_gfxcard;
}
#endif
+#ifdef FILESYS
if (do_mount && ! ersatzkickfile) {
card_init[cardno] = expamem_init_filesys;
card_map[cardno++] = expamem_map_filesys;
}
+#endif
#ifdef CATWEASEL
if (currprefs.catweasel && catweasel_init ()) {
card_init[cardno] = expamem_init_catweasel;
}
(*card_init[0]) ();
-
}
void expansion_init (void)
{
- z3fastmem = 0;
- gfxmemory = 0;
- fastmemory = 0;
- allocated_z3fastmem = 0;
- allocated_gfxmem = 0;
allocated_fastmem = 0;
fastmem_mask = fastmem_start = 0;
fastmemory = 0;
-#if defined(PICASSO96)
+
+#ifdef PICASSO96
+ allocated_gfxmem = 0;
gfxmem_mask = gfxmem_start = 0;
gfxmemory = 0;
#endif
-#if defined(CATWEASEL)
+
+#ifdef CATWEASEL
catweasel_mask = catweasel_start = 0;
#endif
+
+#ifdef FILESYS
filesys_start = 0;
filesysory = 0;
+#endif
+
+ allocated_z3fastmem = 0;
z3fastmem_mask = z3fastmem_start = 0;
z3fastmem = 0;
allocate_expamem ();
+#ifdef FILESYS
filesysory = (uae_u8 *) mapped_malloc (0x10000, "filesys");
if (!filesysory) {
write_log ("virtual memory exhausted (filesysory)!\n");
exit (0);
}
filesys_bank.baseaddr = (uae_u8*)filesysory;
+#endif
}
void expansion_cleanup (void)
{
if (fastmemory)
mapped_free (fastmemory);
+ fastmemory = 0;
+
if (z3fastmem)
mapped_free (z3fastmem);
+ z3fastmem = 0;
+
+#ifdef PICASSO96
if (gfxmemory)
mapped_free (gfxmemory);
+ gfxmemory = 0;
+#endif
+
+#ifdef FILESYS
if (filesysory)
mapped_free (filesysory);
- fastmemory = 0;
- z3fastmem = 0;
- gfxmemory = 0;
filesysory = 0;
-#if defined(CATWEASEL)
+#endif
+
+#ifdef CATWEASEL
catweasel_free ();
#endif
}
+#ifdef SAVESTATE
+
/* State save/restore code. */
uae_u8 *save_fram (int *len)
return gfxmemory;
}
-void restore_fram (int len, long filepos)
+void restore_fram (int len, size_t filepos)
{
fast_filepos = filepos;
changed_prefs.fastmem_size = len;
}
-void restore_zram (int len, long filepos)
+void restore_zram (int len, size_t filepos)
{
z3_filepos = filepos;
changed_prefs.z3fastmem_size = len;
}
-void restore_pram (int len, long filepos)
+void restore_pram (int len, size_t filepos)
{
p96_filepos = filepos;
changed_prefs.gfxmem_size = len;
gfxmem_start = restore_u32 ();
return src;
}
+
+#endif /* SAVESTATE */
\ No newline at end of file
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "threaddep/thread.h"
#include "options.h"
#include "uae.h"
#include "newcpu.h"
#include "filesys.h"
#include "autoconf.h"
+#include "traps.h"
#include "fsusage.h"
#include "native2amiga.h"
#include "scsidev.h"
#define DUMPLOCK(u,x)
#endif
+static uae_sem_t test_sem;
+
static void aino_test (a_inode *aino)
{
#ifdef AINO_DEBUG
int is_hardfile (struct uaedev_mount_info *mountinfo, int unit_no)
{
+ if (!mountinfo)
+ mountinfo = ¤t_mountinfo;
if (mountinfo->ui[unit_no].volname)
return FILESYS_VIRTUAL;
if (mountinfo->ui[unit_no].hf.secspertrack == 0) {
static char *char1 (uaecptr addr)
{
static char buf[1024];
- int i = 0;
+ unsigned int i = 0;
do {
buf[i] = get_byte(addr);
addr++;
uinfo->self = unit;
unit->volume = 0;
- unit->port = m68k_areg (regs, 5);
+ unit->port = m68k_areg (®s, 5);
unit->unit = unit_num++;
startup_update_unit (unit, uinfo);
return unit;
}
-static uae_u32 startup_handler (void)
+static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
{
/* Just got the startup packet. It's in A4. DosBase is in A2,
* our allocated volume structure is in D6, A5 is a pointer to
* our port. */
- uaecptr rootnode = get_long (m68k_areg (regs, 2) + 34);
+ uaecptr rootnode = get_long (m68k_areg (&context->regs, 2) + 34);
uaecptr dos_info = get_long (rootnode + 24) << 2;
- uaecptr pkt = m68k_dreg (regs, 3);
+ uaecptr pkt = m68k_dreg (&context->regs, 3);
uaecptr arg2 = get_long (pkt + dp_Arg2);
int i, namelen;
char* devname = bstr1 (get_long (pkt + dp_Arg1) << 2);
/* fill in our process in the device node */
put_long ((get_long (pkt + dp_Arg3) << 2) + 8, unit->port);
- unit->dosbase = m68k_areg (regs, 2);
+ unit->dosbase = m68k_areg (&context->regs, 2);
/* make new volume */
- unit->volume = m68k_areg (regs, 3) + 32;
+ unit->volume = m68k_areg (&context->regs, 3) + 32;
#ifdef UAE_FILESYS_THREADS
- unit->locklist = m68k_areg (regs, 3) + 8;
+ unit->locklist = m68k_areg (&context->regs, 3) + 8;
#else
- unit->locklist = m68k_areg (regs, 3);
+ unit->locklist = m68k_areg (&context->regs, 3);
#endif
- unit->dummy_message = m68k_areg (regs, 3) + 12;
+ unit->dummy_message = m68k_areg (&context->regs, 3) + 12;
put_long (unit->dummy_message + 10, 0);
}
} else {
char *buf;
- unsigned long old, filesize;
+ off_t old, filesize;
write_log ("unixfs warning: Bad pointer passed for read: %08x, size %d\n", addr, size);
/* ugh this is inefficient but easy */
* know whether AmigaOS takes care of that, but this does. */
static uae_sem_t singlethread_int_sem;
-static uae_u32 exter_int_helper (void)
+static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context)
{
UnitInfo *uip = current_mountinfo.ui;
uaecptr port;
static int unit_no;
- switch (m68k_dreg (regs, 0)) {
+ switch (m68k_dreg (&context->regs, 0)) {
case 0:
/* Determine whether a given EXTER interrupt is for us. */
if (uae_int_requested) {
*/
#ifdef UAE_FILESYS_THREADS
{
- Unit *unit = find_unit (m68k_areg (regs, 5));
- uaecptr msg = m68k_areg (regs, 4);
+ Unit *unit = find_unit (m68k_areg (&context->regs, 5));
+ uaecptr msg = m68k_areg (&context->regs, 4);
unit->cmds_complete = unit->cmds_acked;
while (comm_pipe_has_data (unit->ui.back_pipe)) {
uaecptr locks, lockend;
lockend = get_long (lockend);
cnt++;
}
- TRACE(("%d %x %x %x\n", cnt, locks, lockend, m68k_areg (regs, 3)));
- put_long (lockend, get_long (m68k_areg (regs, 3)));
- put_long (m68k_areg (regs, 3), locks);
+ TRACE(("%d %x %x %x\n", cnt, locks, lockend, m68k_areg (&context->regs, 3)));
+ put_long (lockend, get_long (m68k_areg (&context->regs, 3)));
+ put_long (m68k_areg (&context->regs, 3), locks);
}
}
#else
int cmd = read_comm_pipe_int_blocking (&native2amiga_pending);
switch (cmd) {
case 0: /* Signal() */
- m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
- m68k_dreg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_dreg (&context->regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 2;
case 1: /* PutMsg() */
- m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
- m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 1;
case 2: /* ReplyMsg() */
- m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 3;
case 3: /* Cause() */
- m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 4;
case 4: /* NotifyHack() */
- m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
- m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (&context->regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 5;
default:
uip[unit_no].self->cmds_acked = uip[unit_no].self->cmds_sent;
port = uip[unit_no].self->port;
if (port) {
- m68k_areg (regs, 0) = port;
- m68k_areg (regs, 1) = find_unit (port)->dummy_message;
+ m68k_areg (&context->regs, 0) = port;
+ m68k_areg (&context->regs, 1) = find_unit (port)->dummy_message;
unit_no++;
return 1;
}
{
UnitInfo *ui = (UnitInfo *)unit_v;
- set_thread_priority (2);
+ uae_set_thread_priority (2);
for (;;) {
uae_u8 *pck;
uae_u8 *msg;
if (get_long (ui->self->locklist) != 0)
write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0);
put_long (ui->self->locklist, 0);
+
}
return 0;
}
#endif
/* Talk about spaghetti code... */
-static uae_u32 filesys_handler (void)
+static uae_u32 REGPARAM2 filesys_handler (TrapContext *context)
{
- Unit *unit = find_unit (m68k_areg (regs, 5));
- uaecptr packet_addr = m68k_dreg (regs, 3);
- uaecptr message_addr = m68k_areg (regs, 4);
+ Unit *unit = find_unit (m68k_areg (&context->regs, 5));
+ uaecptr packet_addr = m68k_dreg (&context->regs, 3);
+ uaecptr message_addr = m68k_areg (&context->regs, 4);
uae_u8 *pck;
uae_u8 *msg;
if (! valid_address (packet_addr, 36) || ! valid_address (message_addr, 14)) {
- write_log ("Bad address passed for packet.\n");
+ write_log ("FILESYS: Bad address %x/%x passed for packet.\n", packet_addr, message_addr);
goto error2;
}
pck = get_real_address (packet_addr);
msg = get_real_address (message_addr);
-#if 0
- if (unit->reset_state == FS_GO_DOWN)
- /* You might as well queue it, if you live long enough */
- return 1;
-#endif
-
do_put_mem_long ((uae_u32 *)(msg + 4), -1);
if (!unit || !unit->volume) {
- write_log ("Filesystem was not initialized.\n");
+ write_log ("FILESYS: was not initialized.\n");
goto error;
}
#ifdef UAE_FILESYS_THREADS
if (!unit->ui.unit_pipe)
goto error;
/* Get two more locks and hand them over to the other thread. */
- morelocks = get_long (m68k_areg (regs, 3));
- put_long (m68k_areg (regs, 3), get_long (get_long (morelocks)));
+ morelocks = get_long (m68k_areg (&context->regs, 3));
+ put_long (m68k_areg (&context->regs, 3), get_long (get_long (morelocks)));
put_long (get_long (morelocks), 0);
/* The packet wasn't processed yet. */
}
*/
-static uae_u32 filesys_diagentry (void)
+static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context)
{
- uaecptr resaddr = m68k_areg (regs, 2) + 0x10;
+ uaecptr resaddr = m68k_areg (&context->regs, 2) + 0x10;
uaecptr start = resaddr;
uaecptr residents, tmp;
TRACE (("filesystem: diagentry called\n"));
- filesys_configdev = m68k_areg (regs, 3);
+ filesys_configdev = m68k_areg (&context->regs, 3);
init_filesys_diagentry ();
uae_sem_init (&singlethread_int_sem, 0, 1);
+ uae_sem_init (&test_sem, 0, 1);
if (ROM_hardfile_resid != 0) {
/* Build a struct Resident. This will set up and initialize
* the uae.device */
put_word (resaddr + 14, 0x7001); /* moveq.l #1,d0 */
put_word (resaddr + 16, RTS);
- m68k_areg (regs, 0) = residents;
+ m68k_areg (&context->regs, 0) = residents;
return 1;
}
#define PP_EXPLIB 412
#define PP_FSHDSTART 416
-static uae_u32 filesys_dev_bootfilesys (void)
+static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context)
{
- uaecptr devicenode = m68k_areg (regs, 3);
- uaecptr parmpacket = m68k_areg (regs, 1);
+ uaecptr devicenode = m68k_areg (&context->regs, 3);
+ uaecptr parmpacket = m68k_areg (&context->regs, 1);
uaecptr fsres = get_long (parmpacket + PP_FSRES);
uaecptr fsnode;
uae_u32 dostype, dostype2;
UnitInfo *uip = current_mountinfo.ui;
- int no = m68k_dreg (regs, 6);
+ int no = m68k_dreg (&context->regs, 6);
int unit_no = no & 65535;
int type = is_hardfile (¤t_mountinfo, unit_no);
/* Remember a pointer AmigaOS gave us so we can later use it to identify
* which unit a given startup message belongs to. */
-static uae_u32 filesys_dev_remember (void)
+static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *context)
{
- int no = m68k_dreg (regs, 6);
+ int no = m68k_dreg (&context->regs, 6);
int unit_no = no & 65535;
int sub_no = no >> 16;
UnitInfo *uip = ¤t_mountinfo.ui[unit_no];
int i;
- uaecptr devicenode = m68k_areg (regs, 3);
- uaecptr parmpacket = m68k_areg (regs, 1);
+ uaecptr devicenode = m68k_areg (&context->regs, 3);
+ uaecptr parmpacket = m68k_areg (&context->regs, 1);
/* copy filesystem loaded from RDB */
if (get_long (parmpacket + PP_FSPTR)) {
uip->rdb_filesysstore = 0;
uip->rdb_filesyssize = 0;
}
- if (m68k_dreg (regs, 3) >= 0)
+ if (m68k_dreg (&context->regs, 3) >= 0)
uip->startup = get_long (devicenode + 28);
return devicenode;
}
}
if (!(flags & 1)) /* not bootable */
- m68k_dreg (regs, 7) = 0;
+ m68k_dreg (®s, 7) = 0;
buf[37 + buf[36]] = 0; /* zero terminate BSTR */
uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), buf + 37));
}
/* Fill in per-unit fields of a parampacket */
-static uae_u32 filesys_dev_storeinfo (void)
+static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context)
{
UnitInfo *uip = current_mountinfo.ui;
- int no = m68k_dreg (regs, 6);
+ int no = m68k_dreg (&context->regs, 6);
int unit_no = no & 65535;
int sub_no = no >> 16;
int type = is_hardfile (¤t_mountinfo, unit_no);
- uaecptr parmpacket = m68k_areg (regs, 0);
+ uaecptr parmpacket = m68k_areg (&context->regs, 0);
if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE) {
/* RDB hardfile */
fsdevname = ds ("uae.device"); /* does not really exist */
ROM_filesys_diagentry = here();
- calltrap (deftrap(filesys_diagentry));
+ calltrap (deftrap2(filesys_diagentry, 0, "filesys_diagentry"));
dw(0x4ED0); /* JMP (a0) - jump to code that inits Residents */
loop = here ();
org (RTAREA_BASE + 0xFF18);
- calltrap (deftrap (filesys_dev_bootfilesys));
+ calltrap (deftrap2 (filesys_dev_bootfilesys, 0, "filesys_dev_bootfilesys"));
dw (RTS);
/* Special trap for the assembly make_dev routine */
org (RTAREA_BASE + 0xFF20);
- calltrap (deftrap (filesys_dev_remember));
+ calltrap (deftrap2 (filesys_dev_remember, 0, "filesys_dev_remember"));
dw (RTS);
org (RTAREA_BASE + 0xFF28);
- calltrap (deftrap (filesys_dev_storeinfo));
+ calltrap (deftrap2 (filesys_dev_storeinfo, 0, "filesys_dev_storeinfo"));
dw (RTS);
org (RTAREA_BASE + 0xFF30);
- calltrap (deftrap (filesys_handler));
+ calltrap (deftrap2 (filesys_handler, 0, "filesys_handler"));
dw (RTS);
org (RTAREA_BASE + 0xFF40);
- calltrap (deftrap (startup_handler));
+ calltrap (deftrap2 (startup_handler, 0, "startup_handler"));
dw (RTS);
org (RTAREA_BASE + 0xFF50);
- calltrap (deftrap (exter_int_helper));
+ calltrap (deftrap2 (exter_int_helper, 0, "exter_int_helper"));
dw (RTS);
org (loop);
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
#include "md-fpp.h"
#include "savestate.h"
-uae_u32 xhex_pi[] ={0x2168c235, 0xc90fdaa2, 0x4000};
+static uae_u32 xhex_pi[] ={0x2168c235, 0xc90fdaa2, 0x4000};
uae_u32 xhex_exp_1[] ={0xa2bb4a9a, 0xadf85458, 0x4000};
-uae_u32 xhex_l2_e[] ={0x5c17f0bc, 0xb8aa3b29, 0x3fff};
-uae_u32 xhex_ln_2[] ={0xd1cf79ac, 0xb17217f7, 0x3ffe};
+static uae_u32 xhex_l2_e[] ={0x5c17f0bc, 0xb8aa3b29, 0x3fff};
+static uae_u32 xhex_ln_2[] ={0xd1cf79ac, 0xb17217f7, 0x3ffe};
uae_u32 xhex_ln_10[] ={0xaaa8ac17, 0x935d8ddd, 0x4000};
uae_u32 xhex_l10_2[] ={0xfbcff798, 0x9a209a84, 0x3ffd};
uae_u32 xhex_l10_e[] ={0x37287195, 0xde5bd8a9, 0x3ffd};
uae_u32 xhex_1e1024[]={0x81750c17, 0xc9767586, 0x4d48};
uae_u32 xhex_1e2048[]={0xc53d5de5, 0x9e8b3b5d, 0x5a92};
uae_u32 xhex_1e4096[]={0x8a20979b, 0xc4605202, 0x7525};
-uae_u32 xhex_inf[] ={0x00000000, 0x00000000, 0x7fff};
-uae_u32 xhex_nan[] ={0xffffffff, 0xffffffff, 0x7fff};
+static uae_u32 xhex_inf[] ={0x00000000, 0x00000000, 0x7fff};
+static uae_u32 xhex_nan[] ={0xffffffff, 0xffffffff, 0x7fff};
#if USE_LONG_DOUBLE
static long double *fp_pi = (long double *)xhex_pi;
static long double *fp_exp_1 = (long double *)xhex_exp_1;
STATIC_INLINE int isinrom (void)
{
- return (munge24 (m68k_getpc ()) & 0xFFF80000) == 0xF80000;
+ return (munge24 (m68k_getpc (®s)) & 0xFFF80000) == 0xF80000;
}
#define DEBUG_FPP 0
#define FFLAG_N 0x0100
#define FFLAG_NAN 0x0400
-#define MAKE_FPSR(r) regs.fp_result=(r)
+#define MAKE_FPSR(regs, r) (regs)->fp_result=(r)
static uae_u16 x87_cw_tab[] = {
0x137f, 0x1f7f, 0x177f, 0x1b7f, /* Extended */
case 0:
switch (size) {
case 6:
- *src = (fptype) (uae_s8) m68k_dreg (regs, reg);
+ *src = (fptype) (uae_s8) m68k_dreg (®s, reg);
break;
case 4:
- *src = (fptype) (uae_s16) m68k_dreg (regs, reg);
+ *src = (fptype) (uae_s16) m68k_dreg (®s, reg);
break;
case 0:
- *src = (fptype) (uae_s32) m68k_dreg (regs, reg);
+ *src = (fptype) (uae_s32) m68k_dreg (®s, reg);
break;
case 1:
- *src = to_single (m68k_dreg (regs, reg));
+ *src = to_single (m68k_dreg (®s, reg));
break;
default:
return 0;
case 1:
return 0;
case 2:
- ad = m68k_areg (regs, reg);
+ ad = m68k_areg (®s, reg);
break;
case 3:
- ad = m68k_areg (regs, reg);
- m68k_areg (regs, reg) += reg == 7 ? sz2[size] : sz1[size];
+ ad = m68k_areg (®s, reg);
+ m68k_areg (®s, reg) += reg == 7 ? sz2[size] : sz1[size];
break;
case 4:
- m68k_areg (regs, reg) -= reg == 7 ? sz2[size] : sz1[size];
- ad = m68k_areg (regs, reg);
+ m68k_areg (®s, reg) -= reg == 7 ? sz2[size] : sz1[size];
+ ad = m68k_areg (®s, reg);
break;
case 5:
- ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword ();
+ ad = m68k_areg (®s, reg) + (uae_s32) (uae_s16) next_iword (®s);
break;
case 6:
- ad = get_disp_ea_020 (m68k_areg (regs, reg), next_iword ());
+ ad = get_disp_ea_020 (®s, m68k_areg (®s, reg), next_iword (®s));
break;
case 7:
switch (reg) {
case 0:
- ad = (uae_s32) (uae_s16) next_iword ();
+ ad = (uae_s32) (uae_s16) next_iword (®s);
break;
case 1:
- ad = next_ilong ();
+ ad = next_ilong (®s);
break;
case 2:
- ad = m68k_getpc ();
- ad += (uae_s32) (uae_s16) next_iword ();
+ ad = m68k_getpc (®s);
+ ad += (uae_s32) (uae_s16) next_iword (®s);
break;
case 3:
- tmppc = m68k_getpc ();
- tmp = next_iword ();
- ad = get_disp_ea_020 (tmppc, tmp);
+ tmppc = m68k_getpc (®s);
+ tmp = next_iword (®s);
+ ad = get_disp_ea_020 (®s, tmppc, tmp);
break;
case 4:
- ad = m68k_getpc ();
- m68k_setpc (ad + sz2[size]);
+ ad = m68k_getpc (®s);
+ m68k_setpc (®s, ad + sz2[size]);
if (size == 6)
ad++;
break;
return 1;
}
-STATIC_INLINE int put_fp_value (fptype value, uae_u32 opcode, uae_u16 extra)
+STATIC_INLINE int put_fp_value (struct regstruct *regs, fptype value, uae_u32 opcode, uae_u16 extra)
{
uae_u16 tmp;
uaecptr tmppc;
write_log ("PUTFP: %f %04.4X %04.4X\n", value, opcode, extra);
#endif
if (!(extra & 0x4000)) {
- regs.fp[(extra >> 10) & 7] = value;
+ regs->fp[(extra >> 10) & 7] = value;
return 1;
}
reg = opcode & 7;
ad = m68k_areg (regs, reg);
break;
case 5:
- ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword ();
+ ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword (regs);
break;
case 6:
- ad = get_disp_ea_020 (m68k_areg (regs, reg), next_iword ());
+ ad = get_disp_ea_020 (regs, m68k_areg (regs, reg), next_iword (regs));
break;
case 7:
switch (reg) {
case 0:
- ad = (uae_s32) (uae_s16) next_iword ();
+ ad = (uae_s32) (uae_s16) next_iword (regs);
break;
case 1:
- ad = next_ilong ();
+ ad = next_ilong (regs);
break;
case 2:
- ad = m68k_getpc ();
- ad += (uae_s32) (uae_s16) next_iword ();
+ ad = m68k_getpc (regs);
+ ad += (uae_s32) (uae_s16) next_iword (regs);
break;
case 3:
- tmppc = m68k_getpc ();
- tmp = next_iword ();
- ad = get_disp_ea_020 (tmppc, tmp);
+ tmppc = m68k_getpc (regs);
+ tmp = next_iword (regs);
+ ad = get_disp_ea_020 (regs, tmppc, tmp);
break;
case 4:
- ad = m68k_getpc ();
- m68k_setpc (ad + sz2[size]);
+ ad = m68k_getpc (regs);
+ m68k_setpc (regs, ad + sz2[size]);
break;
default:
return 0;
case 1:
return 0;
case 2:
- *ad = m68k_areg (regs, reg);
+ *ad = m68k_areg (®s, reg);
break;
case 3:
- *ad = m68k_areg (regs, reg);
+ *ad = m68k_areg (®s, reg);
break;
case 4:
- *ad = m68k_areg (regs, reg);
+ *ad = m68k_areg (®s, reg);
break;
case 5:
- *ad = m68k_areg (regs, reg) + (uae_s32) (uae_s16) next_iword ();
+ *ad = m68k_areg (®s, reg) + (uae_s32) (uae_s16) next_iword (®s);
break;
case 6:
- *ad = get_disp_ea_020 (m68k_areg (regs, reg), next_iword ());
+ *ad = get_disp_ea_020 (®s, m68k_areg (®s, reg), next_iword (®s));
break;
case 7:
switch (reg) {
case 0:
- *ad = (uae_s32) (uae_s16) next_iword ();
+ *ad = (uae_s32) (uae_s16) next_iword (®s);
break;
case 1:
- *ad = next_ilong ();
+ *ad = next_ilong (®s);
break;
case 2:
- *ad = m68k_getpc ();
- *ad += (uae_s32) (uae_s16) next_iword ();
+ *ad = m68k_getpc (®s);
+ *ad += (uae_s32) (uae_s16) next_iword (®s);
break;
case 3:
- tmppc = m68k_getpc ();
- tmp = next_iword ();
- *ad = get_disp_ea_020 (tmppc, tmp);
+ tmppc = m68k_getpc (®s);
+ tmp = next_iword (®s);
+ *ad = get_disp_ea_020 (®s, tmppc, tmp);
break;
default:
return 0;
return -1;
}
-void fdbcc_opp (uae_u32 opcode, uae_u16 extra)
+void fdbcc_opp (uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
{
- uaecptr pc = (uae_u32) m68k_getpc ();
- uae_s32 disp = (uae_s32) (uae_s16) next_iword ();
+ uaecptr pc = (uae_u32) m68k_getpc (regs);
+ uae_s32 disp = (uae_s32) (uae_s16) next_iword (regs);
int cc;
#if DEBUG_FPP
#endif
cc = fpp_cond (opcode, extra & 0x3f);
if (cc == -1) {
- m68k_setpc (pc - 4);
- op_illg (opcode);
+ m68k_setpc (regs, pc - 4);
+ op_illg (opcode, regs);
} else if (!cc) {
int reg = opcode & 0x7;
m68k_dreg (regs, reg) = ((m68k_dreg (regs, reg) & ~0xffff)
| ((m68k_dreg (regs, reg) - 1) & 0xffff));
if ((m68k_dreg (regs, reg) & 0xffff) == 0xffff)
- m68k_setpc (pc + disp);
+ m68k_setpc (regs, pc + disp);
}
}
-void fscc_opp (uae_u32 opcode, uae_u16 extra)
+void fscc_opp (uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
{
uae_u32 ad;
int cc;
#endif
cc = fpp_cond (opcode, extra & 0x3f);
if (cc == -1) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
} else if ((opcode & 0x38) == 0) {
m68k_dreg (regs, opcode & 7) = (m68k_dreg (regs, opcode & 7) & ~0xff) | (cc ? 0xff : 0x00);
} else {
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
} else
put_byte (ad, cc ? 0xff : 0x00);
}
}
-void ftrapcc_opp (uae_u32 opcode, uaecptr oldpc)
+void ftrapcc_opp (uae_u32 opcode, struct regstruct *regs, uaecptr oldpc)
{
int cc;
#endif
cc = fpp_cond (opcode, opcode & 0x3f);
if (cc == -1) {
- m68k_setpc (oldpc);
- op_illg (opcode);
+ m68k_setpc (regs, oldpc);
+ op_illg (opcode, regs);
}
if (cc)
- Exception (7, oldpc - 2);
+ Exception (7, regs, oldpc - 2);
}
-void fbcc_opp (uae_u32 opcode, uaecptr pc, uae_u32 extra)
+void fbcc_opp (uae_u32 opcode, struct regstruct *regs, uaecptr pc, uae_u32 extra)
{
int cc;
#endif
cc = fpp_cond (opcode, opcode & 0x3f);
if (cc == -1) {
- m68k_setpc (pc);
- op_illg (opcode);
+ m68k_setpc (regs, pc);
+ op_illg (opcode, regs);
} else if (cc) {
if ((opcode & 0x40) == 0)
extra = (uae_s32) (uae_s16) extra;
- m68k_setpc (pc + extra);
+ m68k_setpc (regs, pc + extra);
}
}
-void fsave_opp (uae_u32 opcode)
+void fsave_opp (uae_u32 opcode, struct regstruct *regs)
{
uae_u32 ad;
int incr = (opcode & 0x38) == 0x20 ? -1 : 1;
write_log ("fsave_opp at %08lx\n", m68k_getpc ());
#endif
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 2);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 2);
+ op_illg (opcode, regs);
return;
}
m68k_areg (regs, opcode & 7) = ad;
}
-void frestore_opp (uae_u32 opcode)
+void frestore_opp (uae_u32 opcode, struct regstruct *regs)
{
uae_u32 ad;
uae_u32 d;
write_log ("frestore_opp at %08lx\n", m68k_getpc ());
#endif
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 2);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 2);
+ op_illg (opcode, regs);
return;
}
if (currprefs.cpu_level >= 4) {
regs.fp[reg] = (float)regs.fp[reg];
}
-void fpp_opp (uae_u32 opcode, uae_u16 extra)
+void fpp_opp (uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
{
int reg;
fptype src;
#endif
switch ((extra >> 13) & 0x7) {
case 3:
- if (put_fp_value (regs.fp[(extra >> 7) & 7], opcode, extra) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ if (put_fp_value (regs, regs->fp[(extra >> 7) & 7], opcode, extra) == 0) {
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
}
return;
case 4:
if ((opcode & 0x38) == 0) {
if (extra & 0x2000) {
if (extra & 0x1000)
- m68k_dreg (regs, opcode & 7) = regs.fpcr;
+ m68k_dreg (regs, opcode & 7) = regs->fpcr;
if (extra & 0x0800)
m68k_dreg (regs, opcode & 7) = get_fpsr ();
if (extra & 0x0400)
- m68k_dreg (regs, opcode & 7) = regs.fpiar;
+ m68k_dreg (regs, opcode & 7) = regs->fpiar;
} else {
if (extra & 0x1000) {
- regs.fpcr = m68k_dreg (regs, opcode & 7);
- native_set_fpucw (regs.fpcr);
+ regs->fpcr = m68k_dreg (regs, opcode & 7);
+ native_set_fpucw (regs->fpcr);
}
if (extra & 0x0800)
set_fpsr (m68k_dreg (regs, opcode & 7));
if (extra & 0x0400)
- regs.fpiar = m68k_dreg (regs, opcode & 7);
+ regs->fpiar = m68k_dreg (regs, opcode & 7);
}
} else if ((opcode & 0x38) == 0x08) {
if (extra & 0x2000) {
if (extra & 0x1000)
- m68k_areg (regs, opcode & 7) = regs.fpcr;
+ m68k_areg (regs, opcode & 7) = regs->fpcr;
if (extra & 0x0800)
m68k_areg (regs, opcode & 7) = get_fpsr ();
if (extra & 0x0400)
- m68k_areg (regs, opcode & 7) = regs.fpiar;
+ m68k_areg (regs, opcode & 7) = regs->fpiar;
} else {
if (extra & 0x1000) {
- regs.fpcr = m68k_areg (regs, opcode & 7);
- native_set_fpucw (regs.fpcr);
+ regs->fpcr = m68k_areg (regs, opcode & 7);
+ native_set_fpucw (regs->fpcr);
}
if (extra & 0x0800)
set_fpsr (m68k_areg (regs, opcode & 7));
if (extra & 0x0400)
- regs.fpiar = m68k_areg (regs, opcode & 7);
+ regs->fpiar = m68k_areg (regs, opcode & 7);
}
} else if ((opcode & 0x3f) == 0x3c) {
if ((extra & 0x2000) == 0) {
if (extra & 0x1000) {
- regs.fpcr = next_ilong ();
- native_set_fpucw (regs.fpcr);
+ regs->fpcr = next_ilong (regs);
+ native_set_fpucw (regs->fpcr);
}
if (extra & 0x0800)
- set_fpsr (next_ilong ());
+ set_fpsr (next_ilong (regs));
if (extra & 0x0400)
- regs.fpiar = next_ilong ();
+ regs->fpiar = next_ilong (regs);
}
} else if (extra & 0x2000) {
/* FMOVEM FPP->memory */
int incr = 0;
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
if ((opcode & 0x38) == 0x20) {
}
ad -= incr;
if (extra & 0x1000) {
- put_long (ad, regs.fpcr);
+ put_long (ad, regs->fpcr);
ad += 4;
}
if (extra & 0x0800) {
ad += 4;
}
if (extra & 0x0400) {
- put_long (ad, regs.fpiar);
+ put_long (ad, regs->fpiar);
ad += 4;
}
ad -= incr;
uae_u32 ad;
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
ad = (opcode & 0x38) == 0x20 ? ad - 12 : ad;
if (extra & 0x1000) {
- regs.fpcr = get_long (ad);
- native_set_fpucw(regs.fpcr);
+ regs->fpcr = get_long (ad);
+ native_set_fpucw(regs->fpcr);
ad += 4;
}
if (extra & 0x0800) {
ad += 4;
}
if (extra & 0x0400) {
- regs.fpiar = get_long (ad);
+ regs->fpiar = get_long (ad);
ad += 4;
}
if ((opcode & 0x38) == 0x18)
if (extra & 0x2000) {
/* FMOVEM FPP->memory */
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
switch ((extra >> 11) & 3) {
while (list) {
uae_u32 wrd1, wrd2, wrd3;
if (incr < 0) {
- from_exten (regs.fp[fpp_movem_index2[list]], &wrd1, &wrd2, &wrd3);
+ from_exten (regs->fp[fpp_movem_index2[list]], &wrd1, &wrd2, &wrd3);
ad -= 4;
put_long (ad, wrd3);
ad -= 4;
ad -= 4;
put_long (ad, wrd1);
} else {
- from_exten (regs.fp[fpp_movem_index1[list]], &wrd1, &wrd2, &wrd3);
+ from_exten (regs->fp[fpp_movem_index1[list]], &wrd1, &wrd2, &wrd3);
put_long (ad, wrd1);
ad += 4;
put_long (ad, wrd2);
} else {
/* FMOVEM memory->FPP */
if (get_fp_ad (opcode, &ad) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
switch ((extra >> 11) & 3) {
wrd2 = get_long (ad);
ad -= 4;
wrd1 = get_long (ad);
- regs.fp[fpp_movem_index2[list]] = to_exten (wrd1, wrd2, wrd3);
+ regs->fp[fpp_movem_index2[list]] = to_exten (wrd1, wrd2, wrd3);
} else {
wrd1 = get_long (ad);
ad += 4;
ad += 4;
wrd3 = get_long (ad);
ad += 4;
- regs.fp[fpp_movem_index1[list]] = to_exten (wrd1, wrd2, wrd3);
+ regs->fp[fpp_movem_index1[list]] = to_exten (wrd1, wrd2, wrd3);
}
list = fpp_movem_next[list];
}
if ((extra & 0xfc00) == 0x5c00) {
switch (extra & 0x7f) {
case 0x00:
- regs.fp[reg] = *fp_pi;
+ regs->fp[reg] = *fp_pi;
break;
case 0x0b:
- regs.fp[reg] = *fp_l10_2;
+ regs->fp[reg] = *fp_l10_2;
break;
case 0x0c:
- regs.fp[reg] = *fp_exp_1;
+ regs->fp[reg] = *fp_exp_1;
break;
case 0x0d:
- regs.fp[reg] = *fp_l2_e;
+ regs->fp[reg] = *fp_l2_e;
break;
case 0x0e:
- regs.fp[reg] = *fp_l10_e;
+ regs->fp[reg] = *fp_l10_e;
break;
case 0x0f:
- regs.fp[reg] = 0.0;
+ regs->fp[reg] = 0.0;
break;
case 0x30:
- regs.fp[reg] = *fp_ln_2;
+ regs->fp[reg] = *fp_ln_2;
break;
case 0x31:
- regs.fp[reg] = *fp_ln_10;
+ regs->fp[reg] = *fp_ln_10;
break;
case 0x32:
- regs.fp[reg] = (fptype)fp_1e0;
+ regs->fp[reg] = (fptype)fp_1e0;
break;
case 0x33:
- regs.fp[reg] = (fptype)fp_1e1;
+ regs->fp[reg] = (fptype)fp_1e1;
break;
case 0x34:
- regs.fp[reg] = (fptype)fp_1e2;
+ regs->fp[reg] = (fptype)fp_1e2;
break;
case 0x35:
- regs.fp[reg] = (fptype)fp_1e4;
+ regs->fp[reg] = (fptype)fp_1e4;
break;
case 0x36:
- regs.fp[reg] = (fptype)fp_1e8;
+ regs->fp[reg] = (fptype)fp_1e8;
break;
case 0x37:
- regs.fp[reg] = *fp_1e16;
+ regs->fp[reg] = *fp_1e16;
break;
case 0x38:
- regs.fp[reg] = *fp_1e32;
+ regs->fp[reg] = *fp_1e32;
break;
case 0x39:
- regs.fp[reg] = *fp_1e64;
+ regs->fp[reg] = *fp_1e64;
break;
case 0x3a:
- regs.fp[reg] = *fp_1e128;
+ regs->fp[reg] = *fp_1e128;
break;
case 0x3b:
- regs.fp[reg] = *fp_1e256;
+ regs->fp[reg] = *fp_1e256;
break;
case 0x3c:
- regs.fp[reg] = *fp_1e512;
+ regs->fp[reg] = *fp_1e512;
break;
case 0x3d:
- regs.fp[reg] = *fp_1e1024;
+ regs->fp[reg] = *fp_1e1024;
break;
case 0x3e:
- regs.fp[reg] = *fp_1e2048;
+ regs->fp[reg] = *fp_1e2048;
break;
case 0x3f:
- regs.fp[reg] = *fp_1e4096;
+ regs->fp[reg] = *fp_1e4096;
break;
default:
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
- MAKE_FPSR (regs.fp[reg]); /* see Motorola 68k Manual */
+ MAKE_FPSR (regs, regs->fp[reg]); /* see Motorola 68k Manual */
return;
}
if (get_fp_value (opcode, extra, &src) == 0) {
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
switch (extra & 0x7f) {
case 0x00: /* FMOVE */
case 0x40: /* Explicit rounding. This is just a quick fix. */
case 0x44: /* Same for all other cases that have three choices */
- regs.fp[reg] = src; /* Brian King was here. */
+ regs->fp[reg] = src; /* Brian King was here. */
/*<ea> to register needs FPSR updated. See Motorola 68K Manual. */
if ((extra & 0x44) == 0x40)
fround (reg);
frndint
fstp LDPTR tmp_fp
}
- regs.fp[reg] = tmp_fp;
+ regs->fp[reg] = tmp_fp;
}
#else /* no X86_MSVC */
switch ((regs.fpcr >> 4) & 3) {
#endif /* X86_MSVC */
break;
case 0x02: /* FSINH */
- regs.fp[reg] = sinh (src);
+ regs->fp[reg] = sinh (src);
break;
case 0x03: /* FINTRZ */
if (src >= 0.0)
- regs.fp[reg] = floor (src);
+ regs->fp[reg] = floor (src);
else
- regs.fp[reg] = ceil (src);
+ regs->fp[reg] = ceil (src);
break;
case 0x04: /* FSQRT */
case 0x41:
case 0x45:
- regs.fp[reg] = sqrt (src);
+ regs->fp[reg] = sqrt (src);
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x06: /* FLOGNP1 */
- regs.fp[reg] = log (src + 1.0);
+ regs->fp[reg] = log (src + 1.0);
break;
case 0x08: /* FETOXM1 */
- regs.fp[reg] = exp (src) - 1.0;
+ regs->fp[reg] = exp (src) - 1.0;
break;
case 0x09: /* FTANH */
- regs.fp[reg] = tanh (src);
+ regs->fp[reg] = tanh (src);
break;
case 0x0a: /* FATAN */
- regs.fp[reg] = atan (src);
+ regs->fp[reg] = atan (src);
break;
case 0x0c: /* FASIN */
- regs.fp[reg] = asin (src);
+ regs->fp[reg] = asin (src);
break;
case 0x0d: /* FATANH */
#if 1 /* The BeBox doesn't have atanh, and it isn't in the HPUX libm either */
- regs.fp[reg] = 0.5 * log ((1 + src) / (1 - src));
+ regs->fp[reg] = 0.5 * log ((1 + src) / (1 - src));
#else
- regs.fp[reg] = atanh (src);
+ regs->fp[reg] = atanh (src);
#endif
break;
case 0x0e: /* FSIN */
- regs.fp[reg] = sin (src);
+ regs->fp[reg] = sin (src);
break;
case 0x0f: /* FTAN */
- regs.fp[reg] = tan (src);
+ regs->fp[reg] = tan (src);
break;
case 0x10: /* FETOX */
- regs.fp[reg] = exp (src);
+ regs->fp[reg] = exp (src);
break;
case 0x11: /* FTWOTOX */
- regs.fp[reg] = pow (2.0, src);
+ regs->fp[reg] = pow (2.0, src);
break;
case 0x12: /* FTENTOX */
- regs.fp[reg] = pow (10.0, src);
+ regs->fp[reg] = pow (10.0, src);
break;
case 0x14: /* FLOGN */
- regs.fp[reg] = log (src);
+ regs->fp[reg] = log (src);
break;
case 0x15: /* FLOG10 */
- regs.fp[reg] = log10 (src);
+ regs->fp[reg] = log10 (src);
break;
case 0x16: /* FLOG2 */
- regs.fp[reg] = *fp_l2_e * log (src);
+ regs->fp[reg] = *fp_l2_e * log (src);
break;
case 0x18: /* FABS */
case 0x58:
case 0x5c:
- regs.fp[reg] = src < 0 ? -src : src;
+ regs->fp[reg] = src < 0 ? -src : src;
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x19: /* FCOSH */
- regs.fp[reg] = cosh (src);
+ regs->fp[reg] = cosh (src);
break;
case 0x1a: /* FNEG */
case 0x5a:
case 0x5e:
- regs.fp[reg] = -src;
+ regs->fp[reg] = -src;
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x1c: /* FACOS */
- regs.fp[reg] = acos (src);
+ regs->fp[reg] = acos (src);
break;
case 0x1d: /* FCOS */
- regs.fp[reg] = cos (src);
+ regs->fp[reg] = cos (src);
break;
case 0x1e: /* FGETEXP */
{
int expon;
frexp (src, &expon);
- regs.fp[reg] = (double) (expon - 1);
+ regs->fp[reg] = (double) (expon - 1);
}
break;
case 0x1f: /* FGETMAN */
{
int expon;
- regs.fp[reg] = frexp (src, &expon) * 2.0;
+ regs->fp[reg] = frexp (src, &expon) * 2.0;
}
break;
case 0x20: /* FDIV */
case 0x60:
case 0x64:
- regs.fp[reg] /= src;
+ regs->fp[reg] /= src;
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x21: /* FMOD */
{
- fptype divi = regs.fp[reg] / src;
+ fptype divi = regs->fp[reg] / src;
if (divi >= 0.0)
- regs.fp[reg] -= src * floor (divi);
+ regs->fp[reg] -= src * floor (divi);
else
- regs.fp[reg] -= src * ceil (divi);
+ regs->fp[reg] -= src * ceil (divi);
}
break;
case 0x22: /* FADD */
case 0x62:
case 0x66:
- regs.fp[reg] += src;
+ regs->fp[reg] += src;
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x23: /* FMUL */
case 0x63:
case 0x67:
- regs.fp[reg] *= src;
+ regs->fp[reg] *= src;
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x24: /* FSGLDIV */
- regs.fp[reg] /= src;
+ regs->fp[reg] /= src;
break;
case 0x25: /* FREM */
- regs.fp[reg] -= src * floor ((regs.fp[reg] / src) + 0.5);
+ regs->fp[reg] -= src * floor ((regs->fp[reg] / src) + 0.5);
break;
case 0x26: /* FSCALE */
#ifdef ldexp
- regs.fp[reg] = ldexp (regs.fp[reg], (int) src);
+ regs->fp[reg] = ldexp (regs->fp[reg], (int) src);
#else
- regs.fp[reg] *= exp (*fp_ln_2 * (int) src);
+ regs->fp[reg] *= exp (*fp_ln_2 * (int) src);
#endif
break;
case 0x27: /* FSGLMUL */
- regs.fp[reg] *= src;
+ regs->fp[reg] *= src;
break;
case 0x28: /* FSUB */
case 0x68:
case 0x6c:
- regs.fp[reg] -= src;
+ regs->fp[reg] -= src;
if ((extra & 0x44) == 0x40)
fround (reg);
break;
case 0x35:
case 0x36:
case 0x37:
- regs.fp[extra & 7] = cos (src);
- regs.fp[reg] = sin (src);
+ regs->fp[extra & 7] = cos (src);
+ regs->fp[reg] = sin (src);
break;
case 0x38: /* FCMP */
{
- fptype tmp = regs.fp[reg] - src;
- regs.fpsr = 0;
- MAKE_FPSR (tmp);
+ fptype tmp = regs->fp[reg] - src;
+ regs->fpsr = 0;
+ MAKE_FPSR (regs, tmp);
}
return;
case 0x3a: /* FTST */
- regs.fpsr = 0;
- MAKE_FPSR (src);
+ regs->fpsr = 0;
+ MAKE_FPSR (regs, src);
return;
default:
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
return;
}
- MAKE_FPSR (regs.fp[reg]);
+ MAKE_FPSR (regs, regs->fp[reg]);
return;
}
- m68k_setpc (m68k_getpc () - 4);
- op_illg (opcode);
+ m68k_setpc (regs, m68k_getpc (regs) - 4);
+ op_illg (opcode, regs);
}
#endif
restore_u32 ();
if (currprefs.cpu_level == 2) {
currprefs.cpu_level++;
- init_m68k_full ();
+ init_m68k ();
}
changed_prefs.cpu_level = currprefs.cpu_level;
for (i = 0; i < 8; i++) {
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
-#include "threaddep/thread.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
special_mem |= S_READ;
#endif
if (GAYLE_LOG)
- write_log ("GAYLE_READ %08.8X PC=%08.8X\n", addr, m68k_getpc());
+ write_log ("GAYLE_READ %08.8X PC=%08.8X\n", addr, M68K_GETPC);
addr &= 0xfffff;
if(addr >= 0xa0000 && addr <= 0xaffff)
return ide_read(addr, size);
special_mem |= S_WRITE;
#endif
if (GAYLE_LOG)
- write_log ("GAYLE_WRITE %08.8X=%08.8X (%d) PC=%08.8X\n", addr, val, size, m68k_getpc());
+ write_log ("GAYLE_WRITE %08.8X=%08.8X (%d) PC=%08.8X\n", addr, val, size, M68K_GETPC);
addr &= 0x3ffff;
if(addr >= 0xa0000 && addr <= 0xaffff)
ide_write(addr, val, size);
ide_write(addr, val, size);
}
-static uae_u32 gayle_lget (uaecptr) REGPARAM;
-static uae_u32 gayle_wget (uaecptr) REGPARAM;
-static uae_u32 gayle_bget (uaecptr) REGPARAM;
-static void gayle_lput (uaecptr, uae_u32) REGPARAM;
-static void gayle_wput (uaecptr, uae_u32) REGPARAM;
-static void gayle_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 gayle_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 gayle_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 gayle_bget (uaecptr) REGPARAM;
+static void REGPARAM3 gayle_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 gayle_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 gayle_bput (uaecptr, uae_u32) REGPARAM;
addrbank gayle_bank = {
gayle_lget, gayle_wget, gayle_bget,
unsigned int i;
printf("#include \"sysconfig.h\"\n");
printf("#include \"sysdeps.h\"\n");
- printf("#include \"config.h\"\n");
printf("#include \"options.h\"\n");
printf("#include \"custom.h\"\n");
printf("#include \"memory.h\"\n");
unsigned int i;
printf("#include \"sysconfig.h\"\n");
printf("#include \"sysdeps.h\"\n");
- printf("#include \"config.h\"\n");
printf("#include \"options.h\"\n");
printf("#include \"custom.h\"\n");
printf("#include \"memory.h\"\n");
printf("#include \"blitter.h\"\n");
printf("#include \"blitfunc.h\"\n\n");
- printf("blitter_func *blitfunc_dofast[256] = {\n");
+ printf("blitter_func * const blitfunc_dofast[256] = {\n");
for (i = 0; i < 256; i++) {
if (index < sizeof(blttbl) && i == blttbl[index]) {
printf("blitdofast_%x",i);
printf("};\n\n");
index = 0;
- printf("blitter_func *blitfunc_dofast_desc[256] = {\n");
+ printf("blitter_func * const blitfunc_dofast_desc[256] = {\n");
for (i = 0; i < 256; i++) {
if (index < sizeof(blttbl) && i == blttbl[index]) {
printf("blitdofast_desc_%x",i);
switch(table68k[opcode].size) {
case sz_long:
comprintf("\t\t\tmov_l_rR(i,native,offset);\n"
- "\t\t\tbswap_32(i);\n"
+ "\t\t\tgen_bswap_32(i);\n"
"\t\t\toffset+=4;\n");
break;
case sz_word:
comprintf("\t\t\tmov_w_rR(i,native,offset);\n"
- "\t\t\tbswap_16(i);\n"
+ "\t\t\tgen_bswap_16(i);\n"
"\t\t\tsign_extend_16_rr(i,i);\n"
"\t\t\toffset+=2;\n");
break;
switch(table68k[opcode].size) {
case sz_long:
comprintf("\t\t\tmov_l_rr(tmp,i);\n"
- "\t\t\tbswap_32(tmp);\n"
+ "\t\t\tgen_bswap_32(tmp);\n"
"\t\t\tmov_l_Rr(native,tmp,offset);\n"
"\t\t\toffset+=4;\n");
break;
case sz_word:
comprintf("\t\t\tmov_l_rr(tmp,i);\n"
- "\t\t\tbswap_16(tmp);\n"
+ "\t\t\tgen_bswap_16(tmp);\n"
"\t\t\tmov_w_Rr(native,tmp,offset);\n"
"\t\t\toffset+=2;\n");
break;
case sz_long:
comprintf("\t\t\toffset-=4;\n"
"\t\t\tmov_l_rr(tmp,15-i);\n"
- "\t\t\tbswap_32(tmp);\n"
+ "\t\t\tgen_bswap_32(tmp);\n"
"\t\t\tmov_l_Rr(native,tmp,offset);\n"
);
break;
case sz_word:
comprintf("\t\t\toffset-=2;\n"
"\t\t\tmov_l_rr(tmp,15-i);\n"
- "\t\t\tbswap_16(tmp);\n"
+ "\t\t\tgen_bswap_16(tmp);\n"
"\t\t\tmov_w_Rr(native,tmp,offset);\n"
);
break;
fprintf (f, "#include \"sysconfig.h\"\n");
fprintf (f, "#if defined(JIT)\n");
fprintf (f, "#include \"sysdeps.h\"\n");
- fprintf (f, "#include \"config.h\"\n");
fprintf (f, "#include \"options.h\"\n");
fprintf (f, "#include \"memory.h\"\n");
fprintf (f, "#include \"custom.h\"\n");
} else {
if (noflags) {
fprintf (stblfile, "{ op_%lx_%d_comp_nf, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, lookuptab[i].name);
- fprintf (headerfile, "extern cpuop_func op_%lx_%d_comp_nf;\n", opcode, postfix);
+ fprintf (headerfile, "extern compop_func op_%lx_%d_comp_nf;\n", opcode, postfix);
printf ("unsigned long REGPARAM2 op_%lx_%d_comp_nf(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name);
} else {
fprintf (stblfile, "{ op_%lx_%d_comp_ff, %ld, 0x%08x }, /* %s */\n", opcode, postfix, opcode, flags, lookuptab[i].name);
- fprintf (headerfile, "extern cpuop_func op_%lx_%d_comp_ff;\n", opcode, postfix);
+ fprintf (headerfile, "extern compop_func op_%lx_%d_comp_ff;\n", opcode, postfix);
printf ("unsigned long REGPARAM2 op_%lx_%d_comp_ff(uae_u32 opcode) /* %s */\n{\n", opcode, postfix, lookuptab[i].name);
}
com_flush();
postfix = i;
if (noflags)
- fprintf (stblfile, "struct cputbl op_smalltbl_%d_comp_nf[] = {\n", postfix);
+ fprintf (stblfile, "const struct comptbl op_smalltbl_%d_comp_nf[] = {\n", postfix);
else
- fprintf (stblfile, "struct cputbl op_smalltbl_%d_comp_ff[] = {\n", postfix);
+ fprintf (stblfile, "const struct comptbl op_smalltbl_%d_comp_ff[] = {\n", postfix);
/* sam: this is for people with low memory (eg. me :)) */
printf ("\t%s %s;\n", type, name);
/* we must do this because execution order of (something | something2) is not defined */
if (norefill) {
- printf ("\t%s = get_word_ce_prefetch (%d) << 16;\n", name, r + 2);
- printf ("\t%s |= regs.irc;\n", name);
+ printf ("\t%s = get_word_ce_prefetch (regs, %d) << 16;\n", name, r + 2);
+ printf ("\t%s |= regs->irc;\n", name);
} else {
- printf ("\t%s = get_word_ce_prefetch (%d) << 16;\n", name, r + 2);
- printf ("\t%s |= get_word_ce_prefetch (%d);\n", name, r + 4);
+ printf ("\t%s = get_word_ce_prefetch (regs, %d) << 16;\n", name, r + 2);
+ printf ("\t%s |= get_word_ce_prefetch (regs, %d);\n", name, r + 4);
}
} else {
if (using_prefetch) {
if (norefill) {
printf ("\t%s %s;\n", type, name);
- printf ("\t%s = get_word_prefetch (%d) << 16;\n", name, r + 2);
- printf ("\t%s |= regs.irc;\n", name);
+ printf ("\t%s = get_word_prefetch (regs, %d) << 16;\n", name, r + 2);
+ printf ("\t%s |= regs->irc;\n", name);
insn_n_cycles += 4;
} else {
- printf ("\t%s %s = get_long_prefetch (%d);\n", type, name, r + 2);
+ printf ("\t%s %s = get_long_prefetch (regs, %d);\n", type, name, r + 2);
insn_n_cycles += 8;
}
} else {
insn_n_cycles += 8;
- printf ("\t%s %s = get_ilong (%d);\n", type, name, r);
+ printf ("\t%s %s = get_ilong (regs, %d);\n", type, name, r);
}
}
}
if (using_ce) {
if (norefill)
- strcpy (buffer, "regs.irc");
+ strcpy (buffer, "regs->irc");
else
- sprintf (buffer, "get_word_ce_prefetch (%d)", r + 2);
+ sprintf (buffer, "get_word_ce_prefetch (regs, %d)", r + 2);
} else {
if (using_prefetch) {
if (norefill) {
- sprintf (buffer, "regs.irc", r);
+ sprintf (buffer, "regs->irc", r);
} else {
- sprintf (buffer, "get_word_prefetch (%d)", r + 2);
+ sprintf (buffer, "get_word_prefetch (regs, %d)", r + 2);
insn_n_cycles += 4;
}
} else {
- sprintf (buffer, "get_iword (%d)", r);
+ sprintf (buffer, "get_iword (regs, %d)", r);
insn_n_cycles += 4;
}
}
if (using_ce) {
if (norefill)
- strcpy (buffer, "(uae_u8)regs.irc");
+ strcpy (buffer, "(uae_u8)regs->irc");
else
- sprintf (buffer, "(uae_u8)get_word_ce_prefetch (%d)", r + 2);
+ sprintf (buffer, "(uae_u8)get_word_ce_prefetch (regs, %d)", r + 2);
} else {
insn_n_cycles += 4;
if (using_prefetch) {
if (norefill) {
- sprintf (buffer, "(uae_u8)regs.irc", r);
+ sprintf (buffer, "(uae_u8)regs->irc", r);
} else {
- sprintf (buffer, "(uae_u8)get_word_prefetch (%d)", r + 2);
+ sprintf (buffer, "(uae_u8)get_word_prefetch (regs, %d)", r + 2);
insn_n_cycles += 4;
}
} else {
- sprintf (buffer, "get_ibyte (%d)", r);
+ sprintf (buffer, "get_ibyte (regs, %d)", r);
insn_n_cycles += 4;
}
}
{
if (!using_prefetch)
return;
- printf ("\tregs.ir = regs.irc;\n");
+ printf ("\tregs->ir = regs->irc;\n");
}
static int did_prefetch;
if (!using_prefetch)
return;
if (using_ce)
- printf ("\tget_word_ce_prefetch (%d);\n", m68k_pc_offset + 2);
+ printf ("\tget_word_ce_prefetch (regs, %d);\n", m68k_pc_offset + 2);
else
- printf ("\tget_word_prefetch (%d);\n", m68k_pc_offset + 2);
+ printf ("\tget_word_prefetch (regs, %d);\n", m68k_pc_offset + 2);
did_prefetch = 1;
insn_n_cycles += 4;
}
if (!using_prefetch)
return;
if (using_ce) {
- printf ("\tget_word_ce_prefetch (%d);\n", o);
+ printf ("\tget_word_ce_prefetch (regs, %d);\n", o);
} else {
- printf ("\tget_word_prefetch (%d);\n", o);
+ printf ("\tget_word_prefetch (regs, %d);\n", o);
}
did_prefetch = 1;
insn_n_cycles += 4;
if (!using_prefetch)
return;
if (using_ce)
- printf ("\tget_word_ce_prefetch (0);\n");
+ printf ("\tget_word_ce_prefetch (regs, 0);\n");
else
- printf ("\tget_word_prefetch (0);\n");
+ printf ("\tget_word_prefetch (regs, 0);\n");
did_prefetch = 1;
insn_n_cycles += 4;
}
{
if (m68k_pc_offset == 0)
return;
- printf ("\tm68k_incpc (%d);\n", m68k_pc_offset);
+ printf ("\tm68k_incpc (regs, %d);\n", m68k_pc_offset);
m68k_pc_offset = 0;
}
start_brace ();
/* This would ordinarily be done in gen_nextiword, which we bypass. */
insn_n_cycles += 4;
- printf ("\t%sa = get_disp_ea_020(m68k_areg(regs, %s), next_iword());\n", name, reg);
+ printf ("\t%sa = get_disp_ea_020(regs, m68k_areg(regs, %s), next_iword(regs));\n", name, reg);
} else
- printf ("\t%sa = get_disp_ea_000(m68k_areg(regs, %s), %s);\n", name, reg, gen_nextiword (flags & GF_NOREFILL));
+ printf ("\t%sa = get_disp_ea_000(regs, m68k_areg(regs, %s), %s);\n", name, reg, gen_nextiword (flags & GF_NOREFILL));
if (!(flags & GF_AD8R)) {
addcycles (2);
insn_n_cycles += 2;
}
break;
case PC16:
- printf ("\tuaecptr %sa = m68k_getpc () + %d;\n", name, m68k_pc_offset);
+ printf ("\tuaecptr %sa = m68k_getpc (regs) + %d;\n", name, m68k_pc_offset);
printf ("\t%sa += (uae_s32)(uae_s16)%s;\n", name, gen_nextiword (flags & GF_NOREFILL));
break;
case PC8r:
start_brace ();
/* This would ordinarily be done in gen_nextiword, which we bypass. */
insn_n_cycles += 4;
- printf ("\ttmppc = m68k_getpc();\n");
- printf ("\t%sa = get_disp_ea_020(tmppc, next_iword());\n", name);
+ printf ("\ttmppc = m68k_getpc(regs);\n");
+ printf ("\t%sa = get_disp_ea_020(regs, tmppc, next_iword(regs));\n", name);
} else {
- printf ("\ttmppc = m68k_getpc() + %d;\n", m68k_pc_offset);
- printf ("\t%sa = get_disp_ea_000(tmppc, %s);\n", name, gen_nextiword (flags & GF_NOREFILL));
+ printf ("\ttmppc = m68k_getpc(regs) + %d;\n", m68k_pc_offset);
+ printf ("\t%sa = get_disp_ea_000(regs, tmppc, %s);\n", name, gen_nextiword (flags & GF_NOREFILL));
}
if (!(flags & GF_PC8R)) {
addcycles (2);
if ((using_prefetch || using_ce) && using_exception_3 && getv != 0 && size != sz_byte) {
printf ("\tif (%sa & 1) {\n", name);
- printf ("\t\texception3 (opcode, m68k_getpc() + %d, %sa);\n",
+ printf ("\t\texception3 (opcode, m68k_getpc(regs) + %d, %sa);\n",
m68k_pc_offset_last + e3fudge, name);
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
int i;
for (i = 0; i <= n; i++)
printf ("\t");
- printf ("COPY_CARRY;\n");
+ printf ("COPY_CARRY (®s->ccrflags);\n");
}
typedef enum
switch (type) {
case flag_logical:
- printf ("\tCLEAR_CZNV;\n");
- printf ("\tSET_ZFLG (%s == 0);\n", vstr);
- printf ("\tSET_NFLG (%s < 0);\n", vstr);
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, %s == 0);\n", vstr);
+ printf ("\tSET_NFLG (®s->ccrflags, %s < 0);\n", vstr);
break;
case flag_logical_noclobber:
- printf ("\tSET_ZFLG (%s == 0);\n", vstr);
- printf ("\tSET_NFLG (%s < 0);\n", vstr);
+ printf ("\tSET_ZFLG (®s->ccrflags, %s == 0);\n", vstr);
+ printf ("\tSET_NFLG (®s->ccrflags, %s < 0);\n", vstr);
break;
case flag_av:
- printf ("\tSET_VFLG ((flgs ^ flgn) & (flgo ^ flgn));\n");
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs ^ flgn) & (flgo ^ flgn));\n");
break;
case flag_sv:
- printf ("\tSET_VFLG ((flgs ^ flgo) & (flgn ^ flgo));\n");
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs ^ flgo) & (flgn ^ flgo));\n");
break;
case flag_zn:
- printf ("\tSET_ZFLG (GET_ZFLG & (%s == 0));\n", vstr);
- printf ("\tSET_NFLG (%s < 0);\n", vstr);
+ printf ("\tSET_ZFLG (®s->ccrflags, GET_ZFLG (®s->ccrflags) & (%s == 0));\n", vstr);
+ printf ("\tSET_NFLG (®s->ccrflags, %s < 0);\n", vstr);
break;
case flag_add:
- printf ("\tSET_ZFLG (%s == 0);\n", vstr);
- printf ("\tSET_VFLG ((flgs ^ flgn) & (flgo ^ flgn));\n");
- printf ("\tSET_CFLG (%s < %s);\n", undstr, usstr);
+ printf ("\tSET_ZFLG (®s->ccrflags, %s == 0);\n", vstr);
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs ^ flgn) & (flgo ^ flgn));\n");
+ printf ("\tSET_CFLG (®s->ccrflags, %s < %s);\n", undstr, usstr);
duplicate_carry (0);
- printf ("\tSET_NFLG (flgn != 0);\n");
+ printf ("\tSET_NFLG (®s->ccrflags, flgn != 0);\n");
break;
case flag_sub:
- printf ("\tSET_ZFLG (%s == 0);\n", vstr);
- printf ("\tSET_VFLG ((flgs ^ flgo) & (flgn ^ flgo));\n");
- printf ("\tSET_CFLG (%s > %s);\n", usstr, udstr);
+ printf ("\tSET_ZFLG (®s->ccrflags, %s == 0);\n", vstr);
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs ^ flgo) & (flgn ^ flgo));\n");
+ printf ("\tSET_CFLG (®s->ccrflags, %s > %s);\n", usstr, udstr);
duplicate_carry (0);
- printf ("\tSET_NFLG (flgn != 0);\n");
+ printf ("\tSET_NFLG (®s->ccrflags, flgn != 0);\n");
break;
case flag_addx:
- printf ("\tSET_VFLG ((flgs ^ flgn) & (flgo ^ flgn));\n"); /* minterm SON: 0x42 */
- printf ("\tSET_CFLG (flgs ^ ((flgs ^ flgo) & (flgo ^ flgn)));\n"); /* minterm SON: 0xD4 */
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs ^ flgn) & (flgo ^ flgn));\n"); /* minterm SON: 0x42 */
+ printf ("\tSET_CFLG (®s->ccrflags, flgs ^ ((flgs ^ flgo) & (flgo ^ flgn)));\n"); /* minterm SON: 0xD4 */
duplicate_carry (0);
break;
case flag_subx:
- printf ("\tSET_VFLG ((flgs ^ flgo) & (flgo ^ flgn));\n"); /* minterm SON: 0x24 */
- printf ("\tSET_CFLG (flgs ^ ((flgs ^ flgn) & (flgo ^ flgn)));\n"); /* minterm SON: 0xB2 */
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs ^ flgo) & (flgo ^ flgn));\n"); /* minterm SON: 0x24 */
+ printf ("\tSET_CFLG (®s->ccrflags, flgs ^ ((flgs ^ flgn) & (flgo ^ flgn)));\n"); /* minterm SON: 0xB2 */
duplicate_carry (0);
break;
case flag_cmp:
- printf ("\tSET_ZFLG (%s == 0);\n", vstr);
- printf ("\tSET_VFLG ((flgs != flgo) && (flgn != flgo));\n");
- printf ("\tSET_CFLG (%s > %s);\n", usstr, udstr);
- printf ("\tSET_NFLG (flgn != 0);\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, %s == 0);\n", vstr);
+ printf ("\tSET_VFLG (®s->ccrflags, (flgs != flgo) && (flgn != flgo));\n");
+ printf ("\tSET_CFLG (®s->ccrflags, %s > %s);\n", usstr, udstr);
+ printf ("\tSET_NFLG (®s->ccrflags, flgn != 0);\n");
break;
}
}
/* fall through */
case 2: /* priviledged */
- printf ("if (!regs.s) { Exception(8,0); goto %s; }\n", endlabelstr);
+ printf ("if (!regs->s) { Exception(8, regs, 0); goto %s; }\n", endlabelstr);
need_endlabel = 1;
start_brace ();
break;
case 3: /* privileged if size == word */
if (curi->size == sz_byte)
break;
- printf ("if (!regs.s) { Exception(8,0); goto %s; }\n", endlabelstr);
+ printf ("if (!regs->s) { Exception(8, regs, 0); goto %s; }\n", endlabelstr);
need_endlabel = 1;
start_brace ();
break;
break;
case i_ORSR:
case i_EORSR:
- printf ("\tMakeSR();\n");
+ printf ("\tMakeSR(regs);\n");
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
if (curi->size == sz_byte) {
printf ("\tsrc &= 0xFF;\n");
}
addcycles (4);
fill_prefetch_next ();
- printf ("\tregs.sr %c= src;\n", curi->mnemo == i_EORSR ? '^' : '|');
- printf ("\tMakeFromSR();\n");
+ printf ("\tregs->sr %c= src;\n", curi->mnemo == i_EORSR ? '^' : '|');
+ printf ("\tMakeFromSR(regs);\n");
break;
case i_ANDSR:
- printf ("\tMakeSR();\n");
+ printf ("\tMakeSR(regs);\n");
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
if (curi->size == sz_byte) {
printf ("\tsrc |= 0xFF00;\n");
}
addcycles (4);
fill_prefetch_next ();
- printf ("\tregs.sr &= src;\n");
- printf ("\tMakeFromSR();\n");
+ printf ("\tregs->sr &= src;\n");
+ printf ("\tMakeFromSR(regs);\n");
break;
case i_SUB:
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
addcycles (2);
fill_prefetch_next ();
start_brace ();
- printf ("\tuae_u32 newv = dst - src - (GET_XFLG ? 1 : 0);\n");
+ printf ("\tuae_u32 newv = dst - src - (GET_XFLG (®s->ccrflags) ? 1 : 0);\n");
genflags (flag_subx, curi->size, "newv", "src", "dst");
genflags (flag_zn, curi->size, "newv", "", "");
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
fill_prefetch_next ();
start_brace ();
- printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG ? 1 : 0);\n");
+ printf ("\tuae_u16 newv_lo = (dst & 0xF) - (src & 0xF) - (GET_XFLG (®s->ccrflags) ? 1 : 0);\n");
printf ("\tuae_u16 newv_hi = (dst & 0xF0) - (src & 0xF0);\n");
printf ("\tuae_u16 newv, tmp_newv;\n");
printf ("\tint bcd = 0;\n");
printf ("\tnewv = tmp_newv = newv_hi + newv_lo;\n");
printf ("\tif (newv_lo & 0xF0) { newv -= 6; bcd = 6; };\n");
- printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n");
- printf ("\tSET_CFLG ((((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG ? 1 : 0)) & 0x300) > 0xFF);\n");
+ printf ("\tif ((((dst & 0xFF) - (src & 0xFF) - (GET_XFLG (®s->ccrflags) ? 1 : 0)) & 0x100) > 0xFF) { newv -= 0x60; }\n");
+ printf ("\tSET_CFLG (®s->ccrflags, (((dst & 0xFF) - (src & 0xFF) - bcd - (GET_XFLG (®s->ccrflags) ? 1 : 0)) & 0x300) > 0xFF);\n");
duplicate_carry (0);
genflags (flag_zn, curi->size, "newv", "", "");
- printf ("\tSET_VFLG ((tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n");
+ printf ("\tSET_VFLG (®s->ccrflags, (tmp_newv & 0x80) != 0 && (newv & 0x80) == 0);\n");
addcycles (2);
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
break;
addcycles (2);
fill_prefetch_next ();
start_brace ();
- printf ("\tuae_u32 newv = dst + src + (GET_XFLG ? 1 : 0);\n");
+ printf ("\tuae_u32 newv = dst + src + (GET_XFLG (®s->ccrflags) ? 1 : 0);\n");
genflags (flag_addx, curi->size, "newv", "src", "dst");
genflags (flag_zn, curi->size, "newv", "", "");
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, GF_AA);
fill_prefetch_next ();
start_brace ();
- printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG ? 1 : 0);\n");
+ printf ("\tuae_u16 newv_lo = (src & 0xF) + (dst & 0xF) + (GET_XFLG (®s->ccrflags) ? 1 : 0);\n");
printf ("\tuae_u16 newv_hi = (src & 0xF0) + (dst & 0xF0);\n");
printf ("\tuae_u16 newv, tmp_newv;\n");
printf ("\tint cflg;\n");
printf ("\tif (newv_lo > 9) { newv += 6; }\n");
printf ("\tcflg = (newv & 0x3F0) > 0x90;\n");
printf ("\tif (cflg) newv += 0x60;\n");
- printf ("\tSET_CFLG (cflg);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, cflg);\n");
duplicate_carry (0);
genflags (flag_zn, curi->size, "newv", "", "");
- printf ("\tSET_VFLG ((tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n");
+ printf ("\tSET_VFLG (®s->ccrflags, (tmp_newv & 0x80) == 0 && (newv & 0x80) != 0);\n");
addcycles (2);
genastore ("newv", curi->dmode, "dstreg", curi->size, "dst");
break;
addcycles (2);
fill_prefetch_next ();
start_brace ();
- printf ("\tuae_u32 newv = 0 - src - (GET_XFLG ? 1 : 0);\n");
+ printf ("\tuae_u32 newv = 0 - src - (GET_XFLG (®s->ccrflags) ? 1 : 0);\n");
genflags (flag_subx, curi->size, "newv", "src", "0");
genflags (flag_zn, curi->size, "newv", "", "");
genastore_rev ("newv", curi->smode, "srcreg", curi->size, "src");
addcycles (2);
fill_prefetch_next ();
start_brace ();
- printf ("\tuae_u16 newv_lo = - (src & 0xF) - (GET_XFLG ? 1 : 0);\n");
+ printf ("\tuae_u16 newv_lo = - (src & 0xF) - (GET_XFLG (®s->ccrflags) ? 1 : 0);\n");
printf ("\tuae_u16 newv_hi = - (src & 0xF0);\n");
printf ("\tuae_u16 newv;\n");
printf ("\tint cflg;\n");
printf ("\tnewv = newv_hi + newv_lo;");
printf ("\tcflg = (newv & 0x1F0) > 0x90;\n");
printf ("\tif (cflg) newv -= 0x60;\n");
- printf ("\tSET_CFLG (cflg);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, cflg);\n");
duplicate_carry(0);
genflags (flag_zn, curi->size, "newv", "", "");
genastore ("newv", curi->smode, "srcreg", curi->size, "src");
printf ("\tsrc &= 7;\n");
else
printf ("\tsrc &= 31;\n");
- printf ("\tSET_ZFLG (1 ^ ((dst >> src) & 1));\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, 1 ^ ((dst >> src) & 1));\n");
break;
case i_BCHG:
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
else
printf ("\tsrc &= 31;\n");
printf ("\tdst ^= (1 << src);\n");
- printf ("\tSET_ZFLG (((uae_u32)dst & (1 << src)) >> src);\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, ((uae_u32)dst & (1 << src)) >> src);\n");
genastore ("dst", curi->dmode, "dstreg", curi->size, "dst");
break;
case i_BCLR:
printf ("\tsrc &= 7;\n");
else
printf ("\tsrc &= 31;\n");
- printf ("\tSET_ZFLG (1 ^ ((dst >> src) & 1));\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, 1 ^ ((dst >> src) & 1));\n");
printf ("\tdst &= ~(1 << src);\n");
genastore ("dst", curi->dmode, "dstreg", curi->size, "dst");
break;
printf ("\tsrc &= 7;\n");
else
printf ("\tsrc &= 31;\n");
- printf ("\tSET_ZFLG (1 ^ ((dst >> src) & 1));\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, 1 ^ ((dst >> src) & 1));\n");
printf ("\tdst |= (1 << src);\n");
genastore ("dst", curi->dmode, "dstreg", curi->size, "dst");
break;
if (isreg (curi->smode))
addcycles (2);
fill_prefetch_next ();
- printf ("\tMakeSR();\n");
+ printf ("\tMakeSR(regs);\n");
if (curi->size == sz_byte)
- genastore ("regs.sr & 0xff", curi->smode, "srcreg", sz_word, "src");
+ genastore ("regs->sr & 0xff", curi->smode, "srcreg", sz_word, "src");
else
- genastore ("regs.sr", curi->smode, "srcreg", sz_word, "src");
+ genastore ("regs->sr", curi->smode, "srcreg", sz_word, "src");
break;
case i_MV2SR:
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0, 0);
if (curi->size == sz_byte) {
addcycles (8);
- printf ("\tMakeSR();\n\tregs.sr &= 0xFF00;\n\tregs.sr |= src & 0xFF;\n");
+ printf ("\tMakeSR(regs);\n\tregs->sr &= 0xFF00;\n\tregs->sr |= src & 0xFF;\n");
} else {
addcycles (4);
- printf ("\tregs.sr = src;\n");
+ printf ("\tregs->sr = src;\n");
}
fill_prefetch_next ();
- printf ("\tMakeFromSR();\n");
+ printf ("\tMakeFromSR(regs);\n");
break;
case i_SWAP:
genamode (curi->smode, "srcreg", sz_long, "src", 1, 0, 0);
case i_TRAP:
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tException (src + 32,0);\n");
+ printf ("\tException (src + 32, regs, 0);\n");
did_prefetch = 1;
m68k_pc_offset = 0;
break;
case i_MVR2USP:
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
fill_prefetch_next ();
- printf ("\tregs.usp = src;\n");
+ printf ("\tregs->usp = src;\n");
break;
case i_MVUSP2R:
genamode (curi->smode, "srcreg", curi->size, "src", 2, 0, 0);
fill_prefetch_next ();
- genastore ("regs.usp", curi->smode, "srcreg", curi->size, "src");
+ genastore ("regs->usp", curi->smode, "srcreg", curi->size, "src");
break;
case i_RESET:
fill_prefetch_next ();
printf ("\tcpureset();\n");
if (using_prefetch)
- printf ("\tregs.irc = get_iword(4);\n");
+ printf ("\tregs->irc = get_iword(regs, 4);\n");
break;
case i_NOP:
fill_prefetch_next ();
case i_STOP:
/* real stop do not prefetch anything, later... */
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
- printf ("\tregs.sr = src;\n");
- printf ("\tMakeFromSR();\n");
- printf ("\tm68k_setstopped(1);\n");
+ printf ("\tregs->sr = src;\n");
+ printf ("\tMakeFromSR(regs);\n");
+ printf ("\tm68k_setstopped(regs, 1);\n");
sync_m68k_pc ();
fill_prefetch_full ();
break;
if (cpu_level == 0) {
genamode (Aipi, "7", sz_word, "sr", 1, 0, GF_NOREFILL);
genamode (Aipi, "7", sz_long, "pc", 1, 0, GF_NOREFILL);
- printf ("\tregs.sr = sr; m68k_setpc_rte(pc);\n");
- printf ("\tMakeFromSR();\n");
+ printf ("\tregs->sr = sr; m68k_setpc(regs, pc);\n");
+ printf ("\tMakeFromSR(regs);\n");
} else {
int old_brace_level = n_braces;
if (next_cpu_level < 0)
printf ("\telse if ((format & 0xF000) == 0x9000) { m68k_areg(regs, 7) += 12; break; }\n");
printf ("\telse if ((format & 0xF000) == 0xa000) { m68k_areg(regs, 7) += 24; break; }\n");
printf ("\telse if ((format & 0xF000) == 0xb000) { m68k_areg(regs, 7) += 84; break; }\n");
- printf ("\telse { Exception(14,0); goto %s; }\n", endlabelstr);
- printf ("\tregs.sr = newsr; MakeFromSR();\n}\n");
+ printf ("\telse { Exception(14, regs, 0); goto %s; }\n", endlabelstr);
+ printf ("\tregs->sr = newsr; MakeFromSR(regs);\n}\n");
pop_braces (old_brace_level);
- printf ("\tregs.sr = newsr; MakeFromSR();\n");
+ printf ("\tregs->sr = newsr; MakeFromSR(regs);\n");
printf ("\tif (newpc & 1)\n");
- printf ("\t\texception3 (0x%04.4X, m68k_getpc(), newpc);\n", opcode);
+ printf ("\t\texception3 (0x%04.4X, m68k_getpc(regs), newpc);\n", opcode);
printf ("\telse\n");
- printf ("\t\tm68k_setpc_rte(newpc);\n");
+ printf ("\t\tm68k_setpc(regs, newpc);\n");
need_endlabel = 1;
}
/* PC is set and prefetch filled. */
genamode (curi->smode, "srcreg", curi->size, "offs", 1, 0, 0);
printf ("\tm68k_areg(regs, 7) += offs;\n");
printf ("\tif (pc & 1)\n");
- printf ("\t\texception3 (0x%04.4X, m68k_getpc(), pc);\n", opcode);
+ printf ("\t\texception3 (0x%04.4X, m68k_getpc(regs), pc);\n", opcode);
printf ("\telse\n");
- printf ("\t\tm68k_setpc_rte(pc);\n");
+ printf ("\t\tm68k_setpc(regs, pc);\n");
/* PC is set and prefetch filled. */
m68k_pc_offset = 0;
fill_prefetch_full ();
break;
case i_RTS:
if (using_ce)
- printf ("\tm68k_do_rts_ce();\n");
+ printf ("\tm68k_do_rts_ce(regs);\n");
else
- printf ("\tm68k_do_rts();\n");
+ printf ("\tm68k_do_rts(regs);\n");
m68k_pc_offset = 0;
fill_prefetch_full ();
break;
case i_TRAPV:
sync_m68k_pc ();
- printf ("\tif (GET_VFLG) {\n");
- printf ("\t\tException (7, m68k_getpc ());\n");
+ printf ("\tif (GET_VFLG (®s->ccrflags)) {\n");
+ printf ("\t\tException (7, regs, m68k_getpc (regs));\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
fill_prefetch_next ();
need_endlabel = 1;
break;
case i_RTR:
- printf ("\tMakeSR();\n");
+ printf ("\tMakeSR(regs);\n");
genamode (Aipi, "7", sz_word, "sr", 1, 0, 0);
genamode (Aipi, "7", sz_long, "pc", 1, 0, 0);
- printf ("\tregs.sr &= 0xFF00; sr &= 0xFF;\n");
- printf ("\tregs.sr |= sr; m68k_setpc(pc);\n");
- printf ("\tMakeFromSR();\n");
+ printf ("\tregs->sr &= 0xFF00; sr &= 0xFF;\n");
+ printf ("\tregs->sr |= sr; m68k_setpc(regs, pc);\n");
+ printf ("\tMakeFromSR(regs);\n");
m68k_pc_offset = 0;
fill_prefetch_full ();
break;
case i_JSR:
genamode (curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL);
start_brace ();
- printf ("\tuaecptr oldpc = m68k_getpc() + %d;\n", m68k_pc_offset);
+ printf ("\tuaecptr oldpc = m68k_getpc(regs) + %d;\n", m68k_pc_offset);
if (using_exception_3) {
printf ("\tif (srca & 1) {\n");
printf ("\t\texception3i (opcode, oldpc, srca);\n");
printf ("\t}\n");
need_endlabel = 1;
}
- printf ("\tm68k_setpc (srca);\n");
+ printf ("\tm68k_setpc (regs, srca);\n");
m68k_pc_offset = 0;
fill_prefetch_1 (0);
printf("\tm68k_areg (regs, 7) -= 4;\n");
genamode (curi->smode, "srcreg", curi->size, "src", 0, 0, GF_AA|GF_NOREFILL);
if (using_exception_3) {
printf ("\tif (srca & 1) {\n");
- printf ("\t\texception3i (opcode, m68k_getpc() + 6, srca);\n");
+ printf ("\t\texception3i (opcode, m68k_getpc(regs) + 6, srca);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
need_endlabel = 1;
}
if (curi->smode == Ad16 || curi->smode == Ad8r || curi->smode == absw || curi->smode == PC16 || curi->smode == PC8r)
addcycles (2);
- printf ("\tm68k_setpc(srca);\n");
+ printf ("\tm68k_setpc(regs, srca);\n");
m68k_pc_offset = 0;
fill_prefetch_full ();
break;
printf ("\ts = (uae_s32)src + 2;\n");
if (using_exception_3) {
printf ("\tif (src & 1) {\n");
- printf ("\t\texception3i (opcode, m68k_getpc() + 2, m68k_getpc() + s);\n");
+ printf ("\t\texception3i (opcode, m68k_getpc(regs) + 2, m68k_getpc(regs) + s);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
need_endlabel = 1;
}
addcycles (2);
if (using_ce)
- printf ("\tm68k_do_bsr_ce (m68k_getpc() + %d, s);\n", m68k_pc_offset);
+ printf ("\tm68k_do_bsr_ce (regs, m68k_getpc(regs) + %d, s);\n", m68k_pc_offset);
else
- printf ("\tm68k_do_bsr (m68k_getpc() + %d, s);\n", m68k_pc_offset);
+ printf ("\tm68k_do_bsr (regs, m68k_getpc(regs) + %d, s);\n", m68k_pc_offset);
m68k_pc_offset = 0;
fill_prefetch_full ();
break;
if (curi->size == sz_long) {
if (cpu_level < 2) {
addcycles (2);
- printf ("\tif (cctrue(%d)) {\n", curi->cc, endlabelstr);
- printf ("\t\texception3i (opcode, m68k_getpc() + 2, m68k_getpc() + 1);\n");
+ printf ("\tif (cctrue(®s->ccrflags, %d)) {\n", curi->cc, endlabelstr);
+ printf ("\t\texception3i (opcode, m68k_getpc(regs) + 2, m68k_getpc(regs) + 1);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
sync_m68k_pc ();
}
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA | GF_NOREFILL);
addcycles (2);
- printf ("\tif (!cctrue(%d)) goto didnt_jump;\n", curi->cc);
+ printf ("\tif (!cctrue(®s->ccrflags, %d)) goto didnt_jump;\n", curi->cc);
if (using_exception_3) {
printf ("\tif (src & 1) {\n");
- printf ("\t\texception3i (opcode, m68k_getpc() + 2, m68k_getpc() + 2 + (uae_s32)src);\n");
+ printf ("\t\texception3i (opcode, m68k_getpc(regs) + 2, m68k_getpc(regs) + 2 + (uae_s32)src);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
need_endlabel = 1;
}
if (using_prefetch) {
if (curi->size == sz_byte) {
- printf ("\tm68k_incpc ((uae_s32)src + 2);\n");
+ printf ("\tm68k_incpc (regs, (uae_s32)src + 2);\n");
} else {
- printf ("\tm68k_incpc ((uae_s32)src + 2);\n");
+ printf ("\tm68k_incpc (regs, (uae_s32)src + 2);\n");
}
fill_prefetch_full ();
if (using_ce)
else
printf ("\treturn 10 * %d;\n", CYCLE_UNIT / 2);
} else {
- printf ("\tm68k_incpc ((uae_s32)src + 2);\n");
+ printf ("\tm68k_incpc (regs, (uae_s32)src + 2);\n");
returncycles ("\t", 10);
}
printf ("didnt_jump:;\n");
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, GF_AA | GF_NOREFILL);
genamode (curi->dmode, "dstreg", curi->size, "offs", 1, 0, GF_AA | GF_NOREFILL);
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
addcycles (2);
- printf ("\tif (!cctrue(%d)) {\n", curi->cc);
- printf ("\t\tm68k_incpc((uae_s32)offs + 2);\n");
+ printf ("\tif (!cctrue(®s->ccrflags, %d)) {\n", curi->cc);
+ printf ("\t\tm68k_incpc(regs, (uae_s32)offs + 2);\n");
printf ("\t"); fill_prefetch_1 (0);
printf ("\t"); genastore ("(src-1)", curi->smode, "srcreg", curi->size, "src");
printf ("\t\tif (src) {\n");
if (using_exception_3) {
printf ("\t\t\tif (offs & 1) {\n");
- printf ("\t\t\t\texception3i (opcode, m68k_getpc() + 2, m68k_getpc() + 2 + (uae_s32)offs + 2);\n");
+ printf ("\t\t\t\texception3i (opcode, m68k_getpc(regs) + 2, m68k_getpc(regs) + 2 + (uae_s32)offs + 2);\n");
printf ("\t\t\t\tgoto %s;\n", endlabelstr);
printf ("\t\t\t}\n");
need_endlabel = 1;
printf ("\t} else {\n");
addcycles2 ("\t\t", 2);
printf ("\t}\n");
- printf ("\tm68k_setpc (oldpc + %d);\n", m68k_pc_offset);
+ printf ("\tm68k_setpc (regs, oldpc + %d);\n", m68k_pc_offset);
m68k_pc_offset = 0;
fill_prefetch_full ();
insn_n_cycles = 12;
start_brace ();
fill_prefetch_next();
start_brace ();
- printf ("\tint val = cctrue(%d) ? 0xff : 0;\n", curi->cc);
+ printf ("\tint val = cctrue(®s->ccrflags, %d) ? 0xff : 0;\n", curi->cc);
if (using_ce) {
printf ("\tint cycles = 0;\n");
if (isreg (curi->smode))
genastore ("val", curi->smode, "srcreg", curi->size, "src");
break;
case i_DIVU:
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0, 0);
genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0, 0);
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
printf ("\tif (src == 0) {\n");
if (cpu_level > 0) {
/* 68020 sets V when dividing by zero and N if dst is negative
* 68000 clears both
*/
- printf("\t\tSET_VFLG (1);\n");
- printf("\t\tif (dst < 0) SET_NFLG (1);\n");
+ printf("\t\tSET_VFLG (®s->ccrflags, 1);\n");
+ printf("\t\tif (dst < 0) SET_NFLG (®s->ccrflags, 1);\n");
}
- printf ("\t\tm68k_incpc (%d);\n", m68k_pc_offset);
- printf ("\t\tException (5, oldpc);\n");
+ printf ("\t\tm68k_incpc (regs, %d);\n", m68k_pc_offset);
+ printf ("\t\tException (5, regs, oldpc);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t} else {\n");
printf ("\t\tuae_u32 newv = (uae_u32)dst / (uae_u32)(uae_u16)src;\n");
/* The N flag appears to be set each time there is an overflow.
* Weird. but 68020 only sets N when dst is negative.. */
printf ("\t\tif (newv > 0xffff) {\n");
- printf ("\t\t\tSET_VFLG (1);\n");
+ printf ("\t\t\tSET_VFLG (®s->ccrflags, 1);\n");
#ifdef UNDEF68020
if (cpu_level >= 2)
printf ("\t\t\tif (currprefs.cpu_level == 0 || dst < 0) SET_NFLG (1);\n");
else /* ??? some 68000 revisions may not set NFLG when overflow happens.. */
#endif
- printf ("\t\t\tSET_NFLG (1);\n");
+ printf ("\t\t\tSET_NFLG (®s->ccrflags, 1);\n");
printf ("\t\t} else {\n");
printf ("\t\t"); genflags (flag_logical, sz_word, "newv", "", "");
printf ("\t\t\tnewv = (newv & 0xffff) | ((uae_u32)rem << 16);\n");
need_endlabel = 1;
break;
case i_DIVS:
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
genamode (curi->smode, "srcreg", sz_word, "src", 1, 0, 0);
genamode (curi->dmode, "dstreg", sz_long, "dst", 1, 0, 0);
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
printf ("\tif (src == 0) {\n");
if (cpu_level > 0) {
/* 68020 sets V when dividing by zero. Z is also set.
* 68000 clears both
*/
- printf("\t\tSET_VFLG (1);\n");
- printf("\t\tSET_ZFLG (1);\n");
+ printf("\t\tSET_VFLG (®s->ccrflags, 1);\n");
+ printf("\t\tSET_ZFLG (®s->ccrflags, 1);\n");
}
- printf ("\t\tm68k_incpc (%d);\n", m68k_pc_offset);
- printf ("\t\tException (5, oldpc);\n");
+ printf ("\t\tm68k_incpc (regs, %d);\n", m68k_pc_offset);
+ printf ("\t\tException (5, regs, oldpc);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t} else {\n");
printf ("\t\tuae_s32 newv = (uae_s32)dst / (uae_s32)(uae_s16)src;\n");
addcycles3 ("\t\t");
}
printf ("\t\tif ((newv & 0xffff8000) != 0 && (newv & 0xffff8000) != 0xffff8000) {\n");
- printf ("\t\t\tSET_VFLG (1);\n");
+ printf ("\t\t\tSET_VFLG (®s->ccrflags, 1);\n");
#ifdef UNDEF68020
if (cpu_level > 0)
printf ("\t\t\tif (currprefs.cpu_level == 0) SET_NFLG (1);\n");
else
#endif
- printf ("\t\t\tSET_NFLG (1);\n");
+ printf ("\t\t\tSET_NFLG (®s->ccrflags, 1);\n");
printf ("\t\t} else {\n");
printf ("\t\t\tif (((uae_s16)rem < 0) != ((uae_s32)dst < 0)) rem = -rem;\n");
genflags (flag_logical, sz_word, "newv", "", "");
insn_n_cycles += (70 - 38) / 2 + 38; /* average */
break;
case i_CHK:
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
genamode (curi->smode, "srcreg", curi->size, "src", 1, 0, 0);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0);
sync_m68k_pc ();
addcycles (6);
fill_prefetch_next ();
printf ("\tif ((uae_s32)dst < 0) {\n");
- printf ("\t\tSET_NFLG (1);\n");
- printf ("\t\tException (6, oldpc);\n");
+ printf ("\t\tSET_NFLG (®s->ccrflags, 1);\n");
+ printf ("\t\tException (6, regs, oldpc);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t} else if (dst > src) {\n");
- printf ("\t\tSET_NFLG (0);\n");
- printf ("\t\tException (6, oldpc);\n");
+ printf ("\t\tSET_NFLG (®s->ccrflags, 0);\n");
+ printf ("\t\tException (6, regs, oldpc);\n");
printf ("\t\tgoto %s;\n", endlabelstr);
printf ("\t}\n");
need_endlabel = 1;
break;
case i_CHK2:
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0);
fill_prefetch_0 ();
- printf ("\t{uae_s32 upper,lower,reg = regs.regs[(extra >> 12) & 15];\n");
+ printf ("\t{uae_s32 upper,lower,reg = regs->regs[(extra >> 12) & 15];\n");
switch (curi->size) {
case sz_byte:
- printf ("\tlower=(uae_s32)(uae_s8)get_byte(dsta); upper = (uae_s32)(uae_s8)get_byte(dsta+1);\n");
+ printf ("\tlower = (uae_s32)(uae_s8)get_byte(dsta); upper = (uae_s32)(uae_s8)get_byte(dsta+1);\n");
printf ("\tif ((extra & 0x8000) == 0) reg = (uae_s32)(uae_s8)reg;\n");
break;
case sz_word:
- printf ("\tlower=(uae_s32)(uae_s16)get_word(dsta); upper = (uae_s32)(uae_s16)get_word(dsta+2);\n");
+ printf ("\tlower = (uae_s32)(uae_s16)get_word(dsta); upper = (uae_s32)(uae_s16)get_word(dsta+2);\n");
printf ("\tif ((extra & 0x8000) == 0) reg = (uae_s32)(uae_s16)reg;\n");
break;
case sz_long:
- printf ("\tlower=get_long(dsta); upper = get_long(dsta+4);\n");
+ printf ("\tlower = get_long(dsta); upper = get_long(dsta+4);\n");
break;
default:
abort ();
}
- printf ("\tSET_ZFLG (upper == reg || lower == reg);\n");
- printf ("\tSET_CFLG_ALWAYS (lower <= upper ? reg < lower || reg > upper : reg > upper || reg < lower);\n");
- printf ("\tif ((extra & 0x800) && GET_CFLG) { Exception(6,oldpc); goto %s; }\n}\n", endlabelstr);
+ printf ("\tSET_ZFLG (®s->ccrflags, upper == reg || lower == reg);\n");
+ printf ("\tSET_CFLG_ALWAYS (®s->ccrflags, lower <= upper ? reg < lower || reg > upper : reg > upper || reg < lower);\n");
+ printf ("\tif ((extra & 0x800) && GET_CFLG (®s->ccrflags)) { Exception(6, regs, oldpc); goto %s; }\n}\n", endlabelstr);
need_endlabel = 1;
break;
printf ("\tuae_u32 sign = (%s & val) >> %d;\n", cmask (curi->size), bit_size (curi->size) - 1);
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
printf ("\tif (cnt >= %d) {\n", bit_size (curi->size));
printf ("\t\tval = %s & (uae_u32)-sign;\n", bit_mask (curi->size));
- printf ("\t\tSET_CFLG (sign);\n");
+ printf ("\t\tSET_CFLG (®s->ccrflags, sign);\n");
duplicate_carry (1);
if (source_is_imm1_8 (curi))
printf ("\t} else {\n");
else
printf ("\t} else if (cnt > 0) {\n");
printf ("\t\tval >>= cnt - 1;\n");
- printf ("\t\tSET_CFLG (val & 1);\n");
+ printf ("\t\tSET_CFLG (®s->ccrflags, val & 1);\n");
duplicate_carry (1);
printf ("\t\tval >>= 1;\n");
printf ("\t\tval |= (%s << (%d - cnt)) & (uae_u32)-sign;\n",
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
printf ("\tif (cnt >= %d) {\n", bit_size (curi->size));
- printf ("\t\tSET_VFLG (val != 0);\n");
- printf ("\t\tSET_CFLG (cnt == %d ? val & 1 : 0);\n",
+ printf ("\t\tSET_VFLG (®s->ccrflags, val != 0);\n");
+ printf ("\t\tSET_CFLG (®s->ccrflags, cnt == %d ? val & 1 : 0);\n",
bit_size (curi->size));
duplicate_carry (1);
printf ("\t\tval = 0;\n");
bit_mask (curi->size),
bit_size (curi->size) - 1,
bit_mask (curi->size));
- printf ("\t\tSET_VFLG ((val & mask) != mask && (val & mask) != 0);\n");
+ printf ("\t\tSET_VFLG (®s->ccrflags, (val & mask) != mask && (val & mask) != 0);\n");
printf ("\t\tval <<= cnt - 1;\n");
- printf ("\t\tSET_CFLG ((val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1);
+ printf ("\t\tSET_CFLG (®s->ccrflags, (val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1);
duplicate_carry (1);
printf ("\t\tval <<= 1;\n");
printf ("\t\tval &= %s;\n", bit_mask (curi->size));
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
printf ("\tif (cnt >= %d) {\n", bit_size (curi->size));
- printf ("\t\tSET_CFLG ((cnt == %d) & (val >> %d));\n",
+ printf ("\t\tSET_CFLG (®s->ccrflags, (cnt == %d) & (val >> %d));\n",
bit_size (curi->size), bit_size (curi->size) - 1);
duplicate_carry (1);
printf ("\t\tval = 0;\n");
else
printf ("\t} else if (cnt > 0) {\n");
printf ("\t\tval >>= cnt - 1;\n");
- printf ("\t\tSET_CFLG (val & 1);\n");
+ printf ("\t\tSET_CFLG (®s->ccrflags, val & 1);\n");
duplicate_carry (1);
printf ("\t\tval >>= 1;\n");
printf ("\t}\n");
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
printf ("\tif (cnt >= %d) {\n", bit_size (curi->size));
- printf ("\t\tSET_CFLG (cnt == %d ? val & 1 : 0);\n",
+ printf ("\t\tSET_CFLG (®s->ccrflags, cnt == %d ? val & 1 : 0);\n",
bit_size (curi->size));
duplicate_carry (1);
printf ("\t\tval = 0;\n");
else
printf ("\t} else if (cnt > 0) {\n");
printf ("\t\tval <<= (cnt - 1);\n");
- printf ("\t\tSET_CFLG ((val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1);
+ printf ("\t\tSET_CFLG (®s->ccrflags, (val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1);
duplicate_carry (1);
printf ("\t\tval <<= 1;\n");
printf ("\tval &= %s;\n", bit_mask (curi->size));
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
if (source_is_imm1_8 (curi))
printf ("{");
else
printf ("\tval <<= cnt;\n");
printf ("\tval |= loval;\n");
printf ("\tval &= %s;\n", bit_mask (curi->size));
- printf ("\tSET_CFLG (val & 1);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, val & 1);\n");
printf ("}\n");
genflags (flag_logical_noclobber, curi->size, "val", "", "");
shift_ce (curi->dmode, curi->size);
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
if (source_is_imm1_8 (curi))
printf ("{");
else
printf ("\tval >>= cnt;\n");
printf ("\tval |= hival;\n");
printf ("\tval &= %s;\n", bit_mask (curi->size));
- printf ("\tSET_CFLG ((val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1);
+ printf ("\tSET_CFLG (®s->ccrflags, (val & %s) >> %d);\n", cmask (curi->size), bit_size (curi->size) - 1);
printf ("\t}\n");
genflags (flag_logical_noclobber, curi->size, "val", "", "");
shift_ce (curi->dmode, curi->size);
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
if (source_is_imm1_8 (curi))
printf ("{");
else {
printf ("\t{\n\tuae_u32 carry;\n");
printf ("\tuae_u32 loval = val >> (%d - cnt);\n", bit_size (curi->size) - 1);
printf ("\tcarry = loval & 1;\n");
- printf ("\tval = (((val << 1) | GET_XFLG) << cnt) | (loval >> 1);\n");
- printf ("\tSET_XFLG (carry);\n");
+ printf ("\tval = (((val << 1) | GET_XFLG (®s->ccrflags)) << cnt) | (loval >> 1);\n");
+ printf ("\tSET_XFLG (®s->ccrflags, carry);\n");
printf ("\tval &= %s;\n", bit_mask (curi->size));
printf ("\t} }\n");
- printf ("\tSET_CFLG (GET_XFLG);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, GET_XFLG (®s->ccrflags));\n");
genflags (flag_logical_noclobber, curi->size, "val", "", "");
shift_ce (curi->dmode, curi->size);
genastore ("val", curi->dmode, "dstreg", curi->size, "data");
}
printf ("\tint ccnt = cnt & 63;\n");
printf ("\tcnt &= 63;\n");
- printf ("\tCLEAR_CZNV;\n");
+ printf ("\tCLEAR_CZNV (®s->ccrflags);\n");
if (source_is_imm1_8 (curi))
printf ("{");
else {
}
printf ("\tcnt--;\n");
printf ("\t{\n\tuae_u32 carry;\n");
- printf ("\tuae_u32 hival = (val << 1) | GET_XFLG;\n");
+ printf ("\tuae_u32 hival = (val << 1) | GET_XFLG (®s->ccrflags);\n");
printf ("\thival <<= (%d - cnt);\n", bit_size (curi->size) - 1);
printf ("\tval >>= cnt;\n");
printf ("\tcarry = val & 1;\n");
printf ("\tval >>= 1;\n");
printf ("\tval |= hival;\n");
- printf ("\tSET_XFLG (carry);\n");
+ printf ("\tSET_XFLG (®s->ccrflags, carry);\n");
printf ("\tval &= %s;\n", bit_mask (curi->size));
printf ("\t} }\n");
- printf ("\tSET_CFLG (GET_XFLG);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, GET_XFLG (®s->ccrflags));\n");
genflags (flag_logical_noclobber, curi->size, "val", "", "");
shift_ce (curi->dmode, curi->size);
genastore ("val", curi->dmode, "dstreg", curi->size, "data");
printf ("\tuae_u32 cflg = val & 1;\n");
printf ("\tval = (val >> 1) | sign;\n");
genflags (flag_logical, curi->size, "val", "", "");
- printf ("\tSET_CFLG (cflg);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, cflg);\n");
duplicate_carry (0);
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
printf ("\tval <<= 1;\n");
genflags (flag_logical, curi->size, "val", "", "");
printf ("\tsign2 = %s & val;\n", cmask (curi->size));
- printf ("\tSET_CFLG (sign != 0);\n");
+ printf ("\tSET_CFLG (®s->ccrflags, sign != 0);\n");
duplicate_carry (0);
- printf ("\tSET_VFLG (GET_VFLG | (sign2 != sign));\n");
+ printf ("\tSET_VFLG (®s->ccrflags, GET_VFLG (®s->ccrflags) | (sign2 != sign));\n");
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
case i_LSRW:
printf ("\tuae_u32 carry = val & 1;\n");
printf ("\tval >>= 1;\n");
genflags (flag_logical, curi->size, "val", "", "");
- printf ("SET_CFLG (carry);\n");
+ printf ("SET_CFLG (®s->ccrflags, carry);\n");
duplicate_carry (0);
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
printf ("\tuae_u32 carry = val & %s;\n", cmask (curi->size));
printf ("\tval <<= 1;\n");
genflags (flag_logical, curi->size, "val", "", "");
- printf ("SET_CFLG (carry >> %d);\n", bit_size (curi->size) - 1);
+ printf ("SET_CFLG (®s->ccrflags, carry >> %d);\n", bit_size (curi->size) - 1);
duplicate_carry (0);
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
printf ("\tval <<= 1;\n");
printf ("\tif (carry) val |= 1;\n");
genflags (flag_logical, curi->size, "val", "", "");
- printf ("SET_CFLG (carry >> %d);\n", bit_size (curi->size) - 1);
+ printf ("SET_CFLG (®s->ccrflags, carry >> %d);\n", bit_size (curi->size) - 1);
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
case i_RORW:
printf ("\tval >>= 1;\n");
printf ("\tif (carry) val |= %s;\n", cmask (curi->size));
genflags (flag_logical, curi->size, "val", "", "");
- printf ("SET_CFLG (carry);\n");
+ printf ("SET_CFLG (®s->ccrflags, carry);\n");
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
case i_ROXLW:
}
printf ("\tuae_u32 carry = val & %s;\n", cmask (curi->size));
printf ("\tval <<= 1;\n");
- printf ("\tif (GET_XFLG) val |= 1;\n");
+ printf ("\tif (GET_XFLG (®s->ccrflags)) val |= 1;\n");
genflags (flag_logical, curi->size, "val", "", "");
- printf ("SET_CFLG (carry >> %d);\n", bit_size (curi->size) - 1);
+ printf ("SET_CFLG (®s->ccrflags, carry >> %d);\n", bit_size (curi->size) - 1);
duplicate_carry (0);
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
}
printf ("\tuae_u32 carry = val & 1;\n");
printf ("\tval >>= 1;\n");
- printf ("\tif (GET_XFLG) val |= %s;\n", cmask (curi->size));
+ printf ("\tif (GET_XFLG (®s->ccrflags)) val |= %s;\n", cmask (curi->size));
genflags (flag_logical, curi->size, "val", "", "");
- printf ("SET_CFLG (carry);\n");
+ printf ("SET_CFLG (®s->ccrflags, carry);\n");
duplicate_carry (0);
genastore ("val", curi->smode, "srcreg", curi->size, "data");
break;
fill_prefetch_next ();
start_brace ();
printf ("\tint regno = (src >> 12) & 15;\n");
- printf ("\tuae_u32 *regp = regs.regs + regno;\n");
+ printf ("\tuae_u32 *regp = regs->regs + regno;\n");
printf ("\tif (! m68k_movec2(src & 0xFFF, regp)) goto %s;\n", endlabelstr);
break;
case i_MOVE2C:
fill_prefetch_next ();
start_brace ();
printf ("\tint regno = (src >> 12) & 15;\n");
- printf ("\tuae_u32 *regp = regs.regs + regno;\n");
+ printf ("\tuae_u32 *regp = regs->regs + regno;\n");
printf ("\tif (! m68k_move2c(src & 0xFFF, regp)) goto %s;\n", endlabelstr);
break;
case i_CAS:
printf ("\tint ru = (src >> 6) & 7;\n");
printf ("\tint rc = src & 7;\n");
genflags (flag_cmp, curi->size, "newv", "m68k_dreg(regs, rc)", "dst");
- printf ("\tif (GET_ZFLG)");
+ printf ("\tif (GET_ZFLG (®s->ccrflags))");
old_brace_level = n_braces;
start_brace ();
genastore ("(m68k_dreg(regs, ru))", curi->dmode, "dstreg", curi->size, "dst");
break;
case i_CAS2:
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
- printf ("\tuae_u32 rn1 = regs.regs[(extra >> 28) & 15];\n");
- printf ("\tuae_u32 rn2 = regs.regs[(extra >> 12) & 15];\n");
+ printf ("\tuae_u32 rn1 = regs->regs[(extra >> 28) & 15];\n");
+ printf ("\tuae_u32 rn2 = regs->regs[(extra >> 12) & 15];\n");
if (curi->size == sz_word) {
int old_brace_level = n_braces;
printf ("\tuae_u16 dst1 = get_word(rn1), dst2 = get_word(rn2);\n");
genflags (flag_cmp, curi->size, "newv", "m68k_dreg(regs, (extra >> 16) & 7)", "dst1");
- printf ("\tif (GET_ZFLG) {\n");
+ printf ("\tif (GET_ZFLG (®s->ccrflags)) {\n");
genflags (flag_cmp, curi->size, "newv", "m68k_dreg(regs, extra & 7)", "dst2");
- printf ("\tif (GET_ZFLG) {\n");
+ printf ("\tif (GET_ZFLG (®s->ccrflags)) {\n");
printf ("\tput_word(rn1, m68k_dreg(regs, (extra >> 22) & 7));\n");
printf ("\tput_word(rn1, m68k_dreg(regs, (extra >> 6) & 7));\n");
printf ("\t}}\n");
pop_braces (old_brace_level);
- printf ("\tif (! GET_ZFLG) {\n");
+ printf ("\tif (! GET_ZFLG (®s->ccrflags)) {\n");
printf ("\tm68k_dreg(regs, (extra >> 22) & 7) = (m68k_dreg(regs, (extra >> 22) & 7) & ~0xffff) | (dst1 & 0xffff);\n");
printf ("\tm68k_dreg(regs, (extra >> 6) & 7) = (m68k_dreg(regs, (extra >> 6) & 7) & ~0xffff) | (dst2 & 0xffff);\n");
printf ("\t}\n");
int old_brace_level = n_braces;
printf ("\tuae_u32 dst1 = get_long(rn1), dst2 = get_long(rn2);\n");
genflags (flag_cmp, curi->size, "newv", "m68k_dreg(regs, (extra >> 16) & 7)", "dst1");
- printf ("\tif (GET_ZFLG) {\n");
+ printf ("\tif (GET_ZFLG (®s->ccrflags)) {\n");
genflags (flag_cmp, curi->size, "newv", "m68k_dreg(regs, extra & 7)", "dst2");
- printf ("\tif (GET_ZFLG) {\n");
+ printf ("\tif (GET_ZFLG (®s->ccrflags)) {\n");
printf ("\tput_long(rn1, m68k_dreg(regs, (extra >> 22) & 7));\n");
printf ("\tput_long(rn1, m68k_dreg(regs, (extra >> 6) & 7));\n");
printf ("\t}}\n");
pop_braces (old_brace_level);
- printf ("\tif (! GET_ZFLG) {\n");
+ printf ("\tif (! GET_ZFLG (®s->ccrflags)) {\n");
printf ("\tm68k_dreg(regs, (extra >> 22) & 7) = dst1;\n");
printf ("\tm68k_dreg(regs, (extra >> 6) & 7) = dst2;\n");
printf ("\t}\n");
printf ("\tif (extra & 0x800)\n");
old_brace_level = n_braces;
start_brace ();
- printf ("\tuae_u32 src = regs.regs[(extra >> 12) & 15];\n");
+ printf ("\tuae_u32 src = regs->regs[(extra >> 12) & 15];\n");
genamode (curi->dmode, "dstreg", curi->size, "dst", 2, 0, 0);
genastore ("src", curi->dmode, "dstreg", curi->size, "dst");
pop_braces (old_brace_level);
break;
case i_BKPT: /* only needed for hardware emulators */
sync_m68k_pc ();
- printf ("\top_illg(opcode);\n");
+ printf ("\top_illg(opcode, regs);\n");
break;
case i_CALLM: /* not present in 68030 */
sync_m68k_pc ();
- printf ("\top_illg(opcode);\n");
+ printf ("\top_illg(opcode, regs);\n");
break;
case i_RTM: /* not present in 68030 */
sync_m68k_pc ();
- printf ("\top_illg(opcode);\n");
+ printf ("\top_illg(opcode, regs);\n");
break;
case i_TRAPcc:
if (curi->smode != am_unknown && curi->smode != am_illg)
genamode (curi->smode, "srcreg", curi->size, "dummy", 1, 0, 0);
fill_prefetch_0 ();
- printf ("\tif (cctrue(%d)) { Exception(7,m68k_getpc()); goto %s; }\n", curi->cc, endlabelstr);
+ printf ("\tif (cctrue(®s->ccrflags, %d)) { Exception(7, regs, m68k_getpc(regs)); goto %s; }\n", curi->cc, endlabelstr);
need_endlabel = 1;
break;
case i_DIVL:
sync_m68k_pc ();
start_brace ();
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
genamode (curi->dmode, "dstreg", curi->size, "dst", 1, 0, 0);
sync_m68k_pc ();
printf ("\ttmp = (bf0 << (offset & 7)) | (bf1 >> (8 - (offset & 7)));\n");
}
printf ("\ttmp >>= (32 - width);\n");
- printf ("\tSET_NFLG_ALWAYS (tmp & (1 << (width-1)) ? 1 : 0);\n");
- printf ("\tSET_ZFLG (tmp == 0); SET_VFLG (0); SET_CFLG (0);\n");
+ printf ("\tSET_NFLG_ALWAYS (®s->ccrflags, tmp & (1 << (width-1)) ? 1 : 0);\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, tmp == 0); SET_VFLG (®s->ccrflags, 0); SET_CFLG (®s->ccrflags, 0);\n");
switch (curi->mnemo) {
case i_BFTST:
break;
printf ("\ttmp = ~tmp;\n");
break;
case i_BFEXTS:
- printf ("\tif (GET_NFLG) tmp |= width == 32 ? 0 : (-1 << width);\n");
+ printf ("\tif (GET_NFLG (®s->ccrflags)) tmp |= width == 32 ? 0 : (-1 << width);\n");
printf ("\tm68k_dreg(regs, (extra >> 12) & 7) = tmp;\n");
break;
case i_BFCLR:
break;
case i_BFINS:
printf ("\ttmp = m68k_dreg(regs, (extra >> 12) & 7);\n");
- printf ("\tSET_NFLG (tmp & (1 << (width - 1)) ? 1 : 0);\n");
- printf ("\tSET_ZFLG (tmp == 0);\n");
+ printf ("\tSET_NFLG (®s->ccrflags, tmp & (1 << (width - 1)) ? 1 : 0);\n");
+ printf ("\tSET_ZFLG (®s->ccrflags, tmp == 0);\n");
break;
default:
break;
fpulimit();
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tfpp_opp(opcode,extra);\n");
+ printf ("\tfpp_opp(opcode, regs, extra);\n");
break;
case i_FDBcc:
fpulimit();
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tfdbcc_opp(opcode,extra);\n");
+ printf ("\tfdbcc_opp(opcode, regs, extra);\n");
break;
case i_FScc:
fpulimit();
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tfscc_opp(opcode,extra);\n");
+ printf ("\tfscc_opp(opcode, regs, extra);\n");
break;
case i_FTRAPcc:
fpulimit();
sync_m68k_pc ();
start_brace ();
- printf ("\tuaecptr oldpc = m68k_getpc();\n");
+ printf ("\tuaecptr oldpc = m68k_getpc(regs);\n");
if (curi->smode != am_unknown && curi->smode != am_illg)
genamode (curi->smode, "srcreg", curi->size, "dummy", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tftrapcc_opp(opcode,oldpc);\n");
+ printf ("\tftrapcc_opp(opcode, regs, oldpc);\n");
break;
case i_FBcc:
fpulimit();
sync_m68k_pc ();
start_brace ();
- printf ("\tuaecptr pc = m68k_getpc();\n");
+ printf ("\tuaecptr pc = m68k_getpc(regs);\n");
genamode (curi->dmode, "srcreg", curi->size, "extra", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tfbcc_opp(opcode,pc,extra);\n");
+ printf ("\tfbcc_opp(opcode,regs, pc,extra);\n");
break;
case i_FSAVE:
fpulimit();
sync_m68k_pc ();
- printf ("\tfsave_opp(opcode);\n");
+ printf ("\tfsave_opp(opcode, regs);\n");
break;
case i_FRESTORE:
fpulimit();
sync_m68k_pc ();
- printf ("\tfrestore_opp(opcode);\n");
+ printf ("\tfrestore_opp(opcode, regs);\n");
break;
case i_CINVL:
case i_MMUOP:
genamode (curi->smode, "srcreg", curi->size, "extra", 1, 0, 0);
sync_m68k_pc ();
- printf ("\tmmu_op(opcode,extra);\n");
+ printf ("\tmmu_op(opcode, regs, extra);\n");
break;
default:
abort ();
{
fprintf (f, "#include \"sysconfig.h\"\n");
fprintf (f, "#include \"sysdeps.h\"\n");
- fprintf (f, "#include \"config.h\"\n");
fprintf (f, "#include \"options.h\"\n");
fprintf (f, "#include \"memory.h\"\n");
fprintf (f, "#include \"custom.h\"\n");
fprintf (f, "#include \"cputbl.h\"\n");
fprintf (f, "#define CPUFUNC(x) x##_ff\n"
- "#define SET_CFLG_ALWAYS(x) SET_CFLG(x)\n"
- "#define SET_NFLG_ALWAYS(x) SET_NFLG(x)\n"
+ "#define SET_CFLG_ALWAYS(flags, x) SET_CFLG(flags, x)\n"
+ "#define SET_NFLG_ALWAYS(flags, x) SET_NFLG(flags, x)\n"
"#ifdef NOFLAGS\n"
"#include \"noflags.h\"\n"
"#endif\n");
printf ("/* %s */\n", outopcode (opcode));
if (i68000)
printf("#ifndef CPUEMU_68000_ONLY\n");
- printf ("%s REGPARAM2 CPUFUNC(op_%04lx_%d)(uae_u32 opcode)\n{\n", using_ce ? "void" : "unsigned long", opcode, postfix);
+ printf ("%s REGPARAM2 CPUFUNC(op_%04lx_%d)(uae_u32 opcode, struct regstruct *regs)\n{\n", using_ce ? "void" : "unsigned long", opcode, postfix);
switch (table68k[opcode].stype) {
case 0: smsk = 7; break;
}
if (i > 0 && i < 4)
fprintf (stblfile, "#ifndef CPUEMU_68000_ONLY\n");
- fprintf (stblfile, "struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix);
+ fprintf (stblfile, "const struct cputbl CPUFUNC(op_smalltbl_%d)[] = {\n", postfix);
generate_func ();
if (i > 0 && i < 4)
fprintf (stblfile, "#endif /* CPUEMU_68000_ONLY */\n");
--- /dev/null
+/*
+ * E-UAE - The portable Amiga Emulator
+ *
+ * Generate pixel output code.
+ *
+ * (c) 2006 Richard Drummond
+ */
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+/* Output for big-endian target if true, little-endian is false. */
+int do_bigendian;
+
+typedef enum
+{
+ DEPTH_8BPP,
+ DEPTH_16BPP,
+ DEPTH_32BPP,
+} DEPTH_T;
+#define DEPTH_MAX DEPTH_32BPP
+
+static const char *get_depth_str (DEPTH_T bpp)
+{
+ if (bpp == DEPTH_8BPP)
+ return "8";
+ else if (bpp == DEPTH_16BPP)
+ return "16";
+ else
+ return "32";
+}
+
+static const char *get_depth_type_str (DEPTH_T bpp)
+{
+ if (bpp == DEPTH_8BPP)
+ return "uae_u8";
+ else if (bpp == DEPTH_16BPP)
+ return "uae_u16";
+ else
+ return "uae_u32";
+}
+
+
+typedef enum
+{
+ HMODE_NORMAL,
+ HMODE_DOUBLE,
+ HMODE_HALVE,
+ HMODE_HALVE2
+} HMODE_T;
+#define HMODE_MAX HMODE_HALVE2
+
+static const char *get_hmode_str (HMODE_T hmode)
+{
+ if (hmode == HMODE_DOUBLE)
+ return "_stretch1";
+ else if (hmode == HMODE_HALVE)
+ return "_shrink1";
+ else if (hmode == HMODE_HALVE2)
+ return "_shrink2";
+ else
+ return "";
+}
+
+
+typedef enum
+{
+ CMODE_NORMAL,
+ CMODE_DUALPF,
+ CMODE_EXTRAHB,
+ CMODE_HAM
+} CMODE_T;
+#define CMODE_MAX CMODE_HAM
+
+
+static FILE *outfile;
+static unsigned int outfile_indent = 0;
+
+void set_outfile (FILE *f)
+{
+ outfile = f;
+}
+
+int set_indent (int indent)
+{
+ int old_indent = outfile_indent;
+ outfile_indent = indent;
+ return old_indent;
+}
+
+void outln (const char *s)
+{
+ unsigned int i;
+ for (i = 0; i < outfile_indent; i++)
+ fputc (' ', outfile);
+ fprintf (outfile, "%s\n", s);
+}
+
+void outlnf (const char *s, ...)
+{
+ va_list ap;
+ unsigned int i;
+ for (i = 0; i < outfile_indent; i++)
+ fputc (' ', outfile);
+ va_start (ap, s);
+ vfprintf (outfile, s, ap);
+ fputc ('\n', outfile);
+}
+
+static void out_linetoscr_decl (DEPTH_T bpp, HMODE_T hmode, int aga)
+{
+ outlnf ("static int NOINLINE linetoscr_%s%s%s (int spix, int dpix, int stoppos)",
+ get_depth_str (bpp),
+ get_hmode_str (hmode), aga ? "_aga" : "");
+}
+
+static void out_linetoscr_do_srcpix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode)
+{
+ if (aga && cmode != CMODE_DUALPF)
+ outln ( " spix_val = pixdata.apixels[spix] ^ xor_val;");
+ else if (cmode != CMODE_HAM)
+ outln ( " spix_val = pixdata.apixels[spix];");
+}
+
+static void out_linetoscr_do_dstpix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode)
+{
+ if (aga && cmode == CMODE_HAM)
+ outln ( " dpix_val = CONVERT_RGB (ham_linebuf[spix]);");
+ else if (cmode == CMODE_HAM)
+ outln ( " dpix_val = xcolors[ham_linebuf[spix]];");
+ else if (aga && cmode == CMODE_DUALPF) {
+ outln ( " if (spriteagadpfpixels[spix]) {");
+ outln ( " dpix_val = colors_for_drawing.acolors[spriteagadpfpixels[spix]];");
+ outln ( " spriteagadpfpixels[spix] = 0;");
+ outln ( " } else {");
+ outln ( " unsigned int val = lookup[spix_val];");
+ outln ( " if (lookup_no[spix_val] == 2)");
+ outln ( " val += dblpfofs[bpldualpf2of];");
+ outln ( " val ^= xor_val;");
+ outln ( " dpix_val = colors_for_drawing.acolors[val];");
+ outln ( " }");
+ } else if (cmode == CMODE_DUALPF) {
+ outln ( " dpix_val = colors_for_drawing.acolors[lookup[spix_val]];");
+ } else if (aga && cmode == CMODE_EXTRAHB) {
+ outln ( " if (spix_val >= 32 && spix_val < 64) {");
+ outln ( " unsigned int c = (colors_for_drawing.color_regs_aga[spix_val - 32] >> 1) & 0x7F7F7F;");
+ outln ( " dpix_val = CONVERT_RGB (c);");
+ outln ( " } else");
+ outln ( " dpix_val = colors_for_drawing.acolors[spix_val];");
+ } else if (cmode == CMODE_EXTRAHB) {
+ outln ( " if (spix_val <= 31)");
+ outln ( " dpix_val = colors_for_drawing.acolors[spix_val];");
+ outln ( " else");
+ outln ( " dpix_val = xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];");
+ } else
+ outln ( " dpix_val = colors_for_drawing.acolors[spix_val];");
+}
+
+static void out_linetoscr_do_incspix (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode)
+{
+ if (hmode == HMODE_HALVE2) {
+ outln ( " spix++;");
+ outln ( " tmp_val = dpix_val;");
+ out_linetoscr_do_srcpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_dstpix (bpp, hmode, aga, cmode);
+ outlnf ( " dpix_val = merge_2pixel%d (dpix_val, tmp_val);", bpp == 0 ? 8 : bpp == 1 ? 16 : 32);
+ outln ( " spix++;");
+ } else if (hmode == HMODE_HALVE)
+ outln ( " spix += 2;");
+ else
+ outln ( " spix++;");
+}
+
+static void out_linetoscr_mode (DEPTH_T bpp, HMODE_T hmode, int aga, CMODE_T cmode)
+{
+ int old_indent = set_indent (8);
+
+ if (aga && cmode == CMODE_DUALPF) {
+ outln ( "int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;");
+ outln ( "int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;");
+ } else if (cmode == CMODE_DUALPF)
+ outln ( "int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;");
+
+
+ /* TODO: add support for combining pixel writes in 8-bpp modes. */
+
+ if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE) {
+ outln ( "int rem;");
+ outln ( "if (((long)&buf[dpix]) & 2) {");
+ outln ( " uae_u32 spix_val;");
+ outln ( " uae_u32 dpix_val;");
+ if (hmode == HMODE_HALVE2)
+ outln ( " uae_u32 tmp_val;");
+
+ out_linetoscr_do_srcpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_dstpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_incspix (bpp, hmode, aga, cmode);
+
+ outln ( " buf[dpix++] = dpix_val;");
+ outln ( "}");
+ outln ( "if (dpix >= stoppos)");
+ outln ( " return spix;");
+ outln ( "rem = (((long)&buf[stoppos]) & 2);");
+ outln ( "if (rem)");
+ outln ( " stoppos--;");
+ }
+
+
+ outln ( "while (dpix < stoppos) {");
+ outln ( " uae_u32 spix_val;");
+ outln ( " uae_u32 dpix_val;");
+ outln ( " uae_u32 out_val;");
+ if (hmode == HMODE_HALVE2)
+ outln ( " uae_u32 tmp_val;");
+ outln ( "");
+
+ out_linetoscr_do_srcpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_dstpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_incspix (bpp, hmode, aga, cmode);
+
+ outln ( " out_val = dpix_val;");
+
+ if (hmode != HMODE_DOUBLE && bpp == DEPTH_16BPP) {
+ out_linetoscr_do_srcpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_dstpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_incspix (bpp, hmode, aga, cmode);
+
+ if (do_bigendian)
+ outln ( " out_val = (out_val << 16) | (dpix_val & 0xFFFF);");
+ else
+ outln ( " out_val = (out_val & 0xFFFF) | (dpix_val << 16);");
+ }
+
+ if (hmode == HMODE_DOUBLE) {
+ if (bpp == DEPTH_8BPP) {
+ outln ( " *((uae_u16 *)&buf[dpix]) = (uae_u16) out_val;");
+ outln ( " dpix += 2;");
+ } else if (bpp == DEPTH_16BPP) {
+ outln ( " *((uae_u32 *)&buf[dpix]) = out_val;");
+ outln ( " dpix += 2;");
+ } else {
+ outln ( " buf[dpix++] = out_val;");
+ outln ( " buf[dpix++] = out_val;");
+ }
+ } else {
+ if (bpp == DEPTH_16BPP) {
+ outln ( " *((uae_u32 *)&buf[dpix]) = out_val;");
+ outln ( " dpix += 2;");
+ } else
+ outln ( " buf[dpix++] = out_val;");
+ }
+
+ outln ( "}");
+
+
+ if (bpp == DEPTH_16BPP && hmode != HMODE_DOUBLE) {
+ outln ( "if (rem) {");
+ outln ( " uae_u32 spix_val;");
+ outln ( " uae_u32 dpix_val;");
+ if (hmode == HMODE_HALVE2)
+ outln ( " uae_u32 tmp_val;");
+
+ out_linetoscr_do_srcpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_dstpix (bpp, hmode, aga, cmode);
+ out_linetoscr_do_incspix (bpp, hmode, aga, cmode);
+
+ outln ( " buf[dpix++] = dpix_val;");
+ outln ( "}");
+ }
+
+ set_indent (old_indent);
+
+ return;
+}
+
+static void out_linetoscr (DEPTH_T bpp, HMODE_T hmode, int aga)
+{
+ if (aga)
+ outln ("#ifdef AGA");
+
+ out_linetoscr_decl (bpp, hmode, aga);
+ outln ( "{");
+
+ outlnf ( " %s *buf = (%s *) xlinebuffer;", get_depth_type_str (bpp), get_depth_type_str (bpp));
+ if (aga)
+ outln ( " uae_u8 xor_val = (uae_u8)(dp_for_drawing->bplcon4 >> 8);");
+ outln ( "");
+
+ outln ( " if (dp_for_drawing->ham_seen) {");
+ out_linetoscr_mode (bpp, hmode, aga, CMODE_HAM);
+ outln ( " } else if (bpldualpf) {");
+ out_linetoscr_mode (bpp, hmode, aga, CMODE_DUALPF);
+ outln ( " } else if (bplehb) {");
+ out_linetoscr_mode (bpp, hmode, aga, CMODE_EXTRAHB);
+ outln ( " } else {");
+ out_linetoscr_mode (bpp, hmode, aga, CMODE_NORMAL);
+
+ outln ( " }\n");
+ outln ( " return spix;");
+ outln ( "}");
+
+ if (aga)
+ outln ( "#endif");
+ outln ( "");
+}
+
+int main (int argc, char *argv[])
+{
+ DEPTH_T bpp;
+ int aga;
+ HMODE_T hmode;
+ unsigned int i;
+
+ do_bigendian = 0;
+
+ for (i = 1; i < argc; i++) {
+ if (argv[i][0] != '-')
+ continue;
+ if (argv[i][1] == 'b' && argv[i][2] == '\0')
+ do_bigendian = 1;
+ }
+
+ set_outfile (stdout);
+
+ outln ("/*");
+ outln (" * E-UAE - The portable Amiga emulator.");
+ outln (" *");
+ outln (" * This file was generated by genlinetoscr. Don't edit.");
+ outln (" */");
+ outln ("");
+
+ for (bpp = DEPTH_8BPP; bpp <= DEPTH_MAX; bpp++) {
+ for (aga = 0; aga <= 1 ; aga++) {
+ for (hmode = HMODE_NORMAL; hmode <= HMODE_MAX; hmode++)
+ out_linetoscr (bpp, hmode, aga);
+ }
+ }
+ return 0;
+}
#include <assert.h>
-#include "config.h"
#include "options.h"
#include "threaddep/thread.h"
#include "memory.h"
#include "xwin.h"
#include "autoconf.h"
#include "osemu.h"
-#include "osdep/exectasks.h"
#ifdef USE_EXECLIB
#include "sysconfig.h"
#include "sysdeps.h"
-#include "options.h"
#include "custom.h"
#include "xwin.h"
};
-unsigned long doMask (int p, int bits, int shift)
+unsigned int doMask (int p, int bits, int shift)
{
/* scale to 0..255, shift to align msb with mask, and apply mask */
unsigned long val = p << 24;
return n;
}
-unsigned long doMask256 (int p, int bits, int shift)
+unsigned int doMask256 (int p, int bits, int shift)
{
/* p is a value from 0 to 255 (Amiga color value)
* shift to align msb with mask, and apply mask */
}
#endif
-void alloc_colors64k (int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha)
+void alloc_colors64k (int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap)
{
+ int bpp = rw + gw + bw + aw;
int i;
for (i = 0; i < 4096; i++) {
g = greyscale (g);
b = greyscale (b);
xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs) | doAlpha (alpha, aw, as);
+ if (byte_swap) {
+ if (bpp <= 16)
+ xcolors[i] = bswap_16 (xcolors[i]);
+ else
+ xcolors[i] = bswap_32 (xcolors[i]);
+ }
+ if (bpp <= 16) {
+ /* Fill upper 16 bits of each colour value
+ * with a copy of the colour. */
+ xcolors[i] |= xcolors[i] * 0x00010001;
+ }
}
#ifdef AGA
/* create AGA color tables */
xgreencolors[i] = greyscale (doColor (i, gw, gs)) | doAlpha (alpha, aw, as);
xbluecolors[i] = greyscale (doColor (i, bw, bs)) | doAlpha (alpha, aw, as);
}
+ if (byte_swap) {
+ if (bpp <= 16) {
+ xredcolors [i] = bswap_16 (xredcolors[i]);
+ xgreencolors[i] = bswap_16 (xgreencolors[i]);
+ xbluecolors [i] = bswap_16 (xbluecolors[i]);
+ } else {
+ xredcolors [i] = bswap_32 (xredcolors[i]);
+ xgreencolors[i] = bswap_32 (xgreencolors[i]);
+ xbluecolors [i] = bswap_32 (xbluecolors[i]);
+ }
+ }
+ if (bpp <= 16) {
+ /* Fill upper 16 bits of each colour value with
+ * a copy of the colour. */
+ xredcolors [i] = xredcolors [i] * 0x00010001;
+ xgreencolors[i] = xgreencolors[i] * 0x00010001;
+ xbluecolors [i] = xbluecolors [i] * 0x00010001;
+ }
+
#endif
xredcolor_b = rw;
xgreencolor_b = gw;
xbluecolor_m = (1 << bw) - 1;
}
-static int allocated[4096];
static int color_diff[4096];
static int newmaxcol = 0;
xcolnr *map;
for (i = 0; i < 4096; i++)
- xcolors[i] = i;
+ xcolors[i] = i << 16 | i;
map = (xcolnr *)malloc (sizeof(xcolnr) * maxcol);
if (!map) {
}
for (i = 0; i < 4096; i++)
- xcolors[i] = i;
+ xcolors[i] = i << 16 | i;
/*
* compute #cols per components
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "threaddep/thread.h"
#include "options.h"
#include "memory.h"
#include "newcpu.h"
#include "disk.h"
#include "autoconf.h"
+#include "traps.h"
#include "filesys.h"
#include "execlib.h"
#include "native2amiga.h"
#define ASYNC_REQUEST_TEMP 1
#define ASYNC_REQUEST_CHANGEINT 10
-static struct hardfileprivdata {
+struct hardfileprivdata {
volatile uaecptr d_request[MAX_ASYNC_REQUESTS];
volatile int d_request_type[MAX_ASYNC_REQUESTS];
volatile uae_u32 d_request_data[MAX_ASYNC_REQUESTS];
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
}
-#if 0 // not yet production ready
-
static uae_u64 cmd_read (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
{
addrbank *bank_data = &get_mem_bank (dataptr);
return hdf_write (hfd, bank_data->xlateaddr (dataptr), offset, len);
}
-#else
-
-static uae_u64 cmd_read (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
-{
- uae_u64 got = 0;
- uae_u8 buffer[FILESYS_MAX_BLOCKSIZE];
- int i;
-
- gui_hd_led (1);
- hf_log2 ("cmd_read: %p %04.4x-%08.8x %08.8x\n", dataptr, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)len);
- while (len > 0) {
- int got2;
- got2 = hdf_read (hfd, buffer, offset, hfd->blocksize);
- if (got2 != hfd->blocksize)
- break;
- for (i = 0; i < got2; i++)
- put_byte(dataptr + i, buffer[i]);
- len -= got2;
- got += got2;
- dataptr += got2;
- offset += got2;
- }
- return got;
-}
-static uae_u64 cmd_write (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
-{
- uae_u64 got = 0;
- uae_u8 buffer[FILESYS_MAX_BLOCKSIZE];
- int i;
-
- gui_hd_led (1);
- hf_log2 ("cmd_write: %p %04.4x-%08.8x %08.8x\n", dataptr, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)len);
- while (len > 0) {
- int got2;
- for (i = 0; i < hfd->blocksize; i++)
- buffer[i] = get_byte (dataptr + i);
- got2 = hdf_write (hfd, buffer, offset, hfd->blocksize);
- if (got2 != hfd->blocksize)
- break;
- len -= got2;
- got += got2;
- dataptr += got2;
- offset += got2;
- }
- return got;
-}
-
-#endif
-
static int handle_scsi (uaecptr request, struct hardfiledata *hfd)
{
uae_u32 acmd = get_long (request + 40);
ls = 12;
break;
default:
- lr = -1;
+ lr = -1;
write_log ("UAEHF: unsupported scsi command 0x%02.2X\n", cmd);
status = 2; /* CHECK CONDITION */
s[0] = 0x70;
return -1;
}
-static uae_u32 hardfile_open (void)
+static uae_u32 REGPARAM2 hardfile_open (TrapContext *context)
{
- uaecptr tmp1 = m68k_areg(regs, 1); /* IOReq */
- int unit = mangleunit (m68k_dreg (regs, 0));
+ uaecptr tmp1 = m68k_areg(&context->regs, 1); /* IOReq */
+ int unit = mangleunit (m68k_dreg (&context->regs, 0));
struct hardfileprivdata *hfpd = &hardfpd[unit];
+ int err = -1;
- hf_log ("hardfile_open, unit %d (%d)\n", unit, m68k_dreg (regs, 0));
/* Check unit number */
if (unit >= 0 && get_hardfile_data (unit) && start_thread (unit)) {
hfpd->opencount++;
- put_word (m68k_areg(regs, 6) + 32, get_word (m68k_areg(regs, 6) + 32) + 1);
+ put_word (m68k_areg(&context->regs, 6) + 32, get_word (m68k_areg(&context->regs, 6) + 32) + 1);
put_long (tmp1 + 24, unit); /* io_Unit */
put_byte (tmp1 + 31, 0); /* io_Error */
put_byte (tmp1 + 8, 7); /* ln_type = NT_REPLYMSG */
+ hf_log ("hardfile_open, unit %d (%d), OK\n", unit, m68k_dreg (&context->regs, 0));
return 0;
}
-
- put_long (tmp1 + 20, (uae_u32)-1);
- put_byte (tmp1 + 31, (uae_u8)-1);
- return (uae_u32)-1;
+ if (is_hardfile(NULL, unit) == FILESYS_VIRTUAL)
+ err = -6;
+ hf_log ("hardfile_open, unit %d (%d), ERR=%d\n", unit, m68k_dreg (&context->regs, 0), err);
+ put_long (tmp1 + 20, (uae_u32)err);
+ put_byte (tmp1 + 31, (uae_u8)err);
+ return (uae_u32)err;
}
-static uae_u32 hardfile_close (void)
+static uae_u32 REGPARAM2 hardfile_close (TrapContext *context)
{
- uaecptr request = m68k_areg(regs, 1); /* IOReq */
+ uaecptr request = m68k_areg(&context->regs, 1); /* IOReq */
int unit = mangleunit (get_long (request + 24));
struct hardfileprivdata *hfpd = &hardfpd[unit];
- if (!hfpd->opencount) return 0;
+ if (!hfpd->opencount)
+ return 0;
hfpd->opencount--;
if (hfpd->opencount == 0)
write_comm_pipe_u32 (&hfpd->requests, 0, 1);
- put_word (m68k_areg(regs, 6) + 32, get_word (m68k_areg(regs, 6) + 32) - 1);
+ put_word (m68k_areg(&context->regs, 6) + 32, get_word (m68k_areg(&context->regs, 6) + 32) - 1);
return 0;
}
-static uae_u32 hardfile_expunge (void)
+static uae_u32 REGPARAM2 hardfile_expunge (TrapContext *context)
{
return 0; /* Simply ignore this one... */
}
switch (cmd)
{
case CMD_READ:
-#if 0
- if (dataptr & 1)
- goto bad_command;
-#endif
offset = get_long (request + 44);
len = get_long (request + 36); /* io_Length */
if ((offset & bmask) || (len & bmask)) {
case TD_READ64:
case NSCMD_TD_READ64:
-#if 0
- if (dataptr & 1)
- goto bad_command;
-#endif
offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
len = get_long (request + 36); /* io_Length */
if ((offset64 & bmask) || (len & bmask)) {
if (hfd->readonly) {
error = 28; /* write protect */
} else {
-#if 0
- if (dataptr & 1)
- goto bad_command;
-#endif
offset = get_long (request + 44);
len = get_long (request + 36); /* io_Length */
if ((offset & bmask) || (len & bmask)) {
if (hfd->readonly) {
error = 28; /* write protect */
} else {
-#if 0
- if (dataptr & 1)
- goto bad_command;
-#endif
offset64 = get_long (request + 44) | ((uae_u64)get_long (request + 32) << 32);
len = get_long (request + 36); /* io_Length */
if ((offset64 & bmask) || (len & bmask)) {
break;
case HD_SCSICMD: /* SCSI */
- if (hfd->nrcyls == 0)
+ if (hfd->nrcyls == 0) {
error = handle_scsi (request, hfd);
- else /* we don't want users trashing their "partition" hardfiles with hdtoolbox */
- error = -3; /* io_Error */
+ } else { /* we don't want users trashing their "partition" hardfiles with hdtoolbox */
+ error = -3; /* IOERR_NOCMD */
+ write_log ("UAEHF: HD_SCSICMD tried on regular HDF, unit %d", unit);
+ }
break;
default:
return async;
}
-static uae_u32 hardfile_abortio (void)
+static uae_u32 REGPARAM2 hardfile_abortio (TrapContext *context)
{
- uae_u32 request = m68k_areg(regs, 1);
+ uae_u32 request = m68k_areg(&context->regs, 1);
int unit = mangleunit (get_long (request + 24));
struct hardfiledata *hfd = get_hardfile_data (unit);
struct hardfileprivdata *hfpd = &hardfpd[unit];
return hardfile_can_quick (command);
}
-static uae_u32 hardfile_beginio (void)
+static uae_u32 REGPARAM2 hardfile_beginio (TrapContext *context)
{
- uae_u32 request = m68k_areg(regs, 1);
+ uae_u32 request = m68k_areg(&context->regs, 1);
uae_u8 flags = get_byte (request + 30);
int cmd = get_word (request + 28);
int unit = mangleunit (get_long (request + 24));
{
struct hardfileprivdata *hfpd = devs;
- set_thread_priority (2);
+ uae_set_thread_priority (2);
hfpd->thread_running = 1;
uae_sem_post (&hfpd->sync_sem);
for (;;) {
if (hfpd->opencount > 0) {
for (j = 0; j < MAX_ASYNC_REQUESTS; j++) {
uaecptr request;
- if (request = hfpd->d_request[i])
+ if ((request = hfpd->d_request[i]))
abort_async (hfpd, request, 0, 0);
}
}
#include "memory.h"
#include "identify.h"
-struct mem_labels int_labels[] =
+const struct mem_labels int_labels[] =
{
{ "Reset:SSP", 0x0000 },
{ "EXECBASE", 0x0004 },
{ 0, 0 }
};
-struct mem_labels trap_labels[] =
+const struct mem_labels trap_labels[] =
{
{ "TRAP 00", 0x0080 },
{ "TRAP 01", 0x0084 },
{ 0, 0 }
};
-struct mem_labels mem_labels[] =
+const struct mem_labels mem_labels[] =
{
{ "CIAB PRA", 0xBFD000 },
{ "CIAB PRB", 0xBFD100 },
/* This table was generated from the list of AGA chip names in
* AGA.guide available on aminet. It could well have errors in it. */
-struct customData custd[] =
+const struct customData custd[] =
{
#if 0
{ "BLTDDAT", 0xdff000 }, /* Blitter dest. early read (dummy address) */
extern void akiko_exitgui (void);
extern void AKIKO_hsync_handler (void);
+extern uae_u32 REGPARAM3 akiko_lget (uaecptr addr) REGPARAM;
+extern uae_u32 REGPARAM3 akiko_wget (uaecptr addr) REGPARAM;
+extern uae_u32 REGPARAM3 akiko_bget (uaecptr addr) REGPARAM;
+extern void REGPARAM3 akiko_bput (uaecptr addr, uae_u32 value) REGPARAM;
+extern void REGPARAM3 akiko_wput (uaecptr addr, uae_u32 value) REGPARAM;
+extern void REGPARAM3 akiko_lput (uaecptr addr, uae_u32 value) REGPARAM;
+
extern int cd32_enabled;
extern uae_u8 *extendedkickmemory;
extern void action_replay_cleanup (void);
extern void action_replay_chipwrite(void);
extern void action_replay_map_banks(void);
-extern void REGPARAM2 chipmem_lput_actionreplay23 (uaecptr addr, uae_u32 l) REGPARAM;
-extern void REGPARAM2 chipmem_wput_actionreplay23 (uaecptr addr, uae_u32 w) REGPARAM;
-extern void REGPARAM2 chipmem_bput_actionreplay1 (uaecptr addr, uae_u32 b) REGPARAM;
-extern void REGPARAM2 chipmem_wput_actionreplay1 (uaecptr addr, uae_u32 w) REGPARAM;
-extern void REGPARAM2 chipmem_lput_actionreplay1 (uaecptr addr, uae_u32 l) REGPARAM;
+extern void REGPARAM3 chipmem_lput_actionreplay23 (uaecptr addr, uae_u32 l) REGPARAM;
+extern void REGPARAM3 chipmem_wput_actionreplay23 (uaecptr addr, uae_u32 w) REGPARAM;
+extern void REGPARAM3 chipmem_bput_actionreplay1 (uaecptr addr, uae_u32 b) REGPARAM;
+extern void REGPARAM3 chipmem_wput_actionreplay1 (uaecptr addr, uae_u32 w) REGPARAM;
+extern void REGPARAM3 chipmem_lput_actionreplay1 (uaecptr addr, uae_u32 l) REGPARAM;
extern void action_replay_version(void);
* (c) 1996 Ed Hanway
*/
-typedef uae_u32 (*TrapFunction) (void);
-
-extern int lasttrap;
-extern uae_u8 *rtarea;
-extern void do_emultrap (int nr);
-
extern uae_u32 addr (int);
extern void db (uae_u8);
extern void dw (uae_u16);
extern void dl (uae_u32);
-extern uae_u32 ds (char *);
+extern uae_u32 ds (const char *);
extern void calltrap (uae_u32);
extern void org (uae_u32);
extern uae_u32 here (void);
-extern int deftrap2 (TrapFunction func, int mode, const char *str);
-extern int deftrap (TrapFunction);
+
+#define deftrap(f) define_trap((f), 0, "")
+#ifdef TRACE_TRAPS
+# define deftrap2(f, mode, str) define_trap((f), (mode), (str))
+#else
+# define deftrap2(f, mode, str) define_trap((f), (mode), "")
+#endif
+
extern void align (int);
-extern uae_u32 CallLib (uaecptr base, uae_s16 offset);
-extern void call_calltrap (int nr) REGPARAM;
extern volatile int uae_int_requested;
extern void set_uae_int_flag (void);
extern void expansion_init (void);
extern void expansion_cleanup (void);
-extern uae_u8* rtarea;
-
#define TRAPFLAG_NO_REGSAVE 1
#define TRAPFLAG_NO_RETVAL 2
#define TRAPFLAG_EXTRA_STACK 4
#define TRAPFLAG_DORET 8
-extern uaecptr libemu_InstallFunction (TrapFunction, uaecptr, int, const char *);
-extern uaecptr libemu_InstallFunctionFlags (TrapFunction, uaecptr, int, int, const char *);
-
#define RTAREA_BASE 0xF00000
* (c) 1995 Bernd Schmidt
*/
-#if 0
-struct bltinfo {
- int blitzero;
- int blitashift,blitbshift,blitdownashift,blitdownbshift;
- uae_u32 bltadat, bltbdat, bltcdat,bltddat,bltahold,bltbhold,bltafwm,bltalwm;
- int vblitsize,hblitsize;
- int bltamod,bltbmod,bltcmod,bltdmod;
-};
-#else
struct bltinfo {
int blitzero;
int blitashift,blitbshift,blitdownashift,blitdownbshift;
int vblitsize,hblitsize;
int bltamod,bltbmod,bltcmod,bltdmod;
};
-#endif
+
extern enum blitter_states {
BLT_done, BLT_init, BLT_read, BLT_work, BLT_write, BLT_next
} bltstate;
#define BLITTER_MAX_WORDS 2048
-extern blitter_func *blitfunc_dofast[256];
-extern blitter_func *blitfunc_dofast_desc[256];
+extern blitter_func * const blitfunc_dofast[256];
+extern blitter_func * const blitfunc_dofast_desc[256];
extern uae_u32 blit_masktable[BLITTER_MAX_WORDS];
#define BLIT_MODE_IMMEDIATE -1
void *hAsyncTask; /* async task handle */
void *hEvent; /* thread event handle */
unsigned int *mtable; /* window messages allocated for asynchronous event notification */
+#else
+ uae_sem_t sem; /* semaphore to notify the socket thread of work */
+ uae_thread_id thread; /* socket thread */
+ int sockabort[2]; /* pipe used to tell the thread to abort a select */
+ int action;
+ int s; /* for accept */
+ uae_u32 name; /* For gethostbyname */
+ uae_u32 a_addr; /* gethostbyaddr, accept */
+ uae_u32 a_addrlen; /* for gethostbyaddr, accept */
+ uae_u32 flags;
+ void *buf;
+ uae_u32 len;
+ uae_u32 to, tolen, from, fromlen;
+ int nfds;
+ uae_u32 sets [3];
+ uae_u32 timeout;
+ uae_u32 sigmp;
#endif
} *socketbases;
struct UAEBSDBase {
char dummy[LIBRARY_SIZEOF];
- uae_u32 sb[sizeof (void*) / 4];
+ struct socketbase *sb;
char scratchbuf[SCRATCHBUFSIZE];
};
#define SF_BLOCKING 0x80000000
#define SF_BLOCKINGINPROGRESS 0x40000000
-struct socketbase *get_socketbase (void);
-
-extern uae_u32 addstr (uae_u32 *, char *);
-extern uae_u32 addmem (uae_u32 *, char *, int len);
+extern uae_u32 addstr (uae_u32 *, const char *);
+extern uae_u32 addmem (uae_u32 *, const char *, int len);
extern char *strncpyah (char *, uae_u32, int);
extern char *strcpyah (char *, uae_u32);
-extern uae_u32 strcpyha (uae_u32, char *);
-extern uae_u32 strncpyha (uae_u32, char *, int);
+extern uae_u32 strcpyha (uae_u32, const char *);
+extern uae_u32 strncpyha (uae_u32, const char *, int);
#define SB struct socketbase *sb
-extern void seterrno (SB, int);
-extern void setherrno (SB, int);
+extern void bsdsocklib_seterrno (SB, int);
+extern void bsdsocklib_setherrno (SB, int);
extern void sockmsg (unsigned int, WPARAM, LPARAM);
extern void sockabort (SB);
extern SOCKET_TYPE getsock (SB, int);
extern void releasesock (SB, int);
-extern void waitsig (SB);
-extern void cancelsig (SB);
+extern void waitsig (TrapContext *context, SB);
+extern void cancelsig (TrapContext *context, SB);
-extern int host_sbinit (SB);
+extern int host_sbinit (TrapContext*, SB);
extern void host_sbcleanup (SB);
extern void host_sbreset (void);
extern void host_closesocketquick (SOCKET_TYPE);
extern int host_socket (SB, int, int, int);
extern uae_u32 host_bind (SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_listen (SB, uae_u32, uae_u32);
-extern void host_accept (SB, uae_u32, uae_u32, uae_u32);
-extern void host_sendto (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
-extern void host_recvfrom (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
+extern void host_accept (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
+extern void host_sendto (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
+extern void host_recvfrom (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown (SB, uae_u32, uae_u32);
extern void host_setsockopt (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockopt (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getsockname (SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_getpeername (SB, uae_u32, uae_u32, uae_u32);
-extern uae_u32 host_IoctlSocket (SB, uae_u32, uae_u32, uae_u32);
+extern uae_u32 host_IoctlSocket (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_shutdown (SB, uae_u32, uae_u32);
-extern int host_CloseSocket (SB, int);
-extern void host_connect (SB, uae_u32, uae_u32, uae_u32);
-extern void host_WaitSelect (SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
+extern int host_CloseSocket (TrapContext *, SB, int);
+extern void host_connect (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
+extern void host_WaitSelect (TrapContext *, SB, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32);
extern uae_u32 host_SetSocketSignals (void);
extern uae_u32 host_getdtablesize (void);
extern uae_u32 host_ObtainSocket (void);
extern uae_u32 host_ReleaseSocket (void);
extern uae_u32 host_ReleaseCopyOfSocket (void);
-extern uae_u32 host_Inet_NtoA (SB, uae_u32);
+extern uae_u32 host_Inet_NtoA (TrapContext *context, SB, uae_u32);
extern uae_u32 host_inet_addr (uae_u32);
extern uae_u32 host_Inet_LnaOf (void);
extern uae_u32 host_Inet_NetOf (void);
extern uae_u32 host_Inet_MakeAddr (void);
extern uae_u32 host_inet_network (void);
-extern void host_gethostbynameaddr (SB, uae_u32, uae_u32, long);
+extern void host_gethostbynameaddr (TrapContext *, SB, uae_u32, uae_u32, long);
extern uae_u32 host_getnetbyname (void);
extern uae_u32 host_getnetbyaddr (void);
-extern void host_getservbynameport (SB, uae_u32, uae_u32, uae_u32);
-extern void host_getprotobyname (SB, uae_u32);
-extern uae_u32 host_getprotobynumber (void);
+extern void host_getservbynameport (TrapContext *, SB, uae_u32, uae_u32, uae_u32);
+extern void host_getprotobyname (TrapContext *, SB, uae_u32);
+extern void host_getprotobynumber (TrapContext *, SB, uae_u32);
extern uae_u32 host_vsyslog (void);
extern uae_u32 host_Dup2Socket (void);
extern uae_u32 host_gethostname (uae_u32, uae_u32);
-
extern void bsdlib_install (void);
extern void bsdlib_reset (void);
extern void dumpcia (void);
extern void rethink_cias (void);
-extern unsigned int ciaaicr,ciaaimask,ciabicr,ciabimask;
-extern unsigned int ciaacra,ciaacrb,ciabcra,ciabcrb;
-extern unsigned int ciabpra;
-extern unsigned long ciaata,ciaatb,ciabta,ciabtb;
-extern unsigned long ciaatod,ciabtod,ciaatol,ciabtol,ciaaalarm,ciabalarm;
-extern int ciaatlatch,ciabtlatch;
extern int parallel_direct_write_data (uae_u8, uae_u8);
extern int parallel_direct_read_data (uae_u8*);
volatile int reader_waiting;
} smp_comm_pipe;
-static __inline__ void init_comm_pipe (smp_comm_pipe *p, int size, int chunks)
+STATIC_INLINE void init_comm_pipe (smp_comm_pipe *p, int size, int chunks)
{
memset (p, 0, sizeof (*p));
p->data = (uae_pt *)malloc (size*sizeof (uae_pt));
uae_sem_init (&p->writer_wait, 0, 0);
}
-static __inline__ void destroy_comm_pipe (smp_comm_pipe *p)
+STATIC_INLINE void destroy_comm_pipe (smp_comm_pipe *p)
{
uae_sem_destroy (&p->lock);
uae_sem_destroy (&p->reader_wait);
uae_sem_destroy (&p->writer_wait);
}
-static __inline__ void maybe_wake_reader (smp_comm_pipe *p, int no_buffer)
+STATIC_INLINE void maybe_wake_reader (smp_comm_pipe *p, int no_buffer)
{
if (p->reader_waiting
&& (no_buffer || ((p->wrp - p->rdp + p->size) % p->size) >= p->chunks))
}
}
-static __inline__ void write_comm_pipe_pt (smp_comm_pipe *p, uae_pt data, int no_buffer)
+STATIC_INLINE void write_comm_pipe_pt (smp_comm_pipe *p, uae_pt data, int no_buffer)
{
int nxwrp = (p->wrp + 1) % p->size;
uae_sem_post (&p->lock);
}
-static __inline__ uae_pt read_comm_pipe_pt_blocking (smp_comm_pipe *p)
+STATIC_INLINE uae_pt read_comm_pipe_pt_blocking (smp_comm_pipe *p)
{
uae_pt data;
/* We ignore chunks here. If this is a problem, make the size bigger in the init call. */
if (p->writer_waiting) {
- write_log ("read_comm_pipe_pt_blocking!\n");
p->writer_waiting = 0;
uae_sem_post (&p->writer_wait);
}
return data;
}
-static __inline__ int comm_pipe_has_data (smp_comm_pipe *p)
+STATIC_INLINE int comm_pipe_has_data (smp_comm_pipe *p)
{
return p->rdp != p->wrp;
}
-static __inline__ int read_comm_pipe_int_blocking (smp_comm_pipe *p)
+STATIC_INLINE int read_comm_pipe_int_blocking (smp_comm_pipe *p)
{
uae_pt foo = read_comm_pipe_pt_blocking (p);
return foo.i;
}
-static __inline__ uae_u32 read_comm_pipe_u32_blocking (smp_comm_pipe *p)
+STATIC_INLINE uae_u32 read_comm_pipe_u32_blocking (smp_comm_pipe *p)
{
uae_pt foo = read_comm_pipe_pt_blocking (p);
return foo.u32;
}
-static __inline__ void *read_comm_pipe_pvoid_blocking (smp_comm_pipe *p)
+STATIC_INLINE void *read_comm_pipe_pvoid_blocking (smp_comm_pipe *p)
{
uae_pt foo = read_comm_pipe_pt_blocking (p);
return foo.pv;
}
-static __inline__ void write_comm_pipe_int (smp_comm_pipe *p, int data, int no_buffer)
+STATIC_INLINE void write_comm_pipe_int (smp_comm_pipe *p, int data, int no_buffer)
{
uae_pt foo;
foo.i = data;
write_comm_pipe_pt (p, foo, no_buffer);
}
-static __inline__ void write_comm_pipe_u32 (smp_comm_pipe *p, int data, int no_buffer)
+STATIC_INLINE void write_comm_pipe_u32 (smp_comm_pipe *p, int data, int no_buffer)
{
uae_pt foo;
foo.u32 = data;
write_comm_pipe_pt (p, foo, no_buffer);
}
-static __inline__ void write_comm_pipe_pvoid (smp_comm_pipe *p, void *data, int no_buffer)
+STATIC_INLINE void write_comm_pipe_pvoid (smp_comm_pipe *p, void *data, int no_buffer)
{
uae_pt foo;
foo.pv = data;
extern void flush(int save_regs);
extern void small_flush(int save_regs);
extern void set_target(uae_u8* t);
-extern uae_u8* get_target(void);
extern void freescratch(void);
extern void build_comp(void);
extern void set_cache_state(int enabled);
#endif
extern void alloc_cache(void);
extern void compile_block(cpu_history* pc_hist, int blocklen, int totcyles);
-extern void lopt_emit_all(void);
extern int check_for_cache_miss(void);
uae_u8 is_addx;
uae_u8 is_const_jump;
} op_properties;
+
extern op_properties prop[65536];
-static __inline__ int end_block(uae_u16 opcode)
+STATIC_INLINE int end_block(uae_u16 opcode)
{
return prop[opcode].is_jump ||
(prop[opcode].is_const_jump && !currprefs.comp_constjump);
#define MENDFUNC(nargs,func,args)
#define COMPCALL(func) func
-#define LOWFUNC(flags,mem,nargs,func,args) static __inline__ void func args
+#define LOWFUNC(flags,mem,nargs,func,args) STATIC_INLINE void func args
#define LENDFUNC(flags,mem,nargs,func,args)
#if USE_OPTIMIZER
DECLARE(mov_l_bRr(R4 d, R4 s, IMM offset));
DECLARE(mov_w_bRr(R4 d, R2 s, IMM offset));
DECLARE(mov_b_bRr(R4 d, R1 s, IMM offset));
-DECLARE(bswap_32(RW4 r));
-DECLARE(bswap_16(RW2 r));
+DECLARE(gen_bswap_32(RW4 r));
+DECLARE(gen_bswap_16(RW2 r));
DECLARE(mov_l_rr(W4 d, R4 s));
DECLARE(mov_l_mr(IMM d, R4 s));
DECLARE(mov_w_mr(IMM d, R2 s));
void exec_nostats(void);
void do_nothing(void);
+void comp_fdbcc_opp (uae_u32 opcode, uae_u16 extra);
+void comp_fscc_opp (uae_u32 opcode, uae_u16 extra);
+void comp_ftrapcc_opp (uae_u32 opcode, uaecptr oldpc);
+void comp_fbcc_opp (uae_u32 opcode);
+void comp_fsave_opp (uae_u32 opcode);
+void comp_frestore_opp (uae_u32 opcode);
+void comp_fpp_opp (uae_u32 opcode, uae_u16 extra);
-STATIC_INLINE uae_u32 get_word_prefetch (int o)
+STATIC_INLINE uae_u32 get_word_prefetch (struct regstruct *regs, int o)
{
- uae_u32 v = regs.irc;
- regs.irc = get_word (m68k_getpc() + o);
+ uae_u32 v = regs->irc;
+ regs->irc = get_word (m68k_getpc(regs) + o);
return v;
}
-STATIC_INLINE uae_u32 get_long_prefetch (int o)
+STATIC_INLINE uae_u32 get_long_prefetch (struct regstruct *regs, int o)
{
- uae_u32 v = get_word_prefetch (o) << 16;
- v |= get_word_prefetch (o + 2);
+ uae_u32 v = get_word_prefetch (regs, o) << 16;
+ v |= get_word_prefetch (regs, o + 2);
return v;
}
return mem_access_delay_byte_read (addr);
}
-STATIC_INLINE uae_u32 get_word_ce_prefetch (int o)
+STATIC_INLINE uae_u32 get_word_ce_prefetch (struct regstruct *regs, int o)
{
- uae_u32 v = regs.irc;
- regs.irc = get_word_ce (m68k_getpc() + o);
+ uae_u32 v = regs->irc;
+ regs->irc = get_word_ce (m68k_getpc(regs) + o);
return v;
}
mem_access_delay_byte_write (addr, v);
}
-STATIC_INLINE void m68k_do_rts_ce (void)
+STATIC_INLINE void m68k_do_rts_ce (struct regstruct *regs)
{
uaecptr pc;
pc = get_word_ce (m68k_areg (regs, 7)) << 16;
pc |= get_word_ce (m68k_areg (regs, 7) + 2);
m68k_areg (regs, 7) += 4;
if (pc & 1)
- exception3 (0x4e75, m68k_getpc(), pc);
+ exception3 (0x4e75, m68k_getpc(regs), pc);
else
- m68k_setpc (pc);
+ m68k_setpc (regs, pc);
}
-STATIC_INLINE void m68k_do_bsr_ce (uaecptr oldpc, uae_s32 offset)
+STATIC_INLINE void m68k_do_bsr_ce (struct regstruct *regs, uaecptr oldpc, uae_s32 offset)
{
m68k_areg (regs, 7) -= 4;
put_word_ce (m68k_areg (regs, 7), oldpc >> 16);
put_word_ce (m68k_areg (regs, 7) + 2, oldpc);
- m68k_incpc (offset);
+ m68k_incpc (regs, offset);
}
-STATIC_INLINE void m68k_do_jsr_ce (uaecptr oldpc, uaecptr dest)
+STATIC_INLINE void m68k_do_jsr_ce (struct regstruct *regs, uaecptr oldpc, uaecptr dest)
{
m68k_areg (regs, 7) -= 4;
put_word_ce (m68k_areg (regs, 7), oldpc >> 16);
put_word_ce (m68k_areg (regs, 7) + 2, oldpc);
- m68k_setpc (dest);
+ m68k_setpc (regs, dest);
}
#endif
\ No newline at end of file
* (c) 1995 Bernd Schmidt
*/
+#include "machdep/rpt.h"
+
/* These are the masks that are ORed together in the chipset_mask option.
* If CSMASK_AGA is set, the ECS bits are guaranteed to be set as well. */
#define CSMASK_ECS_AGNUS 1
uae_u32 get_copper_address(int copno);
-extern void custom_init (void);
+extern int custom_init (void);
extern void customreset (void);
extern int intlev (void);
extern void dumpcustom (void);
extern int maxhpos, maxvpos, minfirstline, vblank_endline, numscrlines;
extern int vblank_hz, fake_vblank_hz, vblank_skip;
-extern unsigned long syncbase;
+extern frame_time_t syncbase;
#define NUMSCRLINES (maxvpos+1-minfirstline+1)
#define DMA_AUD0 0x0001
#ifdef AGA
/* convert 24 bit AGA Amiga RGB to native color */
-/* warning: ugly and works with little-endian cpu's only */
-#define CONVERT_RGB(c) \
+/* warning: this is still ugly, but now works with either byte order */
+#ifdef WORDS_BIGENDIAN
+# define CONVERT_RGB(c) \
+ ( xbluecolors[((uae_u8*)(&c))[3]] | xgreencolors[((uae_u8*)(&c))[2]] | xredcolors[((uae_u8*)(&c))[1]] )
+#else
+# define CONVERT_RGB(c) \
( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] )
+#endif
#else
#define CONVERT_RGB(c) 0
#endif
struct color_change {
int linepos;
int regno;
- unsigned long value;
+ unsigned int value;
};
/* 440 rather than 880, since sprites are always lores. */
uae_u32 words[2 * MAX_SPR_PIXELS / 4];
};
extern union sps_union spixstate;
+
+#ifdef OS_WITHOUT_MEMORY_MANAGEMENT
+extern uae_u16 *spixels;
+#else
extern uae_u16 spixels[MAX_SPR_PIXELS * 2];
+#endif
/* Way too much... */
#define MAX_REG_CHANGE ((MAXVPOS + 1) * 2 * MAXHPOS)
extern volatile frame_time_t vsynctime, vsyncmintime;
extern void reset_frame_rate_hack (void);
extern int rpt_available;
-extern unsigned long syncbase;
+extern frame_time_t syncbase;
extern void compute_vsynctime (void);
extern void init_eventtab (void);
8: AGA only
*/
-extern struct mem_labels mem_labels[];
-extern struct mem_labels int_labels[];
-extern struct mem_labels trap_labels[];
-extern struct customData custd[];
+extern const struct mem_labels mem_labels[];
+extern const struct mem_labels int_labels[];
+extern const struct mem_labels trap_labels[];
+extern const struct customData custd[];
extern int special_mem;
#define S_READ 1
#define S_WRITE 2
-#endif
extern void *cache_alloc (int);
extern void cache_free (void*);
+extern int canbang;
+void init_shm (void);
+#endif
+
#ifdef ADDRESS_SPACE_24BIT
#define MEMORY_BANKS 256
+#define MEMORY_RANGE_MASK ((1<<24)-1)
#else
#define MEMORY_BANKS 65536
+#define MEMORY_RANGE_MASK (~0)
#endif
-typedef uae_u32 (*mem_get_func)(uaecptr) REGPARAM;
-typedef void (*mem_put_func)(uaecptr, uae_u32) REGPARAM;
-typedef uae_u8 *(*xlate_func)(uaecptr) REGPARAM;
-typedef int (*check_func)(uaecptr, uae_u32) REGPARAM;
+typedef uae_u32 (REGPARAM3 *mem_get_func)(uaecptr) REGPARAM;
+typedef void (REGPARAM3 *mem_put_func)(uaecptr, uae_u32) REGPARAM;
+typedef uae_u8 *(REGPARAM3 *xlate_func)(uaecptr) REGPARAM;
+typedef int (REGPARAM3 *check_func)(uaecptr, uae_u32) REGPARAM;
extern char *address_space, *good_address_map;
extern uae_u8 *chipmemory;
/* Default memory access functions */
-extern int default_check(uaecptr addr, uae_u32 size) REGPARAM;
-extern uae_u8 *default_xlate(uaecptr addr) REGPARAM;
+extern int REGPARAM3 default_check(uaecptr addr, uae_u32 size) REGPARAM;
+extern uae_u8 *REGPARAM3 default_xlate(uaecptr addr) REGPARAM;
#define bankindex(addr) (((uaecptr)(addr)) >> 16)
extern addrbank *mem_banks[MEMORY_BANKS];
+
+#ifdef JIT
extern uae_u8 *baseaddr[MEMORY_BANKS];
+#endif
+
#define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
+
+#ifdef JIT
#define put_mem_bank(addr, b, realstart) do { \
(mem_banks[bankindex(addr)] = (b)); \
if ((b)->baseaddr) \
else \
baseaddr[bankindex(addr)] = (uae_u8*)(((long)b)+1); \
} while (0)
+#else
+#define put_mem_bank(addr, b, realstart) \
+ (mem_banks[bankindex(addr)] = (b));
+#endif
extern void memory_init (void);
extern void memory_cleanup (void);
extern void map_banks (addrbank *bank, int first, int count, int realsize);
extern void map_overlay (int chip);
-#ifndef NO_INLINE_MEMORY_ACCESS
-
#define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
#define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
#define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
#define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
#define byteput(addr,b) (call_mem_put_func(get_mem_bank(addr).bput, addr, b))
-#else
-
-extern uae_u32 alongget(uaecptr addr);
-extern uae_u32 awordget(uaecptr addr);
-extern uae_u32 longget(uaecptr addr);
-extern uae_u32 wordget(uaecptr addr);
-extern uae_u32 byteget(uaecptr addr);
-extern void longput(uaecptr addr, uae_u32 l);
-extern void wordput(uaecptr addr, uae_u32 w);
-extern void byteput(uaecptr addr, uae_u32 b);
-
-#endif
-
-#ifndef MD_HAVE_MEM_1_FUNCS
-
-#define longget_1 longget
-#define wordget_1 wordget
-#define byteget_1 byteget
-#define longput_1 longput
-#define wordput_1 wordput
-#define byteput_1 byteput
-
-#endif
-
STATIC_INLINE uae_u32 get_long(uaecptr addr)
{
- return longget_1(addr);
+ return longget(addr);
}
STATIC_INLINE uae_u32 get_word(uaecptr addr)
{
- return wordget_1(addr);
+ return wordget(addr);
}
STATIC_INLINE uae_u32 get_byte(uaecptr addr)
{
- return byteget_1(addr);
+ return byteget(addr);
+}
+
+/*
+ * Read a host pointer from addr
+ */
+#if SIZEOF_VOID_P == 4
+# define get_pointer(addr) ((void *)get_long(addr))
+#else
+# if SIZEOF_VOID_P == 8
+STATIC_INLINE void *get_pointer (uaecptr addr)
+{
+ const unsigned int n = SIZEOF_VOID_P / 4;
+ union {
+ void *ptr;
+ uae_u32 longs[SIZEOF_VOID_P / 4];
+ } p;
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+#ifdef WORDS_BIGENDIAN
+ p.longs[i] = get_long (addr + i * 4);
+#else
+ p.longs[n - 1 - i] = get_long (addr + i * 4);
+#endif
+ }
+ return p.ptr;
}
+# else
+# error "Unknown or unsupported pointer size."
+# endif
+#endif
+
STATIC_INLINE void put_long(uaecptr addr, uae_u32 l)
{
- longput_1(addr, l);
+ longput(addr, l);
}
STATIC_INLINE void put_word(uaecptr addr, uae_u32 w)
{
- wordput_1(addr, w);
+ wordput(addr, w);
}
STATIC_INLINE void put_byte(uaecptr addr, uae_u32 b)
{
- byteput_1(addr, b);
+ byteput(addr, b);
}
+/*
+ * Store host pointer v at addr
+ */
+#if SIZEOF_VOID_P == 4
+# define put_pointer(addr, p) (put_long((addr), (uae_u32)(p)))
+#else
+# if SIZEOF_VOID_P == 8
+STATIC_INLINE void put_pointer (uaecptr addr, void *v)
+{
+ const unsigned int n = SIZEOF_VOID_P / 4;
+ union {
+ void *ptr;
+ uae_u32 longs[SIZEOF_VOID_P / 4];
+ } p;
+ unsigned int i;
+
+ p.ptr = v;
+
+ for (i = 0; i < n; i++) {
+#ifdef WORDS_BIGENDIAN
+ put_long (addr + i * 4, p.longs[i]);
+#else
+ put_long (addr + i * 4, p.longs[n - 1 - i]);
+#endif
+ }
+}
+# endif
+#endif
+
STATIC_INLINE uae_u8 *get_real_address(uaecptr addr)
{
return get_mem_bank(addr).xlateaddr(addr);
}
/* For faster access in custom chip emulation. */
-extern uae_u32 chipmem_lget (uaecptr) REGPARAM;
-extern uae_u32 chipmem_wget (uaecptr) REGPARAM;
-extern uae_u32 chipmem_bget (uaecptr) REGPARAM;
-extern void chipmem_lput (uaecptr, uae_u32) REGPARAM;
-extern void chipmem_wput (uaecptr, uae_u32) REGPARAM;
-extern void chipmem_bput (uaecptr, uae_u32) REGPARAM;
-
-extern uae_u32 chipmem_agnus_lget (uaecptr) REGPARAM;
-extern uae_u32 chipmem_agnus_wget (uaecptr) REGPARAM;
-extern uae_u32 chipmem_agnus_bget (uaecptr) REGPARAM;
-extern void chipmem_agnus_lput (uaecptr, uae_u32) REGPARAM;
-extern void chipmem_agnus_wput (uaecptr, uae_u32) REGPARAM;
-extern void chipmem_agnus_bput (uaecptr, uae_u32) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_lget (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_wget (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_bget (uaecptr) REGPARAM;
+extern void REGPARAM3 chipmem_lput (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_wput (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_bput (uaecptr, uae_u32) REGPARAM;
+
+extern uae_u32 REGPARAM3 chipmem_agnus_lget (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_agnus_wget (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_agnus_bget (uaecptr) REGPARAM;
+extern void REGPARAM3 chipmem_agnus_lput (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_agnus_wput (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_agnus_bput (uaecptr, uae_u32) REGPARAM;
extern uae_u32 chipmem_mask, kickmem_mask;
extern uae_u8 *kickmemory;
extern addrbank dummy_bank;
/* 68020+ Chip RAM DMA contention emulation */
-extern uae_u32 chipmem_lget_ce2 (uaecptr) REGPARAM;
-extern uae_u32 chipmem_wget_ce2 (uaecptr) REGPARAM;
-extern uae_u32 chipmem_bget_ce2 (uaecptr) REGPARAM;
-extern void chipmem_lput_ce2 (uaecptr, uae_u32) REGPARAM;
-extern void chipmem_wput_ce2 (uaecptr, uae_u32) REGPARAM;
-extern void chipmem_bput_c2 (uaecptr, uae_u32) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_lget_ce2 (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_wget_ce2 (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_bget_ce2 (uaecptr) REGPARAM;
+extern void REGPARAM3 chipmem_lput_ce2 (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_wput_ce2 (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_bput_c2 (uaecptr, uae_u32) REGPARAM;
#ifdef NATMEM_OFFSET
#endif
-extern int canbang;
-
extern uae_u8 *mapped_malloc (size_t, char *);
extern void mapped_free (uae_u8 *);
extern void clearexec (void);
* function has to be setup with deftrap2() and
* TRAPFLAG_EXTRA_STACK and stack magic is required.
*/
-uaecptr uae_AllocMem (uae_u32 size, uae_u32 flags);
-void uae_FreeMem (uaecptr memory, uae_u32 size);
+uaecptr uae_AllocMem (TrapContext *context, uae_u32 size, uae_u32 flags);
+void uae_FreeMem (TrapContext *context, uaecptr memory, uae_u32 size);
/*
extern smp_comm_pipe native2amiga_pending;
#endif
-STATIC_INLINE do_uae_int_requested(void)
+STATIC_INLINE void do_uae_int_requested (void)
{
- uae_int_requested = 1;
- set_uae_int_flag ();
- INTREQ (0x8000 | 0x0008);
+ uae_int_requested = 1;
+ set_uae_int_flag ();
+ INTREQ (0x8000 | 0x0008);
}
#ifndef SET_CFLG
-#define SET_CFLG(x) (CFLG = (x))
-#define SET_NFLG(x) (NFLG = (x))
-#define SET_VFLG(x) (VFLG = (x))
-#define SET_ZFLG(x) (ZFLG = (x))
-#define SET_XFLG(x) (XFLG = (x))
-
-#define GET_CFLG CFLG
-#define GET_NFLG NFLG
-#define GET_VFLG VFLG
-#define GET_ZFLG ZFLG
-#define GET_XFLG XFLG
-
-#define CLEAR_CZNV do { \
- SET_CFLG (0); \
- SET_ZFLG (0); \
- SET_NFLG (0); \
- SET_VFLG (0); \
+#define SET_CFLG(regs, x) (CFLG(regs) = (x))
+#define SET_NFLG(regs, x) (NFLG(regs) = (x))
+#define SET_VFLG(regs, x) (VFLG(regs) = (x))
+#define SET_ZFLG(regs, x) (ZFLG(regs) = (x))
+#define SET_XFLG(regs, x) (XFLG(regs) = (x))
+
+#define GET_CFLG(regs) CFLG(regs)
+#define GET_NFLG(regs) NFLG(regs)
+#define GET_VFLG(regs) VFLG(regs)
+#define GET_ZFLG(regs) ZFLG(regs)
+#define GET_XFLG(regs) XFLG(regs)
+
+#define CLEAR_CZNV(regs) do { \
+ SET_CFLG (regs, 0); \
+ SET_ZFLG (regs, 0); \
+ SET_NFLG (regs, 0); \
+ SET_VFLG (regs, 0); \
} while (0)
-#define COPY_CARRY (SET_XFLG (GET_CFLG))
+#define COPY_CARRY(regs) (SET_XFLG (regs, GET_CFLG (regs)))
#endif
-extern int areg_byteinc[];
-extern int imm8_table[];
+extern const int areg_byteinc[];
+extern const int imm8_table[];
extern int movem_index1[256];
extern int movem_index2[256];
extern int fpp_movem_next[256];
#endif
-typedef unsigned long cpuop_func (uae_u32) REGPARAM;
-typedef void cpuop_func_ce (uae_u32) REGPARAM;
+struct regstruct;
+
+typedef unsigned long REGPARAM3 cpuop_func (uae_u32, struct regstruct *regs) REGPARAM;
+typedef void REGPARAM3 cpuop_func_ce (uae_u32, struct regstruct *regs) REGPARAM;
struct cputbl {
cpuop_func *handler;
-#ifndef JIT
uae_u16 opcode;
-#else
+};
+
+#ifdef JIT
+typedef unsigned long REGPARAM3 compop_func (uae_u32) REGPARAM;
+
+struct comptbl {
+ compop_func *handler;
uae_u32 opcode;
int specific;
-#endif
};
+#endif
-extern unsigned long op_illg (uae_u32) REGPARAM;
+extern unsigned long REGPARAM3 op_illg (uae_u32, struct regstruct *regs) REGPARAM;
typedef char flagtype;
extern struct regstruct
{
uae_u32 regs[16];
- uaecptr usp,isp,msp;
+ struct flag_struct ccrflags;
+
+ uae_u32 pc;
+ uae_u8 *pc_p;
+ uae_u8 *pc_oldp;
+
+ uaecptr usp, isp, msp;
uae_u16 sr;
flagtype t1;
flagtype t0;
flagtype stopped;
int intmask;
- uae_u32 pc;
- uae_u8 *pc_p;
- uae_u8 *pc_oldp;
-
uae_u32 vbr,sfc,dfc;
#ifdef FPUEMU
fptype fp[8];
fptype fp_result;
- uae_u32 fpcr,fpsr,fpiar;
+ uae_u32 fpcr,fpsr, fpiar;
uae_u32 fpsr_highbyte;
#endif
extern int irqdelay[15];
extern int mmu_enabled, mmu_triggered;
-STATIC_INLINE void set_special (uae_u32 x)
+STATIC_INLINE void set_special (struct regstruct *regs, uae_u32 x)
{
- regs.spcflags |= x;
+ regs->spcflags |= x;
cycles_do_special();
}
-STATIC_INLINE void unset_special (uae_u32 x)
+STATIC_INLINE void unset_special (struct regstruct *regs, uae_u32 x)
{
- regs.spcflags &= ~x;
+ regs->spcflags &= ~x;
}
-#define m68k_dreg(r,num) ((r).regs[(num)])
-#define m68k_areg(r,num) (((r).regs + 8)[(num)])
+#define m68k_dreg(r,num) ((r)->regs[(num)])
+#define m68k_areg(r,num) (((r)->regs + 8)[(num)])
-STATIC_INLINE void m68k_setpc (uaecptr newpc)
+STATIC_INLINE void m68k_setpc (struct regstruct *regs, uaecptr newpc)
{
- regs.pc_p = regs.pc_oldp = get_real_address (newpc);
- regs.pc = newpc;
+ regs->pc_p = regs->pc_oldp = get_real_address (newpc);
+ regs->pc = newpc;
}
-STATIC_INLINE uaecptr m68k_getpc (void)
+STATIC_INLINE uaecptr m68k_getpc (struct regstruct *regs)
{
- return regs.pc + (uaecptr)(((char *)regs.pc_p - (char *)regs.pc_oldp));
+ return regs->pc + ((char *)regs->pc_p - (char *)regs->pc_oldp);
}
+#define M68K_GETPC m68k_getpc(®s)
-STATIC_INLINE uaecptr m68k_getpc_p (uae_u8 *p)
+STATIC_INLINE uaecptr m68k_getpc_p (struct regstruct *regs, uae_u8 *p)
{
- return regs.pc + (uaecptr)(((char *)p - (char *)regs.pc_oldp));
+ return regs->pc + ((char *)p - (char *)regs->pc_oldp);
}
-#define get_ibyte(o) do_get_mem_byte((uae_u8 *)(regs.pc_p + (o) + 1))
-#define get_iword(o) do_get_mem_word((uae_u16 *)(regs.pc_p + (o)))
-#define get_ilong(o) do_get_mem_long((uae_u32 *)(regs.pc_p + (o)))
+#define get_ibyte(regs, o) do_get_mem_byte((uae_u8 *)((regs)->pc_p + (o) + 1))
+#define get_iword(regs, o) do_get_mem_word((uae_u16 *)((regs)->pc_p + (o)))
+#define get_ilong(regs, o) do_get_mem_long((uae_u32 *)((regs)->pc_p + (o)))
-#define m68k_incpc(o) (regs.pc_p += (o))
+#define m68k_incpc(regs, o) ((regs)->pc_p += (o))
/* These are only used by the 68020/68881 code, and therefore don't
* need to handle prefetch. */
-STATIC_INLINE uae_u32 next_ibyte (void)
+STATIC_INLINE uae_u32 next_ibyte (struct regstruct *regs)
{
- uae_u32 r = get_ibyte (0);
- m68k_incpc (2);
+ uae_u32 r = get_ibyte (regs, 0);
+ m68k_incpc (regs, 2);
return r;
}
-STATIC_INLINE uae_u32 next_iword (void)
+STATIC_INLINE uae_u32 next_iword (struct regstruct *regs)
{
- uae_u32 r = get_iword (0);
- m68k_incpc (2);
+ uae_u32 r = get_iword (regs, 0);
+ m68k_incpc (regs, 2);
return r;
}
-STATIC_INLINE uae_u32 next_ilong (void)
+STATIC_INLINE uae_u32 next_ilong (struct regstruct *regs)
{
- uae_u32 r = get_ilong (0);
- m68k_incpc (4);
+ uae_u32 r = get_ilong (regs, 0);
+ m68k_incpc (regs, 4);
return r;
}
-STATIC_INLINE void m68k_do_rts(void)
+STATIC_INLINE void m68k_do_rts(struct regstruct *regs)
{
- m68k_setpc(get_long(m68k_areg(regs, 7)));
+ m68k_setpc(regs, get_long(m68k_areg(regs, 7)));
m68k_areg(regs, 7) += 4;
}
-STATIC_INLINE void m68k_do_bsr(uaecptr oldpc, uae_s32 offset)
+STATIC_INLINE void m68k_do_bsr(struct regstruct *regs, uaecptr oldpc, uae_s32 offset)
{
m68k_areg(regs, 7) -= 4;
put_long(m68k_areg(regs, 7), oldpc);
- m68k_incpc(offset);
+ m68k_incpc(regs, offset);
}
-STATIC_INLINE void m68k_do_jsr(uaecptr oldpc, uaecptr dest)
+STATIC_INLINE void m68k_do_jsr(struct regstruct *regs, uaecptr oldpc, uaecptr dest)
{
m68k_areg(regs, 7) -= 4;
put_long(m68k_areg(regs, 7), oldpc);
- m68k_setpc(dest);
+ m68k_setpc(regs, dest);
}
-#define m68k_setpc_fast m68k_setpc
-#define m68k_setpc_bcc m68k_setpc
-#define m68k_setpc_rte m68k_setpc
-
-STATIC_INLINE void m68k_setstopped (int stop)
+STATIC_INLINE void m68k_setstopped (struct regstruct *regs, int stop)
{
- regs.stopped = stop;
+ regs->stopped = stop;
/* A traced STOP instruction drops through immediately without
actually stopping. */
- if (stop && (regs.spcflags & SPCFLAG_DOTRACE) == 0)
- set_special (SPCFLAG_STOP);
+ if (stop && (regs->spcflags & SPCFLAG_DOTRACE) == 0)
+ set_special (regs, SPCFLAG_STOP);
}
-extern uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp);
-extern uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp);
+extern uae_u32 REGPARAM3 get_disp_ea_020 (struct regstruct *regs, uae_u32 base, uae_u32 dp) REGPARAM;
+extern uae_u32 REGPARAM3 get_disp_ea_000 (struct regstruct *regs, uae_u32 base, uae_u32 dp) REGPARAM;
+extern void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr);
+extern void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt);
-extern void MakeSR (void);
-extern void MakeFromSR (void);
-extern void Exception (int, uaecptr);
+extern void REGPARAM3 MakeSR (struct regstruct *regs) REGPARAM;
+extern void REGPARAM3 MakeFromSR (struct regstruct *regs) REGPARAM;
+extern void REGPARAM3 Exception (int, struct regstruct *regs, uaecptr) REGPARAM;
extern void Interrupt (int nr);
extern void dump_counts (void);
extern int m68k_move2c (int, uae_u32 *);
extern void m68k_go (int);
extern void m68k_dumpstate (void *, uaecptr *);
extern void m68k_disasm (void *, uaecptr, uaecptr *, int);
-extern void m68k_disasm_ea (void *, uaecptr, uaecptr *, int, uaecptr *, uaecptr *);
extern void sm68k_disasm(char *, char *, uaecptr addr, uaecptr *nextpc);
extern void m68k_reset (void);
extern int getDivu68kCycles(uae_u32 dividend, uae_u16 divisor);
extern int getDivs68kCycles(uae_s32 dividend, uae_s16 divisor);
-extern void mmu_op (uae_u32, uae_u16);
+extern void mmu_op (uae_u32, struct regstruct *regs, uae_u16);
-extern void fpp_opp (uae_u32, uae_u16);
-extern void fdbcc_opp (uae_u32, uae_u16);
-extern void fscc_opp (uae_u32, uae_u16);
-extern void ftrapcc_opp (uae_u32,uaecptr);
-extern void fbcc_opp (uae_u32, uaecptr, uae_u32);
-extern void fsave_opp (uae_u32);
-extern void frestore_opp (uae_u32);
+extern void fpp_opp (uae_u32, struct regstruct *regs, uae_u16);
+extern void fdbcc_opp (uae_u32, struct regstruct *regs, uae_u16);
+extern void fscc_opp (uae_u32, struct regstruct *regs, uae_u16);
+extern void ftrapcc_opp (uae_u32, struct regstruct *regs, uaecptr);
+extern void fbcc_opp (uae_u32, struct regstruct *regs, uaecptr, uae_u32);
+extern void fsave_opp (uae_u32, struct regstruct *regs);
+extern void frestore_opp (uae_u32, struct regstruct *regs);
+extern uae_u32 fpp_get_fpsr (const struct regstruct *regs);
extern void exception3 (uae_u32 opcode, uaecptr addr, uaecptr fault);
extern void exception3i (uae_u32 opcode, uaecptr addr, uaecptr fault);
extern void exception2 (uaecptr addr, uaecptr fault);
extern void cpureset (void);
-extern void fill_prefetch_slow (void);
+extern void fill_prefetch_slow (struct regstruct *regs);
#define CPU_OP_NAME(a) op ## a
/* 68040 */
-extern struct cputbl op_smalltbl_0_ff[];
+extern const struct cputbl op_smalltbl_0_ff[];
/* 68020 + 68881 */
-extern struct cputbl op_smalltbl_1_ff[];
+extern const struct cputbl op_smalltbl_1_ff[];
/* 68020 */
-extern struct cputbl op_smalltbl_2_ff[];
+extern const struct cputbl op_smalltbl_2_ff[];
/* 68010 */
-extern struct cputbl op_smalltbl_3_ff[];
+extern const struct cputbl op_smalltbl_3_ff[];
/* 68000 */
-extern struct cputbl op_smalltbl_4_ff[];
+extern const struct cputbl op_smalltbl_4_ff[];
/* 68000 slow but compatible. */
-extern struct cputbl op_smalltbl_5_ff[];
+extern const struct cputbl op_smalltbl_5_ff[];
/* 68000 slow but compatible and cycle-exact. */
-extern struct cputbl op_smalltbl_6_ff[];
+extern const struct cputbl op_smalltbl_6_ff[];
extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl");
*/
#define UAEMAJOR 1
-#define UAEMINOR 3
-#define UAESUBREV 2
+#define UAEMINOR 4
+#define UAESUBREV 0
typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang;
extern uae_u8 *restore_filesys (uae_u8 *src);
extern uae_u8 *save_filesys (int num, int *len);
-extern void restore_cram (int, long);
-extern void restore_bram (int, long);
-extern void restore_fram (int, long);
-extern void restore_zram (int, long);
-extern void restore_pram (int, long);
-extern void restore_ram (long, uae_u8*);
+extern void restore_cram (int, size_t);
+extern void restore_bram (int, size_t);
+extern void restore_fram (int, size_t);
+extern void restore_zram (int, size_t);
+extern void restore_pram (int, size_t);
+extern void restore_ram (size_t, uae_u8*);
extern uae_u8 *save_cram (int *);
extern uae_u8 *save_bram (int *);
extern void serial_init(void);
extern void serial_exit(void);
extern void serial_dtr_off(void);
+extern void serial_dtr_on (void);
extern uae_u16 SERDATR(void);
extern int SERDATS(void);
#define FILEFLAG_SCRIPT 0x20
#define FILEFLAG_PURE 0x40
+#ifdef REGPARAM2
+#undef REGPARAM2
+#endif
+#define REGPARAM2 __fastcall
+#define REGPARAM3 __fastcall
#define REGPARAM
#include <io.h>
* Best to leave this as it is.
*/
#define CPU_EMU_SIZE 0
+
+/*
+ * Byte-swapping functions
+ */
+
+/* Try to use system bswap_16/bswap_32 functions. */
+#if defined HAVE_BSWAP_16 && defined HAVE_BSWAP_32
+# include <byteswap.h>
+# ifdef HAVE_BYTESWAP_H
+# include <byteswap.h>
+# endif
+#else
+/* Else, if using SDL, try SDL's endian functions. */
+# ifdef USE_SDL
+# include <SDL_endian.h>
+# define bswap_16(x) SDL_Swap16(x)
+# define bswap_32(x) SDL_Swap32(x)
+# else
+/* Otherwise, we'll roll our own. */
+# define bswap_16(x) (((x) >> 8) | (((x) & 0xFF) << 8))
+# define bswap_32(x) (((x) << 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) >> 24))
+# endif
+#endif
--- /dev/null
+ /*
+ * E-UAE - The portable Amiga Emulator
+ *
+ * Support for traps
+ *
+ * Copyright Richard Drummond 2005
+ *
+ * Based on code:
+ * Copyright 1995, 1996 Bernd Schmidt
+ * Copyright 1996 Ed Hanway
+ */
+
+#ifndef TRAPS_H
+#define TRAPS_H
+
+/*
+ * Data passed to a trap handler
+ */
+typedef struct TrapContext
+{
+ struct regstruct regs;
+} TrapContext;
+
+
+#define TRAPFLAG_NO_REGSAVE 1
+#define TRAPFLAG_NO_RETVAL 2
+#define TRAPFLAG_EXTRA_STACK 4
+#define TRAPFLAG_DORET 8
+
+/*
+ * A function which handles a 68k trap
+ */
+typedef uae_u32 (REGPARAM3 *TrapHandler) (TrapContext *) REGPARAM;
+
+
+/*
+ * Interface with 68k interpreter
+ */
+extern void REGPARAM3 m68k_handle_trap (unsigned int trap_num, struct regstruct *) REGPARAM;
+
+unsigned int define_trap (TrapHandler handler_func, int flags, const char *name);
+
+/*
+ * Call a 68k Library function from an extended trap
+ */
+extern uae_u32 CallLib (TrapContext *context, uaecptr library_base, uae_s16 func_offset);
+
+/*
+ * Initialization
+ */
+void init_traps (void);
+void init_extended_traps (void);
+
+#endif
#define UAEEXE_NOMEM 2
extern void uaeexe_install(void);
-extern int uaeexe(char *cmd);
+extern int uaeexe(const char *cmd);
* Copyright 1995-1997 Bernd Schmidt
*/
-typedef long int xcolnr;
+typedef uae_u32 xcolnr;
typedef int (*allocfunc_type)(int, int, int, xcolnr *);
extern int bits_in_mask (unsigned long mask);
extern int mask_shift (unsigned long mask);
-extern unsigned long doMask (int p, int bits, int shift);
-extern unsigned long doMask256 (int p, int bits, int shift);
+extern unsigned int doMask (int p, int bits, int shift);
+extern unsigned int doMask256 (int p, int bits, int shift);
extern void setup_maxcol (int);
extern void alloc_colors256 (int (*)(int, int, int, xcolnr *));
-extern void alloc_colors64k (int, int, int, int, int, int, int, int, int);
+extern void alloc_colors64k (int, int, int, int, int, int, int, int, int, int);
extern void setup_greydither (int bits, allocfunc_type allocfunc);
extern void setup_greydither_maxcol (int maxcol, allocfunc_type allocfunc);
extern void setup_dither (int bits, allocfunc_type allocfunc);
struct vidbuf_description
{
+ /* Function implemented by graphics driver */
+ void (*flush_line) (struct vidbuf_description *gfxinfo, int line_no);
+ void (*flush_block) (struct vidbuf_description *gfxinfo, int first_line, int end_line);
+ void (*flush_screen) (struct vidbuf_description *gfxinfo, int first_line, int end_line);
+ void (*flush_clear_screen) (struct vidbuf_description *gfxinfo);
+ int (*lockscr) (struct vidbuf_description *gfxinfo);
+ void (*unlockscr) (struct vidbuf_description *gfxinfo);
+
/* The graphics code has a choice whether it wants to use a large buffer
* for the whole display, or only a small buffer for a single line.
* If you use a large buffer:
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "keyboard.h"
#include "inputdevice.h"
#define DIR_DOWN 8
struct inputevent {
- char *confname;
- char *name;
+ const char *confname;
+ const char *name;
int allow_mask;
int type;
int unit;
int i;
if (potgo_logging)
- write_log ("W:%d: %04.4X %p\n", vpos, v, m68k_getpc());
+ write_log ("W:%d: %04.4X %p\n", vpos, v, M68K_GETPC);
#ifdef DONGLE_DEBUG
if (notinrom ())
write_log ("POTGO %04.4X %s\n", v, debuginfo(0));
write_log ("POTGOR %04.4X %s\n", v, debuginfo(0));
#endif
if (potgo_logging)
- write_log("R:%d:%04.4X %d %p\n", vpos, v, cd32_shifter[1], m68k_getpc());
+ write_log("R:%d:%04.4X %d %p\n", vpos, v, cd32_shifter[1], M68K_GETPC);
return v;
}
#include "sysdeps.h"
#include <assert.h>
-#include "config.h"
#include "options.h"
#include "keybuf.h"
#include "keyboard.h"
static int fakestate[2][7] = { {0},{0} };
-static int *fs_np, *fs_ck, *fs_se, *fs_xa1, *fs_xa2;
+static int *fs_np, *fs_ck, *fs_se;
+#ifdef ARCADIA
+static int *fs_xa1, *fs_xa2;
+#endif
/* Not static so the DOS code can mess with them */
int kpb_first, kpb_last;
}
if (fs_se != 0) {
switch (k) {
- case AK_T: fs = 1; fs_se[0] = b; break;
- case AK_F: fs = 1; fs_se[1] = b; break;
- case AK_H: fs = 1; fs_se[2] = b; break;
- case AK_B: fs = 1; fs_se[3] = b; break;
+ case AK_W: fs = 1; fs_se[0] = b; break;
+ case AK_A: fs = 1; fs_se[1] = b; break;
+ case AK_D: fs = 1; fs_se[2] = b; break;
+ case AK_S: fs = 1; fs_se[3] = b; break;
case AK_LALT: fs = 1; fs_se[4] = b; break;
case AK_LSH: fs = 1; fs_se[5] = b; break;
}
}
+#ifdef ARCADIA
if (fs_xa1 != 0) {
switch (k) {
case AK_NP8: fs = 1; fs_xa1[0] = b; break;
case AK_Q: fs = 1; fs_xa2[6] = b; break;
}
}
-
+#endif
if (fs && currprefs.input_selected_setting == 0) {
if (JSEM_ISANYKBD (0, &currprefs))
do_fake (0);
kc ^= AK_RCTRL << 1;
kc ^= AK_CTRL << 1;
}
+#ifdef ARCADIA
if (fs_xa1 || fs_xa2) {
int k2 = k;
if (k == AK_1)
if (k != k2)
kc = (k2 << 1) | (b ? 0 : 1);
}
+#endif
}
if (input_recording > 0) {
void joystick_setting_changed (void)
{
- fs_np = fs_ck = fs_se = fs_xa1 = fs_xa2 = 0;
+ fs_np = fs_ck = fs_se;
+#ifdef ARCADIA
+ fs_xa1 = fs_xa2 = 0;
+#endif
if (JSEM_ISNUMPAD (0, &currprefs))
fs_np = fakestate[0];
else if (JSEM_ISSOMEWHEREELSE (1, &currprefs))
fs_se = fakestate[1];
+#ifdef ARCADIA
if (JSEM_ISXARCADE1 (0, &currprefs))
fs_xa1 = fakestate[0];
else if (JSEM_ISXARCADE1 (1, &currprefs))
fs_xa2 = fakestate[0];
else if (JSEM_ISXARCADE2 (1, &currprefs))
fs_xa2 = fakestate[1];
-
+#endif
}
void keybuf_init (void)
inputdevice_updateconfig (&currprefs);
}
+#ifdef SAVESTATE
uae_u8 *save_keyboard (int *len)
{
restore_u32 ();
return src;
}
+
+#endif /* SAVESTATE */
#include "sysdeps.h"
#include <assert.h>
-#include "config.h"
#include "options.h"
#include "threaddep/thread.h"
#include "uae.h"
#include "gui.h"
#include "zfile.h"
#include "autoconf.h"
+#include "traps.h"
#include "osemu.h"
-#include "osdep/exectasks.h"
#include "picasso96.h"
#include "bsdsocket.h"
#include "uaeexe.h"
}
}
-#if defined (JIT) && (defined( _WIN32 ) || defined(_WIN64)) && !defined( NO_WIN32_EXCEPTION_HANDLER )
- __except( EvalException( GetExceptionInformation(), GetExceptionCode() ) )
+#if defined (JIT) && (defined( _WIN32 ) || defined(_WIN64)) && !defined(NO_WIN32_EXCEPTION_HANDLER)
+ __except(EvalException(GetExceptionInformation(), GetExceptionCode()))
{
// EvalException does the good stuff...
}
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
uae_u32 max_z3fastmem = 512 * 1024 * 1024;
#endif
-static long chip_filepos;
-static long bogo_filepos;
-static long rom_filepos;
+static size_t chip_filepos;
+static size_t bogo_filepos;
+static size_t rom_filepos;
static struct romlist *rl;
static int romlist_cnt;
static int illegal_count;
/* A dummy bank that only contains zeros */
-static uae_u32 dummy_lget (uaecptr) REGPARAM;
-static uae_u32 dummy_wget (uaecptr) REGPARAM;
-static uae_u32 dummy_bget (uaecptr) REGPARAM;
-static void dummy_lput (uaecptr, uae_u32) REGPARAM;
-static void dummy_wput (uaecptr, uae_u32) REGPARAM;
-static void dummy_bput (uaecptr, uae_u32) REGPARAM;
-static int dummy_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u32 REGPARAM3 dummy_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 dummy_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 dummy_bget (uaecptr) REGPARAM;
+static void REGPARAM3 dummy_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 dummy_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 dummy_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 dummy_check (uaecptr addr, uae_u32 size) REGPARAM;
#define MAX_ILG 200
#define NONEXISTINGDATA 0
illegal_count++;
if (rw) {
write_log ("Illegal %cput at %08lx=%08lx PC=%x\n",
- size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, val, m68k_getpc());
+ size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, val, M68K_GETPC);
} else {
write_log ("Illegal %cget at %08lx PC=%x\n",
- size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, m68k_getpc());
+ size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, M68K_GETPC);
}
}
if (illegal_count < MAX_ILG || MAX_ILG < 0) {
if (MAX_ILG >= 0)
illegal_count++;
- write_log ("Illegal check at %08lx PC=%x\n", addr, m68k_getpc());
+ write_log ("Illegal check at %08lx PC=%x\n", addr, M68K_GETPC);
}
}
#ifdef AUTOCONFIG
/* A3000 "motherboard resources" bank. */
-static uae_u32 mbres_lget (uaecptr) REGPARAM;
-static uae_u32 mbres_wget (uaecptr) REGPARAM;
-static uae_u32 mbres_bget (uaecptr) REGPARAM;
-static void mbres_lput (uaecptr, uae_u32) REGPARAM;
-static void mbres_wput (uaecptr, uae_u32) REGPARAM;
-static void mbres_bput (uaecptr, uae_u32) REGPARAM;
-static int mbres_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u32 REGPARAM3 mbres_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 mbres_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 mbres_bget (uaecptr) REGPARAM;
+static void REGPARAM3 mbres_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 mbres_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 mbres_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 mbres_check (uaecptr addr, uae_u32 size) REGPARAM;
static int mbres_val = 0;
uae_u8 *chipmemory;
-static int chipmem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *chipmem_xlate (uaecptr addr) REGPARAM;
+static int REGPARAM3 chipmem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 chipmem_xlate (uaecptr addr) REGPARAM;
#ifdef AGA
return (addr + size) <= allocated_chipmem;
}
-uae_u8 REGPARAM2 *chipmem_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 chipmem_xlate (uaecptr addr)
{
addr -= chipmem_start & chipmem_mask;
addr &= chipmem_mask;
static uae_u8 *bogomemory;
-static uae_u32 bogomem_lget (uaecptr) REGPARAM;
-static uae_u32 bogomem_wget (uaecptr) REGPARAM;
-static uae_u32 bogomem_bget (uaecptr) REGPARAM;
-static void bogomem_lput (uaecptr, uae_u32) REGPARAM;
-static void bogomem_wput (uaecptr, uae_u32) REGPARAM;
-static void bogomem_bput (uaecptr, uae_u32) REGPARAM;
-static int bogomem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *bogomem_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 bogomem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 bogomem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 bogomem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 bogomem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 bogomem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 bogomem_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 bogomem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 bogomem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 bogomem_lget (uaecptr addr)
{
return (addr + size) <= allocated_bogomem;
}
-uae_u8 REGPARAM2 *bogomem_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 bogomem_xlate (uaecptr addr)
{
addr -= bogomem_start & bogomem_mask;
addr &= bogomem_mask;
static uae_u8 *a3000memory;
-static uae_u32 a3000mem_lget (uaecptr) REGPARAM;
-static uae_u32 a3000mem_wget (uaecptr) REGPARAM;
-static uae_u32 a3000mem_bget (uaecptr) REGPARAM;
-static void a3000mem_lput (uaecptr, uae_u32) REGPARAM;
-static void a3000mem_wput (uaecptr, uae_u32) REGPARAM;
-static void a3000mem_bput (uaecptr, uae_u32) REGPARAM;
-static int a3000mem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *a3000mem_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 a3000mem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 a3000mem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 a3000mem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 a3000mem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 a3000mem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 a3000mem_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 a3000mem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 a3000mem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 a3000mem_lget (uaecptr addr)
{
return (addr + size) <= allocated_a3000mem;
}
-uae_u8 REGPARAM2 *a3000mem_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 a3000mem_xlate (uaecptr addr)
{
addr -= a3000mem_start & a3000mem_mask;
addr &= a3000mem_mask;
a1000_handle_kickstart (1);
}
-static uae_u32 kickmem_lget (uaecptr) REGPARAM;
-static uae_u32 kickmem_wget (uaecptr) REGPARAM;
-static uae_u32 kickmem_bget (uaecptr) REGPARAM;
-static void kickmem_lput (uaecptr, uae_u32) REGPARAM;
-static void kickmem_wput (uaecptr, uae_u32) REGPARAM;
-static void kickmem_bput (uaecptr, uae_u32) REGPARAM;
-static int kickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *kickmem_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 kickmem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 kickmem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 kickmem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 kickmem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 kickmem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 kickmem_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 kickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 kickmem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 kickmem_lget (uaecptr addr)
{
return (addr + size) <= kickmem_size;
}
-uae_u8 REGPARAM2 *kickmem_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 kickmem_xlate (uaecptr addr)
{
addr -= kickmem_start & kickmem_mask;
addr &= kickmem_mask;
return 0;
}
-static uae_u32 extendedkickmem_lget (uaecptr) REGPARAM;
-static uae_u32 extendedkickmem_wget (uaecptr) REGPARAM;
-static uae_u32 extendedkickmem_bget (uaecptr) REGPARAM;
-static void extendedkickmem_lput (uaecptr, uae_u32) REGPARAM;
-static void extendedkickmem_wput (uaecptr, uae_u32) REGPARAM;
-static void extendedkickmem_bput (uaecptr, uae_u32) REGPARAM;
-static int extendedkickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *extendedkickmem_xlate (uaecptr addr) REGPARAM;
+static uae_u32 REGPARAM3 extendedkickmem_lget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 extendedkickmem_wget (uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 extendedkickmem_bget (uaecptr) REGPARAM;
+static void REGPARAM3 extendedkickmem_lput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem_wput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem_bput (uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 extendedkickmem_check (uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 extendedkickmem_xlate (uaecptr addr) REGPARAM;
uae_u32 REGPARAM2 extendedkickmem_lget (uaecptr addr)
{
return (addr + size) <= extendedkickmem_size;
}
-uae_u8 REGPARAM2 *extendedkickmem_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 extendedkickmem_xlate (uaecptr addr)
{
addr -= extendedkickmem_start & extendedkickmem_mask;
addr &= extendedkickmem_mask;
static int be_cnt;
-uae_u8 REGPARAM2 *default_xlate (uaecptr a)
+uae_u8 *REGPARAM2 default_xlate (uaecptr a)
{
if (quit_program == 0) {
/* do this only in 68010+ mode, there are some tricky A500 programs.. */
if (be_cnt < 3) {
int i, j;
uaecptr a2 = a - 32;
- uaecptr a3 = m68k_getpc() - 32;
- write_log ("Your Amiga program just did something terribly stupid %p PC=%p\n", a, m68k_getpc());
+ uaecptr a3 = m68k_getpc(®s) - 32;
+ write_log ("Your Amiga program just did something terribly stupid %p PC=%p\n", a, M68K_GETPC);
m68k_dumpstate (0, 0);
for (i = 0; i < 10; i++) {
write_log ("%08.8X ", i >= 5 ? a3 : a2);
be_cnt = 0;
} else {
regs.panic = 1;
- regs.panic_pc = m68k_getpc ();
+ regs.panic_pc = m68k_getpc (®s);
regs.panic_addr = a;
- set_special (SPCFLAG_BRK);
+ set_special (®s, SPCFLAG_BRK);
}
}
}
else
map_banks (&kickmem_bank, 0, i, 0x80000);
if (savestate_state != STATE_RESTORE && savestate_state != STATE_REWIND)
- m68k_setpc(m68k_getpc());
+ m68k_setpc(®s, m68k_getpc(®s));
}
void memory_reset (void)
}
}
+#ifdef SAVESTATE
/* memory save/restore code */
return bogomemory;
}
-void restore_cram (int len, long filepos)
+void restore_cram (int len, size_t filepos)
{
chip_filepos = filepos;
changed_prefs.chipmem_size = len;
}
-void restore_bram (int len, long filepos)
+void restore_bram (int len, size_t filepos)
{
bogo_filepos = filepos;
changed_prefs.bogomem_size = len;
*len = dst - dstbak;
return dstbak;
}
+
+#endif /* SAVESTATE */
#ifdef PROWIZARD
#include "uae.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "autoconf.h"
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "threaddep/thread.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
-#include "disk.h"
#include "autoconf.h"
-#include "filesys.h"
-#include "execlib.h"
+#include "traps.h"
#include "native2amiga.h"
smp_comm_pipe native2amiga_pending;
#ifdef SUPPORT_THREADS
-void uae_Cause(uaecptr interrupt)
+void uae_Cause (uaecptr interrupt)
{
uae_sem_wait (&n2asem);
write_comm_pipe_int (&native2amiga_pending, 3, 0);
uae_sem_post (&n2asem);
}
-void uae_ReplyMsg(uaecptr msg)
+void uae_ReplyMsg (uaecptr msg)
{
uae_sem_wait (&n2asem);
write_comm_pipe_int (&native2amiga_pending, 2, 0);
uae_sem_post (&n2asem);
}
-void uae_PutMsg(uaecptr port, uaecptr msg)
+void uae_PutMsg (uaecptr port, uaecptr msg)
{
uae_sem_wait (&n2asem);
write_comm_pipe_int (&native2amiga_pending, 1, 0);
uae_sem_post (&n2asem);
}
-void uae_Signal(uaecptr task, uae_u32 mask)
+void uae_Signal (uaecptr task, uae_u32 mask)
{
uae_sem_wait (&n2asem);
write_comm_pipe_int (&native2amiga_pending, 0, 0);
uae_sem_post (&n2asem);
}
-void uae_NotificationHack(uaecptr port, uaecptr nr)
+void uae_NotificationHack (uaecptr port, uaecptr nr)
{
uae_sem_wait (&n2asem);
write_comm_pipe_int (&native2amiga_pending, 4, 0);
#endif
-void uae_NewList(uaecptr list)
+void uae_NewList (uaecptr list)
{
put_long (list, list + 4);
put_long (list + 4, 0);
put_long (list + 8, list);
}
-uaecptr uae_AllocMem (uae_u32 size, uae_u32 flags)
+uaecptr uae_AllocMem (TrapContext *context, uae_u32 size, uae_u32 flags)
{
- m68k_dreg (regs, 0) = size;
- m68k_dreg (regs, 1) = flags;
- return CallLib (get_long (4), -198); /* AllocMem */
+ m68k_dreg (&context->regs, 0) = size;
+ m68k_dreg (&context->regs, 1) = flags;
+ return CallLib (context, get_long (4), -198); /* AllocMem */
}
-void uae_FreeMem (uaecptr memory, uae_u32 size)
+void uae_FreeMem (TrapContext *context, uaecptr memory, uae_u32 size)
{
- m68k_dreg (regs, 0) = size;
- m68k_areg (regs, 1) = memory;
- CallLib (get_long (4), -0xD2); /* FreeMem */
+ m68k_dreg (&context->regs, 0) = size;
+ m68k_areg (&context->regs, 1) = memory;
+ CallLib (context, get_long (4), -0xD2); /* FreeMem */
}
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "events.h"
#include "uae.h"
#include "newcpu.h"
#include "cpu_prefetch.h"
#include "autoconf.h"
+#include "traps.h"
#include "ersatz.h"
#include "debug.h"
#include "gui.h"
int irqdelay[15];
int mmu_enabled, mmu_triggered;
-int areg_byteinc[] = { 1,1,1,1,1,1,1,2 };
-int imm8_table[] = { 8,1,2,3,4,5,6,7 };
+const int areg_byteinc[] = { 1,1,1,1,1,1,1,2 };
+const int imm8_table[] = { 8,1,2,3,4,5,6,7 };
int movem_index1[256];
int movem_index2[256];
}
#endif
+STATIC_INLINE void count_instr (unsigned int opcode)
+{
+}
+
+static unsigned long REGPARAM3 op_illg_1 (uae_u32 opcode, struct regstruct *regs) REGPARAM;
-static unsigned long op_illg_1 (uae_u32 opcode) REGPARAM;
-
-static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode)
+static unsigned long REGPARAM2 op_illg_1 (uae_u32 opcode, struct regstruct *regs)
{
- op_illg (opcode);
+ op_illg (opcode, regs);
return 4;
}
{
int i, opcnt;
unsigned long opcode;
- struct cputbl *tbl = 0;
+ const struct cputbl *tbl = 0;
switch (currprefs.cpu_level)
{
for (opcode = 0; opcode < 65536; opcode++)
cpufunctbl[opcode] = op_illg_1;
- for (i = 0; tbl[i].handler != NULL; i++) {
-#ifdef JIT
- tbl[i].specific = 0;
-#endif
+ for (i = 0; tbl[i].handler != NULL; i++)
cpufunctbl[tbl[i].opcode] = tbl[i].handler;
- }
+
opcnt = 0;
for (opcode = 0; opcode < 65536; opcode++) {
cpuop_func *f;
currprefs.cpu_cycle_exact ? -1 : currprefs.cpu_compatible ? 1 : 0,
currprefs.address_space_24);
#ifdef JIT
- build_comp();
+ build_comp ();
#endif
}
-void fill_prefetch_slow (void)
+void fill_prefetch_slow (struct regstruct *regs)
{
#ifdef CPUEMU_6
if (currprefs.cpu_cycle_exact) {
- regs.ir = get_word_ce (m68k_getpc ());
- regs.irc = get_word_ce (m68k_getpc () + 2);
+ regs->ir = get_word_ce (m68k_getpc (regs));
+ regs->irc = get_word_ce (m68k_getpc (regs) + 2);
} else {
#endif
- regs.ir = get_word (m68k_getpc ());
- regs.irc = get_word (m68k_getpc () + 2);
+ regs->ir = get_word (m68k_getpc (regs));
+ regs->irc = get_word (m68k_getpc (regs) + 2);
#ifdef CPUEMU_6
}
#endif
|| currprefs.cpu_cycle_exact != changed_prefs.cpu_cycle_exact) {
if (!currprefs.cpu_compatible && changed_prefs.cpu_compatible)
- fill_prefetch_slow ();
+ fill_prefetch_slow (®s);
currprefs.cpu_level = changed_prefs.cpu_level;
currprefs.cpu_compatible = changed_prefs.cpu_compatible;
write_log ("%d CPU functions\n", nr_cpuop_funcs);
build_cpufunctbl ();
-}
-void init_m68k_full (void)
-{
- init_m68k ();
+#ifdef JIT
+ /* We need to check whether NATMEM settings have changed
+ * before starting the CPU */
+ check_prefs_changed_comp ();
+#endif
}
-struct regstruct regs, lastint_regs, mmu_backup_regs;
+struct regstruct regs, mmu_backup_regs;
static struct regstruct regs_backup[16];
static int backup_pointer = 0;
static long int m68kpc_offset;
-int lastint_no;
#define get_ibyte_1(o) get_byte(regs.pc + (regs.pc_p - regs.pc_oldp) + (o) + 1)
#define get_iword_1(o) get_word(regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
sprintf (offtxt, "-$%04x", -disp16);
else
sprintf (offtxt, "$%04x", disp16);
- addr = m68k_areg(regs,reg) + disp16;
+ addr = m68k_areg(®s,reg) + disp16;
sprintf (buffer,"(A%d,%s) == $%08lx", reg, offtxt, (unsigned long)addr);
}
break;
dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
disp8 = dp & 0xFF;
r = (dp & 0x7000) >> 12;
- dispreg = dp & 0x8000 ? m68k_areg(regs,r) : m68k_dreg(regs,r);
+ dispreg = dp & 0x8000 ? m68k_areg(®s,r) : m68k_dreg(®s,r);
if (!(dp & 0x800)) dispreg = (uae_s32)(uae_s16)(dispreg);
dispreg <<= (dp >> 9) & 3;
if (dp & 0x100) {
uae_s32 outer = 0, disp = 0;
- uae_s32 base = m68k_areg(regs,reg);
+ uae_s32 base = m68k_areg(®s,reg);
char name[10];
sprintf (name,"A%d, ",reg);
if (dp & 0x80) { base = 0; name[0] = 0; }
disp,outer,
(unsigned long)addr);
} else {
- addr = m68k_areg(regs,reg) + (uae_s32)((uae_s8)disp8) + dispreg;
+ addr = m68k_areg(®s,reg) + (uae_s32)((uae_s8)disp8) + dispreg;
sprintf (buffer,"(A%d, %c%d.%c*%d, $%02x) == $%08lx", reg,
dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
1 << ((dp >> 9) & 3), disp8,
}
break;
case PC16:
- addr = m68k_getpc () + m68kpc_offset;
+ addr = m68k_getpc (®s) + m68kpc_offset;
disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
addr += (uae_s16)disp16;
sprintf (buffer,"(PC,$%04x) == $%08lx", disp16 & 0xffff,(unsigned long)addr);
break;
case PC8r:
- addr = m68k_getpc () + m68kpc_offset;
+ addr = m68k_getpc (®s) + m68kpc_offset;
dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
disp8 = dp & 0xFF;
r = (dp & 0x7000) >> 12;
- dispreg = dp & 0x8000 ? m68k_areg(regs,r) : m68k_dreg(regs,r);
+ dispreg = dp & 0x8000 ? m68k_areg(®s,r) : m68k_dreg(®s,r);
if (!(dp & 0x800)) dispreg = (uae_s32)(uae_s16)(dispreg);
dispreg <<= (dp >> 9) & 3;
return offset;
}
+#if 0
/* The plan is that this will take over the job of exception 3 handling -
* the CPU emulation functions will just do a longjmp to m68k_go whenever
* they hit an odd address. */
switch (mode){
case Dreg:
- *val = m68k_dreg (regs, reg);
+ *val = m68k_dreg (®s, reg);
return 1;
case Areg:
- *val = m68k_areg (regs, reg);
+ *val = m68k_areg (®s, reg);
return 1;
case Aind:
case Aipi:
- addr = m68k_areg (regs, reg);
+ addr = m68k_areg (®s, reg);
break;
case Apdi:
- addr = m68k_areg (regs, reg);
+ addr = m68k_areg (®s, reg);
break;
case Ad16:
disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
- addr = m68k_areg(regs,reg) + (uae_s16)disp16;
+ addr = m68k_areg(®s,reg) + (uae_s16)disp16;
break;
case Ad8r:
- addr = m68k_areg (regs, reg);
+ addr = m68k_areg (®s, reg);
d8r_common:
dp = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
disp8 = dp & 0xFF;
r = (dp & 0x7000) >> 12;
- dispreg = dp & 0x8000 ? m68k_areg(regs,r) : m68k_dreg(regs,r);
+ dispreg = dp & 0x8000 ? m68k_areg(®s,r) : m68k_dreg(®s,r);
if (!(dp & 0x800)) dispreg = (uae_s32)(uae_s16)(dispreg);
dispreg <<= (dp >> 9) & 3;
}
break;
case PC16:
- addr = m68k_getpc () + m68kpc_offset;
+ addr = m68k_getpc (®s) + m68kpc_offset;
disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
addr += (uae_s16)disp16;
break;
case PC8r:
- addr = m68k_getpc () + m68kpc_offset;
+ addr = m68k_getpc (®s) + m68kpc_offset;
goto d8r_common;
case absw:
addr = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset);
if ((addr & 1) == 0)
return 1;
- last_addr_for_exception_3 = m68k_getpc () + m68kpc_offset;
+ last_addr_for_exception_3 = m68k_getpc (®s) + m68kpc_offset;
last_fault_for_exception_3 = addr;
last_writeaccess_for_exception_3 = 0;
last_instructionaccess_for_exception_3 = 0;
return 0;
}
+#endif
-uae_u32 get_disp_ea_020 (uae_u32 base, uae_u32 dp)
+uae_u32 REGPARAM2 get_disp_ea_020 (struct regstruct *regs, uae_u32 base, uae_u32 dp)
{
int reg = (dp >> 12) & 15;
- uae_s32 regd = regs.regs[reg];
+ uae_s32 regd = regs->regs[reg];
if ((dp & 0x800) == 0)
regd = (uae_s32)(uae_s16)regd;
regd <<= (dp >> 9) & 3;
if (dp & 0x80) base = 0;
if (dp & 0x40) regd = 0;
- if ((dp & 0x30) == 0x20) base += (uae_s32)(uae_s16)next_iword();
- if ((dp & 0x30) == 0x30) base += next_ilong();
+ if ((dp & 0x30) == 0x20) base += (uae_s32)(uae_s16)next_iword(regs);
+ if ((dp & 0x30) == 0x30) base += next_ilong(regs);
- if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)next_iword();
- if ((dp & 0x3) == 0x3) outer = next_ilong();
+ if ((dp & 0x3) == 0x2) outer = (uae_s32)(uae_s16)next_iword(regs);
+ if ((dp & 0x3) == 0x3) outer = next_ilong(regs);
if ((dp & 0x4) == 0) base += regd;
if (dp & 0x3) base = get_long (base);
}
}
-uae_u32 get_disp_ea_000 (uae_u32 base, uae_u32 dp)
+uae_u32 REGPARAM3 get_disp_ea_000 (struct regstruct *regs, uae_u32 base, uae_u32 dp) REGPARAM
{
int reg = (dp >> 12) & 15;
- uae_s32 regd = regs.regs[reg];
+ uae_s32 regd = regs->regs[reg];
#if 1
if ((dp & 0x800) == 0)
regd = (uae_s32)(uae_s16)regd;
#endif
}
-void MakeSR (void)
+void REGPARAM2 MakeSR (struct regstruct *regs)
{
#if 0
- assert((regs.t1 & 1) == regs.t1);
- assert((regs.t0 & 1) == regs.t0);
- assert((regs.s & 1) == regs.s);
- assert((regs.m & 1) == regs.m);
+ assert((regs.t1 & 1) == regs->t1);
+ assert((regs.t0 & 1) == regs->t0);
+ assert((regs.s & 1) == regs->s);
+ assert((regs.m & 1) == regs->m);
assert((XFLG & 1) == XFLG);
assert((NFLG & 1) == NFLG);
assert((ZFLG & 1) == ZFLG);
assert((VFLG & 1) == VFLG);
assert((CFLG & 1) == CFLG);
#endif
- regs.sr = ((regs.t1 << 15) | (regs.t0 << 14)
- | (regs.s << 13) | (regs.m << 12) | (regs.intmask << 8)
- | (GET_XFLG << 4) | (GET_NFLG << 3) | (GET_ZFLG << 2) | (GET_VFLG << 1)
- | GET_CFLG);
-}
-
-void MakeFromSR (void)
-{
- int oldm = regs.m;
- int olds = regs.s;
-
- SET_XFLG ((regs.sr >> 4) & 1);
- SET_NFLG ((regs.sr >> 3) & 1);
- SET_ZFLG ((regs.sr >> 2) & 1);
- SET_VFLG ((regs.sr >> 1) & 1);
- SET_CFLG (regs.sr & 1);
- if (regs.t1 == ((regs.sr >> 15) & 1) &&
- regs.t0 == ((regs.sr >> 14) & 1) &&
- regs.s == ((regs.sr >> 13) & 1) &&
- regs.m == ((regs.sr >> 12) & 1) &&
- regs.intmask == ((regs.sr >> 8) & 7))
+ regs->sr = ((regs->t1 << 15) | (regs->t0 << 14)
+ | (regs->s << 13) | (regs->m << 12) | (regs->intmask << 8)
+ | (GET_XFLG(®s->ccrflags) << 4) | (GET_NFLG(®s->ccrflags) << 3)
+ | (GET_ZFLG(®s->ccrflags) << 2) | (GET_VFLG(®s->ccrflags) << 1)
+ | GET_CFLG(®s->ccrflags));
+}
+
+void REGPARAM2 MakeFromSR (struct regstruct *regs)
+{
+ int oldm = regs->m;
+ int olds = regs->s;
+
+ SET_XFLG (®s->ccrflags, (regs->sr >> 4) & 1);
+ SET_NFLG (®s->ccrflags, (regs->sr >> 3) & 1);
+ SET_ZFLG (®s->ccrflags, (regs->sr >> 2) & 1);
+ SET_VFLG (®s->ccrflags, (regs->sr >> 1) & 1);
+ SET_CFLG (®s->ccrflags, regs->sr & 1);
+ if (regs->t1 == ((regs->sr >> 15) & 1) &&
+ regs->t0 == ((regs->sr >> 14) & 1) &&
+ regs->s == ((regs->sr >> 13) & 1) &&
+ regs->m == ((regs->sr >> 12) & 1) &&
+ regs->intmask == ((regs->sr >> 8) & 7))
return;
- regs.t1 = (regs.sr >> 15) & 1;
- regs.t0 = (regs.sr >> 14) & 1;
- regs.s = (regs.sr >> 13) & 1;
- regs.m = (regs.sr >> 12) & 1;
- regs.intmask = (regs.sr >> 8) & 7;
+ regs->t1 = (regs->sr >> 15) & 1;
+ regs->t0 = (regs->sr >> 14) & 1;
+ regs->s = (regs->sr >> 13) & 1;
+ regs->m = (regs->sr >> 12) & 1;
+ regs->intmask = (regs->sr >> 8) & 7;
if (currprefs.cpu_level >= 2) {
- if (olds != regs.s) {
+ if (olds != regs->s) {
if (olds) {
if (oldm)
- regs.msp = m68k_areg(regs, 7);
+ regs->msp = m68k_areg(regs, 7);
else
- regs.isp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.usp;
+ regs->isp = m68k_areg(regs, 7);
+ m68k_areg(regs, 7) = regs->usp;
} else {
- regs.usp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.m ? regs.msp : regs.isp;
+ regs->usp = m68k_areg(regs, 7);
+ m68k_areg(regs, 7) = regs->m ? regs->msp : regs->isp;
}
- } else if (olds && oldm != regs.m) {
+ } else if (olds && oldm != regs->m) {
if (oldm) {
- regs.msp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.isp;
+ regs->msp = m68k_areg (regs, 7);
+ m68k_areg (regs, 7) = regs->isp;
} else {
- regs.isp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.msp;
+ regs->isp = m68k_areg (regs, 7);
+ m68k_areg (regs, 7) = regs->msp;
}
}
} else {
- regs.t0 = regs.m = 0;
- if (olds != regs.s) {
+ regs->t0 = regs->m = 0;
+ if (olds != regs->s) {
if (olds) {
- regs.isp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.usp;
+ regs->isp = m68k_areg (regs, 7);
+ m68k_areg (regs, 7) = regs->usp;
} else {
- regs.usp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.isp;
+ regs->usp = m68k_areg (regs, 7);
+ m68k_areg (regs, 7) = regs->isp;
}
}
}
- set_special (SPCFLAG_INT);
- if (regs.t1 || regs.t0)
- set_special (SPCFLAG_TRACE);
+ set_special (regs, SPCFLAG_INT);
+ if (regs->t1 || regs->t0)
+ set_special (regs, SPCFLAG_TRACE);
else
/* Keep SPCFLAG_DOTRACE, we still want a trace exception for
SR-modifying instructions (including STOP). */
- unset_special (SPCFLAG_TRACE);
+ unset_special (regs, SPCFLAG_TRACE);
}
static void exception_trace (int nr)
{
- unset_special (SPCFLAG_TRACE | SPCFLAG_DOTRACE);
+ unset_special (®s, SPCFLAG_TRACE | SPCFLAG_DOTRACE);
if (regs.t1 && !regs.t0) {
/* trace stays pending if exception is div by zero, chk,
* trapv or trap #x
*/
if (nr == 5 || nr == 6 || nr == 7 || (nr >= 32 && nr <= 47))
- set_special (SPCFLAG_DOTRACE);
+ set_special (®s, SPCFLAG_DOTRACE);
}
regs.t1 = regs.t0 = regs.m = 0;
}
#ifdef DEBUGGER
if (!exception_debugging)
return;
- console_out ("Exception %d, PC=%08.8X\n", nr, m68k_getpc());
+ console_out ("Exception %d, PC=%08.8X\n", nr, m68k_getpc(®s));
#endif
}
/* cycle-exact exception handler, 68000 only */
-static void Exception_ce (int nr, uaecptr oldpc)
+static void Exception_ce (int nr, struct regstruct *regs, uaecptr oldpc)
{
- uae_u32 currpc = m68k_getpc (), newpc;
+ uae_u32 currpc = m68k_getpc (regs), newpc;
int c;
- int sv = regs.s;
+ int sv = regs->s;
exception_debug (nr);
- MakeSR();
+ MakeSR(regs);
c = 0;
switch (nr)
*/
if (c)
do_cycles (c * CYCLE_UNIT / 2);
- if (!regs.s) {
- regs.usp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.isp;
- regs.s = 1;
+ if (!regs->s) {
+ regs->usp = m68k_areg(regs, 7);
+ m68k_areg(regs, 7) = regs->isp;
+ regs->s = 1;
}
if (nr == 2 || nr == 3) { /* 2=bus error,3=address error */
uae_u16 mode = (sv ? 4 : 0) | (last_instructionaccess_for_exception_3 ? 2 : 1);
m68k_areg(regs, 7) -= 14;
/* fixme: bit3=I/N */
put_word_ce (m68k_areg(regs, 7) + 12, last_addr_for_exception_3);
- put_word_ce (m68k_areg(regs, 7) + 8, regs.sr);
+ put_word_ce (m68k_areg(regs, 7) + 8, regs->sr);
put_word_ce (m68k_areg(regs, 7) + 10, last_addr_for_exception_3 >> 16);
put_word_ce (m68k_areg(regs, 7) + 6, last_op_for_exception_3);
put_word_ce (m68k_areg(regs, 7) + 4, last_fault_for_exception_3);
}
m68k_areg (regs, 7) -= 6;
put_word_ce (m68k_areg(regs, 7) + 4, currpc);
- put_word_ce (m68k_areg(regs, 7) + 0, regs.sr);
+ put_word_ce (m68k_areg(regs, 7) + 0, regs->sr);
put_word_ce (m68k_areg(regs, 7) + 2, currpc >> 16);
kludge_me_do:
newpc = get_word_ce (4 * nr) << 16;
if (nr == 2 || nr == 3)
uae_reset (1); /* there is nothing else we can do.. */
else
- exception3 (regs.ir, m68k_getpc(), newpc);
+ exception3 (regs->ir, m68k_getpc(regs), newpc);
return;
}
- m68k_setpc (newpc);
- fill_prefetch_slow ();
- set_special(SPCFLAG_END_COMPILE);
+ m68k_setpc (regs, newpc);
+ fill_prefetch_slow (regs);
+ set_special(regs, SPCFLAG_END_COMPILE);
exception_trace (nr);
}
#endif
-static void Exception_normal (int nr, uaecptr oldpc)
+static void Exception_normal (int nr, struct regstruct *regs, uaecptr oldpc)
{
- uae_u32 currpc = m68k_getpc (), newpc;
- int sv = regs.s;
+ uae_u32 currpc = m68k_getpc (regs), newpc;
+ int sv = regs->s;
exception_debug (nr);
- MakeSR();
+ MakeSR(regs);
- if (!regs.s) {
- regs.usp = m68k_areg(regs, 7);
+ if (!regs->s) {
+ regs->usp = m68k_areg(regs, 7);
if (currprefs.cpu_level >= 2)
- m68k_areg(regs, 7) = regs.m ? regs.msp : regs.isp;
+ m68k_areg(regs, 7) = regs->m ? regs->msp : regs->isp;
else
- m68k_areg(regs, 7) = regs.isp;
- regs.s = 1;
+ m68k_areg(regs, 7) = regs->isp;
+ regs->s = 1;
}
if (currprefs.cpu_level > 0) {
if (nr == 2 || nr == 3) {
m68k_areg(regs, 7) -= 2;
put_word (m68k_areg(regs, 7), 0xb000 + nr * 4);
}
- write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs.vbr + 4*nr));
+ write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs->vbr + 4*nr));
} else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) {
m68k_areg(regs, 7) -= 4;
put_long (m68k_areg(regs, 7), oldpc);
m68k_areg(regs, 7) -= 2;
put_word (m68k_areg(regs, 7), 0x2000 + nr * 4);
- } else if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */
+ } else if (regs->m && nr >= 24 && nr < 32) { /* M + Interrupt */
m68k_areg(regs, 7) -= 2;
put_word (m68k_areg(regs, 7), nr * 4);
m68k_areg(regs, 7) -= 4;
put_long (m68k_areg(regs, 7), currpc);
m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), regs.sr);
- regs.sr |= (1 << 13);
- regs.msp = m68k_areg(regs, 7);
- m68k_areg(regs, 7) = regs.isp;
+ put_word (m68k_areg(regs, 7), regs->sr);
+ regs->sr |= (1 << 13);
+ regs->msp = m68k_areg(regs, 7);
+ m68k_areg(regs, 7) = regs->isp;
m68k_areg(regs, 7) -= 2;
put_word (m68k_areg(regs, 7), 0x1000 + nr * 4);
} else {
put_word (m68k_areg(regs, 7) + 0, mode);
put_long (m68k_areg(regs, 7) + 2, last_fault_for_exception_3);
put_word (m68k_areg(regs, 7) + 6, last_op_for_exception_3);
- put_word (m68k_areg(regs, 7) + 8, regs.sr);
+ put_word (m68k_areg(regs, 7) + 8, regs->sr);
put_long (m68k_areg(regs, 7) + 10, last_addr_for_exception_3);
- write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs.vbr + 4*nr));
+ write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs->vbr + 4*nr));
goto kludge_me_do;
}
m68k_areg(regs, 7) -= 4;
put_long (m68k_areg(regs, 7), currpc);
m68k_areg(regs, 7) -= 2;
- put_word (m68k_areg(regs, 7), regs.sr);
+ put_word (m68k_areg(regs, 7), regs->sr);
kludge_me_do:
- newpc = get_long (regs.vbr + 4 * nr);
+ newpc = get_long (regs->vbr + 4 * nr);
if (newpc & 1) {
if (nr == 2 || nr == 3)
uae_reset (1); /* there is nothing else we can do.. */
else
- exception3 (regs.ir, m68k_getpc(), newpc);
+ exception3 (regs->ir, m68k_getpc(regs), newpc);
return;
}
- m68k_setpc (newpc);
- set_special(SPCFLAG_END_COMPILE);
- fill_prefetch_slow ();
+ m68k_setpc (regs, newpc);
+ set_special(regs, SPCFLAG_END_COMPILE);
+ fill_prefetch_slow (regs);
exception_trace (nr);
}
-void Exception (int nr, uaecptr oldpc)
+void REGPARAM2 Exception (int nr, struct regstruct *regs, uaecptr oldpc)
{
#if 0
if (1 || nr < 24)
#endif
#ifdef CPUEMU_6
if (currprefs.cpu_cycle_exact && currprefs.cpu_level == 0)
- Exception_ce (nr, oldpc);
+ Exception_ce (nr, regs, oldpc);
else
#endif
- Exception_normal (nr, oldpc);
+ Exception_normal (nr, regs, oldpc);
}
-void Interrupt (int nr)
+STATIC_INLINE void do_interrupt(int nr, struct regstruct *regs)
{
#if 0
if (nr == 4)
write_log("irq %d at %x (%04.4X)\n", nr, m68k_getpc(), intena & intreq);
#endif
- regs.stopped = 0;
- unset_special (SPCFLAG_STOP);
+ regs->stopped = 0;
+ unset_special (regs, SPCFLAG_STOP);
assert(nr < 8 && nr >= 0);
- lastint_regs = regs;
- lastint_no = nr;
- Exception (nr + 24, 0);
+ Exception (nr + 24, regs, 0);
+
+ regs->intmask = nr;
+ set_special (regs, SPCFLAG_INT);
+}
- regs.intmask = nr;
- set_special (SPCFLAG_INT);
+void Interrupt (int nr)
+{
+ do_interrupt (nr, ®s);
}
static uae_u32 caar, cacr, itt0, itt1, dtt0, dtt1, tc, mmusr, urp, srp, buscr, pcr;
{
//write_log("move2c %04.4X <- %08.8X\n", regno, *regp);
if (movec_illg (regno)) {
- op_illg (0x4E7B);
+ op_illg (0x4E7B, ®s);
return 0;
} else {
switch (regno) {
case 0x800: regs.usp = *regp; break;
case 0x801: regs.vbr = *regp; break;
case 0x802: caar = *regp & 0xfc; break;
- case 0x803: regs.msp = *regp; if (regs.m == 1) m68k_areg(regs, 7) = regs.msp; break;
- case 0x804: regs.isp = *regp; if (regs.m == 0) m68k_areg(regs, 7) = regs.isp; break;
+ case 0x803: regs.msp = *regp; if (regs.m == 1) m68k_areg(®s, 7) = regs.msp; break;
+ case 0x804: regs.isp = *regp; if (regs.m == 0) m68k_areg(®s, 7) = regs.isp; break;
case 0x805: mmusr = *regp; break;
case 0x806: urp = *regp; break;
case 0x807: srp = *regp; break;
case 0x808: pcr = *regp & (0x40 | 2 | 1); break;
default:
- op_illg (0x4E7B);
+ op_illg (0x4E7B, ®s);
return 0;
}
}
{
//write_log("movec2 %04.4X\n", regno);
if (movec_illg (regno)) {
- op_illg (0x4E7A);
+ op_illg (0x4E7A, ®s);
return 0;
} else {
switch (regno) {
case 0x800: *regp = regs.usp; break;
case 0x801: *regp = regs.vbr; break;
case 0x802: *regp = caar; break;
- case 0x803: *regp = regs.m == 1 ? m68k_areg(regs, 7) : regs.msp; break;
- case 0x804: *regp = regs.m == 0 ? m68k_areg(regs, 7) : regs.isp; break;
+ case 0x803: *regp = regs.m == 1 ? m68k_areg(®s, 7) : regs.msp; break;
+ case 0x804: *regp = regs.m == 0 ? m68k_areg(®s, 7) : regs.isp; break;
case 0x805: *regp = mmusr; break;
case 0x806: *regp = urp; break;
case 0x807: *regp = srp; break;
case 0x808: *regp = 0x04300100 | pcr; break;
default:
- op_illg (0x4E7A);
+ op_illg (0x4E7A, ®s);
return 0;
}
}
{
#if defined(uae_s64)
if (src == 0) {
- Exception (5, oldpc);
+ Exception (5, ®s, oldpc);
return;
}
if (extra & 0x800) {
/* signed variant */
- uae_s64 a = (uae_s64)(uae_s32)m68k_dreg(regs, (extra >> 12) & 7);
+ uae_s64 a = (uae_s64)(uae_s32)m68k_dreg(®s, (extra >> 12) & 7);
uae_s64 quot, rem;
if (extra & 0x400) {
a &= 0xffffffffu;
- a |= (uae_s64)m68k_dreg(regs, extra & 7) << 32;
+ a |= (uae_s64)m68k_dreg(®s, extra & 7) << 32;
}
rem = a % (uae_s64)(uae_s32)src;
quot = a / (uae_s64)(uae_s32)src;
if ((quot & UVAL64(0xffffffff80000000)) != 0
&& (quot & UVAL64(0xffffffff80000000)) != UVAL64(0xffffffff80000000))
{
- SET_VFLG (1);
- SET_NFLG (1);
- SET_CFLG (0);
+ SET_VFLG (®s.ccrflags, 1);
+ SET_NFLG (®s.ccrflags, 1);
+ SET_CFLG (®s.ccrflags, 0);
} else {
if (((uae_s32)rem < 0) != ((uae_s64)a < 0)) rem = -rem;
- SET_VFLG (0);
- SET_CFLG (0);
- SET_ZFLG (((uae_s32)quot) == 0);
- SET_NFLG (((uae_s32)quot) < 0);
- m68k_dreg(regs, extra & 7) = (uae_u32)rem;
- m68k_dreg(regs, (extra >> 12) & 7) = (uae_u32)quot;
+ SET_VFLG (®s.ccrflags, 0);
+ SET_CFLG (®s.ccrflags, 0);
+ SET_ZFLG (®s.ccrflags, ((uae_s32)quot) == 0);
+ SET_NFLG (®s.ccrflags, ((uae_s32)quot) < 0);
+ m68k_dreg(®s, extra & 7) = (uae_u32)rem;
+ m68k_dreg(®s, (extra >> 12) & 7) = (uae_u32)quot;
}
} else {
/* unsigned */
- uae_u64 a = (uae_u64)(uae_u32)m68k_dreg(regs, (extra >> 12) & 7);
+ uae_u64 a = (uae_u64)(uae_u32)m68k_dreg(®s, (extra >> 12) & 7);
uae_u64 quot, rem;
if (extra & 0x400) {
a &= 0xffffffffu;
- a |= (uae_u64)m68k_dreg(regs, extra & 7) << 32;
+ a |= (uae_u64)m68k_dreg(®s, extra & 7) << 32;
}
rem = a % (uae_u64)src;
quot = a / (uae_u64)src;
if (quot > 0xffffffffu) {
- SET_VFLG (1);
- SET_NFLG (1);
- SET_CFLG (0);
+ SET_VFLG (®s.ccrflags, 1);
+ SET_NFLG (®s.ccrflags, 1);
+ SET_CFLG (®s.ccrflags, 0);
} else {
- SET_VFLG (0);
- SET_CFLG (0);
- SET_ZFLG (((uae_s32)quot) == 0);
- SET_NFLG (((uae_s32)quot) < 0);
- m68k_dreg(regs, extra & 7) = (uae_u32)rem;
- m68k_dreg(regs, (extra >> 12) & 7) = (uae_u32)quot;
+ SET_VFLG (®s.ccrflags, 0);
+ SET_CFLG (®s.ccrflags, 0);
+ SET_ZFLG (®s.ccrflags, ((uae_s32)quot) == 0);
+ SET_NFLG (®s.ccrflags, ((uae_s32)quot) < 0);
+ m68k_dreg(®s, extra & 7) = (uae_u32)rem;
+ m68k_dreg(®s, (extra >> 12) & 7) = (uae_u32)quot;
}
}
#else
if (src == 0) {
- Exception (5, oldpc);
+ Exception (5, ®s, oldpc);
return;
}
if (extra & 0x800) {
/* signed variant */
- uae_s32 lo = (uae_s32)m68k_dreg(regs, (extra >> 12) & 7);
+ uae_s32 lo = (uae_s32)m68k_dreg(®s, (extra >> 12) & 7);
uae_s32 hi = lo < 0 ? -1 : 0;
uae_s32 save_high;
uae_u32 quot, rem;
uae_u32 sign;
if (extra & 0x400) {
- hi = (uae_s32)m68k_dreg(regs, extra & 7);
+ hi = (uae_s32)m68k_dreg(®s, extra & 7);
}
save_high = hi;
sign = (hi ^ src);
}
} else {
/* unsigned */
- uae_u32 lo = (uae_u32)m68k_dreg(regs, (extra >> 12) & 7);
+ uae_u32 lo = (uae_u32)m68k_dreg(®s, (extra >> 12) & 7);
uae_u32 hi = 0;
uae_u32 quot, rem;
if (extra & 0x400) {
- hi = (uae_u32)m68k_dreg(regs, extra & 7);
+ hi = (uae_u32)m68k_dreg(®s, extra & 7);
}
if (div_unsigned(hi, lo, src, ", &rem)) {
SET_VFLG (1);
#if defined(uae_s64)
if (extra & 0x800) {
/* signed variant */
- uae_s64 a = (uae_s64)(uae_s32)m68k_dreg(regs, (extra >> 12) & 7);
+ uae_s64 a = (uae_s64)(uae_s32)m68k_dreg(®s, (extra >> 12) & 7);
a *= (uae_s64)(uae_s32)src;
- SET_VFLG (0);
- SET_CFLG (0);
- SET_ZFLG (a == 0);
- SET_NFLG (a < 0);
+ SET_VFLG (®s.ccrflags, 0);
+ SET_CFLG (®s.ccrflags, 0);
+ SET_ZFLG (®s.ccrflags, a == 0);
+ SET_NFLG (®s.ccrflags, a < 0);
if (extra & 0x400)
- m68k_dreg(regs, extra & 7) = (uae_u32)(a >> 32);
+ m68k_dreg(®s, extra & 7) = (uae_u32)(a >> 32);
else if ((a & UVAL64(0xffffffff80000000)) != 0
&& (a & UVAL64(0xffffffff80000000)) != UVAL64(0xffffffff80000000))
{
- SET_VFLG (1);
+ SET_VFLG (®s.ccrflags, 1);
}
- m68k_dreg(regs, (extra >> 12) & 7) = (uae_u32)a;
+ m68k_dreg(®s, (extra >> 12) & 7) = (uae_u32)a;
} else {
/* unsigned */
- uae_u64 a = (uae_u64)(uae_u32)m68k_dreg(regs, (extra >> 12) & 7);
+ uae_u64 a = (uae_u64)(uae_u32)m68k_dreg(®s, (extra >> 12) & 7);
a *= (uae_u64)src;
- SET_VFLG (0);
- SET_CFLG (0);
- SET_ZFLG (a == 0);
- SET_NFLG (((uae_s64)a) < 0);
+ SET_VFLG (®s.ccrflags, 0);
+ SET_CFLG (®s.ccrflags, 0);
+ SET_ZFLG (®s.ccrflags, a == 0);
+ SET_NFLG (®s.ccrflags, ((uae_s64)a) < 0);
if (extra & 0x400)
- m68k_dreg(regs, extra & 7) = (uae_u32)(a >> 32);
+ m68k_dreg(®s, extra & 7) = (uae_u32)(a >> 32);
else if ((a & UVAL64(0xffffffff00000000)) != 0) {
- SET_VFLG (1);
+ SET_VFLG (®s.ccrflags, 1);
}
- m68k_dreg(regs, (extra >> 12) & 7) = (uae_u32)a;
+ m68k_dreg(®s, (extra >> 12) & 7) = (uae_u32)a;
}
#else
if (extra & 0x800) {
uae_u32 sign;
src1 = (uae_s32)src;
- src2 = (uae_s32)m68k_dreg(regs, (extra >> 12) & 7);
+ src2 = (uae_s32)m68k_dreg(®s, (extra >> 12) & 7);
sign = (src1 ^ src2);
if (src1 < 0) src1 = -src1;
if (src2 < 0) src2 = -src2;
SET_ZFLG (dst_hi == 0 && dst_lo == 0);
SET_NFLG (((uae_s32)dst_hi) < 0);
if (extra & 0x400)
- m68k_dreg(regs, extra & 7) = dst_hi;
+ m68k_dreg(®s, extra & 7) = dst_hi;
else if ((dst_hi != 0 || (dst_lo & 0x80000000) != 0)
&& ((dst_hi & 0xffffffff) != 0xffffffff
|| (dst_lo & 0x80000000) != 0x80000000))
{
SET_VFLG (1);
}
- m68k_dreg(regs, (extra >> 12) & 7) = dst_lo;
+ m68k_dreg(®s, (extra >> 12) & 7) = dst_lo;
} else {
/* unsigned */
uae_u32 dst_lo,dst_hi;
- mul_unsigned(src,(uae_u32)m68k_dreg(regs, (extra >> 12) & 7),&dst_hi,&dst_lo);
+ mul_unsigned(src,(uae_u32)m68k_dreg(®s, (extra >> 12) & 7),&dst_hi,&dst_lo);
SET_VFLG (0);
SET_CFLG (0);
SET_ZFLG (dst_hi == 0 && dst_lo == 0);
SET_NFLG (((uae_s32)dst_hi) < 0);
if (extra & 0x400)
- m68k_dreg(regs, extra & 7) = dst_hi;
+ m68k_dreg(®s, extra & 7) = dst_hi;
else if (dst_hi != 0) {
SET_VFLG (1);
}
#endif
-static char* ccnames[] =
-{ "T ","F ","HI","LS","CC","CS","NE","EQ",
- "VC","VS","PL","MI","GE","LT","GT","LE" };
-
void m68k_reset (void)
{
regs.kick_mask = 0x00F80000;
regs.spcflags = 0;
+#ifdef SAVESTATE
if (savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND) {
- m68k_setpc (regs.pc);
+ m68k_setpc (®s, regs.pc);
/* MakeFromSR() must not swap stack pointer */
regs.s = (regs.sr >> 13) & 1;
- MakeFromSR();
+ MakeFromSR(®s);
/* set stack pointer */
if (regs.s)
- m68k_areg(regs, 7) = regs.isp;
+ m68k_areg(®s, 7) = regs.isp;
else
- m68k_areg(regs, 7) = regs.usp;
+ m68k_areg(®s, 7) = regs.usp;
return;
}
-
- m68k_areg (regs, 7) = get_long (0x00f80000);
- m68k_setpc (get_long (0x00f80004));
+#endif
+ m68k_areg (®s, 7) = get_long (0x00f80000);
+ m68k_setpc (®s, get_long (0x00f80004));
regs.s = 1;
regs.m = 0;
regs.stopped = 0;
regs.t1 = 0;
regs.t0 = 0;
- SET_ZFLG (0);
- SET_XFLG (0);
- SET_CFLG (0);
- SET_VFLG (0);
- SET_NFLG (0);
+ SET_ZFLG (®s.ccrflags, 0);
+ SET_XFLG (®s.ccrflags, 0);
+ SET_CFLG (®s.ccrflags, 0);
+ SET_VFLG (®s.ccrflags, 0);
+ SET_NFLG (®s.ccrflags, 0);
regs.intmask = 7;
regs.vbr = regs.sfc = regs.dfc = 0;
#ifdef FPUEMU
regs.fp_result=1;
regs.irc = 0xffff;
#endif
- fill_prefetch_slow ();
+ fill_prefetch_slow (®s);
}
STATIC_INLINE int in_rom (uaecptr pc)
return (munge24 (pc) & 0xFFFF0000) == RTAREA_BASE;
}
-unsigned long REGPARAM2 op_illg (uae_u32 opcode)
+unsigned long REGPARAM2 op_illg (uae_u32 opcode, struct regstruct *regs)
{
- uaecptr pc = m68k_getpc ();
+ uaecptr pc = m68k_getpc (regs);
static int warned;
+ int inrom = in_rom(pc);
+ int inrt = in_rtarea(pc);
if (cloanto_rom && (opcode & 0xF100) == 0x7100) {
m68k_dreg (regs, (opcode >> 9) & 7) = (uae_s8)(opcode & 0xFF);
- m68k_incpc (2);
- fill_prefetch_slow ();
+ m68k_incpc (regs, 2);
+ fill_prefetch_slow (regs);
return 4;
}
- if (opcode == 0x4E7B && in_rom (pc) && get_long (0x10) == 0) {
+ if (opcode == 0x4E7B && inrom && get_long (0x10) == 0) {
notify_user (NUMSG_KS68020);
uae_restart (-1, NULL);
}
#ifdef AUTOCONFIG
if (opcode == 0xFF0D) {
- if (in_rom (pc)) {
+ if (inrom) {
/* This is from the dummy Kickstart replacement */
- uae_u16 arg = get_iword (2);
- m68k_incpc (4);
+ uae_u16 arg = get_iword (regs, 2);
+ m68k_incpc (regs, 4);
ersatz_perform (arg);
- fill_prefetch_slow ();
+ fill_prefetch_slow (regs);
return 4;
- } else if (in_rtarea (pc)) {
+ } else if (inrt) {
/* User-mode STOP replacement */
- m68k_setstopped (1);
+ m68k_setstopped (regs, 1);
return 4;
}
}
- if ((opcode & 0xF000) == 0xA000 && in_rtarea (pc)) {
+ if ((opcode & 0xF000) == 0xA000 && inrt) {
/* Calltrap. */
- m68k_incpc(2);
- call_calltrap (opcode & 0xFFF);
- fill_prefetch_slow ();
+ m68k_incpc(regs, 2);
+ m68k_handle_trap (opcode & 0xFFF, regs);
+ fill_prefetch_slow (regs);
return 4;
}
#endif
if ((opcode & 0xF000) == 0xF000) {
if (warned < 20) {
- write_log ("B-Trap %x at %x (%p)\n", opcode, m68k_getpc () + m68kpc_offset, regs.pc_p);
+ write_log ("B-Trap %x at %x (%p)\n", opcode, m68k_getpc (regs) + m68kpc_offset, regs->pc_p);
warned++;
}
- Exception(0xB,0);
+ Exception(0xB, regs, 0);
return 4;
}
if ((opcode & 0xF000) == 0xA000) {
#ifdef AUTOCONFIG
- if (in_rtarea (pc)) {
+ if (inrt) {
/* Calltrap. */
- call_calltrap (opcode & 0xFFF);
+ m68k_handle_trap (opcode & 0xFFF, regs);
}
#endif
- Exception(0xA,0);
+ Exception(0xA, regs, 0);
return 4;
}
if (warned < 20) {
- write_log ("Illegal instruction: %04x at %08.8X -> %08.8X\n", opcode, pc, get_long (regs.vbr + 0x10));
+ write_log ("Illegal instruction: %04x at %08.8X -> %08.8X\n", opcode, pc, get_long (regs->vbr + 0x10));
warned++;
}
- Exception (4,0);
+ Exception (4, regs, 0);
return 4;
}
#ifdef CPUEMU_0
-void mmu_op(uae_u32 opcode, uae_u16 extra)
+void mmu_op(uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
{
if ((opcode & 0xFE0) == 0x0500) {
/* PFLUSH */
/* PTEST */
//write_log ("PTEST @$%lx\n", m68k_getpc());
} else
- op_illg (opcode);
+ op_illg (opcode, regs);
}
#endif
-static int n_insns = 0, n_spcinsns = 0;
-
static uaecptr last_trace_ad = 0;
static void do_trace (void)
/* should also include TRAP, CHK, SR modification FPcc */
/* probably never used so why bother */
/* We can afford this to be inefficient... */
- m68k_setpc (m68k_getpc ());
- fill_prefetch_slow ();
+ m68k_setpc (®s, m68k_getpc (®s));
+ fill_prefetch_slow (®s);
opcode = get_word (regs.pc);
if (opcode == 0x4e72 /* RTE */
|| opcode == 0x4e74 /* RTD */
|| (opcode & 0xffc0) == 0x4ec0 /* JMP */
|| (opcode & 0xff00) == 0x6100 /* BSR */
|| ((opcode & 0xf000) == 0x6000 /* Bcc */
- && cctrue((opcode >> 8) & 0xf))
+ && cctrue(®s.ccrflags, (opcode >> 8) & 0xf))
|| ((opcode & 0xf0f0) == 0x5050 /* DBcc */
- && !cctrue((opcode >> 8) & 0xf)
- && (uae_s16)m68k_dreg(regs, opcode & 7) != 0))
+ && !cctrue(®s.ccrflags, (opcode >> 8) & 0xf)
+ && (uae_s16)m68k_dreg(®s, opcode & 7) != 0))
{
- last_trace_ad = m68k_getpc ();
- unset_special (SPCFLAG_TRACE);
- set_special (SPCFLAG_DOTRACE);
+ last_trace_ad = m68k_getpc (®s);
+ unset_special (®s, SPCFLAG_TRACE);
+ set_special (®s, SPCFLAG_DOTRACE);
}
} else if (regs.t1) {
- last_trace_ad = m68k_getpc ();
- unset_special (SPCFLAG_TRACE);
- set_special (SPCFLAG_DOTRACE);
+ last_trace_ad = m68k_getpc (®s);
+ unset_special (®s, SPCFLAG_TRACE);
+ set_special (®s, SPCFLAG_DOTRACE);
}
}
#define IDLETIME (currprefs.cpu_idle * sleep_resolution / 1000)
-static int do_specialties (int cycles)
+STATIC_INLINE int do_specialties (int cycles, struct regstruct *regs)
{
#ifdef ACTION_REPLAY
#ifdef ACTION_REPLAY_HRTMON
- if ((regs.spcflags & SPCFLAG_ACTION_REPLAY) && hrtmon_flag != ACTION_REPLAY_INACTIVE) {
- int isinhrt = (m68k_getpc() >= hrtmem_start && m68k_getpc() < hrtmem_start + hrtmem_size);
+ if ((regs->spcflags & SPCFLAG_ACTION_REPLAY) && hrtmon_flag != ACTION_REPLAY_INACTIVE) {
+ int isinhrt = (m68k_getpc(regs) >= hrtmem_start && m68k_getpc(regs) < hrtmem_start + hrtmem_size);
/* exit from HRTMon? */
if(hrtmon_flag == ACTION_REPLAY_ACTIVE && !isinhrt)
hrtmon_hide();
hrtmon_breakenter();
if(hrtmon_flag == ACTION_REPLAY_ACTIVATE)
hrtmon_enter();
- if(!(regs.spcflags & ~SPCFLAG_ACTION_REPLAY))
+ if(!(regs->spcflags & ~SPCFLAG_ACTION_REPLAY))
return 0;
}
#endif
- if ((regs.spcflags & SPCFLAG_ACTION_REPLAY) && action_replay_flag != ACTION_REPLAY_INACTIVE ) {
+ if ((regs->spcflags & SPCFLAG_ACTION_REPLAY) && action_replay_flag != ACTION_REPLAY_INACTIVE ) {
/*if(action_replay_flag == ACTION_REPLAY_ACTIVE && !is_ar_pc_in_rom())*/
/* write_log("PC:%p\n",m68k_getpc());*/
if(action_replay_flag == ACTION_REPLAY_HIDE && !is_ar_pc_in_rom())
{
action_replay_hide();
- unset_special(SPCFLAG_ACTION_REPLAY);
+ unset_special(regs, SPCFLAG_ACTION_REPLAY);
}
if (action_replay_flag == ACTION_REPLAY_WAIT_PC )
{
/*write_log("Waiting for PC: %p, current PC= %p\n",wait_for_pc, m68k_getpc());*/
- if (m68k_getpc() == wait_for_pc)
+ if (m68k_getpc(regs) == wait_for_pc)
{
action_replay_flag = ACTION_REPLAY_ACTIVATE; /* Activate after next instruction. */
}
}
#endif
- if (regs.spcflags & SPCFLAG_COPPER)
+ if (regs->spcflags & SPCFLAG_COPPER)
do_copper ();
/*n_spcinsns++;*/
#ifdef JIT
- unset_special(SPCFLAG_END_COMPILE); /* has done its job */
+ unset_special(regs, SPCFLAG_END_COMPILE); /* has done its job */
#endif
- while ((regs.spcflags & SPCFLAG_BLTNASTY) && dmaen (DMA_BLITTER) && cycles > 0 && !currprefs.blitter_cycle_exact) {
+ while ((regs->spcflags & SPCFLAG_BLTNASTY) && dmaen (DMA_BLITTER) && cycles > 0 && !currprefs.blitter_cycle_exact) {
int c = blitnasty();
if (c > 0) {
cycles -= c * CYCLE_UNIT * 2;
} else
c = 4;
do_cycles (c * CYCLE_UNIT);
- if (regs.spcflags & SPCFLAG_COPPER)
+ if (regs->spcflags & SPCFLAG_COPPER)
do_copper ();
}
- if (regs.spcflags & SPCFLAG_DOTRACE)
- Exception (9,last_trace_ad);
- if (regs.spcflags & SPCFLAG_TRAP) {
- unset_special (SPCFLAG_TRAP);
- Exception (3, 0);
+ if (regs->spcflags & SPCFLAG_DOTRACE)
+ Exception (9, regs, last_trace_ad);
+ if (regs->spcflags & SPCFLAG_TRAP) {
+ unset_special (regs, SPCFLAG_TRAP);
+ Exception (3, regs, 0);
}
- while (regs.spcflags & SPCFLAG_STOP) {
+ while (regs->spcflags & SPCFLAG_STOP) {
do_cycles (4 * CYCLE_UNIT);
- if (regs.spcflags & SPCFLAG_COPPER)
+ if (regs->spcflags & SPCFLAG_COPPER)
do_copper ();
- if (regs.spcflags & (SPCFLAG_INT | SPCFLAG_DOINT)) {
+ if (regs->spcflags & (SPCFLAG_INT | SPCFLAG_DOINT)) {
int intr = intlev ();
#ifdef JIT
if (currprefs.cachesize)
- unset_special (SPCFLAG_INT | SPCFLAG_DOINT);
+ unset_special (regs, SPCFLAG_INT | SPCFLAG_DOINT);
#endif
- if (intr != -1 && intr > regs.intmask)
+ if (intr != -1 && intr > regs->intmask)
Interrupt (intr);
}
- if ((regs.spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE))) {
- unset_special (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
+ if ((regs->spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE))) {
+ unset_special (regs, SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
return 1;
}
- if (currprefs.cpu_idle && currprefs.m68k_speed != 0 && ((regs.spcflags & SPCFLAG_STOP)) == SPCFLAG_STOP) {
+ if (currprefs.cpu_idle && currprefs.m68k_speed != 0 && ((regs->spcflags & SPCFLAG_STOP)) == SPCFLAG_STOP) {
/* sleep 1ms if STOP-instruction is executed */
if (1) {
static int sleepcnt, lvpos, zerocnt;
}
}
- if (regs.spcflags & SPCFLAG_TRACE)
+ if (regs->spcflags & SPCFLAG_TRACE)
do_trace ();
/* interrupt takes at least 2 cycles (maybe 4) to reach the CPU and
* there are programs that require this delay (which is not too surprising..)
*/
#ifdef JIT
- if ((regs.spcflags & SPCFLAG_DOINT)
- || (!currprefs.cachesize && (regs.spcflags & SPCFLAG_INT))) {
+ if ((regs->spcflags & SPCFLAG_DOINT)
+ || (!currprefs.cachesize && (regs->spcflags & SPCFLAG_INT))) {
#else
- if (regs.spcflags & SPCFLAG_INT) {
+ if (regs->spcflags & SPCFLAG_INT) {
#endif
int intr = intlev ();
#ifdef JIT
if (currprefs.cachesize)
- unset_special (SPCFLAG_DOINT);
+ unset_special (regs, SPCFLAG_DOINT);
#endif
- if (intr != -1 && intr > regs.intmask)
- Interrupt (intr);
+ if (intr != -1 && intr > regs->intmask)
+ do_interrupt (intr, regs);
}
#ifdef JIT
- if ((regs.spcflags & SPCFLAG_INT) && currprefs.cachesize) {
- unset_special (SPCFLAG_INT);
- set_special (SPCFLAG_DOINT);
+ if ((regs->spcflags & SPCFLAG_INT) && currprefs.cachesize) {
+ unset_special (regs, SPCFLAG_INT);
+ set_special (regs, SPCFLAG_DOINT);
}
#endif
- if ((regs.spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE))) {
- unset_special (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
+ if ((regs->spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE))) {
+ unset_special (regs, SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
return 1;
}
return 0;
This version emulates 68000's prefetch "cache" */
static void m68k_run_1 (void)
{
+ struct regstruct *r = ®s;
+
for (;;) {
int cycles;
- uae_u32 opcode = regs.ir;
+ uae_u32 opcode = r->ir;
+
+ count_instr (opcode);
+
#if 0
int pc = m68k_getpc();
if (pc == 0xdff002)
//write_log("%08.8X-%04.4X ",pc, opcode);
}
#endif
- /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */
-/* regs_backup[backup_pointer = (backup_pointer + 1) % 16] = regs;*/
-#if COUNT_INSTRS == 2
- if (table68k[opcode].handler != -1)
- instrcount[table68k[opcode].handler]++;
-#elif COUNT_INSTRS == 1
- instrcount[opcode]++;
-#endif
-#if defined X86_ASSEMBLY
- __asm__ __volatile__("\tcall *%%ebx"
- : "=&a" (cycles) : "b" (cpufunctbl[opcode]), "0" (opcode)
- : "%edx", "%ecx",
- "%esi", "%edi", "%ebp", "memory", "cc");
-#else
- cycles = (*cpufunctbl[opcode])(opcode);
-#endif
- /*n_insns++;*/
+
+ cycles = (*cpufunctbl[opcode])(opcode, r);
+
cycles &= cycles_mask;
cycles |= cycles_val;
do_cycles (cycles);
- if (regs.spcflags) {
- if (do_specialties (cycles))
+ if (r->spcflags) {
+ if (do_specialties (cycles, r))
return;
}
if (!currprefs.cpu_compatible || (currprefs.cpu_cycle_exact && currprefs.cpu_level == 0))
}
}
-#endif
+#endif /* CPUEMU_5 */
#ifndef CPUEMU_6
static void m68k_run_1_ce (void)
{
+ struct regstruct *r = ®s;
+
for (;;) {
- uae_u32 opcode = regs.ir;
-#if 0
- int pc = m68k_getpc();
- if (pc != pcs[0]) {
- memmove (pcs + 1, pcs, 998 * 4);
- pcs[0] = pc;
- }
-#endif
- (*cpufunctbl[opcode])(opcode);
- if (regs.spcflags) {
- if (do_specialties (0))
+ uae_u32 opcode = r->ir;
+
+ (*cpufunctbl[opcode])(opcode, r);
+ if (r->spcflags) {
+ if (do_specialties (0, r))
return;
}
if (!currprefs.cpu_cycle_exact || currprefs.cpu_level > 0)
/* I bet you didn't expect *that* ;-) */
}
-#ifdef JIT
-
void exec_nostats(void)
{
+ struct regstruct *r = ®s;
int new_cycles;
for (;;)
{
- uae_u16 opcode = get_iword(0);
-#if defined X86_ASSEMBLY
- __asm__ __volatile__("\tpush %%ebp\n\tcall *%%ebx\n\tpop %%ebp" /* FIXME */
- : "=&a" (new_cycles)
- : "b" (cpufunctbl[opcode]), "0" (opcode)
- : "%edx", "%ecx", "%esi", "%edi",
- "%ebp", "memory", "cc");
-#else
- new_cycles = (*cpufunctbl[opcode])(opcode);
-#endif
+ uae_u16 opcode = get_iword(r, 0);
+
+ new_cycles = (*cpufunctbl[opcode])(opcode, r);
new_cycles &= cycles_mask;
new_cycles |= cycles_val;
do_cycles (new_cycles);
- if (end_block(opcode) ||
- regs.spcflags) {
+ if (end_block(opcode) || r->spcflags)
return; /* We will deal with the spcflags in the caller */
- }
}
}
void execute_normal(void)
{
+ struct regstruct *r = ®s;
int blocklen;
cpu_history pc_hist[MAXRUN];
int new_cycles;
if (check_for_cache_miss())
return;
+
total_cycles = 0;
blocklen = 0;
- start_pc_p = regs.pc_oldp;
- start_pc = regs.pc;
- for (;;)
- { /* Take note: This is the do-it-normal loop */
- uae_u16 opcode = get_iword (0);
+ start_pc_p = r->pc_oldp;
+ start_pc = r->pc;
+ for (;;) {
+ /* Take note: This is the do-it-normal loop */
+ uae_u16 opcode = get_iword (r, 0);
special_mem = DISTRUST_CONSISTENT_MEM;
- pc_hist[blocklen].location = (uae_u16*)regs.pc_p;
-#if defined X86_ASSEMBLY
- __asm__ __volatile__("\tpush %%ebp\n\tcall *%%ebx\n\tpop %%ebp" /* FIXME */
- : "=&a" (new_cycles)
- : "b" (cpufunctbl[opcode]), "0" (opcode)
- : "%edx", "%ecx", "%esi", "%edi",
- "%ebp", "memory", "cc");
-#else
- new_cycles = (*cpufunctbl[opcode])(opcode);
-#endif
+ pc_hist[blocklen].location = (uae_u16*)r->pc_p;
+
+ new_cycles = (*cpufunctbl[opcode])(opcode, r);
+
new_cycles &= cycles_mask;
new_cycles |= cycles_val;
do_cycles (new_cycles);
total_cycles += new_cycles;
pc_hist[blocklen].specmem = special_mem;
blocklen++;
- if (end_block(opcode) || blocklen >= MAXRUN || regs.spcflags) {
+ if (end_block(opcode) || blocklen >= MAXRUN || r->spcflags) {
compile_block(pc_hist,blocklen,total_cycles);
return; /* We will deal with the spcflags in the caller */
}
we'd have ended up inside that "if" */
}
}
-#endif
typedef void compiled_handler(void);
static void m68k_run_2a (void)
{
for (;;) {
-#if defined X86_ASSEMBLY
- __asm__ __volatile__(
- "\tpush %%ebp\n\tcall *%0\n\tpop %%ebp" /* FIXME */
- :: "m" (cache_tags[cacheline(regs.pc_p)].handler)
- : "%edx", "%ecx", "%eax",
- "%esi", "%ebx", "%edi", "%ebp", "memory", "cc");
-#else
((compiled_handler*)(pushall_call_handler))();
-#endif
/* Whenever we return from that, we should check spcflags */
if (regs.spcflags) {
- if (do_specialties (0)) {
+ if (do_specialties (0, ®s)) {
return;
}
}
}
}
-#endif
+#endif /* JIT */
#ifndef CPUEMU_0
static void m68k_run_2p (void)
{
uae_u32 prefetch, prefetch_pc;
+ struct regstruct *r = ®s;
- prefetch_pc = m68k_getpc ();
+ prefetch_pc = m68k_getpc (r);
prefetch = get_long (prefetch_pc);
for (;;) {
int cycles;
uae_u32 opcode;
- uae_u32 pc = m68k_getpc ();
+ uae_u32 pc = m68k_getpc (r);
if (pc == prefetch_pc)
opcode = prefetch >> 16;
else if (pc == prefetch_pc + 2)
opcode = prefetch & 0xffff;
else
opcode = get_word (pc);
-#if COUNT_INSTRS == 2
- if (table68k[opcode].handler != -1)
- instrcount[table68k[opcode].handler]++;
-#elif COUNT_INSTRS == 1
- instrcount[opcode]++;
-#endif
- prefetch_pc = m68k_getpc () + 2;
+
+ count_instr (opcode);
+
+ prefetch_pc = m68k_getpc (r) + 2;
prefetch = get_long (prefetch_pc);
- cycles = (*cpufunctbl[opcode])(opcode);
+ cycles = (*cpufunctbl[opcode])(opcode, r);
cycles &= cycles_mask;
cycles |= cycles_val;
do_cycles (cycles);
- if (regs.spcflags) {
- if (do_specialties (cycles))
+ if (r->spcflags) {
+ if (do_specialties (cycles, r))
return;
}
}
/* Same thing, but don't use prefetch to get opcode. */
static void m68k_run_2 (void)
{
- for (;;) {
+ struct regstruct *r = ®s;
+
+ for (;;) {
int cycles;
- uae_u32 opcode = get_iword (0);
+ uae_u32 opcode = get_iword (r, 0);
+ count_instr (opcode);
-#ifdef DEBUG_CD32IO
- {
- int pc = m68k_getpc();
- if (pc >= 0xe57cc0 && pc <= 0xe57ef2)
- out_cd32io (pc);
- if (pc == cd32nextpc)
- out_cd32io2 ();
- }
-#endif
-#if 0
- int pc = m68k_getpc();
- if (pc == 0xd0000) {
- write_log ("%x %x %x %x\n", pcs[0], pcs[1], pcs[2], pcs[3]);
- activate_debugger();
- }
- if (pc != pcs[0] && pc <0xd00000) {
- memmove (pcs + 1, pcs, 998 * 4);
- pcs[0] = pc;
- }
-#endif
- /* assert (!regs.stopped && !(regs.spcflags & SPCFLAG_STOP)); */
-/* regs_backup[backup_pointer = (backup_pointer + 1) % 16] = regs;*/
-#if COUNT_INSTRS == 2
- if (table68k[opcode].handler != -1)
- instrcount[table68k[opcode].handler]++;
-#elif COUNT_INSTRS == 1
- instrcount[opcode]++;
-#endif
-#if defined X86_ASSEMBLY
- __asm__ __volatile__("\tcall *%%ebx"
- : "=&a" (cycles) : "b" (cpufunctbl[opcode]), "0" (opcode)
- : "%edx", "%ecx",
- "%esi", "%edi", "%ebp", "memory", "cc");
-#else
- cycles = (*cpufunctbl[opcode])(opcode);
-#endif
+ cycles = (*cpufunctbl[opcode])(opcode, r);
- /*n_insns++;*/
cycles &= cycles_mask;
cycles |= cycles_val;
do_cycles (cycles);
- if (regs.spcflags) {
- if (do_specialties (cycles))
+ if (r->spcflags) {
+ if (do_specialties (cycles, r))
return;
}
}
/* "MMU" 68k */
static void m68k_run_mmu (void)
{
- for (;;) {
+ for (;;) {
int cycles;
- uae_u32 opcode = get_iword (0);
+ uae_u32 opcode = get_iword (®s, 0);
mmu_backup_regs = regs;
- cycles = (*cpufunctbl[opcode])(opcode);
+ cycles = (*cpufunctbl[opcode])(opcode, ®s);
cycles &= cycles_mask;
cycles |= cycles_val;
if (mmu_triggered)
mmu_do_hit();
do_cycles (cycles);
if (regs.spcflags) {
- if (do_specialties (cycles))
+ if (do_specialties (cycles, ®s))
return;
}
}
}
-#endif
-
-#ifdef X86_ASSEMBLY
-STATIC_INLINE void m68k_run1 (void (*func)(void))
-{
- /* Work around compiler bug: GCC doesn't push %ebp in m68k_run_1. */
- __asm__ __volatile__ ("pushl %%ebp\n\tcall *%0\n\tpopl %%ebp"
- : : "r" (func) : "%eax", "%edx", "%ecx", "memory", "cc");
-}
-#else
-#define m68k_run1(F) (F) ()
-#endif
+#endif /* CPUEMU_0 */
int in_m68k_go = 0;
last_fault_for_exception_3 = fault;
last_writeaccess_for_exception_3 = 0;
last_instructionaccess_for_exception_3 = 0;
- Exception (2, addr);
+ Exception (2, ®s, addr);
}
void m68k_go (int may_quit)
in_m68k_go++;
for (;;) {
+ void (*run_func)(void);
if (quit_program > 0) {
int hardreset = quit_program == 3 ? 1 : 0;
if (quit_program == 1)
break;
quit_program = 0;
+#ifdef SAVESTATE
if (savestate_state == STATE_RESTORE)
restore_state (savestate_fname);
else if (savestate_state == STATE_REWIND)
savestate_rewind ();
+#endif
/* following three lines must not be reordered or
* fastram state restore breaks
*/
memset (chipmemory, 0, allocated_chipmem);
write_log ("chipmem cleared\n");
}
+#ifdef SAVESTATE
/* We may have been restoring state, but we're done now. */
if (savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND) {
map_overlay (1);
- fill_prefetch_slow (); /* compatibility with old state saves */
+ fill_prefetch_slow (®s); /* compatibility with old state saves */
}
savestate_restore_finish ();
- fill_prefetch_slow ();
+#endif
+ fill_prefetch_slow (®s);
if (currprefs.produce_sound == 0)
eventtab[ev_audio].active = 0;
handle_active_events ();
if (regs.spcflags)
- do_specialties (0);
- m68k_setpc (regs.pc);
+ do_specialties (0, ®s);
+ m68k_setpc (®s, regs.pc);
}
#ifdef DEBUGGER
if (regs.spcflags) {
uae_u32 of = regs.spcflags;
regs.spcflags &= ~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
- do_specialties (0);
+ do_specialties (0, ®s);
regs.spcflags |= of & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
}
#ifndef JIT
- m68k_run1 (currprefs.cpu_level == 0 && currprefs.cpu_cycle_exact ? m68k_run_1_ce :
+ run_func = currprefs.cpu_level == 0 && currprefs.cpu_cycle_exact ? m68k_run_1_ce :
currprefs.cpu_level == 0 && currprefs.cpu_compatible ? m68k_run_1 :
- currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2);
+ currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2;
#else
if (mmu_enabled && !currprefs.cachesize) {
- m68k_run1 (m68k_run_mmu);
+ run_func = m68k_run_mmu;
} else {
- m68k_run1 (currprefs.cpu_cycle_exact && currprefs.cpu_level == 0 ? m68k_run_1_ce :
+ run_func = currprefs.cpu_cycle_exact && currprefs.cpu_level == 0 ? m68k_run_1_ce :
currprefs.cpu_compatible > 0 && currprefs.cpu_level == 0 ? m68k_run_1 :
currprefs.cpu_level >= 2 && currprefs.cachesize ? m68k_run_2a :
- currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2);
+ currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2;
}
#endif
+ run_func ();
}
in_m68k_go--;
}
+#if 0
static void m68k_verify (uaecptr addr, uaecptr *nextpc)
{
uae_u32 opcode, val;
if (dp->suse) {
if (!verify_ea (dp->sreg, dp->smode, dp->size, &val)) {
- Exception (3, 0);
+ Exception (3, ®s, 0);
return;
}
}
if (dp->duse) {
if (!verify_ea (dp->dreg, dp->dmode, dp->size, &val)) {
- Exception (3, 0);
+ Exception (3, ®s, 0);
return;
}
}
}
+#endif
+
+static const char* ccnames[] =
+{ "T ","F ","HI","LS","CC","CS","NE","EQ",
+ "VC","VS","PL","MI","GE","LT","GT","LE" };
void m68k_disasm_2 (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode)
{
uaecptr newpc = 0;
- m68kpc_offset = addr - m68k_getpc ();
+ m68kpc_offset = addr - m68k_getpc (®s);
while (cnt-- > 0) {
char instrname[100], *ccpt;
for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++)
;
- f_out (f, "%08lx ", m68k_getpc () + m68kpc_offset);
+ f_out (f, "%08lx ", m68k_getpc (®s) + m68kpc_offset);
m68kpc_offset += 2;
strcpy (instrname, lookup->name);
}
if (dp->suse) {
- newpc = m68k_getpc () + m68kpc_offset;
+ newpc = m68k_getpc (®s) + m68kpc_offset;
newpc += ShowEA (0, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr, safemode);
}
if (dp->suse && dp->duse)
strcat (instrname, ",");
if (dp->duse) {
- newpc = m68k_getpc () + m68kpc_offset;
+ newpc = m68k_getpc (®s) + m68kpc_offset;
newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode);
}
if (ccpt != 0) {
if (deaddr)
*deaddr = newpc;
- if (cctrue(dp->cc))
+ if (cctrue(®s.ccrflags, dp->cc))
f_out (f, " == %08lx (TRUE)", newpc);
else
f_out (f, " == %08lx (FALSE)", newpc);
f_out (f, "\n");
}
if (nextpc)
- *nextpc = m68k_getpc () + m68kpc_offset;
+ *nextpc = m68k_getpc (®s) + m68kpc_offset;
}
void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr)
uaecptr newpc = 0;
- m68kpc_offset = addr - m68k_getpc ();
+ m68kpc_offset = addr - m68k_getpc (®s);
oldpc = m68kpc_offset;
opcode = get_iword_1 (m68kpc_offset);
}
if (dp->suse) {
- newpc = m68k_getpc () + m68kpc_offset;
+ newpc = m68k_getpc (®s) + m68kpc_offset;
newpc += ShowEA (0, opcode, dp->sreg, dp->smode, dp->size, instrname, NULL, 0);
}
if (dp->suse && dp->duse)
strcat (instrname, ",");
if (dp->duse) {
- newpc = m68k_getpc () + m68kpc_offset;
+ newpc = m68k_getpc (®s) + m68kpc_offset;
newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, NULL, 0);
}
}
if (nextpc)
- *nextpc = m68k_getpc () + m68kpc_offset;
+ *nextpc = m68k_getpc (®s) + m68kpc_offset;
}
void m68k_dumpstate (void *f, uaecptr *nextpc)
int i;
for (i = 0; i < 8; i++){
- f_out (f, "D%d: %08lx ", i, m68k_dreg(regs, i));
+ f_out (f, "D%d: %08lx ", i, m68k_dreg(®s, i));
if ((i & 3) == 3) f_out (f, "\n");
}
for (i = 0; i < 8; i++){
- f_out (f, "A%d: %08lx ", i, m68k_areg(regs, i));
+ f_out (f, "A%d: %08lx ", i, m68k_areg(®s, i));
if ((i & 3) == 3) f_out (f, "\n");
}
- if (regs.s == 0) regs.usp = m68k_areg(regs, 7);
- if (regs.s && regs.m) regs.msp = m68k_areg(regs, 7);
- if (regs.s && regs.m == 0) regs.isp = m68k_areg(regs, 7);
+ if (regs.s == 0) regs.usp = m68k_areg(®s, 7);
+ if (regs.s && regs.m) regs.msp = m68k_areg(®s, 7);
+ if (regs.s && regs.m == 0) regs.isp = m68k_areg(®s, 7);
f_out (f, "USP=%08lx ISP=%08lx MSP=%08lx VBR=%08lx\n",
regs.usp,regs.isp,regs.msp,regs.vbr);
f_out (f, "T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d STP=%d\n",
regs.t1, regs.t0, regs.s, regs.m,
- GET_XFLG, GET_NFLG, GET_ZFLG, GET_VFLG, GET_CFLG,
+ GET_XFLG(®s.ccrflags), GET_NFLG(®s.ccrflags), GET_ZFLG(®s.ccrflags),
+ GET_VFLG(®s.ccrflags), GET_CFLG(®s.ccrflags),
regs.intmask, regs.stopped);
#ifdef FPUEMU
if (currprefs.cpu_level >= 2) {
f_out (f, "Prefetch %04x (%s) %04x (%s)\n", regs.irc, lookup1->name, regs.ir, lookup2->name);
}
- m68k_disasm (f, m68k_getpc (), nextpc, 1);
+ m68k_disasm (f, m68k_getpc (®s), nextpc, 1);
if (nextpc)
f_out (f, "Next PC: %08lx\n", *nextpc);
}
+#ifdef SAVESTATE
/* CPU save/restore code */
l = restore_u32();
if (l & CPUMODE_HALT) {
regs.stopped = 1;
- set_special (SPCFLAG_STOP);
+ set_special (®s, SPCFLAG_STOP);
} else
regs.stopped = 0;
if (model >= 68010) {
void restore_cpu_finish(void)
{
- init_m68k_full ();
- m68k_setpc (regs.pc);
+ init_m68k ();
+ m68k_setpc (®s, regs.pc);
}
static int cpumodel[] = { 68000, 68010, 68020, 68020, 68040, 68060 };
save_u32 (model); /* MODEL */
save_u32 (currprefs.address_space_24 ? 1 : 0); /* FLAGS */
for(i = 0;i < 15; i++) save_u32 (regs.regs[i]); /* D0-D7 A0-A6 */
- save_u32 (m68k_getpc ()); /* PC */
+ save_u32 (m68k_getpc (®s)); /* PC */
save_u16 (regs.irc); /* prefetch */
save_u16 (regs.ir); /* instruction prefetch */
- MakeSR ();
+ MakeSR (®s);
save_u32 (!regs.s ? regs.regs[15] : regs.usp); /* USP */
save_u32 (regs.s ? regs.regs[15] : regs.isp); /* ISP */
save_u16 (regs.sr); /* SR/CCR */
return dstbak;
}
+#endif /* SAVESTATE */
+
static void exception3f (uae_u32 opcode, uaecptr addr, uaecptr fault, int writeaccess, int instructionaccess)
{
last_addr_for_exception_3 = addr;
last_op_for_exception_3 = opcode;
last_writeaccess_for_exception_3 = writeaccess;
last_instructionaccess_for_exception_3 = instructionaccess;
- Exception (3, fault);
+ Exception (3, ®s, fault);
}
void exception3 (uae_u32 opcode, uaecptr addr, uaecptr fault)
void exception2 (uaecptr addr, uaecptr fault)
{
write_log ("delayed exception2!\n");
- regs.panic_pc = m68k_getpc();
+ regs.panic_pc = m68k_getpc (®s);
regs.panic_addr = addr;
regs.panic = 2;
- set_special (SPCFLAG_BRK);
- m68k_setpc (0xf80000);
+ set_special (®s, SPCFLAG_BRK);
+ m68k_setpc (®s, 0xf80000);
#ifdef JIT
- set_special(SPCFLAG_END_COMPILE);
+ set_special(®s, SPCFLAG_END_COMPILE);
#endif
- fill_prefetch_slow ();
+ fill_prefetch_slow (®s);
}
void cpureset (void)
customreset ();
return;
}
- ins = get_word (m68k_getpc() + 2);
+ ins = get_word (m68k_getpc(®s) + 2);
if ((ins & ~7) == 0x4ed0) {
int reg = ins & 7;
- uae_u32 addr = m68k_areg (regs, reg);
+ uae_u32 addr = m68k_areg (®s, reg);
write_log ("reset/jmp (ax) combination emulated\n");
customreset ();
if (addr < 0x80000)
addr += 0xf80000;
- m68k_setpc (addr);
+ m68k_setpc (®s, addr);
}
#endif
}
#if defined(AHI)
-#ifdef __GNUC__
-#define INITGUID
-#endif
+#include <ctype.h>
+#include <assert.h>
+
#include <windows.h>
#include <stdlib.h>
#include <stdarg.h>
-#include <mmsystem.h>
#include <dsound.h>
#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <io.h>
-#include "winspool.h"
-#include "sysdeps.h"
-#include "config.h"
+#include "sysdeps.h"
#include "options.h"
#include "memory.h"
#include "events.h"
#include "custom.h"
-#include "gensound.h"
#include "newcpu.h"
-#include "threaddep/thread.h"
-#include <ctype.h>
-#include <assert.h>
+#include "traps.h"
#include "od-win32/win32.h"
-#include "gui.h"
#include "picasso96_win.h"
#include "sounddep/sound.h"
-#include "od-win32/ahidsound.h"
-#include "vfw.h"
#include "dxwrap.h"
#include "win32.h"
#include "win32gfx.h"
-#include "inputdevice.h"
-#include "avioutput.h"
#include "parser.h"
#include "enforcer.h"
+#include "ahidsound.h"
static long samples,playchannel,intcount,norec;
int ahi_on;
#define SET_NATIVE_FUNC2(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32,uae_u32,uae_u32))(x)
#define CALL_NATIVE_FUNC2( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7) if(native_func) return native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6,a7,regs_ )
-static uae_u32 emulib_ExecuteNativeCode2 (void)
+static uae_u32 REGPARAM2 emulib_ExecuteNativeCode2 (TrapContext *context)
{
- uae_u8* object_UAM = (uae_u8*) m68k_areg( regs, 0 );
- uae_u32 d1 = m68k_dreg( regs, 1 );
- uae_u32 d2 = m68k_dreg( regs, 2 );
- uae_u32 d3 = m68k_dreg( regs, 3 );
- uae_u32 d4 = m68k_dreg( regs, 4 );
- uae_u32 d5 = m68k_dreg( regs, 5 );
- uae_u32 d6 = m68k_dreg( regs, 6 );
- uae_u32 d7 = m68k_dreg( regs, 7 );
- uae_u32 a1 = m68k_areg( regs, 1 );
- uae_u32 a2 = m68k_areg( regs, 2 );
- uae_u32 a3 = m68k_areg( regs, 3 );
- uae_u32 a4 = m68k_areg( regs, 4 );
- uae_u32 a5 = m68k_areg( regs, 5 );
- uae_u32 a7 = m68k_areg( regs, 7 );
- uae_u32 regs_ = (uae_u32)®s;
+ uae_u8* object_UAM = (uae_u8*) m68k_areg(&context->regs, 0);
+ uae_u32 d1 = m68k_dreg(&context->regs, 1);
+ uae_u32 d2 = m68k_dreg(&context->regs, 2);
+ uae_u32 d3 = m68k_dreg(&context->regs, 3);
+ uae_u32 d4 = m68k_dreg(&context->regs, 4);
+ uae_u32 d5 = m68k_dreg(&context->regs, 5);
+ uae_u32 d6 = m68k_dreg(&context->regs, 6);
+ uae_u32 d7 = m68k_dreg(&context->regs, 7);
+ uae_u32 a1 = m68k_areg(&context->regs, 1);
+ uae_u32 a2 = m68k_areg(&context->regs, 2);
+ uae_u32 a3 = m68k_areg(&context->regs, 3);
+ uae_u32 a4 = m68k_areg(&context->regs, 4);
+ uae_u32 a5 = m68k_areg(&context->regs, 5);
+ uae_u32 a7 = m68k_areg(&context->regs, 7);
+ uae_u32 regs_ = (uae_u32)&context->regs;
CREATE_NATIVE_FUNC_PTR2;
uaevar.z3offset = (uae_u32)(get_real_address (0x10000000) - 0x10000000);
uaevar.amigawnd = hAmigaWnd;
static uae_u32 bswap_buffer_size = 0;
static double syncdivisor;
-uae_u32 ahi_demux (void)
+uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
{
//use the extern int (6 #13)
// d0 0=opensound d1=unit d2=samplerate d3=blksize ret: sound frequency
// d0=108 free swap array
// d0=200 ahitweak d1=offset for dsound position pointer
- int opcode = m68k_dreg (regs, 0);
+ int opcode = m68k_dreg (&context->regs, 0);
switch (opcode)
{
int i,slen,t,todo,byte1,byte2;
cap_pos = 0;
sound_bits_ahi = 16;
sound_channels_ahi = 2;
- sound_freq_ahi = m68k_dreg (regs, 2);
- amigablksize = m68k_dreg (regs, 3);
+ sound_freq_ahi = m68k_dreg (&context->regs, 2);
+ amigablksize = m68k_dreg (&context->regs, 3);
sound_freq_ahi = ahi_open_sound();
uaevar.changenum--;
return sound_freq_ahi;
case 6: /* new open function */
cap_pos = 0;
- sound_freq_ahi = m68k_dreg (regs, 2);
- amigablksize = m68k_dreg (regs, 3);
- sound_channels_ahi = m68k_dreg (regs, 4);
- sound_bits_ahi = m68k_dreg (regs, 5);
+ sound_freq_ahi = m68k_dreg (&context->regs, 2);
+ amigablksize = m68k_dreg (&context->regs, 3);
+ sound_channels_ahi = m68k_dreg (&context->regs, 4);
+ sound_bits_ahi = m68k_dreg (&context->regs, 5);
sound_freq_ahi = ahi_open_sound();
uaevar.changenum--;
return sound_freq_ahi;
case 2:
{
- uaecptr addr = m68k_areg (regs, 0);
+ uaecptr addr = m68k_areg (&context->regs, 0);
for (i = 0; i < amigablksize * 4; i += 4)
*ahisndbufpt++ = get_long(addr + i);
ahi_finish_sound_buffer();
} else {
cap_pos = 0;
}
- addr = m68k_areg (regs, 0);
+ addr = m68k_areg (&context->regs, 0);
sndbufrecpt = (unsigned int*)pos1;
t=t/4;
for (i = 0; i < t; i++) {
case 11:
for (i = 0; i < clipsize; i++)
- put_byte(m68k_areg (regs, 0) + i,clipdat[i]);
+ put_byte(m68k_areg (&context->regs, 0) + i,clipdat[i]);
CloseClipboard();
return 0;
case 12:
{
- uae_u8 *addr = get_real_address (m68k_areg (regs, 0));
+ uae_u8 *addr = get_real_address (m68k_areg (&context->regs, 0));
if (OpenClipboard (0)) {
EmptyClipboard();
slen = strlen(addr);
extern uae_u16 vtotal;
extern unsigned int new_beamcon0;
p96hack_vpos2 = 0;
- if (m68k_dreg (regs, 1) > 0)
- p96hack_vpos2 = 15625 / m68k_dreg (regs, 1);
+ if (m68k_dreg (&context->regs, 1) > 0)
+ p96hack_vpos2 = 15625 / m68k_dreg (&context->regs, 1);
p96refresh_active=1;
picasso_refresh (0);
} //end for higher P96 mouse draw rate
return 0;
case 20:
- return enforcer_enable(m68k_dreg (regs, 1));
+ return enforcer_enable(m68k_dreg (&context->regs, 1));
case 21:
return enforcer_disable();
{
char *dllname;
uae_u32 result;
- dllname = ( char *) m68k_areg (regs, 0);
+ dllname = ( char *) m68k_areg (&context->regs, 0);
dllname = (char *)get_real_address ((uae_u32)dllname);
result=(uae_u32) LoadLibrary(dllname);
write_log("%s windows dll/alib loaded at %d (0 mean failure)\n",dllname,result);
{
HMODULE m;
char *funcname;
- m = (HMODULE) m68k_dreg (regs, 1);
- funcname = (char *)m68k_areg (regs, 0);
+ m = (HMODULE) m68k_dreg (&context->regs, 1);
+ funcname = (char *)m68k_areg (&context->regs, 0);
funcname = (char *)get_real_address ((uae_u32)funcname);
return (uae_u32) GetProcAddress(m,funcname);
}
unsigned long rate1;
double v;
rate1 = read_processor_time();
- ret = emulib_ExecuteNativeCode2 ();
+ ret = emulib_ExecuteNativeCode2 (context);
rate1 = read_processor_time() - rate1;
v = syncdivisor * rate1;
if (v > 0) {
case 103: //close dll
{
HMODULE libaddr;
- libaddr = (HMODULE) m68k_dreg (regs, 1);
+ libaddr = (HMODULE) m68k_dreg (&context->regs, 1);
FreeLibrary(libaddr);
return 0;
}
//a0 = start address
//d1 = number of 16bit vars
//returns address of new array
- src = m68k_areg(regs, 0);
- num_vars = m68k_dreg(regs, 1);
+ src = m68k_areg(&context->regs, 0);
+ num_vars = m68k_dreg(&context->regs, 1);
if (bswap_buffer_size < num_vars * 2) {
bswap_buffer_size = (num_vars + 1024) * 2;
//a0 = start address
//d1 = number of 32bit vars
//returns address of new array
- src = m68k_areg(regs, 0);
- num_vars = m68k_dreg(regs, 1);
+ src = m68k_areg(&context->regs, 0);
+ num_vars = m68k_dreg(&context->regs, 1);
if (bswap_buffer_size < num_vars * 4) {
bswap_buffer_size = (num_vars + 16384) * 4;
free(bswap_buffer);
#endif
case 200:
- ahitweak = m68k_dreg (regs, 1);
- ahi_pollrate = m68k_dreg (regs, 2);
+ ahitweak = m68k_dreg (&context->regs, 1);
+ ahi_pollrate = m68k_dreg (&context->regs, 2);
if (ahi_pollrate < 10)
ahi_pollrate = 10;
if (ahi_pollrate > 60)
-extern void ahi_updatesound( int force );
-extern uae_u32 ahi_demux(void);
+extern void ahi_updatesound(int force);
+extern uae_u32 REGPARAM2 ahi_demux(TrapContext*);
extern int ahi_open_sound (void);
extern void ahi_close_sound (void);
extern void ahi_finish_sound_buffer( void );
// set the source format
wfxSrc.wFormatTag = WAVE_FORMAT_PCM;
- wfxSrc.nChannels = (currprefs.sound_stereo == 3 || currprefs.sound_stereo == 2) ? 4 : (currprefs.sound_stereo ? 2 : 1);
+ wfxSrc.nChannels = currprefs.sound_stereo == 3 ? 4 : (currprefs.sound_stereo ? 2 : 1);
wfxSrc.nSamplesPerSec = workprefs.sound_freq;
wfxSrc.nBlockAlign = wfxSrc.nChannels * (workprefs.sound_bits / 8);
wfxSrc.nAvgBytesPerSec = wfxSrc.nBlockAlign * wfxSrc.nSamplesPerSec;
uae_u16 tw;
uae_u32 tl;
int bits = 16;
- int channels = (currprefs.sound_stereo == 3 || currprefs.sound_stereo == 2) ? 4 : (currprefs.sound_stereo ? 2 : 1);
+ int channels = currprefs.sound_stereo == 3 ? 4 : (currprefs.sound_stereo ? 2 : 1);
fseek (wavfile, 0, SEEK_SET);
fwrite ("RIFF", 1, 4, wavfile);
#ifdef WINDDK
-#include "config.h"
#include "uae.h"
#include "threaddep/thread.h"
#include "blkdev.h"
#include <stddef.h>
#include <process.h>
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
#include "events.h"
#include "newcpu.h"
#include "autoconf.h"
+#include "traps.h"
#include "bsdsocket.h"
-#include "osdep/exectasks.h"
#include "threaddep/thread.h"
#include "native2amiga.h"
#include "resource.h"
#define THREADEND(result) _endthreadex(result)
#endif
-#define SETERRNO seterrno(sb,WSAGetLastError()-WSABASEERR)
-#define SETHERRNO setherrno(sb,WSAGetLastError()-WSABASEERR)
-#define WAITSIGNAL waitsig(sb)
+#define SETERRNO bsdsocklib_seterrno(sb, WSAGetLastError() - WSABASEERR)
+#define SETHERRNO bsdsocklib_setherrno(sb, WSAGetLastError() - WSABASEERR)
+#define WAITSIGNAL waitsig(context, sb)
#define SETSIGNAL addtosigqueue(sb,0)
-#define CANCELSIGNAL cancelsig(sb)
+#define CANCELSIGNAL cancelsig(context, sb)
#define FIOSETOWN _IOW('f', 124, long) /* set owner (struct Task *) */
#define FIOGETOWN _IOR('f', 123, long) /* get owner (struct Task *) */
-#define BEGINBLOCKING if (sb->ftable[sd-1] & SF_BLOCKING) sb->ftable[sd-1] |= SF_BLOCKINGINPROGRESS
+#define BEGINBLOCKING if (sb->ftable[sd-1] & SF_BLOCKING) sb->ftable[sd - 1] |= SF_BLOCKINGINPROGRESS
#define ENDBLOCKING sb->ftable[sd-1] &= ~SF_BLOCKINGINPROGRESS
static WSADATA wsbData;
#define SF_RAW_RICMP 0x04000000
typedef struct ip_option_information {
- u_char Ttl; /* Time To Live (used for traceroute) */
- u_char Tos; /* Type Of Service (usually 0) */
- u_char Flags; /* IP header flags (usually 0) */
- u_char OptionsSize; /* Size of options data (usually 0, max 40) */
- u_char FAR *OptionsData; /* Options data buffer */
+ u_char Ttl; /* Time To Live (used for traceroute) */
+ u_char Tos; /* Type Of Service (usually 0) */
+ u_char Flags; /* IP header flags (usually 0) */
+ u_char OptionsSize; /* Size of options data (usually 0, max 40) */
+ u_char FAR *OptionsData; /* Options data buffer */
} IPINFO, *PIPINFO, FAR *LPIPINFO;
static void bsdsetpriority (HANDLE thread)
{
- int pri = os_winnt ? THREAD_PRIORITY_NORMAL : priorities[currprefs.win32_active_priority].value;
- SetThreadPriority(thread, pri);
+ int pri = os_winnt ? THREAD_PRIORITY_NORMAL : priorities[currprefs.win32_active_priority].value;
+ SetThreadPriority(thread, pri);
}
static int mySockStartup( void )
{
- int result = 0;
- SOCKET dummy;
- DWORD lasterror;
+ int result = 0;
+ SOCKET dummy;
+ DWORD lasterror;
- if (WSAStartup(MAKEWORD( SOCKVER_MAJOR, SOCKVER_MINOR ), &wsbData))
- {
+ if (WSAStartup(MAKEWORD( SOCKVER_MAJOR, SOCKVER_MINOR ), &wsbData)) {
lasterror = WSAGetLastError();
-
- if( lasterror == WSAVERNOTSUPPORTED )
- {
+
+ if( lasterror == WSAVERNOTSUPPORTED ) {
char szMessage[ MAX_DPATH ];
WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_DPATH );
gui_message( szMessage );
- }
- else
+ } else
write_log( "BSDSOCK: ERROR - Unable to initialize Windows socket layer! Error code: %d\n", lasterror );
return 0;
- }
+ }
- if (LOBYTE (wsbData.wVersion) != SOCKVER_MAJOR || HIBYTE (wsbData.wVersion) != SOCKVER_MINOR )
- {
- char szMessage[ MAX_DPATH ];
- WIN32GUI_LoadUIString( IDS_WSOCK2NEEDED, szMessage, MAX_DPATH );
- gui_message( szMessage );
+ if (LOBYTE (wsbData.wVersion) != SOCKVER_MAJOR || HIBYTE (wsbData.wVersion) != SOCKVER_MINOR) {
+ char szMessage[MAX_DPATH];
+ WIN32GUI_LoadUIString(IDS_WSOCK2NEEDED, szMessage, MAX_DPATH);
+ gui_message(szMessage);
return 0;
- }
- else
- {
- write_log( "BSDSOCK: using %s\n", wsbData.szDescription );
+ } else {
+ write_log( "BSDSOCK: using %s\n", wsbData.szDescription );
// make sure WSP/NSPStartup gets called from within the regular stack
// (Windows 95/98 need this)
- if((dummy = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) != INVALID_SOCKET)
- {
+ if((dummy = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) != INVALID_SOCKET) {
closesocket(dummy);
result = 1;
- }
- else
- {
+ } else {
write_log( "BSDSOCK: ERROR - WSPStartup/NSPStartup failed! Error code: %d\n",
WSAGetLastError() );
result = 0;
}
- }
+ }
- return result;
+ return result;
}
static int socket_layer_initialized = 0;
{
int result = 0;
-#ifndef CAN_DO_STACK_MAGIC
- currprefs.socket_emu = 0;
-#endif
- if(currprefs.socket_emu)
- {
- if((result = mySockStartup()))
- {
+ if(currprefs.socket_emu) {
+ if((result = mySockStartup())) {
InitializeCriticalSection(&csSigQueueLock);
- if(hSockThread == NULL)
- {
+ if(hSockThread == NULL) {
WNDCLASS wc; // Set up an invisible window and dummy wndproc
InitializeCriticalSection( &SockThreadCS );
wc.hbrBackground = GetStockObject (BLACK_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = "SocketFun";
- if(RegisterClass(&wc))
- {
+ if(RegisterClass(&wc)) {
hSockWnd = CreateWindowEx ( 0,
- "SocketFun", "WinUAE Socket Window",
- WS_POPUP,
- 0, 0,
- 1, 1,
- NULL, NULL, 0, NULL);
+ "SocketFun", "WinUAE Socket Window",
+ WS_POPUP,
+ 0, 0,
+ 1, 1,
+ NULL, NULL, 0, NULL);
hSockThread = THREAD(sock_thread, NULL);
}
}
}
- }
- socket_layer_initialized = result;
+ }
+ socket_layer_initialized = result;
- return result;
+ return result;
}
void deinit_socket_layer(void)
{
- int i;
- if(currprefs.socket_emu)
- {
+ int i;
+ if(currprefs.socket_emu) {
WSACleanup();
- if(socket_layer_initialized)
- {
+ if(socket_layer_initialized) {
DeleteCriticalSection(&csSigQueueLock);
- if(hSockThread)
- {
+ if(hSockThread) {
DeleteCriticalSection(&SockThreadCS);
CloseHandle(hSockReq);
hSockReq = NULL;
WaitForSingleObject(hSockThread, INFINITE);
CloseHandle(hSockThread);
}
- for (i = 0; i < MAX_SELECT_THREADS; i++)
- {
- if (hThreads[i])
- {
+ for (i = 0; i < MAX_SELECT_THREADS; i++) {
+ if (hThreads[i]) {
CloseHandle(hThreads[i]);
hThreads[i] = NULL;
}
}
}
- }
+ }
}
#ifdef BSDSOCKET
void locksigqueue(void)
{
- EnterCriticalSection(&csSigQueueLock);
+ EnterCriticalSection(&csSigQueueLock);
}
void unlocksigqueue(void)
{
- LeaveCriticalSection(&csSigQueueLock);
+ LeaveCriticalSection(&csSigQueueLock);
}
// Asynchronous completion notification
static uae_u32 asyncsd[MAXPENDINGASYNC];
static int asyncindex;
-int host_sbinit(SB)
+int host_sbinit(TrapContext *context, SB)
{
sb->sockAbort = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if (WSAGETASYNCERROR(lParam))
{
- seterrno(sb,WSAGETASYNCERROR(lParam)-WSABASEERR);
- if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) setherrno(sb,sb->sb_errno-1000);
+ bsdsocklib_seterrno(sb,WSAGETASYNCERROR(lParam)-WSABASEERR);
+ if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) bsdsocklib_setherrno(sb,sb->sb_errno-1000);
else if (sb->sb_errno == 55) // ENOBUFS
write_log("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n",WSAGETASYNCBUFLEN(lParam));
}
- else seterrno(sb,0);
+ else bsdsocklib_seterrno(sb,0);
SETSIGNAL;
int i;
locksigqueue();
- for (i = asyncindex+1; i != asyncindex; i++)
- {
- if (i == MAXPENDINGASYNC) i = 0;
-
- if (!asyncsb[i])
- {
+ for (i = asyncindex+1; i != asyncindex; i++) {
+ if (i == MAXPENDINGASYNC)
+ i = 0;
+ if (!asyncsb[i]) {
asyncsb[i] = sb;
if (++asyncindex == MAXPENDINGASYNC) asyncindex = 0;
unlocksigqueue();
-
- if (s == INVALID_SOCKET)
- {
+ if (s == INVALID_SOCKET) {
return i*2+0xb001;
- }
- else
- {
+ } else {
asyncsd[i] = sd;
asyncsock[i] = s;
- return i*2+0xb000;
+ return i * 2+0xb000;
}
}
}
-
unlocksigqueue();
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
write_log("BSDSOCK: ERROR - Async operation completion table overflow\n");
return 0;
}
-static void cancelasyncmsg(unsigned int wMsg)
+static void cancelasyncmsg(TrapContext *context, unsigned int wMsg)
{
SB;
sb = asyncsb[wMsg];
- if (sb != NULL)
- {
+ if (sb != NULL) {
asyncsb[wMsg] = NULL;
CANCELSIGNAL;
}
void setWSAAsyncSelect(SB, uae_u32 sd, SOCKET s, long lEvent )
{
- if (sb->mtable[sd-1])
- {
+ if (sb->mtable[sd-1]) {
long wsbevents = 0;
long eventflags;
int i;
eventflags = sb->ftable[sd-1] & REP_ALL;
- if (eventflags & REP_ACCEPT) wsbevents |= FD_ACCEPT;
- if (eventflags & REP_CONNECT) wsbevents |= FD_CONNECT;
- if (eventflags & REP_OOB) wsbevents |= FD_OOB;
- if (eventflags & REP_READ) wsbevents |= FD_READ;
- if (eventflags & REP_WRITE) wsbevents |= FD_WRITE;
- if (eventflags & REP_CLOSE) wsbevents |= FD_CLOSE;
+ if (eventflags & REP_ACCEPT)
+ wsbevents |= FD_ACCEPT;
+ if (eventflags & REP_CONNECT)
+ wsbevents |= FD_CONNECT;
+ if (eventflags & REP_OOB)
+ wsbevents |= FD_OOB;
+ if (eventflags & REP_READ)
+ wsbevents |= FD_READ;
+ if (eventflags & REP_WRITE)
+ wsbevents |= FD_WRITE;
+ if (eventflags & REP_CLOSE)
+ wsbevents |= FD_CLOSE;
wsbevents |= lEvent;
i = (sb->mtable[sd-1]-0xb000)/2;
asyncsb[i] = sb;
fd1++;
s1 = getsock(sb, fd1);
- if (s1 != INVALID_SOCKET)
- {
- if (fd2 != -1)
- {
- if ((unsigned int) (fd2) >= (unsigned int) sb->dtablesize)
- {
+ if (s1 != INVALID_SOCKET) {
+ if (fd2 != -1) {
+ if ((unsigned int) (fd2) >= (unsigned int) sb->dtablesize) {
TRACE (("Bad file descriptor (%d)\n", fd2));
- seterrno (sb, 9); /* EBADF */
+ bsdsocklib_seterrno (sb, 9); /* EBADF */
}
fd2++;
s2 = getsock(sb,fd2);
- if (s2 != INVALID_SOCKET)
- {
- shutdown(s2,1);
+ if (s2 != INVALID_SOCKET) {
+ shutdown(s2,1);
closesocket(s2);
}
setsd(sb,fd2,s1);
TRACE(("0\n"));
return 0;
- }
- else
- {
+ } else {
fd2 = getsd(sb, 1);
setsd(sb,fd2,s1);
TRACE(("%d\n",fd2));
TRACE(("socket(%s,%s,%d) -> ",af == AF_INET ? "AF_INET" : "AF_other",type == SOCK_STREAM ? "SOCK_STREAM" : type == SOCK_DGRAM ? "SOCK_DGRAM " : "SOCK_RAW",protocol));
- if ((s = socket(af,type,protocol)) == INVALID_SOCKET)
- {
+ if ((s = socket(af,type,protocol)) == INVALID_SOCKET) {
SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
return -1;
- }
- else
- sd = getsd(sb,(int)s);
+ } else
+ sd = getsd(sb,(int)s);
sb->ftable[sd-1] = SF_BLOCKING;
ioctlsocket(s,FIONBIO,&nonblocking);
TRACE(("%d\n",sd));
- if (type == SOCK_RAW)
- {
- if (protocol==IPPROTO_UDP)
- {
+ if (type == SOCK_RAW) {
+ if (protocol==IPPROTO_UDP) {
sb->ftable[sd-1] |= SF_RAW_UDP;
}
- if (protocol==IPPROTO_ICMP)
- {
+ if (protocol==IPPROTO_ICMP) {
struct sockaddr_in sin;
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
bind(s,(struct sockaddr *)&sin,sizeof(sin)) ;
}
- if (protocol==IPPROTO_RAW)
- {
+ if (protocol==IPPROTO_RAW) {
sb->ftable[sd-1] |= SF_RAW_RAW;
}
}
TRACE(("bind(%d,0x%lx,%d) -> ",sd,name,namelen));
s = getsock(sb, sd);
- if (s != INVALID_SOCKET)
- {
- if (namelen <= sizeof buf)
- {
+ if (s != INVALID_SOCKET) {
+ if (namelen <= sizeof buf) {
memcpy(buf,get_real_address(name),namelen);
// some Amiga programs set this field to bogus values
prephostaddr((SOCKADDR_IN *)buf);
- if ((success = bind(s,(struct sockaddr *)buf,namelen)) != 0)
- {
+ if ((success = bind(s,(struct sockaddr *)buf,namelen)) != 0) {
SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
- }
- else
+ } else
TRACE(("OK\n"));
- }
- else
+ } else
write_log("BSDSOCK: ERROR - Excessive namelen (%d) in bind()!\n",namelen);
}
TRACE(("listen(%d,%d) -> ",sd,backlog));
s = getsock(sb, sd);
- if (s != INVALID_SOCKET)
- {
- if ((success = listen(s,backlog)) != 0)
- {
+ if (s != INVALID_SOCKET) {
+ if ((success = listen(s,backlog)) != 0) {
SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
- }
- else
+ } else
TRACE(("OK\n"));
}
return success;
}
-void host_accept(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
+void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
{
struct sockaddr *rp_name,*rp_nameuae;
struct sockaddr sockaddr;
unsigned int wMsg;
sd++;
- if (name != 0 )
- {
+ if (name != 0) {
rp_nameuae = rp_name = (struct sockaddr *)get_real_address(name);
hlenuae = hlen = get_long(namelen);
if (hlenuae < sizeof(sockaddr))
rp_name = &sockaddr;
hlen = sizeof(sockaddr);
}
- }
- else
- {
+ } else {
rp_name = &sockaddr;
hlen = sizeof(sockaddr);
}
s = (SOCKET)getsock(sb,(int)sd);
- if (s != INVALID_SOCKET)
- {
+ if (s != INVALID_SOCKET) {
BEGINBLOCKING;
s2 = accept(s,rp_name,&hlen);
- if (s2 == INVALID_SOCKET)
- {
+ if (s2 == INVALID_SOCKET) {
SETERRNO;
- if (sb->ftable[sd-1] & SF_BLOCKING && sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR)
- {
- if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0)
- {
- if (sb->mtable[sd-1] == 0)
- {
+ if (sb->ftable[sd-1] & SF_BLOCKING && sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR) {
+ if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) {
+ if (sb->mtable[sd-1] == 0) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_ACCEPT);
- }
- else
- {
+ } else {
setWSAAsyncSelect(sb,sd,s,FD_ACCEPT);
}
WAITSIGNAL;
- if (sb->mtable[sd-1] == 0)
- {
- cancelasyncmsg(wMsg);
- }
- else
- {
+ if (sb->mtable[sd-1] == 0) {
+ cancelasyncmsg(context, wMsg);
+ } else {
setWSAAsyncSelect(sb,sd,s,0);
}
- if (sb->eintr)
- {
+ if (sb->eintr) {
TRACE(("[interrupted]\n"));
ENDBLOCKING;
return;
s2 = accept(s,rp_name,&hlen);
- if (s2 == INVALID_SOCKET)
- {
+ if (s2 == INVALID_SOCKET) {
SETERRNO;
- if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR)
+ if (sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR)
write_log("BSDSOCK: ERRRO - accept() would block despite FD_ACCEPT message\n");
}
}
}
}
- if (s2 == INVALID_SOCKET)
- {
+ if (s2 == INVALID_SOCKET) {
sb->resultval = -1;
TRACE(("failed (%d)\n",sb->sb_errno));
- }
- else
- {
+ } else {
sb->resultval = getsd(sb, s2);
sb->ftable[sb->resultval-1] = sb->ftable[sd-1]; // new socket inherits the old socket's properties
sb->resultval--;
- if (rp_name != 0)
- { // 1.11.2002 XXX
- if (hlen <= hlenuae)
- { // Fix for CNET BBS Part 2
+ if (rp_name != 0) { // 1.11.2002 XXX
+ if (hlen <= hlenuae) { // Fix for CNET BBS Part 2
prepamigaaddr(rp_name,hlen);
- if (namelen != 0)
- {
+ if (namelen != 0) {
put_long(namelen,hlen);
}
- }
- else
- { // Copy only the number of bytes requested
- if (hlenuae != 0)
- {
+ } else { // Copy only the number of bytes requested
+ if (hlenuae != 0) {
prepamigaaddr(rp_name,hlenuae);
memcpy(rp_nameuae,rp_name,hlenuae);
put_long(namelen,hlenuae);
SB;
} sockreq;
-BOOL HandleStuff( void )
+static BOOL HandleStuff( void )
{
BOOL quit = FALSE;
SB = NULL;
BOOL handled = TRUE;
- if( hSockReq )
- {
+ if (hSockReq) {
// 100ms sleepiness might need some tuning...
- //if(WaitForSingleObject( hSockReq, 100 ) == WAIT_OBJECT_0 )
+ //if(WaitForSingleObject( hSockReq, 100 ) == WAIT_OBJECT_0 )
{
switch( sockreq.packet_type )
{
- case connect_req:
- sockreq.sb->resultval = connect(sockreq.s,(struct sockaddr *)(sockreq.params.connect_s.buf),sockreq.params.connect_s.namelen);
- break;
- case sendto_req:
- if( sockreq.params.sendto_s.to )
- {
+ case connect_req:
+ sockreq.sb->resultval = connect(sockreq.s,(struct sockaddr *)(sockreq.params.connect_s.buf),sockreq.params.connect_s.namelen);
+ break;
+ case sendto_req:
+ if(sockreq.params.sendto_s.to) {
sockreq.sb->resultval = sendto(sockreq.s,sockreq.params.sendto_s.realpt,sockreq.params.sendto_s.len,sockreq.params.sendto_s.flags,(struct sockaddr *)(sockreq.params.sendto_s.buf),sockreq.params.sendto_s.tolen);
- }
- else
- {
+ } else {
sockreq.sb->resultval = send(sockreq.s,sockreq.params.sendto_s.realpt,sockreq.params.sendto_s.len,sockreq.params.sendto_s.flags);
}
- break;
- case recvfrom_req:
- if( sockreq.params.recvfrom_s.addr )
- {
- sockreq.sb->resultval = recvfrom( sockreq.s, sockreq.params.recvfrom_s.realpt, sockreq.params.recvfrom_s.len,
- sockreq.params.recvfrom_s.flags, sockreq.params.recvfrom_s.rp_addr,
- sockreq.params.recvfrom_s.hlen );
-
- }
- else
- {
- sockreq.sb->resultval = recv( sockreq.s, sockreq.params.recvfrom_s.realpt, sockreq.params.recvfrom_s.len,
- sockreq.params.recvfrom_s.flags );
- }
- break;
- case abort_req:
- *(sockreq.params.abort_s.newsock) = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
- if (*(sockreq.params.abort_s.newsock) != sb->sockAbort)
- {
- shutdown( sb->sockAbort, 1 );
- closesocket(sb->sockAbort);
- }
- handled = FALSE; /* Don't bother the SETERRNO section after the switch() */
- break;
- case last_req:
- default:
- write_log( "BSDSOCK: Invalid sock-thread request!\n" );
- handled = FALSE;
- break;
+ break;
+ case recvfrom_req:
+ if(sockreq.params.recvfrom_s.addr) {
+ sockreq.sb->resultval = recvfrom( sockreq.s, sockreq.params.recvfrom_s.realpt, sockreq.params.recvfrom_s.len,
+ sockreq.params.recvfrom_s.flags, sockreq.params.recvfrom_s.rp_addr,
+ sockreq.params.recvfrom_s.hlen );
+
+ } else {
+ sockreq.sb->resultval = recv( sockreq.s, sockreq.params.recvfrom_s.realpt, sockreq.params.recvfrom_s.len,
+ sockreq.params.recvfrom_s.flags );
+ }
+ break;
+ case abort_req:
+ *(sockreq.params.abort_s.newsock) = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
+ if (*(sockreq.params.abort_s.newsock) != sb->sockAbort) {
+ shutdown( sb->sockAbort, 1 );
+ closesocket(sb->sockAbort);
+ }
+ handled = FALSE; /* Don't bother the SETERRNO section after the switch() */
+ break;
+ case last_req:
+ default:
+ write_log( "BSDSOCK: Invalid sock-thread request!\n" );
+ handled = FALSE;
+ break;
}
- if( handled )
- {
- if( sockreq.sb->resultval == SOCKET_ERROR )
- {
+ if(handled) {
+ if(sockreq.sb->resultval == SOCKET_ERROR) {
sb = sockreq.sb;
SETERRNO;
}
}
SetEvent( hSockReqHandled );
}
- }
- else
- {
- quit = TRUE;
+ } else {
+ quit = TRUE;
}
return quit;
}
static LRESULT CALLBACK SocketWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- if( message >= 0xB000 && message < 0xB000+MAXPENDINGASYNC*2 )
- {
+ if(message >= 0xB000 && message < 0xB000+MAXPENDINGASYNC * 2) {
#if DEBUG_SOCKETS
- write_log( "sockmsg(0x%x, 0x%x, 0x%x)\n", message, wParam, lParam );
+ write_log( "sockmsg(0x%x, 0x%x, 0x%x)\n", message, wParam, lParam );
#endif
- sockmsg( message, wParam, lParam );
- return 0;
+ sockmsg(message, wParam, lParam);
+ return 0;
}
- return DefWindowProc( hwnd, message, wParam, lParam );
+ return DefWindowProc(hwnd, message, wParam, lParam);
}
HANDLE WaitHandle;
MSG msg;
- if( hSockWnd )
- {
+ if(hSockWnd) {
// Make sure we're outrunning the wolves
int pri = THREAD_PRIORITY_ABOVE_NORMAL;
if (!os_winnt) {
pri = priorities[currprefs.win32_active_priority].value;
if (pri == THREAD_PRIORITY_HIGHEST)
- pri = THREAD_PRIORITY_TIME_CRITICAL;
+ pri = THREAD_PRIORITY_TIME_CRITICAL;
else
pri++;
}
- SetThreadPriority( GetCurrentThread(), pri );
+ SetThreadPriority(GetCurrentThread(), pri);
- while( TRUE )
- {
- if( hSockReq )
- {
+ while(TRUE) {
+ if(hSockReq) {
DWORD wait;
WaitHandle = hSockReq;
wait = MsgWaitForMultipleObjects (1, &WaitHandle, FALSE,INFINITE, QS_POSTMESSAGE);
- if (wait == WAIT_OBJECT_0)
- {
- if( HandleStuff() ) // See if its time to quit...
+ if (wait == WAIT_OBJECT_0) {
+ if(HandleStuff()) // See if its time to quit...
break;
}
- if (wait == WAIT_OBJECT_0 +1)
- {
+ if (wait == WAIT_OBJECT_0 +1) {
Sleep(10);
- while( PeekMessage( &msg, NULL, WM_USER, 0xB000+MAXPENDINGASYNC*2, PM_REMOVE ) > 0 )
- {
+ while( PeekMessage(&msg, NULL, WM_USER, 0xB000+MAXPENDINGASYNC*2, PM_REMOVE) > 0) {
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
-void host_connect(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
+void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
{
SOCKET s;
int success = 0;
unsigned int wMsg;
char buf[MAXADDRLEN];
-
sd++;
TRACE(("connect(%d,0x%lx,%d) -> ",sd,name,namelen));
s = (SOCKET)getsock(sb,(int)sd);
- if (s != INVALID_SOCKET)
- {
- if (namelen <= MAXADDRLEN)
- {
- if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0)
- {
- if (sb->mtable[sd-1] == 0)
- {
+ if (s != INVALID_SOCKET) {
+ if (namelen <= MAXADDRLEN) {
+ if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) {
+ if (sb->mtable[sd-1] == 0) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_CONNECT);
- }
- else
- {
+ } else {
setWSAAsyncSelect(sb,sd,s,FD_CONNECT);
}
TRIGGER_THREAD;
- if (sb->resultval)
- {
- if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR)
- {
- if (sb->ftable[sd-1] & SF_BLOCKING)
- {
- seterrno(sb,0);
+ if (sb->resultval) {
+ if (sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR) {
+ if (sb->ftable[sd-1] & SF_BLOCKING) {
+ bsdsocklib_seterrno(sb,0);
WAITSIGNAL;
- if (sb->eintr)
- {
+ if (sb->eintr) {
// Destroy socket to cancel abort, replace it with fake socket to enable proper closing.
// This is in accordance with BSD behaviour.
shutdown(s,1);
closesocket(s);
sb->dtable[sd-1] = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
}
+ } else {
+ bsdsocklib_seterrno(sb,36); // EINPROGRESS
}
- else
- {
- seterrno(sb,36); // EINPROGRESS
- }
- }
- else
- {
+ } else {
CANCELSIGNAL; // Cancel pending signal
}
}
ENDBLOCKING;
- if (sb->mtable[sd-1] == 0)
- {
- cancelasyncmsg(wMsg);
- }
- else
- {
+ if (sb->mtable[sd-1] == 0) {
+ cancelasyncmsg(context, wMsg);
+ } else {
setWSAAsyncSelect(sb,sd,s,0);
}
}
- }
- else
- write_log("BSDSOCK: WARNING - Excessive namelen (%d) in connect()!\n",namelen);
+ } else
+ write_log("BSDSOCK: WARNING - Excessive namelen (%d) in connect()!\n",namelen);
}
TRACE(("%d\n",sb->sb_errno));
}
-void host_sendto(SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen)
+void host_sendto(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen)
{
SOCKET s;
char *realpt;
#ifdef TRACING_ENABLED
if (to)
- TRACE(("sendto(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,to,tolen));
+ TRACE(("sendto(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,to,tolen));
else
- TRACE(("send(%d,0x%lx,%d,%d) -> ",sd,msg,len,flags));
+ TRACE(("send(%d,0x%lx,%d,%d) -> ",sd,msg,len,flags));
#endif
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
- realpt = get_real_address(msg);
+ if (s != INVALID_SOCKET) {
+ realpt = get_real_address(msg);
- if (to)
- {
+ if (to) {
if (tolen > sizeof buf) write_log("BSDSOCK: WARNING - Target address in sendto() too large (%d)!\n",tolen);
- else
- {
+ else {
memcpy(buf,get_real_address(to),tolen);
// some Amiga software sets this field to bogus values
prephostaddr((SOCKADDR_IN *)buf);
}
}
- if (sb->ftable[sd-1]&SF_RAW_RAW)
- {
- if (*(realpt+9) == 0x1)
- { // ICMP
+ if (sb->ftable[sd-1] & SF_RAW_RAW) {
+ if (*(realpt+9) == 0x1) { // ICMP
struct sockaddr_in sin;
shutdown(s,1);
closesocket(s);
sb->ftable[sd-1]&= ~SF_RAW_RAW;
sb->ftable[sd-1]|= SF_RAW_RICMP;
}
- if (*(realpt+9) == 0x11)
- { // UDP
+ if (*(realpt+9) == 0x11) { // UDP
struct sockaddr_in sin;
shutdown(s,1);
closesocket(s);
BEGINBLOCKING;
- for (;;)
- {
+ for (;;) {
+
PREPARE_THREAD;
sockreq.packet_type = sendto_req;
sockreq.params.sendto_s.to = to;
sockreq.params.sendto_s.tolen = tolen;
- if (sb->ftable[sd-1]&SF_RAW_UDP)
- {
+ if (sb->ftable[sd-1]&SF_RAW_UDP) {
*(buf+2) = *(realpt+2);
*(buf+3) = *(realpt+3);
// Copy DST-Port
sockreq.params.sendto_s.realpt += iCut;
sockreq.params.sendto_s.len -= iCut;
}
- if (sb->ftable[sd-1]&SF_RAW_RUDP)
- {
+ if (sb->ftable[sd-1]&SF_RAW_RUDP) {
int iTTL;
iTTL = (int) *(realpt+8)&0xff;
setsockopt(s,IPPROTO_IP,4,(char*) &iTTL,sizeof(iTTL));
sockreq.params.sendto_s.realpt += iCut;
sockreq.params.sendto_s.len -= iCut;
}
- if (sb->ftable[sd-1]&SF_RAW_RICMP)
- {
+ if (sb->ftable[sd-1]&SF_RAW_RICMP) {
int iTTL;
iTTL = (int) *(realpt+8)&0xff;
setsockopt(s,IPPROTO_IP,4,(char*) &iTTL,sizeof(iTTL));
}
TRIGGER_THREAD;
- if (sb->ftable[sd-1]&SF_RAW_UDP||sb->ftable[sd-1]&SF_RAW_RUDP||sb->ftable[sd-1]&SF_RAW_RICMP)
- {
+ if (sb->ftable[sd-1]&SF_RAW_UDP||sb->ftable[sd-1]&SF_RAW_RUDP||sb->ftable[sd-1]&SF_RAW_RICMP) {
sb->resultval += iCut;
}
- if (sb->resultval == -1)
- {
+ if (sb->resultval == -1) {
if (sb->sb_errno != WSAEWOULDBLOCK-WSABASEERR || !(sb->ftable[sd-1] & SF_BLOCKING))
break;
- }
- else
- {
+ } else {
realpt += sb->resultval;
len -= sb->resultval;
-
if (len <= 0)
break;
else
continue;
}
- if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0)
- {
- if (sb->mtable[sd-1] == 0)
- {
+ if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) {
+ if (sb->mtable[sd-1] == 0) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_WRITE);
- }
- else
- {
+ } else {
setWSAAsyncSelect(sb,sd,s,FD_WRITE);
}
WAITSIGNAL;
- if (sb->mtable[sd-1] == 0)
- {
- cancelasyncmsg(wMsg);
- }
- else
- {
+ if (sb->mtable[sd-1] == 0) {
+ cancelasyncmsg(context, wMsg);
+ } else {
setWSAAsyncSelect(sb,sd,s,0);
}
- if (sb->eintr)
- {
+ if (sb->eintr) {
TRACE(("[interrupted]\n"));
return;
}
- }
- else break;
+ } else
+ break;
}
ENDBLOCKING;
- }
- else sb->resultval = -1;
+
+ } else
+ sb->resultval = -1;
#ifdef TRACING_ENABLED
if (sb->resultval == -1)
}
-void host_recvfrom(SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen)
+void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen)
{
SOCKET s;
char *realpt;
#ifdef TRACING_ENABLED
if (addr)
- TRACE(("recvfrom(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,addr,get_long(addrlen)));
- else
- TRACE(("recv(%d,0x%lx,%d,0x%lx) -> ",sd,msg,len,flags));
+ TRACE(("recvfrom(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,addr,get_long(addrlen)));
+ else
+ TRACE(("recv(%d,0x%lx,%d,0x%lx) -> ",sd,msg,len,flags));
#endif
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
- realpt = get_real_address(msg);
+ if (s != INVALID_SOCKET) {
+ realpt = get_real_address(msg);
- if (addr)
- {
- hlen = get_long(addrlen);
- rp_addr = (struct sockaddr *)get_real_address(addr);
- }
+ if (addr) {
+ hlen = get_long(addrlen);
+ rp_addr = (struct sockaddr *)get_real_address(addr);
+ }
- BEGINBLOCKING;
+ BEGINBLOCKING;
- for (;;)
- {
- PREPARE_THREAD;
-
- sockreq.packet_type = recvfrom_req;
- sockreq.s = s;
- sockreq.sb = sb;
- sockreq.params.recvfrom_s.addr = addr;
- sockreq.params.recvfrom_s.flags = flags;
- sockreq.params.recvfrom_s.hlen = &hlen;
- sockreq.params.recvfrom_s.len = len;
- sockreq.params.recvfrom_s.realpt = realpt;
- sockreq.params.recvfrom_s.rp_addr = rp_addr;
-
- TRIGGER_THREAD;
- if (sb->resultval == -1)
- {
- if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR && sb->ftable[sd-1] & SF_BLOCKING)
- {
- if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0)
- {
- if (sb->mtable[sd-1] == 0)
- {
- WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_READ|FD_CLOSE);
- }
- else
- {
- setWSAAsyncSelect(sb,sd,s,FD_READ|FD_CLOSE);
- }
+ for (;;) {
- WAITSIGNAL;
-
- if (sb->mtable[sd-1] == 0)
- {
- cancelasyncmsg(wMsg);
- }
- else
+ PREPARE_THREAD;
+
+ sockreq.packet_type = recvfrom_req;
+ sockreq.s = s;
+ sockreq.sb = sb;
+ sockreq.params.recvfrom_s.addr = addr;
+ sockreq.params.recvfrom_s.flags = flags;
+ sockreq.params.recvfrom_s.hlen = &hlen;
+ sockreq.params.recvfrom_s.len = len;
+ sockreq.params.recvfrom_s.realpt = realpt;
+ sockreq.params.recvfrom_s.rp_addr = rp_addr;
+
+ TRIGGER_THREAD;
+ if (sb->resultval == -1) {
+ if (sb->sb_errno == WSAEWOULDBLOCK-WSABASEERR && sb->ftable[sd-1] & SF_BLOCKING)
{
- setWSAAsyncSelect(sb,sd,s,0);
- }
+ if (sb->mtable[sd-1] || (wMsg = allocasyncmsg(sb,sd,s)) != 0) {
+ if (sb->mtable[sd-1] == 0) {
+ WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_READ|FD_CLOSE);
+ } else {
+ setWSAAsyncSelect(sb,sd,s,FD_READ|FD_CLOSE);
+ }
+ WAITSIGNAL;
- if (sb->eintr)
- {
- TRACE(("[interrupted]\n"));
- return;
- }
- }
- else break;
+ if (sb->mtable[sd-1] == 0) {
+ cancelasyncmsg(context, wMsg);
+ } else {
+ setWSAAsyncSelect(sb,sd,s,0);
+ }
+
+ if (sb->eintr) {
+ TRACE(("[interrupted]\n"));
+ return;
+ }
+ } else
+ break;
+ } else
+ break;
+ } else
+ break;
}
- else break;
- }
- else break;
- }
- ENDBLOCKING;
+ ENDBLOCKING;
- if (addr)
- {
- prepamigaaddr(rp_addr,hlen);
- put_long(addrlen,hlen);
- }
- }
- else sb->resultval = -1;
+ if (addr) {
+ prepamigaaddr(rp_addr,hlen);
+ put_long(addrlen,hlen);
+ }
+ } else
+ sb->resultval = -1;
#ifdef TRACING_ENABLED
if (sb->resultval == -1)
- TRACE(("failed (%d)\n",sb->sb_errno));
+ TRACE(("failed (%d)\n",sb->sb_errno));
else
- TRACE(("%d\n",sb->resultval));
+ TRACE(("%d\n",sb->resultval));
#endif
}
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
- if (shutdown(s,how))
- {
- SETERRNO;
- TRACE(("failed (%d)\n",sb->sb_errno));
- }
- else
- {
- TRACE(("OK\n"));
- return 0;
- }
+ if (s != INVALID_SOCKET) {
+ if (shutdown(s,how)) {
+ SETERRNO;
+ TRACE(("failed (%d)\n",sb->sb_errno));
+ } else {
+ TRACE(("OK\n"));
+ return 0;
+ }
}
return -1;
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
- if (len > sizeof buf)
- {
- write_log("BSDSOCK: WARNING - Excessive optlen in setsockopt() (%d)\n",len);
- len = sizeof buf;
- }
- if (level == IPPROTO_IP && optname == 2)
- { // IP_HDRINCL emulated by icmp.dll
- sb->resultval = 0;
- return;
+ if (s != INVALID_SOCKET) {
+ if (len > sizeof buf) {
+ write_log("BSDSOCK: WARNING - Excessive optlen in setsockopt() (%d)\n",len);
+ len = sizeof buf;
+ }
+ if (level == IPPROTO_IP && optname == 2) { // IP_HDRINCL emulated by icmp.dll
+ sb->resultval = 0;
+ return;
+ }
+ if (level == SOL_SOCKET && optname == SO_LINGER) {
+ ((LINGER *)buf)->l_onoff = get_long(optval);
+ ((LINGER *)buf)->l_linger = get_long(optval+4);
+ } else {
+ if (len == 4)
+ *(long *)buf = get_long(optval);
+ else if (len == 2)
+ *(short *)buf = get_word(optval);
+ else
+ write_log("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n",level,optname);
}
- if (level == SOL_SOCKET && optname == SO_LINGER)
- {
- ((LINGER *)buf)->l_onoff = get_long(optval);
- ((LINGER *)buf)->l_linger = get_long(optval+4);
- }
- else
- {
- if (len == 4) *(long *)buf = get_long(optval);
- else if (len == 2) *(short *)buf = get_word(optval);
- else write_log("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n",level,optname);
- }
- // handle SO_EVENTMASK
- if (level == 0xffff && optname == 0x2001)
- {
- long wsbevents = 0;
- uae_u32 eventflags = get_long(optval);
-
- sb->ftable[sd-1] = (sb->ftable[sd-1] & ~REP_ALL) | (eventflags & REP_ALL);
-
- if (eventflags & REP_ACCEPT) wsbevents |= FD_ACCEPT;
- if (eventflags & REP_CONNECT) wsbevents |= FD_CONNECT;
- if (eventflags & REP_OOB) wsbevents |= FD_OOB;
- if (eventflags & REP_READ) wsbevents |= FD_READ;
- if (eventflags & REP_WRITE) wsbevents |= FD_WRITE;
- if (eventflags & REP_CLOSE) wsbevents |= FD_CLOSE;
+ // handle SO_EVENTMASK
+ if (level == 0xffff && optname == 0x2001) {
+ long wsbevents = 0;
+ uae_u32 eventflags = get_long(optval);
+
+ sb->ftable[sd-1] = (sb->ftable[sd-1] & ~REP_ALL) | (eventflags & REP_ALL);
+
+ if (eventflags & REP_ACCEPT)
+ wsbevents |= FD_ACCEPT;
+ if (eventflags & REP_CONNECT)
+ wsbevents |= FD_CONNECT;
+ if (eventflags & REP_OOB)
+ wsbevents |= FD_OOB;
+ if (eventflags & REP_READ)
+ wsbevents |= FD_READ;
+ if (eventflags & REP_WRITE)
+ wsbevents |= FD_WRITE;
+ if (eventflags & REP_CLOSE)
+ wsbevents |= FD_CLOSE;
- if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s)))
- {
- WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,sb->mtable[sd-1],wsbevents);
- sb->resultval = 0;
- }
- else sb->resultval = -1;
- }
- else sb->resultval = setsockopt(s,level,optname,buf,len);
+ if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) {
+ WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,sb->mtable[sd-1],wsbevents);
+ sb->resultval = 0;
+ } else
+ sb->resultval = -1;
+ } else
+ sb->resultval = setsockopt(s,level,optname,buf,len);
- if (!sb->resultval)
- {
- TRACE(("OK\n"));
- return;
- }
- else SETERRNO;
+ if (!sb->resultval) {
+ TRACE(("OK\n"));
+ return;
+ } else
+ SETERRNO;
- TRACE(("failed (%d)\n",sb->sb_errno));
+ TRACE(("failed (%d)\n",sb->sb_errno));
}
}
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
- if (!getsockopt(s,level,optname,buf,&len))
- {
- if (level == SOL_SOCKET && optname == SO_LINGER)
- {
+ if (s != INVALID_SOCKET) {
+ if (!getsockopt(s,level,optname,buf,&len)) {
+ if (level == SOL_SOCKET && optname == SO_LINGER) {
put_long(optval,((LINGER *)buf)->l_onoff);
put_long(optval+4,((LINGER *)buf)->l_linger);
- }
- else
- {
- if (len == 4) put_long(optval,*(long *)buf);
- else if (len == 2) put_word(optval,*(short *)buf);
- else write_log("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n",level,optname);
+ } else {
+ if (len == 4)
+ put_long(optval,*(long *)buf);
+ else if (len == 2)
+ put_word(optval,*(short *)buf);
+ else
+ write_log("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n",level,optname);
}
-// put_long(optlen,len); // some programs pass the actual ength instead of a pointer to the length, so...
+// put_long(optlen,len); // some programs pass the actual length instead of a pointer to the length, so...
TRACE(("OK (%d,%d)\n",len,*(long *)buf));
return 0;
- }
- else
- {
+ } else {
SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
}
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
+ if (s != INVALID_SOCKET) {
rp_name = (struct sockaddr *)get_real_address(name);
- if (getsockname(s,rp_name,&len))
- {
+ if (getsockname(s,rp_name,&len)) {
SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
- }
- else
- {
+ } else {
TRACE(("%d\n",len));
prepamigaaddr(rp_name,len);
put_long(namelen,len);
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
+ if (s != INVALID_SOCKET) {
rp_name = (struct sockaddr *)get_real_address(name);
- if (getpeername(s,rp_name,&len))
- {
+ if (getpeername(s,rp_name,&len)) {
SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
- }
- else
- {
+ } else {
TRACE(("%d\n",len));
prepamigaaddr(rp_name,len);
put_long(namelen,len);
return -1;
}
-uae_u32 host_IoctlSocket(SB, uae_u32 sd, uae_u32 request, uae_u32 arg)
+uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request, uae_u32 arg)
{
SOCKET s;
uae_u32 data;
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
+ if (s != INVALID_SOCKET) {
switch (request)
{
case FIOSETOWN:
break;
case FIONBIO:
TRACE(("[FIONBIO] -> "));
- if (get_long(arg))
- {
+ if (get_long(arg)) {
TRACE(("nonblocking\n"));
sb->ftable[sd-1] &= ~SF_BLOCKING;
- }
- else
- {
+ } else {
TRACE(("blocking\n"));
sb->ftable[sd-1] |= SF_BLOCKING;
}
success = 0;
break;
case FIOASYNC:
- if (get_long(arg))
- {
+ if (get_long(arg)) {
sb->ftable[sd-1] |= REP_ALL;
TRACE(("[FIOASYNC] -> enabled\n"));
- if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s)))
- {
+ if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) {
WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,sb->mtable[sd-1],FD_ACCEPT | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE | FD_CLOSE);
success = 0;
break;
}
}
- else write_log(("BSDSOCK: WARNING - FIOASYNC disabling unsupported.\n"));
+ else
+ write_log(("BSDSOCK: WARNING - FIOASYNC disabling unsupported.\n"));
success = -1;
break;
default:
write_log("BSDSOCK: WARNING - Unknown IoctlSocket request: 0x%08lx\n",request);
- seterrno(sb,22); // EINVAL
+ bsdsocklib_seterrno(sb,22); // EINVAL
+ break;
}
}
return success;
}
-int host_CloseSocket(SB, int sd)
+int host_CloseSocket(TrapContext *context, SB, int sd)
{
unsigned int wMsg;
SOCKET s;
sd++;
s = getsock(sb,sd);
- if (s != INVALID_SOCKET)
- {
- if (sb->mtable[sd-1])
- {
- asyncsb[(sb->mtable[sd-1]-0xb000)/2] = NULL;
- sb->mtable[sd-1] = 0;
- }
+ if (s != INVALID_SOCKET) {
- if (checksd(sb ,sd) == TRUE)
- return 0;
+ if (sb->mtable[sd-1]) {
+ asyncsb[(sb->mtable[sd-1]-0xb000)/2] = NULL;
+ sb->mtable[sd-1] = 0;
+ }
+ if (checksd(sb ,sd) == TRUE)
+ return 0;
+ BEGINBLOCKING;
- BEGINBLOCKING;
+ for (;;) {
- for (;;)
- {
- shutdown(s,1);
- if (!closesocket(s))
- {
- releasesock(sb,sd);
- TRACE(("OK\n"));
- return 0;
- }
+ shutdown(s,1);
+ if (!closesocket(s)) {
+ releasesock(sb,sd);
+ TRACE(("OK\n"));
+ return 0;
+ }
- SETERRNO;
+ SETERRNO;
- if (sb->sb_errno != WSAEWOULDBLOCK-WSABASEERR || !(sb->ftable[sd-1] & SF_BLOCKING)) break;
+ if (sb->sb_errno != WSAEWOULDBLOCK-WSABASEERR || !(sb->ftable[sd-1] & SF_BLOCKING))
+ break;
- if ((wMsg = allocasyncmsg(sb,sd,s)) != 0)
- {
- WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_CLOSE);
+ if ((wMsg = allocasyncmsg(sb,sd,s)) != 0) {
+ WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : hSockWnd,wMsg,FD_CLOSE);
-
- WAITSIGNAL;
+ WAITSIGNAL;
-
- cancelasyncmsg(wMsg);
+ cancelasyncmsg(context, wMsg);
- if (sb->eintr)
- {
- TRACE(("[interrupted]\n"));
- break;
+ if (sb->eintr) {
+ TRACE(("[interrupted]\n"));
+ break;
+ }
+ } else
+ break;
}
- }
- else break;
- }
- ENDBLOCKING;
+ ENDBLOCKING;
}
TRACE(("failed (%d)\n",sb->sb_errno));
uae_u32 currlong, mask;
SOCKET s;
- if (addthis != INVALID_SOCKET)
- {
+ if (addthis != INVALID_SOCKET) {
*fd_set_win->fd_array = addthis;
fd_set_win->fd_count = 1;
- }
- else fd_set_win->fd_count = 0;
+ } else
+ fd_set_win->fd_count = 0;
- if (!fd_set_amiga)
- {
+ if (!fd_set_amiga) {
fd_set_win->fd_array[fd_set_win->fd_count] = INVALID_SOCKET;
return;
}
- if (nfds > sb->dtablesize)
- {
+ if (nfds > sb->dtablesize) {
write_log("BSDSOCK: ERROR - select()ing more sockets (%d) than socket descriptors available (%d)!\n",nfds,sb->dtablesize);
nfds = sb->dtablesize;
}
- for (j = 0; ; j += 32, fd_set_amiga += 4)
- {
+ for (j = 0; ; j += 32, fd_set_amiga += 4) {
currlong = get_long(fd_set_amiga);
mask = 1;
- for (i = 0; i < 32; i++, mask <<= 1)
- {
- if (i+j > nfds)
- {
+ for (i = 0; i < 32; i++, mask <<= 1) {
+ if (i+j > nfds) {
fd_set_win->fd_array[fd_set_win->fd_count] = INVALID_SOCKET;
return;
}
- if (currlong & mask)
- {
+ if (currlong & mask) {
s = getsock(sb,j+i+1);
- if (s != INVALID_SOCKET)
- {
+ if (s != INVALID_SOCKET) {
fd_set_win->fd_array[fd_set_win->fd_count++] = s;
- if (fd_set_win->fd_count >= FD_SETSIZE)
- {
+ if (fd_set_win->fd_count >= FD_SETSIZE) {
write_log("BSDSOCK: ERROR - select()ing more sockets (%d) than the hard-coded fd_set limit (%d) - please report\n",nfds,FD_SETSIZE);
return;
}
int n, i, j, val, mask;
SOCKET currsock;
- for (n = 0; n < nfds; n += 32)
- {
+ for (n = 0; n < nfds; n += 32) {
val = 0;
mask = 1;
- for (i = 0; i < 32; i++, mask <<= 1)
- {
- if ((currsock = getsock(sb, n+i+1)) != INVALID_SOCKET)
- { // Do not use sb->dtable directly because of Newsrog
- for (j = fd_set_win->fd_count; j--; )
- {
- if (fd_set_win->fd_array[j] == currsock)
- {
+ for (i = 0; i < 32; i++, mask <<= 1) {
+ if ((currsock = getsock(sb, n+i+1)) != INVALID_SOCKET) {
+ // Do not use sb->dtable directly because of Newsrog
+ for (j = fd_set_win->fd_count; j--; ) {
+ if (fd_set_win->fd_array[j] == currsock) {
val |= mask;
break;
}
static void fd_zero(uae_u32 fdset, uae_u32 nfds)
{
unsigned int i;
- for (i = 0; i < nfds; i += 32, fdset += 4) put_long(fdset,0);
+ for (i = 0; i < nfds; i += 32, fdset += 4)
+ put_long(fdset,0);
}
// This seems to be the only way of implementing a cancelable WinSock2 select() call... sigh.
SB;
- for (;;)
- {
+ for (;;) {
WaitForSingleObject(hEvents[index],INFINITE);
- if ((args = threadargsw[index]) != NULL)
- {
+ if ((args = threadargsw[index]) != NULL) {
sb = args->sb;
nfds = args->nfds;
readfds = args->readfds;
// construct descriptor tables
makesocktable(sb,readfds,&readsocks,nfds,sb->sockAbort);
- if (writefds) makesocktable(sb,writefds,&writesocks,nfds,INVALID_SOCKET);
- if (exceptfds) makesocktable(sb,exceptfds,&exceptsocks,nfds,INVALID_SOCKET);
+ if (writefds)
+ makesocktable(sb,writefds,&writesocks,nfds,INVALID_SOCKET);
+ if (exceptfds)
+ makesocktable(sb,exceptfds,&exceptsocks,nfds,INVALID_SOCKET);
- if (timeout)
- {
+ if (timeout) {
tv.tv_sec = get_long(timeout);
tv.tv_usec = get_long(timeout+4);
TRACE(("(timeout: %d.%06d) ",tv.tv_sec,tv.tv_usec));
TRACE(("-> "));
sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,timeout ? &tv : 0);
- if (sb->resultval == SOCKET_ERROR)
- {
- // select was stopped by sb->sockAbort
- if (readsocks.fd_count > 1)
- {
- makesocktable(sb,readfds,&readsocks,nfds,INVALID_SOCKET);
- tv.tv_sec = 0;
- tv.tv_usec = 10000;
- // Check for 10ms if data is available
- sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,&tv);
- if (sb->resultval == 0)
- { // Now timeout -> really no data available
- if (GetLastError() != 0)
- {
- sb->resultval = SOCKET_ERROR;
- // Set old resultval
+ if (sb->resultval == SOCKET_ERROR) {
+ // select was stopped by sb->sockAbort
+ if (readsocks.fd_count > 1) {
+ makesocktable(sb,readfds,&readsocks,nfds,INVALID_SOCKET);
+ tv.tv_sec = 0;
+ tv.tv_usec = 10000;
+ // Check for 10ms if data is available
+ sb->resultval = select(nfds+1,&readsocks,writefds ? &writesocks : NULL,exceptfds ? &exceptsocks : NULL,&tv);
+ if (sb->resultval == 0) { // Now timeout -> really no data available
+ if (GetLastError() != 0) {
+ sb->resultval = SOCKET_ERROR;
+ // Set old resultval
}
}
}
}
- if (FD_ISSET(sb->sockAbort,&readsocks))
- {
- if (sb->resultval != SOCKET_ERROR)
- {
+ if (FD_ISSET(sb->sockAbort,&readsocks)) {
+ if (sb->resultval != SOCKET_ERROR) {
sb->resultval--;
- }
}
- else
- {
- sb->needAbort = 0;
- }
- if (sb->resultval == SOCKET_ERROR)
- {
+ } else {
+ sb->needAbort = 0;
+ }
+ if (sb->resultval == SOCKET_ERROR) {
SETERRNO;
TRACE(("failed (%d) - ",sb->sb_errno));
- if (readfds) fd_zero(readfds,nfds);
- if (writefds) fd_zero(writefds,nfds);
- if (exceptfds) fd_zero(exceptfds,nfds);
- }
- else
- {
- if (readfds) makesockbitfield(sb,readfds,&readsocks,nfds);
- if (writefds) makesockbitfield(sb,writefds,&writesocks,nfds);
- if (exceptfds) makesockbitfield(sb,exceptfds,&exceptsocks,nfds);
+ if (readfds)
+ fd_zero(readfds,nfds);
+ if (writefds)
+ fd_zero(writefds,nfds);
+ if (exceptfds)
+ fd_zero(exceptfds,nfds);
+ } else {
+ if (readfds)
+ makesockbitfield(sb,readfds,&readsocks,nfds);
+ if (writefds)
+ makesockbitfield(sb,writefds,&writesocks,nfds);
+ if (exceptfds)
+ makesockbitfield(sb,exceptfds,&exceptsocks,nfds);
}
SETSIGNAL;
return result;
}
-void host_WaitSelect(SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, uae_u32 timeout, uae_u32 sigmp)
+void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, uae_u32 timeout, uae_u32 sigmp)
{
uae_u32 sigs, wssigs;
int i;
TRACE(("WaitSelect(%d,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx) ",nfds,readfds,writefds,exceptfds,timeout,wssigs));
- if (!readfds && !writefds && !exceptfds && !timeout && !wssigs)
- {
+ if (!readfds && !writefds && !exceptfds && !timeout && !wssigs) {
sb->resultval = 0;
TRACE(("-> [ignored]\n"));
return;
}
- if (wssigs)
- {
- m68k_dreg(regs,0) = 0;
- m68k_dreg(regs,1) = wssigs;
- sigs = CallLib(get_long(4),-0x132) & wssigs; // SetSignal()
+ if (wssigs) {
+ m68k_dreg(&context->regs,0) = 0;
+ m68k_dreg(&context->regs,1) = wssigs;
+ sigs = CallLib(context, get_long(4),-0x132) & wssigs; // SetSignal()
- if (sigs)
- {
+ if (sigs) {
TRACE(("-> [preempted by signals 0x%08lx]\n",sigs & wssigs));
put_long(sigmp,sigs & wssigs);
// Check for zero address -> otherwise WinUAE crashes
- if (readfds) fd_zero(readfds,nfds);
- if (writefds) fd_zero(writefds,nfds);
- if (exceptfds) fd_zero(exceptfds,nfds);
+ if (readfds)
+ fd_zero(readfds,nfds);
+ if (writefds)
+ fd_zero(writefds,nfds);
+ if (exceptfds)
+ fd_zero(exceptfds,nfds);
sb->resultval = 0;
- seterrno(sb,0);
+ bsdsocklib_seterrno(sb,0);
return;
}
}
- if (nfds == 0)
- { // No sockets to check, only wait for signals
- m68k_dreg(regs,0) = wssigs;
- sigs = CallLib(get_long(4),-0x13e); // Wait()
+ if (nfds == 0) {
+ // No sockets to check, only wait for signals
+ m68k_dreg(&context->regs,0) = wssigs;
+ sigs = CallLib(context, get_long(4),-0x13e); // Wait()
put_long(sigmp,sigs & wssigs);
- if (readfds) fd_zero(readfds,nfds);
- if (writefds) fd_zero(writefds,nfds);
- if (exceptfds) fd_zero(exceptfds,nfds);
+ if (readfds)
+ fd_zero(readfds,nfds);
+ if (writefds)
+ fd_zero(writefds,nfds);
+ if (exceptfds)
+ fd_zero(exceptfds,nfds);
sb->resultval = 0;
return;
}
break;
}
- if (i >= MAX_SELECT_THREADS)
- {
- for (i = 0; i < MAX_SELECT_THREADS; i++)
- {
- if (!hThreads[i])
- {
+ if (i >= MAX_SELECT_THREADS) {
+ for (i = 0; i < MAX_SELECT_THREADS; i++) {
+ if (!hThreads[i]) {
hEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL);
hThreads[i] = THREAD(thread_WaitSelect,&i);
- if (hEvents[i] == NULL || hThreads[i] == NULL)
- {
+ if (hEvents[i] == NULL || hThreads[i] == NULL) {
hThreads[i] = 0;
write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",
GetLastError());
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
sb->resultval = -1;
return;
}
-
// this should improve responsiveness
SetThreadPriority(hThreads[i],THREAD_PRIORITY_TIME_CRITICAL);
break;
}
}
- if (i >= MAX_SELECT_THREADS) write_log("BSDSOCK: ERROR - Too many select()s\n");
- else
- {
+ if (i >= MAX_SELECT_THREADS)
+ write_log("BSDSOCK: ERROR - Too many select()s\n");
+ else {
SOCKET newsock = INVALID_SOCKET;
taw.sb = sb;
SetEvent(hEvents[i]);
- m68k_dreg(regs,0) = (((uae_u32)1)<<sb->signal)|sb->eintrsigs|wssigs;
- sigs = CallLib(get_long(4),-0x13e); // Wait()
+ m68k_dreg(&context->regs,0) = (((uae_u32)1)<<sb->signal)|sb->eintrsigs|wssigs;
+ sigs = CallLib(context, get_long(4),-0x13e); // Wait()
/*
if ((1<<sb->signal) & sigs)
{ // 2.3.2002/SR Fix for AmiFTP -> Thread is ready, no need to Abort
sb->needAbort = 0;
}
*/
- if (sb->needAbort)
- {
+ if (sb->needAbort) {
if ((newsock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == INVALID_SOCKET)
write_log("BSDSOCK: ERROR - Cannot create socket: %d\n",WSAGetLastError());
shutdown(sb->sockAbort,1);
- if (newsock != sb->sockAbort)
- {
+ if (newsock != sb->sockAbort) {
shutdown(sb->sockAbort,1);
closesocket(sb->sockAbort);
}
CANCELSIGNAL;
- if (newsock != INVALID_SOCKET) sb->sockAbort = newsock;
+ if (newsock != INVALID_SOCKET)
+ sb->sockAbort = newsock;
- if( sigmp )
- {
+ if(sigmp) {
put_long(sigmp,sigs & wssigs);
- if (sigs & sb->eintrsigs)
- {
+ if (sigs & sb->eintrsigs) {
TRACE(("[interrupted]\n"));
sb->resultval = -1;
- seterrno(sb,4); // EINTR
- }
- else if (sigs & wssigs)
- {
+ bsdsocklib_seterrno(sb,4); // EINTR
+ } else if (sigs & wssigs) {
TRACE(("[interrupted by signals 0x%08lx]\n",sigs & wssigs));
if (readfds) fd_zero(readfds,nfds);
if (writefds) fd_zero(writefds,nfds);
if (exceptfds) fd_zero(exceptfds,nfds);
- seterrno(sb,0);
+ bsdsocklib_seterrno(sb,0);
sb->resultval = 0;
}
- if (sb->resultval >= 0)
- {
+ if (sb->resultval >= 0) {
TRACE(("%d\n",sb->resultval));
- }
- else
- {
+ } else {
TRACE(("%d errno %d\n",sb->resultval,sb->sb_errno));
}
- }
- else TRACE(("%d\n",sb->resultval));
+ } else
+ TRACE(("%d\n",sb->resultval));
}
}
-uae_u32 host_Inet_NtoA(SB, uae_u32 in)
+uae_u32 host_Inet_NtoA(TrapContext *context, SB, uae_u32 in)
{
char *addr;
struct in_addr ina;
TRACE(("Inet_NtoA(%lx) -> ",in));
- if ((addr = inet_ntoa(ina)) != NULL)
- {
- scratchbuf = m68k_areg(regs,6)+offsetof(struct UAEBSDBase,scratchbuf);
+ if ((addr = inet_ntoa(ina)) != NULL) {
+ scratchbuf = m68k_areg(&context->regs,6) + offsetof(struct UAEBSDBase,scratchbuf);
strncpyha(scratchbuf,addr,SCRATCHBUFSIZE);
TRACE(("%s\n",addr));
return scratchbuf;
- }
- else SETERRNO;
+ } else
+ SETERRNO;
TRACE(("failed (%d)\n",sb->sb_errno));
{
DWORD dwFlags;
BOOL bReturn = TRUE;
- if (InternetGetConnectedState(&dwFlags,0) == FALSE)
- { // Internet is offline
- if (InternetAttemptConnect(0) != ERROR_SUCCESS)
- { // Show Dialer window
+ if (InternetGetConnectedState(&dwFlags,0) == FALSE) { // Internet is offline
+ if (InternetAttemptConnect(0) != ERROR_SUCCESS) { // Show Dialer window
sb->sb_errno = 10001;
sb->sb_herrno = 1;
bReturn = FALSE;
// No success or aborted
}
- if (isfullscreen())
- {
+ if (isfullscreen()) {
ShowWindow (hAmigaWnd, SW_RESTORE);
SetActiveWindow(hAmigaWnd);
}
char *buf;
SB;
- for (;;)
- {
- WaitForSingleObject(hGetEvents[index],INFINITE);
- if (threadGetargs_inuse[index] == -1)
- {
+ for (;;) {
+ WaitForSingleObject(hGetEvents[index], INFINITE);
+ if (threadGetargs_inuse[index] == -1) {
threadGetargs_inuse[index] = 0;
threadGetargs[index] = NULL;
}
- if ((args = threadGetargs[index]) != NULL )
- {
+ if ((args = threadGetargs[index]) != NULL) {
sb = args->sb;
- if (args->args1 == 0)
- { // gethostbyname or gethostbyaddr
+ if (args->args1 == 0) {
+ // gethostbyname or gethostbyaddr
struct hostent *host;
name = args->args2;
namelen = args->args3;
buf = args->args5;
name_rp = get_real_address(name);
- if (strchr(name_rp,'.') == 0 || CheckOnline(sb) == TRUE)
- { // Local Address or Internet Online ?
- if (addrtype == -1)
- {
+ if (strchr(name_rp,'.') == 0 || CheckOnline(sb) == TRUE) {
+ // Local Address or Internet Online ?
+ if (addrtype == -1) {
host = gethostbyname(name_rp);
- }
- else
- {
+ } else {
host = gethostbyaddr(name_rp,namelen,addrtype);
}
- if (threadGetargs_inuse[index] != -1)
- { // No CTRL-C Signal
- if (host == 0)
- {
+ if (threadGetargs_inuse[index] != -1) {
+ // No CTRL-C Signal
+ if (host == 0) {
// Error occured
SETERRNO;
TRACE(("failed (%d) - ",sb->sb_errno));
- }
- else
- {
- seterrno(sb,0);
+ } else {
+ bsdsocklib_seterrno(sb,0);
memcpy(buf,host,sizeof(HOSTENT));
}
}
}
}
- if (args->args1 == 1)
- { // getprotobyname
+ if (args->args1 == 1) {
+ // getprotobyname
struct protoent *proto;
name = args->args2;
buf = args->args5;
name_rp = get_real_address(name);
proto = getprotobyname (name_rp);
- if (threadGetargs_inuse[index] != -1)
- { // No CTRL-C Signal
- if (proto == 0)
- {
+ if (threadGetargs_inuse[index] != -1) { // No CTRL-C Signal
+ if (proto == 0) {
// Error occured
SETERRNO;
TRACE(("failed (%d) - ",sb->sb_errno));
- }
- else
- {
- seterrno(sb,0);
+ } else {
+ bsdsocklib_seterrno(sb,0);
memcpy(buf,proto,sizeof(struct protoent));
}
}
}
- if (args->args1 == 2)
- { // getservbyport and getservbyname
+ if (args->args1 == 2) {
+ // getservbyport and getservbyname
uae_u32 nameport;
uae_u32 proto;
uae_u32 type;
type = args->args4;
buf = args->args5;
- if (proto) proto_rp = get_real_address(proto);
+ if (proto)
+ proto_rp = get_real_address(proto);
- if (type)
- {
+ if (type) {
serv = getservbyport(nameport,proto_rp);
- }
- else
- {
+ } else {
name_rp = get_real_address(nameport);
serv = getservbyname(name_rp,proto_rp);
}
- if (threadGetargs_inuse[index] != -1)
- { // No CTRL-C Signal
- if (serv == 0)
- {
+ if (threadGetargs_inuse[index] != -1) {
+ // No CTRL-C Signal
+ if (serv == 0) {
// Error occured
SETERRNO;
TRACE(("failed (%d) - ",sb->sb_errno));
- }
- else
- {
- seterrno(sb,0);
+ } else {
+ bsdsocklib_seterrno(sb,0);
memcpy(buf,serv,sizeof(struct servent));
}
}
return result;
}
-void host_gethostbynameaddr(SB, uae_u32 name, uae_u32 namelen, long addrtype)
+void host_gethostbynameaddr(TrapContext *context, SB, uae_u32 name, uae_u32 namelen, long addrtype)
{
HOSTENT *h;
int size, numaliases = 0, numaddr = 0;
uae_u32 aptr;
char *name_rp;
int i;
-
struct threadargs args;
-
uae_u32 addr;
uae_u32 *addr_list[2];
-
char buf[MAXGETHOSTSTRUCT];
unsigned int wMsg = 0;
name_rp = get_real_address(name);
- if (addrtype == -1)
- {
+ if (addrtype == -1) {
TRACE(("gethostbyname(%s) -> ",name_rp));
// workaround for numeric host "names"
- if ((addr = inet_addr(name_rp)) != INADDR_NONE)
- {
- seterrno(sb,0);
+ if ((addr = inet_addr(name_rp)) != INADDR_NONE) {
+ bsdsocklib_seterrno(sb,0);
((HOSTENT *)buf)->h_name = name_rp;
((HOSTENT *)buf)->h_aliases = NULL;
((HOSTENT *)buf)->h_addrtype = AF_INET;
goto kludge;
}
- }
- else
- {
+ } else {
TRACE(("gethostbyaddr(0x%lx,0x%lx,%ld) -> ",name,namelen,addrtype));
}
args.args4 = addrtype;
args.args5 = buf;
- for (i = 0; i < MAX_GET_THREADS; i++)
- {
- if (threadGetargs_inuse[i] == -1)
- {
+ for (i = 0; i < MAX_GET_THREADS; i++) {
+ if (threadGetargs_inuse[i] == -1) {
threadGetargs_inuse[i] = 0;
threadGetargs[i] = NULL;
}
if (hGetThreads[i] && !threadGetargs_inuse[i]) break;
}
- if (i >= MAX_GET_THREADS)
- {
- for (i = 0; i < MAX_GET_THREADS; i++)
- {
- if (hGetThreads[i] == NULL)
- {
+ if (i >= MAX_GET_THREADS) {
+ for (i = 0; i < MAX_GET_THREADS; i++) {
+ if (hGetThreads[i] == NULL) {
hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL);
hGetThreads[i] = THREAD(thread_get, &i);
- if (hGetEvents[i] == NULL || hGetThreads[i] == NULL)
- {
+ if (hGetEvents[i] == NULL || hGetThreads[i] == NULL) {
hGetThreads[i] = NULL;
write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",
GetLastError());
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
sb->resultval = -1;
return;
}
}
}
- if (i >= MAX_GET_THREADS) write_log("BSDSOCK: ERROR - Too many gethostbyname()s\n");
- else
- {
+ if (i >= MAX_GET_THREADS)
+ write_log("BSDSOCK: ERROR - Too many gethostbyname()s\n");
+ else {
bsdsetpriority (hGetThreads[i]);
threadGetargs[i] = &args;
threadGetargs_inuse[i] = 1;
SetEvent(hGetEvents[i]);
- }
+ }
sb->eintr = 0;
- while ( threadGetargs_inuse[i] != 0 && sb->eintr == 0)
- {
+ while ( threadGetargs_inuse[i] != 0 && sb->eintr == 0) {
WAITSIGNAL;
if (sb->eintr == 1)
threadGetargs_inuse[i] = -1;
}
-
+
CANCELSIGNAL;
-
- if (!sb->sb_errno)
- {
+
+ if (!sb->sb_errno) {
kludge:
h = (HOSTENT *)buf;
while (h->h_aliases[numaliases])
size += strlen(h->h_aliases[numaliases++])+5;
- if (h->h_addr_list != NULL)
- {
+ if (h->h_addr_list != NULL) {
while (h->h_addr_list[numaddr]) numaddr++;
size += numaddr*(h->h_length+4);
}
- if (sb->hostent)
- {
- uae_FreeMem( sb->hostent, sb->hostentsize );
+ if (sb->hostent) {
+ uae_FreeMem(context, sb->hostent, sb->hostentsize);
}
- sb->hostent = uae_AllocMem( size, 0 );
+ sb->hostent = uae_AllocMem(context, size, 0);
- if (!sb->hostent)
- {
+ if (!sb->hostent) {
write_log("BSDSOCK: WARNING - gethostby%s() ran out of Amiga memory "
"(couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",
addrtype == -1 ? "name" : "addr", size, name_rp);
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
return;
}
put_long(sb->hostent+12,h->h_length);
put_long(sb->hostent+16,sb->hostent+24+numaliases*4);
- for (i = 0; i < numaliases; i++) put_long(sb->hostent+20+i*4,addstr(&aptr,h->h_aliases[i]));
+ for (i = 0; i < numaliases; i++)
+ put_long(sb->hostent+20+i*4,addstr(&aptr,h->h_aliases[i]));
put_long(sb->hostent+20+numaliases*4,0);
- for (i = 0; i < numaddr; i++) put_long(sb->hostent+24+(numaliases+i)*4,addmem(&aptr,h->h_addr_list[i],h->h_length));
+ for (i = 0; i < numaddr; i++)
+ put_long(sb->hostent+24+(numaliases+i)*4,addmem(&aptr,h->h_addr_list[i],h->h_length));
put_long(sb->hostent+24+numaliases*4+numaddr*4,0);
put_long(sb->hostent,aptr);
addstr(&aptr,h->h_name);
TRACE(("OK (%s)\n",h->h_name));
- seterrno(sb,0);
- }
- else
- {
+ bsdsocklib_seterrno(sb,0);
+
+ } else {
TRACE(("failed (%d/%d)\n",sb->sb_errno,sb->sb_herrno));
}
}
-void host_getprotobyname(SB, uae_u32 name)
+void host_getprotobyname(TrapContext *context, SB, uae_u32 name)
{
PROTOENT *p;
int size, numaliases = 0;
uae_u32 aptr;
char *name_rp;
int i;
-
struct threadargs args;
-
-
char buf[MAXGETHOSTSTRUCT];
name_rp = get_real_address(name);
args.args2 = name;
args.args5 = buf;
- for (i = 0; i < MAX_GET_THREADS; i++)
- {
- if (threadGetargs_inuse[i] == -1)
- {
+ for (i = 0; i < MAX_GET_THREADS; i++) {
+ if (threadGetargs_inuse[i] == -1) {
threadGetargs_inuse[i] = 0;
threadGetargs[i] = NULL;
}
if (hGetThreads[i] && !threadGetargs_inuse[i]) break;
}
- if (i >= MAX_GET_THREADS)
- {
- for (i = 0; i < MAX_GET_THREADS; i++)
- {
- if (!hGetThreads[i])
- {
+ if (i >= MAX_GET_THREADS) {
+ for (i = 0; i < MAX_GET_THREADS; i++) {
+ if (!hGetThreads[i]) {
hEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL);
hGetThreads[i] = THREAD(thread_get,&i);
- if (hGetEvents[i] == NULL || hGetThreads[i] == NULL)
- {
+ if (hGetEvents[i] == NULL || hGetThreads[i] == NULL) {
hGetThreads[i] = 0;
write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",GetLastError());
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
sb->resultval = -1;
return;
}
}
}
- if (i >= MAX_GET_THREADS) write_log("BSDSOCK: ERROR - Too many getprotobyname()s\n");
- else
- {
+ if (i >= MAX_GET_THREADS)
+ write_log("BSDSOCK: ERROR - Too many getprotobyname()s\n");
+ else {
bsdsetpriority (hGetThreads[i]);
threadGetargs[i] = &args;
threadGetargs_inuse[i] = 1;
SetEvent(hGetEvents[i]);
- }
+ }
sb->eintr = 0;
- while ( threadGetargs_inuse[i] != 0 && sb->eintr == 0)
- {
+ while ( threadGetargs_inuse[i] != 0 && sb->eintr == 0) {
WAITSIGNAL;
if (sb->eintr == 1)
threadGetargs_inuse[i] = -1;
- }
+ }
CANCELSIGNAL;
- if (!sb->sb_errno)
- {
+ if (!sb->sb_errno) {
p = (PROTOENT *)buf;
// compute total size of protoent
size = 16;
- if (p->p_name != NULL) size += strlen(p->p_name)+1;
+ if (p->p_name != NULL)
+ size += strlen(p->p_name)+1;
if (p->p_aliases != NULL)
while (p->p_aliases[numaliases]) size += strlen(p->p_aliases[numaliases++])+5;
- if (sb->protoent)
- {
- uae_FreeMem( sb->protoent, sb->protoentsize );
+ if (sb->protoent) {
+ uae_FreeMem(context, sb->protoent, sb->protoentsize);
}
- sb->protoent = uae_AllocMem( size, 0 );
+ sb->protoent = uae_AllocMem(context, size, 0);
- if (!sb->protoent)
- {
+ if (!sb->protoent) {
write_log("BSDSOCK: WARNING - getprotobyname() ran out of Amiga memory "
"(couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",
size, name_rp);
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
return;
}
put_long(sb->protoent+4,sb->protoent+12);
put_long(sb->protoent+8,p->p_proto);
- for (i = 0; i < numaliases; i++) put_long(sb->protoent+12+i*4,addstr(&aptr,p->p_aliases[i]));
+ for (i = 0; i < numaliases; i++)
+ put_long(sb->protoent+12+i*4,addstr(&aptr,p->p_aliases[i]));
put_long(sb->protoent+12+numaliases*4,0);
put_long(sb->protoent,aptr);
addstr(&aptr,p->p_name);
TRACE(("OK (%s, %d)\n",p->p_name,p->p_proto));
- seterrno(sb,0);
- }
- else
- {
+ bsdsocklib_seterrno(sb,0);
+
+ } else {
TRACE(("failed (%d)\n",sb->sb_errno));
}
}
+void host_getprotobynumber(TrapContext *context, SB, uae_u32 name)
+{
+ bsdsocklib_seterrno(sb, 1);
+}
-void host_getservbynameport(SB, uae_u32 nameport, uae_u32 proto, uae_u32 type)
+void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32 proto, uae_u32 type)
{
SERVENT *s;
int size, numaliases = 0;
char buf[MAXGETHOSTSTRUCT];
struct threadargs args;
- if (proto) proto_rp = get_real_address(proto);
+ if (proto)
+ proto_rp = get_real_address(proto);
- if (type)
- {
+ if (type) {
TRACE(("getservbyport(%d,%s) -> ",nameport,proto_rp ? proto_rp : "NULL"));
- }
- else
- {
+ } else {
name_rp = get_real_address(nameport);
TRACE(("getservbyname(%s,%s) -> ",name_rp,proto_rp ? proto_rp : "NULL"));
}
args.args4 = type;
args.args5 = buf;
- for (i = 0; i < MAX_GET_THREADS; i++)
- {
- if (threadGetargs_inuse[i] == -1)
- {
+ for (i = 0; i < MAX_GET_THREADS; i++) {
+ if (threadGetargs_inuse[i] == -1) {
threadGetargs_inuse[i] = 0;
threadGetargs[i] = NULL;
}
if (hGetThreads[i] && !threadGetargs_inuse[i]) break;
}
- if (i >= MAX_GET_THREADS)
- {
- for (i = 0; i < MAX_GET_THREADS; i++)
- {
- if (!hGetThreads[i])
- {
+ if (i >= MAX_GET_THREADS) {
+ for (i = 0; i < MAX_GET_THREADS; i++) {
+ if (!hGetThreads[i]) {
hGetEvents[i] = CreateEvent(NULL,FALSE,FALSE,NULL);
hGetThreads[i] = THREAD(thread_get,&i);
- if (hGetEvents[i] == NULL || hGetThreads[i] == NULL)
- {
+ if (hGetEvents[i] == NULL || hGetThreads[i] == NULL) {
hGetThreads[i] = 0;
write_log("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",GetLastError());
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
sb->resultval = -1;
return;
}
}
}
- if (i >= MAX_GET_THREADS) write_log("BSDSOCK: ERROR - Too many getprotobyname()s\n");
- else
- {
+ if (i >= MAX_GET_THREADS)
+ write_log("BSDSOCK: ERROR - Too many getprotobyname()s\n");
+ else {
bsdsetpriority (hGetThreads[i]);
threadGetargs[i] = &args;
threadGetargs_inuse[i] = 1;
SetEvent(hGetEvents[i]);
- }
+ }
sb->eintr = 0;
- while ( threadGetargs_inuse[i] != 0 && sb->eintr == 0)
- {
+ while ( threadGetargs_inuse[i] != 0 && sb->eintr == 0) {
WAITSIGNAL;
if (sb->eintr == 1)
threadGetargs_inuse[i] = -1;
CANCELSIGNAL;
- if (!sb->sb_errno)
- {
+ if (!sb->sb_errno) {
s = (SERVENT *)buf;
// compute total size of servent
size = 20;
- if (s->s_name != NULL) size += strlen(s->s_name)+1;
- if (s->s_proto != NULL) size += strlen(s->s_proto)+1;
+ if (s->s_name != NULL)
+ size += strlen(s->s_name)+1;
+ if (s->s_proto != NULL)
+ size += strlen(s->s_proto)+1;
if (s->s_aliases != NULL)
- while (s->s_aliases[numaliases]) size += strlen(s->s_aliases[numaliases++])+5;
+ while (s->s_aliases[numaliases])
+ size += strlen(s->s_aliases[numaliases++])+5;
- if (sb->servent)
- {
- uae_FreeMem( sb->servent, sb->serventsize );
+ if (sb->servent) {
+ uae_FreeMem(context, sb->servent, sb->serventsize);
}
- sb->servent = uae_AllocMem( size, 0 );
+ sb->servent = uae_AllocMem(context, size, 0);
- if (!sb->servent)
- {
+ if (!sb->servent) {
write_log("BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %ld bytes)\n",type ? "port" : "name",size);
- seterrno(sb,12); // ENOMEM
+ bsdsocklib_seterrno(sb,12); // ENOMEM
return;
}
addstr(&aptr,s->s_proto);
TRACE(("OK (%s, %d)\n",s->s_name,(unsigned short)htons(s->s_port)));
- seterrno(sb,0);
- }
- else
- {
+ bsdsocklib_seterrno(sb,0);
+
+ } else {
TRACE(("failed (%d)\n",sb->sb_errno));
}
+++ /dev/null
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * User configuration options
- *
- * Copyright 1995 - 1998 Bernd Schmidt
- */
-
-/*
- * Please note: Many things are configurable with command line parameters,
- * and you can put anything you can pass on the command line into a
- * configuration file ~/.uaerc. Please read the documentation for more
- * information.
- *
- * NOTE NOTE NOTE
- * Whenever you change something in this file, you have to "make clean"
- * afterwards.
- * Don't remove the '#' signs. If you want to enable something, move it out
- * of the C comment block, if you want to disable something, move it inside
- * the block.
- */
-
-/*
- * When USE_COMPILER is defined, a m68k->i386 instruction compiler will be
- * used. This is experimental. It has only been tested on a Linux/i386 ELF
- * machine, although it might work on other i386 Unices.
- * This is supposed to speed up application programs. It will not work very
- * well for hardware bangers like games and demos, in fact it will be much
- * slower. It can also be slower for some applications and/or benchmarks.
- * It needs a lot of tuning. Please let me know your results with this.
- * The second define, RELY_ON_LOADSEG_DETECTION, decides how the compiler
- * tries to detect self-modifying code. If it is not set, the first bytes
- * of every compiled routine are used as checksum before executing the
- * routine. If it is set, the UAE filesystem will perform some checks to
- * detect whether an executable is being loaded. This is less reliable
- * (it won't work if you don't use the harddisk emulation, so don't try to
- * use floppies or even the RAM disk), but much faster.
- *
- * @@@ NOTE: This option is unfortunately broken in this version. Don't
- * try to use it. @@@
- *
-#define USE_COMPILER
-#define RELY_ON_LOADSEG_DETECTION
- */
-
-/*
- * Set USER_PROGRAMS_BEHAVE to 1 or 2 to indicate that you are only running
- * non-hardware banging programs which leave all the dirty work to the
- * Kickstart. This affects the compiler. Any program that is _not_ in the ROM
- * (i.e. everything but the Kickstart) will use faster memory access
- * functions.
- * There is of course the problem that the Amiga doesn't really distinguish
- * between user programs and the kernel. Not all of the OS is in the ROM,
- * e.g. the parallel.device is on the disk and gets loaded into RAM at least
- * with Kickstart 1.3 (don't know about newer Kickstarts). So you probably
- * can't print, and some other stuff may also fail to work.
- * A useless option, really, given the way lots of Amiga software is written.
-#define USER_PROGRAMS_BEHAVE 0
- */
-
-/***************************************************************************
- * Operating system/machine specific options
- * Configure these for your CPU. The default settings should work on any
- * machine, but may not give optimal performance everywhere.
- * (These don't do very much yet, except HAVE_RDTSC
- */
-
-/*
- * Define this where unaligned-accesses don't break things, and are "fast enough"
- */
-#define UNALIGNED_PROFITABLE
-
-/*
- * PPros don't like branches. With this option, UAE tries to avoid them in some
- * places.
- */
-#define BRANCHES_ARE_EXPENSIVE
\ No newline at end of file
#define DI_DEBUG
//#define DI_DEBUG2
-#include "config.h"
#include "sysconfig.h"
#include <stdlib.h>
#if defined (OPENGL) && defined (GFXFILTER)
-#include "config.h"
#include "options.h"
#include "xwin.h"
#include "custom.h"
#ifdef DRIVESOUND
#include "uae.h"
-#include "config.h"
#include "options.h"
#include "driveclick.h"
#include "threaddep/thread.h"
* Copyright 1999 Brian King, under GNU Public License
*
*/
-#ifndef _MSC_VER
-#define INITGUID
-#endif
-
-#include "config.h"
#include "sysconfig.h"
#include <stdlib.h>
#include <windows.h>
#include <sys/timeb.h>
-#ifdef _MSC_VER
#include <mmsystem.h>
#include <ddraw.h>
#include <dsound.h>
#include <dxerr8.h>
-#else
-#include "winstuff.h"
-#endif
#include "sysdeps.h"
#include "options.h"
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="genlinetoscr"
+ ProjectGUID="{E9F73E11-A463-45C6-A733-2BED75852BA1}"
+ RootNamespace="genlinetoscr_msvc"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ Description=""
+ CommandLine=""
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ Description="deleteing linetoscr.c"
+ CommandLine="del ..\..\linetoscr.c"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="genlinetoscr.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ Description="generating linetoscr.c"
+ CommandLine="genlinetoscr.exe >..\..\linetoscr.c"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\genlinetoscr.c"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
#include <shellapi.h>
#include "resource.h"
-#include "config.h"
#include "threaddep/thread.h"
#include "filesys.h"
#include "blkdev.h"
}
#endif
-#if 0 // not yet production ready
+#if 0
static int hdf_rw (struct hardfiledata *hfd, void *bufferp, uae_u64 offset, int len, int dowrite)
{
#else
-int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+static int hdf_read_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
DWORD outlen = 0;
int coffset;
return 0;
}
-int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+{
+ int got = 0;
+ uae_u8 *p = buffer;
+ while (len > 0) {
+ int maxlen = len > CACHE_SIZE ? CACHE_SIZE : len;
+ int ret = hdf_read_2(hfd, p, offset, maxlen);
+ got += ret;
+ if (ret != maxlen)
+ return got;
+ offset += maxlen;
+ p += maxlen;
+ len -= maxlen;
+ }
+ return got;
+}
+
+static int hdf_write_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
DWORD outlen = 0;
if (hfd->readonly)
outlen = zfile_fwrite (hfd->cache, 1, len, hfd->handle);
return outlen;
}
+
+int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+{
+ int got = 0;
+ uae_u8 *p = buffer;
+ while (len > 0) {
+ int maxlen = len > CACHE_SIZE ? CACHE_SIZE : len;
+ int ret = hdf_write_2(hfd, p, offset, maxlen);
+ got += ret;
+ if (ret != maxlen)
+ return got;
+ offset += maxlen;
+ p += maxlen;
+ len -= maxlen;
+ }
+ return got;
+}
+
#endif
#ifdef WINDDK
&interfaceData // Device Interface Data
);
- if ( status == FALSE ) {
+ if (status == FALSE) {
errorCode = GetLastError();
- if ( errorCode != ERROR_NO_MORE_ITEMS ) {
+ if (errorCode != ERROR_NO_MORE_ITEMS) {
write_log ("SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
}
ret = 0;
// pass a bigger buffer to get the detail data
//
- if ( status == FALSE ) {
+ if (status == FALSE) {
errorCode = GetLastError();
- if ( errorCode != ERROR_INSUFFICIENT_BUFFER ) {
+ if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
write_log("SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
ret = 0;
goto end;
sizeof (outBuf),
&returnedLength,
NULL);
- if ( !status ) {
+ if (!status) {
write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", GetLastError());
ret = 1;
goto end;
write_log ("not a direct access device, ignored (type=%d)\n", devDesc->DeviceType);
goto end;
}
- if ( devDesc->VendorIdOffset && p[devDesc->VendorIdOffset] ) {
+ if (devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) {
j = 0;
- for ( i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
+ for (i = devDesc->VendorIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
udi->vendor_id[j++] = p[i];
}
- if ( devDesc->ProductIdOffset && p[devDesc->ProductIdOffset] ) {
+ if (devDesc->ProductIdOffset && p[devDesc->ProductIdOffset]) {
j = 0;
- for ( i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
+ for (i = devDesc->ProductIdOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
udi->product_id[j++] = p[i];
}
- if ( devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset] ) {
+ if (devDesc->ProductRevisionOffset && p[devDesc->ProductRevisionOffset]) {
j = 0;
- for ( i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
+ for (i = devDesc->ProductRevisionOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
udi->product_rev[j++] = p[i];
}
- if ( devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset] ) {
+ if (devDesc->SerialNumberOffset && p[devDesc->SerialNumberOffset]) {
j = 0;
- for ( i = devDesc->SerialNumberOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++ )
+ for (i = devDesc->SerialNumberOffset; p[i] != (UCHAR) NULL && i < returnedLength; i++)
udi->product_serial[j++] = p[i];
}
if (udi->vendor_id[0])
* (c) 2002 Toni Wilen
*/
-#include "config.h"
#include "sysconfig.h"
#include <assert.h>
#include "win32.h"
#include "debug.h"
#include "ar.h"
-#include "ahidsound.h"
#include "savestate.h"
#include "sound.h"
#include "akiko.h"
-#ifndef M68K_H
-#define M68K_H
-
- /*
+/*
* UAE - The Un*x Amiga Emulator
- *
+ *
* MC68000 emulation - machine dependent bits
*
* Copyright 1996 Bernd Schmidt
+ * Copyright 2004-2005 Richard Drummond
*/
+ /*
+ * Machine dependent structure for holding the 68k CCR flags
+ */
struct flag_struct {
unsigned int cznv;
unsigned int x;
};
-#define FLAGVAL_Z 0x4000
-#define FLAGVAL_N 0x8000
-
-#define SET_ZFLG(y) (regflags.cznv = (regflags.cznv & ~0x4000) | (((y) ? 0x4000 : 0)))
-#define SET_CFLG(y) (regflags.cznv = (regflags.cznv & ~0x100) | (((y) ? 0x100 : 0)))
-#define SET_VFLG(y) (regflags.cznv = (regflags.cznv & ~0x1) | (((y) ? 1 : 0)))
-#define SET_NFLG(y) (regflags.cznv = (regflags.cznv & ~0x8000) | (((y) ? 0x8000 : 0)))
-#define SET_XFLG(y) (regflags.x = ((y) ? 1 : 0))
-
-#define GET_ZFLG ((regflags.cznv >> 14) & 1)
-#define GET_CFLG ((regflags.cznv >> 8) & 1)
-#define GET_VFLG ((regflags.cznv >> 0) & 1)
-#define GET_NFLG ((regflags.cznv >> 15) & 1)
-#define GET_XFLG (regflags.x & 1)
-
-#define CLEAR_CZNV (regflags.cznv = 0)
-#define GET_CZNV (regflags.cznv)
-#define IOR_CZNV(X) (regflags.cznv |= (X))
-#define SET_CZNV(X) (regflags.cznv = (X))
-#define COPY_CARRY (regflags.x = (regflags.cznv) >> 8)
-
-#ifdef X86_ASSEMBLY
-extern struct flag_struct regflags __asm__ ("regflags");
-#else
-extern struct flag_struct regflags;
-#endif
-
-static __inline__ int cctrue(int cc)
+/*
+ * The bits in the cznv field in the above structure are assigned to
+ * allow the easy mirroring of the x86 condition flags. (For example,
+ * from the AX register - the x86 overflow flag can be copied to AL
+ * with a setto %AL instr and the other flags copied to AH with an
+ * lahf instr).
+ *
+ * The 68k CZNV flags are thus assinged in cznv as:
+ *
+ * <--AL--> <--AH-->
+ * 76543210 FEDCBA98 --------- ---------
+ * xxxxxxxV NZxxxxxC xxxxxxxxx xxxxxxxxx
+ */
+
+#define FLAGBIT_N 15
+#define FLAGBIT_Z 14
+#define FLAGBIT_C 8
+#define FLAGBIT_V 0
+#define FLAGBIT_X 8
+
+#define FLAGVAL_N (1 << FLAGBIT_N)
+#define FLAGVAL_Z (1 << FLAGBIT_Z)
+#define FLAGVAL_C (1 << FLAGBIT_C)
+#define FLAGVAL_V (1 << FLAGBIT_V)
+#define FLAGVAL_X (1 << FLAGBIT_X)
+
+#define SET_ZFLG(flags, y) ((flags)->cznv = ((flags)->cznv & ~FLAGVAL_Z) | (((y) & 1) << FLAGBIT_Z))
+#define SET_CFLG(flags, y) ((flags)->cznv = ((flags)->cznv & ~FLAGVAL_C) | (((y) & 1) << FLAGBIT_C))
+#define SET_VFLG(flags, y) ((flags)->cznv = ((flags)->cznv & ~FLAGVAL_V) | (((y) & 1) << FLAGBIT_V))
+#define SET_NFLG(flags, y) ((flags)->cznv = ((flags)->cznv & ~FLAGVAL_N) | (((y) & 1) << FLAGBIT_N))
+#define SET_XFLG(flags, y) ((flags)->x = (y) << FLAGBIT_X)
+
+#define GET_ZFLG(flags) (((flags)->cznv >> FLAGBIT_Z) & 1)
+#define GET_CFLG(flags) (((flags)->cznv >> FLAGBIT_C) & 1)
+#define GET_VFLG(flags) (((flags)->cznv >> FLAGBIT_V) & 1)
+#define GET_NFLG(flags) (((flags)->cznv >> FLAGBIT_N) & 1)
+#define GET_XFLG(flags) (((flags)->x >> FLAGBIT_X) & 1)
+
+#define CLEAR_CZNV(flags) ((flags)->cznv = 0)
+#define GET_CZNV(flags) ((flags)->cznv)
+#define IOR_CZNV(flags, X) ((flags)->cznv |= (X))
+#define SET_CZNV(flags, X) ((flags)->cznv = (X))
+
+#define COPY_CARRY(flags) ((flags)->x = (flags)->cznv)
+
+
+/*
+ * Test CCR condition
+ */
+STATIC_INLINE int cctrue (struct flag_struct *flags, int cc)
{
- uae_u32 cznv = regflags.cznv;
- switch(cc){
- case 0: return 1; /* T */
- case 1: return 0; /* F */
- case 2: return (cznv & 0x4100) == 0; /* !GET_CFLG && !GET_ZFLG; HI */
- case 3: return (cznv & 0x4100) != 0; /* GET_CFLG || GET_ZFLG; LS */
- case 4: return (cznv & 0x100) == 0; /* !GET_CFLG; CC */
- case 5: return (cznv & 0x100) != 0; /* GET_CFLG; CS */
- case 6: return (cznv & 0x4000) == 0; /* !GET_ZFLG; NE */
- case 7: return (cznv & 0x4000) != 0; /* GET_ZFLG; EQ */
- case 8: return (cznv & 0x01) == 0; /* !GET_VFLG; VC */
- case 9: return (cznv & 0x01) != 0; /* GET_VFLG; VS */
- case 10:return (cznv & 0x8000) == 0; /* !GET_NFLG; PL */
- case 11:return (cznv & 0x8000) != 0; /* GET_NFLG; MI */
- case 12:return (((cznv << 15) ^ cznv) & 0x8000) == 0; /* GET_NFLG == GET_VFLG; GE */
- case 13:return (((cznv << 15) ^ cznv) & 0x8000) != 0;/* GET_NFLG != GET_VFLG; LT */
- case 14:
- cznv &= 0xc001;
- return (((cznv << 15) ^ cznv) & 0xc000) == 0; /* !GET_ZFLG && (GET_NFLG == GET_VFLG); GT */
- case 15:
- cznv &= 0xc001;
- return (((cznv << 15) ^ cznv) & 0xc000) != 0; /* GET_ZFLG || (GET_NFLG != GET_VFLG); LE */
+ uae_u32 cznv = flags->cznv;
+
+ switch (cc) {
+ case 0: return 1; /* T */
+ case 1: return 0; /* F */
+ case 2: return (cznv & (FLAGVAL_C | FLAGVAL_Z)) == 0; /* !CFLG && !ZFLG HI */
+ case 3: return (cznv & (FLAGVAL_C | FLAGVAL_Z)) != 0; /* CFLG || ZFLG LS */
+ case 4: return (cznv & FLAGVAL_C) == 0; /* !CFLG CC */
+ case 5: return (cznv & FLAGVAL_C) != 0; /* CFLG CS */
+ case 6: return (cznv & FLAGVAL_Z) == 0; /* !ZFLG NE */
+ case 7: return (cznv & FLAGVAL_Z) != 0; /* ZFLG EQ */
+ case 8: return (cznv & FLAGVAL_V) == 0; /* !VFLG VC */
+ case 9: return (cznv & FLAGVAL_V) != 0; /* VFLG VS */
+ case 10: return (cznv & FLAGVAL_N) == 0; /* !NFLG PL */
+ case 11: return (cznv & FLAGVAL_N) != 0; /* NFLG MI */
+ case 12: return (((cznv << (FLAGBIT_N - FLAGBIT_V)) ^ cznv) & FLAGVAL_N) == 0; /* NFLG == VFLG GE */
+ case 13: return (((cznv << (FLAGBIT_N - FLAGBIT_V)) ^ cznv) & FLAGVAL_N) != 0; /* NFLG != VFLG LT */
+ case 14: cznv &= (FLAGVAL_N | FLAGVAL_Z | FLAGVAL_V); /* ZFLG && (NFLG == VFLG) GT */
+ return (((cznv << (FLAGBIT_N - FLAGBIT_V)) ^ cznv) & (FLAGVAL_N | FLAGVAL_Z)) == 0;
+ case 15: cznv &= (FLAGVAL_N | FLAGVAL_Z | FLAGVAL_V); /* ZFLG && (NFLG != VFLG) LE */
+ return (((cznv << (FLAGBIT_N - FLAGBIT_V)) ^ cznv) & (FLAGVAL_N | FLAGVAL_Z)) != 0;
}
- abort();
+ abort ();
return 0;
}
-
-#ifdef X86_ASSEMBLY
-
-#define optflag_testl(v) \
- __asm__ __volatile__ ("andl %0,%0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :: "r" (v) : "%eax","cc","memory")
-#define optflag_testw(v) \
- __asm__ __volatile__ ("andw %w0,%w0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :: "r" (v) : "%eax","cc","memory")
-
-#define optflag_testb(v) \
- __asm__ __volatile__ ("andb %b0,%b0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :: "q" (v) : "%eax","cc","memory")
-
-#define optflag_addl(v, s, d) do { \
- __asm__ __volatile__ ("addl %k1,%k0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :"=r" (v) : "rmi" (s), "0" (d) : "%eax","cc","memory"); \
- COPY_CARRY; \
- } while (0)
-#define optflag_addw(v, s, d) do { \
- __asm__ __volatile__ ("addw %w1,%w0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- : "=r" (v) : "rmi" (s), "0" (d) : "%eax","cc","memory"); \
- COPY_CARRY; \
- } while (0)
-
-#define optflag_addb(v, s, d) do { \
- __asm__ __volatile__ ("addb %b1,%b0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :"=q" (v) : "qmi" (s), "0" (d) : "%eax","cc","memory"); \
- COPY_CARRY; \
- } while (0)
-
-#define optflag_subl(v, s, d) do { \
- __asm__ __volatile__ ("subl %k1,%k0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- : "=r" (v) : "rmi" (s), "0" (d) : "%eax","cc","memory"); \
- COPY_CARRY; \
- } while (0)
-
-#define optflag_subw(v, s, d) do { \
- __asm__ __volatile__ ("subw %w1,%w0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- : "=r" (v) : "rmi" (s), "0" (d) : "%eax","cc","memory"); \
- COPY_CARRY; \
- } while (0)
-
-#define optflag_subb(v, s, d) do { \
- __asm__ __volatile__ ("subb %b1,%b0\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- : "=q" (v) : "qmi" (s), "0" (d) : "%eax","cc","memory"); \
- COPY_CARRY; \
- } while (0)
-
-#define optflag_cmpl(s, d) \
- __asm__ __volatile__ ("cmpl %k0,%k1\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :: "rmi" (s), "r" (d) : "%eax","cc","memory")
-
-#define optflag_cmpw(s, d) \
- __asm__ __volatile__ ("cmpw %w0,%w1\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :: "rmi" (s), "r" (d) : "%eax","cc","memory");
-
-#define optflag_cmpb(s, d) \
- __asm__ __volatile__ ("cmpb %b0,%b1\n\t" \
- "lahf\n\t" \
- "seto %%al\n\t" \
- "movb %%al,regflags\n\t" \
- "movb %%ah,regflags+1\n\t" \
- :: "qmi" (s), "q" (d) : "%eax","cc","memory")
-
-#endif
-
-#endif
\ No newline at end of file
* 2002.05.xx 1.2 Bernd Roesch - sysex in/MTC/Song Position pointer add
*/
-#include "config.h"
#include "sysconfig.h"
#include <windows.h>
#include <stdlib.h>
#include <stdarg.h>
-#ifdef _MSC_VER
#include <mmsystem.h>
#include <ddraw.h>
-#else
-#include "winstuff.h"
-#endif
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "sysconfig.h"
#include "sysdeps.h"
#include "sys/mman.h"
-#include "include/memory.h"
+#include "memory.h"
#include "options.h"
#include "autoconf.h"
#include "win32.h"
uae_u32 max_allowed_mman = 512;
#endif
-static uae_u8 stackmagic64asm[] = {
- 0x48,0x8b,0x44,0x24,0x28, // mov rax,qword ptr [rsp+28h]
- 0x49,0x8b,0xe1, // mov rsp,r9
- 0xff,0xd0 // call rax
-};
-uae_u8 *stack_magic_amd64_asm_executable;
-
void cache_free(void *cache)
{
VirtualFree (cache, 0, MEM_RELEASE);
uae_u64 totalphys64;
MEMORYSTATUS memstats;
-#ifdef CPU_64_BIT
- if (!stack_magic_amd64_asm_executable) {
- stack_magic_amd64_asm_executable = cache_alloc(sizeof stackmagic64asm);
- memcpy(stack_magic_amd64_asm_executable, stackmagic64asm, sizeof stackmagic64asm);
- }
-#endif
-
if (natmem_offset && os_winnt)
VirtualFree(natmem_offset, 0, MEM_RELEASE);
natmem_offset = NULL;
void mapped_free(uae_u8 *mem)
{
shmpiece *x = shm_start;
- while( x )
- {
+ while(x) {
if( mem == x->native_address )
shmdt( x->native_address);
x = x->next;
}
x = shm_start;
- while( x )
- {
+ while(x) {
struct shmid_ds blah;
- if( mem == x->native_address )
- {
- if( shmctl( x->id, IPC_STAT, &blah ) == 0 )
- {
- shmctl( x->id, IPC_RMID, &blah );
- }
- else
- {
- //free( x->native_address );
+ if (mem == x->native_address) {
+ if (shmctl(x->id, IPC_STAT, &blah) == 0) {
+ shmctl(x->id, IPC_RMID, &blah);
+ } else {
VirtualFree((LPVOID)mem, 0, os_winnt ? MEM_RESET : (MEM_DECOMMIT | MEM_RELEASE));
}
}
{
key_t result = -1;
int i;
- for( i = 0; i < MAX_SHMID; i++ )
- {
- if( shmids[i].key == -1 )
- {
+ for (i = 0; i < MAX_SHMID; i++) {
+ if( shmids[i].key == -1) {
shmids[i].key = i;
result = i;
break;
STATIC_INLINE key_t find_shmkey( key_t key )
{
int result = -1;
- if( shmids[key].key == key )
- {
+ if(shmids[key].key == key) {
result = key;
}
return result;
int mprotect(void *addr, size_t len, int prot)
{
int result = 0;
-
return result;
}
unsigned int size=shmids[shmid].size;
if(shmids[shmid].attached )
return shmids[shmid].attached;
- if ((uae_u8*)shmaddr<natmem_offset){
- if(!strcmp(shmids[shmid].name,"chip"))
- {
+ if ((uae_u8*)shmaddr<natmem_offset) {
+ if(!strcmp(shmids[shmid].name,"chip")) {
shmaddr=natmem_offset;
got = TRUE;
// if(!currprefs.fastmem_size)
// size+=32;
}
- if(!strcmp(shmids[shmid].name,"kick"))
- {
+ if(!strcmp(shmids[shmid].name,"kick")) {
shmaddr=natmem_offset+0xf80000;
got = TRUE;
size+=32;
}
- if(!strcmp(shmids[shmid].name,"rom_e0"))
- {
+ if(!strcmp(shmids[shmid].name,"rom_e0")) {
shmaddr=natmem_offset+0xe00000;
got = TRUE;
}
- if(!strcmp(shmids[shmid].name,"rom_f0"))
- {
+ if(!strcmp(shmids[shmid].name,"rom_f0")) {
shmaddr=natmem_offset+0xf00000;
got = TRUE;
}
- if(!strcmp(shmids[shmid].name,"rtarea"))
- {
+ if(!strcmp(shmids[shmid].name,"rtarea")) {
shmaddr=natmem_offset+RTAREA_BASE;
got = TRUE;
size+=32;
}
- if(!strcmp(shmids[shmid].name,"fast"))
- {
+ if(!strcmp(shmids[shmid].name,"fast")) {
shmaddr=natmem_offset+0x200000;
got = TRUE;
size+=32;
gfxoffs=allocated_z3fastmem;
got = TRUE;
}
- if(!strcmp(shmids[shmid].name,"gfx"))
- {
+ if(!strcmp(shmids[shmid].name,"gfx")) {
shmaddr=natmem_offset+currprefs.z3fastmem_start+gfxoffs;
got = TRUE;
size+=32;
shmids[shmid].attached=result;
return result;
}
- if(!strcmp(shmids[shmid].name,"bogo"))
- {
+ if(!strcmp(shmids[shmid].name,"bogo")) {
shmaddr=natmem_offset+0x00C00000;
got = TRUE;
if (currprefs.bogomem_size <= 0x100000)
size+=32;
}
- if(!strcmp(shmids[shmid].name,"filesys"))
- {
+ if(!strcmp(shmids[shmid].name,"filesys")) {
result=natmem_offset+0x10000;
shmids[shmid].attached=result;
return result;
}
- if(!strcmp(shmids[shmid].name,"arcadia"))
- {
+ if(!strcmp(shmids[shmid].name,"arcadia")) {
result=natmem_offset+0x10000;
shmids[shmid].attached=result;
return result;
}
- if(!strcmp(shmids[shmid].name,"hrtmon"))
- {
+ if(!strcmp(shmids[shmid].name,"hrtmon")) {
shmaddr=natmem_offset+0x00a10000;
got = TRUE;
}
- if(!strcmp(shmids[shmid].name,"arhrtmon"))
- {
+ if(!strcmp(shmids[shmid].name,"arhrtmon")) {
shmaddr=natmem_offset+0x00800000;
got = TRUE;
}
{
int result = -1;
- if( ( key == IPC_PRIVATE ) ||
- ( ( shmflg & IPC_CREAT ) && ( find_shmkey( key ) == -1) ) )
- {
- write_log( "shmget of size %d (%dk) for %s\n", size, size >> 10, name );
- if( ( result = get_next_shmkey() ) != -1 )
- {
- //blah = VirtualAlloc( 0, size,MEM_COMMIT, PAGE_EXECUTE_READWRITE );
+ if((key == IPC_PRIVATE) || ((shmflg & IPC_CREAT) && (find_shmkey(key) == -1))) {
+ write_log ("shmget of size %d (%dk) for %s\n", size, size >> 10, name);
+ if ((result = get_next_shmkey()) != -1) {
shmids[result].size = size;
- strcpy( shmids[result].name, name );
- }
- else
- {
+ strcpy(shmids[result].name, name);
+ } else {
result = -1;
}
}
{
int result = -1;
- if( ( find_shmkey( shmid ) != -1 ) && buf )
- {
- switch( cmd )
+ if ((find_shmkey(shmid) != -1) && buf) {
+ switch(cmd)
{
case IPC_STAT:
*buf = shmids[shmid];
int isinf( double x )
{
-#ifdef _MSC_VER
const int nClass = _fpclass(x);
int result;
- if (nClass == _FPCLASS_NINF || nClass == _FPCLASS_PINF) result = 1;
- else
- result = 0;
-#else
- int result = 0;
-#endif
+ if (nClass == _FPCLASS_NINF || nClass == _FPCLASS_PINF)
+ result = 1;
+ else
+ result = 0;
return result;
}
-int isnan( double x )
+int isnan(double x)
{
-#ifdef _MSC_VER
int result = _isnan(x);
-#else
- int result = 0;
-#endif
return result;
}
#if defined (OPENGL) && defined (GFXFILTER)
-#include "config.h"
#include "options.h"
#include "xwin.h"
#include "dxwrap.h"
+++ /dev/null
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * Stack magic definitions for autoconf.c
- *
- * Copyright 1997 Bernd Schmidt
- */
-
-#include <setjmp.h>
-
-#ifdef CAN_DO_STACK_MAGIC
-
-#ifdef CPU_64_BIT
-
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * AMD64/GCC stack magic definitions for autoconf.c
- *
- * Copyright 2005 Richard Drummond
- */
-
-#include <setjmp.h>
-
-struct stack_frame
-{
- uae_u64 back_chain;
-
- /* Local area */
- uae_u32 local_has_retval;
- uae_u32 local_retval;
- uae_u64 dummy; /* keep 16-byte aligned */
-
- /* Previous frame */
- uae_u64 end_back_chain;
-};
-
-typedef void stupidfunc(void*,void*,uae_u32*,void*,void*);
-
-extern uae_u8 *stack_magic_amd64_asm_executable;
-
-__declspec(noreturn) static __forceinline void transfer_control (void *s, int size, void *pc, void *f, int has_retval)
-{
- struct stack_frame *stacktop = (struct stack_frame *)((char *)s + size - sizeof (struct stack_frame));
-
- stacktop->end_back_chain = 0xC0DEDBAD;
- stacktop->local_retval = 0;
- stacktop->local_has_retval = has_retval;
- stacktop->back_chain = (uae_u64) &stacktop->end_back_chain;
-
- ((stupidfunc*)stack_magic_amd64_asm_executable)(s, f, &(stacktop->local_retval), ((uae_u8*)stacktop) - 4 * 8, pc);
- /* Not reached. */
- abort ();
-}
-
-STATIC_INLINE uae_u32 get_retval_from_stack (void *s, int size)
-{
- return ((struct stack_frame *)((char *)s + size - sizeof(struct stack_frame)))->local_retval;
-}
-
-STATIC_INLINE int stack_has_retval (void *s, int size)
-{
- return ((struct stack_frame *)((char *)s + size - sizeof(struct stack_frame)))->local_has_retval;
-}
-
-#else
-
-__declspec(noreturn) static __forceinline void transfer_control(void *s, int size, void *pc, void *f, int has_retval)
-{
- unsigned long *stacktop = (unsigned long *)((char *)s + size - 5 * 4);
- stacktop[0] = 0xC0DEDBAD; /* return address */
- stacktop[1] = (int)s; /* function arg 1: stack */
- stacktop[2] = (int)f; /* function arg 2: trap function */
- stacktop[3] = (int)stacktop; /* function arg 3: return value address */
- stacktop[4] = has_retval;
-
- __asm
- {
- mov esp, stacktop
- push pc
- ret
- }
- /* Not reached. */
- abort();
-}
-
-static __inline__ uae_u32 get_retval_from_stack (void *s, int size)
-{
- return *(uae_u32 *)((char *)s + size - 5 * 4);
-}
-
-static __inline__ int stack_has_retval (void *s, int size)
-{
- return *(int *)((char *)s + size - 4);
-}
-
-#endif
-
-#endif
* Copyright 1998-1999 Brian King - added MIDI output support
*/
-#include "config.h"
#include "sysconfig.h"
#include <windows.h>
#include <winspool.h>
#include <stdlib.h>
#include <stdarg.h>
-#ifdef _MSC_VER
#include <mmsystem.h>
#include <ddraw.h>
#include <commctrl.h>
#include <commdlg.h>
-#else
-#include "winstuff.h"
-#endif
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "include/memory.h"
#include "custom.h"
#include "autoconf.h"
+#include "newcpu.h"
+#include "traps.h"
#include "od-win32/win32gui.h"
#include "od-win32/parser.h"
#include "od-win32/midi.h"
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "threaddep/thread.h"
#include "uae.h"
#include "xwin.h"
#include "savestate.h"
#include "autoconf.h"
+#include "traps.h"
#if defined(PICASSO96)
This function is used to paint a line on the board memory possibly using the blitter. It is called by Draw
and obeyes the destination RGBFormat as well as ForeGround and BackGround pens and draw modes.
*/
-uae_u32 picasso_DrawLine (void)
+uae_u32 REGPARAM2 picasso_DrawLine (struct regstruct *regs)
{
uae_u32 result = 0;
#ifdef P96_DRAWLINE
struct Line line;
struct RenderInfo ri;
- uae_u8 Mask = m68k_dreg( regs, 0 );
- RGBFTYPE RGBFormat = m68k_dreg( regs, 7 );
+ uae_u8 Mask = m68k_dreg(regs, 0);
+ RGBFTYPE RGBFormat = m68k_dreg(regs, 7);
- CopyRenderInfoStructureA2U( m68k_areg( regs, 1 ), &ri );
- CopyLineStructureA2U( m68k_areg( regs, 2 ), &line );
+ CopyRenderInfoStructureA2U(m68k_areg(regs, 1), &ri);
+ CopyLineStructureA2U(m68k_areg(regs, 2), &line);
#if defined( P96TRACING_ENABLED ) && P96TRACING_LEVEL > 0
DumpLine( &line );
#endif
* BoardInfo struct supplied by the caller, the rtg.library, for example
* the MemoryBase, MemorySize and RegisterBase fields.
*/
-uae_u32 picasso_FindCard (void)
+uae_u32 REGPARAM2 picasso_FindCard (struct regstruct *regs)
{
uaecptr AmigaBoardInfo = m68k_areg (regs, 0);
* gbi_MaxHorResolution: fill this in for all modes (even if you don't support them)
* gbi_MaxVerResolution: fill this in for all modes (even if you don't support them)
*/
-uae_u32 picasso_InitCard (void)
+uae_u32 REGPARAM2 picasso_InitCard (struct regstruct *regs)
{
struct LibResolution res;
int i;
*
* NOTE: Return the opposite of the switch-state. BDK
*/
-uae_u32 picasso_SetSwitch (void)
+uae_u32 REGPARAM2 picasso_SetSwitch (struct regstruct *regs)
{
uae_u16 flag = m68k_dreg (regs, 0) & 0xFFFF;
* per cannon your board has. So you might have to shift the colors
* before writing them to the hardware.
*/
-uae_u32 picasso_SetColorArray (void)
+uae_u32 REGPARAM2 picasso_SetColorArray (struct regstruct *regs)
{
/* Fill in some static UAE related structure about this new CLUT setting
* We need this for CLUT-based displays, and for mapping CLUT to hi/true colour */
* e.g. from chunky to TrueColor. Usually, all you have to do is to set
* the RAMDAC of your board accordingly.
*/
-uae_u32 picasso_SetDAC (void)
+uae_u32 REGPARAM2 picasso_SetDAC (struct regstruct *regs)
{
/* Fill in some static UAE related structure about this new DAC setting
* Lets us keep track of what pixel format the Amiga is thinking about in our frame-buffer */
* or linear start adress. They will be set when appropriate by their
* own functions.
*/
-uae_u32 picasso_SetGC (void)
+uae_u32 REGPARAM2 picasso_SetGC (struct regstruct *regs)
{
/* Fill in some static UAE related structure about this new ModeInfo setting */
uae_u32 border = m68k_dreg (regs, 0);
* because SetSwitch() is not called for subsequent Picasso screens.
*/
-uae_u32 picasso_SetPanning (void)
+uae_u32 REGPARAM2 picasso_SetPanning (struct regstruct *regs)
{
uae_u16 Width = m68k_dreg (regs, 0);
uaecptr start_of_screen = m68k_areg (regs, 1);
- uaecptr bi = m68k_areg( regs, 0 );
+ uaecptr bi = m68k_areg(regs, 0);
uaecptr bmeptr = get_long( bi + PSSO_BoardInfo_BitMapExtra ); /* Get our BoardInfo ptr's BitMapExtra ptr */
uae_u16 bme_width, bme_height;
* This function is used to invert a rectangular area on the board. It is called by BltBitMap,
* BltPattern and BltTemplate.
*/
-uae_u32 picasso_InvertRect (void)
+uae_u32 REGPARAM2 picasso_InvertRect (struct regstruct *regs)
{
uaecptr renderinfo = m68k_areg (regs, 1);
unsigned long X = (uae_u16)m68k_dreg (regs, 0);
* d5: UBYTE Mask
* d7: uae_u32 RGBFormat
***********************************************************/
-uae_u32 picasso_FillRect (void)
+uae_u32 REGPARAM2 picasso_FillRect (struct regstruct *regs)
{
uaecptr renderinfo = m68k_areg (regs, 1);
uae_u32 X = (uae_u16)m68k_dreg (regs, 0);
* d6: UBYTE Mask
* d7: uae_u32 RGBFormat
***********************************************************/
-uae_u32 picasso_BlitRect (void)
+uae_u32 REGPARAM2 picasso_BlitRect (struct regstruct *regs)
{
uaecptr renderinfo = m68k_areg (regs, 1);
unsigned long srcx = (uae_u16)m68k_dreg (regs, 0);
* because the RGBFormat or opcode aren't supported.
* OTHERWISE return 1
***********************************************************/
-uae_u32 picasso_BlitRectNoMaskComplete (void)
+uae_u32 REGPARAM2 picasso_BlitRectNoMaskComplete (struct regstruct *regs)
{
uaecptr srcri = m68k_areg (regs, 1);
uaecptr dstri = m68k_areg (regs, 2);
* always 16 pixels (one word) and the height is calculated as 2^Size. The data must be shifted up
* and to the left by XOffset and YOffset pixels at the beginning.
*/
-uae_u32 picasso_BlitPattern (void)
+uae_u32 REGPARAM2 picasso_BlitPattern (struct regstruct *regs)
{
uaecptr rinf = m68k_areg (regs, 1);
uaecptr pinf = m68k_areg (regs, 2);
* using a single plane of image data which will be expanded to the destination RGBFormat
* using ForeGround and BackGround pens as well as draw modes.
***********************************************************************************/
-uae_u32 picasso_BlitTemplate (void)
+uae_u32 REGPARAM2 picasso_BlitTemplate (struct regstruct *regs)
{
uae_u8 inversion = 0;
uaecptr rinf = m68k_areg (regs, 1);
* This function calculates the amount of bytes needed for a line of
* "Width" pixels in the given RGBFormat.
*/
-uae_u32 picasso_CalculateBytesPerRow (void)
+uae_u32 REGPARAM2 picasso_CalculateBytesPerRow (struct regstruct *regs)
{
uae_u16 width = m68k_dreg (regs, 0);
uae_u32 type = m68k_dreg (regs, 7);
*
* NOTE: return the opposite of the state
*/
-uae_u32 picasso_SetDisplay (void)
+uae_u32 REGPARAM2 picasso_SetDisplay (struct regstruct *regs)
{
uae_u32 state = m68k_dreg (regs, 0);
P96TRACE (("SetDisplay(%d)\n", state));
* on the board. Watch out for plane pointers that are 0x00000000 (represents a plane with all bits "0")
* or 0xffffffff (represents a plane with all bits "1").
*/
-uae_u32 picasso_BlitPlanar2Chunky (void)
+uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (struct regstruct *regs)
{
uaecptr bm = m68k_areg (regs, 1);
uaecptr ri = m68k_areg (regs, 2);
* triple bytes or longwords respectively similar to the color values used in FillRect(), BlitPattern() or
* BlitTemplate().
*/
-uae_u32 picasso_BlitPlanar2Direct (void)
+uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (struct regstruct *regs)
{
uaecptr bm = m68k_areg (regs, 1);
uaecptr ri = m68k_areg (regs, 2);
extern int GetNumResolutions( void );
extern int GetDisplayModeIndex( uae_u32 x, uae_u32 y, uae_u32 d);
-extern uae_u32 picasso_SetDisplay (void);
-extern uae_u32 picasso_CalculateBytesPerRow (void);
-extern uae_u32 picasso_FillRect (void);
-extern uae_u32 picasso_BlitRect (void);
-extern uae_u32 picasso_InvertRect (void);
-extern uae_u32 picasso_SetPanning (void);
-extern uae_u32 picasso_SetGC (void);
-extern uae_u32 picasso_SetDAC (void);
-extern uae_u32 picasso_SetColorArray (void);
-extern uae_u32 picasso_SetSwitch (void);
-extern uae_u32 picasso_SetSwitch (void);
-extern uae_u32 picasso_FindCard (void);
-extern uae_u32 picasso_InitCard (void);
-extern uae_u32 picasso_BlitPlanar2Chunky (void);
-extern uae_u32 picasso_BlitPlanar2Direct (void);
-extern uae_u32 picasso_BlitTemplate (void);
-extern uae_u32 picasso_BlitPattern (void);
-extern uae_u32 picasso_BlitRectNoMaskComplete (void);
-extern uae_u32 picasso_SetSprite (void);
-extern uae_u32 picasso_SetSpritePosition (void);
-extern uae_u32 picasso_SetSpriteImage (void);
-extern uae_u32 picasso_SetSpriteColor (void);
-extern uae_u32 picasso_DrawLine (void);
+
+extern uae_u32 REGPARAM3 picasso_SetDisplay (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_CalculateBytesPerRow (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_FillRect (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_BlitRect (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_InvertRect (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetPanning (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetGC (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetDAC (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetColorArray (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetSwitch (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetSwitch (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_FindCard (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_InitCard (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_BlitPlanar2Chunky (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_BlitPlanar2Direct (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_BlitTemplate (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_BlitPattern (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_BlitRectNoMaskComplete (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetSprite (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetSpritePosition (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetSpriteImage (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_SetSpriteColor (struct regstruct *regs);
+extern uae_u32 REGPARAM3 picasso_DrawLine (struct regstruct *regs);
+
extern uae_u32 gfxmem_mask;
extern uae_u8 *gfxmemory;
* Copyright 1997 Mathias Ortmann
*/
-#include "config.h"
#include "sysconfig.h"
#include "sysdeps.h"
#include <sys/timeb.h>
#include <sys/utime.h>
#include <process.h>
+
#include "options.h"
#include "posixemu.h"
#include "threaddep/thread.h"
#include "filesys.h"
/* Our Win32 implementation of this function */
-void gettimeofday( struct timeval *tv, void *blah )
+void gettimeofday (struct timeval *tv, void *blah)
{
#if 1
struct timeb time;
}
/* convert time_t to/from AmigaDOS time */
-#define secs_per_day ( 24 * 60 * 60 )
-#define diff ( (8 * 365 + 2) * secs_per_day )
+#define secs_per_day (24 * 60 * 60)
+#define diff ((8 * 365 + 2) * secs_per_day)
static void get_time(time_t t, long* days, long* mins, long* ticks)
{
FindClose(hFind);
- if (lpft) *lpft = fd.ftLastWriteTime;
- if (size) *size = fd.nFileSizeLow;
+ if (lpft)
+ *lpft = fd.ftLastWriteTime;
+ if (size)
+ *size = fd.nFileSizeLow;
return fd.dwFileAttributes;
}
return -1;
} else {
statbuf->st_mode = (attr & FILE_ATTRIBUTE_READONLY) ? FILEFLAG_READ : FILEFLAG_READ | FILEFLAG_WRITE;
- if (attr & FILE_ATTRIBUTE_ARCHIVE) statbuf->st_mode |= FILEFLAG_ARCHIVE;
- if (attr & FILE_ATTRIBUTE_DIRECTORY) statbuf->st_mode |= FILEFLAG_DIR;
+ if (attr & FILE_ATTRIBUTE_ARCHIVE)
+ statbuf->st_mode |= FILEFLAG_ARCHIVE;
+ if (attr & FILE_ATTRIBUTE_DIRECTORY)
+ statbuf->st_mode |= FILEFLAG_DIR;
FileTimeToLocalFileTime(&ft,&lft);
statbuf->st_mtime = (long)((*(__int64 *)&lft-((__int64)(369*365+89)*(__int64)(24*60*60)*(__int64)10000000))/(__int64)10000000);
}
int posixemu_chmod(const char *name, int mode)
{
DWORD attr = FILE_ATTRIBUTE_NORMAL;
- if (!(mode & FILEFLAG_WRITE)) attr |= FILE_ATTRIBUTE_READONLY;
- if (mode & FILEFLAG_ARCHIVE) attr |= FILE_ATTRIBUTE_ARCHIVE;
- if (SetFileAttributes(name,attr)) return 1;
+ if (!(mode & FILEFLAG_WRITE))
+ attr |= FILE_ATTRIBUTE_READONLY;
+ if (mode & FILEFLAG_ARCHIVE)
+ attr |= FILE_ATTRIBUTE_ARCHIVE;
+ if (SetFileAttributes(name,attr))
+ return 1;
return -1;
}
static void tmToSystemTime( struct tm *tmtime, LPSYSTEMTIME systime )
{
- if( tmtime == NULL )
- {
- GetSystemTime( systime );
- }
- else
- {
+ if (tmtime == NULL) {
+ GetSystemTime (systime);
+ } else {
systime->wDay = tmtime->tm_mday;
systime->wDayOfWeek = tmtime->tm_wday;
systime->wMonth = tmtime->tm_mon + 1;
}
get_time(actime, &days, &mins, &ticks);
- if( setfiletime( name, days, mins, ticks, tolocal ) )
+ if(setfiletime (name, days, mins, ticks, tolocal))
result = 0;
return result;
}
/* pthread Win32 emulation */
-void sem_init (HANDLE * event, int manual_reset, int initial_state)
+void uae_sem_init (uae_sem_t * event, int manual_reset, int initial_state)
{
- if( *event )
- {
- if( initial_state )
- {
- SetEvent( *event );
- }
+ if(*event) {
+ if (initial_state)
+ SetEvent(*event);
else
- {
- ResetEvent( *event );
- }
- }
- else
- {
- *event = CreateEvent (NULL, manual_reset, initial_state, NULL);
+ ResetEvent(*event);
+ } else {
+ *event = CreateEvent (NULL, manual_reset, initial_state, NULL);
}
}
-void sem_wait (HANDLE * event)
+void uae_sem_wait (uae_sem_t * event)
{
WaitForSingleObject (*event, INFINITE);
}
-void sem_post (HANDLE * event)
+void uae_sem_post (uae_sem_t * event)
{
SetEvent (*event);
}
-int sem_trywait (HANDLE * event)
+int uae_sem_trywait (uae_sem_t * event)
{
return WaitForSingleObject (*event, 0) == WAIT_OBJECT_0 ? 0 : -1;
}
-void sem_close (HANDLE * event)
+void uae_sem_destroy (uae_sem_t * event)
{
if( *event )
{
typedef unsigned (__stdcall *BEGINTHREADEX_FUNCPTR)(void *);
-int start_penguin (void *(*f)(void *), void *arg, DWORD *foo)
+int uae_start_thread (void *(*f)(void *), void *arg, uae_thread_id *tid)
{
HANDLE hThread;
int result = 1;
+ unsigned foo;
- hThread = (HANDLE)_beginthreadex( NULL, 0, (BEGINTHREADEX_FUNCPTR)f, arg, 0, foo );
+ hThread = (HANDLE)_beginthreadex(NULL, 0, (BEGINTHREADEX_FUNCPTR)f, arg, 0, &foo);
+ *tid = hThread;
if (hThread)
SetThreadPriority (hThread, THREAD_PRIORITY_ABOVE_NORMAL);
else
return result;
}
-void set_thread_priority (int pri)
+void uae_set_thread_priority (int pri)
{
+ /* workaround for filesystem emulation freeze with some dual core systems */
+ SetThreadAffinityMask(GetCurrentThread(), 1);
}
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,3,2,0
- PRODUCTVERSION 1,3,2,0
+ FILEVERSION 1,4,0,0
+ PRODUCTVERSION 1,4,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "WinUAE"
- VALUE "FileVersion", "1.3.2"
+ VALUE "FileVersion", "1.4.0"
VALUE "InternalName", "WinUAE"
VALUE "LegalCopyright", "© 1996-2006 under the GNU Public License (GPL)"
VALUE "OriginalFilename", "WinUAE.exe"
VALUE "ProductName", "WinUAE"
- VALUE "ProductVersion", "1.3.2"
+ VALUE "ProductVersion", "1.4.0"
END
END
BLOCK "VarFileInfo"
#include "sysdeps.h"
#include "options.h"
#include "custom.h"
-#include "picasso96.h"
#include "dxwrap.h"
#include "win32.h"
#include "win32gfx.h"
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
if (w & 0x8000) {
if (!warned) {
- write_log( "SERIAL: program uses 9bit mode PC=%x\n", m68k_getpc() );
+ write_log("SERIAL: program uses 9bit mode PC=%x\n", M68K_GETPC);
warned++;
}
ninebit = 1;
serial_period_hsyncs = 1;
serial_period_hsync_counter = 0;
- write_log ("SERIAL: period=%d, baud=%d, hsyncs=%d PC=%x\n", w, baud, serial_period_hsyncs, m68k_getpc());
+ write_log ("SERIAL: period=%d, baud=%d, hsyncs=%d PC=%x\n", w, baud, serial_period_hsyncs, M68K_GETPC);
if (ninebit)
baud *= 2;
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "events.h"
#include "gensound.h"
#include "sounddep/sound.h"
#include "threaddep/thread.h"
-#include "ahidsound.h"
#include "avioutput.h"
#include "gui.h"
#include "dxwrap.h"
#define FILTER_SOUND_TYPE_A1200 1
#define ISSTEREO(p) (p.sound_stereo == 1 || p.sound_stereo == 2)
-
-#ifdef AHI
-#include "ahidsound.h"
-#endif
del cpuemu_0.c
del cpuemu_5.c
del cpuemu_6.c
+del linetoscr.c
cd od-win32
+cd genlinetoscr_msvc
+rm -f genlinetoscr.exe
+rm -rf debug
+rm -rf release
+cd ..
+
cd build68k_msvc
-rm -f build68k.exe build68k_msvc.plg
+rm -f build68k.exe
rm -rf debug
rm -rf release
cd ..
cd genblitter_msvc
-rm -f genblitter.exe genblitter_msvc.plg
+rm -f genblitter.exe
rm -rf debug
rm -rf release
cd ..
cd gencomp_msvc
-rm -f gencomp.exe gencomp_msvc.plg
+rm -f gencomp.exe
rm -rf debug
rm -rf release
cd ..
cd gencpu_msvc
-rm -f gencpu.exe gencpu_msvc.plg
+rm -f gencpu.exe
rm -rf debug
rm -rf release
cd ..
+++ /dev/null
-_TEXT SEGMENT
-
-_stack_magic_amd64:
- mov rax, [rsp+16] ; move parameter 'pc' to a spare register
- mov rsp, r9 ; swap stack
- mov rsp, r9 ; swap stack
- call rax ; call function pointed to by 'pc'
-
- mov rax,rsp
- sub rax,2300*512
- ret
- ret
-
-END
key_t key;
size_t size;
void *addr;
- char name[ MAX_PATH ];
+ char name[MAX_PATH];
void *attached;
};
int shmctl (int shmid, int cmd, struct shmid_ds *buf);
void init_shm (void);
-int isinf( double x );
-int isnan( double x );
+int isinf(double x);
+int isnan(double x);
#define PROT_READ 0x01
#define PROT_WRITE 0x02
#define IPC_RMID 0x02
#define IPC_CREAT 0x04
#define IPC_STAT 0x08
-#endif
\ No newline at end of file
+
+#endif
#pragma warning (disable : 4761)
-#pragma warning (disable: 4996)
+#pragma warning (disable : 4996)
#define DIRECTINPUT_VERSION 0x0800
#define DIRECT3D_VERSION 0x0900
#define DRIVESOUND
#define GFXFILTER
-#define CAN_DO_STACK_MAGIC
#define X86_MSVC_ASSEMBLY
#ifndef UAE_MINI
#define UAE_FILESYS_THREADS
#define AUTOCONFIG /* autoconfig support, fast ram, harddrives etc.. */
#define JIT /* JIT compiler support */
-#undef USE_SDL
#define NATMEM_OFFSET natmem_offset
-#define CAN_DO_STACK_MAGIC
-#define USE_NORMAL_CALLING_CONVENTION 1
+#define USE_NORMAL_CALLING_CONVENTION 0
#define USE_X86_FPUCW 1
#define WINDDK /* Windows DDK available, keyboard leds and harddrive support */
#define CATWEASEL /* Catweasel MK2/3 support */
#define AGA /* AGA chipset emulation */
#define CD32 /* CD32 emulation */
#define CDTV /* CDTV emulation */
-#define D3D /* D3D display support */
-#define OPENGL /* OpenGL display support */
+#define D3D /* D3D display filter support */
+#define OPENGL /* OpenGL display filter support */
#define PARALLEL_PORT /* parallel port emulation */
#define PARALLEL_DIRECT /* direct parallel port emulation */
#define SERIAL_PORT /* serial port emulation */
#define PICASSO96 /* Picasso96 display card emulation */
#define BSDSOCKET /* bsdsocket.library emulation */
#define CAPS /* CAPS-image support */
-#define FDI2RAW /* FDI 1.0 and 2.0 image support */
+#define FDI2RAW /* FDI 1.0 and 2.x image support */
#define AVIOUTPUT /* Avioutput support */
#define PROWIZARD /* Pro-Wizard module ripper */
#define ARCADIA /* Arcadia arcade system */
#define ARCHIVEACCESS /* ArchiveAccess decompression library */
#define LOGITECHLCD /* Logitech G15 LCD */
+#define SAVESTATE /* State file support */
#else
#undef X86_MSVC_ASSEMBLY
#define X64_MSVC_ASSEMBLY
#define CPU_64_BIT
+#define SIZEOF_VOID_P 8
+#else
+#define SIZEOF_VOID_P 4
#endif
#if !defined(AHI)
-#if 1
-
typedef HANDLE uae_sem_t;
-typedef int uae_thread_id;
-extern void sem_close (void*);
-extern int sem_trywait (void*);
-extern void sem_post (void*);
-extern void sem_wait (void*t);
-extern void sem_init (void*, int manual_reset, int initial_state);
-extern int start_penguin (void *(*f)(void *), void *arg, DWORD * foo);
-extern void set_thread_priority (int);
+typedef HANDLE uae_thread_id;
-#define uae_sem_init sem_init
-#define uae_sem_destroy sem_close
-#define uae_sem_post sem_post
-#define uae_sem_wait sem_wait
-#define uae_sem_trywait sem_trywait
-#define uae_start_thread start_penguin
+extern void uae_sem_destroy (uae_sem_t*);
+extern int uae_sem_trywait (uae_sem_t*);
+extern void uae_sem_post (uae_sem_t*);
+extern void uae_sem_wait (uae_sem_t*t);
+extern void uae_sem_init (uae_sem_t*, int manual_reset, int initial_state);
+extern int uae_start_thread(void *(*f)(void *), void *arg, uae_thread_id *thread);
+extern void uae_set_thread_priority (int);
#include "commpipe.h"
-#else
-
-/*
- * UAE - The Un*x Amiga Emulator
- *
- * Threading support, using SDL
- *
- * Copyright 1997, 2001 Bernd Schmidt
- */
-
-#include "SDL.h"
-#include "SDL_thread.h"
-
-/* Sempahores. We use POSIX semaphores; if you are porting this to a machine
- * with different ones, make them look like POSIX semaphores. */
-typedef SDL_sem *uae_sem_t;
-
-#define uae_sem_init(PSEM, DUMMY, INIT) do { \
- *PSEM = SDL_CreateSemaphore (INIT); \
-} while (0)
-#define uae_sem_destroy(PSEM) SDL_DestroySemaphore (*PSEM)
-#define uae_sem_post(PSEM) SDL_SemPost (*PSEM)
-#define uae_sem_wait(PSEM) SDL_SemWait (*PSEM)
-#define uae_sem_trywait(PSEM) SDL_SemTryWait (*PSEM)
-#define uae_sem_getvalue(PSEM) SDL_SemValue (*PSEM)
-
-#include "commpipe.h"
-extern void set_thread_priority (int);
-
-typedef SDL_Thread *uae_thread_id;
-#define BAD_THREAD NULL
-
-static __inline__ int uae_start_thread (void *(*f) (void *), void *arg, uae_thread_id *foo)
+STATIC_INLINE uae_wait_thread(uae_thread_id *tid)
{
- *foo = SDL_CreateThread ((int (*)(void *))f, arg);
- return *foo == 0;
+ WaitForSingleObject(tid, INFINITE);
}
-
-/* Do nothing; thread exits if thread function returns. */
-#define UAE_THREAD_EXIT do {} while (0)
-
-#endif
\ No newline at end of file
/* Uncomment this line if you want the logs time-stamped */
/* #define TIMESTAMP_LOGS */
-#include "config.h"
#include "sysconfig.h"
#include <stdlib.h>
#include "memory.h"
#include "custom.h"
#include "events.h"
+#include "newcpu.h"
+#include "traps.h"
#include "xwin.h"
#include "keyboard.h"
#include "inputdevice.h"
#include "keybuf.h"
#include "drawing.h"
#include "dxwrap.h"
-#include "picasso96.h"
+#include "picasso96_win.h"
#include "bsdsocket.h"
#include "win32.h"
#include "win32gfx.h"
#include "resource.h"
#include "autoconf.h"
#include "gui.h"
-#include "newcpu.h"
#include "sys/mman.h"
#include "avioutput.h"
#include "ahidsound.h"
if ((p >= (void*)regs.pc_p && p < (void*)(regs.pc_p + 32))
|| (p >= (void*)prevpc && p < (void*)(prevpc + 32))) {
int got = 0;
- uaecptr opc = m68k_getpc();
+ uaecptr opc = m68k_getpc(®s);
void *ps = get_real_address (0);
m68k_dumpstate (0, 0);
efix (&ctx->Eax, p, ps, &got);
efix (&ctx->Edx, p, ps, &got);
efix (&ctx->Esi, p, ps, &got);
efix (&ctx->Edi, p, ps, &got);
- write_log ("Access violation! (68KPC=%08.8X HOSTADDR=%p)\n", m68k_getpc(), p);
+ write_log ("Access violation! (68KPC=%08.8X HOSTADDR=%p)\n", M68K_GETPC, p);
if (got == 0) {
write_log ("failed to find and fix the problem (%p). crashing..\n", p);
} else {
void *ppc = regs.pc_p;
- m68k_setpc (0);
+ m68k_setpc (®s, 0);
if (ppc != regs.pc_p) {
prevpc = (uae_u8*)ppc;
}
return m;
}
-uae_u8 *win32_stackbase;
-
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HANDLE thread;
DWORD_PTR oldaff;
- win32_stackbase = _alloca(32768 * 32);
-
thread = GetCurrentThread();
oldaff = SetThreadAffinityMask(thread, 1);
__try {
extern int manual_palette_refresh_needed;
extern int mouseactive, focus;
extern int ignore_messages_all;
-#define WINUAEBETA 0
-#define WINUAEBETASTR ""
+#define WINUAEBETA 1
+#define WINUAEBETASTR " Beta 1"
extern char start_path_exe[MAX_DPATH];
extern char start_path_data[MAX_DPATH];
#ifdef GFXFILTER
-#include "config.h"
#include "options.h"
#include "xwin.h"
#include "dxwrap.h"
* Copyright 1997-2000 Brian King
*/
-#include "config.h"
#include "sysconfig.h"
#include <stdlib.h>
#include "memory.h"
#include "custom.h"
#include "events.h"
+#include "newcpu.h"
+#include "traps.h"
#include "xwin.h"
#include "keyboard.h"
#include "drawing.h"
}
}
}
- alloc_colors64k (red_bits, green_bits, blue_bits, red_shift,green_shift, blue_shift, alpha_bits, alpha_shift, alpha);
+ alloc_colors64k (red_bits, green_bits, blue_bits, red_shift,green_shift, blue_shift, alpha_bits, alpha_shift, alpha, 0);
#ifdef GFXFILTER
S2X_configure (red_bits, green_bits, blue_bits, red_shift,green_shift, blue_shift);
#endif
#include <ddraw.h>
#include <shobjidl.h>
-#include "config.h"
#include "resource.h"
#include "sysconfig.h"
#include "sysdeps.h"
#include "custom.h"
#include "events.h"
#include "newcpu.h"
+#include "traps.h"
#include "disk.h"
#include "uae.h"
#include "threaddep/thread.h"
BOOL success = FALSE;
int n, snd;
- workprefs.genlock = IsDlgButtonChecked (hDlg, IDC_FASTCOPPER);
+ workprefs.genlock = IsDlgButtonChecked (hDlg, IDC_GENLOCK);
workprefs.immediate_blits = IsDlgButtonChecked (hDlg, IDC_BLITIMM);
n = IsDlgButtonChecked (hDlg, IDC_CYCLEEXACT) ? 1 : 0;
if (workprefs.cpu_cycle_exact != n) {
switch (LOWORD(wParam))
{
case IDC_RESETAMIGA:
- uae_reset (0);
+ uae_reset (1);
SendMessage (hDlg, WM_COMMAND, IDOK, 0);
return TRUE;
case IDC_QUITEMU:
RelativePath="..\sounddep\sound.c"
>
</File>
- <File
- RelativePath="..\support.c"
- >
- </File>
<File
RelativePath="..\win32.c"
>
RelativePath="..\..\scsiemul.c"
>
</File>
+ <File
+ RelativePath="..\..\traps.c"
+ >
+ </File>
<File
RelativePath="..\..\uaeexe.c"
>
{ i_ILLG, "" },
};
-struct instr *table68k = 0;
+struct instr *table68k;
static int specialcase (uae_u16 opcode, int cpu_lev)
{
return 0;
}
-static amodes mode_from_mr (int mode, int reg)
+STATIC_INLINE amodes mode_from_mr (int mode, int reg)
{
switch (mode) {
case 0: return Dreg;
endofline:
/* now, we have a match */
if (table68k[opc].mnemo != i_ILLG)
- printf ("Double match: %x: %s\n", opc, opcstr);
+ ;//write_log ("Double match: %x: %s\n", opc, opcstr);
if (find == -1) {
for (find = 0;; find++) {
if (strcmp(mnemonic, lookuptab[find].name) == 0) {
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "memory.h"
#include "zfile.h"
/* read and write IFF-style hunks */
-static void save_chunk (struct zfile *f, uae_u8 *chunk, long len, char *name, int compress)
+static void save_chunk (struct zfile *f, uae_u8 *chunk, size_t len, char *name, int compress)
{
uae_u8 tmp[8], *dst;
uae_u8 zero[4]= { 0, 0, 0, 0 };
uae_u32 flags;
size_t pos;
- long chunklen, len2;
+ size_t chunklen, len2;
if (!chunk)
return;
write_log ("Chunk '%s' chunk size %d (%d)\n", name, chunklen, len);
}
-static uae_u8 *restore_chunk (struct zfile *f, char *name, long *len, long *totallen, long *filepos)
+static uae_u8 *restore_chunk (struct zfile *f, char *name, size_t *len, size_t *totallen, size_t *filepos)
{
uae_u8 tmp[4], dummy[4], *mem, *src;
uae_u32 flags;
- long len2;
+ size_t len2;
*totallen = 0;
/* chunk name */
return mem;
}
-void restore_ram (long filepos, uae_u8 *memory)
+void restore_ram (size_t filepos, uae_u8 *memory)
{
uae_u8 tmp[8];
uae_u8 *src = tmp;
struct zfile *f;
uae_u8 *chunk,*end;
char name[5];
- long len, totallen;
- long filepos;
+ size_t len, totallen;
+ size_t filepos;
chunk = 0;
f = zfile_fopen (filename, "rb");
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
-#include "threaddep/thread.h"
-#include "options.h"
-#include "memory.h"
-#include "custom.h"
-#include "newcpu.h"
-#include "disk.h"
-#include "autoconf.h"
-#include "filesys.h"
-#include "execlib.h"
#include "scsidev.h"
uaecptr scsidev_startup (uaecptr resaddr) { return resaddr; }
void scsidev_install (void) {}
void scsidev_reset (void) {}
void scsidev_start_threads (void) {}
-
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "uae.h"
#include "threaddep/thread.h"
#include "options.h"
#include "events.h"
#include "newcpu.h"
#include "autoconf.h"
+#include "traps.h"
#include "execlib.h"
#include "native2amiga.h"
#include "blkdev.h"
}
}
-static uae_u32 dev_close_2 (void)
+static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context)
{
- uae_u32 request = m68k_areg (regs, 1);
+ uae_u32 request = m68k_areg (&context->regs, 1);
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
return 0;
dev_close_3 (dev, pdev);
put_long (request + 24, 0);
- put_word (m68k_areg(regs, 6) + 32, get_word (m68k_areg(regs, 6) + 32) - 1);
+ put_word (m68k_areg(&context->regs, 6) + 32, get_word (m68k_areg(&context->regs, 6) + 32) - 1);
return 0;
}
-static uae_u32 dev_close (void)
+static uae_u32 REGPARAM2 dev_close (TrapContext *context)
{
- return dev_close_2 ();
+ return dev_close_2 (context);
}
-static uae_u32 diskdev_close (void)
+static uae_u32 REGPARAM2 diskdev_close (TrapContext *context)
{
- return dev_close_2 ();
+ return dev_close_2 (context);
}
static int openfail (uaecptr ioreq, int error)
return (uae_u32)-1;
}
-static uae_u32 dev_open_2 (int type)
+static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context, int type)
{
- uaecptr ioreq = m68k_areg(regs, 1);
- uae_u32 unit = m68k_dreg (regs, 0);
- uae_u32 flags = m68k_dreg (regs, 1);
+ uaecptr ioreq = m68k_areg (&context->regs, 1);
+ uae_u32 unit = m68k_dreg (&context->regs, 0);
+ uae_u32 flags = m68k_dreg (&context->regs, 1);
struct devstruct *dev = getdevstruct (unit);
struct priv_devstruct *pdev = 0;
int i;
}
dev->opencnt++;
- put_word (m68k_areg(regs, 6) + 32, get_word (m68k_areg(regs, 6) + 32) + 1);
+ put_word (m68k_areg(&context->regs, 6) + 32, get_word (m68k_areg(&context->regs, 6) + 32) + 1);
put_byte (ioreq + 31, 0);
put_byte (ioreq + 8, 7);
return 0;
}
-static uae_u32 dev_open (void)
+static uae_u32 REGPARAM2 dev_open (TrapContext *context)
{
- return dev_open_2 (UAEDEV_SCSI_ID);
+ return dev_open_2 (context, UAEDEV_SCSI_ID);
}
-static uae_u32 diskdev_open (void)
+static uae_u32 REGPARAM2 diskdev_open (TrapContext *context)
{
- return dev_open_2 (UAEDEV_DISK_ID);
+ return dev_open_2 (context, UAEDEV_DISK_ID);
}
-static uae_u32 dev_expunge (void)
+static uae_u32 REGPARAM2 dev_expunge (TrapContext *context)
{
return 0;
}
-static uae_u32 diskdev_expunge (void)
+static uae_u32 REGPARAM2 diskdev_expunge (TrapContext *context)
{
return 0;
}
return dev_can_quick (command);
}
-static uae_u32 dev_beginio (void)
+static uae_u32 REGPARAM2 dev_beginio (TrapContext *context)
{
- uae_u32 request = m68k_areg(regs, 1);
+ uae_u32 request = m68k_areg (&context->regs, 1);
uae_u8 flags = get_byte (request + 30);
int command = get_word (request + 28);
struct priv_devstruct *pdev = getpdevstruct (request);
{
struct devstruct *dev = devs;
- set_thread_priority (2);
+ uae_set_thread_priority (2);
dev->thread_running = 1;
uae_sem_post (&dev->sync_sem);
for (;;) {
return 0;
}
-static uae_u32 dev_init_2 (int type)
+static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context, int type)
{
- uae_u32 base = m68k_dreg (regs,0);
+ uae_u32 base = m68k_dreg (&context->regs,0);
if (log_scsi)
write_log ("%s init\n", getdevname (type));
return base;
}
-static uae_u32 dev_init (void)
+static uae_u32 REGPARAM2 dev_init (TrapContext *context)
{
- return dev_init_2 (UAEDEV_SCSI_ID);
+ return dev_init_2 (context, UAEDEV_SCSI_ID);
}
-static uae_u32 diskdev_init (void)
+static uae_u32 REGPARAM2 diskdev_init (TrapContext *context)
{
- return dev_init_2 (UAEDEV_DISK_ID);
+ return dev_init_2 (context, UAEDEV_DISK_ID);
}
-static uae_u32 dev_abortio (void)
+static uae_u32 REGPARAM2 dev_abortio (TrapContext *context)
{
- uae_u32 request = m68k_areg(regs, 1);
+ uae_u32 request = m68k_areg (&context->regs, 1);
struct priv_devstruct *pdev = getpdevstruct (request);
struct devstruct *dev;
/* initcode */
initcode = here ();
- calltrap (deftrap (dev_init)); dw (RTS);
+ calltrap (deftrap (diskdev_init)); dw (RTS);
/* Open */
openfunc = here ();
- calltrap (deftrap (dev_open)); dw (RTS);
+ calltrap (deftrap (diskdev_open)); dw (RTS);
/* Close */
closefunc = here ();
- calltrap (deftrap (dev_close)); dw (RTS);
+ calltrap (deftrap (diskdev_close)); dw (RTS);
/* Expunge */
expungefunc = here ();
- calltrap (deftrap (dev_expunge)); dw (RTS);
+ calltrap (deftrap (diskdev_expunge)); dw (RTS);
/* BeginIO */
beginiofunc = here ();
--- /dev/null
+ /*
+ * E-UAE - The portable Amiga Emulator
+ *
+ * Support for traps
+ *
+ * Copyright Richard Drummond 2005
+ *
+ * Inspired by code from UAE:
+ * Copyright 1995, 1996 Bernd Schmidt
+ * Copyright 1996 Ed Hanway
+ */
+
+#include "sysconfig.h"
+#include "sysdeps.h"
+
+#include "options.h"
+#include "memory.h"
+#include "custom.h"
+#include "newcpu.h"
+#include "threaddep/thread.h"
+#include "autoconf.h"
+#include "traps.h"
+
+/*
+ * Traps are the mechanism via which 68k code can call emulator code
+ * (and for that emulator code in turn to call 68k code). They are
+ * thus the basis for much of the cool stuff that E-UAE can do.
+ *
+ * Emulator traps take advantage of the illegal 68k opwords 0xA000 to
+ * 0xAFFF. Normally these would generate an A-line exception. However,
+ * when encountered in the RTAREA section of memory, these opwords
+ * instead invoke a corresponding emulator trap, allowing a host
+ * function to be called.
+ *
+ * Two types of emulator trap are available - a simple trap and an
+ * extended trap. A simple trap may not call 68k code; an extended
+ * trap can.
+ *
+ * Extended traps are rather complex beasts (to implement, not
+ * necessarily to use). This is because for the trap handler function
+ * to be able to call 68k code, we must somehow allow the emulator's
+ * 68k interpreter to resume execution of 68k code in the middle of
+ * the trap handler function.
+ *
+ * In UAE of old this used to be implemented via a stack-swap mechanism.
+ * While this worked, it was definitely in the realm of black magic and
+ * horribly non-portable, requiring assembly language glue specific to
+ * the host ABI and compiler to actually perform the swap.
+ *
+ * In this implementation, in essence we do something similar - but the
+ * new stack is provided by a new thread. No voodoo required, just a
+ * working thread layer.
+ *
+ * The complexity in this approach arises in synchronizing the trap
+ * threads with the emulator thread. This implementation errs on the side
+ * of paranoia when it comes to thread synchronization. Once all the
+ * bugs are knocked out of the bsdsocket emulation, a simpler scheme may
+ * suffice.
+ */
+
+/*
+ * Record of a defined trap (that is, a trap allocated to a host function)
+ */
+struct Trap
+{
+ TrapHandler handler; /* Handler function to be invoked for this trap. */
+ int flags; /* Trap attributes. */
+ const char *name; /* For debugging purposes. */
+};
+
+#define MAX_TRAPS 4096
+
+/* Defined traps */
+static struct Trap traps[MAX_TRAPS];
+static unsigned int trap_count;
+
+
+static const int trace_traps = 1;
+
+
+static void trap_HandleExtendedTrap (TrapHandler, int has_retval);
+
+/*
+ * Define an emulator trap
+ *
+ * handler_func = host function that will be invoked to handle this trap
+ * flags = trap attributes
+ * name = name for debugging purposes
+ *
+ * returns trap number of defined trap
+ */
+unsigned int define_trap (TrapHandler handler_func, int flags, const char *name)
+{
+ if (trap_count == MAX_TRAPS) {
+ write_log ("Ran out of emulator traps\n");
+ abort ();
+ return 0;
+ } else {
+ unsigned int trap_num = trap_count++;
+ struct Trap *trap = &traps[trap_num];
+
+ trap->handler = handler_func;
+ trap->flags = flags;
+ trap->name = name;
+
+ return trap_num;
+ }
+}
+
+
+/*
+ * This function is called by the 68k interpreter to handle an emulator trap.
+ *
+ * trap_num = number of trap to invoke
+ * regs = current 68k state
+ */
+void REGPARAM2 m68k_handle_trap (unsigned int trap_num, struct regstruct *regs)
+{
+ struct Trap *trap = &traps[trap_num];
+ uae_u32 retval = 0;
+
+ int has_retval = (trap->flags & TRAPFLAG_NO_RETVAL) == 0;
+ int implicit_rts = (trap->flags & TRAPFLAG_DORET) != 0;
+
+ if (trap->name && trap->name[0] != 0 && trace_traps)
+ write_log ("TRAP: %s\n", trap->name);
+
+ if (trap_num < trap_count) {
+
+ if (trap->flags & TRAPFLAG_EXTRA_STACK) {
+ /* Handle an extended trap.
+ * Note: the return value of this trap is passed back to 68k
+ * space via a separate, dedicated simple trap which the trap
+ * handler causes to be invoked when it is done.
+ */
+ trap_HandleExtendedTrap (trap->handler, has_retval);
+ } else {
+ /* Handle simple trap */
+ retval = (trap->handler) ((TrapContext *)regs);
+
+ if (has_retval)
+ m68k_dreg (regs, 0) = retval;
+
+ if (implicit_rts) {
+ m68k_do_rts (regs);
+ fill_prefetch_slow (regs);
+ }
+ }
+
+ } else
+ write_log ("Illegal emulator trap %d\n", trap_num);
+}
+
+
+
+/*
+ * Implementation of extended traps
+ */
+
+typedef struct ExtendedTrapContext
+{
+ /*
+ * Same as simple trap
+ */
+ struct regstruct regs; /* Trap's working copy of 68k state. This is what
+ * the trap handler should access to get arguments
+ * from 68k space. */
+
+ /*
+ * Extended trap only
+ */
+ TrapHandler trap_handler; /* Trap handler function that gets called on the trap context */
+ int trap_has_retval; /* Should the handler return a value to 68k space in D0? */
+ uae_u32 trap_retval; /* Return value from trap handler */
+
+
+ struct regstruct saved_regs; /* Copy of 68k state at trap entry. */
+
+
+ uae_thread_id thread; /* Thread which effects the trap context. */
+ uae_sem_t switch_to_emu_sem; /* For IPC between the main emulator. */
+ uae_sem_t switch_to_trap_sem; /* context and the trap context. */
+
+
+ uaecptr call68k_func_addr; /* When calling a 68k function from a trap handler, this
+ * is set to the address of the function to call. */
+ uae_u32 call68k_retval; /* And this gets set to the return value of the 68k call */
+} ExtendedTrapContext;
+
+
+/* 68k addresses which invoke the corresponding traps. */
+static uaecptr m68k_call_trapaddr;
+static uaecptr m68k_return_trapaddr;
+static uaecptr exit_trap_trapaddr;
+
+/* For IPC between main thread and trap context */
+static uae_sem_t trap_mutex;
+static ExtendedTrapContext *current_context;
+
+
+/*
+ * Thread body for trap context
+ */
+static void *trap_thread (void *arg)
+{
+ ExtendedTrapContext *context = (ExtendedTrapContext *) arg;
+
+ uae_set_thread_priority (2);
+
+ /* Wait until main thread is ready to switch to the
+ * this trap context. */
+ uae_sem_wait (&context->switch_to_trap_sem);
+
+ /* Execute trap handler function. */
+ context->trap_retval = context->trap_handler ((TrapContext *)context);
+
+ /* Trap handler is done - we still need to tidy up
+ * and make sure the handler's return value is propagated
+ * to the calling 68k thread.
+ *
+ * We do this by causing our exit handler to be executed on the 68k context.
+ */
+
+ /* Enter critical section - only one trap at a time, please! */
+ uae_sem_wait (&trap_mutex);
+
+ /* Don't allow an interrupt and thus potentially another
+ * trap to be invoked while we hold the above mutex.
+ * This is probably just being paranoid. */
+ context->regs.intmask = 7;
+
+ /* Set PC to address of the exit handler, so that it will be called
+ * when the 68k context resumes. */
+ m68k_setpc (&context->regs, exit_trap_trapaddr);
+ current_context = context;
+
+ /* Switch back to 68k context */
+ uae_sem_post (&context->switch_to_emu_sem);
+
+ /* Good bye, cruel world... */
+
+ /* dummy return value */
+ return 0;
+}
+
+/*
+ * Set up extended trap context and call handler function
+ */
+static void trap_HandleExtendedTrap (TrapHandler handler_func, int has_retval)
+{
+ struct ExtendedTrapContext *context = calloc (1, sizeof (ExtendedTrapContext));
+
+ if (context) {
+ uae_sem_init (&context->switch_to_trap_sem, 0, 0);
+ uae_sem_init (&context->switch_to_emu_sem, 0, 0);
+
+ context->trap_handler = handler_func;
+ context->trap_has_retval = has_retval;
+
+ context->regs = regs; /* Working copy of regs */
+
+ context->saved_regs = regs; /* Copy of regs to be restored when trap is done */
+
+ /* Start thread to handle new trap context. */
+ uae_start_thread (trap_thread, (void *)context, &context->thread);
+
+ /* Switch to trap context to begin execution of
+ * trap handler function.
+ */
+ uae_sem_post (&context->switch_to_trap_sem);
+
+ /* Wait for trap context to switch back to us.
+ *
+ * It'll do this when the trap handler is done - or when
+ * the handler wants to call 68k code. */
+ uae_sem_wait (&context->switch_to_emu_sem);
+
+ /* Use trap's modified 68k state. This will reset the PC, so that
+ * execution will resume at either the m68k call handler or the
+ * the exit handler. */
+ regs = context->regs;
+ }
+}
+
+/*
+ * Call m68k function from an extended trap handler
+ *
+ * This function is to be called from the trap context.
+ */
+static uae_u32 trap_Call68k (ExtendedTrapContext *context, uaecptr func_addr)
+{
+ /* Enter critical section - only one trap at a time, please! */
+ uae_sem_wait (&trap_mutex);
+ current_context = context;
+
+ /* Don't allow an interrupt and thus potentially another
+ * trap to be invoked while we hold the above mutex.
+ * This is probably just being paranoid. */
+ context->regs.intmask = 7;
+
+ /* Set up function call address. */
+ context->call68k_func_addr = func_addr;
+
+ /* Set PC to address of 68k call trap, so that it will be
+ * executed when emulator context resumes. */
+ m68k_setpc (&context->regs, m68k_call_trapaddr);
+ fill_prefetch_slow (&context->regs);
+
+ /* Switch to emulator context. */
+ uae_sem_post (&context->switch_to_emu_sem);
+
+ /* Wait for 68k call return handler to switch back to us. */
+ uae_sem_wait (&context->switch_to_trap_sem);
+
+ /* End critical section. */
+ uae_sem_post (&trap_mutex);
+
+ /* Get return value from 68k function called. */
+ return context->call68k_retval;
+}
+
+/*
+ * Handles the emulator's side of a 68k call (from an extended trap)
+ */
+static uae_u32 REGPARAM2 m68k_call_handler (struct regstruct *regs)
+{
+ ExtendedTrapContext *context = current_context;
+
+ uae_u32 sp = m68k_areg (regs, 7);
+
+ /* Push address of trap context on 68k stack. This is
+ * so the return trap can find this context. */
+ sp -= sizeof (void *);
+ put_pointer (sp, context);
+
+ /* Push addr to return handler trap on 68k stack.
+ * When the called m68k function does an RTS, the CPU will pull this
+ * address off the stack and so call the return handler. */
+ sp -= 4;
+ put_long (sp, m68k_return_trapaddr);
+
+ m68k_areg (regs, 7) = sp;
+
+ /* Set PC to address of 68k function to call. */
+ m68k_setpc (regs, context->call68k_func_addr);
+ fill_prefetch_slow (&context->regs);
+
+ /* End critical section: allow other traps run. */
+ uae_sem_post (&trap_mutex);
+
+ /* Restore interrupts. */
+ regs->intmask = context->saved_regs.intmask;
+
+ /* Dummy return value. */
+ return 0;
+}
+
+/*
+ * Handles the return from a 68k call at the emulator's side.
+ */
+static uae_u32 REGPARAM2 m68k_return_handler (struct regstruct *regs)
+{
+ ExtendedTrapContext *context;
+ uae_u32 sp;
+
+ /* One trap returning at a time, please! */
+ uae_sem_wait (&trap_mutex);
+
+ /* Get trap context from 68k stack. */
+ sp = m68k_areg (regs, 7);
+ context = get_pointer(sp);
+ sp += sizeof (void *);
+ m68k_areg (regs, 7) = sp;
+
+ /* Get return value from the 68k call. */
+ context->call68k_retval = m68k_dreg (regs, 0);
+
+ /* Update trap's working copy of CPU state. */
+ context->regs = *regs;
+
+ /* Switch back to trap context. */
+ uae_sem_post (&context->switch_to_trap_sem);
+
+ /* Wait for trap context to switch back to us.
+ *
+ * It'll do this when the trap handler is done - or when
+ * the handler wants to call another 68k function. */
+ uae_sem_wait (&context->switch_to_emu_sem);
+
+ /* Use trap's modified 68k state. This will reset the PC, so that
+ * execution will resume at either the m68k call handler or the
+ * the exit handler. */
+ *regs = context->regs;
+
+ /* Dummy return value. */
+ return 0;
+}
+
+/*
+ * Handles completion of an extended trap and passes
+ * return value from trap function to 68k space.
+ */
+static uae_u32 REGPARAM2 exit_trap_handler (struct regstruct *regs)
+{
+ ExtendedTrapContext *context = current_context;
+
+ /* Wait for trap context thread to exit. */
+ uae_wait_thread (context->thread);
+
+ /* Restore 68k state saved at trap entry. */
+ *regs = context->saved_regs;
+
+ /* If trap is supposed to return a value, then store
+ * return value in D0. */
+ if (context->trap_has_retval)
+ m68k_dreg (regs, 0) = context->trap_retval;
+
+ uae_sem_destroy (&context->switch_to_trap_sem);
+ uae_sem_destroy (&context->switch_to_emu_sem);
+
+ free (context);
+
+ /* End critical section */
+ uae_sem_post (&trap_mutex);
+
+ /* Dummy return value. */
+ return 0;
+}
+
+
+
+/*
+ * Call a 68k library function from extended trap.
+ */
+uae_u32 CallLib (TrapContext *context, uaecptr base, uae_s16 offset)
+{
+ uae_u32 retval;
+ uaecptr olda6 = m68k_areg (&context->regs, 6);
+
+ m68k_areg (&context->regs, 6) = base;
+ retval = trap_Call68k ((ExtendedTrapContext *)context, base + offset);
+ m68k_areg (&context->regs, 6) = olda6;
+
+ return retval;
+}
+
+
+/*
+ * Initialize trap mechanism.
+ */
+void init_traps (void)
+{
+ trap_count = 0;
+}
+
+/*
+ * Initialize the extended trap mechanism.
+ */
+void init_extended_traps (void)
+{
+ m68k_call_trapaddr = here ();
+ calltrap (deftrap2 ((TrapHandler)m68k_call_handler, TRAPFLAG_NO_RETVAL, "m68k_call"));
+
+ m68k_return_trapaddr = here();
+ calltrap (deftrap2 ((TrapHandler)m68k_return_handler, TRAPFLAG_NO_RETVAL, "m68k_return"));
+
+ exit_trap_trapaddr = here();
+ calltrap (deftrap2 ((TrapHandler)exit_trap_handler, TRAPFLAG_NO_RETVAL, "exit_trap"));
+
+ uae_sem_init (&trap_mutex, 0, 1);
+}
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
#include "autoconf.h"
+#include "traps.h"
#include "uaeexe.h"
static struct uae_xcmd *first = NULL;
static struct uae_xcmd *last = NULL;
static char running = 0;
-static uae_u32 uaeexe_server(void);
+static uae_u32 REGPARAM3 uaeexe_server (TrapContext *context) REGPARAM;
/*
* Install the server
* to launch the command asynchronously. Please note also that the
* remote cli works better if you've got the fifo-handler installed.
*/
-int uaeexe(char *cmd)
+int uaeexe(const char *cmd)
{
struct uae_xcmd *nw;
if (!running)
goto NORUN;
- nw = (struct uae_xcmd *)malloc (sizeof *nw);
+ nw = malloc (sizeof *nw);
if (!nw)
goto NOMEM;
- nw->cmd = (char *)malloc (strlen (cmd) + 1);
+ nw->cmd = malloc (strlen (cmd) + 1);
if (!nw->cmd) {
free (nw);
goto NOMEM;
nw->prev = last;
nw->next = NULL;
- if(!first) first = nw;
+ if(!first)
+ first = nw;
if(last) {
- last->next = nw;
- last = nw;
- } else last = nw;
+ last->next = nw;
+ last = nw;
+ } else
+ last = nw;
return UAEEXE_OK;
NOMEM:
struct uae_xcmd *cmd;
char *s;
- if(!first) return NULL;
+ if(!first)
+ return NULL;
s = first->cmd;
- cmd = first; first = first->next;
- if(!first) last = NULL;
+ cmd = first;
+ first = first->next;
+ if(!first)
+ last = NULL;
free(cmd);
return s;
}
/*
* helper function
*/
-#define ARG(x) (get_long (m68k_areg (regs, 7) + 4*(x+1)))
-static uae_u32 uaeexe_server(void)
+#define ARG(x) (get_long (m68k_areg (&context->regs, 7) + 4*(x+1)))
+static uae_u32 REGPARAM2 uaeexe_server (TrapContext *context)
{
int len;
char *cmd;
write_log("Remote CLI started.\n");
}
- cmd = get_cmd(); if(!cmd) return 0;
- if(!ARG(0)) {running = 0;return 0;}
+ cmd = get_cmd();
+ if(!cmd)
+ return 0;
+ if(!ARG(0)) {
+ running = 0;
+ return 0;
+ }
dst = (char *)get_real_address(ARG(0));
len = ARG(1);
strncpy(dst,cmd,len);
- printf("Sending '%s' to remote cli\n",cmd); /**/
+ write_log ("Sending '%s' to remote cli\n",cmd);
free(cmd);
return ARG(0);
}
-
-
-#include "config.h"
#include "sysconfig.h"
#include <stdlib.h>
return olevent;
}
-static int isout;
-static char outmsg[IPC_BUFFER_SIZE];
+#define MAX_OUTMESSAGES 30
+static char *outmsg[MAX_OUTMESSAGES];
+static int outmessages;
int sendIPC(char *msg)
{
if (hipc == INVALID_HANDLE_VALUE)
return 0;
- if (isout)
+ if (outmessages >= MAX_OUTMESSAGES)
return 0;
- strcpy (outmsg, msg);
+ outmsg[outmessages++] = my_strdup (msg);
if (!readpending && !writepending)
SetEvent (olevent);
return 1;
return 0;
if (WaitForSingleObject(olevent, 0) != WAIT_OBJECT_0)
return 0;
- if (!readpending && !writepending && isout) {
- isout = 0;
+ if (!readpending && !writepending && outmessages > 0) {
memset (&ol, 0, sizeof ol);
ol.hEvent = olevent;
- ok = WriteFile(hipc, outmsg, strlen (outmsg) + 1, &ret, &ol);
+ ok = WriteFile(hipc, outmsg[outmessages], strlen (outmsg[outmessages]) + 1, &ret, &ol);
+ xfree(outmsg[outmessages--]);
err = GetLastError();
if (!ok && err != ERROR_IO_PENDING) {
write_log ("IPC: WriteFile() err=%d\n", err);
#include <assert.h>
#include <string.h>
-#include "config.h"
#include "options.h"
-#include "threaddep/thread.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
#include "xwin.h"
#include "autoconf.h"
+#include "traps.h"
#include "disk.h"
#include "debug.h"
#include "gensound.h"
* Changes chip memory size
* (reboots)
*/
-static uae_u32 emulib_ChgCMemSize (uae_u32 memsize)
+static uae_u32 REGPARAM2 emulib_ChgCMemSize (struct regstruct *regs, uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x200000) {
memsize = 0x200000;
write_log ("Unsupported chipmem size!\n");
}
- m68k_dreg(regs, 0) = 0;
+ m68k_dreg (regs, 0) = 0;
currprefs.chipmem_size = memsize;
uae_reset(0);
* Changes slow memory size
* (reboots)
*/
-static uae_u32 emulib_ChgSMemSize (uae_u32 memsize)
+static uae_u32 REGPARAM2 emulib_ChgSMemSize (struct regstruct *regs, uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x180000 && memsize != 0x1C0000) {
write_log ("Unsupported bogomem size!\n");
}
- m68k_dreg(regs, 0) = 0;
+ m68k_dreg (regs, 0) = 0;
currprefs.bogomem_size = memsize;
uae_reset (0);
return 1;
* Changes fast memory size
* (reboots)
*/
-static uae_u32 emulib_ChgFMemSize (uae_u32 memsize)
+static uae_u32 REGPARAM2 emulib_ChgFMemSize (struct regstruct *regs, uae_u32 memsize)
{
if (memsize != 0x100000 && memsize != 0x200000 &&
memsize != 0x400000 && memsize != 0x800000) {
memsize = 0;
write_log ("Unsupported fastmem size!\n");
}
- m68k_dreg(regs, 0) = 0;
+ m68k_dreg (regs, 0) = 0;
currprefs.fastmem_size = memsize;
uae_reset (0);
return 0;
*/
static uae_u32 emulib_Debug (void)
{
+#ifdef DEBUGGER
activate_debugger ();
return 1;
+#else
+ return 0;
+#endif
}
/* We simply find the first "text" hunk, get the offset of its actual code segment (20 bytes away)
return 0;
}
-#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
+#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32)
-#define SET_NATIVE_FUNC(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32))(x)
-#define CALL_NATIVE_FUNC( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) if(native_func) native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 )
+#define SET_NATIVE_FUNC(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32))(x)
+#define CALL_NATIVE_FUNC( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) if(native_func) native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 )
/* A0 - Contains a ptr to the native .obj data. This ptr is Amiga-based. */
-/* We simply find the first function in this .obj data, and execute it. */
-static uae_u32 emulib_ExecuteNativeCode (void)
+/* We simply find the first function in this .obj data, and execute it. */
+static uae_u32 REGPARAM2 emulib_ExecuteNativeCode (struct regstruct *regs)
{
#if 0
- uaecptr object_AAM = m68k_areg( regs, 0 );
- uae_u32 d1 = m68k_dreg( regs, 1 );
- uae_u32 d2 = m68k_dreg( regs, 2 );
- uae_u32 d3 = m68k_dreg( regs, 3 );
- uae_u32 d4 = m68k_dreg( regs, 4 );
- uae_u32 d5 = m68k_dreg( regs, 5 );
- uae_u32 d6 = m68k_dreg( regs, 6 );
- uae_u32 d7 = m68k_dreg( regs, 7 );
- uae_u32 a1 = m68k_areg( regs, 1 );
- uae_u32 a2 = m68k_areg( regs, 2 );
- uae_u32 a3 = m68k_areg( regs, 3 );
- uae_u32 a4 = m68k_areg( regs, 4 );
- uae_u32 a5 = m68k_areg( regs, 5 );
- uae_u32 a6 = m68k_areg( regs, 6 );
+ uaecptr object_AAM = m68k_areg (regs, 0);
+ uae_u32 d1 = m68k_dreg (regs, 1);
+ uae_u32 d2 = m68k_dreg (regs, 2);
+ uae_u32 d3 = m68k_dreg (regs, 3);
+ uae_u32 d4 = m68k_dreg (regs, 4);
+ uae_u32 d5 = m68k_dreg (regs, 5);
+ uae_u32 d6 = m68k_dreg (regs, 6);
+ uae_u32 d7 = m68k_dreg (regs, 7);
+ uae_u32 a1 = m68k_areg (regs, 1);
+ uae_u32 a2 = m68k_areg (regs, 2);
+ uae_u32 a3 = m68k_areg (regs, 3);
+ uae_u32 a4 = m68k_areg (regs, 4);
+ uae_u32 a5 = m68k_areg (regs, 5);
+ uae_u32 a6 = m68k_areg (regs, 6);
uae_u8* object_UAM = NULL;
CREATE_NATIVE_FUNC_PTR;
static uae_u32 emulib_Minimize (void)
{
- return OSDEP_minimize_uae();
+ return 0; // OSDEP_minimize_uae();
}
-static uae_u32 uaelib_demux (void)
+static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context)
{
-#define ARG0 (get_long (m68k_areg (regs, 7) + 4))
-#define ARG1 (get_long (m68k_areg (regs, 7) + 8))
-#define ARG2 (get_long (m68k_areg (regs, 7) + 12))
-#define ARG3 (get_long (m68k_areg (regs, 7) + 16))
-#define ARG4 (get_long (m68k_areg (regs, 7) + 20))
-#define ARG5 (get_long (m68k_areg (regs, 7) + 24))
+#define ARG0 (get_long (m68k_areg (&context->regs, 7) + 4))
+#define ARG1 (get_long (m68k_areg (&context->regs, 7) + 8))
+#define ARG2 (get_long (m68k_areg (&context->regs, 7) + 12))
+#define ARG3 (get_long (m68k_areg (&context->regs, 7) + 16))
+#define ARG4 (get_long (m68k_areg (&context->regs, 7) + 20))
+#define ARG5 (get_long (m68k_areg (&context->regs, 7) + 24))
switch (ARG0) {
case 0: return emulib_GetVersion ();
case 6: return emulib_EnableSound (ARG1);
case 7: return emulib_EnableJoystick (ARG1);
case 8: return emulib_SetFrameRate (ARG1);
- case 9: return emulib_ChgCMemSize (ARG1);
- case 10: return emulib_ChgSMemSize (ARG1);
- case 11: return emulib_ChgFMemSize (ARG1);
+ case 9: return emulib_ChgCMemSize (&context->regs, ARG1);
+ case 10: return emulib_ChgSMemSize (&context->regs, ARG1);
+ case 11: return emulib_ChgFMemSize (&context->regs, ARG1);
case 12: return emulib_ChangeLanguage (ARG1);
/* The next call brings bad luck */
case 13: return emulib_ExitEmu ();
case 15: return emulib_Debug ();
#ifdef PICASSO96
- case 16: return picasso_FindCard ();
- case 17: return picasso_FillRect ();
- case 18: return picasso_SetSwitch ();
- case 19: return picasso_SetColorArray ();
- case 20: return picasso_SetDAC ();
- case 21: return picasso_SetGC ();
- case 22: return picasso_SetPanning ();
- case 23: return picasso_CalculateBytesPerRow ();
- case 24: return picasso_BlitPlanar2Chunky ();
- case 25: return picasso_BlitRect ();
- case 26: return picasso_SetDisplay ();
- case 27: return picasso_BlitTemplate ();
- case 28: return picasso_BlitRectNoMaskComplete ();
- case 29: return picasso_InitCard ();
- case 30: return picasso_BlitPattern ();
- case 31: return picasso_InvertRect ();
- case 32: return picasso_BlitPlanar2Direct ();
+ case 16: return picasso_FindCard (&context->regs);
+ case 17: return picasso_FillRect (&context->regs);
+ case 18: return picasso_SetSwitch (&context->regs);
+ case 19: return picasso_SetColorArray (&context->regs);
+ case 20: return picasso_SetDAC (&context->regs);
+ case 21: return picasso_SetGC (&context->regs);
+ case 22: return picasso_SetPanning (&context->regs);
+ case 23: return picasso_CalculateBytesPerRow (&context->regs);
+ case 24: return picasso_BlitPlanar2Chunky (&context->regs);
+ case 25: return picasso_BlitRect (&context->regs);
+ case 26: return picasso_SetDisplay (&context->regs);
+ case 27: return picasso_BlitTemplate (&context->regs);
+ case 28: return picasso_BlitRectNoMaskComplete (&context->regs);
+ case 29: return picasso_InitCard (&context->regs);
+ case 30: return picasso_BlitPattern (&context->regs);
+ case 31: return picasso_InvertRect (&context->regs);
+ case 32: return picasso_BlitPlanar2Direct (&context->regs);
/* case 34: return picasso_WaitVerticalSync (); handled in asm-code */
case 35: return allocated_gfxmem ? 1 : 0;
#ifdef HARDWARE_SPRITE_EMULATION
- case 36: return picasso_SetSprite ();
- case 37: return picasso_SetSpritePosition ();
- case 38: return picasso_SetSpriteImage ();
- case 39: return picasso_SetSpriteColor ();
+ case 36: return picasso_SetSprite (&context->regs);
+ case 37: return picasso_SetSpritePosition (&context->regs);
+ case 38: return picasso_SetSpriteImage (&context->regs);
+ case 39: return picasso_SetSpriteColor (&context->regs);
#endif
- case 40: return picasso_DrawLine ();
+ case 40: return picasso_DrawLine (&context->regs);
#endif
case 68: return emulib_Minimize ();
- case 69: return emulib_ExecuteNativeCode ();
+ case 69: return emulib_ExecuteNativeCode (&context->regs);
case 80: return currprefs.maprom ? currprefs.maprom : 0xffffffff;
case 81: return cfgfile_uaelib (ARG1, ARG2, ARG3, ARG4);
uaecptr a = here ();
currprefs.mmkeyboard = 0;
org (RTAREA_BASE + 0xFF60);
+#if 0
dw (0x4eb9);
dw ((RTAREA_BASE >> 16) | get_word(RTAREA_BASE + 36));
dw (get_word(RTAREA_BASE + 38) + 12);
- calltrap (deftrap (uaelib_demux));
+#endif
+ calltrap (define_trap (uaelib_demux, 0, ""));
dw (RTS);
org (a);
}
#include "sysconfig.h"
#include "sysdeps.h"
-#include "config.h"
#include "options.h"
#include "zfile.h"
#include "unzip.h"
}
#endif
-static char *ignoreextensions[] =
+static const char *ignoreextensions[] =
{ ".gif", ".jpg", ".png", ".xml", ".pdf", ".txt", 0 };
-static char *diskimageextensions[] =
+static const char *diskimageextensions[] =
{ ".adf", ".adz", ".ipf", ".fdi", ".exe", 0 };
static int isdiskimage (char *name)
return z;
}
-static char *plugins_7z[] = { "7z", "rar", "zip", NULL };
-static char *plugins_7z_x[] = { "7z", "Rar!", "MK" };
-static int plugins_7z_t[] = { ArchiveFormat7Zip, ArchiveFormatRAR, ArchiveFormatZIP };
+static const char *plugins_7z[] = { "7z", "rar", "zip", NULL };
+static const char *plugins_7z_x[] = { "7z", "Rar!", "MK" };
+static const int plugins_7z_t[] = { ArchiveFormat7Zip, ArchiveFormatRAR, ArchiveFormatZIP };
static int iszip (struct zfile *z)
{