Rename printk() to printf().
[pintos-anon] / src / lib / kernel / printf.c
1 #include <stdarg.h>
2 #include <stdio.h>
3
4 #include "devices/serial.h"
5 #include "devices/vga.h"
6 #include "threads/interrupt.h"
7
8 static void vprintf_helper (char, void *);
9
10 int
11 vprintf (const char *format, va_list args) 
12 {
13   enum intr_level old_level;
14   int char_cnt = 0;
15
16   old_level = intr_disable ();
17   __vprintf (format, args, vprintf_helper, &char_cnt);
18   intr_set_level (old_level);
19
20   return char_cnt;
21 }
22
23 /* Helper function for vprintf(). */
24 static void
25 vprintf_helper (char c, void *char_cnt_) 
26 {
27   int *char_cnt = char_cnt_;
28   (*char_cnt)++;
29   putchar (c);
30 }
31
32 /* Writes C to the console. */
33 int
34 putchar (int c) 
35 {
36   serial_outb (c);
37   vga_putc (c);
38   return c;
39 }