Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * Hypervisor Software File: strand.h | |
5 | * | |
6 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
7 | * | |
8 | * - Do no alter or remove copyright notices | |
9 | * | |
10 | * - Redistribution and use of this software in source and binary forms, with | |
11 | * or without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistribution of source code must retain the above copyright notice, | |
15 | * this list of conditions and the following disclaimer. | |
16 | * | |
17 | * - Redistribution in binary form must reproduce the above copyright notice, | |
18 | * this list of conditions and the following disclaimer in the | |
19 | * documentation and/or other materials provided with the distribution. | |
20 | * | |
21 | * Neither the name of Sun Microsystems, Inc. or the names of contributors | |
22 | * may be used to endorse or promote products derived from this software | |
23 | * without specific prior written permission. | |
24 | * | |
25 | * This software is provided "AS IS," without a warranty of any kind. | |
26 | * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
27 | * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
28 | * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
29 | * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
30 | * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
31 | * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
32 | * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
33 | * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
34 | * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
35 | * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
36 | * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
37 | * | |
38 | * You acknowledge that this software is not designed, licensed or | |
39 | * intended for use in the design, construction, operation or maintenance of | |
40 | * any nuclear facility. | |
41 | * | |
42 | * ========== Copyright Header End ============================================ | |
43 | */ | |
44 | /* | |
45 | * Copyright 2007 Sun Microsystems, Inc. All rights reserved. | |
46 | * Use is subject to license terms. | |
47 | */ | |
48 | ||
49 | #ifndef _PLATFORM_STRAND_H | |
50 | #define _PLATFORM_STRAND_H | |
51 | ||
52 | #pragma ident "@(#)strand.h 1.3 07/07/25 SMI" | |
53 | ||
54 | #ifdef __cplusplus | |
55 | extern "C" { | |
56 | #endif | |
57 | ||
58 | #include <config.h> | |
59 | #include <cyclic.h> | |
60 | ||
61 | /* | |
62 | * Size of svc code's per-cpu scratch area in 64-bit words | |
63 | */ | |
64 | #define NSVCSCRATCHREGS 6 | |
65 | ||
66 | ||
67 | /* | |
68 | * Number of per-cpu scratch locations | |
69 | */ | |
70 | #define NCPUSCRATCH 8 | |
71 | ||
72 | ||
73 | /* | |
74 | * Stack depth for each cpu | |
75 | */ | |
76 | #define STACKDEPTH 12 | |
77 | ||
78 | #ifndef _ASM | |
79 | ||
80 | typedef uint64_t cpuset_t; | |
81 | ||
82 | /* | |
83 | * Structures for saving watchdog failure state | |
84 | */ | |
85 | struct trapstate { | |
86 | uint64_t htstate; | |
87 | uint64_t tstate; | |
88 | uint64_t tt; | |
89 | uint64_t tpc; | |
90 | uint64_t tnpc; | |
91 | }; | |
92 | ||
93 | struct trapglobals { | |
94 | uint64_t g[8]; | |
95 | }; | |
96 | ||
97 | /* | |
98 | * Stack support | |
99 | * | |
100 | * Each CPU has a very simple stack. Only two operations are supported: | |
101 | * Push and Pop. In the event the stack gets full or under poped, hv will | |
102 | * abort. | |
103 | */ | |
104 | struct stack { | |
105 | uint64_t top; /* top of the stack */ | |
106 | uint64_t val[STACKDEPTH]; /* reg value */ | |
107 | }; | |
108 | ||
109 | #if NSTRANDS > 256 | |
110 | #error The strand id field is encoded in an 8bit value | |
111 | #error for more than 256 strands this needs to have its type changed | |
112 | #endif | |
113 | ||
114 | struct strand { | |
115 | uint8_t id; /* physical strand number */ | |
116 | struct config *configp; | |
117 | ||
118 | /* | |
119 | * This list is used to assign work to this strand. | |
120 | * The current_slot points to the slot action in progress | |
121 | * We only allow the local strand to manipulate its slots | |
122 | * which means (along as interrupts are off) we've no need | |
123 | * for locks around this structure. | |
124 | */ | |
125 | uint16_t current_slot; | |
126 | struct sched_slot slot[NUM_SCHED_SLOTS]; | |
127 | ||
128 | /* | |
129 | * This is the HV strand X-Call mailbox. | |
130 | * This should evolve into an LDC channel with endpoints between | |
131 | * each of the strands, (an N*N matrix), and a mondo queue indicating | |
132 | * which incomming endpoints need servicing, but that happens when | |
133 | * we assign guest0 as the HV's context - later. | |
134 | */ | |
135 | struct xcall_mbox xc_mb; | |
136 | uint64_t hv_txmondo[8]; | |
137 | uint64_t hv_rxmondo[8]; | |
138 | ||
139 | /* | |
140 | * Initialisation support .. FIXME .. we could use scratch | |
141 | * values instead as these are only used at the beginning of time | |
142 | */ | |
143 | uint64_t scrub_basepa; | |
144 | uint64_t scrub_size; | |
145 | ||
146 | /* | |
147 | * The mini-stack used for the PUSH & POP macros. | |
148 | */ | |
149 | struct mini_stack mini_stack; | |
150 | ||
151 | uint64_t scr[NCPUSCRATCH]; /* scratch space */ | |
152 | ||
153 | /* | |
154 | * hstick interrupt support | |
155 | */ | |
156 | struct cyclic cyclic; | |
157 | ||
158 | /* | |
159 | * Error handling support | |
160 | */ | |
161 | ||
162 | /* | |
163 | * support for when we get a UE with TSTATE.GL == GL | |
164 | */ | |
165 | uint64_t ue_tmp1; | |
166 | uint64_t ue_tmp2; | |
167 | uint64_t ue_tmp3; | |
168 | struct trapglobals ue_globals[MAXTL]; | |
169 | uint64_t err_seq_no; /* unique sequence # */ | |
170 | uint32_t err_flag; /* error handling flags */ | |
171 | void *strand_diag_buf[MAXTL]; | |
172 | void *strand_sun4v_rprt_buf[MAXTL]; | |
173 | void *strand_err_table_entry[MAXTL]; | |
174 | uint64_t strand_err_isfsr[MAXTL]; | |
175 | uint64_t strand_err_dsfsr[MAXTL]; | |
176 | uint64_t strand_err_dsfar[MAXTL]; | |
177 | uint64_t strand_err_desr[MAXTL]; | |
178 | uint64_t strand_err_dfesr[MAXTL]; | |
179 | uint64_t strand_err_return_addr[MAXTL]; | |
180 | uint64_t io_prot; /* i/o error protection flag */ | |
181 | uint64_t io_error; /* i/o error flag */ | |
182 | uint64_t nrpending; /* pending non-resumable on this CPU */ | |
183 | uint64_t rerouted_cpu; /* rerouting CPU -or- CPU in error */ | |
184 | uint64_t rerouted_ehdl; /* EHDL rerouted to this CPU */ | |
185 | uint64_t rerouted_addr; /* PA rerouted to this CPU */ | |
186 | uint64_t rerouted_stick; /* %stick rerouted to this CPU */ | |
187 | uint64_t rerouted_attr; /* ATTR rerouted to this CPU */ | |
188 | uint64_t abort_pc; /* %pc of hvabort caller */ | |
189 | uint64_t err_globals_saved; /* globals saved OK on TL == MAXGL */ | |
190 | ||
191 | /* | |
192 | * Config | |
193 | */ | |
194 | uint64_t dtnode; | |
195 | ||
196 | /* | |
197 | * Saved failure state | |
198 | */ | |
199 | uint64_t fail_tl; | |
200 | uint64_t fail_gl; | |
201 | struct trapstate trapstate[MAXTL]; | |
202 | struct trapglobals trapglobals[MAXGL]; | |
203 | ||
204 | /* | |
205 | * save a "clean" copy of the MRA data: | |
206 | * | |
207 | * mra[0:3]: z_tsb_cfg | |
208 | * mra[4:7]: nz_tsb_cfg | |
209 | */ | |
210 | uint64_t mra[MAX_NMRA]; | |
211 | ||
212 | /* | |
213 | * This is the real stack used for the C environment | |
214 | */ | |
215 | uint64_t strand_stack[STRAND_STACK_SIZE / sizeof (uint64_t)]; | |
216 | }; | |
217 | ||
218 | #endif /* !_ASM */ | |
219 | ||
220 | /* | |
221 | * struct cpu.wip: Work In Progress | |
222 | */ | |
223 | #define CPU_WIP_CE (1 << 0) /* ce processing */ | |
224 | #define CPU_WIP_UE (1 << 1) /* ue processing */ | |
225 | #define CPU_WIP_CI (1 << 2) /* cmpr interrupt processing */ | |
226 | #define CPU_WIP_ERRPOLL (1 << 4) /* polling for errors */ | |
227 | ||
228 | #ifdef __cplusplus | |
229 | } | |
230 | #endif | |
231 | ||
232 | #endif /* _PLATFORM_STRAND_H */ |