![]() |
|
|||
File indexing completed on 2025-05-11 08:23:40
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * This file contains the libchip configuration information 0007 * to instantiate the libchip driver for the VGA console 0008 * and serial ports on a PC. 0009 */ 0010 0011 /* 0012 * COPYRIGHT (c) 1989-2014, 2016. 0013 * On-Line Applications Research Corporation (OAR). 0014 * 0015 * Redistribution and use in source and binary forms, with or without 0016 * modification, are permitted provided that the following conditions 0017 * are met: 0018 * 1. Redistributions of source code must retain the above copyright 0019 * notice, this list of conditions and the following disclaimer. 0020 * 2. Redistributions in binary form must reproduce the above copyright 0021 * notice, this list of conditions and the following disclaimer in the 0022 * documentation and/or other materials provided with the distribution. 0023 * 0024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0027 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0028 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0029 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0030 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0031 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0032 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0033 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0034 * POSSIBILITY OF SUCH DAMAGE. 0035 */ 0036 0037 #include <bsp.h> 0038 #include <bsp/bspimpl.h> 0039 #include <libchip/serial.h> 0040 #include <libchip/ns16550.h> 0041 #if BSP_ENABLE_VGA 0042 #include <rtems/vgacons.h> 0043 #endif 0044 #include <bsp/irq.h> 0045 #include "../../shared/dev/serial/legacy-console.h" 0046 0047 #if BSP_ENABLE_VGA 0048 #define VGA_CONSOLE_FUNCTIONS &vgacons_fns 0049 #endif 0050 0051 #if BSP_ENABLE_COM1_COM4 0052 #if 0 0053 #define COM_CONSOLE_FUNCTIONS &ns16550_fns_polled 0054 #else 0055 #define COM_CONSOLE_FUNCTIONS &ns16550_fns 0056 #endif 0057 0058 /* 0059 * Base IO for UART 0060 */ 0061 #define COM1_BASE_IO 0x3F8 0062 #define COM2_BASE_IO 0x3E8 0063 #define COM3_BASE_IO 0x2F8 0064 #define COM4_BASE_IO 0x2E8 0065 0066 #define CLOCK_RATE (115200 * 16) 0067 0068 static uint8_t com_get_register(uintptr_t addr, uint8_t i) 0069 { 0070 uint8_t val; 0071 inport_byte( (addr + i), val ); 0072 return val; 0073 } 0074 0075 static void com_set_register(uintptr_t addr, uint8_t i, uint8_t val) 0076 { 0077 outport_byte( (addr + i), val ); 0078 } 0079 #endif 0080 0081 /* 0082 * Default to the PC VGA console if present and configured. 0083 */ 0084 console_tbl Console_Configuration_Ports[] = { 0085 #if BSP_ENABLE_VGA 0086 /* 0087 * If present the VGA console must always be minor 0. 0088 * See console_control. 0089 */ 0090 { 0091 "/dev/vgacons", /* sDeviceName */ 0092 VGA_CONSOLE, /* deviceType */ 0093 VGA_CONSOLE_FUNCTIONS, /* pDeviceFns */ 0094 vgacons_probe, /* deviceProbe */ 0095 NULL, /* pDeviceFlow */ 0096 16, /* ulMargin */ 0097 8, /* ulHysteresis */ 0098 (void *) NULL, /* NULL */ /* pDeviceParams */ 0099 0x00000000, /* ulCtrlPort1 */ 0100 0x00000000, /* ulCtrlPort2 */ 0101 0x00000000, /* ulDataPort */ 0102 NULL, /* getRegister */ 0103 NULL, /* setRegister */ 0104 NULL,/* unused */ /* getData */ 0105 NULL,/* unused */ /* setData */ 0106 0x0, /* ulClock */ 0107 0x0 /* ulIntVector -- base for port */ 0108 }, 0109 #endif 0110 }; 0111 0112 unsigned long Console_Configuration_Count = 0113 (sizeof(Console_Configuration_Ports)/sizeof(console_tbl)); 0114 0115 static console_tbl Legacy_Ports[] = { 0116 #if BSP_ENABLE_COM1_COM4 0117 { 0118 "/dev/com1", /* sDeviceName */ 0119 SERIAL_NS16550, /* deviceType */ 0120 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ 0121 NULL, /* deviceProbe */ 0122 NULL, /* pDeviceFlow */ 0123 16, /* ulMargin */ 0124 8, /* ulHysteresis */ 0125 (void *) 9600, /* Baud Rate */ /* pDeviceParams */ 0126 COM1_BASE_IO, /* ulCtrlPort1 */ 0127 0x00000000, /* ulCtrlPort2 */ 0128 COM1_BASE_IO, /* ulDataPort */ 0129 com_get_register, /* getRegister */ 0130 com_set_register, /* setRegister */ 0131 NULL,/* unused */ /* getData */ 0132 NULL,/* unused */ /* setData */ 0133 CLOCK_RATE, /* ulClock */ 0134 BSP_UART_COM1_IRQ /* ulIntVector -- base for port */ 0135 }, 0136 { 0137 "/dev/com2", /* sDeviceName */ 0138 SERIAL_NS16550, /* deviceType */ 0139 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ 0140 NULL, /* deviceProbe */ 0141 NULL, /* pDeviceFlow */ 0142 16, /* ulMargin */ 0143 8, /* ulHysteresis */ 0144 (void *) 9600, /* Baud Rate */ /* pDeviceParams */ 0145 COM2_BASE_IO, /* ulCtrlPort1 */ 0146 0x00000000, /* ulCtrlPort2 */ 0147 COM2_BASE_IO, /* ulDataPort */ 0148 com_get_register, /* getRegister */ 0149 com_set_register, /* setRegister */ 0150 NULL,/* unused */ /* getData */ 0151 NULL,/* unused */ /* setData */ 0152 CLOCK_RATE, /* ulClock */ 0153 BSP_UART_COM2_IRQ /* ulIntVector -- base for port */ 0154 }, 0155 { 0156 "/dev/com3", /* sDeviceName */ 0157 SERIAL_NS16550, /* deviceType */ 0158 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ 0159 NULL, /* deviceProbe */ 0160 NULL, /* pDeviceFlow */ 0161 16, /* ulMargin */ 0162 8, /* ulHysteresis */ 0163 (void *) 9600, /* Baud Rate */ /* pDeviceParams */ 0164 COM3_BASE_IO, /* ulCtrlPort1 */ 0165 0x00000000, /* ulCtrlPort2 */ 0166 COM3_BASE_IO, /* ulDataPort */ 0167 com_get_register, /* getRegister */ 0168 com_set_register, /* setRegister */ 0169 NULL,/* unused */ /* getData */ 0170 NULL,/* unused */ /* setData */ 0171 CLOCK_RATE, /* ulClock */ 0172 BSP_UART_COM3_IRQ /* ulIntVector -- base for port */ 0173 }, 0174 { 0175 "/dev/com4", /* sDeviceName */ 0176 SERIAL_NS16550, /* deviceType */ 0177 COM_CONSOLE_FUNCTIONS, /* pDeviceFns */ 0178 NULL, /* deviceProbe */ 0179 NULL, /* pDeviceFlow */ 0180 16, /* ulMargin */ 0181 8, /* ulHysteresis */ 0182 (void *) 9600, /* Baud Rate */ /* pDeviceParams */ 0183 COM4_BASE_IO, /* ulCtrlPort1 */ 0184 0x00000000, /* ulCtrlPort2 */ 0185 COM4_BASE_IO, /* ulDataPort */ 0186 com_get_register, /* getRegister */ 0187 com_set_register, /* setRegister */ 0188 NULL,/* unused */ /* getData */ 0189 NULL,/* unused */ /* setData */ 0190 CLOCK_RATE, /* ulClock */ 0191 BSP_UART_COM4_IRQ /* ulIntVector -- base for port */ 0192 }, 0193 #endif 0194 }; 0195 0196 #define Legacy_Port_Count \ 0197 (sizeof(Legacy_Ports)/sizeof(console_tbl)) 0198 0199 void legacy_uart_probe(void) 0200 { 0201 #if BSP_ENABLE_COM1_COM4 0202 const char *opt; 0203 /* 0204 * Check the command line to see if com1-com4 are disabled. 0205 */ 0206 opt = bsp_cmdline_arg("--disable-com1-com4"); 0207 if ( opt ) { 0208 printk( "COM1-COM4: disabled\n" ); 0209 } else { 0210 if (Legacy_Port_Count) { 0211 printk("Legacy UART Ports: COM1-COM4\n"); 0212 console_register_devices( Legacy_Ports, Legacy_Port_Count ); 0213 } 0214 } 0215 #endif 0216 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |