blob: 62242b916c57dad34cf0322ec041a5f37b9bdd7a [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
Alicja Michalskac45d5c82024-03-29 14:01:23 +010031 TigerType uint8 = 4
32 AlderType uint8 = 5
33 JasperType uint8 = 6
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030034)
35
36var key uint8 = SunriseType
37
38var platform = map[string]uint8{
39 "snr": SunriseType,
40 "lbg": LewisburgType,
Matt DeVillier5eeead2d2020-08-09 14:13:56 -050041 "apl": ApolloType,
Michał Kopećd3b550d2022-04-06 10:15:22 +020042 "cnl": CannonType,
Alicja Michalskac45d5c82024-03-29 14:01:23 +010043 "tgl": TigerType,
Jonathon Hall1af3e3c2023-01-27 18:05:30 -050044 "adl": AlderType,
45 "jsl": JasperType,
46}
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030047func PlatformSet(name string) int {
48 if platformType, valid := platform[name]; valid {
49 key = platformType
50 return 0
51 }
52 return -1
53}
54func PlatformGet() uint8 {
55 return key
56}
57func IsPlatform(platformType uint8) bool {
58 return platformType == key
59}
60func IsPlatformApollo() bool {
61 return IsPlatform(ApolloType)
62}
63func IsPlatformSunrise() bool {
64 return IsPlatform(SunriseType)
65}
66func IsPlatformLewisburg() bool {
67 return IsPlatform(LewisburgType)
68}
Matt DeVillier5eeead2d2020-08-09 14:13:56 -050069func IsPlatformCannonLake() bool {
70 return IsPlatform(CannonType)
71}
Alicja Michalskac45d5c82024-03-29 14:01:23 +010072func IsPlatformTigerLake() bool {
73 return IsPlatform(TigerType)
74}
Michał Kopećd3b550d2022-04-06 10:15:22 +020075func IsPlatformAlderLakeH() bool {
76 return IsPlatform(AlderType)
77}
Maxim Polyakov82ec61e2020-04-26 22:12:01 +030078
79var InputRegDumpFile *os.File = nil
80var OutputGenFile *os.File = nil
81
82var ignoredFieldsFormat bool = false
83func IgnoredFieldsFlagSet(flag bool) {
84 ignoredFieldsFormat = flag
85}
86func AreFieldsIgnored() bool {
87 return ignoredFieldsFormat
88}
89
90var nonCheckingFlag bool = false
91func NonCheckingFlagSet(flag bool) {
92 nonCheckingFlag = flag
93}
94func IsNonCheckingFlagUsed() bool {
95 return nonCheckingFlag
96}
97
Maxim Polyakov726282b2020-09-30 16:46:11 +030098
99var infolevel int = 0
100func InfoLevelSet(lvl int) {
Maxim Polyakov82ec61e2020-04-26 22:12:01 +0300101 infolevel = lvl
102}
Maxim Polyakov726282b2020-09-30 16:46:11 +0300103func InfoLevelGet() int {
Maxim Polyakov82ec61e2020-04-26 22:12:01 +0300104 return infolevel
105}
106
107var fldstyle uint8 = CbFlds
108const (
109 NoFlds uint8 = 0
110 CbFlds uint8 = 1 // coreboot style
111 FspFlds uint8 = 2 // FSP/edk2 style
112 RawFlds uint8 = 3 // raw DW0/1 values
113)
114var fldstylemap = map[string]uint8{
115 "none" : NoFlds,
116 "cb" : CbFlds,
117 "fsp" : FspFlds,
118 "raw" : RawFlds}
119func FldStyleSet(name string) int {
120 if style, valid := fldstylemap[name]; valid {
121 fldstyle = style
122 return 0
123 }
124 return -1
125}
126func FldStyleGet() uint8 {
127 return fldstyle
128}
129func IsFieldsMacroUsed() bool {
130 return FldStyleGet() != NoFlds
131}
132func IsCbStyleMacro() bool {
133 return FldStyleGet() == CbFlds
134}
135func IsFspStyleMacro() bool {
136 return FldStyleGet() == FspFlds
137}
138func IsRawFields() bool {
139 return FldStyleGet() == RawFlds
140}