fp@0: /** fp@0: * rt_com fp@0: * ====== fp@0: * fp@0: * RT-Linux kernel module for communication across serial lines. fp@0: * fp@0: * Copyright (C) 1997 Jens Michaelsen fp@0: * Copyright (C) 1997-2000 Jochen Kupper fp@0: * Copyright (C) 1999 Hua Mao fp@0: * fp@0: * This program is free software; you can redistribute it and/or fp@0: * modify it under the terms of the GNU General Public License as fp@0: * published by the Free Software Foundation; either version 2 of the fp@0: * License, or (at your option) any later version. fp@0: * fp@0: * This program is distributed in the hope that it will be useful, but fp@0: * WITHOUT ANY WARRANTY; without even the implied warranty of fp@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU fp@0: * General Public License for more details. fp@0: * fp@0: * You should have received a copy of the GNU General Public License fp@0: * along with this program; see the file License. if not, write to the fp@0: * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, fp@0: * MA 02111-1307, USA. fp@0: */ fp@0: fp@0: fp@0: fp@0: #ifndef AIP_COM_P_H fp@0: #define AIP_COM_P_H fp@0: fp@0: fp@0: #define RT_COM_NAME "rt_com(aip)" //Hm, IgH fp@0: fp@0: /* input/ouput buffer (FIFO) sizes */ fp@0: #define RT_COM_BUF_SIZ 256 // MUST BE ONLY POWER OF 2 !! fp@0: /* amount of free space on input buffer for RTS reset */ fp@0: #define RT_COM_BUF_LOW (RT_COM_BUF_SIZ / 3) fp@0: /* amount of free space on input buffer for RTS set */ fp@0: #define RT_COM_BUF_HI (RT_COM_BUF_SIZ * 2 / 3) fp@0: /* limit of free space on input buffer for buffer full error */ fp@0: #define RT_COM_BUF_FULL 20 fp@0: fp@0: fp@0: /* usage flags */ fp@0: #define RT_COM_PORT_FREE 0x00 fp@0: #define RT_COM_PORT_INUSE 0x01 fp@0: #define RT_COM_PORT_SETUP 0x02 fp@0: fp@0: fp@0: /* Some hardware description */ fp@0: #define RT_COM_BASE_BAUD 115200 fp@0: fp@0: /** Interrupt Service Routines fp@0: * These are private functions */ fp@0: static void rt_com0_isr( void ); fp@0: static void rt_com1_isr( void ); fp@0: fp@0: fp@0: fp@0: fp@0: /** Interrupt handling fp@0: * fp@0: * Define internal convinience macros for interrupt handling, so we fp@0: * get rid of the system dependencies. fp@0: */ fp@0: //#define rt_com_irq_off( state ) do{}while(0) //rt_global_save_flags( &state ); rt_global_cli() schreiben und lesen sowieso in IRQ Hm fp@0: //#define rt_com_irq_on(state) do{}while(0) //rt_global_restore_flags( state ) fp@0: #define rt_com_irq_off( state ) rt_global_save_flags( &state ); rt_global_cli() fp@0: #define rt_com_irq_on(state) rt_global_restore_flags( state ) fp@0: #define rt_com_request_irq( irq, isr ) rt_request_global_irq( irq, isr ); rt_enable_irq( irq ); fp@0: #define rt_com_free_irq( irq ) rt_free_global_irq( irq ) fp@0: fp@0: fp@0: /* port register offsets */ fp@0: #define RT_COM_RXB 0x00 fp@0: #define RT_COM_TXB 0x00 fp@0: #define RT_COM_IER 0x01 fp@0: #define RT_COM_IIR 0x02 fp@0: #define RT_COM_FCR 0x02 fp@0: #define RT_COM_LCR 0x03 fp@0: #define RT_COM_MCR 0x04 fp@0: #define RT_COM_LSR 0x05 fp@0: #define RT_COM_MSR 0x06 fp@0: #define RT_COM_DLL 0x00 fp@0: #define RT_COM_DLM 0x01 fp@0: fp@0: /** MCR Modem Control Register masks */ fp@0: #define MCR_DTR 0x01 // Data Terminal Ready fp@0: #define MCR_RTS 0x02 // Request To Send fp@0: #define MCR_OUT1 0x04 fp@0: #define MCR_OUT2 0x08 fp@0: #define MCR_LOOP 0x10 fp@0: #define MCR_AFE 0x20 // AutoFlow Enable fp@0: fp@0: /** IER Interrupt Enable Register masks */ fp@0: #define IER_ERBI 0x01 // Enable Received Data Available Interrupt fp@0: #define IER_ETBEI 0x02 // Enable Transmitter Holding Register fp@0: // Empty Interrupt fp@0: #define IER_ELSI 0x04 // Enable Receiver Line Status Interrupt fp@0: #define IER_EDSSI 0x08 // Enable Modem Status Interrupt fp@0: fp@0: /** MSR Modem Status Register masks */ fp@0: #define MSR_DELTA_CTS 0x01 fp@0: #define MSR_DELTA_DSR 0x02 fp@0: #define MSR_TERI 0x04 fp@0: #define MSR_DELTA_DCD 0x08 fp@0: #define MSR_CTS 0x10 fp@0: #define MSR_DSR 0x20 fp@0: #define MSR_RI 0x40 fp@0: #define MSR_DCD 0x80 fp@0: fp@0: /** LSR Line Status Register masks */ fp@0: #define LSR_DATA_READY 0x01 fp@0: #define LSR_OVERRUN_ERR 0x02 fp@0: #define LSR_PARITY_ERR 0x04 fp@0: #define LSR_FRAMING_ERR 0x08 fp@0: #define LSR_BREAK 0x10 fp@0: #define LSR_THRE 0x20 // Transmitter Holding Register fp@0: #define LSR_TEMT 0x40 // Transmitter Empty fp@0: fp@0: /** FCR FIFO Control Register masks */ fp@0: #define FCR_FIFO_ENABLE 0x01 fp@0: #define FCR_INPUT_FIFO_RESET 0x02 fp@0: #define FCR_OUTPUT_FIFO_RESET 0x04 fp@0: fp@0: /** data buffer fp@0: * fp@0: * Used for buffering of input and output data. Two buffers per port fp@0: * (one for input, one for output). Organized as a FIFO */ fp@0: struct rt_buf_struct{ fp@0: unsigned int head; fp@0: unsigned int tail; fp@0: char buf[ RT_COM_BUF_SIZ ]; fp@0: }; fp@0: fp@0: fp@0: fp@0: /** Port data fp@0: * fp@0: * Internal information structure containing all data for a port. One fp@0: * structure for every port. fp@0: * fp@0: * Contains all current setup parameters and all data currently fp@0: * buffered by rt_com. fp@0: * fp@0: * mode (functioning mode) fp@0: * possible values: fp@0: * - RT_COM_DSR_ON_TX - for standard functioning mode (DSR needed on TX) fp@0: * - RT_COM_NO_HAND_SHAKE - for comunication without hand shake signals fp@0: * (only RXD-TXD-GND) fp@0: * - RT_COM_HW_FLOW - for hardware flow control (RTS-CTS) fp@0: * Of course RT_COM_DSR_ON_TX and RT_COM_NO_HAND_SHAKE cannot be fp@0: * sppecified at the same time. fp@0: * fp@0: * NOTE: When you select a mode that uses hand shake signals pay fp@0: * attention that no input signals (CTS,DSR,RI,DCD) must be fp@0: * floating. fp@0: * fp@0: * used (usage flag) fp@0: * possible values: fp@0: * - RT_COM_PORT_INUSE - port region requested by init_module fp@0: * - RT_COM_PORT_FREE - port region requested by rt_com_set_param fp@0: * - RT_COM_PORT_SETUP - port parameters are setup, fp@0: * don't specify at compile time ! fp@0: * fp@0: * error fp@0: * last error detected fp@0: * fp@0: * ier (interrupt enable register) fp@0: * copy of IER chip register, last value set by rt_com. fp@0: * fp@0: * mcr (modem control register) fp@0: * copy of the MCR internal register fp@0: */ fp@0: struct rt_com_struct{ fp@0: int baud_base; fp@0: int port; fp@0: int irq; fp@0: void (*isr)(void); fp@0: int baud; fp@0: unsigned int wordlength; fp@0: unsigned int parity; fp@0: unsigned int stopbits; fp@0: int mode; fp@0: int fifotrig; fp@0: int used; fp@0: int error; fp@0: int type; fp@0: int ier; fp@0: int mcr; fp@0: struct rt_buf_struct ibuf; fp@0: struct rt_buf_struct obuf; fp@0: }; fp@0: fp@0: fp@0: #endif /* RT_COM_P_H */ fp@0: fp@0: fp@0: fp@0: /** fp@0: * Local Variables: fp@0: * mode: C fp@0: * c-file-style: "Stroustrup" fp@0: * End: fp@0: */