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.


Now by default IO and MSR operations are dropped by Palacios unless they have been...
[palacios.git] / palacios / include / interfaces / vmm_keyed_stream.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) 2011, Peter Dinda <pdinda@northwestern.edu> 
11  * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Peter Dinda <pdinda@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_KEYED_STREAM_H__
22 #define __VMM_KEYED_STREAM_H__
23
24 #include <palacios/vmm.h>
25
26
27 /*
28   A keyed stream essentially supports this:
29
30   URL => {collection of key->stream pairs}
31
32   If you open a key for reading, you get the read pointer set to its beginning.   
33   You can then make repeated reads to advance the read pointer.  You cannot seek.
34
35   Writing works similarly.
36
37   You cannot both read and write. 
38
39 */
40
41 /* A keyed stream and its components are opaque to palacios */
42 typedef void * v3_keyed_stream_t;
43 typedef void * v3_keyed_stream_key_t;
44
45 typedef enum {V3_KS_RD_ONLY,V3_KS_WR_ONLY,V3_KS_WR_ONLY_CREATE} v3_keyed_stream_open_t;
46
47 #ifdef __V3VEE__
48
49
50 v3_keyed_stream_t     v3_keyed_stream_open(char *url, v3_keyed_stream_open_t open_type);
51 void                  v3_keyed_stream_close(v3_keyed_stream_t stream);
52 void                  v3_keyed_stream_preallocate_hint_key(v3_keyed_stream_t stream, char *key, uint64_t size);
53 v3_keyed_stream_key_t v3_keyed_stream_open_key(v3_keyed_stream_t stream, char *key);
54 void                  v3_keyed_stream_close_key(v3_keyed_stream_t stream,  char *key);
55 sint64_t              v3_keyed_stream_write_key(v3_keyed_stream_t stream,  
56                                                 v3_keyed_stream_key_t key,
57                                                 void *buf, 
58                                                 sint64_t len);
59 sint64_t              v3_keyed_stream_read_key(v3_keyed_stream_t stream,
60                                                v3_keyed_stream_key_t key,
61                                                void *buf, 
62                                                sint64_t len);
63
64 #define STD_SAVE(stream,ks,x)                   \
65     do { \
66         if (sizeof((x)) != v3_keyed_stream_write_key((stream), (ks), &(x), sizeof((x)))) { \
67             v3_keyed_stream_close_key((stream),(ks)); \
68             return -1;                                \
69         } \
70     } while (0)
71
72 #define STD_LOAD(stream,ks,x)                   \
73     do {                                                                \
74         if (sizeof((x)) != v3_keyed_stream_read_key((stream), (ks), &(x), sizeof((x)))) { \
75             v3_keyed_stream_close_key((stream),(ks)); \
76             return -1;                                 \
77         } \
78     } while (0)
79 #endif
80
81
82 struct v3_keyed_stream_hooks {
83     // url is meaningful only to the host implementation
84     v3_keyed_stream_t (*open)(char *url,
85                               v3_keyed_stream_open_t open_type);
86                               
87     void (*close)(v3_keyed_stream_t stream);
88
89     void (*preallocate_hint_key)(v3_keyed_stream_t stream,
90                                  char *key,
91                                  uint64_t size);
92
93     v3_keyed_stream_key_t (*open_key)(v3_keyed_stream_t stream,
94                                       char *key);
95
96     void (*close_key)(v3_keyed_stream_t stream, 
97                       v3_keyed_stream_key_t key);
98     
99
100     sint64_t (*write_key)(v3_keyed_stream_t stream,
101                           v3_keyed_stream_key_t key,
102                           void *buf, 
103                           sint64_t len);
104
105     sint64_t (*read_key)(v3_keyed_stream_t stream,
106                          v3_keyed_stream_key_t key,
107                          void *buf, 
108                          sint64_t len);
109     
110 };
111
112
113 extern void V3_Init_Keyed_Streams(struct v3_keyed_stream_hooks *hooks);
114
115 #endif