mirror of
https://xff.cz/git/u-boot/
synced 2025-09-26 21:11:18 +02:00
m68k: fix multiple memory accesses on swap operations
On a u32 val = __sw32(*addr); multiple memory accesses are not welcome, since "addr" may be an IO peripheral register address. This patch changes __sw16/32 to perform a single memory access for the source value. Signed-off-by: Angelo Dureghello <angelo@sysam.it>
This commit is contained in:
@@ -10,21 +10,28 @@
|
|||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define __sw16(x) \
|
|
||||||
((__u16)( \
|
static inline __u32 __sw32(__u32 x)
|
||||||
(((__u16)(x) & (__u16)0x00ffU) << 8) | \
|
{
|
||||||
(((__u16)(x) & (__u16)0xff00U) >> 8) ))
|
__u32 v = x;
|
||||||
#define __sw32(x) \
|
|
||||||
((__u32)( \
|
return v << 24 |
|
||||||
(((__u32)(x)) << 24) | \
|
(v & (__u32)0x0000ff00UL) << 8 |
|
||||||
(((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \
|
(v & (__u32)0x00ff0000UL) >> 8 |
|
||||||
(((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \
|
v >> 24;
|
||||||
(((__u32)(x)) >> 24) ))
|
}
|
||||||
|
|
||||||
|
static inline __u16 __sw16(__u16 x)
|
||||||
|
{
|
||||||
|
__u16 v = x;
|
||||||
|
|
||||||
|
return (v & (__u16)0x00ffU) << 8 |
|
||||||
|
(v & (__u16)0xff00U) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
static __inline__ unsigned ld_le16(const volatile unsigned short *addr)
|
static __inline__ unsigned ld_le16(const volatile unsigned short *addr)
|
||||||
{
|
{
|
||||||
unsigned result = *addr;
|
return __sw16(*addr);
|
||||||
return __sw16(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void st_le16(volatile unsigned short *addr,
|
static __inline__ void st_le16(volatile unsigned short *addr,
|
||||||
@@ -35,8 +42,7 @@ static __inline__ void st_le16(volatile unsigned short *addr,
|
|||||||
|
|
||||||
static __inline__ unsigned ld_le32(const volatile unsigned *addr)
|
static __inline__ unsigned ld_le32(const volatile unsigned *addr)
|
||||||
{
|
{
|
||||||
unsigned result = *addr;
|
return __sw32(*addr);
|
||||||
return __sw32(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void st_le32(volatile unsigned *addr, const unsigned val)
|
static __inline__ void st_le32(volatile unsigned *addr, const unsigned val)
|
||||||
|
Reference in New Issue
Block a user