prtfru.c revision bdad7b9cb5784df1403f5f3d188edea03f0fb7cb
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 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A#
define GMT "%a, %b %d %Y %H:%M:%S GMT" 2N/Astatic char tagname[
sizeof (
"?_0123456789_0123456789_0123456789")];
2N/A * Definition for data elements found in devices but not found in 2N/A * the system's version of libfrureg 2N/A * Write message to standard error and possibly the error log buffer 2N/A /* make relevant output appear before error message */ 2N/A * Write message to standard output 2N/A * Safe wrapper for putchar() 2N/A * Safe wrapper for puts() 2N/A * XML-safe wrapper for putchar(): quotes XML-special characters 2N/A * XML-safe analog of puts(): quotes XML-special characters 2N/A for (
/* */; ((c = *s) != 0); s++)
2N/A * Output the XML DTD derived from the registry provided by libfrureg 2N/A * Output the DTD preamble 2N/A output(
"<!ELEMENT FRUID_XML_Tree (Parameter*, " 2N/A "(Fru | Location | Container)*,\n" 2N/A " Parameter*, ErrorLog?, Parameter*)>\n" 2N/A "<!ATTLIST FRUID_XML_Tree>\n" 2N/A "<!ELEMENT Parameter EMPTY>\n" 2N/A "<!ATTLIST Parameter type CDATA #REQUIRED>\n" 2N/A "<!ATTLIST Parameter name CDATA #REQUIRED>\n" 2N/A "<!ATTLIST Parameter value CDATA #REQUIRED>\n" 2N/A "<!ELEMENT Fru (Fru | Location | Container)*>\n" 2N/A "<!ATTLIST Fru name CDATA #REQUIRED>\n" 2N/A "<!ELEMENT Location (Fru | Location | Container)*>\n" 2N/A "<!ATTLIST Location\n" 2N/A " name CDATA #IMPLIED\n" 2N/A " value CDATA #IMPLIED\n" 2N/A "<!ELEMENT Container (ContainerData?, " 2N/A "(Fru | Location | Container)*)>\n" 2N/A "<!ATTLIST Container name CDATA #REQUIRED>\n" 2N/A "<!ATTLIST Container imagefile CDATA #IMPLIED>\n" 2N/A "<!ELEMENT ContainerData (Segment*)>\n" 2N/A "<!ATTLIST ContainerData>\n" 2N/A "<!ATTLIST Segment name CDATA #REQUIRED>\n" 2N/A "<!ELEMENT Index EMPTY>\n" 2N/A "<!ATTLIST Index value CDATA #REQUIRED>\n" 2N/A "<!ELEMENT ErrorLog (#PCDATA)>\n" 2N/A "<!ATTLIST ErrorLog>\n" 2N/A * Output the definition for each element 2N/A /* Prevent incompatible duplicate defn. from FRUID Registry. */ 2N/A "definition for \"%s\"\n"),
2N/A "<!ATTLIST Index_%s>\n" 2N/A "<!ELEMENT Index_%s (%s",
2N/A "<!ATTLIST %s value CDATA #REQUIRED>\n",
2N/A output(
"<!-- %s valid enumeration values\n");
2N/A /* Provide for returning the tag for an "unknown" element */ 2N/A output(
"<!ATTLIST UNKNOWN tag CDATA \"UNKNOWN\">\n\n");
2N/A * List all data elements as possible members of "Segment" 2N/A * Function to convert bcd to binary to correct the SPD_Manufacturer_Week 2N/A * Safely pretty-print the value of a field 2N/A "%llo" :
"%lld (%lld degrees C)",
2N/A errmsg =
"time value too large for formatting";
2N/A errmsg =
"formatted time would overflow buffer";
2N/A "/Status_EventsR[%d]/Message(FMA)",
2N/A"FMA Message R") == 0)
2N/A"FMA Event Data R") == 0)
2N/A"SPD_Fundamental_Memory_Type") == 0) {
2N/A"DDR II SDRAM") == 0)
2N/A /* If nothing matched above, print the field in hex */ 2N/A if ((i ==
4) || (i ==
6) ||
2N/A (i ==
8) || (i ==
10))
2N/A "SPD_Data_Revision_Code") == 0) {
2N/A /* Safely print any error message associated with the field */ 2N/A * Recursively print the contents of a data element 2N/A * Construct the path, or, for XML, the name, for the current "00000000 (No Value Recorded)\"");
"cannot convert time value");
"formatted time would overflow buffer");
"00000000 (No Value Recorded)");
"cannot convert time value");
"formatted time would overflow buffer");
* Handle the various categories of data elements: iteration, * Make a new element definition to describe the components * Validate the contents of the iteration control bytes "(should be less than %d)\n"),
"(should not be greater than %d)\n"),
* Print each component of the iteration * Print each component of the record * Base case: print the field formatted for XML ?
"%*s<UNKNOWN tag=\"%s\" value=\"" output(
"\"/>\n");
/* \" confuses cstyle */ * Base case: print the field * Print the contents of a packet (i.e., a tagged data element) * Build a definition for unrecognized tags (e.g., not in libfrureg) * Print the defined element * Print a segment's name and the contents of each data element in the segment /* Iterate over the packets in the segment, printing the contents */ error(
gettext(
"Error processing data in segment \"%s\": %s\n"),
* Close the XML element for a "location" node * Close the XML element for a "fru" node * Close the XML element for a "container" node * Introduce a node in XML and set the appropriate node-closing function * Print node info and, where appropriate, node contents /* Print the contents of each packet in each segment of a container */ * Process the node if its path matches the search path in "args" * Write the trailer required for well-formed DTD-compliant XML error(
gettext(
"Error copying error messages to \"ErrorLog\""),
output(
"</FRUID_XML_Tree>\n");
* Print available FRU ID information /* Copy parameter flags to global flags */ /* Help arrange for correct, efficient interleaving of output */ /* Initialize for XML--or not */ "Error creating error log file: %s\n",
/* Output the XML preamble */ output(
"<?xml version=\"1.0\" ?>\n" " Copyright 2000-2002 Sun Microsystems, Inc. " " Use is subject to license terms.\n" "<!DOCTYPE FRUID_XML_Tree SYSTEM \"prtfrureg.dtd\">\n\n" /* Arrange to always properly terminate XML */ "infrastructure to provide FRUID data\n" "Please use the platform SP to access the FRUID "