Changeset 1232cd46 in rtems


Ignore:
Timestamp:
Jun 25, 2018, 6:44:16 AM (10 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
cdfed94f
Parents:
c558cc4
git-author:
Sebastian Huber <sebastian.huber@…> (06/25/18 06:44:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/28/18 13:02:13)
Message:

bsp/riscv: Add device tree support for console

Update #3433.

Files:
2 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • bsps/riscv/riscv/console/htif.c

    rc558cc4 r1232cd46  
    2828 */
    2929
    30 #include <bsp.h>
    31 #include <bsp/console-polled.h>
    32 #include <rtems/libio.h>
    33 #include <stdlib.h>
     30#include <dev/serial/htif.h>
     31
    3432#include <assert.h>
    35 #include <stdio.h>
    3633
    3734/* Most of the code below is copied from riscv-pk project */
     
    7774}
    7875
    79 static int htif_console_getchar(void)
     76int htif_console_poll_char(rtems_termios_device_context *base)
    8077{
    8178  __check_fromhost();
     
    8986}
    9087
    91 static void htif_console_putchar(uint8_t ch)
     88void htif_console_write_polled(
     89  rtems_termios_device_context *base,
     90  const char *buf,
     91  size_t len
     92)
    9293{
    93   __set_tohost(1, 1, ch);
     94  size_t i;
     95
     96  for (i = 0; i < len; ++i) {
     97    __set_tohost(1, 1, buf[i]);
     98  }
    9499}
    95100
     
    102107}
    103108
    104 void console_initialize_hardware(void)
     109void htif_console_context_init(
     110  rtems_termios_device_context *base,
     111  int device_tree_node
     112)
    105113{
    106   /* Do nothing */
     114  rtems_termios_device_context_initialize(base, "HTIF");
    107115}
    108116
    109 static void outbyte_console(char ch)
     117static bool htif_console_first_open(
     118  struct rtems_termios_tty *tty,
     119  rtems_termios_device_context *base,
     120  struct termios *term,
     121  rtems_libio_open_close_args_t *args
     122)
    110123{
    111   htif_console_putchar(ch);
     124  return true;
    112125}
    113126
    114 static char inbyte_console(void)
    115 {
    116   return htif_console_getchar();
    117 }
    118 
    119 /*
    120  *  console_outbyte_polled
    121  *
    122  *  This routine transmits a character using polling.
    123  */
    124 void console_outbyte_polled(
    125   int  port,
    126   char ch
    127 )
    128 {
    129   outbyte_console( ch );
    130 }
    131 
    132 /*
    133  *  console_inbyte_nonblocking
    134  *
    135  *  This routine polls for a character.
    136  */
    137 
    138 int console_inbyte_nonblocking(int port)
    139 {
    140   char c;
    141 
    142   c = inbyte_console();
    143   if (!c) {
    144     return -1;
    145   }
    146   return (int) c;
    147 }
    148 
    149 /*
    150  *  To support printk
    151  */
    152 
    153 #include <rtems/bspIo.h>
    154 
    155 static void RISCV_output_char(char c)
    156 {
    157   console_outbyte_polled( 0, c );
    158 }
    159 
    160 BSP_output_char_function_type BSP_output_char = RISCV_output_char;
    161 BSP_polling_getchar_function_type BSP_poll_char =
    162   (void *)console_inbyte_nonblocking;
     127const rtems_termios_device_handler htif_console_handler = {
     128  .first_open = htif_console_first_open,
     129  .write = htif_console_write_polled,
     130  .poll_read = htif_console_poll_char,
     131  .mode = TERMIOS_POLLED
     132};
  • c/src/lib/libbsp/riscv/riscv/Makefile.am

    rc558cc4 r1232cd46  
    5050librtemsbsp_a_SOURCES += ../../../../../../bsps/riscv/riscv/btimer/btimer.c
    5151
    52 # console
    53 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/console-polled.c
    54 
    5552# IRQ
    5653librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/irq/irq-default-handler.c
     
    6057librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/cache/nocache.c
    6158
    62 # debugio
    63 librtemsbsp_a_SOURCES += ../../../../../../bsps/riscv/riscv/console/console-io.c
     59# Console
     60librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/console-termios.c
     61librtemsbsp_a_SOURCES += ../../../../../../bsps/riscv/riscv/console/console-config.c
     62librtemsbsp_a_SOURCES += ../../../../../../bsps/riscv/riscv/console/htif.c
    6463
    6564if HAS_SMP
  • c/src/lib/libbsp/riscv/riscv/configure.ac

    rc558cc4 r1232cd46  
    2828RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_COPY_TO_READ_ONLY_LOAD_AREA],[copy the FDT blob into the read-only load area via bsp_fdt_copy()])
    2929
     30RTEMS_BSPOPTS_SET([RISCV_ENABLE_HTIF_SUPPORT],[*],[1])
     31RTEMS_BSPOPTS_HELP([RISCV_ENABLE_HTIF_SUPPORT],[enables the HTIF support if defined to a non-zero value, otherwise it is disabled (enabled by default)])
     32
    3033RTEMS_BSP_CLEANUP_OPTIONS
    3134
Note: See TracChangeset for help on using the changeset viewer.