summaryrefslogtreecommitdiff
path: root/boot/efi/protocol.c
blob: b033022edcb9f56dc1705e0be10d4283ab728353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <efi/error.h>

#include "kjarna_efi.h"

void *efi_get_protocol(EFI_HANDLE handle, EFI_GUID *guid)
{
	void *protocol;

	efi_errno = gBS->OpenProtocol(
			handle,
			guid,
			&protocol,
			efi_context->handle,
			nullptr,
			EFI_OPEN_PROTOCOL_GET_PROTOCOL);

	return !EFI_ERROR(efi_errno) ? protocol : nullptr;
}

void efi_close_protocol(EFI_HANDLE handle, EFI_GUID *guid)
{
	efi_errno = gBS->CloseProtocol(
			handle,
			guid,
			efi_context->handle,
			nullptr);
}