Exemplo n.º 1
0
static int wlan_rx_process(unsigned char *buf, unsigned int max_len)
{
	static unsigned int cnt;
	static unsigned int skb;
	unsigned int p = 0;
	r_msg_hdr_t *msg = NULL;
	unsigned char vif_id;
	unsigned char *pData = NULL;
	unsigned short len;
	unsigned char event;
	if ((NULL == buf) || (0 == max_len)) {
		printke("[%s][ERROR]\n", __func__);
		return OK;
	}
	buf = buf + 8;
	msg = (r_msg_hdr_t *) (buf);
	max_len = max_len - 8;
	while (p < max_len) {

		vif_id = msg->mode;
		pData = (unsigned char *)(msg + 1);
		len = msg->len;

		if ((0xFF == msg->type) || (0xFF == msg->subtype))
			break;
		if (HOST_SC2331_PKT == msg->type) {
			pData = pData + msg->subtype;
			len = len - msg->subtype;
			wlan_rx_skb_process(vif_id, pData, len);
		} else if (HOST_SC2331_WAPI == msg->type) {
			wlan_rx_wapi_process(vif_id, pData, len);
		} else if (SC2331_HOST_RSP == msg->type) {
			wlan_rx_rsp_process(vif_id, msg);
		} else if (HOST_SC2331_CMD == msg->type) {
			event = msg->subtype;
			wlan_rx_event_process(vif_id, event, pData, len);
		} else {
			printke("[%s][RX DATA ERR]\n", __func__);
			break;
		}
		p = p + sizeof(t_msg_hdr_t) + ALIGN_4BYTE(msg->len);
		msg = (r_msg_hdr_t *) (buf + p);
		skb++;
	}
	cnt++;
	if (1000 == cnt) {
		printkd("r%d\n", skb);
		cnt = 0;
		skb = 0;
	}
	return OK;
}
Exemplo n.º 2
0
void PackToBin::Pack(const std::string& filepath, 
					 const ee::TexturePacker& tp, 
					 bool compress, 
					 float scale)
{
	std::set<int> ref_pkgs;

	uint32_t default_sym_id = 0xffffffff;
	const std::string default_sym_path = ee::ImageDataMgr::Instance()->GetDefaultSym();
	if (!default_sym_path.empty()) {
		int pkg_id, node_id;
		PackIDMgr::Instance()->QueryID(default_sym_path, pkg_id, node_id, true);
		default_sym_id = simp::NodeID::ComposeID(pkg_id, node_id);
	}

	// src nodes
	std::vector<PackNode*> nodes;
	PackNodeFactory::Instance()->FetchAll(nodes);
	std::vector<PackNode*>::iterator itr = nodes.begin();
	for ( ; itr != nodes.end(); ) 
	{
		PackNode* node = *itr;
		if (!PackIDMgr::Instance()->IsCurrPkg(node)) {
			ref_pkgs.insert(node->GetPkgID());
			itr = nodes.erase(itr);
		} else {
			if (default_sym_id != 0xffffffff && default_sym_id == node->GetID() &&
				default_sym_path != node->GetFilepath()) {
				itr = nodes.erase(itr);
			} else {
				++itr;
			}
		}
	}
	if (nodes.empty()) {
		return;
	}
	std::sort(nodes.begin(), nodes.end(), PackNodeCmp());

	// to pages
	std::vector<Page*> pages;
	Page* page = new Page(simp::SIMP_PAGE_SIZE);
	int page_sz = ALIGN_4BYTE(simp::Page::Size());
	for (int i = 0, n = nodes.size(); i < n; ++i)
	{
		PackNode* node = nodes[i];
		int sz = node->SizeOfUnpackFromBin();
		while (true)
		{
			// head sz
			int num;
			auto& page_nodes = page->GetNodes();
			if (page_nodes.empty()) {
				num = 1;
			} else {
				num = node->GetID() - page_nodes[0]->GetID() + 1;
			}
			int align_n = ALIGN_4BYTE(num);
			int head_sz =
				sizeof(uint8_t) * align_n +  // types
				simp::SIZEOF_POINTER * num;  // nodes

			if (page_sz + head_sz + sz <= page->GetSize()) {
				page_sz += sz;
				page->Add(node);
				break;
			}
			if (page->NodeNum() > 0) {
				page->Condense(page_sz + head_sz);
				pages.push_back(page);
				page = new Page(simp::SIMP_PAGE_SIZE);
				page_sz = ALIGN_4BYTE(simp::Page::Size());
			} else {
				page->Enlarge();
			}
		}
	}
	if (page->NodeNum() > 0) 
	{
		// head sz
		auto& page_nodes = page->GetNodes();
		int num = page_nodes.back()->GetID() - page_nodes.front()->GetID() + 1;
		int align_n = ALIGN_4BYTE(num);
		int head_sz =
			sizeof(uint8_t) * align_n +  // types
			simp::SIZEOF_POINTER * num;  // nodes

		page->Condense(page_sz + head_sz);
		pages.push_back(page);
	}

	// pack index
	PageIndex(filepath + ".epe", pages, compress, scale, ref_pkgs);

	// pack pages
	for (int i = 0, n = pages.size(); i < n; ++i) {
		std::string path = filepath + "." + ee::StringHelper::ToString(i + 1) + ".epe";
		PackPage(path, *pages[i], tp, compress);
	}
}