Subversion Repositories Kolibri OS

Rev

Rev 6926 | Rev 6928 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6926 Rev 6927
Line 138... Line 138...
138
; ebp pipe
138
; ebp pipe
Line 139... Line 139...
139
 
139
 
140
align 4
140
align 4
141
pipe_read:
141
pipe_read:
-
 
142
        mov     edi, edx
-
 
143
 
142
        mov     edi, edx
144
.again:
143
        lea     ecx, [ebp+PIPE.pipe_lock]
145
        lea     ecx, [ebp+PIPE.pipe_lock]
Line 144... Line 146...
144
        call    mutex_lock
146
        call    mutex_lock
145
 
147
 
Line 159... Line 161...
159
        mov     esi, [ebp+PIPE.buffer]
161
        mov     esi, [ebp+PIPE.buffer]
160
        add     esi, [ebp+PIPE.read_end]
162
        add     esi, [ebp+PIPE.read_end]
161
        mov     [esp+SYSCALL_STACK._eax], ecx
163
        mov     [esp+SYSCALL_STACK._eax], ecx
162
        sub     [ebp+PIPE.count], ecx
164
        sub     [ebp+PIPE.count], ecx
163
        cld
165
        cld
164
        rep stosb
166
        rep movsb
165
        and     esi, 0xFFF
167
        and     esi, 0xFFF
166
        add     [ebp+PIPE.read_end], esi
168
        mov     [ebp+PIPE.read_end], esi
Line 167... Line 169...
167
 
169
 
168
        lea     ecx, [ebp+PIPE.pipe_lock]
170
        lea     ecx, [ebp+PIPE.pipe_lock]
169
        call    mutex_unlock
171
        call    mutex_unlock
Line 170... Line 172...
170
        ret
172
        ret
171
 
-
 
172
.wait:
173
 
173
 
174
.wait:
174
        sub     esp, sizeof.MUTEX_WAITER
175
        sub     esp, sizeof.MUTEX_WAITER
175
        mov     ebx, [TASK_BASE]
176
        mov     ebx, [TASK_BASE]
Line 176... Line 177...
176
        mov     [esp+MUTEX_WAITER.task], ebx
177
        mov     [esp+MUTEX_WAITER.task], ebx
Line 177... Line -...
177
        lea     edx, [ebp+PIPE.rlist]
-
 
178
 
178
        lea     edx, [ebp+PIPE.rlist]
179
        list_add_tail esp, edx      ;esp= new waiter, edx= list head
179
 
Line 180... Line 180...
180
 
180
        list_add_tail esp, edx      ;esp= new waiter, edx= list head
181
.again:
181
 
Line -... Line 182...
-
 
182
        lea     ecx, [ebp+PIPE.pipe_lock]
-
 
183
        call    mutex_unlock
-
 
184
 
-
 
185
        mov     [ebx+TASKDATA.state], 1
-
 
186
        call    change_task
-
 
187
 
-
 
188
        list_del esp
-
 
189
        add     esp, sizeof.MUTEX_WAITER
-
 
190
        jmp     .again
-
 
191
 
-
 
192
.eof:
-
 
193
        mov     [esp+SYSCALL_STACK._eax], eax
-
 
194
        lea     ecx, [ebp+PIPE.pipe_lock]
-
 
195
        call    mutex_unlock
-
 
196
        ret
-
 
197
 
-
 
198
; edx buf
-
 
199
; esi count
-
 
200
; ebp pipe
182
        lea     ecx, [ebp+PIPE.pipe_lock]
201
 
183
        call    mutex_unlock
202
align 4
Line -... Line 203...
-
 
203
pipe_write:
-
 
204
        mov     edi, edx
-
 
205
 
-
 
206
.again:
184
 
207
        lea     ecx, [ebp+PIPE.pipe_lock]
185
        mov     [ebx+TASKDATA.state], 1
208
        call    mutex_lock
186
        call    change_task
209
 
-
 
210
        xor     eax, eax
-
 
211
        cmp     eax, [ebp+PIPE.readers]
-
 
212
        je      .epipe
-
 
213
 
-
 
214
        mov     ecx, [ebp+PIPE.count]
-
 
215
        sub     ecx, 4096
-
 
216
        jz      .wait
-
 
217
 
-
 
218
.check_count:
-
 
219
        cmp     ecx, esi
-
 
220
        jb      .write
-
 
221
        mov     ecx, esi
-
 
222
.write:
-
 
223
        mov     esi, [ebp+PIPE.buffer]
-
 
224
        add     esi, [ebp+PIPE.write_end]
-
 
225
        mov     [esp+SYSCALL_STACK._eax], ecx
-
 
226
        add     [ebp+PIPE.count], ecx
-
 
227
        cld
-
 
228
        rep movsb
-
 
229
        and     esi, 0xFFF
-
 
230
        mov     [ebp+PIPE.write_end], esi
-
 
231
 
-
 
232
        lea     ecx, [ebp+PIPE.pipe_lock]
-
 
233
        call    mutex_unlock
-
 
234
        ret
-
 
235
 
-
 
236
.wait:
-
 
237
        sub     esp, sizeof.MUTEX_WAITER
-
 
238
        mov     ebx, [TASK_BASE]
-
 
239
        mov     [esp+MUTEX_WAITER.task], ebx
-
 
240
        lea     edx, [ebp+PIPE.wlist]
-
 
241
 
Line 187... Line 242...
187
 
242
        list_add_tail esp, edx      ;esp= new waiter, edx= list head
188
        lea     ecx, [ebp+PIPE.pipe_lock]
243
 
189
        call    mutex_lock
244
        lea     ecx, [ebp+PIPE.pipe_lock]
Line 190... Line 245...
190
 
245
        call    mutex_unlock
191
        mov     ecx, [ebp+PIPE.count]
246
 
192
        test    ecx, ecx
247
        mov     [ebx+TASKDATA.state], 1
193
        jz      .again
248
        call    change_task
194
 
249
 
Line 195... Line -...
195
        list_del esp
-
 
196
        add     esp, sizeof.MUTEX_WAITER
250
        list_del esp
197
        jmp     .check_count
251
        add     esp, sizeof.MUTEX_WAITER
198
 
-
 
199
.eof:
252
        jmp     .again
200
        mov     [esp+SYSCALL_STACK._eax], eax
253