summaryrefslogtreecommitdiffstats
path: root/src/kernel/printk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/printk.c')
-rw-r--r--src/kernel/printk.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/kernel/printk.c b/src/kernel/printk.c
new file mode 100644
index 0000000..0daa097
--- /dev/null
+++ b/src/kernel/printk.c
@@ -0,0 +1,41 @@
1/*
2 * linux/kernel/printk.c
3 *
4 * (C) 1991 Linus Torvalds
5 */
6
7/*
8 * When in kernel-mode, we cannot use printf, as fs is liable to
9 * point to 'interesting' things. Make a printf with fs-saving, and
10 * all is well.
11 */
12#include <stdarg.h>
13#include <stddef.h>
14
15#include <linux/kernel.h>
16
17static char buf[1024];
18
19extern int vsprintf(char * buf, const char * fmt, va_list args);
20
21int printk(const char *fmt, ...)
22{
23 va_list args;
24 int i;
25
26 va_start(args, fmt);
27 i=vsprintf(buf,fmt,args);
28 va_end(args);
29 __asm__("push %%fs\n\t"
30 "push %%ds\n\t"
31 "pop %%fs\n\t"
32 "pushl %0\n\t"
33 "pushl $buf\n\t"
34 "pushl $0\n\t"
35 "call tty_write\n\t"
36 "addl $8,%%esp\n\t"
37 "popl %0\n\t"
38 "pop %%fs"
39 ::"r" (i):"ax","cx","dx");
40 return i;
41}