xref: /titanic_50/usr/src/psm/stand/boot/sparc/common/sun4dep.c (revision d8260c5137b0926a897a3763eca8997922ad7401)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <sys/types.h>
29 #include <sys/param.h>
30 #include <sys/fcntl.h>
31 #include <sys/promif.h>
32 #include <sys/prom_plat.h>
33 #include <sys/salib.h>
34 
35 int pagesize = PAGESIZE;
36 
37 void
38 fiximp(void)
39 {
40 	extern int use_align;
41 
42 	use_align = 1;
43 }
44 
45 void
46 setup_aux(void)
47 {
48 	pnode_t node;
49 	/* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */
50 	static char cpubuf[5 * OBP_MAXDRVNAME];
51 	char dname[OBP_MAXDRVNAME];
52 	extern uint_t icache_flush;
53 	extern char *cpulist;
54 
55 	icache_flush = 1;
56 	node = prom_findnode_bydevtype(prom_rootnode(), OBP_CPU);
57 	if (node != OBP_NONODE && node != OBP_BADNODE) {
58 		int nlen, clen, i;
59 
60 		if ((nlen = prom_getproplen(node, OBP_NAME)) <= 0 ||
61 		    nlen > sizeof (cpubuf) ||
62 		    prom_getprop(node, OBP_NAME, cpubuf) <= 0)
63 			prom_panic("no name in cpu node");
64 
65 		/* nlen includes the terminating null character */
66 
67 		/*
68 		 * For the CMT case, need check the parent "core"
69 		 * node for the compatible property.
70 		 */
71 		if ((clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 ||
72 		    ((node = prom_parentnode(node)) != OBP_NONODE &&
73 		    node != OBP_BADNODE &&
74 		    (clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0 &&
75 		    prom_getprop(node, OBP_DEVICETYPE, dname) > 0 &&
76 		    strcmp(dname, "core") == 0)) {
77 			if ((clen + nlen) > sizeof (cpubuf))
78 				prom_panic("cpu node \"compatible\" too long");
79 			/* read in compatible, leaving space for ':' */
80 			if (prom_getprop(node, OBP_COMPATIBLE,
81 			    &cpubuf[nlen]) != clen)
82 				prom_panic("cpu node \"compatible\" error");
83 			clen += nlen;	/* total length */
84 			/* convert all null characters to ':' */
85 			clen--;	/* except the final one... */
86 			for (i = 0; i < clen; i++)
87 				if (cpubuf[i] == '\0')
88 					cpubuf[i] = ':';
89 		}
90 		cpulist = cpubuf;
91 	} else
92 		prom_panic("no cpu node");
93 }
94 
95 
96 #ifdef MPSAS
97 
98 void sas_symtab(int start, int end);
99 extern int sas_command(char *cmdstr);
100 
101 /*
102  * SAS support - inform SAS of new symbols being dynamically added
103  * during simulation via the first standalone.
104  */
105 
106 #ifndef	BUFSIZ
107 #define	BUFSIZ	1024		/* for cmd string buffer allocation */
108 #endif
109 
110 int	sas_symdebug = 0;		/* SAS support */
111 
112 void
113 sas_symtab(int start, int end)
114 {
115 	char *addstr = "symtab add $LD_KERNEL_PATH/%s%s 0x%x 0x%x\n";
116 	char *file, *prefix, cmdstr[BUFSIZ];
117 	extern char filename[];
118 
119 	file = filename;
120 	prefix = *file == '/' ? "../../.." : "";
121 
122 	(void) sprintf(cmdstr, addstr, prefix, file, start, end);
123 
124 	/* add the symbol table */
125 	if (sas_symdebug) (void) printf("sas_symtab: %s", cmdstr);
126 	sas_command(cmdstr);
127 }
128 
129 void
130 sas_bpts()
131 {
132 	sas_command("file $KERN_SCRIPT_FILE\n");
133 }
134 #endif	/* MPSAS */
135 
136 /*
137  * Allocate a region of virtual address space, unmapped.
138  */
139 caddr_t
140 resalloc_virt(caddr_t virt, size_t size)
141 {
142 	if (prom_claim_virt(size, virt) == (caddr_t)-1)
143 		return ((caddr_t)0);
144 
145 	return (virt);
146 }
147