vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / accelerants / intel_extreme / commands.h
blob094c5e21ab64b8882f7ddedce5c9b8425fe54b3f
1 /*
2 * Copyright 2006-2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Axel Dörfler, axeld@pinc-software.de
7 */
8 #ifndef COMMANDS_H
9 #define COMMANDS_H
12 #include "accelerant.h"
15 struct command {
16 uint32 opcode;
18 uint32* Data() { return &opcode; }
21 class QueueCommands {
22 public:
23 QueueCommands(ring_buffer &ring);
24 ~QueueCommands();
26 void Put(struct command &command, size_t size);
27 void PutFlush();
28 void PutWaitFor(uint32 event);
29 void PutOverlayFlip(uint32 code, bool updateCoefficients);
31 void MakeSpace(uint32 size);
32 void Write(uint32 data);
34 private:
35 ring_buffer &fRingBuffer;
39 // commands
41 struct xy_command : command {
42 uint16 dest_bytes_per_row;
43 uint8 raster_operation;
44 uint8 mode;
45 uint16 dest_left;
46 uint16 dest_top;
47 uint16 dest_right;
48 uint16 dest_bottom;
49 uint32 dest_base;
51 xy_command(uint32 command, uint16 rop)
53 opcode = command;
54 switch (gInfo->shared_info->bits_per_pixel) {
55 case 8:
56 mode = COMMAND_MODE_CMAP8;
57 break;
58 case 15:
59 mode = COMMAND_MODE_RGB15;
60 break;
61 case 16:
62 mode = COMMAND_MODE_RGB16;
63 break;
64 case 32:
65 mode = COMMAND_MODE_RGB32;
66 opcode |= COMMAND_BLIT_RGBA;
67 break;
70 dest_bytes_per_row = gInfo->shared_info->bytes_per_row;
71 dest_base = gInfo->shared_info->frame_buffer_offset;
72 raster_operation = rop;
76 struct xy_source_blit_command : xy_command {
77 uint16 source_left;
78 uint16 source_top;
79 uint16 source_bytes_per_row;
80 uint16 reserved;
81 uint32 source_base;
83 xy_source_blit_command()
84 : xy_command(XY_COMMAND_SOURCE_BLIT, 0xcc)
86 source_bytes_per_row = dest_bytes_per_row;
87 source_base = dest_base;
88 reserved = 0;
92 struct xy_color_blit_command : xy_command {
93 uint32 color;
95 xy_color_blit_command(bool invert)
96 : xy_command(XY_COMMAND_COLOR_BLIT, invert ? 0x55 : 0xf0)
101 struct xy_setup_mono_pattern_command : xy_command {
102 uint32 background_color;
103 uint32 foreground_color;
104 uint64 pattern;
106 xy_setup_mono_pattern_command()
107 : xy_command(XY_COMMAND_SETUP_MONO_PATTERN, 0xf0)
109 mode |= COMMAND_MODE_SOLID_PATTERN;
111 // this defines the clipping window (but clipping is disabled)
112 dest_left = 0;
113 dest_top = 0;
114 dest_right = 0;
115 dest_bottom = 0;
119 struct xy_scanline_blit_command : command {
120 uint16 dest_left;
121 uint16 dest_top;
122 uint16 dest_right;
123 uint16 dest_bottom;
125 xy_scanline_blit_command()
127 opcode = XY_COMMAND_SCANLINE_BLIT;
131 #endif // COMMANDS_H