예제 #1
0
void Write32(const u32 _uValue, const u32 _iAddress)
{
	//INFO_LOG(PROCESSORINTERFACE, "(w32) 0x%08x @ 0x%08x", _uValue, _iAddress);
	switch(_iAddress & 0xFFF) 
	{
	case PI_INTERRUPT_CAUSE:
		Common::AtomicAnd(m_InterruptCause, ~_uValue); // writes turn them off
		UpdateException();
		return;

	case PI_INTERRUPT_MASK: 
		m_InterruptMask = _uValue;
		DEBUG_LOG(PROCESSORINTERFACE,"New Interrupt mask: %08x", m_InterruptMask);
		UpdateException();
		return;
	
	case PI_FIFO_BASE:
		Fifo_CPUBase = _uValue & 0xFFFFFFE0;
		DEBUG_LOG(PROCESSORINTERFACE,"Fifo base = %08x", _uValue);
		break;

	case PI_FIFO_END:
		Fifo_CPUEnd = _uValue & 0xFFFFFFE0;
		DEBUG_LOG(PROCESSORINTERFACE,"Fifo end = %08x", _uValue);
		break;

	case PI_FIFO_WPTR:
		Fifo_CPUWritePointer = _uValue & 0xFFFFFFE0;		
		DEBUG_LOG(PROCESSORINTERFACE,"Fifo writeptr = %08x", _uValue);
		break;

    case PI_FIFO_RESET:
		//Abort the actual frame
		//g_video_backend->Video_AbortFrame();
        //Fifo_CPUWritePointer = Fifo_CPUBase; ??
		//PanicAlert("Unknown write to PI_FIFO_RESET (%08x)", _uValue);
		WARN_LOG(PROCESSORINTERFACE, "Fifo reset (%08x)", _uValue);
        break;

	case PI_RESET_CODE:
		DEBUG_LOG(PROCESSORINTERFACE, "Write %08x to PI_RESET_CODE", _uValue);
		break;

	case PI_FLIPPER_UNK:
		DEBUG_LOG(PROCESSORINTERFACE, "write %08x to unknown PI reg %08x", _uValue, _iAddress);
		break;

	default:
		ERROR_LOG(PROCESSORINTERFACE,"!!!!Unknown PI write!!!! 0x%08x", _iAddress);
		PanicAlert("Unknown write to PI: %08x", _iAddress);
		break;
	}
}
예제 #2
0
void SetInterrupt(u32 _causemask, bool _bSet)
{
	// TODO(ector): add sanity check that current thread id is cpu thread

	if (_bSet && !(m_InterruptCause & _causemask))
	{
		DEBUG_LOG(PROCESSORINTERFACE, "Setting Interrupt %s (set)", Debug_GetInterruptName(_causemask));
	}

	if (!_bSet && (m_InterruptCause & _causemask))
	{
		DEBUG_LOG(PROCESSORINTERFACE, "Setting Interrupt %s (clear)", Debug_GetInterruptName(_causemask));
	}

	if (_bSet)
		Common::AtomicOr(m_InterruptCause, _causemask);
	else
		Common::AtomicAnd(m_InterruptCause, ~_causemask);// is there any reason to have this possibility?
										// F|RES: i think the hw devices reset the interrupt in the PI to 0
										// if the interrupt cause is eliminated. that isnt done by software (afaik)
	UpdateException();
}
예제 #3
0
void SetInterrupt(u32 _causemask, bool _bSet)
{
	_dbg_assert_msg_(POWERPC, Core::IsCPUThread(), "SetInterrupt from wrong thread");

	if (_bSet && !(m_InterruptCause & _causemask))
	{
		DEBUG_LOG(PROCESSORINTERFACE, "Setting Interrupt %s (set)", Debug_GetInterruptName(_causemask));
	}

	if (!_bSet && (m_InterruptCause & _causemask))
	{
		DEBUG_LOG(PROCESSORINTERFACE, "Setting Interrupt %s (clear)", Debug_GetInterruptName(_causemask));
	}

	if (_bSet)
		m_InterruptCause |= _causemask;
	else
		m_InterruptCause &= ~_causemask;// is there any reason to have this possibility?
		                                // F|RES: i think the hw devices reset the interrupt in the PI to 0
		                                // if the interrupt cause is eliminated. that isn't done by software (afaik)
	UpdateException();
}
예제 #4
0
void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
{
	mmio->Register(base | PI_INTERRUPT_CAUSE,
		MMIO::DirectRead<u32>(&m_InterruptCause),
		MMIO::ComplexWrite<u32>([](u32, u32 val) {
			Common::AtomicAnd(m_InterruptCause, ~val);
			UpdateException();
		})
	);

	mmio->Register(base | PI_INTERRUPT_MASK,
		MMIO::DirectRead<u32>(&m_InterruptMask),
		MMIO::ComplexWrite<u32>([](u32, u32 val) {
			m_InterruptMask = val;
			UpdateException();
		})
	);

	mmio->Register(base | PI_FIFO_BASE,
		MMIO::DirectRead<u32>(&Fifo_CPUBase),
		MMIO::DirectWrite<u32>(&Fifo_CPUBase, 0xFFFFFFE0)
	);

	mmio->Register(base | PI_FIFO_END,
		MMIO::DirectRead<u32>(&Fifo_CPUEnd),
		MMIO::DirectWrite<u32>(&Fifo_CPUEnd, 0xFFFFFFE0)
	);

	mmio->Register(base | PI_FIFO_WPTR,
		MMIO::DirectRead<u32>(&Fifo_CPUWritePointer),
		MMIO::DirectWrite<u32>(&Fifo_CPUWritePointer, 0xFFFFFFE0)
	);

	mmio->Register(base | PI_FIFO_RESET,
		MMIO::InvalidRead<u32>(),
		MMIO::ComplexWrite<u32>([](u32, u32 val) {
			WARN_LOG(PROCESSORINTERFACE, "Fifo reset (%08x)", val);
		})
	);

	mmio->Register(base | PI_RESET_CODE,
		MMIO::DirectRead<u32>(&m_ResetCode),
		MMIO::DirectWrite<u32>(&m_ResetCode)
	);

	mmio->Register(base | PI_FLIPPER_REV,
		MMIO::DirectRead<u32>(&m_FlipperRev),
		MMIO::InvalidWrite<u32>()
	);

	// 16 bit reads are based on 32 bit reads.
	for (int i = 0; i < 0x1000; i += 4)
	{
		mmio->Register(base | i,
			MMIO::ReadToLarger<u16>(mmio, base | i, 0),
			MMIO::InvalidWrite<u16>()
		);
		mmio->Register(base | (i + 2),
			MMIO::ReadToLarger<u16>(mmio, base | i, 16),
			MMIO::InvalidWrite<u16>()
		);
	}
}
예제 #5
0
void DBUpdater<T>::ApplyFile(DatabaseWorkerPool<T>& pool, std::string const& host, std::string const& user,
    std::string const& password, std::string const& port_or_socket, std::string const& database, Path const& path)
{
    std::vector<std::string> args;
    args.reserve(8);

    // args[0] represents the program name
    args.push_back("mysql");

    // CLI Client connection info
    args.push_back("-h" + host);
    args.push_back("-u" + user);

    if (!password.empty())
        args.push_back("-p" + password);

    // Check if we want to connect through ip or socket (Unix only)
#ifdef _WIN32

    args.push_back("-P" + port_or_socket);

#else

    if (!std::isdigit(port_or_socket[0]))
    {
        // We can't check if host == "." here, because it is named localhost if socket option is enabled
        args.push_back("-P0");
        args.push_back("--protocol=SOCKET");
        args.push_back("-S" + port_or_socket);
    }
    else
        // generic case
        args.push_back("-P" + port_or_socket);

#endif

    // Set the default charset to utf8
    args.push_back("--default-character-set=utf8");

    // Set max allowed packet to 1 GB
    args.push_back("--max-allowed-packet=1GB");

    // Database
    if (!database.empty())
        args.push_back(database);

    // Invokes a mysql process which doesn't leak credentials to logs
    int const ret = Trinity::StartProcess(DBUpdaterUtil::GetCorrectedMySQLExecutable(), args,
                                 "sql.updates", path.generic_string(), true);

    if (ret != EXIT_SUCCESS)
    {
        TC_LOG_FATAL("sql.updates", "Applying of file \'%s\' to database \'%s\' failed!" \
            " If you are a user, please pull the latest revision from the repository. "
            "Also make sure you have not applied any of the databases with your sql client. "
            "You cannot use auto-update system and import sql files from TrinityCore repository with your sql client. "
            "If you are a developer, please fix your sql query.",
            path.generic_string().c_str(), pool.GetConnectionInfo()->database.c_str());

        throw UpdateException("update failed");
    }
}