From 16aff5292e5b87484ad8f334eeb5fa3c8e1675d6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 28 Jan 2008 22:03:49 +0000 Subject: [PATCH] Basic Z16F serial driver functionality git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@577 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/c5471/c5471_serial.c | 2 +- arch/arm/src/dm320/dm320_serial.c | 2 +- arch/c5471/src/up_serial.c | 2 +- arch/dm320/src/up_serial.c | 2 +- arch/z16/src/z16f/chip.h | 12 +++++------ arch/z16/src/z16f/z16f_head.S | 7 ++---- arch/z16/src/z16f/z16f_serial.c | 2 +- drivers/serial.c | 2 +- include/nuttx/fs.h | 36 ++++++++++++++++++------------- include/nuttx/serial.h | 6 +++--- 10 files changed, 38 insertions(+), 35 deletions(-) diff --git a/arch/arm/src/c5471/c5471_serial.c b/arch/arm/src/c5471/c5471_serial.c index 22ce3c0637..9ff5b5be9f 100644 --- a/arch/arm/src/c5471/c5471_serial.c +++ b/arch/arm/src/c5471/c5471_serial.c @@ -355,7 +355,7 @@ static inline void up_setrate(struct up_dev_s *priv, unsigned int rate) static int up_setup(struct uart_dev_s *dev) { -#ifdef CONFIG_SUPPRESS_UART_CONFIG +#ifndef CONFIG_SUPPRESS_UART_CONFIG struct up_dev_s *priv = dev->priv; unsigned int cval; diff --git a/arch/arm/src/dm320/dm320_serial.c b/arch/arm/src/dm320/dm320_serial.c index 2eea71dd0c..4f90fd5d31 100644 --- a/arch/arm/src/dm320/dm320_serial.c +++ b/arch/arm/src/dm320/dm320_serial.c @@ -286,7 +286,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, boolean enable) static int up_setup(struct uart_dev_s *dev) { -#ifdef CONFIG_SUPPRESS_UART_CONFIG +#ifndef CONFIG_SUPPRESS_UART_CONFIG struct up_dev_s *priv = (struct up_dev_s*)dev->priv; uint16 brsr; diff --git a/arch/c5471/src/up_serial.c b/arch/c5471/src/up_serial.c index 6a069164dd..3cba4a2d88 100644 --- a/arch/c5471/src/up_serial.c +++ b/arch/c5471/src/up_serial.c @@ -352,7 +352,7 @@ static inline void up_setrate(struct up_dev_s *priv, unsigned int rate) static int up_setup(struct uart_dev_s *dev) { -#ifdef CONFIG_SUPPRESS_UART_CONFIG +#ifndef CONFIG_SUPPRESS_UART_CONFIG struct up_dev_s *priv = dev->priv; unsigned int cval; diff --git a/arch/dm320/src/up_serial.c b/arch/dm320/src/up_serial.c index c952c159f2..3d7c098373 100644 --- a/arch/dm320/src/up_serial.c +++ b/arch/dm320/src/up_serial.c @@ -281,7 +281,7 @@ static inline void up_enablebreaks(struct up_dev_s *priv, boolean enable) static int up_setup(struct uart_dev_s *dev) { -#ifdef CONFIG_SUPPRESS_UART_CONFIG +#ifndef CONFIG_SUPPRESS_UART_CONFIG struct up_dev_s *priv = (struct up_dev_s*)dev->priv; uint16 brsr; diff --git a/arch/z16/src/z16f/chip.h b/arch/z16/src/z16f/chip.h index bcfff92798..f43a653927 100644 --- a/arch/z16/src/z16f/chip.h +++ b/arch/z16/src/z16f/chip.h @@ -517,12 +517,12 @@ /* Register access macros ***********************************************************/ #ifndef __ASSEMBLY__ -# define getreg8(a) (*(ubyte volatile _Near*)((a) & 0xffff)) -# define putreg8(v,a) (*(ubyte volatile _Near*)((a) & 0xffff) = (v)) -# define getreg16(a) (*(uint16 volatile _Near*)((a) & 0xffff)) -# define putreg16(v,a) (*(uint16 volatile _Near*)((a) & 0xffff) = (v)) -# define getreg32(a) (*(uint32 volatile _Near*)((a) & 0xffff)) -# define putreg32(v,a) (*(uint32 volatile _Near*)((a) & 0xffff) = (v)) +# define getreg8(a) (*(ubyte volatile _Near*)(a)) +# define putreg8(v,a) (*(ubyte volatile _Near*)(a) = (v)) +# define getreg16(a) (*(uint16 volatile _Near*)(a)) +# define putreg16(v,a) (*(uint16 volatile _Near*)(a) = (v)) +# define getreg32(a) (*(uint32 volatile _Near*)(a)) +# define putreg32(v,a) (*(uint32 volatile _Near*)(a) = (v)) #endif /* __ASSEMBLY__ */ /************************************************************************************ diff --git a/arch/z16/src/z16f/z16f_head.S b/arch/z16/src/z16f/z16f_head.S index 7e0682e76b..f6108c250a 100755 --- a/arch/z16/src/z16f/z16f_head.S +++ b/arch/z16/src/z16f/z16f_head.S @@ -50,14 +50,11 @@ #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) +#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_ARCH_LOWGETC) || CONFIG_NFILE_DESCRIPTORS == 0 xref _z16f_lowuartinit:EROM #endif #if defined(CONFIG_DEV_CONSOLE) && CONFIG_NFILE_DESCRIPTORS > 0 - xref up_earlyserialinit:EROM + xref _up_earlyserialinit:EROM #endif xref _os_start:EROM xref _up_doirq:EROM diff --git a/arch/z16/src/z16f/z16f_serial.c b/arch/z16/src/z16f/z16f_serial.c index fb92919b17..63f40f62a2 100644 --- a/arch/z16/src/z16f/z16f_serial.c +++ b/arch/z16/src/z16f/z16f_serial.c @@ -298,7 +298,7 @@ static void z16f_waittx(struct uart_dev_s *dev, boolean (*status)(struct uart_de static int z16f_setup(struct uart_dev_s *dev) { -#ifdef CONFIG_SUPPRESS_UART_CONFIG +#ifndef CONFIG_SUPPRESS_UART_CONFIG struct z16f_uart_s *priv = (struct z16f_uart_s*)dev->priv; uint32 brg; ubyte ctl0; diff --git a/drivers/serial.c b/drivers/serial.c index 3d805e7a29..153ee431dd 100644 --- a/drivers/serial.c +++ b/drivers/serial.c @@ -379,7 +379,7 @@ static int uart_close(struct file *filep) static int uart_open(struct file *filep) { struct inode *inode = filep->f_inode; - uart_dev_t *dev = inode->i_private; + uart_dev_t *dev = inode->i_private; int ret = OK; /* If the port is the middle of closing, wait until the close is finished */ diff --git a/include/nuttx/fs.h b/include/nuttx/fs.h index 73c5096292..111f472189 100644 --- a/include/nuttx/fs.h +++ b/include/nuttx/fs.h @@ -177,27 +177,33 @@ struct mountpt_operations }; #endif /* CONFIG_DISABLE_MOUNTPOUNT */ +/* These are the various kinds of operations that can be associated with + * an inode. + */ + +union inode_ops_u +{ + FAR const struct file_operations *i_ops; /* Driver operations for inode */ +#ifndef CONFIG_DISABLE_MOUNTPOUNT + FAR const struct block_operations *i_bops; /* Block driver operations */ + FAR const struct mountpt_operations *i_mops; /* Operations on a mountpoint */ +#endif +}; + /* This structure represents one inode in the Nuttx psuedo-file system */ struct inode { - FAR struct inode *i_peer; /* Pointer to same level inode */ - FAR struct inode *i_child; /* Pointer to lower level inode */ - sint16 i_crefs; /* References to inode */ - uint16 i_flags; /* flags for inode */ - union - { - const struct file_operations *i_ops; /* Driver operations for inode */ -#ifndef CONFIG_DISABLE_MOUNTPOUNT - const struct block_operations *i_bops; /* Block driver operations */ - const struct mountpt_operations *i_mops; /* Operations on a mountpoint */ -#endif - } u; + FAR struct inode *i_peer; /* Pointer to same level inode */ + FAR struct inode *i_child; /* Pointer to lower level inode */ + sint16 i_crefs; /* References to inode */ + uint16 i_flags; /* Flags for inode */ + union inode_ops_u u; /* Inode operations */ #ifdef CONFIG_FILE_MODE - mode_t i_mode; /* Access mode flags */ + mode_t i_mode; /* Access mode flags */ #endif - FAR void *i_private; /* Per inode driver private data */ - char i_name[1]; /* Name of inode (variable) */ + FAR void *i_private; /* Per inode driver private data */ + char i_name[1]; /* Name of inode (variable) */ }; #define FSNODE_SIZE(n) (sizeof(struct inode) + (n)) diff --git a/include/nuttx/serial.h b/include/nuttx/serial.h index 46da7800cd..7741b9983d 100644 --- a/include/nuttx/serial.h +++ b/include/nuttx/serial.h @@ -180,7 +180,7 @@ struct uart_ops_s struct uart_dev_s { int open_count; /* The number of times - * the device has been opened */ + * the device has been opened */ boolean xmitwaiting; /* TRUE: User is waiting * for space in xmit.buffer */ boolean recvwaiting; /* TRUE: User is waiting @@ -194,8 +194,8 @@ struct uart_dev_s * for sapce in recv.buffer */ struct uart_buffer_s xmit; /* Describes transmit buffer */ struct uart_buffer_s recv; /* Describes receive buffer */ - const struct uart_ops_s *ops; /* Arch-specifics operations */ - void *priv; /* Used by the arch-specific logic */ + FAR const struct uart_ops_s *ops; /* Arch-specific operations */ + FAR void *priv; /* Used by the arch-specific logic */ }; typedef struct uart_dev_s uart_dev_t;