summaryrefslogtreecommitdiff
path: root/bootwrapper/helpers.h
blob: 862e1dab3b34d3a2d0c6310df151e7046dbd7a1d (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
/*
 * 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.                        
 */ 

#ifndef _VIRT_HELPERS_H_
#define _VIRT_HELPERS_H_

extern unsigned int DORMANT_BASE;
/*******************************************************
 * Export prototypes of the functions which will be used
 * to save/restore the Non-secure context.
 *******************************************************/
extern void wfe(void);
extern void sev(void);
extern void wfi(void);
extern void dmb(void);
extern void dsb(void);
extern void isb(void);
extern void virt_dead(void);
extern void smc(unsigned, unsigned);
extern void dcisw(unsigned);
extern void dccsw(unsigned);
extern void dccisw(unsigned);

extern void write_sp(unsigned, unsigned);
extern void write_lr(unsigned, unsigned);
extern void write_cpsr(unsigned);
extern void write_sctlr(unsigned);
extern void write_actlr(unsigned);
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_cntkctl(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 read_cntpct(unsigned *, unsigned *);
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_nmrr(void);
extern unsigned read_prrr(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_mpidr(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_mvbar(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_sp(unsigned);
extern unsigned read_lr(unsigned);
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_sctlr(void);
extern unsigned read_actlr(void);
extern unsigned read_nsacr(void);
extern unsigned read_ttbr0(void);
extern unsigned read_ttbcr(void);
extern unsigned read_cnthctl(void);
extern unsigned read_cntkctl(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 num_secondaries(void);
extern unsigned *copy_words(volatile unsigned *destination,
                            volatile unsigned *source, unsigned num_words);
extern unsigned *get_sp(unsigned, unsigned);

/*
 * V7 functions
 */
extern void save_performance_monitors(unsigned int *pointer);
extern void save_banked_registers(unsigned int *pointer);
extern void save_control_registers(unsigned int *context);
extern void save_mmu(unsigned int *pointer);
extern void save_cp15(unsigned int *pointer);

extern void restore_control_registers(unsigned int *context);
extern void restore_mmu(unsigned int *pointer);
extern void restore_cp15(unsigned int *pointer);
extern void restore_performance_monitors(unsigned int *pointer);
extern void restore_banked_registers(unsigned int *pointer);
extern void disable_clean_inv_l1_dcache_v7(void);
extern void cache_maint_op(unsigned, unsigned);
extern unsigned get_loc(void);
extern void disable_coherency(void);
extern void disable_dcache(void);
extern void enable_coherency(void);
extern void enable_dcache(void);
extern void flush_to_loc(void);
extern void inv_tlb_all(void);
extern void inv_icache_all(void);
extern void inv_icache_mva_pou(unsigned *);
extern void inv_dcache_mva_poc(unsigned *);
extern void cln_dcache_mva_poc(unsigned *);
extern void cln_dcache_mva_pou(unsigned *);
extern void enable_user_perfmon_access(void);
extern void enable_perfmon(void);
extern void enable_swp(void);
extern void enable_pmu(void);
extern void enter_monitor_mode(void);
extern void enter_nonsecure_world(unsigned);

/*
 * GIC functions
 */
extern void save_gic_interface(unsigned int *pointer,
                               unsigned gic_interface_address);
extern int save_gic_distributor_private(unsigned int *pointer,
                                        unsigned gic_distributor_address);
extern int save_gic_distributor_shared(unsigned int *pointer,
                                       unsigned gic_distributor_address);
extern void restore_gic_interface(unsigned int *pointer,
                                  unsigned gic_interface_address);
extern void restore_gic_distributor_private(unsigned int *pointer,
                                            unsigned gic_distributor_address);
extern void restore_gic_distributor_shared(unsigned int *pointer,
                                           unsigned gic_distributor_address);
extern void disable_gic_dist(unsigned int *tmp,
                             volatile unsigned int *dist_base);
extern void enable_gic_dist(unsigned int tmp, volatile unsigned int *dist_base);

extern void switcher_exit(void);
extern void hyp_save(unsigned, unsigned);

#endif                          /* _VIRT_HELPERS_H_ */