xref: /illumos-gate/usr/src/uts/i86pc/sys/framebuffer.h (revision d48be21240dfd051b689384ce2b23479d757f2d8)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 Toomas Soome <tsoome@me.com>
14  */
15 
16 #ifndef _SYS_FRAMEBUFFER_H
17 #define	_SYS_FRAMEBUFFER_H
18 
19 /*
20  * Framebuffer info from boot loader. Collect linear framebuffer data
21  * provided by boot loader and early boot setup.
22  * Note the UEFI and multiboot2 present data with slight differences.
23  */
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include <sys/types.h>
30 #include <sys/font.h>
31 #include <sys/rgb.h>
32 
33 typedef struct fb_info_pixel_coord {
34 	uint16_t x;
35 	uint16_t y;
36 } fb_info_pixel_coord_t;
37 
38 typedef struct fb_info_char_coord {
39 	uint16_t x;
40 	uint16_t y;
41 } fb_info_char_coord_t;
42 
43 typedef struct fb_cursor {
44 	fb_info_pixel_coord_t origin;	/* cursor upper left */
45 	fb_info_char_coord_t pos;	/* cursor coord in chars */
46 	boolean_t visible;
47 } fb_cursor_t;
48 
49 typedef struct boot_framebuffer {
50 	uint64_t framebuffer;	/* native_ptr_t */
51 	fb_cursor_t cursor;
52 } __packed boot_framebuffer_t;
53 
54 typedef enum fb_type {
55 	FB_TYPE_UNINITIALIZED = 0,	/* FB not set up, use vga text mode */
56 	FB_TYPE_EGA_TEXT,		/* vga text mode */
57 	FB_TYPE_INDEXED,		/* FB mode */
58 	FB_TYPE_RGB,			/* FB mode */
59 	FB_TYPE_UNKNOWN
60 } fb_type_t;
61 
62 typedef struct fb_info {
63 	fb_type_t fb_type;	/* Marker from xbi_fb_init */
64 	uint64_t paddr;		/* FB address from bootloader */
65 	uint8_t *fb;		/* kernel mapped frame buffer */
66 	uint8_t *shadow_fb;
67 	uint64_t fb_size;	/* mapped FB size in bytes */
68 	uint32_t pitch;		/* scan line in bytes */
69 	uint8_t bpp;		/* bytes per pixel */
70 	uint8_t depth;		/* bits per pixel */
71 	uint8_t fg_color;	/* ansi foreground */
72 	uint8_t bg_color;	/* ansi background */
73 	rgb_t	rgb;
74 	fb_info_pixel_coord_t screen;		/* screen size */
75 	fb_info_pixel_coord_t terminal_origin;	/* terminal upper left corner */
76 	fb_info_char_coord_t terminal;		/* terminal size in chars */
77 	fb_cursor_t cursor;
78 	uint16_t font_width;
79 	uint16_t font_height;
80 	boolean_t inverse;
81 	boolean_t inverse_screen;
82 } fb_info_t;
83 
84 extern fb_info_t fb_info;
85 void boot_fb_cursor(boolean_t);
86 extern uint32_t boot_color_map(uint8_t);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* _SYS_FRAMEBUFFER_H */
93