Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / hypervisor / src / greatlakes / ontario / src / config.c
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: config.c
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#pragma ident "@(#)config.c 1.31 07/05/03 SMI"
50
51/*
52 * Guest configuration
53 */
54
55#include <sys/htypes.h>
56#include <hypervisor.h>
57#include <traps.h>
58#include <cache.h>
59#include <mmu.h>
60#include <vdev_ops.h>
61#include <vdev_intr.h>
62#include <config.h>
63#include <ncs.h>
64#include <cyclic.h>
65#include <vcpu.h>
66#include <strand.h>
67#include <guest.h>
68#include <memory.h>
69#include <pcie.h>
70#include <fire.h>
71#include <ldc.h>
72
73#define DEVOPS(n) DEVOPS_##n
74
75#define _VINO_HANDLER(n) \
76 (n), (n), (n), (n), (n), (n), (n), (n), \
77 (n), (n), (n), (n), (n), (n), (n), (n), \
78 (n), (n), (n), (n), (n), (n), (n), (n), \
79 (n), (n), (n), (n), (n), (n), (n), (n), \
80 (n), (n), (n), (n), (n), (n), (n), (n), \
81 (n), (n), (n), (n), (n), (n), (n), (n), \
82 (n), (n), (n), (n), (n), (n), (n), (n), \
83 (n), (n), (n), (n), (n), (n), (n), (n)
84
85#define VINO_HANDLER(n) _VINO_HANDLER(DEVOPS_##n)
86
87extern void vdev_devino2vino(void);
88extern void vdev_intr_getvalid(void);
89extern void vdev_intr_setvalid(void);
90extern void vdev_intr_settarget(void);
91extern void vdev_intr_gettarget(void);
92extern void vdev_intr_getstate(void);
93extern void vdev_intr_setstate(void);
94
95extern void ldc_vintr_getcookie(void);
96extern void ldc_vintr_setcookie(void);
97extern void ldc_vintr_getvalid(void);
98extern void ldc_vintr_setvalid(void);
99extern void ldc_vintr_gettarget(void);
100extern void ldc_vintr_settarget(void);
101extern void ldc_vintr_getstate(void);
102extern void ldc_vintr_setstate(void);
103
104#if defined(CONFIG_FIRE)
105
106extern const uint64_t fire_a_iotsb;
107extern const uint64_t fire_a_equeue;
108extern const uint64_t fire_b_iotsb;
109extern const uint64_t *fire_b_equeue;
110extern const uint64_t fire_virtual_intmap;
111
112#define FIRE_EQ(leaf, n) \
113 .base = (uint64_t *)&fire_##leaf##_equeue+(n*0x400), \
114 .eqmask = FIRE_EQMASK
115
116const struct fire_msi_cookie fire_msi[NFIRELEAVES] = {
117 {
118 .fire = FIRE_DEV_COOKIE(A),
119 .eq = {
120 { FIRE_EQ(a, 0) }, { FIRE_EQ(a, 1) },
121 { FIRE_EQ(a, 2) }, { FIRE_EQ(a, 3) },
122 { FIRE_EQ(a, 4) }, { FIRE_EQ(a, 5) },
123 { FIRE_EQ(a, 6) }, { FIRE_EQ(a, 7) },
124 { FIRE_EQ(a, 8) }, { FIRE_EQ(a, 9) },
125 { FIRE_EQ(a, 10) }, { FIRE_EQ(a, 11) },
126 { FIRE_EQ(a, 12) }, { FIRE_EQ(a, 13) },
127 { FIRE_EQ(a, 14) }, { FIRE_EQ(a, 15) },
128 { FIRE_EQ(a, 16) }, { FIRE_EQ(a, 17) },
129 { FIRE_EQ(a, 18) }, { FIRE_EQ(a, 19) },
130 { FIRE_EQ(a, 20) }, { FIRE_EQ(a, 21) },
131 { FIRE_EQ(a, 22) }, { FIRE_EQ(a, 23) },
132 { FIRE_EQ(a, 24) }, { FIRE_EQ(a, 25) },
133 { FIRE_EQ(a, 26) }, { FIRE_EQ(a, 27) },
134 { FIRE_EQ(a, 28) }, { FIRE_EQ(a, 29) },
135 { FIRE_EQ(a, 30) }, { FIRE_EQ(a, 31) },
136 { FIRE_EQ(a, 32) }, { FIRE_EQ(a, 33) },
137 { FIRE_EQ(a, 34) }, { FIRE_EQ(a, 35) },
138 },
139 },
140 {
141 .fire = FIRE_DEV_COOKIE(B),
142 .eq = {
143 { FIRE_EQ(b, 0) }, { FIRE_EQ(b, 1) },
144 { FIRE_EQ(b, 2) }, { FIRE_EQ(b, 3) },
145 { FIRE_EQ(b, 4) }, { FIRE_EQ(b, 5) },
146 { FIRE_EQ(b, 6) }, { FIRE_EQ(b, 7) },
147 { FIRE_EQ(b, 8) }, { FIRE_EQ(b, 9) },
148 { FIRE_EQ(b, 10) }, { FIRE_EQ(b, 11) },
149 { FIRE_EQ(b, 12) }, { FIRE_EQ(b, 13) },
150 { FIRE_EQ(b, 14) }, { FIRE_EQ(b, 15) },
151 { FIRE_EQ(b, 16) }, { FIRE_EQ(b, 17) },
152 { FIRE_EQ(b, 18) }, { FIRE_EQ(b, 19) },
153 { FIRE_EQ(b, 20) }, { FIRE_EQ(b, 21) },
154 { FIRE_EQ(b, 22) }, { FIRE_EQ(b, 23) },
155 { FIRE_EQ(b, 24) }, { FIRE_EQ(b, 25) },
156 { FIRE_EQ(b, 26) }, { FIRE_EQ(b, 27) },
157 { FIRE_EQ(b, 28) }, { FIRE_EQ(b, 29) },
158 { FIRE_EQ(b, 30) }, { FIRE_EQ(b, 31) },
159 { FIRE_EQ(b, 32) }, { FIRE_EQ(b, 33) },
160 { FIRE_EQ(b, 34) }, { FIRE_EQ(b, 35) },
161 },
162 }
163};
164
165const struct fire_err_cookie fire_err[NFIRELEAVES] = {
166 { .fire = FIRE_DEV_COOKIE(A), },
167 { .fire = FIRE_DEV_COOKIE(B), },
168};
169
170const fire_dev_t fire_dev[NFIRELEAVES] = {
171 { /* Fire Leaf AID = 0x1e */
172 .inomax = NFIREDEVINO,
173 .vino = AID2VINO(A),
174 .handle = AID2HANDLE(A),
175 .jbus = AID2JBUS(A),
176 .intclr = AID2INTCLR(A),
177 .intmap = AID2INTMAP(A),
178 .intmap_other = AID2INTMAP(B),
179 .virtual_intmap = (void *)&fire_virtual_intmap,
180 .mmu = AID2MMU(A),
181 .pcie = AID2PCIE(A),
182 .cfg = AID2PCIECFG(A),
183 .eqctlset = AID2PCIE(A)|FIRE_DLC_IMU_EQS_EQ_CTRL_SET(0),
184 .eqctlclr = AID2PCIE(A)|FIRE_DLC_IMU_EQS_EQ_CTRL_CLR(0),
185 .eqstate = AID2PCIE(A)|FIRE_DLC_IMU_EQS_EQ_STATE(0),
186 .eqtail = AID2PCIE(A)|FIRE_DLC_IMU_EQS_EQ_TAIL(0),
187 .eqhead = AID2PCIE(A)|FIRE_DLC_IMU_EQS_EQ_HEAD(0),
188 .msimap = AID2PCIE(A)|FIRE_DLC_IMU_RDS_MSI_MSI_MAPPING(0),
189 .msiclr = AID2PCIE(A)|FIRE_DLC_IMU_RDS_MSI_MSI_CLEAR_REG(0),
190 .msgmap = AID2PCIE(A)|FIRE_DLC_IMU_RDS_MESS_ERR_COR_MAPPING,
191 .msieqbase = (void *)&fire_a_equeue, /* RELOC */
192 .iotsb = (void *)&fire_a_iotsb, /* RELOC */
193 .msicookie = FIRE_MSI_COOKIE(A), /* RELOC */
194 .errcookie = FIRE_ERR_COOKIE(A), /* RELOC */
195 .perfregs = FIRE_PERF_REGS(A),
196 },
197 { /* Fire Leaf AID = 0x1f */
198 .inomax = NFIREDEVINO,
199 .vino = AID2VINO(B),
200 .handle = AID2HANDLE(B),
201 .jbus = AID2JBUS(B),
202 .intclr = AID2INTCLR(B),
203 .intmap = AID2INTMAP(B),
204 .intmap_other = AID2INTMAP(A),
205 .virtual_intmap = (void *)&fire_virtual_intmap,
206 .mmu = AID2MMU(B),
207 .pcie = AID2PCIE(B),
208 .cfg = AID2PCIECFG(B),
209 .eqctlset = AID2PCIE(B)|FIRE_DLC_IMU_EQS_EQ_CTRL_SET(0),
210 .eqctlclr = AID2PCIE(B)|FIRE_DLC_IMU_EQS_EQ_CTRL_CLR(0),
211 .eqstate = AID2PCIE(B)|FIRE_DLC_IMU_EQS_EQ_STATE(0),
212 .eqtail = AID2PCIE(B)|FIRE_DLC_IMU_EQS_EQ_TAIL(0),
213 .eqhead = AID2PCIE(B)|FIRE_DLC_IMU_EQS_EQ_HEAD(0),
214 .msimap = AID2PCIE(B)|FIRE_DLC_IMU_RDS_MSI_MSI_MAPPING(0),
215 .msiclr = AID2PCIE(B)|FIRE_DLC_IMU_RDS_MSI_MSI_CLEAR_REG(0),
216 .msgmap = AID2PCIE(B)|FIRE_DLC_IMU_RDS_MESS_ERR_COR_MAPPING,
217 .msieqbase = (void *)&fire_b_equeue, /* RELOC */
218 .iotsb = (void *)&fire_b_iotsb, /* RELOC */
219 .msicookie = FIRE_MSI_COOKIE(B), /* RELOC */
220 .errcookie = FIRE_ERR_COOKIE(B), /* RELOC */
221 .perfregs = FIRE_PERF_REGS(B),
222 }
223};
224
225#else /* !CONFIG_FIRE */
226
227#define VINO_HANDLER_FIRE(n) VINO_HANDLER(RESERVED)
228
229#endif /* !CONFIG_FIRE */
230
231
232struct config config;
233
234#ifdef CONFIG_CRYPTO
235struct mau maus[NMAUS];
236#endif /* CONFIG_CRYPTO */
237
238vcpu_t vcpus[NVCPUS];
239strand_t strands[NSTRANDS];
240mblock_t mblocks[NMBLOCKS];
241
242#ifdef CONFIG_PCIE
243pcie_device_t pcie_bus[NUM_PCIE_BUSSES];
244#endif
245
246struct guest guests[NGUESTS];
247
248uint8_t hcall_tables[NGUESTS * HCALL_TABLE_SIZE + L2_LINE_SIZE-1];
249struct ldc_endpoint hv_ldcs[MAX_HV_LDC_CHANNELS];
250struct sp_ldc_endpoint sp_ldcs[MAX_SP_LDC_CHANNELS];
251
252/* BEGIN CSTYLED */
253#pragma align 64 (cons_queues)
254struct guest_console_queues cons_queues[NGUESTS];
255/* END CSTYLED */
256
257struct devopsvec fire_dev_ops = { FIRE_DEV_OPS };
258struct devopsvec fire_int_ops = { FIRE_INT_OPS };
259struct devopsvec fire_msi_ops = { FIRE_MSI_OPS };
260struct devopsvec fire_err_int_ops = { FIRE_ERR_OPS };
261
262struct devopsvec vdev_ops = { VDEV_OPS };
263
264struct devopsvec cdev_ops = { CDEV_OPS };
265
266/*
267 * vino2inst and dev2inst arrays contain indexes
268 * into this struct devinst.
269 *
270 * vino2inst array is used to go from vINO => inst
271 *
272 * dev2inst array is used to go from devID => inst
273 */
274struct devinst devinstances[NDEV_INSTS] = {
275 { 0, 0 },
276 { .cookie = FIRE_DEV_COOKIE(A), .ops = &fire_dev_ops },
277 { .cookie = FIRE_DEV_COOKIE(B), .ops = &fire_dev_ops },
278
279 { .cookie = FIRE_DEV_COOKIE(A), .ops = &fire_int_ops },
280 { .cookie = FIRE_DEV_COOKIE(B), .ops = &fire_int_ops },
281
282 { .cookie = FIRE_DEV_COOKIE(A), .ops = &fire_msi_ops },
283 { .cookie = FIRE_DEV_COOKIE(B), .ops = &fire_msi_ops },
284
285 { .cookie = FIRE_DEV_COOKIE(A), .ops = &fire_err_int_ops },
286 { .cookie = FIRE_DEV_COOKIE(B), .ops = &fire_err_int_ops },
287
288 { .cookie = 0, .ops = &vdev_ops },
289
290 { .cookie = 0, .ops = &cdev_ops },
291
292 { 0, 0 },
293
294};
295
296const struct vino_pcie config_pcie_vinos = {
297 VINO_HANDLER_FIRE(A),
298 VINO_HANDLER_FIRE(B)
299};