Skip to content

Commit 54eee79

Browse files
mintsukiFlyGoat
authored andcommitted
Defer copying VBIOS to low memory until later, similar to the CSM
1 parent ad50836 commit 54eee79

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/csmwrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
229229

230230
/* Copy ROM to location, as late as possible */
231231
memcpy((void*)csm_bin_base, Csm16_bin, sizeof(Csm16_bin));
232+
memcpy((void*)VGABIOS_START, vbios_loc, vbios_size);
232233

233234
memset(&Regs, 0, sizeof(EFI_IA32_REGISTER_SET));
234235
Regs.X.AX = Legacy16InitializeYourself;

src/csmwrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ extern int copy_rsdt(struct csmwrap_priv *priv);
4545
int build_e820_map(struct csmwrap_priv *priv);
4646
int apply_intel_platform_workarounds(void);
4747

48+
extern void *vbios_loc;
49+
extern uintptr_t vbios_size;
50+
4851

4952
static inline int
5053
efi_guidcmp (EFI_GUID left, EFI_GUID right)

src/video.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// Generated by: xxd -i vgabios.bin >> vgabios.h
66
#include "bins/vgabios.h"
77

8+
void *vbios_loc;
9+
uintptr_t vbios_size;
10+
811
static EFI_STATUS FindGopPciDevice(struct csmwrap_priv *priv)
912
{
1013
EFI_STATUS Status = EFI_SUCCESS;
@@ -386,7 +389,8 @@ EFI_STATUS csmwrap_video_oprom_init(struct csmwrap_priv *priv)
386389
return Status;
387390
}
388391

389-
memcpy((void*)VGABIOS_START, LocalRomImage, LocalRomSize);
392+
vbios_loc = LocalRomImage;
393+
vbios_size = LocalRomSize;
390394

391395
priv->video_type = CSMWRAP_VIDEO_OPROM;
392396

@@ -493,8 +497,8 @@ EFI_STATUS csmwrap_video_seavgabios_init(struct csmwrap_priv *priv)
493497
return EFI_UNSUPPORTED;
494498
}
495499

496-
/* Copy VGA BIOS to location */
497-
memcpy((void*)VGABIOS_START, vgabios_bin, sizeof(vgabios_bin));
500+
vbios_loc = vgabios_bin;
501+
vbios_size = sizeof(vgabios_bin);
498502

499503
priv->video_type = CSMWRAP_VIDEO_SEAVGABIOS;
500504

@@ -522,8 +526,8 @@ EFI_STATUS csmwrap_video_fallback(struct csmwrap_priv *priv)
522526
cb_fb->reserved_mask_pos = 24;
523527
cb_fb->reserved_mask_size = 8;
524528

525-
/* Copy VGA BIOS to location */
526-
memcpy((void*)VGABIOS_START, vgabios_bin, sizeof(vgabios_bin));
529+
vbios_loc = vgabios_bin;
530+
vbios_size = sizeof(vgabios_bin);
527531

528532
priv->video_type = CSMWRAP_VIDEO_FALLBACK;
529533

0 commit comments

Comments
 (0)