]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/boot/efi/util.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / boot / efi / util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /*
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU Lesser General Public License as published by
5 * the Free Software Foundation; either version 2.1 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * Copyright (C) 2012-2013 Kay Sievers <kay@vrfy.org>
14 * Copyright (C) 2012 Harald Hoyer <harald@redhat.com>
15 */
16
17 #ifndef __SDBOOT_UTIL_H
18 #define __SDBOOT_UTIL_H
19
20 #include <efi.h>
21 #include <efilib.h>
22
23 #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
24
25 static inline const CHAR16 *yes_no(BOOLEAN b) {
26 return b ? L"yes" : L"no";
27 }
28
29 EFI_STATUS parse_boolean(CHAR8 *v, BOOLEAN *b);
30
31 UINT64 ticks_read(void);
32 UINT64 ticks_freq(void);
33 UINT64 time_usec(void);
34
35 EFI_STATUS efivar_set(CHAR16 *name, CHAR16 *value, BOOLEAN persistent);
36 EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 *buf, UINTN size, BOOLEAN persistent);
37 EFI_STATUS efivar_set_int(CHAR16 *name, UINTN i, BOOLEAN persistent);
38 VOID efivar_set_time_usec(CHAR16 *name, UINT64 usec);
39
40 EFI_STATUS efivar_get(CHAR16 *name, CHAR16 **value);
41 EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 **buffer, UINTN *size);
42 EFI_STATUS efivar_get_int(CHAR16 *name, UINTN *i);
43
44 CHAR8 *strchra(CHAR8 *s, CHAR8 c);
45 CHAR16 *stra_to_path(CHAR8 *stra);
46 CHAR16 *stra_to_str(CHAR8 *stra);
47
48 INTN file_read(EFI_FILE_HANDLE dir, CHAR16 *name, UINTN off, UINTN size, CHAR8 **content);
49 #endif