![]() |
|
|||
File indexing completed on 2025-05-11 08:22:49
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * uMon Support Output Driver 0005 * 0006 * COPYRIGHT (c) 1989-2009. 0007 * On-Line Applications Research Corporation (OAR). 0008 * 0009 * Modified by Fernando Nicodemos <fgnicodemos@terra.com.br> 0010 * from NCB - Sistemas Embarcados Ltda. (Brazil) 0011 * 0012 * Redistribution and use in source and binary forms, with or without 0013 * modification, are permitted provided that the following conditions 0014 * are met: 0015 * 1. Redistributions of source code must retain the above copyright 0016 * notice, this list of conditions and the following disclaimer. 0017 * 2. Redistributions in binary form must reproduce the above copyright 0018 * notice, this list of conditions and the following disclaimer in the 0019 * documentation and/or other materials provided with the distribution. 0020 * 0021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0031 * POSSIBILITY OF SUCH DAMAGE. 0032 */ 0033 0034 #include <rtems/umon.h> 0035 #include <libchip/serial.h> 0036 #include <libchip/sersupp.h> 0037 0038 /* static function prototypes */ 0039 static int umoncons_first_open(int major, int minor, void *arg); 0040 static int umoncons_last_close(int major, int minor, void *arg); 0041 static int umoncons_read(int minor); 0042 static ssize_t umoncons_write(int minor, const char *buf, size_t len); 0043 static void umoncons_init(int minor); 0044 static void umoncons_write_polled(int minor, char c); 0045 static int umoncons_set_attributes(int minor, const struct termios *t); 0046 0047 /* Pointers to functions for handling the UART. */ 0048 const console_fns umoncons_fns = 0049 { 0050 libchip_serial_default_probe, 0051 umoncons_first_open, 0052 umoncons_last_close, 0053 umoncons_read, 0054 umoncons_write, 0055 umoncons_init, 0056 umoncons_write_polled, /* not used in this driver */ 0057 umoncons_set_attributes, 0058 false /* TRUE if interrupt driven, FALSE if not. */ 0059 }; 0060 0061 /*********************************************************************/ 0062 /* Functions called via callbacks (i.e. the ones in uart_fns */ 0063 /*********************************************************************/ 0064 0065 /* 0066 * This is called the first time each device is opened. Since 0067 * the driver is polled, we don't have to do anything. If the driver 0068 * were interrupt driven, we'd enable interrupts here. 0069 */ 0070 static int umoncons_first_open(int major, int minor, void *arg) 0071 { 0072 return 0; 0073 } 0074 0075 0076 /* 0077 * This is called the last time each device is closed. Since 0078 * the driver is polled, we don't have to do anything. If the driver 0079 * were interrupt driven, we'd disable interrupts here. 0080 */ 0081 static int umoncons_last_close(int major, int minor, void *arg) 0082 { 0083 return 0; 0084 } 0085 0086 0087 /* 0088 * Read one character from UART. 0089 * 0090 * return -1 if there's no data, otherwise return 0091 * the character in lowest 8 bits of returned int. 0092 */ 0093 static int umoncons_read(int minor) 0094 { 0095 if ( !mon_gotachar() ) 0096 return -1; 0097 return mon_getchar(); 0098 } 0099 0100 0101 /* 0102 * Write buffer to LCD 0103 * 0104 * return 1 on success, -1 on error 0105 */ 0106 static ssize_t umoncons_write(int minor, const char *buf, size_t len) 0107 { 0108 size_t i; 0109 0110 for ( i=0 ; i<len ; i++ ) 0111 mon_putchar( buf[i] ); 0112 0113 return len; 0114 } 0115 0116 0117 /* Set up the uMon driver. */ 0118 static void umoncons_init(int minor) 0119 { 0120 rtems_umon_connect(); 0121 } 0122 0123 /* This is used for putchark support */ 0124 static void umoncons_write_polled(int minor, char c) 0125 { 0126 mon_putchar( c ); 0127 } 0128 0129 /* This is for setting baud rate, bits, etc. */ 0130 static int umoncons_set_attributes(int minor, const struct termios *t) 0131 { 0132 return 0; 0133 } 0134 0135 /***********************************************************************/ 0136 /* 0137 * The following functions are not used by TERMIOS, but other RTEMS 0138 * functions use them instead. 0139 */ 0140 /***********************************************************************/ 0141 /* 0142 * Read from UART. This is used in the exit code, and can't 0143 * rely on interrupts. 0144 */ 0145 int umoncons_poll_read(int minor) 0146 { 0147 if (!mon_gotachar()) 0148 return -1; 0149 return mon_getchar(); 0150 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |