xref: /titanic_44/usr/src/psm/promif/ieee1275/common/prom_prop.c (revision fa9e4066f08beec538e775443c5be79dd423fcab)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*fa9e4066Sahrens  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * Stuff for mucking about with properties
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  * XXX: There is no distinction between intefer and non-integer properties
337c478bd9Sstevel@tonic-gate  * XXX: and no functions included for decoding properties.  As is, this
347c478bd9Sstevel@tonic-gate  * XXX: file is suitable for a big-endian machine, since properties are
357c478bd9Sstevel@tonic-gate  * XXX: encoded using an XDR-like property encoding mechanism, which is
367c478bd9Sstevel@tonic-gate  * XXX: big-endian native ordering.  To fix this, you need to add type-
377c478bd9Sstevel@tonic-gate  * XXX: sensitive decoding mechanisms and have the consumer of the data
387c478bd9Sstevel@tonic-gate  * XXX: decode the data, since only the consumer can claim to know the
397c478bd9Sstevel@tonic-gate  * XXX: the type of the data. (It can't be done automatically.)
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #include <sys/promif.h>
437c478bd9Sstevel@tonic-gate #include <sys/promimpl.h>
447c478bd9Sstevel@tonic-gate #include <sys/platform_module.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate static void prom_setprop_null(void);
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate  * prom_setprop_{enter,exit} are set to plat_setprop_{enter,exit} on
517c478bd9Sstevel@tonic-gate  * platforms which require access to the seeproms to be serialized.
527c478bd9Sstevel@tonic-gate  * Otherwise these default to null functions.  These functions must be
537c478bd9Sstevel@tonic-gate  * called before promif_preprom, since it can sleep and change CPU's,
547c478bd9Sstevel@tonic-gate  * thereby failing the assert in promif_postprom().
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate void (*prom_setprop_enter)(void) = prom_setprop_null;
577c478bd9Sstevel@tonic-gate void (*prom_setprop_exit)(void) = prom_setprop_null;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate int
prom_asr_export_len()607c478bd9Sstevel@tonic-gate prom_asr_export_len()
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate 	cell_t ci[4];
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,asr-export-len");	/* Service name */
657c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)0;			/* #argument cells */
667c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
677c478bd9Sstevel@tonic-gate 	ci[3] = (cell_t)-1;			/* Res1: Prime result */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate 	promif_preprom();
707c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
717c478bd9Sstevel@tonic-gate 	promif_postprom();
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[3]));		/* Res1: buf length */
747c478bd9Sstevel@tonic-gate }
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate int
prom_asr_list_keys_len()777c478bd9Sstevel@tonic-gate prom_asr_list_keys_len()
787c478bd9Sstevel@tonic-gate {
797c478bd9Sstevel@tonic-gate 	cell_t ci[4];
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,asr-list-keys-len");
827c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)0;			/* #argument cells */
837c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
847c478bd9Sstevel@tonic-gate 	ci[3] = (cell_t)-1;			/* Res1: Prime result */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 	promif_preprom();
877c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
887c478bd9Sstevel@tonic-gate 	promif_postprom();
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[3]));		/* Res1: buf length */
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate int
prom_asr_export(caddr_t value)947c478bd9Sstevel@tonic-gate prom_asr_export(caddr_t value)
957c478bd9Sstevel@tonic-gate {
967c478bd9Sstevel@tonic-gate 	int rv;
977c478bd9Sstevel@tonic-gate 	cell_t ci[5];
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,asr-export");	/* Service name */
1007c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1017c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
1027c478bd9Sstevel@tonic-gate 	ci[3] = p1275_ptr2cell(value);		/* Arg1: buffer address */
1037c478bd9Sstevel@tonic-gate 	ci[4] = -1;				/* Res1: buf len */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	promif_preprom();
1067c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1077c478bd9Sstevel@tonic-gate 	promif_postprom();
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate 	if (rv != 0)
1107c478bd9Sstevel@tonic-gate 		return (-1);
1117c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));		/* Res1: buf length */
1127c478bd9Sstevel@tonic-gate }
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate int
prom_asr_list_keys(caddr_t value)1157c478bd9Sstevel@tonic-gate prom_asr_list_keys(caddr_t value)
1167c478bd9Sstevel@tonic-gate {
1177c478bd9Sstevel@tonic-gate 	int rv;
1187c478bd9Sstevel@tonic-gate 	cell_t ci[5];
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,asr-list-keys");	/* Service name */
1217c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)1;			/* #argument cells */
1227c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
1237c478bd9Sstevel@tonic-gate 	ci[3] = p1275_ptr2cell(value);		/* Arg1: buffer address */
1247c478bd9Sstevel@tonic-gate 	ci[4] = -1;				/* Res1: buf len */
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 	promif_preprom();
1277c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1287c478bd9Sstevel@tonic-gate 	promif_postprom();
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	if (rv != 0)
1317c478bd9Sstevel@tonic-gate 		return (-1);
1327c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[4]));		/* Res1: buf length */
1337c478bd9Sstevel@tonic-gate }
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate int
prom_asr_disable(char * keystr,int keystr_len,char * reason,int reason_len)1367c478bd9Sstevel@tonic-gate prom_asr_disable(char *keystr, int keystr_len,
1377c478bd9Sstevel@tonic-gate     char *reason, int reason_len)
1387c478bd9Sstevel@tonic-gate {
1397c478bd9Sstevel@tonic-gate 	int rv;
1407c478bd9Sstevel@tonic-gate 	cell_t ci[5];
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,asr-disable");	/* Service name */
1437c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)4;			/* #argument cells */
1447c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)0;			/* #return cells */
1457c478bd9Sstevel@tonic-gate 	ci[3] = p1275_ptr2cell(keystr);		/* Arg1: key address */
1467c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(keystr_len);	/* Arg2: key len */
1477c478bd9Sstevel@tonic-gate 	ci[3] = p1275_ptr2cell(reason);		/* Arg1: reason address */
1487c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(reason_len);	/* Arg2: reason len */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate 	promif_preprom();
1517c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1527c478bd9Sstevel@tonic-gate 	promif_postprom();
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate 	return (rv);
1557c478bd9Sstevel@tonic-gate }
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate int
prom_asr_enable(char * keystr,int keystr_len)1587c478bd9Sstevel@tonic-gate prom_asr_enable(char *keystr, int keystr_len)
1597c478bd9Sstevel@tonic-gate {
1607c478bd9Sstevel@tonic-gate 	int rv;
1617c478bd9Sstevel@tonic-gate 	cell_t ci[5];
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("SUNW,asr-enable");	/* Service name */
1647c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)2;			/* #argument cells */
1657c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)0;			/* #return cells */
1667c478bd9Sstevel@tonic-gate 	ci[3] = p1275_ptr2cell(keystr);		/* Arg1: key address */
1677c478bd9Sstevel@tonic-gate 	ci[3] = p1275_int2cell(keystr_len);	/* Arg2: key len */
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate 	promif_preprom();
1707c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
1717c478bd9Sstevel@tonic-gate 	promif_postprom();
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate 	return (rv);
1747c478bd9Sstevel@tonic-gate }
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate static void
prom_setprop_null(void)1777c478bd9Sstevel@tonic-gate prom_setprop_null(void)
1787c478bd9Sstevel@tonic-gate {
1797c478bd9Sstevel@tonic-gate }
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate int
prom_getproplen(pnode_t nodeid,caddr_t name)182*fa9e4066Sahrens prom_getproplen(pnode_t nodeid, caddr_t name)
1837c478bd9Sstevel@tonic-gate {
1847c478bd9Sstevel@tonic-gate 	cell_t ci[6];
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("getproplen");	/* Service name */
1877c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)2;			/* #argument cells */
1887c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #return cells */
1897c478bd9Sstevel@tonic-gate 	ci[3] = p1275_phandle2cell((phandle_t)nodeid);	/* Arg1: package */
1907c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(name);		/* Arg2: Property name */
1917c478bd9Sstevel@tonic-gate 	ci[5] = (cell_t)-1;			/* Res1: Prime result */
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	promif_preprom();
1947c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
1957c478bd9Sstevel@tonic-gate 	promif_postprom();
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[5]));		/* Res1: Property length */
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate int
prom_getprop(pnode_t nodeid,caddr_t name,caddr_t value)202*fa9e4066Sahrens prom_getprop(pnode_t nodeid, caddr_t name, caddr_t value)
2037c478bd9Sstevel@tonic-gate {
2047c478bd9Sstevel@tonic-gate 	int len, rv;
2057c478bd9Sstevel@tonic-gate 	cell_t ci[8];
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	/*
2087c478bd9Sstevel@tonic-gate 	 * This function assumes the buffer is large enough to
2097c478bd9Sstevel@tonic-gate 	 * hold the result, so in 1275 mode, we pass in the length
2107c478bd9Sstevel@tonic-gate 	 * of the property as the length of the buffer, since we
2117c478bd9Sstevel@tonic-gate 	 * have no way of knowing the size of the buffer. Pre-1275
2127c478bd9Sstevel@tonic-gate 	 * OpenBoot(tm) PROMs did not have a bounded getprop.
2137c478bd9Sstevel@tonic-gate 	 *
2147c478bd9Sstevel@tonic-gate 	 * Note that we ignore the "length" result of the service.
2157c478bd9Sstevel@tonic-gate 	 */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	if ((len = prom_getproplen(nodeid, name)) <= 0)
2187c478bd9Sstevel@tonic-gate 		return (len);
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("getprop");	/* Service name */
2217c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)4;			/* #argument cells */
2227c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)0;			/* #result cells */
2237c478bd9Sstevel@tonic-gate 	ci[3] = p1275_phandle2cell((phandle_t)nodeid);	/* Arg1: package */
2247c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(name);		/* Arg2: property name */
2257c478bd9Sstevel@tonic-gate 	ci[5] = p1275_ptr2cell(value);		/* Arg3: buffer address */
2267c478bd9Sstevel@tonic-gate 	ci[6] = len;				/* Arg4: buf len (assumed) */
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	promif_preprom();
2297c478bd9Sstevel@tonic-gate 	rv = p1275_cif_handler(&ci);
2307c478bd9Sstevel@tonic-gate 	promif_postprom();
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	if (rv != 0)
2337c478bd9Sstevel@tonic-gate 		return (-1);
2347c478bd9Sstevel@tonic-gate 	return (len);				/* Return known length */
2357c478bd9Sstevel@tonic-gate }
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate int
prom_bounded_getprop(pnode_t nodeid,caddr_t name,caddr_t value,int len)238*fa9e4066Sahrens prom_bounded_getprop(pnode_t nodeid, caddr_t name, caddr_t value, int len)
2397c478bd9Sstevel@tonic-gate {
2407c478bd9Sstevel@tonic-gate 	cell_t ci[8];
2417c478bd9Sstevel@tonic-gate 
2427c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("getprop");	/* Service name */
2437c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)4;			/* #argument cells */
2447c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
2457c478bd9Sstevel@tonic-gate 	ci[3] = p1275_phandle2cell((phandle_t)nodeid); /* Arg1: package */
2467c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(name);		/* Arg2: property name */
2477c478bd9Sstevel@tonic-gate 	ci[5] = p1275_ptr2cell(value);		/* Arg3: buffer address */
2487c478bd9Sstevel@tonic-gate 	ci[6] = p1275_int2cell(len);		/* Arg4: buffer length */
2497c478bd9Sstevel@tonic-gate 	ci[7] = (cell_t)-1;			/* Res1: Prime result */
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 	promif_preprom();
2527c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
2537c478bd9Sstevel@tonic-gate 	promif_postprom();
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[7]));		/* Res1: Returned length */
2567c478bd9Sstevel@tonic-gate }
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate caddr_t
prom_nextprop(pnode_t nodeid,caddr_t previous,caddr_t next)259*fa9e4066Sahrens prom_nextprop(pnode_t nodeid, caddr_t previous, caddr_t next)
2607c478bd9Sstevel@tonic-gate {
2617c478bd9Sstevel@tonic-gate 	cell_t ci[7];
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 	(void) prom_strcpy(next, "");	/* Prime result, in case call fails */
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("nextprop");	/* Service name */
2667c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)3;			/* #argument cells */
2677c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)0;			/* #result cells */
2687c478bd9Sstevel@tonic-gate 	ci[3] = p1275_phandle2cell((phandle_t)nodeid); /* Arg1: phandle */
2697c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(previous);	/* Arg2: addr of prev name */
2707c478bd9Sstevel@tonic-gate 	ci[5] = p1275_ptr2cell(next);		/* Arg3: addr of 32 byte buf */
2717c478bd9Sstevel@tonic-gate 
2727c478bd9Sstevel@tonic-gate 	promif_preprom();
2737c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
2747c478bd9Sstevel@tonic-gate 	promif_postprom();
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate 	return (next);
2777c478bd9Sstevel@tonic-gate }
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate int
prom_setprop(pnode_t nodeid,caddr_t name,caddr_t value,int len)280*fa9e4066Sahrens prom_setprop(pnode_t nodeid, caddr_t name, caddr_t value, int len)
2817c478bd9Sstevel@tonic-gate {
2827c478bd9Sstevel@tonic-gate 	cell_t ci[8];
2837c478bd9Sstevel@tonic-gate #ifdef PROM_32BIT_ADDRS
2847c478bd9Sstevel@tonic-gate 	caddr_t ovalue = NULL;
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate 	if ((uintptr_t)value > (uint32_t)-1) {
2877c478bd9Sstevel@tonic-gate 		ovalue = value;
2887c478bd9Sstevel@tonic-gate 		value = promplat_alloc(len);
2897c478bd9Sstevel@tonic-gate 		if (value == NULL) {
2907c478bd9Sstevel@tonic-gate 			return (-1);
2917c478bd9Sstevel@tonic-gate 		}
2927c478bd9Sstevel@tonic-gate 		promplat_bcopy(ovalue, value, len);
2937c478bd9Sstevel@tonic-gate 	}
2947c478bd9Sstevel@tonic-gate #endif
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	prom_setprop_enter();
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate 	promif_preprom();
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 	ci[0] = p1275_ptr2cell("setprop");	/* Service name */
3017c478bd9Sstevel@tonic-gate 	ci[1] = (cell_t)4;			/* #argument cells */
3027c478bd9Sstevel@tonic-gate 	ci[2] = (cell_t)1;			/* #result cells */
3037c478bd9Sstevel@tonic-gate 	ci[3] = p1275_phandle2cell((phandle_t)nodeid);	/* Arg1: phandle */
3047c478bd9Sstevel@tonic-gate 	ci[4] = p1275_ptr2cell(name);		/* Arg2: property name */
3057c478bd9Sstevel@tonic-gate 	ci[5] = p1275_ptr2cell(value);		/* Arg3: New value ptr */
3067c478bd9Sstevel@tonic-gate 	ci[6] = p1275_int2cell(len);		/* Arg4: New value len */
3077c478bd9Sstevel@tonic-gate 	ci[7] = (cell_t)-1;			/* Res1: Prime result */
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate 	(void) p1275_cif_handler(&ci);
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate 	promif_postprom();
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate 	prom_setprop_exit();
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate #ifdef PROM_32BIT_ADDRS
3167c478bd9Sstevel@tonic-gate 	if (ovalue != NULL)
3177c478bd9Sstevel@tonic-gate 		promplat_free(value, len);
3187c478bd9Sstevel@tonic-gate #endif
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate 	return (p1275_cell2int(ci[7]));		/* Res1: Actual new size */
3217c478bd9Sstevel@tonic-gate }
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate /*
3247c478bd9Sstevel@tonic-gate  * prom_decode_composite_string:
3257c478bd9Sstevel@tonic-gate  *
3267c478bd9Sstevel@tonic-gate  * Returns successive strings in a composite string property.
3277c478bd9Sstevel@tonic-gate  * A composite string property is a buffer containing one or more
3287c478bd9Sstevel@tonic-gate  * NULL terminated strings contained within the length of the buffer.
3297c478bd9Sstevel@tonic-gate  *
3307c478bd9Sstevel@tonic-gate  * Always call with the base address and length of the property buffer.
3317c478bd9Sstevel@tonic-gate  * On the first call, call with prev == 0, call successively
3327c478bd9Sstevel@tonic-gate  * with prev == to the last value returned from this function
3337c478bd9Sstevel@tonic-gate  * until the routine returns zero which means no more string values.
3347c478bd9Sstevel@tonic-gate  */
3357c478bd9Sstevel@tonic-gate char *
prom_decode_composite_string(void * buf,size_t buflen,char * prev)3367c478bd9Sstevel@tonic-gate prom_decode_composite_string(void *buf, size_t buflen, char *prev)
3377c478bd9Sstevel@tonic-gate {
3387c478bd9Sstevel@tonic-gate 	if ((buf == 0) || (buflen == 0) || ((int)buflen == -1))
3397c478bd9Sstevel@tonic-gate 		return ((char *)0);
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate 	if (prev == 0)
3427c478bd9Sstevel@tonic-gate 		return ((char *)buf);
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate 	prev += prom_strlen(prev) + 1;
3457c478bd9Sstevel@tonic-gate 	if (prev >= ((char *)buf + buflen))
3467c478bd9Sstevel@tonic-gate 		return ((char *)0);
3477c478bd9Sstevel@tonic-gate 	return (prev);
3487c478bd9Sstevel@tonic-gate }
349