Debian Codegraph @

util/intelp2m/config/p2m/config.go

raw symbols SCIP
1 package p2m
2
3 import (
4 "fmt"
5 )
6
7 type PlatformType int
8 type FieldType int
9
10 const (
11 Sunrise PlatformType = iota
12 Lewisburg
13 Apollo
14 Cannon
15 Alder
16 Jasper
17 Tiger
18 Meteor
19 Emmitsburg
20 Elkhart
21 )
22
23 const (
24 NoFlds FieldType = iota
25 CbFlds // coreboot style
26 FspFlds // FSP/edk2 style
27 RawFlds // raw DW0/1 values
28 )
29
30 var platforms = map[string]PlatformType{
31 "snr": Sunrise,
32 "lbg": Lewisburg,
33 "apl": Apollo,
34 "cnl": Cannon,
35 "tgl": Tiger,
36 "adl": Alder,
37 "jsl": Jasper,
38 "mtl": Meteor,
39 "ebg": Emmitsburg,
40 "ehl": Elkhart,
41 }
42
43 var fields = map[string]FieldType{
44 "none": NoFlds,
45 "cb": CbFlds,
46 "fsp": FspFlds,
47 "raw": RawFlds,
48 }
49
50 type Settings struct {
51 Version string
52 Platform PlatformType
53 Field FieldType
54 InputPath string
55 OutputPath string
56 LogsPath string
57 IgnoredFields bool
58 AutoCheck bool
59 GenLevel int
60 }
61
62 var defaultConfig = Settings{
63 Version: "unknown",
64 Platform: Sunrise,
65 Field: NoFlds,
66 IgnoredFields: false,
67 AutoCheck: true,
68 GenLevel: 0,
69 }
70
71 var Config = defaultConfig
72
73 func SettingsReset() {
74 Config = defaultConfig
75 }
76
77 func SetPlatformType(format string) error {
78 if _, exist := platforms[format]; !exist {
79 return fmt.Errorf("unknown platform type %s", format)
80 }
81 Config.Platform = platforms[format]
82 return nil
83 }
84
85 func SetFieldType(format string) error {
86 if _, exist := fields[format]; !exist {
87 return fmt.Errorf("unknown field type %s", format)
88 }
89 Config.Field = fields[format]
90 return nil
91 }