chiark / gitweb /
efaafd74928803f18f7a4e07b8c624b04ef0e3b1
[elogind.git] / src / sd-boot / 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 UINT64 ticks_read(void);
27 UINT64 ticks_freq(void);
28 UINT64 time_usec(void);
29
30 EFI_STATUS efivar_set(CHAR16 *name, CHAR16 *value, BOOLEAN persistent);
31 EFI_STATUS efivar_set_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 *buf, UINTN size, BOOLEAN persistent);
32 EFI_STATUS efivar_set_int(CHAR16 *name, UINTN i, BOOLEAN persistent);
33 VOID efivar_set_time_usec(CHAR16 *name, UINT64 usec);
34
35 EFI_STATUS efivar_get(CHAR16 *name, CHAR16 **value);
36 EFI_STATUS efivar_get_raw(const EFI_GUID *vendor, CHAR16 *name, CHAR8 **buffer, UINTN *size);
37 EFI_STATUS efivar_get_int(CHAR16 *name, UINTN *i);
38
39 CHAR8 *strchra(CHAR8 *s, CHAR8 c);
40 CHAR16 *stra_to_path(CHAR8 *stra);
41 CHAR16 *stra_to_str(CHAR8 *stra);
42
43 INTN file_read(EFI_FILE_HANDLE dir, CHAR16 *name, UINTN off, UINTN size, CHAR8 **content);
44 #endif