| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include <stdarg.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include <stdio.h> |
| 11 |
#include <sys/time.h> |
| 12 |
|
| 13 |
#include "2api.h" |
| 14 |
#include "2common.h" |
| 15 |
#include "2sysincludes.h" |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
__attribute__((weak)) |
| 21 |
void vb2ex_printf(const char *func, const char *fmt, ...) |
| 22 |
{ |
| 23 |
#ifdef VBOOT_DEBUG |
| 24 |
va_list ap; |
| 25 |
va_start(ap, fmt); |
| 26 |
if (func) |
| 27 |
fprintf(stderr, "%s: ", func); |
| 28 |
vfprintf(stderr, fmt, ap); |
| 29 |
va_end(ap); |
| 30 |
#endif |
| 31 |
} |
| 32 |
|
| 33 |
__attribute__((weak)) |
| 34 |
void vb2ex_abort(void) |
| 35 |
{ |
| 36 |
|
| 37 |
abort(); |
| 38 |
} |
| 39 |
|
| 40 |
__attribute__((weak)) |
| 41 |
vb2_error_t vb2ex_commit_data(struct vb2_context *ctx) |
| 42 |
{ |
| 43 |
ctx->flags &= ~VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED; |
| 44 |
ctx->flags &= ~VB2_CONTEXT_SECDATA_KERNEL_CHANGED; |
| 45 |
ctx->flags &= ~VB2_CONTEXT_NVDATA_CHANGED; |
| 46 |
return VB2_SUCCESS; |
| 47 |
} |
| 48 |
|
| 49 |
__attribute__((weak)) |
| 50 |
vb2_error_t vb2ex_read_resource(struct vb2_context *ctx, |
| 51 |
enum vb2_resource_index index, uint32_t offset, |
| 52 |
void *buf, uint32_t size) |
| 53 |
{ |
| 54 |
VB2_DEBUG("function not implemented\n"); |
| 55 |
return VB2_ERROR_EX_UNIMPLEMENTED; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
__attribute__((weak)) |
| 62 |
vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx) |
| 63 |
{ |
| 64 |
VB2_DEBUG("function not implemented\n"); |
| 65 |
return VB2_ERROR_EX_UNIMPLEMENTED; |
| 66 |
} |
| 67 |
|
| 68 |
__attribute__((weak)) |
| 69 |
vb2_error_t vb2ex_tpm_set_mode(enum vb2_tpm_mode mode_val) |
| 70 |
{ |
| 71 |
VB2_DEBUG("function not implemented\n"); |
| 72 |
return VB2_ERROR_EX_UNIMPLEMENTED; |
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
__attribute__((weak)) |
| 79 |
vb2_error_t vb2ex_ec_running_rw(int *in_rw) |
| 80 |
{ |
| 81 |
*in_rw = 0; |
| 82 |
return VB2_SUCCESS; |
| 83 |
} |
| 84 |
|
| 85 |
__attribute__((weak)) |
| 86 |
vb2_error_t vb2ex_ec_jump_to_rw(void) |
| 87 |
{ |
| 88 |
return VB2_SUCCESS; |
| 89 |
} |
| 90 |
|
| 91 |
__attribute__((weak)) |
| 92 |
vb2_error_t vb2ex_ec_disable_jump(void) |
| 93 |
{ |
| 94 |
return VB2_SUCCESS; |
| 95 |
} |
| 96 |
|
| 97 |
__attribute__((weak)) |
| 98 |
vb2_error_t vb2ex_ec_hash_image(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_get_expected_image_hash(enum vb2_firmware_selection select, |
| 110 |
const uint8_t **hash, int *hash_size) |
| 111 |
{ |
| 112 |
static const uint8_t fake_hash[32] = {1, 2, 3, 4}; |
| 113 |
|
| 114 |
*hash = fake_hash; |
| 115 |
*hash_size = sizeof(fake_hash); |
| 116 |
return VB2_SUCCESS; |
| 117 |
} |
| 118 |
|
| 119 |
__attribute__((weak)) |
| 120 |
vb2_error_t vb2ex_ec_update_image(enum vb2_firmware_selection select) |
| 121 |
{ |
| 122 |
return VB2_SUCCESS; |
| 123 |
} |
| 124 |
|
| 125 |
__attribute__((weak)) |
| 126 |
vb2_error_t vb2ex_ec_protect(void) |
| 127 |
{ |
| 128 |
return VB2_SUCCESS; |
| 129 |
} |
| 130 |
|
| 131 |
__attribute__((weak)) |
| 132 |
vb2_error_t vb2ex_ec_vboot_done(struct vb2_context *ctx) |
| 133 |
{ |
| 134 |
return VB2_SUCCESS; |
| 135 |
} |
| 136 |
|
| 137 |
__attribute__((weak)) |
| 138 |
vb2_error_t vb2ex_ec_battery_cutoff(void) |
| 139 |
{ |
| 140 |
return VB2_SUCCESS; |
| 141 |
} |
| 142 |
|
| 143 |
__attribute__((weak)) |
| 144 |
vb2_error_t vb2ex_auxfw_check(enum vb2_auxfw_update_severity *severity) |
| 145 |
{ |
| 146 |
*severity = VB2_AUXFW_NO_UPDATE; |
| 147 |
return VB2_SUCCESS; |
| 148 |
} |
| 149 |
|
| 150 |
__attribute__((weak)) |
| 151 |
vb2_error_t vb2ex_auxfw_update(void) |
| 152 |
{ |
| 153 |
return VB2_SUCCESS; |
| 154 |
} |
| 155 |
|
| 156 |
__attribute__((weak)) |
| 157 |
vb2_error_t vb2ex_auxfw_finalize(struct vb2_context *ctx) |
| 158 |
{ |
| 159 |
return VB2_SUCCESS; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
__attribute__((weak)) |
| 166 |
uint32_t vb2ex_mtime(void) |
| 167 |
{ |
| 168 |
struct timeval tv; |
| 169 |
gettimeofday(&tv, NULL); |
| 170 |
return tv.tv_sec * VB2_MSEC_PER_SEC + tv.tv_usec / VB2_USEC_PER_MSEC; |
| 171 |
} |