Repository: raspberrypi/pico-sdk
File: src/rp2_common/pico_bootrom/include/pico/bootrom.h (C/C++)

Code before:

/*!
 * \brief Lookup a bootrom address by code
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the data, or NULL if the code does not match any bootrom function
 */
void *rom_data_lookup(uint32_t code);

/*!
 * \brief Helper function to lookup the addresses of multiple bootrom functions
 * \ingroup pico_bootrom
 *
 * This method looks up the 'codes' in the table, and convert each table entry to the looked up
 * function pointer, if there is a function for that code in the bootrom.
 *
 * \param table an IN/OUT array, elements are codes on input, function pointers on success.
 * \param count the number of elements in the table
 * \return true if all the codes were found, and converted to function pointers, false otherwise
 */
bool rom_funcs_lookup(uint32_t *table, unsigned int count);

// The following is a list of bootrom functions available via rom_func_lookup and their signature

typedef uint32_t (*rom_popcount32_fn)(uint32_t);
#define ROM_FUNC_POPCOUNT32             rom_table_code('P','3')

typedef uint32_t (*rom_reverse32_fn)(uint32_t);
#define ROM_FUNC_REVERSE32              rom_table_code('R','3')

typedef uint32_t (*rom_clz32_fn)(uint32_t);
#define ROM_FUNC_CLZ32                  rom_table_code('L','3')

typedef uint32_t (*rom_ctz32_fn)(uint32_t);
#define ROM_FUNC_CTZ32                  rom_table_code('T','3')

typedef uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);
#define ROM_FUNC_MEMSET                 rom_table_code('M','S')

typedef uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);
#define ROM_FUNC_MEMSET4                rom_table_code('S','4')

typedef uint32_t *(*rom_memcpy_fn)(uint8_t *, const uint8_t *, uint32_t);
#define ROM_FUNC_MEMCPY                 rom_table_code('M','C')

typedef uint32_t *(*rom_memcpy44_fn)(uint32_t *, const uint32_t *, uint32_t);
#define ROM_FUNC_MEMCPY44               rom_table_code('C','4')

typedef void __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);
typedef rom_reset_usb_boot_fn reset_usb_boot_fn; // kept for backwards compatibility
#define ROM_FUNC_RESET_USB_BOOT         rom_table_code('U','B')

Review comment (suggestion):
Could / should these `#define`s also be used in https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S ?
EDIT: also `src/rp2_common/pico_mem_ops/mem_ops_aeabi.S`

Code after:

/*!
 * \brief Lookup a bootrom address by code
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the data, or NULL if the code does not match any bootrom function
 */
void *rom_data_lookup(uint32_t code);

/*!
 * \brief Helper function to lookup the addresses of multiple bootrom functions
 * \ingroup pico_bootrom
 *
 * This method looks up the 'codes' in the table, and convert each table entry to the looked up
 * function pointer, if there is a function for that code in the bootrom.
 *
 * \param table an IN/OUT array, elements are codes on input, function pointers on success.
 * \param count the number of elements in the table
 * \return true if all the codes were found, and converted to function pointers, false otherwise
 */
bool rom_funcs_lookup(uint32_t *table, unsigned int count);

// The following is a list of bootrom functions available via rom_func_lookup and their signature

typedef uint32_t (*rom_popcount32_fn)(uint32_t);
#define ROM_FUNC_POPCOUNT32             rom_table_code('P', '3')

typedef uint32_t (*rom_reverse32_fn)(uint32_t);
#define ROM_FUNC_REVERSE32              rom_table_code('R', '3')

typedef uint32_t (*rom_clz32_fn)(uint32_t);
#define ROM_FUNC_CLZ32                  rom_table_code('L', '3')

typedef uint32_t (*rom_ctz32_fn)(uint32_t);
#define ROM_FUNC_CTZ32                  rom_table_code('T', '3')

typedef uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);
#define ROM_FUNC_MEMSET                 rom_table_code('M', 'S')

typedef uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);
#define ROM_FUNC_MEMSET4                rom_table_code('S', '4')

typedef uint32_t *(*rom_memcpy_fn)(uint8_t *, const uint8_t *, uint32_t);
#define ROM_FUNC_MEMCPY                 rom_table_code('M', 'C')

typedef uint32_t *(*rom_memcpy44_fn)(uint32_t *, const uint32_t *, uint32_t);
#define ROM_FUNC_MEMCPY44               rom_table_code('C', '4')

typedef void __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);
typedef rom_reset_usb_boot_fn reset_usb_boot_fn; // kept for backwards compatibility
#define ROM_FUNC_RESET_USB_BOOT         rom_table_code('U', 'B')