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 * Currently, this is not implemented.
47 */
49 /**
50 * Reserved for future use.
51 */
52 uint32_t reserved[31];
53 /**
54 * The current ownership nonce.
55 */
56 nonce_t nonce;
57 /**
58 * Signature over [primary_bl0_slot..nonce]
59 */
60 owner_signature_t signature;
61
62} boot_svc_ownership_activate_req_t;
63
64OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, header, 0);
65OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, primary_bl0_slot,
67OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, din,
69OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, erase_previous,
71OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, reserved,
73OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, nonce,
75OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_req_t, signature,
77OT_ASSERT_SIZE(boot_svc_ownership_activate_req_t, 256);
78
79/**
80 * An Ownership Activate response.
81 */
83 /**
84 * Boot services message header.
85 */
86 boot_svc_header_t header;
87 /**
88 * Response status from the ROM_EXT.
89 */
90 uint32_t status;
91} boot_svc_ownership_activate_res_t;
92
93OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_res_t, header, 0);
94OT_ASSERT_MEMBER_OFFSET(boot_svc_ownership_activate_res_t, status,
96OT_ASSERT_SIZE(boot_svc_ownership_activate_res_t, 48);
97
98/**
99 * Initialize an ownership activate request.
100 *
101 * @param[out] msg Output buffer for the message.
102 */
103void boot_svc_ownership_activate_req_init(
104 uint32_t primary_bl0_slot, uint32_t erase_previous, nonce_t nonce,
105 const owner_signature_t *signature, boot_svc_ownership_activate_req_t *msg);
106
107/**
108 * Initialize an ownership activate response.
109 *
110 * @param status Reponse from the ROM_EXT after receiving the request.
111 * @param[out] msg Output buffer for the message.
112 */
113void boot_svc_ownership_activate_res_init(
114 rom_error_t status, boot_svc_ownership_activate_res_t *msg);
115
116#ifdef __cplusplus
117} // extern "C"
118#endif // __cplusplus
119
120#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_OWNERSHIP_ACTIVATE_H_