2015-04-10 16:44:37 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-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-08-29 14:41:17 -04:00
|
|
|
/**
|
2015-07-15 17:10:25 -04:00
|
|
|
* @file
|
|
|
|
* @brief IA-32 specific nanokernel interface header
|
|
|
|
* This header contains the IA-32 specific nanokernel interface. It is included
|
|
|
|
* by the generic nanokernel interface header (nanokernel.h)
|
2015-07-01 17:22:39 -04:00
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#ifndef _ARCH_IFACE_H
|
|
|
|
#define _ARCH_IFACE_H
|
|
|
|
|
2016-02-25 13:21:02 -08:00
|
|
|
#include <irq.h>
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifndef _ASMLANGUAGE
|
2015-06-01 16:18:34 -04:00
|
|
|
#include <arch/x86/asm_inline.h>
|
2015-09-18 16:05:10 -04:00
|
|
|
#include <arch/x86/addr_types.h>
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif
|
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-10-04 09:32:31 -04:00
|
|
|
/* APIs need to support non-byte addressable architectures */
|
2015-06-01 13:39:43 -04:00
|
|
|
|
|
|
|
#define OCTET_TO_SIZEOFUNIT(X) (X)
|
|
|
|
#define SIZEOFUNIT_TO_OCTET(X) (X)
|
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
2015-04-10 16:44:37 -07:00
|
|
|
* Macro used internally by NANO_CPU_INT_REGISTER and NANO_CPU_INT_REGISTER_ASM.
|
2015-07-27 09:47:56 -04:00
|
|
|
* Not meant to be used explicitly by platform, driver or application code.
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
#define MK_ISR_NAME(x) __isr__##x
|
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
#ifdef CONFIG_MICROKERNEL
|
|
|
|
#define ALL_DYN_IRQ_STUBS (CONFIG_NUM_DYNAMIC_STUBS + CONFIG_MAX_NUM_TASK_IRQS)
|
|
|
|
#elif defined(CONFIG_NANOKERNEL)
|
|
|
|
#define ALL_DYN_IRQ_STUBS (CONFIG_NUM_DYNAMIC_STUBS)
|
|
|
|
#endif
|
2015-04-10 16:44:37 -07:00
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
#define ALL_DYN_EXC_STUBS (CONFIG_NUM_DYNAMIC_EXC_STUBS + \
|
|
|
|
CONFIG_NUM_DYNAMIC_EXC_NOERR_STUBS)
|
2015-04-10 16:44:37 -07:00
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
#define ALL_DYN_STUBS (ALL_DYN_EXC_STUBS + ALL_DYN_IRQ_STUBS)
|
|
|
|
|
2015-12-14 09:56:38 -08:00
|
|
|
|
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
/*
|
|
|
|
* Synchronize these DYN_STUB_* macros with the generated assembly for
|
|
|
|
* _DynIntStubsBegin in intstub.S / _DynExcStubsBegin in excstub.S
|
|
|
|
* Assumes all stub types are same size/format
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
|
|
|
|
/* Size of each dynamic interrupt/exception stub in bytes */
|
2016-01-14 08:10:23 -08:00
|
|
|
#ifdef CONFIG_X86_IAMCU
|
2015-12-14 09:56:38 -08:00
|
|
|
#define DYN_STUB_SIZE 8
|
|
|
|
#else
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
#define DYN_STUB_SIZE 9
|
2015-12-14 09:56:38 -08:00
|
|
|
#endif
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Offset from the beginning of a stub to the byte containing the argument
|
|
|
|
* to the push instruction, which is the stub index
|
|
|
|
*/
|
|
|
|
#define DYN_STUB_IDX_OFFSET 6
|
|
|
|
|
|
|
|
/* Size of the periodic jmp instruction to the common handler */
|
|
|
|
#define DYN_STUB_JMP_SIZE 5
|
|
|
|
|
|
|
|
/*
|
|
|
|
* How many consecutive stubs we have until we encounter a periodic
|
|
|
|
* jump to _DynStubCommon
|
|
|
|
*/
|
|
|
|
#define DYN_STUB_PER_BLOCK 8
|
|
|
|
|
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
|
|
|
|
/* interrupt/exception/error related definitions */
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
2015-05-26 10:21:42 -04:00
|
|
|
* Floating point register set alignment.
|
|
|
|
*
|
|
|
|
* If support for SSEx extensions is enabled a 16 byte boundary is required,
|
2015-10-04 10:01:56 -04:00
|
|
|
* since the 'fxsave' and 'fxrstor' instructions require this. In all other
|
2015-10-04 09:32:31 -04:00
|
|
|
* cases a 4 byte boundary is sufficient.
|
2015-05-26 10:21:42 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_SSE
|
|
|
|
#define FP_REG_SET_ALIGN 16
|
|
|
|
#else
|
|
|
|
#define FP_REG_SET_ALIGN 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2015-08-20 11:04:01 -04:00
|
|
|
* The TCS must be aligned to the same boundary as that used by the floating
|
|
|
|
* point register set. This applies even for threads that don't initially
|
2015-05-26 10:21:42 -04:00
|
|
|
* use floating point, since it is possible to enable floating point support
|
|
|
|
* later on.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define STACK_ALIGN FP_REG_SET_ALIGN
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-11 10:10:41 -05:00
|
|
|
typedef struct s_isrList {
|
2015-07-15 17:10:25 -04:00
|
|
|
/** Address of ISR/stub */
|
|
|
|
void *fnc;
|
2015-10-01 15:31:31 -04:00
|
|
|
/** IRQ associated with the ISR/stub */
|
|
|
|
unsigned int irq;
|
|
|
|
/** Priority associated with the IRQ */
|
|
|
|
unsigned int priority;
|
2015-07-15 17:10:25 -04:00
|
|
|
/** Vector number associated with ISR/stub */
|
|
|
|
unsigned int vec;
|
|
|
|
/** Privilege level associated with ISR/stub */
|
|
|
|
unsigned int dpl;
|
2015-04-10 16:44:37 -07:00
|
|
|
} ISR_LIST;
|
|
|
|
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Connect a routine to an interrupt vector
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-09-17 12:59:37 -04:00
|
|
|
* This macro "connects" the specified routine, @a r, to the specified interrupt
|
|
|
|
* vector, @a v using the descriptor privilege level @a d. On the IA-32
|
2015-07-01 17:22:39 -04:00
|
|
|
* architecture, an interrupt vector is a value from 0 to 255. This macro
|
|
|
|
* populates the special intList section with the address of the routine, the
|
|
|
|
* vector number and the descriptor privilege level. The genIdt tool then picks
|
|
|
|
* up this information and generates an actual IDT entry with this information
|
|
|
|
* properly encoded. This macro replaces the _IntVecSet () routine in static
|
|
|
|
* interrupt systems.
|
|
|
|
*
|
2015-09-17 12:59:37 -04:00
|
|
|
* The @a d argument specifies the privilege level for the interrupt-gate
|
2015-07-01 17:22:39 -04:00
|
|
|
* descriptor; (hardware) interrupts and exceptions should specify a level of 0,
|
|
|
|
* whereas handlers for user-mode software generated interrupts should specify 3.
|
2015-07-15 17:10:25 -04:00
|
|
|
* @param r Routine to be connected
|
2015-10-01 15:31:31 -04:00
|
|
|
* @param n IRQ number
|
|
|
|
* @param p IRQ priority
|
2015-07-15 17:10:25 -04:00
|
|
|
* @param v Interrupt Vector
|
|
|
|
* @param d Descriptor Privilege Level
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-07-01 17:29:04 -04:00
|
|
|
* @return N/A
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
*/
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-10-01 15:31:31 -04:00
|
|
|
#define NANO_CPU_INT_REGISTER(r, n, p, v, d) \
|
|
|
|
ISR_LIST __attribute__((section(".intList"))) MK_ISR_NAME(r) = \
|
|
|
|
{&r, n, p, v, d}
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-01-08 00:46:14 -08:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2016-01-08 00:46:14 -08:00
|
|
|
* Inline assembly code for the interrupt stub
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* This is the actual assembly code which gets run when the interrupt
|
|
|
|
* is triggered. Due to different calling convention semantics we have
|
|
|
|
* different versions for IAMCU and SYSV.
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* For IAMCU case, we call _execute_handler() with the isr and its argument
|
|
|
|
* as parameters.
|
2015-07-15 17:10:25 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* For SysV case, we first call _IntEnt to properly enter Zephyr's interrupt
|
|
|
|
* handling context, and then directly call the isr. A jump is done to
|
|
|
|
* _IntExitWithEoi which does EOI to the interrupt controller, restores
|
|
|
|
* context, and finally does 'iret'.
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-27 10:07:31 -08:00
|
|
|
* This is only intended to be used by the IRQ_CONNECT() macro.
|
2015-06-01 14:14:31 -04:00
|
|
|
*/
|
2016-01-08 00:46:14 -08:00
|
|
|
#if CONFIG_X86_IAMCU
|
|
|
|
#define _IRQ_STUB_ASM \
|
|
|
|
"pushl %%eax\n\t" \
|
|
|
|
"pushl %%edx\n\t" \
|
|
|
|
"pushl %%ecx\n\t" \
|
|
|
|
"movl %[isr], %%eax\n\t" \
|
|
|
|
"movl %[isr_param], %%edx\n\t" \
|
|
|
|
"call _execute_handler\n\t" \
|
|
|
|
"popl %%ecx\n\t" \
|
|
|
|
"popl %%edx\n\t" \
|
|
|
|
"popl %%eax\n\t" \
|
|
|
|
"iret\n\t"
|
2015-11-19 10:00:27 -08:00
|
|
|
#else
|
2016-01-08 00:46:14 -08:00
|
|
|
#define _IRQ_STUB_ASM \
|
|
|
|
"call _IntEnt\n\t" \
|
|
|
|
"pushl %[isr_param]\n\t" \
|
|
|
|
"call %P[isr]\n\t" \
|
|
|
|
"jmp _IntExitWithEoi\n\t"
|
|
|
|
#endif /* CONFIG_X86_IAMCU */
|
2015-06-01 14:14:31 -04:00
|
|
|
|
2015-10-09 16:23:25 -04:00
|
|
|
/**
|
2016-01-08 00:46:14 -08:00
|
|
|
* Code snippets for populating the vector ID and priority into the intList
|
2015-10-09 16:23:25 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* The 'magic' of static interrupts is accomplished by building up an array
|
|
|
|
* 'intList' at compile time, and the gen_idt tool uses this to create the
|
|
|
|
* actual IDT data structure.
|
|
|
|
*
|
|
|
|
* For controllers like APIC, the vectors in the IDT are not normally assigned
|
|
|
|
* at build time; instead the sentinel value -1 is saved, and gen_idt figures
|
|
|
|
* out the right vector to use based on our priority scheme. Groups of 16
|
|
|
|
* vectors starting at 32 correspond to each priority level.
|
|
|
|
*
|
|
|
|
* On MVIC, the mapping is fixed; the vector to use is just the irq line
|
|
|
|
* number plus 0x20. The priority argument supplied by the user is discarded.
|
|
|
|
*
|
2016-01-27 10:07:31 -08:00
|
|
|
* These macros are only intended to be used by IRQ_CONNECT() macro.
|
2015-10-09 16:23:25 -04:00
|
|
|
*/
|
2016-01-08 00:46:14 -08:00
|
|
|
#if CONFIG_MVIC
|
2016-02-01 16:09:32 -08:00
|
|
|
#define _PRIORITY_ARG(irq_p, priority_p) (-1)
|
2016-01-08 00:46:14 -08:00
|
|
|
#define _VECTOR_ARG(irq_p) (irq_p + 0x20)
|
|
|
|
#else
|
|
|
|
#define _PRIORITY_ARG(irq_p, priority_p) (priority_p)
|
|
|
|
#define _VECTOR_ARG(irq_p) (-1)
|
|
|
|
#endif /* CONFIG_MVIC */
|
2015-10-09 16:23:25 -04:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2016-01-08 00:46:14 -08:00
|
|
|
* Configure a static interrupt.
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* All arguments must be computable by the compiler at build time; if this
|
|
|
|
* can't be done use irq_connect_dynamic() instead.
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* Internally this function does a few things:
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* 1. There is a block of inline assembly which is completely skipped over
|
|
|
|
* at runtime with an initial 'jmp' instruction.
|
|
|
|
*
|
|
|
|
* 2. There is a declaration of the interrupt parameters in the .intList
|
|
|
|
* section, used by gen_idt to create the IDT. This does the same thing
|
|
|
|
* as the NANO_CPU_INT_REGISTER() macro, but is done in assembly as we
|
|
|
|
* need to populate the .fnc member with the address of the assembly
|
|
|
|
* IRQ stub that we generate immediately afterwards.
|
|
|
|
*
|
|
|
|
* 3. The IRQ stub itself is declared. It doesn't get run in the context
|
|
|
|
* of the calling function due to the initial 'jmp' instruction at the
|
|
|
|
* beginning of the assembly block, but a pointer to it gets saved in the IDT.
|
|
|
|
*
|
|
|
|
* 4. _SysIntVecProgram() is called at runtime to set the mapping between
|
|
|
|
* the vector and the IRQ line.
|
|
|
|
*
|
|
|
|
* @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 triggering options
|
|
|
|
*
|
|
|
|
* @return The vector assigned to this interrupt
|
|
|
|
*/
|
2016-02-25 13:21:02 -08:00
|
|
|
#define _ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p) \
|
2016-01-08 00:46:14 -08:00
|
|
|
({ \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"jmp 2f\n\t" \
|
|
|
|
".pushsection .intList\n\t" \
|
|
|
|
".long 1f\n\t" /* ISR_LIST.fnc */ \
|
|
|
|
".long %P[irq]\n\t" /* ISR_LIST.irq */ \
|
|
|
|
".long %P[priority]\n\t" /* ISR_LIST.priority */ \
|
|
|
|
".long %P[vector]\n\t" /* ISR_LIST.vec */ \
|
|
|
|
".long 0\n\t" /* ISR_LIST.dpl */ \
|
|
|
|
".popsection\n\t" \
|
|
|
|
"1:\n\t" \
|
|
|
|
_IRQ_STUB_ASM \
|
|
|
|
"2:\n\t" \
|
|
|
|
: \
|
|
|
|
: [isr] "i" (isr_p), \
|
|
|
|
[isr_param] "i" (isr_param_p), \
|
|
|
|
[priority] "i" _PRIORITY_ARG(irq_p, priority_p), \
|
|
|
|
[vector] "i" _VECTOR_ARG(irq_p), \
|
|
|
|
[irq] "i" (irq_p)); \
|
|
|
|
_SysIntVecProgram(_IRQ_TO_INTERRUPT_VECTOR(irq_p), (irq_p), (flags_p)); \
|
|
|
|
_IRQ_TO_INTERRUPT_VECTOR(irq_p); \
|
|
|
|
})
|
|
|
|
|
2016-01-27 12:19:15 -08:00
|
|
|
#ifdef CONFIG_MVIC
|
|
|
|
/* Fixed vector-to-irq association mapping.
|
|
|
|
* No need for the table at all.
|
|
|
|
*/
|
|
|
|
#define _IRQ_TO_INTERRUPT_VECTOR(irq) (irq + 0x20)
|
|
|
|
#else
|
2016-01-08 00:46:14 -08:00
|
|
|
/**
|
|
|
|
* @brief Convert a statically connected IRQ to its interrupt vector number
|
2015-06-01 14:14:31 -04:00
|
|
|
*
|
2016-01-08 00:46:14 -08:00
|
|
|
* @param irq IRQ number
|
2015-06-01 14:14:31 -04:00
|
|
|
*/
|
2016-01-27 12:19:15 -08:00
|
|
|
extern unsigned char _irq_to_interrupt_vector[];
|
2016-01-08 00:46:14 -08:00
|
|
|
#define _IRQ_TO_INTERRUPT_VECTOR(irq) \
|
|
|
|
((unsigned int) _irq_to_interrupt_vector[irq])
|
2016-01-27 12:19:15 -08:00
|
|
|
#endif
|
2015-06-01 14:14:31 -04:00
|
|
|
|
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
|
|
|
* @brief Nanokernel Exception Stack Frame
|
2015-10-04 09:32:31 -04:00
|
|
|
*
|
2015-04-10 16:44:37 -07:00
|
|
|
* A pointer to an "exception stack frame" (ESF) is passed as an argument
|
2015-10-05 10:48:46 -04:00
|
|
|
* to exception handlers registered via nanoCpuExcConnect(). As the system
|
|
|
|
* always operates at ring 0, only the EIP, CS and EFLAGS registers are pushed
|
|
|
|
* onto the stack when an exception occurs.
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
2015-10-05 10:48:46 -04:00
|
|
|
* The exception stack frame includes the volatile registers (EAX, ECX, and
|
|
|
|
* EDX) as well as the 5 non-volatile registers (EDI, ESI, EBX, EBP and ESP).
|
|
|
|
* Those registers are pushed onto the stack by _ExcEnt().
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct nanoEsf {
|
2015-10-05 10:48:46 -04:00
|
|
|
unsigned int esp;
|
2015-04-10 16:44:37 -07:00
|
|
|
unsigned int ebp;
|
|
|
|
unsigned int ebx;
|
|
|
|
unsigned int esi;
|
|
|
|
unsigned int edi;
|
|
|
|
unsigned int edx;
|
|
|
|
unsigned int eax;
|
2016-01-14 16:22:28 -08:00
|
|
|
unsigned int ecx;
|
2015-04-10 16:44:37 -07:00
|
|
|
unsigned int errorCode;
|
|
|
|
unsigned int eip;
|
|
|
|
unsigned int cs;
|
|
|
|
unsigned int eflags;
|
|
|
|
} NANO_ESF;
|
|
|
|
|
2015-08-29 14:41:17 -04:00
|
|
|
/**
|
2015-07-15 17:10:25 -04:00
|
|
|
* @brief Nanokernel "interrupt stack frame" (ISF)
|
2015-10-04 09:32:31 -04:00
|
|
|
*
|
2015-04-10 16:44:37 -07:00
|
|
|
* An "interrupt stack frame" (ISF) as constructed by the processor
|
2015-10-05 10:48:46 -04:00
|
|
|
* and the interrupt wrapper function _IntEnt(). As the system always operates
|
|
|
|
* at ring 0, only the EIP, CS and EFLAGS registers are pushed onto the stack
|
|
|
|
* when an interrupt occurs.
|
2015-04-10 16:44:37 -07:00
|
|
|
*
|
|
|
|
* The interrupt stack frame includes the volatile registers EAX, ECX, and EDX
|
2015-10-05 10:48:46 -04:00
|
|
|
* pushed on the stack by _IntEnt().
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct nanoIsf {
|
|
|
|
unsigned int edx;
|
|
|
|
unsigned int ecx;
|
|
|
|
unsigned int eax;
|
|
|
|
unsigned int eip;
|
|
|
|
unsigned int cs;
|
|
|
|
unsigned int eflags;
|
|
|
|
} NANO_ISF;
|
|
|
|
|
|
|
|
#endif /* !_ASMLANGUAGE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reason codes passed to both _NanoFatalErrorHandler()
|
|
|
|
* and _SysFatalErrorHandler().
|
|
|
|
*/
|
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/** Unhandled exception/interrupt */
|
|
|
|
#define _NANO_ERR_SPURIOUS_INT (0)
|
|
|
|
/** Page fault */
|
|
|
|
#define _NANO_ERR_PAGE_FAULT (1)
|
|
|
|
/** General protection fault */
|
|
|
|
#define _NANO_ERR_GEN_PROT_FAULT (2)
|
|
|
|
/** Invalid task exit */
|
|
|
|
#define _NANO_ERR_INVALID_TASK_EXIT (3)
|
|
|
|
/** Stack corruption detected */
|
|
|
|
#define _NANO_ERR_STACK_CHK_FAIL (4)
|
|
|
|
/** Kernel Allocation Failure */
|
|
|
|
#define _NANO_ERR_ALLOCATION_FAIL (5)
|
2015-12-04 13:03:51 -08:00
|
|
|
/** Unhandled exception */
|
|
|
|
#define _NANO_ERR_CPU_EXCEPTION (6)
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#ifndef _ASMLANGUAGE
|
|
|
|
|
2016-01-05 15:37:22 -05:00
|
|
|
#ifdef CONFIG_INT_LATENCY_BENCHMARK
|
2015-05-12 10:12:36 -05:00
|
|
|
void _int_latency_start(void);
|
|
|
|
void _int_latency_stop(void);
|
2016-01-05 15:37:22 -05:00
|
|
|
#else
|
|
|
|
#define _int_latency_start() do { } while (0)
|
|
|
|
#define _int_latency_stop() do { } while (0)
|
|
|
|
#endif
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Disable all interrupts on the CPU (inline)
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
* 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;
|
2015-08-12 18:31:41 -04:00
|
|
|
* this key can be passed to irq_unlock() to re-enable interrupts.
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-12 18:31:41 -04:00
|
|
|
* 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
|
|
|
*
|
|
|
|
* 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-07-01 17:22:39 -04:00
|
|
|
*
|
2015-08-20 11:04:01 -04:00
|
|
|
* The "interrupt disable state" is an attribute of a thread. Thus, if a
|
2015-07-01 17:22:39 -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-07-01 17:22:39 -04:00
|
|
|
* for execution.
|
|
|
|
*
|
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 inline __attribute__((always_inline)) unsigned int _arch_irq_lock(void)
|
2015-05-14 16:30:48 -05:00
|
|
|
{
|
2015-08-12 18:31:41 -04:00
|
|
|
unsigned int key = _do_irq_lock();
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-12 10:12:36 -05:00
|
|
|
_int_latency_start();
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
return key;
|
2015-05-14 16:30:48 -05:00
|
|
|
}
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
|
2015-07-01 17:22:39 -04:00
|
|
|
/**
|
|
|
|
*
|
2015-07-01 17:51:40 -04:00
|
|
|
* @brief Enable all interrupts on the CPU (inline)
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
2015-09-17 12:59:37 -04:00
|
|
|
* This routine re-enables interrupts on the CPU. The @a key parameter
|
2015-07-01 17:22:39 -04:00
|
|
|
* is an architecture-dependent lock-out key that is returned by a previous
|
2015-08-12 18:31:41 -04:00
|
|
|
* invocation of irq_lock().
|
2015-07-01 17:22:39 -04:00
|
|
|
*
|
|
|
|
* This routine can be called from either interrupt, task or fiber level.
|
|
|
|
*
|
2015-07-01 17:29:04 -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 inline __attribute__((always_inline)) void _arch_irq_unlock(unsigned int key)
|
2015-05-14 16:30:48 -05:00
|
|
|
{
|
|
|
|
if (!(key & 0x200)) {
|
2015-04-10 16:44:37 -07:00
|
|
|
return;
|
2015-05-14 16:30:48 -05:00
|
|
|
}
|
2015-12-08 09:26:53 -08:00
|
|
|
|
2015-05-12 10:12:36 -05:00
|
|
|
_int_latency_stop();
|
2015-12-08 09:26:53 -08:00
|
|
|
|
2015-08-12 18:31:41 -04:00
|
|
|
_do_irq_unlock();
|
2015-05-14 16:30:48 -05:00
|
|
|
}
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/** interrupt/exception/error related definitions */
|
2015-04-10 16:44:37 -07:00
|
|
|
typedef void (*NANO_EOI_GET_FUNC) (void *);
|
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
2015-09-17 12:59:37 -04:00
|
|
|
* The NANO_SOFT_IRQ macro must be used as the value for the @a irq parameter
|
2016-01-08 13:40:09 -08:00
|
|
|
* to NANO_CPU_INT_REGSITER when connecting to an interrupt that does not
|
|
|
|
* correspond to any IRQ line (such as spurious vector or SW IRQ)
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
|
|
|
#define NANO_SOFT_IRQ ((unsigned int) (-1))
|
|
|
|
|
|
|
|
#ifdef CONFIG_FP_SHARING
|
2015-05-22 15:11:32 -04:00
|
|
|
/* Definitions for the 'options' parameter to the fiber_fiber_start() API */
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-08-20 11:04:01 -04:00
|
|
|
/** thread uses floating point unit */
|
2015-07-15 17:10:25 -04:00
|
|
|
#define USE_FP 0x10
|
2015-04-10 16:44:37 -07:00
|
|
|
#ifdef CONFIG_SSE
|
2015-08-20 11:04:01 -04:00
|
|
|
/** thread uses SSEx instructions */
|
2015-07-15 17:10:25 -04:00
|
|
|
#define USE_SSE 0x20
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif /* CONFIG_SSE */
|
|
|
|
#endif /* CONFIG_FP_SHARING */
|
|
|
|
|
2016-02-25 13:21:02 -08:00
|
|
|
extern int _arch_irq_connect_dynamic(unsigned int irq,
|
2015-04-10 16:44:37 -07:00
|
|
|
unsigned int priority,
|
2015-05-12 10:43:08 -05:00
|
|
|
void (*routine)(void *parameter),
|
2015-11-02 18:06:08 -05:00
|
|
|
void *parameter,
|
|
|
|
uint32_t flags);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
|
|
|
* @brief Enable a specific IRQ
|
|
|
|
* @param irq IRQ
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
2016-02-25 13:21:02 -08:00
|
|
|
extern void _arch_irq_enable(unsigned int irq);
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
|
|
|
* @brief Disable a specific IRQ
|
|
|
|
* @param irq IRQ
|
|
|
|
*/
|
2016-02-25 13:21:02 -08:00
|
|
|
extern void _arch_irq_disable(unsigned int irq);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_FP_SHARING
|
2015-07-15 17:10:25 -04:00
|
|
|
/**
|
|
|
|
* @brief Enable floating point hardware resources sharing
|
2015-08-20 11:04:01 -04:00
|
|
|
* Dynamically enable/disable the capability of a thread to share floating
|
2015-04-10 16:44:37 -07:00
|
|
|
* point hardware resources. The same "floating point" options accepted by
|
2015-05-22 15:11:32 -04:00
|
|
|
* fiber_fiber_start() are accepted by these APIs (i.e. USE_FP and USE_SSE).
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
2015-08-20 11:04:01 -04:00
|
|
|
extern void fiber_float_enable(nano_thread_id_t thread_id,
|
|
|
|
unsigned int options);
|
|
|
|
extern void task_float_enable(nano_thread_id_t thread_id,
|
|
|
|
unsigned int options);
|
|
|
|
extern void fiber_float_disable(nano_thread_id_t thread_id);
|
|
|
|
extern void task_float_disable(nano_thread_id_t thread_id);
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif /* CONFIG_FP_SHARING */
|
|
|
|
|
|
|
|
#include <stddef.h> /* for size_t */
|
|
|
|
|
2015-05-12 10:12:36 -05:00
|
|
|
extern void nano_cpu_idle(void);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-15 17:10:25 -04:00
|
|
|
/** Nanokernel provided routine to report any detected fatal error. */
|
2015-04-10 16:44:37 -07:00
|
|
|
extern FUNC_NORETURN void _NanoFatalErrorHandler(unsigned int reason,
|
2015-10-20 09:42:34 -07:00
|
|
|
const NANO_ESF * pEsf);
|
2015-07-15 17:10:25 -04:00
|
|
|
/** User provided routine to handle any detected fatal error post reporting. */
|
2015-04-10 16:44:37 -07:00
|
|
|
extern FUNC_NORETURN void _SysFatalErrorHandler(unsigned int reason,
|
2015-10-20 09:42:34 -07:00
|
|
|
const NANO_ESF * pEsf);
|
2015-07-15 17:10:25 -04:00
|
|
|
/** Dummy ESF for fatal errors that would otherwise not have an ESF */
|
2015-05-08 17:12:56 -05:00
|
|
|
extern const NANO_ESF _default_esf;
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-08-29 14:41:17 -04:00
|
|
|
/**
|
2015-07-15 17:10:25 -04:00
|
|
|
* @brief Configure an interrupt vector of the specified priority
|
|
|
|
*
|
2015-07-27 09:47:56 -04:00
|
|
|
* This routine is invoked by the kernel to configure an interrupt vector of
|
|
|
|
* the specified priority. To this end, it allocates an interrupt vector,
|
2015-10-04 09:32:31 -04:00
|
|
|
* programs hardware to route interrupt requests on the specified IRQ to that
|
x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.
Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.
CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.
Some other out-of-date verbiage in comments related to supporting
non-APIC removed.
Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.
SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.
All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.
_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.
Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2015-10-19 14:10:53 -07:00
|
|
|
* vector, and returns the vector number
|
2015-04-10 16:44:37 -07:00
|
|
|
*/
|
2015-07-15 17:10:25 -04:00
|
|
|
extern int _SysIntVecAlloc(unsigned int irq,
|
2015-11-02 18:06:08 -05:00
|
|
|
unsigned int priority,
|
|
|
|
uint32_t flags);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Program interrupt controller
|
|
|
|
*
|
|
|
|
* This routine programs the interrupt controller with the given vector
|
|
|
|
* based on the given IRQ parameter.
|
|
|
|
*
|
2016-01-27 10:07:31 -08:00
|
|
|
* Drivers call this routine instead of IRQ_CONNECT() when interrupts are
|
2015-11-02 18:06:08 -05:00
|
|
|
* configured statically.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
extern void _SysIntVecProgram(unsigned int vector, unsigned int irq, uint32_t flags);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-07-27 09:47:56 -04:00
|
|
|
/* functions provided by the kernel for usage by _SysIntVecAlloc() */
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-12 10:12:36 -05:00
|
|
|
extern int _IntVecAlloc(unsigned int priority);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-12 10:12:36 -05:00
|
|
|
extern void _IntVecMarkAllocated(unsigned int vector);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2015-05-12 10:12:36 -05:00
|
|
|
extern void _IntVecMarkFree(unsigned int vector);
|
2015-04-10 16:44:37 -07:00
|
|
|
|
2016-01-27 14:14:21 -08:00
|
|
|
#if CONFIG_DEBUG_IRQS
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @brief Dump out the IDT for debugging purposes
|
|
|
|
*
|
|
|
|
* The IDT has a strange structure which confounds direct examination in
|
|
|
|
* a debugger. This function will print out its contents in human-readable
|
|
|
|
* form. If unused, gc-sections will strip this function from the binary.
|
|
|
|
*/
|
|
|
|
void irq_debug_dump_idt(void);
|
|
|
|
#endif /* CONFIG_DEBUG_IRQS */
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif /* !_ASMLANGUAGE */
|
|
|
|
|
2015-10-04 09:32:31 -04:00
|
|
|
/* Segment selector definitions are shared */
|
2015-04-10 16:44:37 -07:00
|
|
|
#include "segselect.h"
|
|
|
|
|
2015-09-28 16:04:34 -04:00
|
|
|
/* reboot through Reset Control Register (I/O port 0xcf9) */
|
|
|
|
|
|
|
|
#define SYS_X86_RST_CNT_REG 0xcf9
|
|
|
|
#define SYS_X86_RST_CNT_SYS_RST 0x02
|
|
|
|
#define SYS_X86_RST_CNT_CPU_RST 0x4
|
|
|
|
#define SYS_X86_RST_CNT_FULL_RST 0x08
|
|
|
|
|
2016-01-22 12:38:49 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-04-10 16:44:37 -07:00
|
|
|
#endif /* _ARCH_IFACE_H */
|