ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_freestanding_mem.c File Reference

Project-owned freestanding memory ABI primitives (memset, memcpy, memmove, memcmp, memchr). More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_freestanding.h"
Include dependency graph for ra8_freestanding_mem.c:

Go to the source code of this file.

Functions

void * memset (void *dst, int value, size_t n)
 Fill memory with a constant byte value.
void * memcpy (void *dst, const void *src, size_t n)
 Copy memory area between non-overlapping regions.
void * memmove (void *dst, const void *src, size_t n)
 Copy memory area between potentially overlapping regions.
int memcmp (const void *a, const void *b, size_t n)
 Compare bytes in two memory areas.
void * memchr (const void *s, int c, size_t n)
 Locate a byte in a memory area.

Detailed Description

Project-owned freestanding memory ABI primitives (memset, memcpy, memmove, memcmp, memchr).

Tag
[Ring 0 / Foundation] {World: Dual}

Standard ISO C memory primitives implemented directly for the bare-metal RA8 target firmware. Compiled with loop-distribution optimization disabled to guarantee that the compiler never lowers primitive bodies into self-recursive runtime calls. Fully deterministic, bounds-safe, and heap-free.

Since
0.1.0

Definition in file ra8_freestanding_mem.c.

Function Documentation

◆ memchr()

void * memchr ( const void * s,
int c,
size_t n )

Locate a byte in a memory area.

Scans the initial n bytes of s for the first instance of c.

Parameters
[in]sPointer to memory buffer.
[in]cByte value to search for.
[in]nMaximum bytes to examine.
Returns
Pointer to matching byte, or nullptr if not found.
Return values
non-nullPointer to matching byte within s.
nullptrByte not found within first n bytes, or n is zero.
Precondition
s points to at least n readable bytes if n > 0.
s is addressable and valid.
Postcondition
Memory buffer is unmodified.
Returned pointer is within [s, s + n) on success.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory is not concurrently modified.
Since
0.1.0

Definition at line 164 of file ra8_freestanding_mem.c.

Referenced by elf_string_foreach(), internal_extract_class(), internal_extract_label(), internal_extract_meta(), internal_rtt_match_stage(), internal_scan_tags(), internal_urlname_path_start(), and mdl_extract_hits().

◆ memcmp()

int memcmp ( const void * a,
const void * b,
size_t n )

Compare bytes in two memory areas.

Compares the first n bytes of a and b as unsigned char.

Parameters
[in]aFirst memory area pointer.
[in]bSecond memory area pointer.
[in]nMaximum number of bytes to compare.
Returns
Negative if a < b, positive if a > b, 0 if equal.
Return values
0All n bytes match or n is zero.
<0First differing byte in a is less than in b.
>0First differing byte in a is greater than in b.
Precondition
a points to at least n readable bytes if n > 0.
b points to at least n readable bytes if n > 0.
Postcondition
Input buffers are unmodified.
Comparison semantics follow unsigned byte order.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Definition at line 136 of file ra8_freestanding_mem.c.

Referenced by cdc_echo_round(), demo_read_verify(), demo_restore(), demo_write_verify(), dfu_upload_verify(), er_image_loader(), er_nav_chapter(), fs_fmt_create_and_verify(), fs_fmt_rename_and_verify(), gcm_dec_ok(), gcm_enc_ok(), hid_read_round(), hid_read_round(), internal_attr_duplicate(), internal_bpp(), internal_bytes_equal(), internal_c6_cam_request_is(), internal_cache_decode(), internal_compare(), internal_cookie_field_is(), internal_data_offset(), internal_decode_entity(), internal_demo_read_once(), internal_demo_roundtrip(), internal_demo_roundtrip(), internal_demo_verify_cert_pin(), internal_dispatch(), internal_drive(), internal_end(), internal_format(), internal_is_webp(), internal_is_webp(), internal_jof_is_webp(), internal_kat_one(), internal_key_eq(), internal_mdl_state_decode_header(), internal_mdl_state_scan_slot(), internal_mdl_transfer_commit(), internal_name_chunk(), internal_net_tcp_on_estab(), internal_one_round_trip(), internal_parse_header_region(), internal_probe(), internal_probe_sniff(), internal_program_table(), internal_ra8_io_roundtrip_read_verify(), internal_rtt_drain(), internal_rtt_match_stage(), internal_section_table(), internal_swap_vfs_read_verify(), internal_tc_blob_roundtrip(), internal_upload_verify(), internal_urlname_last_path_marker(), internal_verify_book(), internal_zip_scan_window_for_eocd(), jof_parse(), kat_sha256(), microsd_verify_one(), mlun_verify_one(), ns_host_echo_round(), ospirw_verify_one(), priv_jof_png_prologue(), ra8_io_roundtrip_read_verify(), sdhi_card_block_roundtrip(), sdhi_demo_read_and_verify(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_ospi_raw(), sh_paged_hdr_ok(), verify_blob(), wlun_verify_one(), and worker_is_webp().

◆ memcpy()

void * memcpy ( void * dst,
const void * src,
size_t n )

Copy memory area between non-overlapping regions.

Copies n bytes from src to dst sequentially.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource buffer pointer.
[in]nNumber of bytes to copy.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst and src do not overlap.
dst and src point to at least n valid bytes if n > 0.
Postcondition
The n bytes at dst match the n bytes at src.
Source memory is unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Definition at line 70 of file ra8_freestanding_mem.c.

Referenced by app_flash_readback(), app_make_cfg(), app_make_manifest(), app_net_read(), board_net_poll_rx(), board_sd_read_block(), board_usb_bridge_bulk_in_take(), board_usb_bridge_bulk_out(), board_usb_bridge_dcp_in_take(), board_usb_bridge_dcp_out(), board_usb_feed_bulk_in(), board_usb_loop_bulk_out(), board_usb_loop_ctrl_out(), board_usbhs_host_shadow_handoff(), board_view_read_rgb888_fd(), book_src_read(), book_src_resident(), cb_host_output_open(), cb_trace_bind(), cm_ct_read(), cm_read(), comic_page_info(), demo_fat_fill_boot(), demo_fat_fill_boot(), demo_fat_fill_root(), demo_fat_fill_root(), demo_fat_fill_sector(), demo_msc_read(), demo_msc_write(), dfu_read(), dfu_write(), emulate_mve(), epub_miniz_realloc(), internal_apply_cookie_line(), internal_arena_realloc(), internal_arena_valid(), internal_authority_of(), internal_backing_read(), internal_bd_copy_slice(), internal_bdsink_fill_chunk(), internal_board_sd_stage_block(), internal_body_buffer_prefix(), internal_book_src_read_paged(), internal_c6_cam_audio_write_header(), internal_c6_get(), internal_c6_output_write(), internal_c6link_op_get_ap(), internal_c6link_op_get_mac(), internal_cache_body_leaf(), internal_cache_copy(), internal_cache_host_leaf(), internal_cache_read_block(), internal_cache_write_block(), internal_cli_artifact_url(), internal_compress_put(), internal_config_set_str(), internal_copy(), internal_copy_fits(), internal_copy_name(), internal_copy_object(), internal_copy_object(), internal_copy_object(), internal_cover_copy(), internal_cursor_entry(), internal_decode_header(), internal_decode_one(), internal_demo_bio_send(), internal_demo_http_get(), internal_demo_roundtrip(), internal_derive_stem(), internal_devcfg_deserialize(), internal_devcfg_serialize(), internal_devcfg_xm_read(), internal_devcfg_xm_write(), internal_dir_next(), internal_dir_pack_sector(), internal_dir_unpack_sector(), internal_download_all(), internal_download_manifest(), internal_drain_rx_slot(), internal_dump_row(), internal_emit(), internal_event_cb(), internal_exfat_list_emit(), internal_fat16_write_bpb(), internal_fat32_write_bpb(), internal_fat_dir_scan_sector(), internal_filter_prefix(), internal_float_to_u32(), internal_flush_band(), internal_h_memcpy(), internal_h_realloc(), internal_handle_init(), internal_hdr_read(), internal_host_echo_send_out(), internal_intern_name(), internal_jof_pull(), internal_json_str(), internal_library_act_on_node(), internal_library_remove_root(), internal_list_pages(), internal_make_header(), internal_make_name(), internal_make_span(), internal_mdl_accept_chunk(), internal_mdl_copy_field(), internal_mdl_http_field_copy(), internal_mdl_stage_headers(), internal_mdl_state_emit_chapters(), internal_mdl_state_encode(), internal_mdl_state_encode_header(), internal_mdl_state_parse_binary64(), internal_mdl_state_paths(), internal_mdl_transfer_commit(), internal_memory_capture(), internal_memory_capture(), internal_memory_read(), internal_memory_write(), internal_meta_candidate_path(), internal_meta_consume(), internal_miss(), internal_mram_read(), internal_mve_mem_exec(), internal_name(), internal_net_eth_hdr(), internal_net_queue(), internal_net_rx_arp(), internal_net_send_arp_reply(), internal_net_send_arp_request(), internal_net_send_tcp(), internal_packet_to_buffer(), internal_packet_to_buffer(), internal_panel_set_name(), internal_parent(), internal_parse_xml_tag(), internal_pax_apply(), internal_pdm_stream_data(), internal_png_consume_rows(), internal_png_translate(), internal_pointer_address(), internal_prof_decimate(), internal_ra8_esp_hosted_c6link_transfer(), internal_ram_read(), internal_ram_write(), internal_ram_write(), internal_ram_write(), internal_rbkc_header(), internal_read_at(), internal_read_block(), internal_render_svg(), internal_resolve_descriptor_path(), internal_resolve_one_leaf(), internal_resolve_path_rel(), internal_resolve_scheme_rel(), internal_sd_boot_frame(), internal_select_window(), internal_slab_next(), internal_slab_set_next(), internal_sort_pages(), internal_spans_overlap(), internal_split_output(), internal_split_output(), internal_split_output(), internal_split_path(), internal_split_path(), internal_stage_name(), internal_str_copy_trimmed(), internal_stub_read(), internal_submit_consume_orphan(), internal_super_read(), internal_swap_rows(), internal_tar_feed(), internal_tar_header(), internal_tar_member(), internal_temp_leaf(), internal_temp_name(), internal_temp_name(), internal_temp_name(), internal_temp_name(), internal_u32_to_float(), internal_urlname_copy(), internal_ustar_name(), internal_vmsc_fill_boot(), internal_vmsc_fill_root(), internal_vmsc_overlay_get(), internal_vmsc_overlay_put(), internal_write_block(), internal_write_entry(), internal_write_eth_header(), internal_write_one_sector(), internal_zip_workspace_realloc(), jof_memstore_pread(), jof_memstore_sink(), main(), mdl_export_workspace_take(), mdl_meta_parse(), mdl_path_join(), mdl_rabook_vfs_validate(), mdl_search_build_url(), mdl_state_set_series_metadata(), mdl_xml_escape(), mg_png_pull(), microsd_msc_read(), mkbookimg_dest_name(), nx_ether_driver_c6_rx(), nx_ether_driver_c6_set_mac(), prep_mailbox(), priv_alphabet_soup_split_path(), priv_bridge_pump_device(), priv_c6link_frame_classify(), priv_c6link_frame_filler(), priv_c6link_frame_seal(), priv_cache_store_super_write(), priv_comic_page_add(), priv_fs_posix_dir_next(), priv_fs_posix_parent_open(), priv_jof_on_rows(), priv_jof_prefix_pull(), priv_mdl_cache_save(), priv_mdl_epub_str_cat(), priv_mdl_export_jof(), priv_mdl_net_curl_buf_write(), priv_mdl_rabook_flat_read(), priv_mdl_state_decimal_to_binary64(), priv_mdl_verify_workspace_take(), priv_media_download_memory_read(), priv_media_download_memory_write_at(), priv_ra8_esp_hosted_rtos_alloc(), priv_ra8_esp_hosted_rtos_block_size(), priv_ra8_esp_hosted_rtos_release(), priv_rar5_filter_delta(), priv_reflow_tok_capture_attr(), priv_rv_trace_reference(), ra8_c6link_mdl_start_request(), ra8_dfu_read_header(), ra8_eth_gwca_default_send(), ra8_eth_gwca_tx_frame(), ra8_img_arena_realloc_sized(), ra8_ota_check_for_update(), ra8_ota_init(), ra8_power_profile_get_stats(), ra8_psa_key_import(), ra8_psa_sign_hash(), ra8_psa_verify_hash(), ra8_rabook_add_image(), ra8_rabook_gray8_encode(), ra8_rabook_intern(), ra8_vmem_stream_read(), ra8_vsource_loader(), rot_tamper_rejected(), sb_tampered_rejected(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_boot(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_root(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), sh_comic_blob_read(), sh_fit(), sh_paged_mram_read(), sh_reader_render(), sh_shelf_build_thumbs(), strchr(), strrchr(), strstr(), unarch_mem_read(), wlun_msc_read(), wlun_msc_write(), and worker_pull().

◆ memmove()

void * memmove ( void * dst,
const void * src,
size_t n )

Copy memory area between potentially overlapping regions.

Copies n bytes from src to dst handling overlaps safely.

Parameters
[out]dstDestination buffer pointer.
[in]srcSource buffer pointer.
[in]nNumber of bytes to copy.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n writable bytes if n > 0.
src points to at least n readable bytes if n > 0.
Postcondition
The n bytes at dst match the initial n bytes at src.
Handles any overlap between dst and src correctly.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when memory regions are not concurrently modified.
Since
0.1.0

Definition at line 95 of file ra8_freestanding_mem.c.

Referenced by internal_chunk_flat_read(), internal_js_slide(), and internal_prepend_underscore().

◆ memset()

void * memset ( void * dst,
int value,
size_t n )

Fill memory with a constant byte value.

Sets the first n bytes of dst to value converted to uint8_t.

Parameters
[out]dstDestination buffer to fill.
[in]valueByte value to write.
[in]nNumber of bytes to write.
Returns
Original destination pointer dst.
Return values
dstThe destination pointer passed in dst is always returned.
Precondition
dst points to at least n writable bytes if n > 0.
The destination memory region is addressable and valid.
Postcondition
The first n bytes of dst contain (uint8_t)value.
Bytes beyond n are unmodified.
Note
Freestanding runtime primitive; never allocates; reentrant and thread-safe when destination memory is not concurrently modified.
Since
0.1.0

Definition at line 45 of file ra8_freestanding_mem.c.

Referenced by app_make_cfg(), app_make_manifest(), ble_npl_callout_init(), ble_npl_event_init(), ble_npl_eventq_init(), board_net_init(), compile_fixture(), demo_calloc(), demo_fat_fill_sector(), demo_jiggle_send(), demo_msc_class_register(), demo_reopen_naive(), epub_entry_open(), fs_fmt_create_and_verify(), fs_fmt_rename_and_verify(), fw_fs_ra8_vfs_init(), fw_fs_space(), fw_fs_stat(), hid_send_iter(), hid_send_iter(), internal_allocate_pipeline(), internal_bdsink_flush(), internal_board_sd_cmd_send_csd(), internal_board_sd_fill_block(), internal_cache_encode_record(), internal_cache_storage(), internal_canfd_reset(), internal_copy_name(), internal_demo_calloc(), internal_demo_get_and_verify(), internal_demo_phase_remount(), internal_demo_put_and_verify(), internal_devcfg_serialize(), internal_dir_pack_sector(), internal_extract_series_metadata(), internal_fill_565(), internal_fill_slot(), internal_fill_strip(), internal_gb_render(), internal_h_calloc(), internal_h_memset(), internal_handle_send(), internal_handle_send(), internal_init_state(), internal_js_begin(), internal_library_workspace_reset(), internal_make_tables(), internal_mdl_next_capacity(), internal_mdl_state_big_init(), internal_mdl_state_big_shift(), internal_mdl_state_encode_header(), internal_mram_reset(), internal_native_window(), internal_net_ip_hdr(), internal_net_send_arp_reply(), internal_net_send_arp_request(), internal_net_send_ping(), internal_net_send_tcp(), internal_png_bind_geometry(), internal_pool_reset(), internal_ra8_io_roundtrip_read_verify(), internal_ram_erase(), internal_rbkc_pack(), internal_read_block(), internal_read_one(), internal_replay_open(), internal_resp_reset(), internal_run_budget(), internal_run_prepared(), internal_sdhi_begin_write(), internal_sdhi_load_block(), internal_sdhi_reset(), internal_seed_cells(), internal_session_mbedtls_setup(), internal_solve_words(), internal_super_read(), internal_swap_vfs_read_verify(), internal_tar_header(), internal_tx_ext_init(), internal_txn_begin(), internal_txn_begin(), internal_validate_body(), internal_vmsc_fill_sector(), internal_wire_window(), internal_write_entry(), internal_xspi_do_erase(), internal_xspi_reset(), load_panel(), long_shift_seam_install(), main(), mdl_extract_hits(), mdl_fetch_run(), mdl_governor_init_clock(), mdl_meta_init(), mdl_rabook_vfs_validate(), mdl_state_add_chapter_numbered(), mdl_state_init(), mem_tile_decode(), microsd_class_register(), mlun_class_register(), ospirw_class_register(), priv_cache_store_super_write(), priv_comic_cbz_open(), priv_dfu_write_secure(), priv_host_deliver_setup(), priv_jof_png_rows(), priv_mdl_export_prepare_cover(), priv_mdl_zip_workspace_bind(), priv_ota_manifest_decode(), priv_ra8_esp_hosted_rtos_deinit(), priv_ra8_esp_hosted_rtos_init(), priv_ra8_esp_hosted_rtos_pool_deinit(), priv_ra8_esp_hosted_rtos_pool_init(), priv_ra8_esp_hosted_rtos_sync_deinit(), priv_ra8_esp_hosted_rtos_sync_init(), priv_viewer_render_jof(), priv_viewer_tile_jof(), ra8_eth_gwca_init_ring(), ra8_eth_gwca_install_linkfix(), ra8_fs_dir_open(), ra8_glyph_atlas_init(), ra8_io_blockdev_vsource_init(), ra8_io_roundtrip_read_verify(), ra8_jpeg_sw_decode(), ra8_jpeg_sw_encode(), ra8_ota_deinit(), ra8_psa_crypto_deinit(), ra8_psa_key_destroy(), ra8_rabook_gray4_downscale(), ra8_rabook_gray4_encode(), ra8_tile_cache_init(), ra8_tls_session_close(), ra8_vmem_init(), ra8_vsource_loader(), ra8_wdt_supervisor_deinit(), ra8_wdt_supervisor_init(), ra8_webp_arena_calloc(), sdhi_card_block_roundtrip(), sdhi_demo_read_and_verify(), sdmsc_class_register(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_fat_fill_sector(), selftest_msc_class_register(), selftest_msc_class_register(), selftest_msc_class_register(), soup_init(), and wlun_class_register().