summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2011-12-16 12:01:10 +0100
committerDaniel Hellstrom <daniel@gaisler.com>2012-03-27 15:20:16 +0200
commitd00f8fe0d070fd4fd60b5dd7675c78763516e125 (patch)
tree125ea9c46b7b230e1d0c1b77cb49153f7f0bf572
parent9220c2907d4836f08e8756b74441c41b318521a1 (diff)
LEON: timer/console code-style cleanups
-rw-r--r--c/src/lib/libbsp/sparc/shared/include/cons.h19
-rw-r--r--c/src/lib/libbsp/sparc/shared/include/tlib.h21
-rw-r--r--c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c59
-rw-r--r--c/src/lib/libbsp/sparc/shared/uart/cons.c18
4 files changed, 62 insertions, 55 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/include/cons.h b/c/src/lib/libbsp/sparc/shared/include/cons.h
index 90fd2585f3..816e20f899 100644
--- a/c/src/lib/libbsp/sparc/shared/include/cons.h
+++ b/c/src/lib/libbsp/sparc/shared/include/cons.h
@@ -1,11 +1,16 @@
-/*
+/* Console driver interface to UART drivers
*
- * - First console device that has System Console flag set will be
- * system console.
- * - Last console device that has Debug Console flag set will be
- * debug console.
- * - If none of the registered console devices has system console set,
- * the first is registered device is used, unless it has
+ * - First console device that has System Console flag set will be
+ * system console.
+ * - If none of the registered console devices has system console set,
+ * the first is registered device is used, unless it has
+ *
+ * COPYRIGHT (c) 2010.
+ * 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.com/license/LICENSE.
*/
#ifndef __CONS_H__
diff --git a/c/src/lib/libbsp/sparc/shared/include/tlib.h b/c/src/lib/libbsp/sparc/shared/include/tlib.h
index 737060e39d..95be5efce4 100644
--- a/c/src/lib/libbsp/sparc/shared/include/tlib.h
+++ b/c/src/lib/libbsp/sparc/shared/include/tlib.h
@@ -1,13 +1,19 @@
/*
- * Timer Library
+ * Timer Library (TLIB)
*
- * The Library rely on timer drivers, the timer presented by the
- * timer driver must look like a down-counter timer, which generates
- * interrupt (if configured) when underflown.
+ * The Library rely on timer drivers, the timer presented by the
+ * timer driver must look like a down-counter timer, which generates
+ * interrupt (if configured) when underflown.
*
- * If Timer hardware is an up-counter the Timer driver must recalculate
- * into values that would match as if it was a down-counter.
+ * If Timer hardware is an up-counter the Timer driver must recalculate
+ * into values that would match as if it was a down-counter.
*
+ * 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.com/license/LICENSE.
*/
struct tlib_dev;
@@ -42,7 +48,8 @@ struct tlib_dev {
#ifdef RTEMS_DRVMGR_STARTUP
/* Clock Driver Timer register function. Only used when the TLIB-Clock
- * driver is used. A specific Timer is
+ * driver is used. A specific Timer is registered as the System Clock
+ * timer.
*/
extern void Clock_timer_register(int timer_number);
#endif
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index f3528ca672..71a14d127a 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -8,7 +8,7 @@
* The BSP define APBUART_INFO_AVAIL in order to add the info routine
* used for debugging.
*
- * COPYRIGHT (c) 2008.
+ * COPYRIGHT (c) 2010.
* Aeroflex Gaisler.
*
* The license and distribution terms for this file may be
@@ -126,7 +126,7 @@ void apbuart_cons_register_drv (void)
/* Interrupt mode routines */
static const rtems_termios_callbacks Callbacks_intr = {
apbuart_firstOpen, /* firstOpen */
- NULL, /* lastClose */
+ apbuart_lastClose, /* lastClose */
NULL, /* pollRead */
apbuart_write_intr, /* write */
apbuart_set_attributes, /* setAttributes */
@@ -138,7 +138,7 @@ static const rtems_termios_callbacks Callbacks_intr = {
/* Polling mode routines */
static const rtems_termios_callbacks Callbacks_task = {
apbuart_firstOpen, /* firstOpen */
- NULL, /* lastClose */
+ apbuart_lastClose, /* lastClose */
apbuart_pollRead_task, /* pollRead */
apbuart_write_intr, /* write */
apbuart_set_attributes, /* setAttributes */
@@ -150,7 +150,7 @@ static const rtems_termios_callbacks Callbacks_task = {
/* Polling mode routines */
static const rtems_termios_callbacks Callbacks_poll = {
apbuart_firstOpen, /* firstOpen */
- NULL, /* lastClose */
+ apbuart_lastClose, /* lastClose */
apbuart_pollRead, /* pollRead */
apbuart_write_polled, /* write */
apbuart_set_attributes, /* setAttributes */
@@ -193,9 +193,8 @@ int apbuart_init1(struct drvmgr_dev *dev)
/* Get device information from AMBA PnP information */
ambadev = (struct amba_dev_info *)priv->dev->businfo;
- if ( ambadev == NULL ) {
+ if (ambadev == NULL)
return -1;
- }
pnpinfo = &ambadev->info;
priv->regs = (struct apbuart_regs *)pnpinfo->apb_slv->start;
@@ -222,7 +221,7 @@ int apbuart_init1(struct drvmgr_dev *dev)
* We default to have System Console on first APBUART, user may override
* this behaviour by setting the syscon option to 0.
*/
- if ( drvmgr_on_rootbus(dev) && first_uart ) {
+ if (drvmgr_on_rootbus(dev) && first_uart) {
priv->condev.flags = CONSOLE_FLAG_SYSCON;
first_uart = 0;
} else {
@@ -230,8 +229,8 @@ int apbuart_init1(struct drvmgr_dev *dev)
}
value = drvmgr_dev_key_get(priv->dev, "syscon", KEY_TYPE_INT);
- if ( value ) {
- if ( value->i )
+ if (value) {
+ if (value->i)
priv->condev.flags |= CONSOLE_FLAG_SYSCON;
else
priv->condev.flags &= ~CONSOLE_FLAG_SYSCON;
@@ -242,13 +241,13 @@ int apbuart_init1(struct drvmgr_dev *dev)
/* Select 0=Polled, 1=IRQ, 2=Task-Driven UART Mode */
value = drvmgr_dev_key_get(priv->dev, "mode", KEY_TYPE_INT);
- if ( value )
+ if (value)
priv->mode = value->i;
else
priv->mode = TERMIOS_POLLED;
- if ( priv->mode == TERMIOS_IRQ_DRIVEN ) {
+ if (priv->mode == TERMIOS_IRQ_DRIVEN) {
priv->condev.callbacks = &Callbacks_intr;
- } else if ( priv->mode == TERMIOS_TASK_DRIVEN ) {
+ } else if (priv->mode == TERMIOS_TASK_DRIVEN) {
priv->condev.callbacks = &Callbacks_task;
} else {
priv->condev.callbacks = &Callbacks_poll;
@@ -256,7 +255,7 @@ int apbuart_init1(struct drvmgr_dev *dev)
/* Get Filesystem name prefix */
prefix[0] = '\0';
- if ( drvmgr_get_dev_prefix(dev, prefix) ) {
+ if (drvmgr_get_dev_prefix(dev, prefix)) {
/* Got special prefix, this means we have a bus prefix
* And we should use our "bus minor"
*/
@@ -323,7 +322,7 @@ void apbuart_outbyte_polled(
int wait_sent)
{
send:
- while ( (regs->status & LEON_REG_UART_STATUS_THE) == 0 ) {
+ while ((regs->status & LEON_REG_UART_STATUS_THE) == 0) {
/* Lower bus utilization while waiting for UART */
asm volatile ("nop"::); asm volatile ("nop"::);
asm volatile ("nop"::); asm volatile ("nop"::);
@@ -338,7 +337,7 @@ send:
}
/* Wait until the character has been sent? */
- if ( wait_sent ) {
+ if (wait_sent) {
while ((regs->status & LEON_REG_UART_STATUS_THE) == 0)
;
}
@@ -371,7 +370,7 @@ int apbuart_firstOpen(int major, int minor, void *arg)
/* Enable TX/RX */
uart->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE;
- if ( uart->mode != TERMIOS_POLLED ) {
+ if (uart->mode != TERMIOS_POLLED) {
/* Register interrupt and enable it */
drvmgr_interrupt_register(uart->dev, 0, "apbuart",
apbuart_isr, uart);
@@ -388,12 +387,12 @@ int apbuart_lastClose(int major, int minor, void *arg)
{
struct apbuart_priv *uart = (struct apbuart_priv *)minor;
- if ( uart->mode != TERMIOS_POLLED ) {
+ if (uart->mode != TERMIOS_POLLED) {
/* Turn off RX interrupts */
uart->regs->ctrl &= ~(LEON_REG_UART_CTRL_RI);
/**** Flush device ****/
- while ( uart->sending ){
+ while (uart->sending) {
/* Wait until all data has been sent */
}
@@ -424,17 +423,17 @@ int apbuart_pollRead_task(int minor)
char buf[32];
tot = 0;
- while ( (c=apbuart_inbyte_nonblocking(uart->regs)) != EOF ) {
+ while ((c=apbuart_inbyte_nonblocking(uart->regs)) != EOF) {
buf[tot] = c;
tot++;
- if ( tot > 31 ) {
+ if (tot > 31) {
rtems_termios_enqueue_raw_characters(uart->cookie, buf, tot);
tot = 0;
}
}
- if ( tot > 0 ) {
+ if (tot > 0)
rtems_termios_enqueue_raw_characters(uart->cookie, buf, tot);
- }
+
return EOF;
}
@@ -549,18 +548,17 @@ int apbuart_set_attributes(int minor, const struct termios *t)
ctrl &= ~(LEON_REG_UART_CTRL_PS|LEON_REG_UART_CTRL_PE);
}
- if ( !(t->c_cflag & CLOCAL) ){
+ if (!(t->c_cflag & CLOCAL))
ctrl |= LEON_REG_UART_CTRL_FL;
- }else{
+ else
ctrl &= ~LEON_REG_UART_CTRL_FL;
- }
/* Update new settings */
uart->regs->ctrl = ctrl;
/* Baud rate */
baud = apbuart_baud_num2baud(t->c_cflag & CBAUD);
- if ( baud > 0 ){
+ if (baud > 0){
/* Get APBUART core frequency */
drvmgr_freq_get(uart->dev, DEV_APB_SLV, &core_clk_hz);
@@ -655,12 +653,11 @@ void apbuart_isr(void *arg)
int cnt;
/* Get all received characters */
- if ( uart->mode == TERMIOS_TASK_DRIVEN ) {
- if ( (status=uart->regs->status) & LEON_REG_UART_STATUS_DR ) {
+ if (uart->mode == TERMIOS_TASK_DRIVEN) {
+ if ((status=uart->regs->status) & LEON_REG_UART_STATUS_DR)
rtems_termios_rxirq_occured(uart->cookie);
- }
} else {
- while ( (status=uart->regs->status) & LEON_REG_UART_STATUS_DR ) {
+ while ((status=uart->regs->status) & LEON_REG_UART_STATUS_DR) {
/* Data has arrived, get new data */
data = uart->regs->data;
@@ -669,7 +666,7 @@ void apbuart_isr(void *arg)
}
}
- if ( uart->sending && (status & LEON_REG_UART_STATUS_THE) ) {
+ if (uart->sending && (status & LEON_REG_UART_STATUS_THE)) {
/* Sent the one char, we disable TX interrupts */
uart->regs->ctrl &= ~LEON_REG_UART_CTRL_TI;
diff --git a/c/src/lib/libbsp/sparc/shared/uart/cons.c b/c/src/lib/libbsp/sparc/shared/uart/cons.c
index 9a8d3690dc..8617b96adf 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/cons.c
@@ -45,7 +45,7 @@ void console_dev_init(struct console_priv *con, int minor)
char name[16], *fsname;
rtems_status_code status;
- if ( !con->dev->fsname ) {
+ if (!con->dev->fsname) {
strcpy(name, "/dev/console_a");
/* Special console name and MINOR for SYSTEM CONSOLE */
if (minor == 0)
@@ -56,9 +56,8 @@ void console_dev_init(struct console_priv *con, int minor)
fsname = con->dev->fsname;
}
status = rtems_io_register_name(fsname, console_major, minor);
- if ( (minor == 0) && (status != RTEMS_SUCCESSFUL) ) {
+ if ((minor == 0) && (status != RTEMS_SUCCESSFUL))
rtems_fatal_error_occurred(status);
- }
}
void console_dev_register(struct console_dev *dev)
@@ -66,12 +65,12 @@ void console_dev_register(struct console_dev *dev)
int i, minor = 0;
struct console_priv *con = NULL;
- if ( (dev->flags & CONSOLE_FLAG_SYSCON) && !cons[0].dev ) {
+ if ((dev->flags & CONSOLE_FLAG_SYSCON) && !cons[0].dev) {
con = &cons[0];
con->flags = FLAG_SYSCON;
} else {
for (i=1; i<CONSOLE_MAX; i++) {
- if ( !cons[i].dev ) {
+ if (!cons[i].dev) {
con = &cons[i];
con->flags = 0;
minor = i;
@@ -79,7 +78,7 @@ void console_dev_register(struct console_dev *dev)
}
}
}
- if ( con == NULL ) {
+ if (con == NULL) {
/* Not enough console structures */
return;
}
@@ -91,7 +90,7 @@ void console_dev_register(struct console_dev *dev)
/* Console layer is already initialized, that means that we can
* register termios interface directly.
*/
- if ( console_initialized )
+ if (console_initialized)
console_dev_init(con, minor);
}
@@ -115,9 +114,8 @@ rtems_device_driver console_initialize(
/* Register all Console a file system device node */
for (i=0; i<CONSOLE_MAX; i++) {
- if ( cons[i].dev ) {
+ if (cons[i].dev)
console_dev_init(&cons[i], i);
- }
}
console_initialized = 1;
@@ -133,7 +131,7 @@ rtems_device_driver console_open(
rtems_status_code status;
struct termios term;
- if ( (minor >= CONSOLE_MAX) || !cons[minor].dev )
+ if ((minor >= CONSOLE_MAX) || !cons[minor].dev)
return RTEMS_INVALID_NUMBER;
status = rtems_termios_open(