2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * Turn on module debugging output 2N/A return (-
1);
/* mod errno already set */ 2N/A * Inherit if we can, it saves memory 2N/A * Register root node methods 2N/A "Request to enumerate %s component with an " 2N/A "ambiguous instance number, min (%d) != max (%d).\n",
2N/A /* check for authority, create if none */ 2N/A * Set FRU for the motherboard node 2N/A /* Get authority, if present */ 2N/A /* authority, if any */ 2N/A /* omit chassis alias */ 2N/A /* hardware-id part */ 2N/A /* separating slash */ 2N/A * If the nvlist represents a facility node, then we append the 2N/A * facility type and name to the end of the string representation using 2N/A * Create base HC nvlist 2N/A * Add optional payload members 2N/A * Count equal signs and slashes to determine how many 2N/A * hc-pairs will be present in the final FMRI. There should 2N/A * be at least as many slashes as equal signs. There can be 2N/A * more, though if the string after an = includes them. 2N/A * Do we appear to have a well-formed string version of the FMRI? 2N/A * We go through a pretty complicated procedure to find the 2N/A * name and id for each pair. That's because, unfortunately, 2N/A * we have some ids that can have slashes within them. So 2N/A * we can't just search for the next slash after the equal sign 2N/A * and decide that starts a new pair. Instead we have to find 2N/A * an equal sign for the next pair and work our way back to the 2N/A * Make sure there are a valid authority members 2N/A * The first colon we encounter must occur before the 2N/A * Return possible devid, serial, part and revision. Need 2N/A * to account for both version 0 and version 1 names. 2N/A * This function creates an nvlist to represent the facility portion of an 2N/A * hc-scheme node, given a string representation of the fmri. This is called by 2N/A * hc_fmri_str2nvl. If the string does not contain a facility component 2N/A * (e.g. ?<ftype>=<fname>) then it bails early and returns 0. 2N/A * On failure it returns -1 and sets the topo mod errno 2N/A/* hc-specific member names */ 2N/A /* We're expecting a string version of an hc scheme FMRI */ 2N/A * Walk from the end of the string and add components to "hc-specific" 2N/A * if the names match the known list. 2N/A /* The rest should belong to "hc-list" */ 2N/A /* found a "hc-specific" member */ 2N/A for (i = 0; i < n +
1; ++i)
2N/A * Only enumerate elements with correct canonical names 2N/A char str[
21];
/* sizeof (UINT64_MAX) + '\0' */ 2N/A * Check that the requested name is in our canonical list 2N/A * Copy the parent's HC_LIST 2N/A /* First the must-have fields */ 2N/A /* And then optional arguments */ 2N/A * Still need to check chassis serial in case of proxied 2N/A * Ideally, we should just be able to call topo_walk_bysibling(). But that 2N/A * explicitly iterate over children of the parent looking for a matching value. 2N/A * Generic walker for the hc-scheme topo tree. This function uses the 2N/A * hierachical nature of the hc-scheme to efficiently step through 2N/A * the topo hc tree. Node lookups are done by topo_walk_byid() and 2N/A * topo_walk_bysibling() at each component level to avoid unnecessary 2N/A * traversal of the tree. hc_walker() never returns TOPO_WALK_NEXT, so 2N/A * whether TOPO_WALK_CHILD or TOPO_WALK_SIBLING is specified by 2N/A * topo_walk_step() doesn't affect the traversal. 2N/A "complete: terminate walk\n");
2N/A * Check to see if our node matches the requested FMRI. If it doesn't 2N/A * (because the enumerator determines matching based on something other 2N/A * root), then iterate over siblings to find the matching node. 2N/A * We are at the end of the hc-list. Now, check for 2N/A * a facility leaf and walk one more time. 2N/A * Otherwise, this is the node we're looking for. 2N/A "complete: terminate walk\n");
2N/A * Move on to the next component in the hc-list 2N/A * A call to hc_walk_init() followed by a call to topo_walk_step() will simply 2N/A * find the specified hc-scheme node "rsrc" and run the callback function "cb" 2N/A * on it with argument "pdata". 2N/A * Note that this sequence does not walk the whole tree but simply matches 2N/A * each element in the hc-scheme name "rsrc" one level at a time until it 2N/A * finds the "rsrc" node. 2N/A * Private args to prop method are optional 2N/A * Private args to prop method are optional 2N/A * check with the enumerator that created this FMRI 2N/A * If the method exists but failed for some other 2N/A * reason, propagate the error as making any decision 2N/A * over presence is impossible. 2N/A * Enumerator didn't provide "presence_state" method - 2N/A * so check the authority information. If there is a devid 2N/A * then compare that. Otherwise, if the part id 2N/A * or serial number doesn't match, then it isn't the 2N/A * same FMRI. Otherwise, if we have a serial number and 2N/A * it hasn't changed, then assume it is the same FMRI. 2N/A * Lookup the specified facility node. Return with an error if we can't 2N/A * Invoke user's callback for each facility node in the topo list, 2N/A * passing in a pointer to the facility node 2N/A * lookup arguments: hw resource, facility type, facility subtype, 2N/A * callback and callback args 2N/A "walker arg nvlist\n");
2N/A * check with the enumerator that created this FMRI 2N/A * Get the portion of the FMRI independent of the authority 2N/A /* if we have devid, check that in preference */