diff options
Diffstat (limited to 'bsps/sparc/leon3/include')
-rw-r--r-- | bsps/sparc/leon3/include/bsp/irq.h | 1 | ||||
-rw-r--r-- | bsps/sparc/leon3/include/bsp/leon3.h | 35 | ||||
-rw-r--r-- | bsps/sparc/leon3/include/leon.h | 53 |
3 files changed, 52 insertions, 37 deletions
diff --git a/bsps/sparc/leon3/include/bsp/irq.h b/bsps/sparc/leon3/include/bsp/irq.h index ef0f6245f9..38ea1de1f8 100644 --- a/bsps/sparc/leon3/include/bsp/irq.h +++ b/bsps/sparc/leon3/include/bsp/irq.h @@ -37,6 +37,7 @@ #ifndef LIBBSP_LEON3_IRQ_CONFIG_H #define LIBBSP_LEON3_IRQ_CONFIG_H +#include <rtems.h> #include <rtems/score/processormask.h> #define BSP_INTERRUPT_VECTOR_MAX_STD 15 /* Standard IRQ controller */ diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h index c0359937f9..623cbe5912 100644 --- a/bsps/sparc/leon3/include/bsp/leon3.h +++ b/bsps/sparc/leon3/include/bsp/leon3.h @@ -37,8 +37,9 @@ #define _BSP_LEON3_H #include <rtems.h> -#include <grlib/grlib.h> #include <grlib/apbuart-regs.h> +#include <grlib/irqamp-regs.h> +#include <grlib/io.h> struct ambapp_dev; @@ -53,14 +54,37 @@ extern "C" { */ /** + * @brief This object provides the index of the boot processor. + * + * This object should be read-only after initialization. + */ +extern uint32_t LEON3_Cpu_Index; + +/** * @brief This lock serializes the interrupt controller access. */ extern rtems_interrupt_lock LEON3_IrqCtrl_Lock; /** + * @brief Acquires the interrupt controller lock. + * + * @param[out] _lock_context is the lock context. + */ +#define LEON3_IRQCTRL_ACQUIRE( _lock_context ) \ + rtems_interrupt_lock_acquire( &LEON3_IrqCtrl_Lock, _lock_context ) + +/** + * @brief Releases the interrupt controller lock. + * + * @param[in, out] _lock_context is the lock context. + */ +#define LEON3_IRQCTRL_RELEASE( _lock_context ) \ + rtems_interrupt_lock_release( &LEON3_IrqCtrl_Lock, _lock_context ) + +/** * @brief This pointer provides the IRQ(A)MP register block address. */ -extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; +extern irqamp *LEON3_IrqCtrl_Regs; /** * @brief This pointer provides the IRQ(A)MP device information block. @@ -80,7 +104,7 @@ extern uint32_t LEON3_IrqCtrl_EIrq; * * @param[in, out] regs is the IRQ(A)MP register block address. */ -void leon3_ext_irq_init( volatile struct irqmp_regs *regs ); +void leon3_ext_irq_init( irqamp *regs ); /** * @brief Acknowledges and maps extended interrupts if this feature is @@ -91,12 +115,15 @@ void leon3_ext_irq_init( volatile struct irqmp_regs *regs ); static inline uint32_t bsp_irq_fixup( uint32_t irq ) { uint32_t eirq; + uint32_t cpu_self; if ( irq != LEON3_IrqCtrl_EIrq ) { return irq; } - eirq = LEON3_IrqCtrl_Regs->intid[ _LEON3_Get_current_processor() ] & 0x1f; + cpu_self = _LEON3_Get_current_processor(); + eirq = grlib_load_32( &LEON3_IrqCtrl_Regs->pextack[ cpu_self ] ); + eirq = IRQAMP_PEXTACK_EID_4_0_GET( eirq ); if ( eirq < 16 ) { return irq; diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h index 82e93ddb41..69ae455f55 100644 --- a/bsps/sparc/leon3/include/leon.h +++ b/bsps/sparc/leon3/include/leon.h @@ -44,6 +44,7 @@ #include <rtems.h> #include <amba.h> +#include <grlib/io.h> #include <bsp/leon3.h> #ifdef __cplusplus @@ -151,9 +152,6 @@ extern "C" { extern volatile struct gptimer_regs *LEON3_Timer_Regs; extern struct ambapp_dev *LEON3_Timer_Adev; -/* LEON3 CPU Index of boot CPU */ -extern uint32_t LEON3_Cpu_Index; - /* Macros used for manipulating bits in LEON3 GP Timer Control Register */ #define LEON3_IRQMPSTATUS_CPUNR 28 @@ -172,21 +170,11 @@ extern uint32_t LEON3_Cpu_Index; * store the result back are vulnerable. */ -#define LEON3_IRQCTRL_ACQUIRE( _lock_context ) \ - rtems_interrupt_lock_acquire( &LEON3_IrqCtrl_Lock, _lock_context ) - -#define LEON3_IRQCTRL_RELEASE( _lock_context ) \ - rtems_interrupt_lock_release( &LEON3_IrqCtrl_Lock, _lock_context ) - #define LEON_Clear_interrupt( _source ) \ - do { \ - LEON3_IrqCtrl_Regs->iclear = (1U << (_source)); \ - } while (0) + grlib_store_32(&LEON3_IrqCtrl_Regs->iclear, 1U << (_source)) #define LEON_Force_interrupt( _source ) \ - do { \ - LEON3_IrqCtrl_Regs->iforce = (1U << (_source)); \ - } while (0) + grlib_store_32(&LEON3_IrqCtrl_Regs->iforce0, 1U << (_source)) #define LEON_Enable_interrupt_broadcast( _source ) \ do { \ @@ -207,24 +195,30 @@ extern uint32_t LEON3_Cpu_Index; } while (0) #define LEON_Is_interrupt_pending( _source ) \ - (LEON3_IrqCtrl_Regs->ipend & (1U << (_source))) + (grlib_load_32(&LEON3_IrqCtrl_Regs->ipend) & (1U << (_source))) #define LEON_Cpu_Is_interrupt_masked( _source, _cpu ) \ - (!(LEON3_IrqCtrl_Regs->mask[_cpu] & (1U << (_source)))) + (!(grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu]) & (1U << (_source)))) #define LEON_Cpu_Mask_interrupt( _source, _cpu ) \ do { \ rtems_interrupt_lock_context _lock_context; \ + uint32_t _pimask; \ LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ - LEON3_IrqCtrl_Regs->mask[_cpu] &= ~(1U << (_source)); \ + _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \ + _pimask &= ~(1U << (_source)); \ + grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \ LEON3_IRQCTRL_RELEASE( &_lock_context ); \ } while (0) #define LEON_Cpu_Unmask_interrupt( _source, _cpu ) \ do { \ rtems_interrupt_lock_context _lock_context; \ + uint32_t _pimask; \ LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ - LEON3_IrqCtrl_Regs->mask[_cpu] |= (1U << (_source)); \ + _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \ + _pimask |= 1U << (_source); \ + grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \ LEON3_IRQCTRL_RELEASE( &_lock_context ); \ } while (0) @@ -233,8 +227,8 @@ extern uint32_t LEON3_Cpu_Index; rtems_interrupt_lock_context _lock_context; \ uint32_t _mask = 1U << (_source); \ LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ - (_previous) = LEON3_IrqCtrl_Regs->mask[_cpu]; \ - LEON3_IrqCtrl_Regs->mask[_cpu] = _previous & ~_mask; \ + (_previous) = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \ + grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], (_previous) & ~_mask); \ LEON3_IRQCTRL_RELEASE( &_lock_context ); \ (_previous) &= _mask; \ } while (0) @@ -242,10 +236,12 @@ extern uint32_t LEON3_Cpu_Index; #define LEON_Cpu_Restore_interrupt( _source, _previous, _cpu ) \ do { \ rtems_interrupt_lock_context _lock_context; \ - uint32_t _mask = 1U << (_source); \ + uint32_t _pimask; \ LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ - LEON3_IrqCtrl_Regs->mask[_cpu] = \ - (LEON3_IrqCtrl_Regs->mask[_cpu] & ~_mask) | (_previous); \ + _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \ + _pimask &= ~(1U << (_source)); \ + _pimask |= _previous; \ + grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \ LEON3_IRQCTRL_RELEASE( &_lock_context ); \ } while (0) @@ -389,15 +385,6 @@ extern unsigned int leon3_timer_prescaler; RTEMS_NO_RETURN void leon3_power_down_loop(void); -static inline uint32_t leon3_get_cpu_count( - volatile struct irqmp_regs *irqmp -) -{ - uint32_t mpstat = irqmp->mpstat; - - return ((mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1; -} - static inline void leon3_set_system_register(uint32_t addr, uint32_t val) { __asm__ volatile( |