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) \
31 extern struct v3_file_hooks *file_hooks; \
32 ((file_hooks) && (file_hooks)->file_open) ? \
33 (file_hooks)->file_open((path), (mode)) : -1 ; \
36 #define V3_FileClose(fd) \
38 extern struct v3_file_hooks *file_hooks; \
39 ((file_hooks) && (file_hooks)->file_close) ? \
40 (file_hooks)->file_close((fd)) : -1 ; \
43 #define V3_FileSize(fd) \
45 extern struct v3_file_hooks *file_hooks; \
46 ((file_hooks) && (file_hooks)->file_size) ? \
47 (file_hooks)->file_size((fd)) : -1 ; \
50 #define V3_FileRead(fd,start,buf,len) \
52 extern struct v3_file_hooks *file_hooks; \
53 ((file_hooks) && (file_hooks)->file_read) ? \
54 (file_hooks)->file_read((fd),(start),(buf),(len)) : -1 ; \
57 #define V3_FileWrite(fd,start,buf,len) \
59 extern struct v3_file_hooks *file_hooks; \
60 ((file_hooks) && (file_hooks)->file_write) ? \
61 (file_hooks)->file_write((fd),(start),(buf),(len)) : -1 ; \
67 #define FILE_OPEN_MODE_READ (1 << 0)
68 #define FILE_OPEN_MODE_WRITE (1 << 1)
70 struct v3_file_hooks {
72 int (*file_open)(const char *path, int mode);
73 int (*file_close)(int fd);
75 long long (*file_size)(int fd);
77 // blocking reads and writes
78 long long (*file_read)(int fd, long long start, void *buffer, long long length);
79 long long (*file_write)(int fd, long long start, void *buffer, long long length);
84 extern void V3_Init_File(struct v3_file_hooks * hooks);