Subversion Repositories shark

Rev

Rev 714 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
538 mauro 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/**
22
 ------------
23
 CVS :        $Id: scom.h,v 1.1 2004-03-29 18:31:42 mauro Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1 $
27
 Last update: $Date: 2004-03-29 18:31:42 $
28
 ------------
29
 
30
**/
31
 
32
/*
33
 * Copyright (C) 2000 Gerardo Lamastra
34
 *
35
 * This program is free software; you can redistribute it and/or modify
36
 * it under the terms of the GNU General Public License as published by
37
 * the Free Software Foundation; either version 2 of the License, or
38
 * (at your option) any later version.
39
 *
40
 * This program is distributed in the hope that it will be useful,
41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
43
 * GNU General Public License for more details.
44
 *
45
 * You should have received a copy of the GNU General Public License
46
 * along with this program; if not, write to the Free Software
47
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
48
 *
49
 */
50
 
51
/* Project:     HARTIK 3.0                                      */
52
/* Description: Hard Real TIme Kernel for 386 & higher machines */
53
/* Author:      Gerardo Lamastra                                */
54
/* Date:        9/5/96                                          */
55
 
56
/* File:        SCOM.H                                          */
57
/* Revision:    2.0                                             */
58
 
59
#ifndef __SCOM_H__
60
#define __SCOM_H__
61
 
62
#ifdef __cplusplus
63
extern "C" {
64
#endif
65
 
66
#include <modules/sem.h>
67
 
68
/* Number of available COM links */
69
#define COM_LINKS       4
70
 
71
#define COM1            0
72
#define COM2            1
73
#define COM3            2
74
#define COM4            3
75
 
76
/* These values identify interrupt type */
77
#define RX_FULL         1
78
#define TX_EMPTY        2
79
#define LS_CHANGED      4
80
#define MS_CHANGED      8
81
 
82
/* This is set when the channel is open */
83
#define LINK_BUSY       128
84
/* This is set if the fast handler is installed */
85
#define FAST_INSTALLED  64
86
 
87
/* Register displacements */
88
#define THR     0
89
#define RBR     0
90
#define IER     1
91
#define FCR     2
92
#define IIR     2
93
#define LCR     3
94
#define MCR     4
95
#define LSR     5
96
#define MSR     6
97
#define SPad    7
98
 
99
/* Parity value */
100
#define NONE    0
101
#define ODD     1
102
#define EVEN    3
103
 
104
/* Used for decoding the IIR status */
105
extern const int IIRbits[];
106
#define DECODE(v)       IIRbits[((v >> 1) & 3)]
107
#define PENDIRQ(v)      !((v) & 1)
108
 
109
/* Bit setting macros */
110
#define bit_on(v,b)     v |= (b)
111
#define bit_off(v,b)    v &= (~(b))
112
 
113
/* The descriptor of a serial link                               */
114
/* Each array entry is associated to a COM port                  */
115
/* The control field is used to specify which kind of interrupts */
116
/* are going to be served; the status field tracks if the entry  */
117
/* is curretly used & if the shared fast handler is linked       */
118
/* The semaphores are opened if you use an asyncronous server    */
119
/* with the link                                                 */
120
 
121
extern struct COM_LINK {
122
    /* These fields are for general use */
123
    BYTE status;
124
    BYTE control;
125
    BYTE request;
126
    BYTE msk;
127
    PID server;
128
    sem_t mutex;
129
    sem_t tx_sem;
130
    sem_t rx_sem;
131
    BYTE *tx_buf;
132
    BYTE *rx_buf;
133
    unsigned tx_len,rx_len;
134
    unsigned tx_cnt,rx_cnt;
135
} com_link[COM_LINKS];
136
 
137
/* Available servers */
138
TASK duplexServer(int port);
139
TASK rxServer(int port);
140
 
141
int com_open(unsigned int port,DWORD speed,BYTE parity,BYTE len,BYTE stop);
142
int com_server(unsigned int port,unsigned int control,PID server);
143
int com_close(unsigned int port);
144
unsigned com_read(unsigned int port,unsigned int reg);
145
unsigned com_receive(unsigned int port);
146
void com_write(unsigned int port,unsigned int reg,unsigned int value);
147
void com_send(unsigned int port,BYTE b);
148
void com_AsyncSend(int port,void *buf,unsigned int len);
149
void com_AsyncReceive(int port,void *buf,unsigned int len);
150
 
151
#ifdef __cplusplus
152
};
153
#endif
154
 
155
#endif