// automatically generated by stateify.

package vfio

import (
	"context"

	"gvisor.dev/gvisor/pkg/state"
)

func (r *DevAddrRange) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.DevAddrRange"
}

func (r *DevAddrRange) StateFields() []string {
	return []string{
		"Start",
		"End",
	}
}

func (r *DevAddrRange) beforeSave() {}

// +checklocksignore
func (r *DevAddrRange) StateSave(stateSinkObject state.Sink) {
	r.beforeSave()
	stateSinkObject.Save(0, &r.Start)
	stateSinkObject.Save(1, &r.End)
}

func (r *DevAddrRange) afterLoad(context.Context) {}

// +checklocksignore
func (r *DevAddrRange) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &r.Start)
	stateSourceObject.Load(1, &r.End)
}

func (s *DevAddrSet) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.DevAddrSet"
}

func (s *DevAddrSet) StateFields() []string {
	return []string{
		"root",
	}
}

func (s *DevAddrSet) beforeSave() {}

// +checklocksignore
func (s *DevAddrSet) StateSave(stateSinkObject state.Sink) {
	s.beforeSave()
	var rootValue []DevAddrFlatSegment
	rootValue = s.saveRoot()
	stateSinkObject.SaveValue(0, rootValue)
}

func (s *DevAddrSet) afterLoad(context.Context) {}

// +checklocksignore
func (s *DevAddrSet) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.LoadValue(0, new([]DevAddrFlatSegment), func(y any) { s.loadRoot(ctx, y.([]DevAddrFlatSegment)) })
}

func (n *DevAddrnode) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.DevAddrnode"
}

func (n *DevAddrnode) StateFields() []string {
	return []string{
		"nrSegments",
		"parent",
		"parentIndex",
		"hasChildren",
		"maxGap",
		"keys",
		"values",
		"children",
	}
}

func (n *DevAddrnode) beforeSave() {}

// +checklocksignore
func (n *DevAddrnode) StateSave(stateSinkObject state.Sink) {
	n.beforeSave()
	stateSinkObject.Save(0, &n.nrSegments)
	stateSinkObject.Save(1, &n.parent)
	stateSinkObject.Save(2, &n.parentIndex)
	stateSinkObject.Save(3, &n.hasChildren)
	stateSinkObject.Save(4, &n.maxGap)
	stateSinkObject.Save(5, &n.keys)
	stateSinkObject.Save(6, &n.values)
	stateSinkObject.Save(7, &n.children)
}

func (n *DevAddrnode) afterLoad(context.Context) {}

// +checklocksignore
func (n *DevAddrnode) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &n.nrSegments)
	stateSourceObject.Load(1, &n.parent)
	stateSourceObject.Load(2, &n.parentIndex)
	stateSourceObject.Load(3, &n.hasChildren)
	stateSourceObject.Load(4, &n.maxGap)
	stateSourceObject.Load(5, &n.keys)
	stateSourceObject.Load(6, &n.values)
	stateSourceObject.Load(7, &n.children)
}

func (d *DevAddrFlatSegment) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.DevAddrFlatSegment"
}

func (d *DevAddrFlatSegment) StateFields() []string {
	return []string{
		"Start",
		"End",
		"Value",
	}
}

func (d *DevAddrFlatSegment) beforeSave() {}

// +checklocksignore
func (d *DevAddrFlatSegment) StateSave(stateSinkObject state.Sink) {
	d.beforeSave()
	stateSinkObject.Save(0, &d.Start)
	stateSinkObject.Save(1, &d.End)
	stateSinkObject.Save(2, &d.Value)
}

func (d *DevAddrFlatSegment) afterLoad(context.Context) {}

// +checklocksignore
func (d *DevAddrFlatSegment) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &d.Start)
	stateSourceObject.Load(1, &d.End)
	stateSourceObject.Load(2, &d.Value)
}

func (fd *pciDeviceFD) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.pciDeviceFD"
}

func (fd *pciDeviceFD) StateFields() []string {
	return []string{
		"vfsfd",
		"FileDescriptionDefaultImpl",
		"DentryMetadataFileDescriptionImpl",
		"NoLockFD",
		"hostFD",
		"queue",
		"mappings",
		"memmapFile",
	}
}

// +checklocksignore
func (fd *pciDeviceFD) StateSave(stateSinkObject state.Sink) {
	fd.beforeSave()
	stateSinkObject.Save(0, &fd.vfsfd)
	stateSinkObject.Save(1, &fd.FileDescriptionDefaultImpl)
	stateSinkObject.Save(2, &fd.DentryMetadataFileDescriptionImpl)
	stateSinkObject.Save(3, &fd.NoLockFD)
	stateSinkObject.Save(4, &fd.hostFD)
	stateSinkObject.Save(5, &fd.queue)
	stateSinkObject.Save(6, &fd.mappings)
	stateSinkObject.Save(7, &fd.memmapFile)
}

func (fd *pciDeviceFD) afterLoad(context.Context) {}

// +checklocksignore
func (fd *pciDeviceFD) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &fd.vfsfd)
	stateSourceObject.Load(1, &fd.FileDescriptionDefaultImpl)
	stateSourceObject.Load(2, &fd.DentryMetadataFileDescriptionImpl)
	stateSourceObject.Load(3, &fd.NoLockFD)
	stateSourceObject.Load(4, &fd.hostFD)
	stateSourceObject.Load(5, &fd.queue)
	stateSourceObject.Load(6, &fd.mappings)
	stateSourceObject.Load(7, &fd.memmapFile)
}

func (mf *pciDeviceFdMemmapFile) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.pciDeviceFdMemmapFile"
}

func (mf *pciDeviceFdMemmapFile) StateFields() []string {
	return []string{
		"DefaultMemoryType",
		"NoBufferedIOFallback",
		"fd",
		"pfm",
	}
}

func (mf *pciDeviceFdMemmapFile) beforeSave() {}

// +checklocksignore
func (mf *pciDeviceFdMemmapFile) StateSave(stateSinkObject state.Sink) {
	mf.beforeSave()
	stateSinkObject.Save(0, &mf.DefaultMemoryType)
	stateSinkObject.Save(1, &mf.NoBufferedIOFallback)
	stateSinkObject.Save(2, &mf.fd)
	stateSinkObject.Save(3, &mf.pfm)
}

func (mf *pciDeviceFdMemmapFile) afterLoad(context.Context) {}

// +checklocksignore
func (mf *pciDeviceFdMemmapFile) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &mf.DefaultMemoryType)
	stateSourceObject.Load(1, &mf.NoBufferedIOFallback)
	stateSourceObject.Load(2, &mf.fd)
	stateSourceObject.Load(3, &mf.pfm)
}

func (fd *tpuFD) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.tpuFD"
}

func (fd *tpuFD) StateFields() []string {
	return []string{
		"vfsfd",
		"FileDescriptionDefaultImpl",
		"DentryMetadataFileDescriptionImpl",
		"NoLockFD",
		"hostFD",
		"device",
		"queue",
		"memmapFile",
	}
}

// +checklocksignore
func (fd *tpuFD) StateSave(stateSinkObject state.Sink) {
	fd.beforeSave()
	stateSinkObject.Save(0, &fd.vfsfd)
	stateSinkObject.Save(1, &fd.FileDescriptionDefaultImpl)
	stateSinkObject.Save(2, &fd.DentryMetadataFileDescriptionImpl)
	stateSinkObject.Save(3, &fd.NoLockFD)
	stateSinkObject.Save(4, &fd.hostFD)
	stateSinkObject.Save(5, &fd.device)
	stateSinkObject.Save(6, &fd.queue)
	stateSinkObject.Save(7, &fd.memmapFile)
}

func (fd *tpuFD) afterLoad(context.Context) {}

// +checklocksignore
func (fd *tpuFD) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &fd.vfsfd)
	stateSourceObject.Load(1, &fd.FileDescriptionDefaultImpl)
	stateSourceObject.Load(2, &fd.DentryMetadataFileDescriptionImpl)
	stateSourceObject.Load(3, &fd.NoLockFD)
	stateSourceObject.Load(4, &fd.hostFD)
	stateSourceObject.Load(5, &fd.device)
	stateSourceObject.Load(6, &fd.queue)
	stateSourceObject.Load(7, &fd.memmapFile)
}

func (mf *tpuFDMemmapFile) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.tpuFDMemmapFile"
}

func (mf *tpuFDMemmapFile) StateFields() []string {
	return []string{
		"NoMapInternal",
		"fd",
	}
}

func (mf *tpuFDMemmapFile) beforeSave() {}

// +checklocksignore
func (mf *tpuFDMemmapFile) StateSave(stateSinkObject state.Sink) {
	mf.beforeSave()
	stateSinkObject.Save(0, &mf.NoMapInternal)
	stateSinkObject.Save(1, &mf.fd)
}

func (mf *tpuFDMemmapFile) afterLoad(context.Context) {}

// +checklocksignore
func (mf *tpuFDMemmapFile) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &mf.NoMapInternal)
	stateSourceObject.Load(1, &mf.fd)
}

func (dev *tpuDevice) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.tpuDevice"
}

func (dev *tpuDevice) StateFields() []string {
	return []string{
		"minor",
		"num",
		"useDevGofer",
	}
}

func (dev *tpuDevice) beforeSave() {}

// +checklocksignore
func (dev *tpuDevice) StateSave(stateSinkObject state.Sink) {
	dev.beforeSave()
	stateSinkObject.Save(0, &dev.minor)
	stateSinkObject.Save(1, &dev.num)
	stateSinkObject.Save(2, &dev.useDevGofer)
}

func (dev *tpuDevice) afterLoad(context.Context) {}

// +checklocksignore
func (dev *tpuDevice) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &dev.minor)
	stateSourceObject.Load(1, &dev.num)
	stateSourceObject.Load(2, &dev.useDevGofer)
}

func (dev *vfioDevice) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.vfioDevice"
}

func (dev *vfioDevice) StateFields() []string {
	return []string{
		"useDevGofer",
	}
}

func (dev *vfioDevice) beforeSave() {}

// +checklocksignore
func (dev *vfioDevice) StateSave(stateSinkObject state.Sink) {
	dev.beforeSave()
	stateSinkObject.Save(0, &dev.useDevGofer)
}

func (dev *vfioDevice) afterLoad(context.Context) {}

// +checklocksignore
func (dev *vfioDevice) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &dev.useDevGofer)
}

func (fd *vfioFD) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.vfioFD"
}

func (fd *vfioFD) StateFields() []string {
	return []string{
		"vfsfd",
		"FileDescriptionDefaultImpl",
		"DentryMetadataFileDescriptionImpl",
		"NoLockFD",
		"hostFD",
		"device",
		"queue",
		"memmapFile",
	}
}

// +checklocksignore
func (fd *vfioFD) StateSave(stateSinkObject state.Sink) {
	fd.beforeSave()
	stateSinkObject.Save(0, &fd.vfsfd)
	stateSinkObject.Save(1, &fd.FileDescriptionDefaultImpl)
	stateSinkObject.Save(2, &fd.DentryMetadataFileDescriptionImpl)
	stateSinkObject.Save(3, &fd.NoLockFD)
	stateSinkObject.Save(4, &fd.hostFD)
	stateSinkObject.Save(5, &fd.device)
	stateSinkObject.Save(6, &fd.queue)
	stateSinkObject.Save(7, &fd.memmapFile)
}

func (fd *vfioFD) afterLoad(context.Context) {}

// +checklocksignore
func (fd *vfioFD) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &fd.vfsfd)
	stateSourceObject.Load(1, &fd.FileDescriptionDefaultImpl)
	stateSourceObject.Load(2, &fd.DentryMetadataFileDescriptionImpl)
	stateSourceObject.Load(3, &fd.NoLockFD)
	stateSourceObject.Load(4, &fd.hostFD)
	stateSourceObject.Load(5, &fd.device)
	stateSourceObject.Load(6, &fd.queue)
	stateSourceObject.Load(7, &fd.memmapFile)
}

func (mf *vfioFDMemmapFile) StateTypeName() string {
	return "pkg/sentry/devices/tpuproxy/vfio.vfioFDMemmapFile"
}

func (mf *vfioFDMemmapFile) StateFields() []string {
	return []string{
		"NoMapInternal",
		"fd",
	}
}

func (mf *vfioFDMemmapFile) beforeSave() {}

// +checklocksignore
func (mf *vfioFDMemmapFile) StateSave(stateSinkObject state.Sink) {
	mf.beforeSave()
	stateSinkObject.Save(0, &mf.NoMapInternal)
	stateSinkObject.Save(1, &mf.fd)
}

func (mf *vfioFDMemmapFile) afterLoad(context.Context) {}

// +checklocksignore
func (mf *vfioFDMemmapFile) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &mf.NoMapInternal)
	stateSourceObject.Load(1, &mf.fd)
}

func init() {
	state.Register((*DevAddrRange)(nil))
	state.Register((*DevAddrSet)(nil))
	state.Register((*DevAddrnode)(nil))
	state.Register((*DevAddrFlatSegment)(nil))
	state.Register((*pciDeviceFD)(nil))
	state.Register((*pciDeviceFdMemmapFile)(nil))
	state.Register((*tpuFD)(nil))
	state.Register((*tpuFDMemmapFile)(nil))
	state.Register((*tpuDevice)(nil))
	state.Register((*vfioDevice)(nil))
	state.Register((*vfioFD)(nil))
	state.Register((*vfioFDMemmapFile)(nil))
}
