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 <libchip/serial.h> |
---|
20 | #include <libchip/ns16550.h> |
---|
21 | #if BSP_ENABLE_VGA |
---|
22 | #include "vgacons.h" |
---|
23 | #endif |
---|
24 | #include <bsp/irq.h> |
---|
25 | #include <rtems/pci.h> |
---|
26 | |
---|
27 | #if BSP_ENABLE_VGA |
---|
28 | #define VGA_CONSOLE_FUNCTIONS &vgacons_fns |
---|
29 | #endif |
---|
30 | |
---|
31 | #if BSP_ENABLE_COM1_COM4 |
---|
32 | #if 0 |
---|
33 | #define COM_CONSOLE_FUNCTIONS &ns16550_fns_polled |
---|
34 | #else |
---|
35 | #define COM_CONSOLE_FUNCTIONS &ns16550_fns |
---|
36 | #endif |
---|
37 | |
---|
38 | /* |
---|
39 | * Base IO for UART |
---|
40 | */ |
---|
41 | #define COM1_BASE_IO 0x3F8 |
---|
42 | #define COM2_BASE_IO 0x3E8 |
---|
43 | #define COM3_BASE_IO 0x2F8 |
---|
44 | #define COM4_BASE_IO 0x2E8 |
---|
45 | |
---|
46 | #define CLOCK_RATE (115200 * 16) |
---|
47 | |
---|
48 | static uint8_t com_get_register(uint32_t addr, uint8_t i) |
---|
49 | { |
---|
50 | register uint8_t val; |
---|
51 | |
---|
52 | inport_byte( (addr + i),val ); |
---|
53 | return val; |
---|
54 | } |
---|
55 | |
---|
56 | static void com_set_register(uint32_t addr, uint8_t i, uint8_t val) |
---|
57 | { |
---|
58 | outport_byte( (addr + i),val ); |
---|
59 | } |
---|
60 | |
---|
61 | extern bool pc386_com1_com4_enabled(int); |
---|
62 | #endif |
---|
63 | |
---|
64 | #if (BSP_IS_EDISON == 1 ) |
---|
65 | extern const console_fns edison_fns; |
---|
66 | #endif |
---|
67 | |
---|
68 | console_tbl Console_Configuration_Ports[] = { |
---|
69 | #if (BSP_IS_EDISON == 1) |
---|
70 | { |
---|
71 | "/dev/vgacons", /* sDeviceName */ |
---|
72 | -1, /* deviceType */ |
---|
73 | &edison_fns, /* pDeviceFns */ |
---|
74 | NULL, /* deviceProbe */ |
---|
75 | NULL, /* pDeviceFlow */ |
---|
76 | 16, /* ulMargin */ |
---|
77 | 8, /* ulHysteresis */ |
---|
78 | (void *) NULL, /* NULL */ /* pDeviceParams */ |
---|
79 | 0x00000000, /* ulCtrlPort1 */ |
---|
80 | 0x00000000, /* ulCtrlPort2 */ |
---|
81 | 0x00000000, /* ulDataPort */ |
---|
82 | NULL, /* getRegister */ |
---|
83 | NULL, /* setRegister */ |
---|
84 | NULL,/* unused */ /* getData */ |
---|
85 | NULL,/* unused */ /* setData */ |
---|
86 | 0X0, /* ulClock */ |
---|
87 | 0x0 /* ulIntVector -- base for port */ |
---|
88 | }, |
---|
89 | #endif |
---|
90 | #if BSP_ENABLE_VGA |
---|
91 | { |
---|
92 | "/dev/vgacons", /* sDeviceName */ |
---|
93 | VGA_CONSOLE, /* deviceType */ |
---|
94 | VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
95 | vgacons_probe, /* deviceProbe */ |
---|
96 | NULL, /* pDeviceFlow */ |
---|
97 | 16, /* ulMargin */ |
---|
98 | 8, /* ulHysteresis */ |
---|
99 | (void *) NULL, /* NULL */ /* pDeviceParams */ |
---|
100 | 0x00000000, /* ulCtrlPort1 */ |
---|
101 | 0x00000000, /* ulCtrlPort2 */ |
---|
102 | 0x00000000, /* ulDataPort */ |
---|
103 | NULL, /* getRegister */ |
---|
104 | NULL, /* setRegister */ |
---|
105 | NULL,/* unused */ /* getData */ |
---|
106 | NULL,/* unused */ /* setData */ |
---|
107 | 0X0, /* ulClock */ |
---|
108 | 0x0 /* ulIntVector -- base for port */ |
---|
109 | }, |
---|
110 | #endif |
---|
111 | #if BSP_ENABLE_COM1_COM4 |
---|
112 | { |
---|
113 | "/dev/com1", /* sDeviceName */ |
---|
114 | SERIAL_NS16550, /* deviceType */ |
---|
115 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
116 | pc386_com1_com4_enabled, /* deviceProbe */ |
---|
117 | NULL, /* pDeviceFlow */ |
---|
118 | 16, /* ulMargin */ |
---|
119 | 8, /* ulHysteresis */ |
---|
120 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
121 | COM1_BASE_IO, /* ulCtrlPort1 */ |
---|
122 | 0x00000000, /* ulCtrlPort2 */ |
---|
123 | COM1_BASE_IO, /* ulDataPort */ |
---|
124 | com_get_register, /* getRegister */ |
---|
125 | com_set_register, /* setRegister */ |
---|
126 | NULL,/* unused */ /* getData */ |
---|
127 | NULL,/* unused */ /* setData */ |
---|
128 | CLOCK_RATE, /* ulClock */ |
---|
129 | BSP_UART_COM1_IRQ /* ulIntVector -- base for port */ |
---|
130 | }, |
---|
131 | { |
---|
132 | "/dev/com2", /* sDeviceName */ |
---|
133 | SERIAL_NS16550, /* deviceType */ |
---|
134 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
135 | pc386_com1_com4_enabled, /* deviceProbe */ |
---|
136 | NULL, /* pDeviceFlow */ |
---|
137 | 16, /* ulMargin */ |
---|
138 | 8, /* ulHysteresis */ |
---|
139 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
140 | COM2_BASE_IO, /* ulCtrlPort1 */ |
---|
141 | 0x00000000, /* ulCtrlPort2 */ |
---|
142 | COM2_BASE_IO, /* ulDataPort */ |
---|
143 | com_get_register, /* getRegister */ |
---|
144 | com_set_register, /* setRegister */ |
---|
145 | NULL,/* unused */ /* getData */ |
---|
146 | NULL,/* unused */ /* setData */ |
---|
147 | CLOCK_RATE, /* ulClock */ |
---|
148 | BSP_UART_COM2_IRQ /* ulIntVector -- base for port */ |
---|
149 | }, |
---|
150 | |
---|
151 | { |
---|
152 | "/dev/com3", /* sDeviceName */ |
---|
153 | SERIAL_NS16550, /* deviceType */ |
---|
154 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
155 | pc386_com1_com4_enabled, /* deviceProbe */ |
---|
156 | NULL, /* pDeviceFlow */ |
---|
157 | 16, /* ulMargin */ |
---|
158 | 8, /* ulHysteresis */ |
---|
159 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
160 | COM3_BASE_IO, /* ulCtrlPort1 */ |
---|
161 | 0x00000000, /* ulCtrlPort2 */ |
---|
162 | COM3_BASE_IO, /* ulDataPort */ |
---|
163 | com_get_register, /* getRegister */ |
---|
164 | com_set_register, /* setRegister */ |
---|
165 | NULL,/* unused */ /* getData */ |
---|
166 | NULL,/* unused */ /* setData */ |
---|
167 | CLOCK_RATE, /* ulClock */ |
---|
168 | BSP_UART_COM3_IRQ /* ulIntVector -- base for port */ |
---|
169 | }, |
---|
170 | |
---|
171 | { |
---|
172 | "/dev/com4", /* sDeviceName */ |
---|
173 | SERIAL_NS16550, /* deviceType */ |
---|
174 | COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ |
---|
175 | pc386_com1_com4_enabled, /* deviceProbe */ |
---|
176 | NULL, /* pDeviceFlow */ |
---|
177 | 16, /* ulMargin */ |
---|
178 | 8, /* ulHysteresis */ |
---|
179 | (void *) 9600, /* Baud Rate */ /* pDeviceParams */ |
---|
180 | COM4_BASE_IO, /* ulCtrlPort1 */ |
---|
181 | 0x00000000, /* ulCtrlPort2 */ |
---|
182 | COM4_BASE_IO, /* ulDataPort */ |
---|
183 | com_get_register, /* getRegister */ |
---|
184 | com_set_register, /* setRegister */ |
---|
185 | NULL,/* unused */ /* getData */ |
---|
186 | NULL,/* unused */ /* setData */ |
---|
187 | CLOCK_RATE, /* ulClock */ |
---|
188 | BSP_UART_COM4_IRQ /* ulIntVector -- base for port */ |
---|
189 | }, |
---|
190 | #endif |
---|
191 | |
---|
192 | }; |
---|
193 | |
---|
194 | /* |
---|
195 | * Define a variable that contains the number of statically configured |
---|
196 | * console devices. |
---|
197 | */ |
---|
198 | unsigned long Console_Configuration_Count = \ |
---|
199 | (sizeof(Console_Configuration_Ports)/sizeof(console_tbl)); |
---|