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);
50 // when render_request is invoked, Palacios will redraw immediately
51 int v3_graphics_console_register_render_request(
52 v3_graphics_console_t cons,
53 int (*render_request)(v3_graphics_console_t cons,
56 // when update_inquire is invoked, palacios will indicate if there
57 // is anything new with a non-zero return value
58 int v3_graphics_console_register_update_inquire(
59 v3_graphics_console_t cons,
60 int (*update_inquire)(v3_graphics_console_t cons,
64 void v3_graphics_console_close(v3_graphics_console_t cons);
71 A graphics console provides a frame buffer into which to render
72 which is specified as follows.
75 The data of the actual frame buffer is in row-major order.
77 struct v3_frame_buffer_spec {
80 uint8_t bytes_per_pixel;
81 uint8_t bits_per_channel;
82 uint8_t red_offset; // byte offset in pixel to get to red channel
83 uint8_t green_offset; // byte offset in pixel to get to green channel
84 uint8_t blue_offset; // byte offset in pixel to get to blue channel
89 struct v3_graphics_console_hooks {
90 // Note that the minimum spec argument may be null, indicating that it is not provided
91 v3_graphics_console_t (*open)(void * priv_data,
92 struct v3_frame_buffer_spec *desired_spec,
93 struct v3_frame_buffer_spec *actual_spec);
94 void (*close)(v3_graphics_console_t cons);
96 void * (*get_data_read)(v3_graphics_console_t cons, struct v3_frame_buffer_spec *cur_spec);
97 void (*release_data_read)(v3_graphics_console_t cons);
98 void * (*get_data_rw)(v3_graphics_console_t cons, struct v3_frame_buffer_spec *cur_spec);
99 void (*release_data_rw)(v3_graphics_console_t cons);
101 // callback to indicate that the FB is stale and that an update can occur
102 // a positive return value indicates we should re-render now
103 // this callback is from Palacios to the implementation and is called
104 // when virtual GPU state changes to ask if the FB should be re-rendered now
105 int (*changed)(v3_graphics_console_t cons);
108 // callback to allow Palacios to register a render request callback
109 // with the implementation. Using this callback, the implementation
110 // can specifically request that Palacios render immediately
111 int (*register_render_request)(v3_graphics_console_t cons,
112 int (*render_request)(v3_graphics_console_t cons,
116 // callback to allow Palacios to register an update inquire callback
117 // with the implementation. Using this callback, the implementation
118 // can ask if Palacios has any new data
119 int (*register_update_inquire)(v3_graphics_console_t cons,
120 int (*update_inquire)(v3_graphics_console_t cons,
127 extern void V3_Init_Graphics_Console(struct v3_graphics_console_hooks *hooks);