mem.h revision 249321
160786Sps/*- 2240121Sdelphij * Copyright (c) 2012 NetApp, Inc. 360786Sps * All rights reserved. 460786Sps * 560786Sps * Redistribution and use in source and binary forms, with or without 660786Sps * modification, are permitted provided that the following conditions 7240121Sdelphij * are met: 860786Sps * 1. Redistributions of source code must retain the above copyright 960786Sps * notice, this list of conditions and the following disclaimer. 1063120Sps * 2. Redistributions in binary form must reproduce the above copyright 1160786Sps * notice, this list of conditions and the following disclaimer in the 1260786Sps * documentation and/or other materials provided with the distribution. 1360786Sps * 1460786Sps * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 1560786Sps * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1660786Sps * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1760786Sps * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 1860786Sps * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1960786Sps * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2060786Sps * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2160786Sps * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2260786Sps * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2360786Sps * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2460786Sps * SUCH DAMAGE. 2560786Sps * 2660786Sps * $FreeBSD: head/usr.sbin/bhyve/mem.h 249321 2013-04-10 02:12:39Z neel $ 2760786Sps */ 2860786Sps 2960786Sps#ifndef _MEM_H_ 3060786Sps#define _MEM_H_ 3160786Sps 3260786Sps#include <sys/linker_set.h> 3360786Sps 3460786Spsstruct vmctx; 3560786Sps 36161478Sdelphijtypedef int (*mem_func_t)(struct vmctx *ctx, int vcpu, int dir, uint64_t addr, 37170259Sdelphij int size, uint64_t *val, void *arg1, long arg2); 38170259Sdelphij 3960786Spsstruct mem_range { 4060786Sps const char *name; 4160786Sps int flags; 4260786Sps mem_func_t handler; 4360786Sps void *arg1; 4460786Sps long arg2; 4560786Sps uint64_t base; 4660786Sps uint64_t size; 4760786Sps}; 48191930Sdelphij#define MEM_F_READ 0x1 4960786Sps#define MEM_F_WRITE 0x2 5060786Sps#define MEM_F_RW 0x3 5160786Sps 5260786Spsvoid init_mem(void); 5360786Spsint emulate_mem(struct vmctx *, int vcpu, uint64_t paddr, struct vie *vie); 5460786Sps 5560786Spsint register_mem(struct mem_range *memp); 5660786Spsint register_mem_fallback(struct mem_range *memp); 5760786Spsint unregister_mem(struct mem_range *memp); 5860786Sps 5960786Sps#endif /* _MEM_H_ */ 6060786Sps