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 /* Forward declaration */
82 struct console_driver vesafb_console __console_driver;
83 
84 /** A VESA frame buffer */
85 struct vesafb {
86  /** Frame buffer console */
87  struct fbcon fbcon;
88  /** Physical start address */
90  /** Pixel geometry */
92  /** Colour mapping */
94  /** Font definition */
95  struct fbcon_font font;
96  /** Character glyphs */
97  struct segoff glyphs;
98  /** Saved VGA mode */
100 };
101 
102 /** The VESA frame buffer */
103 static struct vesafb vesafb;
104 
105 /** Base memory buffer used for VBE calls */
106 union vbe_buffer {
107  /** VBE controller information block */
109  /** VBE mode information block */
111 };
112 static union vbe_buffer __bss16 ( vbe_buf );
113 #define vbe_buf __use_data16 ( vbe_buf )
114 
115 /**
116  * Convert VBE status code to iPXE status code
117  *
118  * @v status VBE status code
119  * @ret rc Return status code
120  */
121 static int vesafb_rc ( unsigned int status ) {
122  unsigned int code;
123 
124  if ( ( status & 0xff ) != 0x4f )
125  return -ENOTSUP;
126  code = ( ( status >> 8 ) & 0xff );
127  return ( code ? -EIO_VBE ( code ) : 0 );
128 }
129 
130 /**
131  * Get character glyph
132  *
133  * @v character Character
134  * @v glyph Character glyph to fill in
135  */
136 static void vesafb_glyph ( unsigned int character, uint8_t *glyph ) {
137  size_t offset = ( character * VESAFB_CHAR_HEIGHT );
138 
141 }
142 
143 /**
144  * Get font definition
145  *
146  */
147 static void vesafb_font ( void ) {
148 
149  /* Get font information
150  *
151  * Working around gcc bugs is icky here. The value we want is
152  * returned in %ebp, but there's no way to specify %ebp in an
153  * output constraint. We can't put %ebp in the clobber list,
154  * because this tends to cause random build failures on some
155  * gcc versions. We can't manually push/pop %ebp and return
156  * the value via a generic register output constraint, because
157  * gcc might choose to use %ebp to satisfy that constraint
158  * (and we have no way to prevent it from so doing).
159  *
160  * Work around this hideous mess by using %ecx and %edx as the
161  * output registers, since they get clobbered anyway.
162  */
163  __asm__ __volatile__ ( REAL_CODE ( "pushw %%bp\n\t" /* gcc bug */
164  "int $0x10\n\t"
165  "movw %%es, %%cx\n\t"
166  "movw %%bp, %%dx\n\t"
167  "popw %%bp\n\t" /* gcc bug */ )
168  : "=c" ( vesafb.glyphs.segment ),
169  "=d" ( vesafb.glyphs.offset )
170  : "a" ( VBE_GET_FONT ),
171  "b" ( VESAFB_FONT ) );
172  DBGC ( &vbe_buf, "VESAFB has font %04x at %04x:%04x\n",
176 }
177 
178 /**
179  * Get VBE mode list
180  *
181  * @ret mode_numbers Mode number list (terminated with VBE_MODE_END)
182  * @ret rc Return status code
183  *
184  * The caller is responsible for eventually freeing the mode list.
185  */
186 static int vesafb_mode_list ( uint16_t **mode_numbers ) {
187  struct vbe_controller_info *controller = &vbe_buf.controller;
189  uint16_t mode_number;
191  size_t len;
192  int rc;
193 
194  /* Avoid returning uninitialised data on error */
195  *mode_numbers = NULL;
196 
197  /* Get controller information block */
198  controller->vbe_signature = 0;
199  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
200  : "=a" ( status )
201  : "a" ( VBE_CONTROLLER_INFO ),
202  "D" ( __from_data16 ( controller ) )
203  : "memory", "ebx", "edx" );
204  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
205  DBGC ( &vbe_buf, "VESAFB could not get controller information: "
206  "[%04x] %s\n", status, strerror ( rc ) );
207  return rc;
208  }
209  if ( controller->vbe_signature != VBE_CONTROLLER_SIGNATURE ) {
210  DBGC ( &vbe_buf, "VESAFB invalid controller signature "
211  "\"%c%c%c%c\"\n", ( controller->vbe_signature >> 0 ),
212  ( controller->vbe_signature >> 8 ),
213  ( controller->vbe_signature >> 16 ),
214  ( controller->vbe_signature >> 24 ) );
215  DBGC_HDA ( &vbe_buf, 0, controller, sizeof ( *controller ) );
216  return -EINVAL;
217  }
218  DBGC ( &vbe_buf, "VESAFB found VBE version %d.%d with mode list at "
219  "%04x:%04x\n", controller->vbe_major_version,
220  controller->vbe_minor_version,
221  controller->video_mode_ptr.segment,
222  controller->video_mode_ptr.offset );
223 
224  /* Calculate length of mode list */
225  video_mode_ptr = real_to_user ( controller->video_mode_ptr.segment,
226  controller->video_mode_ptr.offset );
227  len = 0;
228  do {
229  copy_from_user ( &mode_number, video_mode_ptr, len,
230  sizeof ( mode_number ) );
231  len += sizeof ( mode_number );
232  } while ( mode_number != VBE_MODE_END );
233 
234  /* Allocate and fill mode list */
235  *mode_numbers = malloc ( len );
236  if ( ! *mode_numbers )
237  return -ENOMEM;
238  copy_from_user ( *mode_numbers, video_mode_ptr, 0, len );
239 
240  return 0;
241 }
242 
243 /**
244  * Get video mode information
245  *
246  * @v mode_number Mode number
247  * @ret rc Return status code
248  */
249 static int vesafb_mode_info ( unsigned int mode_number ) {
250  struct vbe_mode_info *mode = &vbe_buf.mode;
252  int rc;
253 
254  /* Get mode information */
255  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
256  : "=a" ( status )
257  : "a" ( VBE_MODE_INFO ),
258  "c" ( mode_number ),
259  "D" ( __from_data16 ( mode ) )
260  : "memory" );
261  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
262  DBGC ( &vbe_buf, "VESAFB could not get mode %04x information: "
263  "[%04x] %s\n", mode_number, status, strerror ( rc ) );
264  return rc;
265  }
266  DBGC ( &vbe_buf, "VESAFB mode %04x %dx%d %dbpp(%d:%d:%d:%d) model "
267  "%02x [x%d]%s%s%s%s%s\n", mode_number, mode->x_resolution,
268  mode->y_resolution, mode->bits_per_pixel, mode->rsvd_mask_size,
269  mode->red_mask_size, mode->green_mask_size, mode->blue_mask_size,
270  mode->memory_model, ( mode->number_of_image_pages + 1 ),
272  "" : " [unsupported]" ),
273  ( ( mode->mode_attributes & VBE_MODE_ATTR_TTY ) ?
274  " [tty]" : "" ),
276  "" : " [text]" ),
277  ( ( mode->mode_attributes & VBE_MODE_ATTR_LINEAR ) ?
278  "" : " [nonlinear]" ),
280  " [buf]" : "" ) );
281 
282  return 0;
283 }
284 
285 /**
286  * Set video mode
287  *
288  * @v mode_number Mode number
289  * @ret rc Return status code
290  */
291 static int vesafb_set_mode ( unsigned int mode_number ) {
292  struct vbe_mode_info *mode = &vbe_buf.mode;
294  int rc;
295 
296  /* Get mode information */
297  if ( ( rc = vesafb_mode_info ( mode_number ) ) != 0 )
298  return rc;
299 
300  /* Record mode parameters */
301  vesafb.start = mode->phys_base_ptr;
302  vesafb.pixel.width = mode->x_resolution;
304  vesafb.pixel.len = ( ( mode->bits_per_pixel + 7 ) / 8 );
306  DBGC ( &vbe_buf, "VESAFB mode %04x has frame buffer at %08x\n",
307  mode_number, mode->phys_base_ptr );
308 
309  /* Initialise font colours */
310  vesafb.map.red_scale = ( 8 - mode->red_mask_size );
311  vesafb.map.green_scale = ( 8 - mode->green_mask_size );
312  vesafb.map.blue_scale = ( 8 - mode->blue_mask_size );
316 
317  /* Select this mode */
318  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
319  : "=a" ( status )
320  : "a" ( VBE_SET_MODE ),
321  "b" ( mode_number ) );
322  if ( ( rc = vesafb_rc ( status ) ) != 0 ) {
323  DBGC ( &vbe_buf, "VESAFB could not set mode %04x: [%04x] %s\n",
324  mode_number, status, strerror ( rc ) );
325  return rc;
326  }
327 
328  return 0;
329 }
330 
331 /**
332  * Select video mode
333  *
334  * @v mode_numbers Mode number list (terminated with VBE_MODE_END)
335  * @v min_width Minimum required width (in pixels)
336  * @v min_height Minimum required height (in pixels)
337  * @v min_bpp Minimum required colour depth (in bits per pixel)
338  * @ret mode_number Mode number, or negative error
339  */
340 static int vesafb_select_mode ( const uint16_t *mode_numbers,
341  unsigned int min_width, unsigned int min_height,
342  unsigned int min_bpp ) {
343  struct vbe_mode_info *mode = &vbe_buf.mode;
344  int best_mode_number = -ENOENT;
345  unsigned int best_score = INT_MAX;
346  unsigned int score;
347  uint16_t mode_number;
348  int rc;
349 
350  /* Find the first suitable mode */
351  while ( ( mode_number = *(mode_numbers++) ) != VBE_MODE_END ) {
352 
353  /* Force linear mode variant */
354  mode_number |= VBE_MODE_LINEAR;
355 
356  /* Get mode information */
357  if ( ( rc = vesafb_mode_info ( mode_number ) ) != 0 )
358  continue;
359 
360  /* Skip unusable modes */
361  if ( ( mode->mode_attributes & ( VBE_MODE_ATTR_SUPPORTED |
363  VBE_MODE_ATTR_LINEAR ) ) !=
366  continue;
367  }
369  continue;
370 
371  /* Skip modes not meeting the requirements */
372  if ( ( mode->x_resolution < min_width ) ||
373  ( mode->y_resolution < min_height ) ||
374  ( mode->bits_per_pixel < min_bpp ) ) {
375  continue;
376  }
377 
378  /* Select this mode if it has the best (i.e. lowest)
379  * score. We choose the scoring system to favour
380  * modes close to the specified width and height;
381  * within modes of the same width and height we prefer
382  * a higher colour depth.
383  */
384  score = ( ( mode->x_resolution * mode->y_resolution ) -
385  mode->bits_per_pixel );
386  if ( score < best_score ) {
387  best_mode_number = mode_number;
388  best_score = score;
389  }
390  }
391 
392  if ( best_mode_number >= 0 ) {
393  DBGC ( &vbe_buf, "VESAFB selected mode %04x\n",
394  best_mode_number );
395  } else {
396  DBGC ( &vbe_buf, "VESAFB found no suitable mode\n" );
397  }
398 
399  return best_mode_number;
400 }
401 
402 /**
403  * Restore video mode
404  *
405  */
406 static void vesafb_restore ( void ) {
407  uint32_t discard_a;
408 
409  /* Restore saved VGA mode */
410  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
411  : "=a" ( discard_a )
412  : "a" ( VBE_SET_VGA_MODE | vesafb.saved_mode ) );
413  DBGC ( &vbe_buf, "VESAFB restored VGA mode %#02x\n",
414  vesafb.saved_mode );
415 }
416 
417 /**
418  * Initialise VESA frame buffer
419  *
420  * @v config Console configuration, or NULL to reset
421  * @ret rc Return status code
422  */
423 static int vesafb_init ( struct console_configuration *config ) {
424  uint32_t discard_b;
425  uint16_t *mode_numbers;
426  int mode_number;
427  int rc;
428 
429  /* Record current VGA mode */
430  __asm__ __volatile__ ( REAL_CODE ( "int $0x10" )
431  : "=a" ( vesafb.saved_mode ), "=b" ( discard_b )
432  : "a" ( VBE_GET_VGA_MODE ) );
433  DBGC ( &vbe_buf, "VESAFB saved VGA mode %#02x\n", vesafb.saved_mode );
434 
435  /* Get VESA mode list */
436  if ( ( rc = vesafb_mode_list ( &mode_numbers ) ) != 0 )
437  goto err_mode_list;
438 
439  /* Select mode */
440  if ( ( mode_number = vesafb_select_mode ( mode_numbers, config->width,
441  config->height,
442  config->depth ) ) < 0 ) {
443  rc = mode_number;
444  goto err_select_mode;
445  }
446 
447  /* Set mode */
448  if ( ( rc = vesafb_set_mode ( mode_number ) ) != 0 )
449  goto err_set_mode;
450 
451  /* Get font data */
452  vesafb_font();
453 
454  /* Initialise frame buffer console */
455  if ( ( rc = fbcon_init ( &vesafb.fbcon, phys_to_user ( vesafb.start ),
457  config ) ) != 0 )
458  goto err_fbcon_init;
459 
460  free ( mode_numbers );
461  return 0;
462 
463  fbcon_fini ( &vesafb.fbcon );
464  err_fbcon_init:
465  err_set_mode:
466  vesafb_restore();
467  err_select_mode:
468  free ( mode_numbers );
469  err_mode_list:
470  return rc;
471 }
472 
473 /**
474  * Finalise VESA frame buffer
475  *
476  */
477 static void vesafb_fini ( void ) {
478 
479  /* Finalise frame buffer console */
480  fbcon_fini ( &vesafb.fbcon );
481 
482  /* Restore saved VGA mode */
483  vesafb_restore();
484 }
485 
486 /**
487  * Print a character to current cursor position
488  *
489  * @v character Character
490  */
491 static void vesafb_putchar ( int character ) {
492 
493  fbcon_putchar ( &vesafb.fbcon, character );
494 }
495 
496 /**
497  * Configure console
498  *
499  * @v config Console configuration, or NULL to reset
500  * @ret rc Return status code
501  */
502 static int vesafb_configure ( struct console_configuration *config ) {
503  int rc;
504 
505  /* Reset console, if applicable */
506  if ( ! vesafb_console.disabled ) {
507  vesafb_fini();
510  }
511  vesafb_console.disabled = CONSOLE_DISABLED;
512 
513  /* Do nothing more unless we have a usable configuration */
514  if ( ( config == NULL ) ||
515  ( config->width == 0 ) || ( config->height == 0 ) ) {
516  return 0;
517  }
518 
519  /* Initialise VESA frame buffer */
520  if ( ( rc = vesafb_init ( config ) ) != 0 )
521  return rc;
522 
523  /* Mark console as enabled */
524  vesafb_console.disabled = 0;
526 
527  /* Set magic colour to transparent if we have a background picture */
528  if ( config->pixbuf )
530 
531  return 0;
532 }
533 
534 /** VESA frame buffer console driver */
535 struct console_driver vesafb_console __console_driver = {
537  .putchar = vesafb_putchar,
538  .configure = vesafb_configure,
539  .disabled = CONSOLE_DISABLED,
540 };
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
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:106
#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:84
Frame buffer console.
static int vesafb_init(struct console_configuration *config)
Initialise VESA frame buffer.
Definition: vesafb.c:423
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
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 __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:502
#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:491
struct fbcon fbcon
Frame buffer console.
Definition: vesafb.c:87
#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:42
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:99
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 DBGC_HDA(...)
Definition: compiler.h:506
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:340
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:82
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:583
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:136
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:249
void fbcon_fini(struct fbcon *fbcon)
Finalise frame buffer console.
Definition: fbcon.c:713
physaddr_t start
Physical start address.
Definition: vesafb.c:89
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:95
uint8_t green_scale
Green scale (right shift amount from 24-bit RGB)
Definition: fbcon.h:78
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:91
static void vesafb_font(void)
Get font definition.
Definition: vesafb.c:147
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:108
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:33
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:80
VESA frame buffer console.
__asm__ __volatile__("\n1:\n\t" "movb -1(%2,%1), %%al\n\t" "stosb\n\t" "loop 1b\n\t" "xorl %%eax, %%eax\n\t" "mov %3, %1\n\t" "rep stosb\n\t" :"=&D"(discard_D), "=&c"(discard_c) :"r"(data), "g"(pad_len), "0"(value0), "1"(len) :"eax")
struct segoff glyphs
Character glyphs.
Definition: vesafb.c:97
#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:291
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
VBE mode information.
Definition: vesafb.h:62
static void vesafb_restore(void)
Restore video mode.
Definition: vesafb.c:406
#define vbe_buf
Definition: vesafb.c:113
#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:110
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:121
static void vesafb_fini(void)
Finalise VESA frame buffer.
Definition: vesafb.c:477
struct fbcon_colour_map map
Colour mapping.
Definition: vesafb.c:93
A console driver.
Definition: console.h:55
#define INT_MAX
Definition: limits.h:37
#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:85
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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:58
ANSI colours.
static int vesafb_mode_list(uint16_t **mode_numbers)
Get VBE mode list.
Definition: vesafb.c:186
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33
Graphics mode.
Definition: vesafb.h:140