File tree Expand file tree Collapse file tree 2 files changed +6
-26
lines changed
src/rp2_common/pico_bootrom Expand file tree Collapse file tree 2 files changed +6
-26
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,13 @@ void *rom_data_lookup(uint32_t code) {
2222 rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn ) rom_hword_as_ptr (BOOTROM_TABLE_LOOKUP_OFFSET );
2323 uint16_t * data_table = (uint16_t * ) rom_hword_as_ptr (BOOTROM_DATA_TABLE_OFFSET );
2424 return rom_table_lookup (data_table , code );
25+ #else
26+ #ifdef __riscv
27+ uint32_t rom_offset_adjust = rom_size_is_64k () ? 32 * 1024 : 0 ;
28+ rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn ) (uintptr_t )* (uint16_t * )(BOOTROM_TABLE_LOOKUP_OFFSET + rom_offset_adjust );
2529#else
2630 rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn ) (uintptr_t )* (uint16_t * )(BOOTROM_TABLE_LOOKUP_OFFSET );
31+ #endif
2732 return rom_table_lookup (code , RT_FLAG_DATA );
2833#endif
2934}
Original file line number Diff line number Diff line change @@ -174,32 +174,7 @@ __force_inline static void *rom_hword_as_ptr(uint16_t rom_address) {
174174#ifdef __riscv
175175static __force_inline bool rom_size_is_64k (void ) {
176176#ifdef RASPBERRYPI_AMETHYST_FPGA
177- // Detect ROM size by testing for bus fault at +32k
178- uint result ;
179- pico_default_asm_volatile (
180- "li %0, 0\n"
181- // Save and disable IRQs before touching trap vector
182- "csrr t2, mstatus\n"
183- "csrci mstatus, 0x8\n"
184- // Set up trap vector to skip the instruction which sets the %0 flag
185- "la t0, 1f\n"
186- "csrrw t0, mtvec, t0\n"
187- // This load will fault if the bootrom is no larger than 32k:
188- "li t1, 32 * 1024\n"
189- "lw t1, (t1)\n"
190- // No fault, so set return to true
191- "li %0, 1\n"
192- ".p2align 2\n"
193- // Always end up back here, restore the trap table
194- "1:\n"
195- "csrw mtvec, t0\n"
196- // Now safe to restore interrupts
197- "csrw mstatus, t2\n"
198- : "= r " (result )
199- :
200- : "t0 ", "t1" , "t2"
201- );
202- return result ;
177+ return * (uint16_t * )0x14 >= 0x8000 ;
203178#else
204179 return false;
205180#endif
You can’t perform that action at this time.
0 commit comments