Add putbuf().
[pintos-anon] / src / lib / kernel / console.c
index 7ce9cbfc12dab8af872dfafaf5c9b665849661e2..149f29c7eb46f07e12c6af8744d8669e25b0340c 100644 (file)
@@ -1,3 +1,4 @@
+#include <console.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include "devices/serial.h"
@@ -58,6 +59,20 @@ puts (const char *s)
   return 0;
 }
 
+/* Writes the N characters in BUFFER to the console. */
+void
+putbuf (const char *buffer, size_t n) 
+{
+  if (!intr_context ())
+    lock_acquire (&console_lock);
+
+  while (n-- > 0)
+    putchar_unlocked (*buffer++);
+
+  if (!intr_context ())
+    lock_release (&console_lock);
+}
+
 /* Writes C to the vga display and serial port. */
 int
 putchar (int c)