TF-M Reference Manual
1.2.0
TrustedFirmware-M
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
crt_memcpy.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2019-2020, Arm Limited. All rights reserved.
3
*
4
* SPDX-License-Identifier: BSD-3-Clause
5
*
6
*/
7
8
#include "
crt_impl_private.h
"
9
10
void
*
memcpy
(
void
*dest,
const
void
*src,
size_t
n)
11
{
12
union
tfm_mem_addr_t
p_dest, p_src;
13
14
p_dest.
uint_addr
= (uintptr_t)dest;
15
p_src.
uint_addr
= (uintptr_t)src;
16
17
/* Byte copy for unaligned address. check the last bit of address. */
18
while
(n && (
GET_MEM_ADDR_BIT0
(p_dest.
uint_addr
) ||
19
GET_MEM_ADDR_BIT0
(p_src.
uint_addr
))) {
20
*p_dest.
p_byte
++ = *p_src.
p_byte
++;
21
n--;
22
}
23
24
/*
25
* Double byte copy for aligned address.
26
* Check the 2nd last bit of address.
27
*/
28
while
(n >=
sizeof
(uint16_t) && (
GET_MEM_ADDR_BIT1
(p_dest.
uint_addr
) ||
29
GET_MEM_ADDR_BIT1
(p_src.
uint_addr
))) {
30
*(p_dest.
p_dbyte
)++ = *(p_src.
p_dbyte
)++;
31
n -=
sizeof
(uint16_t);
32
}
33
34
/* Quad byte copy for aligned address. */
35
while
(n >=
sizeof
(uint32_t)) {
36
*(p_dest.
p_qbyte
)++ = *(p_src.
p_qbyte
)++;
37
n -=
sizeof
(uint32_t);
38
}
39
40
/* Byte copy for the remaining bytes. */
41
while
(n--) {
42
*p_dest.
p_byte
++ = *p_src.
p_byte
++;
43
}
44
45
return
dest;
46
}
tfm_mem_addr_t::p_dbyte
uint16_t * p_dbyte
Definition:
crt_impl_private.h:20
GET_MEM_ADDR_BIT1
#define GET_MEM_ADDR_BIT1(x)
Definition:
crt_impl_private.h:15
tfm_mem_addr_t::uint_addr
uintptr_t uint_addr
Definition:
crt_impl_private.h:18
tfm_mem_addr_t::p_qbyte
uint32_t * p_qbyte
Definition:
crt_impl_private.h:21
crt_impl_private.h
tfm_mem_addr_t
Definition:
crt_impl_private.h:17
GET_MEM_ADDR_BIT0
#define GET_MEM_ADDR_BIT0(x)
Definition:
crt_impl_private.h:14
tfm_mem_addr_t::p_byte
uint8_t * p_byte
Definition:
crt_impl_private.h:19
memcpy
void * memcpy(void *dest, const void *src, size_t n)
Definition:
crt_memcpy.c:10
secure_fw
partitions
lib
sprt
crt_memcpy.c
Generated on Thu Feb 18 2021 13:29:10 for TF-M Reference Manual by
1.8.6