Exemple #1
0
int omap3530_sdma_attach_intr(omap3530_spi_t *omap3530)
{
	int rx_idx = omap3530->sdma_rx_chid ;

	if ((omap3530->sdma_coid = ConnectAttach(0, 0, omap3530->chid, _NTO_SIDE_CHANNEL, 0)) == -1) 
		goto fail0;
	
	omap3530->sdmaevent.sigev_notify   = SIGEV_PULSE;
	omap3530->sdmaevent.sigev_coid     = omap3530->sdma_coid;
	omap3530->sdmaevent.sigev_code     = OMAP3530_SDMA_EVENT;
	omap3530->sdmaevent.sigev_priority = OMAP3530_SPI_PRIORITY+1;

	omap3530->iid_sdma = InterruptAttachEvent(omap3530->irq_sdma+rx_idx, &omap3530->sdmaevent, _NTO_INTR_FLAGS_TRK_MSK);
	
	if (omap3530->iid_sdma != -1)
		return 0;

	ConnectDetach(omap3530->sdma_coid);
fail0:

	return -1;
}
void *InterruptTask::IntThread(void *arg){
	static int interruptId;
	struct sigevent event;
	int s;

	InterruptTask *taskInst;
	taskInst = (InterruptTask *)arg;

	event.sigev_notify = SIGEV_INTR;
	interruptId = InterruptAttachEvent(taskInst->mIntNum, &event, 0);

	while(1){
		if(InterruptWait(0, NULL) == -1){
			continue;
		}
		
		InterruptUnmask(taskInst->mIntNum, interruptId);
		taskInst->mRunning = 1;
		taskInst->IntTask();
		taskInst->mRunning = 0;
		
	}

}
Exemple #3
0
static void *interrupt_thread( void *p )
{
    int ret;
    int intr;
    int intr_id;
    struct sigevent event;
    struct _pulse pulse;
    iov_t  iov;
    int    rcvid;
    int chid;
    int coid;
    int count;
    uint64_t rdata;
    uint16_t target;
    uint64_t clk;
    int    pool_id;

    intr = (int)p;
    rdata = 0;
    target = 512;

    ret = ThreadCtl( _NTO_TCTL_IO, 0 );
    if( ret != 0 )
    {
        slogf( _SLOGC_CHAR, _SLOG_CRITICAL, 
               "random: Unable to gain IO privs: %s",
               strerror( errno ) );
        return NULL;
    }

    chid = ChannelCreate( 0 );
    if( chid == -1 )
    {
        slogf( _SLOGC_CHAR, _SLOG_CRITICAL, 
               "random: ChannelCreate() failed: %s",
               strerror( errno ) );
        return NULL;
    }

    coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );
    if( coid == -1 )
    {
        slogf( _SLOGC_CHAR, _SLOG_CRITICAL, 
               "random: ConnectAttach() failed: %s",
               strerror( errno ) );
        return NULL;
    }

    ret = yarrow_add_source( Yarrow, &pool_id );
    if( ret != 0 )
    {
        slogf( _SLOGC_CHAR, _SLOG_CRITICAL, 
               "random: Unable to get pool_id for interrupt %d thread.", intr );
        return NULL;
    }

    event.sigev_notify   = SIGEV_PULSE;
    event.sigev_coid     = coid;
    event.sigev_code     = 1;
    event.sigev_priority = 15;
    intr_id = InterruptAttachEvent( intr, &event, _NTO_INTR_FLAGS_TRK_MSK );
    if( intr_id == -1 )
    {
        slogf( _SLOGC_CHAR, _SLOG_CRITICAL, 
               "random: Unable to attach event to intr %d: %s", 
               intr, strerror( errno ) );
        return NULL;
    }

    /* This is how many interrupts we are gonna get */
    if( Yarrow )
    {
        yarrow_output( Yarrow, (uint8_t *)&rdata, sizeof( rdata ) );
        target = rdata & 0x1FF;
    }

    count = 0;

    SETIOV( &iov, &pulse, sizeof( pulse ) );
    while( 1 )
    {
        rcvid = MsgReceivev( chid, &iov, 1, NULL );
        if( rcvid == -1 )
        {
            if( errno == ESRCH )
                return NULL;
            continue;
        }

        switch( pulse.code )
        {
            case 1:
                InterruptUnmask( intr, intr_id );
                count++;
                if( count >= target )
                {
                    ClockTime( CLOCK_REALTIME, NULL, &clk );
                    clk = clk ^ rdata;

                    if( Yarrow )
                    {
                        yarrow_input( Yarrow, (uint8_t *)&clk, sizeof( clk ), 
                                      pool_id, 8 );

                        yarrow_output( Yarrow, (uint8_t *)&rdata, 
                                       sizeof( rdata ) );
                    }

                    target = rdata & 0x1FF;
                    count = 0;
                }
                break;

            default:
                if( rcvid )
                    MsgError( rcvid, ENOTSUP );
        }
        
    }

    return NULL;
}
Exemple #4
-35
int omap3_edma_attach_intr(omap3_spi_t *omap3)
{
    struct sigevent		event;

    if ((omap3->edma_coid = ConnectAttach(0, 0, omap3->chid, _NTO_SIDE_CHANNEL, 0)) == -1)
        goto fail0;

    event.sigev_notify   = SIGEV_PULSE;
    event.sigev_coid	 = omap3->edma_coid;
    event.sigev_code	 = OMAP3_EDMA_EVENT;
    event.sigev_priority = omap3->prio;

    omap3->iid_edma = InterruptAttachEvent(omap3->irq_edma, &event, _NTO_INTR_FLAGS_TRK_MSK);

    if (omap3->iid_edma != -1)
        return 0;

    ConnectDetach(omap3->edma_coid);
fail0:

    return -1;
}