POK(kernelpart)
cons.c
Go to the documentation of this file.
1 /*
2  * POK header
3  *
4  * The following file is a part of the POK project. Any modification should
5  * made according to the POK licence. You CANNOT use this file or a part of
6  * this file is this part of a file for your own project
7  *
8  * For more information on the POK licence, please see our LICENCE FILE
9  *
10  * Please follow the coding guidelines described in doc/CODING_GUIDELINES
11  *
12  * Copyright (c) 2007-2009 POK team
13  *
14  * Created by julien on Thu Jan 15 23:34:13 2009
15  */
16 
23 #include <errno.h>
24 
25 #include "ioports.h"
26 #include <libc.h>
27 #include <core/debug.h>
28 #include <core/cons.h>
29 #include "cons.h"
30 
31 #if defined (POK_NEEDS_CONSOLE) || defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_INSTRUMENTATION) || defined (POK_NEEDS_COVERAGE_INFOS)
32 
33 static void write_serial(char a)
34 {
35  while ((inw(UART1 + UART_STAT_OFFSET) & UART_STATUS_THE) == 0)
36  continue;
37 
39 }
40 
41 pok_bool_t pok_cons_write (const char *s, size_t length)
42 {
43  for (; length > 0; length--)
44  write_serial (*s++);
45  return 0;
46 }
47 
48 
53 int pok_cons_init (void)
54 {
55  outw(UART1 + UART_CTRL_OFFSET, UART_CTRL_TE); /* transmit enable */
56  outw(UART1 + UART_STAT_OFFSET, 0);
57 
58  pok_print_init (write_serial, NULL);
59  return 0;
60 }
61 #else
62 int pok_cons_init (void)
63 {
64  return 0;
65 }
66 #endif
67 
68