blob: ef73a9a355bc3c5db3a78d13da4406aa7f30bf4f [file] [log] [blame]
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07001/*
2 * Copyright (c) 2011-2012, 2014-2015 Wind River Systems, Inc.
3 *
Javier B Perez Hernandezf7fffae2015-10-06 11:00:37 -05004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07007 *
Javier B Perez Hernandezf7fffae2015-10-06 11:00:37 -05008 * http://www.apache.org/licenses/LICENSE-2.0
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -07009 *
Javier B Perez Hernandezf7fffae2015-10-06 11:00:37 -050010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070015 */
16
Anas Nashif275ca602015-12-04 10:09:39 -050017/**
18 * @file
19 * @brief UART-driven console
20 *
Dan Kalowskyda67b292015-10-20 09:42:33 -070021 *
22 * Serial console driver.
23 * Hooks into the printk and fputc (for printf) modules. Poll driven.
Anas Nashifea0d0b22015-07-01 17:22:39 -040024 */
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070025
Andrei Emeltchenko139c8562015-04-20 11:04:22 +030026#include <nanokernel.h>
Dan Kalowskyc02dd342015-05-28 10:56:47 -070027#include <arch/cpu.h>
Andrei Emeltchenko139c8562015-04-20 11:04:22 +030028
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070029#include <stdio.h>
30#include <stdint.h>
Andrei Emeltchenko139c8562015-04-20 11:04:22 +030031#include <errno.h>
Johan Hedbergf88cccd2015-12-08 10:35:04 +020032#include <ctype.h>
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070033
Daniel Leungad2d2962015-08-12 10:17:35 -070034#include <device.h>
35#include <init.h>
36
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070037#include <board.h>
Tomasz Bursztyka17e06fb2015-10-15 09:48:03 +030038#include <uart.h>
Tomasz Bursztykaae09a482015-04-23 13:12:51 +030039#include <console/uart_console.h>
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070040#include <toolchain.h>
41#include <sections.h>
Johan Hedberg8683dc42015-12-09 11:36:25 +020042#include <atomic.h>
Johan Hedberga9f6f892015-12-08 22:45:12 +020043#include <misc/printk.h>
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070044
Daniel Leung08b4fd42015-12-01 08:42:20 -080045static struct device *uart_console_dev;
46
Benjamin Walsh0ff5d372016-04-11 17:11:28 -040047#ifdef CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS
Marcus Shawcroft1bc999c2016-10-23 08:53:21 +010048
49static uart_console_in_debug_hook_t debug_hook_in;
50void uart_console_in_debug_hook_install(uart_console_in_debug_hook_t hook)
51{
52 debug_hook_in = hook;
53}
54
Benjamin Walsh0ff5d372016-04-11 17:11:28 -040055static UART_CONSOLE_OUT_DEBUG_HOOK_SIG(debug_hook_out_nop)
56{
57 ARG_UNUSED(c);
58 return !UART_CONSOLE_DEBUG_HOOK_HANDLED;
59}
60
61static uart_console_out_debug_hook_t *debug_hook_out = debug_hook_out_nop;
62void uart_console_out_debug_hook_install(uart_console_out_debug_hook_t *hook)
63{
64 debug_hook_out = hook;
65}
66#define HANDLE_DEBUG_HOOK_OUT(c) \
67 (debug_hook_out(c) == UART_CONSOLE_DEBUG_HOOK_HANDLED)
68#else
69#define HANDLE_DEBUG_HOOK_OUT(c) 0
70#endif /* CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS */
71
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070072#if 0 /* NOTUSED */
Anas Nashifea0d0b22015-07-01 17:22:39 -040073/**
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070074 *
Anas Nashiff367f072015-07-01 17:51:40 -040075 * @brief Get a character from UART
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070076 *
Anas Nashif1362e3c2015-07-01 17:29:04 -040077 * @return the character or EOF if nothing present
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070078 */
79
Daniel Leung08b4fd42015-12-01 08:42:20 -080080static int console_in(void)
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070081{
82 unsigned char c;
Dan Kalowskyda67b292015-10-20 09:42:33 -070083
Daniel Leung08b4fd42015-12-01 08:42:20 -080084 if (uart_poll_in(uart_console_dev, &c) < 0)
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070085 return EOF;
86 else
87 return (int)c;
88}
89#endif
90
91#if defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE)
Anas Nashifea0d0b22015-07-01 17:22:39 -040092/**
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070093 *
Anas Nashiff367f072015-07-01 17:51:40 -040094 * @brief Output one character to UART
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -070095 *
96 * Outputs both line feed and carriage return in the case of a '\n'.
97 *
Daniel Leung08b4fd42015-12-01 08:42:20 -080098 * @param c Character to output
99 *
Anas Nashif1362e3c2015-07-01 17:29:04 -0400100 * @return The character passed as input.
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700101 */
102
Daniel Leung08b4fd42015-12-01 08:42:20 -0800103static int console_out(int c)
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700104{
Benjamin Walsh0ff5d372016-04-11 17:11:28 -0400105 int handled_by_debug_server = HANDLE_DEBUG_HOOK_OUT(c);
106
107 if (handled_by_debug_server) {
108 return c;
109 }
110
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700111 if ('\n' == c) {
Andy Ross425145d2016-09-01 08:49:10 -0700112 uart_poll_out(uart_console_dev, '\r');
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700113 }
Andy Ross425145d2016-09-01 08:49:10 -0700114 uart_poll_out(uart_console_dev, c);
115
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700116 return c;
117}
Daniel Leung08b4fd42015-12-01 08:42:20 -0800118
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700119#endif
120
121#if defined(CONFIG_STDOUT_CONSOLE)
122extern void __stdout_hook_install(int (*hook)(int));
123#else
124#define __stdout_hook_install(x) \
125 do {/* nothing */ \
126 } while ((0))
127#endif
128
129#if defined(CONFIG_PRINTK)
130extern void __printk_hook_install(int (*fn)(int));
131#else
132#define __printk_hook_install(x) \
133 do {/* nothing */ \
134 } while ((0))
135#endif
136
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300137#if defined(CONFIG_CONSOLE_HANDLER)
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300138static struct nano_fifo *avail_queue;
139static struct nano_fifo *lines_queue;
Szymon Jancd7e8fd02016-05-25 16:23:42 +0200140static uint8_t (*completion_cb)(char *line, uint8_t len);
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300141
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200142/* Control characters */
143#define ESC 0x1b
144#define DEL 0x7f
145
146/* ANSI escape sequences */
147#define ANSI_ESC '['
148#define ANSI_UP 'A'
149#define ANSI_DOWN 'B'
150#define ANSI_FORWARD 'C'
151#define ANSI_BACKWARD 'D'
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200152
Daniel Leung1ad2a562015-08-05 12:13:36 -0700153static int read_uart(struct device *uart, uint8_t *buf, unsigned int size)
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300154{
155 int rx;
156
157 rx = uart_fifo_read(uart, buf, size);
158 if (rx < 0) {
159 /* Overrun issue. Stop the UART */
160 uart_irq_rx_disable(uart);
161
162 return -EIO;
163 }
164
165 return rx;
166}
167
Johan Hedberga9f6f892015-12-08 22:45:12 +0200168static inline void cursor_forward(unsigned int count)
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200169{
Johan Hedberga9f6f892015-12-08 22:45:12 +0200170 printk("\x1b[%uC", count);
171}
172
173static inline void cursor_backward(unsigned int count)
174{
175 printk("\x1b[%uD", count);
176}
177
Johan Hedbergceba31a2015-12-09 12:40:29 +0200178static inline void cursor_save(void)
179{
180 printk("\x1b[s");
181}
182
183static inline void cursor_restore(void)
184{
185 printk("\x1b[u");
186}
187
Johan Hedberga9f6f892015-12-08 22:45:12 +0200188static void insert_char(char *pos, char c, uint8_t end)
189{
Johan Hedberga9f6f892015-12-08 22:45:12 +0200190 char tmp;
191
192 /* Echo back to console */
193 uart_poll_out(uart_console_dev, c);
194
195 if (end == 0) {
196 *pos = c;
197 return;
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200198 }
Johan Hedberga9f6f892015-12-08 22:45:12 +0200199
200 tmp = *pos;
201 *(pos++) = c;
202
Johan Hedbergceba31a2015-12-09 12:40:29 +0200203 cursor_save();
204
205 while (end-- > 0) {
Johan Hedberga9f6f892015-12-08 22:45:12 +0200206 uart_poll_out(uart_console_dev, tmp);
Johan Hedbergceba31a2015-12-09 12:40:29 +0200207 c = *pos;
208 *(pos++) = tmp;
Johan Hedberga9f6f892015-12-08 22:45:12 +0200209 tmp = c;
210 }
211
212 /* Move cursor back to right place */
Johan Hedbergceba31a2015-12-09 12:40:29 +0200213 cursor_restore();
Johan Hedberga9f6f892015-12-08 22:45:12 +0200214}
215
216static void del_char(char *pos, uint8_t end)
217{
Johan Hedberga9f6f892015-12-08 22:45:12 +0200218 uart_poll_out(uart_console_dev, '\b');
219
220 if (end == 0) {
221 uart_poll_out(uart_console_dev, ' ');
222 uart_poll_out(uart_console_dev, '\b');
223 return;
224 }
225
Johan Hedbergceba31a2015-12-09 12:40:29 +0200226 cursor_save();
227
228 while (end-- > 0) {
229 *pos = *(pos + 1);
230 uart_poll_out(uart_console_dev, *(pos++));
Johan Hedberga9f6f892015-12-08 22:45:12 +0200231 }
232
233 uart_poll_out(uart_console_dev, ' ');
234
235 /* Move cursor back to right place */
Johan Hedbergceba31a2015-12-09 12:40:29 +0200236 cursor_restore();
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200237}
238
Johan Hedberg8683dc42015-12-09 11:36:25 +0200239enum {
240 ESC_ESC,
241 ESC_ANSI,
242 ESC_ANSI_FIRST,
243 ESC_ANSI_VAL,
244 ESC_ANSI_VAL_2
245};
246
247static atomic_t esc_state;
248static unsigned int ansi_val, ansi_val_2;
249static uint8_t cur, end;
250
251static void handle_ansi(uint8_t byte)
252{
253 if (atomic_test_and_clear_bit(&esc_state, ESC_ANSI_FIRST)) {
254 if (!isdigit(byte)) {
255 ansi_val = 1;
256 goto ansi_cmd;
257 }
258
259 atomic_set_bit(&esc_state, ESC_ANSI_VAL);
260 ansi_val = byte - '0';
261 ansi_val_2 = 0;
262 return;
263 }
264
265 if (atomic_test_bit(&esc_state, ESC_ANSI_VAL)) {
266 if (isdigit(byte)) {
267 if (atomic_test_bit(&esc_state, ESC_ANSI_VAL_2)) {
268 ansi_val_2 *= 10;
269 ansi_val_2 += byte - '0';
270 } else {
271 ansi_val *= 10;
272 ansi_val += byte - '0';
273 }
274 return;
275 }
276
277 /* Multi value sequence, e.g. Esc[Line;ColumnH */
278 if (byte == ';' &&
279 !atomic_test_and_set_bit(&esc_state, ESC_ANSI_VAL_2)) {
280 return;
281 }
282
283 atomic_clear_bit(&esc_state, ESC_ANSI_VAL);
284 atomic_clear_bit(&esc_state, ESC_ANSI_VAL_2);
285 }
286
287ansi_cmd:
288 switch (byte) {
289 case ANSI_BACKWARD:
290 if (ansi_val > cur) {
291 break;
292 }
293
294 end += ansi_val;
295 cur -= ansi_val;
296 cursor_backward(ansi_val);
297 break;
298 case ANSI_FORWARD:
299 if (ansi_val > end) {
300 break;
301 }
302
303 end -= ansi_val;
304 cur += ansi_val;
305 cursor_forward(ansi_val);
306 break;
307 default:
308 break;
309 }
310
311 atomic_clear_bit(&esc_state, ESC_ANSI);
312}
313
Daniel Leunge643ced2016-03-03 10:14:50 -0800314void uart_console_isr(struct device *unused)
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300315{
316 ARG_UNUSED(unused);
317
Johan Hedberg5ad78032015-12-07 15:03:20 +0200318 while (uart_irq_update(uart_console_dev) &&
319 uart_irq_is_pending(uart_console_dev)) {
320 static struct uart_console_input *cmd;
321 uint8_t byte;
322 int rx;
323
324 if (!uart_irq_rx_ready(uart_console_dev)) {
325 continue;
326 }
327
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300328 /* Character(s) have been received */
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300329
Johan Hedberg5ad78032015-12-07 15:03:20 +0200330 rx = read_uart(uart_console_dev, &byte, 1);
331 if (rx < 0) {
332 return;
333 }
334
Marcus Shawcroft1bc999c2016-10-23 08:53:21 +0100335#ifdef CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS
336 if (debug_hook_in != NULL && debug_hook_in(byte) != 0) {
Johan Hedberg5ad78032015-12-07 15:03:20 +0200337 /*
338 * The input hook indicates that no further processing
339 * should be done by this handler.
340 */
341 return;
342 }
Marcus Shawcroft1bc999c2016-10-23 08:53:21 +0100343#endif
Johan Hedberg5ad78032015-12-07 15:03:20 +0200344
345 if (!cmd) {
Peter Mitsiscd6db372015-12-11 11:46:40 -0500346 cmd = nano_isr_fifo_get(avail_queue, TICKS_NONE);
Johan Hedberg5ad78032015-12-07 15:03:20 +0200347 if (!cmd)
Peter Mitsisb1c10202015-09-17 13:22:00 -0400348 return;
Johan Hedberg5ad78032015-12-07 15:03:20 +0200349 }
Peter Mitsisb1c10202015-09-17 13:22:00 -0400350
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200351 /* Handle ANSI escape mode */
Johan Hedberg8683dc42015-12-09 11:36:25 +0200352 if (atomic_test_bit(&esc_state, ESC_ANSI)) {
353 handle_ansi(byte);
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200354 continue;
355 }
356
357 /* Handle escape mode */
Johan Hedberg8683dc42015-12-09 11:36:25 +0200358 if (atomic_test_and_clear_bit(&esc_state, ESC_ESC)) {
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200359 switch (byte) {
360 case ANSI_ESC:
Johan Hedberg8683dc42015-12-09 11:36:25 +0200361 atomic_set_bit(&esc_state, ESC_ANSI);
362 atomic_set_bit(&esc_state, ESC_ANSI_FIRST);
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200363 break;
364 default:
365 break;
366 }
367
368 continue;
369 }
370
371 /* Handle special control characters */
372 if (!isprint(byte)) {
373 switch (byte) {
374 case DEL:
Johan Hedberga9f6f892015-12-08 22:45:12 +0200375 if (cur > 0) {
376 del_char(&cmd->line[--cur], end);
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200377 }
378 break;
379 case ESC:
Johan Hedberg8683dc42015-12-09 11:36:25 +0200380 atomic_set_bit(&esc_state, ESC_ESC);
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200381 break;
382 case '\r':
Johan Hedberga9f6f892015-12-08 22:45:12 +0200383 cmd->line[cur + end] = '\0';
Johan Hedberg65433182016-02-05 13:45:48 +0200384 uart_poll_out(uart_console_dev, '\r');
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200385 uart_poll_out(uart_console_dev, '\n');
Johan Hedberga9f6f892015-12-08 22:45:12 +0200386 cur = 0;
387 end = 0;
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200388 nano_isr_fifo_put(lines_queue, cmd);
389 cmd = NULL;
390 break;
Szymon Jancd7e8fd02016-05-25 16:23:42 +0200391 case '\t':
392 if (completion_cb && !end) {
393 cur += completion_cb(cmd->line, cur);
394 }
395 break;
Johan Hedbergf88cccd2015-12-08 10:35:04 +0200396 default:
397 break;
398 }
399
400 continue;
401 }
402
Johan Hedberg6147fc62015-12-08 09:26:31 +0200403 /* Ignore characters if there's no more buffer space */
Johan Hedberga9f6f892015-12-08 22:45:12 +0200404 if (cur + end < sizeof(cmd->line) - 1) {
405 insert_char(&cmd->line[cur++], byte, end);
Johan Hedberg6147fc62015-12-08 09:26:31 +0200406 }
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300407 }
408}
409
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300410static void console_input_init(void)
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300411{
412 uint8_t c;
413
Daniel Leung08b4fd42015-12-01 08:42:20 -0800414 uart_irq_rx_disable(uart_console_dev);
415 uart_irq_tx_disable(uart_console_dev);
Daniel Leunge643ced2016-03-03 10:14:50 -0800416
417 uart_irq_callback_set(uart_console_dev, uart_console_isr);
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300418
419 /* Drain the fifo */
Daniel Leung08b4fd42015-12-01 08:42:20 -0800420 while (uart_irq_rx_ready(uart_console_dev)) {
421 uart_fifo_read(uart_console_dev, &c, 1);
Daniel Leung1ad2a562015-08-05 12:13:36 -0700422 }
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300423
Daniel Leung08b4fd42015-12-01 08:42:20 -0800424 uart_irq_rx_enable(uart_console_dev);
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300425}
426
Szymon Jancd7e8fd02016-05-25 16:23:42 +0200427void uart_register_input(struct nano_fifo *avail, struct nano_fifo *lines,
428 uint8_t (*completion)(char *str, uint8_t len))
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300429{
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300430 avail_queue = avail;
431 lines_queue = lines;
Szymon Jancd7e8fd02016-05-25 16:23:42 +0200432 completion_cb = completion;
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300433
434 console_input_init();
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300435}
Szymon Jancd7e8fd02016-05-25 16:23:42 +0200436
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300437#else
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300438#define console_input_init(x) \
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300439 do {/* nothing */ \
440 } while ((0))
Andrei Emeltchenko879541a2015-05-04 14:43:36 +0300441#define uart_register_input(x) \
Andrei Emeltchenko139c8562015-04-20 11:04:22 +0300442 do {/* nothing */ \
443 } while ((0))
444#endif
445
Anas Nashifea0d0b22015-07-01 17:22:39 -0400446/**
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700447 *
Daniel Leungad2d2962015-08-12 10:17:35 -0700448 * @brief Install printk/stdout hook for UART console output
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700449 *
Anas Nashif1362e3c2015-07-01 17:29:04 -0400450 * @return N/A
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700451 */
452
Daniel Leungad2d2962015-08-12 10:17:35 -0700453void uart_console_hook_install(void)
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700454{
Daniel Leung08b4fd42015-12-01 08:42:20 -0800455 __stdout_hook_install(console_out);
456 __printk_hook_install(console_out);
Inaky Perez-Gonzalez8ddf82c2015-04-10 16:44:37 -0700457}
Daniel Leungad2d2962015-08-12 10:17:35 -0700458
459/**
460 *
461 * @brief Initialize one UART as the console/debug port
462 *
Andre Guedes024cfe72016-03-09 14:01:20 -0300463 * @return 0 if successful, otherwise failed.
Daniel Leungad2d2962015-08-12 10:17:35 -0700464 */
465static int uart_console_init(struct device *arg)
466{
467 ARG_UNUSED(arg);
468
Daniel Leung08b4fd42015-12-01 08:42:20 -0800469 uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
470
Daniel Leungad2d2962015-08-12 10:17:35 -0700471 uart_console_hook_install();
472
Andre Guedes024cfe72016-03-09 14:01:20 -0300473 return 0;
Daniel Leungad2d2962015-08-12 10:17:35 -0700474}
Dmitriy Korovkin57f27412015-10-26 15:56:02 -0400475
Chuck Jordan12e29fe2016-05-06 12:43:56 -0700476/* UART console initializes after the UART device itself */
Benjamin Walsha4ec9632016-01-28 15:16:31 -0500477SYS_INIT(uart_console_init,
Dmitriy Korovkin57f27412015-10-26 15:56:02 -0400478#if defined(CONFIG_EARLY_CONSOLE)
Benjamin Walshd340d4c2016-01-28 14:48:47 -0500479 PRIMARY,
Dmitriy Korovkin57f27412015-10-26 15:56:02 -0400480#else
Benjamin Walshd340d4c2016-01-28 14:48:47 -0500481 SECONDARY,
Dmitriy Korovkin57f27412015-10-26 15:56:02 -0400482#endif
Daniel Leung546b8ad2016-03-28 14:05:33 -0700483 CONFIG_UART_CONSOLE_INIT_PRIORITY);