efivar.h revision 1.1 1 1.1 jakllsch /* $NetBSD: efivar.h,v 1.1 2014/04/01 16:16:07 jakllsch Exp $ */
2 1.1 jakllsch
3 1.1 jakllsch /*++
4 1.1 jakllsch
5 1.1 jakllsch Copyright (c) 1998 Intel Corporation
6 1.1 jakllsch
7 1.1 jakllsch Module Name:
8 1.1 jakllsch
9 1.1 jakllsch Abstract:
10 1.1 jakllsch
11 1.1 jakllsch
12 1.1 jakllsch
13 1.1 jakllsch Revision History
14 1.1 jakllsch
15 1.1 jakllsch --*/
16 1.1 jakllsch
17 1.1 jakllsch
18 1.1 jakllsch
19 1.1 jakllsch //
20 1.1 jakllsch // The variable store protocol interface is specific to the reference
21 1.1 jakllsch // implementation. The initialization code adds variable store devices
22 1.1 jakllsch // to the system, and the FW connects to the devices to provide the
23 1.1 jakllsch // variable store interfaces through these devices.
24 1.1 jakllsch //
25 1.1 jakllsch
26 1.1 jakllsch //
27 1.1 jakllsch // Variable Store Device protocol
28 1.1 jakllsch //
29 1.1 jakllsch
30 1.1 jakllsch #define VARIABLE_STORE_PROTOCOL \
31 1.1 jakllsch { 0xf088cd91, 0xa046, 0x11d2, {0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
32 1.1 jakllsch
33 1.1 jakllsch INTERFACE_DECL(_EFI_VARIABLE_STORE);
34 1.1 jakllsch
35 1.1 jakllsch typedef
36 1.1 jakllsch EFI_STATUS
37 1.1 jakllsch (EFIAPI *EFI_STORE_CLEAR) (
38 1.1 jakllsch IN struct _EFI_VARIABLE_STORE *This,
39 1.1 jakllsch IN UINTN BankNo,
40 1.1 jakllsch IN OUT VOID *Scratch
41 1.1 jakllsch );
42 1.1 jakllsch
43 1.1 jakllsch
44 1.1 jakllsch typedef
45 1.1 jakllsch EFI_STATUS
46 1.1 jakllsch (EFIAPI *EFI_STORE_READ) (
47 1.1 jakllsch IN struct _EFI_VARIABLE_STORE *This,
48 1.1 jakllsch IN UINTN BankNo,
49 1.1 jakllsch IN UINTN Offset,
50 1.1 jakllsch IN UINTN BufferSize,
51 1.1 jakllsch OUT VOID *Buffer
52 1.1 jakllsch );
53 1.1 jakllsch
54 1.1 jakllsch typedef
55 1.1 jakllsch EFI_STATUS
56 1.1 jakllsch (EFIAPI *EFI_STORE_UPDATE) (
57 1.1 jakllsch IN struct _EFI_VARIABLE_STORE *This,
58 1.1 jakllsch IN UINTN BankNo,
59 1.1 jakllsch IN UINTN Offset,
60 1.1 jakllsch IN UINTN BufferSize,
61 1.1 jakllsch IN VOID *Buffer
62 1.1 jakllsch );
63 1.1 jakllsch
64 1.1 jakllsch typedef
65 1.1 jakllsch EFI_STATUS
66 1.1 jakllsch (EFIAPI *EFI_STORE_SIZE) (
67 1.1 jakllsch IN struct _EFI_VARIABLE_STORE *This,
68 1.1 jakllsch IN UINTN NoBanks
69 1.1 jakllsch );
70 1.1 jakllsch
71 1.1 jakllsch typedef
72 1.1 jakllsch EFI_STATUS
73 1.1 jakllsch (EFIAPI *EFI_TRANSACTION_UPDATE) (
74 1.1 jakllsch IN struct _EFI_VARIABLE_STORE *This,
75 1.1 jakllsch IN UINTN BankNo,
76 1.1 jakllsch IN VOID *NewContents
77 1.1 jakllsch );
78 1.1 jakllsch
79 1.1 jakllsch typedef struct _EFI_VARIABLE_STORE {
80 1.1 jakllsch
81 1.1 jakllsch //
82 1.1 jakllsch // Number of banks and bank size
83 1.1 jakllsch //
84 1.1 jakllsch
85 1.1 jakllsch UINT32 Attributes;
86 1.1 jakllsch UINT32 BankSize;
87 1.1 jakllsch UINT32 NoBanks;
88 1.1 jakllsch
89 1.1 jakllsch //
90 1.1 jakllsch // Functions to access the storage banks
91 1.1 jakllsch //
92 1.1 jakllsch
93 1.1 jakllsch EFI_STORE_CLEAR ClearStore;
94 1.1 jakllsch EFI_STORE_READ ReadStore;
95 1.1 jakllsch EFI_STORE_UPDATE UpdateStore;
96 1.1 jakllsch EFI_STORE_SIZE SizeStore OPTIONAL;
97 1.1 jakllsch EFI_TRANSACTION_UPDATE TransactionUpdate OPTIONAL;
98 1.1 jakllsch
99 1.1 jakllsch } EFI_VARIABLE_STORE;
100 1.1 jakllsch
101 1.1 jakllsch
102 1.1 jakllsch //
103 1.1 jakllsch //
104 1.1 jakllsch // ClearStore() - A function to clear the requested storage bank. A cleared
105 1.1 jakllsch // bank contains all "on" bits.
106 1.1 jakllsch //
107 1.1 jakllsch // ReadStore() - Read data from the requested store.
108 1.1 jakllsch //
109 1.1 jakllsch // UpdateStore() - Updates data on the requested store. The FW will only
110 1.1 jakllsch // ever issue updates to clear bits in the store. Updates must be
111 1.1 jakllsch // performed in LSb to MSb order of the update buffer.
112 1.1 jakllsch //
113 1.1 jakllsch // SizeStore() - An optional function for non-runtime stores that can be
114 1.1 jakllsch // dynamically sized. The FW will only ever increase or decrease the store
115 1.1 jakllsch // by 1 banksize at a time, and it is always adding or removing a bank from
116 1.1 jakllsch // the end of the store.
117 1.1 jakllsch //
118 1.1 jakllsch // By default the FW will update variables and storage banks in an
119 1.1 jakllsch // "atomic" manner by keeping 1 old copy of the data during an update,
120 1.1 jakllsch // and recovering appropiately if the power is lost during the middle
121 1.1 jakllsch // of an operation. To do this the FW needs to have multiple banks
122 1.1 jakllsch // of storage dedicated to its use. If that's not possible, the driver
123 1.1 jakllsch // can implement an atomic bank update function and the FW will allow
124 1.1 jakllsch // 1 bank in this case. (It will allow any number of banks,
125 1.1 jakllsch // but it won't require an "extra" bank to provide its bank transaction
126 1.1 jakllsch // function).
127 1.1 jakllsch //
128 1.1 jakllsch // TransactionUpdate() - An optional function that can clear & update an
129 1.1 jakllsch // entire bank in an "atomic" fashion. If the operation fails in the
130 1.1 jakllsch // middle the driver is responsible for having either the previous copy
131 1.1 jakllsch // of the bank's data or the new copy. A copy that's partially written
132 1.1 jakllsch // is not valid as internal data settings may get lost. Supply this
133 1.1 jakllsch // function only when needed.
134 1.1 jakllsch //
135 1.1 jakllsch
136