-/* $OpenBSD: efiboot.c,v 1.37 2021/05/23 20:30:42 kettenis Exp $ */
+/* $OpenBSD: efiboot.c,v 1.38 2021/06/07 00:04:20 krw Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
#include "efidev.h"
#include "efiboot.h"
-#include "eficall.h"
#include "run_i386.h"
#define KERN_LOADSPACE_SIZE (64 * 1024 * 1024)
IH = image;
/* disable reset by watchdog after 5 minutes */
- EFI_CALL(BS->SetWatchdogTimer, 0, 0, 0, NULL);
+ BS->SetWatchdogTimer(0, 0, 0, NULL);
efi_video_init();
efi_heap_init();
- status = EFI_CALL(BS->HandleProtocol, image, &imgp_guid,
- (void **)&imgp);
+ status = BS->HandleProtocol(image, &imgp_guid, (void **)&imgp);
if (status == EFI_SUCCESS)
- status = EFI_CALL(BS->HandleProtocol, imgp->DeviceHandle,
- &devp_guid, (void **)&dp0);
+ status = BS->HandleProtocol(imgp->DeviceHandle, &devp_guid,
+ (void **)&dp0);
if (status == EFI_SUCCESS) {
for (dp = dp0; !IsDevicePathEnd(dp);
dp = NextDevicePathNode(dp)) {
/* retry once in case of failure */
for (retry = 1; retry >= 0; retry--) {
efi_memprobe_internal(); /* sync the current map */
- status = EFI_CALL(BS->ExitBootServices, IH, mmap_key);
+ status = BS->ExitBootServices(IH, mmap_key);
if (status == EFI_SUCCESS)
break;
if (retry == 0)
TAILQ_INIT(&efi_disklist);
sz = 0;
- status = EFI_CALL(BS->LocateHandle, ByProtocol, &blkio_guid, 0, &sz, 0);
+ status = BS->LocateHandle(ByProtocol, &blkio_guid, 0, &sz, 0);
if (status == EFI_BUFFER_TOO_SMALL) {
handles = alloc(sz);
- status = EFI_CALL(BS->LocateHandle, ByProtocol, &blkio_guid,
+ status = BS->LocateHandle(ByProtocol, &blkio_guid,
0, &sz, handles);
}
if (handles == NULL || EFI_ERROR(status))
depth = 1;
for (i = 0; i < sz / sizeof(EFI_HANDLE); i++) {
- status = EFI_CALL(BS->HandleProtocol, handles[i], &blkio_guid,
+ status = BS->HandleProtocol(handles[i], &blkio_guid,
(void **)&blkio);
if (EFI_ERROR(status))
panic("BS->HandleProtocol() returns %d", status);
if (efi_bootdp == NULL || depth == -1 || bootdev != 0)
goto next;
- status = EFI_CALL(BS->HandleProtocol, handles[i], &devp_guid,
+ status = BS->HandleProtocol(handles[i], &devp_guid,
(void **)&dp);
if (EFI_ERROR(status))
goto next;
EFI_STATUS status;
heap = HEAP_LIMIT;
- status = EFI_CALL(BS->AllocatePages, AllocateMaxAddress, EfiLoaderData,
+ status = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData,
EFI_SIZE_TO_PAGES(heapsiz), &heap);
if (status != EFI_SUCCESS)
panic("BS->AllocatePages()");
addr = 0x10000000ULL; /* Below 256MB */
int error;
- status = EFI_CALL(BS->AllocatePages, AllocateMaxAddress, EfiLoaderData,
+ status = BS->AllocatePages(AllocateMaxAddress, EfiLoaderData,
EFI_SIZE_TO_PAGES(KERN_LOADSPACE_SIZE), &addr);
if (status != EFI_SUCCESS)
panic("BS->AllocatePages()");
free((void *)bios_efiinfo.mmap_start, bios_efiinfo.mmap_size);
siz = 0;
- status = EFI_CALL(BS->GetMemoryMap, &siz, NULL, &mapkey, &mmsiz,
- &mmver);
+ status = BS->GetMemoryMap(&siz, NULL, &mapkey, &mmsiz, &mmver);
if (status != EFI_BUFFER_TOO_SMALL)
panic("cannot get the size of memory map");
mm0 = alloc(siz);
- status = EFI_CALL(BS->GetMemoryMap, &siz, mm0, &mapkey, &mmsiz, &mmver);
+ status = BS->GetMemoryMap(&siz, mm0, &mapkey, &mmsiz, &mmver);
if (status != EFI_SUCCESS)
panic("cannot get the memory map");
n = siz / mmsiz;
EFI_STATUS status;
conout = ST->ConOut;
- status = EFI_CALL(BS->LocateProtocol, &con_guid, NULL,
- (void **)&conctrl);
+ status = BS->LocateProtocol(&con_guid, NULL, (void **)&conctrl);
if (status == EFI_SUCCESS)
- (void)EFI_CALL(conctrl->SetMode, conctrl,
- EfiConsoleControlScreenText);
+ conctrl->SetMode(conctrl, EfiConsoleControlScreenText);
mode80x25 = -1;
mode100x31 = -1;
for (i = 0; i < conout->Mode->MaxMode; i++) {
- status = EFI_CALL(conout->QueryMode, conout, i, &cols, &rows);
+ status = conout->QueryMode(conout, i, &cols, &rows);
if (EFI_ERROR(status))
continue;
if (mode80x25 < 0 && cols == 80 && rows == 25)
}
}
if (mode100x31 >= 0)
- EFI_CALL(conout->SetMode, conout, mode100x31);
+ conout->SetMode(conout, mode100x31);
else if (mode80x25 >= 0)
- EFI_CALL(conout->SetMode, conout, mode80x25);
+ conout->SetMode(conout, mode80x25);
conin = ST->ConIn;
efi_video_reset();
}
static void
efi_video_reset(void)
{
- EFI_CALL(conout->EnableCursor, conout, TRUE);
- EFI_CALL(conout->SetAttribute, conout,
- EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK));
- EFI_CALL(conout->ClearScreen, conout);
+ conout->EnableCursor(conout, TRUE);
+ conout->SetAttribute(conout, EFI_TEXT_ATTR(EFI_LIGHTGRAY, EFI_BLACK));
+ conout->ClearScreen(conout);
}
void
return (r);
}
- status = EFI_CALL(conin->ReadKeyStroke, conin, &key);
+ status = conin->ReadKeyStroke(conin, &key);
while (status == EFI_NOT_READY || key.UnicodeChar == 0) {
if (dev & 0x80)
return (0);
- EFI_CALL(BS->WaitForEvent, 1, &conin->WaitForKey, &dummy);
- status = EFI_CALL(conin->ReadKeyStroke, conin, &key);
+ BS->WaitForEvent(1, &conin->WaitForKey, &dummy);
+ status = conin->ReadKeyStroke(conin, &key);
}
if (dev & 0x80)
buf[0] = c;
buf[1] = 0;
- EFI_CALL(conout->OutputString, conout, buf);
+ conout->OutputString(conout, buf);
}
int
cn->cn_dev = makedev(8, 0);
sz = 0;
- status = EFI_CALL(BS->LocateHandle, ByProtocol, &serio_guid, 0, &sz, 0);
+ status = BS->LocateHandle(ByProtocol, &serio_guid, 0, &sz, 0);
if (status == EFI_BUFFER_TOO_SMALL) {
handles = alloc(sz);
- status = EFI_CALL(BS->LocateHandle, ByProtocol, &serio_guid,
+ status = BS->LocateHandle(ByProtocol, &serio_guid,
0, &sz, handles);
}
if (handles == NULL || EFI_ERROR(status)) {
* UID 0-3 map to legacy COM[1-4] and they use the legacy
* port address.
*/
- status = EFI_CALL(BS->HandleProtocol, handles[i], &devp_guid,
+ status = BS->HandleProtocol(handles[i], &devp_guid,
(void **)&dp0);
if (EFI_ERROR(status))
continue;
continue;
/* Prepare SERIAL_IO_INTERFACE */
- status = EFI_CALL(BS->HandleProtocol, handles[i], &serio_guid,
+ status = BS->HandleProtocol(handles[i], &serio_guid,
(void **)&serio);
if (EFI_ERROR(status))
continue;
return pio_comspeed(dev, sp);
if (serio->Mode->BaudRate != sp) {
- status = EFI_CALL(serio->SetAttributes, serio,
- sp, serio->Mode->ReceiveFifoDepth,
+ status = serio->SetAttributes(serio, sp,
+ serio->Mode->ReceiveFifoDepth,
serio->Mode->Timeout, serio->Mode->Parity,
serio->Mode->DataBits, serio->Mode->StopBits);
if (EFI_ERROR(status)) {
for (;;) {
sz = 1;
- status = EFI_CALL(serio->Read, serio, &sz, &buf);
+ status = serio->Read(serio, &sz, &buf);
if (status == EFI_SUCCESS && sz > 0)
break;
if (status != EFI_TIMEOUT && EFI_ERROR(status))
}
serio = serios[minor(dev)];
buf = c;
- EFI_CALL(serio->Write, serio, &sz, &buf);
+ serio->Write(serio, &sz, &buf);
}
/***********************************************************************
{
EFI_STATUS status;
- status = EFI_CALL(gop->SetMode, gop, mode);
+ status = gop->SetMode(gop, mode);
if (EFI_ERROR(status) || gop->Mode->Mode != mode)
printf("GOP SetMode() failed (%d)\n", status);
/*
* Frame buffer
*/
- status = EFI_CALL(BS->LocateProtocol, &gop_guid, NULL,
- (void **)&gop);
+ status = BS->LocateProtocol(&gop_guid, NULL, (void **)&gop);
if (!EFI_ERROR(status)) {
if (gopmode < 0) {
for (i = 0; i < gop->Mode->MaxMode; i++) {
- status = EFI_CALL(gop->QueryMode, gop,
- i, &sz, &gopi);
+ status = gop->QueryMode(gop, i, &sz, &gopi);
if (EFI_ERROR(status))
continue;
gopsiz = gopi->HorizontalResolution *
printf("Hit any key to reboot\n");
efi_cons_getc(0);
#endif
- EFI_CALL(RS->ResetSystem, EfiResetCold, EFI_SUCCESS, 0, NULL);
+ RS->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
for (;;)
continue;
}
};
#define isleap(_y) (((_y) % 4) == 0 && (((_y) % 100) != 0 || ((_y) % 400) == 0))
- EFI_CALL(ST->RuntimeServices->GetTime, &t, NULL);
+ ST->RuntimeServices->GetTime(&t, NULL);
/* Calc days from UNIX epoch */
r = (t.Year - 1970) * 365;
int
Xexit_efi(void)
{
- EFI_CALL(BS->Exit, IH, 0, 0, NULL);
+ BS->Exit(IH, 0, 0, NULL);
for (;;)
continue;
return (0);
mode = strtol(cmd.argv[1], NULL, 10);
if (0 <= mode && mode < nitems(efi_video) &&
efi_video[mode].cols > 0) {
- EFI_CALL(conout->SetMode, conout, mode);
+ conout->SetMode(conout, mode);
efi_video_reset();
}
} else {
int
Xpoweroff_efi(void)
{
- EFI_CALL(RS->ResetSystem, EfiResetShutdown, EFI_SUCCESS, 0, NULL);
+ RS->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
return (0);
}
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION
*gopi;
- status = EFI_CALL(BS->LocateProtocol, &gop_guid, NULL,
- (void **)&gop);
+ status = BS->LocateProtocol(&gop_guid, NULL, (void **)&gop);
if (EFI_ERROR(status))
return (0);
if (cmd.argc >= 2) {
mode = strtol(cmd.argv[1], NULL, 10);
if (0 <= mode && mode < gop->Mode->MaxMode) {
- status = EFI_CALL(gop->QueryMode, gop, mode,
- &sz, &gopi);
+ status = gop->QueryMode(gop, mode, &sz, &gopi);
if (!EFI_ERROR(status)) {
if (efi_gop_setmode(mode) == EFI_SUCCESS)
gopmode = mode;
}
} else {
for (i = 0; i < gop->Mode->MaxMode; i++) {
- status = EFI_CALL(gop->QueryMode, gop, i, &sz, &gopi);
+ status = gop->QueryMode(gop, i, &sz, &gopi);
if (EFI_ERROR(status))
continue;
printf("Mode %d: %d x %d (stride = %d)\n", i,
-/* $OpenBSD: efipxe.c,v 1.9 2021/03/11 11:16:55 jsg Exp $ */
+/* $OpenBSD: efipxe.c,v 1.10 2021/06/07 00:04:20 krw Exp $ */
/*
* Copyright (c) 2017 Patrick Wildt <patrick@blueri.se>
*
#include <efi.h>
#include <efiapi.h>
-#include "eficall.h"
#include "efiboot.h"
extern EFI_BOOT_SERVICES *BS;
if (efi_bootdp == NULL)
return;
- status = EFI_CALL(BS->LocateHandleBuffer, ByProtocol, &pxe_guid, NULL,
- &nhandles, &handles);
+ status = BS->LocateHandleBuffer(ByProtocol, &pxe_guid, NULL, &nhandles,
+ &handles);
if (status != EFI_SUCCESS)
return;
for (i = 0; i < nhandles; i++) {
EFI_PXE_BASE_CODE_DHCPV4_PACKET *dhcp;
- status = EFI_CALL(BS->HandleProtocol, handles[i],
- &devp_guid, (void **)&dp0);
+ status = BS->HandleProtocol(handles[i], &devp_guid,
+ (void **)&dp0);
if (status != EFI_SUCCESS)
continue;
if (depth == -1 || efi_device_path_ncmp(efi_bootdp, dp0, depth))
continue;
- status = EFI_CALL(BS->HandleProtocol, handles[i], &pxe_guid,
+ status = BS->HandleProtocol(handles[i], &pxe_guid,
(void **)&pxe);
if (status != EFI_SUCCESS)
continue;
return ENOMEM;
memset(tftpfile, 0, sizeof(*tftpfile));
- status = EFI_CALL(PXE->Mtftp, PXE, EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
- NULL, FALSE, &size, NULL, &servip, path, NULL, FALSE);
+ status = PXE->Mtftp(PXE, EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE, NULL,
+ FALSE, &size, NULL, &servip, path, NULL, FALSE);
if (status != EFI_SUCCESS) {
free(tftpfile, sizeof(*tftpfile));
return ENOENT;
if (tftpfile->inbufsize == 0)
goto out;
- status = EFI_CALL(BS->AllocatePages, AllocateAnyPages, EfiLoaderData,
+ status = BS->AllocatePages(AllocateAnyPages, EfiLoaderData,
EFI_SIZE_TO_PAGES(tftpfile->inbufsize), &addr);
if (status != EFI_SUCCESS) {
free(tftpfile, sizeof(*tftpfile));
}
tftpfile->inbuf = (unsigned char *)((paddr_t)addr);
- status = EFI_CALL(PXE->Mtftp, PXE, EFI_PXE_BASE_CODE_TFTP_READ_FILE,
+ status = PXE->Mtftp(PXE, EFI_PXE_BASE_CODE_TFTP_READ_FILE,
tftpfile->inbuf, FALSE, &size, NULL, &servip, path, NULL, FALSE);
if (status != EFI_SUCCESS) {
free(tftpfile, sizeof(*tftpfile));
struct tftp_handle *tftpfile = f->f_fsdata;
if (tftpfile->inbuf != NULL)
- EFI_CALL(BS->FreePages, (paddr_t)tftpfile->inbuf,
+ BS->FreePages((paddr_t)tftpfile->inbuf,
EFI_SIZE_TO_PAGES(tftpfile->inbufsize));
free(tftpfile, sizeof(*tftpfile));
return 0;