Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


bf4a1d054e74db9271d34994fc6466f5a705c7cc
[palacios.git] / palacios / include / palacios / vmm_file.h
1 /*
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
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.
13  *
14  * Author: Peter Dinda <pdinda@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #ifndef __VMM_FILE_H__
22 #define __VMM_FILE_H__
23
24 #include <palacios/vmm.h>
25
26
27 #ifdef __V3VEE__
28
29 #define V3_FileOpen(path, mode)                                         \
30     ({                                                                  \
31         extern struct v3_file_hooks * file_hooks;                       \
32         ((file_hooks) && (file_hooks)->file_open) ?                     \
33             (file_hooks)->file_open((path), (mode)) : -1;               \
34     })
35
36 #define V3_FileClose(fd)                                                \
37     ({                                                                  \
38         extern struct v3_file_hooks * file_hooks;                       \
39         ((file_hooks) && (file_hooks)->file_close) ?                    \
40             (file_hooks)->file_close((fd))  :  -1;                      \
41     })
42
43 #define V3_FileSize(fd)                                                 \
44     ({                                                                  \
45         extern struct v3_file_hooks * file_hooks;                       \
46         ((file_hooks) && (file_hooks)->file_size) ?                     \
47             (file_hooks)->file_size((fd))  : -1;                        \
48     })
49
50 #define V3_FileRead(fd, start, buf, len)                                \
51     ({                                                                  \
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;  \
55     })
56
57 #define V3_FileWrite(fd,start,buf,len)                                  \
58     ({                                                                  \
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; \
62     })
63
64
65 #endif
66
67 #define FILE_OPEN_MODE_READ     (1 << 0)
68 #define FILE_OPEN_MODE_WRITE    (1 << 1)
69
70 struct v3_file_hooks {
71
72     int (*file_open)(const char * path, int mode);
73     int (*file_close)(int fd);
74
75     long long (*file_size)(int fd);
76
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);
80
81 };
82
83
84 extern void V3_Init_File(struct v3_file_hooks * hooks);
85
86 #endif