xref: /freebsd/stand/i386/loader/gfx_bios.c (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
1 /*
2  * Copyright (c) 2024 Netflix, Inc.
3  *
4  * SPDX-License-Identifier: BSD-2-Clause
5  */
6 
7 /*
8  * This file provides all the gfx glue, or stubs, so that we can build, if we
9  * want, two versions of the bios loader: one with graphics support and one
10  * without. This allows us to keep the calls in other places, like libraries
11  * that are tricky to compile twice. It also reduces the number of ifdefs we
12  * need to support the old text-only video console. This could also be two
13  * separate files, but it is short and having it all here helps to constrain
14  * dependency creap somewhat.
15  */
16 
17 #include <stand.h>
18 #ifndef BIOS_TEXT_ONLY
19 #include "bootstrap.h"
20 #include "libi386/libi386.h"
21 #include "libi386/vbe.h"
22 #include <gfx_fb.h>
23 #endif
24 
25 #ifdef BIOS_TEXT_ONLY
26 void autoload_font(bool bios);
27 
28 void
29 autoload_font(bool bios)
30 {
31 }
32 
33 vm_offset_t build_font_module(vm_offset_t addr);
34 
35 vm_offset_t
36 build_font_module(vm_offset_t addr)
37 {
38 	return addr;
39 }
40 
41 struct preloaded_file;
42 void bi_load_vbe_data(struct preloaded_file *kfp);
43 
44 void bi_load_vbe_data(struct preloaded_file *kfp)
45 {
46 }
47 
48 #else
49 
50 void
51 bi_load_vbe_data(struct preloaded_file *kfp)
52 {
53 	if (!kfp->f_tg_kernel_support) {
54 		/*
55 		 * Loaded kernel does not have vt/vbe backend,
56 		 * switch console to text mode.
57 		 */
58 		if (vbe_available())
59 			bios_set_text_mode(VGA_TEXT_MODE);
60 		return;
61 	}
62 
63 	if (vbe_available()) {
64 		file_addmetadata(kfp, MODINFOMD_VBE_FB,
65 		    sizeof(gfx_state.tg_fb), &gfx_state.tg_fb);
66 	}
67 }
68 #endif
69