コード例 #1
0
ファイル: device_init.c プロジェクト: t0mac0/wiimouse
//*****************************************************************************
//
// Exported Functions
//
//*****************************************************************************
PROTECTED bool DeviceInit( void )
{
    bool retval = TRUE;
    Result result;

    // initialize device critical hardware
    ASSERT(CriticalHwInit());

    // initialize logging
    ASSERT(RESULT_IS_SUCCESS(result, LOG_Init()));

    // register the default usart as the default logging output destination
    ASSERT(RESULT_IS_SUCCESS(result, LOG_RegisterOutputDest(LOG_OUTPUT_DEFAULT, HW_USART_DefaultOutputDest, TRUE)));
    LOG_Printf("Logging enabled on default USART\n");

    //  initialize device modules
    if( RESULT_IS_ERROR(result, MOD_MGR_Init()) )
    {
        LOG_CatchError(result);
        ASSERT(0);
    }

    // initialize the system timer
    ASSERT(UTIL_TIMER_Init());

    return retval;
}
コード例 #2
0
ファイル: block_manager.cpp プロジェクト: troywang/ecfs
int BlockManager::delete_block (int32_t blockid)
{
	boost::mutex::scoped_lock lock(mMutex);

	BlockMap::iterator it = mCommitted.find(blockid);
	if (it == mCommitted.end())
		return RESULT_SUCCESS;

	int ret = mServer.get_oplog_manager().del_block(blockid);
	if (!RESULT_IS_SUCCESS(ret))
		return ret;

	BlockInfo *info = it->second;
	for (int i = 0; i < FLAGS_N; i++)
	{
		int32_t cid = info->chunkids[i];
		int16_t nid = NODE_ID(cid);
		NodeChunkMap::iterator it = mNodeChunks.find(nid);
		if (it == mNodeChunks.end()) {
			LOG(ERROR) << "!!!BUG!!!, not found node chunks " << nid;
			continue;
		}

		it->second->mChunkInuse.erase(cid);
	}
	mCommitted.erase(it);

	return RESULT_SUCCESS;
}
コード例 #3
0
ファイル: nunchuck_sm_actions.c プロジェクト: t0mac0/wiimouse
PROTECTED Result NunchuckActionNunchuckReconnect(void)
{
	Result result = NUNCHUCK_RESULT(SUCCESS);

	LOG_Printf("NunchuckActionNunchuckReconnect\n");

	if( RESULT_IS_SUCCESS(result, NunchuckCtlConnect()) )
	{
		NunchuckReaderEnableReading();

		NunchuckHidReporterEnableReporting();

		NunchuckProcessorTaskResume();

	}
	else
	{
		if( (NunchuckCurrentEvent == NUNCHUCK_SM_EVENT_NUNCHUCK_RECONNECT) ||
				(NunchuckCurrentEvent == NUNCHUCK_SM_EVENT_NUNCHUCK_ENABLE) )
		{
			NunchuckSmIssueEvent(NUNCHUCK_SM_EVENT_NUNCHUCK_RECONNECT);
		}
	}


	return result;
}
コード例 #4
0
ファイル: packet_mgr_task.c プロジェクト: t0mac0/wiimouse
//*****************************************************************************//
PRIVATE inline void ProcessInputPackets( void )
{
    Result result;
    LIB_ARRAY_LIST_Iterator iterator;
    pPacketMgrTagListenerInfo listener;
    pLIB_XML_Tag tag;
    uint32 packetId;

    tag = NULL;
    packetId = 0;

    OS_TAKE_MUTEX(packetMgrInputBuffer.Mutex);

    // TODO: should be a semaphore
    if( packetMgrInputBuffer.PacketsAvailable > 0 )
    {
        if( RESULT_IS_SUCCESS(result, PacketMgrParsePacket(&tag, &packetId)) )
        {
            if( LIB_ARRAY_LIST_IteratorInit(packetMgrTagListenerList, &iterator) )
            {
                while( LIB_ARRAY_LIST_IteratorHasNext(&iterator) )
                {
                    listener = (pPacketMgrTagListenerInfo) LIB_ARRAY_LIST_IteratorNext(&iterator);

                    if( strncmp(listener->Tag, tag->Tag, LIB_XML_MAX_TAG_LEN) == 0 )
                    {
                        listener->CallBack(tag, packetId);
                    }
                }
            }
        }
    }

    OS_GIVE_MUTEX(packetMgrInputBuffer.Mutex);
}
コード例 #5
0
ファイル: block_manager.cpp プロジェクト: troywang/ecfs
int BlockManager::pick_chunks (int32_t count, const std::set<int32_t> &excludes, /* out */std::vector<int32_t> &chunks)
{
	std::set<int16_t> exclude_nodes;
	for (std::set<int32_t>::iterator it = excludes.begin(); it != excludes.end(); it++)
	{
		int16_t nodeid = NODE_ID(*it);
		exclude_nodes.insert(nodeid);
	}

	boost::mutex::scoped_lock lock(mMutex);
	for (NodeChunkMap::iterator it = mNodeChunks.begin(); it != mNodeChunks.end(); it++)
	{
		if (!it->second->has_enough_chunks())
			exclude_nodes.insert(it->first);
	}

	std::vector<int16_t> picked_nodes;
	int ret = mServer.get_node_manager().pick_data_nodes(count, exclude_nodes, picked_nodes);
	if (!RESULT_IS_SUCCESS(ret))
		return ret;

	for (size_t i = 0; i < picked_nodes.size(); i++)
	{
		int16_t nodeid = picked_nodes[i];
		NodeChunkMap::iterator it = mNodeChunks.find(nodeid);
		if (it == mNodeChunks.end()) {
			LOG(ERROR) << "!!!BUG!!!, not found node chunk info " << nodeid;
			return RESULT_ERR_PROG_BUG;
		}

		NodeChunkInfo *info = it->second;
		int32_t chunkid = pick_one_chunk(info);
		if (chunkid == -1) {
			LOG(ERROR) << "!!!BUG!!!, cannot pick one chunk ";
			return RESULT_ERR_PROG_BUG;
		}

		chunks.push_back(chunkid);

		LOG_INFO_SMART << "pick chunk " << chunkid << " from " << nodeid;
	}

	return RESULT_SUCCESS;
}
コード例 #6
0
ファイル: block_manager.cpp プロジェクト: troywang/ecfs
void BlockManager::do_chunk_report (int16_t nodeid)
{
	bool success = false;
	boost::shared_ptr<DatanodeThriftConnection> pConn;
	try
	{
		ResultReportChunks _ret;
		pConn = mServer.get_datanode_connection(nodeid);
		pConn->get_client()->report_chunks(_ret);
		success = RESULT_IS_SUCCESS(_ret.result.code);
		if (success) {
			process_chunks(nodeid, _ret.chunkUnUse, _ret.chunkInUse);
		}
	} catch (ErasureException &err) {
		LOG(ERROR) << "failed to do chunk report: " << err.what();
	} catch (apache::thrift::TException &err) {
		LOG(ERROR) << "failed to do chunk report: " << err.what();
		if (pConn.get())
			pConn->destroy();
	}

	mServer.done_chunk_report(nodeid, success);
}