iPXE
vesafb.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 /** @file
27  *
28  * VESA frame buffer console
29  *
30  */
31 
32 #include <stdlib.h>
33 #include <errno.h>
34 #include <limits.h>
35 #include <realmode.h>
36 #include <ipxe/console.h>
37 #include <ipxe/io.h>
38 #include <ipxe/ansicol.h>
39 #include <ipxe/fbcon.h>
40 #include <ipxe/vesafb.h>
41 #include <config/console.h>
42 
43 /* Avoid dragging in BIOS console if not otherwise used */
44 extern struct console_driver bios_console;
46 
47 /* Disambiguate the various error causes */
48 #define EIO_FAILED __einfo_error ( EINFO_EIO_FAILED )
49 #define EINFO_EIO_FAILED \
50  __einfo_uniqify ( EINFO_EIO, 0x01, \
51  "Function call failed" )
52 #define EIO_HARDWARE __einfo_error ( EINFO_EIO_HARDWARE )
53 #define EINFO_EIO_HARDWARE \
54  __einfo_uniqify ( EINFO_EIO, 0x02, \
55  "Not supported in current configuration" )
56 #define EIO_MODE __einfo_error ( EINFO_EIO_MODE )
57 #define EINFO_EIO_MODE \
58  __einfo_uniqify ( EINFO_EIO, 0x03, \
59  "Invalid in current video mode" )
60 #define EIO_VBE( code ) \
61  EUNIQ ( EINFO_EIO, (code), EIO_FAILED, EIO_HARDWARE, EIO_MODE )
62 
63 /* Set default console usage if applicable
64  *
65  * We accept either CONSOLE_FRAMEBUFFER or CONSOLE_VESAFB.
66  */
67 #if ( defined ( CONSOLE_FRAMEBUFFER ) && ! defined ( CONSOLE_VESAFB ) )
68 #define CONSOLE_VESAFB CONSOLE_FRAMEBUFFER
69 #endif
70 #if ! ( defined ( CONSOLE_VESAFB ) && CONSOLE_EXPLICIT ( CONSOLE_VESAFB ) )
71 #undef CONSOLE_VESAFB
72 #define CONSOLE_VESAFB ( CONSOLE_USAGE_ALL & ~CONSOLE_USAGE_LOG )
73 #endif
74 
75 /** Character height */
76 #define VESAFB_CHAR_HEIGHT 16
77 
78 /** Font corresponding to selected character width and height */
79 #define VESAFB_FONT VBE_FONT_8x16
80 
81 /** Number of ASCII glyphs within the font */
82 #define VESAFB_ASCII 128
83 
84 /** Glyph to render for non-ASCII characters
85  *
86  * We choose to use one of the box-drawing glyphs.
87  */
88 #define VESAFB_UNKNOWN 0xfe
89 
90 /* Forward declaration */
91 struct console_driver vesafb_console __console_driver;
92 
93 /** A VESA frame buffer */
94 struct vesafb {
95  /** Frame buffer console */
96  struct fbcon fbcon;
97  /** Physical start address */
99  /** Pixel geometry */
101  /** Colour mapping */
103  /** Font definition */
104  struct fbcon_font font;
105  /** Character glyphs */
106  const uint8_t *glyphs;
107  /** Saved VGA mode */
109 };
110 
111 /** The VESA frame buffer */
112 static struct vesafb vesafb;
113 
114 /** Base memory buffer used for VBE calls */
115 union vbe_buffer {
116  /** VBE controller information block */
118  /** VBE mode information block */
120 };
121 static union vbe_buffer __bss16 ( vbe_buf );
122 #define vbe_buf __use_data16 ( vbe_buf )
123 
124 /**
125  * Convert VBE status code to iPXE status code
126  *
127  * @v status VBE status code
128  * @ret rc Return status code
129  */
130 static int vesafb_rc ( unsigned int status ) {
131  unsigned int code;
132 
133  if ( ( status & 0xff ) != 0x4f )
134  return -ENOTSUP;
135  code = ( ( status >> 8 ) & 0xff );
136  return ( code ? -EIO_VBE ( code ) : 0 );
137 }
138 
139 /**
140  * Get character glyph
141  *
142  * @v character Unicode character
143  * @ret glyph Character glyph
144  */
145 static const uint8_t * vesafb_glyph ( unsigned int character ) {
146  unsigned int index;
147 
148  /* Identify glyph */
149  if ( character < VESAFB_ASCII ) {
150  /* ASCII character: use corresponding glyph */
151  index = character;
152  } else {
153  /* Non-ASCII character: use "unknown" glyph */
155  }
156 
157  /* Return glyph in BIOS font table */
158  return &vesafb.glyphs[ index * VESAFB_CHAR_HEIGHT ];
159 }
160 
161 /**
162  * Get font definition
163  *
164  */
165 static void vesafb_font ( void ) {
166  struct segoff glyphs;
167 
168  /* Get font information
169  *
170  * Working around gcc bugs is icky here. The value we want is
171  * returned in %ebp, but there's no way to specify %ebp in an
172  * output constraint. We can't put %ebp in the clobber list,
173  * because this tends to cause random build failures on some
174  * gcc versions. We can't manually push/pop %ebp and return
175  * the value via a generic register output constraint, because
176  * gcc might choose to use %ebp to satisfy that constraint
177  * (and we have no way to prevent it from so doing).
178  *
179  * Work around this hideous mess by using %ecx and %edx as the
180  * output registers, since they get clobbered anyway.
181  */
182  __asm__ __volatile__ ( REAL_CODE ( "pushw %%bp\n\t" /* gcc bug */
183  "int $0x10\n\t"
184  "movw %%es, %%cx\n\t"
185  "movw %%bp, %%dx\n\t"
186  "popw %%bp\n\t" /* gcc bug */ )
187  : "=c" ( glyphs.segment ),
188  "=d" ( glyphs.offset )
189  : "a" ( VBE_GET_FONT ),
190  "b" ( VESAFB_FONT ) );
191  DBGC ( &vbe_buf, "VESAFB has font %04x at %04x:%04x\n",
192  VESAFB_FONT, glyphs.segment, glyphs.offset );
193  vesafb.glyphs = real_to_virt ( glyphs.segment, glyphs.offset );
196 }
197 
198 /**
199  * Get VBE mode list
200  *
201  * @ret mode_numbers Mode number list (terminated with VBE_MODE_END)
202  * @ret rc Return status code
203  *
204  * The caller is responsible for eventually freeing the mode list.
205  */
206 static int vesafb_mode_list ( uint16_t **mode_numbers ) {
207  struct vbe_controller_info *controller = &vbe_buf.controller;
208  const uint16_t *video_mode_ptr;
209  const uint16_t *mode_number;
211  size_t len;
212  int rc;
213 
214  /* Avoid returning uninitialised data on error */
215  *mode_numbers = NULL;
216 
217  /* Get controller information block */
218  controller->vbe_signature = 0;
219  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
220  : "=a" ( status )
221  : "a" ( VBE_CONTROLLER_INFO ),
222  "D" ( __from_data16 ( controller ) )
223  : "memory", "ebx", "edx" );
224  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
225  DBGC ( &vbe_buf, "VESAFB could not get controller information: "
226  "[%04x] %s\n", status, strerror ( rc ) );
227  return rc;
228  }
229  if ( controller->vbe_signature != VBE_CONTROLLER_SIGNATURE ) {
230  DBGC ( &vbe_buf, "VESAFB invalid controller signature "
231  "\"%c%c%c%c\"\n", ( controller->vbe_signature >> 0 ),
232  ( controller->vbe_signature >> 8 ),
233  ( controller->vbe_signature >> 16 ),
234  ( controller->vbe_signature >> 24 ) );
235  DBGC_HDA ( &vbe_buf, 0, controller, sizeof ( *controller ) );
236  return -EINVAL;
237  }
238  DBGC ( &vbe_buf, "VESAFB found VBE version %d.%d with mode list at "
239  "%04x:%04x\n", controller->vbe_major_version,
240  controller->vbe_minor_version,
241  controller->video_mode_ptr.segment,
242  controller->video_mode_ptr.offset );
243 
244  /* Calculate length of mode list */
245  video_mode_ptr = real_to_virt ( controller->video_mode_ptr.segment,
246  controller->video_mode_ptr.offset );
247  mode_number = video_mode_ptr;
248  while ( *(mode_number++) != VBE_MODE_END ) {}
249  len = ( ( ( const void * ) mode_number ) -
250  ( ( const void * ) video_mode_ptr ) );
251 
252  /* Allocate and fill mode list */
253  *mode_numbers = malloc ( len );
254  if ( ! *mode_numbers )
255  return -ENOMEM;
256  memcpy ( *mode_numbers, video_mode_ptr, len );
257 
258  return 0;
259 }
260 
261 /**
262  * Get video mode information
263  *
264  * @v mode_number Mode number
265  * @ret rc Return status code
266  */
267 static int vesafb_mode_info ( unsigned int mode_number ) {
268  struct vbe_mode_info *mode = &vbe_buf.mode;
270  int rc;
271 
272  /* Get mode information */
273  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
274  : "=a" ( status )
275  : "a" ( VBE_MODE_INFO ),
276  "c" ( mode_number ),
277  "D" ( __from_data16 ( mode ) )
278  : "memory" );
279  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
280  DBGC ( &vbe_buf, "VESAFB could not get mode %04x information: "
281  "[%04x] %s\n", mode_number, status, strerror ( rc ) );
282  return rc;
283  }
284  DBGC ( &vbe_buf, "VESAFB mode %04x %dx%d %dbpp(%d:%d:%d:%d) model "
285  "%02x [x%d]%s%s%s%s%s\n", mode_number, mode->x_resolution,
286  mode->y_resolution, mode->bits_per_pixel, mode->rsvd_mask_size,
287  mode->red_mask_size, mode->green_mask_size, mode->blue_mask_size,
288  mode->memory_model, ( mode->number_of_image_pages + 1 ),
289  ( ( mode->mode_attributes & VBE_MODE_ATTR_SUPPORTED ) ?
290  "" : " [unsupported]" ),
291  ( ( mode->mode_attributes & VBE_MODE_ATTR_TTY ) ?
292  " [tty]" : "" ),
293  ( ( mode->mode_attributes & VBE_MODE_ATTR_GRAPHICS ) ?
294  "" : " [text]" ),
295  ( ( mode->mode_attributes & VBE_MODE_ATTR_LINEAR ) ?
296  "" : " [nonlinear]" ),
297  ( ( mode->mode_attributes & VBE_MODE_ATTR_TRIPLE_BUF ) ?
298  " [buf]" : "" ) );
299 
300  return 0;
301 }
302 
303 /**
304  * Set video mode
305  *
306  * @v mode_number Mode number
307  * @ret rc Return status code
308  */
309 static int vesafb_set_mode ( unsigned int mode_number ) {
310  struct vbe_mode_info *mode = &vbe_buf.mode;
312  int rc;
313 
314  /* Get mode information */
315  if ( ( rc = vesafb_mode_info ( mode_number ) ) != 0 )
316  return rc;
317 
318  /* Record mode parameters */
319  vesafb.start = mode->phys_base_ptr;
320  vesafb.pixel.width = mode->x_resolution;
321  vesafb.pixel.height = mode->y_resolution;
322  vesafb.pixel.len = ( ( mode->bits_per_pixel + 7 ) / 8 );
323  vesafb.pixel.stride = mode->bytes_per_scan_line;
324  DBGC ( &vbe_buf, "VESAFB mode %04x has frame buffer at %08x\n",
325  mode_number, mode->phys_base_ptr );
326 
327  /* Initialise font colours */
328  vesafb.map.red_scale = ( 8 - mode->red_mask_size );
329  vesafb.map.green_scale = ( 8 - mode->green_mask_size );
330  vesafb.map.blue_scale = ( 8 - mode->blue_mask_size );
331  vesafb.map.red_lsb = mode->red_field_position;
332  vesafb.map.green_lsb = mode->green_field_position;
333  vesafb.map.blue_lsb = mode->blue_field_position;
334 
335  /* Select this mode */
336  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
337  : "=a" ( status )
338  : "a" ( VBE_SET_MODE ),
339  "b" ( mode_number ) );
340  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
341  DBGC ( &vbe_buf, "VESAFB could not set mode %04x: [%04x] %s\n",
342  mode_number, status, strerror ( rc ) );
343  return rc;
344  }
345 
346  return 0;
347 }
348 
349 /**
350  * Select video mode
351  *
352  * @v mode_numbers Mode number list (terminated with VBE_MODE_END)
353  * @v min_width Minimum required width (in pixels)
354  * @v min_height Minimum required height (in pixels)
355  * @v min_bpp Minimum required colour depth (in bits per pixel)
356  * @ret mode_number Mode number, or negative error
357  */
358 static int vesafb_select_mode ( const uint16_t *mode_numbers,
359  unsigned int min_width, unsigned int min_height,
360  unsigned int min_bpp ) {
361  struct vbe_mode_info *mode = &vbe_buf.mode;
362  int best_mode_number = -ENOENT;
363  unsigned int best_score = INT_MAX;
364  unsigned int score;
365  uint16_t mode_number;
366  int rc;
367 
368  /* Find the first suitable mode */
369  while ( ( mode_number = *(mode_numbers++) ) != VBE_MODE_END ) {
370 
371  /* Force linear mode variant */
372  mode_number |= VBE_MODE_LINEAR;
373 
374  /* Get mode information */
375  if ( ( rc = vesafb_mode_info ( mode_number ) ) != 0 )
376  continue;
377 
378  /* Skip unusable modes */
379  if ( ( mode->mode_attributes & ( VBE_MODE_ATTR_SUPPORTED |
381  VBE_MODE_ATTR_LINEAR ) ) !=
384  continue;
385  }
386  if ( mode->memory_model != VBE_MODE_MODEL_DIRECT_COLOUR )
387  continue;
388 
389  /* Skip modes not meeting the requirements */
390  if ( ( mode->x_resolution < min_width ) ||
391  ( mode->y_resolution < min_height ) ||
392  ( mode->bits_per_pixel < min_bpp ) ) {
393  continue;
394  }
395 
396  /* Select this mode if it has the best (i.e. lowest)
397  * score. We choose the scoring system to favour
398  * modes close to the specified width and height;
399  * within modes of the same width and height we prefer
400  * a higher colour depth.
401  */
402  score = ( ( mode->x_resolution * mode->y_resolution ) -
403  mode->bits_per_pixel );
404  if ( score < best_score ) {
405  best_mode_number = mode_number;
406  best_score = score;
407  }
408  }
409 
410  if ( best_mode_number >= 0 ) {
411  DBGC ( &vbe_buf, "VESAFB selected mode %04x\n",
412  best_mode_number );
413  } else {
414  DBGC ( &vbe_buf, "VESAFB found no suitable mode\n" );
415  }
416 
417  return best_mode_number;
418 }
419 
420 /**
421  * Restore video mode
422  *
423  */
424 static void vesafb_restore ( void ) {
425  uint32_t discard_a;
426 
427  /* Restore saved VGA mode */
428  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
429  : "=a" ( discard_a )
430  : "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
431  DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
432  vesafb.saved_mode );
433 }
434 
435 /**
436  * Initialise VESA frame buffer
437  *
438  * @v config Console configuration, or NULL to reset
439  * @ret rc Return status code
440  */
441 static int vesafb_init ( struct console_configuration *config ) {
442  uint32_t discard_b;
443  uint16_t *mode_numbers;
444  int mode_number;
445  int rc;
446 
447  /* Record current VGA mode */
448  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
449  : "=a" ( vesafb.saved_mode ), "=b" ( discard_b )
450  : "a" ( VBE_GET_VGA_MODE ) );
451  DBGC ( &vbe_buf, "VESAFB saved VGA mode %#02x\n", vesafb.saved_mode );
452 
453  /* Get VESA mode list */
454  if ( ( rc = vesafb_mode_list ( &mode_numbers ) ) != 0 )
455  goto err_mode_list;
456 
457  /* Select mode */
458  if ( ( mode_number = vesafb_select_mode ( mode_numbers, config->width,
459  config->height,
460  config->depth ) ) < 0 ) {
461  rc = mode_number;
462  goto err_select_mode;
463  }
464 
465  /* Set mode */
466  if ( ( rc = vesafb_set_mode ( mode_number ) ) != 0 )
467  goto err_set_mode;
468 
469  /* Get font data */
470  vesafb_font();
471 
472  /* Initialise frame buffer console */
473  if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_virt ( vesafb.start ),
475  config ) ) != 0 )
476  goto err_fbcon_init;
477 
478  free ( mode_numbers );
479  return 0;
480 
481  fbcon_fini ( &vesafb.fbcon );
482  err_fbcon_init:
483  err_set_mode:
484  vesafb_restore();
485  err_select_mode:
486  free ( mode_numbers );
487  err_mode_list:
488  return rc;
489 }
490 
491 /**
492  * Finalise VESA frame buffer
493  *
494  */
495 static void vesafb_fini ( void ) {
496 
497  /* Finalise frame buffer console */
498  fbcon_fini ( &vesafb.fbcon );
499 
500  /* Restore saved VGA mode */
501  vesafb_restore();
502 }
503 
504 /**
505  * Print a character to current cursor position
506  *
507  * @v character Character
508  */
509 static void vesafb_putchar ( int character ) {
510 
511  fbcon_putchar ( &vesafb.fbcon, character );
512 }
513 
514 /**
515  * Configure console
516  *
517  * @v config Console configuration, or NULL to reset
518  * @ret rc Return status code
519  */
520 static int vesafb_configure ( struct console_configuration *config ) {
521  int rc;
522 
523  /* Reset console, if applicable */
524  if ( ! vesafb_console.disabled ) {
525  vesafb_fini();
528  }
529  vesafb_console.disabled = CONSOLE_DISABLED;
530 
531  /* Do nothing more unless we have a usable configuration */
532  if ( ( config == NULL ) ||
533  ( config->width == 0 ) || ( config->height == 0 ) ) {
534  return 0;
535  }
536 
537  /* Initialise VESA frame buffer */
538  if ( ( rc = vesafb_init ( config ) ) != 0 )
539  return rc;
540 
541  /* Mark console as enabled */
542  vesafb_console.disabled = 0;
544 
545  /* Set magic colour to transparent if we have a background picture */
546  if ( config->pixbuf )
548 
549  return 0;
550 }
551 
552 /** VESA frame buffer console driver */
553 struct console_driver vesafb_console __console_driver = {
555  .putchar = vesafb_putchar,
556  .configure = vesafb_configure,
557  .disabled = CONSOLE_DISABLED,
558 };
Direct colour mode.
Definition: vesafb.h:174
uint16_t segment
Definition: registers.h:193
unsigned int height
Character height (in pixels)
Definition: fbcon.h:35
#define EINVAL
Invalid argument.
Definition: errno.h:428
iPXE I/O API
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned short uint16_t
Definition: stdint.h:11
A frame buffer geometry.
Definition: fbcon.h:50
static const uint8_t * vesafb_glyph(unsigned int character)
Get character glyph.
Definition: vesafb.c:145
unsigned int height
Height.
Definition: console.h:28
static union vbe_buffer __bss16(vbe_buf)
Base memory buffer used for VBE calls.
Definition: vesafb.c:115
#define CONSOLE_VESAFB
Definition: vesafb.c:72
int fbcon_init(struct fbcon *fbcon, void *start, struct fbcon_geometry *pixel, struct fbcon_colour_map *map, struct fbcon_font *font, struct console_configuration *config)
Initialise frame buffer console.
Definition: fbcon.c:600
VBE controller information.
Definition: vesafb.h:19
uint8_t green_lsb
Green LSB.
Definition: fbcon.h:84
Frame buffer console.
static int vesafb_init(struct console_configuration *config)
Initialise VESA frame buffer.
Definition: vesafb.c:441
Error codes.
uint8_t red_lsb
Red LSB.
Definition: fbcon.h:82
#define VBE_MODE_INFO
INT 10,4f01: return VBE mode information.
Definition: vesafb.h:59
uint16_t mode
Acceleration mode.
Definition: ena.h:26
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:52
#define CONSOLE_DISABLED
Console is disabled for all uses.
Definition: console.h:111
#define VESAFB_FONT
Font corresponding to selected character width and height.
Definition: vesafb.c:79
static int vesafb_configure(struct console_configuration *config)
Configure console.
Definition: vesafb.c:520
#define DBGC(...)
Definition: compiler.h:505
#define VBE_MODE_LINEAR
VBE linear frame buffer mode bit.
Definition: vesafb.h:183
#define VESAFB_CHAR_HEIGHT
Character height.
Definition: vesafb.c:76
long index
Definition: bigint.h:62
#define ENOENT
No such file or directory.
Definition: errno.h:514
struct segoff video_mode_ptr
Pointer to video mode list.
Definition: vesafb.h:22
void fbcon_putchar(struct fbcon *fbcon, int character)
Print a character to current cursor position.
Definition: fbcon.c:460
unsigned int width
Width.
Definition: console.h:26
static void vesafb_putchar(int character)
Print a character to current cursor position.
Definition: vesafb.c:509
struct fbcon fbcon
Frame buffer console.
Definition: vesafb.c:96
#define VBE_SET_VGA_MODE
INT 10,00: set VGA mode.
Definition: vesafb.h:205
unsigned int depth
Colour depth.
Definition: console.h:30
static unsigned int code
Response code.
Definition: hyperv.h:26
A console configuration.
Definition: console.h:24
int usage
Console usage bitmask.
Definition: console.h:101
#define ENOTSUP
Operation not supported.
Definition: errno.h:589
static __always_inline void * real_to_virt(unsigned int segment, unsigned int offset)
Convert segment:offset address to virtual address.
Definition: realmode.h:77
#define VBE_MODE_END
VBE mode list end marker.
Definition: vesafb.h:56
#define CONSOLE_DISABLED_OUTPUT
Console is disabled for output.
Definition: console.h:108
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Linear frame buffer mode is available.
Definition: vesafb.h:146
uint8_t saved_mode
Saved VGA mode.
Definition: vesafb.c:108
uint8_t red_scale
Red scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:76
size_t len
Length of a single entity.
Definition: fbcon.h:56
A frame buffer console.
Definition: fbcon.h:112
#define VESAFB_UNKNOWN
Glyph to render for non-ASCII characters.
Definition: vesafb.c:88
#define DBGC_HDA(...)
Definition: compiler.h:506
ring len
Length.
Definition: dwmac.h:231
A frame buffer colour mapping.
Definition: fbcon.h:74
static int vesafb_select_mode(const uint16_t *mode_numbers, unsigned int min_width, unsigned int min_height, unsigned int min_bpp)
Select video mode.
Definition: vesafb.c:358
A 16-bit general register.
Definition: registers.h:24
#define VBE_GET_VGA_MODE
INT 10,0f: get VGA mode.
Definition: vesafb.h:208
struct console_driver vesafb_console __console_driver
VESA frame buffer console driver.
Definition: vesafb.c:91
uint16_t offset
Definition: registers.h:192
struct console_driver bios_console
Definition: vesafb.c:45
User interaction.
static int vesafb_mode_info(unsigned int mode_number)
Get video mode information.
Definition: vesafb.c:267
void fbcon_fini(struct fbcon *fbcon)
Finalise frame buffer console.
Definition: fbcon.c:728
physaddr_t start
Physical start address.
Definition: vesafb.c:98
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
#define VBE_GET_FONT
INT 10,1130: get font information.
Definition: vesafb.h:186
struct fbcon_font font
Font definition.
Definition: vesafb.c:104
uint8_t green_scale
Green scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:78
__asm__ __volatile__("call *%9" :"=a"(result), "=c"(discard_ecx), "=d"(discard_edx) :"d"(0), "a"(code), "b"(0), "c"(in_phys), "D"(0), "S"(out_phys), "m"(hypercall))
unsigned char uint8_t
Definition: stdint.h:10
TTY output functions supported by BIOS.
Definition: vesafb.h:136
struct fbcon_geometry pixel
Pixel geometry.
Definition: vesafb.c:100
static void vesafb_font(void)
Get font definition.
Definition: vesafb.c:165
void ansicol_set_magic_transparent(void)
Set magic colour to transparent.
Definition: ansicoldef.c:189
unsigned int uint32_t
Definition: stdint.h:12
struct vbe_controller_info controller
VBE controller information block.
Definition: vesafb.c:117
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:620
A font definition.
Definition: fbcon.h:33
Console configuration.
uint8_t blue_scale
Blue scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:80
uint8_t status
Status.
Definition: ena.h:16
VESA frame buffer console.
unsigned long physaddr_t
Definition: stdint.h:20
#define VBE_CONTROLLER_INFO
INT 10,4f00: return controller information.
Definition: vesafb.h:16
#define VBE_CONTROLLER_SIGNATURE
VBE controller information signature.
Definition: vesafb.h:52
__asm__(".section \".rodata\", \"a\", " PROGBITS "\n\t" "\nprivate_key_data:\n\t" ".size private_key_data, ( . - private_key_data )\n\t" ".equ private_key_len, ( . - private_key_data )\n\t" ".previous\n\t")
uint8_t controller
CD-ROM controller number.
Definition: int13.h:18
int disabled
Console disabled flags.
Definition: console.h:62
const uint8_t *(* glyph)(unsigned int character)
Get character glyph.
Definition: fbcon.h:42
void ansicol_reset_magic(void)
Reset magic colour.
Definition: ansicoldef.c:179
#define __from_data16(pointer)
Definition: libkir.h:22
Hardware triple buffering support.
Definition: vesafb.h:152
static int vesafb_set_mode(unsigned int mode_number)
Set video mode.
Definition: vesafb.c:309
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:54
Mode supported in hardware.
Definition: vesafb.h:134
struct pixel_buffer * pixbuf
Background picture, if any.
Definition: console.h:40
#define VESAFB_ASCII
Number of ASCII glyphs within the font.
Definition: vesafb.c:82
VBE mode information.
Definition: vesafb.h:62
static void vesafb_restore(void)
Restore video mode.
Definition: vesafb.c:424
#define vbe_buf
Definition: vesafb.c:122
#define VBE_SET_MODE
INT 10,4f02: set VBE mode.
Definition: vesafb.h:180
uint8_t blue_lsb
Blue LSB.
Definition: fbcon.h:86
struct vbe_mode_info mode
VBE mode information block.
Definition: vesafb.c:119
static int vesafb_rc(unsigned int status)
Convert VBE status code to iPXE status code.
Definition: vesafb.c:130
static void vesafb_fini(void)
Finalise VESA frame buffer.
Definition: vesafb.c:495
struct fbcon_colour_map map
Colour mapping.
Definition: vesafb.c:102
A console driver.
Definition: console.h:55
const uint8_t * glyphs
Character glyphs.
Definition: vesafb.c:106
#define INT_MAX
Definition: limits.h:37
#define EIO_VBE(code)
Definition: vesafb.c:60
#define REAL_CODE(asm_code_str)
Definition: libkir.h:226
A VESA frame buffer.
Definition: vesafb.c:94
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:58
ANSI colours.
static int vesafb_mode_list(uint16_t **mode_numbers)
Get VBE mode list.
Definition: vesafb.c:206
Graphics mode.
Definition: vesafb.h:140