blob: aef4f8f6039c969e38076b930b902b5913e2523e [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#ifndef ZIRCON_KERNEL_OBJECT_INCLUDE_OBJECT_VCPU_DISPATCHER_H_
#define ZIRCON_KERNEL_OBJECT_INCLUDE_OBJECT_VCPU_DISPATCHER_H_
#include <zircon/rights.h>
#include <zircon/syscalls/hypervisor.h>
#include <object/dispatcher.h>
#include <object/handle.h>
class GuestDispatcher;
class Vcpu;
class VmObject;
typedef struct zx_port_packet zx_port_packet_t;
class VcpuDispatcher final : public SoloDispatcher<VcpuDispatcher, ZX_DEFAULT_VCPU_RIGHTS> {
public:
static zx_status_t Create(fbl::RefPtr<GuestDispatcher> guest_dispatcher, zx_vaddr_t entry,
KernelHandle<VcpuDispatcher>* handle, zx_rights_t* rights);
~VcpuDispatcher();
zx_obj_type_t get_type() const { return ZX_OBJ_TYPE_VCPU; }
zx_status_t Enter(zx_port_packet_t& packet);
void Kick();
zx_status_t Interrupt(uint32_t vector);
zx_status_t ReadState(zx_vcpu_state_t& vcpu_state) const;
zx_status_t WriteState(const zx_vcpu_state_t& vcpu_state);
zx_status_t WriteState(const zx_vcpu_io_t& io_state);
void GetInfo(zx_info_vcpu_t* info);
private:
VcpuDispatcher(fbl::RefPtr<GuestDispatcher> guest_dispatcher, ktl::unique_ptr<Vcpu> vcpu);
fbl::RefPtr<GuestDispatcher> guest_dispatcher_;
ktl::unique_ptr<Vcpu> vcpu_;
};
#endif // ZIRCON_KERNEL_OBJECT_INCLUDE_OBJECT_VCPU_DISPATCHER_H_