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) 2011, Peter Dinda <pdinda@northwestern.edu>
11 * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Peter Dinda <pdinda@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_GRAPHICS_CONSOLE_H__
22 #define __VMM_GRAPHICS_CONSOLE_H__
24 #include <palacios/vmm.h>
27 /* A graphics console is opaque to the palacios */
28 typedef void * v3_graphics_console_t;
34 struct v3_frame_buffer_spec ;
37 /* we give a desired spec and get back the actual spec */
38 v3_graphics_console_t v3_graphics_console_open(struct v3_vm_info * vm,
39 struct v3_frame_buffer_spec *desired_spec,
40 struct v3_frame_buffer_spec *actual_spec);
42 /* Spec is an optional output argument the indicates the current FB specification */
43 /* The data will only be read or read/written between a get and release */
44 void *v3_graphics_console_get_frame_buffer_data_read(v3_graphics_console_t cons, struct v3_frame_buffer_spec *spec);
45 void v3_graphics_console_release_frame_buffer_data_read(v3_graphics_console_t cons);
46 void *v3_graphics_console_get_frame_buffer_data_rw(v3_graphics_console_t cons, struct v3_frame_buffer_spec *spec);
47 void v3_graphics_console_release_frame_buffer_data_rw(v3_graphics_console_t cons);
48 // returns >0 if a redraw in response to this update would be useful now
49 int v3_graphics_console_inform_update(v3_graphics_console_t cons);
51 void v3_graphics_console_close(v3_graphics_console_t cons);
58 A graphics console provides a frame buffer into which to render
59 which is specified as follows.
62 The data of the actual frame buffer is in row-major order.
64 struct v3_frame_buffer_spec {
67 uint8_t bytes_per_pixel;
68 uint8_t bits_per_channel;
69 uint8_t red_offset; // byte offset in pixel to get to red channel
70 uint8_t green_offset; // byte offset in pixel to get to green channel
71 uint8_t blue_offset; // byte offset in pixel to get to blue channel
76 struct v3_graphics_console_hooks {
77 // Note that the minimum spec argument may be null, indicating that it is not provided
78 v3_graphics_console_t (*open)(void * priv_data,
79 struct v3_frame_buffer_spec *desired_spec,
80 struct v3_frame_buffer_spec *actual_spec);
81 void (*close)(v3_graphics_console_t cons);
83 void * (*get_data_read)(v3_graphics_console_t cons, struct v3_frame_buffer_spec *cur_spec);
84 void (*release_data_read)(v3_graphics_console_t cons);
85 void * (*get_data_rw)(v3_graphics_console_t cons, struct v3_frame_buffer_spec *cur_spec);
86 void (*release_data_rw)(v3_graphics_console_t cons);
88 // callback to indicate that the FB is stale and that an update can occur
89 // a positive return value indicates we should re-render now
90 int (*changed)(v3_graphics_console_t cons);
94 extern void V3_Init_Graphics_Console(struct v3_graphics_console_hooks *hooks);