Software APIs
boot_svc_empty.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "sw/device/silicon_creator/lib/boot_svc/boot_svc_empty.h"
6 
7 void boot_svc_empty_req_init(boot_svc_empty_t *msg) {
8  // We use `uint32_t` instead of `size_t` so that end-of-loop check passes both
9  // on- and off-target tests.
10  uint32_t i = 0, j = kBootSvcEmptyPayloadWordCount - 1;
11  for (; launder32(i) < kBootSvcEmptyPayloadWordCount &&
12  launder32(j) < kBootSvcEmptyPayloadWordCount;
13  ++i, --j) {
14  msg->payload[i] = 0;
15  }
16  HARDENED_CHECK_EQ(i, kBootSvcEmptyPayloadWordCount);
17  HARDENED_CHECK_EQ(j, UINT32_MAX);
18  boot_svc_header_finalize(kBootSvcEmptyReqType, sizeof(boot_svc_empty_t),
19  &msg->header);
20 }
21 
22 void boot_svc_empty_res_init(boot_svc_empty_t *msg) {
23  boot_svc_header_finalize(kBootSvcEmptyResType, sizeof(boot_svc_empty_t),
24  &msg->header);
25 }