2017-01-20 20:52:29 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Cadence Design Systems, Inc.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Xtensa specific kernel interface header
|
|
|
|
* This header contains the Xtensa specific kernel interface. It is included
|
|
|
|
* by the generic kernel interface header (include/arch/cpu.h)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ARCH_IFACE_H
|
|
|
|
#define _ARCH_IFACE_H
|
|
|
|
|
|
|
|
#include <irq.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
|
2017-01-31 11:17:02 +01:00
|
|
|
#include "sys_io.h" /* Include from the very same folder of this file */
|
Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-19 10:32:08 -05:00
|
|
|
#include <zephyr/types.h>
|
2017-01-20 20:52:29 +01:00
|
|
|
#include <sw_isr_table.h>
|
|
|
|
#include <arch/xtensa/xtensa_irq.h>
|
2017-02-08 16:26:32 +01:00
|
|
|
#include <xtensa/config/core.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XCC does not define the following macros with the expected names, but the
|
|
|
|
* file machine/endian.h from XT_LIB defines similar ones. Thus we include it
|
|
|
|
* and define the missing macros ourselves.
|
|
|
|
*/
|
2017-02-15 14:18:13 -08:00
|
|
|
#ifndef __BYTE_ORDER__
|
2017-02-08 16:26:32 +01:00
|
|
|
#define __BYTE_ORDER__ XCHAL_MEMORY_ORDER
|
2017-02-15 14:18:13 -08:00
|
|
|
#endif
|
|
|
|
#ifndef __ORDER_BIG_ENDIAN__
|
2017-02-08 16:26:32 +01:00
|
|
|
#define __ORDER_BIG_ENDIAN__ XTHAL_BIGENDIAN
|
2017-02-15 14:18:13 -08:00
|
|
|
#endif
|
|
|
|
#ifndef __ORDER_LITTLE_ENDIAN__
|
2017-02-08 16:26:32 +01:00
|
|
|
#define __ORDER_LITTLE_ENDIAN__ XTHAL_LITTLEENDIAN
|
2017-02-15 14:18:13 -08:00
|
|
|
#endif
|
2017-01-20 20:52:29 +01:00
|
|
|
|
|
|
|
#define STACK_ALIGN 16
|
|
|
|
#define OCTET_TO_SIZEOFUNIT(X) (X)
|
|
|
|
#define SIZEOFUNIT_TO_OCTET(X) (X)
|
|
|
|
|
|
|
|
#define _NANO_ERR_HW_EXCEPTION (0) /* MPU/Bus/Usage fault */
|
|
|
|
#define _NANO_ERR_INVALID_TASK_EXIT (1) /* Invalid task exit */
|
|
|
|
#define _NANO_ERR_STACK_CHK_FAIL (2) /* Stack corruption detected */
|
|
|
|
#define _NANO_ERR_ALLOCATION_FAIL (3) /* Kernel Allocation Failure */
|
2017-02-06 12:25:02 -08:00
|
|
|
#define _NANO_ERR_RESERVED_IRQ (4) /* Reserved interrupt */
|
2017-04-18 15:22:05 -07:00
|
|
|
#define _NANO_ERR_KERNEL_OOPS (5) /* Kernel oops (fatal to thread) */
|
|
|
|
#define _NANO_ERR_KERNEL_PANIC (6) /* Kernel panic (fatal to system) */
|
2017-01-20 20:52:29 +01:00
|
|
|
|
|
|
|
/* Xtensa GPRs are often designated by two different names */
|
2017-04-21 10:55:34 -05:00
|
|
|
#define sys_define_gpr_with_alias(name1, name2) union { u32_t name1, name2; }
|
2017-01-20 20:52:29 +01:00
|
|
|
|
|
|
|
#include <arch/xtensa/exc.h>
|
|
|
|
|
2017-01-24 15:33:02 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief find most significant bit set in a 32-bit word
|
|
|
|
*
|
|
|
|
* This routine finds the first bit set starting from the most significant bit
|
|
|
|
* in the argument passed in and returns the index of that bit. Bits are
|
|
|
|
* numbered starting at 1 from the least significant bit. A return value of
|
|
|
|
* zero indicates that the value passed is zero.
|
|
|
|
*
|
|
|
|
* @return most significant bit set, 0 if @a op is 0
|
|
|
|
*/
|
|
|
|
|
2017-04-21 10:55:34 -05:00
|
|
|
static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
|
2017-01-24 15:33:02 -08:00
|
|
|
{
|
|
|
|
if (!op)
|
|
|
|
return 0;
|
|
|
|
return 32 - __builtin_clz(op);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief find least significant bit set in a 32-bit word
|
|
|
|
*
|
|
|
|
* This routine finds the first bit set starting from the least significant bit
|
|
|
|
* in the argument passed in and returns the index of that bit. Bits are
|
|
|
|
* numbered starting at 1 from the least significant bit. A return value of
|
|
|
|
* zero indicates that the value passed is zero.
|
|
|
|
*
|
|
|
|
* @return least significant bit set, 0 if @a op is 0
|
|
|
|
*/
|
|
|
|
|
2017-04-21 10:55:34 -05:00
|
|
|
static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op)
|
2017-01-24 15:33:02 -08:00
|
|
|
{
|
|
|
|
return __builtin_ffs(op);
|
|
|
|
}
|
2017-01-20 20:52:29 +01:00
|
|
|
|
|
|
|
/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
|
2017-04-21 10:55:34 -05:00
|
|
|
extern void _irq_priority_set(u32_t irq, u32_t prio, u32_t flags);
|
2017-01-20 20:52:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure a static interrupt.
|
|
|
|
*
|
|
|
|
* All arguments must be computable by the compiler at build time; if this
|
|
|
|
* can't be done use irq_connect_dynamic() instead.
|
|
|
|
*
|
|
|
|
* Internally this function does a few things:
|
|
|
|
*
|
|
|
|
* 1. The enum statement has no effect but forces the compiler to only
|
|
|
|
* accept constant values for the irq_p parameter, very important as the
|
|
|
|
* numerical IRQ line is used to create a named section.
|
|
|
|
*
|
|
|
|
* 2. An instance of _isr_table_entry is created containing the ISR and its
|
|
|
|
* parameter. If you look at how _sw_isr_table is created, each entry in the
|
|
|
|
* array is in its own section named by the IRQ line number. What we are doing
|
|
|
|
* here is to override one of the default entries (which points to the
|
|
|
|
* spurious IRQ handler) with what was supplied here.
|
|
|
|
*
|
|
|
|
* 3. The priority level for the interrupt is configured by a call to
|
|
|
|
* _irq_priority_set()
|
|
|
|
*
|
|
|
|
* @param irq_p IRQ line number
|
|
|
|
* @param priority_p Interrupt priority
|
|
|
|
* @param isr_p Interrupt service routine
|
|
|
|
* @param isr_param_p ISR parameter
|
|
|
|
* @param flags_p IRQ options
|
|
|
|
*
|
|
|
|
* @return The vector assigned to this interrupt
|
|
|
|
*/
|
|
|
|
#define _ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
|
|
|
|
({ \
|
|
|
|
enum { IRQ = irq_p }; \
|
|
|
|
static struct _isr_table_entry \
|
|
|
|
_CONCAT(_isr_irq, irq_p) \
|
|
|
|
__attribute__ ((used)) \
|
|
|
|
__attribute__ ((section(\
|
|
|
|
STRINGIFY(_CONCAT(.gnu.linkonce.d.isr_irq, irq_p)))\
|
|
|
|
)) = {isr_param_p, isr_p}; \
|
|
|
|
_irq_priority_set(irq_p, priority_p, flags_p); \
|
|
|
|
irq_p; \
|
|
|
|
})
|
2017-02-06 12:25:02 -08:00
|
|
|
|
|
|
|
|
|
|
|
FUNC_NORETURN void _SysFatalErrorHandler(unsigned int reason,
|
|
|
|
const NANO_ESF *esf);
|
|
|
|
|
2017-04-21 10:55:34 -05:00
|
|
|
extern u32_t _timer_cycle_get_32(void);
|
2017-02-15 13:40:17 -08:00
|
|
|
#define _arch_k_cycle_get_32() _timer_cycle_get_32()
|
|
|
|
|
2017-01-20 20:52:29 +01:00
|
|
|
#endif /* !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__) */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ARCH_IFACE_H */
|