Ejemplo n.º 1
0
void
network_poll(void)
{
    while (poll_data.busy)
	thread_wait_event(poll_data.wake_poll_thread, -1);

    thread_reset_event(poll_data.wake_poll_thread);
}
Ejemplo n.º 2
0
/* Handle the receiving of frames from the channel. */
static void
poll_thread(void *arg)
{
    uint8_t *mac = (uint8_t *)arg;
    const uint8_t *data = NULL;
    struct pcap_pkthdr h;
    uint32_t mac_cmp32[2];
    uint16_t mac_cmp16[2];
    event_t *evt;

    pclog("PCAP: polling thread started, arg %08lx\n", arg);

    /* Create a waitable event. */
    evt = thread_create_event();

    /* As long as the channel is open.. */
    while (pcap != NULL) {
	/* Wait for the next packet to arrive. */
	data = f_pcap_next(pcap, &h);
	if (data != NULL) {
		/* Received MAC. */
		mac_cmp32[0] = *(uint32_t *)(data+6);
		mac_cmp16[0] = *(uint16_t *)(data+10);

		/* Local MAC. */
		mac_cmp32[1] = *(uint32_t *)mac;
		mac_cmp16[1] = *(uint16_t *)(mac+4);
		if ((mac_cmp32[0] != mac_cmp32[1]) ||
		    (mac_cmp16[0] != mac_cmp16[1])) {
			if (poll_rx != NULL)
				poll_rx(poll_arg, (uint8_t *)data, h.caplen); 
		} else {
			/* Mark as invalid packet. */
			data = NULL;
		}
	}

	/* If we did not get anything, wait a while. */
	if (data == NULL)
		thread_wait_event(evt, 10);
    }

    thread_destroy_event(evt);
    poll_tid = NULL;

    pclog("PCAP: polling stopped.\n");
}
Ejemplo n.º 3
0
static void sound_cd_thread(void *param)
{
        while (1)
        {
                int c;
                
                thread_wait_event(sound_cd_event, -1);
                ioctl_audio_callback(cd_buffer, CD_BUFLEN*2);
                if (soundon)
                {
                        for (c = 0; c < CD_BUFLEN*2; c += 2)
                        {
                                cd_buffer[c]   = ((int32_t)cd_buffer[c]   * cd_vol_l) / 65535;
                                cd_buffer[c+1] = ((int32_t)cd_buffer[c+1] * cd_vol_r) / 65535;
                        }
                        givealbuffer_cd(cd_buffer);
                }
        }
}