xref: /titanic_44/usr/src/psm/stand/boot/sparc/common/sun4dep.c (revision db8b037b5616a366b7dfdc01ef9552f02f9adfdd)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/types.h>
27 #include <sys/param.h>
28 #include <sys/fcntl.h>
29 #include <sys/promif.h>
30 #include <sys/prom_plat.h>
31 #include <sys/salib.h>
32 
33 int pagesize = PAGESIZE;
34 
35 void
36 fiximp(void)
37 {
38 	extern int use_align;
39 
40 	use_align = 1;
41 }
42 
43 void
44 setup_aux(void)
45 {
46 	pnode_t node;
47 	/* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */
48 	static char cpubuf[5 * OBP_MAXDRVNAME];
49 	char dname[OBP_MAXDRVNAME];
50 	extern uint_t icache_flush;
51 	extern char *cpulist;
52 
53 	icache_flush = 1;
54 	node = prom_findnode_bydevtype(prom_rootnode(), OBP_CPU);
55 	if (node != OBP_NONODE && node != OBP_BADNODE) {
56 		int nlen, clen, i;
57 
58 		if ((nlen = prom_getproplen(node, OBP_NAME)) <= 0 ||
59 		    nlen > sizeof (cpubuf) ||
60 		    prom_getprop(node, OBP_NAME, cpubuf) <= 0)
61 			prom_panic("no name in cpu node");
62 
63 		/* nlen includes the terminating null character */
64 
65 		/*
66 		 * For the CMT case, need check the parent "core"
67 		 * node for the compatible property.
68 		 */
69 		if ((clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 ||
70 		    ((node = prom_parentnode(node)) != OBP_NONODE &&
71 		    node != OBP_BADNODE &&
72 		    (clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 &&
73 		    prom_getprop(node, OBP_DEVICETYPE, dname) > 0 &&
74 		    strcmp(dname, "core") == 0)) {
75 			if ((clen + nlen) > sizeof (cpubuf))
76 				prom_panic("cpu node \"compatible\" too long");
77 			/* read in compatible, leaving space for ':' */
78 			if (prom_getprop(node, OBP_COMPATIBLE,
79 			    &cpubuf[nlen]) != clen)
80 				prom_panic("cpu node \"compatible\" error");
81 			clen += nlen;	/* total length */
82 			/* convert all null characters to ':' */
83 			clen--;	/* except the final one... */
84 			for (i = 0; i < clen; i++)
85 				if (cpubuf[i] == '\0')
86 					cpubuf[i] = ':';
87 		}
88 		cpulist = cpubuf;
89 	} else
90 		prom_panic("no cpu node");
91 }
92 
93 /*
94  * Allocate a region of virtual address space, unmapped.
95  */
96 caddr_t
97 resalloc_virt(caddr_t virt, size_t size)
98 {
99 	if (prom_claim_virt(size, virt) == (caddr_t)-1)
100 		return ((caddr_t)0);
101 
102 	return (virt);
103 }
104