visor/src/efi.c

46 lines
895 B
C
Raw Normal View History

2025-03-10 19:19:53 +01:00
#include <stdbool.h>
2025-03-10 02:36:46 +01:00
#include <efi.h>
#include <efilib.h>
2025-03-10 19:19:53 +01:00
#include "virt.h"
2025-03-11 18:46:10 +01:00
#include "bootstrap.h"
#include "procvisor.h"
2025-03-10 19:19:53 +01:00
struct virt_vtable *virt = &virt_vtable_intel;
static char virt_err[100];
2025-03-11 18:46:10 +01:00
void *
bs_alloc(size_t size)
{
size_t npages = (size + (4096 - 1)) / 4096;
void *ptr;
uefi_call_wrapper(BS->AllocatePages, 4, AllocateAnyPages, EfiRuntimeServicesData, npages, &ptr);
return ptr;
}
2025-03-10 02:36:46 +01:00
EFIAPI
EFI_STATUS
efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *systemTable)
{
InitializeLib(imageHandle, systemTable);
2025-03-10 20:24:32 +01:00
2025-03-11 18:46:10 +01:00
AsciiPrint("* Setting up processor structures\n");
struct procvisor *pv = proc_setup();
(void)pv;
2025-03-10 19:19:53 +01:00
2025-03-10 20:24:32 +01:00
AsciiPrint("* Checking for VT-x Support\n");
2025-03-10 19:19:53 +01:00
if (!virt->has_support(virt_err, sizeof virt_err)) {
AsciiPrint(virt_err);
2025-03-10 20:24:32 +01:00
} else {
AsciiPrint("* Enabling VT-x\n");
virt->enable();
AsciiPrint("* VT-x enabled!\n");
2025-03-10 19:19:53 +01:00
}
for (;;) {}
2025-03-10 02:36:46 +01:00
return EFI_SUCCESS;
}