summaryrefslogtreecommitdiff
path: root/big-little/include/context.h
blob: 11a737cf37bb7506e8ed192e48c40d078e43d636 (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
/*
 * 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 __CONTEXT_H__
#define __CONTEXT_H__

#include "misc.h"

typedef struct ns_gic_cpu_context {
	unsigned int gic_cpu_if_regs[32];	/* GIC context local to the CPU */
	unsigned int gic_dist_if_pvt_regs[32];	/* GIC SGI/PPI context local to the CPU */
} gic_cpu_context;

typedef struct fault_regs {
	unsigned dfar;
	unsigned ifar;
	unsigned ifsr;
	unsigned dfsr;
	unsigned adfsr;
	unsigned aifsr;
} cp15_fault_regs;

typedef struct ns_banked_cp15_context {
	unsigned int cp15_misc_regs[2];	/* cp15 miscellaneous registers */
	unsigned int cp15_ctrl_regs[20];	/* cp15 control registers */
	unsigned int cp15_mmu_regs[16];	/* cp15 mmu registers */
	cp15_fault_regs ns_cp15_fault_regs;	/* cp15 fault status registers */
} banked_cp15_context;

typedef struct gen_tmr_ctx {
	unsigned cntfrq;
	unsigned long long cntvoff;
	unsigned cnthctl;
	unsigned cntkctl;
	unsigned long long cntp_cval;
	unsigned cntp_tval;
	unsigned cntp_ctl;
	unsigned long long cntv_cval;
	unsigned cntv_tval;
	unsigned cntv_ctl;
	unsigned long long cnthp_cval;
	unsigned cnthp_tval;
	unsigned cnthp_ctl;
} generic_timer_context;

typedef struct ns_cpu_context {
	unsigned int banked_cpu_regs[32];	/* Banked cpu registers */
	banked_cp15_context banked_cp15_regs;	/* Per cpu banked cp15 context */
	unsigned int pmon_regs[32];	/* Generic performance monitor registers */
	generic_timer_context cp15_timer_ctx;	/* Global counter registers if accessible in NS world */
	gic_cpu_context gic_cpu_ctx;	/* Per cpu GIC distributor and interface context */
	unsigned int endianess;	/* Per cpu endianess */
	unsigned int vfp_regs[34];	/* Dummy entry for VFP context. */
	unsigned int debug_regs[32];	/* Dummy entry for Debug context. TODO */
} cpu_context;

typedef struct ns_global_context {
	unsigned int gic_dist_if_regs[512];	/* GIC distributor context to be saved by the last cpu. */
	unsigned int generic_timer_regs[8];	/* Global timers if the NS world has access to them */
} global_context;

/*
 * Structure to preserve the OS mmu and stack state for swtich from OS to Switcher
 * context handler.
 */
typedef struct os_state {
	unsigned sctlr;
	unsigned dacr;
	unsigned ttbr0;
	unsigned nmrr;
	unsigned prrr;
} os_state;

/*
 * Top level structure to hold the complete context of a core in a cluster in
 * a multi-cluster system
 */
typedef struct core_context {
	/*
	 * Non-secure context save area
	 */
	cpu_context ns_cpu_ctx;

} core_context;

/*
 * Top level structure to hold the complete context of a cluster in a multi-
 * cluster system
 */
typedef struct cluster_context {
	core_context core[MAX_CORES];
	unsigned num_cores;
	global_context ns_cluster_ctx;
} cluster_context;

/*
 * Top level structure to hold the complete context of a multi cluster system
 */
typedef struct system_context {
	cluster_context cluster;
	unsigned num_clusters;
	unsigned warm_reset;
} system_context;

extern void context_save(unsigned, unsigned);
extern void context_restore(unsigned, unsigned);
extern void save_generic_timers(generic_timer_context *);
extern void restore_eagle_timers(generic_timer_context *);
extern void save_hyp_context(unsigned, unsigned);
extern void restore_hyp_context(unsigned, unsigned);
extern void save_vfp(unsigned *);
extern void restore_vfp(unsigned *);
extern void enable_trigger(unsigned);
#endif				/* __CONTEXT_H__ */