Software APIs
boot_svc_ownership_activate.h
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#ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_ACTIVATE_H_
6#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_ACTIVATE_H_
7
8#include <stdint.h>
9
12#include "sw/device/silicon_creator/lib/boot_svc/boot_svc_header.h"
13#include "sw/device/silicon_creator/lib/error.h"
14#include "sw/device/silicon_creator/lib/nonce.h"
15#include "sw/device/silicon_creator/lib/ownership/datatypes.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif // __cplusplus
20
21enum {
22 /** Ownership activate request: `ACTV`. */
23 kBootSvcOwnershipActivateReqType = 0x56544341,
24 /** Ownership activate response: `VTCA`. */
25 kBootSvcOwnershipActivateResType = 0x41435456,
26};
27
28/**
29 * An Ownership Activate request.
30 */
32 /**
33 * Boot services message header.
34 */
35 boot_svc_header_t header;
36 /**
37 * Which side of the flash is primary after activation.
38 */
40 /**
41 * The 64-bit DIN subfield of the full 256-bit device ID.
42 */
43 uint32_t din[2];
44 /**
45 * Erase previous owner's flash (hardened_bool_t).
46 */
48 /**
49 * Reserved for future use.
50 */
51 uint32_t reserved[31];
52 /**
53 * The current ownership nonce.
54 */
55 nonce_t nonce;
56 /**
57 * Signature over [primary_bl0_slot..nonce]
58 */
59 owner_signature_t signature;
60
61} boot_svc_ownership_activate_req_t;
62
63OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, header, 0);
64OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, primary_bl0_slot,
66OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, din,
68OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, erase_previous,
70OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, reserved,
72OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, nonce,
74OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, signature,
76OT_ASSERT_SIZE(boot_svc_ownership_activate_req_t, 256);
77
78/**
79 * An Ownership Activate response.
80 */
82 /**
83 * Boot services message header.
84 */
85 boot_svc_header_t header;
86 /**
87 * Response status from the ROM_EXT.
88 */
89 rom_error_t status;
90} boot_svc_ownership_activate_res_t;
91
92OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_res_t, header, 0);
93OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_res_t, status,
95OT_ASSERT_SIZE(boot_svc_ownership_activate_res_t, 48);
96
97/**
98 * Initialize an ownership activate request.
99 *
100 * @param[out] msg Output buffer for the message.
101 */
102void boot_svc_ownership_activate_req_init(
103 uint32_t primary_bl0_slot, uint32_t erase_previous, nonce_t nonce,
104 const owner_signature_t *signature, boot_svc_ownership_activate_req_t *msg);
105
106/**
107 * Initialize an ownership activate response.
108 *
109 * @param status Reponse from the ROM_EXT after receiving the request.
110 * @param[out] msg Output buffer for the message.
111 */
112void boot_svc_ownership_activate_res_init(
113 rom_error_t status, boot_svc_ownership_activate_res_t *msg);
114
115#ifdef __cplusplus
116} // extern "C"
117#endif // __cplusplus
118
119#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_ACTIVATE_H_