39#ifndef _INCLUDE_LEON_h
40#define _INCLUDE_LEON_h
56#define LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR 1
57#define LEON_INTERRUPT_UART_2_RX_TX 2
58#define LEON_INTERRUPT_UART_1_RX_TX 3
59#define LEON_INTERRUPT_EXTERNAL_0 4
60#define LEON_INTERRUPT_EXTERNAL_1 5
61#define LEON_INTERRUPT_EXTERNAL_2 6
62#define LEON_INTERRUPT_EXTERNAL_3 7
63#define LEON_INTERRUPT_TIMER1 8
64#define LEON_INTERRUPT_TIMER2 9
65#define LEON_INTERRUPT_EMPTY1 10
66#define LEON_INTERRUPT_EMPTY2 11
67#define LEON_INTERRUPT_EMPTY3 12
68#define LEON_INTERRUPT_EMPTY4 13
69#define LEON_INTERRUPT_EMPTY5 14
70#define LEON_INTERRUPT_EMPTY6 15
83#define LEON_TRAP_TYPE( _source ) SPARC_ASYNCHRONOUS_TRAP((_source) + 0x10)
85#define LEON_TRAP_SOURCE( _trap ) ((_trap) - 0x10)
87#define LEON_INT_TRAP( _trap ) \
88 ( (_trap) >= LEON_TRAP_TYPE( LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR ) && \
89 (_trap) <= LEON_TRAP_TYPE( LEON_INTERRUPT_EMPTY6 ) )
102 volatile unsigned int Memory_Config_1;
103 volatile unsigned int Memory_Config_2;
104 volatile unsigned int Edac_Control;
105 volatile unsigned int Failed_Address;
106 volatile unsigned int Memory_Status;
107 volatile unsigned int Cache_Control;
108 volatile unsigned int Power_Down;
109 volatile unsigned int Write_Protection_1;
110 volatile unsigned int Write_Protection_2;
111 volatile unsigned int Leon_Configuration;
112 volatile unsigned int dummy2;
113 volatile unsigned int dummy3;
114 volatile unsigned int dummy4;
115 volatile unsigned int dummy5;
116 volatile unsigned int dummy6;
117 volatile unsigned int dummy7;
118 volatile unsigned int Timer_Counter_1;
119 volatile unsigned int Timer_Reload_1;
120 volatile unsigned int Timer_Control_1;
121 volatile unsigned int Watchdog;
122 volatile unsigned int Timer_Counter_2;
123 volatile unsigned int Timer_Reload_2;
124 volatile unsigned int Timer_Control_2;
125 volatile unsigned int dummy8;
126 volatile unsigned int Scaler_Counter;
127 volatile unsigned int Scaler_Reload;
128 volatile unsigned int dummy9;
129 volatile unsigned int dummy10;
130 volatile unsigned int UART_Channel_1;
131 volatile unsigned int UART_Status_1;
132 volatile unsigned int UART_Control_1;
133 volatile unsigned int UART_Scaler_1;
134 volatile unsigned int UART_Channel_2;
135 volatile unsigned int UART_Status_2;
136 volatile unsigned int UART_Control_2;
137 volatile unsigned int UART_Scaler_2;
138 volatile unsigned int Interrupt_Mask;
139 volatile unsigned int Interrupt_Pending;
140 volatile unsigned int Interrupt_Force;
141 volatile unsigned int Interrupt_Clear;
142 volatile unsigned int PIO_Data;
143 volatile unsigned int PIO_Direction;
144 volatile unsigned int PIO_Interrupt;
160#define LEON_REG_MEMCFG1_OFFSET 0x00
161#define LEON_REG_MEMCFG2_OFFSET 0x04
162#define LEON_REG_EDACCTRL_OFFSET 0x08
163#define LEON_REG_FAILADDR_OFFSET 0x0C
164#define LEON_REG_MEMSTATUS_OFFSET 0x10
165#define LEON_REG_CACHECTRL_OFFSET 0x14
166#define LEON_REG_POWERDOWN_OFFSET 0x18
167#define LEON_REG_WRITEPROT1_OFFSET 0x1C
168#define LEON_REG_WRITEPROT2_OFFSET 0x20
169#define LEON_REG_LEONCONF_OFFSET 0x24
170#define LEON_REG_UNIMPLEMENTED_2_OFFSET 0x28
171#define LEON_REG_UNIMPLEMENTED_3_OFFSET 0x2C
172#define LEON_REG_UNIMPLEMENTED_4_OFFSET 0x30
173#define LEON_REG_UNIMPLEMENTED_5_OFFSET 0x34
174#define LEON_REG_UNIMPLEMENTED_6_OFFSET 0x38
175#define LEON_REG_UNIMPLEMENTED_7_OFFSET 0x3C
176#define LEON_REG_TIMERCNT1_OFFSET 0x40
177#define LEON_REG_TIMERLOAD1_OFFSET 0x44
178#define LEON_REG_TIMERCTRL1_OFFSET 0x48
179#define LEON_REG_WDOG_OFFSET 0x4C
180#define LEON_REG_TIMERCNT2_OFFSET 0x50
181#define LEON_REG_TIMERLOAD2_OFFSET 0x54
182#define LEON_REG_TIMERCTRL2_OFFSET 0x58
183#define LEON_REG_UNIMPLEMENTED_8_OFFSET 0x5C
184#define LEON_REG_SCALERCNT_OFFSET 0x60
185#define LEON_REG_SCALER_LOAD_OFFSET 0x64
186#define LEON_REG_UNIMPLEMENTED_9_OFFSET 0x68
187#define LEON_REG_UNIMPLEMENTED_10_OFFSET 0x6C
188#define LEON_REG_UARTDATA1_OFFSET 0x70
189#define LEON_REG_UARTSTATUS1_OFFSET 0x74
190#define LEON_REG_UARTCTRL1_OFFSET 0x78
191#define LEON_REG_UARTSCALER1_OFFSET 0x7C
192#define LEON_REG_UARTDATA2_OFFSET 0x80
193#define LEON_REG_UARTSTATUS2_OFFSET 0x84
194#define LEON_REG_UARTCTRL2_OFFSET 0x88
195#define LEON_REG_UARTSCALER2_OFFSET 0x8C
196#define LEON_REG_IRQMASK_OFFSET 0x90
197#define LEON_REG_IRQPEND_OFFSET 0x94
198#define LEON_REG_IRQFORCE_OFFSET 0x98
199#define LEON_REG_IRQCLEAR_OFFSET 0x9C
200#define LEON_REG_PIODATA_OFFSET 0xA0
201#define LEON_REG_PIODIR_OFFSET 0xA4
202#define LEON_REG_PIOIRQ_OFFSET 0xA8
203#define LEON_REG_SIM_RAM_SIZE_OFFSET 0xF4
204#define LEON_REG_SIM_ROM_SIZE_OFFSET 0xF8
212#define LEON_MEMORY_CONFIGURATION_PROM_SIZE_MASK 0x0003C000
218#define LEON_MEMORY_CONFIGURATION_RAM_SIZE_MASK 0x00001E00
225#define LEON_REG_TIMER_CONTROL_EN 0x00000001
227#define LEON_REG_TIMER_CONTROL_RL 0x00000002
229#define LEON_REG_TIMER_CONTROL_LD 0x00000004
237#define LEON_REG_UART_CONTROL_RTD 0x000000FF
243#define LEON_REG_UART_STATUS_CLR 0x00000000
244#define LEON_REG_UART_STATUS_DR 0x00000001
245#define LEON_REG_UART_STATUS_TSE 0x00000002
246#define LEON_REG_UART_STATUS_THE 0x00000004
247#define LEON_REG_UART_STATUS_BR 0x00000008
248#define LEON_REG_UART_STATUS_OE 0x00000010
249#define LEON_REG_UART_STATUS_PE 0x00000020
250#define LEON_REG_UART_STATUS_FE 0x00000040
251#define LEON_REG_UART_STATUS_ERR 0x00000078
258#define LEON_REG_UART_CTRL_RE 0x00000001
259#define LEON_REG_UART_CTRL_TE 0x00000002
260#define LEON_REG_UART_CTRL_RI 0x00000004
261#define LEON_REG_UART_CTRL_TI 0x00000008
262#define LEON_REG_UART_CTRL_PS 0x00000010
263#define LEON_REG_UART_CTRL_PE 0x00000020
264#define LEON_REG_UART_CTRL_FL 0x00000040
265#define LEON_REG_UART_CTRL_LB 0x00000080
278static __inline__
int bsp_irq_fixup(
int irq)
293#define LEON_Clear_interrupt( _source ) \
295 LEON_REG.Interrupt_Clear = (1 << (_source)); \
298#define LEON_Force_interrupt( _source ) \
300 LEON_REG.Interrupt_Force = (1 << (_source)); \
303#define LEON_Is_interrupt_pending( _source ) \
304 (LEON_REG.Interrupt_Pending & (1 << (_source)))
306#define LEON_Is_interrupt_masked( _source ) \
307 (!(LEON_REG.Interrupt_Mask & (1 << (_source))))
309#define LEON_Mask_interrupt( _source ) \
313 _level = sparc_disable_interrupts(); \
314 LEON_REG.Interrupt_Mask &= ~(1 << (_source)); \
315 sparc_enable_interrupts( _level ); \
318#define LEON_Unmask_interrupt( _source ) \
322 _level = sparc_disable_interrupts(); \
323 LEON_REG.Interrupt_Mask |= (1 << (_source)); \
324 sparc_enable_interrupts( _level ); \
327#define LEON_Disable_interrupt( _source, _previous ) \
330 uint32_t _mask = 1 << (_source); \
332 _level = sparc_disable_interrupts(); \
333 (_previous) = LEON_REG.Interrupt_Mask; \
334 LEON_REG.Interrupt_Mask = _previous & ~_mask; \
335 sparc_enable_interrupts( _level ); \
336 (_previous) &= _mask; \
339#define LEON_Restore_interrupt( _source, _previous ) \
342 uint32_t _mask = 1 << (_source); \
344 _level = sparc_disable_interrupts(); \
345 LEON_REG.Interrupt_Mask = \
346 (LEON_REG.Interrupt_Mask & ~_mask) | (_previous); \
347 sparc_enable_interrupts( _level ); \
351#define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source)
352#define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source)
353#define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source)
354#define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source)
355#define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source)
356#define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source)
357#define BSP_Disable_interrupt(_source, _previous) \
358 LEON_Disable_interrupt(_source, _prev)
359#define BSP_Restore_interrupt(_source, _previous) \
360 LEON_Restore_interrupt(_source, _previous)
363#define BSP_Cpu_Is_interrupt_masked(_source, _cpu) \
364 BSP_Is_interrupt_masked(_source)
365#define BSP_Cpu_Unmask_interrupt(_source, _cpu) \
366 BSP_Unmask_interrupt(_source)
367#define BSP_Cpu_Mask_interrupt(_source, _cpu) \
368 BSP_Mask_interrupt(_source)
369#define BSP_Cpu_Disable_interrupt(_source, _previous, _cpu) \
370 BSP_Disable_interrupt(_source, _prev)
371#define BSP_Cpu_Restore_interrupt(_source, _previous, _cpu) \
372 BSP_Cpu_Restore_interrupt(_source, _previous)
391#define LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO 0x00000002
392#define LEON_REG_TIMER_COUNTER_STOP_AT_ZERO 0x00000000
394#define LEON_REG_TIMER_COUNTER_LOAD_COUNTER 0x00000004
396#define LEON_REG_TIMER_COUNTER_ENABLE_COUNTING 0x00000001
397#define LEON_REG_TIMER_COUNTER_DISABLE_COUNTING 0x00000000
399#define LEON_REG_TIMER_COUNTER_RELOAD_MASK 0x00000002
400#define LEON_REG_TIMER_COUNTER_ENABLE_MASK 0x00000001
402#define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003
403#define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003
406static inline unsigned int leon_r32_no_cache(uintptr_t addr)
409 __asm__ volatile (
" lda [%1] 1, %0\n" :
"=r"(tmp) :
"r"(addr));
register struct Per_CPU_Control *_SPARC_Per_CPU_current __asm__("g6")
The pointer to the current per-CPU control is available via register g6.
Information Required to Build RTEMS for a Particular Member of the SPARC Family.