File tree Expand file tree Collapse file tree 2 files changed +27
-17
lines changed 
src/rp2_common/pico_bootrom Expand file tree Collapse file tree 2 files changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -14,25 +14,9 @@ void *rom_func_lookup(uint32_t code) {
1414    return  rom_func_lookup_inline (code );
1515}
1616
17- #pragma  GCC diagnostic push
18- // diagnostic: GCC thinks near-zero value is a null pointer member access, but it's not 
19- #pragma  GCC diagnostic ignored "-Warray-bounds"
2017void  * rom_data_lookup (uint32_t  code ) {
21- #if  PICO_RP2040 
22-     rom_table_lookup_fn  rom_table_lookup  =  (rom_table_lookup_fn ) rom_hword_as_ptr (BOOTROM_TABLE_LOOKUP_OFFSET );
23-     uint16_t  * data_table  =  (uint16_t  * ) rom_hword_as_ptr (BOOTROM_DATA_TABLE_OFFSET );
24-     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 );
29- #else 
30-     rom_table_lookup_fn  rom_table_lookup  =  (rom_table_lookup_fn ) (uintptr_t )* (uint16_t * )(BOOTROM_TABLE_LOOKUP_OFFSET );
31- #endif 
32-     return  rom_table_lookup (code , RT_FLAG_DATA );
33- #endif 
18+     return  rom_data_lookup_inline (code );
3419}
35- #pragma  GCC diagnostic pop
3620/// \end::table_lookup[] 
3721
3822bool  rom_funcs_lookup (uint32_t  * table , unsigned int   count ) {
Original file line number Diff line number Diff line change @@ -215,6 +215,32 @@ static __force_inline void *rom_func_lookup_inline(uint32_t code) {
215215}
216216#pragma  GCC diagnostic pop
217217
218+ /*! 
219+  * \brief Lookup a bootrom data address by its code. This method is forcibly inlined into the caller for FLASH/RAM sensitive code usage 
220+  * \ingroup pico_bootrom 
221+  * \param code the code 
222+  * \return a pointer to the data, or NULL if the code does not match any bootrom data 
223+  */ 
224+ #pragma  GCC diagnostic push
225+ // diagnostic: GCC thinks near-zero value is a null pointer member access, but it's not 
226+ #pragma  GCC diagnostic ignored "-Warray-bounds"
227+ static  __force_inline  void  * rom_data_lookup_inline (uint32_t  code ) {
228+ #if  PICO_RP2040 
229+     rom_table_lookup_fn  rom_table_lookup  =  (rom_table_lookup_fn ) rom_hword_as_ptr (BOOTROM_TABLE_LOOKUP_OFFSET );
230+     uint16_t  * data_table  =  (uint16_t  * ) rom_hword_as_ptr (BOOTROM_DATA_TABLE_OFFSET );
231+     return  rom_table_lookup (data_table , code );
232+ #else 
233+ #ifdef  __riscv 
234+     uint32_t  rom_offset_adjust  =  rom_size_is_64k () ? 32  *  1024  : 0 ;
235+     rom_table_lookup_fn  rom_table_lookup  =  (rom_table_lookup_fn ) (uintptr_t )* (uint16_t * )(BOOTROM_TABLE_LOOKUP_OFFSET  +  rom_offset_adjust );
236+ #else 
237+     rom_table_lookup_fn  rom_table_lookup  =  (rom_table_lookup_fn ) (uintptr_t )* (uint16_t * )(BOOTROM_TABLE_LOOKUP_OFFSET );
238+ #endif 
239+     return  rom_table_lookup (code , RT_FLAG_DATA );
240+ #endif 
241+ }
242+ #pragma  GCC diagnostic pop
243+ 
218244/*! 
219245 * \brief Reboot the device into BOOTSEL mode 
220246 * \ingroup pico_bootrom 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments