![]() |
|
|||
File indexing completed on 2025-05-11 08:23:41
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * This file contains the termios TTY driver for the i386 0005 * vga. 0006 * 0007 * COPYRIGHT (c) 1989-2011. 0008 * On-Line Applications Research Corporation (OAR). 0009 * 0010 * Redistribution and use in source and binary forms, with or without 0011 * modification, are permitted provided that the following conditions 0012 * are met: 0013 * 1. Redistributions of source code must retain the above copyright 0014 * notice, this list of conditions and the following disclaimer. 0015 * 2. Redistributions in binary form must reproduce the above copyright 0016 * notice, this list of conditions and the following disclaimer in the 0017 * documentation and/or other materials provided with the distribution. 0018 * 0019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0029 * POSSIBILITY OF SUCH DAMAGE. 0030 */ 0031 0032 #include <rtems.h> 0033 #include <rtems/libio.h> 0034 #include <stdlib.h> 0035 #include <libchip/serial.h> 0036 #include <rtems/vgacons.h> 0037 #include <rtems/keyboard.h> 0038 #include <libchip/sersupp.h> 0039 #include <bsp/irq.h> 0040 #include <bsp.h> 0041 #include <crt.h> 0042 #include <assert.h> 0043 #include <rtems/keyboard.h> 0044 0045 #define VGACONS_STATIC static 0046 0047 /* 0048 * vgacons_init 0049 * 0050 * This function initializes the VGA console to a quiecsent state. 0051 */ 0052 VGACONS_STATIC void vgacons_init(int minor) 0053 { 0054 /* 0055 * Note: We do not initialize the KBD interface here since 0056 * it was initialized regardless of whether the 0057 * vga is available or not. Therefore it is initialized 0058 * in bsp_start. 0059 */ 0060 } 0061 0062 /* 0063 * vgacons_open 0064 * 0065 * This function opens a port for communication. 0066 * 0067 * Default state is 9600 baud, 8 bits, No parity, and 1 stop bit. 0068 */ 0069 VGACONS_STATIC int vgacons_open( 0070 int major, 0071 int minor, 0072 void *arg 0073 ) 0074 { 0075 return RTEMS_SUCCESSFUL; 0076 } 0077 0078 /* 0079 * vgacons_close 0080 * 0081 * This function shuts down the requested port. 0082 */ 0083 VGACONS_STATIC int vgacons_close( 0084 int major, 0085 int minor, 0086 void *arg 0087 ) 0088 { 0089 return(RTEMS_SUCCESSFUL); 0090 } 0091 0092 /* 0093 * vgacons_write_polled 0094 * 0095 * This routine polls out the requested character. 0096 */ 0097 VGACONS_STATIC void vgacons_write_polled( 0098 int minor, 0099 char c 0100 ) 0101 { 0102 _IBMPC_outch( c ); 0103 if( c == '\n') 0104 _IBMPC_outch( '\r' ); /* LF = LF + CR */ 0105 } 0106 0107 /* 0108 * vgacons_write_support_polled 0109 * 0110 * Console Termios output entry point when using polled output. 0111 * 0112 */ 0113 VGACONS_STATIC ssize_t vgacons_write_support_polled( 0114 int minor, 0115 const char *buf, 0116 size_t len 0117 ) 0118 { 0119 int nwrite = 0; 0120 0121 /* 0122 * poll each byte in the string out of the port. 0123 */ 0124 while (nwrite < len) { 0125 vgacons_write_polled(minor, *buf++); 0126 nwrite++; 0127 } 0128 0129 /* 0130 * return the number of bytes written. 0131 */ 0132 return nwrite; 0133 } 0134 0135 /* 0136 * vgacons_inbyte_nonblocking_polled 0137 * 0138 * Console Termios polling input entry point. 0139 */ 0140 VGACONS_STATIC int vgacons_inbyte_nonblocking_polled( 0141 int minor 0142 ) 0143 { 0144 if( rtems_kbpoll() ) { 0145 int c = getch(); 0146 return c; 0147 } 0148 0149 return -1; 0150 } 0151 0152 /* 0153 * vgacons_set_attributes 0154 * 0155 * This function sets the UART channel to reflect the requested termios 0156 * port settings. 0157 */ 0158 VGACONS_STATIC int vgacons_set_attributes( 0159 int minor, 0160 const struct termios *t 0161 ) 0162 { 0163 return 0; 0164 } 0165 0166 bool vgacons_probe( 0167 int minor 0168 ) 0169 { 0170 rtems_status_code status; 0171 static bool firstTime = true; 0172 0173 /* 0174 * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c16 0175 */ 0176 const uint8_t* volatile nb_max_row = (const uint8_t*) NB_MAX_ROW_ADDR; 0177 const uint16_t* volatile nb_max_col = (const uint16_t*) NB_MAX_COL_ADDR; 0178 if ((*nb_max_row == 0) && (*nb_max_col == 0)) { 0179 return false; 0180 } 0181 0182 /* 0183 * If there is a video card, let's assume there is also a keyboard. 0184 * The means that we need the ISR installed in case someone wants to 0185 * use the Keyboard or PS2 Mouse. With Microwindows, the console 0186 * can be COM1 and you can still use the mouse/VGA for graphics. 0187 */ 0188 if ( firstTime ) { 0189 status = rtems_interrupt_handler_install( 0190 BSP_KEYBOARD, 0191 "vgacons", 0192 RTEMS_INTERRUPT_UNIQUE, 0193 keyboard_interrupt, 0194 NULL 0195 ); 0196 assert(status == RTEMS_SUCCESSFUL); 0197 } 0198 firstTime = false; 0199 0200 return true; 0201 } 0202 0203 const console_fns vgacons_fns = 0204 { 0205 libchip_serial_default_probe, /* deviceProbe */ 0206 vgacons_open, /* deviceFirstOpen */ 0207 vgacons_close, /* deviceLastClose */ 0208 vgacons_inbyte_nonblocking_polled, /* deviceRead */ 0209 vgacons_write_support_polled, /* deviceWrite */ 0210 vgacons_init, /* deviceInitialize */ 0211 vgacons_write_polled, /* deviceWritePolled */ 0212 vgacons_set_attributes, /* deviceSetAttributes */ 0213 FALSE, /* deviceOutputUsesInterrupts */ 0214 };
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |