]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/boot/efi/util.h
Merge pull request #9832 from yuwata/fix-9831
[thirdparty/systemd.git] / src / boot / efi / util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <efi.h>
5 #include <efilib.h>
6
7 #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
8
9 static inline const CHAR16 *yes_no(BOOLEAN b) {
10 return b ? L"yes" : L"no";
11 }
12
13 EFI_STATUS parse_boolean(CHAR8 *v, BOOLEAN *b);
14
15 UINT64 ticks_read(void);
16 UINT64 ticks_freq(void);
17 UINT64 time_usec(void);
18
19 EFI_STATUS efivar_set(CHAR16 *name, CHAR16 *value, BOOLEAN persistent);
20 EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 *buf, UINTN size, BOOLEAN persistent);
21 EFI_STATUS efivar_set_int(CHAR16 *name, UINTN i, BOOLEAN persistent);
22 VOID efivar_set_time_usec(CHAR16 *name, UINT64 usec);
23
24 EFI_STATUS efivar_get(CHAR16 *name, CHAR16 **value);
25 EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 **buffer, UINTN *size);
26 EFI_STATUS efivar_get_int(CHAR16 *name, UINTN *i);
27
28 CHAR8 *strchra(CHAR8 *s, CHAR8 c);
29 CHAR16 *stra_to_path(CHAR8 *stra);
30 CHAR16 *stra_to_str(CHAR8 *stra);
31
32 EFI_STATUS file_read(EFI_FILE_HANDLE dir, CHAR16 *name, UINTN off, UINTN size, CHAR8 **content, UINTN *content_size);
33
34 static inline void FreePoolp(void *p) {
35 FreePool(*(void**) p);
36 }
37
38 #define _cleanup_(x) __attribute__((cleanup(x)))
39 #define _cleanup_freepool_ _cleanup_(FreePoolp)