| OLD | NEW |
| (Empty) | |
| 1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. |
| 4 */ |
| 5 |
| 6 /* Non-volatile storage routines. |
| 7 */ |
| 8 |
| 9 #ifndef VBOOT_REFERENCE_NVSTORAGE_H_ |
| 10 #define VBOOT_REFERENCE_NVSTORAGE_H_ |
| 11 |
| 12 #define NV_BLOCK_SIZE 16 /* Size of NV storage block in bytes */ |
| 13 |
| 14 typedef struct VbNvContext { |
| 15 /* Raw NV data. Caller must fill this before calling VbNvOpen(). */ |
| 16 uint8_t raw[NV_BLOCK_SIZE]; |
| 17 /* Flag indicating whether raw data has changed. Set by VbNvClose() if |
| 18 * the raw data has changed and needs to be stored to the underlying |
| 19 * non-volatile data store. */ |
| 20 int raw_changed; |
| 21 |
| 22 /* Internal data for NV storage routines. Caller should not touch |
| 23 * these fields. */ |
| 24 int regenerate_crc; |
| 25 |
| 26 } VbNvContext; |
| 27 |
| 28 |
| 29 /* Parameter type for VbNvGet(), VbNvSet(). */ |
| 30 typedef enum VbNvParam { |
| 31 VBNV_FIRMWARE_SETTINGS_RESET = 0, |
| 32 VBNV_KERNEL_SETTINGS_RESET, |
| 33 VBNV_DEBUG_RESET_MODE, |
| 34 VBNV_TRY_B_COUNT, |
| 35 VBNV_RECOVERY_REQUEST, |
| 36 VBNV_LOCALIZATION_INDEX, |
| 37 VBNV_KERNEL_FIELD, |
| 38 } VbNvParam; |
| 39 |
| 40 |
| 41 /* Initialize the NV storage library. This must be called before any |
| 42 * other functions in this library. Returns 0 if success, non-zero if |
| 43 * error. */ |
| 44 int VbNvOpen(VbNvContext* context); |
| 45 |
| 46 /* Clean up and flush changes back to the raw data. This must be |
| 47 * called after other functions in this library. Caller must check |
| 48 * context.raw_changed after calling tis function. Returns 0 if |
| 49 * success, non-zero if error. */ |
| 50 int VbNvClose(VbNvContext* context); |
| 51 |
| 52 /* Read a NV storage parameter into *dest. Returns 0 if success, |
| 53 * non-zero if error. */ |
| 54 int VbNvGet(VbNvContext* context, VbNvParam param, uint32_t* dest); |
| 55 |
| 56 /* Set a NV storage param to a new value. Returns 0 if success, |
| 57 * non-zero if error. */ |
| 58 int VbNvSet(VbNvContext* context, VbNvParam param, uint32_t value); |
| 59 |
| 60 |
| 61 #endif /* VBOOT_REFERENCE_NVSTORAGE_H_ */ |
| OLD | NEW |