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