Maxim Polyakov | 82ec61e | 2020-04-26 22:12:01 +0300 | [diff] [blame] | 1 | package config |
| 2 | |
| 3 | import "os" |
| 4 | |
| 5 | const ( |
| 6 | TempInteltool int = 0 |
| 7 | TempGpioh int = 1 |
| 8 | TempSpec int = 2 |
| 9 | ) |
| 10 | |
| 11 | var template int = 0 |
| 12 | |
| 13 | func TemplateSet(temp int) bool { |
| 14 | if temp > TempSpec { |
| 15 | return false |
| 16 | } else { |
| 17 | template = temp |
| 18 | return true |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | func TemplateGet() int { |
| 23 | return template |
| 24 | } |
| 25 | |
| 26 | const ( |
| 27 | SunriseType uint8 = 0 |
| 28 | LewisburgType uint8 = 1 |
| 29 | ApolloType uint8 = 2 |
Matt DeVillier | 5eeead2d | 2020-08-09 14:13:56 -0500 | [diff] [blame] | 30 | CannonType uint8 = 3 |
Jonathon Hall | 1af3e3c | 2023-01-27 18:05:30 -0500 | [diff] [blame^] | 31 | AlderType uint8 = 4 |
| 32 | JasperType uint8 = 5 |
Maxim Polyakov | 82ec61e | 2020-04-26 22:12:01 +0300 | [diff] [blame] | 33 | ) |
| 34 | |
| 35 | var key uint8 = SunriseType |
| 36 | |
| 37 | var platform = map[string]uint8{ |
| 38 | "snr": SunriseType, |
| 39 | "lbg": LewisburgType, |
Matt DeVillier | 5eeead2d | 2020-08-09 14:13:56 -0500 | [diff] [blame] | 40 | "apl": ApolloType, |
Michał Kopeć | d3b550d | 2022-04-06 10:15:22 +0200 | [diff] [blame] | 41 | "cnl": CannonType, |
Jonathon Hall | 1af3e3c | 2023-01-27 18:05:30 -0500 | [diff] [blame^] | 42 | "adl": AlderType, |
| 43 | "jsl": JasperType, |
| 44 | } |
Maxim Polyakov | 82ec61e | 2020-04-26 22:12:01 +0300 | [diff] [blame] | 45 | func PlatformSet(name string) int { |
| 46 | if platformType, valid := platform[name]; valid { |
| 47 | key = platformType |
| 48 | return 0 |
| 49 | } |
| 50 | return -1 |
| 51 | } |
| 52 | func PlatformGet() uint8 { |
| 53 | return key |
| 54 | } |
| 55 | func IsPlatform(platformType uint8) bool { |
| 56 | return platformType == key |
| 57 | } |
| 58 | func IsPlatformApollo() bool { |
| 59 | return IsPlatform(ApolloType) |
| 60 | } |
| 61 | func IsPlatformSunrise() bool { |
| 62 | return IsPlatform(SunriseType) |
| 63 | } |
| 64 | func IsPlatformLewisburg() bool { |
| 65 | return IsPlatform(LewisburgType) |
| 66 | } |
Matt DeVillier | 5eeead2d | 2020-08-09 14:13:56 -0500 | [diff] [blame] | 67 | func IsPlatformCannonLake() bool { |
| 68 | return IsPlatform(CannonType) |
| 69 | } |
Michał Kopeć | d3b550d | 2022-04-06 10:15:22 +0200 | [diff] [blame] | 70 | func IsPlatformAlderLakeH() bool { |
| 71 | return IsPlatform(AlderType) |
| 72 | } |
Maxim Polyakov | 82ec61e | 2020-04-26 22:12:01 +0300 | [diff] [blame] | 73 | |
| 74 | var InputRegDumpFile *os.File = nil |
| 75 | var OutputGenFile *os.File = nil |
| 76 | |
| 77 | var ignoredFieldsFormat bool = false |
| 78 | func IgnoredFieldsFlagSet(flag bool) { |
| 79 | ignoredFieldsFormat = flag |
| 80 | } |
| 81 | func AreFieldsIgnored() bool { |
| 82 | return ignoredFieldsFormat |
| 83 | } |
| 84 | |
| 85 | var nonCheckingFlag bool = false |
| 86 | func NonCheckingFlagSet(flag bool) { |
| 87 | nonCheckingFlag = flag |
| 88 | } |
| 89 | func IsNonCheckingFlagUsed() bool { |
| 90 | return nonCheckingFlag |
| 91 | } |
| 92 | |
Maxim Polyakov | 726282b | 2020-09-30 16:46:11 +0300 | [diff] [blame] | 93 | |
| 94 | var infolevel int = 0 |
| 95 | func InfoLevelSet(lvl int) { |
Maxim Polyakov | 82ec61e | 2020-04-26 22:12:01 +0300 | [diff] [blame] | 96 | infolevel = lvl |
| 97 | } |
Maxim Polyakov | 726282b | 2020-09-30 16:46:11 +0300 | [diff] [blame] | 98 | func InfoLevelGet() int { |
Maxim Polyakov | 82ec61e | 2020-04-26 22:12:01 +0300 | [diff] [blame] | 99 | return infolevel |
| 100 | } |
| 101 | |
| 102 | var fldstyle uint8 = CbFlds |
| 103 | const ( |
| 104 | NoFlds uint8 = 0 |
| 105 | CbFlds uint8 = 1 // coreboot style |
| 106 | FspFlds uint8 = 2 // FSP/edk2 style |
| 107 | RawFlds uint8 = 3 // raw DW0/1 values |
| 108 | ) |
| 109 | var fldstylemap = map[string]uint8{ |
| 110 | "none" : NoFlds, |
| 111 | "cb" : CbFlds, |
| 112 | "fsp" : FspFlds, |
| 113 | "raw" : RawFlds} |
| 114 | func FldStyleSet(name string) int { |
| 115 | if style, valid := fldstylemap[name]; valid { |
| 116 | fldstyle = style |
| 117 | return 0 |
| 118 | } |
| 119 | return -1 |
| 120 | } |
| 121 | func FldStyleGet() uint8 { |
| 122 | return fldstyle |
| 123 | } |
| 124 | func IsFieldsMacroUsed() bool { |
| 125 | return FldStyleGet() != NoFlds |
| 126 | } |
| 127 | func IsCbStyleMacro() bool { |
| 128 | return FldStyleGet() == CbFlds |
| 129 | } |
| 130 | func IsFspStyleMacro() bool { |
| 131 | return FldStyleGet() == FspFlds |
| 132 | } |
| 133 | func IsRawFields() bool { |
| 134 | return FldStyleGet() == RawFlds |
| 135 | } |