diff options
author | Marty Gloff <mgloff@us.ibm.com> | 2015-12-14 16:38:05 -0600 |
---|---|---|
committer | William G. Hoffa <wghoffa@us.ibm.com> | 2016-03-30 14:45:08 -0400 |
commit | 550f30129f455317e65610cd90e9d06b2018e4c1 (patch) | |
tree | 04e21e3516a03954d06926dc8e15aaa899939327 | |
parent | 10b4a480645ebe9ac9bf612afc1c0f1dd4309cdb (diff) | |
download | blackbird-hostboot-550f30129f455317e65610cd90e9d06b2018e4c1.tar.gz blackbird-hostboot-550f30129f455317e65610cd90e9d06b2018e4c1.zip |
Method to support initial temporary defaults for attributes
Supply temporary HB defaults and attribute definitions.
Create temporary HB attribute definitions from new FAPI ones.
Add attributes to a target based on FAPI targetType.
Change-Id: I41d5fe0ef1d51d25975ec18a50bd125837f77995
RTC:131375
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/1016
Tested-by: Jenkins Server
Tested-by: FSP CI Jenkins
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: Elizabeth K. Liner <eliner@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
-rw-r--r-- | src/build/mkrules/dist.targets.mk | 6 | ||||
-rwxr-xr-x | src/usr/fapi2/fapi2.mk | 8 | ||||
-rwxr-xr-x | src/usr/targeting/common/xmltohb/common.mk | 9 | ||||
-rw-r--r-- | src/usr/targeting/common/xmltohb/tempdefaults.xml | 86 | ||||
-rwxr-xr-x | src/usr/targeting/common/xmltohb/xmltohb.pl | 15 | ||||
-rw-r--r-- | src/usr/targeting/xmltohb/makefile | 94 | ||||
-rwxr-xr-x | src/usr/targeting/xmltohb/updatetempsxml.pl | 742 |
7 files changed, 930 insertions, 30 deletions
diff --git a/src/build/mkrules/dist.targets.mk b/src/build/mkrules/dist.targets.mk index 8eb31011a..8b8ace2d4 100644 --- a/src/build/mkrules/dist.targets.mk +++ b/src/build/mkrules/dist.targets.mk @@ -85,6 +85,7 @@ COPY_FILES = \ src/usr/targeting/common/xmltohb/attribute_types_hb.xml:openpower \ src/usr/targeting/common/xmltohb/target_types_hb.xml:openpower \ src/usr/targeting/common/xmltohb/xmltohb.pl:openpower \ + src/usr/targeting/xmltohb/updatetempsxml.pl:openpower \ src/include/usr/vmmconst.h:openpower \ src/usr/targeting/common/xmltohb/bios.xsd:openpower \ src/usr/targeting/common/xmltohb/bios_metadata_petitboot.xslt:openpower \ @@ -213,10 +214,15 @@ fsp.tar_CONTENTS = \ src/build/buildpnor/defaultPnorLayout.xml \ $(if $(FAKEPNOR), src/build/buildpnor/pnorLayoutFake.xml, ) \ img/simics_NIMBUS_targeting.bin \ + obj/genfiles/fapiattrs.xml \ + obj/genfiles/hb_plat_attr_srvc.H \ + src/import/hwpf/fapi2/xml/attribute_info/hb_temp_defaults.xml \ $(addsuffix :targeting/,\ $(call ROOTPATH_WILDCARD_RECURSIVE,src/usr/targeting/common))\ $(addsuffix :targeting/,\ $(call ROOTPATH_WILDCARD_RECURSIVE,src/include/usr/targeting/common)) \ + $(addsuffix :targeting/,\ + $(call ROOTPATH_WILDCARD,src/usr/targeting/xmltohb/updatetempsxml.pl))\ $(addsuffix :hwas/,\ $(call ROOTPATH_WILDCARD_RECURSIVE,src/usr/hwas/common))\ $(addsuffix :hwas/,\ diff --git a/src/usr/fapi2/fapi2.mk b/src/usr/fapi2/fapi2.mk index 7d1bcb40e..db3bc2484 100755 --- a/src/usr/fapi2/fapi2.mk +++ b/src/usr/fapi2/fapi2.mk @@ -67,6 +67,14 @@ FAPI2_ATTR_XML += $(wildcard \ FAPI2_ATTR_XML += $(wildcard \ $(ROOTPATH)/src/import/chips/p9/procedures/xml/attribute_info/*.xml) +# Filter out Temp defaults XML file from Attribute XML files. +# NOTE: The hb_temp_defaults.xml file is not a normal attribute file with the +# normal structures that define the attribute itself. It temporarily +# provides default values for new attributes defined in other files. +HB_TEMP_DFLT_XML = $(wildcard \ + ${ROOTPATH}/src/import/hwpf/fapi2/xml/attribute_info/hb_temp_defaults.xml) +FAPI2_ATTR_XML := $(filter-out ${HB_TEMP_DFLT_XML},$(FAPI2_ATTR_XML)) + # Chip SCOM address header files. FAPI2_PLAT_INCLUDE += $(addsuffix /common/include, \ $(addprefix $(ROOTPATH)/src/import/chips/$CHIPS)) diff --git a/src/usr/targeting/common/xmltohb/common.mk b/src/usr/targeting/common/xmltohb/common.mk index 5b56664f2..c0ff7a2fe 100755 --- a/src/usr/targeting/common/xmltohb/common.mk +++ b/src/usr/targeting/common/xmltohb/common.mk @@ -81,9 +81,18 @@ FAPI_ATTR_SOURCES += runtime_attributes/memory_occ_attributes.xml FAPI_ATTR_SOURCES += proc_abus_dmi_xbus_scominit_attributes.xml FAPI_ATTR_SOURCES += pstate_attributes.xml +# Temp defaults XML sources used by updatetempsxml.pl script +TEMP_DEFAULTS_XML += tempdefaults.xml +HB_TEMP_DEFAULTS_XML += hb_temp_defaults.xml + +ATTRIBUTE_SERVICE_H += plat_attribute_service.H +HB_PLAT_ATTR_SRVC_H += hb_plat_attr_srvc.H + +TEMP_GENERIC_XML += temp_generic.xml XMLTOHB_GENERIC_XML += generic.xml XMLTOHB_FAPI_XML += fapiattrs.xml XMLTOHB_MERGE_SCRIPT += mergexml.sh +XMLTOHB_TEMPS_MERGE_SCRIPT += updatetempsxml.pl XMLTOHB_COMPILER_SCRIPT += xmltohb.pl VMM_CONSTS_FILE += vmmconst.h diff --git a/src/usr/targeting/common/xmltohb/tempdefaults.xml b/src/usr/targeting/common/xmltohb/tempdefaults.xml new file mode 100644 index 000000000..84594c941 --- /dev/null +++ b/src/usr/targeting/common/xmltohb/tempdefaults.xml @@ -0,0 +1,86 @@ +<!-- IBM_PROLOG_BEGIN_TAG --> +<!-- This is an automatically generated prolog. --> +<!-- --> +<!-- $Source: src/usr/targeting/common/xmltohb/tempdefaults.xml $ --> +<!-- --> +<!-- OpenPOWER HostBoot Project --> +<!-- --> +<!-- Contributors Listed Below - COPYRIGHT 2015,2016 --> +<!-- [+] International Business Machines Corp. --> +<!-- --> +<!-- --> +<!-- Licensed under the Apache License, Version 2.0 (the "License"); --> +<!-- you may not use this file except in compliance with the License. --> +<!-- You may obtain a copy of the License at --> +<!-- --> +<!-- http://www.apache.org/licenses/LICENSE-2.0 --> +<!-- --> +<!-- Unless required by applicable law or agreed to in writing, software --> +<!-- distributed under the License is distributed on an "AS IS" BASIS, --> +<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or --> +<!-- implied. See the License for the specific language governing --> +<!-- permissions and limitations under the License. --> +<!-- --> +<!-- IBM_PROLOG_END_TAG --> + +<attributes> + +<!-- ===================================================================== + ATTRIBUTE TYPES + Contains the definition of temporary defaults for existing attributes + without a default. + <tempDefault> + <attribute> + <id>...</id> + <default>...</default> + <force/> # optional to force use of specified default value + # even when existing attribute definition has a + # default value defined + </attribute> + </tempDefault> + + Contains initial temporary definitions of new attributes. + + These definitions should be removed and replaced with permanent + definitions elsewhere prior to shipping code that uses them. + + Examples: + <tempDefault> + <attribute> + <id>FRU_ID</id> + <default>0x56789</default> + <force/> + </attribute> + </tempDefault> + + <tempDefault> + <attribute> + <id>OPT_MEMMAP_GROUP_POLICY</id> + <default>0x12</default> + </attribute> + </tempDefault> + + <tempDefault> + <attribute> + <id>PHB_BASE_ADDRS</id> + <default> + 0x0FFFFFFFFFFFFFFF, + 0x1FFFFFFFFFFFFFFF, + 0x2FFFFFFFFFFFFFFF, + 0x3FFFFFFFFFFFFFFF + </default> + <force/> + </attribute> + </tempDefault> + ================================================================= --> + +<!-- ===================================================================== + Start of temporary definitions + ================================================================= --> + + +<!-- ===================================================================== + End of temporary definitions + ================================================================= --> + +</attributes> diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl index c417bc763..b01b009ef 100755 --- a/src/usr/targeting/common/xmltohb/xmltohb.pl +++ b/src/usr/targeting/common/xmltohb/xmltohb.pl @@ -534,6 +534,7 @@ sub validateAttributes { = { required => 0, isscalar => 0}; $elements{"display-name"} = { required => 0, isscalar => 1}; $elements{"virtual"} = { required => 0, isscalar => 0}; + $elements{"tempAttribute"} = { required => 0, isscalar => 0}; foreach my $attribute (@{$attributes->{attribute}}) { @@ -885,7 +886,8 @@ sub writeFapiPlatAttrMacrosHeaderFileContent { { if(exists $attribute->{readable}) { - $macroSection .= ' #define ' . $hwpfToHbAttrMap->{id} . + $macroSection .= ' #define ' . + $hwpfToHbAttrMap->{id} . "_GETMACRO(ID,PTARGET,VAL) \\\n" . " FAPI_PLAT_ATTR_SVC_GETMACRO_" . $hwpfToHbAttrMap->{macro} . "(ID,PTARGET,VAL)\n"; @@ -893,8 +895,8 @@ sub writeFapiPlatAttrMacrosHeaderFileContent { } else { - fatal("FAPI attribute $hwpfToHbAttrMap->{id} requires " . - "platform supply readable attribute."); + fatal("FAPI attribute $hwpfToHbAttrMap->{id} " . + "requires platform supply readable attribute."); } } @@ -902,7 +904,8 @@ sub writeFapiPlatAttrMacrosHeaderFileContent { { if(exists $attribute->{writeable}) { - $macroSection .= ' #define ' . $hwpfToHbAttrMap->{id} . + $macroSection .= ' #define ' . + $hwpfToHbAttrMap->{id} . "_SETMACRO(ID,PTARGET,VAL) \\\n" . " FAPI_PLAT_ATTR_SVC_SETMACRO_" . $hwpfToHbAttrMap->{macro} . "(ID,PTARGET,VAL)\n"; @@ -910,8 +913,8 @@ sub writeFapiPlatAttrMacrosHeaderFileContent { } else { - fatal("FAPI attribute $hwpfToHbAttrMap->{id} requires " - . "platform supply writeable attribute."); + fatal("FAPI attribute $hwpfToHbAttrMap->{id} " + . "requires platform supply writeable attribute."); } } } diff --git a/src/usr/targeting/xmltohb/makefile b/src/usr/targeting/xmltohb/makefile index 47d54492e..773551986 100644 --- a/src/usr/targeting/xmltohb/makefile +++ b/src/usr/targeting/xmltohb/makefile @@ -46,14 +46,28 @@ include ${COMMON_TARGETING_MAKEFILE} VPATH = ${COMMON_TARGETING_REL_PATH} FAPI_ATTR_SOURCE_DIR = ${ROOTPATH}/src/usr/hwpf/hwp +XMLTOHB_FAPIATTR_SOURCES = \ + ${addprefix ${FAPI_ATTR_SOURCE_DIR}/, ${FAPI_ATTR_SOURCES}} +FAPI2_ATTR_XML_DIR = ${ROOTPATH}/src/import/hwpf/fapi2/xml/attribute_info +HB_TEMP_DFLT_SOURCES = $(wildcard \ + ${FAPI2_ATTR_XML_DIR}/${HB_TEMP_DEFAULTS_XML}) + +FAPI2_INCLUDE_PATH = \ + ${ROOTPATH}/src/include/usr/fapi2 +FAPIATTRSRVC_SOURCE = \ + ${FAPI2_INCLUDE_PATH}/${ATTRIBUTE_SERVICE_H} -XMLTOHB_FAPIATTR_SOURCES += \ - ${addprefix ${FAPI_ATTR_SOURCE_DIR}/, ${FAPI_ATTR_SOURCES}} # Attribute XML files. FAPI2_ATTR_XML += $(wildcard $(ROOTPATH)/src/import/chips/p9/procedures/xml/attribute_info/*) FAPI2_ATTR_XML += $(wildcard $(ROOTPATH)/src/import/hwpf/fapi2/xml/attribute_info/*) +# Filter out Temp defaults XML file from Attribute XML files. +# NOTE: The hb_temp_defaults.xml file is not a normal attribute file with the +# normal structures that define the attribute itself. It temporarily +# provides default values for new attributes defined in other files. +FAPI2_ATTR_XML := $(filter-out ${HB_TEMP_DFLT_SOURCES},$(FAPI2_ATTR_XML)) + XMLTOHB_FAPIATTR_SOURCES += ${FAPI2_ATTR_XML} @@ -71,37 +85,47 @@ XMLTOHB_GENERIC_SOURCES += ${XMLTOHB_HB_ATTRIBUTE_SOURCES} XMLTOHB_GENERIC_SOURCES += ${GENDIR}/${XMLTOHB_MERGED_COMMON_TARGET_SOURCES} XMLTOHB_GENERIC_SOURCES += ${XMLTOHB_HB_TARGET_SOURCES} +TEMP_DEFAULT_SOURCES = tempdefaults.xml + #XML target types merge script XMLTOHB_TARGET_MERGE_SCRIPT = updatetargetxml.pl +#XML temp defaults merge script +XMLTOHB_TEMPS_MERGE_SCRIPT = updatetempsxml.pl + VMM_CONSTS_FILE = \ ${ROOTPATH}/src/include/usr/vmmconst.h GENFILES = ${XMLTOHB_TARGETS} #debug : -# @echo COMMON_TARGETING_PATH_PREFIX = ${COMMON_TARGETING_PATH_PREFIX} -# @echo COMMON_TARGETING_REL_PATH = ${COMMON_TARGETING_REL_PATH} -# @echo COMMON_TARGETING_MAKEFILE = ${COMMON_TARGETING_MAKEFILE} -# @echo XMLTOHB_HEADER_TARGETS = ${XMLTOHB_HEADER_TARGETS} -# @echo XMLTOHB_SOURCE_TARGETS = ${XMLTOHB_SOURCE_TARGETS} -# @echo XMLTOHB_SYSTEM_BINARIES = ${XMLTOHB_SYSTEM_BINARIES} -# @echo XMLTOHB_TARGETS = ${XMLTOHB_TARGETS} -# @echo XMLTOHB_GENERIC_SOURCES = ${XMLTOHB_GENERIC_SOURCES} -# @echo FAPI_ATTR_SOURCES = ${FAPI_ATTR_SOURCES} -# @echo FAPI_ATTR_SOURCE_DIR = ${FAPI_ATTR_SOURCE_DIR} -# @echo XMLTOHB_FAPIATTR_SOURCES = ${XMLTOHB_FAPIATTR_SOURCES} -# @echo XMLTOHB_COMMON_ATTRIBUTE_SOURCES = ${XMLTOHB_COMMON_ATTRIBUTE_SOURCES} -# @echo XMLTOHB_COMMON_TARGET_SOURCES = ${XMLTOHB_COMMON_TARGET_SOURCES} -# @echo XMLTOHB_HB_ATTRIBUTE_SOURCES = ${XMLTOHB_HB_ATTRIBUTE_SOURCES} -# @echo XMLTOHB_HB_TARGET_SOURCES = ${XMLTOHB_HB_TARGET_SOURCES} -# @echo XMLTOHB_MERGED_COMMON_TARGET_SOURCES = ${XMLTOHB_MERGED_COMMON_TARGET_SOURCES} -# @echo VPATH = ${VPATH} +# @echo COMMON_TARGETING_PATH_PREFIX = ${COMMON_TARGETING_PATH_PREFIX} +# @echo COMMON_TARGETING_REL_PATH = ${COMMON_TARGETING_REL_PATH} +# @echo COMMON_TARGETING_MAKEFILE = ${COMMON_TARGETING_MAKEFILE} +# @echo XMLTOHB_HEADER_TARGETS = ${XMLTOHB_HEADER_TARGETS} +# @echo XMLTOHB_SOURCE_TARGETS = ${XMLTOHB_SOURCE_TARGETS} +# @echo XMLTOHB_SYSTEM_BINARIES = ${XMLTOHB_SYSTEM_BINARIES} +# @echo XMLTOHB_TARGETS = ${XMLTOHB_TARGETS} +# @echo XMLTOHB_GENERIC_SOURCES = ${XMLTOHB_GENERIC_SOURCES} +# @echo FAPI_ATTR_SOURCE_DIR = ${FAPI_ATTR_SOURCE_DIR} +# @echo FAPI_ATTR_SOURCES = ${FAPI_ATTR_SOURCES} +# @echo XMLTOHB_FAPIATTR_SOURCES = ${XMLTOHB_FAPIATTR_SOURCES} +# @echo HB_TEMP_DFLT_SOURCES = ${HB_TEMP_DFLT_SOURCES} +# @echo XMLTOHB_COMMON_ATTRIBUTE_SOURCES = ${XMLTOHB_COMMON_ATTRIBUTE_SOURCES} +# @echo XMLTOHB_COMMON_TARGET_SOURCES = ${XMLTOHB_COMMON_TARGET_SOURCES} +# @echo TEMP_DEFAULT_SOURCES = ${TEMP_DEFAULT_SOURCES} +# @echo XMLTOHB_HB_ATTRIBUTE_SOURCES = ${XMLTOHB_HB_ATTRIBUTE_SOURCES} +# @echo XMLTOHB_HB_TARGET_SOURCES = ${XMLTOHB_HB_TARGET_SOURCES} +# @echo XMLTOHB_MERGED_COMMON_TARGET_SOURCES = ${XMLTOHB_MERGED_COMMON_TARGET_SOURCES} +# @echo TEMP_GENERIC_XML = ${TEMP_GENERIC_XML} +# @echo VPATH = ${VPATH} EXTRA_PARTS = $(addprefix $(IMGDIR)/, $(XMLTOHB_SYSTEM_BINARIES)) CLEAN_TARGETS += $(addprefix $(GENDIR)/, ${XMLTOHB_SYSTEM_BINARIES}) CLEAN_TARGETS += $(addprefix $(GENDIR)/, ${XMLTOHB_SYSTEM_BINARIES:.bin=.xml}) +CLEAN_TARGETS += ${GENDIR}/${HB_PLAT_ATTR_SRVC_H} +CLEAN_TARGETS += ${GENDIR}/${TEMP_GENERIC_XML} CLEAN_TARGETS += ${GENDIR}/${XMLTOHB_GENERIC_XML} CLEAN_TARGETS += ${GENDIR}/${XMLTOHB_FAPI_XML} CLEAN_TARGETS += ${GENDIR}/${XMLTOHB_MERGED_COMMON_TARGET_SOURCES} @@ -113,6 +137,9 @@ GENDIR_ERRL = $(ROOTPATH)/obj/genfiles/errl XMLTOHB_RAN_INDICATION = $(GENDIR)/.called_xmltohb_compiler CLEAN_TARGETS += $(XMLTOHB_RAN_INDICATION) +COPYHDR_RAN_INDICATION = $(GENDIR)/.called_copy_attrsrvhdr +CLEAN_TARGETS += $(COPYHDR_RAN_INDICATION) + include ${ROOTPATH}/config.mk # Delete any generated file on error @@ -127,16 +154,35 @@ ${GENDIR}/${XMLTOHB_MERGED_COMMON_TARGET_SOURCES}: \ ./${XMLTOHB_TARGET_MERGE_SCRIPT} $(addprefix --hb=,${COMMON_TARGETING_REL_PATH}/${XMLTOHB_HB_TARGET_SOURCES}) \ $(addprefix --common=,${COMMON_TARGETING_REL_PATH}/${XMLTOHB_COMMON_TARGET_SOURCES}) > $@ -# generic XML is created from the generic sources only -${GENDIR}/${XMLTOHB_GENERIC_XML}: \ - ${XMLTOHB_MERGE_SCRIPT} ${XMLTOHB_GENERIC_SOURCES} - $< $(wordlist 2,$(words $^),$^) > $@ - # merge all FAPI attribute files into one ${GENDIR}/${XMLTOHB_FAPI_XML}: ${XMLTOHB_MERGE_SCRIPT} \ ${XMLTOHB_FAPIATTR_SOURCES} $< $(wordlist 2,$(words $^),$^) > $@ +# copy FAPI attribute service header file +$(call GENTARGET,$(XMLTOHB_TARGETS)) : $(COPYHDR_RAN_INDICATION) +$(COPYHDR_RAN_INDICATION): ${FAPIATTRSRVC_SOURCE} + cp ${FAPIATTRSRVC_SOURCE} ${GENDIR}/${HB_PLAT_ATTR_SRVC_H} + touch $(COPYHDR_RAN_INDICATION) + +# temp generic XML is created from the generic sources only +${GENDIR}/${TEMP_GENERIC_XML}: \ + ${XMLTOHB_MERGE_SCRIPT} ${XMLTOHB_GENERIC_SOURCES} + $< $(wordlist 2,$(words $^),$^) > $@ + +# generic XML is created from temp generic XML, temporary defaults, merged FAPI +# attributes, and HB temp defaults +${GENDIR}/${XMLTOHB_GENERIC_XML}: \ + ${XMLTOHB_TEMPS_MERGE_SCRIPT} ${GENDIR}/${TEMP_GENERIC_XML} \ + ${GENDIR}/${XMLTOHB_FAPI_XML} \ + ${HB_TEMP_DFLT_SOURCES} ${TEMP_DEFAULT_SOURCES} + ./${XMLTOHB_TEMPS_MERGE_SCRIPT} \ + --generic=${GENDIR}/${TEMP_GENERIC_XML} \ + --fapi=${GENDIR}/${XMLTOHB_FAPI_XML} \ + --fapi_inc=${GENDIR}/${HB_PLAT_ATTR_SRVC_H} \ + --fw_dflts=${HB_TEMP_DFLT_SOURCES} \ + --defaults=${COMMON_TARGETING_REL_PATH}/${TEMP_DEFAULT_SOURCES} > $@ + # create the header files, only needs generic xml $(call GENTARGET,$(XMLTOHB_TARGETS)) : $(XMLTOHB_RAN_INDICATION) $(XMLTOHB_RAN_INDICATION): ${XMLTOHB_COMPILER_SCRIPT} \ diff --git a/src/usr/targeting/xmltohb/updatetempsxml.pl b/src/usr/targeting/xmltohb/updatetempsxml.pl new file mode 100755 index 000000000..f8bd350b6 --- /dev/null +++ b/src/usr/targeting/xmltohb/updatetempsxml.pl @@ -0,0 +1,742 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/targeting/xmltohb/updatetempsxml.pl $ +# +# OpenPOWER HostBoot Project +# +# Contributors Listed Below - COPYRIGHT 2012,2016 +# [+] International Business Machines Corp. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG + +# +# Original file, updatetargetxml.pl, created for fsp. +# File copied to Hostboot and modified +# File used as basis for updatetempsxml.pl +# +# Usage: +# +# updatetempsxml --generic=temp_generic.xml +# --fapi=fapiattrs.xml +# --fapi_inc=fapi2PlatAttrService.H +# --fw_dflts=hb_temp_defaults.xml +# --defaults=tempdefaults.xml +# +# Purpose: +# +# This perl script processes the fapiattrs.xml and hb_temp_defaults.xml +# files to find any new attributes which need to be defined in the +# generic.xml file. It also process the tempdefaults.xml file to find the +# <tempDefault> tags and any new attribute definitions so that generic.xml +# can be updated with default values and attribute definitions as needed. +# The updated generic.xml is written to the console. +# + +use strict; +use XML::Simple; +use Data::Dumper; + + +$XML::Simple::PREFERRED_PARSER = 'XML::Parser'; + +my $generic = ""; +my $fapi = ""; +my $fapi_inc = ""; +my $fw_dflts = ""; +my $defaults = ""; +my $usage = 0; +use Getopt::Long; +GetOptions( "generic:s" => \$generic, + "fapi:s" => \$fapi, + "fapi_inc:s" => \$fapi_inc, + "fw_dflts:s" => \$fw_dflts, + "defaults:s" => \$defaults, + "help" => \$usage, ); + +if (($generic eq "") || ($fapi eq "") || ($fapi_inc eq "") || + ($fw_dflts eq "") || ($defaults eq "")) +{ + display_help(); + exit 1; +} +elsif ($usage) +{ + display_help(); + exit 0; +} + + +open (FH, "<$generic") || + die "ERROR: unable to open $generic\n"; +close (FH); + +my $genericXml = XMLin("$generic"); +my $genericXmlArray = XMLin("$generic", ForceArray=>1); + +open (FH, "<$fapi") || + die "ERROR: unable to open $fapi\n"; +close (FH); + +my $fapiXml = XMLin("$fapi", ForceArray=>1); + +open (FH, "<$fapi_inc") || + die "ERROR: unable to open $fapi_inc\n"; +close (FH); + +open (FH, "<$fw_dflts") || + die "ERROR: unable to open $fw_dflts\n"; +close (FH); + +my $fwDfltsXml = XMLin("$fw_dflts", ForceArray=>1); + +open (FH, "<$defaults") || + die "ERROR: unable to open $defaults\n"; +close (FH); + +my $defaultsXml = XMLin("$defaults", ForceArray=>1); + + +# Walk through temp_generic.xml file looking for target types +my @TgtTypeInfo; + +foreach my $TgtType ( @{$genericXmlArray->{targetType}} ) +{ + my $TgtTypeType = ""; + my $TgtTypeAttrIds = " "; + + # Find attributes for this target type + foreach my $TgtTypeAttr ( @{$TgtType->{attribute}} ) + { + # Find default for TYPE attribute + if($TgtTypeAttr->{id}->[0] eq "TYPE") + { + if(exists $TgtTypeAttr->{default}) + { + $TgtTypeType = $TgtTypeAttr->{default}->[0]; + } + elsif($TgtType->{id}->[0] ne "base") + { + print STDERR "Target ".$TgtType->{id}->[0]. + " has TYPE attribute without a value\n"; + } + } + # Record IDs of all other attributes for this target type + else + { + $TgtTypeAttrIds .= $TgtTypeAttr->{id}->[0]." "; + } + } + + # Create entry with information for this target type + if($TgtTypeType ne "") + { + push @TgtTypeInfo, [ $TgtType->{id}->[0], $TgtTypeType, + $TgtTypeAttrIds ]; + } +} + + +# Walk through hb_temp_defaults.xml file looking for new FAPI attributes +my @NewAttr; +my @UpdtTgt; + +foreach my $TempAttr ( @{$fwDfltsXml->{attribute}} ) +{ + my $fapi_attr = ""; + my $fapi_id = $TempAttr->{id}->[0]; +# print STDERR "Processing FAPI Id $fapi_id\n"; + my $generic_id = $fapi_id; + $generic_id =~ s/ATTR_//; + my $found = 0; + + # First, check if attribute definition exists in fapiattrs.xml + foreach my $FapiAttr ( @{$fapiXml->{attribute}} ) + { + if ($FapiAttr->{id}->[0] eq $fapi_id) + { + $found = 1; + $fapi_attr = $FapiAttr; + + # Check if FAPI attribute is associated with specific target types + if (exists $FapiAttr->{targetType}) + { + my @types = split(',',$FapiAttr->{targetType}->[0]); + foreach my $type(@types) + { + $type =~ s/\s//g; + $type =~ s/TARGET_TYPE_//; + $type =~ s/_ENDPOINT//; + $type =~ s/_CHIPLET//; + $type =~ s/_CHIP//; + + # Loop through target type info from temp_generic.xml file + for my $i ( 0 .. $#TgtTypeInfo) + { + # Check for entry of specified target type without a + # definition of the given attribute + if(($TgtTypeInfo[$i][1] eq $type) && + !($TgtTypeInfo[$i][2] =~ /\s$generic_id\s/)) + { + # Determine if default exists for the update + if (exists $TempAttr->{default}) + { + push @UpdtTgt, [ $TgtTypeInfo[$i][0], $type, + $generic_id, + $TempAttr->{default}->[0]]; + } + else + { + push @UpdtTgt, [ $TgtTypeInfo[$i][0], $type, + $generic_id, ""]; + } + } + elsif($TgtTypeInfo[$i][2] =~ /\s$generic_id\s/) + { + print STDERR "Target $TgtTypeInfo[$i][0] of type ". + "$type already has attribute $generic_id\n"; + } + } + } + } + + last; + } + } + die "FATAL: FAPI attribute definition not found in $fapi for " + . "$fapi_id\n" if($found == 0); + + # Second, check if handling already exists in fapi2PlatAttrService.H + $found = 0; + open (FH, "<$fapi_inc"); + while (my $line = <FH>) + { + # Check if line starts a GETMACRO or SETMACRO #define statement + if (($line =~ /^\s*\#define\s*(ATTR_.*)_(.ETMACRO).*/) && + ($1 eq $fapi_id)) + { + print STDERR "Existing handling found in $fapi_inc for " + . "$fapi_id\n"; + $found = 1; + last; + } + } + close (FH); + next if($found); + + # Third, check if mapping already exists in generic.xml + $found = 0; + foreach my $GenericAttr ( @{$genericXmlArray->{attribute}} ) + { + # Check for attribute mapping + if (exists $GenericAttr->{hwpfToHbAttrMap}) + { + my $GenericMap = $GenericAttr->{hwpfToHbAttrMap}->[0]; + + # Check if FAPI and generic attributes are mapped to each other + if ($GenericMap->{id}->[0] eq $fapi_id) + { + print STDERR "Existing mapping found in $generic for " + . "$fapi_id\n"; + $found = 1; + last; + } + } + } + next if($found); + + # Collect information for creating attribute and enumeration definitions + my $description = $fapi_attr->{description}->[0]; + + my $valueType = $fapi_attr->{valueType}->[0]; + $valueType =~ s/(uint\d*)/$1_t/ if($valueType =~ /^uint\d*/); + + my $fwDefault = ""; + if (exists $TempAttr->{default}) + { + $fwDefault = $TempAttr->{default}->[0]; + } + + my $array = ""; + if(exists $fapi_attr->{array}) + { + my @dimensions = split(' ',$fapi_attr->{array}->[0]); + $array = @dimensions[0]; + for my $i ( 1 .. $#dimensions ) + { + $array .= ",$dimensions[$i]"; + } + } + + my $persistency = "volatile"; + + # Create enumeration definition to support generic attribute if FAPI + # attribute associated with temp FW default uses enum + my $enum_id = ""; + my $enumDefault = ""; + if(exists $fapi_attr->{enum}) + { + $enum_id = $generic_id; + push @NewAttr, [ "<enumerationType>\n" ]; + push @NewAttr, [ " <id>$enum_id</id>\n" ]; + push @NewAttr, [ " <description>\n" ]; + push @NewAttr, [ " Enumeration for FAPI attribute $fapi_id\n" ]; + push @NewAttr, [ " </description>\n" ]; + + my @enum_defs = split(',',$fapi_attr->{enum}->[0]); + for my $i ( 0 .. $#enum_defs ) + { + $enum_defs[$i] =~ /^\s*(.*)\s*=\s*(.*)\s*/; + my $enumName = $1; + my $enumValue = $2; + $enumName =~ s/ //; + $enumDefault = $enumName if($fwDefault eq $enumValue); + push @NewAttr, [ " <enumerator>\n" ]; + push @NewAttr, [ " <name>$enumName</name>\n" ]; + push @NewAttr, [ " <value>$enumValue</value>\n" ]; + push @NewAttr, [ " </enumerator>\n" ]; + } + + push @NewAttr, [ " <default>$enumDefault</default>\n" ] + if($enumDefault ne ""); + + push @NewAttr, [ "</enumerationType>\n\n" ]; + } + + # Create generic attribute with mapping + push @NewAttr, [ "<attribute>\n" ]; + push @NewAttr, [ " <id>$generic_id</id>\n" ]; + push @NewAttr, [ " <description>\n" ]; + push @NewAttr, [ " $description\n" ]; + push @NewAttr, [ " </description>\n" ]; + push @NewAttr, [ " <simpleType>\n" ]; + if($enumDefault ne "") + { + push @NewAttr, [ " <enumeration>\n" ]; + push @NewAttr, [ " <id>$enum_id</id>\n" ]; + push @NewAttr, [ " <default>$enumDefault</default>\n" ]; + push @NewAttr, [ " </enumeration>\n" ]; + } + elsif($fwDefault ne "") + { + push @NewAttr, [ " <$valueType>\n" ]; + push @NewAttr, [ " <default>$fwDefault</default>\n" ]; + push @NewAttr, [ " </$valueType>\n" ]; + } + elsif($enum_id ne "") + { + push @NewAttr, [ " <enumeration>\n" ]; + push @NewAttr, [ " <id>$enum_id</id>\n" ]; + push @NewAttr, [ " </enumeration>\n" ]; + } + else + { + push @NewAttr, [ " <$valueType></$valueType>\n" ]; + } + push @NewAttr, [ " <array>$array</array>\n" ] if($array ne ""); + push @NewAttr, [ " </simpleType>\n" ]; + push @NewAttr, [ " <persistency>$persistency</persistency>\n" ]; + push @NewAttr, [ " <readable/>\n" ]; + push @NewAttr, [ " <writeable/>\n" ] if(exists $fapi_attr->{writeable}); + push @NewAttr, [ " <hasStringConversion/>\n" ] if($enum_id ne ""); + push @NewAttr, [ " <hwpfToHbAttrMap>\n" ]; + push @NewAttr, [ " <id>$fapi_id</id>\n" ]; + push @NewAttr, [ " <macro>DIRECT</macro>\n" ]; + push @NewAttr, [ " </hwpfToHbAttrMap>\n" ]; + push @NewAttr, [ " <tempAttribute/>\n" ]; + push @NewAttr, [ "</attribute>\n" ]; + push @NewAttr, [ "\n" ]; +} + + +# Check tempdefaults.xml for <tempDefault> entries which are setting temporary +# default values for existing attributes going into the generic.xml file +my @ChgAttr; + +foreach my $Default ( @{$defaultsXml->{tempDefault}} ) +{ + foreach my $attr ( @{$Default->{attribute}} ) + { + my $attribute_id = $attr->{id}->[0]; + my $default = ""; + my $force = "n"; + + # Check entry for setting a default value + if (exists $attr->{default}) + { + $default = $attr->{default}->[0]; + } + + # Check entry for forcing the default setting + if (exists $attr->{force}) + { + $force = "y"; + } + + # Check that the temporary default is for an existing attribute + if (exists $genericXml->{attribute}->{$attribute_id}) + { + # Check that temporary default was set for the attribute, that is, + # <default> was specified and value was set + if (($default ne "") && !($default =~ /^HASH\(0x.*\)/)) + { +# print STDERR "[ $attribute_id, $default, $force ]\n"; + push @ChgAttr, [ $attribute_id, $default, $force ]; + } + else + { + die "ERROR: Attribute $attribute_id default not specified\n"; + } + } + else + { + die "ERROR: Attribute $attribute_id definition not found\n"; + } + } +} + + +# Check tempdefaults.xml for <attribute> and <enumerationType> entries to be +# appended to the generic.xml file and for <tempDefault> entries to be ignored. +# Save <attribute> and <enumerationType> entry lines in @NewAttr so that they +# can be appended to the generic.xml file later. +use constant +{ + stateFindEntry => 0, # Find start of an <attribute>, + # <enumerationType>, or <tempDefault> entry + # in the tempdefaults.xml file + stateFindID => 1, # Find ID field in the current entry + stateFindEntryEnd => 2, # Find end of the current entry + stateTempDefault => -1, # Find end of the <tempDefault> entry +}; + +my $state = stateFindEntry; # First find an entry +my $count = 0; +my $id = ""; +my $type = ""; + +open (FH, "<$defaults"); + +while (my $line = <FH>) +{ + # Check if line starts an <attribute> and <enumerationType> entry + if ($state == stateFindEntry && + $line =~ /^\s*<(attribute|enumerationType)>.*/) + { + $state = stateFindID; # Next find the ID within this entry + $type = $1; + push @NewAttr, [ $line ]; + $count = 1; + } + # Check if line specifies the ID of the entry + elsif ($state == stateFindID && $line =~ /^\s*<id>/) + { + $state = stateFindEntryEnd; # Now find the end of this entry + $id = $line; + $id =~ s/\n//; + $id =~ s/.*<id>(.*)<\/id>.*/$1/; + + # Check that the ID doesn't already exist in the generic.xml data + if (exists $genericXml->{$type}->{$id}) + { + print STDERR "Attribute $id definition already exists\n"; + + # Ignore the tempdefaults.xml definition + $state = stateFindEntry; # Find another entry + for my $i ( 1 .. $count ) + { + pop @NewAttr; + } + $count = 0; + } + else + { + push @NewAttr, [ $line ]; + $count += 1; + } + } + # Check if line ends the <attribute> and <enumerationType> entry + elsif ($state == stateFindEntryEnd && $line =~ /^\s*<\/$type>.*/) + { + $state = stateFindEntry; # Find another entry + push @NewAttr, [ $line ]; + push @NewAttr, [ "\n" ]; + $count = 0; + } + # Save each line of the entry + elsif ($state == stateFindID || $state == stateFindEntryEnd) + { + push @NewAttr, [ $line ]; + $count += 1; + } + # Check if line starts a <tempDefault> entry that can be ignored + elsif ($state == stateFindEntry && $line =~ /^\s*<(tempDefault)>.*/) + { + $state = stateTempDefault; # Now find the end of <tempDefault> entry + $type = $1; + } + # Check if line ends the <tempDefault> entry + elsif ($state == stateTempDefault && $line =~ /^\s*<\/$type>.*/) + { + $state = stateFindEntry; # Find another entry + } +} + +close (FH); + + +# Check input temp_generic.xml file for attributes which have a temporary +# default defined in tempdefaults.xml file. When an attribute with a temporary +# default is found, either create a default value in the generic.xml data if a +# value does not exist or substitute the default value in the generic.xml data +# if the temporary value is being forced. +# +# Check input temp_generic.xml file for targets which have a temporary default +# defined in hb_temp_defaults.xml file. Use data from @UpdtTgt to update a +# <targetType> entry for a matching target. +# +# Append <attribute> and <enumerationType> entry lines from @NewAttr before +# ending the attributes section of the generic.xml file. +use constant +{ + stateFindEntry => 0, # Find start of an <attribute> or + # <targetType> entry in the + # temp_generic.xml file + stateFindAttrID => 1, # Find ID field in the <attribute> entry + stateFindAttrDataType => 2, # Find data type of the <attribute> entry + stateFindMultiTypeLns => 3, # Find multiple lines for data type + stateFindDefaultEnd => 4, # Find end of the default definition + stateMaxAttr => 9, # Maximum value for attribute states + stateFindTgtTypeID => 11, # Find ID field in the <targetType> entry + stateFindTgtTypeEnd => 12, # Find end of the <targetType> entry +}; + +$state = stateFindEntry; # First find an entry + +open (FH, "<$generic"); + +while (my $line = <FH>) +{ + # Check if line starts an <attribute> entry + if ($state < stateMaxAttr && $line =~ /^\s*<attribute>.*/) + { + $state = stateFindAttrID; # Next find the ID within attribute entry + } + # Check if line starts a <targetType> entry + elsif ($state == stateFindEntry && $line =~ /^\s*<targetType>.*/) + { + $state = stateFindTgtTypeID; # Next find ID within target type entry + } + # Check if line specifies the ID of the entry + elsif (($state == stateFindAttrID || $state == stateFindTgtTypeID) && + $line =~ /^\s*<id>/) + { + $state += 1; # Increment to the next state, find data type of the + # <attribute> entry or end of the <targetType> entry + $id = $line; + $id =~ s/\n//; + $id =~ s/.*<id>(.*)<\/id>.*/$1/; + } + # Check if line specifies the data type of the entry + elsif ($state == stateFindAttrDataType && + $line =~ /^.*<(uint8_t|uint16_t|uint32_t|uint64_t| + hbmutex|enumeration)>/) + { + $type = $1; + my $definition = $line; + # If the data type is specified on a single line + if ($definition =~ /^\s*(.*)<$type>(.*)<\/$type>(.*)/) + { + $state = stateFindEntry; # Find another entry + my $pre = $1; + $definition = $2; + my $post = $3; + $post =~ s/\n//; + + # Go through temporary default data + for my $i ( 0 .. $#ChgAttr ) + { + # If ID of temporary default data matches ID of file entry + if ($ChgAttr[$i][0] eq $id) + { + # If file entry already has a default defined + if ($definition =~ /^.*<default>(.*)<\/default>.*/) + { + # Check if temporary default is not being forced + if ($ChgAttr[$i][2] eq "n") + { + print STDERR + "Attribute $id default already exists\n"; + } + else + { + # Substitute temporary default value + $line =~ s/<default>$1/<default>$ChgAttr[$i][1]/; + } + } + else # Create a default definition using temporary default + { + print " $pre<$type>\n"; + print " <default>$ChgAttr[$i][1]"; + print "</default>\n"; + print " $definition\n" if($definition ne ""); + $line = " </$type>$post\n"; + } + + last; + } + } + } + else + { + $state = stateFindMultiTypeLns; # Look for data type definition + # across multiple lines + } + } + # Check if line specifies a default value for a multi line data type def + elsif ($state == stateFindMultiTypeLns && $line =~ /^\s*<default>.*/) + { + $state = stateFindEntry; # Find another entry + # Go through temporary default data + for my $i ( 0 .. $#ChgAttr ) + { + # If ID of temporary default data matches ID of file entry + if ($ChgAttr[$i][0] eq $id) + { + # Check if temporary default is not being forced + if ($ChgAttr[$i][2] eq "n") + { + print STDERR "Attribute $id default already exists\n"; + } + # If the default is specified on a single line + elsif ($line =~ /^\s*<default>(.*)<\/default>.*/) + { + # Substitute temporary default value + $line =~ s/<default>$1/<default>$ChgAttr[$i][1]/; + } + else # Start a default definition using temporary default + { + $state = stateFindDefaultEnd; # Look for end of default + # definition + print " <default>"; + print " $ChgAttr[$i][1]"; + } + + last; + } + } + } + # Check if line ends a multi line data type definition + elsif ($state == stateFindMultiTypeLns && $line =~ /^\s*<\/$type>.*/) + { + $state = stateFindEntry; # Find another entry + # Go through temporary default data + for my $i ( 0 .. $#ChgAttr ) + { + # If ID of temporary default data matches ID of file entry + if ($ChgAttr[$i][0] eq $id) + { + # Create a default definition using temporary default + print " <default>$ChgAttr[$i][1]</default>\n"; + } + + last; + } + } + # Check if line ends default definition for multi line data type definition + elsif ($state == stateFindDefaultEnd && $line =~ /^\s*<\/default>.*/) + { + $state = stateFindEntry; # Find another entry + } + # Check if line ends an <attribute> entry + elsif ($state < stateMaxAttr && $line =~ /^\s*<\/attribute>.*/) + { + $state = stateFindEntry; # Find another entry + } + # Check if line ends a <targetType> entry + elsif ($state == stateFindTgtTypeEnd && $line =~ /^\s*<\/targetType>.*/) + { + $state = stateFindEntry; # Find another entry + # Go through update target data + for my $i ( 0 .. $#UpdtTgt ) + { + # If ID of update target data matches ID of file entry + if ($UpdtTgt[$i][0] eq $id) + { + # Create new attribute entry for this target + print " <attribute>\n"; + print " <id>$UpdtTgt[$i][2]</id>\n"; + if ($UpdtTgt[$i][3] ne "") + { + print " <default>$UpdtTgt[$i][3]</default>\n"; + } + print " </attribute>\n"; + } + } + } + # Check if line ends the attributes in the input temp_generic.xml file + elsif ($line =~ /^\s*<\/attributes>.*/) + { + # Go through new temporary attribute entries from tempdefaults.xml + for my $i ( 0 .. $#NewAttr ) + { + print "$NewAttr[$i][0]"; + } + } + + print "$line" if $state != stateFindDefaultEnd; +} + +close (FH); + + +sub display_help +{ + use File::Basename; + my $scriptname = basename($0); + print STDERR " +Description: + + This perl script processes the fapiattrs.xml and hb_temp_defaults.xml + files to find any new attributes which need to be defined in the + generic.xml file. It also process the tempdefaults.xml file to find the + <tempDefault> tags and any new attribute definitions so that generic.xml + can be updated with default values and attribute definitions as needed. + The updated generic.xml is written to the console. + +Usage: + + $scriptname --help + $scriptname --generic=genericfname + --fapi=fapifname + --fapi_inc=fapiincfname + --fw_dflts=fwdfltsfname + --defaults=defaultsfname + --generic=genericfname + genericfname is complete pathname of the generic.xml file + --fapi=fapifname + fapifname is complete pathname of the fapiattrs.xml file + --fapi_inc=fapiincfname + fapiincfname is complete pathname of the + fapi2PlatAttrService.H file + --fw_dflts=fwdfltsfname + fwdfltsfname is complete pathname of the + hb_temp_defaults.xml file + --defaults=defaultsfname + defaultsfname is complete pathname of the tempdefaults.xml file +\n"; +} |