| 1 | package platforms |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "review.coreboot.org/coreboot.git/util/intelp2m/config/p2m" |
| 7 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/adl" |
| 8 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/apl" |
| 9 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/cnl" |
| 10 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/common" |
| 11 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/ebg" |
| 12 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/ehl" |
| 13 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/jsl" |
| 14 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/lbg" |
| 15 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/mtl" |
| 16 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/snr" |
| 17 | "review.coreboot.org/coreboot.git/util/intelp2m/platforms/tgl" |
| 18 | ) |
| 19 | |
| 20 | type Constructor func(dw0, dw1 uint32) common.PlatformIf |
| 21 | |
| 22 | var ErrUnregisteredPlatform = fmt.Errorf("unregistered platform type %d", p2m.Config.Platform) |
| 23 | |
| 24 | var platformConstructorMap = map[p2m.PlatformType]Constructor{ |
| 25 | p2m.Alder: adl.GetPlatform, |
| 26 | p2m.Apollo: apl.GetPlatform, |
| 27 | p2m.Cannon: cnl.GetPlatform, |
| 28 | p2m.Sunrise: snr.GetPlatform, |
| 29 | p2m.Tiger: tgl.GetPlatform, |
| 30 | p2m.Jasper: jsl.GetPlatform, |
| 31 | p2m.Meteor: mtl.GetPlatform, |
| 32 | p2m.Emmitsburg: ebg.GetPlatform, |
| 33 | p2m.Lewisburg: lbg.GetPlatform, |
| 34 | p2m.Elkhart: ehl.GetPlatform, |
| 35 | } |
| 36 | |
| 37 | var GppMap = map[p2m.PlatformType][]string{ |
| 38 | p2m.Alder: adl.GPPGroups, |
| 39 | p2m.Apollo: apl.GPPGroups, |
| 40 | p2m.Cannon: cnl.GPPGroups, |
| 41 | p2m.Sunrise: snr.GPPGroups, |
| 42 | p2m.Tiger: tgl.GPPGroups, |
| 43 | p2m.Jasper: jsl.GPPGroups, |
| 44 | p2m.Meteor: mtl.GPPGroups, |
| 45 | p2m.Emmitsburg: ebg.GPPGroups, |
| 46 | p2m.Lewisburg: lbg.GPPGroups, |
| 47 | p2m.Elkhart: ehl.GPPGroups, |
| 48 | } |
| 49 | |
| 50 | func GetConstructor() (Constructor, error) { |
| 51 | constructor, exist := platformConstructorMap[p2m.Config.Platform] |
| 52 | if !exist { |
| 53 | return nil, ErrUnregisteredPlatform |
| 54 | } |
| 55 | return constructor, nil |
| 56 | } |
| 57 | |
| 58 | func GetGPPGroups() ([]string, error) { |
| 59 | groups, exist := GppMap[p2m.Config.Platform] |
| 60 | if !exist { |
| 61 | return nil, ErrUnregisteredPlatform |
| 62 | } |
| 63 | return groups, nil |
| 64 | } |