aboutsummaryrefslogtreecommitdiff
path: root/stand/i386/loader/gfx_bios.c
blob: 1581325a81e09b8eff90a4214939165786c29f6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright (c) 2024 Netflix, Inc.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

/*
 * This file provides all the gfx glue, or stubs, so that we can build, if we
 * want, two versions of the bios loader: one with graphics support and one
 * without. This allows us to keep the calls in other places, like libraries
 * that are tricky to compile twice. It also reduces the number of ifdefs we
 * need to support the old text-only video console. This could also be two
 * separate files, but it is short and having it all here helps to constrain
 * dependency creap somewhat.
 */

#include <stand.h>
#ifndef BIOS_TEXT_ONLY
#include "bootstrap.h"
#include "libi386/libi386.h"
#include "libi386/vbe.h"
#include <gfx_fb.h>
#endif

#ifdef BIOS_TEXT_ONLY		/* Note: likely need a forced commits when this changes */
void autoload_font(bool bios);

void
autoload_font(bool bios)
{
}

vm_offset_t build_font_module(vm_offset_t addr);

vm_offset_t
build_font_module(vm_offset_t addr)
{
	return addr;
}

struct preloaded_file;
void bi_load_vbe_data(struct preloaded_file *kfp);

void bi_load_vbe_data(struct preloaded_file *kfp)
{
}

#else

void
bi_load_vbe_data(struct preloaded_file *kfp)
{
	if (!kfp->f_tg_kernel_support) {
		/*
		 * Loaded kernel does not have vt/vbe backend,
		 * switch console to text mode.
		 */
		if (vbe_available())
			bios_set_text_mode(VGA_TEXT_MODE);
		return;
	}

	if (vbe_available()) {
		file_addmetadata(kfp, MODINFOMD_VBE_FB,
		    sizeof(gfx_state.tg_fb), &gfx_state.tg_fb);
	}
}
#endif