1*f412fd2aSLoGin #pragma once 2530d68baSNigel Croxon /*++ 3530d68baSNigel Croxon 4530d68baSNigel Croxon Copyright (c) 1998 Intel Corporation 5530d68baSNigel Croxon 6530d68baSNigel Croxon Module Name: 7530d68baSNigel Croxon 8530d68baSNigel Croxon Abstract: 9530d68baSNigel Croxon 10530d68baSNigel Croxon 11530d68baSNigel Croxon 12530d68baSNigel Croxon Revision History 13530d68baSNigel Croxon 14530d68baSNigel Croxon --*/ 15530d68baSNigel Croxon 16530d68baSNigel Croxon 17530d68baSNigel Croxon 18530d68baSNigel Croxon // 19530d68baSNigel Croxon // The variable store protocol interface is specific to the reference 20530d68baSNigel Croxon // implementation. The initialization code adds variable store devices 21530d68baSNigel Croxon // to the system, and the FW connects to the devices to provide the 22530d68baSNigel Croxon // variable store interfaces through these devices. 23530d68baSNigel Croxon // 24530d68baSNigel Croxon 25530d68baSNigel Croxon // 26530d68baSNigel Croxon // Variable Store Device protocol 27530d68baSNigel Croxon // 28530d68baSNigel Croxon 29530d68baSNigel Croxon #define VARIABLE_STORE_PROTOCOL \ 30530d68baSNigel Croxon { 0xf088cd91, 0xa046, 0x11d2, {0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} } 31530d68baSNigel Croxon 32530d68baSNigel Croxon INTERFACE_DECL(_EFI_VARIABLE_STORE); 33530d68baSNigel Croxon 34530d68baSNigel Croxon typedef 35530d68baSNigel Croxon EFI_STATUS 36530d68baSNigel Croxon (EFIAPI *EFI_STORE_CLEAR) ( 37530d68baSNigel Croxon IN struct _EFI_VARIABLE_STORE *This, 38530d68baSNigel Croxon IN UINTN BankNo, 39530d68baSNigel Croxon IN OUT VOID *Scratch 40530d68baSNigel Croxon ); 41530d68baSNigel Croxon 42530d68baSNigel Croxon 43530d68baSNigel Croxon typedef 44530d68baSNigel Croxon EFI_STATUS 45530d68baSNigel Croxon (EFIAPI *EFI_STORE_READ) ( 46530d68baSNigel Croxon IN struct _EFI_VARIABLE_STORE *This, 47530d68baSNigel Croxon IN UINTN BankNo, 48530d68baSNigel Croxon IN UINTN Offset, 49530d68baSNigel Croxon IN UINTN BufferSize, 50530d68baSNigel Croxon OUT VOID *Buffer 51530d68baSNigel Croxon ); 52530d68baSNigel Croxon 53530d68baSNigel Croxon typedef 54530d68baSNigel Croxon EFI_STATUS 55530d68baSNigel Croxon (EFIAPI *EFI_STORE_UPDATE) ( 56530d68baSNigel Croxon IN struct _EFI_VARIABLE_STORE *This, 57530d68baSNigel Croxon IN UINTN BankNo, 58530d68baSNigel Croxon IN UINTN Offset, 59530d68baSNigel Croxon IN UINTN BufferSize, 60530d68baSNigel Croxon IN VOID *Buffer 61530d68baSNigel Croxon ); 62530d68baSNigel Croxon 63530d68baSNigel Croxon typedef 64530d68baSNigel Croxon EFI_STATUS 65530d68baSNigel Croxon (EFIAPI *EFI_STORE_SIZE) ( 66530d68baSNigel Croxon IN struct _EFI_VARIABLE_STORE *This, 67530d68baSNigel Croxon IN UINTN NoBanks 68530d68baSNigel Croxon ); 69530d68baSNigel Croxon 70530d68baSNigel Croxon typedef 71530d68baSNigel Croxon EFI_STATUS 72530d68baSNigel Croxon (EFIAPI *EFI_TRANSACTION_UPDATE) ( 73530d68baSNigel Croxon IN struct _EFI_VARIABLE_STORE *This, 74530d68baSNigel Croxon IN UINTN BankNo, 75530d68baSNigel Croxon IN VOID *NewContents 76530d68baSNigel Croxon ); 77530d68baSNigel Croxon 78530d68baSNigel Croxon typedef struct _EFI_VARIABLE_STORE { 79530d68baSNigel Croxon 80530d68baSNigel Croxon // 81530d68baSNigel Croxon // Number of banks and bank size 82530d68baSNigel Croxon // 83530d68baSNigel Croxon 84530d68baSNigel Croxon UINT32 Attributes; 85530d68baSNigel Croxon UINT32 BankSize; 86530d68baSNigel Croxon UINT32 NoBanks; 87530d68baSNigel Croxon 88530d68baSNigel Croxon // 89530d68baSNigel Croxon // Functions to access the storage banks 90530d68baSNigel Croxon // 91530d68baSNigel Croxon 92530d68baSNigel Croxon EFI_STORE_CLEAR ClearStore; 93530d68baSNigel Croxon EFI_STORE_READ ReadStore; 94530d68baSNigel Croxon EFI_STORE_UPDATE UpdateStore; 95530d68baSNigel Croxon EFI_STORE_SIZE SizeStore OPTIONAL; 96530d68baSNigel Croxon EFI_TRANSACTION_UPDATE TransactionUpdate OPTIONAL; 97530d68baSNigel Croxon 98530d68baSNigel Croxon } EFI_VARIABLE_STORE; 99530d68baSNigel Croxon 100530d68baSNigel Croxon 101530d68baSNigel Croxon // 102530d68baSNigel Croxon // 103530d68baSNigel Croxon // ClearStore() - A function to clear the requested storage bank. A cleared 104530d68baSNigel Croxon // bank contains all "on" bits. 105530d68baSNigel Croxon // 106530d68baSNigel Croxon // ReadStore() - Read data from the requested store. 107530d68baSNigel Croxon // 108530d68baSNigel Croxon // UpdateStore() - Updates data on the requested store. The FW will only 109530d68baSNigel Croxon // ever issue updates to clear bits in the store. Updates must be 110530d68baSNigel Croxon // performed in LSb to MSb order of the update buffer. 111530d68baSNigel Croxon // 112530d68baSNigel Croxon // SizeStore() - An optional function for non-runtime stores that can be 113530d68baSNigel Croxon // dynamically sized. The FW will only ever increase or decrease the store 114530d68baSNigel Croxon // by 1 banksize at a time, and it is always adding or removing a bank from 115530d68baSNigel Croxon // the end of the store. 116530d68baSNigel Croxon // 117530d68baSNigel Croxon // By default the FW will update variables and storage banks in an 118530d68baSNigel Croxon // "atomic" manner by keeping 1 old copy of the data during an update, 119530d68baSNigel Croxon // and recovering appropiately if the power is lost during the middle 120530d68baSNigel Croxon // of an operation. To do this the FW needs to have multiple banks 121530d68baSNigel Croxon // of storage dedicated to its use. If that's not possible, the driver 122530d68baSNigel Croxon // can implement an atomic bank update function and the FW will allow 123530d68baSNigel Croxon // 1 bank in this case. (It will allow any number of banks, 124530d68baSNigel Croxon // but it won't require an "extra" bank to provide its bank transaction 125530d68baSNigel Croxon // function). 126530d68baSNigel Croxon // 127530d68baSNigel Croxon // TransactionUpdate() - An optional function that can clear & update an 128530d68baSNigel Croxon // entire bank in an "atomic" fashion. If the operation fails in the 129530d68baSNigel Croxon // middle the driver is responsible for having either the previous copy 130530d68baSNigel Croxon // of the bank's data or the new copy. A copy that's partially written 131530d68baSNigel Croxon // is not valid as internal data settings may get lost. Supply this 132530d68baSNigel Croxon // function only when needed. 133530d68baSNigel Croxon // 134530d68baSNigel Croxon 135