summaryrefslogtreecommitdiff
path: root/lib/uefi.c3l/src/protocol/variable.c3
blob: bf5175bd73707b23d5e7a03f6881d932d11df278 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module uefi::proto::variable;
import uefi;


/* 8.2.) Variable services */
/* 8.2.1.) GetVariable() */
alias FnGetVariable = fn EfiStatus(EfiStringRaw, EfiGuid*, uint*, usz*, void*);

/* Variable Attributes */
enum EfiVarAttr : uint (uint raw) // TODO: Add `inline` inside parens when supported
{
	NON_VOLATILE                          { 0x0000_0001 },
	BOOTSERVICE_ACCESS                    { 0x0000_0002 },
	RUNTIME_ACCESS                        { 0x0000_0004 },
	HARDWARE_ERROR_RECORD                 { 0x0000_0008 },
	HR                                    { 0x0000_0008 }, /* spec notes aliasing of this to above */
	RESERVED                              { 0x0000_0010 },
	TIME_BASED_AUTHENTICATED_WRITE_ACCESS { 0x0000_0020 },
	APPEND_WRITE                          { 0x0000_0040 },
	ENHANCED_AUTHENTICATED_ACCESS         { 0x0000_0080 },
}

struct VariableAuthentication3CertId
{
	char type;
	uint id_size;
	/* implied to follow:  char id[id_size]; */
}

/* 8.2.2.) GetNextVariableName() */
alias FnGetNextVariableName = fn EfiStatus(usz*, EfiStringRaw, EfiGuid*);

/* 8.2.3.) SetVariable() */
alias FnSetVariable = fn EfiStatus(EfiStringRaw, EfiGuid*, uint, usz, void*);

/* TODO: Too much extra complexity to use right now. Add later. */
/* struct VariableAuthentication2
{
    EfiTime                     timestamp;
    WinCertificateUefiGuid      auth_info;
} */

const char EFI_VARIABLE_AUTHENTICATION_3_TIMESTAMP_TYPE = 1;
const char EFI_VARIABLE_AUTHENTICATION_3_NONCE_TYPE     = 2;
struct VariableAuthentication3
{
	char version;
	char type;
	uint metadata_size;
	uint flags;
}

struct VariableAuthentication3Nonce
{
	uint nonce_size;
	/* implied to follow:  char nonce[nonce_size]; */
}

/* 8.2.4.) QueryVariableInfo() */
alias FnQueryVariableInfo = fn EfiStatus(uint, ulong*, ulong*, ulong*);

/* 8.2.7.2.) Hardware Error Record Variables */
const EfiGuid EFI_HARDWARE_ERROR_VARIABLE = {
	0x414e6bdd,
	0xe47b,
	0x47cc,
	{ 0xb2, 0x44, 0xbb, 0x61, 0x02, 0x0c, 0xf5, 0x16 }
};