1241744Sgrehan/*- 2241744Sgrehan * Copyright (c) 2012 NetApp, Inc. 3241744Sgrehan * All rights reserved. 4241744Sgrehan * 5241744Sgrehan * Redistribution and use in source and binary forms, with or without 6241744Sgrehan * modification, are permitted provided that the following conditions 7241744Sgrehan * are met: 8241744Sgrehan * 1. Redistributions of source code must retain the above copyright 9241744Sgrehan * notice, this list of conditions and the following disclaimer. 10241744Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 11241744Sgrehan * notice, this list of conditions and the following disclaimer in the 12241744Sgrehan * documentation and/or other materials provided with the distribution. 13241744Sgrehan * 14241744Sgrehan * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 15241744Sgrehan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16241744Sgrehan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17241744Sgrehan * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 18241744Sgrehan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19241744Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20241744Sgrehan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21241744Sgrehan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22241744Sgrehan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23241744Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24241744Sgrehan * SUCH DAMAGE. 25241744Sgrehan * 26241744Sgrehan * $FreeBSD$ 27241744Sgrehan */ 28241744Sgrehan 29241744Sgrehan#ifndef _MEM_H_ 30241744Sgrehan#define _MEM_H_ 31241744Sgrehan 32241744Sgrehan#include <sys/linker_set.h> 33241744Sgrehan 34241744Sgrehanstruct vmctx; 35241744Sgrehan 36241744Sgrehantypedef int (*mem_func_t)(struct vmctx *ctx, int vcpu, int dir, uint64_t addr, 37241744Sgrehan int size, uint64_t *val, void *arg1, long arg2); 38241744Sgrehan 39241744Sgrehanstruct mem_range { 40241744Sgrehan const char *name; 41241744Sgrehan int flags; 42241744Sgrehan mem_func_t handler; 43241744Sgrehan void *arg1; 44241744Sgrehan long arg2; 45241744Sgrehan uint64_t base; 46241744Sgrehan uint64_t size; 47241744Sgrehan}; 48241744Sgrehan#define MEM_F_READ 0x1 49241744Sgrehan#define MEM_F_WRITE 0x2 50241744Sgrehan#define MEM_F_RW 0x3 51270159Sgrehan#define MEM_F_IMMUTABLE 0x4 /* mem_range cannot be unregistered */ 52241744Sgrehan 53241744Sgrehanvoid init_mem(void); 54270159Sgrehanint emulate_mem(struct vmctx *, int vcpu, uint64_t paddr, struct vie *vie, 55270159Sgrehan struct vm_guest_paging *paging); 56241744Sgrehan 57241744Sgrehanint register_mem(struct mem_range *memp); 58247144Sgrehanint register_mem_fallback(struct mem_range *memp); 59249321Sneelint unregister_mem(struct mem_range *memp); 60241744Sgrehan 61241744Sgrehan#endif /* _MEM_H_ */ 62