blob: 16ba3ab3905f52dc8903daf173e89258d22a5e32 [file] [log] [blame]
Randall Spangler96191122011-07-08 14:01:54 -07001/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
Randall Spanglercbaf6962010-08-05 16:42:43 -07002 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
Bill Richardson0b8f35c2010-05-26 09:18:38 -07005
Randall Spangler3003c1d2010-05-27 09:20:11 -07006#include "cgptlib.h"
Randall Spangler7202eae2010-06-08 11:02:17 -07007#include "load_firmware_fw.h"
Bill Richardson0b8f35c2010-05-26 09:18:38 -07008#include "load_kernel_fw.h"
9#include "rollback_index.h"
10#include "tlcl.h"
Gaurav Shahb64faaa2011-03-15 16:36:29 -070011#include "tpm_bootmode.h"
Randall Spanglerd1836442010-06-10 09:59:04 -070012#include "vboot_common.h"
Randall Spanglerd1836442010-06-10 09:59:04 -070013#include "vboot_kernel.h"
Randall Spangler9e162cd2011-02-22 13:06:53 -080014#include "vboot_nvstorage.h"
Bill Richardson0b8f35c2010-05-26 09:18:38 -070015
Randall Spangler39f66112010-07-14 09:10:23 -070016
Bill Richardson0b8f35c2010-05-26 09:18:38 -070017int main(void)
18{
Randall Spanglerd1836442010-06-10 09:59:04 -070019 /* cgptlib.h */
Randall Spangler3003c1d2010-05-27 09:20:11 -070020 GptInit(0);
21 GptNextKernelEntry(0, 0, 0);
22 GptUpdateKernelEntry(0, 0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070023
Randall Spanglerd1836442010-06-10 09:59:04 -070024 /* load_firmware_fw.h */
Randall Spanglerd471f2a2010-06-16 12:05:10 -070025 UpdateFirmwareBodyHash(0, 0, 0);
Randall Spangler7202eae2010-06-08 11:02:17 -070026 LoadFirmware(0);
27
Randall Spanglerd1836442010-06-10 09:59:04 -070028 /* load_kernel_fw.h */
Randall Spangler0ff6fea2010-05-27 18:36:02 -070029 LoadKernel(0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070030
Randall Spanglerd1836442010-06-10 09:59:04 -070031 /* rollback_index.h */
Randall Spangler1fe16072010-09-02 11:37:51 -070032 RollbackS3Resume();
Randall Spangler66680282010-08-16 12:33:44 -070033 RollbackFirmwareSetup(0, 0);
Randall Spangler5ac39bf2011-03-17 17:58:56 -070034 RollbackFirmwareRead(0);
Randall Spangler66680282010-08-16 12:33:44 -070035 RollbackFirmwareWrite(0);
Randall Spangler10788382010-06-23 15:35:31 -070036 RollbackFirmwareLock();
37 RollbackKernelRecovery(0);
Randall Spangler66680282010-08-16 12:33:44 -070038 RollbackKernelRead(0);
39 RollbackKernelWrite(0);
Randall Spangler10788382010-06-23 15:35:31 -070040 RollbackKernelLock();
Bill Richardson0b8f35c2010-05-26 09:18:38 -070041
Gaurav Shahb64faaa2011-03-15 16:36:29 -070042 /* tpm_bootmode.c */
43 SetTPMBootModeState(0, 0, 0);
44
Randall Spanglerd1836442010-06-10 09:59:04 -070045 /* tlcl.h */
Bill Richardson0b8f35c2010-05-26 09:18:38 -070046 TlclStartup();
Randall Spangler1fe16072010-09-02 11:37:51 -070047 TlclResume();
Randall Spangler3e1081f2010-07-19 10:04:21 -070048 TlclSelfTestFull();
Luigi Semenzato59204c52010-06-09 13:37:15 -070049 TlclContinueSelfTest();
Bill Richardson0b8f35c2010-05-26 09:18:38 -070050 TlclDefineSpace(0, 0, 0);
51 TlclWrite(0, 0, 0);
52 TlclRead(0, 0, 0);
53 TlclWriteLock(0);
54 TlclReadLock(0);
55 TlclAssertPhysicalPresence();
56 TlclSetNvLocked();
57 TlclIsOwned();
58 TlclForceClear();
Luigi Semenzatoded1cec2010-05-27 15:19:58 -070059 TlclSetEnable();
Luigi Semenzato416f6812010-07-08 12:12:12 -070060 TlclClearEnable();
Luigi Semenzatoded1cec2010-05-27 15:19:58 -070061 TlclSetDeactivated(0);
Randall Spangler3e1081f2010-07-19 10:04:21 -070062 TlclGetFlags(0, 0, 0);
Gaurav Shah2447dd22010-08-30 11:43:57 -070063 TlclSetGlobalLock();
64 TlclExtend(0, 0, 0);
65 TlclGetPermissions(0, 0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070066
Randall Spangler1b1998d2011-07-01 16:12:47 -070067 /* vboot_api.h - entry points INTO vboot_reference */
Randall Spangler1b1998d2011-07-01 16:12:47 -070068 VbInit(0, 0);
69 VbSelectFirmware(0, 0);
70 VbUpdateFirmwareBodyHash(0, 0, 0);
71 VbSelectAndLoadKernel(0, 0);
72
Randall Spanglerd1836442010-06-10 09:59:04 -070073 /* vboot_common.h */
74 OffsetOf(0, 0);
75 GetPublicKeyData(0);
76 GetPublicKeyDataC(0);
77 GetSignatureData(0);
78 GetSignatureDataC(0);
79 VerifyMemberInside(0, 0, 0, 0, 0, 0);
80 VerifyPublicKeyInside(0, 0, 0);
81 VerifySignatureInside(0, 0, 0);
Randall Spanglera55e5ca2010-06-15 18:45:09 -070082 PublicKeyInit(0, 0, 0);
83 PublicKeyCopy(0, 0);
Randall Spanglerd1836442010-06-10 09:59:04 -070084 PublicKeyToRSA(0);
Randall Spangler87c13d82010-07-19 10:35:40 -070085 VerifyData(0, 0, 0, 0);
Randall Spangler39ed88e2010-06-15 14:53:01 -070086 VerifyDigest(0, 0, 0);
Randall Spangler138acfe2010-08-17 15:45:21 -070087 KeyBlockVerify(0, 0, 0, 0);
Randall Spangler87c13d82010-07-19 10:35:40 -070088 VerifyFirmwarePreamble(0, 0, 0);
Randall Spanglera712e012011-07-13 09:48:41 -070089 VbGetFirmwarePreambleFlags(0);
Randall Spangler87c13d82010-07-19 10:35:40 -070090 VerifyKernelPreamble(0, 0, 0);
Randall Spangler95c40312011-03-09 15:54:16 -080091 VbSharedDataInit(0, 0);
92 VbSharedDataReserve(0, 0);
93 VbSharedDataSetKernelKey(0, 0);
Randall Spanglerd1836442010-06-10 09:59:04 -070094
Randall Spangler9e162cd2011-02-22 13:06:53 -080095 VbNvSetup(0);
96 VbNvGet(0, 0, 0);
97 VbNvSet(0, 0, 0);
98 VbNvTeardown(0);
99
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700100 return 0;
101}