bsp/leon3: Console driver changes

Move declaration of global variables and functions to <leon.h> header
file.  Make several global variables and functions static.
This commit is contained in:
Sebastian Huber
2013-11-26 09:11:57 +01:00
parent 6fe6d017a4
commit 1d5d6de35e
3 changed files with 56 additions and 68 deletions

View File

@@ -31,42 +31,11 @@
#include <stdlib.h>
#include <assert.h>
#include <rtems/bspIo.h>
#include <amba.h>
#include <leon.h>
#include <rtems/termiostypes.h>
/* Let user override which on-chip APBUART will be debug UART
* 0 = Default APBUART. On MP system CPU0=APBUART0, CPU1=APBUART1...
* 1 = APBUART[0]
* 2 = APBUART[1]
* 3 = APBUART[2]
* ...
*/
int syscon_uart_index __attribute__((weak)) = 0;
/*
* apbuart_outbyte_polled
*
* This routine transmits a character using polling.
*/
extern void apbuart_outbyte_polled(
struct apbuart_regs *regs,
unsigned char ch,
int do_cr_on_newline,
int wait_sent
);
/* body is in printk_support.c */
/*
* apbuart_inbyte_nonblocking
*
* This routine polls for a character.
*/
extern int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
/* body is in debugputs.c */
struct apbuart_priv {
@@ -153,16 +122,14 @@ static int leon3_console_write_support(int minor, const char *buf, size_t len)
#else
/*
* Prototypes to avoid warnings
*/
ssize_t console_write_polled(int minor, const char *buf, size_t len);
int console_pollRead(int minor);
/*
* Console Termios Support Entry Points
*/
ssize_t console_write_polled(int minor, const char *buf, size_t len)
static ssize_t leon3_console_write_polled(
int minor,
const char *buf,
size_t len
)
{
struct apbuart_priv *uart = leon3_console_get_uart(minor);
int nwrite = 0;
@@ -174,7 +141,7 @@ ssize_t console_write_polled(int minor, const char *buf, size_t len)
return nwrite;
}
int console_pollRead(int minor)
static int leon3_console_pollRead(int minor)
{
struct apbuart_priv *uart = leon3_console_get_uart(minor);
@@ -183,15 +150,7 @@ int console_pollRead(int minor)
#endif
/*
* Prototypes to avoid warnings
*/
int console_set_attributes(int minor, const struct termios *t);
int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg);
int console_scan_uarts(void);
int console_set_attributes(int minor, const struct termios *t)
static int leon3_console_set_attributes(int minor, const struct termios *t)
{
struct apbuart_priv *uart = leon3_console_get_uart(minor);
unsigned int scaler;
@@ -259,7 +218,7 @@ int console_set_attributes(int minor, const struct termios *t)
}
/* AMBA PP find routine. Extract AMBA PnP information into data structure. */
int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
static int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
{
struct ambapp_apb_info *apb = (struct ambapp_apb_info *)dev->devinfo;
@@ -281,15 +240,13 @@ int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg)
}
/* Find all UARTs */
int console_scan_uarts(void)
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);
return uarts;
}
/*
@@ -310,7 +267,7 @@ rtems_device_driver console_initialize(
rtems_termios_initialize();
/* Find UARTs */
console_scan_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
@@ -429,7 +386,7 @@ rtems_device_driver console_open(
leon3_console_last_close, /* lastClose */
NULL, /* pollRead */
leon3_console_write_support, /* write */
console_set_attributes, /* setAttributes */
leon3_console_set_attributes,/* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
1 /* outputUsesInterrupts */
@@ -439,9 +396,9 @@ rtems_device_driver console_open(
static const rtems_termios_callbacks Callbacks = {
leon3_console_first_open, /* firstOpen */
NULL, /* lastClose */
console_pollRead, /* pollRead */
console_write_polled, /* write */
console_set_attributes, /* setAttributes */
leon3_console_pollRead, /* pollRead */
leon3_console_write_polled, /* write */
leon3_console_set_attributes,/* setAttributes */
NULL, /* stopRemoteTx */
NULL, /* startRemoteTx */
0 /* outputUsesInterrupts */

View File

@@ -16,28 +16,22 @@
*/
#include <bsp.h>
#include <leon.h>
#include <rtems/libio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
/* Let user override which on-chip APBUART will be debug UART
* 0 = Default APBUART. On MP system CPU0=APBUART0, CPU1=APBUART1...
* 1 = APBUART[0]
* 2 = APBUART[1]
* 3 = APBUART[2]
* ...
*/
int debug_uart_index __attribute__((weak)) = 0;
struct apbuart_regs *dbg_uart = NULL;
static struct apbuart_regs *dbg_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.
*/
char pre_printk_dbgbuf[32] = {0};
int pre_printk_pos = 0;
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.

View File

@@ -273,6 +273,43 @@ static inline unsigned int leon_r32_no_cache(uintptr_t addr)
return tmp;
}
/* Let user override which on-chip APBUART will be debug UART
* 0 = Default APBUART. On MP system CPU0=APBUART0, CPU1=APBUART1...
* 1 = APBUART[0]
* 2 = APBUART[1]
* 3 = APBUART[2]
* ...
*/
extern int syscon_uart_index;
/* Let user override which on-chip APBUART will be debug UART
* 0 = Default APBUART. On MP system CPU0=APBUART0, CPU1=APBUART1...
* 1 = APBUART[0]
* 2 = APBUART[1]
* 3 = APBUART[2]
* ...
*/
extern int debug_uart_index;
/*
* apbuart_outbyte_polled
*
* This routine transmits a character using polling.
*/
void apbuart_outbyte_polled(
struct apbuart_regs *regs,
unsigned char ch,
int do_cr_on_newline,
int wait_sent
);
/*
* apbuart_inbyte_nonblocking
*
* This routine polls for a character.
*/
int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
#endif /* !ASM */
#ifdef __cplusplus