summaryrefslogtreecommitdiff
path: root/acsr/helpers.h
blob: a4d461eadda38719e3a77b175617f2842529fb09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*
 * Copyright (c) 2012, ARM Limited. All rights reserved.
 *       
 * Redistribution and use in source and binary forms, with
 * or without modification, are permitted provided that the
 * following conditions are met:
 *     
 * Redistributions of source code must retain the above
 * copyright notice, this list of conditions and the 
 * following disclaimer.
 *
 * Redistributions in binary form must reproduce the
 * above copyright notice, this list of conditions and 
 * the following disclaimer in the documentation 
 * and/or other materials provided with the distribution.
 *      
 * Neither the name of ARM nor the names of its
 * contributors may be used to endorse or promote products
 * derived from this software without specific prior written
 * permission.                        
 */

/*
 * V7 functions
 */
extern void save_control_registers(unsigned *pointer, int is_secure);
extern void save_mmu(unsigned *pointer);
extern void save_mpu(unsigned *pointer);
extern void save_performance_monitors(unsigned *pointer);
extern void save_banked_registers(unsigned *pointer);
extern void save_cp15(unsigned *pointer);
extern void save_vfp(unsigned *pointer);
extern void save_generic_timer(unsigned *pointer, int is_hyp);
extern void save_v7_debug(unsigned *pointer);
extern void save_fault_status(unsigned *pointer);

extern void restore_control_registers(unsigned *pointer, int is_secure);
extern void restore_mmu(unsigned *pointer);
extern void restore_mpu(unsigned *pointer);
extern void restore_performance_monitors(unsigned *pointer);
extern void restore_banked_registers(unsigned *pointer);
extern void restore_cp15(unsigned *pointer);
extern void restore_vfp(unsigned *pointer);
extern void restore_generic_timer(unsigned *pointer, int is_hyp);
extern void restore_v7_debug(unsigned *pointer);
extern void restore_fault_status(unsigned *pointer);

extern unsigned va_to_pa(unsigned virtual_address);
extern unsigned get_cpu_type(void);

extern unsigned read_mpidr(void);
extern unsigned read_sctlr(void);
extern unsigned read_actlr(void);
extern unsigned read_prrr(void);
extern unsigned read_nmrr(void);
extern unsigned read_l2ctlr(void);
extern unsigned read_mvbar(void);
extern unsigned read_cbar(void);
extern unsigned read_drar(void);
extern unsigned read_dsar(void);
extern unsigned read_teehbr(void);
extern unsigned read_l2ectlr(void);
extern unsigned read_pmuserenr(void);
extern unsigned read_pmintenset(void);
extern unsigned read_pmintenclr(void);
extern unsigned read_pmovsset(void);
extern unsigned read_pmccntr(void);
extern unsigned read_pmxevtyper(void);
extern unsigned read_pmxevcntr(void);
extern unsigned read_pmcr(void);
extern unsigned read_pmcntenset(void);
extern unsigned read_pmcntenclr(void);
extern unsigned read_pmovsr(void);
extern unsigned read_pmswinc(void);
extern unsigned read_pmselr(void);
extern unsigned read_pmceid0(void);
extern unsigned read_pmceid1(void);
extern unsigned read_dfar(void);
extern unsigned read_ifar(void);
extern unsigned read_dfsr(void);
extern unsigned read_ifsr(void);
extern unsigned read_adfsr(void);
extern unsigned read_aifsr(void);
extern unsigned read_cntfrq(void);
extern unsigned read_hsctlr(void);
extern unsigned read_hsr(void);
extern unsigned read_dacr(void);
extern unsigned read_ttbr0(void);
extern unsigned read_cpacr(void);
extern unsigned read_scr(void);
extern unsigned read_cpsr(void);
extern unsigned read_midr(void);
extern unsigned read_vmpidr(void);
extern unsigned read_vmidr(void);
extern unsigned read_id_pfr0(void);
extern unsigned read_id_pfr1(void);
extern unsigned read_id_dfr0(void);
extern unsigned read_id_afr0(void);
extern unsigned read_id_mmfr0(void);
extern unsigned read_id_mmfr1(void);
extern unsigned read_id_mmfr2(void);
extern unsigned read_id_mmfr3(void);
extern unsigned read_id_isar0(void);
extern unsigned read_id_isar1(void);
extern unsigned read_id_isar2(void);
extern unsigned read_id_isar3(void);
extern unsigned read_id_isar4(void);
extern unsigned read_id_isar5(void);
extern unsigned read_aidr(void);
extern unsigned read_vbar(void);
extern unsigned read_ctr(void);
extern unsigned read_tcmtr(void);
extern unsigned read_tlbtr(void);
extern unsigned read_hcr(void);
extern unsigned read_hdcr(void);
extern unsigned read_hcptr(void);
extern unsigned read_hstr(void);
extern unsigned read_vtcr(void);
extern unsigned read_hdfar(void);
extern unsigned read_hpfar(void);
extern unsigned read_cpsr(void);
extern unsigned read_cpuid(void);
extern unsigned read_clusterid(void);
extern unsigned read_clidr(void);
extern unsigned read_ccsidr(void);
extern unsigned read_csselr(void);
extern unsigned read_nsacr(void);
extern unsigned read_ttbr0(void);
extern unsigned read_ttbcr(void);
extern unsigned read_cnthctl(void);
extern unsigned long read_cnthp_cval(void);
extern unsigned read_cnthp_tval(void);
extern unsigned read_cnthp_ctl(void);
extern unsigned read_cntp_ctl(void);
extern unsigned read_cntp_tval(void);
extern unsigned long long read_httbr(void);
extern unsigned long long read_vttbr(void);
extern unsigned long long read_cntpct(void);

extern void dsb(void);
extern void dmb(void);
extern void wfi(void);
extern void endless_wfi(void);
extern void wfe(void);
extern void sev(void);
extern void isb(void);

extern void write_osdlr(unsigned value);
extern void write_sctlr(unsigned value);
extern void write_actlr(unsigned value);
extern void write_nsacr(unsigned);
extern void write_ttbr0(unsigned);
extern void write_ttbcr(unsigned);
extern void write_cntfrq(unsigned);
extern void write_cnthctl(unsigned);
extern void write_cnthp_cval(unsigned, unsigned);
extern void write_cnthp_tval(unsigned);
extern void write_cnthp_ctl(unsigned);
extern void write_cntp_ctl(unsigned);
extern void write_cntp_tval(unsigned);
extern void write_csselr(unsigned);
extern void write_hcr(unsigned);
extern void write_hdcr(unsigned);
extern void write_hcptr(unsigned);
extern void write_hstr(unsigned);
extern void write_hsctlr(unsigned);
extern void write_httbr(unsigned long long);
extern void write_vttbr(unsigned long long);
extern void write_htcr(unsigned);
extern void write_vtcr(unsigned);
extern void write_hmair0(unsigned);
extern void write_hmair1(unsigned);
extern void write_vmpidr(unsigned);
extern void write_vmidr(unsigned);
extern void write_dacr(unsigned);
extern void write_ttbr0(unsigned);
extern void write_cpacr(unsigned);
extern void write_nsacr(unsigned);
extern void write_scr(unsigned);
extern void write_mvbar(unsigned);
extern void write_hvbar(unsigned);
extern void write_vbar(unsigned);
extern void write_prrr(unsigned);
extern void write_nmrr(unsigned);
extern void write_dfar(unsigned);
extern void write_ifar(unsigned);
extern void write_dfsr(unsigned);
extern void write_ifsr(unsigned);
extern void write_adfsr(unsigned);
extern void write_aifsr(unsigned);
extern void write_l2ectlr(unsigned);
extern void write_pmuserenr(unsigned);
extern void write_pmintenset(unsigned);
extern void write_pmintenclr(unsigned);
extern void write_pmovsset(unsigned);
extern void write_pmccntr(unsigned);
extern void write_pmxevtyper(unsigned);
extern void write_pmxevcntr(unsigned);
extern void write_pmcr(unsigned);
extern void write_pmcntenset(unsigned);
extern void write_pmcntenclr(unsigned);
extern void write_pmovsr(unsigned);
extern void write_pmswinc(unsigned);
extern void write_pmselr(unsigned);
extern void write_pmceid0(unsigned);
extern void write_pmceid1(unsigned);
extern void write_osdlr(unsigned value);

extern unsigned *copy_words(volatile unsigned *destination,
			    volatile unsigned *source, unsigned num_words);
extern void appf_memcpy(void *dst, const void *src, unsigned length);
extern void appf_memset(void *dst, unsigned value, unsigned length);

extern void initialize_spinlock(bakery_t * bakery);
extern void get_spinlock(unsigned cpuid, bakery_t * bakery);
extern void release_spinlock(unsigned cpuid, bakery_t * bakery);

/*
 * GCC Compatibility
 */
#ifndef __ARMCC_VERSION
#define __nop() __asm__ __volatile__( "nop\n" )
#endif