#3459 closed enhancement (fixed)
Rework initialization and interrupt stack support
Reported by: | Sebastian Huber | Owned by: | Sebastian Huber |
---|---|---|---|
Priority: | normal | Milestone: | 5.1 |
Component: | score | Version: | 5 |
Severity: | normal | Keywords: | qualification |
Cc: | Blocked By: | ||
Blocking: | #3433 |
Description
We need an initialization stack to run the sequential system initialization before multitasking is enabled. The system initialization is done with interrupts disabled.
We need an interrupt stack for interrupt processing. This helps to avoid a per thread stack overhead for interrupt processing. The size for interrupt stack is application dependent, e.g. maximum interrupt nest level, stack demands of interrupt handlers.
The initialization and interrupt stacks are needed for each processor in the system.
Since interrupts are disabled during the sequential system initialization we can re-use the interrupt stack for the initialization stack. This is important for low end targets, with very limited RAM sizes. We need the initialization stack before a proper C run-time environment is set up e.g. we cannot assume that the access to global data is available. The stack memory area begin and size should be available via global symbols (named addresses). On some BSPs, e.g. ARM, this is done via the linker command file.
It should be possible to set the stack size via the CONFIGURE_INTERRUPT_STACK_SIZE configuration option and not via some magic stuff in linker command files.
Many BSPs set the BSS area to zero during system initialization. Thus, the initialization stack must not be contained in the BSS area.
The interrupt stack implementation is currently controlled by the following CPU port defines:
/** * Does RTEMS manage a dedicated interrupt stack in software? * * If TRUE, then a stack is allocated in @ref _ISR_Handler_initialization. * If FALSE, nothing is done. * * If the CPU supports a dedicated interrupt stack in hardware, * then it is generally the responsibility of the BSP to allocate it * and set it up. * * If the CPU does not support a dedicated interrupt stack, then * the porter has two options: (1) execute interrupts on the * stack of the interrupted task, and (2) have RTEMS manage a dedicated * interrupt stack. * * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. * * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is * possible that both are FALSE for a particular CPU. Although it * is unclear what that would imply about the interrupt processing * procedure on that CPU. * * Port Specific Information: * * XXX document implementation including references if appropriate */ #define CPU_HAS_SOFTWARE_INTERRUPT_STACK FALSE /** * Does this CPU have hardware support for a dedicated interrupt stack? * * If TRUE, then it must be installed during initialization. * If FALSE, then no installation is performed. * * If this is TRUE, @ref CPU_ALLOCATE_INTERRUPT_STACK should also be TRUE. * * Only one of @ref CPU_HAS_SOFTWARE_INTERRUPT_STACK and * @ref CPU_HAS_HARDWARE_INTERRUPT_STACK should be set to TRUE. It is * possible that both are FALSE for a particular CPU. Although it * is unclear what that would imply about the interrupt processing * procedure on that CPU. * * Port Specific Information: * * XXX document implementation including references if appropriate */ #define CPU_HAS_HARDWARE_INTERRUPT_STACK TRUE /** * Does RTEMS allocate a dedicated interrupt stack in the Interrupt Manager? * * If TRUE, then the memory is allocated during initialization. * If FALSE, then the memory is allocated during initialization. * * This should be TRUE is CPU_HAS_SOFTWARE_INTERRUPT_STACK is TRUE. * * Port Specific Information: * * XXX document implementation including references if appropriate */ #define CPU_ALLOCATE_INTERRUPT_STACK TRUE
Do the following steps to unify and simplify the initialization and interrupt stack support.
- Add RTEMS_DECLARE_GLOBAL_SYMBOL() and RTEMS_DEFINE_GLOBAL_SYMBOL() macros to basedefs.h, to allow a global symbol definition via C code, e.g. in confdefs.h, to make the interrupt stack size available to the low level initialization code.
- Add a special input section ".rtemsstack" to the linker command files to allow a placement of the interrupt stacks. The BSPs can provide the optimal memory location for this section, e.g. on-chip RAM, tightly-coupled memory.
This makes the CPU_HAS_SOFTWARE_INTERRUPT_STACK and CPU_HAS_HARDWARE_INTERRUPT_STACK CPU port defines superfluous, since the low level initialization code has all information available via global symbols.
This makes the CPU_ALLOCATE_INTERRUPT_STACK CPU port define superfluous, since the interrupt stacks are allocated by confdefs.h for all architectures. There is no need for BSP-specific linker command file magic.
The optional _CPU_Interrupt_stack_setup() is still useful to customize the registration of the interrupt stack area in the per-CPU information.
Change History (36)
comment:1 Changed on 06/18/18 at 06:30:48 by Sebastian Huber
Blocking: | 3433 added |
---|
comment:2 Changed on 06/19/18 at 13:27:08 by Sebastian Huber <sebastian.huber@…>
comment:3 Changed on 06/20/18 at 07:34:03 by Sebastian Huber
Just for reference, the reuse of the initialization stack for the interrupt stack is only possible because boot_card() is a no-return function. This was not the case in RTEMS versions before 4.11.
comment:12 Changed on 07/03/18 at 05:07:40 by Sebastian Huber <sebastian.huber@…>
comment:13 Changed on 07/03/18 at 05:12:58 by Sebastian Huber <sebastian.huber@…>
comment:14 Changed on 07/19/18 at 05:38:20 by Sebastian Huber <sebastian.huber@…>
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:16 Changed on 08/03/18 at 11:04:49 by Sebastian Huber <sebastian.huber@…>
In 42f9963d/rtems:
comment:17 Changed on 09/03/18 at 05:03:42 by Sebastian Huber <sebastian.huber@…>
In fad3f79b/rtems:
comment:19 Changed on 09/21/18 at 06:08:11 by Sebastian Huber <sebastian.huber@…>
In 56e61e24/rtems:
comment:21 Changed on 09/24/18 at 07:16:51 by Sebastian Huber <sebastian.huber@…>
In 7d1acc03/rtems:
comment:22 Changed on 11/08/18 at 07:11:03 by Sebastian Huber <sebastian.huber@…>
In ff081aee/rtems:
comment:26 Changed on 11/19/18 at 06:20:49 by Sebastian Huber <sebastian.huber@…>
In 84e59b7c/rtems:
comment:27 Changed on 11/19/18 at 06:20:57 by Sebastian Huber <sebastian.huber@…>
In 508f319e/rtems:
comment:28 Changed on 11/19/18 at 06:21:05 by Sebastian Huber <sebastian.huber@…>
In a74ee417/rtems:
comment:32 Changed on 11/19/18 at 06:21:37 by Sebastian Huber <sebastian.huber@…>
In 38f81bfc/rtems:
comment:33 Changed on 11/19/18 at 06:21:45 by Sebastian Huber <sebastian.huber@…>
In 0a6a4ddb/rtems:
comment:36 Changed on 06/23/21 at 07:16:03 by Sebastian Huber
Keywords: | qualification added |
---|
In b0c3ba2f/rtems: