[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 3/6] + cdi.video: tyndur-Bibliothek



Signed-off-by: Alexander Siol <alex@xxxxxxxxxx>
---
 src/modules/cdi/lib/video/bitmap.c  |   76 +++++
 src/modules/cdi/lib/video/bitmap.h  |   51 +++
 src/modules/cdi/lib/video/context.c |  102 ++++++
 src/modules/cdi/lib/video/context.h |   64 ++++
 src/modules/cdi/lib/video/rpc.c     |  576 +++++++++++++++++++++++++++++++++++
 src/modules/cdi/lib/video/vesa.c    |  190 ++++++++++++
 src/modules/cdi/lib/video/video.c   |  236 ++++++++++++++
 src/modules/cdi/lib/video/video.h   |   26 ++
 8 files changed, 1321 insertions(+), 0 deletions(-)
 create mode 100644 src/modules/cdi/lib/video/bitmap.c
 create mode 100644 src/modules/cdi/lib/video/bitmap.h
 create mode 100644 src/modules/cdi/lib/video/context.c
 create mode 100644 src/modules/cdi/lib/video/context.h
 create mode 100644 src/modules/cdi/lib/video/rpc.c
 create mode 100644 src/modules/cdi/lib/video/vesa.c
 create mode 100644 src/modules/cdi/lib/video/video.c
 create mode 100644 src/modules/cdi/lib/video/video.h

diff --git a/src/modules/cdi/lib/video/bitmap.c b/src/modules/cdi/lib/video/bitmap.c
new file mode 100644
index 0000000..fbc3e4e
--- /dev/null
+++ b/src/modules/cdi/lib/video/bitmap.c
@@ -0,0 +1,76 @@
+/*  
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
+
+#include "bitmap.h"
+#include <cdi/video.h>
+#include <types.h>
+#include <stdlib.h>
+
+cdi_list_t bitmap_list = NULL;
+uint64_t bitmapid_ctr = 0;
+
+void bitmaps_initialize(void)
+{
+    bitmap_list = cdi_list_create();
+}
+
+interfacebitmap_t* bitmap_create(struct cdi_video_bitmap* bitmap, pid_t pid)
+{
+    interfacebitmap_t *interfacebitmap;
+    interfacebitmap = calloc(1, sizeof(interfacebitmap_t));
+    interfacebitmap->bitmap = bitmap;
+    interfacebitmap->id = ++bitmapid_ctr;
+    interfacebitmap->owner = pid;
+
+    cdi_list_push(bitmap_list, interfacebitmap);
+
+    return interfacebitmap;
+}
+
+void bitmap_destroy(interfacebitmap_t *bitmap)
+{
+    int i;
+    for (i = 0; i < cdi_list_size(bitmap_list); i++) {
+        if (cdi_list_get(bitmap_list, i) == bitmap) {
+            cdi_list_remove(bitmap_list, i);
+        }
+    }
+    free(bitmap);
+}
+
+interfacebitmap_t* bitmap_get_by_id(uint64_t id) 
+{
+    interfacebitmap_t *bitmap;
+    int i;
+    for (i = 0; i < cdi_list_size(bitmap_list); i++) {
+        bitmap = cdi_list_get(bitmap_list, i);
+        if (bitmap->id == id) {
+            return bitmap;
+        }
+    }
+    return NULL;
+}
diff --git a/src/modules/cdi/lib/video/bitmap.h b/src/modules/cdi/lib/video/bitmap.h
new file mode 100644
index 0000000..fca571f
--- /dev/null
+++ b/src/modules/cdi/lib/video/bitmap.h
@@ -0,0 +1,51 @@
+/*  
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
+
+#ifndef __CDI_VIDEO_LIB_BITMAP_H__
+#define __CDI_VIDEO_LIB_BITMAP_H__
+
+#include <cdi/video.h>
+#include <types.h>
+
+extern cdi_list_t bitmaps;
+extern uint64_t bitmapid_ctr;
+
+typedef struct {
+    struct cdi_video_bitmap *bitmap;
+    pid_t owner;
+    uint64_t id;
+    // TODO: ACL-Bitmaps
+} interfacebitmap_t;
+
+void bitmaps_initialize(void);
+
+interfacebitmap_t* bitmap_create(struct cdi_video_bitmap* bitmap, pid_t pid);
+interfacebitmap_t* bitmap_get_by_id(uint64_t id);
+
+void bitmap_destroy(interfacebitmap_t *bitmap);
+
+#endif /* __CDI_VIDEO_LIB_BITMAP_H__ */
diff --git a/src/modules/cdi/lib/video/context.c b/src/modules/cdi/lib/video/context.c
new file mode 100644
index 0000000..e139c41
--- /dev/null
+++ b/src/modules/cdi/lib/video/context.c
@@ -0,0 +1,102 @@
+/*  
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
+
+#include "video.h"
+#include <types.h>
+#include <cdi/lists.h>
+#include "context.h"
+#include <stdlib.h>
+
+int context_ctr = 0;
+cdi_list_t context_list;
+cdi_list_t user_list;
+
+void context_initialize(void)
+{
+    context_list = cdi_list_create();
+    user_list = cdi_list_create();
+}
+
+driver_context_t* get_current_context_of_pid(pid_t pid)
+{
+    int i;
+    for (i = 0; i < cdi_list_size(user_list); i++) {
+        pid_context_t *pidcontext;
+        pidcontext = cdi_list_get(user_list, i);
+        if (pidcontext->owner == pid) {
+            return pidcontext->context;
+        }
+    }
+    return NULL;
+}
+
+int set_current_context_of_pid(pid_t pid, driver_context_t *context) 
+{
+    int i;
+    // Zuordnung suchen
+    for (i = 0; i < cdi_list_size(user_list); i++) {
+        pid_context_t *pidcontext;
+        pidcontext = cdi_list_get(user_list, i);
+        if (pidcontext->owner == pid) {
+            // Gefunden, ersetzen
+            pidcontext->context = context;
+            return 0;
+        }
+    }
+
+    // Keine Zuordnung gefunden, neue anlegen
+    pid_context_t *pidcontext = calloc(1, sizeof(pid_context_t));
+    pidcontext->owner = pid;
+    pidcontext->context = context;
+    cdi_list_push(user_list, pidcontext);
+
+    return 0;
+}
+
+driver_context_t* get_context_by_id(int id)
+{
+    int i;
+    for (i = 0; i < cdi_list_size(context_list); i++) {
+        driver_context_t *context;
+        context = cdi_list_get(context_list, i);
+        if (context->id == id) {
+            return context;
+        }
+    }
+    return NULL;
+}
+
+driver_context_t* create_context(pid_t pid)
+{
+    driver_context_t *context = calloc(1, sizeof(driver_context_t));
+    context->owner = pid;
+    context->id = ++context_ctr;
+
+    cdi_list_push(context_list, context);
+
+    return context;
+}
diff --git a/src/modules/cdi/lib/video/context.h b/src/modules/cdi/lib/video/context.h
new file mode 100644
index 0000000..b6fc355
--- /dev/null
+++ b/src/modules/cdi/lib/video/context.h
@@ -0,0 +1,64 @@
+/*  
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
+
+#ifndef __CDI_VIDEO_LIB_CONTEXT_H__
+#define __CDI_VIDEO_LIB_CONTEXT_H__
+
+#include <cdi/lists.h>
+#include <cdi/video.h>
+#include <types.h>
+
+extern int context_ctr;
+extern cdi_list_t context_list;
+extern cdi_list_t user_list;
+
+typedef struct {
+    pid_t owner;
+    int id;
+    struct cdi_video_device *device;
+    struct cdi_video_bitmap *target;
+    struct cdi_video_color color;
+    enum cdi_video_raster_op rop;
+    dword *cmd_buffer;
+    dword cmd_buffer_id;
+    size_t cmd_buffer_size;
+} driver_context_t;
+
+typedef struct {
+    pid_t owner;
+    driver_context_t *context;
+} pid_context_t;
+
+
+
+driver_context_t* get_current_context_of_pid(pid_t pid);
+int set_current_context_of_pid(pid_t pid, driver_context_t *context);
+driver_context_t* get_context_by_id(int id);
+driver_context_t* create_context(pid_t pid);
+void context_initialize(void);
+
+#endif /* __CDI_VIDEO_LIB_CONTEXT_H__ */
\ No newline at end of file
diff --git a/src/modules/cdi/lib/video/rpc.c b/src/modules/cdi/lib/video/rpc.c
new file mode 100644
index 0000000..9a04275
--- /dev/null
+++ b/src/modules/cdi/lib/video/rpc.c
@@ -0,0 +1,576 @@
+/*  
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Alexander Siol.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <lostio.h>
+#include <rpc.h>
+#include <syscall.h>
+
+#include <cdi.h>
+#include <cdi/video.h>
+#include <cdi/misc.h>
+#include "video.h"
+#include "context.h"
+#include "bitmap.h"
+#include <video/commands.h>
+
+static interfacebitmap_t *frontbuffer_bitmap;
+
+void rpc_video_interface(pid_t pid,
+                          dword correlation_id,
+                          size_t data_size,
+                          void* data)
+{
+    dword response = -1;
+    dword *cmd = data;
+
+    dword *orig_cmd = NULL;
+    dword orig_size = 0;
+    dword orig_response = 0;
+
+    int response_sent = 0;
+    //stdout = 0;
+    //printf("device: %x\n", cdi_list_get(videodriver->drv.devices, 0));
+
+    driver_context_t *context;
+    context = get_current_context_of_pid(pid);
+
+    pre_loop:
+
+    while (data_size > 0) {
+        int param = 1;
+        response = -1;
+        response_sent = 0;
+        stdout = 0;
+        //printf("Handling Command %d\n", cmd[0]);
+        switch ((enum video_commands)cmd[0]) {
+            /// Kontextverwaltung
+            case VIDEO_CMD_CREATE_CONTEXT:
+                {
+                    driver_context_t *newcontext;
+                    newcontext = create_context(pid);
+                    response = newcontext->id;
+                }
+                break;
+
+            case VIDEO_CMD_USE_CONTEXT:
+                {
+                    param++;
+                    driver_context_t *tmpcontext;
+                    tmpcontext = get_context_by_id(cmd[1]);
+                    if (tmpcontext->owner == pid) {
+                        set_current_context_of_pid(pid, tmpcontext);
+                        context = tmpcontext;
+                        response = 0;
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_USE_DEVICE:
+                {
+                    param++;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n"
+                            "\tVIDEO_CMD_USE_DEVICE\n");
+                        break;
+                    }
+                    if (cmd[1] < cdi_list_size(videodriver->drv.devices)) {
+                        struct cdi_video_device* dev;
+                        dev = cdi_list_get(videodriver->drv.devices, cmd[1]);
+                        context->device = dev;
+                        stdout = 0;
+                        //printf("device %x used.\n", dev);
+                        response = 0;
+                    } else {
+                        //printf("cannot use device %x.\n", cmd[1]);
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_USE_TARGET:
+                {
+                    // FIXME: Interface verwendet nur dword
+                    param++;
+                    uint64_t bitmapid = cmd[1];
+                    interfacebitmap_t *bitmap;
+                    bitmap = bitmap_get_by_id(bitmapid);
+                    if (bitmap->owner == pid) {
+                        context->target = bitmap->bitmap;
+                        response = 0;
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_USE_COLOR:
+                {
+                    param++;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    char* colorarray = (char*)&cmd[1];
+                    context->color.alpha = colorarray[0];
+                    context->color.red   = colorarray[1];
+                    context->color.green = colorarray[2];
+                    context->color.blue  = colorarray[3];
+                    response = 0;
+                }
+                break;
+
+            case VIDEO_CMD_USE_ROP:
+                {
+                    param++;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    // FIXME: rop irgendwie validieren
+                    context->rop = cmd[1];
+                    videodriver->set_raster_op(context->device, context->rop);
+                }
+                break;
+
+            case VIDEO_CMD_GET_CMD_BUFFER:
+                {
+                    param++;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    size_t buffer_size = cmd[1];
+                    if (context->cmd_buffer_id) {
+                        close_shared_memory(context->cmd_buffer_id);
+                        context->cmd_buffer_size = 0;
+                    }
+                    context->cmd_buffer_id = create_shared_memory(buffer_size);
+                    if (context->cmd_buffer_id) {
+                        context->cmd_buffer =
+                            open_shared_memory(context->cmd_buffer_id);
+                        context->cmd_buffer_size = buffer_size;
+                        response = context->cmd_buffer_id;
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_DO_CMD_BUFFER:
+                {
+                    param += 1;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->cmd_buffer == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    orig_cmd = cmd + sizeof(dword) * param;
+                    orig_size = data_size - sizeof(dword) * param;
+                    data_size = cmd[1];
+                    cmd = context->cmd_buffer;
+                    orig_response = 0;
+                    stdout = 0;
+                    //printf("do_command_buffer, size: %d\n", data_size);
+                    goto pre_loop;
+                }
+                break;
+
+            /// Bitmaps
+            case VIDEO_CMD_CREATE_BITMAP:
+                {
+                    param += 3;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    int width = cmd[1];
+                    int height = cmd[2];
+                    int data_len = cmd[3];
+                    param += data_len / 4;
+                    struct cdi_video_bitmap *cdibitmap;
+                    cdibitmap = videodriver->bitmap_create(context->device,
+                        width, height, (data_len>0)?((void*)&cmd[4]):(NULL));
+                    if (cdibitmap) {
+                        interfacebitmap_t *bitmap;
+                        bitmap = bitmap_create(cdibitmap, pid);
+                        if (bitmap) {
+                            // FIXME: id ist uint64_t
+                            response = bitmap->id;
+                        } else {
+                            response = -1;
+                        }
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_DESTROY_BITMAP:
+                {
+                    param++;
+                    interfacebitmap_t *bitmap;
+                    bitmap = bitmap_get_by_id(cmd[1]);
+                    if (bitmap->owner == pid) {
+                        if (bitmap == frontbuffer_bitmap) {
+                            frontbuffer_bitmap = NULL;
+                        }
+                        videodriver->bitmap_destroy(bitmap->bitmap->device, 
+                            bitmap->bitmap);
+                        bitmap_destroy(bitmap);
+                        response = 0;
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_CREATE_FRONTBUFFER_BITMAP:
+                {
+                    param++;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->device == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (frontbuffer_bitmap) {
+                        //printf("frontbuffer_bitmap vorhanden?\n");
+                        response = -1;
+                        break;
+                    }
+                    if (cmd[1] < cdi_list_size(context->device->displays)) {
+                        struct cdi_video_display *display;
+                        display = cdi_list_get(context->device->displays, cmd[1]);
+                        if (display->frontbuffer == NULL) {
+                            // Ohne vorhandene FB-Bitmap gehts nicht weiter,
+                            // also Abbrechen
+                            //printf("Keine Bitmap vorhanden\n");
+                            response = -1;
+                            break;
+                        }
+                        interfacebitmap_t *frontbitmap;
+                        frontbitmap = bitmap_create(display->frontbuffer, pid);
+                        frontbuffer_bitmap = frontbitmap;
+                        response = (dword)frontbitmap->id;
+                    } else {
+                        //printf("display nicht gefunden.\n");
+                        response = -1;
+                    }
+                }
+                break;
+
+            /*
+            case VIDEO_CMD_RELEASE_FRONTBUFFER_BITMAP:
+                {
+                    if (frontbuffer_bitmap) {
+                        if (frontbuffer_bitmap->owner == pid) {
+                            bitmap_destroy(frontbuffer_bitmap);
+                            frontbuffer_bitmap = 0;
+                            response = 0;
+                        } else {
+                            response = -1;
+                        }
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;*/
+
+
+            /// Allgemeine Abfragen
+            case VIDEO_CMD_GET_NUM_DEVICES:
+                response = cdi_list_size(videodriver->drv.devices);
+                break;
+
+            case VIDEO_CMD_GET_NUM_DISPLAYS:
+                {
+                    param++;
+                    int devnum = cmd[1];
+                    if (devnum < cdi_list_size(videodriver->drv.devices)) {
+                        struct cdi_video_device *dev;
+                        dev = cdi_list_get(videodriver->drv.devices, devnum);
+                        response = cdi_list_size(dev->displays);
+                    } else {
+                        response = -1;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_GET_DISPLAY_MODES:
+                {
+                    param += 2;
+                    int devnum = cmd[1];
+                    struct cdi_video_device *dev;
+                    if (devnum < cdi_list_size(videodriver->drv.devices)) {
+                        dev = cdi_list_get(videodriver->drv.devices, devnum);
+                    } else {
+                        response = -1;
+                        break;
+                    }
+                    if (cmd[2] < cdi_list_size(dev->displays)) {
+                        struct cdi_video_display *display;
+                        display = cdi_list_get(dev->displays, cmd[2]);
+                        int num_modes = cdi_list_size(display->modes);
+                        if (num_modes >= 0) {
+                            dword *modelist = calloc(1, sizeof(dword) + 
+                                sizeof(dword) * num_modes * 4);
+                            modelist[0] = num_modes;
+                            int i;
+                            for (i = 0; i < cdi_list_size(display->modes); i++) 
+                            {
+                                struct cdi_video_displaymode *mode;
+                                mode = cdi_list_get(display->modes, i);
+                                modelist[1 + i*4] = mode->width;
+                                modelist[1 + i*4 + 1] = mode->height;
+                                modelist[1 + i*4 + 2] = mode->depth;
+                                modelist[1 + i*4 + 3] = mode->refreshrate;
+                            }
+                            rpc_send_response(pid, correlation_id, sizeof(dword) 
+                                + sizeof(dword) * num_modes * 4, 
+                                (char*)modelist);
+                            response_sent = 1;
+                        } else {
+                            response = -3;
+                        }
+                    } else {
+                        response = -2;
+                    }
+                }
+                break;
+
+            /// Anderes
+            case VIDEO_CMD_SET_RESOLUTION:
+                {
+                    // cmd[1] : display
+                    param += 5;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->device == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (frontbuffer_bitmap) {
+                        response = -1;
+                        break;
+                    }
+                    struct cdi_video_displaymode *mode = NULL;
+                    struct cdi_video_displaymode *best_match = NULL;
+                    if (cmd[1] < cdi_list_size(context->device->displays)) {
+                        struct cdi_video_display *display;
+                        display = cdi_list_get(context->device->displays, cmd[1]);
+                        int i;
+                        for (i = 0; i < cdi_list_size(display->modes); i++)
+                        {
+                            mode = cdi_list_get(display->modes, i);
+                            if (mode->width == cmd[2] &&
+                                mode->height == cmd[3] &&
+                                mode->depth == cmd[4] &&
+                                mode->refreshrate == cmd[5])
+                            {
+                                // Wir haben unseren Modus
+                                best_match = mode;
+                                break;
+                            } else if (mode->width == cmd[2] &&
+                                mode->height == cmd[3])
+                            {
+                                best_match = mode;
+                            }
+                        }
+                        if (best_match) {
+                            stdout = 0;
+                            //printf("Set Mode %x\n", best_match);
+                            videodriver->display_set_mode(context->device,
+                                display, mode);
+                            response = 0;
+                            break;
+                        }
+                    }
+                    response = -1;
+                }
+                break;
+
+            case VIDEO_CMD_DRAW_PIXEL:
+                {
+                    param += 2;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->target == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    int x = cmd[1], y = cmd[2];
+                    videodriver->draw_dot(context->target, x, y, context->color);
+                    response = 0;
+                }
+                break;
+
+            case VIDEO_CMD_DRAW_RECTANGLE:
+                {
+                    param += 4;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->target == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    int x = cmd[1], y = cmd[2], width = cmd[3], height = cmd[4];
+                    videodriver->draw_rectangle(context->target, x, y, width,
+                        height, context->color);
+                    response = 0;
+                }
+                break;
+
+            case VIDEO_CMD_DRAW_ELLIPSE:
+                {
+                    param += 4;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->target == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    int x = cmd[1], y = cmd[2], width = cmd[3], height = cmd[4];
+                    videodriver->draw_ellipse(context->target, x, y, width,
+                        height, context->color);
+                    response = 0;
+                }
+                break;
+
+            case VIDEO_CMD_DRAW_LINE:
+                {
+                    param += 4;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->target == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    int x1 = cmd[1], y1 = cmd[2], x2 = cmd[3], y2 = cmd[4];
+                    videodriver->draw_line(context->target, x1, y1, x2, y2,
+                        context->color);
+                    response = 0;
+                }
+                break;
+
+            case VIDEO_CMD_DRAW_BITMAP:
+                {
+                    param += 3;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->target == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    int x = cmd[1], y = cmd[2], bitmapid = cmd[3];
+                    interfacebitmap_t *bitmap;
+                    bitmap = bitmap_get_by_id(bitmapid);
+                    if (bitmap) {
+                        videodriver->draw_bitmap(context->target, 
+                            bitmap->bitmap, x, y);
+                        response = 0;
+                    }
+                }
+                break;
+
+            case VIDEO_CMD_DRAW_BITMAP_PART:
+                {
+                    param += 7;
+                    if (context == NULL) {
+                        fprintf(stderr, "Fehler, kein Kontext in cdi.video!\n");
+                        break;
+                    }
+                    if (context->target == NULL) {
+                        response = -1;
+                        break;
+                    }
+                    int x = cmd[1], y = cmd[2], bitmapid = cmd[3],
+                        srcx = cmd[4], srcy = cmd[5], width = cmd[6],
+                        height = cmd[7];
+                    interfacebitmap_t *bitmap;
+                    bitmap = bitmap_get_by_id(bitmapid);
+                    if (bitmap) {
+                        videodriver->draw_bitmap_part(context->target,
+                            bitmap->bitmap, x, y, srcx, srcy, width, height);
+                        response = 0;
+                    }
+                }
+                break;
+
+            default:
+                stdout = 0;
+                printf("Fehler: Unbekanntes Kommando: %d\n", cmd[0]);
+                break;
+        }
+
+        //printf("Handling %d finished, Result %d\n", cmd[0], response);
+
+        cmd += param;
+        data_size -= sizeof(dword) * param;
+    }
+
+    if (orig_size > 0 && orig_cmd) {
+        data_size = orig_size;
+        cmd = orig_cmd;
+        orig_size = 0;
+        goto pre_loop;
+    }
+    if (orig_cmd) {
+        orig_cmd = 0;
+        orig_size = 0;
+        response = orig_response;
+        //stdout = 0;
+        //cdi_sleep_ms(500);
+        //printf("do_command_buffer finished.\n");
+    }
+
+    if (response_sent == 0) {
+        rpc_send_dword_response(pid, correlation_id, response);
+    }
+}
diff --git a/src/modules/cdi/lib/video/vesa.c b/src/modules/cdi/lib/video/vesa.c
new file mode 100644
index 0000000..c6ad48d
--- /dev/null
+++ b/src/modules/cdi/lib/video/vesa.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2008-2009 Mathias Gottschlag, Janosch Graef, Alexander Siol
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it 
+ * and/or modify it under the terms of the Do What The Fuck You Want 
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+#include "cdi/vesa.h"
+#include "cdi/bios.h"
+#include "cdi/video.h"
+#include "cdi/misc.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+//#define DEBUG
+
+/**
+ * Initializes VESA
+ * Reads in graphics card info like video modes etc
+ * @return 0, if VESA is available, -1 if it is not (because of some error)
+ */
+int cdi_video_vesa_initialize
+    (struct cdi_video_vesa_info_block **vesainfo,
+    void (*mode_callback)(int modenum, struct cdi_video_vesa_mode_info *mode))
+{
+    int result;
+
+    // Phys. Speicher holen - notwendig, da der Speicher Pagealigned sein muss.
+    void* vesainfo_phys = NULL;
+    result = cdi_alloc_phys_mem(sizeof(struct cdi_video_vesa_info_block),
+        (void**)vesainfo, &vesainfo_phys);
+    if (result == -1) {
+        fprintf(stderr, "cdi_alloc_phys_mem failed.\n");
+        return -1;
+    }
+
+
+    // Register und Speicher vorbereiten
+    struct cdi_bios_registers regs;
+    memset(&regs, 0, sizeof(regs));
+    regs.ax = 0x4F00;
+    regs.ds = 0x8000;
+    regs.es = 0x8000;
+    regs.di = 0x0000;
+    memcpy(*vesainfo, "VBE2", 4);
+
+    // Speicherliste vorbereiten
+    cdi_list_t memorylist = cdi_list_create();
+    struct cdi_bios_memory infomemory;
+    infomemory.src = *vesainfo;
+    infomemory.dest = 0x80000;
+    infomemory.size = sizeof(struct cdi_video_vesa_info_block);
+    memorylist = cdi_list_push(memorylist, &infomemory);
+
+    // BIOS aufrufen
+    result = cdi_bios_int10(&regs, memorylist);
+
+    cdi_list_destroy(memorylist);
+
+    // cdi_bios_int10 not supported?
+    if (result == -1) {
+        fprintf(stderr, "cdi_bios_int10 failed.\n");
+        return -1;
+    }
+
+#ifdef DEBUG
+    printf("VESA: %c%c%c%c\n", (*vesainfo)->signature[0], (*vesainfo)->signature[1], 
+        (*vesainfo)->signature[2], (*vesainfo)->signature[3]);
+    printf("Version: %d.%d\n", (*vesainfo)->version[1], (*vesainfo)->version[0]);
+    printf("Modes: %05X\n", (*vesainfo)->modeptr);
+#endif
+
+    int i;
+    uint16_t *modeptr = (uint16_t*)((char*)*vesainfo + ((*vesainfo)->modeptr & 0xFFFF));
+    for (i = 0; i < 111; i++) {
+        if (modeptr[i] == 0xFFFF) break;
+        // Linear FB anfordern 
+        // FIXME: Unter qemu funktioniert das nicht, vgabios ist Schuld
+        modeptr[i] |= 0x4000;
+
+#ifdef DEBUG
+        printf("---\n");
+        printf("Mode: %04X\n", modeptr[i]);
+#endif
+
+        struct cdi_video_vesa_mode_info *modeinfo;
+        modeinfo = cdi_video_vesa_get_mode(modeptr[i]);
+
+        // Call Callback
+        (*mode_callback)(modeptr[i], modeinfo);
+        free(modeinfo);
+    }
+    return 0;
+}
+
+struct cdi_video_vesa_mode_info* cdi_video_vesa_get_mode(int modenum)
+{
+    void *modeinfo_phys;
+    struct cdi_bios_memory infomemory;
+    cdi_list_t memorylist;
+    memorylist = cdi_list_create();
+
+    struct cdi_video_vesa_mode_info* modeinfo;
+    //modeinfo = malloc(sizeof(struct cdi_video_vesa_mode_info));
+
+    cdi_alloc_phys_mem(sizeof(struct cdi_video_vesa_mode_info), (void**)&modeinfo, &modeinfo_phys);
+
+
+    infomemory.src = modeinfo;
+    infomemory.dest = 0x80000;
+    infomemory.size = sizeof(struct cdi_video_vesa_mode_info);
+
+    cdi_list_push(memorylist, &infomemory);
+
+    // Setup registers/memory
+    struct cdi_bios_registers regs;
+    memset(&regs, 0, sizeof(regs));
+    regs.ax = 0x4F01;
+    regs.ds = 0x8000;
+    regs.es = 0x8000;
+    regs.di = 0x0000;
+    regs.cx = modenum;
+
+    cdi_bios_int10(&regs, memorylist);
+    cdi_list_destroy(memorylist);
+
+#ifdef DEBUG
+    printf("Mode: %dx%dx%d, Framebuffer %x\n", modeinfo->width, modeinfo->height, 
+        modeinfo->depth, modeinfo->linearfb);
+    printf("Sizes: red: %d, blue: %d, green: %d, reserved %d\n",
+        modeinfo->redmasksize, modeinfo->bluemasksize, modeinfo->greenmasksize,
+        modeinfo->resmasksize);
+#endif
+
+    return modeinfo;
+}
+
+int cdi_video_vesa_change_mode(int modenumber)
+{
+    // Text mode
+    /*
+    if ((newmode->width == 80)
+     && (newmode->height == 25)
+     && (newmode->depth == 4)
+     && (newmode->type == CDI_VIDEO_TEXT)) {
+        struct cdi_bios_registers regs;
+        memset(&regs, 0, sizeof(regs));
+        regs.ax = 0x0083;
+        cdi_bios_int10(&regs, 0);
+    }*/
+    // Search for mode number
+    /*
+    uint16_t modenumber = 0xFFFF;
+    int i;
+    for (i = 0; i < cdi_list_size(modes); i++) {
+        struct cdi_video_vesa_mode *mode = cdi_list_get(modes, i);
+        if ((struct cdi_video_vesa_mode*)mode == newmode) {
+            modenumber = mode->vesamode;
+            break;
+        }
+        if ((mode->mode.width == newmode->mode.width)
+         && (mode->mode.height == newmode->mode.height)
+         && (mode->mode.depth == newmode->mode.depth)) {
+            modenumber = mode->vesamode;
+            break;
+        }
+    }
+    if (modenumber == 0xFFFF) {
+        return -1;
+    }
+
+    */
+
+    // Change mode
+    struct cdi_bios_registers regs;
+    memset(&regs, 0, sizeof(regs));
+    regs.ax = 0x4F02;
+    regs.bx = modenumber | 0xC000;
+    cdi_bios_int10(&regs, 0);
+    if ((regs.ax & 0xFF00) != 0x4F00) return -1;
+    if (regs.ax & 0xFF) return -1;
+    
+    return 0;
+}
+
diff --git a/src/modules/cdi/lib/video/video.c b/src/modules/cdi/lib/video/video.c
new file mode 100644
index 0000000..48d37df
--- /dev/null
+++ b/src/modules/cdi/lib/video/video.c
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2008 Mathias Gottschlag, Alexander Siol
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it 
+ * and/or modify it under the terms of the Do What The Fuck You Want 
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <lostio.h>
+#include <rpc.h>
+#include <syscall.h>
+
+#include <cdi.h>
+#include <cdi/video.h>
+#include "video.h"
+#include "context.h"
+#include "bitmap.h"
+#include <video/commands.h>
+
+int videocard_count = 0;
+struct cdi_video_driver* videodriver = 0;
+
+
+
+unsigned long int video_do_command_buffer(void* data, size_t len, pid_t origin);
+
+
+/**
+ * Initialisiert die Datenstrukturen fuer einen Grafikkartentreiber
+ */
+void cdi_video_driver_init(struct cdi_video_driver* driver)
+{
+    cdi_driver_init((struct cdi_driver*) driver);
+
+    context_initialize();
+    bitmaps_initialize();
+
+    register_message_handler("VIDEODRV", rpc_video_interface);
+}
+
+/**
+ * Deinitialisiert die Datenstrukturen fuer einen Grafikkartentreiber
+ */
+void cdi_video_driver_destroy(struct cdi_video_driver* driver)
+{
+    cdi_driver_destroy((struct cdi_driver*) driver);
+}
+
+/**
+ * Registiert einen Grafikkartentreiber
+ */
+void cdi_video_driver_register(struct cdi_video_driver* driver)
+{
+    videodriver = driver;
+    cdi_driver_register((struct cdi_driver*) driver);
+}
+
+/*
+unsigned long int video_do_command_buffer(void* data, size_t len, pid_t origin) {
+    dword* cmd = data;
+    unsigned long int result
+    while (len > 0) {
+        switch (cmd[0]) {
+            case VIDEO_COMMAND_GET_NUM_DEVICES:
+                
+                printf("Print Tree\n");
+                int devnum, dispnum, modenum;
+                for (devnum = 0; devnum < cdi_list_size(videodriver->drv.devices); devnum++) {
+                    struct cdi_video_device *dev = cdi_list_get(videodriver->drv.devices, devnum);
+                    printf("Dev %d\n", devnum);
+                    for (dispnum = 0; dispnum < cdi_list_size(dev->displays); dispnum++) {
+                        struct cdi_video_display *disp = cdi_list_get(dev->displays, dispnum);
+                        printf("\tDisplay %d\n", dispnum);
+                        for (modenum = 0; modenum < cdi_list_size(disp->modes); modenum++) {
+                            struct cdi_video_displaymode *mode = cdi_list_get(disp->modes, modenum);
+                            printf("\t\t%dx%dx%d @ %d\n", mode->width, mode->height, mode->depth, mode->refreshrate);
+                        }
+                    }
+                }
+                break;
+            default:
+                printf("Ungültiges Kommando!\n");
+                break;
+        }
+        len -= sizeof(dword);
+        cmd += sizeof(dword);
+    }
+    return 0;
+}*/
+
+/*
+
+unsigned long int video_do_command_buffer(void* data, size_t len, pid_t origin) {
+    video_command_t *cmd = NULL;
+    unsigned long int result = 0;
+    size_t processed_data = 0;
+
+    while (len > 0) {
+        cmd = data;
+        processed_data = 0;
+        result = 0;
+
+        switch (cmd->command) {
+            case VIDEO_SET_ACTIVE_CARD:
+                if (videocards[cmd->data[0]].card != NULL) {
+                    current_card = cmd->data[0];
+                    result = 1;
+                }
+                break;
+            case VIDEO_GET_NUM_CARDS:
+                result = videocard_count;
+                break;
+            case VIDEO_ADD_VSCREEN:
+                result = vscreen_add(current_card, origin);
+                break;
+            case VIDEO_REMOVE_VSCREEN:
+                if (len >= sizeof(video_command_t)) {
+                    vscreen_remove(current_card, cmd->data[0]);
+                    result = 1;
+                }
+                break;
+            case VIDEO_SET_ACTIVE_VSCREEN:
+                if (len >= sizeof(video_command_t)) {
+                    vscreen_set_active(current_card, cmd->data[0]);
+                }
+                break;
+            case VIDEO_GET_ACTIVE_VSCREEN:
+                result = vscreen_get_active(current_card);
+                break;
+
+            case VIDEO_SET_RESOLUTION:
+                if (len >= 
+                    (sizeof(video_command_t) + sizeof(unsigned long int) * 5)) {
+                    int index = cmd->data[0];
+                    int screen = cmd->data[1];
+                    int width = cmd->data[2];
+                    int height = cmd->data[3];
+                    int depth = cmd->data[4];
+                    int text = cmd->data[5];
+                    result = vscreen_set_resolution(current_card, index, screen,
+                        origin, width, height, depth, text);
+                    processed_data = 5 * sizeof(unsigned long int);
+                }
+                break;
+            case VIDEO_GET_RESOLUTION:
+                break;
+            case VIDEO_GET_RESOLUTION_LIST:
+                break;
+            case VIDEO_UPLOAD_BITMAP:
+                if (len >= 
+                    (sizeof(video_command_t) + sizeof(unsigned long int) * 4)) {
+                    int index = cmd->data[0];
+                    int width = cmd->data[1];
+                    int height = cmd->data[2];
+                    int format = cmd->data[3];
+                    int length = cmd->data[4];
+                    void *bitmap_data = 0;
+                    if (length) {
+                        bitmap_data = &cmd->data[5];
+                        result = upload_bitmap(current_card, index, origin, width, 
+                            height, format, length, bitmap_data);
+                    }
+                    processed_data = 4 * sizeof(unsigned long int) + length;
+                }
+                break;
+            case VIDEO_DESTROY_BITMAP:
+                if (len >= 
+                    (sizeof(video_command_t) + sizeof(unsigned long int) * 1)) {
+                    int index = cmd->data[0];
+                    int bitmap = cmd->data[1];
+                    result = destroy_bitmap(current_card, index, origin, bitmap);
+                    processed_data = 1 * sizeof(unsigned long int);
+                }
+                break;
+            case VIDEO_DESTROY_ALL_BITMAPS:
+                if (len >= sizeof(video_command_t)) {
+                    int index = cmd->data[0];
+                    result = destroy_all_bitmaps(current_card, index, origin);
+                }
+                break;
+            case VIDEO_DO_COMMAND_BUFFER:
+               if (len >= 
+                    (sizeof(video_command_t) + sizeof(unsigned long int) * 2)) {
+                    int index = cmd->data[0];
+                    int screen = cmd->data[1];
+                    int length = cmd->data[2];
+                    
+                    // Screen/Bildschirm heraussuchen
+                    if (index != videocards[current_card].activevscreen) break;
+                    if (!vscreen) break;
+                    if (vscreen->owner != origin) break;
+                    if (!display) break;
+                    
+                    // Buffer
+                    if (!vscreen->cmdbufferid) {
+                        break;
+                    }
+                    if (!length) break;
+                    if (length > 64 * 1024) length = 64 * 1024;
+                    
+                    void *buffer = (void*)vscreen->cmdbuffer;
+                    // TODO: Auf diese Funktion umstellen!
+                    video_do_command_buffer(buffer, length, origin);
+                    result = 1; */ /*
+                    printf("[ cdi-video ] video_do_buffer()\n");
+                    result = video_do_buffer(current_card, index, screen, 
+                        origin, length);
+                }
+                break;
+            case VIDEO_GET_COMMAND_BUFFER:
+                if (len >= sizeof(video_command_t)) {
+                    result = vscreen_get_command_buffer(current_card, cmd->data[0],
+                        origin);
+                    printf("[ cdi-video ] Kommandobuffer angelegt, ID: %d\n", result);
+                }
+                else {
+                    printf("[ cdi-video ] Kommandobuffer nicht angelegt da Kommando fehlerhaft!\n");
+                }
+                break;
+
+            default:
+                printf("[ cdi-video ] Unbekanntes Kommando: %d\n", cmd->command);
+        }
+
+        data = data + sizeof(video_command_t) + processed_data;
+        len = len - sizeof(video_command_t) - processed_data;
+    }
+
+    return result;
+}*/
diff --git a/src/modules/cdi/lib/video/video.h b/src/modules/cdi/lib/video/video.h
new file mode 100644
index 0000000..f4c3108
--- /dev/null
+++ b/src/modules/cdi/lib/video/video.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2008 Mathias Gottschlag, Alexander Siol
+ *
+ * This program is free software. It comes without any warranty, to
+ * the extent permitted by applicable law. You can redistribute it 
+ * and/or modify it under the terms of the Do What The Fuck You Want 
+ * To Public License, Version 2, as published by Sam Hocevar. See
+ * http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ */
+
+#ifndef VIDEO_H
+#define VIDEO_H
+
+#include <cdi.h>
+#include <types.h>
+
+extern struct cdi_video_driver* videodriver;
+
+//Interface über RPC
+void rpc_video_interface(pid_t pid,
+                          dword correlation_id,
+                          size_t data_size,
+                          void* data);
+
+#endif
+
-- 
1.6.0.4