7#ifndef _PLATFORM_BOOTROM_H
8#define _PLATFORM_BOOTROM_H
21#define ROM_FUNC_POPCOUNT32 ROM_TABLE_CODE('P', '3')
22#define ROM_FUNC_REVERSE32 ROM_TABLE_CODE('R', '3')
23#define ROM_FUNC_CLZ32 ROM_TABLE_CODE('L', '3')
24#define ROM_FUNC_CTZ32 ROM_TABLE_CODE('T', '3')
25#define ROM_FUNC_MEMSET ROM_TABLE_CODE('M', 'S')
26#define ROM_FUNC_MEMSET4 ROM_TABLE_CODE('S', '4')
27#define ROM_FUNC_MEMCPY ROM_TABLE_CODE('M', 'C')
28#define ROM_FUNC_MEMCPY44 ROM_TABLE_CODE('C', '4')
29#define ROM_FUNC_RESET_USB_BOOT ROM_TABLE_CODE('U', 'B')
30#define ROM_FUNC_CONNECT_INTERNAL_FLASH ROM_TABLE_CODE('I', 'F')
31#define ROM_FUNC_FLASH_EXIT_XIP ROM_TABLE_CODE('E', 'X')
32#define ROM_FUNC_FLASH_RANGE_ERASE ROM_TABLE_CODE('R', 'E')
33#define ROM_FUNC_FLASH_RANGE_PROGRAM ROM_TABLE_CODE('R', 'P')
34#define ROM_FUNC_FLASH_FLUSH_CACHE ROM_TABLE_CODE('F', 'C')
35#define ROM_FUNC_FLASH_ENTER_CMD_XIP ROM_TABLE_CODE('C', 'X')
46#define ROM_TABLE_CODE(c1, c2) ((c1) | ((c2) << 8))
52typedef uint32_t (*rom_popcount32_fn)(uint32_t);
53typedef uint32_t (*rom_reverse32_fn)(uint32_t);
54typedef uint32_t (*rom_clz32_fn)(uint32_t);
55typedef uint32_t (*rom_ctz32_fn)(uint32_t);
56typedef uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);
57typedef uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);
58typedef uint32_t *(*rom_memcpy_fn)(uint8_t *,
const uint8_t *, uint32_t);
59typedef uint32_t *(*rom_memcpy44_fn)(uint32_t *,
const uint32_t *, uint32_t);
60typedef void __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);
61typedef rom_reset_usb_boot_fn reset_usb_boot_fn;
62typedef void (*rom_connect_internal_flash_fn)(void);
63typedef void (*rom_flash_exit_xip_fn)(void);
64typedef void (*rom_flash_range_erase_fn)(uint32_t, size_t, uint32_t, uint8_t);
65typedef void (*rom_flash_range_program_fn)(uint32_t,
const uint8_t*, size_t);
66typedef void (*rom_flash_flush_cache_fn)(void);
67typedef void (*rom_flash_enter_cmd_xip_fn)(void);
117typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);
120#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
129 rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
130 uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
131 return rom_table_lookup(func_table, code);
151static inline void __attribute__((noreturn))
reset_usb_boot(uint32_t usb_activity_gpio_pin_mask,
152 uint32_t disable_interface_mask) {
153 rom_reset_usb_boot_fn func = (rom_reset_usb_boot_fn)
rom_func_lookup(ROM_FUNC_RESET_USB_BOOT);
154 func(usb_activity_gpio_pin_mask, disable_interface_mask);
static uint32_t rom_table_code(uint8_t c1, uint8_t c2)
Return a bootrom lookup code based on two ASCII characters.
Definition: bootrom.h:82
bool rom_funcs_lookup(uint32_t *table, unsigned int count)
Helper function to lookup the addresses of multiple bootrom functions.
Definition: bootrom.c:29
#define ROM_TABLE_CODE(c1, c2)
Return a bootrom lookup code based on two ASCII characters.
Definition: bootrom.h:46
static void reset_usb_boot(uint32_t usb_activity_gpio_pin_mask, uint32_t disable_interface_mask)
Reboot the device into BOOTSEL mode.
Definition: bootrom.h:151
static __force_inline void * rom_func_lookup_inline(uint32_t code)
Lookup a bootrom function by code. This method is forceably inlined into the caller for FLASH/RAM sen...
Definition: bootrom.h:128
void * rom_func_lookup(uint32_t code)
Lookup a bootrom function by code.
Definition: bootrom.c:18
void * rom_data_lookup(uint32_t code)
Lookup a bootrom address by code.
Definition: bootrom.c:22