Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: src/platform/vboot_reference/tests/rollback_index_mock.c

Issue 2344002: Add recovery mode protection to new NVRAM locking scheme. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: typo in comment Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/platform/vboot_reference/vboot_firmware/include/rollback_index.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Mock rollback index library for testing. 5 * Mock rollback index library for testing.
6 */ 6 */
7 7
8 #include "rollback_index.h" 8 #include "rollback_index.h"
9 9
10 #include <stdint.h> 10 #include <stdint.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 12
13 uint16_t g_firmware_key_version = 0; 13 uint16_t g_firmware_key_version = 0;
14 uint16_t g_firmware_version = 0; 14 uint16_t g_firmware_version = 0;
15 uint16_t g_kernel_key_version = 0; 15 uint16_t g_kernel_key_version = 0;
16 uint16_t g_kernel_version = 0; 16 uint16_t g_kernel_version = 0;
17 17
18 void SetupTPM(void) { 18 void SetupTPM(void) {
19 #ifndef NDEBUG 19 #ifndef NDEBUG
20 debug("Rollback Index Library Mock: TPM initialized.\n"); 20 debug("Rollback Index Library Mock: TPM initialized.\n");
21 #endif 21 #endif
22 } 22 }
23 23
24 uint16_t GetStoredVersion(int type) { 24 void GetStoredVersions(int type, uint16_t* key_version, uint16_t* version) {
25 switch (type) { 25 switch (type) {
26 case FIRMWARE_KEY_VERSION: 26 case FIRMWARE_VERSIONS:
27 return g_firmware_key_version; 27 *key_version = g_firmware_key_version;
28 *version = g_firmware_version;
28 break; 29 break;
29 case FIRMWARE_VERSION: 30 case KERNEL_VERSIONS:
30 return g_firmware_version; 31 *key_version = g_kernel_key_version;
31 break; 32 *version = g_kernel_version;
32 case KERNEL_KEY_VERSION:
33 return g_kernel_key_version;
34 break;
35 case KERNEL_VERSION:
36 return g_kernel_version;
37 break; 33 break;
38 } 34 }
39 return 0;
40 } 35 }
41 36
42 int WriteStoredVersion(int type, uint16_t version) { 37 int WriteStoredVersions(int type, uint16_t key_version, uint16_t version) {
43 switch (type) { 38 switch (type) {
44 case FIRMWARE_KEY_VERSION: 39 case FIRMWARE_VERSIONS:
45 g_firmware_key_version = version; 40 g_firmware_key_version = key_version;
46 break;
47 case FIRMWARE_VERSION:
48 g_firmware_version = version; 41 g_firmware_version = version;
49 break; 42 break;
50 case KERNEL_KEY_VERSION: 43 case KERNEL_VERSIONS:
51 g_kernel_key_version = version; 44 g_kernel_key_version = key_version;
52 break;
53 case KERNEL_VERSION:
54 g_kernel_version = version; 45 g_kernel_version = version;
55 break; 46 break;
56 } 47 }
57 #ifndef NDEBUG 48 #ifndef NDEBUG
58 debug("Rollback Index Library Mock: Stored Version written.\n"); 49 debug("Rollback Index Library Mock: Stored Versions written.\n");
59 #endif 50 #endif
60 return 1; 51 return 1;
61 } 52 }
62 53
63 void LockFirmwareVersions() { 54 void LockFirmwareVersions() {
64 #ifndef NDEBUG 55 #ifndef NDEBUG
65 debug("Rollback Index Library Mock: Firmware Versions Locked.\n"); 56 debug("Rollback Index Library Mock: Firmware Versions Locked.\n");
66 #endif 57 #endif
67 } 58 }
68 void LockKernelVersionsByLockingPP() { 59 void LockKernelVersionsByLockingPP() {
69 #ifndef NDEBUG 60 #ifndef NDEBUG
70 debug("Rollback Index Library Mock: Kernel Versions Locked.\n"); 61 debug("Rollback Index Library Mock: Kernel Versions Locked.\n");
71 #endif 62 #endif
72 } 63 }
OLDNEW
« no previous file with comments | « no previous file | src/platform/vboot_reference/vboot_firmware/include/rollback_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698