blob: eaab1de28b67a4141427789e413438e79e56b726 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/kernel/console.C $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2010,2013 */
/* */
/* p1 */
/* */
/* Object Code Only (OCO) source materials */
/* Licensed Internal Code Source Materials */
/* IBM HostBoot Licensed Internal Code */
/* */
/* The source code for this program is not published or otherwise */
/* divested of its trade secrets, irrespective of what has been */
/* deposited with the U.S. Copyright Office. */
/* */
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
#include <util/singleton.H>
#include <kernel/console.H>
#include <util/sprintf.H>
#include <stdarg.h>
char kernel_printk_buffer[Console::BUFFER_SIZE];
Console::Console() : iv_pos(0), iv_buffer(kernel_printk_buffer)
{
memset(iv_buffer, '\0', Console::BUFFER_SIZE);
}
int Console::putc(int c)
{
if ('\b' == c)
{
__sync_sub_and_fetch(&iv_pos, 1);
}
else if (BUFFER_SIZE > iv_pos)
{
iv_buffer[__sync_fetch_and_add(&iv_pos, 1)] = c;
}
return c;
}
void printk(const char* str, ...)
{
using Util::vasprintf;
va_list args;
va_start(args, str);
Console& console = Singleton<Console>::instance();
vasprintf(console, str, args);
va_end(args);
}
|