199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2011 Doug Rabson
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * USERBOOT interface versions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Version 4 added more generic callbacks for setting up
199767f8919635c4928607450d9e0abb932109ceToomas Soome * registers and descriptors. The callback structure is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * backward compatible (new callbacks have been added at
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the tail end).
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Exit codes from the loader
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Console i/o
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Wait until a key is pressed on the console and then return it
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Write the character ch to the console
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Return non-zero if a key can be read from the console
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Host filesystem i/o
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Open a file in the host filesystem
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*open)(void *arg, const char *filename, void **h_return);
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Close a file
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Return non-zero if the file is a directory
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read size bytes from a file. The number of bytes remaining
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in dst after reading is returned in *resid_return
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*read)(void *arg, void *h, void *dst, size_t size,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read an entry from a directory. The entry's inode number is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * returned in *fileno_return, its type in *type_return and
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the name length in *namelen_return. The name itself is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * copied to the buffer name which must be at least PATH_MAX
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*readdir)(void *arg, void *h, uint32_t *fileno_return,
199767f8919635c4928607450d9e0abb932109ceToomas Soome uint8_t *type_return, size_t *namelen_return, char *name);
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Seek to a location within an open file
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*seek)(void *arg, void *h, uint64_t offset,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Return some stat(2) related information about the file
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*stat)(void *arg, void *h, int *mode_return,
199767f8919635c4928607450d9e0abb932109ceToomas Soome int *uid_return, int *gid_return, uint64_t *size_return);
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Disk image i/o
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Read from a disk image at the given offset
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*diskread)(void *arg, int unit, uint64_t offset,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Guest virtual machine i/o
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copy to the guest address space
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copy from the guest address space
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Set a guest register value
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Set a guest MSR value
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Set a guest CR value
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Set the guest GDT address
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Transfer control to the guest at the given address
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Sleep for usec microseconds
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Exit with the given exit code
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Return guest physical memory map details
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ioctl interface to the disk device
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*diskioctl)(void *arg, int unit, u_long cmd,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Returns an environment variable in the form "name=value".
199767f8919635c4928607450d9e0abb932109ceToomas Soome * If there are no more variables that need to be set in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * loader environment then return NULL.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 'num' is used as a handle for the callback to identify which
199767f8919635c4928607450d9e0abb932109ceToomas Soome * environment variable to return next. It will begin at 0 and
199767f8919635c4928607450d9e0abb932109ceToomas Soome * each invocation will add 1 to the previous value of 'num'.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Version 4 additions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*vm_set_register)(void *arg, int vcpu, int reg, uint64_t val);
199767f8919635c4928607450d9e0abb932109ceToomas Soome int (*vm_set_desc)(void *arg, int vcpu, int reg, uint64_t base,