summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/leon3
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-19 06:28:01 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-04-20 13:08:32 +0200
commitd7d66d7d4523b904c8ccc6aea3709dc0d5aa5bdc (patch)
treecaa54b4229e86a68c84ab5961af34e087dce5302 /c/src/lib/libbsp/sparc/leon3
parentbsps/powerpc: Move shared btimer support (diff)
downloadrtems-d7d66d7d4523b904c8ccc6aea3709dc0d5aa5bdc.tar.bz2
bsps: Move console drivers to bsps
This patch is a part of the BSP source reorganization. Update #3285.
Diffstat (limited to 'c/src/lib/libbsp/sparc/leon3')
-rw-r--r--c/src/lib/libbsp/sparc/leon3/Makefile.am6
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/console.c160
-rw-r--r--c/src/lib/libbsp/sparc/leon3/console/printk_support.c119
3 files changed, 3 insertions, 282 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index 6432fcde9a..7c76d726f0 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -67,12 +67,12 @@ librtemsbsp_a_SOURCES += ../shared/timer/tlib_ckinit.c
librtemsbsp_a_SOURCES +=../../../../../../bsps/sparc/leon3/clock/ckinit.c
# console
-librtemsbsp_a_SOURCES += ../../shared/console-termios.c
-librtemsbsp_a_SOURCES += console/console.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/serial/console-termios.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/console/console.c
librtemsbsp_a_SOURCES += ../shared/uart/cons.c
librtemsbsp_a_SOURCES += ../shared/uart/apbuart_cons.c
# debugio
-librtemsbsp_a_SOURCES += console/printk_support.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/sparc/leon3/console/printk_support.c
# IRQ
librtemsbsp_a_SOURCES += startup/eirq.c
diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c
deleted file mode 100644
index acab893399..0000000000
--- a/c/src/lib/libbsp/sparc/leon3/console/console.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * This file contains the TTY driver for the serial ports on the LEON.
- *
- * This driver uses the termios pseudo driver.
- *
- * COPYRIGHT (c) 1989-1998.
- * On-Line Applications Research Corporation (OAR).
- *
- * Modified for LEON3 BSP.
- * COPYRIGHT (c) 2004.
- * Gaisler Research.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-/* Define CONSOLE_USE_INTERRUPTS to enable APBUART interrupt handling instead
- * of polling mode.
- *
- * Note that it is not possible to use the interrupt mode of the driver
- * together with the "old" APBUART and -u to GRMON. However the new
- * APBUART core (from GRLIB 1.0.17-b2710) has the GRMON debug bit and can
- * handle interrupts.
- *
- * NOTE: This can be defined in the make/custom/leon3.cfg file.
- */
-
-#include <bsp.h>
-#include <bsp/fatal.h>
-#include <bsp/apbuart_termios.h>
-#include <rtems/console.h>
-#include <string.h>
-
-/* The LEON3 BSP UART driver can rely on the Driver Manager if the
- * DrvMgr is initialized during startup. Otherwise the classic driver
- * must be used.
- *
- * The DrvMgr APBUART driver is located in the shared/uart directory
- */
-#ifndef RTEMS_DRVMGR_STARTUP
-
-int syscon_uart_index __attribute__((weak)) = 0;
-
-/* body is in debugputs.c */
-static struct apbuart_context apbuarts[BSP_NUMBER_OF_TERMIOS_PORTS];
-static int uarts = 0;
-
-static rtems_termios_device_context *leon3_console_get_context(int index)
-{
- struct apbuart_context *uart = &apbuarts[index];
-
- rtems_termios_device_context_initialize(&uart->base, "APBUART");
-
- return &uart->base;
-}
-
-/* AMBA PP find routine. Extract AMBA PnP information into data structure. */
-static int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
-{
- struct ambapp_apb_info *apb = (struct ambapp_apb_info *)dev->devinfo;
-
- /* Extract needed information of one APBUART */
- apbuarts[uarts].regs = (struct apbuart_regs *)apb->start;
- apbuarts[uarts].irq = apb->irq;
- /* Get APBUART core frequency, it is assumed that it is the same
- * as Bus frequency where the UART is situated
- */
- apbuarts[uarts].freq_hz = ambapp_freq_get(&ambapp_plb, dev);
- uarts++;
-
- if (uarts >= BSP_NUMBER_OF_TERMIOS_PORTS)
- return 1; /* Satisfied number of UARTs, stop search */
- else
- return 0; /* Continue searching for more UARTs */
-}
-
-/* Find all UARTs */
-static void leon3_console_scan_uarts(void)
-{
- memset(apbuarts, 0, sizeof(apbuarts));
-
- /* Find APBUART cores */
- ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER,
- GAISLER_APBUART, find_matching_apbuart, NULL);
-}
-
-rtems_device_driver console_initialize(
- rtems_device_major_number major,
- rtems_device_minor_number minor,
- void *arg
-)
-{
- const rtems_termios_device_handler *handler =
-#if CONSOLE_USE_INTERRUPTS
- &apbuart_handler_interrupt;
-#else
- &apbuart_handler_polled;
-#endif
- rtems_status_code status;
- int i;
- char console_name[16];
-
- rtems_termios_initialize();
-
- /* Find UARTs */
- leon3_console_scan_uarts();
-
- /* Update syscon_uart_index to index used as /dev/console
- * Let user select System console by setting syscon_uart_index. If the
- * BSP is to provide the default UART (syscon_uart_index==0):
- * non-MP: APBUART[0] is system console
- * MP: LEON CPU index select UART
- */
- if (syscon_uart_index == 0) {
-#if defined(RTEMS_MULTIPROCESSING)
- syscon_uart_index = LEON3_Cpu_Index;
-#else
- syscon_uart_index = 0;
-#endif
- } else {
- syscon_uart_index = syscon_uart_index - 1; /* User selected sys-console */
- }
-
- /* Register Device Names
- *
- * 0 /dev/console - APBUART[USER-SELECTED, DEFAULT=APBUART[0]]
- * 1 /dev/console_a - APBUART[0] (by default not present because is console)
- * 2 /dev/console_b - APBUART[1]
- * ...
- *
- * On a MP system one should not open UARTs that other OS instances use.
- */
- if (syscon_uart_index < uarts) {
- status = rtems_termios_device_install(
- CONSOLE_DEVICE_NAME,
- handler,
- NULL,
- leon3_console_get_context(syscon_uart_index)
- );
- if (status != RTEMS_SUCCESSFUL)
- bsp_fatal(LEON3_FATAL_CONSOLE_REGISTER_DEV);
- }
- strcpy(console_name,"/dev/console_a");
- for (i = 0; i < uarts; i++) {
- if (i == syscon_uart_index)
- continue; /* skip UART that is registered as /dev/console */
- console_name[13] = 'a' + i;
- rtems_termios_device_install(
- console_name,
- handler,
- NULL,
- leon3_console_get_context(i)
- );
- }
-
- return RTEMS_SUCCESSFUL;
-}
-
-#endif
diff --git a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c b/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
deleted file mode 100644
index f7e1fb683f..0000000000
--- a/c/src/lib/libbsp/sparc/leon3/console/printk_support.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * This file contains the TTY driver for the serial ports on the LEON.
- *
- * This driver uses the termios pseudo driver.
- *
- * COPYRIGHT (c) 1989-1999.
- * On-Line Applications Research Corporation (OAR).
- *
- * Modified for LEON3 BSP.
- * COPYRIGHT (c) 2011.
- * Aeroflex Gaisler.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <leon.h>
-#include <rtems/libio.h>
-#include <rtems/sysinit.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <bsp/apbuart.h>
-#include <bsp/apbuart_termios.h>
-
-int leon3_debug_uart_index __attribute__((weak)) = 0;
-struct apbuart_regs *leon3_debug_uart = NULL;
-
-/* Before UART driver has registered (or when no UART is available), calls to
- * printk that gets to bsp_out_char() will be filling data into the
- * pre_printk_dbgbuf[] buffer, hopefully the buffer can help debugging the
- * early BSP boot.. At least the last printk() will be caught.
- */
-static char pre_printk_dbgbuf[32] = {0};
-static int pre_printk_pos = 0;
-
-/* Initialize the BSP system debug console layer. It will scan AMBA Plu&Play
- * for a debug APBUART and enable RX/TX for that UART.
- */
-static void bsp_debug_uart_init(void)
-{
- int i;
- struct ambapp_dev *adev;
- struct ambapp_apb_info *apb;
-
- /* Update leon3_debug_uart_index to index used as debug console. Let user
- * select Debug console by setting leon3_debug_uart_index. If the BSP is to
- * provide the default UART (leon3_debug_uart_index==0):
- * non-MP: APBUART[0] is debug console
- * MP: LEON CPU index select UART
- */
- if (leon3_debug_uart_index == 0) {
-#if defined(RTEMS_MULTIPROCESSING)
- leon3_debug_uart_index = LEON3_Cpu_Index;
-#else
- leon3_debug_uart_index = 0;
-#endif
- } else {
- leon3_debug_uart_index--; /* User selected dbg-console */
- }
-
- /* Find APBUART core for System Debug Console */
- i = leon3_debug_uart_index;
- adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),
- VENDOR_GAISLER, GAISLER_APBUART,
- ambapp_find_by_idx, (void *)&i);
- if (adev) {
- /* Found a matching debug console, initialize debug uart if present
- * for printk
- */
- apb = (struct ambapp_apb_info *)adev->devinfo;
- leon3_debug_uart = (struct apbuart_regs *)apb->start;
- leon3_debug_uart->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
- leon3_debug_uart->status = 0;
- }
-}
-
-RTEMS_SYSINIT_ITEM(
- bsp_debug_uart_init,
- RTEMS_SYSINIT_BSP_START,
- RTEMS_SYSINIT_ORDER_FOURTH
-);
-
-/* putchar/getchar for printk */
-static void bsp_out_char(char c)
-{
- if (leon3_debug_uart == NULL) {
- /* Local debug buffer when UART driver has not registered */
- pre_printk_dbgbuf[pre_printk_pos++] = c;
- pre_printk_pos = pre_printk_pos & (sizeof(pre_printk_dbgbuf)-1);
- return;
- }
-
- apbuart_outbyte_polled(leon3_debug_uart, c, 1, 1);
-}
-
-/*
- * To support printk
- */
-
-#include <rtems/bspIo.h>
-
-BSP_output_char_function_type BSP_output_char = bsp_out_char;
-
-static int bsp_in_char(void)
-{
- int tmp;
-
- if (leon3_debug_uart == NULL)
- return EOF;
-
- while ((tmp = apbuart_inbyte_nonblocking(leon3_debug_uart)) < 0)
- ;
- return tmp;
-}
-
-BSP_polling_getchar_function_type BSP_poll_char = bsp_in_char;