Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 1 | /* 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 Richardson | 40890c5 | 2015-01-26 13:48:32 -0800 | [diff] [blame] | 8 | #include <stdarg.h> |
Julius Werner | ac15a15 | 2020-09-01 15:31:14 -0700 | [diff] [blame] | 9 | #include <stdlib.h> |
Bill Richardson | 40890c5 | 2015-01-26 13:48:32 -0800 | [diff] [blame] | 10 | #include <stdio.h> |
| 11 | |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 12 | #include "2api.h" |
Joel Kitching | ffd42a8 | 2019-08-29 13:58:52 +0800 | [diff] [blame] | 13 | #include "2sysincludes.h" |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 14 | |
Julius Werner | f10e909 | 2014-12-16 19:24:54 -0800 | [diff] [blame] | 15 | __attribute__((weak)) |
Bill Richardson | 40890c5 | 2015-01-26 13:48:32 -0800 | [diff] [blame] | 16 | void vb2ex_printf(const char *func, const char *fmt, ...) |
| 17 | { |
Julius Werner | 5160e69 | 2019-03-05 13:56:41 -0800 | [diff] [blame] | 18 | #ifdef VBOOT_DEBUG |
Bill Richardson | 40890c5 | 2015-01-26 13:48:32 -0800 | [diff] [blame] | 19 | va_list ap; |
| 20 | va_start(ap, fmt); |
Randall Spangler | a609478 | 2017-01-20 14:54:47 -0800 | [diff] [blame] | 21 | if (func) |
| 22 | fprintf(stderr, "%s: ", func); |
Bill Richardson | 40890c5 | 2015-01-26 13:48:32 -0800 | [diff] [blame] | 23 | vfprintf(stderr, fmt, ap); |
| 24 | va_end(ap); |
Julius Werner | 5160e69 | 2019-03-05 13:56:41 -0800 | [diff] [blame] | 25 | #endif |
Bill Richardson | 40890c5 | 2015-01-26 13:48:32 -0800 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | __attribute__((weak)) |
Joel Kitching | b139517 | 2021-01-18 16:05:19 +0800 | [diff] [blame^] | 29 | void vb2ex_abort(void) |
| 30 | { |
| 31 | /* Stub simply exits. */ |
| 32 | abort(); |
| 33 | } |
| 34 | |
| 35 | __attribute__((weak)) |
Joel Kitching | e6700f4 | 2019-07-31 14:12:30 +0800 | [diff] [blame] | 36 | vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx) |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 37 | { |
Joel Kitching | 231112a | 2019-04-25 18:16:06 +0800 | [diff] [blame] | 38 | fprintf(stderr, "%s: function not implemented\n", __func__); |
Joel Kitching | a1df89d | 2018-12-03 14:39:57 +0800 | [diff] [blame] | 39 | return VB2_ERROR_EX_UNIMPLEMENTED; |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Julius Werner | f10e909 | 2014-12-16 19:24:54 -0800 | [diff] [blame] | 42 | __attribute__((weak)) |
Joel Kitching | e6700f4 | 2019-07-31 14:12:30 +0800 | [diff] [blame] | 43 | vb2_error_t vb2ex_read_resource(struct vb2_context *ctx, |
| 44 | enum vb2_resource_index index, uint32_t offset, |
| 45 | void *buf, uint32_t size) |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 46 | { |
Joel Kitching | 231112a | 2019-04-25 18:16:06 +0800 | [diff] [blame] | 47 | fprintf(stderr, "%s: function not implemented\n", __func__); |
Joel Kitching | a1df89d | 2018-12-03 14:39:57 +0800 | [diff] [blame] | 48 | return VB2_ERROR_EX_UNIMPLEMENTED; |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 49 | } |
Julius Werner | f10e909 | 2014-12-16 19:24:54 -0800 | [diff] [blame] | 50 | |
| 51 | __attribute__((weak)) |
Joel Kitching | e6700f4 | 2019-07-31 14:12:30 +0800 | [diff] [blame] | 52 | vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val) |
Matt Delco | 08bf680 | 2019-02-13 15:54:24 -0800 | [diff] [blame] | 53 | { |
Joel Kitching | 231112a | 2019-04-25 18:16:06 +0800 | [diff] [blame] | 54 | fprintf(stderr, "%s: function not implemented\n", __func__); |
Joel Kitching | a1df89d | 2018-12-03 14:39:57 +0800 | [diff] [blame] | 55 | return VB2_ERROR_EX_UNIMPLEMENTED; |
Matt Delco | 08bf680 | 2019-02-13 15:54:24 -0800 | [diff] [blame] | 56 | } |
Joel Kitching | aaf3943 | 2019-09-11 14:15:45 +0800 | [diff] [blame] | 57 | |
Joel Kitching | b139517 | 2021-01-18 16:05:19 +0800 | [diff] [blame^] | 58 | /*****************************************************************************/ |
| 59 | /* auxfw and EC-related stubs */ |
| 60 | |
| 61 | __attribute__((weak)) |
| 62 | int vb2ex_ec_trusted(void) |
| 63 | { |
| 64 | return 1; |
| 65 | } |
| 66 | |
| 67 | __attribute__((weak)) |
| 68 | vb2_error_t vb2ex_ec_running_rw(int *in_rw) |
| 69 | { |
| 70 | *in_rw = 0; |
| 71 | return VB2_SUCCESS; |
| 72 | } |
| 73 | |
| 74 | __attribute__((weak)) |
| 75 | vb2_error_t vb2ex_ec_jump_to_rw(void) |
| 76 | { |
| 77 | return VB2_SUCCESS; |
| 78 | } |
| 79 | |
| 80 | __attribute__((weak)) |
| 81 | vb2_error_t vb2ex_ec_disable_jump(void) |
| 82 | { |
| 83 | return VB2_SUCCESS; |
| 84 | } |
| 85 | |
| 86 | __attribute__((weak)) |
| 87 | vb2_error_t vb2ex_ec_hash_image(enum vb2_firmware_selection select, |
| 88 | const uint8_t **hash, int *hash_size) |
| 89 | { |
| 90 | static const uint8_t fake_hash[32] = {1, 2, 3, 4}; |
| 91 | |
| 92 | *hash = fake_hash; |
| 93 | *hash_size = sizeof(fake_hash); |
| 94 | return VB2_SUCCESS; |
| 95 | } |
| 96 | |
| 97 | __attribute__((weak)) |
| 98 | vb2_error_t vb2ex_ec_get_expected_image_hash(enum vb2_firmware_selection select, |
| 99 | const uint8_t **hash, int *hash_size) |
| 100 | { |
| 101 | static const uint8_t fake_hash[32] = {1, 2, 3, 4}; |
| 102 | |
| 103 | *hash = fake_hash; |
| 104 | *hash_size = sizeof(fake_hash); |
| 105 | return VB2_SUCCESS; |
| 106 | } |
| 107 | |
| 108 | __attribute__((weak)) |
| 109 | vb2_error_t vb2ex_ec_update_image(enum vb2_firmware_selection select) |
| 110 | { |
| 111 | return VB2_SUCCESS; |
| 112 | } |
| 113 | |
| 114 | __attribute__((weak)) |
| 115 | vb2_error_t vb2ex_ec_protect(enum vb2_firmware_selection select) |
| 116 | { |
| 117 | return VB2_SUCCESS; |
| 118 | } |
| 119 | |
| 120 | __attribute__((weak)) |
| 121 | vb2_error_t vb2ex_ec_vboot_done(struct vb2_context *ctx) |
| 122 | { |
| 123 | return VB2_SUCCESS; |
| 124 | } |
| 125 | |
| 126 | __attribute__((weak)) |
| 127 | vb2_error_t vb2ex_ec_battery_cutoff(void) |
| 128 | { |
| 129 | return VB2_SUCCESS; |
| 130 | } |
| 131 | |
Joel Kitching | aaf3943 | 2019-09-11 14:15:45 +0800 | [diff] [blame] | 132 | __attribute__((weak)) |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 133 | vb2_error_t vb2ex_auxfw_check(enum vb2_auxfw_update_severity *severity) |
| 134 | { |
Joel Kitching | a5c13bc | 2020-09-24 17:13:31 +0800 | [diff] [blame] | 135 | *severity = VB2_AUXFW_NO_UPDATE; |
| 136 | return VB2_SUCCESS; |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | __attribute__((weak)) |
| 140 | vb2_error_t vb2ex_auxfw_update(void) |
| 141 | { |
Joel Kitching | a5c13bc | 2020-09-24 17:13:31 +0800 | [diff] [blame] | 142 | return VB2_SUCCESS; |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | __attribute__((weak)) |
| 146 | vb2_error_t vb2ex_auxfw_finalize(struct vb2_context *ctx) |
| 147 | { |
Joel Kitching | a5c13bc | 2020-09-24 17:13:31 +0800 | [diff] [blame] | 148 | return VB2_SUCCESS; |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 149 | } |
| 150 | |
Joel Kitching | 37ae620 | 2021-01-18 15:56:42 +0800 | [diff] [blame] | 151 | /*****************************************************************************/ |
| 152 | /* UI-related stubs */ |
| 153 | |
Hsuan Ting Chen | b92543c | 2020-06-19 13:28:06 +0800 | [diff] [blame] | 154 | __attribute__((weak)) |
| 155 | const char *vb2ex_get_debug_info(struct vb2_context *ctx) |
| 156 | { |
| 157 | return NULL; |
| 158 | } |
| 159 | |
| 160 | __attribute__((weak)) |
Hsuan Ting Chen | 4e5ce42 | 2020-09-15 15:30:00 +0800 | [diff] [blame] | 161 | const char *vb2ex_get_firmware_log(int reset) |
Hsuan Ting Chen | 8196d4e | 2020-07-30 13:52:34 +0800 | [diff] [blame] | 162 | { |
| 163 | return NULL; |
| 164 | } |
| 165 | |
| 166 | __attribute__((weak)) |
Yu-Ping Wu | abcd6d2 | 2020-11-06 11:24:22 +0800 | [diff] [blame] | 167 | uint32_t vb2ex_prepare_log_screen(enum vb2_screen screen, uint32_t locale_id, |
| 168 | const char *str) |
Hsuan Ting Chen | b92543c | 2020-06-19 13:28:06 +0800 | [diff] [blame] | 169 | { |
| 170 | return 1; |
| 171 | } |
Meng-Huan Yu | 2fb7683 | 2020-08-24 16:17:56 +0800 | [diff] [blame] | 172 | |
| 173 | __attribute__((weak)) |
| 174 | const char *vb2ex_get_diagnostic_storage(void) |
| 175 | { |
| 176 | return "mock"; |
| 177 | } |
| 178 | |
| 179 | __attribute__((weak)) |
| 180 | vb2_error_t vb2ex_diag_memory_quick_test(int reset, const char **out) |
| 181 | { |
| 182 | *out = "mock"; |
| 183 | return VB2_SUCCESS; |
| 184 | } |
| 185 | |
| 186 | __attribute__((weak)) |
| 187 | vb2_error_t vb2ex_diag_memory_full_test(int reset, const char **out) |
| 188 | { |
| 189 | *out = "mock"; |
| 190 | return VB2_SUCCESS; |
| 191 | } |
Joel Kitching | 37ae620 | 2021-01-18 15:56:42 +0800 | [diff] [blame] | 192 | |
| 193 | __attribute__((weak)) |
| 194 | void vb2ex_msleep(uint32_t msec) |
| 195 | { |
| 196 | } |
| 197 | |
| 198 | __attribute__((weak)) |
| 199 | void vb2ex_beep(uint32_t msec, uint32_t frequency) |
| 200 | { |
| 201 | } |
| 202 | |
| 203 | __attribute__((weak)) |
| 204 | uint32_t vb2ex_get_locale_count(void) |
| 205 | { |
| 206 | return 0; |
| 207 | } |
| 208 | |
| 209 | __attribute__((weak)) |
| 210 | uint32_t vb2ex_get_bootloader_count(void) |
| 211 | { |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | __attribute__((weak)) |
| 216 | int vb2ex_physical_presence_pressed(void) |
| 217 | { |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | __attribute__((weak)) |
| 222 | vb2_error_t vb2ex_commit_data(struct vb2_context *ctx) |
| 223 | { |
| 224 | ctx->flags &= ~VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED; |
| 225 | ctx->flags &= ~VB2_CONTEXT_SECDATA_KERNEL_CHANGED; |
| 226 | ctx->flags &= ~VB2_CONTEXT_NVDATA_CHANGED; |
| 227 | return VB2_SUCCESS; |
| 228 | } |