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  struct segoff 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  * @v glyph Character glyph to fill in
144  */
145 static void vesafb_glyph ( unsigned int character, uint8_t *glyph ) {
146  unsigned int index;
147  size_t offset;
148 
149  /* Identify glyph */
150  if ( character < VESAFB_ASCII ) {
151  /* ASCII character: use corresponding glyph */
152  index = character;
153  } else {
154  /* Non-ASCII character: use "unknown" glyph */
156  }
157 
158  /* Copy glyph from BIOS font table */
162 }
163 
164 /**
165  * Get font definition
166  *
167  */
168 static void vesafb_font ( void ) {
169 
170  /* Get font information
171  *
172  * Working around gcc bugs is icky here. The value we want is
173  * returned in %ebp, but there's no way to specify %ebp in an
174  * output constraint. We can't put %ebp in the clobber list,
175  * because this tends to cause random build failures on some
176  * gcc versions. We can't manually push/pop %ebp and return
177  * the value via a generic register output constraint, because
178  * gcc might choose to use %ebp to satisfy that constraint
179  * (and we have no way to prevent it from so doing).
180  *
181  * Work around this hideous mess by using %ecx and %edx as the
182  * output registers, since they get clobbered anyway.
183  */
184  __asm__ __volatile__ ( REAL_CODE ( "pushw %%bp\n\t" /* gcc bug */
185  "int $0x10\n\t"
186  "movw %%es, %%cx\n\t"
187  "movw %%bp, %%dx\n\t"
188  "popw %%bp\n\t" /* gcc bug */ )
189  : "=c" ( vesafb.glyphs.segment ),
190  "=d" ( vesafb.glyphs.offset )
191  : "a" ( VBE_GET_FONT ),
192  "b" ( VESAFB_FONT ) );
193  DBGC ( &vbe_buf, "VESAFB has font %04x at %04x:%04x\n",
197 }
198 
199 /**
200  * Get VBE mode list
201  *
202  * @ret mode_numbers Mode number list (terminated with VBE_MODE_END)
203  * @ret rc Return status code
204  *
205  * The caller is responsible for eventually freeing the mode list.
206  */
207 static int vesafb_mode_list ( uint16_t **mode_numbers ) {
208  struct vbe_controller_info *controller = &vbe_buf.controller;
210  uint16_t mode_number;
212  size_t len;
213  int rc;
214 
215  /* Avoid returning uninitialised data on error */
216  *mode_numbers = NULL;
217 
218  /* Get controller information block */
219  controller->vbe_signature = 0;
220  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
221  : "=a" ( status )
222  : "a" ( VBE_CONTROLLER_INFO ),
223  "D" ( __from_data16 ( controller ) )
224  : "memory", "ebx", "edx" );
225  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
226  DBGC ( &vbe_buf, "VESAFB could not get controller information: "
227  "[%04x] %s\n", status, strerror ( rc ) );
228  return rc;
229  }
230  if ( controller->vbe_signature != VBE_CONTROLLER_SIGNATURE ) {
231  DBGC ( &vbe_buf, "VESAFB invalid controller signature "
232  "\"%c%c%c%c\"\n", ( controller->vbe_signature >> 0 ),
233  ( controller->vbe_signature >> 8 ),
234  ( controller->vbe_signature >> 16 ),
235  ( controller->vbe_signature >> 24 ) );
236  DBGC_HDA ( &vbe_buf, 0, controller, sizeof ( *controller ) );
237  return -EINVAL;
238  }
239  DBGC ( &vbe_buf, "VESAFB found VBE version %d.%d with mode list at "
240  "%04x:%04x\n", controller->vbe_major_version,
241  controller->vbe_minor_version,
242  controller->video_mode_ptr.segment,
243  controller->video_mode_ptr.offset );
244 
245  /* Calculate length of mode list */
246  video_mode_ptr = real_to_user ( controller->video_mode_ptr.segment,
247  controller->video_mode_ptr.offset );
248  len = 0;
249  do {
250  copy_from_user ( &mode_number, video_mode_ptr, len,
251  sizeof ( mode_number ) );
252  len += sizeof ( mode_number );
253  } while ( mode_number != VBE_MODE_END );
254 
255  /* Allocate and fill mode list */
256  *mode_numbers = malloc ( len );
257  if ( ! *mode_numbers )
258  return -ENOMEM;
259  copy_from_user ( *mode_numbers, video_mode_ptr, 0, len );
260 
261  return 0;
262 }
263 
264 /**
265  * Get video mode information
266  *
267  * @v mode_number Mode number
268  * @ret rc Return status code
269  */
270 static int vesafb_mode_info ( unsigned int mode_number ) {
271  struct vbe_mode_info *mode = &vbe_buf.mode;
273  int rc;
274 
275  /* Get mode information */
276  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
277  : "=a" ( status )
278  : "a" ( VBE_MODE_INFO ),
279  "c" ( mode_number ),
280  "D" ( __from_data16 ( mode ) )
281  : "memory" );
282  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
283  DBGC ( &vbe_buf, "VESAFB could not get mode %04x information: "
284  "[%04x] %s\n", mode_number, status, strerror ( rc ) );
285  return rc;
286  }
287  DBGC ( &vbe_buf, "VESAFB mode %04x %dx%d %dbpp(%d:%d:%d:%d) model "
288  "%02x [x%d]%s%s%s%s%s\n", mode_number, mode->x_resolution,
289  mode->y_resolution, mode->bits_per_pixel, mode->rsvd_mask_size,
290  mode->red_mask_size, mode->green_mask_size, mode->blue_mask_size,
291  mode->memory_model, ( mode->number_of_image_pages + 1 ),
293  "" : " [unsupported]" ),
294  ( ( mode->mode_attributes & VBE_MODE_ATTR_TTY ) ?
295  " [tty]" : "" ),
297  "" : " [text]" ),
298  ( ( mode->mode_attributes & VBE_MODE_ATTR_LINEAR ) ?
299  "" : " [nonlinear]" ),
301  " [buf]" : "" ) );
302 
303  return 0;
304 }
305 
306 /**
307  * Set video mode
308  *
309  * @v mode_number Mode number
310  * @ret rc Return status code
311  */
312 static int vesafb_set_mode ( unsigned int mode_number ) {
313  struct vbe_mode_info *mode = &vbe_buf.mode;
315  int rc;
316 
317  /* Get mode information */
318  if ( ( rc = vesafb_mode_info ( mode_number ) ) != 0 )
319  return rc;
320 
321  /* Record mode parameters */
322  vesafb.start = mode->phys_base_ptr;
323  vesafb.pixel.width = mode->x_resolution;
325  vesafb.pixel.len = ( ( mode->bits_per_pixel + 7 ) / 8 );
327  DBGC ( &vbe_buf, "VESAFB mode %04x has frame buffer at %08x\n",
328  mode_number, mode->phys_base_ptr );
329 
330  /* Initialise font colours */
331  vesafb.map.red_scale = ( 8 - mode->red_mask_size );
332  vesafb.map.green_scale = ( 8 - mode->green_mask_size );
333  vesafb.map.blue_scale = ( 8 - mode->blue_mask_size );
337 
338  /* Select this mode */
339  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
340  : "=a" ( status )
341  : "a" ( VBE_SET_MODE ),
342  "b" ( mode_number ) );
343  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
344  DBGC ( &vbe_buf, "VESAFB could not set mode %04x: [%04x] %s\n",
345  mode_number, status, strerror ( rc ) );
346  return rc;
347  }
348 
349  return 0;
350 }
351 
352 /**
353  * Select video mode
354  *
355  * @v mode_numbers Mode number list (terminated with VBE_MODE_END)
356  * @v min_width Minimum required width (in pixels)
357  * @v min_height Minimum required height (in pixels)
358  * @v min_bpp Minimum required colour depth (in bits per pixel)
359  * @ret mode_number Mode number, or negative error
360  */
361 static int vesafb_select_mode ( const uint16_t *mode_numbers,
362  unsigned int min_width, unsigned int min_height,
363  unsigned int min_bpp ) {
364  struct vbe_mode_info *mode = &vbe_buf.mode;
365  int best_mode_number = -ENOENT;
366  unsigned int best_score = INT_MAX;
367  unsigned int score;
368  uint16_t mode_number;
369  int rc;
370 
371  /* Find the first suitable mode */
372  while ( ( mode_number = *(mode_numbers++) ) != VBE_MODE_END ) {
373 
374  /* Force linear mode variant */
375  mode_number |= VBE_MODE_LINEAR;
376 
377  /* Get mode information */
378  if ( ( rc = vesafb_mode_info ( mode_number ) ) != 0 )
379  continue;
380 
381  /* Skip unusable modes */
382  if ( ( mode->mode_attributes & ( VBE_MODE_ATTR_SUPPORTED |
384  VBE_MODE_ATTR_LINEAR ) ) !=
387  continue;
388  }
390  continue;
391 
392  /* Skip modes not meeting the requirements */
393  if ( ( mode->x_resolution < min_width ) ||
394  ( mode->y_resolution < min_height ) ||
395  ( mode->bits_per_pixel < min_bpp ) ) {
396  continue;
397  }
398 
399  /* Select this mode if it has the best (i.e. lowest)
400  * score. We choose the scoring system to favour
401  * modes close to the specified width and height;
402  * within modes of the same width and height we prefer
403  * a higher colour depth.
404  */
405  score = ( ( mode->x_resolution * mode->y_resolution ) -
406  mode->bits_per_pixel );
407  if ( score < best_score ) {
408  best_mode_number = mode_number;
409  best_score = score;
410  }
411  }
412 
413  if ( best_mode_number >= 0 ) {
414  DBGC ( &vbe_buf, "VESAFB selected mode %04x\n",
415  best_mode_number );
416  } else {
417  DBGC ( &vbe_buf, "VESAFB found no suitable mode\n" );
418  }
419 
420  return best_mode_number;
421 }
422 
423 /**
424  * Restore video mode
425  *
426  */
427 static void vesafb_restore ( void ) {
428  uint32_t discard_a;
429 
430  /* Restore saved VGA mode */
431  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
432  : "=a" ( discard_a )
433  : "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
434  DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
435  vesafb.saved_mode );
436 }
437 
438 /**
439  * Initialise VESA frame buffer
440  *
441  * @v config Console configuration, or NULL to reset
442  * @ret rc Return status code
443  */
444 static int vesafb_init ( struct console_configuration *config ) {
445  uint32_t discard_b;
446  uint16_t *mode_numbers;
447  int mode_number;
448  int rc;
449 
450  /* Record current VGA mode */
451  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
452  : "=a" ( vesafb.saved_mode ), "=b" ( discard_b )
453  : "a" ( VBE_GET_VGA_MODE ) );
454  DBGC ( &vbe_buf, "VESAFB saved VGA mode %#02x\n", vesafb.saved_mode );
455 
456  /* Get VESA mode list */
457  if ( ( rc = vesafb_mode_list ( &mode_numbers ) ) != 0 )
458  goto err_mode_list;
459 
460  /* Select mode */
461  if ( ( mode_number = vesafb_select_mode ( mode_numbers, config->width,
462  config->height,
463  config->depth ) ) < 0 ) {
464  rc = mode_number;
465  goto err_select_mode;
466  }
467 
468  /* Set mode */
469  if ( ( rc = vesafb_set_mode ( mode_number ) ) != 0 )
470  goto err_set_mode;
471 
472  /* Get font data */
473  vesafb_font();
474 
475  /* Initialise frame buffer console */
476  if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
478  config ) ) != 0 )
479  goto err_fbcon_init;
480 
481  free ( mode_numbers );
482  return 0;
483 
484  fbcon_fini ( &vesafb.fbcon );
485  err_fbcon_init:
486  err_set_mode:
487  vesafb_restore();
488  err_select_mode:
489  free ( mode_numbers );
490  err_mode_list:
491  return rc;
492 }
493 
494 /**
495  * Finalise VESA frame buffer
496  *
497  */
498 static void vesafb_fini ( void ) {
499 
500  /* Finalise frame buffer console */
501  fbcon_fini ( &vesafb.fbcon );
502 
503  /* Restore saved VGA mode */
504  vesafb_restore();
505 }
506 
507 /**
508  * Print a character to current cursor position
509  *
510  * @v character Character
511  */
512 static void vesafb_putchar ( int character ) {
513 
514  fbcon_putchar ( &vesafb.fbcon, character );
515 }
516 
517 /**
518  * Configure console
519  *
520  * @v config Console configuration, or NULL to reset
521  * @ret rc Return status code
522  */
523 static int vesafb_configure ( struct console_configuration *config ) {
524  int rc;
525 
526  /* Reset console, if applicable */
527  if ( ! vesafb_console.disabled ) {
528  vesafb_fini();
531  }
532  vesafb_console.disabled = CONSOLE_DISABLED;
533 
534  /* Do nothing more unless we have a usable configuration */
535  if ( ( config == NULL ) ||
536  ( config->width == 0 ) || ( config->height == 0 ) ) {
537  return 0;
538  }
539 
540  /* Initialise VESA frame buffer */
541  if ( ( rc = vesafb_init ( config ) ) != 0 )
542  return rc;
543 
544  /* Mark console as enabled */
545  vesafb_console.disabled = 0;
547 
548  /* Set magic colour to transparent if we have a background picture */
549  if ( config->pixbuf )
551 
552  return 0;
553 }
554 
555 /** VESA frame buffer console driver */
556 struct console_driver vesafb_console __console_driver = {
558  .putchar = vesafb_putchar,
559  .configure = vesafb_configure,
560  .disabled = CONSOLE_DISABLED,
561 };
Direct colour mode.
Definition: vesafb.h:174
uint16_t segment
Definition: registers.h:193
unsigned int height
Character height (in pixels)
Definition: fbcon.h:36
#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:51
uint8_t blue_field_position
Bit position of LSB of blue mask.
Definition: vesafb.h:114
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
uint8_t red_mask_size
Size of direct colour red mask in bits.
Definition: vesafb.h:104
uint8_t bits_per_pixel
Bits per pixel.
Definition: vesafb.h:92
uint8_t memory_model
Memory model type.
Definition: vesafb.h:96
VBE controller information.
Definition: vesafb.h:19
uint8_t green_lsb
Green LSB.
Definition: fbcon.h:85
Frame buffer console.
static int vesafb_init(struct console_configuration *config)
Initialise VESA frame buffer.
Definition: vesafb.c:444
Error codes.
uint8_t red_lsb
Red LSB.
Definition: fbcon.h:83
#define VBE_MODE_INFO
INT 10,4f01: return VBE mode information.
Definition: vesafb.h:59
unsigned int width
Width (number of entities per displayed row)
Definition: fbcon.h:53
#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 __always_inline void copy_from_user(void *dest, userptr_t src, off_t src_off, size_t len)
Copy data from user buffer.
Definition: uaccess.h:337
uint16_t y_resolution
Vertical resolution in pixels or characters.
Definition: vesafb.h:84
static int vesafb_configure(struct console_configuration *config)
Configure console.
Definition: vesafb.c:523
#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
#define ENOENT
No such file or directory.
Definition: errno.h:514
uint32_t phys_base_ptr
Physical address for flat memory frame buffer.
Definition: vesafb.h:122
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:441
userptr_t phys_to_user(unsigned long phys_addr)
Convert physical address to user pointer.
unsigned int width
Width.
Definition: console.h:26
static void vesafb_putchar(int character)
Print a character to current cursor position.
Definition: vesafb.c:512
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
void(* glyph)(unsigned int character, uint8_t *glyph)
Get character glyph.
Definition: fbcon.h:43
unsigned int depth
Colour depth.
Definition: console.h:30
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
#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
uint8_t status
Status.
Definition: ena.h:16
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ENOMEM
Not enough space.
Definition: errno.h:534
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:77
size_t len
Length of a single entity.
Definition: fbcon.h:57
A frame buffer console.
Definition: fbcon.h:113
#define VESAFB_UNKNOWN
Glyph to render for non-ASCII characters.
Definition: vesafb.c:88
#define DBGC_HDA(...)
Definition: compiler.h:506
A frame buffer colour mapping.
Definition: fbcon.h:75
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:361
A 16-bit general register.
Definition: registers.h:24
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
#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
int fbcon_init(struct fbcon *fbcon, userptr_t 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:588
User interaction.
uint8_t number_of_image_pages
Number of images.
Definition: vesafb.h:100
static void vesafb_glyph(unsigned int character, uint8_t *glyph)
Get character glyph.
Definition: vesafb.c:145
uint8_t rsvd_mask_size
Size of direct colour reserved mask in bits.
Definition: vesafb.h:116
static int vesafb_mode_info(unsigned int mode_number)
Get video mode information.
Definition: vesafb.c:270
void fbcon_fini(struct fbcon *fbcon)
Finalise frame buffer console.
Definition: fbcon.c:718
physaddr_t start
Physical start address.
Definition: vesafb.c:98
uint8_t green_mask_size
Size of direct colour green mask in bits.
Definition: vesafb.h:108
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:79
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:168
__asm__ __volatile__("\n1:\n\t" "movb -1(%3,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %4, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c), "+m"(*value) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
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
uint16_t mode_attributes
Mode attributes.
Definition: vesafb.h:64
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
A font definition.
Definition: fbcon.h:34
Console configuration.
uint8_t blue_mask_size
Size of direct colour blue mask in bits.
Definition: vesafb.h:112
uint8_t blue_scale
Blue scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:81
VESA frame buffer console.
struct segoff glyphs
Character glyphs.
Definition: vesafb.c:106
#define copy_from_real
Definition: libkir.h:79
unsigned long physaddr_t
Definition: stdint.h:20
#define VBE_CONTROLLER_INFO
INT 10,4f00: return controller information.
Definition: vesafb.h:16
uint16_t bytes_per_scan_line
Bytes per scan line.
Definition: vesafb.h:80
#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
uint8_t code
Response code.
Definition: scsi.h:16
int disabled
Console disabled flags.
Definition: console.h:62
uint32_t len
Length.
Definition: ena.h:14
uint16_t x_resolution
Horizontal resolution in pixels or characters.
Definition: vesafb.h:82
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:312
unsigned int height
Height (number of entities per displayed column)
Definition: fbcon.h:55
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:427
#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:87
struct vbe_mode_info mode
VBE mode information block.
Definition: vesafb.c:119
static __always_inline userptr_t real_to_user(unsigned int segment, unsigned int offset)
Convert segment:offset address to user buffer.
Definition: realmode.h:75
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:498
struct fbcon_colour_map map
Colour mapping.
Definition: vesafb.c:102
A console driver.
Definition: console.h:55
#define INT_MAX
Definition: limits.h:37
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
#define EIO_VBE(code)
Definition: vesafb.c:60
uint8_t red_field_position
Bit position of LSB of red mask.
Definition: vesafb.h:106
#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
uint8_t green_field_position
Bit position of LSB of green mask.
Definition: vesafb.h:110
size_t stride
Stride (offset between vertically adjacent entities)
Definition: fbcon.h:59
ANSI colours.
static int vesafb_mode_list(uint16_t **mode_numbers)
Get VBE mode list.
Definition: vesafb.c:207
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
Graphics mode.
Definition: vesafb.h:140