Main Page | Directories | File List | Globals

printk.c

Go to the documentation of this file.
00001 /*
00002  * kernel_sys/printk.c
00003  *
00004  * Copyright (c) 2003-2004 Lukasz Dembinski <dembol@nasa.com.pl>
00005  * All Rights Reserved
00006  * 
00007  * Date:        2004/01
00008  * Author:      Lukasz Dembinski
00009  * Info:        printk.c core file
00010  * Contact:     mailto: <dembol@nasa.com.pl>
00011  *
00012  */
00013 
00014 #include <agnix/agnix.h> 
00015 #include <agnix/init.h> 
00016 
00017 #if CONFIG_DRIVERS_CHAR
00018 
00019 #include <agnix/memory.h>
00020 #include <agnix/terminal.h>
00021 #include <agnix/display.h>
00022 #include <agnix/unistd.h>
00023 #include <stdarg.h>
00024 #include <asm/irq.h>
00025 
00026 extern struct terminal_s term_sys[MAX_TERMINALS];
00027 extern int vsnprintf(char *buf, int size, const char *fmt, va_list args);
00028 extern int term_cur;
00029 extern int term_init;
00030 
00031 void printk(const char *text, ...)
00032 {
00033     va_list args;
00034     char text_buf[1024];
00035     int len;
00036     u32 flags;
00037     int i;
00038 
00039     if (!term_init)
00040         return;
00041 
00042     save_flags(flags); __cli();
00043     
00044     memset(text_buf, 0, 1024);
00045 
00046     va_start(args, text);
00047     len = vsnprintf(text_buf, 1024, text, args);
00048     va_end(args);
00049 
00050     /* printk to all terminals */
00051     for (i = 0; i < MAX_TERMINALS; i++) {
00052         if (term_sys[i].ops && term_sys[i].ops->write)
00053             term_sys[i].ops->write(&term_sys[i], text_buf, len);
00054     }
00055     
00056     restore_flags(flags);
00057 }
00058 
00059 void printf(const char *text, ...)
00060 {
00061     struct terminal_s *term = current_task->term;
00062     va_list args;
00063     char text_buf[1024];
00064     int len;
00065     u32 flags;
00066 
00067     if (!term_init)
00068         return;
00069 
00070     if (term == NULL)
00071         return;
00072 
00073     save_flags(flags); __cli();
00074     
00075     memset(text_buf, 0, 1024);
00076 
00077     va_start(args, text);
00078     len = vsnprintf(text_buf, 1024, text, args);
00079     va_end(args);
00080 
00081     write(0, text_buf, len);
00082 
00083     restore_flags(flags);
00084 }
00085 
00086 #else
00087 
00088 void printk(const char *text, ...)
00089 {
00090 }
00091 
00092 void printf(const char *text, ...)
00093 {
00094 }
00095 
00096 #endif
Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix