POK(kernelpart)
/home/jaouen/pok_official/pok/trunk/kernel/arch/sparc/leon3/cons.c
Go to the documentation of this file.
00001 /*
00002  *                               POK header
00003  * 
00004  * The following file is a part of the POK project. Any modification should
00005  * made according to the POK licence. You CANNOT use this file or a part of
00006  * this file is this part of a file for your own project
00007  *
00008  * For more information on the POK licence, please see our LICENCE FILE
00009  *
00010  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
00011  *
00012  *                                      Copyright (c) 2007-2009 POK team 
00013  *
00014  * Created by julien on Thu Jan 15 23:34:13 2009 
00015  */
00016 
00023 #include <errno.h>
00024 
00025 #include "ioports.h"
00026 #include <libc.h>
00027 #include <core/debug.h>
00028 #include <core/cons.h>
00029 #include "cons.h"
00030 
00031 #if defined (POK_NEEDS_CONSOLE) || defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_INSTRUMENTATION) || defined (POK_NEEDS_COVERAGE_INFOS)
00032 
00033 static void write_serial(char a)
00034 {
00035   while ((inw(UART1 + UART_STAT_OFFSET) & UART_STATUS_THE) == 0)
00036     continue;
00037 
00038   outb(UART1 + UART_DATA_OFFSET, (uint8_t)a);
00039 }
00040 
00041 pok_bool_t pok_cons_write (const char *s, size_t length)
00042 {
00043   for (; length > 0; length--)
00044     write_serial (*s++);
00045   return 0;
00046 }
00047 
00048 
00053 int pok_cons_init (void)
00054 {
00055   outw(UART1 + UART_CTRL_OFFSET, UART_CTRL_TE); /* transmit enable */
00056   outw(UART1 + UART_STAT_OFFSET, 0);
00057 
00058   pok_print_init (write_serial, NULL);
00059   return 0;
00060 }
00061 #else
00062 int pok_cons_init (void)
00063 {
00064   return 0;
00065 }
00066 #endif
00067 
00068