blob: c5f7bbf5eb35a9255c631c4e33fde35d61d7c690 [file] [log] [blame]
Randall Spanglerda2b49c2014-06-10 17:03:40 -07001/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * Stub API implementations which should be implemented by the caller.
6 */
7
Bill Richardson40890c52015-01-26 13:48:32 -08008#include <stdarg.h>
Julius Wernerac15a152020-09-01 15:31:14 -07009#include <stdlib.h>
Bill Richardson40890c52015-01-26 13:48:32 -080010#include <stdio.h>
11
Randall Spanglerda2b49c2014-06-10 17:03:40 -070012#include "2api.h"
Joel Kitchingffd42a82019-08-29 13:58:52 +080013#include "2sysincludes.h"
Randall Spanglerda2b49c2014-06-10 17:03:40 -070014
Julius Wernerf10e9092014-12-16 19:24:54 -080015__attribute__((weak))
Bill Richardson40890c52015-01-26 13:48:32 -080016void vb2ex_printf(const char *func, const char *fmt, ...)
17{
Julius Werner5160e692019-03-05 13:56:41 -080018#ifdef VBOOT_DEBUG
Bill Richardson40890c52015-01-26 13:48:32 -080019 va_list ap;
20 va_start(ap, fmt);
Randall Spanglera6094782017-01-20 14:54:47 -080021 if (func)
22 fprintf(stderr, "%s: ", func);
Bill Richardson40890c52015-01-26 13:48:32 -080023 vfprintf(stderr, fmt, ap);
24 va_end(ap);
Julius Werner5160e692019-03-05 13:56:41 -080025#endif
Bill Richardson40890c52015-01-26 13:48:32 -080026}
27
28__attribute__((weak))
Joel Kitchinge6700f42019-07-31 14:12:30 +080029vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx)
Randall Spanglerda2b49c2014-06-10 17:03:40 -070030{
Joel Kitching231112a2019-04-25 18:16:06 +080031 fprintf(stderr, "%s: function not implemented\n", __func__);
Joel Kitchinga1df89d2018-12-03 14:39:57 +080032 return VB2_ERROR_EX_UNIMPLEMENTED;
Randall Spanglerda2b49c2014-06-10 17:03:40 -070033}
34
Julius Wernerf10e9092014-12-16 19:24:54 -080035__attribute__((weak))
Joel Kitchinge6700f42019-07-31 14:12:30 +080036vb2_error_t vb2ex_read_resource(struct vb2_context *ctx,
37 enum vb2_resource_index index, uint32_t offset,
38 void *buf, uint32_t size)
Randall Spanglerda2b49c2014-06-10 17:03:40 -070039{
Joel Kitching231112a2019-04-25 18:16:06 +080040 fprintf(stderr, "%s: function not implemented\n", __func__);
Joel Kitchinga1df89d2018-12-03 14:39:57 +080041 return VB2_ERROR_EX_UNIMPLEMENTED;
Randall Spanglerda2b49c2014-06-10 17:03:40 -070042}
Julius Wernerf10e9092014-12-16 19:24:54 -080043
44__attribute__((weak))
Joel Kitchinge6700f42019-07-31 14:12:30 +080045vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val)
Matt Delco08bf6802019-02-13 15:54:24 -080046{
Joel Kitching231112a2019-04-25 18:16:06 +080047 fprintf(stderr, "%s: function not implemented\n", __func__);
Joel Kitchinga1df89d2018-12-03 14:39:57 +080048 return VB2_ERROR_EX_UNIMPLEMENTED;
Matt Delco08bf6802019-02-13 15:54:24 -080049}
Joel Kitchingaaf39432019-09-11 14:15:45 +080050
51__attribute__((weak))
Tim Wawrzynczak5d874c22019-10-22 15:36:59 -060052vb2_error_t vb2ex_auxfw_check(enum vb2_auxfw_update_severity *severity)
53{
Joel Kitchinga5c13bc2020-09-24 17:13:31 +080054 *severity = VB2_AUXFW_NO_UPDATE;
55 return VB2_SUCCESS;
Tim Wawrzynczak5d874c22019-10-22 15:36:59 -060056}
57
58__attribute__((weak))
59vb2_error_t vb2ex_auxfw_update(void)
60{
Joel Kitchinga5c13bc2020-09-24 17:13:31 +080061 return VB2_SUCCESS;
Tim Wawrzynczak5d874c22019-10-22 15:36:59 -060062}
63
64__attribute__((weak))
65vb2_error_t vb2ex_auxfw_finalize(struct vb2_context *ctx)
66{
Joel Kitchinga5c13bc2020-09-24 17:13:31 +080067 return VB2_SUCCESS;
Tim Wawrzynczak5d874c22019-10-22 15:36:59 -060068}
69
70__attribute__((weak))
Joel Kitchingaaf39432019-09-11 14:15:45 +080071void vb2ex_abort(void)
72{
73 /* Stub simply exits. */
Julius Wernerac15a152020-09-01 15:31:14 -070074 abort();
Joel Kitchingaaf39432019-09-11 14:15:45 +080075}
Hsuan Ting Chenb92543c2020-06-19 13:28:06 +080076
Joel Kitching37ae6202021-01-18 15:56:42 +080077/*****************************************************************************/
78/* UI-related stubs */
79
Hsuan Ting Chenb92543c2020-06-19 13:28:06 +080080__attribute__((weak))
81const char *vb2ex_get_debug_info(struct vb2_context *ctx)
82{
83 return NULL;
84}
85
86__attribute__((weak))
Hsuan Ting Chen4e5ce422020-09-15 15:30:00 +080087const char *vb2ex_get_firmware_log(int reset)
Hsuan Ting Chen8196d4e2020-07-30 13:52:34 +080088{
89 return NULL;
90}
91
92__attribute__((weak))
Yu-Ping Wuabcd6d22020-11-06 11:24:22 +080093uint32_t vb2ex_prepare_log_screen(enum vb2_screen screen, uint32_t locale_id,
94 const char *str)
Hsuan Ting Chenb92543c2020-06-19 13:28:06 +080095{
96 return 1;
97}
Meng-Huan Yu2fb76832020-08-24 16:17:56 +080098
99__attribute__((weak))
100const char *vb2ex_get_diagnostic_storage(void)
101{
102 return "mock";
103}
104
105__attribute__((weak))
106vb2_error_t vb2ex_diag_memory_quick_test(int reset, const char **out)
107{
108 *out = "mock";
109 return VB2_SUCCESS;
110}
111
112__attribute__((weak))
113vb2_error_t vb2ex_diag_memory_full_test(int reset, const char **out)
114{
115 *out = "mock";
116 return VB2_SUCCESS;
117}
Joel Kitching37ae6202021-01-18 15:56:42 +0800118
119__attribute__((weak))
120void vb2ex_msleep(uint32_t msec)
121{
122}
123
124__attribute__((weak))
125void vb2ex_beep(uint32_t msec, uint32_t frequency)
126{
127}
128
129__attribute__((weak))
130uint32_t vb2ex_get_locale_count(void)
131{
132 return 0;
133}
134
135__attribute__((weak))
136uint32_t vb2ex_get_bootloader_count(void)
137{
138 return 0;
139}
140
141__attribute__((weak))
142int vb2ex_physical_presence_pressed(void)
143{
144 return 0;
145}
146
147__attribute__((weak))
148vb2_error_t vb2ex_commit_data(struct vb2_context *ctx)
149{
150 ctx->flags &= ~VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED;
151 ctx->flags &= ~VB2_CONTEXT_SECDATA_KERNEL_CHANGED;
152 ctx->flags &= ~VB2_CONTEXT_NVDATA_CHANGED;
153 return VB2_SUCCESS;
154}