Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / hypervisor / src / greatlakes / huron / src / init_huron.c
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: init_huron.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 "@(#)init_huron.c 1.2 07/06/06 SMI"
50
51#include <stdarg.h>
52
53#include <sys/htypes.h>
54#include <hypervisor.h>
55#include <traps.h>
56#include <cache.h>
57#include <mmu.h>
58#include <sun4v/asi.h>
59#include <sun4v/errs_defs.h>
60#include <vdev_ops.h>
61#include <vdev_intr.h>
62#include <ncs.h>
63#include <cyclic.h>
64#include <config.h>
65#include <vcpu.h>
66#include <strand.h>
67#include <guest.h>
68#include <memory.h>
69#include <pcie.h>
70#include <support.h>
71#include <fpga.h>
72#include <svc.h>
73#include <ldc.h>
74#include <hvctl.h>
75#include <md.h>
76#include <abort.h>
77#include <proto.h>
78#ifdef CONFIG_PIU
79#include <piu.h>
80#endif
81
82#ifdef CONFIG_PIU
83extern const struct piu_cookie piu_dev[];
84void c_piu_leaf_soft_reset(const struct piu_cookie *, int root);
85#endif
86
87#ifdef CONFIG_CRYPTO
88static void init_rng(void);
89extern void init_mau_crypto_units(void);
90extern void init_cwq_crypto_units(void);
91#endif
92
93/*
94 * FIXME: This needs to be moved into a platform
95 * specific file.
96 */
97void
98reloc_plat_devops()
99{
100 extern devopsvec_t vdev_ops;
101#ifdef CONFIG_PIU /* { */
102 extern devopsvec_t piu_dev_ops;
103 extern devopsvec_t piu_int_ops;
104 extern devopsvec_t piu_msi_ops;
105 extern devopsvec_t piu_err_int_ops;
106#ifdef CONFIG_FPGA_UART
107 extern devopsvec_t fpga_uart_ops;
108#endif /* CONFIG_FPGA_UART */
109#endif /* } */
110 extern devopsvec_t niu_ops;
111 extern devopsvec_t cdev_ops;
112
113 reloc_devopsvec(&vdev_ops);
114#ifdef CONFIG_PIU
115 reloc_devopsvec(&piu_dev_ops);
116 reloc_devopsvec(&piu_int_ops);
117 reloc_devopsvec(&piu_msi_ops);
118 reloc_devopsvec(&piu_err_int_ops);
119#ifdef CONFIG_FPGA_UART
120 reloc_devopsvec(&fpga_uart_ops);
121#endif /* CONFIG_FPGA_UART */
122#endif
123 reloc_devopsvec(&niu_ops);
124 reloc_devopsvec(&cdev_ops);
125}
126
127#ifdef CONFIG_CRYPTO
128static void
129init_rng(void)
130{
131 rng_t *rngp;
132
133 config.config_m.rng = &rng;
134
135 rngp = (rng_t *)config.config_m.rng;
136
137 rngp->lock = 0;
138 rngp->ctl.rc_state = RNG_STATE_ERROR;
139 rngp->ctl.rc_guestid = -1;
140}
141#endif
142
143void
144init_plat_hook(void)
145{
146#ifdef CONFIG_CRYPTO
147 init_mau_crypto_units();
148 init_cwq_crypto_units();
149 init_rng();
150#endif /* CONFIG_CRYPTO */
151}