Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/cortex need to swap on big endian machines.



details:   https://anonhg.NetBSD.org/src/rev/a2254381d4cd
branches:  trunk
changeset: 955232:a2254381d4cd
user:      ryo <ryo%NetBSD.org@localhost>
date:      Thu Sep 24 08:50:09 2020 +0000

description:
need to swap on big endian machines.

"The ITS command queue uses a little endian memory order model." (GIC Architecture Specification)

diffstat:

 sys/arch/arm/cortex/gicv3_its.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r d385b42a900a -r a2254381d4cd sys/arch/arm/cortex/gicv3_its.c
--- a/sys/arch/arm/cortex/gicv3_its.c   Thu Sep 24 08:23:29 2020 +0000
+++ b/sys/arch/arm/cortex/gicv3_its.c   Thu Sep 24 08:50:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_its.c,v 1.27 2020/02/13 02:12:06 jmcneill Exp $ */
+/* $NetBSD: gicv3_its.c,v 1.28 2020/09/24 08:50:09 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.27 2020/02/13 02:12:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_its.c,v 1.28 2020/09/24 08:50:09 ryo Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -118,7 +118,13 @@
        cwriter = gits_read_8(its, GITS_CWRITER);
        woff = cwriter & GITS_CWRITER_Offset;
 
+#if _BYTE_ORDER == _BIG_ENDIAN
+       uint64_t *dw = (uint64_t *)(its->its_cmd.base + woff);
+       for (int i = 0; i < __arraycount(cmd->dw); i++)
+               dw[i] = htole64(cmd->dw[i]);
+#else
        memcpy(its->its_cmd.base + woff, cmd->dw, sizeof(cmd->dw));
+#endif
        bus_dmamap_sync(its->its_dmat, its->its_cmd.map, woff, sizeof(cmd->dw), BUS_DMASYNC_PREWRITE);
 
        woff += sizeof(cmd->dw);



Home | Main Index | Thread Index | Old Index