Ejemplo n.º 1
0
void Jit::Comp_ReplacementFunc(MIPSOpcode op)
{
	// We get here if we execute the first instruction of a replaced function. This means
	// that we do need to return to RA.

	// Inlined function calls (caught in jal) are handled differently.

	int index = op.encoding & MIPS_EMUHACK_VALUE_MASK;

	const ReplacementTableEntry *entry = GetReplacementFunc(index);
	if (!entry) {
		ERROR_LOG(HLE, "Invalid replacement op %08x", op.encoding);
		return;
	}

	if (entry->flags & REPFLAG_DISABLED) {
		MIPSCompileOp(Memory::Read_Instruction(js.compilerPC, true));
	} else if (entry->jitReplaceFunc) {
		MIPSReplaceFunc repl = entry->jitReplaceFunc;
		int cycles = (this->*repl)();

		if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT)) {
			// Compile the original instruction at this address.  We ignore cycles for hooks.
			MIPSCompileOp(Memory::Read_Instruction(js.compilerPC, true));
		} else {
			FlushAll();
			MOV(32, R(ECX), M(&currentMIPS->r[MIPS_REG_RA]));
			js.downcountAmount += cycles;
			WriteExitDestInReg(ECX);
			js.compiling = false;
		}
	} else if (entry->replaceFunc) {
		FlushAll();

		// Standard function call, nothing fancy.
		// The function returns the number of cycles it took in EAX.
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		ABI_CallFunction(entry->replaceFunc);

		if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT)) {
			// Compile the original instruction at this address.  We ignore cycles for hooks.
			MIPSCompileOp(Memory::Read_Instruction(js.compilerPC, true));
		} else {
			MOV(32, R(ECX), M(&currentMIPS->r[MIPS_REG_RA]));
			SUB(32, M(&currentMIPS->downcount), R(EAX));
			WriteExitDestInReg(ECX);
			js.compiling = false;
		}
	} else {
		ERROR_LOG(HLE, "Replacement function %s has neither jit nor regular impl", entry->name);
	}
}
Ejemplo n.º 2
0
void Jit::CompileDelaySlot(int flags, RegCacheState *state)
{
	const u32 addr = js.compilerPC + 4;

	// Need to offset the downcount which was already incremented for the branch + delay slot.
	CheckJitBreakpoint(addr, -2);

	if (flags & DELAYSLOT_SAFE)
		SAVE_FLAGS; // preserve flag around the delay slot!

	js.inDelaySlot = true;
	MIPSOpcode op = Memory::Read_Opcode_JIT(addr);
	MIPSCompileOp(op);
	js.inDelaySlot = false;

	if (flags & DELAYSLOT_FLUSH)
	{
		if (state != NULL)
			GetStateAndFlushAll(*state);
		else
			FlushAll();
	}
	if (flags & DELAYSLOT_SAFE)
		LOAD_FLAGS; // restore flag!
}
Ejemplo n.º 3
0
bool Jit::CheckJitBreakpoint(u32 addr, int downcountOffset)
{
	if (CBreakPoints::IsAddressBreakPoint(addr))
	{
		SAVE_FLAGS;
		FlushAll();
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		ABI_CallFunction(&JitBreakpoint);

		// If 0, the conditional breakpoint wasn't taken.
		CMP(32, R(EAX), Imm32(0));
		FixupBranch skip = J_CC(CC_Z);
		WriteDowncount(downcountOffset);
		// Just to fix the stack.
		LOAD_FLAGS;
		JMP(asm_.dispatcherCheckCoreState, true);
		SetJumpTarget(skip);

		LOAD_FLAGS;

		return true;
	}

	return false;
}
Ejemplo n.º 4
0
void Lout::RemoveAllOutputs()
{
	FlushAll();
	Locker lock( myLock );
	(void)lock;
	myOutput.erase( myOutput.begin(), myOutput.end() );
}
Ejemplo n.º 5
0
void Jit::Comp_Generic(MIPSOpcode op)
{
	FlushAll();
	MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
	_dbg_assert_msg_(JIT, (MIPSGetInfo(op) & DELAYSLOT) == 0, "Cannot use interpreter for branch ops.");

	if (func)
	{
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		if (USE_JIT_MISSMAP)
			ABI_CallFunctionC(&JitLogMiss, op.encoding);
		else
			ABI_CallFunctionC(func, op.encoding);
	}
	else
		ERROR_LOG_REPORT(JIT, "Trying to compile instruction %08x that can't be interpreted", op.encoding);

	const MIPSInfo info = MIPSGetInfo(op);
	if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0)
	{
		// If it does eat them, it'll happen in MIPSCompileOp().
		if ((info & OUT_EAT_PREFIX) == 0)
			js.PrefixUnknown();
	}
}
Ejemplo n.º 6
0
	void cImageManager::DeleteAllBitmapFrames()
	{
		FlushAll();
		for(tFrameBitmapListIt it=mlstBitmapFrames.begin();it!=mlstBitmapFrames.end();)
		{
			hplDelete(*it);
			it = mlstBitmapFrames.erase(it);
		}
	}
Ejemplo n.º 7
0
void Jit::Comp_Generic(u32 op)
{
	FlushAll();
	MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
	if (func)
	{
		//MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		//ABI_CallFunctionC(func, op);
	}
}
Ejemplo n.º 8
0
bool COMXCoreComponent::Deinitialize()
{
  OMX_ERRORTYPE omx_err;

  if(!m_DllOMXOpen)
    return false;

  m_exit = true;

  m_flush_input   = true;
  m_flush_output  = true;

  if(m_handle) 
  {

    FlushAll();

    FreeOutputBuffers(true);
    FreeInputBuffers(true);

    if(GetState() == OMX_StateExecuting)
      SetStateForComponent(OMX_StatePause);

    if(GetState() != OMX_StateIdle)
      SetStateForComponent(OMX_StateIdle);

    if(GetState() != OMX_StateLoaded)
      SetStateForComponent(OMX_StateLoaded);

    omx_err = m_DllOMX->OMX_FreeHandle(m_handle);
    if (omx_err != OMX_ErrorNone)
    {
      CLog::Log(LOGERROR, "COMXCoreComponent::Deinitialize - failed to free handle for component %s omx_err(0x%08x)", 
          m_componentName.c_str(), omx_err);
    }  

    m_handle = NULL;
  }

  m_input_port    = 0;
  m_output_port   = 0;
  m_componentName = "";
  m_DllOMXOpen    = false;

  CustomDecoderFillBufferDoneHandler = NULL;
  CustomDecoderEmptyBufferDoneHandler = NULL;

  m_DllOMX->Unload();

  return true;
}
Ejemplo n.º 9
0
const u8 *MipsJit::DoJit(u32 em_address, JitBlock *b)
{
	js.cancel = false;
	js.blockStart = js.compilerPC = mips_->pc;
	js.lastContinuedPC = 0;
	js.initialBlockSize = 0;
	js.nextExit = 0;
	js.downcountAmount = 0;
	js.curBlock = b;
	js.compiling = true;
	js.inDelaySlot = false;
	js.PrefixStart();
	b->normalEntry = GetCodePtr();
	js.numInstructions = 0;
	while (js.compiling)
	{
		MIPSOpcode inst = Memory::Read_Opcode_JIT(js.compilerPC);
		js.downcountAmount += MIPSGetInstructionCycleEstimate(inst);

		MIPSCompileOp(inst);

		js.compilerPC += 4;
		js.numInstructions++;

		// Safety check, in case we get a bunch of really large jit ops without a lot of branching.
		if (GetSpaceLeft() < 0x800 || js.numInstructions >= JitBlockCache::MAX_BLOCK_INSTRUCTIONS)
		{
			FlushAll();
			WriteExit(js.compilerPC, js.nextExit++);
			js.compiling = false;
		}
	}

	b->codeSize = GetCodePtr() - b->normalEntry;

	// Don't forget to zap the newly written instructions in the instruction cache!
	FlushIcache();

	if (js.lastContinuedPC == 0)
		b->originalSize = js.numInstructions;
	else
	{
		// We continued at least once.  Add the last proxy and set the originalSize correctly.
		blocks.ProxyBlock(js.blockStart, js.lastContinuedPC, (js.compilerPC - js.lastContinuedPC) / sizeof(u32), GetCodePtr());
		b->originalSize = js.initialBlockSize;
	}

	return b->normalEntry;
}
Ejemplo n.º 10
0
void MipsJit::CompileDelaySlot(int flags)
{
	//if (flags & DELAYSLOT_SAFE)
	//	Save flags here

	js.inDelaySlot = true;
	MIPSOpcode op = Memory::Read_Opcode_JIT(js.compilerPC + 4);
	MIPSCompileOp(op);
	js.inDelaySlot = false;

	if (flags & DELAYSLOT_FLUSH)
		FlushAll();
	//if (flags & DELAYSLOT_SAFE)
	//	Restore flags here
}
Ejemplo n.º 11
0
bool Jit::CheckJitBreakpoint(u32 addr, int downcountOffset)
{
	if (CBreakPoints::IsAddressBreakPoint(addr))
	{
		FlushAll();
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		CALL((void *)&JitBreakpoint);

		WriteDowncount(downcountOffset);
		JMP(asm_.dispatcherCheckCoreState, true);

		return true;
	}

	return false;
}
Ejemplo n.º 12
0
void Jit::Comp_Generic(u32 op)
{
	FlushAll();
	MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
	_dbg_assert_msg_(JIT, (MIPSGetInfo(op) & DELAYSLOT) == 0, "Cannot use interpreter for branch ops.");

	if (func)
	{
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		if (USE_JIT_MISSMAP)
			ABI_CallFunctionC((void *)&JitLogMiss, op);
		else
			ABI_CallFunctionC((void *)func, op);
	}
	else
		_dbg_assert_msg_(JIT, 0, "Trying to compile instruction that can't be interpreted");
}
Ejemplo n.º 13
0
void FakeJit::Comp_Generic(MIPSOpcode op)
{
	FlushAll();
	MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
	if (func)
	{
		SaveDowncount();
		RestoreDowncount();
	}

	const MIPSInfo info = MIPSGetInfo(op);
	if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0)
	{
		// If it does eat them, it'll happen in MIPSCompileOp().
		if ((info & OUT_EAT_PREFIX) == 0)
			js.PrefixUnknown();
	}
}
Ejemplo n.º 14
0
int TCPSocket::CreateTCPClientReceiverMode() {
	sprintf(Message, "Client: Initiating TCP Client...\n");
	easyLog("bold");
	addrinfo *ai;
	if (AppStat)
		FlushAll();
	if ((ai = GetAddrInfo()) == NULL)
		return 1; //Error On Getting Address Information
	if (GetConnect(ai))
		return 2; //Error On Connectiong To Server
	if (Login())
		return 3;
	sprintf(Message, "Client Ready: TCP Receiver Mode started...\n");
	easyLog("bold");
	AppStat = true;
	ClientReceiverMode();
	return 0;
}
Ejemplo n.º 15
0
bool Jit::ReplaceJalTo(u32 dest) {
	MIPSOpcode op(Memory::Read_Opcode_JIT(dest));
	if (!MIPS_IS_REPLACEMENT(op.encoding))
		return false;

	int index = op.encoding & MIPS_EMUHACK_VALUE_MASK;
	const ReplacementTableEntry *entry = GetReplacementFunc(index);
	if (!entry) {
		ERROR_LOG(HLE, "ReplaceJalTo: Invalid replacement op %08x at %08x", op.encoding, dest);
		return false;
	}

	if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT | REPFLAG_DISABLED)) {
		// If it's a hook, we can't replace the jal, we have to go inside the func.
		return false;
	}

	// Warning - this might be bad if the code at the destination changes...
	if (entry->flags & REPFLAG_ALLOWINLINE) {
		// Jackpot! Just do it, no flushing. The code will be entirely inlined.

		// First, compile the delay slot. It's unconditional so no issues.
		CompileDelaySlot(DELAYSLOT_NICE);
		// Technically, we should write the unused return address to RA, but meh.
		MIPSReplaceFunc repl = entry->jitReplaceFunc;
		int cycles = (this->*repl)();
		js.downcountAmount += cycles;
	} else {
		gpr.SetImm(MIPS_REG_RA, js.compilerPC + 8);
		CompileDelaySlot(DELAYSLOT_NICE);
		FlushAll();
		MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
		ABI_CallFunction(entry->replaceFunc);
		SUB(32, M(&currentMIPS->downcount), R(EAX));
	}

	js.compilerPC += 4;
	// No writing exits, keep going!

	// Add a trigger so that if the inlined code changes, we invalidate this block.
	// TODO: Correctly determine the size of this block.
	blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr());
	return true;
}
Ejemplo n.º 16
0
int TCPSocket::CreateTCPServer() {
	sprintf(Message, "Server: Initiating TCP Server...\n");
	easyLog("bold");
	addrinfo *ai;
	if (AppStat)
		FlushAll();
	if ((ai = GetAddrInfo()) == NULL)
		return 1; //Error On Getting Address Information
	if ((mySocketFD = GetBind(ai)) == -1)
		return 2; //Error On Binding Socket
	if (SocketBlockingMode())
		return 3;
	if (ListenOn() == -1)
		return 4; //Error On Listener
	sprintf(Message, "Server Ready: TCP Connection Management started...\n");
	easyLog("bold");
	AppStat = true;
	ManageConnections();
	return 0;
}
Ejemplo n.º 17
0
void Jit::CompileDelaySlot(int flags)
{
	const u32 addr = js.compilerPC + 4;

	// TODO: If we ever support conditional breakpoints, we need to handle the flags more carefully.
	// Need to offset the downcount which was already incremented for the branch + delay slot.
	CheckJitBreakpoint(addr, -2);

	if (flags & DELAYSLOT_SAFE)
		SAVE_FLAGS; // preserve flag around the delay slot!

	js.inDelaySlot = true;
	u32 op = Memory::Read_Instruction(addr);
	MIPSCompileOp(op);
	js.inDelaySlot = false;

	if (flags & DELAYSLOT_FLUSH)
		FlushAll();
	if (flags & DELAYSLOT_SAFE)
		LOAD_FLAGS; // restore flag!
}
bool COMXCoreComponent::Deinitialize(bool free_component /* = false */)
{
  OMX_ERRORTYPE omx_err;

  m_exit = true;

  m_flush_input   = true;
  m_flush_output  = true;

  if(m_handle && m_DllOMXOpen)
  {
    FlushAll();

    FreeOutputBuffers();
    FreeInputBuffers();

    TransitionToStateLoaded();

    if(free_component)
    {
      CLog::Log(LOGDEBUG, "COMXCoreComponent::Deinitialize : %s handle 0x%08x dllopen : %d\n", 
          m_componentName.c_str(), m_handle, m_DllOMXOpen);
      omx_err = m_DllOMX->OMX_FreeHandle(m_handle);
      if (omx_err != OMX_ErrorNone)
      {
        CLog::Log(LOGERROR, "COMXCoreComponent::Deinitialize - failed to free handle for component %s omx_err(0x%08x)", 
            m_componentName.c_str(), omx_err);
      }  
      m_handle = NULL;

      m_input_port      = 0;
      m_output_port     = 0;
      m_componentName   = "";
      m_resource_error  = false;
    }
  }

  return true;
}
Ejemplo n.º 19
0
void MipsJit::Comp_Generic(MIPSOpcode op)
{
	FlushAll();
	MIPSInterpretFunc func = MIPSGetInterpretFunc(op);
	if (func)
	{
		//SaveDowncount();
		RestoreRoundingMode();
		// Move Imm32(js.compilerPC) in to M(&mips_->pc)
		QuickCallFunction(V1, (void *)func);
		ApplyRoundingMode();
		//RestoreDowncount();
	}

	const MIPSInfo info = MIPSGetInfo(op);
	if ((info & IS_VFPU) != 0 && (info & VFPU_NO_PREFIX) == 0)
	{
		// If it does eat them, it'll happen in MIPSCompileOp().
		if ((info & OUT_EAT_PREFIX) == 0)
			js.PrefixUnknown();
	}
}
Ejemplo n.º 20
0
//*****************************************************************************
//  Function        : GetFile
//  Description     : Get a file from host.
//  Input           : aIdx          // index of file to download
//  Return          : 0/-1;         // 0  => Success
//                                  // -1 => Error
//  Note            : N/A
//  Globals Changed : N/A
//*****************************************************************************
static int GetFile(int aIdx)
{
  T_APP_INFO app_list;
  int retry, j;
  int len, rx_len;
  BYTE auxname[30+1];
  BYTE linea[30+1];
  DWORD getfile_mark, rx_mark, which;
  int  handle;
  TBuffers.gRxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos
  TBuffers.gTxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos
   memset(TBuffers.gRxBuf,0x00,COMM_BUFF_SIZE);
   memset(TBuffers.gTxBuf,0x00,COMM_BUFF_SIZE);
  for (retry=0; retry<NUM_OF_RETRY; retry++) {
    FlushAll ();
    which = MW_FTP_DATA_CHNL;
    IOCtlMW(gFtpHandle, IO_FTP_DISCONNECT, &which);
    FlushAll ();

    handle = os_file_open(KTempFile, K_O_RDWR|K_O_TRUNC|K_O_CREAT);
    if (handle < 0) {
      //ShowMsgWait("Temp File Open Fail.", TRUE);
      FreeMW(TBuffers.gRxBuf);
      FreeMW(TBuffers.gTxBuf);
      return -1;
    }

    //SprintfMW ((char *)gTxBuf, "\x12\x1b\x20""Dnld %s..\x5", gFileList[aIdx]);
    //PrintfMW(gTxBuf);
//    clear_area_screen(4,2,7,20,FALSE,FALSE);
    sprintf ((char *)TBuffers.gTxBuf, "Descarga %.8s", gFileList[aIdx]);
    

    memset(auxname,0x00,sizeof(auxname));
    memcpy(auxname,gFileList[aIdx],sizeof(auxname));


    memset(linea, 0x00, sizeof(linea));
   // printf("\f\x1C      VERSIONES      \x1D");
    for( j = 0; j < 50; j++ )
    {
        if(os_app_search_id(j) == TRUE)
        {
      
            os_app_info(j , &app_list);
       
            memset(linea,0x00,sizeof(linea));
            sprintf(linea, "%s-%04X.tms", &app_list.s_app_name[2], app_list.w_checksum);
            //printf("\f %s \n %s\n %d",linea,gFileList[aIdx], gNumOfFiles);APM_WaitKey(3000,0);

            if(memcmp(linea,auxname,30)==0){
              os_file_close(handle);
              FreeMW(TBuffers.gRxBuf);
              FreeMW(TBuffers.gTxBuf);
              return 1;
            }
        }

    }

    //ShowMsgWait(TBuffers.gTxBuf, FALSE);
//    centerS(4,2,21,TBuffers.gTxBuf);
    SprintfMW ((char *)TBuffers.gTxBuf, "GET I /%s%s", STR_TEST_DIR_NAME, gFileList[aIdx]);
    if (IOCtlMW(gFtpHandle, IO_FTP_CMD_SEND, TBuffers.gTxBuf) == FALSE) {
      //ShowMsgWait("GET:Command Fail.", TRUE);
      break;
    }

    if (WaitStatus(MW_FTP_STAT_DATA_CONNED, TIMEOUT_STATUS) < 0) {
    	graphicWindow("ERROR FTP");
//    	centerS(3,1,21,"Falla al");
//    	centerS(4,1,21,"Obtener los");
//    	centerS(5,1,21,"datos de FTP");
      //ShowMsgWait("GET:Fail.", TRUE);
      break;
    }
    gRxSpeed = 0;
    rx_len = 0;
    getfile_mark = FreeRunMark();
    while (1) {
      DWORD timeout=0;
      int ret;

      ret = GetCmdResp();
      if (ret >= 400) {
        PrintfMW("\x1B\xE0\x1CGET:%d\x05\x1D", ret);
        break;
      }

      rx_mark = FreeRunMark();
      do {
        len = ReadMW(gFtpHandle, TBuffers.gRxBuf, COMM_BUFF_SIZE);
        if (len > 0) {
          os_file_write(handle, TBuffers.gRxBuf, len);      // save to file
          break;
        }
        if (WaitStatus(MW_FTP_STAT_DATA_CONNED, 1) < 0) {
          timeout = TIMEOUT_READ_BLOCK;
          break;
        }
        //SleepMW();
      } while ((timeout = FreeRunElapsed(rx_mark)) < TIMEOUT_READ_BLOCK && GetCharMW() != MWKEY_CANCL);

      if (GetCharMW() == MWKEY_CANCL)
        break;

      if (timeout >= TIMEOUT_READ_BLOCK)   // End ?
        break;

      rx_len += len;
      printf("\fRx: %3d.%d K.bytes",rx_len/1000,(rx_len%1000)/100);
      //PrintfMW("\x1B\x80""RXed %d bytes\x05\n\x05\n\x05", rx_len);
    }
    os_file_close(handle);

    if (rx_len == 0) {
       graphicWindow("ERROR FTP");
//       clear_area_screen(2,2,7,20,FALSE,FALSE);
//       centerS(4,1,21,"RX Timeout.");
    		  ;
      os_file_close(handle);
      continue;
    }
    os_file_delete(gFileList[aIdx]);
    os_file_rename(gFileList[aIdx], KTempFile);
    which = MW_FTP_DATA_CHNL;
    IOCtlMW(gFtpHandle, IO_FTP_DISCONNECT, &which);  // Close Data channel
    gRxSpeed = (rx_len/(FreeRunElapsed(getfile_mark)/1000));
    //PrintfMW("\x1B\xA0Rx Spd:%d Bps\n", gRxSpeed);
    FreeMW(TBuffers.gRxBuf);
    FreeMW(TBuffers.gTxBuf);
    return 0;
  }
  os_file_close(handle);
  FreeMW(TBuffers.gRxBuf);
  FreeMW(TBuffers.gTxBuf);
  return -1;
}
Ejemplo n.º 21
0
GFile::~GFile() {
    FlushAll();
    if (Handle != NULL) delete Handle;
}
Ejemplo n.º 22
0
const u8 *Jit::DoJit(u32 em_address, JitBlock *b)
{
	js.cancel = false;
	js.blockStart = js.compilerPC = mips_->pc;
	js.nextExit = 0;
	js.downcountAmount = 0;
	js.curBlock = b;
	js.compiling = true;
	js.inDelaySlot = false;
	js.afterOp = JitState::AFTER_NONE;
	js.PrefixStart();

	// We add a check before the block, used when entering from a linked block.
	b->checkedEntry = GetCodePtr();
	// Downcount flag check. The last block decremented downcounter, and the flag should still be available.
	FixupBranch skip = J_CC(CC_NBE);
	MOV(32, M(&mips_->pc), Imm32(js.blockStart));
	JMP(asm_.outerLoop, true);  // downcount hit zero - go advance.
	SetJumpTarget(skip);

	b->normalEntry = GetCodePtr();

	MIPSAnalyst::AnalysisResults analysis = MIPSAnalyst::Analyze(em_address);

	gpr.Start(mips_, analysis);
	fpr.Start(mips_, analysis);

	js.numInstructions = 0;
	while (js.compiling) {
		// Jit breakpoints are quite fast, so let's do them in release too.
		CheckJitBreakpoint(js.compilerPC, 0);

		MIPSOpcode inst = Memory::Read_Opcode_JIT(js.compilerPC);
		js.downcountAmount += MIPSGetInstructionCycleEstimate(inst);

		MIPSCompileOp(inst);

		if (js.afterOp & JitState::AFTER_CORE_STATE) {
			// TODO: Save/restore?
			FlushAll();

			// If we're rewinding, CORE_NEXTFRAME should not cause a rewind.
			// It doesn't really matter either way if we're not rewinding.
			// CORE_RUNNING is <= CORE_NEXTFRAME.
			CMP(32, M(&coreState), Imm32(CORE_NEXTFRAME));
			FixupBranch skipCheck = J_CC(CC_LE);
			if (js.afterOp & JitState::AFTER_REWIND_PC_BAD_STATE)
				MOV(32, M(&mips_->pc), Imm32(js.compilerPC));
			else
				MOV(32, M(&mips_->pc), Imm32(js.compilerPC + 4));
			WriteSyscallExit();
			SetJumpTarget(skipCheck);

			js.afterOp = JitState::AFTER_NONE;
		}
		if (js.afterOp & JitState::AFTER_MEMCHECK_CLEANUP) {
			js.afterOp &= ~JitState::AFTER_MEMCHECK_CLEANUP;
		}

		js.compilerPC += 4;
		js.numInstructions++;

		// Safety check, in case we get a bunch of really large jit ops without a lot of branching.
		if (GetSpaceLeft() < 0x800)
		{
			FlushAll();
			WriteExit(js.compilerPC, js.nextExit++);
			js.compiling = false;
		}
	}

	b->codeSize = (u32)(GetCodePtr() - b->normalEntry);
	NOP();
	AlignCode4();
	b->originalSize = js.numInstructions;
	return b->normalEntry;
}
Ejemplo n.º 23
0
void Jit::GetStateAndFlushAll(RegCacheState &state)
{
	gpr.GetState(state.gpr);
	fpr.GetState(state.fpr);
	FlushAll();
}
Ejemplo n.º 24
0
sListNode::~sListNode()
{
	if (head==this) FlushAll();
}
Ejemplo n.º 25
0
wxsCoder::~wxsCoder()
{
    FlushAll();
}
Ejemplo n.º 26
0
//*****************************************************************************
//  Function        : GetListFile
//  Description     : Get list file from host.
//  Input           : N/A
//  Return          : 0/-1;         // 0  => Success
//                                  // -1 => Error
//  Note            : N/A
//  Globals Changed : N/A
//*****************************************************************************
static int GetListFile(void)
{
  int retry;
  int len, rx_len;
  int i, state, line_idx;
  DWORD getfile_mark, rx_mark, which;
  TBuffers.gRxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos
  TBuffers.gTxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos
   memset(TBuffers.gRxBuf,0x00,COMM_BUFF_SIZE);
   memset(TBuffers.gTxBuf,0x00,COMM_BUFF_SIZE);
  for (retry=0; retry<NUM_OF_RETRY; retry++) {
    FlushAll ();
    which = MW_FTP_DATA_CHNL;
    IOCtlMW(gFtpHandle, IO_FTP_DISCONNECT, &which);
    FlushAll ();
    graphicWindow("DESCARGANDO INFO");
    printf("\n\nArchivo %s",STR_LIST_FILE_NAME);
    //SprintfMW ((char *)gTxBuf, "\x12\x1b\x20""Dnld %s..\x5", STR_LIST_FILE_NAME);
    //PrintfMW(gTxBuf);
    SprintfMW ((char *)TBuffers.gTxBuf, "GET I /%s%s", STR_TEST_DIR_NAME, STR_LIST_FILE_NAME);
    if (IOCtlMW(gFtpHandle, IO_FTP_CMD_SEND, TBuffers.gTxBuf) == FALSE) {
   //   ShowMsgWait("GET:Command Fail.", TRUE);
      break;
    }

    if (WaitStatus(MW_FTP_STAT_DATA_CONNED, TIMEOUT_STATUS) < 0) {
//        centerS(5,1,21,"Fallo de datos");
  	  DispLineMW("Fallo de datos",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
//        getch(0);
        WaitKey(300,1);
      break;
    }
    gNumOfFiles = 0;
    gRxSpeed = 0;
    rx_len = 0;
    getfile_mark = FreeRunMark();
    while (1) {
      DWORD timeout=0;
      int ret;

      ret = GetCmdResp();
      if (ret >= 400) {
        PrintfMW("\x1B\xE0\x1CGET:%d\x05\x1D", ret);
        break;
      }

      state = S_IDLE;
      line_idx = 0;
      rx_mark = FreeRunMark();
      do {
        len = ReadMW(gFtpHandle, TBuffers.gRxBuf, COMM_BUFF_SIZE);
        if (len) {
          for (i=0; i<len; i++) {
            // Process data
            if ((TBuffers.gRxBuf[i] == 0x0d) || (TBuffers.gRxBuf[i] == 0x0a)) {
              if (line_idx) {
                gLineBuf[line_idx] = 0;
                line_idx = 0;
                TrimLineBuf();
                state = ProcGetListFileState(state);
              }
            }
            else if (line_idx < SIZE_LINE) {
              gLineBuf[line_idx] = TBuffers.gRxBuf[i];
              line_idx++;
            }
          }
          break;
        }
        if (WaitStatus(MW_FTP_STAT_DATA_CONNED, 1) < 0) {
          timeout = TIMEOUT_READ_BLOCK;
          break;
        }
        if (GetCharMW() == MWKEY_CANCL)
          break;
        //SleepMW();
      } while ((timeout = FreeRunElapsed(rx_mark)) < TIMEOUT_READ_BLOCK);

      if (timeout >= TIMEOUT_READ_BLOCK)   // End ?
        break;

      rx_len += len;
     printf("\fRx: %3d.%d K.bytes",rx_len/1000,(rx_len%1000)/100);
      //dumpMemory(TBuffers.gRxBuf,rx_len,1);
      //printf("\f%s",TBuffers.gRxBuf);getch(0);
      //PrintfMW("\x1B\x80""RXed %d bytes\x05\n\x05", rx_len);
      if (GetCharMW() == MWKEY_CANCL)
        break;
    }

    if (rx_len == 0) {
      graphicWindow("ERROR FTP");
      //clear_area_screen(2,2,7,20,FALSE);
    //  centerS(4,1,21,"RX Timeout.");
      WaitKey(300,1);
      continue;
    }
    which = MW_FTP_DATA_CHNL;
    IOCtlMW(gFtpHandle, IO_FTP_DISCONNECT, &which);  // Close Data channel
    gRxSpeed = (rx_len/(FreeRunElapsed(getfile_mark)/1000));
    //PrintfMW("\x1B\xA0Rx Spd:%d Bps\n", gRxSpeed);
    FreeMW(TBuffers.gRxBuf);
    FreeMW(TBuffers.gRxBuf);
    return 0;
  }
  FreeMW(TBuffers.gTxBuf);
  FreeMW(TBuffers.gTxBuf);
  return -1;
}
Ejemplo n.º 27
0
//*****************************************************************************
//  Function        : FtpOpen
//  Description     : Open & Login
//  Input           : aCfg;           // TCP port info.
//                    aLoginName;     // Login name
//                    aLoginPassword; // password.
//  Return          : 0/-1;       // 0  => Success
//                                // -1 => Error
//  Note            : N/A
//  Globals Changed : N/A
//*****************************************************************************
static int FtpOpen(struct MW_TCP_PORT *aCfg, char *aLoginName, char *aLoginPassword)
{
  int i;

  // Close all
  CloseAll();
  TBuffers.gRxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos
  TBuffers.gTxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos
  memset(TBuffers.gRxBuf,0x00,COMM_BUFF_SIZE);
  memset(TBuffers.gTxBuf,0x00,COMM_BUFF_SIZE);
  // Open Port
  graphicWindow("CONEXION FTP");
  DispLineMW("Conectando...",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_BIGFONT);

  FlushAll ();
  if (IOCtlMW(gFtpHandle, IO_FTP_CONNECT, aCfg) == FALSE) {
	  graphicWindow("ERROR");
	  //centerS(3,1,21,"Fallo al intentar");
	  DispLineMW("Fallo al intentar",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  DispLineMW("Abrir!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT);
//	  centerS(4,1,21,"Abrir!!");
	  Delay10ms(300);
	  FreeMW(TBuffers.gRxBuf);
	  FreeMW(TBuffers.gTxBuf);
    return -1;
  }
  i = WaitCmdResp(TIMEOUT_RESP);
  if (i < 0) {
		graphicWindow("ERROR");
//		centerS(3,1,21,"El tiempo de espera");
//		centerS(4,1,21,"se agoto al");
//		centerS(5,1,21,"intentat abrir!!");
		DispLineMW("El tiempo de espera",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT);
		DispLineMW("se agoto al",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
		DispLineMW("intentat abrir!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT);
//		getch(300);
		 Delay10ms(300);
		 FreeMW(TBuffers.gTxBuf);
		 FreeMW(TBuffers.gRxBuf);
    return -1;
  }
  if (i >= 400) {
    PrintfMW("\x1B\xE0""Open:%d\x05\x1D", i);
    FreeMW(TBuffers.gRxBuf);
    return -1;
  }

  if (WaitStatus(MW_FTP_STAT_CONNECTED, TIMEOUT_STATUS)<0) {
	  graphicWindow("ERROR");
//	  centerS(3,1,21,"Fallo al intentar");
//	  centerS(4,1,21,"Abrir!!");
//	  getch(300);
	  DispLineMW("Fallo al intentar",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  DispLineMW("Abrir 2!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  Delay10ms(300);
	  FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf);
    return -1;
  }

  // Login
  DispLineMW("Negociando...",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
  //centerS(4,1,21,"Negociando...");
  FlushAll();
  SprintfMW ((char *)TBuffers.gTxBuf, "LOGIN %s %s", aLoginName, aLoginPassword);
  if (IOCtlMW(gFtpHandle, IO_FTP_CMD_SEND, TBuffers.gTxBuf) == FALSE) {
	  graphicWindow("ERROR");
	  DispLineMW("Fallo al intentar",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  DispLineMW("Login",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
//	  centerS(3,1,21,"Fallo al intentar");
//	  centerS(4,1,21,"login!!");
//	  getch(300);
	  Delay10ms(300);
	  FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf);
    return -1;
  }
  i = WaitCmdResp(TIMEOUT_RESP);
  if (i < 0) {
		graphicWindow("ERROR");
//		centerS(3,1,21,"El tiempo de espera");
//		centerS(4,1,21,"se agoto al");
//		centerS(5,1,21,"intentat login!!");
		  DispLineMW("El tiempo de espera",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT);
		  DispLineMW("se agoto al",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
		  DispLineMW("intentat login!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT);
//		getch(300);
		  Delay10ms(300);
		  FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf);
    return -1;
  }
  if (i >= 400) {
	  graphicWindow("ERROR");
//	  centerS(3,1,21,"Fallo al intentar");
//	  centerS(4,1,21,"login!!");
//	  getch(300);
	  DispLineMW("Fallo al intentar",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  DispLineMW("login!!",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  Delay10ms(300);
	  FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf);
    return -1;
  }
  if (WaitStatus(MW_FTP_STAT_OPENED, TIMEOUT_STATUS) < 0) {
	  graphicWindow("ERROR");
//	  centerS(3,1,21,"Fallo al intentar");
//	  centerS(4,1,21,"login!!");
//	  getch(300);
	  DispLineMW("Fallo al intentar",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  DispLineMW("login!!",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT);
	  Delay10ms(300);
	  FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf);
    return -1;
  }
  return 0;
}
Ejemplo n.º 28
0
int fflush (FILE far *stream)
{
return FlushAll();
}