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: unix_devs.h,v $
00046  * Revision 1.8  2005/08/02 17:46:48  haraldkipp
00047  * Major API documentation update.
00048  *
00049  * Revision 1.7  2005/04/04 19:35:06  freckle
00050  * added socket redirection feature for unix emulation uarts. Every nut/os
00051  * uart device can now be mapped to a TCP/IP socket using the
00052  * "-u{0/1/2} hostname:port" command line option
00053  *
00054  * Revision 1.6  2004/08/09 21:31:30  freckle
00055  * Added include/dev/unix_devs.h changes
00056  *
00057  * Revision 1.5  2004/08/05 12:13:56  freckle
00058  * Added unix emulation hook in NutThreadYield to safely process
00059  * NutPostEventAsync calls occuring in non Nut/OS threads.
00060  * Rewrote the unix read function again using the new unix NutThreadYield hook
00061  * to call the NutPostEventAsync function safely (fast & correct).
00062  * _write(nf, 0, 0) aka fflush is ignored on unix emulation.
00063  *
00064  * Revision 1.4  2004/06/22 09:00:00  freckle
00065  * Further work on unix_dev emulation. Multiple parallel reads don't block
00066  * each other. Still, dead-locks occure.
00067  * STDIO is set to non-blocking.
00068  *
00069  * Revision 1.3  2004/06/21 10:57:25  freckle
00070  * dev/unix_devs.c: read operation is using extra pthread to only block the
00071  * current thread instead of all threads
00072  *
00073  * Revision 1.2  2004/04/16 17:50:35  freckle
00074  * Implemented the most common _IOCTL calls
00075  * Added block read functionality to read call
00076  *
00077  * Revision 1.1  2004/04/07 12:13:57  haraldkipp
00078  * Matthias Ringwald's *nix emulation added
00079  *
00080  */
00081 
00082 #include <pthread.h>
00083 #include <sys/device.h>
00084 #include <dev/netbuf.h>
00085 
00086 #ifdef __cplusplus
00087 extern "C" {
00088 #endif
00089 
00094 
00095 // int UnixDevIOCTL(NUTDEVICE * dev, int req, void *conf);
00096 
00097 /*
00098  * Available devices.
00099  */
00100     extern NUTDEVICE devUart0;
00101     extern NUTDEVICE devUart1;
00102     extern NUTDEVICE devUart2;
00103     extern NUTDEVICE devUsartAvr0;
00104     extern NUTDEVICE devUsartAvr1;
00105     extern NUTDEVICE devUsartAvr2;
00106     extern NUTDEVICE devDebug0;
00107     extern NUTDEVICE devDebug1;
00108     extern NUTDEVICE devDebug2;
00109 
00115 struct _UNIXDCB {
00116 
00119     u_long dcb_modeflags;
00120 
00123     u_long dcb_statusflags;
00124 
00127     u_long dcb_rtimeout;
00128 
00131     u_long dcb_wtimeout;
00132 
00135     u_char dcb_last_eol;
00136 
00139     int dcb_fd;
00140     
00143     u_char dcb_socket;
00144 
00147     HANDLE dcb_rx_rdy;
00148     
00151     pthread_mutex_t dcb_rx_mutex;
00152 
00155     pthread_cond_t dcb_rx_trigger;
00156 
00157 };
00158 
00162     typedef struct _UNIXDCB UNIXDCB;
00163 
00168 #ifdef __cplusplus
00169 }
00170 #endif
00171 #endif

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/