/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2011 NetApp, Inc.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#ifndef _BHYVERUN_H_29#define _BHYVERUN_H_3031#include <stdbool.h>3233#define VMEXIT_CONTINUE (0)34#define VMEXIT_ABORT (-1)3536/*37* Exit status codes as described in the bhyve(8) manpage.38*/39#define BHYVE_EXIT_RESET 040#define BHYVE_EXIT_POWEROFF 141#define BHYVE_EXIT_HALT 242#define BHYVE_EXIT_TRIPLEFAULT 343#define BHYVE_EXIT_ERROR 444#define BHYVE_EXIT_SUSPEND 54546extern int guest_ncpus;47extern uint16_t cpu_cores, cpu_sockets, cpu_threads;4849#ifdef BHYVE_SNAPSHOT50extern char *restore_file;51#endif5253struct vcpu;54struct vmctx;55struct vm_run;5657void *paddr_guest2host(struct vmctx *ctx, uintptr_t addr, size_t len);58#ifdef BHYVE_SNAPSHOT59uintptr_t paddr_host2guest(struct vmctx *ctx, void *addr);60#endif6162struct vcpu;63struct vcpu *fbsdrun_vcpu(int vcpuid);64void fbsdrun_addcpu(int vcpuid);65void fbsdrun_deletecpu(int vcpuid);66int fbsdrun_suspendcpu(int vcpuid);6768int fbsdrun_virtio_msix(void);6970typedef int (*vmexit_handler_t)(struct vmctx *, struct vcpu *, struct vm_run *);7172/* Interfaces implemented by machine-dependent code. */73void bhyve_init_config(void);74void bhyve_optparse(int argc, char **argv);75void bhyve_usage(int code);7677/* Interfaces used by command-line option-parsing code. */78bool bhyve_parse_config_option(const char *option);79void bhyve_parse_simple_config_file(const char *path);80#ifdef BHYVE_GDB81void bhyve_parse_gdb_options(const char *opt);82#endif83int bhyve_pincpu_parse(const char *opt);84int bhyve_topology_parse(const char *opt);85int bhyve_numa_parse(const char *opt);8687void bhyve_init_vcpu(struct vcpu *vcpu);88void bhyve_start_vcpu(struct vcpu *vcpu, bool bsp);89int bhyve_init_platform(struct vmctx *ctx, struct vcpu *bsp);90int bhyve_init_platform_late(struct vmctx *ctx, struct vcpu *bsp);9192#endif939495