mbed-os/features/FEATURE_LWIP/lwip-interface/lwip-eth/arch
Hugues de Valon ef7b16d9c5 CM3DS: fix non aligned access in Ethernet driver
This patch changes the way data is put in the TX_DATA_PORT register when
sending packet over Ethernet.
When this driver is compiled with release compilation profile
(space optimization compiler options) with Arm compiler version 5,
the line:
SMSC9220->TX_DATA_PORT = *pktptr;
generates the assembly instruction to get the pktptr pointed value:
LDM r2!, {r3}
with pktptr = r2
However, the code does not prevent the pktptr value from being unaligned
(to a 32 bits boundary) in that zone and the LDM instruction causes a
HardFault if this is the case. When the compiler option is not activated
(debug and develop compilation profiles), the compiler generates LDR
instruction instead which does not cause a HardFault.
The ARM v7-M states page B3-601: "Unaligned load-store multiples and
word or halfword exclusive accesses always fault."

To face that problem, we check if the data pointer is aligned or not. If
it is, we apply the same algorithm than before. If not, a local variable
is created and we copy in it, byte per byte, the contents at the
unaligned pointer. However, it will impact performances adding 8
instructions (one LD and one ST for each copied byte).

Change-Id: I11f6e82ce5521960d2ecf499f718f76fec29c0b0
Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2018-02-21 17:54:12 +00:00
..
TARGET_CM3DS_MPS2 CM3DS: fix non aligned access in Ethernet driver 2018-02-21 17:54:12 +00:00
TARGET_Freescale K64F Ethernet: avoid using NULL thread during init 2017-12-21 11:14:08 +02:00
TARGET_NUVOTON [M487/NUC472] Fixed ethernet multi-function pin 2017-09-20 16:56:30 +08:00
TARGET_NXP ff_lpc546xx: add enet 2018-01-01 15:55:24 +01:00
TARGET_RZ_A1XX Add the function declarations of WEAK attribute to use LWIP on GR-LYCHEE 2018-01-11 18:11:37 +09:00
TARGET_Realtek lwip - fix typo and cleanup coding style 2017-06-05 16:26:30 +08:00
TARGET_STM Adding license info 2017-12-22 13:54:22 +00:00