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
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 #ifndef _INCLUDE_LEON_h
0059 #define _INCLUDE_LEON_h
0060
0061 #include <rtems/score/sparc.h>
0062
0063 #ifdef __cplusplus
0064 extern "C" {
0065 #endif
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 #define LEON_INTERRUPT_CORRECTABLE_MEMORY_ERROR 1
0076 #define LEON_INTERRUPT_UART_2_RX_TX 2
0077 #define LEON_INTERRUPT_UART_1_RX_TX 3
0078 #define LEON_INTERRUPT_EXTERNAL_0 4
0079 #define LEON_INTERRUPT_EXTERNAL_1 5
0080 #define LEON_INTERRUPT_EXTERNAL_2 6
0081 #define LEON_INTERRUPT_EXTERNAL_3 7
0082 #define LEON_INTERRUPT_TIMER1 8
0083 #define LEON_INTERRUPT_TIMER2 9
0084 #define LEON_INTERRUPT_EMPTY1 10
0085 #define LEON_INTERRUPT_EMPTY2 11
0086 #define LEON_INTERRUPT_EMPTY3 12
0087 #define LEON_INTERRUPT_EMPTY4 13
0088 #define LEON_INTERRUPT_EMPTY5 14
0089 #define LEON_INTERRUPT_EMPTY6 15
0090
0091 #ifndef ASM
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 #define LEON_TRAP_TYPE( _source ) SPARC_INTERRUPT_SOURCE_TO_TRAP( _source )
0103
0104 #define LEON_TRAP_SOURCE( _trap ) SPARC_INTERRUPT_TRAP_TO_SOURCE( _trap )
0105
0106 #define LEON_INT_TRAP( _trap ) SPARC_IS_INTERRUPT_TRAP( _trap )
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 typedef struct {
0119 volatile unsigned int Memory_Config_1;
0120 volatile unsigned int Memory_Config_2;
0121 volatile unsigned int Edac_Control;
0122 volatile unsigned int Failed_Address;
0123 volatile unsigned int Memory_Status;
0124 volatile unsigned int Cache_Control;
0125 volatile unsigned int Power_Down;
0126 volatile unsigned int Write_Protection_1;
0127 volatile unsigned int Write_Protection_2;
0128 volatile unsigned int Leon_Configuration;
0129 volatile unsigned int dummy2;
0130 volatile unsigned int dummy3;
0131 volatile unsigned int dummy4;
0132 volatile unsigned int dummy5;
0133 volatile unsigned int dummy6;
0134 volatile unsigned int dummy7;
0135 volatile unsigned int Timer_Counter_1;
0136 volatile unsigned int Timer_Reload_1;
0137 volatile unsigned int Timer_Control_1;
0138 volatile unsigned int Watchdog;
0139 volatile unsigned int Timer_Counter_2;
0140 volatile unsigned int Timer_Reload_2;
0141 volatile unsigned int Timer_Control_2;
0142 volatile unsigned int dummy8;
0143 volatile unsigned int Scaler_Counter;
0144 volatile unsigned int Scaler_Reload;
0145 volatile unsigned int dummy9;
0146 volatile unsigned int dummy10;
0147 volatile unsigned int UART_Channel_1;
0148 volatile unsigned int UART_Status_1;
0149 volatile unsigned int UART_Control_1;
0150 volatile unsigned int UART_Scaler_1;
0151 volatile unsigned int UART_Channel_2;
0152 volatile unsigned int UART_Status_2;
0153 volatile unsigned int UART_Control_2;
0154 volatile unsigned int UART_Scaler_2;
0155 volatile unsigned int Interrupt_Mask;
0156 volatile unsigned int Interrupt_Pending;
0157 volatile unsigned int Interrupt_Force;
0158 volatile unsigned int Interrupt_Clear;
0159 volatile unsigned int PIO_Data;
0160 volatile unsigned int PIO_Direction;
0161 volatile unsigned int PIO_Interrupt;
0162 } LEON_Register_Map;
0163
0164 #endif
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175 #ifdef ASM
0176
0177 #define LEON_REG_MEMCFG1_OFFSET 0x00
0178 #define LEON_REG_MEMCFG2_OFFSET 0x04
0179 #define LEON_REG_EDACCTRL_OFFSET 0x08
0180 #define LEON_REG_FAILADDR_OFFSET 0x0C
0181 #define LEON_REG_MEMSTATUS_OFFSET 0x10
0182 #define LEON_REG_CACHECTRL_OFFSET 0x14
0183 #define LEON_REG_POWERDOWN_OFFSET 0x18
0184 #define LEON_REG_WRITEPROT1_OFFSET 0x1C
0185 #define LEON_REG_WRITEPROT2_OFFSET 0x20
0186 #define LEON_REG_LEONCONF_OFFSET 0x24
0187 #define LEON_REG_UNIMPLEMENTED_2_OFFSET 0x28
0188 #define LEON_REG_UNIMPLEMENTED_3_OFFSET 0x2C
0189 #define LEON_REG_UNIMPLEMENTED_4_OFFSET 0x30
0190 #define LEON_REG_UNIMPLEMENTED_5_OFFSET 0x34
0191 #define LEON_REG_UNIMPLEMENTED_6_OFFSET 0x38
0192 #define LEON_REG_UNIMPLEMENTED_7_OFFSET 0x3C
0193 #define LEON_REG_TIMERCNT1_OFFSET 0x40
0194 #define LEON_REG_TIMERLOAD1_OFFSET 0x44
0195 #define LEON_REG_TIMERCTRL1_OFFSET 0x48
0196 #define LEON_REG_WDOG_OFFSET 0x4C
0197 #define LEON_REG_TIMERCNT2_OFFSET 0x50
0198 #define LEON_REG_TIMERLOAD2_OFFSET 0x54
0199 #define LEON_REG_TIMERCTRL2_OFFSET 0x58
0200 #define LEON_REG_UNIMPLEMENTED_8_OFFSET 0x5C
0201 #define LEON_REG_SCALERCNT_OFFSET 0x60
0202 #define LEON_REG_SCALER_LOAD_OFFSET 0x64
0203 #define LEON_REG_UNIMPLEMENTED_9_OFFSET 0x68
0204 #define LEON_REG_UNIMPLEMENTED_10_OFFSET 0x6C
0205 #define LEON_REG_UARTDATA1_OFFSET 0x70
0206 #define LEON_REG_UARTSTATUS1_OFFSET 0x74
0207 #define LEON_REG_UARTCTRL1_OFFSET 0x78
0208 #define LEON_REG_UARTSCALER1_OFFSET 0x7C
0209 #define LEON_REG_UARTDATA2_OFFSET 0x80
0210 #define LEON_REG_UARTSTATUS2_OFFSET 0x84
0211 #define LEON_REG_UARTCTRL2_OFFSET 0x88
0212 #define LEON_REG_UARTSCALER2_OFFSET 0x8C
0213 #define LEON_REG_IRQMASK_OFFSET 0x90
0214 #define LEON_REG_IRQPEND_OFFSET 0x94
0215 #define LEON_REG_IRQFORCE_OFFSET 0x98
0216 #define LEON_REG_IRQCLEAR_OFFSET 0x9C
0217 #define LEON_REG_PIODATA_OFFSET 0xA0
0218 #define LEON_REG_PIODIR_OFFSET 0xA4
0219 #define LEON_REG_PIOIRQ_OFFSET 0xA8
0220 #define LEON_REG_SIM_RAM_SIZE_OFFSET 0xF4
0221 #define LEON_REG_SIM_ROM_SIZE_OFFSET 0xF8
0222
0223 #endif
0224
0225
0226
0227
0228
0229 #define LEON_MEMORY_CONFIGURATION_PROM_SIZE_MASK 0x0003C000
0230
0231
0232
0233
0234
0235 #define LEON_MEMORY_CONFIGURATION_RAM_SIZE_MASK 0x00001E00
0236
0237
0238
0239
0240
0241
0242 #define LEON_REG_TIMER_CONTROL_EN 0x00000001
0243
0244 #define LEON_REG_TIMER_CONTROL_RL 0x00000002
0245
0246 #define LEON_REG_TIMER_CONTROL_LD 0x00000004
0247
0248
0249
0250
0251
0252
0253
0254 #define LEON_REG_UART_CONTROL_RTD 0x000000FF
0255
0256
0257
0258
0259
0260 #define LEON_REG_UART_STATUS_CLR 0x00000000
0261 #define LEON_REG_UART_STATUS_DR 0x00000001
0262 #define LEON_REG_UART_STATUS_TSE 0x00000002
0263 #define LEON_REG_UART_STATUS_THE 0x00000004
0264 #define LEON_REG_UART_STATUS_BR 0x00000008
0265 #define LEON_REG_UART_STATUS_OE 0x00000010
0266 #define LEON_REG_UART_STATUS_PE 0x00000020
0267 #define LEON_REG_UART_STATUS_FE 0x00000040
0268 #define LEON_REG_UART_STATUS_ERR 0x00000078
0269
0270
0271
0272
0273
0274
0275 #define LEON_REG_UART_CTRL_RE 0x00000001
0276 #define LEON_REG_UART_CTRL_TE 0x00000002
0277 #define LEON_REG_UART_CTRL_RI 0x00000004
0278 #define LEON_REG_UART_CTRL_TI 0x00000008
0279 #define LEON_REG_UART_CTRL_PS 0x00000010
0280 #define LEON_REG_UART_CTRL_PE 0x00000020
0281 #define LEON_REG_UART_CTRL_FL 0x00000040
0282 #define LEON_REG_UART_CTRL_LB 0x00000080
0283
0284 #ifndef ASM
0285
0286
0287
0288
0289
0290
0291
0292
0293 extern LEON_Register_Map LEON_REG;
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305 #define LEON_Clear_interrupt( _source ) \
0306 do { \
0307 LEON_REG.Interrupt_Clear = (1 << (_source)); \
0308 } while (0)
0309
0310 #define LEON_Force_interrupt( _source ) \
0311 do { \
0312 uint32_t _level; \
0313 \
0314 _level = sparc_disable_interrupts(); \
0315 LEON_REG.Interrupt_Force |= (1 << (_source)); \
0316 sparc_enable_interrupts( _level ); \
0317 } while (0)
0318
0319 #define LEON_Is_interrupt_pending( _source ) \
0320 (LEON_REG.Interrupt_Pending & (1 << (_source)))
0321
0322 #define LEON_Is_interrupt_masked( _source ) \
0323 (!(LEON_REG.Interrupt_Mask & (1 << (_source))))
0324
0325 #define LEON_Mask_interrupt( _source ) \
0326 do { \
0327 uint32_t _level; \
0328 \
0329 _level = sparc_disable_interrupts(); \
0330 LEON_REG.Interrupt_Mask &= ~(1 << (_source)); \
0331 sparc_enable_interrupts( _level ); \
0332 } while (0)
0333
0334 #define LEON_Unmask_interrupt( _source ) \
0335 do { \
0336 uint32_t _level; \
0337 \
0338 _level = sparc_disable_interrupts(); \
0339 LEON_REG.Interrupt_Mask |= (1 << (_source)); \
0340 sparc_enable_interrupts( _level ); \
0341 } while (0)
0342
0343 #define LEON_Disable_interrupt( _source, _previous ) \
0344 do { \
0345 uint32_t _level; \
0346 uint32_t _mask = 1 << (_source); \
0347 \
0348 _level = sparc_disable_interrupts(); \
0349 (_previous) = LEON_REG.Interrupt_Mask; \
0350 LEON_REG.Interrupt_Mask = _previous & ~_mask; \
0351 sparc_enable_interrupts( _level ); \
0352 (_previous) &= _mask; \
0353 } while (0)
0354
0355 #define LEON_Restore_interrupt( _source, _previous ) \
0356 do { \
0357 uint32_t _level; \
0358 uint32_t _mask = 1 << (_source); \
0359 \
0360 _level = sparc_disable_interrupts(); \
0361 LEON_REG.Interrupt_Mask = \
0362 (LEON_REG.Interrupt_Mask & ~_mask) | (_previous); \
0363 sparc_enable_interrupts( _level ); \
0364 } while (0)
0365
0366
0367 #define BSP_Clear_interrupt(_source) LEON_Clear_interrupt(_source)
0368 #define BSP_Force_interrupt(_source) LEON_Force_interrupt(_source)
0369 #define BSP_Clear_forced_interrupt( _source ) \
0370 do { \
0371 uint32_t _level; \
0372 \
0373 _level = sparc_disable_interrupts(); \
0374 LEON_REG.Interrupt_Force &= ~(1 << (_source)); \
0375 sparc_enable_interrupts( _level ); \
0376 } while (0)
0377 #define BSP_Is_interrupt_pending(_source) LEON_Is_interrupt_pending(_source)
0378 #define BSP_Is_interrupt_forced(_source) \
0379 (LEON_REG.Interrupt_Force & (1 << (_source)))
0380 #define BSP_Is_interrupt_masked(_source) LEON_Is_interrupt_masked(_source)
0381 #define BSP_Unmask_interrupt(_source) LEON_Unmask_interrupt(_source)
0382 #define BSP_Mask_interrupt(_source) LEON_Mask_interrupt(_source)
0383 #define BSP_Disable_interrupt(_source, _previous) \
0384 LEON_Disable_interrupt(_source, _prev)
0385 #define BSP_Restore_interrupt(_source, _previous) \
0386 LEON_Restore_interrupt(_source, _previous)
0387
0388
0389 #define BSP_Cpu_Is_interrupt_masked(_source, _cpu) \
0390 BSP_Is_interrupt_masked(_source)
0391 #define BSP_Cpu_Unmask_interrupt(_source, _cpu) \
0392 BSP_Unmask_interrupt(_source)
0393 #define BSP_Cpu_Mask_interrupt(_source, _cpu) \
0394 BSP_Mask_interrupt(_source)
0395 #define BSP_Cpu_Disable_interrupt(_source, _previous, _cpu) \
0396 BSP_Disable_interrupt(_source, _prev)
0397 #define BSP_Cpu_Restore_interrupt(_source, _previous, _cpu) \
0398 BSP_Cpu_Restore_interrupt(_source, _previous)
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417 #define LEON_REG_TIMER_COUNTER_RELOAD_AT_ZERO 0x00000002
0418 #define LEON_REG_TIMER_COUNTER_STOP_AT_ZERO 0x00000000
0419
0420 #define LEON_REG_TIMER_COUNTER_LOAD_COUNTER 0x00000004
0421
0422 #define LEON_REG_TIMER_COUNTER_ENABLE_COUNTING 0x00000001
0423 #define LEON_REG_TIMER_COUNTER_DISABLE_COUNTING 0x00000000
0424
0425 #define LEON_REG_TIMER_COUNTER_RELOAD_MASK 0x00000002
0426 #define LEON_REG_TIMER_COUNTER_ENABLE_MASK 0x00000001
0427
0428 #define LEON_REG_TIMER_COUNTER_DEFINED_MASK 0x00000003
0429 #define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK 0x00000003
0430
0431
0432 static inline unsigned int leon_r32_no_cache(uintptr_t addr)
0433 {
0434 unsigned int tmp;
0435 __asm__ volatile (" lda [%1] 1, %0\n" : "=r"(tmp) : "r"(addr));
0436 return tmp;
0437 }
0438
0439 #endif
0440
0441 #ifdef __cplusplus
0442 }
0443 #endif
0444
0445 #endif
0446