summaryrefslogtreecommitdiff
path: root/util/intelp2m/config/config.go
blob: 9f0b75772c5573a98c925f3e056d2e388d0fc984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package config

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
)

var key uint8 = SunriseType

var platform = map[string]uint8{
	"snr": SunriseType,
	"lbg": LewisburgType,
	"apl": ApolloType}
func PlatformSet(name string) int {
	if platformType, valid := platform[name]; valid {
		key = platformType
		return 0
	}
	return -1
}
func PlatformGet() uint8 {
	return key
}
func IsPlatform(platformType uint8) bool {
	return platformType == key
}
func IsPlatformApollo() bool {
	return IsPlatform(ApolloType)
}
func IsPlatformSunrise() bool {
	return IsPlatform(SunriseType)
}
func IsPlatformLewisburg() bool {
	return IsPlatform(LewisburgType)
}

var InputRegDumpFile *os.File = nil
var OutputGenFile *os.File = nil

var ignoredFieldsFormat bool = false
func IgnoredFieldsFlagSet(flag bool) {
	ignoredFieldsFormat = flag
}
func AreFieldsIgnored() bool {
	return ignoredFieldsFormat
}

var nonCheckingFlag bool = false
func NonCheckingFlagSet(flag bool) {
	nonCheckingFlag = flag
}
func IsNonCheckingFlagUsed() bool {
	return nonCheckingFlag
}

var infolevel uint8 = 0
func InfoLevelSet(lvl uint8) {
	infolevel = lvl
}
func InfoLevelGet() uint8 {
	return infolevel
}

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
)
var fldstylemap = map[string]uint8{
	"none" : NoFlds,
	"cb"   : CbFlds,
	"fsp"  : FspFlds,
	"raw"  : RawFlds}
func FldStyleSet(name string) int {
	if style, valid := fldstylemap[name]; valid {
		fldstyle = style
		return 0
	}
	return -1
}
func FldStyleGet() uint8 {
	return fldstyle
}
func IsFieldsMacroUsed() bool {
	return FldStyleGet() != NoFlds
}
func IsCbStyleMacro() bool {
	return FldStyleGet() == CbFlds
}
func IsFspStyleMacro() bool {
	return FldStyleGet() == FspFlds
}
func IsRawFields() bool {
	return FldStyleGet() == RawFlds
}