Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / kernel / printk.c
diff --git a/kitten/kernel/printk.c b/kitten/kernel/printk.c
new file mode 100644 (file)
index 0000000..772c872
--- /dev/null
@@ -0,0 +1,52 @@
+#include <lwk/kernel.h>
+#include <lwk/console.h>
+#include <lwk/smp.h>
+
+/**
+ * Prints a message to the console.
+ */
+int printk(const char *fmt, ...)
+{
+       va_list args;
+       va_start(args, fmt);
+       int rc = vprintk( fmt, args );
+       va_end(args);
+       return rc;
+}
+
+
+int printk_print_cpu_number;
+
+
+int
+vprintk(
+       const char *            fmt,
+       va_list                 args
+)
+{
+       int len;
+       char buf[1024];
+       char *p = buf;
+       int remain = sizeof(buf);
+
+       /* Start with a NULL terminated string */
+       *p = '\0';
+
+       /* Tack on the logical CPU ID */
+       if( printk_print_cpu_number )
+       {
+               len = sprintf(p, "[%u]:", this_cpu);
+               p      += len;
+               remain -= len;
+       }
+
+       /* Construct the string... */
+       len = vscnprintf(p, remain, fmt, args);
+
+       /* Pass the string to the console subsystem */
+       console_write(buf);
+
+       /* Return number of characters printed */
+       return len;
+}
+