Nut/OS  4.10.3
API Reference
unix_devs.h
Go to the documentation of this file.
00001 #ifndef _DEV_UNIX_DEVS_H_
00002 #define _DEV_UNIX_DEVS_H_
00003 
00004 
00005 /*
00006  * Copyright (C) 2000-2004 by ETH Zurich
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. Neither the name of the copyright holders nor the names of
00018  *    contributors may be used to endorse or promote products derived
00019  *    from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY ETH ZURICH AND CONTRIBUTORS
00022  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ETH ZURICH
00025  *  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00028  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00029  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00031  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * For additional information see http://www.ethernut.de/
00035  *
00036  */
00037 
00038 /* unix_devs.h - a nut/os device driver for native unix devices
00039  *
00040  * 2004.04.01 Matthias Ringwald <matthias.ringwald@inf.ethz.ch>
00041  *
00042  */
00043 
00044 /*
00045  * $Log$
00046  * Revision 1.9  2008/08/11 06:59:59  haraldkipp
00047  * BSD types replaced by stdint types (feature request #1282721).
00048  *
00049  * Revision 1.8  2005/08/02 17:46:48  haraldkipp
00050  * Major API documentation update.
00051  *
00052  * Revision 1.7  2005/04/04 19:35:06  freckle
00053  * added socket redirection feature for unix emulation uarts. Every nut/os
00054  * uart device can now be mapped to a TCP/IP socket using the
00055  * "-u{0/1/2} hostname:port" command line option
00056  *
00057  * Revision 1.6  2004/08/09 21:31:30  freckle
00058  * Added include/dev/unix_devs.h changes
00059  *
00060  * Revision 1.5  2004/08/05 12:13:56  freckle
00061  * Added unix emulation hook in NutThreadYield to safely process
00062  * NutPostEventAsync calls occuring in non Nut/OS threads.
00063  * Rewrote the unix read function again using the new unix NutThreadYield hook
00064  * to call the NutPostEventAsync function safely (fast & correct).
00065  * _write(nf, 0, 0) aka fflush is ignored on unix emulation.
00066  *
00067  * Revision 1.4  2004/06/22 09:00:00  freckle
00068  * Further work on unix_dev emulation. Multiple parallel reads don't block
00069  * each other. Still, dead-locks occure.
00070  * STDIO is set to non-blocking.
00071  *
00072  * Revision 1.3  2004/06/21 10:57:25  freckle
00073  * dev/unix_devs.c: read operation is using extra pthread to only block the
00074  * current thread instead of all threads
00075  *
00076  * Revision 1.2  2004/04/16 17:50:35  freckle
00077  * Implemented the most common _IOCTL calls
00078  * Added block read functionality to read call
00079  *
00080  * Revision 1.1  2004/04/07 12:13:57  haraldkipp
00081  * Matthias Ringwald's *nix emulation added
00082  *
00083  */
00084 
00085 #include <pthread.h>
00086 #include <sys/device.h>
00087 #include <dev/netbuf.h>
00088 
00089 #ifdef __cplusplus
00090 extern "C" {
00091 #endif
00092 
00097 
00098 // int UnixDevIOCTL(NUTDEVICE * dev, int req, void *conf);
00099 
00100 /*
00101  * Available devices.
00102  */
00103     extern NUTDEVICE devUart0;
00104     extern NUTDEVICE devUart1;
00105     extern NUTDEVICE devUart2;
00106     extern NUTDEVICE devUsartAvr0;
00107     extern NUTDEVICE devUsartAvr1;
00108     extern NUTDEVICE devUsartAvr2;
00109     extern NUTDEVICE devDebug0;
00110     extern NUTDEVICE devDebug1;
00111     extern NUTDEVICE devDebug2;
00112 
00118 struct _UNIXDCB {
00119 
00122     uint32_t dcb_modeflags;
00123 
00126     uint32_t dcb_statusflags;
00127 
00130     uint32_t dcb_rtimeout;
00131 
00134     uint32_t dcb_wtimeout;
00135 
00138     uint8_t dcb_last_eol;
00139 
00142     int dcb_fd;
00143     
00146         uint8_t dcb_socket;
00147 
00150     HANDLE dcb_rx_rdy;
00151     
00154     pthread_mutex_t dcb_rx_mutex;
00155 
00158     pthread_cond_t dcb_rx_trigger;
00159 
00160 };
00161 
00165     typedef struct _UNIXDCB UNIXDCB;
00166 
00171 #ifdef __cplusplus
00172 }
00173 #endif
00174 #endif