mem.h revision 269008
1148666Sjeff/*- 2148666Sjeff * Copyright (c) 2012 NetApp, Inc. 3148666Sjeff * All rights reserved. 4148666Sjeff * 5148666Sjeff * Redistribution and use in source and binary forms, with or without 6148666Sjeff * modification, are permitted provided that the following conditions 7148666Sjeff * are met: 8148666Sjeff * 1. Redistributions of source code must retain the above copyright 9148666Sjeff * notice, this list of conditions and the following disclaimer. 10148666Sjeff * 2. Redistributions in binary form must reproduce the above copyright 11148666Sjeff * notice, this list of conditions and the following disclaimer in the 12148666Sjeff * documentation and/or other materials provided with the distribution. 13148666Sjeff * 14148666Sjeff * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 15148666Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16148666Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17148666Sjeff * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 18148666Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19148666Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20148666Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21148666Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22148666Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23148666Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24148666Sjeff * SUCH DAMAGE. 25148666Sjeff * 26148666Sjeff * $FreeBSD: head/usr.sbin/bhyve/mem.h 269008 2014-07-23 04:28:51Z neel $ 27174137Srwatson */ 28174137Srwatson 29148666Sjeff#ifndef _MEM_H_ 30148666Sjeff#define _MEM_H_ 31148666Sjeff 32148666Sjeff#include <sys/linker_set.h> 33148666Sjeff 34148666Sjeffstruct vmctx; 35148666Sjeff 36148666Sjefftypedef int (*mem_func_t)(struct vmctx *ctx, int vcpu, int dir, uint64_t addr, 37148666Sjeff int size, uint64_t *val, void *arg1, long arg2); 38148666Sjeff 39148666Sjeffstruct mem_range { 40148666Sjeff const char *name; 41148666Sjeff int flags; 42219028Snetchild mem_func_t handler; 43148666Sjeff void *arg1; 44219028Snetchild long arg2; 45219028Snetchild uint64_t base; 46180495Santoine uint64_t size; 47148666Sjeff}; 48194828Srwatson#define MEM_F_READ 0x1 49174137Srwatson#define MEM_F_WRITE 0x2 50194828Srwatson#define MEM_F_RW 0x3 51148666Sjeff 52148666Sjeffvoid init_mem(void); 53148666Sjeffint emulate_mem(struct vmctx *, int vcpu, uint64_t paddr, struct vie *vie, 54148666Sjeff struct vm_guest_paging *paging); 55148666Sjeff 56148666Sjeffint register_mem(struct mem_range *memp); 57148666Sjeffint register_mem_fallback(struct mem_range *memp); 58148666Sjeffint unregister_mem(struct mem_range *memp); 59148666Sjeff 60148666Sjeff#endif /* _MEM_H_ */ 61148666Sjeff