2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2010, Peter Dinda (pdinda@cs.northwestern.edu>
11 * Copyright (c) 2010, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Peter Dinda <pdinda@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #ifndef __VMM_FILE_H__
22 #define __VMM_FILE_H__
24 #include <palacios/vmm.h>
29 #define V3_FileOpen(path, mode, host_data) \
32 extern struct v3_file_hooks * file_hooks; \
33 if ((file_hooks) && (file_hooks)->file_open) { \
34 fd = (file_hooks)->file_open((path), (mode), (host_data)); \
39 #define V3_FileClose(fd) \
42 extern struct v3_file_hooks * file_hooks; \
43 if ((file_hooks) && (file_hooks)->file_close) { \
44 ret = (file_hooks)->file_close((fd)); \
49 #define V3_FileSize(fd) \
51 long long size = -1; \
52 extern struct v3_file_hooks * file_hooks; \
53 if ((file_hooks) && (file_hooks)->file_size) { \
54 size = (file_hooks)->file_size((fd)); \
59 #define V3_FileRead(fd, start, buf, len) \
62 extern struct v3_file_hooks * file_hooks; \
63 if ((file_hooks) && (file_hooks)->file_read) { \
64 ret = (file_hooks)->file_read((fd), (buf), (len), (start)); \
69 #define V3_FileWrite(fd,start,buf,len) \
72 extern struct v3_file_hooks * file_hooks; \
73 if ((file_hooks) && (file_hooks)->file_write) { \
74 ret = (file_hooks)->file_write((fd), (buf), (len), (start)); \
82 #define FILE_OPEN_MODE_READ (1 << 0)
83 #define FILE_OPEN_MODE_WRITE (1 << 1)
85 struct v3_file_hooks {
87 void * (*file_open)(const char * path, int mode, void * host_data);
88 int (*file_close)(void * fd);
90 long long (*file_size)(void * fd);
92 // blocking reads and writes
93 long long (*file_read)(void * fd, void * buffer, long long length, long long offset);
94 long long (*file_write)(void * fd, void * buffer, long long length, long long offset);
99 extern void V3_Init_File(struct v3_file_hooks * hooks);