1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * This file contains the libchip configuration information |
---|
5 | * to instantiate the libchip driver for the VGA console |
---|
6 | * and serial ports on a PC. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2014, 2016. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #include <bsp.h> |
---|
19 | #include <bsp/bspimpl.h> |
---|
20 | #include <libchip/serial.h> |
---|
21 | #include <libchip/ns16550.h> |
---|
22 | #if BSP_ENABLE_VGA |
---|
23 | #include <rtems/vgacons.h> |
---|
24 | #endif |
---|
25 | #include <bsp/irq.h> |
---|
26 | #include "../../shared/dev/serial/legacy-console.h" |
---|
27 | |
---|
28 | #if BSP_ENABLE_VGA |
---|
29 | #define VGA_CONSOLE_FUNCTIONS &vgacons_fns |
---|
30 | #endif |
---|
31 | |
---|
32 | #if BSP_ENABLE_COM1_COM4 |
---|
33 | #if 0 |
---|
34 | #define COM_CONSOLE_FUNCTIONS &ns16550_fns_polled |
---|
35 | #else |
---|
36 | #define COM_CONSOLE_FUNCTIONS &ns16550_fns |
---|
37 | #endif |
---|
38 | |
---|
39 | /* |
---|
40 | * Base IO for UART |
---|
41 | */ |
---|
42 | #define COM1_BASE_IO 0x3F8 |
---|
43 | #define COM2_BASE_IO 0x3E8 |
---|
44 | #define COM3_BASE_IO 0x2F8 |
---|
45 | #define COM4_BASE_IO 0x2E8 |
---|
46 | |
---|
47 | #define CLOCK_RATE (115200 * 16) |
---|
48 | |
---|
49 | static uint8_t com_get_register(uintptr_t addr, uint8_t i) |
---|
50 | { |
---|
51 | uint8_t val; |
---|
52 | inport_byte( (addr + i), val ); |
---|
53 | return val; |
---|
54 | } |
---|
55 | |
---|
56 | static void com_set_register(uintptr_t addr, uint8_t i, uint8_t val) |
---|
57 | { |
---|
58 | outport_byte( (addr + i), val ); |
---|
59 | } |
---|
60 | #endif |
---|
61 | |
---|
62 | /* |
---|
63 | * Default to the PC VGA console if present and configured. |
---|
64 | */ |
---|
65 | console_tbl Console_Configuration_Ports[] = { |
---|
66 | #if BSP_ENABLE_VGA |
---|
67 | /* |
---|
68 | * If present the VGA console must always be minor 0. |
---|
69 | * See console_control. |
---|
70 | */ |
---|
71 | { |
---|
72 | "/dev/vgacons", /* sDeviceName */ |
---|
73 | VGA_CONSOLE, /* deviceType */ |
---|
74 | VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
75 | vgacons_probe, /* deviceProbe */ |
---|
76 | NULL, /* pDeviceFlow */ |
---|
77 | 16, /* ulMargin */ |
---|
78 | 8, /* ulHysteresis */ |
---|
79 | (void *) NULL, /* NULL */ /* pDeviceParams */ |
---|
80 | 0x00000000, /* ulCtrlPort1 */ |
---|
81 | 0x00000000, /* ulCtrlPort2 */ |
---|
82 | 0x00000000, /* ulDataPort */ |
---|
83 | NULL, /* getRegister */ |
---|
84 | NULL, /* setRegister */ |
---|
85 | NULL,/* unused */ /* getData */ |
---|
86 | NULL,/* unused */ /* setData */ |
---|
87 | 0x0, /* ulClock */ |
---|
88 | 0x0 /* ulIntVector -- base for port */ |
---|
89 | }, |
---|
90 | #endif |
---|
91 | }; |
---|
92 | |
---|
93 | unsigned long Console_Configuration_Count = |
---|
94 | (sizeof(Console_Configuration_Ports)/sizeof(console_tbl)); |
---|
95 | |
---|
96 | static console_tbl Legacy_Ports[] = { |
---|
97 | #if BSP_ENABLE_COM1_COM4 |
---|
98 | { |
---|
99 | "/dev/com1", /* sDeviceName */ |
---|
100 | SERIAL_NS16550, /* deviceType */ |
---|
101 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
102 | NULL, /* deviceProbe */ |
---|
103 | NULL, /* pDeviceFlow */ |
---|
104 | 16, /* ulMargin */ |
---|
105 | 8, /* ulHysteresis */ |
---|
106 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
107 | COM1_BASE_IO, /* ulCtrlPort1 */ |
---|
108 | 0x00000000, /* ulCtrlPort2 */ |
---|
109 | COM1_BASE_IO, /* ulDataPort */ |
---|
110 | com_get_register, /* getRegister */ |
---|
111 | com_set_register, /* setRegister */ |
---|
112 | NULL,/* unused */ /* getData */ |
---|
113 | NULL,/* unused */ /* setData */ |
---|
114 | CLOCK_RATE, /* ulClock */ |
---|
115 | BSP_UART_COM1_IRQ /* ulIntVector -- base for port */ |
---|
116 | }, |
---|
117 | { |
---|
118 | "/dev/com2", /* sDeviceName */ |
---|
119 | SERIAL_NS16550, /* deviceType */ |
---|
120 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
121 | NULL, /* deviceProbe */ |
---|
122 | NULL, /* pDeviceFlow */ |
---|
123 | 16, /* ulMargin */ |
---|
124 | 8, /* ulHysteresis */ |
---|
125 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
126 | COM2_BASE_IO, /* ulCtrlPort1 */ |
---|
127 | 0x00000000, /* ulCtrlPort2 */ |
---|
128 | COM2_BASE_IO, /* ulDataPort */ |
---|
129 | com_get_register, /* getRegister */ |
---|
130 | com_set_register, /* setRegister */ |
---|
131 | NULL,/* unused */ /* getData */ |
---|
132 | NULL,/* unused */ /* setData */ |
---|
133 | CLOCK_RATE, /* ulClock */ |
---|
134 | BSP_UART_COM2_IRQ /* ulIntVector -- base for port */ |
---|
135 | }, |
---|
136 | { |
---|
137 | "/dev/com3", /* sDeviceName */ |
---|
138 | SERIAL_NS16550, /* deviceType */ |
---|
139 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
140 | NULL, /* deviceProbe */ |
---|
141 | NULL, /* pDeviceFlow */ |
---|
142 | 16, /* ulMargin */ |
---|
143 | 8, /* ulHysteresis */ |
---|
144 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
145 | COM3_BASE_IO, /* ulCtrlPort1 */ |
---|
146 | 0x00000000, /* ulCtrlPort2 */ |
---|
147 | COM3_BASE_IO, /* ulDataPort */ |
---|
148 | com_get_register, /* getRegister */ |
---|
149 | com_set_register, /* setRegister */ |
---|
150 | NULL,/* unused */ /* getData */ |
---|
151 | NULL,/* unused */ /* setData */ |
---|
152 | CLOCK_RATE, /* ulClock */ |
---|
153 | BSP_UART_COM3_IRQ /* ulIntVector -- base for port */ |
---|
154 | }, |
---|
155 | { |
---|
156 | "/dev/com4", /* sDeviceName */ |
---|
157 | SERIAL_NS16550, /* deviceType */ |
---|
158 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
159 | NULL, /* deviceProbe */ |
---|
160 | NULL, /* pDeviceFlow */ |
---|
161 | 16, /* ulMargin */ |
---|
162 | 8, /* ulHysteresis */ |
---|
163 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
164 | COM4_BASE_IO, /* ulCtrlPort1 */ |
---|
165 | 0x00000000, /* ulCtrlPort2 */ |
---|
166 | COM4_BASE_IO, /* ulDataPort */ |
---|
167 | com_get_register, /* getRegister */ |
---|
168 | com_set_register, /* setRegister */ |
---|
169 | NULL,/* unused */ /* getData */ |
---|
170 | NULL,/* unused */ /* setData */ |
---|
171 | CLOCK_RATE, /* ulClock */ |
---|
172 | BSP_UART_COM4_IRQ /* ulIntVector -- base for port */ |
---|
173 | }, |
---|
174 | #endif |
---|
175 | }; |
---|
176 | |
---|
177 | #define Legacy_Port_Count \ |
---|
178 | (sizeof(Legacy_Ports)/sizeof(console_tbl)) |
---|
179 | |
---|
180 | void legacy_uart_probe(void) |
---|
181 | { |
---|
182 | #if BSP_ENABLE_COM1_COM4 |
---|
183 | const char *opt; |
---|
184 | /* |
---|
185 | * Check the command line to see if com1-com4 are disabled. |
---|
186 | */ |
---|
187 | opt = bsp_cmdline_arg("--disable-com1-com4"); |
---|
188 | if ( opt ) { |
---|
189 | printk( "COM1-COM4: disabled\n" ); |
---|
190 | } else { |
---|
191 | if (Legacy_Port_Count) { |
---|
192 | printk("Legacy UART Ports: COM1-COM4\n"); |
---|
193 | console_register_devices( Legacy_Ports, Legacy_Port_Count ); |
---|
194 | } |
---|
195 | } |
---|
196 | #endif |
---|
197 | } |
---|