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
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.
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/promif.h>
30 #include <sys/promimpl.h>
33 * Return a character string in buf,buflen representing the running
34 * version of the firmware. Systems that have no concept of such a
35 * string may return the string "unknown".
37 * Return the actual length of the string, including the NULL terminator.
38 * Copy at most buflen bytes into the caller's buffer, always providing
41 * Returns the actual length of the string, plus copies data in the callers
42 * buf copying at most buflen bytes. Returns -1 if an internal error occurs.
46 prom_version_name(char *buf
, int buflen
)
50 char *unknown
= "unknown";
52 *buf
= *(buf
+ buflen
- 1) = '\0'; /* Force NULL termination */
55 * On sun4u systems, the /openprom "version" property
56 * contains the running version of the prom. Some older
57 * pre-FCS proms may not have the "version" property, so
58 * in that case we just return "unknown".
61 nodeid
= prom_finddevice("/openprom");
62 if (nodeid
== (pnode_t
)-1)
65 proplen
= prom_bounded_getprop(nodeid
, "version", buf
, buflen
- 1);
67 (void) prom_strncpy(buf
, unknown
, buflen
- 1);
68 return (prom_strlen(unknown
) + 1);