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 uint32_t visible;
47 } fb_cursor_t;
48
49 typedef struct boot_framebuffer {
50 uint64_t framebuffer; /* native_ptr_t */
51 uint64_t boot_fb_virt; /* native_ptr_t */
52 fb_cursor_t cursor;
53 } __attribute__((packed)) boot_framebuffer_t;
54
55 enum fb_type {
56 FB_TYPE_UNINITIALIZED = 0, /* FB not set up, use vga text mode */
57 FB_TYPE_EGA_TEXT, /* vga text mode */
58 FB_TYPE_INDEXED, /* FB mode */
59 FB_TYPE_RGB, /* FB mode */
60 FB_TYPE_UNKNOWN
61 };
62
63 typedef struct fb_info {
64 enum fb_type fb_type; /* Marker from xbi_fb_init */
65 uint64_t paddr; /* FB address from bootloader */
66 uint8_t *fb; /* kernel mapped frame buffer */
67 uint8_t *shadow_fb;
68 uint64_t fb_size; /* mapped FB size in bytes */
69 uint32_t pitch; /* scan line in bytes */
70 uint8_t bpp; /* bytes per pixel */
71 uint8_t depth; /* bits per pixel */
72 uint8_t fg_color; /* ansi foreground */
73 uint8_t bg_color; /* ansi background */
74 rgb_t rgb;
75 fb_info_pixel_coord_t screen; /* screen size */
76 fb_info_pixel_coord_t terminal_origin; /* terminal upper left corner */
77 fb_info_char_coord_t terminal; /* terminal size in chars */
78 fb_cursor_t cursor;
79 uint16_t font_width;
80 uint16_t font_height;
81 boolean_t inverse;
82 boolean_t inverse_screen;
83 } fb_info_t;
84
85 extern fb_info_t fb_info;
86 void boot_fb_cursor(boolean_t);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* _SYS_FRAMEBUFFER_H */