xref: /openbmc/qemu/include/hw/riscv/boot_opensbi.h (revision ab1b2ba9)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2019 Western Digital Corporation or its affiliates.
4  *
5  * Based on include/sbi/{fw_dynamic.h,sbi_scratch.h} from the OpenSBI project.
6  */
7 
8 #ifndef RISCV_BOOT_OPENSBI_H
9 #define RISCV_BOOT_OPENSBI_H
10 
11 /** Expected value of info magic ('OSBI' ascii string in hex) */
12 #define FW_DYNAMIC_INFO_MAGIC_VALUE     0x4942534f
13 
14 /** Maximum supported info version */
15 #define FW_DYNAMIC_INFO_VERSION         0x2
16 
17 /** Possible next mode values */
18 #define FW_DYNAMIC_INFO_NEXT_MODE_U     0x0
19 #define FW_DYNAMIC_INFO_NEXT_MODE_S     0x1
20 #define FW_DYNAMIC_INFO_NEXT_MODE_M     0x3
21 
22 enum sbi_scratch_options {
23     /** Disable prints during boot */
24     SBI_SCRATCH_NO_BOOT_PRINTS = (1 << 0),
25     /** Enable runtime debug prints */
26     SBI_SCRATCH_DEBUG_PRINTS = (1 << 1),
27 };
28 
29 /** Representation dynamic info passed by previous booting stage */
30 struct fw_dynamic_info {
31     /** Info magic */
32     target_long magic;
33     /** Info version */
34     target_long version;
35     /** Next booting stage address */
36     target_long next_addr;
37     /** Next booting stage mode */
38     target_long next_mode;
39     /** Options for OpenSBI library */
40     target_long options;
41     /**
42      * Preferred boot HART id
43      *
44      * It is possible that the previous booting stage uses same link
45      * address as the FW_DYNAMIC firmware. In this case, the relocation
46      * lottery mechanism can potentially overwrite the previous booting
47      * stage while other HARTs are still running in the previous booting
48      * stage leading to boot-time crash. To avoid this boot-time crash,
49      * the previous booting stage can specify last HART that will jump
50      * to the FW_DYNAMIC firmware as the preferred boot HART.
51      *
52      * To avoid specifying a preferred boot HART, the previous booting
53      * stage can set it to -1UL which will force the FW_DYNAMIC firmware
54      * to use the relocation lottery mechanism.
55      */
56     target_long boot_hart;
57 };
58 
59 #endif
60