RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
bsps
riscv
griscv
include
amba.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
8
9
/*
10
* AMBA Plag & Play Bus Driver Macros
11
*
12
* Macros used for AMBA Plug & Play bus scanning
13
*
14
* COPYRIGHT (c) 2004.
15
* Gaisler Research
16
*
17
* Redistribution and use in source and binary forms, with or without
18
* modification, are permitted provided that the following conditions
19
* are met:
20
* 1. Redistributions of source code must retain the above copyright
21
* notice, this list of conditions and the following disclaimer.
22
* 2. Redistributions in binary form must reproduce the above copyright
23
* notice, this list of conditions and the following disclaimer in the
24
* documentation and/or other materials provided with the distribution.
25
*
26
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
* POSSIBILITY OF SUCH DAMAGE.
37
*/
38
39
#ifndef __AMBA_H__
40
#define __AMBA_H__
41
53
54
#ifndef GRLIB_IO_AREA
55
#define GRLIB_IO_AREA 0xfff00000
56
#endif
57
58
#define GRLIB_CONF_AREA 0xff000
59
#define GRLIB_AHB_SLAVE_CONF_AREA (1 << 11)
60
61
#define GRLIB_AHB_CONF_WORDS 8
62
#define GRLIB_APB_CONF_WORDS 2
63
#define GRLIB_AHB_MASTERS 64
64
#define GRLIB_AHB_SLAVES 64
65
#define GRLIB_APB_SLAVES 16
66
67
#if defined(RTEMS_MULTIPROCESSING)
68
#define GRLIB_CLOCK_INDEX \
69
(rtems_configuration_get_user_multiprocessing_table() ? GRLIB_Cpu_Index : 0)
70
#else
71
#define GRLIB_CLOCK_INDEX 0
72
#endif
73
74
#if defined(RTEMS_SMP)
75
#define GRLIB_COUNTER_GPTIMER_INDEX (GRLIB_CLOCK_INDEX + 1)
76
#else
77
#define GRLIB_COUNTER_GPTIMER_INDEX GRLIB_CLOCK_INDEX
78
#endif
79
80
#define GRLIB_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER 1000000
81
82
#define GRLIB_IRQMPSTATUS_CPUNR 28
83
84
#include <
grlib/ambapp.h
>
85
#include <
grlib/grlib.h
>
86
87
#ifdef __cplusplus
88
extern
"C"
{
89
#endif
90
91
extern
uint32_t GRLIB_Cpu_Index;
92
extern
const
unsigned
char
GRLIB_mp_irq;
93
94
extern
volatile
struct
irqmp_regs
*GRLIB_IrqCtrl_Regs;
95
extern
struct
ambapp_dev
*GRLIB_IrqCtrl_Adev;
96
extern
int
GRLIB_IrqCtrl_EIrq;
97
extern
volatile
struct
gptimer_regs
*GRLIB_Timer_Regs;
98
extern
struct
ambapp_dev
*GRLIB_Timer_Adev;
99
void
gptimer_initialize(
void
);
100
void
irqmp_initialize(
void
);
101
102
static
inline
uint32_t grlib_up_counter_frequency(
void
)
103
{
104
/*
105
* For simplicity, assume that the interrupt controller uses the processor
106
* clock. This is at least true on the GR740.
107
*/
108
return
ambapp_freq_get(
ambapp_plb
(), GRLIB_IrqCtrl_Adev);
109
}
110
111
extern
rtems_interrupt_lock
GRLIB_IrqCtrl_Lock;
112
113
114
static
inline
uint32_t grlib_get_cpu_count(
115
volatile
struct
irqmp_regs
*irqmp
116
)
117
{
118
uint32_t mpstat = irqmp->mpstat;
119
120
return
((mpstat >> GRLIB_IRQMPSTATUS_CPUNR) & 0xf) + 1;
121
}
122
123
#define GRLIB_IRQCTRL_ACQUIRE( _lock_context ) \
124
rtems_interrupt_lock_acquire( &GRLIB_IrqCtrl_Lock, _lock_context )
125
126
#define GRLIB_IRQCTRL_RELEASE( _lock_context ) \
127
rtems_interrupt_lock_release( &GRLIB_IrqCtrl_Lock, _lock_context )
128
129
#define GRLIB_Cpu_Unmask_interrupt( _source, _cpu ) \
130
do { \
131
rtems_interrupt_lock_context _lock_context; \
132
GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
133
GRLIB_IrqCtrl_Regs->mask[_cpu] |= (1U << (_source)); \
134
GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
135
} while (0)
136
137
#define GRLIB_Cpu_Mask_interrupt( _source, _cpu ) \
138
do { \
139
rtems_interrupt_lock_context _lock_context; \
140
GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
141
GRLIB_IrqCtrl_Regs->mask[_cpu] &= ~(1U << (_source)); \
142
GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
143
} while (0)
144
145
#define GRLIB_Enable_interrupt_broadcast( _source ) \
146
do { \
147
rtems_interrupt_lock_context _lock_context; \
148
uint32_t _mask = 1U << ( _source ); \
149
GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
150
GRLIB_IrqCtrl_Regs->bcast |= _mask; \
151
GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
152
} while (0)
153
154
#define GRLIB_Disable_interrupt_broadcast( _source ) \
155
do { \
156
rtems_interrupt_lock_context _lock_context; \
157
uint32_t _mask = 1U << ( _source ); \
158
GRLIB_IRQCTRL_ACQUIRE( &_lock_context ); \
159
GRLIB_IrqCtrl_Regs->bcast &= ~_mask; \
160
GRLIB_IRQCTRL_RELEASE( &_lock_context ); \
161
} while (0)
162
163
#define BSP_Cpu_Is_interrupt_masked( _source, _cpu ) \
164
(!(GRLIB_IrqCtrl_Regs->mask[_cpu] & (1U << (_source))))
165
166
#ifdef __cplusplus
167
}
168
#endif
169
171
172
#endif
/* __AMBA_H__ */
ambapp.h
grlib.h
Common GRLIB AMBA Core Register definitions.
rtems_interrupt_lock
char rtems_interrupt_lock
This structure represents an ISR lock.
Definition
intr.h:532
ambapp_plb
struct ambapp_bus * ambapp_plb(void)
Gets the fully scanned AMBA Plug & Play Processor Local Bus (PLB).
Definition
bspstart.c:58
ambapp_dev
Definition
ambapp.h:94
gptimer_regs
Definition
grlib.h:129
irqmp_regs
Definition
grlib.h:83
Generated by
1.18.0