Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
548 serge 1
 
2
PORT_OPEN        equ 1
3
PORT_CLOSE       equ 2
4
PORT_RESET       equ 3
5
PORT_SETMODE     equ 4
6
PORT_GETMODE     equ 5
7
PORT_SETMCR      equ 6
8
PORT_GETMCR      equ 7
9
PORT_READ        equ 8
10
PORT_WRITE       equ 9
11
12
 
13
LCR_8BIT         equ  0x03
14
MCR_OUT_2        equ  0x08
15
16
 
17
io.code          equ esp+4
18
io.input         equ esp+8
19
io.inp_size      equ esp+12
20
io.output        equ esp+16
21
io.out_size      equ esp+20
22
23
 
24
;  ebx= service version
25
;  eax= error code
26
;    0= no error
27
;   -1= common error
28
29
 
30
init_uart:
31
           mov eax, 68
32
           mov ebx, 16
33
           mov ecx, szUart
34
           int 0x40
35
36
 
37
           test eax, eax
38
           jz .fail
39
40
 
41
           mov eax, esp
42
           xor ebx, ebx
43
44
 
45
           push eax            ;.output
46
           push ebx            ;.inp_size
47
           push ebx            ;.input
48
           push SRV_GETVERSION ;.code
49
           push [Uart]         ;.handle
50
51
 
52
           mov ebx, 17
53
           mov ecx, esp
54
           int 0x40
55
           add esp, 24
56
           pop ebx             ;version
57
           ret
58
.fail:
59
           or eax, -1
60
           ret
61
62
 
63
;  eax= port
64
;
65
; retval
66
;  ebx= connection
67
;  eax= error code
68
69
 
70
uart_open:
71
72
 
73
           mov ebx, esp
74
           push eax            ;port
75
           mov eax, esp
76
77
 
78
           push ebx            ;.output
79
           push 4              ;.inp_size
80
           push eax            ;.input
81
           push PORT_OPEN      ;.code
82
           push [Uart]         ;.handle
83
84
 
85
           mov ebx, 17
86
           mov ecx, esp
87
           int 0x40
88
           add esp, 28         ;io_control+port
89
           pop ebx             ;connection
90
           ret
91
92
 
93
;  eax= connection
94
;
95
; retval
96
;  eax= error code
97
98
 
99
uart_close:
100
           push eax            ;connection
101
           mov eax, esp
102
           xor ebx, ebx
103
104
 
105
           push ebx            ;.output
106
           push 4              ;.inp_size
107
           push eax            ;.input
108
           push PORT_CLOSE     ;.code
109
           push [Uart]         ;.handle
110
111
 
112
           mov ebx, 17
113
           mov ecx, esp        ;io_contol
114
           int 0x40
115
           add esp, 24+4       ;io_control
116
           ret
117
118
 
119
;  eax= connection
120
;
121
; retval
122
;  eax= error code
123
124
 
125
uart_reset:
126
           push eax            ;connection
127
           mov eax, esp
128
           xor ebx, ebx
129
130
 
131
           push ebx            ;.output
132
           push 4              ;.inp_size
133
           push eax            ;.input
134
           push PORT_RESET     ;.code
135
           push [Uart]         ;.handle
136
137
 
138
           mov ebx, 17
139
           mov ecx, esp        ;io_contol
140
           int 0x40
141
           add esp, 24+4       ;io_control
142
           ret
143
144
 
145
;  eax= connection
146
;  ebx= rate
147
;  ecx= mode
148
;
149
; retval
150
;  eax= error code
151
152
 
153
uart_setmode:
154
           push ecx            ;mode
155
           push ebx            ;rate
156
           push eax            ;connection
157
           mov eax, esp
158
           xor ecx, ecx
159
160
 
161
           push ecx            ;.output
162
           push 12             ;.inp_size
163
           push eax            ;.input
164
           push PORT_SETMODE   ;.code
165
           push [Uart]         ;.handle
166
167
 
168
           mov ebx, 17
169
           mov ecx, esp        ;io_contol
170
           int 0x40
171
           add esp, 24+12      ;io_control
172
           ret
173
174
 
175
;  eax= connection
176
;  ebx= modem control value
177
;
178
; retval
179
;  eax= error code
180
181
 
182
uart_set_mcr:
183
           push ebx            ;mcr
184
           push eax            ;connection
185
           mov eax, esp
186
           xor ecx, ecx
187
188
 
189
           push ecx            ;.output
190
           push 8              ;.inp_size
191
           push eax            ;.input
192
           push PORT_SETMCR    ;.code
193
           push [Uart]         ;.handle
194
195
 
196
           mov ebx, 17
197
           mov ecx, esp        ;io_contol
198
           int 0x40
199
           add esp, 24+8       ;io_control
200
           ret
201
202
 
203
;  eax= connection
204
;  ebx= buffer
205
;  ecx= size
206
;
207
; retval
208
;  ebx= bytes read
209
;  eax= error code
210
211
 
212
uart_read:
213
           push 0              ;bytes read
214
           push ecx            ;size
215
           push ebx            ;buffer
216
           push eax            ;connection
217
           mov eax, esp
218
           lea ebx, [esp+12]
219
220
 
221
           push ebx            ;.output
222
           push 12             ;.inp_size
223
           push eax            ;.input
224
           push PORT_READ      ;.code
225
           push [Uart]         ;.handle
226
227
 
228
           mov ebx, 17
229
           mov ecx, esp        ;io_contol
230
           int 0x40
231
           add esp, 24+12      ;io_control
232
           pop ebx
233
           ret
234
235
 
236
;  eax= connection
237
;  ebx= buffer
238
;  ecx= size
239
;
240
; retval
241
;  eax= error code
242
243
 
244
uart_write:
245
           push ecx            ;size
246
           push ebx            ;buffer
247
           push eax            ;connection
248
           mov eax, esp
249
           xor ecx, ecx
250
251
 
252
           push ecx            ;.output
253
           push 12             ;.inp_size
254
           push eax            ;.input
255
           push PORT_WRITE     ;.code
256
           push [Uart]         ;.handle
257
258
 
259
           mov ebx, 17
260
           mov ecx, esp        ;io_contol
261
           int 0x40
262
           add esp, 24+12      ;io_control
263
           ret
264
265
 
266
Uart        rd 1
267
268
 
269