summaryrefslogtreecommitdiff
path: root/big-little/include/context.h
blob: 38e591aeb8d99ecb712872c4444adffe6c1dd355 (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
/*
 * 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 {
        unsigned vcr;
        unsigned eacr;
        unsigned claim;
        unsigned claimclr;
        unsigned dtrrx_e;
        unsigned dtrtx_e;
        unsigned dscr_e;
        unsigned wfar;
        unsigned bvr[16];
        unsigned bcr[16];
        unsigned wvr[16];
        unsigned wcr[16];
        unsigned bxvr[16];
} debug_context_t;              /* total size 88 * 4 = 352 bytes */

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 */
	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. */
	debug_context_t debug_ctx;	/* Entry for Debug context. */
} 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;

/*
 * Constants to indicate whether context manipulation is done
 * as per a hotplug or cluster switch request.
 */
#define OP_TYPE_SWITCH 0x1
#define OP_TYPE_HP     0x2

extern unsigned find_restore_op_type(void);
extern void save_context(unsigned, unsigned);
extern void restore_context(unsigned, unsigned);
extern void save_generic_timers(generic_timer_context *);
extern void restore_eagle_timers(generic_timer_context *);
extern void save_vfp(unsigned *);
extern void restore_vfp(unsigned *);
extern void enable_trigger(unsigned);
#endif				/* __CONTEXT_H__ */