1 | /* |
---|
2 | * Copyright (c) 2013 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <info@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.org/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <libchip/serial.h> |
---|
16 | |
---|
17 | #include <bsp.h> |
---|
18 | #include <bsp/irq.h> |
---|
19 | #include <bsp/zynq-uart.h> |
---|
20 | |
---|
21 | console_tbl Console_Configuration_Ports[] = { |
---|
22 | { |
---|
23 | .sDeviceName = "/dev/ttyS0", |
---|
24 | .deviceType = SERIAL_CUSTOM, |
---|
25 | .pDeviceFns = &zynq_uart_fns, |
---|
26 | .deviceProbe = NULL, |
---|
27 | .pDeviceFlow = NULL, |
---|
28 | .ulMargin = 0, |
---|
29 | .ulHysteresis = 0, |
---|
30 | .pDeviceParams = (void *) 115200, |
---|
31 | .ulCtrlPort1 = 0xe0000000, |
---|
32 | .ulCtrlPort2 = 0, |
---|
33 | .ulDataPort = 0, |
---|
34 | .getRegister = NULL, |
---|
35 | .setRegister = NULL, |
---|
36 | .getData = NULL, |
---|
37 | .setData = NULL, |
---|
38 | .ulClock = 0, |
---|
39 | .ulIntVector = ZYNQ_IRQ_UART_0 |
---|
40 | }, { |
---|
41 | .sDeviceName = "/dev/ttyS1", |
---|
42 | .deviceType = SERIAL_CUSTOM, |
---|
43 | .pDeviceFns = &zynq_uart_fns, |
---|
44 | .deviceProbe = NULL, |
---|
45 | .pDeviceFlow = NULL, |
---|
46 | .ulMargin = 0, |
---|
47 | .ulHysteresis = 0, |
---|
48 | .pDeviceParams = (void *) 115200, |
---|
49 | .ulCtrlPort1 = 0xe0001000, |
---|
50 | .ulCtrlPort2 = 0, |
---|
51 | .ulDataPort = 0, |
---|
52 | .getRegister = NULL, |
---|
53 | .setRegister = NULL, |
---|
54 | .getData = NULL, |
---|
55 | .setData = NULL, |
---|
56 | .ulClock = 0, |
---|
57 | .ulIntVector = ZYNQ_IRQ_UART_1 |
---|
58 | } |
---|
59 | }; |
---|
60 | |
---|
61 | unsigned long Console_Configuration_Count = |
---|
62 | RTEMS_ARRAY_SIZE(Console_Configuration_Ports); |
---|
63 | |
---|
64 | static void output_char(char c) |
---|
65 | { |
---|
66 | int minor = (int) Console_Port_Minor; |
---|
67 | const console_tbl *ct = Console_Port_Tbl != NULL ? |
---|
68 | Console_Port_Tbl[minor] : &Console_Configuration_Ports[minor]; |
---|
69 | const console_fns *cf = ct->pDeviceFns; |
---|
70 | |
---|
71 | if (c == '\n') { |
---|
72 | (*cf->deviceWritePolled)(minor, '\r'); |
---|
73 | } |
---|
74 | |
---|
75 | (*cf->deviceWritePolled)(minor, c); |
---|
76 | } |
---|
77 | |
---|
78 | static void output_char_init(char c) |
---|
79 | { |
---|
80 | if (Console_Port_Tbl == NULL) { |
---|
81 | int minor; |
---|
82 | const console_fns *cf; |
---|
83 | |
---|
84 | bsp_console_select(); |
---|
85 | |
---|
86 | minor = (int) Console_Port_Minor; |
---|
87 | cf = Console_Configuration_Ports[minor].pDeviceFns; |
---|
88 | |
---|
89 | (*cf->deviceInitialize)(minor); |
---|
90 | } |
---|
91 | |
---|
92 | BSP_output_char = output_char; |
---|
93 | output_char(c); |
---|
94 | } |
---|
95 | |
---|
96 | BSP_output_char_function_type BSP_output_char = output_char_init; |
---|
97 | |
---|
98 | BSP_polling_getchar_function_type BSP_poll_char = NULL; |
---|