File indexing completed on 2025-05-11 08:24:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 #ifndef _INCLUDE_LEON_h
0043 #define _INCLUDE_LEON_h
0044
0045 #include <rtems.h>
0046 #include <amba.h>
0047 #include <grlib/io.h>
0048 #include <bsp/leon3.h>
0049
0050 #ifdef __cplusplus
0051 extern "C" {
0052 #endif
0053
0054 #define LEON_INTERRUPT_EXTERNAL_1 5
0055
0056 #ifndef ASM
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066 #define LEON_TRAP_TYPE( _source ) SPARC_INTERRUPT_SOURCE_TO_TRAP( _source )
0067
0068 #define LEON_TRAP_SOURCE( _trap ) SPARC_INTERRUPT_TRAP_TO_SOURCE( _trap )
0069
0070 #define LEON_INT_TRAP( _trap ) SPARC_IS_INTERRUPT_TRAP( _trap )
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 #endif
0083
0084
0085
0086
0087
0088 #define LEON_MEMORY_CONFIGURATION_PROM_SIZE_MASK 0x0003C000
0089
0090
0091
0092
0093
0094 #define LEON_MEMORY_CONFIGURATION_RAM_SIZE_MASK 0x00001E00
0095
0096
0097
0098
0099
0100
0101 #define LEON_REG_TIMER_CONTROL_EN 0x00000001
0102
0103 #define LEON_REG_TIMER_CONTROL_RL 0x00000002
0104
0105 #define LEON_REG_TIMER_CONTROL_LD 0x00000004
0106
0107
0108
0109
0110
0111
0112 #define LEON_REG_UART_CONTROL_RTD 0x000000FF
0113
0114
0115
0116
0117
0118 #define LEON_REG_UART_STATUS_DR 0x00000001
0119 #define LEON_REG_UART_STATUS_TSE 0x00000002
0120 #define LEON_REG_UART_STATUS_THE 0x00000004
0121 #define LEON_REG_UART_STATUS_BR 0x00000008
0122 #define LEON_REG_UART_STATUS_OE 0x00000010
0123 #define LEON_REG_UART_STATUS_PE 0x00000020
0124 #define LEON_REG_UART_STATUS_FE 0x00000040
0125 #define LEON_REG_UART_STATUS_TF 0x00000200
0126 #define LEON_REG_UART_STATUS_ERR 0x00000078
0127
0128
0129
0130
0131
0132 #define LEON_REG_UART_CTRL_RE 0x00000001
0133 #define LEON_REG_UART_CTRL_TE 0x00000002
0134 #define LEON_REG_UART_CTRL_RI 0x00000004
0135 #define LEON_REG_UART_CTRL_TI 0x00000008
0136 #define LEON_REG_UART_CTRL_PS 0x00000010
0137 #define LEON_REG_UART_CTRL_PE 0x00000020
0138 #define LEON_REG_UART_CTRL_FL 0x00000040
0139 #define LEON_REG_UART_CTRL_LB 0x00000080
0140 #define LEON_REG_UART_CTRL_DB 0x00000800
0141 #define LEON_REG_UART_CTRL_SI 0x00004000
0142 #define LEON_REG_UART_CTRL_FA 0x80000000
0143 #define LEON_REG_UART_CTRL_FA_BIT 31
0144
0145
0146
0147 #define LEON3_IRQMPSTATUS_CPUNR 28
0148 #define LEON3_IRQMPSTATUS_BROADCAST 27
0149
0150
0151 #ifndef ASM
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163 #define LEON_Clear_interrupt( _source ) \
0164 grlib_store_32(&LEON3_IrqCtrl_Regs->iclear, 1U << (_source))
0165
0166 #define LEON_Force_interrupt( _source ) \
0167 grlib_store_32(&LEON3_IrqCtrl_Regs->iforce0, 1U << (_source))
0168
0169 #define LEON_Enable_interrupt_broadcast( _source ) \
0170 do { \
0171 rtems_interrupt_lock_context _lock_context; \
0172 uint32_t _mask = 1U << ( _source ); \
0173 uint32_t _brdcst; \
0174 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
0175 _brdcst = grlib_load_32(&LEON3_IrqCtrl_Regs->brdcst); \
0176 _brdcst |= _mask; \
0177 grlib_store_32(&LEON3_IrqCtrl_Regs->brdcst, _brdcst); \
0178 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
0179 } while (0)
0180
0181 #define LEON_Disable_interrupt_broadcast( _source ) \
0182 do { \
0183 rtems_interrupt_lock_context _lock_context; \
0184 uint32_t _mask = 1U << ( _source ); \
0185 uint32_t _brdcst; \
0186 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
0187 _brdcst = grlib_load_32(&LEON3_IrqCtrl_Regs->brdcst); \
0188 _brdcst &= ~_mask; \
0189 grlib_store_32(&LEON3_IrqCtrl_Regs->brdcst, _brdcst); \
0190 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
0191 } while (0)
0192
0193 #define LEON_Is_interrupt_pending( _source ) \
0194 (grlib_load_32(&LEON3_IrqCtrl_Regs->ipend) & (1U << (_source)))
0195
0196 #define LEON_Cpu_Is_interrupt_masked( _source, _cpu ) \
0197 (!(grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu]) & (1U << (_source))))
0198
0199 #define LEON_Cpu_Mask_interrupt( _source, _cpu ) \
0200 do { \
0201 rtems_interrupt_lock_context _lock_context; \
0202 uint32_t _pimask; \
0203 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
0204 _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
0205 _pimask &= ~(1U << (_source)); \
0206 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \
0207 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
0208 } while (0)
0209
0210 #define LEON_Cpu_Unmask_interrupt( _source, _cpu ) \
0211 do { \
0212 rtems_interrupt_lock_context _lock_context; \
0213 uint32_t _pimask; \
0214 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
0215 _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
0216 _pimask |= 1U << (_source); \
0217 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \
0218 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
0219 } while (0)
0220
0221 #define LEON_Cpu_Disable_interrupt( _source, _previous, _cpu ) \
0222 do { \
0223 rtems_interrupt_lock_context _lock_context; \
0224 uint32_t _mask = 1U << (_source); \
0225 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
0226 (_previous) = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
0227 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], (_previous) & ~_mask); \
0228 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
0229 (_previous) &= _mask; \
0230 } while (0)
0231
0232 #define LEON_Cpu_Restore_interrupt( _source, _previous, _cpu ) \
0233 do { \
0234 rtems_interrupt_lock_context _lock_context; \
0235 uint32_t _pimask; \
0236 LEON3_IRQCTRL_ACQUIRE( &_lock_context ); \
0237 _pimask = grlib_load_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ]); \
0238 _pimask &= ~(1U << (_source)); \
0239 _pimask |= _previous; \
0240 grlib_store_32(&LEON3_IrqCtrl_Regs->pimask[_cpu ], _pimask); \
0241 LEON3_IRQCTRL_RELEASE( &_lock_context ); \
0242 } while (0)
0243
0244
0245 #define LEON_Is_interrupt_masked( _source ) \
0246 LEON_Cpu_Is_interrupt_masked(_source, _LEON3_Get_current_processor())
0247
0248 #define LEON_Mask_interrupt(_source) \
0249 LEON_Cpu_Mask_interrupt(_source, _LEON3_Get_current_processor())
0250
0251 #define LEON_Unmask_interrupt(_source) \
0252 LEON_Cpu_Unmask_interrupt(_source, _LEON3_Get_current_processor())
0253
0254 #define LEON_Disable_interrupt(_source, _previous) \
0255 LEON_Cpu_Disable_interrupt(_source, _previous, _LEON3_Get_current_processor())
0256
0257 #define LEON_Restore_interrupt(_source, _previous) \
0258 LEON_Cpu_Restore_interrupt(_source, _previous, _LEON3_Get_current_processor())
0259
0260
0261 #define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source)
0262 #define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source)
0263 #define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source)
0264 #define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source)
0265 #define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source)
0266 #define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source)
0267 #define BSP_Disable_interrupt(_source, _previous) \
0268 LEON_Disable_interrupt(_source, _prev)
0269 #define BSP_Restore_interrupt(_source, _previous) \
0270 LEON_Restore_interrupt(_source, _previous)
0271
0272
0273 #define BSP_Cpu_Is_interrupt_masked(_source, _cpu) \
0274 LEON_Cpu_Is_interrupt_masked(_source, _cpu)
0275 #define BSP_Cpu_Unmask_interrupt(_source, _cpu) \
0276 LEON_Cpu_Unmask_interrupt(_source, _cpu)
0277 #define BSP_Cpu_Mask_interrupt(_source, _cpu) \
0278 LEON_Cpu_Mask_interrupt(_source, _cpu)
0279 #define BSP_Cpu_Disable_interrupt(_source, _previous, _cpu) \
0280 LEON_Cpu_Disable_interrupt(_source, _prev, _cpu)
0281 #define BSP_Cpu_Restore_interrupt(_source, _previous, _cpu) \
0282 LEON_Cpu_Restore_interrupt(_source, _previous, _cpu)
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301 #define LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO 0x00000002
0302 #define LEON_REG_TIMER_COUNTER_STOP_AT_ZERO 0x00000000
0303
0304 #define LEON_REG_TIMER_COUNTER_LOAD_COUNTER 0x00000004
0305
0306 #define LEON_REG_TIMER_COUNTER_ENABLE_COUNTING 0x00000001
0307 #define LEON_REG_TIMER_COUNTER_DISABLE_COUNTING 0x00000000
0308
0309 #define LEON_REG_TIMER_COUNTER_RELOAD_MASK 0x00000002
0310 #define LEON_REG_TIMER_COUNTER_ENABLE_MASK 0x00000001
0311
0312 #define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003
0313 #define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003
0314
0315
0316 static inline unsigned int leon_r32_no_cache(uintptr_t addr)
0317 {
0318 unsigned int tmp;
0319 __asm__ volatile (" lda [%1] 1, %0\n" : "=r"(tmp) : "r"(addr));
0320 return tmp;
0321 }
0322
0323
0324
0325
0326
0327
0328
0329
0330 extern int syscon_uart_index;
0331
0332 #if !defined(LEON3_APBUART_BASE)
0333
0334
0335
0336
0337
0338
0339
0340 extern int leon3_debug_uart_index;
0341 #endif
0342
0343 #endif
0344
0345 #ifdef __cplusplus
0346 }
0347 #endif
0348
0349 #endif
0350
0351