efivar.h 3.8 KB

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