/
arch.go
38 lines (34 loc) · 995 Bytes
/
arch.go
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
package arch
import (
"github.com/pkg/errors"
"github.com/lunixbochs/usercorn/go/arch/arm"
"github.com/lunixbochs/usercorn/go/arch/arm64"
"github.com/lunixbochs/usercorn/go/arch/m68k"
"github.com/lunixbochs/usercorn/go/arch/mips"
"github.com/lunixbochs/usercorn/go/arch/sparc"
"github.com/lunixbochs/usercorn/go/arch/x86"
"github.com/lunixbochs/usercorn/go/arch/x86_16"
"github.com/lunixbochs/usercorn/go/arch/x86_64"
"github.com/lunixbochs/usercorn/go/models"
)
var archMap = map[string]*models.Arch{
"arm": arm.Arch,
"arm64": arm64.Arch,
"m68k": m68k.Arch,
"mips": mips.Arch,
"sparc": sparc.Arch,
"x86": x86.Arch,
"x86_16": x86_16.Arch,
"x86_64": x86_64.Arch,
}
func GetArch(name, os string) (*models.Arch, *models.OS, error) {
a, ok := archMap[name]
if !ok {
return nil, nil, errors.Errorf("Arch '%s' not found.", name)
}
o, ok := a.OS[os]
if !ok {
return nil, nil, errors.Errorf("OS '%s' not found for arch '%s'.", os, name)
}
return a, o, nil
}