Software APIs
boot_svc_next_boot_bl0_slot.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_NEXT_BOOT_BL0_SLOT_H_
6#define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_NEXT_BOOT_BL0_SLOT_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
15#ifdef __cplusplus
16extern "C" {
17#endif // __cplusplus
18
19enum {
20 /** Next BL0 slot request: `NEXT`. */
21 kBootSvcNextBl0SlotReqType = 0x5458454e,
22 /** Next BL0 slot response: `TXEN`. */
23 kBootSvcNextBl0SlotResType = 0x4e455854,
24};
25
26/**
27 * A Next Boot BL0 Slot request message.
28 */
30 /**
31 * Boot services message header.
32 */
33 boot_svc_header_t header;
34 /**
35 * BL0 slot to boot on next reboot.
36 */
37 uint32_t next_bl0_slot;
38 /**
39 * BL0 slot to set as the primary boot slot.
40 */
42} boot_svc_next_boot_bl0_slot_req_t;
43
44OT_ASSERT_MEMBER_OFFSET(boot_svc_next_boot_bl0_slot_req_t, header, 0);
45OT_ASSERT_MEMBER_OFFSET(boot_svc_next_boot_bl0_slot_req_t, next_bl0_slot,
47OT_ASSERT_MEMBER_OFFSET(boot_svc_next_boot_bl0_slot_req_t, primary_bl0_slot,
49OT_ASSERT_SIZE(boot_svc_next_boot_bl0_slot_req_t, 52);
50
51/**
52 * A Next Boot BL0 Slot response message.
53 */
55 /**
56 * Boot services message header.
57 */
58 boot_svc_header_t header;
59 /**
60 * Response status from the ROM_EXT.
61 */
62 rom_error_t status;
63 /**
64 * Which slot is primary.
65 */
67} boot_svc_next_boot_bl0_slot_res_t;
68
69OT_ASSERT_MEMBER_OFFSET(boot_svc_next_boot_bl0_slot_res_t, header, 0);
70OT_ASSERT_MEMBER_OFFSET(boot_svc_next_boot_bl0_slot_res_t, status,
72OT_ASSERT_MEMBER_OFFSET(boot_svc_next_boot_bl0_slot_res_t, primary_bl0_slot,
74OT_ASSERT_SIZE(boot_svc_next_boot_bl0_slot_res_t, 52);
75
76/**
77 * Initialize a Next Boot BL0 Slot Request message.
78 *
79 * @param primary_slot Slot to set as primary.
80 * @param next_slot Slot to boot into on reboot.
81 * @param[out] msg Output buffer for the message.
82 */
83void boot_svc_next_boot_bl0_slot_req_init(
84 uint32_t primary_slot, uint32_t next_slot,
85 boot_svc_next_boot_bl0_slot_req_t *msg);
86
87/**
88 * Initialize a Next Boot BL0 Slot Response message.
89 *
90 * @param primary_slot Slot that is primary.
91 * @param status Reponse from the ROM_EXT after receiving the request.
92 * @param[out] msg Output buffer for the message.
93 */
94void boot_svc_next_boot_bl0_slot_res_init(
95 rom_error_t status, uint32_t primary_slot,
96 boot_svc_next_boot_bl0_slot_res_t *msg);
97
98#ifdef __cplusplus
99} // extern "C"
100#endif // __cplusplus
101
102#endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_BOOT_SVC_BOOT_SVC_NEXT_BOOT_BL0_SLOT_H_