From 491369667b203ae959b48a2c11fabc8e0bce0dde Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 28 Jan 2008 14:59:21 +0000 Subject: [PATCH] Z16F compile/link with all OS features enabled git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@574 42af7a65-404d-4744-a932-0658087f49c3 --- arch/z16/include/z16f/irq.h | 2 +- arch/z16/src/common/up_sigdeliver.c | 4 +-- arch/z16/src/z16f/z16f_head.S | 11 +++++++ arch/z16/src/z16f/z16f_lowuart.S | 1 - arch/z16/src/z16f/z16f_serial.c | 45 +++++++++++++++-------------- 5 files changed, 37 insertions(+), 26 deletions(-) diff --git a/arch/z16/include/z16f/irq.h b/arch/z16/include/z16f/irq.h index 7434b1f256d..3e4ae472cfa 100644 --- a/arch/z16/include/z16f/irq.h +++ b/arch/z16/include/z16f/irq.h @@ -180,7 +180,7 @@ struct xcptcontext */ #ifndef CONFIG_DISABLE_SIGNALS - void *sigdeliver; /* Actual type is sig_deliver_t */ + CODE void *sigdeliver; /* Actual type is sig_deliver_t */ /* The following retains that state during signal execution */ diff --git a/arch/z16/src/common/up_sigdeliver.c b/arch/z16/src/common/up_sigdeliver.c index 59b40715d94..ce94d1a4094 100644 --- a/arch/z16/src/common/up_sigdeliver.c +++ b/arch/z16/src/common/up_sigdeliver.c @@ -113,12 +113,12 @@ void up_sigdeliver(void) * signals. */ - sigdeliver = rtcb->xcp.sigdeliver; + sigdeliver = (sig_deliver_t)rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; /* Then restore the task interrupt state. */ - if ((reg[REG_FLAGS] & Z16F_CNTRL_FLAGS_IRQE) != 0) + if ((regs[REG_FLAGS] & Z16F_CNTRL_FLAGS_IRQE) != 0) { EI(); } diff --git a/arch/z16/src/z16f/z16f_head.S b/arch/z16/src/z16f/z16f_head.S index fc480822a43..7e0682e76bf 100755 --- a/arch/z16/src/z16f/z16f_head.S +++ b/arch/z16/src/z16f/z16f_head.S @@ -50,8 +50,14 @@ #ifdef CONFIG_ARCH_LEDS xref _up_ledinit:EROM #endif +#if defined(CONFIG_DEV_CONSOLE) && CONFIG_NFILE_DESCRIPTORS > 0 + xref _up_earlyserialinit:EROM +#endif #if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC) xref _z16f_lowuartinit:EROM +#endif +#if defined(CONFIG_DEV_CONSOLE) && CONFIG_NFILE_DESCRIPTORS > 0 + xref up_earlyserialinit:EROM #endif xref _os_start:EROM xref _up_doirq:EROM @@ -207,6 +213,11 @@ _z16f_reset8: call _z16f_lowinit /* Perform low-level hardware initialization */ +#if defined(CONFIG_DEV_CONSOLE) && CONFIG_NFILE_DESCRIPTORS > 0 + /* Perform early serial initialization */ + + call _up_earlyserialinit +#endif /* Start NuttX */ call _os_start /* Start the operating system */ diff --git a/arch/z16/src/z16f/z16f_lowuart.S b/arch/z16/src/z16f/z16f_lowuart.S index b3923212274..bea5f25fc5f 100755 --- a/arch/z16/src/z16f/z16f_lowuart.S +++ b/arch/z16/src/z16f/z16f_lowuart.S @@ -168,7 +168,6 @@ _up_lowputc: * *************************************************************************/ -#ifdef CONFIG_ARCH_LOWPUTC _z16f_xmitc: _z16f_xmitc1: ld r0, Z16F_UARTSTAT0_TDRE /* TDRE=Transmitter Data Register Empty */ diff --git a/arch/z16/src/z16f/z16f_serial.c b/arch/z16/src/z16f/z16f_serial.c index 38d7492af2f..fb92919b172 100644 --- a/arch/z16/src/z16f/z16f_serial.c +++ b/arch/z16/src/z16f/z16f_serial.c @@ -158,7 +158,7 @@ static uart_dev_t g_uart0port = #endif { 0 }, /* closesem */ { 0 }, /* xmitsem */ - { 0 ], /* recvsem */ + { 0 }, /* recvsem */ { { 0 }, /* xmit.sem */ 0, /* xmit.head */ @@ -203,7 +203,7 @@ static uart_dev_t g_uart1port = #endif { 0 }, /* closesem */ { 0 }, /* xmitsem */ - { 0 ], /* recvsem */ + { 0 }, /* recvsem */ { { 0 }, /* xmit.sem */ 0, /* xmit.head */ @@ -246,7 +246,7 @@ static ubyte z16f_disableuartirq(struct uart_dev_s *dev) { struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv; irqstate_t flags = irqsave(); - ubyte state = priv->rxdisabed ? 0 : 1 | priv->txdisabled ? 0 : 2; + ubyte state = priv->rxenabled ? 1 : 0 | priv->txenabled ? 2 : 0; z16f_txint(dev, FALSE); z16f_rxint(dev, FALSE); @@ -268,20 +268,19 @@ static void z16f_restoreuartirq(struct uart_dev_s *dev, ubyte state) z16f_rxint(dev, (state & 1) ? TRUE : FALSE); irqrestore(flags); - return state; } /**************************************************************************** * Name: z16f_waittx ****************************************************************************/ -static void z16f_waittx(struct z16f_uart_s *priv, void (*status)(struct z16f_uart_s *)) +static void z16f_waittx(struct uart_dev_s *dev, boolean (*status)(struct uart_dev_s *)) { int tmp; for (tmp = 1000 ; tmp > 0 ; tmp--) { - if (status(priv) != 0) + if (status(dev)) { break; } @@ -374,7 +373,7 @@ static void z16f_shutdown(struct uart_dev_s *dev) static int z16f_attach(struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; + struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv; int ret; /* Attach the RX IRQ */ @@ -412,7 +411,7 @@ errout: static void z16f_detach(struct uart_dev_s *dev) { - struct up_dev_s *priv = (struct up_dev_s*)dev->priv; + struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv; up_disable_irq(priv->rxirq); up_disable_irq(priv->txirq); irq_detach(priv->rxirq); @@ -465,6 +464,7 @@ static int z16f_rxinterrupt(int irq, void *context) uart_recvchars(dev); } + return OK; } /**************************************************************************** @@ -506,6 +506,7 @@ static int z16f_txinterrupt(int irq, void *context) uart_xmitchars(dev); } + return OK; } /**************************************************************************** @@ -567,9 +568,8 @@ static void z16f_rxint(struct uart_dev_s *dev, boolean enable) { up_disable_irq(priv->rxirq); } -#endif - priv->rxenable = enable; + priv->rxenabled = enable; irqrestore(flags); } @@ -625,7 +625,7 @@ static void z16f_txint(struct uart_dev_s *dev, boolean enable) up_disable_irq(priv->txirq); } - priv->txenable = enable; + priv->txenabled = enable; irqrestore(flags); } @@ -673,15 +673,15 @@ static boolean z16f_txempty(struct uart_dev_s *dev) void up_earlyserialinit(void) { - (void)z16f_disableuartirq(TTYS0_DEV); - (void)z16f_disableuartirq(TTYS1_DEV); + (void)z16f_disableuartirq(&TTYS0_DEV); + (void)z16f_disableuartirq(&TTYS1_DEV); CONSOLE_DEV.isconsole = TRUE; z16f_setup(&CONSOLE_DEV); } /**************************************************************************** - * Name: z16f_serialinit + * Name: up_serialinit * * Description: * Register serial console and serial ports. This assumes @@ -689,7 +689,7 @@ void up_earlyserialinit(void) * ****************************************************************************/ -void z16f_serialinit(void) +void up_serialinit(void) { (void)uart_register("/dev/console", &CONSOLE_DEV); (void)uart_register("/dev/ttyS0", &TTYS0_DEV); @@ -722,21 +722,21 @@ int up_putc(int ch) { /* Add CR before LF */ - z16f_waittx(priv, z16f_txready); + z16f_waittx(&CONSOLE_DEV, z16f_txready); putreg8('\r', priv->uartbase + Z16F_UART_TXD); } /* Output the character */ - z16f_waittx(priv, z16f_txready); + z16f_waittx(&CONSOLE_DEV, z16f_txready); putreg8((ubyte)ch, priv->uartbase + Z16F_UART_TXD); /* Now wait for all queue TX data to drain before restoring interrupts. The * driver should receive one txdone interrupt which it may or may not ignore. */ - z16f_waittx(priv, z16f_txempty); - z16f_restoreuartirq(priv, state); + z16f_waittx(&CONSOLE_DEV, z16f_txempty); + z16f_restoreuartirq(&CONSOLE_DEV, state); return ch; } @@ -775,17 +775,18 @@ static void _up_putc(int ch) int up_putc(int ch) { - _up_putc(ch); - /* Check for LF */ if (ch == '\n') { - /* Add CR */ + /* Output CR before LF */ _up_putc('\r'); } + /* Output character */ + + _up_putc(ch); return ch; }