blob: 7b491b1eb30d5d6916a56335fa509a114b6d242e [file] [log] [blame]
Maxim Polyakov82ec61e2020-04-26 22:12:01 +03001package config
2
3import "os"
4
5const (
6 TempInteltool int = 0
7 TempGpioh int = 1
8 TempSpec int = 2
9)
10
11var template int = 0
12
13func TemplateSet(temp int) bool {
14 if temp > TempSpec {
15 return false
16 } else {
17 template = temp
18 return true
19 }
20}
21
22func TemplateGet() int {
23 return template
24}
25
26const (
27 SunriseType uint8 = 0
28 LewisburgType uint8 = 1
29 ApolloType uint8 = 2
Matt DeVillier5eeead2d2020-08-09 14:13:56 -050030 CannonType uint8 = 3
Jonathon Hall1af3e3c2023-01-27 18:05:30 -050031 AlderType uint8 = 4
32 JasperType uint8 = 5
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030033)
34
35var key uint8 = SunriseType
36
37var platform = map[string]uint8{
38 "snr": SunriseType,
39 "lbg": LewisburgType,
Matt DeVillier5eeead2d2020-08-09 14:13:56 -050040 "apl": ApolloType,
Michał Kopećd3b550d2022-04-06 10:15:22 +020041 "cnl": CannonType,
Jonathon Hall1af3e3c2023-01-27 18:05:30 -050042 "adl": AlderType,
43 "jsl": JasperType,
44}
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030045func PlatformSet(name string) int {
46 if platformType, valid := platform[name]; valid {
47 key = platformType
48 return 0
49 }
50 return -1
51}
52func PlatformGet() uint8 {
53 return key
54}
55func IsPlatform(platformType uint8) bool {
56 return platformType == key
57}
58func IsPlatformApollo() bool {
59 return IsPlatform(ApolloType)
60}
61func IsPlatformSunrise() bool {
62 return IsPlatform(SunriseType)
63}
64func IsPlatformLewisburg() bool {
65 return IsPlatform(LewisburgType)
66}
Matt DeVillier5eeead2d2020-08-09 14:13:56 -050067func IsPlatformCannonLake() bool {
68 return IsPlatform(CannonType)
69}
Michał Kopećd3b550d2022-04-06 10:15:22 +020070func IsPlatformAlderLakeH() bool {
71 return IsPlatform(AlderType)
72}
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030073
74var InputRegDumpFile *os.File = nil
75var OutputGenFile *os.File = nil
76
77var ignoredFieldsFormat bool = false
78func IgnoredFieldsFlagSet(flag bool) {
79 ignoredFieldsFormat = flag
80}
81func AreFieldsIgnored() bool {
82 return ignoredFieldsFormat
83}
84
85var nonCheckingFlag bool = false
86func NonCheckingFlagSet(flag bool) {
87 nonCheckingFlag = flag
88}
89func IsNonCheckingFlagUsed() bool {
90 return nonCheckingFlag
91}
92
Maxim Polyakov726282b2020-09-30 16:46:11 +030093
94var infolevel int = 0
95func InfoLevelSet(lvl int) {
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030096 infolevel = lvl
97}
Maxim Polyakov726282b2020-09-30 16:46:11 +030098func InfoLevelGet() int {
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030099 return infolevel
100}
101
102var fldstyle uint8 = CbFlds
103const (
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)
109var fldstylemap = map[string]uint8{
110 "none" : NoFlds,
111 "cb" : CbFlds,
112 "fsp" : FspFlds,
113 "raw" : RawFlds}
114func FldStyleSet(name string) int {
115 if style, valid := fldstylemap[name]; valid {
116 fldstyle = style
117 return 0
118 }
119 return -1
120}
121func FldStyleGet() uint8 {
122 return fldstyle
123}
124func IsFieldsMacroUsed() bool {
125 return FldStyleGet() != NoFlds
126}
127func IsCbStyleMacro() bool {
128 return FldStyleGet() == CbFlds
129}
130func IsFspStyleMacro() bool {
131 return FldStyleGet() == FspFlds
132}
133func IsRawFields() bool {
134 return FldStyleGet() == RawFlds
135}