Exemplo n.º 1
0
Arquivo: fpp.c Projeto: bernds/UAE
static void fpu_op_illg (uae_u32 opcode, int pcoffset)
{
    if ((currprefs.cpu_model == 68060 && (currprefs.fpu_model == 0 || (regs.pcr & 2)))
	|| (currprefs.cpu_model == 68040 && currprefs.fpu_model == 0)) {
	/* 68040 unimplemented/68060 FPU disabled exception.
	 * Line F exception with different stack frame.. */
	uaecptr newpc = m68k_getpc ();
	uaecptr oldpc = newpc - pcoffset;
	MakeSR ();
	if (!regs.s) {
	    regs.usp = m68k_areg (regs, 7);
	    m68k_areg (regs, 7) = regs.isp;
	}
	regs.s = 1;
	m68k_areg (regs, 7) -= 4;
	put_long (m68k_areg (regs, 7), oldpc);
	m68k_areg (regs, 7) -= 4;
	put_long (m68k_areg (regs, 7), oldpc);
	m68k_areg (regs, 7) -= 2;
	put_word (m68k_areg (regs, 7), 0x4000 + 11 * 4);
	m68k_areg (regs, 7) -= 4;
	put_long (m68k_areg (regs, 7), newpc);
	m68k_areg (regs, 7) -= 2;
	put_word (m68k_areg (regs, 7), regs.sr);
	write_log ("68040/060 FPU disabled exception PC=%x\n", newpc);
	newpc = get_long (regs.vbr + 11 * 4);
	m68k_setpc (newpc);
	return;
    }
    op_illg (opcode);
}
Exemplo n.º 2
0
unsigned int m68k_get_reg(void * context, m68k_register_t reg)
{
	if (reg <= M68K_REG_A7)
		return regs.regs[reg];
	else if (reg == M68K_REG_PC)
		return regs.pc;
	else if (reg == M68K_REG_SR)
	{
		MakeSR();
		return regs.sr;
	}
	else if (reg == M68K_REG_SP)
		return regs.regs[15];

	return 0;
}
Exemplo n.º 3
0
// Initiate exception processing
STATIC_INLINE uint32_t m68ki_init_exception(void)
{
#if 0
	/* Save the old status register */
	uint sr = m68ki_get_sr();

	/* Turn off trace flag, clear pending traces */
	FLAG_T1 = FLAG_T0 = 0;
	m68ki_clear_trace();
	/* Enter supervisor mode */
	m68ki_set_s_flag(SFLAG_SET);

	return sr;
#else
	MakeSR();
	uint32_t sr = regs.sr;					// Save old status register
	regs.s = 1;								// Set supervisor mode

	return sr;
#endif
}
Exemplo n.º 4
0
/*
  	This function saves the state of the calculator.
  	Can be called at any time.

  	Return an error code if an error occured, 0 otherwise
*/
int ti68k_state_save(char *filename)
{
  	FILE *f;
  	IMG_INFO *img = &img_infos;
    SAV_INFO sav;
	int i;
  
  	if(!strlen(filename))
  		return ERR_CANT_OPEN;
  
  	// Open file
  	printl(0, "Saving state image (TiEmu v2.00 format): %s\n", filename);
  	f = fopen(filename, "wb");
  	if(f == NULL)
  		return ERR_CANT_OPEN;
  	
  	// Save current image infos
	fwrite(img, 1, sizeof(IMG_INFO), f);

    // Fill state image infos
	sav.revision = SAV_REVISION;
	sav.size = sizeof(SAV_INFO);

    sav.regs_offset = sizeof(IMG_INFO) + sizeof(SAV_INFO);
    sav.io_offset = sav.regs_offset + sizeof(regs);
    sav.ram_offset = sav.io_offset + 2*tihw.io_size;
	sav.misc_offset = sav.ram_offset + tihw.ram_size;
#if 1
	sav.rom_offset = sav.misc_offset + sizeof(Ti68kHardware);
    sav.bkpts_offset = sav.rom_offset + wsm.nblocks*sizeof(int) + hw_flash_nblocks()*65536;
#else
	sav.bkpts_offset = sav.misc_offset + sizeof(Ti68kHardware);
#endif

    fwrite(&sav, 1, sizeof(SAV_INFO), f);
	
	// Update UAE structures
    MakeSR();
    m68k_setpc(m68k_getpc());
    
    // Save registers and special flags
    fwrite(&regs, sizeof(regs), 1, f);
    
    // Save I/O ports state
    fwrite(tihw.io , tihw.io_size, 1, f);
    fwrite(tihw.io2, tihw.io_size, 1, f);
    
    // Save RAM content
    fwrite(tihw.ram, tihw.ram_size, 1, f);

	// Save misc informations
	fwrite(&tihw, sizeof(Ti68kHardware), 1, f);

	// Save modified FLASH segments
	for(i=0; i<wsm.nblocks; i++)
    {
		fwrite(&wsm.changed[i], sizeof(int), 1, f);
		if(wsm.changed[i])
			fwrite(&tihw.rom[i<<16], 1, 65536, f);
    }

    // Save breakpoints (address, access, range, exception)
    save_bkpt(f, bkpts.code);
    save_bkpt(f, bkpts.exception);
	save_bkpt(f, bkpts.pgmentry);

    save_bkpt(f, bkpts.mem_rb);
	save_bkpt(f, bkpts.mem_rw);
	save_bkpt(f, bkpts.mem_rl);
	save_bkpt(f, bkpts.mem_wb);
	save_bkpt(f, bkpts.mem_ww);
	save_bkpt(f, bkpts.mem_wl);

    save_bkpt2(f, bkpts.mem_rng_r);
	save_bkpt2(f, bkpts.mem_rng_w);
    
    fclose(f);

  	return 0;
}
Exemplo n.º 5
0
/*
  	This function saves the state of the calculator.
  	Can be called at any time.

  	Return an error code if an error occured, 0 otherwise
*/
int ti68k_state_save(const char *filename)
{
  	FILE *f;
  	IMG_INFO *img = &img_infos;
    SAV_INFO sav;
	int i;
	long len;
	long bkpts_size;
  
  	if(!strlen(filename))
  		return ERR_CANT_OPEN_STATE;
  
  	// Open file
  	tiemu_info(_("saving state image (TiEmu v2.00 format): %s"), filename);
  	f = fopen(filename, "wb");
  	if(f == NULL)
  		return ERR_CANT_OPEN_STATE;
  	
  	// Save current image infos
	fwrite(img, 1, sizeof(IMG_INFO), f);

    // Fill state image infos
	sav.revision = SAV_REVISION;
	sav.size = sizeof(SAV_INFO);

    sav.regs_offset = sizeof(IMG_INFO) + sizeof(SAV_INFO);
    sav.io_offset = sav.regs_offset + sizeof(regs);
    sav.ram_offset = sav.io_offset + tihw.io_size + tihw.io2_size + tihw.io3_size;
	sav.misc_offset = sav.ram_offset + tihw.ram_size;
	sav.rom_offset = sav.misc_offset + sizeof(Ti68kHardware);
    sav.bkpts_offset = sav.rom_offset + wsm.nblocks*sizeof(int) + hw_flash_nblocks()*65536;

	bkpts_size = 
		g_list_length(bkpts.code) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.exception) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.pgmentry) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_rb) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_rw) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_rl) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_wb) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_ww) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_wl) * sizeof(long) + sizeof(long) +
		g_list_length(bkpts.mem_rng_r) * sizeof(ADDR_RANGE) + sizeof(long) +
		g_list_length(bkpts.mem_rng_w) * sizeof(ADDR_RANGE) + sizeof(long) +
		g_list_length(bkpts.bits) * sizeof(ADDR_BIT) + sizeof(long)
		;

	sav.str_offset = sav.bkpts_offset + bkpts_size;

    fwrite(&sav, 1, sizeof(SAV_INFO), f);
	
	// Update UAE structures
    MakeSR();
    m68k_setpc(m68k_getpc());
    
    // Save registers and special flags
    fwrite(&regs, sizeof(regs), 1, f);
    
    // Save I/O ports state
    fwrite(tihw.io , tihw.io_size, 1, f);
    fwrite(tihw.io2, tihw.io2_size, 1, f);
	fwrite(tihw.io3, tihw.io3_size, 1, f);	
    
    // Save RAM content
    fwrite(tihw.ram, tihw.ram_size, 1, f);

	// Save misc informations
	rtc3_state_save();
	fwrite(&tihw, sizeof(Ti68kHardware), 1, f);

	// Save modified FLASH segments
	for(i=0; i<wsm.nblocks; i++)
    {
		fwrite(&wsm.changed[i], sizeof(int), 1, f);
		if(wsm.changed[i])
			fwrite(&tihw.rom[i<<16], 1, 65536, f);
    }

    // Save breakpoints
    save_bkpt(f, bkpts.code);
    save_bkpt(f, bkpts.exception);
	save_bkpt(f, bkpts.pgmentry);

    save_bkpt(f, bkpts.mem_rb);
	save_bkpt(f, bkpts.mem_rw);
	save_bkpt(f, bkpts.mem_rl);
	save_bkpt(f, bkpts.mem_wb);
	save_bkpt(f, bkpts.mem_ww);
	save_bkpt(f, bkpts.mem_wl);

    save_bkpt2(f, bkpts.mem_rng_r);
	save_bkpt2(f, bkpts.mem_rng_w);

	save_bkpt3(f, bkpts.bits);

	// Save image location associated with this state image
	len = strlen(params.rom_file) + 1;
	fwrite(&len, 1, sizeof(len), f);
	fwrite(params.rom_file, len, 1, f);
	
	len = strlen(params.tib_file) + 1;
	fwrite(&len, 1, sizeof(len), f);
	fwrite(params.tib_file, len, 1, f);
    
    fclose(f);

  	return 0;
}