changeset 3934:27a3c7766ed8

more logk stuff
author Alexandre Becoulet <alexandre.becoulet@free.fr>
date Fri, 18 May 2018 13:44:37 +0200
parents 511e79e2ba7f
children e4c1caba98e3
files hexo/Makefile libdevice/Makefile libdevice/device_clock.c libdevice/device_usbdev.c libdevice/driver.c libdevice/init.c libdevice/irq.c mutek/Makefile mutek/bytecode.t mutek/fault.c mutek/mutek.config mutek/scheduler.c mutek/startup.c
diffstat 13 files changed, 53 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/hexo/Makefile	Fri May 18 13:37:17 2018 +0200
+++ b/hexo/Makefile	Fri May 18 13:44:37 2018 +0200
@@ -1,7 +1,7 @@
 
 enum_headers = include/hexo/power.h
 
-DIR_CFLAGS = -D_HEXO_INTTYPES_DEPRECATED
+DIR_CFLAGS = -D_HEXO_INTTYPES_DEPRECATED -DLOGK_MODULE_ID='"hexo"'
 
 objs = cpu.o interrupt.o enum.o atomic.o bit.o flash.o
 
--- a/libdevice/Makefile	Fri May 18 13:37:17 2018 +0200
+++ b/libdevice/Makefile	Fri May 18 13:44:37 2018 +0200
@@ -1,5 +1,5 @@
 
-DIR_CFLAGS = -D_HEXO_INTTYPES_DEPRECATED
+DIR_CFLAGS = -D_HEXO_INTTYPES_DEPRECATED -DLOGK_MODULE_ID='"dev "'
 
 enum_headers = include/device/types.h \
                include/device/driver.h \
--- a/libdevice/device_clock.c	Fri May 18 13:37:17 2018 +0200
+++ b/libdevice/device_clock.c	Fri May 18 13:44:37 2018 +0200
@@ -21,6 +21,7 @@
 
 */
 
+#undef LOGK_MODULE_ID
 #define LOGK_MODULE_ID "devc"
 
 #include <device/device.h>
--- a/libdevice/device_usbdev.c	Fri May 18 13:37:17 2018 +0200
+++ b/libdevice/device_usbdev.c	Fri May 18 13:44:37 2018 +0200
@@ -20,6 +20,7 @@
 
 */
 
+#undef LOGK_MODULE_ID
 #define LOGK_MODULE_ID "usbd"
 
 #include <device/device.h>
--- a/libdevice/driver.c	Fri May 18 13:37:17 2018 +0200
+++ b/libdevice/driver.c	Fri May 18 13:44:37 2018 +0200
@@ -21,8 +21,6 @@
     Copyright (c) 2011 Institut Telecom / Telecom ParisTech
 */
 
-#define LOGK_MODULE_ID "ddrv"
-
 #include <hexo/error.h>
 #include <hexo/ordering.h>
 
@@ -484,13 +482,13 @@
  switch (err)
     {
     case 0:
-      logk_debug(" - %p %s done", dev, dev->node.name);
+      logk_debug(" - %s init done", dev->node.name);
       dev->status = DEVICE_INIT_DONE;
       break;
 
     case -EAGAIN:
 #if defined(CONFIG_DEVICE_INIT_PARTIAL) || defined(CONFIG_DEVICE_INIT_ASYNC)
-      logk_debug(" - %p %s ongoing", dev, dev->node.name);
+      logk_debug(" - %s init ongoing", dev->node.name);
       dev->status = DEVICE_INIT_ONGOING;
       break;
 #else
@@ -501,13 +499,13 @@
 #ifdef CONFIG_DEVICE_INIT_PARTIAL
       if (dev->init_mask)
         {
-          logk_debug(" - %p %s partial (err=%i)", dev, dev->node.name, err);
+          logk_debug(" - %s init partial (err=%i)", dev->node.name, err);
           dev->status = DEVICE_INIT_PARTIAL;
         }
       else
 #endif
         {
-          logk_error(" - %p %s fail (err=%i)", dev, dev->node.name, err);
+          logk_error(" - %s fail (err=%i)", dev->node.name, err);
 #ifdef CONFIG_DEVICE_TREE
           assert(device_list_isempty(&dev->node.children));
 #endif
@@ -528,9 +526,6 @@
 void device_async_init_done(struct device_s *dev, error_t err)
 {
   assert(dev->status == DEVICE_INIT_ONGOING);
-
-  logk_debug("Initializing %p %s...", dev, dev->node.name);
-
   device_update_status(dev, err);
 }
 
@@ -763,8 +758,8 @@
 #endif
             default:
             missing:
-              logk_error(" - %p %s dependency error `%s'",
-                     dev, dev->node.name, path);
+              logk_error(" - %s dependency error on `%s'",
+                     dev->node.name, path);
               dev->status = DEVICE_INIT_FAILED;
               return -ENOENT;
 
@@ -795,7 +790,7 @@
     return -EAGAIN;
 #endif
 
-  logk_debug("Initializing %p %s...", dev, dev->node.name);
+  logk_debug("Init %s", dev->node.name);
 
   /* device init */
   err = drv->f_init(dev, cl_missing);
--- a/libdevice/init.c	Fri May 18 13:37:17 2018 +0200
+++ b/libdevice/init.c	Fri May 18 13:44:37 2018 +0200
@@ -19,8 +19,6 @@
 
 */
 
-#define LOGK_MODULE_ID "devi"
-
 #include <mutek/startup.h>
 #include <mutek/printk.h>
 
@@ -57,7 +55,7 @@
 
   device_put_accessor(&cpu_dev.base);
 
-  logk_debug(" - %u done", id);
+  logk_debug(" - cpu %u done", id);
 
   mutekh_startup_smp_barrier();
 }
--- a/libdevice/irq.c	Fri May 18 13:37:17 2018 +0200
+++ b/libdevice/irq.c	Fri May 18 13:44:37 2018 +0200
@@ -21,8 +21,6 @@
 
 */
 
-#define LOGK_MODULE_ID "dirq"
-
 #include <device/device.h>
 #include <device/resources.h>
 #include <device/driver.h>
@@ -352,7 +350,7 @@
 
       if (!icu_path)
         {
-          logk_error("Missing icu device resource for device %p", dev);
+          logk_error("%s: Missing icu device resource", dev->node.name);
           return -ENOENT;
         }
 
@@ -360,15 +358,16 @@
 
       if (src_id >= src_count)
         {
-          logk_error("Driver for device %p does not provide source endpoint for IRQ output %u",
-                 dev, src_id);
+          logk_error("%s: Driver does not provide source endpoint for IRQ output %u",
+                 dev->node.name, src_id);
           err = -ENOENT;
           goto error;
         }
 
       if (done[src_id])
         {
-          logk_error("Multiple resource entries for IRQ source endpoint %u", dev, src_id);
+          logk_error("%s: Multiple resource entries for IRQ source endpoint %u",
+                     dev->node.name, src_id);
           err = -ENOENT;
           goto error;
         }
@@ -376,7 +375,8 @@
       struct device_icu_s icu;
       if (device_get_accessor_by_path(&icu.base, &dev->node, icu_path, DRIVER_CLASS_ICU))
         {
-          logk_error("Can not use %s device as an interrupt controller", icu_path);
+          logk_error("%s: Can not use `%s' device as an interrupt controller",
+                     dev->node.name, icu_path);
           err = -EINVAL;
           goto error;
         }
@@ -389,7 +389,8 @@
 
       if (!sink)
         {
-          logk_error("Interrupt controller %p does not have sink endpoint for IRQ input %u", icu_dev, r->u.irq.sink_id);
+          logk_error("%s: Interrupt controller `%s' does not have sink endpoint for IRQ input %u",
+                     dev->node.name, icu_dev->node.name, r->u.irq.sink_id);
           err = -EINVAL;
           goto error;
         }
@@ -410,7 +411,8 @@
         {
           if (irq_id != src->irq_id)
             {
-              logk_error("Irq linked to multiple sinks with different logical ids", icu_dev);
+              logk_error("%s: Irq linked to multiple sinks with different logical ids",
+                         icu_dev->node.name);
               err = -EINVAL;
               goto error;
             }
@@ -425,7 +427,8 @@
           trig_mode &= sink->sense_link;
           if (!trig_mode)
             {
-              logk_error("Icu %p can't share a sink endpoint with a different trigger mode", icu_dev);
+              logk_error("%s: Can't share a sink endpoint with a different trigger modes",
+                         icu_dev->node.name);
               err = -EINVAL;
               goto error;
             }
@@ -440,7 +443,8 @@
               trig_mode &= sink->sense_all;
               if (!trig_mode)
                 {
-                  logk_error("Trigger modes of IRQ source %u of device %p not supported by sink", src_id, dev);
+                  logk_error("%s: Trigger modes of IRQ source %u not supported by sink",
+                             dev->node.name, src_id);
                   err = -EINVAL;
                   goto error;
                 }
@@ -453,7 +457,7 @@
       /* setup interrupt controller */
       if ((err = device_icu_source_link(src, &route_mask)))
         {
-          logk_error("Unable to link IRQ source %u of device %p", src_id, dev);
+          logk_error("%s: Unable to link IRQ source %u", dev->node.name, src_id);
           err = -EINVAL;
           goto error;
         }
@@ -479,7 +483,8 @@
   for (i = 0; i < src_count; i++)
     if (!done[i])
       {
-        logk_error("Unable to link IRQ source endpoint %u of device %p, no IRQ resource entry", i, dev);
+        logk_error("%s: Unable to link IRQ source endpoint %u, no IRQ resource entry",
+                   dev->node.name, i);
         err = -ENOENT;
         goto error;
       }
@@ -634,7 +639,7 @@
 
     err = device_get_accessor_by_path(&icu.base, NULL, icu_name, DRIVER_CLASS_ICU);
     if (err) {
-        logk_error("Error while getting icu \"%s\": %d", icu_name, err);
+        logk_error("Unable to get icu `%s'", icu_name);
         return err;
     }
 
--- a/mutek/Makefile	Fri May 18 13:37:17 2018 +0200
+++ b/mutek/Makefile	Fri May 18 13:44:37 2018 +0200
@@ -1,5 +1,5 @@
 
-DIR_CFLAGS = -D_HEXO_INTTYPES_DEPRECATED
+DIR_CFLAGS = -D_HEXO_INTTYPES_DEPRECATED -DLOGK_MODULE_ID='"mutk"'
 
 objs += startup.o kroutine.o
 
--- a/mutek/bytecode.t	Fri May 18 13:37:17 2018 +0200
+++ b/mutek/bytecode.t	Fri May 18 13:44:37 2018 +0200
@@ -18,6 +18,7 @@
  * Alexandre Becoulet <alexandre.becoulet@free.fr>
  */
 
+#undef LOGK_MODULE_ID
 #define LOGK_MODULE_ID "bcvm"
 
 #include <mutek/printk.h>
--- a/mutek/fault.c	Fri May 18 13:37:17 2018 +0200
+++ b/mutek/fault.c	Fri May 18 13:44:37 2018 +0200
@@ -20,8 +20,6 @@
 
 */
 
-#define LOGK_MODULE_ID "faul"
-
 #include <mutek/printk.h>
 #include <mutek/startup.h>
 
@@ -53,22 +51,22 @@
   lock_spin(&fault_lock);
 
   logk_error("CPU Fault: cpuid(%u) faultid(%u-%s)", cpu_id(), type, name);
-  logk_error("Execution pointer: %p, Bad address (if any): %p",
+  logk(" - PC: %p, Bad address: %p",
              (void*)execptr, (void*)dataptr);
-  logk_error("Registers:");
+  logk_debug(" - Registers:");
 
   reg_t *r = regs->gpr;
   for (i = 0; i < CPU_CONTEXT_REG_COUNT; i++)
 # ifdef CPU_CONTEXT_REG_NAMES
-    logk_error(" %s=%p", reg_names[i], (void*)*(r + i));
+    logk_debug(" %s=%p", reg_names[i], (void*)*(r + i));
 # else
-    logk_error(" %p", (void*)*(r + i));
+    logk_debug(" %p", (void*)*(r + i));
 # endif
 
-  logk_error("Stack:");
+  logk_debug("Stack:");
 
   for (i = 0; i < 12; i++)
-    logk_error(" %p: %p", &sp[i], (void*)(uintptr_t)sp[i]);
+    logk_debug(" %p: %p", &sp[i], (void*)(uintptr_t)sp[i]);
 
   lock_release(&fault_lock);
 #endif
--- a/mutek/mutek.config	Fri May 18 13:37:17 2018 +0200
+++ b/mutek/mutek.config	Fri May 18 13:44:37 2018 +0200
@@ -232,7 +232,7 @@
   parent CONFIG_MUTEK_PRINTK
   flags value userval
   # example: level >= LOGK_LEVEL_DEBUG || id == 'test'
-  default level >= LOGK_LEVEL_NORMAL
+  default level >= CONFIG_MUTEK_PRINTK_RUNTIME_LEVEL
 %config end
 
 %config CONFIG_MUTEK_PRINTK_RUNTIME_LEVEL
--- a/mutek/scheduler.c	Fri May 18 13:37:17 2018 +0200
+++ b/mutek/scheduler.c	Fri May 18 13:44:37 2018 +0200
@@ -26,6 +26,8 @@
 
 #include <mutek/semaphore.h>
 #include <mutek/startup.h>
+#include <mutek/printk.h>
+
 #include <hexo/local.h>
 #include <hexo/cpu.h>
 #include <hexo/ipi.h>
@@ -908,11 +910,14 @@
 #endif
 
   cpu_interrupt_disable();
-# ifndef CONFIG_ARCH_SMP
+
   mutekh_startup_smp_barrier();
   if (cpu_isbootstrap())
-# endif
-    sched_started = 1;
+    {
+      sched_started = 1;
+      logk_debug("Starting scheduler loop");
+    }
+
   mutekh_startup_smp_barrier();
   sched_context_idle();
 }
--- a/mutek/startup.c	Fri May 18 13:37:17 2018 +0200
+++ b/mutek/startup.c	Fri May 18 13:44:37 2018 +0200
@@ -173,6 +173,8 @@
   /* call all bootstrap init functions */
   INIT_BOOTSTRAP_INIT();
 
+  logk_debug("Bootstrap init done");
+
 #if defined(CONFIG_DEVICE_CPU)
   const struct cpu_tree_s *cpu = cpu_tree_lookup(CONFIG_ARCH_BOOTSTRAP_CPU_ID);
   assert(cpu != NULL && "processor id not found in the cpu tree.");
@@ -189,11 +191,14 @@
   /* call smp init functions */
   INIT_SMP_INIT();
 
+  logk_error("Reached end of init, halting");
   abort();
 }
 
 void mutekh_startup_devready()
 {
+  logk("System started");
+
   INIT_DEVREADY_INIT();
 }