26 static void mmio_region_memcpy32(
mmio_region_t base, uint32_t offset,
27 uint8_t *buf,
size_t len,
bool from_mmio) {
35 if (misalignment != 0) {
38 size_t realignment =
sizeof(uint32_t) -
OT_UNSIGNED(misalignment);
42 if (realignment > len) {
48 ptrdiff_t current_word_offset =
OT_SIGNED(offset) - misalignment;
49 uint32_t current_word = mmio_region_read32(base, current_word_offset);
53 uint8_t *current_byte = ((uint8_t *)¤t_word) + misalignment;
55 memcpy(buf, current_byte, realignment);
58 memcpy(current_byte, buf, realignment);
59 mmio_region_write32(base, current_word_offset, current_word);
62 offset += realignment;
72 uint32_t bytes_to_copy =
sizeof(uint32_t);
73 if (bytes_to_copy > len) {
78 uint32_t current_word = 0;
79 if (from_mmio || bytes_to_copy !=
sizeof(uint32_t)) {
84 current_word = mmio_region_read32(base,
OT_SIGNED(offset));
89 memcpy(buf, ¤t_word, bytes_to_copy);
92 memcpy(¤t_word, buf, bytes_to_copy);
93 mmio_region_write32(base,
OT_SIGNED(offset), current_word);
96 offset += bytes_to_copy;
103 void *dest,
size_t len) {
104 mmio_region_memcpy32(base, offset, dest, len,
true);
108 const void *src,
size_t len) {
112 mmio_region_memcpy32(base, offset, (
void *)src, len,
false);
118 extern uint8_t mmio_region_read8(
mmio_region_t base, ptrdiff_t offset);
119 extern uint32_t mmio_region_read32(
mmio_region_t base, ptrdiff_t offset);
120 extern void mmio_region_write8(
mmio_region_t base, ptrdiff_t offset,
122 extern void mmio_region_write32(
mmio_region_t base, ptrdiff_t offset,
124 extern void mmio_region_write8_shadowed(
mmio_region_t base, ptrdiff_t offset,
126 extern void mmio_region_write32_shadowed(
mmio_region_t base, ptrdiff_t offset,
129 uint32_t mask, uint32_t mask_index);
133 ptrdiff_t offset, uint32_t mask,
134 uint32_t mask_index);
136 ptrdiff_t offset, uint32_t mask,
137 uint32_t mask_index);
139 ptrdiff_t offset, uint32_t mask,
140 uint32_t mask_index);