bl702_hal/system/
romfunc.rs

1use self::data::ROM_API_INDEX_e;
2use self::data::ROM_APITABLE_ADDR;
3
4pub mod data;
5
6/// Look up the address of the ROM function in the function table.
7/// Generate a function pointer from that
8///
9/// # Safety
10///
11/// The function pointer needs to be transmuted to the correct signature - take care to match the signature correctly
12/// or memory corruption or other UB could occur
13pub unsafe fn rom_fn_ptr(func: ROM_API_INDEX_e) -> *const () {
14    let rom_function_table_base = ROM_APITABLE_ADDR as *mut usize;
15    let func_entry = rom_function_table_base.wrapping_add(func as usize);
16    let func_addr = func_entry.read_volatile();
17    func_addr as *const ()
18}