Ejemplo n.º 1
0
static int wlan_close(struct net_device *dev)
{
	printkd("%s %s enter\n", __func__, dev->name);
	netif_stop_queue(dev);
	printkd("%s %s ok\n", __func__, dev->name);
	return 0;
}
Ejemplo n.º 2
0
void wakeup_timer_func(unsigned long data)
{
	if ((g_wlan.wlan_trans.sem.count <= 0) && (0 == g_wlan.hw.can_sleep)) {
		printkd("timer[3]\n");
		g_wlan.hw.can_sleep = 1;
		trans_up();
		return;
	}
	printkd("timer[2]\n");
	mod_timer(&(g_wlan.hw.wakeup_timer),
		  jiffies + msecs_to_jiffies(g_wlan.hw.wakeup_time));
}
Ejemplo n.º 3
0
static int wlan_rx_skb_process(const unsigned char vif_id, unsigned char *pData,
			       unsigned short len)
{
	struct sk_buff *skb;
	struct net_device *ndev = g_wlan.netif[vif_id].ndev;
	if ((NULL == pData) || (0 == len) || (NULL == ndev)) {
		printkd("[%s][%d][err]\n", __func__, (int)vif_id);
		return ERROR;
	}
	skb = dev_alloc_skb(len + NET_IP_ALIGN);
	if (NULL == skb)
		return ERROR;
	skb_reserve(skb, NET_IP_ALIGN);
	memcpy(skb->data, pData, len);

	skb_put(skb, len);
	skb->dev = ndev;
	skb->protocol = eth_type_trans(skb, ndev);
	ndev->stats.rx_packets++;
	printkp("rx_skb:%d\n", (int)(ndev->stats.rx_packets));
	ndev->stats.rx_bytes += skb->len;
	if (in_interrupt())
		netif_rx(skb);
	else
		netif_rx_ni(skb);
	return OK;
}
Ejemplo n.º 4
0
static int hw_tx(const unsigned short chn, unsigned char *buf, unsigned int len)
{
	int ret;
	static unsigned int cnt;
	static unsigned int skb;
	tx_big_hdr_t *big_hdr;

	big_hdr = (tx_big_hdr_t *) buf;
	if ((PKT_AGGR_NUM < big_hdr->msg_num) || (0 == big_hdr->msg_num)) {
		ASSERT();
		return ERROR;
	}
	big_hdr->tx_cnt = g_wlan.hw.tx_cnt;
	printkp("[tx][%d][%d]\n", big_hdr->tx_cnt, chn);
	len = (len + 1023) & 0xFC00;
	wlan_tx_buf_decode(buf, len);
	ret = sdio_dev_write(chn, buf, len);
	if (0 != ret) {
		printke("call sdio_dev_write err:%d\n", ret);
		return HW_WRITE_ERROR;
	}
	skb = skb + big_hdr->msg_num;
	cnt++;
	if (1000 == cnt) {
		printkd("w%d\n", skb);
		cnt = 0;
		skb = 0;
	}
	g_wlan.hw.tx_cnt++;
	return OK;
}
Ejemplo n.º 5
0
void wlan_sleep(void)
{
	if ((1 != g_wlan.hw.wakeup) || (0 == g_wlan.hw.can_sleep))
		return;
	g_wlan.hw.wakeup = 0;
	printkd("time[0]\n");
	wake_unlock(&g_wlan.hw.wlan_lock);
	return;
}
Ejemplo n.º 6
0
void thread_sched_policy(wlan_thread_t *thread)
{
	int ret;
	struct sched_param param;
	param.sched_priority = thread->prio;
	ret = sched_setscheduler(current, SCHED_FIFO, &param);
	printkd("sched_setscheduler, prio:%d,ret:%d\n", param.sched_priority,
		ret);
	return;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
int Block::mmSetPermission(uint64_t i_va, uint64_t i_size,
                           uint64_t i_access_type)
{
    int l_rc = 0;

    // Need to align the page address and the size on a page boundary.
    uint64_t l_aligned_va = ALIGN_PAGE_DOWN(i_va);
    uint64_t l_aligned_size = ALIGN_PAGE(i_size);


    if(!isContained(l_aligned_va))
    {
        return (iv_nextBlock ?
                iv_nextBlock->mmSetPermission(i_va,i_size,i_access_type) :
                -EINVAL);
    }

    //printk("\n             aligned VA = 0x%.lX aligned size = %ld access_type = 0x%.lX\n", l_aligned_va,	l_aligned_size, i_access_type);

    // if i_size is zero we are only updating 1 page; increment the size to
    // one page.
    if (i_size == 0)
    {
        l_aligned_size+=PAGESIZE;
    }

    // loop through all the pages asked for based on passed aligned
    // Virtual address and passed in aligned size.
    for(uint64_t cur_page_addr = l_aligned_va;
        cur_page_addr < (l_aligned_va + l_aligned_size);
        cur_page_addr += PAGESIZE)
    {

        ShadowPTE* spte = getPTE(cur_page_addr);

        // if the page present need to delete the hardware
        // page table entry before we set permissions.
        if (spte->isPresent())
        {
            // delete the hardware page table entry
            PageTableManager::delEntry(cur_page_addr);
        }

        if (setPermSPTE(spte, i_access_type))
        {
            printkd("               SET PERMISSIONS.. FAILED \n");
            return -EINVAL;
        }
    }

    return l_rc;
}
Ejemplo n.º 9
0
int wlan_wakeup(void)
{
	int ret;
	if (0 != g_wlan.hw.wakeup)
		return OK;
	wake_lock(&g_wlan.hw.wlan_lock);
	printkd("time[1]\n");
	mod_timer(&(g_wlan.hw.wakeup_timer),
		  jiffies + msecs_to_jiffies(g_wlan.hw.wakeup_time));
	g_wlan.hw.wakeup = 1;
	g_wlan.hw.can_sleep = 0;
	return ret;
}
Ejemplo n.º 10
0
static int wlan_rx_wapi_process(const unsigned char vif_id,
				unsigned char *pData, unsigned short len)
{
	struct ieee80211_hdr_3addr *addr;
	int decryp_data_len = 0;
	struct sk_buff *skb;
	u8 snap_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
	wlan_vif_t *vif;
	struct net_device *ndev;

	vif = &(g_wlan.netif[vif_id]);
	ndev = vif->ndev;
	if ((NULL == pData) || (0 == len) || (NULL == ndev)) {
		printkd("[%s][%d][err]\n", __func__, (int)vif_id);
		return ERROR;
	}
	addr = (struct ieee80211_hdr_3addr *)pData;
	skb = dev_alloc_skb(len + NET_IP_ALIGN);
	if (NULL == skb)
		return ERROR;
	skb_reserve(skb, NET_IP_ALIGN);

	decryp_data_len =
	    wlan_rx_wapi_decryption(vif, (unsigned char *)addr, 24, (len - 24),
				    (skb->data + 12));
	if (decryp_data_len == 0) {
		dev_kfree_skb(skb);
		return ERROR;
	}
	if (memcmp((skb->data + 12), snap_header, sizeof(snap_header)) == 0) {
		skb_reserve(skb, 6);
		memcpy(skb->data, addr->addr1, 6);
		memcpy(skb->data + 6, addr->addr2, 6);
		skb_put(skb, (decryp_data_len + 6));
	} else {
		/* copy eth header */
		memcpy(skb->data, addr->addr3, 6);
		memcpy(skb->data + 6, addr->addr2, 6);
		skb_put(skb, (decryp_data_len + 12));
	}
	skb->dev = ndev;
	skb->protocol = eth_type_trans(skb, ndev);
	ndev->stats.rx_packets++;
	printkp("rx_skb:%d\n", (int)(ndev->stats.rx_packets));
	ndev->stats.rx_bytes += skb->len;
	if (in_interrupt())
		netif_rx(skb);
	else
		netif_rx_ni(skb);
	return OK;
}
Ejemplo n.º 11
0
static int wlan_xmit(struct sk_buff *skb, struct net_device *dev)
{
	wlan_vif_t *vif;
	tx_msg_t msg = { 0 };
	msg_q_t *msg_q;
	int ret, addr_len = 0;
	struct sk_buff *wapi_skb;

	vif = ndev_to_vif(dev);
	msg_q = wlan_tcpack_q(vif, skb->data, skb->len);

	if (vif->cfg80211.cipher_type == WAPI
	    && vif->cfg80211.connect_status == ITM_CONNECTED
	    && vif->cfg80211.key_len[PAIRWISE][vif->cfg80211.
					       key_index[PAIRWISE]] != 0
	    && (*(u16 *) ((u8 *) skb->data + ETH_PKT_TYPE_OFFSET) != 0xb488)) {
		wapi_skb = dev_alloc_skb(skb->len + 100 + NET_IP_ALIGN);
		skb_reserve(wapi_skb, NET_IP_ALIGN);
		memcpy(wapi_skb->data, skb->data, ETHERNET_HDR_LEN);
		addr_len =
		    wlan_tx_wapi_encryption(vif, skb->data,
					    (skb->len - ETHERNET_HDR_LEN),
					    ((unsigned char *)(wapi_skb->data) +
					     ETHERNET_HDR_LEN));
		addr_len = addr_len + ETHERNET_HDR_LEN;
		skb_put(wapi_skb, addr_len);
		dev_kfree_skb(skb);
		skb = wapi_skb;
	}

	msg.p = (void *)skb;
	msg.slice[0].data = skb->data;
	msg.slice[0].len = skb->len;
	msg.hdr.mode = vif->id;
	msg.hdr.type = HOST_SC2331_PKT;
	msg.hdr.subtype = 0;
	msg.hdr.len = skb->len;

	ret = msg_q_in(msg_q, &msg);
	if (OK != ret) {
		printkd("L-PKT\n");
		dev_kfree_skb(skb);
		return NETDEV_TX_OK;
	}
	vif->ndev->stats.tx_bytes += skb->len;
	vif->ndev->stats.tx_packets++;
	dev->trans_start = jiffies;
	g_wlan.wlan_core.need_tx++;
	core_up();
	return NETDEV_TX_OK;
}
Ejemplo n.º 12
0
void krad_websocket_set_sample_rate ( krad_ipc_session_data_t *krad_ipc_session_data, int sample_rate) {

	printkd ("set_sample_rate called %d", sample_rate);
	
	cJSON *msg;
	
	cJSON_AddItemToArray(krad_ipc_session_data->msgs, msg = cJSON_CreateObject());
	
	cJSON_AddStringToObject (msg, "com", "kradmixer");
	
	cJSON_AddStringToObject (msg, "cmd", "set_sample_rate");
	cJSON_AddNumberToObject (msg, "sample_rate", sample_rate);
	
}
Ejemplo n.º 13
0
void Block::releaseSPTE(ShadowPTE* i_pte)
{
    i_pte->setDirty(false);
    i_pte->setPresent(false);

    // set the permission of the physical address pte entry back to writable
    // now that the associated VA Spte has been released.
    if (BaseSegment::mmSetPermission(
            reinterpret_cast<void*>(i_pte->getPageAddr()),
            0, WRITABLE))
    {
        printkd("Got an error setting permission during Flush\n");
    }

    i_pte->setPageAddr(NULL);
}
Ejemplo n.º 14
0
void Block::attachSPTE(void *i_vaddr)
{

    uint64_t l_vaddr = reinterpret_cast<uint64_t>(i_vaddr);
    ShadowPTE* l_pte = getPTE(l_vaddr);

    //Set the present bit for the address associated with this block
    l_pte->setPresent(true);

    // Determine access type.
    uint64_t l_access = (iv_mappedToPhysical ? BYPASS_HRMOR : 0);
    if (l_pte->isExecutable())
    {
        l_access |= EXECUTABLE;
    }
    else if (l_pte->isWritable() && l_pte->isDirty())
    {
        l_access |= WRITABLE;
    }
    else
    {
        l_access |= READ_ONLY;
    }

    //Add page table entry
    PageTableManager::addEntry((l_vaddr / PAGESIZE) * PAGESIZE,
                                l_pte->getPage(),
                                l_access);

    // update permission for the page that corresponds to the physical page
    // addr now that we have handled the page fault.
    if (BaseSegment::mmSetPermission(
            reinterpret_cast<void*>(l_pte->getPageAddr()), 0, READ_ONLY))
    {
       printkd("Got an error trying to set permissions in handle Response "
               "msg handler \n");
    }

}
Ejemplo n.º 15
0
int krad_rebuilder_read_packet (krad_rebuilder_t *krad_rebuilder, unsigned char *data, int track, int *keyframe) {

  int s;
  
  track = track - 1;  
  
  if (krad_rebuilder->tracks[track].slice_read_position < (krad_rebuilder->tracks[track].slice_position - 5)) {
    printf ("fell behind and readjusted %d \n", krad_rebuilder->tracks[track].slice_read_position);
    krad_rebuilder->tracks[track].slice_read_position = krad_rebuilder->tracks[track].slice_position - 5;
    printkd("%d\n", krad_rebuilder->tracks[track].slice_read_position);
  }

  for (s = 0; s < krad_rebuilder->tracks[track].slice_count; s++) {
    if (krad_rebuilder->tracks[track].slices[s].seq == krad_rebuilder->tracks[track].slice_read_position) {
      if (krad_rebuilder->tracks[track].slices[s].fill == krad_rebuilder->tracks[track].slices[s].size) {
        break;
      }
    }
  }

  if (s == krad_rebuilder->tracks[track].slice_count) {
    return 0;
  }

  memcpy (data, krad_rebuilder->tracks[track].slices[s].data, krad_rebuilder->tracks[track].slices[s].size);

  if (keyframe != NULL) {
    if (krad_rebuilder->tracks[track].slices[s].keyframe == 1) {
      *keyframe = 1;
    } else {
      *keyframe = 0;
    }
  }

  krad_rebuilder->tracks[track].slice_read_position++;

  return krad_rebuilder->tracks[track].slices[s].size;
}
Ejemplo n.º 16
0
void krad_decklink_capture_info () {

	IDeckLink *deckLink;
	IDeckLinkInput *deckLinkInput;
	IDeckLinkIterator *deckLinkIterator;
	IDeckLinkDisplayModeIterator *displayModeIterator;
	IDeckLinkDisplayMode *displayMode;
	
	HRESULT result;
	int displayModeCount;
	char *displayModeString;

	displayModeString = NULL;
	displayModeCount = 0;
	
	deckLinkIterator = CreateDeckLinkIteratorInstance();
	
	if (!deckLinkIterator) {
		printke ("Krad Decklink: This application requires the DeckLink drivers installed.\n");
	}
	
	/* Connect to the first DeckLink instance */
	result = deckLinkIterator->Next(&deckLink);
	if (result != S_OK) {
		printke ("Krad Decklink: No DeckLink PCI cards found.\n");
	}
    
	result = deckLink->QueryInterface(IID_IDeckLinkInput, (void**)&deckLinkInput);
	if (result != S_OK) {
		printke ("Krad Decklink: Fail QueryInterface\n");
	}
	
	result = deckLinkInput->GetDisplayModeIterator(&displayModeIterator);
	if (result != S_OK) {
		printke ("Krad Decklink: Could not obtain the video output display mode iterator - result = %08x\n", result);
	}


    while (displayModeIterator->Next(&displayMode) == S_OK) {

        result = displayMode->GetName((const char **) &displayModeString);
        
        if (result == S_OK) {
			
			BMDTimeValue frameRateDuration, frameRateScale;
			displayMode->GetFrameRate(&frameRateDuration, &frameRateScale);

			printkd ("%2d:  %-20s \t %li x %li \t %g FPS\n", 
				displayModeCount, displayModeString, displayMode->GetWidth(), displayMode->GetHeight(), 
				(double)frameRateScale / (double)frameRateDuration);
			
            free (displayModeString);
			displayModeCount++;
		}
		
		displayMode->Release();
	}
	
	if (displayModeIterator != NULL) {
		displayModeIterator->Release();
		displayModeIterator = NULL;
	}

    if (deckLinkInput != NULL) {
        deckLinkInput->Release();
        deckLinkInput = NULL;
    }

    if (deckLink != NULL) {
        deckLink->Release();
        deckLink = NULL;
    }

	if (deckLinkIterator != NULL) {
		deckLinkIterator->Release();
	}
}
Ejemplo n.º 17
0
int MessageHandler::recvMessage(msg_t* i_msg)
{
    // Verify userspace didn't give a non-kernel message type.
    if (i_msg->type < MSG_FIRST_SYS_TYPE)
    {
        printkd("MessageHandler::recvMessage> type=%d\n", i_msg->type);
        return -EINVAL;
    }

    // Lock subsystem spinlock.
    if (iv_lock) iv_lock->lock();

    // List of tasks to end due to errors.
    //     Ending the task must happen outside of the spinlock due to
    //     requirements of TaskManager::endTask.
    Util::Locked::Queue<task_t> endTaskList;

    // Get <key, rc> from response.
    MessageHandler_Pending::key_type key =
        reinterpret_cast<MessageHandler_Pending::key_type>(i_msg->data[0]);
    int msg_rc = static_cast<int>(i_msg->data[1]);

    // Handle all pending responses.
    bool restored_task = false;
    MessageHandler_Pending* mhp = NULL;
    while (NULL != (mhp = iv_pending.find(key)))
    {
        task_t* deferred_task = mhp->task;

        // Call 'handle response'.
        HandleResult rc = this->handleResponse(
                static_cast<msg_sys_types_t>(i_msg->type),
                key, mhp->task, msg_rc);

        // Remove pending information from outstanding queue.
        iv_pending.erase(mhp);
        delete mhp;

        // If there is no associated task then there is nothing to do, find
        // next pending response.
        if (!deferred_task) continue;

        // Handle action requested from 'handle response'.
        if ((SUCCESS == rc) || (!msg_rc && UNHANDLED_RC == rc))
        {
            // Successful response, resume task.

            if (!restored_task) // Immediately execute first deferred task.
            {
                restored_task = true;
                TaskManager::setCurrentTask(deferred_task);
            }
            else // Add other deferred tasks to scheduler ready queue.
            {
                deferred_task->cpu->scheduler->addTask(deferred_task);
            }
        }
        else if (UNHANDLED_RC == rc)
        {
            // Unsuccessful, unhandled response.  Kill task.
            printk("Unhandled msg rc %d for key %p on task %d @ %p\n",
                   msg_rc, key, deferred_task->tid, deferred_task->context.nip);
            endTaskList.insert(deferred_task);
        }
        else if (CONTINUE_DEFER == rc)
        {
            // Requested to continue deferring task.  Do nothing.
        }
        else
        {
            // Logic bug (new HandleResult?).  Shouldn't be here.
            kassert(false);
        }
    }

    // Finished handling the response, unlock subsystem.
    if (iv_lock) iv_lock->unlock();

    while(task_t* end_task = endTaskList.remove())
    {
        TaskManager::endTask(end_task, i_msg->extra_data, TASK_STATUS_CRASHED);
    }

    // Release memory for message (created from sendMsg).
    delete(i_msg);

    return 0;
}
Ejemplo n.º 18
0
    void Daemon::pruneTraceEntries(bool i_all)
    {
        ComponentList::List::iterator component;

        size_t pruned = 0;

        // Iterate through the components...
        bool more = iv_service->iv_compList->first(component);
        while(more)
        {
            Entry* entry = component->iv_last;
            Entry* orig_entry = entry;

            // Invalidate entries until the component is small enough.
            while((entry) &&
                    ((component->iv_curSize > component->iv_maxSize) ||
                     i_all)
                 )
            {
                if (!reinterpret_cast<BufferPage*>(
                        ALIGN_PAGE_DOWN(
                            reinterpret_cast<uint64_t>(entry)))->commonPage)
                {
                    break;
                }

                entry->comp = NULL; // Invalidate entry.

                __sync_sub_and_fetch(&component->iv_curSize, entry->size);
                pruned += entry->size;

                entry = entry->prev;
            }

            if (entry != orig_entry)
            {
                printkd("%s,", component->iv_compName);

                // Break chain of linked list.
                if (entry != NULL)
                {
                    entry->next = NULL;
                }

                // Update component pointers.
                Buffer* b =
                    iv_service->iv_buffers[component->iv_bufferType];

                // consumerOp pseudo-code:
                //    if (entry == NULL) component->first = NULL;
                //    component->last = entry;
                b->consumerOp(&entry, NULL,
                              &component->iv_first, NULL,
                              &component->iv_last, entry);
            }

            // Get next component.
            more = iv_service->iv_compList->next(component);
        }

        // Record size of pruned entries in a global.
        if (pruned)
        {
            printkd(": pruned %ld\n", pruned);
            iv_totalPruned += pruned;
        }
    }
Ejemplo n.º 19
0
void krad_mixer_portgroup_destroy (krad_mixer_t *krad_mixer, krad_mixer_portgroup_t *portgroup) {

  int c;

  if (portgroup == NULL) {
    return;
  }
  
  if (portgroup->crossfade_group != NULL) {
    krad_mixer_crossfade_group_destroy (krad_mixer, portgroup->crossfade_group);
  }
  
  krad_mixer_portgroup_mark_destroy (krad_mixer, portgroup);

  while (portgroup->active != 4) {
    usleep (1000);
  }

  portgroup->delay = 0;
  portgroup->delay_actual = 0;

  printkd("Krad Mixer: Removing %d channel Portgroup %s", portgroup->channels, portgroup->sysname);

  for (c = 0; c < KRAD_MIXER_MAX_CHANNELS; c++) {
    switch ( portgroup->io_type ) {
      case KRAD_TONE:
        free ( portgroup->samples[c] );      
        break;
      case MIXBUS:
        free ( portgroup->samples[c] );
        break;
      case KRAD_AUDIO:
        break;
      case KRAD_LINK:
        free ( portgroup->samples[c] );      
        break;
      case KLOCALSHM:
        break;
    }
  }

  switch ( portgroup->io_type ) {
    case KRAD_TONE:
      krad_tone_destroy (portgroup->io_ptr);
    case MIXBUS:
      break;
    case KRAD_AUDIO:
      krad_audio_portgroup_destroy (portgroup->io_ptr);
      break;
    case KRAD_LINK:
      break;
    case KLOCALSHM:
      krad_mixer_local_portgroup_destroy (portgroup->io_ptr);
      break;
  }
  
  if (portgroup->krad_xmms != NULL) {
    krad_xmms_destroy (portgroup->krad_xmms);
    portgroup->krad_xmms = NULL;
  }
  
  if (portgroup->io_type != KRAD_LINK) {
    krad_tags_destroy (portgroup->krad_tags);  
  }  
  
  if (portgroup->effects != NULL) {
    kr_effects_destroy (portgroup->effects);
    portgroup->effects = NULL;
  }

  portgroup->destroy_mark = 0;
  portgroup->active = 0;
}
Ejemplo n.º 20
0
static void wlan_early_suspend(struct early_suspend *es)
{
	printkd("[%s]\n", __func__);
	wlan_cmd_sleep(1);
}
Ejemplo n.º 21
0
static void wlan_late_resume(struct early_suspend *es)
{
	printkd("[%s]\n", __func__);
	wlan_cmd_sleep(2);
}
Ejemplo n.º 22
0
int krad_websocket_ipc_handler ( krad_ipc_client_t *krad_ipc, void *ptr ) {

	krad_ipc_session_data_t *krad_ipc_session_data = (krad_ipc_session_data_t *)ptr;

	int has_xmms2;

	uint32_t message;
	uint32_t ebml_id;	
	uint64_t ebml_data_size;
	//uint64_t element;
	int list_count;
	int list_size;
	int i;
	float floatval;	
	char portname_actual[256];
	char controlname_actual[1024];
	char string_actual[1024];	
	int bytes_read;
	string_actual[0] = '\0';	
	portname_actual[0] = '\0';
	controlname_actual[0] = '\0';
	
	char *portname = portname_actual;
	char *controlname = controlname_actual;
	char *string = string_actual;	
	char crossfadename_actual[1024];	
	char *crossfadename = crossfadename_actual;
	float crossfade;	
	
	uint64_t number;
	uint64_t numbers[16];	
	
	char tag_item_actual[256];	
	char tag_name_actual[256];
	char tag_value_actual[1024];
	
	tag_name_actual[0] = '\0';
	tag_item_actual[0] = '\0';
	tag_value_actual[0] = '\0';
	
	char *tag_item = tag_item_actual;
	char *tag_name = tag_name_actual;
	char *tag_value = tag_value_actual;
	
	krad_link_rep_t *krad_link_rep;
	
	krad_link_rep = NULL;
	
	has_xmms2 = 0;	
	
	bytes_read = 0;
	ebml_id = 0;
	list_size = 0;	
	floatval = 0;
	message = 0;
	ebml_data_size = 0;
	//element = 0;
	i = 0;
	
	krad_ebml_read_element ( krad_ipc->krad_ebml, &message, &ebml_data_size);

	switch ( message ) {


	
		case EBML_ID_KRAD_RADIO_MSG:
				//printf("Received KRAD_RADIO_MSG %zu bytes of data.\n", ebml_data_size);		
		
			krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);
			switch ( ebml_id ) {
			
				case EBML_ID_KRAD_RADIO_SYSTEM_CPU_USAGE:
					number = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					//printk ("System CPU Usage: %d%%", number);
					krad_websocket_set_cpu_usage (krad_ipc_session_data, number);
					break;

				case EBML_ID_KRAD_RADIO_TAG_LIST:
					//printf("Received Tag list %"PRIu64" bytes of data.\n", ebml_data_size);
					list_size = ebml_data_size;
					while ((list_size) && ((bytes_read += krad_ipc_client_read_tag ( krad_ipc, &tag_item, &tag_name, &tag_value )) <= list_size)) {
						//printk ("%s: %s - %s", tag_item, tag_name, tag_value);
						krad_websocket_set_tag (krad_ipc_session_data, tag_item, tag_name, tag_value);
						if (bytes_read == list_size) {
							break;
						}
					}
					break;
				case EBML_ID_KRAD_RADIO_TAG:
					krad_ipc_client_read_tag_inner ( krad_ipc, &tag_item, &tag_name, &tag_value );
					//printk ("%s: %s - %s", tag_item, tag_name, tag_value);
					krad_websocket_set_tag (krad_ipc_session_data, tag_item, tag_name, tag_value);
					break;

				case EBML_ID_KRAD_RADIO_UPTIME:
					number = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					printkd ("Uptime: %"PRIu64"", number);
					break;
				case EBML_ID_KRAD_RADIO_SYSTEM_INFO:
					krad_ebml_read_string (krad_ipc->krad_ebml, string, ebml_data_size);
					printkd ("%s", string);
					break;

			}
	
	
			break;
	
		case EBML_ID_KRAD_LINK_MSG:
			krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);

			switch ( ebml_id ) {
			
				case EBML_ID_KRAD_LINK_DECKLINK_LIST:

					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);
					list_count = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					for (i = 0; i < list_count; i++) {
						krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);						
						krad_ebml_read_string (krad_ipc->krad_ebml, string, ebml_data_size);
						printk("%d: %s\n", i, string);
						krad_websocket_add_decklink_device (krad_ipc_session_data, string, i);						
					}	
					break;
							
			
				case EBML_ID_KRAD_LINK_LINK_LIST:
					//printf("Received LINK control list %"PRIu64" bytes of data.\n", ebml_data_size);

					list_size = ebml_data_size;
					i = 0;
					while ((list_size) && ((bytes_read += krad_ipc_client_read_link ( krad_ipc, string, &krad_link_rep)) <= list_size)) {
						//printkd ("%d: %s\n", i, string);						
						krad_websocket_add_link (krad_ipc_session_data, krad_link_rep);
						i++;
						free (krad_link_rep);
						
						if (bytes_read == list_size) {
							break;
						}
					}	
					break;
					
					
				case EBML_ID_KRAD_LINK_LINK_CREATED:
				
					krad_ipc_client_read_link ( krad_ipc, string, &krad_link_rep);
					krad_websocket_add_link (krad_ipc_session_data, krad_link_rep);
					free (krad_link_rep);
					
					break;

				case EBML_ID_KRAD_LINK_LINK_UPDATED:
			
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);				
					numbers[0] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);

					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);			
					if ((ebml_id == EBML_ID_KRAD_LINK_LINK_OPUS_BANDWIDTH) || (ebml_id == EBML_ID_KRAD_LINK_LINK_OPUS_SIGNAL)) {
						krad_ebml_read_string (krad_ipc->krad_ebml, string, ebml_data_size);
						krad_websocket_update_link_string (krad_ipc_session_data, numbers[0], ebml_id, string);
					} else {
						numbers[1] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
						krad_websocket_update_link_number (krad_ipc_session_data, numbers[0], ebml_id, numbers[1]);						
					}

					break;

				case EBML_ID_KRAD_LINK_LINK_DESTROYED:
					
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);				
					numbers[0] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					
					krad_websocket_remove_link (krad_ipc_session_data, numbers[0]);
					
					break;

				default:
					//printkd ("Received KRAD_LINK_MSG %"PRIu64" bytes of data.\n", ebml_data_size);
					break;
			}

			break;

		case EBML_ID_KRAD_COMPOSITOR_MSG:
			//printkd ("krad_radio_websocket_ipc_handler got message from krad COMPOSITOR\n");
			krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);
			
			switch ( ebml_id ) {
				case EBML_ID_KRAD_COMPOSITOR_FRAME_RATE:
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);				
					numbers[0] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);					
					numbers[1] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					krad_websocket_set_frame_rate ( krad_ipc_session_data, numbers[0], numbers[1]);
					break;
				case EBML_ID_KRAD_COMPOSITOR_FRAME_SIZE:
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);				
					numbers[0] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);					
					numbers[1] = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					krad_websocket_set_frame_size ( krad_ipc_session_data, numbers[0], numbers[1]);
					break;
			}
					
			
			break;
			
		case EBML_ID_KRAD_MIXER_MSG:
//			printkd ("krad_radio_websocket_ipc_handler got message from krad mixer\n");
//			krad_ipc_server_broadcast ( krad_ipc, EBML_ID_KRAD_MIXER_MSG, EBML_ID_KRAD_MIXER_CONTROL, portname, controlname, floatval);
			krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);
			
			switch ( ebml_id ) {
				case EBML_ID_KRAD_MIXER_CONTROL:
					//printkd ("Received mixer control list %"PRIu64" bytes of data.\n", ebml_data_size);

					krad_ipc_client_read_mixer_control ( krad_ipc, &portname, &controlname, &floatval );
					krad_websocket_set_control ( krad_ipc_session_data, portname, controlname, floatval);
					
					break;	
				case EBML_ID_KRAD_MIXER_PORTGROUP_LIST:
					//printkd ("Received PORTGROUP list %"PRIu64" bytes of data.\n", ebml_data_size);
					list_size = ebml_data_size;
					while ((list_size) && ((bytes_read += krad_ipc_client_read_portgroup ( krad_ipc, portname, &floatval, crossfadename, &crossfade, &has_xmms2 )) <= list_size)) {
						krad_websocket_add_portgroup (krad_ipc_session_data, portname, floatval, crossfadename, crossfade, has_xmms2);
						
						if (bytes_read == list_size) {
							break;
						}
					}	
					break;
				case EBML_ID_KRAD_MIXER_PORTGROUP_CREATED:
					//printk ("PORTGROUP_CREATED msg %"PRIu64" bytes", ebml_data_size );
					
					krad_ipc_client_read_portgroup ( krad_ipc, portname, &floatval, crossfadename, &crossfade, &has_xmms2 );

					krad_websocket_add_portgroup (krad_ipc_session_data, portname, floatval, crossfadename, crossfade, has_xmms2);

					break;
				
				case EBML_ID_KRAD_MIXER_PORTGROUP_DESTROYED:
				
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);	

					if (ebml_id != EBML_ID_KRAD_MIXER_PORTGROUP_NAME) {
						//printkd ("hrm wtf2\n");
					} else {
						//printkd ("tag name size %zu\n", ebml_data_size);
					}
				
					krad_ebml_read_string (krad_ipc->krad_ebml, portname_actual, ebml_data_size);
					//printkd ("PORTGROUP_DESTROYED msg %zu bytes  \n", ebml_data_size );
					
					krad_websocket_remove_portgroup (krad_ipc_session_data, portname_actual);
					
					break;
					
				case EBML_ID_KRAD_MIXER_PORTGROUP_UPDATED:
					//printkd ("PORTGROUP_UPDATED msg %"PRIu64" bytes  \n", ebml_data_size );
				
					krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);

					if (ebml_id == EBML_ID_KRAD_MIXER_PORTGROUP_NAME) {				
			
						krad_ebml_read_string (krad_ipc->krad_ebml, portname_actual, ebml_data_size);
			
			
						krad_ebml_read_element (krad_ipc->krad_ebml, &ebml_id, &ebml_data_size);	

						if (ebml_id == EBML_ID_KRAD_MIXER_PORTGROUP_CROSSFADE_NAME) {
					
							krad_ebml_read_string (krad_ipc->krad_ebml, crossfadename, ebml_data_size);
					
							//printkd ("ya %s %s\n", portname_actual, crossfadename);
					
						}
					}
				
				
					break;
					
				case EBML_ID_KRAD_MIXER_SAMPLE_RATE:
					number = krad_ebml_read_number (krad_ipc->krad_ebml, ebml_data_size);
					krad_websocket_set_sample_rate ( krad_ipc_session_data, number);
					break;
					
					
			}
		
		
			break;
	
	}

	return 0;

}
Ejemplo n.º 23
0
int MessageHandler::recvMessage(msg_t* i_msg)
{
    // Verify userspace didn't give a non-kernel message type.
    if (i_msg->type < MSG_FIRST_SYS_TYPE)
    {
        printkd("MessageHandler::recvMessage> type=%d\n", i_msg->type);
        return -EINVAL;
    }

    // Lock subsystem spinlock.
    if (iv_lock) iv_lock->lock();

    // List of tasks to end due to errors.
    //     Ending the task must happen outside of the spinlock due to
    //     requirements of TaskManager::endTask.
    Util::Locked::Queue<task_t> endTaskList;

    // Get <key, rc> from response.
    MessageHandler_Pending::key_type key =
        reinterpret_cast<MessageHandler_Pending::key_type>(i_msg->data[0]);
    int msg_rc = static_cast<int>(i_msg->data[1]);

    // Handle all pending responses.
    bool restored_task = false;
    MessageHandler_Pending* mhp = NULL;
    while (NULL != (mhp = iv_pending.find(key)))
    {
        task_t* deferred_task = mhp->task;

        // Call 'handle response'.
        HandleResult rc = this->handleResponse(
                static_cast<msg_sys_types_t>(i_msg->type),
                key, mhp->task, msg_rc);

        // Remove pending information from outstanding queue.
        iv_pending.erase(mhp);
        delete mhp;

        // If there is no associated task then there is nothing to do, find
        // next pending response.
        if (!deferred_task) continue;

        // Handle action requested from 'handle response'.
        if ((SUCCESS == rc) || (!msg_rc && UNHANDLED_RC == rc))
        {
            // Successful response, resume task.

            // Immediately execute first deferred task unless it is pinned,
            // in which case it must go back onto the queue of the CPU it's
            // pinned to (and may take slightly longer to dispatch)
            if (!restored_task && !deferred_task->affinity_pinned)
            {
                restored_task = true;
                TaskManager::setCurrentTask(deferred_task);
            }
            else // Add other deferred tasks to scheduler ready queue.
            {
                deferred_task->cpu->scheduler->addTask(deferred_task);
                doorbell_broadcast();
            }
        }
        else if (UNHANDLED_RC == rc)
        {
            // Unsuccessful, unhandled response.  Kill task.
            // Print the errorno string if we have mapped it in errno.h
            printk("Unhandled msg rc %d (%s) for key %p on task %d @ %p\n",
                    msg_rc, ErrnoToString(msg_rc), key, deferred_task->tid,
                    deferred_task->context.nip);
            // Kernel will deadlock if the message handler has the VMM spinlock
            // locked and then attempts to print the backtrace
            if(VmmManager::getLock() != iv_lock)
            {
                KernelMisc::printkBacktrace(deferred_task);
            }
            MAGIC_INSTRUCTION(MAGIC_BREAK_ON_ERROR);
            endTaskList.insert(deferred_task);
        }
        else if (CONTINUE_DEFER == rc)
        {
            // Requested to continue deferring task.  Do nothing.
        }
        else
        {
            // Logic bug (new HandleResult?).  Shouldn't be here.
            kassert(false);
        }
    }

    // Finished handling the response, unlock subsystem.
    if (iv_lock) iv_lock->unlock();

    while(task_t* end_task = endTaskList.remove())
    {
        TaskManager::endTask(end_task, i_msg->extra_data, TASK_STATUS_CRASHED);
    }

    // Release memory for message (created from sendMsg).
    delete(i_msg);

    return 0;
}
Ejemplo n.º 24
0
bool Block::handlePageFault(task_t* i_task, uint64_t i_addr, bool i_store)
{
    // Check containment, call down chain if address isn't in this block.
    if (!isContained(i_addr))
    {
        return (iv_nextBlock ?
                    iv_nextBlock->handlePageFault(i_task, i_addr, i_store) :
                    false);
    }

    // Calculate page aligned virtual address.
    uint64_t l_addr_palign = (i_addr / PAGESIZE) * PAGESIZE;

    ShadowPTE* pte = getPTE(l_addr_palign);

    // If the page table entry has default permission settings
    if (getPermission(pte) == NO_ACCESS)
    {
      printkd("handle page fault.. Permission not set for addr =  0x%.lX\n",
              (uint64_t)l_addr_palign);
      // return false because permission have not been set.
      return false;
    }

    // Mark the page as dirty if this is a store to it.
    if (i_store)
    {
        if (pte->isWritable())
        {
            pte->setDirty(true);
        }
        else // Store to non-writable page!  This is a permission fault, so
             // return unhandled.
        {
            return false;
        }
    }

    if (!pte->isPresent())
    {
        if (this->iv_readMsgHdlr != NULL)
        {
            void* l_page = reinterpret_cast<void*>(pte->getPageAddr());
            //If the page data is zero, create the page
            if (pte->getPage() == 0)
            {
                l_page = PageManager::allocatePage();
                //Add to ShadowPTE
                pte->setPageAddr(reinterpret_cast<uint64_t>(l_page));
            }


            this->iv_readMsgHdlr->sendMessage(MSG_MM_RP_READ,
                    reinterpret_cast<void*>(l_addr_palign),l_page,i_task);
            //Done(waiting for response)
            return true;
        }
        else if (pte->isAllocateFromZero())
        {
            void* l_page = PageManager::allocatePage();

            // set the permission of the physical address pte entry to
            // READ_ONLY now that we have handled the page fault and
            // have a SPTE entry for that VA.
            if (BaseSegment::mmSetPermission(reinterpret_cast<void*>(l_page),
                                             0, READ_ONLY))
            {
               // Did not set permission..
               printkd("handle page fault.. Set Permission failed for physical"
                       " addr =  0x%.lX\n", (uint64_t)l_page);
            }

            memset(l_page, '\0', PAGESIZE);

            pte->setPageAddr(reinterpret_cast<uint64_t>(l_page));
            pte->setPresent(true);

        }
        else
        {
            return false;
        }
    }

    // Determine access type.
    uint64_t l_access = (iv_mappedToPhysical ? BYPASS_HRMOR : 0);
    if (pte->isExecutable())
    {
        l_access |= EXECUTABLE;
    }
    else if (pte->isWritable() && pte->isDirty())
    {
        l_access |= WRITABLE;
    }
    else
    {
        l_access |= READ_ONLY;
    }

    PageTableManager::addEntry(
            l_addr_palign,
            pte->getPage(),
            l_access);

    return true;

}
Ejemplo n.º 25
0
static int wlan_open(struct net_device *dev)
{
	printkd("%s open\n", dev->name);
	netif_start_queue(dev);
	return 0;
}