Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sh3/sh3 db_tlbdump_cmd - get rid of RUN_P2/P1, use ...



details:   https://anonhg.NetBSD.org/src/rev/18f9a7b453a2
branches:  trunk
changeset: 974558:18f9a7b453a2
user:      uwe <uwe%NetBSD.org@localhost>
date:      Mon Aug 03 01:56:18 2020 +0000

description:
db_tlbdump_cmd - get rid of RUN_P2/P1, use functions instead.

Move the bits of code to read TLB entries into separate functions and
call them via P2 pointers instead of doing P2/P1 switch inline.

diffstat:

 sys/arch/sh3/sh3/db_interface.c |  51 +++++++++++++++++++++++++++++++---------
 1 files changed, 39 insertions(+), 12 deletions(-)

diffs (102 lines):

diff -r 196c663114c7 -r 18f9a7b453a2 sys/arch/sh3/sh3/db_interface.c
--- a/sys/arch/sh3/sh3/db_interface.c   Mon Aug 03 01:38:10 2020 +0000
+++ b/sys/arch/sh3/sh3/db_interface.c   Mon Aug 03 01:56:18 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_interface.c,v 1.63 2020/08/03 01:18:45 uwe Exp $    */
+/*     $NetBSD: db_interface.c,v 1.64 2020/08/03 01:56:18 uwe Exp $    */
 
 /*-
  * Copyright (C) 2002 UCHIYAMA Yasushi.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.63 2020/08/03 01:18:45 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.64 2020/08/03 01:56:18 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -66,6 +66,13 @@
 static void kdb_printtrap(u_int, int);
 
 static void db_tlbdump_cmd(db_expr_t, bool, db_expr_t, const char *);
+#ifdef SH4
+static __noinline void
+__db_get_itlb_sh4(uint32_t, uint32_t *, uint32_t *, uint32_t *);
+static __noinline void
+__db_get_utlb_sh4(uint32_t, uint32_t *, uint32_t *, uint32_t *);
+#endif
+
 static char *__db_procname_by_asid(int);
 static void __db_tlbdump_pfn(uint32_t);
 #ifdef SH4
@@ -320,8 +327,13 @@
 #endif /* SH3 */
 #ifdef SH4
        if (CPU_IS_SH4) {
+               void (*get_itlb_p2)(uint32_t, uint32_t *, uint32_t *, uint32_t *);
+               void (*get_utlb_p2)(uint32_t, uint32_t *, uint32_t *, uint32_t *);
                uint32_t aa, da1, da2;
 
+               get_itlb_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_get_itlb_sh4);
+               get_utlb_p2 = (void *)SH3_P1SEG_TO_P2SEG(__db_get_utlb_sh4);
+
                /* MMU configuration */
                r = _reg_read_4(SH4_MMUCR);
                db_printf("%s virtual storage mode, SQ access: (kernel%s)\n",
@@ -338,11 +350,7 @@
                for (i = 0; i < 4; i++) {
                        e = i << SH4_ITLB_E_SHIFT;
 
-                       RUN_P2;
-                       aa = _reg_read_4(SH4_ITLB_AA | e);
-                       da1 = _reg_read_4(SH4_ITLB_DA1 | e);
-                       da2 = _reg_read_4(SH4_ITLB_DA2 | e);
-                       RUN_P1;
+                       (*get_itlb_p2)(e, &aa, &da1, &da2);
 
                        db_printf("0x%08x   %3d",
                            aa & SH4_ITLB_AA_VPN_MASK,
@@ -367,11 +375,7 @@
                for (i = 0; i < 64; i++) {
                        e = i << SH4_UTLB_E_SHIFT;
 
-                       RUN_P2;
-                       aa = _reg_read_4(SH4_UTLB_AA | e);
-                       da1 = _reg_read_4(SH4_UTLB_DA1 | e);
-                       da2 = _reg_read_4(SH4_UTLB_DA2 | e);
-                       RUN_P1;
+                       (*get_utlb_p2)(e, &aa, &da1, &da2);
 
                        db_printf("0x%08x   %3d",
                            aa & SH4_UTLB_AA_VPN_MASK,
@@ -397,6 +401,29 @@
 #endif /* SH4 */
 }
 
+
+#ifdef SH4
+static __noinline void
+__db_get_itlb_sh4(uint32_t e, uint32_t *paa, uint32_t *pda1, uint32_t *pda2)
+{
+
+       *paa = _reg_read_4(SH4_ITLB_AA | e);
+       *pda1 = _reg_read_4(SH4_ITLB_DA1 | e);
+       *pda2 = _reg_read_4(SH4_ITLB_DA2 | e);
+}
+
+
+static __noinline void
+__db_get_utlb_sh4(uint32_t e, uint32_t *paa, uint32_t *pda1, uint32_t *pda2)
+{
+
+       *paa = _reg_read_4(SH4_UTLB_AA | e);
+       *pda1 = _reg_read_4(SH4_UTLB_DA1 | e);
+       *pda2 = _reg_read_4(SH4_UTLB_DA2 | e);
+}
+#endif /* SH4 */
+
+
 static void
 __db_tlbdump_pfn(uint32_t r)
 {



Home | Main Index | Thread Index | Old Index