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, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 1994-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
31
32 /*
33 * This service converts the given physical address into a text string,
34 * representing the name of the field-replacable part for the given
35 * physical address. In other words, it tells the kernel which chip got
36 * the (un)correctable ECC error, which info is hopefully relayed to the user!
37 */
38 int
prom_get_unum(int syn_code,unsigned long long physaddr,char * buf,uint_t buflen,int * ustrlen)39 prom_get_unum(int syn_code, unsigned long long physaddr, char *buf,
40 uint_t buflen, int *ustrlen)
41 {
42 cell_t ci[12];
43 int rv;
44 ihandle_t imemory = prom_memory_ihandle();
45
46 *ustrlen = -1;
47 if ((imemory == (ihandle_t)-1))
48 return (-1);
49
50 ci[0] = p1275_ptr2cell("call-method"); /* Service name */
51 ci[1] = (cell_t)7; /* #argument cells */
52 ci[2] = (cell_t)2; /* #result cells */
53 ci[3] = p1275_ptr2cell("SUNW,get-unumber"); /* Arg1: Method name */
54 ci[4] = p1275_ihandle2cell(imemory); /* Arg2: mem. ihandle */
55 ci[5] = p1275_uint2cell(buflen); /* Arg3: buflen */
56 ci[6] = p1275_ptr2cell(buf); /* Arg4: buf */
57 ci[7] = p1275_ull2cell_high(physaddr); /* Arg5: physhi */
58 ci[8] = p1275_ull2cell_low(physaddr); /* Arg6: physlo */
59 ci[9] = p1275_int2cell(syn_code); /* Arg7: bit # */
60 ci[10] = (cell_t)-1; /* ret1: catch result */
61 ci[11] = (cell_t)-1; /* ret2: length */
62
63 promif_preprom();
64 rv = p1275_cif_handler(&ci);
65 promif_postprom();
66
67 if (rv != 0)
68 return (rv);
69 if (p1275_cell2int(ci[10]) != 0) /* Res1: catch result */
70 return (-1); /* "SUNW,get-unumber" failed */
71 *ustrlen = p1275_cell2uint(ci[11]); /* Res2: unum str length */
72 return (0);
73 }
74