1 |
cebix |
1.1 |
/* |
2 |
|
|
* serial.h - Serial device driver |
3 |
|
|
* |
4 |
gbeauche |
1.11 |
* Basilisk II (C) 1997-2008 Christian Bauer |
5 |
cebix |
1.1 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef SERIAL_H |
22 |
|
|
#define SERIAL_H |
23 |
|
|
|
24 |
|
|
/* |
25 |
|
|
* port: |
26 |
|
|
* 0 - .AIn |
27 |
|
|
* 1 - .AOut |
28 |
|
|
* 2 - .BIn |
29 |
|
|
* 3 - .BOut |
30 |
|
|
*/ |
31 |
|
|
|
32 |
cebix |
1.4 |
#ifdef POWERPC_ROM |
33 |
|
|
extern int16 SerialOpen(uint32 pb, uint32 dce); |
34 |
|
|
extern int16 SerialPrimeIn(uint32 pb, uint32 dce); |
35 |
|
|
extern int16 SerialPrimeOut(uint32 pb, uint32 dce); |
36 |
|
|
extern int16 SerialControl(uint32 pb, uint32 dce); |
37 |
|
|
extern int16 SerialStatus(uint32 pb, uint32 dce); |
38 |
|
|
extern int16 SerialClose(uint32 pb, uint32 dce); |
39 |
|
|
extern int16 SerialNothing(uint32 pb, uint32 dce); |
40 |
|
|
#else |
41 |
cebix |
1.1 |
extern int16 SerialOpen(uint32 pb, uint32 dce, int port); |
42 |
|
|
extern int16 SerialPrime(uint32 pb, uint32 dce, int port); |
43 |
|
|
extern int16 SerialControl(uint32 pb, uint32 dce, int port); |
44 |
|
|
extern int16 SerialStatus(uint32 pb, uint32 dce, int port); |
45 |
|
|
extern int16 SerialClose(uint32 pb, uint32 dce, int port); |
46 |
cebix |
1.4 |
#endif |
47 |
cebix |
1.1 |
|
48 |
|
|
extern void SerialInterrupt(void); |
49 |
|
|
|
50 |
|
|
// System specific and internal functions/data |
51 |
|
|
extern void SerialInit(void); |
52 |
|
|
extern void SerialExit(void); |
53 |
|
|
|
54 |
|
|
// Serial driver Deferred Task structure |
55 |
|
|
enum { |
56 |
|
|
serdtCode = 20, // DT code is stored here |
57 |
|
|
serdtResult = 30, |
58 |
|
|
serdtDCE = 34, |
59 |
|
|
SIZEOF_serdt = 38 |
60 |
|
|
}; |
61 |
|
|
|
62 |
|
|
// Variables for one (In/Out combined) serial port |
63 |
|
|
// To implement a serial driver, you create a subclass of SERDPort |
64 |
|
|
class SERDPort { |
65 |
|
|
public: |
66 |
|
|
SERDPort() |
67 |
|
|
{ |
68 |
|
|
is_open = false; |
69 |
|
|
input_dt = output_dt = 0; |
70 |
|
|
} |
71 |
|
|
|
72 |
cebix |
1.10 |
virtual ~SERDPort() {} |
73 |
|
|
|
74 |
cebix |
1.2 |
virtual int16 open(uint16 config) = 0; |
75 |
|
|
virtual int16 prime_in(uint32 pb, uint32 dce) = 0; |
76 |
|
|
virtual int16 prime_out(uint32 pb, uint32 dce) = 0; |
77 |
|
|
virtual int16 control(uint32 pb, uint32 dce, uint16 code) = 0; |
78 |
|
|
virtual int16 status(uint32 pb, uint32 dce, uint16 code) = 0; |
79 |
|
|
virtual int16 close(void) = 0; |
80 |
cebix |
1.1 |
|
81 |
|
|
bool is_open; // Port has been opened |
82 |
|
|
uint8 cum_errors; // Cumulative errors |
83 |
|
|
|
84 |
|
|
bool read_pending; // Read operation pending |
85 |
|
|
bool read_done; // Read operation complete |
86 |
|
|
uint32 input_dt; // Mac address of Deferred Task for reading |
87 |
|
|
|
88 |
|
|
bool write_pending; // Write operation pending |
89 |
|
|
bool write_done; // Write operation complete |
90 |
|
|
uint32 output_dt; // Mac address of Deferred Task for writing |
91 |
cebix |
1.4 |
|
92 |
|
|
#ifdef POWERPC_ROM |
93 |
gbeauche |
1.8 |
uint32 dt_store; |
94 |
cebix |
1.4 |
#endif |
95 |
cebix |
1.1 |
}; |
96 |
|
|
|
97 |
|
|
extern SERDPort *the_serd_port[2]; |
98 |
|
|
|
99 |
|
|
#endif |