summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/xilinx-zynq/console/debug-console.c
blob: 38c0050e90f8f0c5b3cdb80af8643bb2aa7978ba (plain) (blame)
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
60
61
62
63
64
/*
 * Copyright (c) 2013, 2017 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Dornierstr. 4
 *  82178 Puchheim
 *  Germany
 *  <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#include <rtems/bspIo.h>
#include <rtems/sysinit.h>

#include <bsp/zynq-uart.h>

#include <bspopts.h>

static void zynq_debug_console_out(char c)
{
  rtems_termios_device_context *base =
    &zynq_uart_instances[BSP_CONSOLE_MINOR].base;

  zynq_uart_write_polled(base, c);
}

static void zynq_debug_console_init(void)
{
  rtems_termios_device_context *base =
    &zynq_uart_instances[BSP_CONSOLE_MINOR].base;

  zynq_uart_initialize(base);
  BSP_output_char = zynq_debug_console_out;
}

static void zynq_debug_console_early_init(char c)
{
  rtems_termios_device_context *base =
    &zynq_uart_instances[BSP_CONSOLE_MINOR].base;

  zynq_uart_initialize(base);
  zynq_debug_console_out(c);
}

static int zynq_debug_console_in(void)
{
  rtems_termios_device_context *base =
    &zynq_uart_instances[BSP_CONSOLE_MINOR].base;

  return zynq_uart_read_polled(base);
}

BSP_output_char_function_type BSP_output_char = zynq_debug_console_early_init;

BSP_polling_getchar_function_type BSP_poll_char = zynq_debug_console_in;

RTEMS_SYSINIT_ITEM(
  zynq_debug_console_init,
  RTEMS_SYSINIT_BSP_START,
  RTEMS_SYSINIT_ORDER_LAST
);