Rev 7136 | Rev 8867 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7136 | Rev 8053 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 7136 $ |
8 | $Revision: 8053 $ |
9 | 9 | ||
10 | WINDOW_MOVE_AND_RESIZE_FLAGS = \ |
10 | WINDOW_MOVE_AND_RESIZE_FLAGS = \ |
11 | mouse.WINDOW_RESIZE_N_FLAG + \ |
11 | mouse.WINDOW_RESIZE_N_FLAG + \ |
Line 19... | Line 19... | ||
19 | event_start dd ? |
19 | event_start dd ? |
20 | event_end dd ? |
20 | event_end dd ? |
21 | event_uid dd 0 |
21 | event_uid dd 0 |
22 | endg |
22 | endg |
23 | EV_SPACE = 512 |
23 | EV_SPACE = 512 |
24 | FreeEvents = event_start-EVENT.fd ; "виртуальный" event, используются только поля: |
24 | FreeEvents = event_start-EVENT.fd ; "virtual" event, only following field used: |
25 | ; FreeEvents.fd=event_start и FreeEvents.bk=event_end |
25 | ; FreeEvents.fd=event_start and FreeEvents.bk=event_end |
26 | ;----------------------------------------------------------------------------- |
26 | ;----------------------------------------------------------------------------- |
27 | align 4 |
27 | align 4 |
28 | init_events: ;; used from kernel.asm |
28 | init_events: ;; used from kernel.asm |
29 | stdcall kernel_alloc, EV_SPACE*sizeof.EVENT |
29 | stdcall kernel_alloc, EV_SPACE*sizeof.EVENT |
30 | or eax, eax |
30 | or eax, eax |
31 | jz .fail |
31 | jz .fail |
32 | ; eax - current event, ebx - previos event below |
32 | ; eax - current event, ebx - previous event below |
33 | mov ecx, EV_SPACE ; current - in allocated space |
33 | mov ecx, EV_SPACE ; current - in allocated space |
34 | mov ebx, FreeEvents ; previos - начало списка |
34 | mov ebx, FreeEvents ; previous - list beginning |
35 | push ebx ; оно же и конец потом будет |
35 | push ebx ; it will be the end later |
36 | ;-------------------------------------- |
36 | ;-------------------------------------- |
37 | align 4 |
37 | align 4 |
38 | @@: |
38 | @@: |
39 | mov [ebx+EVENT.fd], eax |
39 | mov [ebx+EVENT.fd], eax |
40 | mov [eax+EVENT.bk], ebx |
40 | mov [eax+EVENT.bk], ebx |
41 | mov ebx, eax ; previos <- current |
41 | mov ebx, eax ; previos <- current |
42 | add eax, sizeof.EVENT ; new current |
42 | add eax, sizeof.EVENT ; new current |
43 | loop @b |
43 | loop @b |
44 | pop eax ; вот оно концом и стало |
44 | pop eax ; here it became the end |
45 | mov [ebx+EVENT.fd], eax |
45 | mov [ebx+EVENT.fd], eax |
46 | mov [eax+EVENT.bk], ebx |
46 | mov [eax+EVENT.bk], ebx |
47 | ;-------------------------------------- |
47 | ;-------------------------------------- |
48 | align 4 |
48 | align 4 |
49 | .fail: |
49 | .fail: |
Line 55... | Line 55... | ||
55 | MANUAL_DESTROY = 0x80000000 ; bit 31 |
55 | MANUAL_DESTROY = 0x80000000 ; bit 31 |
56 | ;----------------------------------------------------------------------------- |
56 | ;----------------------------------------------------------------------------- |
57 | align 4 |
57 | align 4 |
58 | create_event: ;; EXPORT use |
58 | create_event: ;; EXPORT use |
59 | ;info: |
59 | ;info: |
60 | ; Переносим EVENT из списка FreeEvents в список ObjList текущего слота |
60 | ; Move EVENT from the FreeEvents list to the ObjList list of the current slot; |
61 | ; EVENT.state устанавливаем из ecx, EVENT.code косвенно из esi (если esi<>0) |
61 | ; EVENT.state is set from ecx, EVENT.code indirectly from esi (if esi <> 0) |
62 | ;param: |
62 | ;param: |
63 | ; esi - event data |
63 | ; esi - event data |
64 | ; ecx - flags |
64 | ; ecx - flags |
65 | ;retval: |
65 | ;retval: |
66 | ; eax - event (=0 => fail) |
66 | ; eax - event (=0 => fail) |
Line 74... | Line 74... | ||
74 | cli |
74 | cli |
75 | ;-------------------------------------- |
75 | ;-------------------------------------- |
76 | align 4 |
76 | align 4 |
77 | set_event: ;; INTERNAL use !!! don't use for Call |
77 | set_event: ;; INTERNAL use !!! don't use for Call |
78 | ;info: |
78 | ;info: |
79 | ; Берем новый event из FreeEvents, заполняем его поля, как указано в ecx,edx,esi |
79 | ; We take a new event from FreeEvents, fill its fields from ecx, edx, esi |
80 | ; и устанавливаем в список, указанный в ebx. |
80 | ; and add it to the list, which specified in ebx. |
81 | ; Возвращаем сам event (в eax), и его uid (в edx) |
81 | ; Return event (to eax), and it's uid (to edx) |
82 | ;param: |
82 | ;param: |
83 | ; ebx - start-chain "virtual" event for entry new event Right of him |
83 | ; ebx - start-chain "virtual" event for entry new event Right of him |
84 | ; ecx - flags (copied to EVENT.state) |
84 | ; ecx - flags (copied to EVENT.state) |
85 | ; edx - pid (copied to EVENT.pid) |
85 | ; edx - pid (copied to EVENT.pid) |
86 | ; esi - event data (copied to EVENT.code indirect, =0 => skip) |
86 | ; esi - event data (copied to EVENT.code indirect, =0 => skip) |
Line 114... | Line 114... | ||
114 | rep movsd |
114 | rep movsd |
115 | ;-------------------------------------- |
115 | ;-------------------------------------- |
116 | align 4 |
116 | align 4 |
117 | RemoveEventTo: ;; INTERNAL use !!! don't use for Call |
117 | RemoveEventTo: ;; INTERNAL use !!! don't use for Call |
118 | ;param: |
118 | ;param: |
119 | ; eax - указатель на event, КОТОРЫЙ вставляем |
119 | ; eax - pointer to event, WHICH we will insert |
120 | ; ebx - указатель на event, ПОСЛЕ которого вставляем |
120 | ; ebx - pointer to event, AFTER which we will insert |
121 | ;scratched: ebx,ecx |
121 | ;scratched: ebx,ecx |
122 | mov ecx, eax ; ecx=eax=Self, ebx=NewLeft |
122 | mov ecx, eax ; ecx=eax=Self, ebx=NewLeft |
123 | xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight |
123 | xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight |
124 | cmp eax, ecx ; стоп, себе думаю... |
124 | cmp eax, ecx ; stop, I think... |
125 | je .break ; - а не дурак ли я? |
125 | je .break ; - am I not a fool? |
126 | mov [ecx+EVENT.bk], eax ; NewRight.bk=Self |
126 | mov [ecx+EVENT.bk], eax ; NewRight.bk=Self |
127 | xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft |
127 | xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft |
128 | xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight |
128 | xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight |
129 | mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight |
129 | mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight |
130 | mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft |
130 | mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft |
Line 141... | Line 141... | ||
141 | mov ebx, eax |
141 | mov ebx, eax |
142 | mov eax, [ebx+EVENT.pid] |
142 | mov eax, [ebx+EVENT.pid] |
143 | push edi |
143 | push edi |
144 | ;-------------------------------------- |
144 | ;-------------------------------------- |
145 | align 4 |
145 | align 4 |
146 | .small: ; криво как-то... |
146 | .small: ; somehow ugly... |
147 | pop edi |
147 | pop edi |
148 | pushfd |
148 | pushfd |
149 | cli |
149 | cli |
150 | call pid_to_slot ; saved all registers (eax - retval) |
150 | call pid_to_slot ; saved all registers (eax - retval) |
151 | shl eax, 8 |
151 | shl eax, 8 |
152 | jz RemoveEventTo.break ; POPF+RET |
152 | jz RemoveEventTo.break ; POPF+RET |
153 | jmp edi ; штатный возврат |
153 | jmp edi ; normal return |
154 | ;----------------------------------------------------------------------------- |
154 | ;----------------------------------------------------------------------------- |
155 | align 4 |
155 | align 4 |
156 | raise_event: ;; EXPORT use |
156 | raise_event: ;; EXPORT use |
157 | ;info: |
157 | ;info: |
158 | ; Устанавливаем данные EVENT.code |
158 | ; Setting up EVENT.code data |
159 | ; Если там флаг EVENT_SIGNALED уже активен - больше ничего |
159 | ; If is has flag EVENT_SIGNALED activated - nothing else |
160 | ; Иначе: этот флаг взводится, за исключением случая наличия флага EVENT_WATCHED в edx |
160 | ; Otherwise: activate this flag, except when the EVENT_WATCHED flag is present in edx |
161 | ; В этом случае EVENT_SIGNALED взводится лишь при наличие EVENT_WATCHED в самом событии |
161 | ; In this case EVENT_SIGNALED will activated only if EVENT_WATCHED presents in the event itself |
162 | ;param: |
162 | ;param: |
163 | ; eax - event |
163 | ; eax - event |
164 | ; ebx - uid (for Dummy testing) |
164 | ; ebx - uid (for Dummy testing) |
165 | ; edx - flags |
165 | ; edx - flags |
166 | ; esi - event data (=0 => skip) |
166 | ; esi - event data (=0 => skip) |
Line 204... | Line 204... | ||
204 | jmp RemoveEventTo |
204 | jmp RemoveEventTo |
205 | ;----------------------------------------------------------------------------- |
205 | ;----------------------------------------------------------------------------- |
206 | align 4 |
206 | align 4 |
207 | send_event: ;; EXPORT use |
207 | send_event: ;; EXPORT use |
208 | ;info: |
208 | ;info: |
209 | ; Создает новый EVENT (вытаскивает из списка FreeEvents) в списке EventList |
209 | ; Creates a new EVENT (pulls from the FreeEvents list) in the EventList list |
210 | ; целевого слота (eax=pid), с данными из esi косвенно, и state=EVENT_SIGNALED |
210 | ; of target slot (eax=pid), with data from esi indirectly, and state=EVENT_SIGNALED |
211 | ;param: |
211 | ;param: |
212 | ; eax - slots pid, to sending new event |
212 | ; eax - slots pid, to sending new event |
213 | ; esi - pointer to sending data (in code field of new event) |
213 | ; esi - pointer to sending data (in code field of new event) |
214 | ;retval: |
214 | ;retval: |
215 | ; eax - event (=0 => fail) |
215 | ; eax - event (=0 => fail) |
Line 250... | Line 250... | ||
250 | or ebx, -1; infinite timeout |
250 | or ebx, -1; infinite timeout |
251 | ;-------------------------------------- |
251 | ;-------------------------------------- |
252 | align 4 |
252 | align 4 |
253 | Wait_events_ex: |
253 | Wait_events_ex: |
254 | ;info: |
254 | ;info: |
255 | ; Ожидание "абстрактного" события через перевод слота в 5-ю позицию. |
255 | ; Waiting for an "abstract" event by moving the slot to the 5th position. |
256 | ; Абстрактность заключена в том, что факт события определяется функцией APPDATA.wait_test, |
256 | ; Abstractness lies in the fact, that the fact of an event is determined by the APPDATA.wait_test function, |
257 | ; которая задается клиентом и может быть фактически любой. |
257 | ; which is set by the client and can be actually anything. |
258 | ; Это позволяет shed-у надежно определить факт события, и не совершать "холостых" переключений, |
258 | ; This allows the shed to reliably determine the fact of the event, and not make "idle" switches, |
259 | ; предназначенных для разборок типа "свой/чужой" внутри задачи. |
259 | ; intended for showdowns like "friend / foe" within the problem. |
260 | ;param: |
260 | ;param: |
261 | ; edx - wait_test, клиентская ф-я тестирования (адрес кода) |
261 | ; edx - wait_test, client testing function (code address) |
262 | ; ecx - wait_param, дополнительный параметр, возможно необходимый для [wait_test] |
262 | ; ecx - wait_param, additional parameter, possibly needed for [wait_test] |
263 | ; ebx - wait_timeout |
263 | ; ebx - wait_timeout |
264 | ;retval: |
264 | ;retval: |
265 | ; eax - результат вызова [wait_test] (=0 => timeout) |
265 | ; eax - call result [wait_test] (=0 => timeout) |
266 | ;scratched: esi |
266 | ;scratched: esi |
267 | mov esi, [current_slot] |
267 | mov esi, [current_slot] |
268 | mov [esi+APPDATA.wait_param], ecx |
268 | mov [esi+APPDATA.wait_param], ecx |
269 | pushad |
269 | pushad |
270 | mov ebx, esi;пока это вопрос, чего куды сувать.......... |
270 | mov ebx, esi ;now this is a question, what where to put.......... |
271 | pushfd ; это следствие общей концепции: пусть ф-я тестирования имеет |
271 | pushfd ; this is a consequence of the general concept: let the test function have |
272 | cli ; право рассчитывать на закрытые прерывания, как при вызове из shed |
272 | cli ; the right to hope to disable interrupts, as when called from shed |
273 | call edx |
273 | call edx |
274 | popfd |
274 | popfd |
275 | mov [esp+28], eax |
275 | mov [esp+28], eax |
276 | popad |
276 | popad |
277 | or eax, eax |
277 | or eax, eax |
Line 290... | Line 290... | ||
290 | ret |
290 | ret |
291 | ;----------------------------------------------------------------------------- |
291 | ;----------------------------------------------------------------------------- |
292 | align 4 |
292 | align 4 |
293 | wait_event: ;; EXPORT use |
293 | wait_event: ;; EXPORT use |
294 | ;info: |
294 | ;info: |
295 | ; Ожидание флага EVENT_SIGNALED в совершенно конкретном Event |
295 | ; Waiting for the EVENT_SIGNALED flag in a very specific Event |
296 | ; (устанавливаемого, надо полагать, через raise_event) |
296 | ; (set, presumably, via raise_event) |
297 | ; При активном флаге MANUAL_RESET - больше ничего |
297 | ; When the MANUAL_RESET flag is active, nothing else |
298 | ; Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются, |
298 | ; Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared, |
299 | ; и, при активном MANUAL_DESTROY - перемещается в список ObjList текущего слота, |
299 | ; and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot, |
300 | ; а при не активном - уничтожается штатно (destroy_event.internal) |
300 | ; and if not active, it is destroyed normally (destroy_event.internal) |
301 | ;param: |
301 | ;param: |
302 | ; eax - event |
302 | ; eax - event |
303 | ; ebx - uid (for Dummy testing) |
303 | ; ebx - uid (for Dummy testing) |
304 | ;scratched: ecx,edx,esi |
304 | ;scratched: ecx,edx,esi |
305 | call DummyTest |
305 | call DummyTest |
Line 326... | Line 326... | ||
326 | ret |
326 | ret |
327 | ;----------------------------------------------------------------------------- |
327 | ;----------------------------------------------------------------------------- |
328 | align 4 |
328 | align 4 |
329 | get_event_ex: ;; f68:14 |
329 | get_event_ex: ;; f68:14 |
330 | ;info: |
330 | ;info: |
331 | ; Ожидание любого события в очереди EventList текущего слота |
331 | ; Waiting for any event in the EventList of the current slot |
332 | ; Данные события code - копируются в память приложения (косвенно по edi) |
332 | ; Code event data - copied to application memory (indirectly by edi) |
333 | ; При активном флаге MANUAL_RESET - больше ничего |
333 | ; When the MANUAL_RESET flag is active, nothing else |
334 | ; Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются, |
334 | ; Otherwise: the flags EVENT_SIGNALED and EVENT_WATCHED for the received event are cleared, |
335 | ; и, при активном MANUAL_DESTROY - перемещается в список ObjList текущего слота, |
335 | ; and, if MANUAL_DESTROY is active, it moves to the ObjList list of the current slot, |
336 | ; а при не активном - уничтожается штатно (destroy_event.internal) |
336 | ; and if not active, it is destroyed normally (destroy_event.internal) |
337 | ;param: |
337 | ;param: |
338 | ; edi - адрес в коде приложения для копирования данных из EVENT.code |
338 | ; edi - address in the application code to copy data from EVENT.code |
339 | ;retval: |
339 | ;retval: |
340 | ; eax - собственно EVENT (будем называть это его хэндлом) |
340 | ; eax - EVENT itself (we will call it a handle) |
341 | ;scratched: ebx,ecx,edx,esi,edi |
341 | ;scratched: ebx,ecx,edx,esi,edi |
342 | mov edx, get_event_queue ; wait_test |
342 | mov edx, get_event_queue ; wait_test |
343 | call Wait_events ; timeout ignored |
343 | call Wait_events ; timeout ignored |
344 | lea esi, [eax+EVENT.code] |
344 | lea esi, [eax+EVENT.code] |
345 | mov ecx, (sizeof.EVENT-EVENT.code)/4 |
345 | mov ecx, (sizeof.EVENT-EVENT.code)/4 |
Line 361... | Line 361... | ||
361 | jmp RemoveEventTo |
361 | jmp RemoveEventTo |
362 | ;----------------------------------------------------------------------------- |
362 | ;----------------------------------------------------------------------------- |
363 | align 4 |
363 | align 4 |
364 | destroy_event: ;; EXPORT use |
364 | destroy_event: ;; EXPORT use |
365 | ;info: |
365 | ;info: |
366 | ; Переносим EVENT в список FreeEvents, чистим поля magic,destroy,pid,id |
366 | ; Move EVENT to the FreeEvents list, clear the magic, destroy, pid, id fields |
367 | ;param: |
367 | ;param: |
368 | ; eax - event |
368 | ; eax - event |
369 | ; ebx - uid (for Dummy testing) |
369 | ; ebx - uid (for Dummy testing) |
370 | ;retval: |
370 | ;retval: |
371 | ; eax - адрес объекта EVENT (=0 => fail) |
371 | ; eax - address of EVENT object (=0 => fail) |
372 | ;scratched: ebx,ecx |
372 | ;scratched: ebx,ecx |
373 | call DummyTest ; not returned for fail !!! |
373 | call DummyTest ; not returned for fail !!! |
374 | ;-------------------------------------- |
374 | ;-------------------------------------- |
375 | align 4 |
375 | align 4 |
376 | .internal: |
376 | .internal: |
Line 385... | Line 385... | ||
385 | jmp RemoveEventTo |
385 | jmp RemoveEventTo |
386 | ;----------------------------------------------------------------------------- |
386 | ;----------------------------------------------------------------------------- |
387 | align 4 |
387 | align 4 |
388 | get_event_queue: |
388 | get_event_queue: |
389 | ;info: |
389 | ;info: |
390 | ; клиентская ф-я тестирования для get_event_ex |
390 | ; client testing function for get_event_ex |
391 | ;warning: |
391 | ;warning: |
392 | ; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
392 | ; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
393 | ; -may be assumed, that interrupt are disabled |
393 | ; -may be assumed, that interrupt are disabled |
394 | ; -it is not restriction for scratched registers |
394 | ; -it is not restriction for scratched registers |
395 | ;param: |
395 | ;param: |
396 | ; ebx - адрес APPDATA слота тестирования |
396 | ; ebx - APPDATA address of testing slot |
397 | ;retval: |
397 | ;retval: |
398 | ; eax - адрес объекта EVENT (=0 => fail) |
398 | ; eax - address of EVENT object (=0 => fail) |
399 | add ebx, APP_EV_OFFSET |
399 | add ebx, APP_EV_OFFSET |
400 | mov eax, [ebx+APPOBJ.bk] ; выбираем с конца, по принципу FIFO |
400 | mov eax, [ebx+APPOBJ.bk] ; we choose from the end, according to the FIFO principle |
401 | cmp eax, ebx ; empty ??? |
401 | cmp eax, ebx ; empty ??? |
402 | je get_event_alone.ret0 |
402 | je get_event_alone.ret0 |
403 | ;-------------------------------------- |
403 | ;-------------------------------------- |
404 | align 4 |
404 | align 4 |
405 | .ret: |
405 | .ret: |
406 | ret |
406 | ret |
407 | ;----------------------------------------------------------------------------- |
407 | ;----------------------------------------------------------------------------- |
408 | align 4 |
408 | align 4 |
409 | get_event_alone: |
409 | get_event_alone: |
410 | ;info: |
410 | ;info: |
411 | ; клиентская ф-я тестирования для wait_event |
411 | ; client testing function for wait_event |
412 | ;warning: |
412 | ;warning: |
413 | ; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
413 | ; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
414 | ; -may be assumed, that interrupt are disabled |
414 | ; -may be assumed, that interrupt are disabled |
415 | ; -it is not restriction for scratched registers |
415 | ; -it is not restriction for scratched registers |
416 | ;param: |
416 | ;param: |
417 | ; ebx - адрес APPDATA слота тестирования |
417 | ; ebx - APPDATA address of testing slot |
418 | ;retval: |
418 | ;retval: |
419 | ; eax - адрес объекта EVENT (=0 => fail) |
419 | ; eax - address of EVENT object (=0 => fail) |
420 | mov eax, [ebx+APPDATA.wait_param] |
420 | mov eax, [ebx+APPDATA.wait_param] |
421 | test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24 |
421 | test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24 |
422 | jnz .ret |
422 | jnz .ret |
423 | or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24 |
423 | or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24 |
424 | ;-------------------------------------- |
424 | ;-------------------------------------- |
Line 462... | Line 462... | ||
462 | mov [KEY_BUFF+eax], byte 0 |
462 | mov [KEY_BUFF+eax], byte 0 |
463 | sub eax, 120+2 |
463 | sub eax, 120+2 |
464 | ;-------------------------------------- |
464 | ;-------------------------------------- |
465 | align 4 |
465 | align 4 |
466 | .result: |
466 | .result: |
467 | setae byte[esp+32+4] ;считаем, что исходно: dword[esp+32+4]==72 |
467 | setae byte[esp+32+4] ;we consider that initially was: dword[esp+32+4]==72 |
468 | ;-------------------------------------- |
468 | ;-------------------------------------- |
469 | align 4 |
469 | align 4 |
470 | .retf: |
470 | .retf: |
471 | popfd |
471 | popfd |
472 | ;-------------------------------------- |
472 | ;-------------------------------------- |
Line 474... | Line 474... | ||
474 | .ret: |
474 | .ret: |
475 | ret |
475 | ret |
476 | ;----------------------------------------------------------------------------- |
476 | ;----------------------------------------------------------------------------- |
477 | align 4 |
477 | align 4 |
478 | sys_getevent: ;; f11 |
478 | sys_getevent: ;; f11 |
479 | mov ebx, [current_slot];пока это вопрос, чего куды сувать.......... |
479 | mov ebx, [current_slot] ;now this is a question, what where to put...... |
480 | pushfd ; это следствие общей концепции: пусть ф-я тестирования имеет |
480 | pushfd ; this is a consequence of the general concept: let the test function have |
481 | cli ; право рассчитывать на закрытые прерывания, как при вызове из shed |
481 | cli ; the right to hope to disable interrupts, as when called from shed |
482 | call get_event_for_app |
482 | call get_event_for_app |
483 | popfd |
483 | popfd |
484 | mov [esp+32], eax |
484 | mov [esp+32], eax |
485 | ret |
485 | ret |
486 | ;----------------------------------------------------------------------------- |
486 | ;----------------------------------------------------------------------------- |
Line 498... | Line 498... | ||
498 | ret |
498 | ret |
499 | ;----------------------------------------------------------------------------- |
499 | ;----------------------------------------------------------------------------- |
500 | align 4 |
500 | align 4 |
501 | get_event_for_app: ;; used from f10,f11,f23 |
501 | get_event_for_app: ;; used from f10,f11,f23 |
502 | ;info: |
502 | ;info: |
503 | ; клиентская ф-я тестирования для приложений (f10,f23) |
503 | ; client testing function for applications (f10,f23) |
504 | ;warning: |
504 | ;warning: |
505 | ; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
505 | ; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
506 | ; -may be assumed, that interrupt are disabled |
506 | ; -may be assumed, that interrupt are disabled |
507 | ; -it is not restriction for scratched registers |
507 | ; -it is not restriction for scratched registers |
508 | ;param: |
508 | ;param: |
509 | ; ebx - адрес APPDATA слота тестирования |
509 | ; ebx - APPDATA address of testing slot |
510 | ;retval: |
510 | ;retval: |
511 | ; eax - номер события (=0 => no events) |
511 | ; eax - event number (=0 => no events) |
512 | movzx edi, bh ; bh is assumed as [CURRENT_TASK] |
512 | movzx edi, bh ; bh is assumed as [CURRENT_TASK] |
513 | shl edi, 5 |
513 | shl edi, 5 |
514 | add edi, CURRENT_TASK ; edi is assumed as [TASK_BASE] |
514 | add edi, CURRENT_TASK ; edi is assumed as [TASK_BASE] |
515 | mov ecx, [edi+TASKDATA.event_mask] |
515 | mov ecx, [edi+TASKDATA.event_mask] |
516 | and ecx, 0x7FFFFFFF |
516 | and ecx, 0x7FFFFFFF |
517 | ;-------------------------------------- |
517 | ;-------------------------------------- |
518 | align 4 |
518 | align 4 |
519 | .loop: ; пока не исчерпаем все биты маски |
519 | .loop: ; until we run out all the bits of the mask |
520 | bsr eax, ecx ; находим ненулевой бит маски (31 -> 0) |
520 | bsr eax, ecx ; find a non-zero bit of the mask (31 -> 0) |
521 | jz .no_events ; исчерпали все биты маски, но ничего не нашли ??? |
521 | jz .no_events ; ran out all the bits of the mask but found nothing ??? |
522 | btr ecx, eax ; сбрасываем проверяемый бит маски |
522 | btr ecx, eax ; clear the current checking bit of the mask |
523 | ; переходим на обработчик этого (eax) бита |
523 | ; go to the handler of this (eax) bit |
524 | cmp eax, 10 |
524 | cmp eax, 10 |
525 | jae .loop ; eax=[10..31], ignored (event 11...32) |
525 | jae .loop ; eax=[10..31], ignored (event 11...32) |
Line 526... | Line 526... | ||
526 | 526 | ||
527 | cmp eax, 3 |
527 | cmp eax, 3 |