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