2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Wind River Systems, Inc.
|
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
2015-10-06 11:00:37 -05:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
2015-12-04 10:09:39 -05:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief ARCv2 public interrupt handling
|
|
|
|
*
|
2015-04-10 16:44:37 -07:00
|
|
|
* ARCv2 nanokernel interrupt handling interface. Included by ARC/v2/arch.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ARCH_ARC_V2_IRQ__H_
|
|
|
|
#define _ARCH_ARC_V2_IRQ__H_
|
|
|
|
|
2015-05-28 10:56:47 -07:00
|
|
|
#include <arch/arc/v2/aux_regs.h>
|
2015-08-11 22:07:53 -04:00
|
|
|
#include <toolchain/common.h>
|
2016-02-25 13:21:02 -08:00
|
|
|
#include <irq.h>
|
2016-07-25 11:34:34 -07:00
|
|
|
#include <misc/util.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef _ASMLANGUAGE
|
|
|
|
GTEXT(_irq_exit);
|
2016-02-25 13:21:02 -08:00
|
|
|
GTEXT(_arch_irq_enable)
|
|
|
|
GTEXT(_arch_irq_disable)
|
2015-04-10 16:44:37 -07:00
|
|
|
#else
|
|
|
|
|
2016-02-25 13:21:02 -08:00
|
|
|
extern void _arch_irq_enable(unsigned int irq);
|
|
|
|
extern void _arch_irq_disable(unsigned int irq);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
extern void _irq_exit(void);
|
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* @brief Disable all interrupts on the local CPU
|
|
|
|
*
|
|
|
|
* This routine disables interrupts. It can be called from either interrupt,
|
|
|
|
* task or fiber level. This routine returns an architecture-dependent
|
|
|
|
* lock-out key representing the "interrupt disable state" prior to the call;
|
|
|
|
* this key can be passed to irq_unlock() to re-enable interrupts.
|
|
|
|
*
|
|
|
|
* The lock-out key should only be used as the argument to the
|
|
|
|
* irq_unlock() API. It should never be used to manually re-enable
|
|
|
|
* interrupts or to inspect or manipulate the contents of the source register.
|
|
|
|
*
|
|
|
|
* This function can be called recursively: it will return a key to return the
|
|
|
|
* state of interrupt locking to the previous level.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* WARNINGS
|
|
|
|
* Invoking a kernel routine with interrupts locked may result in
|
|
|
|
* interrupts being re-enabled for an unspecified period of time. If the
|
|
|
|
* called routine blocks, interrupts will be re-enabled while another
|
2015-08-20 11:04:01 -04:00
|
|
|
* thread executes, or while the system is idle.
|
2015-08-12 18:31:41 -04:00
|
|
|
*
|
2015-08-20 11:04:01 -04:00
|
|
|
* The "interrupt disable state" is an attribute of a thread. Thus, if a
|
2015-08-12 18:31:41 -04:00
|
|
|
* fiber or task disables interrupts and subsequently invokes a kernel
|
2015-08-20 11:04:01 -04:00
|
|
|
* routine that causes the calling thread to block, the interrupt
|
|
|
|
* disable state will be restored when the thread is later rescheduled
|
2015-08-12 18:31:41 -04:00
|
|
|
* for execution.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return An architecture-dependent lock-out key representing the
|
2015-07-01 17:22:39 -04:00
|
|
|
* "interrupt disable state" prior to the call.
|
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-02-25 13:21:02 -08:00
|
|
|
static ALWAYS_INLINE unsigned int _arch_irq_lock(void)
|
2015-04-10 16:44:37 -07:00
|
|
|
{
|
|
|
|
unsigned int key;
|
|
|
|
|
2016-12-02 12:19:16 -05:00
|
|
|
__asm__ volatile("clri %0" : "=r"(key):: "memory");
|
2015-04-10 16:44:37 -07:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* @brief Enable all interrupts on the local CPU
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-10-22 14:25:02 -04:00
|
|
|
* This routine re-enables interrupts on the local CPU. The @a key parameter
|
2015-08-12 18:31:41 -04:00
|
|
|
* is an architecture-dependent lock-out key that is returned by a previous
|
|
|
|
* invocation of irq_lock().
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* This routine can be called from either interrupt, task or fiber level.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* @return N/A
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-02-25 13:21:02 -08:00
|
|
|
static ALWAYS_INLINE void _arch_irq_unlock(unsigned int key)
|
2015-04-10 16:44:37 -07:00
|
|
|
{
|
2016-12-02 12:19:16 -05:00
|
|
|
__asm__ volatile("seti %0" : : "ir"(key) : "memory");
|
2015-04-10 16:44:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _ASMLANGUAGE */
|
2016-01-22 12:38:49 -05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif /* _ARCH_ARC_V2_IRQ__H_ */
|