diff options
-rw-r--r-- | hw/npu2-opencapi.c | 12 | ||||
-rw-r--r-- | include/io.h | 48 | ||||
-rw-r--r-- | libc/string/memcpy_from_ci.c | 7 |
3 files changed, 36 insertions, 31 deletions
diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c index b03aad3..035c6cd 100644 --- a/hw/npu2-opencapi.c +++ b/hw/npu2-opencapi.c @@ -1427,7 +1427,7 @@ static int64_t npu2_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn, cfg_addr = SETFIELD(NPU2_CQ_CTL_CONFIG_ADDR_REGISTER_NUMBER, cfg_addr, offset & ~3u); - out_be64((uint64_t *)genid_base, cfg_addr); + out_be64((beint64_t *)genid_base, cfg_addr); sync(); switch (size) { @@ -1437,10 +1437,10 @@ static int64_t npu2_opencapi_pcicfg_read(struct phb *phb, uint32_t bdfn, break; case 2: *((uint16_t *)data) = - in_le16((volatile uint16_t *)(genid_base + 128 + (offset & 2))); + in_le16((volatile leint16_t *)(genid_base + 128 + (offset & 2))); break; case 4: - *((uint32_t *)data) = in_le32((volatile uint32_t *)(genid_base + 128)); + *((uint32_t *)data) = in_le32((volatile leint32_t *)(genid_base + 128)); break; default: return OPAL_PARAMETER; @@ -1485,7 +1485,7 @@ static int64_t npu2_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn, cfg_addr = SETFIELD(NPU2_CQ_CTL_CONFIG_ADDR_REGISTER_NUMBER, cfg_addr, offset & ~3u); - out_be64((uint64_t *)genid_base, cfg_addr); + out_be64((beint64_t *)genid_base, cfg_addr); sync(); switch (size) { @@ -1494,11 +1494,11 @@ static int64_t npu2_opencapi_pcicfg_write(struct phb *phb, uint32_t bdfn, data); break; case 2: - out_le16((volatile uint16_t *)(genid_base + 128 + (offset & 2)), + out_le16((volatile leint16_t *)(genid_base + 128 + (offset & 2)), data); break; case 4: - out_le32((volatile uint32_t *)(genid_base + 128), data); + out_le32((volatile leint32_t *)(genid_base + 128), data); break; default: return OPAL_PARAMETER; diff --git a/include/io.h b/include/io.h index ecdd3d0..f00021d 100644 --- a/include/io.h +++ b/include/io.h @@ -34,7 +34,7 @@ static inline uint8_t in_8(const volatile uint8_t *addr) return __in_8(addr); } -static inline uint16_t __in_be16(const volatile uint16_t *addr) +static inline uint16_t __in_be16(const volatile beint16_t *addr) { __be16 val; asm volatile("lhzcix %0,0,%1" : @@ -42,13 +42,13 @@ static inline uint16_t __in_be16(const volatile uint16_t *addr) return be16_to_cpu(val); } -static inline uint16_t in_be16(const volatile uint16_t *addr) +static inline uint16_t in_be16(const volatile beint16_t *addr) { sync(); return __in_be16(addr); } -static inline uint16_t __in_le16(const volatile uint16_t *addr) +static inline uint16_t __in_le16(const volatile leint16_t *addr) { __le16 val; asm volatile("lhzcix %0,0,%1" : @@ -56,13 +56,13 @@ static inline uint16_t __in_le16(const volatile uint16_t *addr) return le16_to_cpu(val); } -static inline uint16_t in_le16(const volatile uint16_t *addr) +static inline uint16_t in_le16(const volatile leint16_t *addr) { sync(); return __in_le16(addr); } -static inline uint32_t __in_be32(const volatile uint32_t *addr) +static inline uint32_t __in_be32(const volatile beint32_t *addr) { __be32 val; asm volatile("lwzcix %0,0,%1" : @@ -70,13 +70,13 @@ static inline uint32_t __in_be32(const volatile uint32_t *addr) return be32_to_cpu(val); } -static inline uint32_t in_be32(const volatile uint32_t *addr) +static inline uint32_t in_be32(const volatile beint32_t *addr) { sync(); return __in_be32(addr); } -static inline uint32_t __in_le32(const volatile uint32_t *addr) +static inline uint32_t __in_le32(const volatile leint32_t *addr) { __le32 val; asm volatile("lwzcix %0,0,%1" : @@ -84,13 +84,13 @@ static inline uint32_t __in_le32(const volatile uint32_t *addr) return le32_to_cpu(val); } -static inline uint32_t in_le32(const volatile uint32_t *addr) +static inline uint32_t in_le32(const volatile leint32_t *addr) { sync(); return __in_le32(addr); } -static inline uint64_t __in_be64(const volatile uint64_t *addr) +static inline uint64_t __in_be64(const volatile beint64_t *addr) { __be64 val; asm volatile("ldcix %0,0,%1" : @@ -98,13 +98,13 @@ static inline uint64_t __in_be64(const volatile uint64_t *addr) return be64_to_cpu(val); } -static inline uint64_t in_be64(const volatile uint64_t *addr) +static inline uint64_t in_be64(const volatile beint64_t *addr) { sync(); return __in_be64(addr); } -static inline uint64_t __in_le64(const volatile uint64_t *addr) +static inline uint64_t __in_le64(const volatile leint64_t *addr) { __le64 val; asm volatile("ldcix %0,0,%1" : @@ -112,7 +112,7 @@ static inline uint64_t __in_le64(const volatile uint64_t *addr) return le64_to_cpu(val); } -static inline uint64_t in_le64(const volatile uint64_t *addr) +static inline uint64_t in_le64(const volatile leint64_t *addr) { sync(); return __in_le64(addr); @@ -130,73 +130,73 @@ static inline void out_8(volatile uint8_t *addr, uint8_t val) return __out_8(addr, val); } -static inline void __out_be16(volatile uint16_t *addr, uint16_t val) +static inline void __out_be16(volatile beint16_t *addr, uint16_t val) { asm volatile("sthcix %0,0,%1" : : "r"(cpu_to_be16(val)), "r"(addr), "m"(*addr) : "memory"); } -static inline void out_be16(volatile uint16_t *addr, uint16_t val) +static inline void out_be16(volatile beint16_t *addr, uint16_t val) { sync(); return __out_be16(addr, val); } -static inline void __out_le16(volatile uint16_t *addr, uint16_t val) +static inline void __out_le16(volatile leint16_t *addr, uint16_t val) { asm volatile("sthcix %0,0,%1" : : "r"(cpu_to_le16(val)), "r"(addr), "m"(*addr) : "memory"); } -static inline void out_le16(volatile uint16_t *addr, uint16_t val) +static inline void out_le16(volatile leint16_t *addr, uint16_t val) { sync(); return __out_le16(addr, val); } -static inline void __out_be32(volatile uint32_t *addr, uint32_t val) +static inline void __out_be32(volatile beint32_t *addr, uint32_t val) { asm volatile("stwcix %0,0,%1" : : "r"(cpu_to_be32(val)), "r"(addr), "m"(*addr) : "memory"); } -static inline void out_be32(volatile uint32_t *addr, uint32_t val) +static inline void out_be32(volatile beint32_t *addr, uint32_t val) { sync(); return __out_be32(addr, val); } -static inline void __out_le32(volatile uint32_t *addr, uint32_t val) +static inline void __out_le32(volatile leint32_t *addr, uint32_t val) { asm volatile("stwcix %0,0,%1" : : "r"(cpu_to_le32(val)), "r"(addr), "m"(*addr) : "memory"); } -static inline void out_le32(volatile uint32_t *addr, uint32_t val) +static inline void out_le32(volatile leint32_t *addr, uint32_t val) { sync(); return __out_le32(addr, val); } -static inline void __out_be64(volatile uint64_t *addr, uint64_t val) +static inline void __out_be64(volatile beint64_t *addr, uint64_t val) { asm volatile("stdcix %0,0,%1" : : "r"(cpu_to_be64(val)), "r"(addr), "m"(*addr) : "memory"); } -static inline void out_be64(volatile uint64_t *addr, uint64_t val) +static inline void out_be64(volatile beint64_t *addr, uint64_t val) { sync(); return __out_be64(addr, val); } -static inline void __out_le64(volatile uint64_t *addr, uint64_t val) +static inline void __out_le64(volatile leint64_t *addr, uint64_t val) { asm volatile("stdcix %0,0,%1" : : "r"(cpu_to_le64(val)), "r"(addr), "m"(*addr) : "memory"); } -static inline void out_le64(volatile uint64_t *addr, uint64_t val) +static inline void out_le64(volatile leint64_t *addr, uint64_t val) { sync(); return __out_le64(addr, val); diff --git a/libc/string/memcpy_from_ci.c b/libc/string/memcpy_from_ci.c index 103853b..dd4d94e 100644 --- a/libc/string/memcpy_from_ci.c +++ b/libc/string/memcpy_from_ci.c @@ -16,7 +16,12 @@ void *memcpy_from_ci(void *destpp, const void *srcpp, size_t len) /* Copy as many blocks as possible if srcp is block aligned */ if ((srcp % block) == 0) { while ((len - block) > -1) { - *((uint64_t*) destp) = in_be64((uint64_t*)srcp); + uint64_t v; + if (HAVE_BIG_ENDIAN) + v = in_be64((beint64_t*)srcp); + else + v = in_le64((leint64_t*)srcp); + *((uint64_t *) destp) = v; srcp += block; destp += block; len -= block; |