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