1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/efi.h> 4 #include <linux/sysfb.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 sysfb_primary_display 12 * via the stub: 13 * 14 * - using a configuration table, which relies on the EFI init code to 15 * locate the table and copy the contents; or 16 * 17 * - by linking directly to the core kernel's copy of the global symbol. 18 * 19 * The latter is preferred because it makes the EFIFB earlycon available very 20 * early, but it only works if the EFI stub is part of the core kernel image 21 * itself. The zboot decompressor can only use the configuration table 22 * approach. 23 */ 24 25 static efi_guid_t primary_display_guid = LINUX_EFI_PRIMARY_DISPLAY_TABLE_GUID; 26 27 struct sysfb_display_info *__alloc_primary_display(void) 28 { 29 struct sysfb_display_info *dpy; 30 efi_status_t status; 31 32 status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY, 33 sizeof(*dpy), (void **)&dpy); 34 35 if (status != EFI_SUCCESS) 36 return NULL; 37 38 memset(dpy, 0, sizeof(*dpy)); 39 40 status = efi_bs_call(install_configuration_table, 41 &primary_display_guid, dpy); 42 if (status == EFI_SUCCESS) 43 return dpy; 44 45 efi_bs_call(free_pool, dpy); 46 return NULL; 47 } 48 49 void free_primary_display(struct sysfb_display_info *dpy) 50 { 51 if (!dpy) 52 return; 53 54 efi_bs_call(install_configuration_table, &primary_display_guid, NULL); 55 efi_bs_call(free_pool, dpy); 56 } 57