Пример #1
0
LOCAL STATUS i8042Write(
    u_int32_t statReg,
    u_int32_t dataReg,
    u_int8_t  data
    )
{
    STATUS status = ERROR;

    /* Start watchdog */
    i8042Timeout = FALSE;
    wdStart(i8042Wdid,
            sysClockRateGet() * I8042_WAIT_SEC,
            (FUNCPTR) i8042Wd,
            0);

    /* Wait for output buffer to be ready */
    while ((sysInByte(statReg) & I8042_KBD_IBFULL) && (i8042Timeout == FALSE));
    wdCancel(i8042Wdid);

    /* Write data */
    sysOutByte(dataReg, data);

    if (i8042Timeout == FALSE)
    {
        status = OK;
    }

    return status;
}
Пример #2
0
LOCAL STATUS i8042Read(
    u_int32_t statReg,
    u_int32_t dataReg,
    u_int8_t *pData
    )
{
    STATUS status = ERROR;

    /* Start watchdog */
    i8042Timeout = FALSE;
    wdStart(i8042Wdid,
            sysClockRateGet() * I8042_WAIT_SEC,
            (FUNCPTR) i8042Wd,
            0);

    /* Wait for output buffer to be ready */
    while (((sysInByte(statReg) & I8042_KBD_OBFULL) == 0) &&
            (i8042Timeout == FALSE));
    wdCancel(i8042Wdid);
    taskDelay(sysClockRateGet() >> 4);

    /* Read data */
    *pData = sysInByte(dataReg);

    if (i8042Timeout == FALSE)
    {
        status = OK;
    }

    return status;
}
Пример #3
0
LOCAL STATUS i8042Command(
    u_int32_t cmdReg,
    u_int8_t  cmd
    )
{
    STATUS status = ERROR;

    /* Start watchdog */
    i8042Timeout = FALSE;
    wdStart(i8042Wdid,
            sysClockRateGet() * I8042_WAIT_SEC,
            (FUNCPTR) i8042Wd,
            0);

    /* Wait for input buffer */
    while ((sysInByte(cmdReg) & I8042_KBD_IBFULL) && (i8042Timeout == FALSE));

    /* Send command */
    sysOutByte(cmdReg, cmd);

    /* Wait for command completion */
    while ((sysInByte(cmdReg) & I8042_KBD_IBFULL) && (i8042Timeout == FALSE));
    wdCancel(i8042Wdid);

    if (i8042Timeout == FALSE)
    {
        status = OK;
    }

    return status;
}
Пример #4
0
/*----------------------------------------------------------------------*/
static
void resetNameBufs()   /* free all named buffers */
{
   int retrys;
   int callTaskId,DwnLkrTaskId;
   int callTaskPrior;

   /* Since reset2SafeState should have left the downLinker in a ready
      state we now longer need change priority/etc. here to get it to clean
      up.     8/6/97
   */

   retrys=0;

   /* start wdog timeout of 7 seconds */ 
#ifdef INOVA
   pHandlerTimeout = 0;
   wdStart(pHandlerWdTimeout,sysClkRateGet() * 7, pHandlerWdISR, 0);

   /* free buffers until all are free or watch-dog timeout has occurred */
   while ( ((dlbUsedBufs(pDlbDynBufs) > 0) || (dlbUsedBufs(pDlbFixBufs) > 0)) &&
		(!pHandlerTimeout) )
   {
        retrys++;
   	DPRINT(0,"dlbFreeAll Dyn");
   	dlbFreeAll(pDlbDynBufs);
   	DPRINT(0,"dlbFreeAll Fix");
   	dlbFreeAll(pDlbFixBufs);
	Tdelay(1);
	DPRINT1(0,"resetNameBufs: retrys: %d\n",retrys);
   }
   wdCancel(pHandlerWdTimeout);
#endif
}
Пример #5
0
pHandlerWdISR()
{
   pHandlerTimeout = 1;
   wdCancel(pHandlerWdTimeout);
#ifdef INSTRUMENT
        wvEvent(EVENT_PHDLR_WDISR,NULL,NULL);
#endif
}
Пример #6
0
/*----------------------------------------------------------------------*/
static
void resetNameBufs()   /* free all named buffers */
{
   int retrys;
   int callTaskId,DwnLkrTaskId;
   int callTaskPrior;

   /* Since reset2SafeState should have left the downLinker in a ready
      state we now longer need change priority/etc. here to get it to clean
      up.     8/6/97
   */
#ifdef XXX
   callTaskId = taskIdSelf();
   DwnLkrTaskId = taskNameToId("tDownLink");
   taskPriorityGet(callTaskId,&callTaskPrior);
#endif


   retrys=0;

   /* start wdog timeout of 7 seconds */ 
   pHandlerTimeout = 0;
   wdStart(pHandlerWdTimeout,sysClkRateGet() * 7, pHandlerWdISR, 0);

   /* free buffers until all are free or watch-dog timeout has occurred */
   while ( ((dlbUsedBufs(pDlbDynBufs) > 0) || (dlbUsedBufs(pDlbFixBufs) > 0)) &&
		(!pHandlerTimeout) )
   {
        retrys++;
   	DPRINT(0,"dlbFreeAll Dyn");
   	dlbFreeAll(pDlbDynBufs);
   	DPRINT(0,"dlbFreeAll Fix");
   	dlbFreeAll(pDlbFixBufs);
	Tdelay(1);
	DPRINT1(0,"resetNameBufs: retrys: %d\n",retrys);
#ifdef XXX
        /* Lower priority to allow downlinker in */
	if (callTaskPrior <= DOWNLINKER_TASK_PRIORITY)
           taskPrioritySet(callTaskId,(DOWNLINKER_TASK_PRIORITY+1));  
	Tdelay(10);

	DPRINT1(-1,"resetNameBufs: retrys: %d\n",retrys);
        if (retrys > 7)
        {
	   if (taskIsSuspended(DwnLkrTaskId))
	   {
	      DPRINT(-1,"resetNameBufs: clearCurrentNameBuffer()\n");
  	      clearCurrentNameBuffer();
           }
        }
#endif
   }
   wdCancel(pHandlerWdTimeout);
   /* taskPrioritySet(callTaskId,callTaskPrior);   */

  /*    resumeDownLink(); */
}
Пример #7
0
void sysAuxClkDisable (void)
    {
    if (sysAuxClkRunning)
	{
	int key;

	key = intLock ();
	sysAuxClkRunning = FALSE;
	wdCancel(auxDog);
	intUnlock (key);
	}
    }
Пример #8
0
static int __wind_wd_cancel(struct task_struct *curr, struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	wind_wd_t *wd;

	wd = (wind_wd_t *)xnregistry_fetch(handle);

	if (!wd)
		return S_objLib_OBJ_ID_ERROR;

	if (wdCancel((WDOG_ID)wd) == ERROR)
		return wind_errnoget();

	return 0;
}
Пример #9
0
int timer_settime
    (
    timer_t                 timerid,	/* timer ID                           */
    int                     flags,	/* absolute or relative               */
    const struct itimerspec *value,	/* time to be set                     */
    struct itimerspec       *ovalue	/* previous time set (NULL=no result) */
    )
    {
    struct timespec now;
    struct timespec timerExpire; /* absolute time that timer will go off */
    ULONG delayTicks;

    if (timerid == NULL)
	{
	errno = EINVAL;
	return (ERROR);
	}

    if (timerid->clock_id != CLOCK_REALTIME || !TV_VALID(value->it_value))
	{
	errno = EINVAL;
	return (ERROR);
	}

    if (ovalue != NULL)
	{

    /* if timer is disarmed, simply set value to 0 */
        if (timerid->active == FALSE)
        {
            ovalue->it_value.tv_sec = 0;
            ovalue->it_value.tv_nsec = 0;
        }
        else
        {

    /* get current time */
            if (clock_gettime (CLOCK_REALTIME, &now) == ERROR)
                return (ERROR);;

    /* use time stamp and get absolute time that timer will go off */
            timerExpire.tv_sec = timerid->timeStamp.tv_sec + timerid->exp.it_value.tv_sec;
            timerExpire.tv_nsec = timerid->timeStamp.tv_nsec + timerid->exp.it_value.tv_nsec;
            TV_NORMALIZE (timerExpire);

    /* compute difference using current time */
            ovalue->it_value.tv_sec = timerExpire.tv_sec - now.tv_sec;
            ovalue->it_value.tv_nsec = timerExpire.tv_nsec - now.tv_nsec;
            TV_NORMALIZE (ovalue->it_value);
        }

    /* get reload value */
        ovalue->it_interval.tv_sec = timerid->exp.it_interval.tv_sec;
        ovalue->it_interval.tv_nsec = timerid->exp.it_interval.tv_nsec;
        TV_NORMALIZE (ovalue->it_interval);

    }

    if (TV_ISZERO(value->it_value))
	{
	if (timerid->active)
	    {
	    timerid->active = FALSE;
	    wdCancel (timerid->wdog);
	    }
	return (OK);
	}

    TV_SET(timerid->exp.it_interval, value->it_interval);
    TV_SET(timerid->exp.it_value, value->it_value);

    if (flags == TIMER_ABSTIME)
	{
	/* convert current to relative time */
	(void) clock_gettime (CLOCK_REALTIME, &now);

	/* could be in the past */

	if (TV_GT(now, timerid->exp.it_value))
	    {
	    TV_ZERO(timerid->exp.it_value);
	    }
	else
	    {
    	    TV_SUB(timerid->exp.it_value, now);
	    }

	/* time stamp when timer is armed */
	TV_SET (timerid->timeStamp, now);
	}
    else
	/* time stamp when timer is armed */
	(void) clock_gettime (CLOCK_REALTIME, &(timerid->timeStamp));

    TV_CONVERT_TO_TICK (delayTicks, timerid->exp.it_value);

    if (timerid->active)
	wdCancel (timerid->wdog);
    else
	timerid->active = TRUE;

    wdStart (timerid->wdog, delayTicks, (FUNCPTR)timerWdHandler, (int)timerid);

    return (OK);
    }
Пример #10
0
static void
reset2SafeState( int why )  /* argument is the type of exception */
{
   int pTmpId, TmpPrior;
   int tuneactive = 0;

   DPRINT(1,"reset2SafeState");
   DPRINT(1,"stopAPint");
   pcsAbortSort();     /* parallel channel sort to stop and return to APint() */
   abortAPint();   /* like stopAPint() but also cause the Parser to suspend itself */
   /* stopAPint(); */
   DPRINT(1,"stop downLinker");
   setDwnLkAbort();   /* like stop downLinker and set to dump further download to bit bucket */
   DPRINT(1,"reset2SafeState");
   DPRINT(0,"fifoSetNoStuff\n");
   fifoSetNoStuff(pTheFifoObject);    /* stop the stuffer in it's tracks */
   DPRINT(0,"Disable STM Intrps");
   stmItrpDisable(pTheStmObject, STM_ALLITRPS);
   /* reset fifo Object not to use parallel channels */
   fifoClearPChanId(pTheFifoObject);
   DPRINT(0,"fifoReset");

   /* Keep the MTS gradient amp disabled whenever possible! */
   gpaTuneSet(pTheAutoObject, SET_GPAENABLE, GPA_DISABLE_DELAY);

   /* if an interactive abort do not reset the apbus, thus preventing the 
      all amplifier from going to Pulse Mode, thus amps that are in CW 
      will stay that way. This is/was a lockdisplay/shimming issue.
      Where exiting lock display set all the amps to Pulse Mode or blanked!, 
      then one shimmed and obtain a certain lock level. After su command 
      then amps would go back to CW thus injecting noise and lowing the
      lock level, If use wht directly to shimming they could neer re-attain 
      the lock level they had before.  But when enter and exit lock display 
      the level would jump back up. Thus causing no end of
      confusion....
      Thus for INTERACTIVE_ABORT the reset apbus bit is left out when reseting the FIFO.

      Oooops, but wait, we found an exception (of course), when exiting qtune the 
      reset of the apbus reset all the tune relays back to noraml, now of course 
      this does not happen thus leaving the console in tuning mode. Thus we added the 
      following test isTuneActive() and if it is then a full reset including the apbus
      is done.
   */
   tuneactive = isTuneActive();
   /* DPRINT1(-3,"Is Tune active: %d\n",tuneactive); */
   if ((why != INTERACTIVE_ABORT) || (tuneactive == 1))
      fifoReset(pTheFifoObject, RESETFIFOBRD);  /* this now also clear the Fifo Buffer & restart the Stuffer */
   else
      fifoReset(pTheFifoObject, RESETFIFO | RESETSTATEMACH | RESETTAGFIFO | RESETAPRDBKFIFO ); /* no apbus reset */

   /* set initial value of parallel channel free buffer pointer to null */
   clearParallelFreeBufs();

   DPRINT(0,"Stuff FIFO DIRECTLY with Safe State & Run fifo");
   fifoLoadHsl(pTheFifoObject, STD_HS_LINES, pTheFifoObject->SafeHSLines);
   fifoLoadHsl(pTheFifoObject, EXT_HS_LINES, pTheFifoObject->SafeHSLinesExt);
   /* Each SafeState Code is actually two long words */
   if (numSafeStatCodes > 0)
   {
      /*   WARNING: Does not pend for FF Almost Full, BEWARE !! */
      /*   Should only be used in phandler's reset2SafeState() */
      fifoStuffCode(pTheFifoObject, pSafeStateCodes, numSafeStatCodes);
      fifoStuffCode(pTheFifoObject, pTurnOffSshaCodes, numTurnOffSshaCodes);
      fifoStuffCode(pTheFifoObject, pHaltOpCodes, numHaltOpCodes);
	DPRINT(1,"Ready to start FIFO in reset to safe state\n" );
      fifoStart(pTheFifoObject);
      /* fifoWait4Stop(pTheFifoObject);  /* use BusyWait don't what any other lower priority tasks to run ! */
      fifoBusyWait4Stop(pTheFifoObject);  /* use BusyWait don't what any other lower priority tasks to run ! */
	DPRINT(1,"FIFO wait for stop completes in reset to safe state\n" );
   }
   activate_ssha();
   DPRINT(0,"getnGiveShimMutex\n");  
   /* allow any pending serial Shim commands to finish */
   getnGiveShimMutex();
   DPRINT(0,"getnGiveVTMutex\n");
   /* allow any pending serial VT commands to finish */
   getnGiveVTMutex();

/* Now Bump Priority of DownLiner so that it can Dump
   the remaining Data that SendProc wants to send it */

/* If we lost the connection to the host computer, the downlinker is
   is not going to get any more data; nor should this task (problem
   handler) wait for the downlinker to become ready.    April 1997  */

   DPRINT(0,"dlbFreeAllNotLoading Dyn");
   dlbFreeAllNotLoading(pDlbDynBufs);
   DPRINT(0,"dlbFreeAllNotLoading Fix");
   dlbFreeAllNotLoading(pDlbFixBufs);
   if (why != LOST_CONN)
   {
      pTmpId = taskNameToId("tDownLink");
      taskPriorityGet(pTmpId,&TmpPrior);
      taskPrioritySet(pTmpId,(pHandlerPriority-1));  

      /* downLinker has now A. ran and is suspended, 
			    B. Done and in READY state or
	 		    C. still waiting in a read of a socket
      */

      /* start wdog timeout of 20 seconds */ 
      wdStart(pHandlerWdTimeout,sysClkRateGet() * 20, pHandlerWdISR, 0);

      /* if it is busy and not suspend then wait till 
      /* it is Ready or Suspended, or Time-Out */
      while (downLinkerIsActive() &&  !taskIsSuspended(pTmpId) && !pHandlerTimeout)
            taskDelay(1);  /* wait one tick , 16msec */

      wdCancel(pHandlerWdTimeout);

      if (taskIsSuspended(pTmpId))
      {
        taskResume(pTmpId);
        wait4DownLinkerReady();
      }
      taskPrioritySet(pTmpId,TmpPrior);
      DPRINT(0,"downlinker resynchronized\n");
   }
   DPRINT(0,"dlbFreeAll Dyn");
   dlbFreeAll(pDlbDynBufs);
   DPRINT(0,"dlbFreeAll Fix");
   dlbFreeAll(pDlbFixBufs);

   /* 
     Now Bump Priority of Parser so that it can Finish Up  
     We don't have to worry as much about the state of the parser
     since it will completely restarted very soon. 
   */

   pTmpId = taskNameToId("tParser");
   taskPriorityGet(pTmpId,&TmpPrior);
   taskPrioritySet(pTmpId,(pHandlerPriority-1));  
   if (taskIsSuspended(pTmpId))
   {
     taskResume(pTmpId);
     wait4ParserReady();
   }
   taskPrioritySet(pTmpId,TmpPrior);
   resetAPint();
   DPRINT(0,"A-code parser resynchronized\n");

   /* Parser might of made a buffer ready to stuff, so better clear it just incase */
   if (why != INTERACTIVE_ABORT)
      fifoReset(pTheFifoObject, RESETFIFOBRD);  /* this now also clear the Fifo Buffer & restart the Stuffer */
   else
      fifoReset(pTheFifoObject, RESETFIFO | RESETSTATEMACH | RESETTAGFIFO | RESETAPRDBKFIFO ); /* no apbus reset */
   
   return;
}