source: rtems/bsps/arm/raspberrypi/console/fbcons.c

Last change on this file was 362cf319, checked in by G S Niteesh <gsnb.gn@…>, on 01/04/20 at 19:50:46

bsp/raspberrypi: Updated the console API.

Replaces the legacy termios API with new termios API (#3034)
Replaces the custom PL011 serial driver with RTEMS arm-pl011.
Update #3034

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup raspberrypi_console
5 *
6 * @brief framebuffer graphic console support.
7 */
8
9/*
10 * Copyright (c) 2015 Yang Qiao
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *
15 *  http://www.rtems.org/license/LICENSE
16 *
17 */
18
19#include <rtems.h>
20#include <rtems/libio.h>
21#include <rtems/termiostypes.h>
22
23#include <stdlib.h>
24
25#include <libchip/serial.h>
26#include <libchip/sersupp.h>
27
28#include <bsp.h>
29#include <bsp/fbcons.h>
30#include <bsp/vc.h>
31#include <bsp/rpi-fb.h>
32
33/*
34 *  fbcons_open
35 *
36 *  This function opens a port for communication.
37 *
38 *  Default state is 9600 baud, 8 bits, No parity, and 1 stop bit.
39 */
40static bool fbcons_open(
41  struct rtems_termios_tty *tty,
42  rtems_termios_device_context *base,
43  struct termios *term,
44  rtems_libio_open_close_args_t *args
45)
46{
47  return true;
48}
49
50/*
51 *  fbcons_close
52 *
53 *  This function shuts down the requested port.
54 */
55static void fbcons_close(
56  struct rtems_termios_tty *tty,
57  rtems_termios_device_context *base,
58  rtems_libio_open_close_args_t *args
59)
60{
61}
62
63/*
64 *  fbcons_write_polled
65 *
66 *  This routine polls out the requested character.
67 */
68void fbcons_write_polled(
69  rtems_termios_device_context *base,
70  char c
71)
72{
73  rpi_fb_outch( c );
74
75  if ( c == '\n' )
76    rpi_fb_outch( '\r' );            /* LF = LF + CR */
77}
78
79/*
80 *  fbcons_write_support_polled
81 *
82 *  Console Termios output entry point when using polled output.
83 *
84 */
85static void fbcons_write_support_polled(
86  rtems_termios_device_context *base,
87  const char *buf,
88  size_t      len
89)
90{
91  int nwrite = 0;
92
93  /*
94   * poll each byte in the string out of the port.
95   */
96  while ( nwrite < len ) {
97    fbcons_write_polled( base, *buf++ );
98    nwrite++;
99  }
100}
101
102/*
103 *  fbcons_inbyte_nonblocking_polled
104 *
105 *  Console Termios polling input entry point.
106 */
107static int fbcons_inbyte_nonblocking_polled(
108  rtems_termios_device_context *base
109)
110{
111  // if( rtems_kbpoll() ) {
112  //   int c = getch();
113  //   return c;
114  // }
115
116  return -1;
117}
118
119/*
120 *  fbcons_set_attributes
121 *
122 *  This function sets the UART channel to reflect the requested termios
123 *  port settings.
124 */
125static bool fbcons_set_attributes(
126  rtems_termios_device_context *base,
127  const struct termios *t
128)
129{
130  return true;
131}
132
133bool fbcons_probe(
134  rtems_termios_device_context *context
135)
136{
137  // rtems_status_code status;
138  static bool firstTime = true;
139  static bool ret = false;
140
141  /*
142   *  keyboard interrupt should be registered when the keyboard is available
143   */
144  if ( firstTime ) {
145    if ( !rpi_fb_hdmi_is_present() ) {
146      ret = false;
147    } else {
148      ret = true;
149    }
150  }
151
152  firstTime = false;
153
154  return ret;
155}
156
157const rtems_termios_device_handler fbcons_fns =
158{
159  .first_open = fbcons_open,
160  .last_close = fbcons_close,
161  .poll_read = fbcons_inbyte_nonblocking_polled,
162  .write = fbcons_write_support_polled,
163  .set_attributes = fbcons_set_attributes,
164  .mode = TERMIOS_POLLED
165};
Note: See TracBrowser for help on using the repository browser.