Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

scc_return_t scc_monitor_security_failure ( void   callback_funcvoid  ) 

This routine will register a function to be called should a Security Failure be signalled by the SCC (Security Monitor).

The callback function may be called from interrupt level, it may be called from some process' task. It should therefore not take a long time to perform its operation, and it may not sleep.

Parameters:
callback_func Function pointer to routine which will receive notification of the security failure.
Returns:
0 if function was successfully registered, non-zero on failure. See scc_return_t.

For internal use only.

There is a fixed global static array which keeps track of the requests to monitor the failure.

Add callback_func to the first empty slot in scc_callbacks[]. If there is no room, return SCC_RET_TOO_MANY_FUNCTIONS.

Definition at line 660 of file mxc_scc.c.

Referenced by OS_DEV_INIT().

{
      int i;
      unsigned long irq_flags;      /* for IRQ save/restore */
      scc_return_t return_status = SCC_RET_TOO_MANY_FUNCTIONS;
      int function_stored = FALSE;

      if (scc_availability == SCC_STATUS_INITIAL) {
            scc_init();
      }

      /* Acquire lock of callbacks table.  Could be spin_lock_irq() if this
       * routine were just called from base (not interrupt) level
       */
      spin_lock_irqsave(&scc_callbacks_lock, irq_flags);

      /* Search through table looking for empty slot */
      for (i = 0; i < SCC_CALLBACK_SIZE; i++) {
            if (scc_callbacks[i] == callback_func) {
                  if (function_stored) {
                        /* Saved duplicate earlier.  Clear this later one. */
                        scc_callbacks[i] = NULL;
                  }
                  /* Exactly one copy is now stored */
                  return_status = SCC_RET_OK;
                  break;
            } else if (scc_callbacks[i] == NULL && !function_stored) {
                  /* Found open slot.  Save it and remember */
                  scc_callbacks[i] = callback_func;
                  return_status = SCC_RET_OK;
                  function_stored = TRUE;
            }
      }

      /* Free the lock */
      spin_unlock_irqrestore(&scc_callbacks_lock, irq_flags);

      return return_status;
}                       /* scc_monitor_security_failure */


Generated by  Doxygen 1.6.0   Back to index