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 "../../../../../../../bsps/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(uint32_t addr, uint8_t i) |
---|
50 | { |
---|
51 | register uint8_t val; |
---|
52 | |
---|
53 | inport_byte( (addr + i), val ); |
---|
54 | return val; |
---|
55 | } |
---|
56 | |
---|
57 | static void com_set_register(uint32_t addr, uint8_t i, uint8_t val) |
---|
58 | { |
---|
59 | outport_byte( (addr + i), val ); |
---|
60 | } |
---|
61 | #endif |
---|
62 | |
---|
63 | /* |
---|
64 | * Default to the PC VGA console if present and configured. |
---|
65 | */ |
---|
66 | console_tbl Console_Configuration_Ports[] = { |
---|
67 | #if BSP_ENABLE_VGA |
---|
68 | /* |
---|
69 | * If present the VGA console must always be minor 0. |
---|
70 | * See console_control. |
---|
71 | */ |
---|
72 | { |
---|
73 | "/dev/vgacons", /* sDeviceName */ |
---|
74 | VGA_CONSOLE, /* deviceType */ |
---|
75 | VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
76 | vgacons_probe, /* deviceProbe */ |
---|
77 | NULL, /* pDeviceFlow */ |
---|
78 | 16, /* ulMargin */ |
---|
79 | 8, /* ulHysteresis */ |
---|
80 | (void *) NULL, /* NULL */ /* pDeviceParams */ |
---|
81 | 0x00000000, /* ulCtrlPort1 */ |
---|
82 | 0x00000000, /* ulCtrlPort2 */ |
---|
83 | 0x00000000, /* ulDataPort */ |
---|
84 | NULL, /* getRegister */ |
---|
85 | NULL, /* setRegister */ |
---|
86 | NULL,/* unused */ /* getData */ |
---|
87 | NULL,/* unused */ /* setData */ |
---|
88 | 0x0, /* ulClock */ |
---|
89 | 0x0 /* ulIntVector -- base for port */ |
---|
90 | }, |
---|
91 | #endif |
---|
92 | }; |
---|
93 | |
---|
94 | unsigned long Console_Configuration_Count = |
---|
95 | (sizeof(Console_Configuration_Ports)/sizeof(console_tbl)); |
---|
96 | |
---|
97 | static console_tbl Legacy_Ports[] = { |
---|
98 | #if BSP_ENABLE_COM1_COM4 |
---|
99 | { |
---|
100 | "/dev/com1", /* sDeviceName */ |
---|
101 | SERIAL_NS16550, /* deviceType */ |
---|
102 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
103 | NULL, /* deviceProbe */ |
---|
104 | NULL, /* pDeviceFlow */ |
---|
105 | 16, /* ulMargin */ |
---|
106 | 8, /* ulHysteresis */ |
---|
107 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
108 | COM1_BASE_IO, /* ulCtrlPort1 */ |
---|
109 | 0x00000000, /* ulCtrlPort2 */ |
---|
110 | COM1_BASE_IO, /* ulDataPort */ |
---|
111 | com_get_register, /* getRegister */ |
---|
112 | com_set_register, /* setRegister */ |
---|
113 | NULL,/* unused */ /* getData */ |
---|
114 | NULL,/* unused */ /* setData */ |
---|
115 | CLOCK_RATE, /* ulClock */ |
---|
116 | BSP_UART_COM1_IRQ /* ulIntVector -- base for port */ |
---|
117 | }, |
---|
118 | { |
---|
119 | "/dev/com2", /* sDeviceName */ |
---|
120 | SERIAL_NS16550, /* deviceType */ |
---|
121 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
122 | NULL, /* deviceProbe */ |
---|
123 | NULL, /* pDeviceFlow */ |
---|
124 | 16, /* ulMargin */ |
---|
125 | 8, /* ulHysteresis */ |
---|
126 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
127 | COM2_BASE_IO, /* ulCtrlPort1 */ |
---|
128 | 0x00000000, /* ulCtrlPort2 */ |
---|
129 | COM2_BASE_IO, /* ulDataPort */ |
---|
130 | com_get_register, /* getRegister */ |
---|
131 | com_set_register, /* setRegister */ |
---|
132 | NULL,/* unused */ /* getData */ |
---|
133 | NULL,/* unused */ /* setData */ |
---|
134 | CLOCK_RATE, /* ulClock */ |
---|
135 | BSP_UART_COM2_IRQ /* ulIntVector -- base for port */ |
---|
136 | }, |
---|
137 | { |
---|
138 | "/dev/com3", /* sDeviceName */ |
---|
139 | SERIAL_NS16550, /* deviceType */ |
---|
140 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
141 | NULL, /* deviceProbe */ |
---|
142 | NULL, /* pDeviceFlow */ |
---|
143 | 16, /* ulMargin */ |
---|
144 | 8, /* ulHysteresis */ |
---|
145 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
146 | COM3_BASE_IO, /* ulCtrlPort1 */ |
---|
147 | 0x00000000, /* ulCtrlPort2 */ |
---|
148 | COM3_BASE_IO, /* ulDataPort */ |
---|
149 | com_get_register, /* getRegister */ |
---|
150 | com_set_register, /* setRegister */ |
---|
151 | NULL,/* unused */ /* getData */ |
---|
152 | NULL,/* unused */ /* setData */ |
---|
153 | CLOCK_RATE, /* ulClock */ |
---|
154 | BSP_UART_COM3_IRQ /* ulIntVector -- base for port */ |
---|
155 | }, |
---|
156 | { |
---|
157 | "/dev/com4", /* sDeviceName */ |
---|
158 | SERIAL_NS16550, /* deviceType */ |
---|
159 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
160 | NULL, /* deviceProbe */ |
---|
161 | NULL, /* pDeviceFlow */ |
---|
162 | 16, /* ulMargin */ |
---|
163 | 8, /* ulHysteresis */ |
---|
164 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
165 | COM4_BASE_IO, /* ulCtrlPort1 */ |
---|
166 | 0x00000000, /* ulCtrlPort2 */ |
---|
167 | COM4_BASE_IO, /* ulDataPort */ |
---|
168 | com_get_register, /* getRegister */ |
---|
169 | com_set_register, /* setRegister */ |
---|
170 | NULL,/* unused */ /* getData */ |
---|
171 | NULL,/* unused */ /* setData */ |
---|
172 | CLOCK_RATE, /* ulClock */ |
---|
173 | BSP_UART_COM4_IRQ /* ulIntVector -- base for port */ |
---|
174 | }, |
---|
175 | #endif |
---|
176 | }; |
---|
177 | |
---|
178 | #define Legacy_Port_Count \ |
---|
179 | (sizeof(Legacy_Ports)/sizeof(console_tbl)) |
---|
180 | |
---|
181 | void legacy_uart_probe(void) |
---|
182 | { |
---|
183 | #if BSP_ENABLE_COM1_COM4 |
---|
184 | const char *opt; |
---|
185 | /* |
---|
186 | * Check the command line to see if com1-com4 are disabled. |
---|
187 | */ |
---|
188 | opt = bsp_cmdline_arg("--disable-com1-com4"); |
---|
189 | if ( opt ) { |
---|
190 | printk( "COM1-COM4: disabled\n" ); |
---|
191 | } else { |
---|
192 | if (Legacy_Port_Count) { |
---|
193 | printk("Legacy UART Ports: COM1-COM4\n"); |
---|
194 | console_register_devices( Legacy_Ports, Legacy_Port_Count ); |
---|
195 | } |
---|
196 | } |
---|
197 | #endif |
---|
198 | } |
---|