File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,15 @@ use self::algo::*;
1010fn find_func < T > ( tag : [ u8 ; 2 ] ) -> T {
1111 let tag = u16:: from_le_bytes ( tag) as u32 ;
1212 type RomTableLookupFn = unsafe extern "C" fn ( table : * const u16 , code : u32 ) -> usize ;
13+ /// This location in flash holds a 16-bit truncated pointer for the ROM lookup function
14+ const ROM_TABLE_LOOKUP_PTR : * const u16 = 0x0000_0018 as _ ;
15+ /// This location in flash holds a 16-bit truncated pointer for the ROM function table
16+ /// (there's also a ROM data table which we don't need)
17+ const FUNC_TABLE : * const u16 = 0x0000_0014 as _ ;
1318 unsafe {
14- let lookup_func = core :: ptr :: read ( 0x0000_0018 as * const u16 ) as usize ;
19+ let lookup_func = ROM_TABLE_LOOKUP_PTR . read ( ) as usize ;
1520 let lookup_func: RomTableLookupFn = core:: mem:: transmute ( lookup_func) ;
16- let table = core :: ptr :: read ( 0x0000_00014 as * const u16 ) as usize ;
21+ let table = FUNC_TABLE . read ( ) as usize ;
1722 let result = lookup_func ( table as * const u16 , tag) ;
1823 if result == 0 {
1924 panic ! ( "Function not found" ) ;
You can’t perform that action at this time.
0 commit comments