xref: /onnv-gate/usr/src/psm/stand/boot/sparc/common/sun4dep.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include <sys/types.h>
30*0Sstevel@tonic-gate #include <sys/param.h>
31*0Sstevel@tonic-gate #include <sys/fcntl.h>
32*0Sstevel@tonic-gate #include <sys/promif.h>
33*0Sstevel@tonic-gate #include <sys/prom_plat.h>
34*0Sstevel@tonic-gate #include <sys/salib.h>
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate int pagesize = PAGESIZE;
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate void
39*0Sstevel@tonic-gate fiximp(void)
40*0Sstevel@tonic-gate {
41*0Sstevel@tonic-gate 	extern int use_align;
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate 	use_align = 1;
44*0Sstevel@tonic-gate }
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate void
47*0Sstevel@tonic-gate setup_aux(void)
48*0Sstevel@tonic-gate {
49*0Sstevel@tonic-gate 	dnode_t node;
50*0Sstevel@tonic-gate 	/* big enough for OBP_NAME and for a reasonably sized OBP_COMPATIBLE. */
51*0Sstevel@tonic-gate 	static char cpubuf[5 * OBP_MAXDRVNAME];
52*0Sstevel@tonic-gate 	extern uint_t icache_flush;
53*0Sstevel@tonic-gate 	extern char *cpulist;
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate 	icache_flush = 1;
56*0Sstevel@tonic-gate 	node = prom_findnode_bydevtype(prom_rootnode(), OBP_CPU);
57*0Sstevel@tonic-gate 	if (node != OBP_NONODE && node != OBP_BADNODE) {
58*0Sstevel@tonic-gate 		int nlen, clen, i;
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate 		if ((nlen = prom_getproplen(node, OBP_NAME)) <= 0 ||
61*0Sstevel@tonic-gate 		    nlen > sizeof (cpubuf) ||
62*0Sstevel@tonic-gate 		    prom_getprop(node, OBP_NAME, cpubuf) <= 0)
63*0Sstevel@tonic-gate 			prom_panic("no name in cpu node");
64*0Sstevel@tonic-gate 		/* nlen includes the terminating null character */
65*0Sstevel@tonic-gate 		if ((clen = prom_getproplen(node, OBP_COMPATIBLE)) > 0) {
66*0Sstevel@tonic-gate 			if ((clen + nlen) > sizeof (cpubuf))
67*0Sstevel@tonic-gate 				prom_panic("cpu node \"compatible\" too long");
68*0Sstevel@tonic-gate 			/* read in compatible, leaving space for ':' */
69*0Sstevel@tonic-gate 			if (prom_getprop(node, OBP_COMPATIBLE,
70*0Sstevel@tonic-gate 			    &cpubuf[nlen]) != clen)
71*0Sstevel@tonic-gate 				prom_panic("cpu node \"compatible\" error");
72*0Sstevel@tonic-gate 			clen += nlen;	/* total length */
73*0Sstevel@tonic-gate 			/* convert all null characters to ':' */
74*0Sstevel@tonic-gate 			clen--;	/* except the final one... */
75*0Sstevel@tonic-gate 			for (i = 0; i < clen; i++)
76*0Sstevel@tonic-gate 				if (cpubuf[i] == '\0')
77*0Sstevel@tonic-gate 					cpubuf[i] = ':';
78*0Sstevel@tonic-gate 		}
79*0Sstevel@tonic-gate 		cpulist = cpubuf;
80*0Sstevel@tonic-gate 	} else
81*0Sstevel@tonic-gate 		prom_panic("no cpu node");
82*0Sstevel@tonic-gate }
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate #ifdef MPSAS
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate void sas_symtab(int start, int end);
88*0Sstevel@tonic-gate extern int sas_command(char *cmdstr);
89*0Sstevel@tonic-gate 
90*0Sstevel@tonic-gate /*
91*0Sstevel@tonic-gate  * SAS support - inform SAS of new symbols being dynamically added
92*0Sstevel@tonic-gate  * during simulation via the first standalone.
93*0Sstevel@tonic-gate  */
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate #ifndef	BUFSIZ
96*0Sstevel@tonic-gate #define	BUFSIZ	1024		/* for cmd string buffer allocation */
97*0Sstevel@tonic-gate #endif
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate int	sas_symdebug = 0;		/* SAS support */
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate void
102*0Sstevel@tonic-gate sas_symtab(int start, int end)
103*0Sstevel@tonic-gate {
104*0Sstevel@tonic-gate 	char *addstr = "symtab add $LD_KERNEL_PATH/%s%s 0x%x 0x%x\n";
105*0Sstevel@tonic-gate 	char *file, *prefix, cmdstr[BUFSIZ];
106*0Sstevel@tonic-gate 	extern char filename[];
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate 	file = filename;
109*0Sstevel@tonic-gate 	prefix = *file == '/' ? "../../.." : "";
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate 	(void) sprintf(cmdstr, addstr, prefix, file, start, end);
112*0Sstevel@tonic-gate 
113*0Sstevel@tonic-gate 	/* add the symbol table */
114*0Sstevel@tonic-gate 	if (sas_symdebug) (void) printf("sas_symtab: %s", cmdstr);
115*0Sstevel@tonic-gate 	sas_command(cmdstr);
116*0Sstevel@tonic-gate }
117*0Sstevel@tonic-gate 
118*0Sstevel@tonic-gate void
119*0Sstevel@tonic-gate sas_bpts()
120*0Sstevel@tonic-gate {
121*0Sstevel@tonic-gate 	sas_command("file $KERN_SCRIPT_FILE\n");
122*0Sstevel@tonic-gate }
123*0Sstevel@tonic-gate #endif	/* MPSAS */
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate /*
126*0Sstevel@tonic-gate  * Allocate a region of virtual address space, unmapped.
127*0Sstevel@tonic-gate  */
128*0Sstevel@tonic-gate caddr_t
129*0Sstevel@tonic-gate resalloc_virt(caddr_t virt, size_t size)
130*0Sstevel@tonic-gate {
131*0Sstevel@tonic-gate 	if (prom_claim_virt(size, virt) == (caddr_t)-1)
132*0Sstevel@tonic-gate 		return ((caddr_t)0);
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate 	return (virt);
135*0Sstevel@tonic-gate }
136