]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/boot/efi/util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
7 #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
8 #define OFFSETOF(x,y) __builtin_offsetof(x,y)
10 static inline UINTN
ALIGN_TO(UINTN l
, UINTN ali
) {
11 return ((l
+ ali
- 1) & ~(ali
- 1));
14 static inline const CHAR16
*yes_no(BOOLEAN b
) {
15 return b
? L
"yes" : L
"no";
18 EFI_STATUS
parse_boolean(const CHAR8
*v
, BOOLEAN
*b
);
20 UINT64
ticks_read(void);
21 UINT64
ticks_freq(void);
22 UINT64
time_usec(void);
24 EFI_STATUS
efivar_set(const CHAR16
*name
, const CHAR16
*value
, BOOLEAN persistent
);
25 EFI_STATUS
efivar_set_raw(const EFI_GUID
*vendor
, const CHAR16
*name
, const VOID
*buf
, UINTN size
, BOOLEAN persistent
);
26 EFI_STATUS
efivar_set_int(CHAR16
*name
, UINTN i
, BOOLEAN persistent
);
27 VOID
efivar_set_time_usec(CHAR16
*name
, UINT64 usec
);
29 EFI_STATUS
efivar_get(const CHAR16
*name
, CHAR16
**value
);
30 EFI_STATUS
efivar_get_raw(const EFI_GUID
*vendor
, const CHAR16
*name
, CHAR8
**buffer
, UINTN
*size
);
31 EFI_STATUS
efivar_get_int(const CHAR16
*name
, UINTN
*i
);
33 CHAR8
*strchra(CHAR8
*s
, CHAR8 c
);
34 CHAR16
*stra_to_path(CHAR8
*stra
);
35 CHAR16
*stra_to_str(CHAR8
*stra
);
37 EFI_STATUS
file_read(EFI_FILE_HANDLE dir
, const CHAR16
*name
, UINTN off
, UINTN size
, CHAR8
**content
, UINTN
*content_size
);
39 static inline void FreePoolp(void *p
) {
40 void *q
= *(void**) p
;
48 #define _cleanup_(x) __attribute__((__cleanup__(x)))
49 #define _cleanup_freepool_ _cleanup_(FreePoolp)
51 static inline void FileHandleClosep(EFI_FILE_HANDLE
*handle
) {
55 uefi_call_wrapper((*handle
)->Close
, 1, *handle
);
58 extern const EFI_GUID loader_guid
;
60 #define UINTN_MAX (~(UINTN)0)
61 #define INTN_MAX ((INTN)(UINTN_MAX>>1))
63 #define TAKE_PTR(ptr) \
65 typeof(ptr) _ptr_ = (ptr); \
70 EFI_STATUS
log_oom(void);