diff mbox series

[02/24] golang/xenlight: generate enum types from IDL

Message ID 2bef5bfd9cc33260be663b84d2b813f28f0f3c47.1570456846.git.rosbrookn@ainfosec.com (mailing list archive)
State Superseded
Headers show
Series generated Go libxl bindings using IDL | expand

Commit Message

Nick Rosbrook Oct. 7, 2019, 3:12 p.m. UTC
From: Nick Rosbrook <rosbrookn@ainfosec.com>

Introduce gengotypes.py to generate Go code the from IDL. As a first step,
implement 'enum' type generation.

As a result of the newly-generated code, remove the existing, and now
conflicting definitions in xenlight.go. In the case of the Error type,
rename the slice 'errors' to 'libxlErrors' so that it does not conflict
with the standard library package 'errors.' And, negate the values used
in 'libxlErrors' since the generated error values are negative.

Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>
---
Cc: George Dunlap <george.dunlap@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wl@xen.org>

 tools/golang/xenlight/gengotypes.py     | 109 +++++++
 tools/golang/xenlight/xenlight.go       | 140 ++-------
 tools/golang/xenlight/xenlight_types.go | 378 ++++++++++++++++++++++++
 3 files changed, 515 insertions(+), 112 deletions(-)
 create mode 100644 tools/golang/xenlight/gengotypes.py
 create mode 100644 tools/golang/xenlight/xenlight_types.go

Comments

George Dunlap Oct. 24, 2019, 2:35 p.m. UTC | #1
On 10/7/19 4:12 PM, Nick Rosbrook wrote:
> From: Nick Rosbrook <rosbrookn@ainfosec.com>
> 
> Introduce gengotypes.py to generate Go code the from IDL. As a first step,
> implement 'enum' type generation.
> 
> As a result of the newly-generated code, remove the existing, and now
> conflicting definitions in xenlight.go. In the case of the Error type,
> rename the slice 'errors' to 'libxlErrors' so that it does not conflict
> with the standard library package 'errors.' And, negate the values used
> in 'libxlErrors' since the generated error values are negative.
> 
> Signed-off-by: Nick Rosbrook <rosbrookn@ainfosec.com>

This looks good, thanks.  Just needs to be ported after and/or merged
with the Makefile changes from 24/24.

 -George
diff mbox series

Patch

diff --git a/tools/golang/xenlight/gengotypes.py b/tools/golang/xenlight/gengotypes.py
new file mode 100644
index 0000000000..59307492cb
--- /dev/null
+++ b/tools/golang/xenlight/gengotypes.py
@@ -0,0 +1,109 @@ 
+#!/usr/bin/python
+
+import os
+import sys
+
+sys.path.append('{}/tools/libxl'.format(os.environ['XEN_ROOT']))
+import idl
+
+# Go versions of some builtin types.
+# Append the libxl-defined builtins after IDL parsing.
+builtin_type_names = {
+    idl.bool.typename: 'bool',
+    idl.string.typename: 'string',
+    idl.integer.typename: 'int',
+    idl.uint8.typename: 'byte',
+    idl.uint16.typename: 'uint16',
+    idl.uint32.typename: 'uint32',
+    idl.uint64.typename: 'uint64',
+}
+
+def xenlight_golang_generate_types(path = None, types = None, comment = None):
+    """
+    Generate a .go file (xenlight_types.go by default)
+    that contains a Go type for each type in types.
+    """
+    if path is None:
+        path = 'xenlight_types.go'
+
+    with open(path, 'w') as f:
+        if comment is not None:
+            f.write(comment)
+        f.write('package xenlight\n')
+
+        for ty in types:
+            f.write(xenlight_golang_type_define(ty))
+            f.write('\n')
+
+    go_fmt(path)
+
+def xenlight_golang_type_define(ty = None):
+    s = ''
+
+    if isinstance(ty, idl.Enumeration):
+        s += xenlight_golang_define_enum(ty)
+
+    return s
+
+def xenlight_golang_define_enum(ty = None):
+    s = ''
+    typename = ''
+
+    if ty.typename is not None:
+        typename = xenlight_golang_fmt_name(ty.typename)
+        s += 'type {} int\n'.format(typename)
+
+    # Start const block
+    s += 'const(\n'
+
+    for v in ty.values:
+        name = xenlight_golang_fmt_name(v.name)
+        s += '{} {} = {}\n'.format(name, typename, v.value)
+
+    # End const block
+    s += ')\n'
+
+    return s
+
+def xenlight_golang_fmt_name(name, exported = True):
+    """
+    Take a given type name and return an
+    appropriate Go type name.
+    """
+    if name in builtin_type_names.keys():
+        return builtin_type_names[name]
+
+    # Name is not a builtin, format it for Go.
+    words = name.split('_')
+
+    # Remove 'libxl' prefix
+    if words[0].lower() == 'libxl':
+        words.remove(words[0])
+
+    if exported:
+        return ''.join(x.title() for x in words)
+
+    return words[0] + ''.join(x.title() for x in words[1:])
+
+def go_fmt(path):
+    """ Call go fmt on the given path. """
+    os.system('go fmt {}'.format(path))
+
+if __name__ == '__main__':
+    idlname = sys.argv[1]
+
+    (builtins, types) = idl.parse(idlname)
+
+    for b in builtins:
+        name = b.typename
+        builtin_type_names[name] = xenlight_golang_fmt_name(name)
+
+    header_comment="""// DO NOT EDIT.
+    //
+    // This file is generated by:
+    // {}
+    //
+    """.format(' '.join(sys.argv))
+
+    xenlight_golang_generate_types(types=types,
+                                   comment=header_comment)
diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go
index 59b8186a64..e617f22fcf 100644
--- a/tools/golang/xenlight/xenlight.go
+++ b/tools/golang/xenlight/xenlight.go
@@ -37,77 +37,42 @@  import (
 	"unsafe"
 )
 
-/*
- * Errors
- */
-
-type Error int
-
-const (
-	ErrorNonspecific                  = Error(-C.ERROR_NONSPECIFIC)
-	ErrorVersion                      = Error(-C.ERROR_VERSION)
-	ErrorFail                         = Error(-C.ERROR_FAIL)
-	ErrorNi                           = Error(-C.ERROR_NI)
-	ErrorNomem                        = Error(-C.ERROR_NOMEM)
-	ErrorInval                        = Error(-C.ERROR_INVAL)
-	ErrorBadfail                      = Error(-C.ERROR_BADFAIL)
-	ErrorGuestTimedout                = Error(-C.ERROR_GUEST_TIMEDOUT)
-	ErrorTimedout                     = Error(-C.ERROR_TIMEDOUT)
-	ErrorNoparavirt                   = Error(-C.ERROR_NOPARAVIRT)
-	ErrorNotReady                     = Error(-C.ERROR_NOT_READY)
-	ErrorOseventRegFail               = Error(-C.ERROR_OSEVENT_REG_FAIL)
-	ErrorBufferfull                   = Error(-C.ERROR_BUFFERFULL)
-	ErrorUnknownChild                 = Error(-C.ERROR_UNKNOWN_CHILD)
-	ErrorLockFail                     = Error(-C.ERROR_LOCK_FAIL)
-	ErrorJsonConfigEmpty              = Error(-C.ERROR_JSON_CONFIG_EMPTY)
-	ErrorDeviceExists                 = Error(-C.ERROR_DEVICE_EXISTS)
-	ErrorCheckpointDevopsDoesNotMatch = Error(-C.ERROR_CHECKPOINT_DEVOPS_DOES_NOT_MATCH)
-	ErrorCheckpointDeviceNotSupported = Error(-C.ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED)
-	ErrorVnumaConfigInvalid           = Error(-C.ERROR_VNUMA_CONFIG_INVALID)
-	ErrorDomainNotfound               = Error(-C.ERROR_DOMAIN_NOTFOUND)
-	ErrorAborted                      = Error(-C.ERROR_ABORTED)
-	ErrorNotfound                     = Error(-C.ERROR_NOTFOUND)
-	ErrorDomainDestroyed              = Error(-C.ERROR_DOMAIN_DESTROYED)
-	ErrorFeatureRemoved               = Error(-C.ERROR_FEATURE_REMOVED)
-)
-
-var errors = [...]string{
-	ErrorNonspecific:                  "Non-specific error",
-	ErrorVersion:                      "Wrong version",
-	ErrorFail:                         "Failed",
-	ErrorNi:                           "Not Implemented",
-	ErrorNomem:                        "No memory",
-	ErrorInval:                        "Invalid argument",
-	ErrorBadfail:                      "Bad Fail",
-	ErrorGuestTimedout:                "Guest timed out",
-	ErrorTimedout:                     "Timed out",
-	ErrorNoparavirt:                   "No Paravirtualization",
-	ErrorNotReady:                     "Not ready",
-	ErrorOseventRegFail:               "OS event registration failed",
-	ErrorBufferfull:                   "Buffer full",
-	ErrorUnknownChild:                 "Unknown child",
-	ErrorLockFail:                     "Lock failed",
-	ErrorJsonConfigEmpty:              "JSON config empty",
-	ErrorDeviceExists:                 "Device exists",
-	ErrorCheckpointDevopsDoesNotMatch: "Checkpoint devops does not match",
-	ErrorCheckpointDeviceNotSupported: "Checkpoint device not supported",
-	ErrorVnumaConfigInvalid:           "VNUMA config invalid",
-	ErrorDomainNotfound:               "Domain not found",
-	ErrorAborted:                      "Aborted",
-	ErrorNotfound:                     "Not found",
-	ErrorDomainDestroyed:              "Domain destroyed",
-	ErrorFeatureRemoved:               "Feature removed",
+var libxlErrors = [...]string{
+	-ErrorNonspecific:                  "Non-specific error",
+	-ErrorVersion:                      "Wrong version",
+	-ErrorFail:                         "Failed",
+	-ErrorNi:                           "Not Implemented",
+	-ErrorNomem:                        "No memory",
+	-ErrorInval:                        "Invalid argument",
+	-ErrorBadfail:                      "Bad Fail",
+	-ErrorGuestTimedout:                "Guest timed out",
+	-ErrorTimedout:                     "Timed out",
+	-ErrorNoparavirt:                   "No Paravirtualization",
+	-ErrorNotReady:                     "Not ready",
+	-ErrorOseventRegFail:               "OS event registration failed",
+	-ErrorBufferfull:                   "Buffer full",
+	-ErrorUnknownChild:                 "Unknown child",
+	-ErrorLockFail:                     "Lock failed",
+	-ErrorJsonConfigEmpty:              "JSON config empty",
+	-ErrorDeviceExists:                 "Device exists",
+	-ErrorCheckpointDevopsDoesNotMatch: "Checkpoint devops does not match",
+	-ErrorCheckpointDeviceNotSupported: "Checkpoint device not supported",
+	-ErrorVnumaConfigInvalid:           "VNUMA config invalid",
+	-ErrorDomainNotfound:               "Domain not found",
+	-ErrorAborted:                      "Aborted",
+	-ErrorNotfound:                     "Not found",
+	-ErrorDomainDestroyed:              "Domain destroyed",
+	-ErrorFeatureRemoved:               "Feature removed",
 }
 
 func (e Error) Error() string {
-	if 0 < int(e) && int(e) < len(errors) {
-		s := errors[e]
+	if 0 < int(e) && int(e) < len(libxlErrors) {
+		s := libxlErrors[e]
 		if s != "" {
 			return s
 		}
 	}
 	return fmt.Sprintf("libxl error: %d", -e)
-
 }
 
 /*
@@ -236,18 +201,6 @@  func (cinfo *C.libxl_version_info) toGo() (info *VersionInfo) {
 	return
 }
 
-type ShutdownReason int32
-
-const (
-	ShutdownReasonUnknown   = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_UNKNOWN)
-	ShutdownReasonPoweroff  = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_POWEROFF)
-	ShutdownReasonReboot    = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_REBOOT)
-	ShutdownReasonSuspend   = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_SUSPEND)
-	ShutdownReasonCrash     = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_CRASH)
-	ShutdownReasonWatchdog  = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_WATCHDOG)
-	ShutdownReasonSoftReset = ShutdownReason(C.LIBXL_SHUTDOWN_REASON_SOFT_RESET)
-)
-
 func (sr ShutdownReason) String() (str string) {
 	cstr := C.libxl_shutdown_reason_to_string(C.libxl_shutdown_reason(sr))
 	str = C.GoString(cstr)
@@ -255,14 +208,6 @@  func (sr ShutdownReason) String() (str string) {
 	return
 }
 
-type DomainType int32
-
-const (
-	DomainTypeInvalid = DomainType(C.LIBXL_DOMAIN_TYPE_INVALID)
-	DomainTypeHvm     = DomainType(C.LIBXL_DOMAIN_TYPE_HVM)
-	DomainTypePv      = DomainType(C.LIBXL_DOMAIN_TYPE_PV)
-)
-
 func (dt DomainType) String() (str string) {
 	cstr := C.libxl_domain_type_to_string(C.libxl_domain_type(dt))
 	str = C.GoString(cstr)
@@ -323,27 +268,6 @@  func (cdi *C.libxl_dominfo) toGo() (di *Dominfo) {
 	return
 }
 
-// # Consistent with values defined in domctl.h
-// # Except unknown which we have made up
-// libxl_scheduler = Enumeration("scheduler", [
-//     (0, "unknown"),
-//     (4, "sedf"),
-//     (5, "credit"),
-//     (6, "credit2"),
-//     (7, "arinc653"),
-//     (8, "rtds"),
-//     ])
-type Scheduler int
-
-var (
-	SchedulerUnknown  Scheduler = C.LIBXL_SCHEDULER_UNKNOWN
-	SchedulerSedf     Scheduler = C.LIBXL_SCHEDULER_SEDF
-	SchedulerCredit   Scheduler = C.LIBXL_SCHEDULER_CREDIT
-	SchedulerCredit2  Scheduler = C.LIBXL_SCHEDULER_CREDIT2
-	SchedulerArinc653 Scheduler = C.LIBXL_SCHEDULER_ARINC653
-	SchedulerRTDS     Scheduler = C.LIBXL_SCHEDULER_RTDS
-)
-
 // const char *libxl_scheduler_to_string(libxl_scheduler p);
 func (s Scheduler) String() string {
 	cs := C.libxl_scheduler_to_string(C.libxl_scheduler(s))
@@ -1141,14 +1065,6 @@  func (Ctx *Context) ListVcpu(id Domid) (glist []Vcpuinfo) {
 	return
 }
 
-type ConsoleType int
-
-const (
-	ConsoleTypeUnknown = ConsoleType(C.LIBXL_CONSOLE_TYPE_UNKNOWN)
-	ConsoleTypeSerial  = ConsoleType(C.LIBXL_CONSOLE_TYPE_SERIAL)
-	ConsoleTypePV      = ConsoleType(C.LIBXL_CONSOLE_TYPE_PV)
-)
-
 func (ct ConsoleType) String() (str string) {
 	cstr := C.libxl_console_type_to_string(C.libxl_console_type(ct))
 	str = C.GoString(cstr)
diff --git a/tools/golang/xenlight/xenlight_types.go b/tools/golang/xenlight/xenlight_types.go
new file mode 100644
index 0000000000..05f62182b7
--- /dev/null
+++ b/tools/golang/xenlight/xenlight_types.go
@@ -0,0 +1,378 @@ 
+// DO NOT EDIT.
+//
+// This file is generated by:
+// gengotypes.py ../../libxl/libxl_types.idl
+//
+package xenlight
+
+type Error int
+
+const (
+	ErrorNonspecific                  Error = -1
+	ErrorVersion                      Error = -2
+	ErrorFail                         Error = -3
+	ErrorNi                           Error = -4
+	ErrorNomem                        Error = -5
+	ErrorInval                        Error = -6
+	ErrorBadfail                      Error = -7
+	ErrorGuestTimedout                Error = -8
+	ErrorTimedout                     Error = -9
+	ErrorNoparavirt                   Error = -10
+	ErrorNotReady                     Error = -11
+	ErrorOseventRegFail               Error = -12
+	ErrorBufferfull                   Error = -13
+	ErrorUnknownChild                 Error = -14
+	ErrorLockFail                     Error = -15
+	ErrorJsonConfigEmpty              Error = -16
+	ErrorDeviceExists                 Error = -17
+	ErrorCheckpointDevopsDoesNotMatch Error = -18
+	ErrorCheckpointDeviceNotSupported Error = -19
+	ErrorVnumaConfigInvalid           Error = -20
+	ErrorDomainNotfound               Error = -21
+	ErrorAborted                      Error = -22
+	ErrorNotfound                     Error = -23
+	ErrorDomainDestroyed              Error = -24
+	ErrorFeatureRemoved               Error = -25
+	ErrorProtocolErrorQmp             Error = -26
+	ErrorUnknownQmpError              Error = -27
+	ErrorQmpGenericError              Error = -28
+	ErrorQmpCommandNotFound           Error = -29
+	ErrorQmpDeviceNotActive           Error = -30
+	ErrorQmpDeviceNotFound            Error = -31
+	ErrorQemuApi                      Error = -32
+)
+
+type DomainType int
+
+const (
+	DomainTypeInvalid DomainType = -1
+	DomainTypeHvm     DomainType = 1
+	DomainTypePv      DomainType = 2
+	DomainTypePvh     DomainType = 3
+)
+
+type RdmReserveStrategy int
+
+const (
+	RdmReserveStrategyIgnore RdmReserveStrategy = 0
+	RdmReserveStrategyHost   RdmReserveStrategy = 1
+)
+
+type RdmReservePolicy int
+
+const (
+	RdmReservePolicyInvalid RdmReservePolicy = -1
+	RdmReservePolicyStrict  RdmReservePolicy = 0
+	RdmReservePolicyRelaxed RdmReservePolicy = 1
+)
+
+type ChannelConnection int
+
+const (
+	ChannelConnectionUnknown ChannelConnection = 0
+	ChannelConnectionPty     ChannelConnection = 1
+	ChannelConnectionSocket  ChannelConnection = 2
+)
+
+type DeviceModelVersion int
+
+const (
+	DeviceModelVersionUnknown            DeviceModelVersion = 0
+	DeviceModelVersionQemuXenTraditional DeviceModelVersion = 1
+	DeviceModelVersionQemuXen            DeviceModelVersion = 2
+)
+
+type ConsoleType int
+
+const (
+	ConsoleTypeUnknown ConsoleType = 0
+	ConsoleTypeSerial  ConsoleType = 1
+	ConsoleTypePv      ConsoleType = 2
+	ConsoleTypeVuart   ConsoleType = 3
+)
+
+type DiskFormat int
+
+const (
+	DiskFormatUnknown DiskFormat = 0
+	DiskFormatQcow    DiskFormat = 1
+	DiskFormatQcow2   DiskFormat = 2
+	DiskFormatVhd     DiskFormat = 3
+	DiskFormatRaw     DiskFormat = 4
+	DiskFormatEmpty   DiskFormat = 5
+	DiskFormatQed     DiskFormat = 6
+)
+
+type DiskBackend int
+
+const (
+	DiskBackendUnknown DiskBackend = 0
+	DiskBackendPhy     DiskBackend = 1
+	DiskBackendTap     DiskBackend = 2
+	DiskBackendQdisk   DiskBackend = 3
+)
+
+type NicType int
+
+const (
+	NicTypeUnknown  NicType = 0
+	NicTypeVifIoemu NicType = 1
+	NicTypeVif      NicType = 2
+)
+
+type ActionOnShutdown int
+
+const (
+	ActionOnShutdownDestroy         ActionOnShutdown = 1
+	ActionOnShutdownRestart         ActionOnShutdown = 2
+	ActionOnShutdownRestartRename   ActionOnShutdown = 3
+	ActionOnShutdownPreserve        ActionOnShutdown = 4
+	ActionOnShutdownCoredumpDestroy ActionOnShutdown = 5
+	ActionOnShutdownCoredumpRestart ActionOnShutdown = 6
+	ActionOnShutdownSoftReset       ActionOnShutdown = 7
+)
+
+type Trigger int
+
+const (
+	TriggerUnknown  Trigger = 0
+	TriggerPower    Trigger = 1
+	TriggerSleep    Trigger = 2
+	TriggerNmi      Trigger = 3
+	TriggerInit     Trigger = 4
+	TriggerReset    Trigger = 5
+	TriggerS3Resume Trigger = 6
+)
+
+type TscMode int
+
+const (
+	TscModeDefault        TscMode = 0
+	TscModeAlwaysEmulate  TscMode = 1
+	TscModeNative         TscMode = 2
+	TscModeNativeParavirt TscMode = 3
+)
+
+type GfxPassthruKind int
+
+const (
+	GfxPassthruKindDefault GfxPassthruKind = 0
+	GfxPassthruKindIgd     GfxPassthruKind = 1
+)
+
+type TimerMode int
+
+const (
+	TimerModeUnknown               TimerMode = -1
+	TimerModeDelayForMissedTicks   TimerMode = 0
+	TimerModeNoDelayForMissedTicks TimerMode = 1
+	TimerModeNoMissedTicksPending  TimerMode = 2
+	TimerModeOneMissedTickPending  TimerMode = 3
+)
+
+type BiosType int
+
+const (
+	BiosTypeUnknown BiosType = 0
+	BiosTypeRombios BiosType = 1
+	BiosTypeSeabios BiosType = 2
+	BiosTypeOvmf    BiosType = 3
+)
+
+type Scheduler int
+
+const (
+	SchedulerUnknown  Scheduler = 0
+	SchedulerSedf     Scheduler = 4
+	SchedulerCredit   Scheduler = 5
+	SchedulerCredit2  Scheduler = 6
+	SchedulerArinc653 Scheduler = 7
+	SchedulerRtds     Scheduler = 8
+	SchedulerNull     Scheduler = 9
+)
+
+type ShutdownReason int
+
+const (
+	ShutdownReasonUnknown   ShutdownReason = -1
+	ShutdownReasonPoweroff  ShutdownReason = 0
+	ShutdownReasonReboot    ShutdownReason = 1
+	ShutdownReasonSuspend   ShutdownReason = 2
+	ShutdownReasonCrash     ShutdownReason = 3
+	ShutdownReasonWatchdog  ShutdownReason = 4
+	ShutdownReasonSoftReset ShutdownReason = 5
+)
+
+type VgaInterfaceType int
+
+const (
+	VgaInterfaceTypeUnknown VgaInterfaceType = 0
+	VgaInterfaceTypeCirrus  VgaInterfaceType = 1
+	VgaInterfaceTypeStd     VgaInterfaceType = 2
+	VgaInterfaceTypeNone    VgaInterfaceType = 3
+	VgaInterfaceTypeQxl     VgaInterfaceType = 4
+)
+
+type VendorDevice int
+
+const (
+	VendorDeviceNone      VendorDevice = 0
+	VendorDeviceXenserver VendorDevice = 1
+)
+
+type ViridianEnlightenment int
+
+const (
+	ViridianEnlightenmentBase                ViridianEnlightenment = 0
+	ViridianEnlightenmentFreq                ViridianEnlightenment = 1
+	ViridianEnlightenmentTimeRefCount        ViridianEnlightenment = 2
+	ViridianEnlightenmentReferenceTsc        ViridianEnlightenment = 3
+	ViridianEnlightenmentHcallRemoteTlbFlush ViridianEnlightenment = 4
+	ViridianEnlightenmentApicAssist          ViridianEnlightenment = 5
+	ViridianEnlightenmentCrashCtl            ViridianEnlightenment = 6
+	ViridianEnlightenmentSynic               ViridianEnlightenment = 7
+	ViridianEnlightenmentStimer              ViridianEnlightenment = 8
+	ViridianEnlightenmentHcallIpi            ViridianEnlightenment = 9
+)
+
+type Hdtype int
+
+const (
+	HdtypeIde  Hdtype = 1
+	HdtypeAhci Hdtype = 2
+)
+
+type CheckpointedStream int
+
+const (
+	CheckpointedStreamNone  CheckpointedStream = 0
+	CheckpointedStreamRemus CheckpointedStream = 1
+	CheckpointedStreamColo  CheckpointedStream = 2
+)
+
+type VuartType int
+
+const (
+	VuartTypeUnknown  VuartType = 0
+	VuartTypeSbsaUart VuartType = 1
+)
+
+type VkbBackend int
+
+const (
+	VkbBackendUnknown VkbBackend = 0
+	VkbBackendQemu    VkbBackend = 1
+	VkbBackendLinux   VkbBackend = 2
+)
+
+type GicVersion int
+
+const (
+	GicVersionDefault GicVersion = 0
+	GicVersionV2      GicVersion = 32
+	GicVersionV3      GicVersion = 48
+)
+
+type TeeType int
+
+const (
+	TeeTypeNone  TeeType = 0
+	TeeTypeOptee TeeType = 1
+)
+
+type Altp2MMode int
+
+const (
+	Altp2MModeDisabled Altp2MMode = 0
+	Altp2MModeMixed    Altp2MMode = 1
+	Altp2MModeExternal Altp2MMode = 2
+	Altp2MModeLimited  Altp2MMode = 3
+)
+
+type UsbctrlType int
+
+const (
+	UsbctrlTypeAuto        UsbctrlType = 0
+	UsbctrlTypePv          UsbctrlType = 1
+	UsbctrlTypeDevicemodel UsbctrlType = 2
+	UsbctrlTypeQusb        UsbctrlType = 3
+)
+
+type UsbdevType int
+
+const (
+	UsbdevTypeHostdev UsbdevType = 1
+)
+
+type VsndPcmFormat int
+
+const (
+	VsndPcmFormatS8               VsndPcmFormat = 1
+	VsndPcmFormatU8               VsndPcmFormat = 2
+	VsndPcmFormatS16Le            VsndPcmFormat = 3
+	VsndPcmFormatS16Be            VsndPcmFormat = 4
+	VsndPcmFormatU16Le            VsndPcmFormat = 5
+	VsndPcmFormatU16Be            VsndPcmFormat = 6
+	VsndPcmFormatS24Le            VsndPcmFormat = 7
+	VsndPcmFormatS24Be            VsndPcmFormat = 8
+	VsndPcmFormatU24Le            VsndPcmFormat = 9
+	VsndPcmFormatU24Be            VsndPcmFormat = 10
+	VsndPcmFormatS32Le            VsndPcmFormat = 11
+	VsndPcmFormatS32Be            VsndPcmFormat = 12
+	VsndPcmFormatU32Le            VsndPcmFormat = 13
+	VsndPcmFormatU32Be            VsndPcmFormat = 14
+	VsndPcmFormatF32Le            VsndPcmFormat = 15
+	VsndPcmFormatF32Be            VsndPcmFormat = 16
+	VsndPcmFormatF64Le            VsndPcmFormat = 17
+	VsndPcmFormatF64Be            VsndPcmFormat = 18
+	VsndPcmFormatIec958SubframeLe VsndPcmFormat = 19
+	VsndPcmFormatIec958SubframeBe VsndPcmFormat = 20
+	VsndPcmFormatMuLaw            VsndPcmFormat = 21
+	VsndPcmFormatALaw             VsndPcmFormat = 22
+	VsndPcmFormatImaAdpcm         VsndPcmFormat = 23
+	VsndPcmFormatMpeg             VsndPcmFormat = 24
+	VsndPcmFormatGsm              VsndPcmFormat = 25
+)
+
+type VsndStreamType int
+
+const (
+	VsndStreamTypeP VsndStreamType = 1
+	VsndStreamTypeC VsndStreamType = 2
+)
+
+type EventType int
+
+const (
+	EventTypeDomainShutdown               EventType = 1
+	EventTypeDomainDeath                  EventType = 2
+	EventTypeDiskEject                    EventType = 3
+	EventTypeOperationComplete            EventType = 4
+	EventTypeDomainCreateConsoleAvailable EventType = 5
+)
+
+type PsrCmtType int
+
+const (
+	PsrCmtTypeCacheOccupancy PsrCmtType = 1
+	PsrCmtTypeTotalMemCount  PsrCmtType = 2
+	PsrCmtTypeLocalMemCount  PsrCmtType = 3
+)
+
+type PsrCbmType int
+
+const (
+	PsrCbmTypeUnknown   PsrCbmType = 0
+	PsrCbmTypeL3Cbm     PsrCbmType = 1
+	PsrCbmTypeL3CbmCode PsrCbmType = 2
+	PsrCbmTypeL3CbmData PsrCbmType = 3
+	PsrCbmTypeL2Cbm     PsrCbmType = 4
+	PsrCbmTypeMbaThrtl  PsrCbmType = 5
+)
+
+type PsrFeatType int
+
+const (
+	PsrFeatTypeCat PsrFeatType = 1
+	PsrFeatTypeMba PsrFeatType = 2
+)