Source-Changes-HG archive

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

[src/trunk]: src/sys/arch * make to work printf() and panic() even before con...



details:   https://anonhg.NetBSD.org/src/rev/283c1af7719d
branches:  trunk
changeset: 362692:283c1af7719d
user:      ryo <ryo%NetBSD.org@localhost>
date:      Thu Jun 21 11:57:05 2018 +0000

description:
* make to work printf() and panic() even before consinit().
* tidy up output for VERBOSE_INIT_ARM.

diffstat:

 sys/arch/aarch64/aarch64/locore.S |   6 +-
 sys/arch/evbarm/fdt/fdt_machdep.c |  74 ++++++++++++++++++++------------------
 2 files changed, 42 insertions(+), 38 deletions(-)

diffs (183 lines):

diff -r 2efbc4611c6d -r 283c1af7719d sys/arch/aarch64/aarch64/locore.S
--- a/sys/arch/aarch64/aarch64/locore.S Thu Jun 21 11:55:19 2018 +0000
+++ b/sys/arch/aarch64/aarch64/locore.S Thu Jun 21 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.6 2018/05/17 08:24:28 ryo Exp $   */
+/*     $NetBSD: locore.S,v 1.7 2018/06/21 11:57:05 ryo Exp $   */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -36,7 +36,7 @@
 #include <aarch64/pte.h>
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.6 2018/05/17 08:24:28 ryo Exp $")
+RCSID("$NetBSD: locore.S,v 1.7 2018/06/21 11:57:05 ryo Exp $")
 
 /* #define DEBUG_LOCORE */
 /* #define DEBUG_MMU */
@@ -181,11 +181,11 @@
        PRINT("DAIF            = ")
        mrs     x0, daif
        bl      print_x0
-#endif
 
        PRINT("VSTART          = ")
        ldr     x0, =vstart     # virtual address of vstart
        bl      print_x0
+#endif
 
        ldr     x0, =vstart     # virtual address of vstart
        br      x0              # jump to the kernel virtual address
diff -r 2efbc4611c6d -r 283c1af7719d sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Thu Jun 21 11:55:19 2018 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Thu Jun 21 11:57:05 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.22 2018/06/14 10:53:39 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.23 2018/06/21 11:57:05 ryo Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.22 2018/06/14 10:53:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.23 2018/06/21 11:57:05 ryo Exp $");
 
 #include "opt_machdep.h"
 #include "opt_bootconfig.h"
@@ -55,6 +55,7 @@
 #include <sys/termios.h>
 #include <sys/extent.h>
 
+#include <dev/cons.h>
 #include <uvm/uvm_extern.h>
 
 #include <sys/conf.h>
@@ -118,43 +119,46 @@
 static void fdt_reset(void);
 static void fdt_powerdown(void);
 
-#ifdef VERBOSE_INIT_ARM
+static dev_type_cnputc(earlyconsputc);
+static dev_type_cngetc(earlyconsgetc);
+
+static struct consdev earlycons = {
+       .cn_putc = earlyconsputc,
+       .cn_getc = earlyconsgetc,
+       .cn_pollc = nullcnpollc,
+};
+
 static void
 fdt_putchar(char c)
 {
        const struct arm_platform *plat = arm_fdt_platform();
-       if (plat && plat->early_putchar)
+       if (plat && plat->early_putchar) {
                plat->early_putchar(c);
-}
-
-static void
-fdt_putstr(const char *s)
-{
-       for (const char *p = s; *p; p++)
-               fdt_putchar(*p);
+       }
+#ifdef EARLYCONS
+       else {
+               void uartputc(int);     /* evbarm/fdt/fdt_start.S */
+               uartputc(c);
+       }
+#endif
 }
 
 static void
-fdt_printn(unsigned long n, int base)
+earlyconsputc(dev_t dev, int c)
 {
-       char *p, buf[(sizeof(unsigned long) * NBBY / 3) + 1 + 2 /* ALT + SIGN */];
+       fdt_putchar(c);
+}
 
-       p = buf;
-       do {
-               *p++ = hexdigits[n % base];
-       } while (n /= base);
+static int
+earlyconsgetc(dev_t dev)
+{
+       return 0;       /* XXX */
+}
 
-       do {
-               fdt_putchar(*--p);
-       } while (p > buf);
-}
-#define DPRINTF(...)           printf(__VA_ARGS__)
-#define DPRINT(x)              fdt_putstr(x)
-#define DPRINTN(x,b)           fdt_printn((x), (b))
+#ifdef VERBOSE_INIT_ARM
+#define DPRINTF(...)   printf(__VA_ARGS__)
 #else
 #define DPRINTF(...)
-#define DPRINT(x)
-#define DPRINTN(x,b)
 #endif
 
 /*
@@ -354,6 +358,9 @@
        const struct arm_platform *plat;
        uint64_t memory_start, memory_end;
 
+       /* set temporally to work printf()/panic() even before consinit() */
+       cn_tab = &earlycons;
+
        /* Load FDT */
        int error = fdt_check_header(fdt_addr_r);
        if (error == 0) {
@@ -371,27 +378,25 @@
                panic("Kernel does not support this device");
 
        /* Early console may be available, announce ourselves. */
-       DPRINT("FDT<");
-       DPRINTN((uintptr_t)fdt_addr_r, 16);
-       DPRINT(">");
+       DPRINTF("FDT<%p>\n", fdt_addr_r);
 
        const int chosen = OF_finddevice("/chosen");
        if (chosen >= 0)
                OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs));
        boot_args = bootargs;
 
-       DPRINT(" devmap");
+       DPRINTF("devmap\n");
        pmap_devmap_register(plat->devmap());
 #ifdef __aarch64__
        pmap_devmap_bootstrap(plat->devmap());
 #endif
 
        /* Heads up ... Setup the CPU / MMU / TLB functions. */
-       DPRINT(" cpufunc");
+       DPRINTF("cpufunc\n");
        if (set_cpufuncs())
                panic("cpu not recognized!");
 
-       DPRINT(" bootstrap");
+       DPRINTF("bootstrap\n");
        plat->bootstrap();
 
        /*
@@ -400,10 +405,9 @@
         */
        fdt_update_stdout_path();
 
-       DPRINT(" consinit");
+       DPRINTF("consinit ");
        consinit();
-
-       DPRINTF(" ok\n");
+       DPRINTF("ok\n");
 
        DPRINTF("uboot: args %#lx, %#lx, %#lx, %#lx\n",
            uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]);



Home | Main Index | Thread Index | Old Index