Exemple #1
0
/*
 * callback to start the stream, invoked by the MIDI control code
 */
void
wav_startreq(void *arg)
{
	struct wav *f = (struct wav *)arg;

	switch (f->pstate) {
	case WAV_INIT:
#ifdef DEBUG
		if (debug_level >= 2) {
			wav_dbg(f);
			dbg_puts(": skipped (failed to seek)\n");
		}
#endif
		return;
	case WAV_READY:
		if (f->mode & MODE_RECMASK)
			f->endpos = f->mmcpos + f->startpos;
		(void)wav_attach(f, 0);
		break;
#ifdef DEBUG
	default:
		wav_dbg(f);
		dbg_puts(": not in READY state\n");
		dbg_panic();
		break;
#endif
	}
}
Exemple #2
0
void
siofile_start(struct file *file, void (*cb)(void *, int), void *arg)
{
	struct siofile *f = (struct siofile *)file;

	if (!sio_start(f->hdl)) {
#ifdef DEBUG
		dbg_puts(f->file.name);
		dbg_puts(": failed to start device\n");
#endif
		file_close(file);
		return;
	}
	f->started = 1;
	f->wtickets = f->bufsz * f->wbpf;
	f->rtickets = 0;
#ifdef DEBUG
	f->wtime = file_wtime;
	f->utime = file_utime;
	if (debug_level >= 3) {
		file_dbg(&f->file);
		dbg_puts(": started\n");
	}
#endif
	f->onmove = cb;
	f->arg = arg;
}
Exemple #3
0
/*
 * allocate the device
 */
int
wav_init(struct wav *f)
{
	if (!dev_ref(f->dev)) {
		wav_exit(f);
		return 0;
	}
	if (!f->mmc)
		f->dev->autostart = 1;
	if (f->mode & MODE_MIDIMASK) {
		wav_midiattach(f);
		return 1;
	}
	f->slot = dev_slotnew(f->dev, "wav", &ctl_wavops, f, 1);
	f->pstate = WAV_INIT;
	if ((f->mode & f->dev->mode) != f->mode) {
#ifdef DEBUG
		if (debug_level >= 1) {
			wav_dbg(f);
			dbg_puts(": ");
			dbg_puts(": operation not supported by device\n");
		}
#endif
		wav_exit(f);
		return 0;
	}
	wav_allocbuf(f);
	return 1;
}
Exemple #4
0
void init_dmc(void)
{
		dbg_puts("init dmc\n");
		MMC_Wr(MMC_DDR_CTRL, v_mmc_ddr_ctrl);
		dbg_out("p0:",readl(DMC_SEC_PORT0_RANGE0));
		dbg_out("p1:",readl(DMC_SEC_PORT1_RANGE0));
		dbg_out("p2:",readl(DMC_SEC_PORT2_RANGE0));
		dbg_out("p3:",readl(DMC_SEC_PORT3_RANGE0));
		dbg_out("p4:",readl(DMC_SEC_PORT4_RANGE0));
		dbg_out("p5:",readl(DMC_SEC_PORT5_RANGE0));
		dbg_out("p6:",readl(DMC_SEC_PORT6_RANGE0));
		dbg_out("p7:",readl(DMC_SEC_PORT7_RANGE0));
		dbg_out("sectrl:",readl(DMC_SEC_CTRL));
	  sec_mmc_wr(DMC_SEC_PORT0_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT1_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT2_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT3_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT4_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT5_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT6_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_PORT7_RANGE0, 0xffff);
    sec_mmc_wr(DMC_SEC_CTRL,         0x80000000);
	
		dbg_puts("init dmc\n");

		//APB_Wr(MMC_REQ_CTRL,0xff); //hisun 2012.02.08
		MMC_Wr(MMC_REQ_CTRL,0xff);   //hisun 2012.02.08
		dbg_puts("init dmc\n");
}
Exemple #5
0
/* NOTE: copy+pasted from linux_eventfd_lower() */
static int
eventfd_lower(int evfd)
{
    uint64_t cur;
    ssize_t n;
    int rv = 0;

    /* Reset the counter */
    dbg_puts("lowering event level");
    n = read(evfd, &cur, sizeof(cur));
    if (n < 0) {
        switch (errno) {
            case EAGAIN:    
                /* Not considered an error */
                break;

            case EINTR:
                rv = -EINTR;
                break;

            default:
                dbg_printf("read(2): %s", strerror(errno));
                rv = -1;
        }
    } else if (n != sizeof(cur)) {
        dbg_puts("short read");
        rv = -1;
    }

    return (rv);
}
Exemple #6
0
/*
 * determine the header by the file name
 */
int
wav_autohdr(char *name, struct dev *dev, unsigned int *hdr, unsigned int *mode)
{
	char *ext;

	if (dev->reqmode & MODE_THRU)
		*mode &= MODE_MIDIMASK;
	if (*hdr == HDR_AUTO) {
		ext = strrchr(name, '.');
		if (ext != NULL) {
			ext++;
			if (strcasecmp(ext, "wav") == 0) {
				*hdr = HDR_WAV;
				*mode &= ~MODE_MIDIMASK;
			} else if (strcasecmp(ext, "syx") == 0) {
				*hdr = HDR_RAW;
				*mode &= ~MODE_AUDIOMASK;
			}
		} else
			*hdr = HDR_RAW;
	}
	if (*mode & MODE_AUDIOMASK)
		*mode &= ~MODE_MIDIMASK;
	if (*mode == 0) {
#ifdef DEBUG
		if (debug_level >= 1) {
			dbg_puts(name);
			dbg_puts(": requested mode not supported\n");
		}
#endif
		return 0;
	}
	return 1;
}
Exemple #7
0
static VOID CALLBACK evfilt_timer_callback(void* param, BOOLEAN fired){
    struct knote* kn;
    struct kqueue* kq;

    if(fired){
        dbg_puts("called, but timer did not fire - this case should never be reached");
        return;
    }

    assert(param);
    kn = (struct knote*)param;

    if(kn->kn_flags & KNFL_KNOTE_DELETED) {
        dbg_puts("knote marked for deletion, skipping event");
        return;
    } else {
        kq = kn->kn_kq;
        assert(kq);

        if (!PostQueuedCompletionStatus(kq->kq_iocp, 1, (ULONG_PTR) 0, (LPOVERLAPPED) kn)) {
            dbg_lasterror("PostQueuedCompletionStatus()");
            return;
            /* FIXME: need more extreme action */
        }
#if DEADWOOD
        evt_signal(kq->kq_loop, EVT_WAKEUP, kn);
#endif
    }
    if(kn->kev.flags & EV_ONESHOT) {
        struct filter* filt;
        if( filter_lookup(&filt, kq, kn->kev.filter) )
            dbg_perror("filter_lookup()");
        knote_release(kn);
    }
}
Exemple #8
0
void
sem_down(void *arg)
{
    dbg_puts("semaphore DOWN\n");
    sem_wait((sem_t *) arg);
    dbg_puts("semaphore UP\n");
    sem_post((sem_t *) arg);
    mark_progress();
}
/*
 * Send AT command.
 */
static void SendCmd(char *cmd)
{
    dbg_puts("Send: ");
    dbg_puts(cmd);
    dbg_puts("\n\r");

    TM_USART_Puts(USART1, cmd);
    TM_USART_Puts(USART1, "\r\n");
}
Exemple #10
0
int
evfilt_timer_copyout(struct filter *filt, 
            struct kevent *dst, 
            int nevents)
{
    struct sleepinfo    si;
    ssize_t       cnt;
    struct knote *kn;

    /* Read the ident */
    cnt = read(filt->kf_pfd, &si, sizeof(si));
    if (cnt < 0) {
        /* FIXME: handle EAGAIN and EINTR */
        dbg_printf("read(2): %s", strerror(errno));
        return (-1);
    } else if (cnt < sizeof(si)) {
        dbg_puts("error: short read");
        return (-1);
    }

    /* Acknowlege receipt */
    cnt = write(filt->kf_pfd, ".", 1);
    if (cnt < 0) {
        /* FIXME: handle EAGAIN and EINTR */
        dbg_printf("write(2): %s", strerror(errno));
        return (-1);
    } else if (cnt < 1) {
        dbg_puts("error: short write");
        return (-1);
    }

    kn = knote_lookup(filt, si.ident);

    /* Race condition: timer events remain queued even after
       the knote is deleted. Ignore these events */
    if (kn == NULL)
        return (0);

    dbg_printf("knote=%p", kn);
    memcpy(dst, &kn->kev, sizeof(*dst));

    dst->data = si.counter;

    if (kn->kev.flags & EV_DISPATCH) {
        KNOTE_DISABLE(kn);
        _timer_delete(kn);
    } else if (kn->kev.flags & EV_ONESHOT) {
        _timer_delete(kn);
        knote_free(filt, kn);
    } 

    return (1);
}
Exemple #11
0
/** temp_dir *************************************************************
 * top level function of the directory, shouldn't need to change anything
 * in here when making a new module. The new function handler name 
 * should be added to test.h.
 ************************************************************************/
void trod_dir(void)
{
	char *cmd = dir_cmd;
	exit_dir = 0; /* reset exit condition */
	while(!exit_dir)
	{
		dbg_puts(cdir);
		get_cmd(cmd, CMD_LEN);
		dbg_puts("\n\r");
		process_cmd(cmd);
	}
}
Exemple #12
0
// init one call
void light_init(void)
{
    dbg_printf("Initializing LIGHT...");
    pin_on(OPIN_TR_EN );//включить выходные регистры
    LIGHT_STA=LIGHT_WORK;// machine stat
    light_machine.work = FALSE; // stop machine
    //
    setStatusRestart(true);// перезагрузка
    //
    BOOL is_init;
    dk_num=0;
    //
    GREEN_PORT_CONF = 0;
    RED_PORT_CONF   = 0;
    YEL_PORT_CONF   = 0;
    //
   for (int i_dk=0; i_dk<DK_N; i_dk++)
    {
       CUR_DK = i_dk;

       for (int i_try=0; i_try<3; i_try++)
       {
         is_init = ligh_load_init(2-i_try);
          if (is_init)
          {
             dk_num++;
             break;
          }
       }
       //
     if (!is_init)
         break;
    }
if (dk_num)
  light_machine.work = TRUE; // start machine
/*create event*/
if (tn_event_create(&g_light_evt, TN_EVENT_ATTR_SINGLE | TN_EVENT_ATTR_CLR, 0) != TERR_NO_ERR){
  dbg_puts("tn_event_create(&g_light_evt) error");
  dbg_trace();
  tn_halt();
  }
/*create task_light_func*/
if (tn_task_create(&task_light_tcb, &task_light_func, TASK_LIGHT_PRI,
        &task_light_stk[TASK_LIGHT_STK_SZ - 1], TASK_LIGHT_STK_SZ, 0,
        TN_TASK_START_ON_CREATION) != TERR_NO_ERR){
  dbg_puts("tn_task_create(&task_light_tcb) error");
  dbg_trace();
  tn_halt();
  }
dbg_puts("[done]");
}
Exemple #13
0
/*
 * Print the format/channels/encoding on stderr.
 */
void
aparams_dbg(struct aparams *par)
{
	char enc[ENCMAX];

	aparams_enctostr(par, enc);
	dbg_puts(enc);
	dbg_puts(",");
	dbg_putu(par->cmin);
	dbg_puts(":");
	dbg_putu(par->cmax);
	dbg_puts(",");
	dbg_putu(par->rate);
}
Exemple #14
0
/*
 * print the given wav structure
 */
void
wav_dbg(struct wav *f)
{
	static char *pstates[] = { "cfg", "ini", "sta", "rdy", "run", "mid" };

	dbg_puts("wav(");
	if (f->slot >= 0) {
		dbg_puts(f->dev->slot[f->slot].name);
		dbg_putu(f->dev->slot[f->slot].unit);
	} else
		dbg_puts(f->pipe.file.name);
	dbg_puts(")/");
	dbg_puts(pstates[f->pstate]);
}
Exemple #15
0
void GPS_init()
{

    dbg_printf("Initializing GPS module...");

    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART);

    MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
    MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
    MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    MAP_UARTConfigSetExpClk(UART_BASE, MAP_SysCtlClockGet(), UART_SPEED, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
    MAP_UARTDisable(UART_BASE);
    MAP_UARTTxIntModeSet(UART_BASE, UART_TXINT_MODE_EOT);
    MAP_UARTIntEnable(UART_BASE, UART_INT_RX | UART_INT_TX);
    MAP_IntEnable(INT_UART);
    MAP_UARTEnable(UART_BASE);
    MAP_UARTFIFODisable(UART_BASE);

    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    //
    MAP_IntEnable(INT_GPIOG);
    // Настроить прерывания на PPS
    MAP_GPIOIntTypeSet(GPIO_PORTG_BASE, GPIO_PIN_7, GPIO_FALLING_EDGE);
    MAP_GPIOPinIntEnable(GPIO_PORTG_BASE, GPIO_PIN_7);
    //

    if (tn_task_create(&task_GPS_tcb, &task_GPS_func, TASK_GPS_PRI,
        &task_GPS_stk[TASK_GPS_STK_SZ - 1], TASK_GPS_STK_SZ, 0,
        TN_TASK_START_ON_CREATION) != TERR_NO_ERR)
    {
        dbg_puts("tn_task_create(&task_GPS_tcb) error");
        goto err;
    }

    // Настроить прерывания на PPS
    //MAP_IntEnable(INT_GPIOG);
    //MAP_GPIOIntTypeSet(GPIO_PORTG_BASE, GPIO_PIN_7, GPIO_FALLING_EDGE);
    //MAP_GPIOPinIntEnable(GPIO_PORTG_BASE, GPIO_PIN_7);

    dbg_puts("[done]");

    return;
err:
    dbg_trace();
    tn_halt();
}
Exemple #16
0
void
sem_up(void *arg)
{
    dbg_puts("semaphore UP\n");
    sem_post((sem_t *) arg);
    mark_progress();
}
Exemple #17
0
/*-----------------------Start system-----------------------------------------*/
void tn_app_init()
{
    tn_cpu_int_disable(); // прерывания включаются обратно после выхода из tn_app_init();
    // start
    startup();
    // for static IP
    struct ip_addr ipaddr   = { pref_get_long(PREF_L_NET_IP) };
    struct ip_addr netmask  = { pref_get_long(PREF_L_NET_MSK) };
    struct ip_addr gw       = { pref_get_long(PREF_L_NET_GW) };
    //ip_addr_debug_print(buf, ipaddr);
    ethernet_init((enum net_mode)pref_get_long(PREF_L_NET_MODE), &ipaddr, &netmask, &gw);
    cmd_ch_init(); // init cmd for ethernet
    // creat task_leds_func
    if (tn_task_create(&task_leds_tcb, &task_leds_func, TASK_LEDS_PRI, &task_leds_stk[TASK_LEDS_STK_SZ - 1],
        TASK_LEDS_STK_SZ, 0, TN_TASK_START_ON_CREATION) != TERR_NO_ERR)
    {
        dbg_puts("tn_task_create(&task_leds_tcb) error");
        goto err;
    }
    //time_init=true;
    return;

err:
    dbg_trace();
    tn_halt();
}
Exemple #18
0
static int
worker_start(void) 
{
    struct worker *wkr;

    dbg_puts("Spawning another worker");

    wkr = calloc(1, sizeof(*wkr));
    if (wkr == NULL) {
        dbg_perror("calloc(3)");
        return (-1);
    }

    scoreboard.count++;
    atomic_inc(&scoreboard.idle);

    if (pthread_create(&wkr->tid, &detached_attr, worker_main, wkr) != 0) {
        dbg_perror("pthread_create(3)");
        atomic_dec(&scoreboard.idle);
        scoreboard.count--;
        return (-1);
    }

    pthread_mutex_lock(&workers_mtx);
    LIST_INSERT_HEAD(&workers, wkr, entries);
    pthread_mutex_unlock(&workers_mtx);

    return (0);
}
Exemple #19
0
static int
//int
worker_stop(void) 
{
    struct work *witem;
    pthread_workqueue_t workq;
    int i;

    witem = witem_alloc(NULL, NULL);

    pthread_mutex_lock(&wqlist_mtx);
    for (i = 0; i < PTHREAD_WORKQUEUE_MAX; i++) {
        workq = wqlist[i];
        if (workq == NULL)
            continue;

        STAILQ_INSERT_TAIL(&workq->item_listhead, witem, item_entry);
        pthread_cond_signal(&wqlist_has_work);
        pthread_mutex_unlock(&wqlist_mtx);

        scoreboard.count--;
        return (0);
    }

    /* FIXME: this means there are no workqueues.. should never happen */
    dbg_puts("Attempting to add a workitem without a workqueue");
    abort();

    return (-1);
}
Exemple #20
0
/*
 * read method of the file structure
 */
unsigned int
wav_read(struct file *file, unsigned char *data, unsigned int count)
{
	struct wav *f = (struct wav *)file;
	unsigned int n;

	if (f->map)
		count /= sizeof(adata_t);
	if (f->rbytes >= 0 && count > f->rbytes) {
		count = f->rbytes; /* file->rbytes fits in count */
		if (count == 0) {
#ifdef DEBUG
			if (debug_level >= 3) {
				wav_dbg(f);
				dbg_puts(": read complete\n");
			}
#endif
			if (!f->mmc)
				file_eof(&f->pipe.file);
			return 0;
		}
	}
	n = pipe_read(file, data, count);
	if (n == 0)
		return 0;
	if (f->rbytes >= 0)
		f->rbytes -= n;
	if (f->map) {
		wav_conv(data, n, f->map);
		n *= sizeof(adata_t);
	}
	return n;
}
Exemple #21
0
static void *
overcommit_worker_main(void *arg)
{
    struct timespec ts;
    pthread_workqueue_t workq;
    void (*func)(void *);
    void *func_arg;
    struct work *witem;
    int rv, idx;

    (void)arg;
     
    pthread_mutex_lock(&ocwq_mtx);

    for (;;) {
        /* Find the highest priority workqueue that is non-empty */
        idx = ffs(ocwq_mask);
        if (idx > 0) {
            workq = ocwq[idx - 1];
            witem = STAILQ_FIRST(&workq->item_listhead);
            if (witem != NULL) {
                /* Remove the first work item */
                STAILQ_REMOVE_HEAD(&workq->item_listhead, item_entry);
                if (STAILQ_EMPTY(&workq->item_listhead))
                    ocwq_mask &= ~(0x1 << workq->wqlist_index);
                /* Execute the work item */
                pthread_mutex_unlock(&ocwq_mtx);
                func = witem->func;
                func_arg = witem->func_arg;
                witem_free(witem);
                func(func_arg);    
                pthread_mutex_lock(&ocwq_mtx);
                continue;
            }
        }

        /* Wait for more work to be available. */
        clock_gettime(CLOCK_REALTIME, &ts);
        ts.tv_sec += 15;
        ocwq_idle_threads++;
        dbg_printf("waiting for work (idle=%d)", ocwq_idle_threads);
        rv = pthread_cond_timedwait(&ocwq_has_work, &ocwq_mtx, &ts);
        if (rv < 0) {
            /* Normally, the signaler will decrement the idle counter,
               but this path is not taken in response to a signaler.
             */
            ocwq_idle_threads--;
            if (errno == ETIMEDOUT) {
                dbg_puts("timeout, no work available");
                break;
            } else {
                dbg_perror("pthread_cond_timedwait");
                //TODO: some kind of crash mechanism
                break;
            }
        }
    }

    pthread_exit(NULL);
}
Exemple #22
0
/* NOTE: copy+pasted from linux_eventfd_raise() */
static int
eventfd_raise(int evfd)
{
    uint64_t counter;
    int rv = 0;

    dbg_puts("raising event level");
    counter = 1;
    if (write(evfd, &counter, sizeof(counter)) < 0) {
        switch (errno) {
            case EAGAIN:    
                /* Not considered an error */
                break;

            case EINTR:
                rv = -EINTR;
                break;

            default:
                dbg_printf("write(2): %s", strerror(errno));
                rv = -1;
        }
    }
    return (rv);
}
Exemple #23
0
/*
 * write method of the file structure
 */
unsigned int
wav_write(struct file *file, unsigned char *data, unsigned int count)
{
	struct wav *f = (struct wav *)file;
	unsigned int n;

	if (f->wbytes >= 0 && count > f->wbytes) {
		count = f->wbytes; /* wbytes fits in count */
		if (count == 0) {
#ifdef DEBUG
			if (debug_level >= 3) {
				wav_dbg(f);
				dbg_puts(": write complete\n");
			}
#endif
			file_hup(&f->pipe.file);
			return 0;
		}
	}
	n = pipe_write(file, data, count);
	if (f->wbytes >= 0)
		f->wbytes -= n;
	f->endpos += n;
	return n;
}
Exemple #24
0
/*
 * close method of the file structure
 */
void
wav_close(struct file *file)
{
	struct wav *f = (struct wav *)file, **pf;

	if (f->mode & MODE_RECMASK) {
		pipe_trunc(&f->pipe.file, f->endpos);
		if (f->hdr == HDR_WAV) {
			wav_writehdr(f->pipe.fd,
			    &f->hpar,
			    &f->startpos,
			    f->endpos - f->startpos);
		}
	}
	pipe_close(file);
	if (f->pstate != WAV_CFG)
		dev_unref(f->dev);
	for (pf = &wav_list; *pf != f; pf = &(*pf)->next) {
#ifdef DEBUG
		if (*pf == NULL) {
			dbg_puts("wav_close: not on list\n");
			dbg_panic();
		}
#endif
	}
	*pf = f->next;
}
Exemple #25
0
/*
 * attach play (rec) abuf structure to the device and
 * switch to the ``RUN'' state; the play abug must not be empty
 */
int
wav_attach(struct wav *f, int force)
{
	struct abuf *rbuf = NULL, *wbuf = NULL;
	struct dev *d = f->dev;

	if (f->mode & MODE_PLAY)
		rbuf = LIST_FIRST(&f->pipe.file.rproc->outs);
	if (f->mode & MODE_RECMASK)
		wbuf = LIST_FIRST(&f->pipe.file.wproc->ins);
	f->pstate = WAV_RUN;
#ifdef DEBUG
	if (debug_level >= 3) {
		wav_dbg(f);
		dbg_puts(": attaching\n");
	}
#endif

	/*
	 * start the device (dev_getpos() and dev_attach() must
	 * be called on a started device
	 */
	dev_wakeup(d);

	dev_attach(d, f->pipe.file.name, f->mode,
	    rbuf, &f->hpar, f->join ? d->opar.cmax - d->opar.cmin + 1 : 0,
	    wbuf, &f->hpar, f->join ? d->ipar.cmax - d->ipar.cmin + 1 : 0,
	    f->xrun, f->maxweight);
	if (f->mode & MODE_PLAY)
		dev_setvol(d, rbuf, MIDI_TO_ADATA(f->vol));
	return 1;
}
Exemple #26
0
/*
 * allocate the play (rec) abuf structure; if this is a
 * file to record, then attach it to the device
 *
 * XXX: buffer size should be larger than dev_bufsz, because
 *	in non-server mode we don't prime play buffers with
 *	silence
 */
void
wav_allocbuf(struct wav *f)
{
	struct abuf *buf;
	struct dev *d = f->dev;
	unsigned int nfr;

	f->pstate = WAV_START;
	if (f->mode & MODE_PLAY) {
		nfr = 2 * d->bufsz * f->hpar.rate / d->rate;
		buf = abuf_new(nfr, &f->hpar);
		aproc_setout(f->pipe.file.rproc, buf);
		abuf_fill(buf);
		if (!ABUF_WOK(buf) || (f->pipe.file.state & FILE_EOF))
			f->pstate = WAV_READY;
	}
	if (f->mode & MODE_RECMASK) {
		nfr = 2 * d->bufsz * f->hpar.rate / d->rate;
		buf = abuf_new(nfr, &f->hpar);
		aproc_setin(f->pipe.file.wproc, buf);
		f->pstate = WAV_READY;
	}
#ifdef DEBUG
	if (debug_level >= 3) {
		wav_dbg(f);
		dbg_puts(": allocating buffers\n");
	}
#endif
	if (f->pstate == WAV_READY && dev_slotstart(d, f->slot))
		(void)wav_attach(f, 0);
}
Exemple #27
0
int
evfilt_socket_copyout(struct kevent *dst, struct knote *src, void *ptr)
{
    struct epoll_event * const ev = (struct epoll_event *) ptr;

    epoll_event_dump(ev);
    memcpy(dst, &src->kev, sizeof(*dst));
#if defined(HAVE_EPOLLRDHUP)
    if (ev->events & EPOLLRDHUP || ev->events & EPOLLHUP)
        dst->flags |= EV_EOF;
#else
    if (ev->events & EPOLLHUP)
        dst->flags |= EV_EOF;
#endif
    if (ev->events & EPOLLERR)
        dst->fflags = 1; /* FIXME: Return the actual socket error */
          
    /* On return, data contains the the amount of space remaining in the write buffer */
    if (ioctl(dst->ident, SIOCOUTQ, &dst->data) < 0) {
            /* race condition with socket close, so ignore this error */
            dbg_puts("ioctl(2) of socket failed");
            dst->data = 0;
    }

    return (0);
}
Exemple #28
0
void dbg_print(char *fmt, ...)
{
        va_list args;
        char buf[BUFFER_SIZE];
        int count;

        va_start(args, fmt);
        count = vsnprintf(buf, BUFFER_SIZE, fmt, args);
        va_end(args);

        if (count >= BUFFER_SIZE) {
                dbg_puts("WARNING: The following message has been "
                         " truncated due to buffer size limitations.\n");
        }
        dbg_puts(buf);
}
/* TODO: USE this to get events with name field */
int
get_one_event(struct inotify_event *dst, int inofd)
{
    ssize_t n;

    dbg_puts("reading one inotify event");
    for (;;) {
        n = read(inofd, dst, sizeof(*dst));
        if (n < 0) {
            if (errno == EINTR)
                continue;
            dbg_perror("read");
            return (-1);
        } else {
            break;
        }
    }
    dbg_printf("read(2) from inotify wd: %ld bytes", (long) n);

    /* FIXME-TODO: if len > 0, read(len) */
    if (dst->len != 0) 
        abort();


    return (0);
}
Exemple #30
0
void hw_timer0a_init(TN_EVENT* evt, unsigned evt_pattern)
{

    if (evt == NULL || evt_pattern == 0)
    {
        dbg_puts("evt == NULL || evt_pattern == 0");
        dbg_trace();
        tn_halt();
    }

    g_timer0a_evt           = evt;
    g_timer0a_evt_pattern   = evt_pattern;

    // TIMER_0_A32
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_TIMER0);
    MAP_TimerDisable(TIMER0_BASE, TIMER_A);
    MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); // periodic mode
    MAP_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    //MAP_IntPrioritySet(INT_TIMER0A, 0); // 0 - max pri 7 - min pri
    MAP_IntEnable(INT_TIMER0A);

/*
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
    MAP_TimerDisable(TIMER3_BASE, TIMER_A);
    MAP_TimerConfigure(TIMER3_BASE, TIMER_CFG_32_BIT_OS);
    MAP_TimerEnable(TIMER3_BASE, TIMER_A);
*/
}