1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include "pico/bootrom.h"
8 
9 /// \tag::table_lookup[]
10 
rom_func_lookup(uint32_t code)11 void *rom_func_lookup(uint32_t code) {
12     return rom_func_lookup_inline(code);
13 }
14 
rom_data_lookup(uint32_t code)15 void *rom_data_lookup(uint32_t code) {
16     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
17     uint16_t *data_table = (uint16_t *) rom_hword_as_ptr(0x16);
18     return rom_table_lookup(data_table, code);
19 }
20 /// \end::table_lookup[]
21 
rom_funcs_lookup(uint32_t * table,unsigned int count)22 bool rom_funcs_lookup(uint32_t *table, unsigned int count) {
23     bool ok = true;
24     for (unsigned int i = 0; i < count; i++) {
25         table[i] = (uintptr_t) rom_func_lookup(table[i]);
26         if (!table[i]) ok = false;
27     }
28     return ok;
29 }
30