Maxim Polyakov has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/70307 )
Change subject: intelp2m: Drop multi-template support ......................................................................
intelp2m: Drop multi-template support
Exclude the template to parse gpio.h, since coreboot no longer has such files with raw DW register values. The new GPIO config should be generated using inteltool.log only.
Change-Id: I07124cca487f11641c4e107134efb8cfc29c6731 Signed-off-by: Maxim Polyakov max.senia.poliak@gmail.com --- M util/intelp2m/config/config.go M util/intelp2m/main.go M util/intelp2m/parser/parser.go M util/intelp2m/parser/template.go M util/intelp2m/parser/template_test.go M util/intelp2m/platforms/adl/macro.go M util/intelp2m/platforms/cnl/macro.go M util/intelp2m/platforms/lbg/macro.go M util/intelp2m/platforms/snr/macro.go 9 files changed, 84 insertions(+), 173 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/07/70307/1
diff --git a/util/intelp2m/config/config.go b/util/intelp2m/config/config.go index 4d2a700..0444ddf 100644 --- a/util/intelp2m/config/config.go +++ b/util/intelp2m/config/config.go @@ -3,32 +3,11 @@ import "os"
const ( - TempInteltool int = 0 - TempGpioh int = 1 - TempSpec int = 2 -) - -var template int = 0 - -func TemplateSet(temp int) bool { - if temp > TempSpec { - return false - } else { - template = temp - return true - } -} - -func TemplateGet() int { - return template -} - -const ( - SunriseType uint8 = 0 - LewisburgType uint8 = 1 - ApolloType uint8 = 2 - CannonType uint8 = 3 - AlderType uint8 = 4 + SunriseType uint8 = 0 + LewisburgType uint8 = 1 + ApolloType uint8 = 2 + CannonType uint8 = 3 + AlderType uint8 = 4 )
var key uint8 = SunriseType @@ -39,6 +18,7 @@ "apl": ApolloType, "cnl": CannonType, "adl": AlderType} + func PlatformSet(name string) int { if platformType, valid := platform[name]; valid { key = platformType @@ -72,6 +52,7 @@ var OutputGenFile *os.File = nil
var ignoredFieldsFormat bool = false + func IgnoredFieldsFlagSet(flag bool) { ignoredFieldsFormat = flag } @@ -80,6 +61,7 @@ }
var nonCheckingFlag bool = false + func NonCheckingFlagSet(flag bool) { nonCheckingFlag = flag } @@ -87,8 +69,8 @@ return nonCheckingFlag }
- var infolevel int = 0 + func InfoLevelSet(lvl int) { infolevel = lvl } @@ -97,17 +79,20 @@ }
var fldstyle uint8 = CbFlds + const ( - NoFlds uint8 = 0 - CbFlds uint8 = 1 // coreboot style - FspFlds uint8 = 2 // FSP/edk2 style - RawFlds uint8 = 3 // raw DW0/1 values + NoFlds uint8 = 0 + CbFlds uint8 = 1 // coreboot style + FspFlds uint8 = 2 // FSP/edk2 style + RawFlds uint8 = 3 // raw DW0/1 values ) + var fldstylemap = map[string]uint8{ - "none" : NoFlds, - "cb" : CbFlds, - "fsp" : FspFlds, - "raw" : RawFlds} + "none": NoFlds, + "cb": CbFlds, + "fsp": FspFlds, + "raw": RawFlds} + func FldStyleSet(name string) int { if style, valid := fldstylemap[name]; valid { fldstyle = style diff --git a/util/intelp2m/main.go b/util/intelp2m/main.go index a8c3c65..e1a51c8 100644 --- a/util/intelp2m/main.go +++ b/util/intelp2m/main.go @@ -61,11 +61,6 @@ flag.Bool("iiii", false, "Show target PAD_CFG() macro in the comments"), }
- template := flag.Int("t", 0, "template type number\n"+ - "\t0 - inteltool.log (default)\n"+ - "\t1 - gpio.h\n"+ - "\t2 - your template\n\t") - platform := flag.String("p", "snr", "set platform:\n"+ "\tsnr - Sunrise PCH or Skylake/Kaby Lake SoC\n"+ "\tlbg - Lewisburg PCH with Xeon SP\n"+ @@ -92,11 +87,6 @@ } }
- if !config.TemplateSet(*template) { - fmt.Printf("Error! Unknown template format of input file!\n") - os.Exit(1) - } - if valid := config.PlatformSet(*platform); valid != 0 { fmt.Printf("Error: invalid platform -%s!\n", *platform) os.Exit(1) diff --git a/util/intelp2m/parser/parser.go b/util/intelp2m/parser/parser.go index 63f24d1..e411534 100644 --- a/util/intelp2m/parser/parser.go +++ b/util/intelp2m/parser/parser.go @@ -57,12 +57,10 @@ // return the host software ownership form the parser struct func (parser *ParserData) hostOwnershipGet(id string) uint8 { var ownership uint8 = 0 - status, group := parser.platform.GroupNameExtract(id) - if config.TemplateGet() == config.TempInteltool && status { - numder, _ := strconv.Atoi(strings.TrimLeft(id, group)) - if (parser.ownership[group] & (1 << uint8(numder))) != 0 { - ownership = 1 - } + _, group := parser.platform.GroupNameExtract(id) + numder, _ := strconv.Atoi(strings.TrimLeft(id, group)) + if (parser.ownership[group] & (1 << uint8(numder))) != 0 { + ownership = 1 } return ownership } @@ -72,22 +70,17 @@ func (parser *ParserData) padInfoExtract() int { var function, id string var dw0, dw1 uint32 - var template = map[int]template{ - config.TempInteltool: UseInteltoolLogTemplate, - config.TempGpioh: useGpioHTemplate, - config.TempSpec: useYourTemplate, + if rc := UseTemplate(parser.line, &function, &id, &dw0, &dw1); rc != 0 { + return rc } - if template[config.TemplateGet()](parser.line, &function, &id, &dw0, &dw1) == 0 { - pad := padInfo{id: id, - function: function, - dw0: dw0, - dw1: dw1, - ownership: parser.hostOwnershipGet(id)} - parser.padmap = append(parser.padmap, pad) - return 0 - } - fmt.Printf("This template (%d) does not match!\n", config.TemplateGet()) - return -1 + pad := padInfo{id: id, + function: function, + dw0: dw0, + dw1: dw1, + ownership: parser.hostOwnershipGet(id)} + parser.padmap = append(parser.padmap, pad) + return 0 + }
// communityGroupExtract @@ -129,8 +122,7 @@ offset uint32, value uint32, ) { - if strings.Contains(parser.line, nameTemplate) && - config.TemplateGet() == config.TempInteltool { + if strings.Contains(parser.line, nameTemplate) { if registerInfoTemplate(parser.line, &name, &offset, &value) == 0 { fmt.Printf("\n\t/* %s : 0x%x : 0x%x */\n", name, offset, value) return true, name, offset, value @@ -157,7 +149,7 @@ // information from the inteltool log was successfully parsed. func (parser *ParserData) padConfigurationExtract() bool { // Only for Sunrise or CannonLake, and only for inteltool.log file template - if config.TemplateGet() != config.TempInteltool || config.IsPlatformApollo() { + if config.IsPlatformApollo() { return false } return parser.padOwnershipExtract() diff --git a/util/intelp2m/parser/template.go b/util/intelp2m/parser/template.go index fc67e73..e7efa73 100644 --- a/util/intelp2m/parser/template.go +++ b/util/intelp2m/parser/template.go @@ -32,7 +32,7 @@ return c != '_' && c != '#' && !unicode.IsLetter(c) && !unicode.IsNumber(c) }
-// useGpioHTemplate +// UseTemplate // line : string from file with pad config map // *function : the string that means the pad function // *id : pad id string @@ -40,9 +40,7 @@ // *dw1 : DW1 register value // return // error status -func UseInteltoolLogTemplate(line string, function *string, - id *string, dw0 *uint32, dw1 *uint32) int { - +func UseTemplate(line string, function *string, id *string, dw0 *uint32, dw1 *uint32) int { var val uint64 // 0x0520: 0x0000003c44000600 GPP_B12 SLP_S0# // 0x0438: 0xffffffffffffffff GPP_C7 RESERVED @@ -64,56 +62,6 @@ return 0 }
-// useGpioHTemplate -// line : string from file with pad config map -// *function : the string that means the pad function -// *id : pad id string -// *dw0 : DW0 register value -// *dw1 : DW1 register value -// return -// error status -func useGpioHTemplate(line string, function *string, - id *string, dw0 *uint32, dw1 *uint32) int { - - // /* RCIN# */ _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000), - // _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000), /* RCIN# */ - // _PAD_CFG_STRUCT(GPP_A0, 0x44000702, 0x00000000) - fields := strings.FieldsFunc(line, tokenCheck) - for i, field := range fields { - if field == "_PAD_CFG_STRUCT" { - if len(fields) < 4 { - /* the number of definitions does not match the format */ - return -1 - } - - if !strings.Contains(fields[i+2], "0x") || !strings.Contains(fields[i+3], "0x") { - /* definitions inside the macro do not match the pattern */ - return -1 - } - *id = fields[i+1] - fmt.Sscanf(fields[i+2], "0x%x", dw0) - fmt.Sscanf(fields[i+3], "0x%x", dw1) - *function = extractPadFuncFromComment(line) - return 0 - } - } - return -1 -} - -// useYourTemplate -func useYourTemplate(line string, function *string, - id *string, dw0 *uint32, dw1 *uint32) int { - - // ADD YOUR TEMPLATE HERE - *function = "" - *id = "" - *dw0 = 0 - *dw1 = 0 - - fmt.Printf("ADD YOUR TEMPLATE!\n") - return -1 -} - // registerInfoTemplate // line : (in) string from file with pad config map // *name : (out) register name diff --git a/util/intelp2m/parser/template_test.go b/util/intelp2m/parser/template_test.go index 98ccb3f..95f8ebf 100644 --- a/util/intelp2m/parser/template_test.go +++ b/util/intelp2m/parser/template_test.go @@ -20,7 +20,7 @@ dw0, dw1 uint32 ) line := fmt.Sprintf("0x0520: 0x%08x%08x %s %s", ref_dw1, ref_dw0, ref_id, ref_fn) - _ = parser.UseInteltoolLogTemplate(line, &fn, &id, &dw0, &dw1) + _ = parser.UseTemplate(line, &fn, &id, &dw0, &dw1) if fn != ref_fn { t.Errorf("function from '%s':\nExpects: '%s'\nActually: '%s'\n\n", line, ref_fn, fn) diff --git a/util/intelp2m/platforms/adl/macro.go b/util/intelp2m/platforms/adl/macro.go index d7b1f58..2c4b5d8 100644 --- a/util/intelp2m/platforms/adl/macro.go +++ b/util/intelp2m/platforms/adl/macro.go @@ -1,14 +1,13 @@ package adl
import ( - "strings" "fmt" + "strings"
+ "review.coreboot.org/coreboot.git/util/intelp2m/fields" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr" - "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" - "review.coreboot.org/coreboot.git/util/intelp2m/config" - "review.coreboot.org/coreboot.git/util/intelp2m/fields" )
const ( @@ -37,10 +36,6 @@ // RemmapRstSrc - remmap Pad Reset Source Config func (PlatformSpecific) RemmapRstSrc() { macro := common.GetMacro() - if config.TemplateGet() != config.TempInteltool { - // Use reset source remapping only if the input file is inteltool.log dump - return - } if strings.Contains(macro.PadIdGet(), "GPD") { // See reset map for the Alderlake GPD Group in the Community 2: // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/alderlake/gpi... @@ -51,9 +46,9 @@ dw0 := macro.Register(PAD_CFG_DW0) var remapping = map[uint8]uint32{ 0: common.RST_RSMRST << common.PadRstCfgShift, - 1: common.RST_DEEP << common.PadRstCfgShift, + 1: common.RST_DEEP << common.PadRstCfgShift, 2: common.RST_PLTRST << common.PadRstCfgShift, - 3: common.RST_PWROK << common.PadRstCfgShift, + 3: common.RST_PWROK << common.PadRstCfgShift, } resetsrc, valid := remapping[dw0.GetResetConfig()] if valid { @@ -61,7 +56,7 @@ ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()] dw0.ValueSet(ResetConfigFieldVal) } else { - fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet()) + fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc, " ] for ", macro.PadIdGet()) } dw0.CntrMaskFieldsClear(common.PadRstCfgMask) } diff --git a/util/intelp2m/platforms/cnl/macro.go b/util/intelp2m/platforms/cnl/macro.go index 5526b8f..02c47eb 100644 --- a/util/intelp2m/platforms/cnl/macro.go +++ b/util/intelp2m/platforms/cnl/macro.go @@ -1,12 +1,12 @@ package cnl
import ( - "strings" "fmt" + "strings"
- "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/config" "review.coreboot.org/coreboot.git/util/intelp2m/fields" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr" )
@@ -35,13 +35,9 @@ // RemmapRstSrc - remmap Pad Reset Source Config func (PlatformSpecific) RemmapRstSrc() { macro := common.GetMacro() - if config.TemplateGet() != config.TempInteltool { - // Use reset source remapping only if the input file is inteltool.log dump - return - } if strings.Contains(macro.PadIdGet(), "GPP_A") || - strings.Contains(macro.PadIdGet(), "GPP_B") || - strings.Contains(macro.PadIdGet(), "GPP_G") { + strings.Contains(macro.PadIdGet(), "GPP_B") || + strings.Contains(macro.PadIdGet(), "GPP_G") { // See reset map for the Cannonlake Groups the Community 0: // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/cannonlake/gp... // remmap is not required because it is the same as common. @@ -51,7 +47,7 @@ dw0 := macro.Register(PAD_CFG_DW0) var remapping = map[uint8]uint32{ 0: common.RST_RSMRST << common.PadRstCfgShift, - 1: common.RST_DEEP << common.PadRstCfgShift, + 1: common.RST_DEEP << common.PadRstCfgShift, 2: common.RST_PLTRST << common.PadRstCfgShift, } resetsrc, valid := remapping[dw0.GetResetConfig()] @@ -60,7 +56,7 @@ ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()] dw0.ValueSet(ResetConfigFieldVal) } else { - fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet()) + fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc, " ] for ", macro.PadIdGet()) } dw0.CntrMaskFieldsClear(common.PadRstCfgMask) } @@ -85,9 +81,9 @@ if !valid { str = "INVALID" fmt.Println("Error", - macro.PadIdGet(), - " invalid TERM value = ", - int(dw1.GetTermination())) + macro.PadIdGet(), + " invalid TERM value = ", + int(dw1.GetTermination())) } macro.Separator().Add(str) } @@ -146,7 +142,7 @@ macro := common.GetMacro() var ids []string macro.Set("PAD_CFG_GPI") - for routeid, isRoute := range map[string]func() (bool) { + for routeid, isRoute := range map[string]func() bool{ "IOAPIC": ioApicRoute, "SCI": sciRoute, "SMI": smiRoute, @@ -204,7 +200,7 @@ // return: string of macro // error func (PlatformSpecific) GenMacro(id string, dw0 uint32, dw1 uint32, ownership uint8) string { - macro := common.GetInstanceMacro(PlatformSpecific{InheritanceMacro : snr.PlatformSpecific{}}, + macro := common.GetInstanceMacro(PlatformSpecific{InheritanceMacro: snr.PlatformSpecific{}}, fields.InterfaceGet()) macro.Clear() macro.Register(PAD_CFG_DW0).CntrMaskFieldsClear(common.AllFields) diff --git a/util/intelp2m/platforms/lbg/macro.go b/util/intelp2m/platforms/lbg/macro.go index db34f8e..bb08e28 100644 --- a/util/intelp2m/platforms/lbg/macro.go +++ b/util/intelp2m/platforms/lbg/macro.go @@ -3,9 +3,8 @@ import ( "fmt"
- "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" - "review.coreboot.org/coreboot.git/util/intelp2m/config" "review.coreboot.org/coreboot.git/util/intelp2m/fields" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr" )
@@ -36,14 +35,10 @@ // RemmapRstSrc - remmap Pad Reset Source Config func (PlatformSpecific) RemmapRstSrc() { macro := common.GetMacro() - if config.TemplateGet() != config.TempInteltool { - // Use reset source remapping only if the input file is inteltool.log dump - return - } dw0 := macro.Register(PAD_CFG_DW0) var remapping = map[uint8]uint32{ 0: common.RST_RSMRST << common.PadRstCfgShift, - 1: common.RST_DEEP << common.PadRstCfgShift, + 1: common.RST_DEEP << common.PadRstCfgShift, 2: common.RST_PLTRST << common.PadRstCfgShift, } resetsrc, valid := remapping[dw0.GetResetConfig()] @@ -52,7 +47,7 @@ ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()] dw0.ValueSet(ResetConfigFieldVal) } else { - fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet()) + fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc, " ] for ", macro.PadIdGet()) } dw0.CntrMaskFieldsClear(common.PadRstCfgMask) } @@ -91,8 +86,8 @@ func (platform PlatformSpecific) GenMacro(id string, dw0 uint32, dw1 uint32, ownership uint8) string { // The GPIO controller architecture in Lewisburg and Sunrise are very similar, // so we will inherit some platform-dependent functions from Sunrise. - macro := common.GetInstanceMacro(PlatformSpecific{InheritanceMacro : snr.PlatformSpecific{}}, - fields.InterfaceGet()) + macro := common.GetInstanceMacro(PlatformSpecific{InheritanceMacro: snr.PlatformSpecific{}}, + fields.InterfaceGet()) macro.Clear() macro.Register(PAD_CFG_DW0).CntrMaskFieldsClear(common.AllFields) macro.Register(PAD_CFG_DW0).CntrMaskFieldsClear(common.AllFields) diff --git a/util/intelp2m/platforms/snr/macro.go b/util/intelp2m/platforms/snr/macro.go index 4e17010..5958b9f 100644 --- a/util/intelp2m/platforms/snr/macro.go +++ b/util/intelp2m/platforms/snr/macro.go @@ -1,12 +1,12 @@ package snr
import ( - "strings" "fmt" + "strings"
- "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" "review.coreboot.org/coreboot.git/util/intelp2m/config" "review.coreboot.org/coreboot.git/util/intelp2m/fields" + "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" )
const ( @@ -20,15 +20,11 @@ MAX_DW_NUM = common.MAX_DW_NUM )
-type PlatformSpecific struct {} +type PlatformSpecific struct{}
// RemmapRstSrc - remmap Pad Reset Source Config func (PlatformSpecific) RemmapRstSrc() { macro := common.GetMacro() - if config.TemplateGet() != config.TempInteltool { - // Use reset source remapping only if the input file is inteltool.log dump - return - } if strings.Contains(macro.PadIdGet(), "GPD") { // See reset map for the Sunrise GPD Group in the Community 2: // https://github.com/coreboot/coreboot/blob/master/src/soc/intel/skylake/gpio.... @@ -39,7 +35,7 @@ dw0 := macro.Register(PAD_CFG_DW0) var remapping = map[uint8]uint32{ 0: common.RST_RSMRST << common.PadRstCfgShift, - 1: common.RST_DEEP << common.PadRstCfgShift, + 1: common.RST_DEEP << common.PadRstCfgShift, 2: common.RST_PLTRST << common.PadRstCfgShift, } resetsrc, valid := remapping[dw0.GetResetConfig()] @@ -48,7 +44,7 @@ ResetConfigFieldVal := (dw0.ValueGet() & 0x3fffffff) | remapping[dw0.GetResetConfig()] dw0.ValueSet(ResetConfigFieldVal) } else { - fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc ," ] for ", macro.PadIdGet()) + fmt.Println("Invalid Pad Reset Config [ 0x", resetsrc, " ] for ", macro.PadIdGet()) } dw0.CntrMaskFieldsClear(common.PadRstCfgMask) } @@ -73,9 +69,9 @@ if !valid { str = "INVALID" fmt.Println("Error", - macro.PadIdGet(), - " invalid TERM value = ", - int(dw1.GetTermination())) + macro.PadIdGet(), + " invalid TERM value = ", + int(dw1.GetTermination())) } macro.Separator().Add(str) } @@ -146,7 +142,7 @@ macro := common.GetMacro() var ids []string macro.Set("PAD_CFG_GPI") - for routeid, isRoute := range map[string]func() (bool) { + for routeid, isRoute := range map[string]func() bool{ "IOAPIC": ioApicRoute, "SCI": sciRoute, "SMI": smiRoute,