brintos

brintos / linux-shallow public Read only

0
0
Text · 1.3 KiB · 5d3a1e3 Raw
54 lines · c
1// SPDX-License-Identifier: GPL-2.02 3#include <linux/efi.h>4#include <linux/screen_info.h>5 6#include <asm/efi.h>7 8#include "efistub.h"9 10/*11 * There are two ways of populating the core kernel's struct screen_info via the stub:12 * - using a configuration table, like below, which relies on the EFI init code13 *   to locate the table and copy the contents;14 * - by linking directly to the core kernel's copy of the global symbol.15 *16 * The latter is preferred because it makes the EFIFB earlycon available very17 * early, but it only works if the EFI stub is part of the core kernel image18 * itself. The zboot decompressor can only use the configuration table19 * approach.20 */21 22static efi_guid_t screen_info_guid = LINUX_EFI_SCREEN_INFO_TABLE_GUID;23 24struct screen_info *__alloc_screen_info(void)25{26	struct screen_info *si;27	efi_status_t status;28 29	status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,30			     sizeof(*si), (void **)&si);31 32	if (status != EFI_SUCCESS)33		return NULL;34 35	memset(si, 0, sizeof(*si));36 37	status = efi_bs_call(install_configuration_table,38			     &screen_info_guid, si);39	if (status == EFI_SUCCESS)40		return si;41 42	efi_bs_call(free_pool, si);43	return NULL;44}45 46void free_screen_info(struct screen_info *si)47{48	if (!si)49		return;50 51	efi_bs_call(install_configuration_table, &screen_info_guid, NULL);52	efi_bs_call(free_pool, si);53}54