1 /**
2 	Based on Protocol/SimpleTextOut.h, original notice:
3 
4 	Simple Text Out protocol from the UEFI 2.0 specification.
5 	
6 	Abstraction of a very simple text based output device like VGA text mode or
7 	a serial terminal. The Simple Text Out protocol instance can represent
8 	a single hardware device or a virtual device that is an aggregation
9 	of multiple physical devices.
10 	
11 	Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
12 	This program and the accompanying materials are licensed and made available under
13 	the terms and conditions of the BSD License that accompanies this distribution.
14 	The full text of the license may be found at
15 	http://opensource.org/licenses/bsd-license.php.
16 	
17 	THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 	WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 	
20 **/
21 module uefi.protocols.simpletextout;
22 import uefi.base;
23 import uefi.base_type;
24 
25 public:
26 extern (C):
27 enum EFI_GUID EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID = EFI_GUID(0x387477c2,
28         0x69c7, 0x11d2, [0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b]);
29 /// Protocol GUID defined in EFI1.1.
30 enum SIMPLE_TEXT_OUTPUT_PROTOCOL = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
31 alias EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
32 /// Backward-compatible with EFI1.1.
33 alias SIMPLE_TEXT_OUTPUT_INTERFACE = EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
34 enum BOXDRAW_HORIZONTAL = 0x2500;
35 enum BOXDRAW_VERTICAL = 0x2502;
36 enum BOXDRAW_DOWN_RIGHT = 0x250c;
37 enum BOXDRAW_DOWN_LEFT = 0x2510;
38 enum BOXDRAW_UP_RIGHT = 0x2514;
39 enum BOXDRAW_UP_LEFT = 0x2518;
40 enum BOXDRAW_VERTICAL_RIGHT = 0x251c;
41 enum BOXDRAW_VERTICAL_LEFT = 0x2524;
42 enum BOXDRAW_DOWN_HORIZONTAL = 0x252c;
43 enum BOXDRAW_UP_HORIZONTAL = 0x2534;
44 enum BOXDRAW_VERTICAL_HORIZONTAL = 0x253c;
45 enum BOXDRAW_DOUBLE_HORIZONTAL = 0x2550;
46 enum BOXDRAW_DOUBLE_VERTICAL = 0x2551;
47 enum BOXDRAW_DOWN_RIGHT_DOUBLE = 0x2552;
48 enum BOXDRAW_DOWN_DOUBLE_RIGHT = 0x2553;
49 enum BOXDRAW_DOUBLE_DOWN_RIGHT = 0x2554;
50 enum BOXDRAW_DOWN_LEFT_DOUBLE = 0x2555;
51 enum BOXDRAW_DOWN_DOUBLE_LEFT = 0x2556;
52 enum BOXDRAW_DOUBLE_DOWN_LEFT = 0x2557;
53 enum BOXDRAW_UP_RIGHT_DOUBLE = 0x2558;
54 enum BOXDRAW_UP_DOUBLE_RIGHT = 0x2559;
55 enum BOXDRAW_DOUBLE_UP_RIGHT = 0x255a;
56 enum BOXDRAW_UP_LEFT_DOUBLE = 0x255b;
57 enum BOXDRAW_UP_DOUBLE_LEFT = 0x255c;
58 enum BOXDRAW_DOUBLE_UP_LEFT = 0x255d;
59 enum BOXDRAW_VERTICAL_RIGHT_DOUBLE = 0x255e;
60 enum BOXDRAW_VERTICAL_DOUBLE_RIGHT = 0x255f;
61 enum BOXDRAW_DOUBLE_VERTICAL_RIGHT = 0x2560;
62 enum BOXDRAW_VERTICAL_LEFT_DOUBLE = 0x2561;
63 enum BOXDRAW_VERTICAL_DOUBLE_LEFT = 0x2562;
64 enum BOXDRAW_DOUBLE_VERTICAL_LEFT = 0x2563;
65 enum BOXDRAW_DOWN_HORIZONTAL_DOUBLE = 0x2564;
66 enum BOXDRAW_DOWN_DOUBLE_HORIZONTAL = 0x2565;
67 enum BOXDRAW_DOUBLE_DOWN_HORIZONTAL = 0x2566;
68 enum BOXDRAW_UP_HORIZONTAL_DOUBLE = 0x2567;
69 enum BOXDRAW_UP_DOUBLE_HORIZONTAL = 0x2568;
70 enum BOXDRAW_DOUBLE_UP_HORIZONTAL = 0x2569;
71 enum BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE = 0x256a;
72 enum BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL = 0x256b;
73 enum BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL = 0x256c;
74 enum BLOCKELEMENT_FULL_BLOCK = 0x2588;
75 enum BLOCKELEMENT_LIGHT_SHADE = 0x2591;
76 enum GEOMETRICSHAPE_UP_TRIANGLE = 0x25b2;
77 enum GEOMETRICSHAPE_RIGHT_TRIANGLE = 0x25ba;
78 enum GEOMETRICSHAPE_DOWN_TRIANGLE = 0x25bc;
79 enum GEOMETRICSHAPE_LEFT_TRIANGLE = 0x25c4;
80 enum ARROW_LEFT = 0x2190;
81 enum ARROW_UP = 0x2191;
82 enum ARROW_RIGHT = 0x2192;
83 enum ARROW_DOWN = 0x2193;
84 enum EFI_BLACK = 0x00;
85 enum EFI_BLUE = 0x01;
86 enum EFI_GREEN = 0x02;
87 enum EFI_CYAN = (EFI_BLUE | EFI_GREEN);
88 enum EFI_RED = 0x04;
89 enum EFI_MAGENTA = (EFI_BLUE | EFI_RED);
90 enum EFI_BROWN = (EFI_GREEN | EFI_RED);
91 enum EFI_LIGHTGRAY = (EFI_BLUE | EFI_GREEN | EFI_RED);
92 enum EFI_BRIGHT = 0x08;
93 enum EFI_DARKGRAY = (EFI_BLACK | EFI_BRIGHT);
94 enum EFI_LIGHTBLUE = (EFI_BLUE | EFI_BRIGHT);
95 enum EFI_LIGHTGREEN = (EFI_GREEN | EFI_BRIGHT);
96 enum EFI_LIGHTCYAN = (EFI_CYAN | EFI_BRIGHT);
97 enum EFI_LIGHTRED = (EFI_RED | EFI_BRIGHT);
98 enum EFI_LIGHTMAGENTA = (EFI_MAGENTA | EFI_BRIGHT);
99 enum EFI_YELLOW = (EFI_BROWN | EFI_BRIGHT);
100 enum EFI_WHITE = (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT);
101 // #define EFI_TEXT_ATTR(Foreground,Background) ((Foreground) | ((Background) << 4))
102 enum EFI_BACKGROUND_BLACK = 0x00;
103 enum EFI_BACKGROUND_BLUE = 0x10;
104 enum EFI_BACKGROUND_GREEN = 0x20;
105 enum EFI_BACKGROUND_CYAN = (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN);
106 enum EFI_BACKGROUND_RED = 0x40;
107 enum EFI_BACKGROUND_MAGENTA = (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED);
108 enum EFI_BACKGROUND_BROWN = (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED);
109 enum EFI_BACKGROUND_LIGHTGRAY = (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED);
110 enum EFI_WIDE_ATTRIBUTE = 0x80;
111 /**
112 	Reset the text output device hardware and optionaly run diagnostics
113 	
114 	@param  This                 The protocol instance pointer.
115 	@param  ExtendedVerification Driver may perform more exhaustive verfication
116 	operation of the device during reset.
117 	
118 	@retval EFI_SUCCESS          The text output device was reset.
119 	@retval EFI_DEVICE_ERROR     The text output device is not functioning correctly and
120 	could not be reset.
121 	
122 **/
123 alias EFI_TEXT_RESET = EFI_STATUS function(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This,
124     BOOLEAN ExtendedVerification) @nogc nothrow;
125 /**
126 	Write a string to the output device.
127 	
128 	@param  This   The protocol instance pointer.
129 	@param  String The NULL-terminated string to be displayed on the output
130 	device(s). All output devices must also support the Unicode
131 	drawing character codes defined in this file.
132 	
133 	@retval EFI_SUCCESS             The string was output to the device.
134 	@retval EFI_DEVICE_ERROR        The device reported an error while attempting to output
135 	the text.
136 	@retval EFI_UNSUPPORTED         The output device's mode is not currently in a
137 	defined text mode.
138 	@retval EFI_WARN_UNKNOWN_GLYPH  This warning code indicates that some of the
139 	characters in the string could not be
140 	rendered and were skipped.
141 	
142 **/
143 alias EFI_TEXT_STRING = EFI_STATUS function(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This,
144     CHAR16* String) @nogc nothrow;
145 /**
146 	Verifies that all characters in a string can be output to the
147 	target device.
148 	
149 	@param  This   The protocol instance pointer.
150 	@param  String The NULL-terminated string to be examined for the output
151 	device(s).
152 	
153 	@retval EFI_SUCCESS      The device(s) are capable of rendering the output string.
154 	@retval EFI_UNSUPPORTED  Some of the characters in the string cannot be
155 	rendered by one or more of the output devices mapped
156 	by the EFI handle.
157 	
158 **/
159 alias EFI_TEXT_TEST_STRING = EFI_STATUS function(
160     EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, CHAR16* String) @nogc nothrow;
161 /**
162 	Returns information for an available text mode that the output device(s)
163 	supports.
164 	
165 	@param  This       The protocol instance pointer.
166 	@param  ModeNumber The mode number to return information on.
167 	@param  Columns    Returns the geometry of the text output device for the
168 	requested ModeNumber.
169 	@param  Rows       Returns the geometry of the text output device for the
170 	requested ModeNumber.
171 	
172 	@retval EFI_SUCCESS      The requested mode information was returned.
173 	@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
174 	@retval EFI_UNSUPPORTED  The mode number was not valid.
175 	
176 **/
177 alias EFI_TEXT_QUERY_MODE = EFI_STATUS function(
178     EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN ModeNumber, UINTN* Columns, UINTN* Rows) @nogc nothrow;
179 /**
180 	Sets the output device(s) to a specified mode.
181 	
182 	@param  This       The protocol instance pointer.
183 	@param  ModeNumber The mode number to set.
184 	
185 	@retval EFI_SUCCESS      The requested text mode was set.
186 	@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
187 	@retval EFI_UNSUPPORTED  The mode number was not valid.
188 	
189 **/
190 alias EFI_TEXT_SET_MODE = EFI_STATUS function(
191     EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN ModeNumber) @nogc nothrow;
192 /**
193 	Sets the background and foreground colors for the OutputString () and
194 	ClearScreen () functions.
195 	
196 	@param  This      The protocol instance pointer.
197 	@param  Attribute The attribute to set. Bits 0..3 are the foreground color, and
198 	bits 4..6 are the background color. All other bits are undefined
199 	and must be zero. The valid Attributes are defined in this file.
200 	
201 	@retval EFI_SUCCESS       The attribute was set.
202 	@retval EFI_DEVICE_ERROR  The device had an error and could not complete the request.
203 	@retval EFI_UNSUPPORTED   The attribute requested is not defined.
204 	
205 **/
206 alias EFI_TEXT_SET_ATTRIBUTE = EFI_STATUS function(
207     EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN Attribute) @nogc nothrow;
208 /**
209 	Clears the output device(s) display to the currently selected background
210 	color.
211 	
212 	@param  This              The protocol instance pointer.
213 	
214 	@retval  EFI_SUCCESS      The operation completed successfully.
215 	@retval  EFI_DEVICE_ERROR The device had an error and could not complete the request.
216 	@retval  EFI_UNSUPPORTED  The output device is not in a valid text mode.
217 	
218 **/
219 alias EFI_TEXT_CLEAR_SCREEN = EFI_STATUS function(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This) @nogc nothrow;
220 /**
221 	Sets the current coordinates of the cursor position
222 	
223 	@param  This        The protocol instance pointer.
224 	@param  Column      The position to set the cursor to. Must be greater than or
225 	equal to zero and less than the number of columns and rows
226 	by QueryMode ().
227 	@param  Row         The position to set the cursor to. Must be greater than or
228 	equal to zero and less than the number of columns and rows
229 	by QueryMode ().
230 	
231 	@retval EFI_SUCCESS      The operation completed successfully.
232 	@retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
233 	@retval EFI_UNSUPPORTED  The output device is not in a valid text mode, or the
234 	cursor position is invalid for the current mode.
235 	
236 **/
237 alias EFI_TEXT_SET_CURSOR_POSITION = EFI_STATUS function(
238     EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, UINTN Column, UINTN Row) @nogc nothrow;
239 /**
240 	Makes the cursor visible or invisible
241 	
242 	@param  This    The protocol instance pointer.
243 	@param  Visible If TRUE, the cursor is set to be visible. If FALSE, the cursor is
244 	set to be invisible.
245 	
246 	@retval EFI_SUCCESS      The operation completed successfully.
247 	@retval EFI_DEVICE_ERROR The device had an error and could not complete the
248 	request, or the device does not support changing
249 	the cursor mode.
250 	@retval EFI_UNSUPPORTED  The output device is not in a valid text mode.
251 	
252 **/
253 alias EFI_TEXT_ENABLE_CURSOR = EFI_STATUS function(
254     EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* This, BOOLEAN Visible) @nogc nothrow;
255 /**
256 	@par Data Structure Description:
257 	Mode Structure pointed to by Simple Text Out protocol.
258 **/
259 struct EFI_SIMPLE_TEXT_OUTPUT_MODE
260 {
261     ///
262     /// The number of modes supported by QueryMode () and SetMode ().
263     ///
264     INT32 MaxMode;
265 
266     //
267     // current settings
268     //
269 
270     ///
271     /// The text mode of the output device(s).
272     ///
273     INT32 Mode;
274     ///
275     /// The current character output attribute.
276     ///
277     INT32 Attribute;
278     ///
279     /// The cursor's column.
280     ///
281     INT32 CursorColumn;
282     ///
283     /// The cursor's row.
284     ///
285     INT32 CursorRow;
286     ///
287     /// The cursor is currently visbile or not.
288     ///
289     BOOLEAN CursorVisible;
290 }
291 /// The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
292 /// It is the minimum required protocol for any handle supplied as the ConsoleOut
293 /// or StandardError device. In addition, the minimum supported text mode of such
294 /// devices is at least 80 x 25 characters.
295 struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL
296 {
297     EFI_TEXT_RESET Reset;
298 
299     EFI_TEXT_STRING OutputString;
300     EFI_TEXT_TEST_STRING TestString;
301 
302     EFI_TEXT_QUERY_MODE QueryMode;
303     EFI_TEXT_SET_MODE SetMode;
304     EFI_TEXT_SET_ATTRIBUTE SetAttribute;
305 
306     EFI_TEXT_CLEAR_SCREEN ClearScreen;
307     EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
308     EFI_TEXT_ENABLE_CURSOR EnableCursor;
309 
310     ///
311     /// Pointer to SIMPLE_TEXT_OUTPUT_MODE data.
312     ///
313     EFI_SIMPLE_TEXT_OUTPUT_MODE* Mode;
314 }