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 Code to dump PMB contents.



details:   https://anonhg.NetBSD.org/src/rev/65c8a5e3590f
branches:  trunk
changeset: 936555:65c8a5e3590f
user:      uwe <uwe%NetBSD.org@localhost>
date:      Thu Jul 30 03:57:52 2020 +0000

description:
Code to dump PMB contents.

diffstat:

 sys/arch/sh3/sh3/pmb.c |  140 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 140 insertions(+), 0 deletions(-)

diffs (144 lines):

diff -r 1b2e128646fa -r 65c8a5e3590f sys/arch/sh3/sh3/pmb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sh3/sh3/pmb.c    Thu Jul 30 03:57:52 2020 +0000
@@ -0,0 +1,140 @@
+/* $NetBSD: pmb.c,v 1.1 2020/07/30 03:57:52 uwe Exp $ */
+/*
+ * Copyright (c) 2020 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: pmb.c,v 1.1 2020/07/30 03:57:52 uwe Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+
+#include <sh3/devreg.h>
+#include <sh3/mmu_sh4.h>
+#include <sh3/pmb.h>
+
+
+void
+st40_pmb_init(int product)
+{
+       int se_mode;
+       bool have_ub;
+       uint8_t ub;
+       char bits[64];
+
+       switch (product) {
+
+       /* ST40-300 */
+       case CPU_PRODUCT_STX7105: {
+               uint32_t pascr = _reg_read_4(ST40_PASCR);
+               snprintb(bits, sizeof(bits), ST40_PASCR_BITS, pascr);
+               printf("PMB: PASCR=%s\n", bits);
+
+               se_mode = (pascr & ST40_PASCR_SE);
+               have_ub = true;
+               ub = (uint8_t)(pascr & ST40_PASCR_UB_MASK);
+               break;
+       }
+
+#if 0
+       /* ST40-200, ST40-500 */
+       case 0xdeadbabe: {
+               uint32_t mmucr = _reg_read_4(SH4_MMUCR);
+
+               se_mode = (mmucr & ST40_MMUCR_SE);
+               have_ub = false;
+               ub = 0;
+               break;
+       }
+#endif
+
+       /* No PMB */
+       default:
+               return;
+       }
+
+       if (!se_mode) {
+               printf("PMB: 29-bit mode\n");
+               if (have_ub) {
+                       for (int area = 0; area < 8; ++area) {
+                               bool unbuffered = !!(ub & (1u << area));
+                               printf("PMB: area%d %s\n", area,
+                                      unbuffered ? "UNBUFFERED" : "buffered");
+                       }
+               }
+               return;
+       }
+
+       printf("PMB: 32-bit mode\n");
+       for (unsigned int i = 0; i < ST40_PMB_ENTRY; ++i) {
+               uint32_t offset = (i << ST40_PMB_E_SHIFT);
+
+               uint32_t addr = _reg_read_4(ST40_PMB_AA + offset);
+#if 0
+               snprintb(bits, sizeof(bits), ST40_PMB_AA_BITS, addr);
+               printf("PMB[%02d] A=%s", i, bits);
+#endif
+               uint32_t data = _reg_read_4(ST40_PMB_DA + offset);
+#if 0
+               snprintb(bits, sizeof(bits), ST40_PMB_DA_BITS, data);
+               printf(" D=%s\n", bits);
+#endif
+               if ((addr & ST40_PMB_AA_V) == 0)
+                       continue;
+
+               uint32_t vpn = addr & ST40_PMB_AA_VPN_MASK;
+               uint32_t ppn = data & ST40_PMB_DA_PPN_MASK;
+               uint32_t szbits = data & ST40_PMB_DA_SZ_MASK;
+
+               vpn >>= ST40_PMB_AA_VPN_SHIFT;
+               ppn >>= ST40_PMB_DA_PPN_SHIFT;
+
+               unsigned int sz = 0;
+               switch (szbits) {
+               case ST40_PMB_DA_SZ_16M:
+                       sz = 1;
+                       break;
+               case ST40_PMB_DA_SZ_64M:
+                       sz = 4;
+                       break;
+               case ST40_PMB_DA_SZ_128M:
+                       sz = 8;
+                       break;
+               case ST40_PMB_DA_SZ_512M:
+                       sz = 32;
+                       break;
+               }
+
+               printf("PMB[%02d] = %02x..%02x -> %02x..%02x"
+                      " %3uM %s %s %s\n",
+                      i,
+                      vpn, vpn + sz - 1,
+                      ppn, ppn + sz - 1,
+                      sz << 4,
+                      data & ST40_PMB_DA_UB ? "UB" : "--",
+                      data & ST40_PMB_DA_C  ?  "C" : "-",
+                      data & ST40_PMB_DA_WT ? "WT" : "CB");
+       }
+}



Home | Main Index | Thread Index | Old Index