/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * Copyright (c) 2015 Joyent, Inc. All rights reserved. * Copyright 2025 Oxide Computer Company */ #include #include #include #include #include #include static prom_node_t *promif_top; static prom_node_t *promif_find_node(pnode_t nodeid); static int getproplen(prom_node_t *pnp, char *name); static void *getprop(prom_node_t *pnp, char *name); static void promif_create_prop(prom_node_t *pnp, char *name, void *val, int len, int flags) { struct prom_prop *p, *q; q = kmem_zalloc(sizeof (*q), KM_SLEEP); q->pp_name = kmem_zalloc(strlen(name) + 1, KM_SLEEP); (void) strcpy(q->pp_name, name); q->pp_val = len > 0 ? kmem_alloc(len, KM_SLEEP) : NULL; q->pp_len = len; switch (flags) { case DDI_PROP_TYPE_INT: case DDI_PROP_TYPE_INT64: /* * Technically, we need byte-swapping to conform to 1275. * However, the old x86 prom simulator used little endian * representation, so we don't swap here either. * * NOTE: this is inconsistent with ddi_prop_lookup_*() * which does byte-swapping when looking up prom properties. * Since all kernel nodes are SID nodes, drivers no longer * access PROM properties on x86. */ default: /* no byte swapping */ (void) bcopy(val, q->pp_val, len); break; } if (pnp->pn_propp == NULL) { pnp->pn_propp = q; return; } for (p = pnp->pn_propp; p->pp_next != NULL; p = p->pp_next) /* empty */; p->pp_next = q; } static prom_node_t * promif_create_node(dev_info_t *dip) { prom_node_t *pnp; ddi_prop_t *hwprop; char *nodename; pnp = kmem_zalloc(sizeof (prom_node_t), KM_SLEEP); pnp->pn_nodeid = DEVI(dip)->devi_nodeid; hwprop = DEVI(dip)->devi_hw_prop_ptr; while (hwprop != NULL) { /* need to encode to proper endianness */ promif_create_prop(pnp, hwprop->prop_name, hwprop->prop_val, hwprop->prop_len, hwprop->prop_flags & DDI_PROP_TYPE_MASK); hwprop = hwprop->prop_next; } nodename = ddi_node_name(dip); promif_create_prop(pnp, "name", nodename, strlen(nodename) + 1, DDI_PROP_TYPE_STRING); return (pnp); } static void promif_create_children(prom_node_t *, dev_info_t *); static void promif_create_peers(prom_node_t *pnp, dev_info_t *dip) { dev_info_t *ndip = ddi_get_next_sibling(dip); while (ndip) { pnp->pn_sibling = promif_create_node(ndip); promif_create_children(pnp->pn_sibling, ndip); pnp = pnp->pn_sibling; ndip = ddi_get_next_sibling(ndip); } } static void promif_create_children(prom_node_t *pnp, dev_info_t *dip) { dev_info_t *cdip = ddi_get_child(dip); while (cdip) { pnp->pn_child = promif_create_node(cdip); promif_create_peers(pnp->pn_child, cdip); pnp = pnp->pn_child; cdip = ddi_get_child(cdip); } } void promif_create_device_tree(void) { promif_top = promif_create_node(ddi_root_node()); promif_create_children(promif_top, ddi_root_node()); } static prom_node_t * promif_find_node(pnode_t nodeid) { /* * We keep track of sibling and child nodes that we haven't visited yet * in a small stack, and pop them off as we check them. The tree is not * particularly broad or deep so a small number of slots will suffice; * allocating 64 slots uses only 512 bytes of stack and is an order * of magnitude more than we need. */ prom_node_t *stack[64]; uint_t top = 0; if (nodeid == OBP_NONODE) return (promif_top); if (promif_top == NULL) return (NULL); stack[top++] = promif_top; while (top > 0) { prom_node_t *cur = stack[--top]; if (cur->pn_nodeid == nodeid) return (cur); if (cur->pn_sibling != NULL) stack[top++] = cur->pn_sibling; VERIFY3U(top, <, ARRAY_SIZE(stack)); if (cur->pn_child != NULL) stack[top++] = cur->pn_child; VERIFY3U(top, <, ARRAY_SIZE(stack)); } return (NULL); } pnode_t promif_nextnode(pnode_t nodeid) { prom_node_t *pnp; /* * Note: next(0) returns the root node */ pnp = promif_find_node(nodeid); if (pnp && (nodeid == OBP_NONODE)) return (pnp->pn_nodeid); if (pnp && pnp->pn_sibling) return (pnp->pn_sibling->pn_nodeid); return (OBP_NONODE); } pnode_t promif_childnode(pnode_t nodeid) { prom_node_t *pnp; pnp = promif_find_node(nodeid); if (pnp && pnp->pn_child) return (pnp->pn_child->pn_nodeid); return (OBP_NONODE); } /* * Retrieve a PROM property (len and value) */ static int getproplen(prom_node_t *pnp, char *name) { struct prom_prop *propp; for (propp = pnp->pn_propp; propp != NULL; propp = propp->pp_next) if (strcmp(propp->pp_name, name) == 0) return (propp->pp_len); return (-1); } int promif_getproplen(pnode_t nodeid, char *name) { prom_node_t *pnp; pnp = promif_find_node(nodeid); if (pnp == NULL) return (-1); return (getproplen(pnp, name)); } static void * getprop(prom_node_t *pnp, char *name) { struct prom_prop *propp; for (propp = pnp->pn_propp; propp != NULL; propp = propp->pp_next) if (strcmp(propp->pp_name, name) == 0) return (propp->pp_val); return (NULL); } int promif_getprop(pnode_t nodeid, char *name, void *value) { prom_node_t *pnp; void *v; int len; pnp = promif_find_node(nodeid); if (pnp == NULL) return (-1); len = getproplen(pnp, name); if (len > 0) { v = getprop(pnp, name); bcopy(v, value, len); } return (len); } static char * nextprop(prom_node_t *pnp, char *name) { struct prom_prop *propp; /* * getting next of NULL or a null string returns the first prop name */ if (name == NULL || *name == '\0') if (pnp->pn_propp) return (pnp->pn_propp->pp_name); for (propp = pnp->pn_propp; propp != NULL; propp = propp->pp_next) if (strcmp(propp->pp_name, name) == 0) if (propp->pp_next) return (propp->pp_next->pp_name); return (NULL); } char * promif_nextprop(pnode_t nodeid, char *name, char *next) { prom_node_t *pnp; char *s; next[0] = '\0'; pnp = promif_find_node(nodeid); if (pnp == NULL) return (NULL); s = nextprop(pnp, name); if (s == NULL) return (next); (void) strcpy(next, s); return (next); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include #include /* * The Intel cpu does not have an underlying monitor. * So, we emulate the best we can..... */ void prom_enter_mon(void) { #if defined(_KMDB) prom_exit_to_mon(); #endif if (boothowto & RB_DEBUG) kmdb_enter(); else { prom_printf("Press any key to continue."); (void) prom_getchar(); } } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include /* * This function is installed for both pre and post output during cpr to keep * the early stages of the resuming kernel from accessing outside the nucleus * mapping; we assert that the console is all powered up before it is installed */ static void null_outfunc(void) { } static promif_owrap_t nullwrapper = { null_outfunc, null_outfunc }; static promif_owrap_t *wrapper = &nullwrapper; static promif_owrap_t pmwrapper; static promif_owrap_t *saved_wrapper; promif_owrap_t *promif_preout(void) { promif_owrap_t *ow = wrapper; (ow->preout)(); return (ow); } void promif_postout(promif_owrap_t *ow) { (ow->postout)(); } void prom_set_outfuncs(void (*pref)(void), void (*postf)(void)) { pmwrapper.preout = pref; pmwrapper.postout = postf; wrapper = &pmwrapper; } void prom_suspend_prepost(void) { saved_wrapper = wrapper; wrapper = &nullwrapper; } void prom_resume_prepost(void) { wrapper = saved_wrapper; saved_wrapper = NULL; } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include #include #include /* * The Intel cpu does not have an underlying monitor. * So, we do the best we can..... */ extern void prom_poll_enter(void); extern cons_polledio_t *cons_polledio; void prom_exit_to_mon(void) { #if !defined(_KMDB) prom_poll_enter(); #endif #if !defined(_KMDB) if (boothowto & RB_DEBUG) kmdb_enter(); #endif /* !_KMDB */ prom_reboot_prompt(); prom_reboot(NULL); } #if !defined(_KMDB) void prom_poll_enter(void) { if (cons_polledio != NULL) { if (cons_polledio->cons_polledio_enter != NULL) { cons_polledio->cons_polledio_enter( cons_polledio->cons_polledio_argument); } } } #endif /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include /* * prom_getchar * * always returns a character; waits for input if none is available. */ uchar_t prom_getchar(void) { while (BSVC_ISCHAR(SYSP) == 0) ; return (BSVC_GETCHAR(SYSP)); } /* * prom_mayget * * returns a character from the keyboard if one is available, * otherwise returns a -1. */ int prom_mayget(void) { if (BSVC_ISCHAR(SYSP) == 0) return (-1); return (BSVC_GETCHAR(SYSP)); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include #include #include int promif_debug = 0; /* debug */ int emul_1275 = 0; /* * Every standalone that wants to use this library must call * prom_init() before any of the other routines can be called. */ /*ARGSUSED*/ void prom_init(char *pgmname, void *cookie) { /* nothing to do */ } #ifndef _KMDB /* * This is for compatibility only. Somewhere between Solaris 2.6 * and 10, we had a prom tree constructed by a bootloader with * realmode drivers. That is now gone, but we are left with some * applications depending on /dev/openprom. We fake a prom tree * based on hardware properties in the kernel device tree. */ void prom_setup() { promif_create_device_tree(); } #endif /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include /* * Routines for walking the PROMs devinfo tree * The prom tree is for /dev/openprom compatibility only, * so we fail all calls except those needed by /dev/openprom */ /* * Return the root nodeid. * Calling prom_nextnode(0) returns the root nodeid. */ pnode_t prom_rootnode(void) { static pnode_t rootnode; return (rootnode ? rootnode : (rootnode = prom_nextnode(OBP_NONODE))); } pnode_t prom_nextnode(pnode_t nodeid) { return (promif_nextnode(nodeid)); } pnode_t prom_childnode(pnode_t nodeid) { return (promif_childnode(nodeid)); } /* * disallow searching */ /*ARGSUSED*/ pnode_t prom_findnode_byname(pnode_t n, char *name) { return (OBP_NONODE); } pnode_t prom_chosennode(void) { return (OBP_NONODE); } pnode_t prom_optionsnode(void) { return (OBP_NONODE); } /*ARGSUSED*/ pnode_t prom_finddevice(char *path) { return (OBP_BADNODE); } pnode_t prom_alias_node(void) { return (OBP_BADNODE); } /*ARGSUSED*/ void prom_pathname(char *buf) { /* nothing, just to get consconfig_dacf to compile */ } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include static void _doprint(const char *, va_list, void (*)(char, char **), char **); static void _printn(uint64_t, int, int, int, void (*)(char, char **), char **); /* * Emit character functions... */ /*ARGSUSED*/ static void _pput(char c, char **p) { (void) prom_putchar(c); } static void _sput(char c, char **p) { **p = c; *p += 1; } /*VARARGS1*/ void prom_printf(const char *fmt, ...) { va_list adx; va_start(adx, fmt); (void) _doprint(fmt, adx, _pput, (char **)0); va_end(adx); } void prom_vprintf(const char *fmt, va_list adx) { va_list tadx; va_copy(tadx, adx); (void) _doprint(fmt, tadx, _pput, (char **)0); va_end(tadx); } /*VARARGS2*/ char * prom_sprintf(char *s, const char *fmt, ...) { char *bp = s; va_list adx; va_start(adx, fmt); (void) _doprint(fmt, adx, _sput, &bp); *bp++ = (char)0; va_end(adx); return (s); } char * prom_vsprintf(char *s, const char *fmt, va_list adx) { char *bp = s; (void) _doprint(fmt, adx, _sput, &bp); *bp++ = (char)0; return (s); } static void _doprint(const char *fmt, va_list adx, void (*emit)(char, char **), char **bp) { int b, c, i, pad, width, ells; register char *s; int64_t l; uint64_t ul; loop: width = 0; while ((c = *fmt++) != '%') { if (c == '\0') return; if (c == '\n') (*emit)('\r', bp); (*emit)(c, bp); } c = *fmt++; for (pad = ' '; c == '0'; c = *fmt++) pad = '0'; for (width = 0; c >= '0' && c <= '9'; c = *fmt++) width = (width * 10) + (c - '0'); for (ells = 0; c == 'l'; c = *fmt++) ells++; switch (c) { case 'd': case 'D': b = 10; if (ells == 0) l = (int64_t)va_arg(adx, int); else if (ells == 1) l = (int64_t)va_arg(adx, long); else l = (int64_t)va_arg(adx, int64_t); if (l < 0) { (*emit)('-', bp); width--; ul = -l; } else ul = l; goto number; case 'p': ells = 1; /* FALLTHROUGH */ case 'x': case 'X': b = 16; goto u_number; case 'u': b = 10; goto u_number; case 'o': case 'O': b = 8; u_number: if (ells == 0) ul = (uint64_t)va_arg(adx, uint_t); else if (ells == 1) ul = (uint64_t)va_arg(adx, ulong_t); else ul = (uint64_t)va_arg(adx, uint64_t); number: _printn(ul, b, width, pad, emit, bp); break; case 'c': b = va_arg(adx, int); for (i = 24; i >= 0; i -= 8) if ((c = ((b >> i) & 0x7f)) != 0) { if (c == '\n') (*emit)('\r', bp); (*emit)(c, bp); } break; case 's': s = va_arg(adx, char *); while ((c = *s++) != 0) { if (c == '\n') (*emit)('\r', bp); (*emit)(c, bp); } break; case '%': (*emit)('%', bp); break; } goto loop; } /* * Printn prints a number n in base b. * We don't use recursion to avoid deep kernel stacks. */ static void _printn(uint64_t n, int b, int width, int pad, void (*emit)(char, char **), char **bp) { char prbuf[40]; register char *cp; cp = prbuf; do { *cp++ = "0123456789abcdef"[n%b]; n /= b; width--; } while (n); while (width-- > 0) *cp++ = (char)pad; do { (*emit)(*--cp, bp); } while (cp > prbuf); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * Stuff for mucking about with properties */ #include #include #include int prom_getproplen(pnode_t nodeid, caddr_t name) { return (promif_getproplen(nodeid, name)); } int prom_getprop(pnode_t nodeid, caddr_t name, caddr_t value) { return (promif_getprop(nodeid, name, value)); } caddr_t prom_nextprop(pnode_t nodeid, caddr_t previous, caddr_t next) { return (promif_nextprop(nodeid, previous, next)); } /* obsolete entries, not needed */ char * prom_decode_composite_string(void *buf, size_t buflen, char *prev) { if ((buf == 0) || (buflen == 0) || ((int)buflen == -1)) return ((char *)0); if (prev == 0) return ((char *)buf); prev += strlen(prev) + 1; if (prev >= ((char *)buf + buflen)) return ((char *)0); return (prev); } /*ARGSUSED*/ int prom_bounded_getprop(pnode_t nodeid, caddr_t name, caddr_t value, int len) { return (-1); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include /*ARGSUSED*/ int prom_mayput(char c) { prom_putchar(c); return (1); } void prom_putchar(char c) { static int bhcharpos = 0; promif_owrap_t *ow; ow = promif_preout(); switch (c) { case '\t': do { BSVC_PUTCHAR(SYSP, ' '); } while (++bhcharpos % 8); break; case '\n': case '\r': bhcharpos = 0; BSVC_PUTCHAR(SYSP, c); break; case '\b': if (bhcharpos) bhcharpos--; BSVC_PUTCHAR(SYSP, c); break; default: bhcharpos++; BSVC_PUTCHAR(SYSP, c); break; } promif_postout(ow); } void prom_writestr(const char *s, size_t n) { while (n-- != 0) prom_putchar(*s++); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include #include #define PROM_VERSION_NUMBER 4 /* Obsolete under new boot */ int prom_getversion(void) { return (PROM_VERSION_NUMBER); } int prom_is_openprom(void) { return (1); /* to humor /dev/openprom */ } /* * Return a string representing the prom version. In this case * a string representing the version of devconf that created * the device tree will be returned. * * Return the actual length of the string including the NULL terminator. */ int prom_version_name(char *buf, int len) { static char prom_versionstr[] = "DevConf 2.0"; extern size_t strlcpy(char *, const char *, size_t); (void) strlcpy(buf, prom_versionstr, len - 1); return (sizeof (prom_versionstr)); }