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.


updated stream API
Jack Lange [Tue, 9 Nov 2010 19:24:07 +0000 (13:24 -0600)]
palacios/include/palacios/vmm_stream.h
palacios/src/palacios/vmm_stream.c

index ce4cb8f..513cf73 100644 (file)
 #ifndef __VMM_STREAM_H__
 #define __VMM_STREAM_H__
 
-#include <palacios/vmm.h>
 
 
 #ifdef __V3VEE__
+#include <palacios/vmm.h>
 
-#define V3_StreamOpen(path, notify_fn, private_data, mode)                                             \
-    ({                                                                 \
-       extern struct v3_stream_hooks *stream_hooks;                            \
-       ((stream_hooks) && (stream_hooks)->stream_open) ?                               \
-           (stream_hooks)->stream_open((path), (notify_fn), (private_data), (mode)) : NULL;            \
-    })
-
-#define V3_StreamRead(stream, b, l)                                    \
-    ({                                                                 \
-       extern struct v3_stream_hooks *stream_hooks;                            \
-       ((stream_hooks) && (stream_hooks)->stream_read) ?                       \
-           (stream_hooks)->stream_read((stream), (b), (l)) : -1;               \
-    })
-
-#define V3_StreamWrite(stream, b, l)                                   \
-    ({                                                                 \
-       extern struct v3_stream_hooks *stream_hooks;                            \
-       ((stream_hooks) && (stream_hooks)->stream_write) ?                      \
-           (stream_hooks)->stream_write((stream), (b), (l)) : -1;              \
-    })
-
+typedef void * v3_stream_t;
 
-#define V3_StreamClose(stream)                                         \
-    ({                                                                 \
-       extern struct v3_stream_hooks *stream_hooks;                            \
-       ((stream_hooks) && (stream_hooks)->stream_close) ?                              \
-           (stream_hooks)->stream_close((stream), (mode)) : NULL;      \
-    })
+/* VM Can be NULL */
+v3_stream_t v3_stream_open(struct v3_vm_info * vm, const char * name);
+int v3_stream_write(v3_stream_t stream, uint8_t * buf, uint32_t len);
 
+void v3_stream_close(v3_stream_t stream);
 
 #endif
 
-#define STREAM_OPEN_MODE_READ  (1 << 0)
-#define STREAM_OPEN_MODE_WRITE (1 << 1)
 
 struct v3_stream_hooks {
-    void *(*stream_open)(const char *path, void (*notify)(void *), void *private_data, int mode);
-    int (*stream_read)(void *stream, char *buf, int len);
-    int (*stream_write)(void *stream, char *buf, int len);
-    int (*stream_close)(void *stream);
+    void *(*open)(const char * name, void * private_data);
+    int (*write)(void * stream, char * buf, int len);
+    void (*close)(void * stream);
 };
 
 
-extern void V3_Init_Stream(struct v3_stream_hooks * hooks);
+void V3_Init_Stream(struct v3_stream_hooks * hooks);
 
 #endif
index 729c661..f9fe479 100644 (file)
  */
 
 
-#include <palacios/vmm_stream.h>
 #include <palacios/vmm.h>
 #include <palacios/vmm_debug.h>
 #include <palacios/vmm_types.h>
 
+#include <palacios/vmm_stream.h>
+
+static struct v3_stream_hooks * stream_hooks = NULL;
+
+// VM can be NULL
+v3_stream_t v3_stream_open(struct v3_vm_info * vm, const char * name) {
+    V3_ASSERT(stream_hooks != NULL);
+    V3_ASSERT(stream_hooks->open != NULL);
+
+    return stream_hooks->open(name, vm->host_private_data);
+}
+
+int v3_stream_write(v3_stream_t stream, uint8_t * buf, uint32_t len) {
+    V3_ASSERT(stream_hooks != NULL);
+    V3_ASSERT(stream_hooks->write != NULL);
+
+    return stream_hooks->write(stream, buf, len);
+}
+
+void v3_stream_close(v3_stream_t stream) {
+    V3_ASSERT(stream_hooks != NULL);
+    V3_ASSERT(stream_hooks->close != NULL);
+
+    return stream_hooks->close(stream);
+}
+
+
+
 
-struct v3_stream_hooks * stream_hooks = 0;
 
 void V3_Init_Stream(struct v3_stream_hooks * hooks) {
     stream_hooks = hooks;