Skip to content

Commit 35cdaf2

Browse files
author
Patrick Williams
committed
Support for serial console.
Change-Id: Ia1b11f68cc4be175076562b7daf0291b14df498b Origin: Google Shared Technology RTC: 97495 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13250 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <[email protected]> Reviewed-by: A. Patrick Williams III <[email protected]>
1 parent ce53b72 commit 35cdaf2

26 files changed

+1028
-15
lines changed

src/build/mkrules/cflags.env.mk

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
# Contributors Listed Below - COPYRIGHT 2013,2014
99
# [+] International Business Machines Corp.
10+
# [+] Google Inc.
1011
#
1112
#
1213
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,3 +53,7 @@ ifdef HOSTBOOT_RUNTIME
5253
CFLAGS += -D__HOSTBOOT_RUNTIME=1
5354
TRACE_FLAGS += --full-strings
5455
endif
56+
57+
ifdef CONFIG_CONSOLE_OUTPUT_TRACE
58+
TRACE_FLAGS += --full-strings
59+
endif

src/build/tools/addCopyright.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#
99
# Contributors Listed Below - COPYRIGHT 2011,2014
1010
# [+] International Business Machines Corp.
11+
# [+] Google Inc.
1112
#
1213
#
1314
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -691,7 +692,8 @@ ( $$ )
691692
# remove everything through [+]
692693
$_ =~ s/[^\]]*\]//;
693694
# remove closing comment string depening on language
694-
if ( filetype($filename) eq "C")
695+
if (( filetype($filename) eq "C") ||
696+
( filetype($filename) eq "LinkerScript"))
695697
{
696698
# remove */
697699
$_ =~ s/\*\///;

src/build/tools/listdeps.pl

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
"libscan.so" => '1',
211211
"libgpio.so" => '1',
212212
"liblpc.so" => '1',
213+
"libconsole.so" => '1',
213214

214215
);
215216

src/include/sys/sync.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* COPYRIGHT International Business Machines Corp. 2011,2014 */
8+
/* Contributors Listed Below - COPYRIGHT 2011,2014 */
9+
/* [+] Google Inc. */
10+
/* [+] International Business Machines Corp. */
11+
/* */
912
/* */
1013
/* Licensed under the Apache License, Version 2.0 (the "License"); */
1114
/* you may not use this file except in compliance with the License. */
@@ -20,8 +23,8 @@
2023
/* permissions and limitations under the License. */
2124
/* */
2225
/* IBM_PROLOG_END_TAG */
23-
#ifndef SYNC
24-
#define SYNC
26+
#ifndef __SYS_SYNC_H
27+
#define __SYS_SYNC_H
2528

2629
#include <stdint.h>
2730

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* IBM_PROLOG_BEGIN_TAG */
2+
/* This is an automatically generated prolog. */
3+
/* */
4+
/* $Source: src/include/usr/console/console_reasoncodes.H $ */
5+
/* */
6+
/* OpenPOWER HostBoot Project */
7+
/* */
8+
/* Contributors Listed Below - COPYRIGHT 2014 */
9+
/* [+] International Business Machines Corp. */
10+
/* [+] Google Inc. */
11+
/* */
12+
/* */
13+
/* Licensed under the Apache License, Version 2.0 (the "License"); */
14+
/* you may not use this file except in compliance with the License. */
15+
/* You may obtain a copy of the License at */
16+
/* */
17+
/* http://www.apache.org/licenses/LICENSE-2.0 */
18+
/* */
19+
/* Unless required by applicable law or agreed to in writing, software */
20+
/* distributed under the License is distributed on an "AS IS" BASIS, */
21+
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
22+
/* implied. See the License for the specific language governing */
23+
/* permissions and limitations under the License. */
24+
/* */
25+
/* IBM_PROLOG_END_TAG */
26+
#ifndef __CONSOLE_CONSOLE_REASONCODES_H
27+
#define __CONSOLE_CONSOLE_REASONCODES_H
28+
29+
#include <hbotcompid.H>
30+
31+
namespace CONSOLE
32+
{
33+
enum ConsoleModuleId
34+
{
35+
MOD_CONSOLE_INVALID_MODULE = 0x00,
36+
MOD_CONSOLE_UART_PUTC = 0x01,
37+
};
38+
39+
enum ConsoleReasonCode
40+
{
41+
RC_INVALID_DATA = CONSOLE_COMP_ID | 0x01,
42+
RC_TIMEOUT = CONSOLE_COMP_ID | 0x02,
43+
};
44+
}
45+
46+
#endif

src/include/usr/console/consoleif.H

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* IBM_PROLOG_BEGIN_TAG */
2+
/* This is an automatically generated prolog. */
3+
/* */
4+
/* $Source: src/include/usr/console/consoleif.H $ */
5+
/* */
6+
/* OpenPOWER HostBoot Project */
7+
/* */
8+
/* Contributors Listed Below - COPYRIGHT 2014 */
9+
/* [+] Google Inc. */
10+
/* [+] International Business Machines Corp. */
11+
/* */
12+
/* */
13+
/* Licensed under the Apache License, Version 2.0 (the "License"); */
14+
/* you may not use this file except in compliance with the License. */
15+
/* You may obtain a copy of the License at */
16+
/* */
17+
/* http://www.apache.org/licenses/LICENSE-2.0 */
18+
/* */
19+
/* Unless required by applicable law or agreed to in writing, software */
20+
/* distributed under the License is distributed on an "AS IS" BASIS, */
21+
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
22+
/* implied. See the License for the specific language governing */
23+
/* permissions and limitations under the License. */
24+
/* */
25+
/* IBM_PROLOG_END_TAG */
26+
#ifndef __CONSOLE_CONSOLEIF_H
27+
#define __CONSOLE_CONSOLEIF_H
28+
29+
#include <config.h>
30+
#include <stdarg.h>
31+
32+
namespace CONSOLE
33+
{
34+
35+
/** @brief Display a string to the console.
36+
*
37+
* @param[in] - String to display.
38+
*/
39+
extern void display(const char*)
40+
#ifdef CONFIG_CONSOLE
41+
;
42+
#else
43+
{};
44+
#endif
45+
46+
/** @brief Display formatted string to the console.
47+
*
48+
* @param[in] - Header (or NULL).
49+
* @param[in] - Format string.
50+
*/
51+
extern void displayf(const char*, const char*, ...)
52+
#ifdef CONFIG_CONSOLE
53+
;
54+
#else
55+
{};
56+
#endif
57+
58+
/** @brief Display formatted string to the console.
59+
*
60+
* @param[in] - Header (or NULL).
61+
* @param[in] - Format string.
62+
* @param[in] - va_list of arguments.
63+
*/
64+
extern void vdisplayf(const char*, const char*, va_list)
65+
#ifdef CONFIG_CONSOLE
66+
;
67+
#else
68+
{};
69+
#endif
70+
71+
72+
/** @brief Wait for console buffers to be flushed to device.
73+
*/
74+
extern void flush()
75+
#ifdef CONFIG_CONSOLE
76+
;
77+
#else
78+
{};
79+
#endif
80+
81+
};
82+
83+
#endif

src/include/usr/hbotcompid.H

+8-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,14 @@ const compId_t DUMP_COMP_ID = 0x1200;
197197
const char DUMP_COMP_NAME[] = "dump";
198198
//@}
199199

200-
// 0x1300 - open to reclaim
200+
201+
/** @name CONSOLE
202+
* Console component.
203+
*/
204+
//@{
205+
const compId_t CONSOLE_COMP_ID = 0x1300;
206+
const char CONSOLE_COMP_NAME[] = "console";
207+
//@}
201208

202209
/** @name MDIA
203210
* MDIA memory diagnostics component

src/include/usr/initservice/initserviceif.H

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* COPYRIGHT International Business Machines Corp. 2011,2014 */
8+
/* Contributors Listed Below - COPYRIGHT 2011,2014 */
9+
/* [+] International Business Machines Corp. */
10+
/* [+] Google Inc. */
11+
/* */
912
/* */
1013
/* Licensed under the Apache License, Version 2.0 (the "License"); */
1114
/* you may not use this file except in compliance with the License. */
@@ -41,8 +44,9 @@ namespace INITSERVICE
4144
enum EventPriority_t
4245
{
4346
LOWEST_PRIORITY = 0, //!<< Notifiy last, LIFO order
44-
INTR_PRIORITY = LOWEST_PRIORITY, //!<< Shutdown INTR
45-
MBOX_PRIORITY = 1, //!<< Shutdown MBOX
47+
CONSOLE_PRIORITY = LOWEST_PRIORITY, //!<< Shutdown Console
48+
INTR_PRIORITY = 1, //!<< Shutdown INTR
49+
MBOX_PRIORITY = 2, //!<< Shutdown MBOX
4650
NO_PRIORITY = 16, //!<< No dependency / dont' care, LIFO order
4751
HIGHEST_PRIORITY = 127, //!<< Nofity first, LIFO order
4852
};

src/kernel.ld

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/* */
88
/* Contributors Listed Below - COPYRIGHT 2010,2014 */
99
/* [+] International Business Machines Corp. */
10+
/* [+] Google Inc. */
1011
/* */
1112
/* */
1213
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -42,6 +43,7 @@ SECTIONS
4243
__minimum_data_start_addr = ALIGN(0x1000);
4344
ctor_start_address = .;
4445
*(.ctors)
46+
*(.ctors.*)
4547
ctor_end_address = .;
4648
*(.rodata)
4749
*(.rodata.*)

src/makefile

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ EXTENDED_MODULES += devtree
161161
EXTENDED_MODULES += sbe
162162
EXTENDED_MODULES += proc_hwreconfig
163163
EXTENDED_MODULES += $(if $(CONFIG_GPIODD),gpio,)
164+
EXTENDED_MODULES += $(if $(CONFIG_CONSOLE),console)
164165

165166
TESTCASE_MODULES += cxxtest
166167
TESTCASE_MODULES += testtrace

src/module.ld

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/* */
88
/* Contributors Listed Below - COPYRIGHT 2010,2014 */
99
/* [+] International Business Machines Corp. */
10+
/* [+] Google Inc. */
1011
/* */
1112
/* */
1213
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -35,6 +36,7 @@ SECTIONS
3536
__minimum_data_start_addr = ALIGN(0x1000);
3637
ctor_start_address = .;
3738
*(.ctors)
39+
*(.ctors.*)
3840
ctor_end_address = .;
3941
*(.rodata)
4042
*(.rodata.*)

src/usr/console/HBconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
config CONSOLE
2+
default n
3+
help
4+
Enable console support.

src/usr/console/console.C

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* IBM_PROLOG_BEGIN_TAG */
2+
/* This is an automatically generated prolog. */
3+
/* */
4+
/* $Source: src/usr/console/console.C $ */
5+
/* */
6+
/* OpenPOWER HostBoot Project */
7+
/* */
8+
/* Contributors Listed Below - COPYRIGHT 2014 */
9+
/* [+] International Business Machines Corp. */
10+
/* [+] Google Inc. */
11+
/* */
12+
/* */
13+
/* Licensed under the Apache License, Version 2.0 (the "License"); */
14+
/* you may not use this file except in compliance with the License. */
15+
/* You may obtain a copy of the License at */
16+
/* */
17+
/* http://www.apache.org/licenses/LICENSE-2.0 */
18+
/* */
19+
/* Unless required by applicable law or agreed to in writing, software */
20+
/* distributed under the License is distributed on an "AS IS" BASIS, */
21+
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
22+
/* implied. See the License for the specific language governing */
23+
/* permissions and limitations under the License. */
24+
/* */
25+
/* IBM_PROLOG_END_TAG */
26+
#include <console/consoleif.H>
27+
#include <util/sprintf.H>
28+
#include <sys/msg.h>
29+
#include <stdio.h>
30+
#include <string.h>
31+
#include <time.h>
32+
#include <vector>
33+
#include "daemon.H"
34+
35+
namespace CONSOLE
36+
{
37+
msg_q_t g_msgq = msg_q_create();
38+
39+
void display(const char* str)
40+
{
41+
timespec_t time;
42+
clock_gettime(CLOCK_MONOTONIC, &time);
43+
44+
msg_t* msg = msg_allocate();
45+
msg->type = DISPLAY;
46+
msg->data[0] = time.tv_sec;
47+
msg->data[1] = time.tv_nsec;
48+
msg->extra_data = strdup(str);
49+
msg_send(g_msgq, msg);
50+
}
51+
52+
void displayf(const char* header, const char* format, ...)
53+
{
54+
va_list args;
55+
va_start(args, format);
56+
57+
vdisplayf(header, format, args);
58+
59+
va_end(args);
60+
}
61+
62+
void vdisplayf(const char* header, const char* format, va_list args)
63+
{
64+
using Util::vasprintf;
65+
66+
class OutputBuffer : public Util::ConsoleBufferInterface
67+
{
68+
public:
69+
int putc(int c)
70+
{
71+
str.push_back(c);
72+
return c;
73+
}
74+
75+
size_t operator()(int c) { return putc(c); }
76+
77+
std::vector<char> str;
78+
};
79+
80+
OutputBuffer b;
81+
82+
if (header)
83+
{
84+
while(*header)
85+
{
86+
b.putc(*header);
87+
header++;
88+
}
89+
b.putc('|');
90+
}
91+
92+
vasprintf(b, format, args);
93+
b.putc('\n');
94+
b.putc('\0');
95+
96+
if (b.str.size())
97+
{
98+
display(&b.str[0]);
99+
}
100+
}
101+
102+
void flush()
103+
{
104+
msg_t* msg = msg_allocate();
105+
msg->type = SYNC;
106+
msg_sendrecv(g_msgq, msg);
107+
}
108+
109+
}

0 commit comments

Comments
 (0)