Software APIs
sw
device
silicon_creator
rom_ext
e2e
boot_svc
boot_svc_test_lib.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/rom_ext/e2e/boot_svc/boot_svc_test_lib.h"
6
7
#include "
sw/device/lib/base/bitfield.h
"
8
#include "sw/device/lib/base/status.h"
9
#include "sw/device/silicon_creator/lib/boot_log.h"
10
#include "sw/device/silicon_creator/lib/drivers/retention_sram.h"
11
#include "sw/device/silicon_creator/lib/drivers/rstmgr.h"
12
13
status_t
boot_svc_test_init(
retention_sram_t
*retram, boot_svc_test_t
test
) {
14
boot_log_t
*
boot_log
= &retram->
creator
.
boot_log
;
15
TRY(boot_log_check(
boot_log
));
16
17
boot_svc_retram_t
*state = (
boot_svc_retram_t
*)&retram->
owner
;
18
19
if (
bitfield_bit32_read
(retram->
creator
.
reset_reasons
,
20
kRstmgrReasonPowerOn)) {
21
memset
(&retram->
owner
, 0,
sizeof
(retram->
owner
));
22
}
23
24
if
(state->test != 0 && state->test !=
test
) {
25
return
INTERNAL();
26
}
27
28
if
(state->test == 0) {
29
state->test =
test
;
30
state->state = kBootSvcTestStateInit;
31
}
32
state->current_side = (
boot_log
->
bl0_slot
== kBootSlotA) ?
'A'
33
: (
boot_log
->
bl0_slot
== kBootSlotB) ?
'B'
34
:
'x'
;
35
state->primary_side = (
boot_log
->
primary_bl0_slot
== kBootSlotA) ?
'A'
36
: (
boot_log
->
primary_bl0_slot
== kBootSlotB) ?
'B'
37
:
'x'
;
38
state->partition[state->boots] = state->current_side;
39
state->boots += 1;
40
return
OK_STATUS();
41
}
Return to
OpenTitan Documentation