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

Side by Side Diff: tests/rollback_index_mock.c

Issue 2735004: Uses TPM return codes. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Created 10 years, 6 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 | 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 int 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 return 0;
22 } 23 }
23 24
24 void GetStoredVersions(int type, uint16_t* key_version, uint16_t* version) { 25 int GetStoredVersions(int type, uint16_t* key_version, uint16_t* version) {
25 switch (type) { 26 switch (type) {
26 case FIRMWARE_VERSIONS: 27 case FIRMWARE_VERSIONS:
27 *key_version = g_firmware_key_version; 28 *key_version = g_firmware_key_version;
28 *version = g_firmware_version; 29 *version = g_firmware_version;
29 break; 30 break;
30 case KERNEL_VERSIONS: 31 case KERNEL_VERSIONS:
31 *key_version = g_kernel_key_version; 32 *key_version = g_kernel_key_version;
32 *version = g_kernel_version; 33 *version = g_kernel_version;
33 break; 34 break;
34 } 35 }
36 return 0;
35 } 37 }
36 38
37 int WriteStoredVersions(int type, uint16_t key_version, uint16_t version) { 39 int WriteStoredVersions(int type, uint16_t key_version, uint16_t version) {
38 switch (type) { 40 switch (type) {
39 case FIRMWARE_VERSIONS: 41 case FIRMWARE_VERSIONS:
40 g_firmware_key_version = key_version; 42 g_firmware_key_version = key_version;
41 g_firmware_version = version; 43 g_firmware_version = version;
42 break; 44 break;
43 case KERNEL_VERSIONS: 45 case KERNEL_VERSIONS:
44 g_kernel_key_version = key_version; 46 g_kernel_key_version = key_version;
45 g_kernel_version = version; 47 g_kernel_version = version;
46 break; 48 break;
47 } 49 }
48 #ifndef NDEBUG 50 #ifndef NDEBUG
49 debug("Rollback Index Library Mock: Stored Versions written.\n"); 51 debug("Rollback Index Library Mock: Stored Versions written.\n");
50 #endif 52 #endif
51 return 1; 53 return 0;
52 } 54 }
53 55
54 void LockFirmwareVersions() { 56 int LockFirmwareVersions() {
55 #ifndef NDEBUG 57 #ifndef NDEBUG
56 debug("Rollback Index Library Mock: Firmware Versions Locked.\n"); 58 debug("Rollback Index Library Mock: Firmware Versions Locked.\n");
57 #endif 59 #endif
60 return 0;
58 } 61 }
59 void LockKernelVersionsByLockingPP() { 62 int LockKernelVersionsByLockingPP() {
60 #ifndef NDEBUG 63 #ifndef NDEBUG
61 debug("Rollback Index Library Mock: Kernel Versions Locked.\n"); 64 debug("Rollback Index Library Mock: Kernel Versions Locked.\n");
62 #endif 65 #endif
66 return 0;
63 } 67 }
OLDNEW
« no previous file with comments | « no previous file | vboot_firmware/include/rollback_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698