From 9b04ee217e0705cd27b30750257cac3942bba87d Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 18 Oct 2009 13:52:21 +0000 Subject: [PATCH] Move some drivers to separate subdirectories git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2156 42af7a65-404d-4744-a932-0658087f49c3 --- Documentation/README.html | 2 ++ README.txt | 2 ++ drivers/Makefile | 23 +++++++++---- drivers/README.txt | 56 +++++++++++++++++++++++++++++++ drivers/pipes/Make.defs | 41 ++++++++++++++++++++++ drivers/{ => pipes}/fifo.c | 4 +-- drivers/{ => pipes}/pipe.c | 2 +- drivers/{ => pipes}/pipe_common.c | 2 +- drivers/{ => pipes}/pipe_common.h | 4 +-- drivers/serial/Make.defs | 41 ++++++++++++++++++++++ drivers/{ => serial}/lowconsole.c | 2 +- drivers/{ => serial}/serial.c | 2 +- drivers/{ => serial}/serialirq.c | 2 +- include/nuttx/ioctl.h | 55 +++++++++++++++++++----------- include/nuttx/lib.h | 11 +++--- 15 files changed, 210 insertions(+), 39 deletions(-) create mode 100644 drivers/README.txt create mode 100644 drivers/pipes/Make.defs rename drivers/{ => pipes}/fifo.c (98%) rename drivers/{ => pipes}/pipe.c (99%) rename drivers/{ => pipes}/pipe_common.c (99%) rename drivers/{ => pipes}/pipe_common.h (98%) create mode 100644 drivers/serial/Make.defs rename drivers/{ => serial}/lowconsole.c (99%) mode change 100755 => 100644 rename drivers/{ => serial}/serial.c (99%) rename drivers/{ => serial}/serialirq.c (99%) diff --git a/Documentation/README.html b/Documentation/README.html index 025bd273f3..8a727506e4 100755 --- a/Documentation/README.html +++ b/Documentation/README.html @@ -123,6 +123,8 @@ | | |- ostest/README.txt | | `- README.txt | `- README.txt + |- drivers/ + | `- README.txt |- examples/ | |- nsh/README.txt | |- pashello/README.txt diff --git a/README.txt b/README.txt index c8ce9a978f..51cb912779 100755 --- a/README.txt +++ b/README.txt @@ -103,6 +103,8 @@ is a guide to the available README files: | | |- ostest/README.txt | | `- README.txt | `- README.txt + |- drivers/ + | `- README.txt |- examples/ | |- nsh/README.txt | |- pashello/README.txt diff --git a/drivers/Makefile b/drivers/Makefile index ad9dcaa0fb..9155aedc11 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -39,12 +39,24 @@ ifeq ($(WINTOOL),y) INCDIROPT = -w endif +ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) +include serial/Make.defs +ROOTDEPPATH = --dep-path . +SERIALDEPPATH = --dep-path serial +endif + ifeq ($(CONFIG_NET),y) include net/Make.defs ROOTDEPPATH = --dep-path . NETDEPPATH = --dep-path net endif +ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) +include pipes/Make.defs +ROOTDEPPATH = --dep-path . +PIPEDEPPATH = --dep-path pipes +endif + ifeq ($(CONFIG_USBDEV),y) include usbdev/Make.defs ROOTDEPPATH = --dep-path . @@ -66,18 +78,17 @@ CFLAGS += ${shell $(TOPDIR)/tools/incdir.sh $(INCDIROPT) "$(CC)" $(TOPDIR)/driv endif endif -ASRCS = $(NET_ASRCS) $(USBDEV_ASRCS) $(MMCSD_ASRCS) $(BCH_ASRCS) +ASRCS = $(SERIAL_ASRCS) $(NET_ASRCS) $(PIPE_ASRCS) $(USBDEV_ASRCS) $(MMCSD_ASRCS) $(BCH_ASRCS) AOBJS = $(ASRCS:.S=$(OBJEXT)) CSRCS = ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) -CSRCS += dev_null.c dev_zero.c pipe.c fifo.c pipe_common.c \ - loop.c serial.c serialirq.c lowconsole.c can.c +CSRCS += dev_null.c dev_zero.c loop.c can.c ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y) CSRCS += ramdisk.c endif endif -CSRCS += $(NET_CSRCS) $(USBDEV_CSRCS) $(MMCSD_CSRCS) $(BCH_CSRCS) +CSRCS += $(SERIAL_CSRCS) $(NET_CSRCS) $(PIPE_CSRCS) $(USBDEV_CSRCS) $(MMCSD_CSRCS) $(BCH_CSRCS) COBJS = $(CSRCS:.c=$(OBJEXT)) SRCS = $(ASRCS) $(CSRCS) @@ -85,7 +96,7 @@ OBJS = $(AOBJS) $(COBJS) BIN = libdrivers$(LIBEXT) -VPATH = net:usbdev:mmcsd:bch +VPATH = serial:net:pipes:usbdev:mmcsd:bch all: $(BIN) @@ -101,7 +112,7 @@ $(BIN): $(OBJS) done ; ) .depend: Makefile $(SRCS) - @$(MKDEP) $(ROOTDEPPATH) $(NETDEPPATH) $(USBDEVDEPPATH) $(MMCSDDEPPATH) $(BCHDEPPATH) \ + @$(MKDEP) $(ROOTDEPPATH) $(SERIALDEPPATH) $(NETDEPPATH) $(PIPEDEPPATH)$(USBDEVDEPPATH) $(MMCSDDEPPATH) $(BCHDEPPATH) \ $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep @touch $@ diff --git a/drivers/README.txt b/drivers/README.txt new file mode 100644 index 0000000000..c7e42c9a7e --- /dev/null +++ b/drivers/README.txt @@ -0,0 +1,56 @@ +README +^^^^^^ + +This directory contains various device drivers -- both block and +character drivers as well as other more specialized drivers. + +Files in this directory: +^^^^^^^^^^^^^^^^^^^^^^^ + +can.c + An unfinished CAN driver. + +dev_null.c and dev_zero.c + These files provide the standard /dev/null and /dev/zero devices. + See include/nuttx/fs.h for functions that should be called if you + want to register these devices (devnull_register() and + devzero_register()). + +loop.c + Supports the standard loop device that can be used to export a + file (or character device) as a block device. See losetup() and + loteardown() in include/nuttx/fs.h. + +ramdisk.c + Can be used to set up a block of memory or (read-only) FLASH as + a block driver that can be mounted as a files system. See + include/nuttx/ramdisk.h. + +Subdirectories of this directory: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +bch/ + Contains logic that may be used to convert a block driver into + a character driver. This is the complementary conversion as that + performed by loop.c. See include/nuttx/fs.h for registration + information. + +mmcsd/ + Support for MMC/SD block drivers. At present, only SPI-based + MMC/SD is supported. See include/nuttx/mmcsd.h. + +net/ + Network interface drivers. See also include/nuttx/net.h + +pipes/ + FIFO and named pipe drivers. Standard interfaces are declared + in include/unistd.h + +serial/ + Front-ends character drivers for chip-specific UARTs. This provide + some TTY-like functionality and are commonly used (but not required for) + the NuttX system console. See include/nuttx/serial.h + +usbdev/ + USB device drivers. See include/nuttx/usb*.h + diff --git a/drivers/pipes/Make.defs b/drivers/pipes/Make.defs new file mode 100644 index 0000000000..be16366bbe --- /dev/null +++ b/drivers/pipes/Make.defs @@ -0,0 +1,41 @@ +############################################################################ +# drivers/pipes/Make.defs +# +# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +PIPE_ASRCS = +ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) +PIPE_CSRCS = pipe.c fifo.c pipe_common.c +else +PIPE_CSRCS = +endif diff --git a/drivers/fifo.c b/drivers/pipes/fifo.c similarity index 98% rename from drivers/fifo.c rename to drivers/pipes/fifo.c index 4e0bbf49ce..bc9f629f50 100644 --- a/drivers/fifo.c +++ b/drivers/pipes/fifo.c @@ -1,7 +1,7 @@ /**************************************************************************** - * drivers/fifo.c + * drivers/pipes/fifo.c * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/pipe.c b/drivers/pipes/pipe.c similarity index 99% rename from drivers/pipe.c rename to drivers/pipes/pipe.c index 4b052e40f5..95049b354e 100644 --- a/drivers/pipe.c +++ b/drivers/pipes/pipe.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/pipe.c + * drivers/pipes/pipe.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/drivers/pipe_common.c b/drivers/pipes/pipe_common.c similarity index 99% rename from drivers/pipe_common.c rename to drivers/pipes/pipe_common.c index a0fd00b7a4..60d028c000 100644 --- a/drivers/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/pipe_common.c + * drivers/pipes/pipe_common.c * * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/drivers/pipe_common.h b/drivers/pipes/pipe_common.h similarity index 98% rename from drivers/pipe_common.h rename to drivers/pipes/pipe_common.h index 56fa4865b0..9e9f27fc1f 100644 --- a/drivers/pipe_common.h +++ b/drivers/pipes/pipe_common.h @@ -1,7 +1,7 @@ /**************************************************************************** - * drivers/pipe_common.h + * drivers/pipe/pipe_common.h * - * Copyright (C) 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2008i-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without diff --git a/drivers/serial/Make.defs b/drivers/serial/Make.defs new file mode 100644 index 0000000000..089e797d41 --- /dev/null +++ b/drivers/serial/Make.defs @@ -0,0 +1,41 @@ +############################################################################ +# drivers/serial/Make.defs +# +# Copyright (C) 2009 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +SERIAL_ASRCS = +ifneq ($(CONFIG_NFILE_DESCRIPTORS),0) +SERIAL_CSRCS = serial.c serialirq.c lowconsole.c +else +SERIAL_CSRCS = +endif diff --git a/drivers/lowconsole.c b/drivers/serial/lowconsole.c old mode 100755 new mode 100644 similarity index 99% rename from drivers/lowconsole.c rename to drivers/serial/lowconsole.c index 15f639391a..1de76cc06a --- a/drivers/lowconsole.c +++ b/drivers/serial/lowconsole.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/lowconsole.c + * drivers/serial/lowconsole.c * * Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/drivers/serial.c b/drivers/serial/serial.c similarity index 99% rename from drivers/serial.c rename to drivers/serial/serial.c index a7cb42b208..df942a0507 100644 --- a/drivers/serial.c +++ b/drivers/serial/serial.c @@ -1,5 +1,5 @@ /************************************************************************************ - * drivers/serial.c + * drivers/serial/serial.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/drivers/serialirq.c b/drivers/serial/serialirq.c similarity index 99% rename from drivers/serialirq.c rename to drivers/serial/serialirq.c index d1a18b2579..a4ce80944d 100644 --- a/drivers/serialirq.c +++ b/drivers/serial/serialirq.c @@ -1,5 +1,5 @@ /************************************************************************************ - * drivers/serialirq.c + * drivers/serial/serialirq.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt diff --git a/include/nuttx/ioctl.h b/include/nuttx/ioctl.h index 7d35548b24..670d753042 100644 --- a/include/nuttx/ioctl.h +++ b/include/nuttx/ioctl.h @@ -55,8 +55,9 @@ #define _FIOCBASE (0x8700) /* File system ioctl commands */ #define _DIOCBASE (0x8800) /* Character driver ioctl commands */ #define _BIOCBASE (0x8900) /* Block driver ioctl commands */ -#define _SIOCBASE (0x8a00) /* Socket ioctl commandss */ -#define _ARPBASE (0x8b00) /* ARP ioctl commandss */ +#define _MTDIOCBASE (0x8a00) /* MTD ioctl commands */ +#define _SIOCBASE (0x8b00) /* Socket ioctl commandss */ +#define _ARPBASE (0x8c00) /* ARP ioctl commandss */ /* Macros used to manage ioctl commands */ @@ -71,35 +72,49 @@ #define _FIOCVALID(c) (_IOC_TYPE(c)==_FIOCBASE) #define _FIOC(nr) _IOC(_FIOCBASE,nr) -#define FIOC_MMAP _FIOC(0x0001) /* IN: Location to return address (void **) - * OUT: If media is directly acccesible, - * return (void*) base address - * of file - */ +#define FIOC_MMAP _FIOC(0x0001) /* IN: Location to return address (void **) + * OUT: If media is directly acccesible, + * return (void*) base address + * of file + */ /* NuttX file system ioctl definitions */ #define _DIOCVALID(c) (_IOC_TYPE(c)==_DIOCBASE) #define _DIOC(nr) _IOC(_DIOCBASE,nr) -#define DIOC_GETPRIV _DIOC(0x0001) /* IN: Location to return handle (void **) - * OUT: Reference to internal data - * structure. May have a reference - * incremented. - */ -#define DIOC_RELPRIV _DIOC(0x0003) /* IN: None - * OUT: None, reference obtained by - * FIOC_GETPRIV released. - */ +#define DIOC_GETPRIV _DIOC(0x0001) /* IN: Location to return handle (void **) + * OUT: Reference to internal data + * structure. May have a reference + * incremented. + */ +#define DIOC_RELPRIV _DIOC(0x0003) /* IN: None + * OUT: None, reference obtained by + * FIOC_GETPRIV released. + */ /* NuttX block driver ioctl definitions */ #define _BIOCVALID(c) (_IOC_TYPE(c)==_BIOCBASE) #define _BIOC(nr) _IOC(_BIOCBASE,nr) -#define BIOC_XIPBASE _BIOC(0x0001) /* IN: None - * OUT: If media is directly acccesible, - * return (void*) base address - * of device memory */ +#define BIOC_XIPBASE _BIOC(0x0001) /* IN: None + * OUT: If media is directly acccesible, + * return (void*) base address + * of device memory */ + +/* NuttX MTD driver ioctl definitions */ + +#define _MTDIOCVALID(c) (_IOC_TYPE(c)==_MTDIOCBASE) +#define _MTDIOC(nr) _IOC(_MTDIOCBASE,nr) + +#define MTDIOC_GEOMETRY _MTDIOC(0x0001) /* IN: Pointer to write-able struct + * mtd_geometry_s (see mtd.h) + * OUT: Geometry structure is populated + * with data for the MTD */ +#define MTDIOC_XIPBASE _MTDIOC(0x0002) /* IN: None + * OUT: If media is directly acccesible, + * return (void*) base address + * of device memory */ /* NuttX ARP driver ioctl definitions (see netinet/arp.h) */ diff --git a/include/nuttx/lib.h b/include/nuttx/lib.h index cb11ae782a..3c74257d4e 100644 --- a/include/nuttx/lib.h +++ b/include/nuttx/lib.h @@ -49,12 +49,10 @@ ****************************************************************************/ /**************************************************************************** - * Global Function Prototypes + * Public Data ****************************************************************************/ -/**************************************************************************** - * Global Function Prototypes - ****************************************************************************/ +#ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" @@ -63,6 +61,10 @@ extern "C" { #define EXTERN extern #endif +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + /* Functions contained in lib_init.c ****************************************/ EXTERN void weak_function lib_initialize(void); @@ -77,4 +79,5 @@ EXTERN void lib_releaselist(FAR struct streamlist *list); } #endif +#endif /* __ASSEMBLY__ */ #endif /* __LIB_H */