blob: 2ff8e9d7ede8a268c690639d520a275e3590acac [file] [log] [blame]
Randall Spangler29e88072012-06-19 10:03:53 -07001/* Copyright (c) 2012 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
Bill Richardson0c3ba242013-03-29 11:09:30 -07006#include "sysincludes.h"
7
Randall Spangler3003c1d2010-05-27 09:20:11 -07008#include "cgptlib.h"
Randall Spangler7202eae2010-06-08 11:02:17 -07009#include "load_firmware_fw.h"
Bill Richardson0b8f35c2010-05-26 09:18:38 -070010#include "load_kernel_fw.h"
11#include "rollback_index.h"
12#include "tlcl.h"
Gaurav Shahb64faaa2011-03-15 16:36:29 -070013#include "tpm_bootmode.h"
Randall Spanglerd1836442010-06-10 09:59:04 -070014#include "vboot_common.h"
Randall Spanglerd1836442010-06-10 09:59:04 -070015#include "vboot_kernel.h"
Randall Spangler9e162cd2011-02-22 13:06:53 -080016#include "vboot_nvstorage.h"
Bill Richardson0b8f35c2010-05-26 09:18:38 -070017
Randall Spangler39f66112010-07-14 09:10:23 -070018
Bill Richardson0b8f35c2010-05-26 09:18:38 -070019int main(void)
20{
Randall Spanglerd1836442010-06-10 09:59:04 -070021 /* cgptlib.h */
Randall Spangler3003c1d2010-05-27 09:20:11 -070022 GptInit(0);
23 GptNextKernelEntry(0, 0, 0);
24 GptUpdateKernelEntry(0, 0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070025
Randall Spanglerd1836442010-06-10 09:59:04 -070026 /* load_firmware_fw.h */
Randall Spangler8eead8e2011-07-28 16:36:08 -070027 LoadFirmware(0, 0, 0);
Randall Spangler7202eae2010-06-08 11:02:17 -070028
Randall Spanglerd1836442010-06-10 09:59:04 -070029 /* load_kernel_fw.h */
Simon Glass527ba812013-07-25 08:48:47 -060030 LoadKernel(0, 0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070031
Randall Spanglerd1836442010-06-10 09:59:04 -070032 /* rollback_index.h */
Randall Spangler1fe16072010-09-02 11:37:51 -070033 RollbackS3Resume();
Shawn Nematbakhsh472d93c2013-07-22 16:19:13 -070034 RollbackFirmwareSetup(0, 0, 0, 0, 0);
Randall Spangler66680282010-08-16 12:33:44 -070035 RollbackFirmwareWrite(0);
Randall Spangler10788382010-06-23 15:35:31 -070036 RollbackFirmwareLock();
Randall Spangler66680282010-08-16 12:33:44 -070037 RollbackKernelRead(0);
38 RollbackKernelWrite(0);
Shawn Nematbakhsh964144b2013-07-22 13:33:46 -070039 RollbackKernelLock(0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070040
Gaurav Shahb64faaa2011-03-15 16:36:29 -070041 /* tpm_bootmode.c */
42 SetTPMBootModeState(0, 0, 0);
43
Randall Spanglerd1836442010-06-10 09:59:04 -070044 /* tlcl.h */
Bill Richardson0b8f35c2010-05-26 09:18:38 -070045 TlclStartup();
Randall Spangler1fe16072010-09-02 11:37:51 -070046 TlclResume();
Randall Spangler3e1081f2010-07-19 10:04:21 -070047 TlclSelfTestFull();
Luigi Semenzato59204c52010-06-09 13:37:15 -070048 TlclContinueSelfTest();
Bill Richardson0b8f35c2010-05-26 09:18:38 -070049 TlclDefineSpace(0, 0, 0);
50 TlclWrite(0, 0, 0);
51 TlclRead(0, 0, 0);
52 TlclWriteLock(0);
53 TlclReadLock(0);
54 TlclAssertPhysicalPresence();
55 TlclSetNvLocked();
56 TlclIsOwned();
57 TlclForceClear();
Luigi Semenzatoded1cec2010-05-27 15:19:58 -070058 TlclSetEnable();
Luigi Semenzato416f6812010-07-08 12:12:12 -070059 TlclClearEnable();
Luigi Semenzatoded1cec2010-05-27 15:19:58 -070060 TlclSetDeactivated(0);
Randall Spangler3e1081f2010-07-19 10:04:21 -070061 TlclGetFlags(0, 0, 0);
Gaurav Shah2447dd22010-08-30 11:43:57 -070062 TlclSetGlobalLock();
63 TlclExtend(0, 0, 0);
64 TlclGetPermissions(0, 0);
Bill Richardson0b8f35c2010-05-26 09:18:38 -070065
Randall Spangler1b1998d2011-07-01 16:12:47 -070066 /* vboot_api.h - entry points INTO vboot_reference */
Randall Spangler1b1998d2011-07-01 16:12:47 -070067 VbInit(0, 0);
68 VbSelectFirmware(0, 0);
69 VbUpdateFirmwareBodyHash(0, 0, 0);
70 VbSelectAndLoadKernel(0, 0);
71
Randall Spanglerd1836442010-06-10 09:59:04 -070072 /* vboot_common.h */
73 OffsetOf(0, 0);
74 GetPublicKeyData(0);
75 GetPublicKeyDataC(0);
76 GetSignatureData(0);
77 GetSignatureDataC(0);
78 VerifyMemberInside(0, 0, 0, 0, 0, 0);
79 VerifyPublicKeyInside(0, 0, 0);
80 VerifySignatureInside(0, 0, 0);
Randall Spanglera55e5ca2010-06-15 18:45:09 -070081 PublicKeyInit(0, 0, 0);
82 PublicKeyCopy(0, 0);
Randall Spanglerd1836442010-06-10 09:59:04 -070083 PublicKeyToRSA(0);
Randall Spangler87c13d82010-07-19 10:35:40 -070084 VerifyData(0, 0, 0, 0);
Randall Spangler39ed88e2010-06-15 14:53:01 -070085 VerifyDigest(0, 0, 0);
Randall Spangler138acfe2010-08-17 15:45:21 -070086 KeyBlockVerify(0, 0, 0, 0);
Randall Spangler87c13d82010-07-19 10:35:40 -070087 VerifyFirmwarePreamble(0, 0, 0);
Randall Spanglera712e012011-07-13 09:48:41 -070088 VbGetFirmwarePreambleFlags(0);
Randall Spangler87c13d82010-07-19 10:35:40 -070089 VerifyKernelPreamble(0, 0, 0);
Randall Spangler95c40312011-03-09 15:54:16 -080090 VbSharedDataInit(0, 0);
91 VbSharedDataReserve(0, 0);
92 VbSharedDataSetKernelKey(0, 0);
Randall Spanglerd1836442010-06-10 09:59:04 -070093
Randall Spangler9e162cd2011-02-22 13:06:53 -080094 VbNvSetup(0);
95 VbNvGet(0, 0, 0);
96 VbNvSet(0, 0, 0);
97 VbNvTeardown(0);
98
Bill Richardson0b8f35c2010-05-26 09:18:38 -070099 return 0;
100}