platform: introduce hardware platform abstraction

These objects describes the hardware an image runs on. Including
 - architecture
 - bootloader
 - required firmware

Use the platform abstraction to move firmware packages out of the package set
definitions.
This commit is contained in:
Tom Gundersen 2022-07-05 17:43:03 +01:00
parent 682481d4d7
commit ec8cc01f95
9 changed files with 227 additions and 141 deletions

View file

@ -0,0 +1,58 @@
package platform
type Arch uint64
const (
ARCH_AARCH64 Arch = iota
ARCH_PPC64LE
ARCH_S390X
ARCH_X86_64
)
func (a Arch) String() string {
switch a {
case ARCH_AARCH64:
return "aarch64"
case ARCH_PPC64LE:
return "ppc64le"
case ARCH_S390X:
return "s390x"
case ARCH_X86_64:
return "x86_64"
default:
panic("invalid architecture")
}
}
type Platform interface {
GetArch() Arch
GetBIOSPlatform() string
GetUEFIVendor() string
GetZiplSupport() bool
GetPackages() []string
GetBuildPackages() []string
}
type BasePlatform struct {
FirmwarePackages []string
}
func (p BasePlatform) GetBIOSPlatform() string {
return ""
}
func (p BasePlatform) GetUEFIVendor() string {
return ""
}
func (p BasePlatform) GetZiplSupport() bool {
return false
}
func (p BasePlatform) GetPackages() []string {
return p.FirmwarePackages
}
func (p BasePlatform) GetBuildPackages() []string {
return []string{}
}