xref: /titanic_50/usr/src/psm/promif/ieee1275/sun4u/prom_tlb.c (revision abc79d9dd51e98eafb6fc25b4a0b4f66bef40b00)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <sys/promif.h>
27 #include <sys/promimpl.h>
28 
29 /*
30  * prom_itlb_load, prom_dtlb_load:
31  *
32  * Manage the Spitfire TLB. Returns 0 if successful, -1 otherwise.
33  * Flush the address in context zero mapped by tte_data and virt,
34  * and load the {i,d} tlb entry index with tte_data and virt.
35  */
36 
37 int
38 prom_itlb_load(int index, unsigned long long tte_data, caddr_t virt)
39 {
40 	cell_t ci[9];
41 	int rv;
42 	ihandle_t immu = prom_mmu_ihandle();
43 
44 	if ((immu == (ihandle_t)-1))
45 		return (-1);
46 
47 	ci[0] = p1275_ptr2cell("call-method");	/* Service name */
48 	ci[1] = (cell_t)5;			/* #argument cells */
49 	ci[2] = (cell_t)1;			/* #result cells */
50 	ci[3] = p1275_ptr2cell("SUNW,itlb-load"); /* Arg1: method name */
51 	ci[4] = p1275_ihandle2cell(immu);	/* Arg2: mmu ihandle */
52 	ci[5] = p1275_ptr2cell(virt);		/* Arg3: SA1: virt */
53 	ci[6] = (cell_t)tte_data;		/* Arg4: SA2: tte_data */
54 	ci[7] = p1275_int2cell(index);		/* Arg5: SA3: index */
55 
56 	promif_preprom();
57 	rv = p1275_cif_handler(&ci);
58 	promif_postprom();
59 
60 	if (rv != 0)
61 		return (-1);
62 	if (ci[8] != 0)				/* Res1: Catch result */
63 		return (-1);
64 	return (0);
65 }
66 
67 int
68 prom_dtlb_load(int index, unsigned long long tte_data, caddr_t virt)
69 {
70 	cell_t ci[9];
71 	int rv;
72 	ihandle_t immu = prom_mmu_ihandle();
73 
74 	if ((immu == (ihandle_t)-1))
75 		return (-1);
76 
77 	ci[0] = p1275_ptr2cell("call-method");	/* Service name */
78 	ci[1] = (cell_t)5;			/* #argument cells */
79 	ci[2] = (cell_t)1;			/* #result cells */
80 	ci[3] = p1275_ptr2cell("SUNW,dtlb-load"); /* Arg1: method name */
81 	ci[4] = p1275_ihandle2cell(immu);	/* Arg2: mmu ihandle */
82 	ci[5] = p1275_ptr2cell(virt);		/* Arg3: SA1: virt */
83 	ci[6] = (cell_t)tte_data;		/* Arg4: SA2: tte_data */
84 	ci[7] = p1275_int2cell(index);		/* Arg5: SA3: index */
85 
86 	promif_preprom();
87 	rv = p1275_cif_handler(&ci);
88 	promif_postprom();
89 
90 	if (rv != 0)
91 		return (-1);
92 	if (ci[8] != 0)				/* Res1: Catch result */
93 		return (-1);
94 	return (0);
95 }
96