Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha Clean up all of the _PMAP_MAY_USE_PROM_CONSOL...



details:   https://anonhg.NetBSD.org/src/rev/18b193844dd3
branches:  trunk
changeset: 943422:18b193844dd3
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Sep 03 02:09:09 2020 +0000

description:
Clean up all of the _PMAP_MAY_USE_PROM_CONSOLE crapola, centralizing the
logic in prom.c, and rename it _PROM_MAY_USE_PROM_CONSOLE in a few places
it's still needed.

diffstat:

 sys/arch/alpha/alpha/locore.s   |   9 +++-
 sys/arch/alpha/alpha/machdep.c  |  56 ++++++------------------------
 sys/arch/alpha/alpha/pmap.c     |  36 +------------------
 sys/arch/alpha/alpha/prom.c     |  74 +++++++++++++++++++++++++++++++---------
 sys/arch/alpha/alpha/promcons.c |  14 +++---
 sys/arch/alpha/include/alpha.h  |   4 +-
 sys/arch/alpha/include/pmap.h   |  14 +-------
 sys/arch/alpha/include/prom.h   |  15 +++++++-
 8 files changed, 103 insertions(+), 119 deletions(-)

diffs (truncated from 572 to 300 lines):

diff -r f7ddde242bd0 -r 18b193844dd3 sys/arch/alpha/alpha/locore.s
--- a/sys/arch/alpha/alpha/locore.s     Thu Sep 03 02:05:03 2020 +0000
+++ b/sys/arch/alpha/alpha/locore.s     Thu Sep 03 02:09:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.125 2020/06/30 16:20:00 maxv Exp $ */
+/* $NetBSD: locore.s,v 1.126 2020/09/03 02:09:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <machine/asm.h>
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.125 2020/06/30 16:20:00 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.126 2020/09/03 02:09:09 thorpej Exp $");
 
 #include "assym.h"
 
@@ -126,6 +126,7 @@
  *
  * All arguments are passed to alpha_init().
  */
+IMPORT(prom_mapped, 4)
 NESTED_NOPROFILE(locorestart,1,0,ra,0,0)
        br      pv,1f
 1:     LDGP(pv)
@@ -157,6 +158,10 @@
        ldq     a0, L_MD_PCBPADDR(a0)           /* phys addr of PCB */
        SWITCH_CONTEXT
 
+       /* PROM is no longer mapped. */
+       lda     t0, prom_mapped
+       stl     zero, 0(t0)
+
        /*
         * We've switched to a new page table base, so invalidate the TLB
         * and I-stream.  This happens automatically everywhere but here.
diff -r f7ddde242bd0 -r 18b193844dd3 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c    Thu Sep 03 02:05:03 2020 +0000
+++ b/sys/arch/alpha/alpha/machdep.c    Thu Sep 03 02:09:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.362 2020/09/02 17:40:23 riastradh Exp $ */
+/* $NetBSD: machdep.c,v 1.363 2020/09/03 02:09:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.362 2020/09/02 17:40:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.363 2020/09/03 02:09:09 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -299,7 +299,7 @@
                            uimin(sizeof v1p->booted_kernel,
                              sizeof bootinfo.booted_kernel));
                        /* booted dev not provided in bootinfo */
-                       init_prom_interface((struct rpb *)
+                       init_prom_interface(ptb, (struct rpb *)
                            ALPHA_PHYS_TO_K0SEG(bootinfo.hwrpb_phys));
                        prom_getenv(PROM_E_BOOTED_DEV, bootinfo.booted_dev,
                            sizeof bootinfo.booted_dev);
@@ -316,7 +316,7 @@
                bootinfo.esym = (u_long)_end;
                bootinfo.hwrpb_phys = ((struct rpb *)HWRPB_ADDR)->rpb_phys;
                bootinfo.hwrpb_size = ((struct rpb *)HWRPB_ADDR)->rpb_size;
-               init_prom_interface((struct rpb *)HWRPB_ADDR);
+               init_prom_interface(ptb, (struct rpb *)HWRPB_ADDR);
                prom_getenv(PROM_E_BOOTED_OSFLAGS, bootinfo.boot_flags,
                    sizeof bootinfo.boot_flags);
                prom_getenv(PROM_E_BOOTED_FILE, bootinfo.booted_kernel,
@@ -375,17 +375,10 @@
        uvm_md_init();
 
        /*
-        * Find out what hardware we're on, and do basic initialization.
+        * cputype has been initialized in init_prom_interface().
+        * Perform basic platform initialization using this info.
         */
-       cputype = hwrpb->rpb_type;
-       if (cputype < 0) {
-               /*
-                * At least some white-box systems have SRM which
-                * reports a systype that's the negative of their
-                * blue-box counterpart.
-                */
-               cputype = -cputype;
-       }
+       KASSERT(prom_interface_initialized);
        c = platform_lookup(cputype);
        if (c == NULL) {
                platform_not_supported();
@@ -416,12 +409,7 @@
 #endif
 
        /* NO MORE FIRMWARE ACCESS ALLOWED */
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-       /*
-        * XXX (unless _PMAP_MAY_USE_PROM_CONSOLE is defined and
-        * XXX pmap_uses_prom_console() evaluates to non-zero.)
-        */
-#endif
+       /* XXX Unless prom_uses_prom_console() evaluates to non-zero.) */
 
        /*
         * Find the beginning and end of the kernel (and leave a
@@ -507,14 +495,12 @@
                 * software use.  We must determine if this cluster
                 * holds the kernel.
                 */
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
+
                /*
                 * XXX If the kernel uses the PROM console, we only use the
                 * XXX memory after the kernel in the first system segment,
                 * XXX to avoid clobbering prom mapping, data, etc.
                 */
-           if (!pmap_uses_prom_console() || physmem == 0) {
-#endif /* _PMAP_MAY_USE_PROM_CONSOLE */
                physmem += memc->mddt_pg_cnt;
                pfn0 = memc->mddt_pfn;
                pfn1 = memc->mddt_pfn + memc->mddt_pg_cnt;
@@ -526,10 +512,7 @@
 #if 0
                        printf("Cluster %d contains kernel\n", i);
 #endif
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-                   if (!pmap_uses_prom_console()) {
-#endif /* _PMAP_MAY_USE_PROM_CONSOLE */
-                       if (pfn0 < kernstartpfn) {
+                       if (pfn0 < kernstartpfn && !prom_uses_prom_console()) {
                                /*
                                 * There is a chunk before the kernel.
                                 */
@@ -540,9 +523,6 @@
                                uvm_page_physload(pfn0, kernstartpfn,
                                    pfn0, kernstartpfn, VM_FREELIST_DEFAULT);
                        }
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-                   }
-#endif /* _PMAP_MAY_USE_PROM_CONSOLE */
                        if (kernendpfn < pfn1) {
                                /*
                                 * There is a chunk after the kernel.
@@ -565,9 +545,6 @@
                        uvm_page_physload(pfn0, pfn1, pfn0, pfn1,
                            VM_FREELIST_DEFAULT);
                }
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-           }
-#endif /* _PMAP_MAY_USE_PROM_CONSOLE */
        }
 
        /*
@@ -813,9 +790,9 @@
         * Everything related to console initialization is done
         * in alpha_init().
         */
-#if defined(DIAGNOSTIC) && defined(_PMAP_MAY_USE_PROM_CONSOLE)
+#if defined(DIAGNOSTIC) && defined(_PROM_MAY_USE_PROM_CONSOLE)
        printf("consinit: %susing prom console\n",
-           pmap_uses_prom_console() ? "" : "not ");
+           prom_uses_prom_console() ? "" : "not ");
 #endif
 }
 
@@ -965,15 +942,6 @@
        printf("\n");
        printf("%ld byte page size, %d processor%s.\n",
            hwrpb->rpb_page_size, ncpus, ncpus == 1 ? "" : "s");
-#if 0
-       /* this isn't defined for any systems that we run on? */
-       printf("serial number 0x%lx 0x%lx\n",
-           ((long *)hwrpb->rpb_ssn)[0], ((long *)hwrpb->rpb_ssn)[1]);
-
-       /* and these aren't particularly useful! */
-       printf("variation: 0x%lx, revision 0x%lx\n",
-           hwrpb->rpb_variation, *(long *)hwrpb->rpb_revision);
-#endif
 }
 
 int    waittime = -1;
diff -r f7ddde242bd0 -r 18b193844dd3 sys/arch/alpha/alpha/pmap.c
--- a/sys/arch/alpha/alpha/pmap.c       Thu Sep 03 02:05:03 2020 +0000
+++ b/sys/arch/alpha/alpha/pmap.c       Thu Sep 03 02:09:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.270 2020/09/03 02:05:03 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.271 2020/09/03 02:09:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.270 2020/09/03 02:05:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.271 2020/09/03 02:09:09 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -150,7 +150,7 @@
 
 #include <uvm/uvm.h>
 
-#if defined(_PMAP_MAY_USE_PROM_CONSOLE) || defined(MULTIPROCESSOR)
+#if defined(MULTIPROCESSOR)
 #include <machine/rpb.h>
 #endif
 
@@ -1287,27 +1287,6 @@
        kernel_lev1map[l1pte_index(VPTBASE)] = pte;
        VPT = (pt_entry_t *)VPTBASE;
 
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-    {
-       extern pt_entry_t prom_pte;                     /* XXX */
-       extern int prom_mapped;                         /* XXX */
-
-       if (pmap_uses_prom_console()) {
-               /*
-                * XXX Save old PTE so we can remap the PROM, if
-                * XXX necessary.
-                */
-               prom_pte = *(pt_entry_t *)ptaddr & ~PG_ASM;
-       }
-       prom_mapped = 0;
-
-       /*
-        * Actually, this code lies.  The prom is still mapped, and will
-        * remain so until the context switch after alpha_init() returns.
-        */
-    }
-#endif
-
        /*
         * Set up level 2 page table.
         */
@@ -1392,15 +1371,6 @@
        pmap_init_cpu(ci);
 }
 
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-int
-pmap_uses_prom_console(void)
-{
-
-       return (cputype == ST_DEC_21000);
-}
-#endif /* _PMAP_MAY_USE_PROM_CONSOLE */
-
 /*
  * pmap_virtual_space:         [ INTERFACE ]
  *
diff -r f7ddde242bd0 -r 18b193844dd3 sys/arch/alpha/alpha/prom.c
--- a/sys/arch/alpha/alpha/prom.c       Thu Sep 03 02:05:03 2020 +0000
+++ b/sys/arch/alpha/alpha/prom.c       Thu Sep 03 02:09:09 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.53 2020/08/30 16:26:56 thorpej Exp $ */
+/* $NetBSD: prom.c,v 1.54 2020/09/03 02:09:09 thorpej Exp $ */
 
 /*
  * Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.53 2020/08/30 16:26:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.54 2020/09/03 02:09:09 thorpej Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -54,17 +54,18 @@
        .cn_pri = 1
 };
 
-struct rpb     *hwrpb;
+struct rpb     *hwrpb __read_mostly;
 int            alpha_console;
 
 extern struct prom_vec prom_dispatch_v;
 
-static int     prom_is_qemu;           /* XXX */
+bool           prom_interface_initialized;
+int            prom_mapped = 1;        /* Is PROM still mapped? */
+static bool    prom_is_qemu;           /* XXX */
 
 static kmutex_t        prom_lock;
 
-#ifdef _PMAP_MAY_USE_PROM_CONSOLE
-int            prom_mapped = 1;        /* Is PROM still mapped? */
+#ifdef _PROM_MAY_USE_PROM_CONSOLE
 
 pt_entry_t     prom_pte, saved_pte[1]; /* XXX */
 
@@ -80,7 +81,31 @@
 
        return ((pt_entry_t *)ALPHA_PHYS_TO_K0SEG(apcb->apcb_ptbr << PGSHIFT));
 }



Home | Main Index | Thread Index | Old Index