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 | e6700f4 | 2019-07-31 14:12:30 +0800 | [diff] [blame] | 29 | vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx) |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 30 | { |
Joel Kitching | 231112a | 2019-04-25 18:16:06 +0800 | [diff] [blame] | 31 | fprintf(stderr, "%s: function not implemented\n", __func__); |
Joel Kitching | a1df89d | 2018-12-03 14:39:57 +0800 | [diff] [blame] | 32 | return VB2_ERROR_EX_UNIMPLEMENTED; |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 33 | } |
| 34 | |
Julius Werner | f10e909 | 2014-12-16 19:24:54 -0800 | [diff] [blame] | 35 | __attribute__((weak)) |
Joel Kitching | e6700f4 | 2019-07-31 14:12:30 +0800 | [diff] [blame] | 36 | vb2_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 Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 39 | { |
Joel Kitching | 231112a | 2019-04-25 18:16:06 +0800 | [diff] [blame] | 40 | fprintf(stderr, "%s: function not implemented\n", __func__); |
Joel Kitching | a1df89d | 2018-12-03 14:39:57 +0800 | [diff] [blame] | 41 | return VB2_ERROR_EX_UNIMPLEMENTED; |
Randall Spangler | da2b49c | 2014-06-10 17:03:40 -0700 | [diff] [blame] | 42 | } |
Julius Werner | f10e909 | 2014-12-16 19:24:54 -0800 | [diff] [blame] | 43 | |
| 44 | __attribute__((weak)) |
Joel Kitching | e6700f4 | 2019-07-31 14:12:30 +0800 | [diff] [blame] | 45 | 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] | 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; |
Matt Delco | 08bf680 | 2019-02-13 15:54:24 -0800 | [diff] [blame] | 49 | } |
Joel Kitching | aaf3943 | 2019-09-11 14:15:45 +0800 | [diff] [blame] | 50 | |
| 51 | __attribute__((weak)) |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 52 | vb2_error_t vb2ex_auxfw_check(enum vb2_auxfw_update_severity *severity) |
| 53 | { |
Joel Kitching | a5c13bc | 2020-09-24 17:13:31 +0800 | [diff] [blame] | 54 | *severity = VB2_AUXFW_NO_UPDATE; |
| 55 | return VB2_SUCCESS; |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | __attribute__((weak)) |
| 59 | vb2_error_t vb2ex_auxfw_update(void) |
| 60 | { |
Joel Kitching | a5c13bc | 2020-09-24 17:13:31 +0800 | [diff] [blame] | 61 | return VB2_SUCCESS; |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | __attribute__((weak)) |
| 65 | vb2_error_t vb2ex_auxfw_finalize(struct vb2_context *ctx) |
| 66 | { |
Joel Kitching | a5c13bc | 2020-09-24 17:13:31 +0800 | [diff] [blame] | 67 | return VB2_SUCCESS; |
Tim Wawrzynczak | 5d874c2 | 2019-10-22 15:36:59 -0600 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | __attribute__((weak)) |
Joel Kitching | aaf3943 | 2019-09-11 14:15:45 +0800 | [diff] [blame] | 71 | void vb2ex_abort(void) |
| 72 | { |
| 73 | /* Stub simply exits. */ |
Julius Werner | ac15a15 | 2020-09-01 15:31:14 -0700 | [diff] [blame] | 74 | abort(); |
Joel Kitching | aaf3943 | 2019-09-11 14:15:45 +0800 | [diff] [blame] | 75 | } |
Hsuan Ting Chen | b92543c | 2020-06-19 13:28:06 +0800 | [diff] [blame] | 76 | |
Joel Kitching | 37ae620 | 2021-01-18 15:56:42 +0800 | [diff] [blame^] | 77 | /*****************************************************************************/ |
| 78 | /* UI-related stubs */ |
| 79 | |
Hsuan Ting Chen | b92543c | 2020-06-19 13:28:06 +0800 | [diff] [blame] | 80 | __attribute__((weak)) |
| 81 | const char *vb2ex_get_debug_info(struct vb2_context *ctx) |
| 82 | { |
| 83 | return NULL; |
| 84 | } |
| 85 | |
| 86 | __attribute__((weak)) |
Hsuan Ting Chen | 4e5ce42 | 2020-09-15 15:30:00 +0800 | [diff] [blame] | 87 | const char *vb2ex_get_firmware_log(int reset) |
Hsuan Ting Chen | 8196d4e | 2020-07-30 13:52:34 +0800 | [diff] [blame] | 88 | { |
| 89 | return NULL; |
| 90 | } |
| 91 | |
| 92 | __attribute__((weak)) |
Yu-Ping Wu | abcd6d2 | 2020-11-06 11:24:22 +0800 | [diff] [blame] | 93 | uint32_t vb2ex_prepare_log_screen(enum vb2_screen screen, uint32_t locale_id, |
| 94 | const char *str) |
Hsuan Ting Chen | b92543c | 2020-06-19 13:28:06 +0800 | [diff] [blame] | 95 | { |
| 96 | return 1; |
| 97 | } |
Meng-Huan Yu | 2fb7683 | 2020-08-24 16:17:56 +0800 | [diff] [blame] | 98 | |
| 99 | __attribute__((weak)) |
| 100 | const char *vb2ex_get_diagnostic_storage(void) |
| 101 | { |
| 102 | return "mock"; |
| 103 | } |
| 104 | |
| 105 | __attribute__((weak)) |
| 106 | vb2_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)) |
| 113 | vb2_error_t vb2ex_diag_memory_full_test(int reset, const char **out) |
| 114 | { |
| 115 | *out = "mock"; |
| 116 | return VB2_SUCCESS; |
| 117 | } |
Joel Kitching | 37ae620 | 2021-01-18 15:56:42 +0800 | [diff] [blame^] | 118 | |
| 119 | __attribute__((weak)) |
| 120 | void vb2ex_msleep(uint32_t msec) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | __attribute__((weak)) |
| 125 | void vb2ex_beep(uint32_t msec, uint32_t frequency) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | __attribute__((weak)) |
| 130 | uint32_t vb2ex_get_locale_count(void) |
| 131 | { |
| 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | __attribute__((weak)) |
| 136 | uint32_t vb2ex_get_bootloader_count(void) |
| 137 | { |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | __attribute__((weak)) |
| 142 | int vb2ex_physical_presence_pressed(void) |
| 143 | { |
| 144 | return 0; |
| 145 | } |
| 146 | |
| 147 | __attribute__((weak)) |
| 148 | vb2_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 | } |