23 #ifndef _INCLUDE_LEON_h 24 #define _INCLUDE_LEON_h 33 #define LEON_INTERRUPT_EXTERNAL_1 5 45 #define LEON_TRAP_TYPE( _source ) SPARC_ASYNCHRONOUS_TRAP((_source) + 0x10) 47 #define LEON_TRAP_SOURCE( _trap ) ((_trap) - 0x10) 49 #define LEON_INT_TRAP( _trap ) \ 50 ( (_trap) >= 0x11 && \ 69 #define LEON_MEMORY_CONFIGURATION_PROM_SIZE_MASK 0x0003C000 75 #define LEON_MEMORY_CONFIGURATION_RAM_SIZE_MASK 0x00001E00 82 #define LEON_REG_TIMER_CONTROL_EN 0x00000001 84 #define LEON_REG_TIMER_CONTROL_RL 0x00000002 86 #define LEON_REG_TIMER_CONTROL_LD 0x00000004 93 #define LEON_REG_UART_CONTROL_RTD 0x000000FF 99 #define LEON_REG_UART_STATUS_DR 0x00000001 100 #define LEON_REG_UART_STATUS_TSE 0x00000002 101 #define LEON_REG_UART_STATUS_THE 0x00000004 102 #define LEON_REG_UART_STATUS_BR 0x00000008 103 #define LEON_REG_UART_STATUS_OE 0x00000010 104 #define LEON_REG_UART_STATUS_PE 0x00000020 105 #define LEON_REG_UART_STATUS_FE 0x00000040 106 #define LEON_REG_UART_STATUS_TF 0x00000200 107 #define LEON_REG_UART_STATUS_ERR 0x00000078 113 #define LEON_REG_UART_CTRL_RE 0x00000001 114 #define LEON_REG_UART_CTRL_TE 0x00000002 115 #define LEON_REG_UART_CTRL_RI 0x00000004 116 #define LEON_REG_UART_CTRL_TI 0x00000008 117 #define LEON_REG_UART_CTRL_PS 0x00000010 118 #define LEON_REG_UART_CTRL_PE 0x00000020 119 #define LEON_REG_UART_CTRL_FL 0x00000040 120 #define LEON_REG_UART_CTRL_LB 0x00000080 121 #define LEON_REG_UART_CTRL_DB 0x00000800 122 #define LEON_REG_UART_CTRL_SI 0x00004000 123 #define LEON_REG_UART_CTRL_FA 0x80000000 124 #define LEON_REG_UART_CTRL_FA_BIT 31 129 #define LEON3_REG_CACHE_CTRL_FI 0x00200000 130 #define LEON3_REG_CACHE_CTRL_DS 0x00800000 133 extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
141 extern uint32_t LEON3_Cpu_Index;
144 extern int LEON3_IrqCtrl_EIrq;
146 static __inline__
int bsp_irq_fixup(
int irq)
150 if (LEON3_IrqCtrl_EIrq != 0 && irq == LEON3_IrqCtrl_EIrq) {
152 cpu = _LEON3_Get_current_processor();
153 eirq = LEON3_IrqCtrl_Regs->intid[cpu] & 0x1f;
163 #define LEON3_IRQMPSTATUS_CPUNR 28 164 #define LEON3_IRQMPSTATUS_BROADCAST 27 181 #define LEON3_IRQCTRL_ACQUIRE( _lock_context ) \ 182 rtems_interrupt_lock_acquire( &LEON3_IrqCtrl_Lock, _lock_context ) 184 #define LEON3_IRQCTRL_RELEASE( _lock_context ) \ 185 rtems_interrupt_lock_release( &LEON3_IrqCtrl_Lock, _lock_context ) 187 #define LEON_Clear_interrupt( _source ) \ 189 LEON3_IrqCtrl_Regs->iclear = (1U << (_source)); \ 192 #define LEON_Force_interrupt( _source ) \ 194 LEON3_IrqCtrl_Regs->iforce = (1U << (_source)); \ 197 #define LEON_Enable_interrupt_broadcast( _source ) \ 199 rtems_interrupt_lock_context _lock_context; \ 200 uint32_t _mask = 1U << ( _source ); \ 201 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ 202 LEON3_IrqCtrl_Regs->bcast |= _mask; \ 203 LEON3_IRQCTRL_RELEASE( &_lock_context ); \ 206 #define LEON_Disable_interrupt_broadcast( _source ) \ 208 rtems_interrupt_lock_context _lock_context; \ 209 uint32_t _mask = 1U << ( _source ); \ 210 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ 211 LEON3_IrqCtrl_Regs->bcast &= ~_mask; \ 212 LEON3_IRQCTRL_RELEASE( &_lock_context ); \ 215 #define LEON_Is_interrupt_pending( _source ) \ 216 (LEON3_IrqCtrl_Regs->ipend & (1U << (_source))) 218 #define LEON_Cpu_Is_interrupt_masked( _source, _cpu ) \ 219 (!(LEON3_IrqCtrl_Regs->mask[_cpu] & (1U << (_source)))) 221 #define LEON_Cpu_Mask_interrupt( _source, _cpu ) \ 223 rtems_interrupt_lock_context _lock_context; \ 224 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ 225 LEON3_IrqCtrl_Regs->mask[_cpu] &= ~(1U << (_source)); \ 226 LEON3_IRQCTRL_RELEASE( &_lock_context ); \ 229 #define LEON_Cpu_Unmask_interrupt( _source, _cpu ) \ 231 rtems_interrupt_lock_context _lock_context; \ 232 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ 233 LEON3_IrqCtrl_Regs->mask[_cpu] |= (1U << (_source)); \ 234 LEON3_IRQCTRL_RELEASE( &_lock_context ); \ 237 #define LEON_Cpu_Disable_interrupt( _source, _previous, _cpu ) \ 239 rtems_interrupt_lock_context _lock_context; \ 240 uint32_t _mask = 1U << (_source); \ 241 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ 242 (_previous) = LEON3_IrqCtrl_Regs->mask[_cpu]; \ 243 LEON3_IrqCtrl_Regs->mask[_cpu] = _previous & ~_mask; \ 244 LEON3_IRQCTRL_RELEASE( &_lock_context ); \ 245 (_previous) &= _mask; \ 248 #define LEON_Cpu_Restore_interrupt( _source, _previous, _cpu ) \ 250 rtems_interrupt_lock_context _lock_context; \ 251 uint32_t _mask = 1U << (_source); \ 252 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \ 253 LEON3_IrqCtrl_Regs->mask[_cpu] = \ 254 (LEON3_IrqCtrl_Regs->mask[_cpu] & ~_mask) | (_previous); \ 255 LEON3_IRQCTRL_RELEASE( &_lock_context ); \ 259 #define LEON_Is_interrupt_masked( _source ) \ 260 LEON_Cpu_Is_interrupt_masked(_source, _LEON3_Get_current_processor()) 262 #define LEON_Mask_interrupt(_source) \ 263 LEON_Cpu_Mask_interrupt(_source, _LEON3_Get_current_processor()) 265 #define LEON_Unmask_interrupt(_source) \ 266 LEON_Cpu_Unmask_interrupt(_source, _LEON3_Get_current_processor()) 268 #define LEON_Disable_interrupt(_source, _previous) \ 269 LEON_Cpu_Disable_interrupt(_source, _previous, _LEON3_Get_current_processor()) 271 #define LEON_Restore_interrupt(_source, _previous) \ 272 LEON_Cpu_Restore_interrupt(_source, _previous, _LEON3_Get_current_processor()) 275 #define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source) 276 #define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source) 277 #define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source) 278 #define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source) 279 #define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source) 280 #define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source) 281 #define BSP_Disable_interrupt(_source, _previous) \ 282 LEON_Disable_interrupt(_source, _prev) 283 #define BSP_Restore_interrupt(_source, _previous) \ 284 LEON_Restore_interrupt(_source, _previous) 287 #define BSP_Cpu_Is_interrupt_masked(_source, _cpu) \ 288 LEON_Cpu_Is_interrupt_masked(_source, _cpu) 289 #define BSP_Cpu_Unmask_interrupt(_source, _cpu) \ 290 LEON_Cpu_Unmask_interrupt(_source, _cpu) 291 #define BSP_Cpu_Mask_interrupt(_source, _cpu) \ 292 LEON_Cpu_Mask_interrupt(_source, _cpu) 293 #define BSP_Cpu_Disable_interrupt(_source, _previous, _cpu) \ 294 LEON_Cpu_Disable_interrupt(_source, _prev, _cpu) 295 #define BSP_Cpu_Restore_interrupt(_source, _previous, _cpu) \ 296 LEON_Cpu_Restore_interrupt(_source, _previous, _cpu) 315 #define LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO 0x00000002 316 #define LEON_REG_TIMER_COUNTER_STOP_AT_ZERO 0x00000000 318 #define LEON_REG_TIMER_COUNTER_LOAD_COUNTER 0x00000004 320 #define LEON_REG_TIMER_COUNTER_ENABLE_COUNTING 0x00000001 321 #define LEON_REG_TIMER_COUNTER_DISABLE_COUNTING 0x00000000 323 #define LEON_REG_TIMER_COUNTER_RELOAD_MASK 0x00000002 324 #define LEON_REG_TIMER_COUNTER_ENABLE_MASK 0x00000001 326 #define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003 327 #define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003 329 #if defined(RTEMS_MULTIPROCESSING) 330 #define LEON3_CLOCK_INDEX \ 331 (rtems_configuration_get_user_multiprocessing_table() ? LEON3_Cpu_Index : 0) 333 #define LEON3_CLOCK_INDEX 0 336 #if defined(RTEMS_SMP) 337 #define LEON3_COUNTER_GPTIMER_INDEX (LEON3_CLOCK_INDEX + 1) 339 #define LEON3_COUNTER_GPTIMER_INDEX LEON3_CLOCK_INDEX 347 #define LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER 1000000 350 static inline unsigned int leon_r32_no_cache(uintptr_t addr)
353 __asm__
volatile (
" lda [%1] 1, %0\n" :
"=r"(tmp) :
"r"(addr));
364 extern int syscon_uart_index;
373 extern int leon3_debug_uart_index;
384 extern int leon3_timer_core_index;
394 extern unsigned int leon3_timer_prescaler;
397 void leon3_ext_irq_init(
void);
401 static inline uint32_t leon3_get_cpu_count(
405 uint32_t mpstat = irqmp->mpstat;
407 return ((mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1;
410 static inline void leon3_set_system_register(uint32_t addr, uint32_t val)
415 :
"r" (addr),
"r" (val)
419 static inline uint32_t leon3_get_system_register(uint32_t addr)
432 static inline void leon3_set_cache_control_register(uint32_t val)
434 leon3_set_system_register(0x0, val);
437 static inline uint32_t leon3_get_cache_control_register(
void)
439 return leon3_get_system_register(0x0);
442 static inline bool leon3_data_cache_snooping_enabled(
void)
444 return leon3_get_cache_control_register() & LEON3_REG_CACHE_CTRL_DS;
447 static inline uint32_t leon3_get_inst_cache_config_register(
void)
449 return leon3_get_system_register(0x8);
452 static inline uint32_t leon3_get_data_cache_config_register(
void)
454 return leon3_get_system_register(0xc);
457 static inline bool leon3_irqmp_has_timestamp(
461 return (irqmp_ts->control >> 27) > 0;
464 static inline uint32_t leon3_up_counter_low(
void)
476 static inline uint32_t leon3_up_counter_high(
void)
488 static inline void leon3_up_counter_enable(
void)
495 static inline bool leon3_up_counter_is_available(
void)
497 return leon3_up_counter_low() != leon3_up_counter_low();
500 static inline uint32_t leon3_up_counter_frequency(
void)
506 return ambapp_freq_get(&ambapp_plb, LEON3_IrqCtrl_Adev);
#define RTEMS_NO_RETURN
Tells the compiler in a function declaration that this function does not return.
This header file defines the RTEMS Classic API.