Example #1
0
void fakempif_new_( int *nprocs, int* ierr )
{
    fakempi = fakempi_new( *nprocs );
    *ierr = ( fakempi == NULL );
    //fakempi_verbose = stderr;
    resettimer();
}
Example #2
0
static void jz_set_mode(enum clock_event_mode mode,
                        struct clock_event_device *clkevt)
{
    struct jz_timerevent *evt_dev = container_of(clkevt,struct jz_timerevent,clkevt);
    unsigned long flags;
    unsigned int latch = (evt_dev->rate + (HZ >> 1)) / HZ;
    spin_lock_irqsave(&evt_dev->lock,flags);
    switch (mode) {
    case CLOCK_EVT_MODE_PERIODIC:
        evt_dev->curmode = mode;
        resettimer(latch - 1);
        break;
    case CLOCK_EVT_MODE_ONESHOT:
        evt_dev->curmode = mode;
        break;
    case CLOCK_EVT_MODE_UNUSED:
    case CLOCK_EVT_MODE_SHUTDOWN:
        stoptimer();
        break;

    case CLOCK_EVT_MODE_RESUME:
        restarttimer();
        break;
    }
    spin_unlock_irqrestore(&evt_dev->lock,flags);
}
Example #3
0
static int jz_set_next_event(unsigned long evt,
                             struct clock_event_device *clk_evt_dev)
{
    struct jz_timerevent *evt_dev = container_of(clk_evt_dev,struct jz_timerevent,clkevt);
    unsigned long flags;
    spin_lock_irqsave(&evt_dev->lock,flags);
    if(evt <= 1) {
        WARN_ON(1);
        evt = 2;
    }
    resettimer(evt - 1);
    spin_unlock_irqrestore(&evt_dev->lock,flags);
    return 0;
}
main(int argc, char **argv)
{
    int r, flags=0, n, i, id,base=10, bKeepFrom = 0;
    struct apts_msg *testcase;
    struct station *sta = NULL;
    char IP[INET_ADDRSTRLEN],string[128];
    char *str,*endptr;
    FILE *tmpfile;
    consoleProcStatetbl_t func;

    for(i=1; i<argc; i++)
    {
        if(argv[i][0]=='-')
        {
            if(argv[i][1]=='t')
            {
                i++;
                timeron=atoi(argv[i]);
                pthread_create(&time_thr,NULL,timerthread,NULL);
            }
            else
            {
                printf("Unrecognized options\n");
                exit(1);
            }
        }
        else
        {
            procname = argv[i]; // gather non-option args here
            if( (strncmp(procname,"L.1AP", 4) == 0 ))
            {
                procname[3] = '\0';
                bKeepFrom = 1;

            }
            else
            {
                bKeepFrom = 0;
            }
        }
    }
    setup_socket();
    testcase = (struct apts_msg *) apts_lookup(procname);
    sockflags = MSG_DONTWAIT;
    tos_vo = 0xD0;
    tos_vi = 0xA0;
    tos_be = 0x00;
    tos_bk = 0x20;
    tmpfile = fopen("tos.txt","r+");
    if(tmpfile == NULL)
    {
        printf("Can not find the tos file,proceeding with default values\n");
    }
    else
    {
        while(fgets(string,128,tmpfile) != NULL)
        {
            if(strstr(string,"#"))
                continue;
            if(strstr(string,"0x"))
            {
                base = 16;
            }
            str = strtok(string,",");
            tos_vo = strtol(str,&endptr,base);
            str = strtok(NULL,",");
            tos_vi = strtol(str,&endptr,base);
            str = strtok(NULL,",");
            tos_be = strtol(str,&endptr,base);
            str = strtok(NULL,",");
            tos_bk = strtol(str,&endptr,base);
        }
    }
    printf("Using TOS: VO=0x%x,VI=0x%x,BE=0x%x,BK=0x%x\n",
           tos_vo,tos_vi,tos_be,tos_bk);

    traceflag=1;
    while (1)
    {
        if(nsta)
        {
            printf("\nWaiting in state %d\n",sta->state);
        }
        if (( sta== NULL) || (bKeepFrom == 1))
            r = recvfrom(sd, rmsg, sizeof(rmsg), flags, (struct sockaddr *)&from, &fromlen);
        else
            r = recv(sd, rmsg, sizeof(rmsg), flags);

        resettimer(INTERSTEP_PERIOD*10);
        if (r<0)
        {
            perror("rcv error:");
            exit(1);
        }
        alarm(0);
        tout=0;

        /* check some cases  */
        if (traceflag && strcmp(procname,"L.1"))
        {
            printf( "APTS Received #    length:%d\n",  r );
            mpx("APTS RX", rmsg, 64);
        }
        // Do not process unless from remote
        if (from.sin_addr.s_addr==0 || from.sin_addr.s_addr==local.sin_addr.s_addr)
        {
            printf( "Received 0 / local\n" );
            continue;
        }
        if (from.sin_addr.s_addr==target.sin_addr.s_addr)
        {
            printf( "Received BROADCAST\n" );
            continue;
        }
        if (rmsg[10]==APTS_BCST)
        {
            printf( "Received BROADCAST, skipping\n" );
            continue;
        }
        /* check some cases  */

        printf("\r\n cmd is %d",rmsg[11]);

        if (rmsg[10]==APTS_HELLO)
        {

            if((id = get_sta_id(from.sin_addr.s_addr))>=0)
            {
                if(!reset)
                    continue;
                printf("\n HELLO after reset");

            }
            else if((id = assign_sta_id(from.sin_addr.s_addr))<0)
            {
                printf( "Can not assign id,sta list full");
                continue;
            }

            sta = &stations[id];
            bzero(sta->ipaddress, 20);
            inet_ntop(AF_INET, &(from.sin_addr), IP, INET_ADDRSTRLEN);
            printf("ip is %s\n",IP);
            strcpy( &(sta->ipaddress[0]), IP);
            sta->cmd =  testcase->cmd;
            sta->cookie = 0;
            sta->nsent = 0;
            sta->nerr = 0;
            sta->msgno = 0;
            sta->myid = id;
            sta->alreadyCleared = 0;
            printf("new_station: size(%d) id=%02d IP address:%s\n", r, id, sta->ipaddress);
            if(reset)
                reset = 0;
            else
                nsta++;
            printf( "New STA = %d\n", nsta );
            sta->state = 0;
            sta->statefunc = consoleProcStatetbl[sta->cmd];

        }/*  if (rmsg[10]==APTS_HELLO)  */
        else
        {
            if(reset)
                continue;
            if((id = get_sta_id(from.sin_addr.s_addr))<0)
            {
                inet_ntop(AF_INET, &(from.sin_addr), IP, INET_ADDRSTRLEN);
                printf("\r\n Unexpected message rcd from ip s_addr=%s sta id=%d", IP, id);
                continue;
            }
            sta = &stations[id];
        }/* else  */

        if(rmsg[10] == APTS_RESET)
        {
            reset_recd = 1;
            printf("\nRcv RESET from STA, sent RESET back to STA, exit\n");
            WfaConResetAll();
            exit(0);
        }
        if(rmsg[10] == APTS_RESET_STOP)
        {
            printf("\r\n Recd Kill from Sta\n");
            exit(0);
        }

        func = (sta->statefunc)[sta->state];
        if(!sta->alreadyCleared)
        {
            func.statefunc(sta,rmsg,r);
        }

    }/* while loop  */
}/*  main */