11#pragma once
2+ #include " boot_mode_table.hh"
23#include " print.hh"
34#include < cstdint>
45#include < string_view>
56
6- extern uint32_t boot_mode_table_addr[];
7-
87namespace BootDetect
98{
109
@@ -55,7 +54,6 @@ constexpr std::string_view bootmethod_string(BootMethod method)
5554// - boot instance = bit 31:16
5655// - boot device = bit 15:0
5756//
58- static constexpr uint32_t BOOTROM_PARAM_ADDR = 0x2FFC0078 ;
5957static constexpr uint32_t BOOTROM_MODE_MASK = 0x0000FFFF ;
6058static constexpr uint32_t BOOTROM_MODE_SHIFT = 0 ;
6159static constexpr uint32_t BOOTROM_INSTANCE_MASK = 0xFFFF0000 ;
@@ -65,28 +63,6 @@ static constexpr uint32_t BOOT_TYPE_SHIFT = 4;
6563static constexpr uint32_t BOOT_INSTANCE_MASK = 0x0F ;
6664static constexpr uint32_t BOOT_INSTANCE_SHIFT = 0 ;
6765
68- inline uint32_t read_raw_bootrom_itf ()
69- {
70- print (" &boot_mode_table_addr = 0x" , Hex{(uint32_t )boot_mode_table_addr}, " \n " );
71-
72- if ((uint32_t )boot_mode_table_addr == 0 ) {
73- print (" Boot mode table address not defined in linker script. Presuming SD Card boot\n " );
74- return BOOT_SDCARD << BOOTROM_MODE_SHIFT;
75- }
76-
77- auto table_addr = boot_mode_table_addr[0 ];
78- print (" boot_mode_table_addr = 0x" , Hex{table_addr}, " \n " );
79-
80- if (table_addr == 0 ) {
81- print (" Boot mode table was not set by startup.s. Presuming SD Card boot\n " );
82- return BOOT_SDCARD << BOOTROM_MODE_SHIFT;
83- }
84-
85- auto val = *reinterpret_cast <uint32_t *>(table_addr);
86- print (" boot_mode value = 0x" , Hex{val}, " \n " );
87- return val;
88- }
89-
9066inline BootMethod read_boot_method ()
9167{
9268 uint32_t bootrom_itf = read_raw_bootrom_itf ();
0 commit comments