42#ifndef _INCLUDE_LEON_h
43#define _INCLUDE_LEON_h
54#define LEON_INTERRUPT_EXTERNAL_1 5
66#define LEON_TRAP_TYPE( _source ) SPARC_INTERRUPT_SOURCE_TO_TRAP( _source )
68#define LEON_TRAP_SOURCE( _trap ) SPARC_INTERRUPT_TRAP_TO_SOURCE( _trap )
70#define LEON_INT_TRAP( _trap ) SPARC_IS_INTERRUPT_TRAP( _trap )
88#define LEON_MEMORY_CONFIGURATION_PROM_SIZE_MASK 0x0003C000
94#define LEON_MEMORY_CONFIGURATION_RAM_SIZE_MASK 0x00001E00
101#define LEON_REG_TIMER_CONTROL_EN 0x00000001
103#define LEON_REG_TIMER_CONTROL_RL 0x00000002
105#define LEON_REG_TIMER_CONTROL_LD 0x00000004
112#define LEON_REG_UART_CONTROL_RTD 0x000000FF
118#define LEON_REG_UART_STATUS_DR 0x00000001
119#define LEON_REG_UART_STATUS_TSE 0x00000002
120#define LEON_REG_UART_STATUS_THE 0x00000004
121#define LEON_REG_UART_STATUS_BR 0x00000008
122#define LEON_REG_UART_STATUS_OE 0x00000010
123#define LEON_REG_UART_STATUS_PE 0x00000020
124#define LEON_REG_UART_STATUS_FE 0x00000040
125#define LEON_REG_UART_STATUS_TF 0x00000200
126#define LEON_REG_UART_STATUS_ERR 0x00000078
132#define LEON_REG_UART_CTRL_RE 0x00000001
133#define LEON_REG_UART_CTRL_TE 0x00000002
134#define LEON_REG_UART_CTRL_RI 0x00000004
135#define LEON_REG_UART_CTRL_TI 0x00000008
136#define LEON_REG_UART_CTRL_PS 0x00000010
137#define LEON_REG_UART_CTRL_PE 0x00000020
138#define LEON_REG_UART_CTRL_FL 0x00000040
139#define LEON_REG_UART_CTRL_LB 0x00000080
140#define LEON_REG_UART_CTRL_DB 0x00000800
141#define LEON_REG_UART_CTRL_SI 0x00004000
142#define LEON_REG_UART_CTRL_FA 0x80000000
143#define LEON_REG_UART_CTRL_FA_BIT 31
147#define LEON3_IRQMPSTATUS_CPUNR 28
148#define LEON3_IRQMPSTATUS_BROADCAST 27
163#define LEON_Clear_interrupt( _source ) \
164 grlib_store_32(&LEON3_IrqCtrl_Regs->iclear, 1U << (_source))
166#define LEON_Force_interrupt( _source ) \
167 grlib_store_32(&LEON3_IrqCtrl_Regs->iforce0, 1U << (_source))
169#define LEON_Enable_interrupt_broadcast( _source ) \
171 rtems_interrupt_lock_context _lock_context; \
172 uint32_t _mask = 1U << ( _source ); \
174 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
175 _brdcst = grlib_load_32(&LEON3_IrqCtrl_Regs->brdcst); \
177 grlib_store_32(&LEON3_IrqCtrl_Regs->brdcst, _brdcst); \
178 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
181#define LEON_Disable_interrupt_broadcast( _source ) \
183 rtems_interrupt_lock_context _lock_context; \
184 uint32_t _mask = 1U << ( _source ); \
186 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
187 _brdcst = grlib_load_32(&LEON3_IrqCtrl_Regs->brdcst); \
189 grlib_store_32(&LEON3_IrqCtrl_Regs->brdcst, _brdcst); \
190 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
193#define LEON_Is_interrupt_pending( _source ) \
194 (grlib_load_32(&LEON3_IrqCtrl_Regs->ipend) & (1U << (_source)))
196#define LEON_Cpu_Is_interrupt_masked( _source, _cpu ) \
197 (!(grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu]) & (1U << (_source))))
199#define LEON_Cpu_Mask_interrupt( _source, _cpu ) \
201 rtems_interrupt_lock_context _lock_context; \
203 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
204 _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
205 _pimask &= ~(1U << (_source)); \
206 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \
207 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
210#define LEON_Cpu_Unmask_interrupt( _source, _cpu ) \
212 rtems_interrupt_lock_context _lock_context; \
214 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
215 _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
216 _pimask |= 1U << (_source); \
217 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \
218 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
221#define LEON_Cpu_Disable_interrupt( _source, _previous, _cpu ) \
223 rtems_interrupt_lock_context _lock_context; \
224 uint32_t _mask = 1U << (_source); \
225 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
226 (_previous) = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
227 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], (_previous) & ~_mask); \
228 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
229 (_previous) &= _mask; \
232#define LEON_Cpu_Restore_interrupt( _source, _previous, _cpu ) \
234 rtems_interrupt_lock_context _lock_context; \
236 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
237 _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
238 _pimask &= ~(1U << (_source)); \
239 _pimask |= _previous; \
240 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \
241 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
245#define LEON_Is_interrupt_masked( _source ) \
246 LEON_Cpu_Is_interrupt_masked(_source, _LEON3_Get_current_processor())
248#define LEON_Mask_interrupt(_source) \
249 LEON_Cpu_Mask_interrupt(_source, _LEON3_Get_current_processor())
251#define LEON_Unmask_interrupt(_source) \
252 LEON_Cpu_Unmask_interrupt(_source, _LEON3_Get_current_processor())
254#define LEON_Disable_interrupt(_source, _previous) \
255 LEON_Cpu_Disable_interrupt(_source, _previous, _LEON3_Get_current_processor())
257#define LEON_Restore_interrupt(_source, _previous) \
258 LEON_Cpu_Restore_interrupt(_source, _previous, _LEON3_Get_current_processor())
261#define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source)
262#define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source)
263#define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source)
264#define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source)
265#define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source)
266#define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source)
267#define BSP_Disable_interrupt(_source, _previous) \
268 LEON_Disable_interrupt(_source, _prev)
269#define BSP_Restore_interrupt(_source, _previous) \
270 LEON_Restore_interrupt(_source, _previous)
273#define BSP_Cpu_Is_interrupt_masked(_source, _cpu) \
274 LEON_Cpu_Is_interrupt_masked(_source, _cpu)
275#define BSP_Cpu_Unmask_interrupt(_source, _cpu) \
276 LEON_Cpu_Unmask_interrupt(_source, _cpu)
277#define BSP_Cpu_Mask_interrupt(_source, _cpu) \
278 LEON_Cpu_Mask_interrupt(_source, _cpu)
279#define BSP_Cpu_Disable_interrupt(_source, _previous, _cpu) \
280 LEON_Cpu_Disable_interrupt(_source, _prev, _cpu)
281#define BSP_Cpu_Restore_interrupt(_source, _previous, _cpu) \
282 LEON_Cpu_Restore_interrupt(_source, _previous, _cpu)
301#define LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO 0x00000002
302#define LEON_REG_TIMER_COUNTER_STOP_AT_ZERO 0x00000000
304#define LEON_REG_TIMER_COUNTER_LOAD_COUNTER 0x00000004
306#define LEON_REG_TIMER_COUNTER_ENABLE_COUNTING 0x00000001
307#define LEON_REG_TIMER_COUNTER_DISABLE_COUNTING 0x00000000
309#define LEON_REG_TIMER_COUNTER_RELOAD_MASK 0x00000002
310#define LEON_REG_TIMER_COUNTER_ENABLE_MASK 0x00000001
312#define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003
313#define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003
316static inline unsigned int leon_r32_no_cache(uintptr_t addr)
319 __asm__
volatile (
" lda [%1] 1, %0\n" :
"=r"(tmp) :
"r"(addr));
330extern int syscon_uart_index;
332#if !defined(LEON3_APBUART_BASE)
340extern int leon3_debug_uart_index;
This header file provides interfaces used by the BSP implementation.
This header file defines the RTEMS Classic API.