File indexing completed on 2025-05-11 08:23:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <rtems.h>
0020 #include <rtems/libio.h>
0021 #include <rtems/termiostypes.h>
0022
0023 #include <stdlib.h>
0024
0025 #include <libchip/serial.h>
0026 #include <libchip/sersupp.h>
0027
0028 #include <bsp.h>
0029 #include <bsp/fbcons.h>
0030 #include <bsp/vc.h>
0031 #include <bsp/rpi-fb.h>
0032
0033
0034
0035
0036
0037
0038
0039
0040 static bool fbcons_open(
0041 struct rtems_termios_tty *tty,
0042 rtems_termios_device_context *base,
0043 struct termios *term,
0044 rtems_libio_open_close_args_t *args
0045 )
0046 {
0047 return true;
0048 }
0049
0050
0051
0052
0053
0054
0055 static void fbcons_close(
0056 struct rtems_termios_tty *tty,
0057 rtems_termios_device_context *base,
0058 rtems_libio_open_close_args_t *args
0059 )
0060 {
0061 }
0062
0063
0064
0065
0066
0067
0068 void fbcons_write_polled(
0069 rtems_termios_device_context *base,
0070 char c
0071 )
0072 {
0073 rpi_fb_outch( c );
0074
0075 if ( c == '\n' )
0076 rpi_fb_outch( '\r' );
0077 }
0078
0079
0080
0081
0082
0083
0084
0085 static void fbcons_write_support_polled(
0086 rtems_termios_device_context *base,
0087 const char *buf,
0088 size_t len
0089 )
0090 {
0091 int nwrite = 0;
0092
0093
0094
0095
0096 while ( nwrite < len ) {
0097 fbcons_write_polled( base, *buf++ );
0098 nwrite++;
0099 }
0100 }
0101
0102
0103
0104
0105
0106
0107 static int fbcons_inbyte_nonblocking_polled(
0108 rtems_termios_device_context *base
0109 )
0110 {
0111
0112
0113
0114
0115
0116 return -1;
0117 }
0118
0119
0120
0121
0122
0123
0124
0125 static bool fbcons_set_attributes(
0126 rtems_termios_device_context *base,
0127 const struct termios *t
0128 )
0129 {
0130 return true;
0131 }
0132
0133 bool fbcons_probe(
0134 rtems_termios_device_context *context
0135 )
0136 {
0137
0138 static bool firstTime = true;
0139 static bool ret = false;
0140
0141
0142
0143
0144 if ( firstTime ) {
0145 if ( !rpi_fb_hdmi_is_present() ) {
0146 ret = false;
0147 } else {
0148 ret = true;
0149 }
0150 }
0151
0152 firstTime = false;
0153
0154 return ret;
0155 }
0156
0157 const rtems_termios_device_handler fbcons_fns =
0158 {
0159 .first_open = fbcons_open,
0160 .last_close = fbcons_close,
0161 .poll_read = fbcons_inbyte_nonblocking_polled,
0162 .write = fbcons_write_support_polled,
0163 .set_attributes = fbcons_set_attributes,
0164 .mode = TERMIOS_POLLED
0165 };