blob: 717c0f8d68c0993b591c5623799e6d1611d7a95c [file] [log] [blame]
Randall Spangler7c557082013-02-05 09:44:31 -08001/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Randall Spangler32a65262011-06-27 10:49:11 -07002 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * Stub implementations of firmware-provided API functions.
6 */
7
Bill Richardson0c3ba242013-03-29 11:09:30 -07008#include <stdint.h>
9
Randall Spangler32a65262011-06-27 10:49:11 -070010#include <stdarg.h>
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <sys/time.h>
15
16#include "vboot_api.h"
17
Sheng-Liang Song487a54b2014-07-26 21:34:28 -070018static enum VbEcBootMode_t vboot_mode;
19
Randall Spangler7c557082013-02-05 09:44:31 -080020void VbExSleepMs(uint32_t msec)
21{
Randall Spangler32a65262011-06-27 10:49:11 -070022}
23
Randall Spangler7c557082013-02-05 09:44:31 -080024VbError_t VbExBeep(uint32_t msec, uint32_t frequency)
25{
26 return VBERROR_SUCCESS;
Randall Spangler32a65262011-06-27 10:49:11 -070027}
28
Randall Spangler7c557082013-02-05 09:44:31 -080029VbError_t VbExDisplayInit(uint32_t *width, uint32_t *height)
30{
31 return VBERROR_SUCCESS;
Randall Spangler32a65262011-06-27 10:49:11 -070032}
33
Randall Spangler7c557082013-02-05 09:44:31 -080034VbError_t VbExDisplayBacklight(uint8_t enable)
35{
36 return VBERROR_SUCCESS;
Randall Spangler32a65262011-06-27 10:49:11 -070037}
38
Hung-Te Lin5e8f1db2014-05-09 20:40:15 +080039VbError_t VbExDisplaySetDimension(uint32_t width, uint32_t height)
40{
41 return VBERROR_SUCCESS;
42}
43
Daisuke Nojiri93543792015-10-06 16:50:33 -070044VbError_t VbExDisplayScreen(uint32_t screen_type, uint32_t locale)
Randall Spangler7c557082013-02-05 09:44:31 -080045{
46 return VBERROR_SUCCESS;
Randall Spangler32a65262011-06-27 10:49:11 -070047}
48
Bill Richardsonb1c85a82011-08-16 17:38:58 -070049VbError_t VbExDisplayImage(uint32_t x, uint32_t y,
Randall Spangler7c557082013-02-05 09:44:31 -080050 void *buffer, uint32_t buffersize)
51{
52 return VBERROR_SUCCESS;
Randall Spangler32a65262011-06-27 10:49:11 -070053}
54
Randall Spangler7c557082013-02-05 09:44:31 -080055VbError_t VbExDisplayDebugInfo(const char *info_str)
56{
57 return VBERROR_SUCCESS;
Randall Spangler32a65262011-06-27 10:49:11 -070058}
59
Randall Spangler7c557082013-02-05 09:44:31 -080060uint32_t VbExKeyboardRead(void)
61{
62 return 0;
Randall Spangler32a65262011-06-27 10:49:11 -070063}
64
Luigi Semenzatoa53a0b02014-01-10 16:26:08 -080065uint32_t VbExKeyboardReadWithFlags(uint32_t *flags_ptr)
66{
67 return 0;
68}
69
70uint32_t VbExGetSwitches(uint32_t mask)
71{
72 return 0;
73}
74
Randall Spangler7c557082013-02-05 09:44:31 -080075uint32_t VbExIsShutdownRequested(void)
76{
77 return 0;
Randall Spangler32a65262011-06-27 10:49:11 -070078}
Bill Richardsonb1c85a82011-08-16 17:38:58 -070079
80VbError_t VbExDecompress(void *inbuf, uint32_t in_size,
81 uint32_t compression_type,
Randall Spangler7c557082013-02-05 09:44:31 -080082 void *outbuf, uint32_t *out_size)
83{
84 return VBERROR_SUCCESS;
Bill Richardsonb1c85a82011-08-16 17:38:58 -070085}
Bill Richardson592567e2012-06-18 13:37:05 -070086
Randall Spanglere778ada2014-07-15 16:14:21 -070087int VbExTrustEC(int devidx)
Randall Spangler7c557082013-02-05 09:44:31 -080088{
89 return 1;
Bill Richardson592567e2012-06-18 13:37:05 -070090}
Randall Spangler053b7b62012-07-07 15:48:04 -070091
Randall Spanglere778ada2014-07-15 16:14:21 -070092VbError_t VbExEcRunningRW(int devidx, int *in_rw)
Randall Spangler7c557082013-02-05 09:44:31 -080093{
94 *in_rw = 0;
95 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -070096}
97
Randall Spanglere778ada2014-07-15 16:14:21 -070098VbError_t VbExEcJumpToRW(int devidx)
Randall Spangler7c557082013-02-05 09:44:31 -080099{
100 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -0700101}
102
Randall Spanglere778ada2014-07-15 16:14:21 -0700103VbError_t VbExEcRebootToRO(int devidx)
Randall Spangler7c557082013-02-05 09:44:31 -0800104{
105 /* Nothing to reboot, so all we can do is return failure. */
106 return VBERROR_UNKNOWN;
Randall Spangler053b7b62012-07-07 15:48:04 -0700107}
108
Randall Spanglere778ada2014-07-15 16:14:21 -0700109VbError_t VbExEcDisableJump(int devidx)
Randall Spangler7c557082013-02-05 09:44:31 -0800110{
111 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -0700112}
113
114#define SHA256_HASH_SIZE 32
115
Mary Ruthven7e0728d2015-12-18 11:16:02 -0800116VbError_t VbExEcHashImage(int devidx, enum VbSelectFirmware_t select,
117 const uint8_t **hash, int *hash_size)
Randall Spangler7c557082013-02-05 09:44:31 -0800118{
119 static const uint8_t fake_hash[32] = {1, 2, 3, 4};
120
121 *hash = fake_hash;
122 *hash_size = sizeof(fake_hash);
123 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -0700124}
125
Mary Ruthven7e0728d2015-12-18 11:16:02 -0800126VbError_t VbExEcGetExpectedImage(int devidx, enum VbSelectFirmware_t select,
127 const uint8_t **image, int *image_size)
Randall Spangler7c557082013-02-05 09:44:31 -0800128{
129 static uint8_t fake_image[64] = {5, 6, 7, 8};
130 *image = fake_image;
131 *image_size = sizeof(fake_image);
132 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -0700133}
134
Mary Ruthven7e0728d2015-12-18 11:16:02 -0800135VbError_t VbExEcGetExpectedImageHash(int devidx, enum VbSelectFirmware_t select,
136 const uint8_t **hash, int *hash_size)
Randall Spangler7c557082013-02-05 09:44:31 -0800137{
138 static const uint8_t fake_hash[32] = {1, 2, 3, 4};
Randall Spangler5ca4ea02013-02-04 15:00:09 -0800139
Randall Spangler7c557082013-02-05 09:44:31 -0800140 *hash = fake_hash;
141 *hash_size = sizeof(fake_hash);
142 return VBERROR_SUCCESS;
Randall Spangler5ca4ea02013-02-04 15:00:09 -0800143}
144
Mary Ruthven7e0728d2015-12-18 11:16:02 -0800145VbError_t VbExEcUpdateImage(int devidx, enum VbSelectFirmware_t select,
146 const uint8_t *image, int image_size)
Randall Spangler7c557082013-02-05 09:44:31 -0800147{
148 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -0700149}
150
Mary Ruthven7e0728d2015-12-18 11:16:02 -0800151VbError_t VbExEcProtect(int devidx, enum VbSelectFirmware_t select)
Randall Spangler7c557082013-02-05 09:44:31 -0800152{
153 return VBERROR_SUCCESS;
Randall Spangler053b7b62012-07-07 15:48:04 -0700154}
Stefan Reinauera2326ee2012-08-23 15:06:45 -0700155
Sheng-Liang Song487a54b2014-07-26 21:34:28 -0700156VbError_t VbExEcEnteringMode(int devidx, enum VbEcBootMode_t mode)
157{
158 vboot_mode = mode;
159 return VBERROR_SUCCESS;
160}
161
Shawn Nematbakhshb491bc82015-10-21 14:31:02 -0700162VbError_t VbExEcVbootDone(int in_recovery)
163{
164 return VBERROR_SUCCESS;
165}
166
Hung-Te Linaee6bd62016-04-07 12:21:03 +0800167VbError_t VbExEcBatteryCutOff(void)
168{
169 return VBERROR_SUCCESS;
170}
171
Sheng-Liang Song487a54b2014-07-26 21:34:28 -0700172enum VbEcBootMode_t VbGetMode(void)
173{
174 return vboot_mode;
175}
176
Stefan Reinauera2326ee2012-08-23 15:06:45 -0700177int VbExLegacy(void)
178{
Randall Spangler7c557082013-02-05 09:44:31 -0800179 return 1;
Stefan Reinauera2326ee2012-08-23 15:06:45 -0700180}
Furquan Shaikh7a1c0d12015-06-02 10:32:52 -0700181
182uint8_t VbExOverrideGptEntryPriority(const GptEntry *e)
183{
184 return 0;
185}