RTEMS  5.1
amba.h
Go to the documentation of this file.
1 
7 /*
8  * AMBA Plag & Play Bus Driver Macros
9  *
10  * Macros used for AMBA Plug & Play bus scanning
11  *
12  * COPYRIGHT (c) 2004.
13  * Gaisler Research
14  *
15  * The license and distribution terms for this file may be
16  * found in the file LICENSE in this distribution or at
17  * http://www.rtems.org/license/LICENSE.
18  */
19 
20 #ifndef __AMBA_H__
21 #define __AMBA_H__
22 
35 #ifndef GRLIB_IO_AREA
36 #define GRLIB_IO_AREA 0xfff00000
37 #endif
38 
39 #define GRLIB_CONF_AREA 0xff000
40 #define GRLIB_AHB_SLAVE_CONF_AREA (1 << 11)
41 
42 #define GRLIB_AHB_CONF_WORDS 8
43 #define GRLIB_APB_CONF_WORDS 2
44 #define GRLIB_AHB_MASTERS 64
45 #define GRLIB_AHB_SLAVES 64
46 #define GRLIB_APB_SLAVES 16
47 
48 #if defined(RTEMS_MULTIPROCESSING)
49  #define GRLIB_CLOCK_INDEX \
50  (rtems_configuration_get_user_multiprocessing_table() ? GRLIB_Cpu_Index : 0)
51 #else
52  #define GRLIB_CLOCK_INDEX 0
53 #endif
54 
55 #if defined(RTEMS_SMP)
56 #define GRLIB_COUNTER_GPTIMER_INDEX (GRLIB_CLOCK_INDEX + 1)
57 #else
58 #define GRLIB_COUNTER_GPTIMER_INDEX GRLIB_CLOCK_INDEX
59 #endif
60 
61 #define GRLIB_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER 1000000
62 
63 #define GRLIB_IRQMPSTATUS_CPUNR 28
64 
65 #include <grlib/ambapp.h>
66 #include <grlib/grlib.h>
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 /* The AMBA Plug&Play info of the bus that the cpu sits on */
73 extern struct ambapp_bus ambapp_plb;
74 
75 extern uint32_t GRLIB_Cpu_Index;
76 extern const unsigned char GRLIB_mp_irq;
77 
78 extern volatile struct irqmp_regs *GRLIB_IrqCtrl_Regs;
79 extern struct ambapp_dev *GRLIB_IrqCtrl_Adev;
80 extern int GRLIB_IrqCtrl_EIrq;
81 extern volatile struct gptimer_regs *GRLIB_Timer_Regs;
82 extern struct ambapp_dev *GRLIB_Timer_Adev;
83 void gptimer_initialize(void);
84 void irqmp_initialize(void);
85 
86 static inline uint32_t grlib_up_counter_frequency(void)
87 {
88  /*
89  * For simplicity, assume that the interrupt controller uses the processor
90  * clock. This is at least true on the GR740.
91  */
92  return ambapp_freq_get(&ambapp_plb, GRLIB_IrqCtrl_Adev);
93 }
94 
95 extern rtems_interrupt_lock GRLIB_IrqCtrl_Lock;
96 
97 
98 static inline uint32_t grlib_get_cpu_count(
99  volatile struct irqmp_regs *irqmp
100 )
101 {
102  uint32_t mpstat = irqmp->mpstat;
103 
104  return ((mpstat >> GRLIB_IRQMPSTATUS_CPUNR) & 0xf) + 1;
105 }
106 
107 #define GRLIB_IRQCTRL_ACQUIRE( _lock_context ) \
108  rtems_interrupt_lock_acquire( &GRLIB_IrqCtrl_Lock, _lock_context )
109 
110 #define GRLIB_IRQCTRL_RELEASE( _lock_context ) \
111  rtems_interrupt_lock_release( &GRLIB_IrqCtrl_Lock, _lock_context )
112 
113 #define GRLIB_Cpu_Unmask_interrupt( _source, _cpu ) \
114  do { \
115  rtems_interrupt_lock_context _lock_context; \
116  GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
117  GRLIB_IrqCtrl_Regs->mask[_cpu] |= (1U << (_source)); \
118  GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
119  } while (0)
120 
121 #define GRLIB_Cpu_Mask_interrupt( _source, _cpu ) \
122  do { \
123  rtems_interrupt_lock_context _lock_context; \
124  GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
125  GRLIB_IrqCtrl_Regs->mask[_cpu] &= ~(1U << (_source)); \
126  GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
127  } while (0)
128 
129 #define GRLIB_Enable_interrupt_broadcast( _source ) \
130  do { \
131  rtems_interrupt_lock_context _lock_context; \
132  uint32_t _mask = 1U << ( _source ); \
133  GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
134  GRLIB_IrqCtrl_Regs->bcast |= _mask; \
135  GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
136  } while (0)
137 
138 #define GRLIB_Disable_interrupt_broadcast( _source ) \
139  do { \
140  rtems_interrupt_lock_context _lock_context; \
141  uint32_t _mask = 1U << ( _source ); \
142  GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
143  GRLIB_IrqCtrl_Regs->bcast &= ~_mask; \
144  GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
145  } while (0)
146 
147 #define BSP_Cpu_Is_interrupt_masked( _source, _cpu ) \
148  (!(GRLIB_IrqCtrl_Regs->mask[_cpu] & (1U << (_source))))
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
156 #endif /* __AMBA_H__ */
Definition: ambapp.h:43
Definition: grlib.h:101
ISR lock control.
Definition: isrlock.h:56
Definition: ambapp.h:126
Definition: grlib.h:55
Common GRLIB AMBA Core Register definitions.