Rev 254 | Rev 363 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 254 | Rev 354 | ||
---|---|---|---|
1 | struc EVENT |
- | |
2 | { .code rd 1 |
- | |
3 | rd 5 |
- | |
4 | .next rd 1 ;+24 |
- | |
5 | .prev rd 1 ;+28 |
- | |
6 | } |
- | |
7 | EVENT_SIZE equ 32 |
- | |
8 | - | ||
9 | virtual at 0 |
- | |
10 | EVENT EVENT |
- | |
11 | end virtual |
- | |
12 | 1 | align 4 |
|
13 | align 4 |
2 | init_events: |
14 | init_events: |
3 | stdcall kernel_alloc, 512*EVENT_SIZE |
15 | stdcall kernel_alloc, 1024*EVENT_SIZE |
4 | mov [events], eax |
16 | mov [events], eax |
5 | xor eax, eax |
17 | xor eax, eax |
6 | mov [event_uid], eax |
- | 7 | not eax |
|
18 | not eax |
8 | mov edi, event_map |
19 | mov edi, event_map |
9 | mov [event_start], edi |
20 | mov [event_start], edi |
10 | mov ecx, 64/4 |
21 | mov ecx, 128/4 |
11 | cld |
22 | cld |
12 | rep stosd |
23 | rep stosd |
13 | mov [event_end], edi |
24 | mov [event_end], edi |
14 | ret |
25 | ret |
15 | |
26 | 16 | align 4 |
|
27 | align 4 |
17 | proc alloc_event |
28 | proc alloc_event |
18 | |
29 | 19 | pushfd |
|
30 | pushfd |
20 | cli |
31 | cli |
21 | mov ebx, [event_start] |
32 | mov ebx, [event_start] |
22 | mov ecx, [event_end] |
33 | mov ecx, [event_end] |
23 | .l1: |
34 | .l1: |
24 | bsf eax,[ebx] |
35 | bsf eax,[ebx] |
25 | jnz .found |
36 | jnz .found |
26 | add ebx,4 |
37 | add ebx,4 |
27 | cmp ebx, ecx |
38 | cmp ebx, ecx |
28 | jb .l1 |
39 | jb .l1 |
29 | popfd |
40 | popfd |
30 | xor eax,eax |
41 | xor eax,eax |
31 | ret |
42 | ret |
32 | .found: |
43 | .found: |
33 | btr [ebx], eax |
44 | btr [ebx], eax |
34 | mov [event_start],ebx |
45 | mov [event_start],ebx |
35 | inc [event_uid] |
- | 36 | ||
- | 37 | sub ebx, event_map |
|
46 | sub ebx, event_map |
38 | lea eax,[eax+ebx*8] |
47 | lea eax,[eax+ebx*8] |
39 | |
- | 40 | lea ebx, [eax+eax*4] |
|
- | 41 | shl eax,5 |
|
48 | shl eax,5 |
42 | lea eax,[eax+ebx*4] ;eax*=52 (EVENT_SIZE) |
- | 43 | add eax, [events] |
|
49 | add eax, [events] |
44 | mov ebx, [event_uid] |
- | 45 | popfd |
|
50 | popfd |
46 | ret |
51 | xor ebx, ebx |
- | |
52 | mov [eax+EVENT.next], ebx |
- | |
53 | mov [eax+EVENT.prev], ebx |
- | |
54 | ret |
47 | endp |
55 | endp |
48 | |
56 | 49 | align 4 |
|
57 | align 4 |
50 | free_event: |
58 | free_event: |
51 | sub eax, [events] |
59 | pushfd |
- | |
60 | cli |
- | |
61 | sub eax, [events] |
52 | mov ecx, EVENT_SIZE |
62 | shr eax, 5 |
53 | mov ebx, event_map |
63 | mov ebx, event_map |
54 | cdq |
- | 55 | div ecx |
|
- | 56 | ||
- | 57 | pushfd |
|
- | 58 | cli |
|
- | 59 | bts [ebx], eax |
|
64 | bts [ebx], eax |
60 | shr eax, 3 |
65 | shr eax, 3 |
61 | and eax, not 3 |
66 | and eax, not 3 |
62 | add eax, ebx |
67 | add eax, ebx |
63 | cmp [event_start], eax |
68 | cmp [event_start], eax |
64 | ja @f |
69 | ja @f |
65 | popfd |
70 | popfd |
66 | ret |
71 | ret |
67 | @@: |
72 | @@: |
68 | mov [event_start], eax |
73 | mov [event_start], eax |
69 | popfd |
74 | popfd |
70 | ret |
75 | ret |
71 | |
- | 72 | EVENT_WATCHED equ 0x10000000 |
|
- | 73 | EVENT_SIGNALED equ 0x20000000 |
|
- | 74 | MANUAL_RESET equ 0x40000000 |
|
- | 75 | MANUAL_DESTROY equ 0x80000000 |
|
- | 76 | ||
- | 77 | ||
- | 78 | ; param |
|
- | 79 | ; eax= event data |
|
- | 80 | ; ebx= flags |
|
- | 81 | ; |
|
- | 82 | ; retval |
|
- | 83 | ; eax= event |
|
- | 84 | ; edx= id |
|
- | 85 | ||
- | 86 | create_event: |
|
- | 87 | .flags equ esp+4 |
|
- | 88 | .data equ esp |
|
- | 89 | ||
- | 90 | push ebx |
|
- | 91 | push eax |
|
- | 92 | ||
- | 93 | call alloc_event |
|
- | 94 | test eax, eax |
|
- | 95 | jz .fail |
|
- | 96 | ||
- | 97 | mov [eax+APPOBJ.magic], 'EVNT' |
|
- | 98 | mov [eax+APPOBJ.destroy], destroy_event |
|
- | 99 | mov [eax+EVENT.id], ebx |
|
- | 100 | ||
- | 101 | mov ebx, [CURRENT_TASK] |
|
- | 102 | shl ebx, 5 |
|
- | 103 | mov ebx, [0x3000+ebx+4] |
|
- | 104 | mov [eax+APPOBJ.pid], ebx |
|
- | 105 | mov edx, [.flags] |
|
- | 106 | mov [eax+EVENT.state], edx |
|
- | 107 | ||
- | 108 | mov esi, [.data] |
|
- | 109 | test esi, esi |
|
- | 110 | jz @F |
|
- | 111 | lea edi, [eax+EVENT.code] |
|
- | 112 | mov ecx, 6 |
|
- | 113 | cld |
|
- | 114 | rep movsd |
|
- | 115 | @@: |
|
- | 116 | mov ecx, [CURRENT_TASK] |
|
- | 117 | shl ecx,8 |
|
- | 118 | add ecx, PROC_BASE+APP_OBJ_OFFSET |
|
- | 119 | ||
- | 120 | pushfd |
|
- | 121 | cli |
|
- | 122 | mov edx, [ecx+APPOBJ.fd] |
|
- | 123 | mov [eax+APPOBJ.fd], edx |
|
- | 124 | mov [eax+APPOBJ.bk], ecx |
|
- | 125 | mov [ecx+APPOBJ.fd], eax |
|
- | 126 | mov [edx+APPOBJ.bk], eax |
|
- | 127 | popfd |
|
- | 128 | mov edx, [eax+EVENT.id] |
|
- | 129 | .fail: |
|
- | 130 | add esp, 8 |
|
- | 131 | ret |
|
- | 132 | ||
- | 133 | restore .flags |
|
- | 134 | restore .data |
|
- | 135 | ||
- | 136 | ; param |
|
- | 137 | ; eax= event |
|
- | 138 | ; ebx= id |
|
- | 139 | ||
- | 140 | destroy_event: |
|
- | 141 | ||
- | 142 | cmp [eax+APPOBJ.magic], 'EVNT' |
|
- | 143 | jne .fail |
|
- | 144 | cmp [eax+EVENT.id], ebx |
|
- | 145 | jne .fail |
|
- | 146 | ||
- | 147 | mov ebx, [eax+APPOBJ.fd] |
|
- | 148 | mov ecx, [eax+APPOBJ.bk] |
|
- | 149 | mov [ebx+APPOBJ.bk], ecx |
|
- | 150 | mov [ecx+APPOBJ.fd], ebx |
|
- | 151 | .internal: |
|
- | 152 | xor edx, edx ;clear common header |
|
- | 153 | mov [eax], edx |
|
- | 154 | mov [eax+4], edx |
|
- | 155 | mov [eax+8], edx |
|
- | 156 | mov [eax+12], edx |
|
- | 157 | mov [eax+16], edx |
|
- | 158 | ||
- | 159 | call free_event ;release object memory |
|
- | 160 | .fail: |
|
- | 161 | ret |
|
- | 162 | ||
76 | 163 | align 4 |
|
77 | align 4 |
164 | proc send_event stdcall pid:dword, event:dword |
78 | proc send_event stdcall pid:dword, event:dword |
165 | locals |
79 | locals |
166 | slot dd ? |
80 | slot dd ? |
167 | endl |
81 | endl |
168 | |
82 | 169 | mov eax, [pid] |
|
83 | mov eax, [pid] |
170 | call pid_to_slot |
84 | call pid_to_slot |
171 | test eax, eax |
85 | test eax, eax |
172 | jz .fail |
86 | jz .fail |
173 | |
87 | 174 | shl eax, 8 |
|
88 | shl eax, 8 |
175 | cmp [PROC_BASE+eax+APPDATA.ev_count], 32 |
89 | cmp [PROC_BASE+eax+APPDATA.ev_count], 32 |
176 | ja .fail |
90 | ja .fail |
177 | |
91 | 178 | mov [slot], eax |
|
92 | mov [slot], eax |
179 | |
- | 180 | call alloc_event |
|
93 | call alloc_event |
181 | test eax, eax |
94 | test eax, eax |
182 | jz .fail |
95 | jz .fail |
183 | |
96 | 184 | lea edi, [eax+EVENT.code] |
|
97 | mov edi, eax |
185 | mov ecx, 6 |
98 | mov ecx, 6 |
186 | mov esi, [event] |
99 | mov esi, [event] |
187 | cld |
100 | cld |
188 | rep movsd |
101 | rep movsd |
189 | |
102 | 190 | mov ecx, [slot] |
|
103 | mov esi, eax |
191 | add ecx, PROC_BASE+APP_EV_OFFSET |
- | 192 | ||
104 | mov eax, [slot] |
193 | mov [eax+APPOBJ.magic], 'EVNT' |
105 | mov edi, [PROC_BASE+eax+APPDATA.ev_last] |
194 | mov [eax+APPOBJ.destroy], destroy_event |
106 | mov [esi+EVENT.prev], edi |
195 | mov ebx, [pid] |
107 | test edi, edi |
196 | mov [eax+APPOBJ.pid], ebx |
108 | jz .set_last |
197 | mov [eax+EVENT.state], EVENT_SIGNALED |
- | 198 | ||
109 | mov [edi+EVENT.next], esi |
199 | pushfd |
- | 200 | cli ;insert event into |
|
110 | .set_last: |
201 | mov edx, [ecx+APPOBJ.fd] ;events list |
111 | mov edx, [PROC_BASE+eax+APPDATA.ev_first] |
202 | mov [eax+APPOBJ.fd], edx ;and set events flag |
112 | test edx, edx |
203 | mov [eax+APPOBJ.bk], ecx |
113 | jnz @F |
204 | mov [ecx+APPOBJ.fd], eax |
114 | mov [PROC_BASE+eax+APPDATA.ev_first], esi |
- | |
115 | @@: |
205 | mov [edx+APPOBJ.bk], eax |
116 | mov [PROC_BASE+eax+APPDATA.ev_last], esi |
206 | inc [ecx+APPDATA.ev_count-APP_EV_OFFSET] |
117 | inc [PROC_BASE+eax+APPDATA.ev_count] |
207 | or [ecx+APPDATA.event_mask-APP_EV_OFFSET], EVENT_EXTENDED |
- | 208 | popfd |
|
118 | or [PROC_BASE+eax+APPDATA.event_mask], EVENT_EXTENDED |
209 | .fail: |
119 | .fail: |
210 | ret |
120 | ret |
211 | endp |
121 | endp |
212 | |
- | 213 | ; timeout ignored |
|
- | 214 | ||
122 | 215 | align 4 |
|
123 | align 4 |
216 | proc get_event_ex stdcall, p_ev:dword, timeout:dword |
124 | proc get_event_ex stdcall, p_ev:dword, timeout:dword |
217 | |
125 | 218 | .wait: |
|
126 | .wait: |
219 | mov edx,[CURRENT_TASK] |
127 | mov ebx,[CURRENT_TASK] |
220 | shl edx,8 |
128 | shl ebx,8 |
221 | cmp [PROC_BASE+edx+APPDATA.ev_count], 0 |
129 | cmp [PROC_BASE+ebx+APPDATA.ev_count], 0 |
222 | je .switch |
130 | je .switch |
223 | |
131 | 224 | add edx, PROC_BASE+APP_EV_OFFSET |
|
- | 225 | ||
132 | mov esi, [PROC_BASE+ebx+APPDATA.ev_first] |
226 | mov eax, [edx+EVENT.fd] |
133 | mov edx, [esi+EVENT.next] |
- | |
134 | mov [PROC_BASE+ebx+APPDATA.ev_first], edx |
227 | cmp eax, edx |
135 | test edx, edx |
228 | je .switch |
136 | jz @F |
- | |
137 | mov [edx+EVENT.prev], 0 |
- | |
138 | @@: |
- | |
139 | jnz @F |
- | |
140 | mov [PROC_BASE+ebx+APPDATA.ev_last], edx |
- | |
141 | and dword [PROC_BASE+ebx+APPDATA.event_mask], not EVENT_EXTENDED |
- | |
142 | @@: |
- | |
143 | dec [PROC_BASE+ebx+APPDATA.ev_count] |
- | |
144 | 229 | ||
145 | mov eax, esi |
230 | lea esi, [eax+EVENT.code] |
146 | and dword [esi], 0xFF00FFFF |
231 | mov edi, [p_ev] ;copy event data |
147 | mov edi, [p_ev] |
232 | mov ecx, 6 |
148 | mov ecx, 6 |
233 | cld |
149 | cld |
234 | rep movsd |
150 | rep movsd |
235 | |
- | 236 | and dword [edi-24], 0xFF00FFFF ;clear priority field |
|
- | 237 | ; |
|
- | 238 | ||
- | 239 | test [eax+EVENT.state], MANUAL_RESET |
|
- | 240 | jnz .done |
|
- | 241 | ||
- | 242 | pushfd |
|
- | 243 | cli ;remove event from events |
|
- | 244 | mov ebx, [eax+APPOBJ.fd] ;list (reset event) |
|
- | 245 | mov ecx, [eax+APPOBJ.bk] ;and clear events flag |
|
- | 246 | mov [ebx+APPOBJ.bk], ecx ;if no active events |
|
- | 247 | mov [ecx+APPOBJ.fd], ebx |
|
- | 248 | dec [edx+APPDATA.ev_count-APP_EV_OFFSET] |
|
- | 249 | jnz @F |
|
- | 250 | and [edx+APPDATA.event_mask-APP_EV_OFFSET], not EVENT_EXTENDED |
|
- | 251 | popfd |
|
- | 252 | ||
- | 253 | test [eax+EVENT.state], MANUAL_DESTROY |
|
- | 254 | jz .destroy |
|
- | 255 | ||
- | 256 | add edx, (APP_OBJ_OFFSET-APP_EV_OFFSET) |
|
- | 257 | ||
- | 258 | pushfd |
|
- | 259 | cli |
|
- | 260 | mov edx, [ecx+APPOBJ.fd] ;insert event into |
|
- | 261 | mov [eax+APPOBJ.fd], edx ;objects list |
|
- | 262 | mov [eax+APPOBJ.bk], ecx |
|
- | 263 | mov [ecx+APPOBJ.fd], eax |
|
- | 264 | mov [edx+APPOBJ.bk], eax |
|
- | 265 | popfd |
|
- | 266 | .done: |
|
- | 267 | ret |
|
- | 268 | ||
- | 269 | .destroy: |
|
- | 270 | call destroy_event.internal |
|
151 | call free_event |
271 | ret |
152 | ret |
272 | .switch: |
153 | .switch: |
273 | mov eax, [0x3010] |
154 | mov eax, [0x3010] |
274 | mov [eax+TASKDATA.state], byte 5 |
155 | mov [eax+TASKDATA.state], byte 5 |
275 | call change_task |
156 | call change_task |
276 | jmp .wait |
157 | jmp .wait |
277 | endp |
158 | endp |
278 | |
- | 279 | ; param |
|
- | 280 | ; eax= event |
|
- | 281 | ; ebx= id |
|
- | 282 | ||
- | 283 | align 4 |
|
- | 284 | wait_event: |
|
- | 285 | .event equ esp |
|
- | 286 | push eax |
|
- | 287 | .wait: |
|
- | 288 | cmp [eax+APPOBJ.magic], 'EVNT' |
|
- | 289 | jne .done |
|
- | 290 | cmp [eax+EVENT.id], ebx |
|
- | 291 | jne .done |
|
- | 292 | ||
- | 293 | test [eax+EVENT.state], EVENT_SIGNALED |
|
- | 294 | jz .switch |
|
- | 295 | ||
- | 296 | test [eax+EVENT.state], MANUAL_RESET |
|
- | 297 | jnz .done |
|
- | 298 | ||
- | 299 | mov edx,[CURRENT_TASK] |
|
- | 300 | shl edx,8 |
|
- | 301 | add edx, PROC_BASE |
|
- | 302 | ||
- | 303 | pushfd |
|
- | 304 | cli ;remove event from events |
|
- | 305 | mov ebx, [eax+APPOBJ.fd] ;list (reset event) |
|
- | 306 | mov ecx, [eax+APPOBJ.bk] ;and clear events flag |
|
- | 307 | mov [ebx+APPOBJ.bk], ecx ;if no active events |
|
- | 308 | mov [ecx+APPOBJ.fd], ebx |
|
- | 309 | dec [edx+APPDATA.ev_count] |
|
- | 310 | jnz @F |
|
- | 311 | and [edx+APPDATA.event_mask], not EVENT_EXTENDED |
|
- | 312 | @@: |
|
- | 313 | and [eax+EVENT.state], not (EVENT_SIGNALED+EVENT_WATCHED) |
|
- | 314 | popfd |
|
- | 315 | ||
- | 316 | test [eax+EVENT.state], MANUAL_DESTROY |
|
- | 317 | jz .destroy |
|
- | 318 | ||
- | 319 | add edx, APP_OBJ_OFFSET |
|
- | 320 | ||
- | 321 | pushfd |
|
- | 322 | cli |
|
- | 323 | mov ecx, [edx+APPOBJ.fd] ;insert event into |
|
- | 324 | mov [eax+APPOBJ.fd], ecx ;objects list |
|
- | 325 | mov [eax+APPOBJ.bk], edx |
|
- | 326 | mov [edx+APPOBJ.fd], eax |
|
- | 327 | mov [ecx+APPOBJ.bk], eax |
|
- | 328 | popfd |
|
- | 329 | .done: |
|
- | 330 | add esp, 4 |
|
- | 331 | ret |
|
- | 332 | .destroy: |
|
- | 333 | call destroy_event.internal |
|
- | 334 | add esp, 4 |
|
- | 335 | ret |
|
- | 336 | .switch: |
|
- | 337 | or [eax+EVENT.state], EVENT_WATCHED |
|
- | 338 | mov eax, [0x3010] |
|
- | 339 | mov [eax+TASKDATA.state], byte 5 |
|
- | 340 | call change_task |
|
- | 341 | mov eax, [.event] |
|
- | 342 | jmp .wait |
|
- | 343 | restore .event |
|
- | 344 | ||
- | 345 | ; param |
|
- | 346 | ; eax= event |
|
- | 347 | ; ebx= id |
|
- | 348 | ; ecx= flags |
|
- | 349 | ||
- | 350 | raise_event: |
|
- | 351 | .event equ esp |
|
- | 352 | push eax |
|
- | 353 | ||
- | 354 | cmp [eax+APPOBJ.magic], 'EVNT' |
|
- | 355 | jne .fail |
|
- | 356 | cmp [eax+EVENT.id], ebx |
|
- | 357 | jne .fail |
|
- | 358 | ||
- | 359 | mov eax, [eax+APPOBJ.pid] |
|
- | 360 | call pid_to_slot |
|
- | 361 | test eax, eax |
|
- | 362 | jz .fail |
|
- | 363 | ||
- | 364 | mov edx, [.event] |
|
- | 365 | test [edx+EVENT.state], EVENT_SIGNALED |
|
- | 366 | jnz .done |
|
- | 367 | ||
- | 368 | test ecx, EVENT_WATCHED |
|
- | 369 | jz @F |
|
- | 370 | test [edx+EVENT.state], EVENT_WATCHED |
|
- | 371 | jz .done |
|
- | 372 | @@: |
|
- | 373 | shl eax, 8 |
|
- | 374 | add eax, PROC_BASE+APP_EV_OFFSET |
|
- | 375 | ||
- | 376 | pushfd |
|
- | 377 | cli |
|
- | 378 | mov ebx, [edx+APPOBJ.fd] |
|
- | 379 | mov ecx, [edx+APPOBJ.bk] |
|
- | 380 | mov [ebx+APPOBJ.bk], ecx |
|
- | 381 | mov [ecx+APPOBJ.fd], ebx |
|
- | 382 | ||
- | 383 | mov ecx, [eax+APPOBJ.fd] |
|
- | 384 | mov [edx+APPOBJ.fd], ecx |
|
- | 385 | mov [edx+APPOBJ.bk], eax |
|
- | 386 | mov [eax+APPOBJ.fd], edx |
|
- | 387 | mov [ecx+APPOBJ.bk], edx |
|
- | 388 | or [edx+EVENT.state], EVENT_SIGNALED |
|
- | 389 | ||
- | 390 | inc [eax+APPDATA.ev_count-APP_EV_OFFSET] |
|
- | 391 | or [eax+APPDATA.event_mask-APP_EV_OFFSET], EVENT_EXTENDED |
|
- | 392 | popfd |
|
- | 393 | .fail: |
|
- | 394 | .done: |
|
- | 395 | add esp, 4 |
|
- | 396 | ret |
|
- | 397 | restore .event |
|
- | 398 | ||
159 | 399 | sys_getevent: |
|
160 | sys_getevent: |
400 | |
161 | 401 | call get_event_for_app |
|
162 | call get_event_for_app |
402 | mov [esp+36],eax |
163 | mov [esp+36],eax |
403 | ret |
164 | ret |
404 | |
165 | 405 | ||
166 | 406 | align 4 |
|
167 | align 4 |
407 | sys_wait_event_timeout: |
168 | sys_wait_event_timeout: |
408 | |
169 | 409 | mov ebx,[timer_ticks] |
|
170 | mov ebx,[timer_ticks] |
410 | add ebx,eax |
171 | add ebx,eax |
411 | cmp ebx,[timer_ticks] |
172 | cmp ebx,[timer_ticks] |
412 | jna .swfet2 |
173 | jna .swfet2 |
413 | .swfet1: |
174 | .swfet1: |
414 | call get_event_for_app |
175 | call get_event_for_app |
415 | test eax,eax |
176 | test eax,eax |
416 | jne .eventoccur_time |
177 | jne .eventoccur_time |
417 | call change_task |
178 | call change_task |
418 | cmp ebx,[timer_ticks] |
179 | cmp ebx,[timer_ticks] |
419 | jg .swfet1 |
180 | jg .swfet1 |
420 | .swfet2: |
181 | .swfet2: |
421 | xor eax,eax |
182 | xor eax,eax |
422 | .eventoccur_time: |
183 | .eventoccur_time: |
423 | mov [esp+36],eax |
184 | mov [esp+36],eax |
424 | ret |
185 | ret |
425 | |
186 | 426 | ||
187 | 427 | align 4 |
|
188 | align 4 |
428 | |
189 | 429 | sys_waitforevent: |
|
190 | sys_waitforevent: |
430 | |
191 | 431 | call get_event_for_app |
|
192 | call get_event_for_app |
432 | test eax,eax |
193 | test eax,eax |
433 | jne eventoccur |
194 | jne eventoccur |
434 | newwait: |
195 | newwait: |
435 | |
196 | 436 | mov eax, [0x3010] |
|
197 | mov eax, [0x3010] |
437 | mov [eax+TASKDATA.state], byte 5 |
198 | mov [eax+TASKDATA.state], byte 5 |
438 | call change_task |
199 | call change_task |
439 | |
200 | 440 | mov eax, [event_sched] |
|
201 | mov eax, [event_sched] |
441 | |
202 | 442 | eventoccur: |
|
203 | eventoccur: |
443 | mov [esp+36],eax |
204 | mov [esp+36],eax |
444 | ret |
205 | ret |
445 | |
206 | 446 | get_event_for_app: |
|
207 | get_event_for_app: |
447 | |
208 | 448 | pushad |
|
209 | pushad |
449 | |
210 | 450 | mov edi,[0x3010] ; WINDOW REDRAW |
|
211 | mov edi,[0x3010] ; WINDOW REDRAW |
451 | test [edi+TASKDATA.event_mask],dword 1 |
212 | test [edi+TASKDATA.event_mask],dword 1 |
452 | jz no_eventoccur1 |
213 | jz no_eventoccur1 |
453 | ;mov edi,[0x3010] |
214 | ;mov edi,[0x3010] |
454 | cmp [edi-twdw+WDATA.fl_redraw],byte 0 |
215 | cmp [edi-twdw+WDATA.fl_redraw],byte 0 |
455 | je no_eventoccur1 |
216 | je no_eventoccur1 |
456 | popad |
217 | popad |
457 | mov eax,1 |
218 | mov eax,1 |
458 | ret |
219 | ret |
459 | no_eventoccur1: |
220 | no_eventoccur1: |
460 | |
221 | 461 | ;mov edi,[0x3010] ; KEY IN BUFFER |
|
222 | ;mov edi,[0x3010] ; KEY IN BUFFER |
462 | test [edi+TASKDATA.event_mask],dword 2 |
223 | test [edi+TASKDATA.event_mask],dword 2 |
463 | jz no_eventoccur2 |
224 | jz no_eventoccur2 |
464 | mov ecx, [0x3000] |
225 | mov ecx, [0x3000] |
465 | movzx edx,word [0xC000+ecx*2] |
226 | movzx edx,word [0xC000+ecx*2] |
466 | mov eax, [0x3004] |
227 | mov eax, [0x3004] |
467 | cmp eax,edx |
228 | cmp eax,edx |
468 | jne no_eventoccur2x |
229 | jne no_eventoccur2x |
469 | cmp [0xf400],byte 0 |
230 | cmp [0xf400],byte 0 |
470 | je no_eventoccur2x |
231 | je no_eventoccur2x |
471 | eventoccur2: |
232 | eventoccur2: |
472 | popad |
233 | popad |
473 | mov eax,2 |
234 | mov eax,2 |
474 | ret |
235 | ret |
475 | no_eventoccur2x: |
236 | no_eventoccur2x: |
476 | mov eax, hotkey_buffer |
237 | mov eax, hotkey_buffer |
477 | @@: |
238 | @@: |
478 | cmp [eax], ecx |
239 | cmp [eax], ecx |
479 | jz eventoccur2 |
240 | jz eventoccur2 |
480 | add eax, 8 |
241 | add eax, 8 |
481 | cmp eax, hotkey_buffer+120*8 |
242 | cmp eax, hotkey_buffer+120*8 |
482 | jb @b |
243 | jb @b |
483 | no_eventoccur2: |
244 | no_eventoccur2: |
484 | |
245 | 485 | ;mov edi,[0x3010] ; BUTTON IN BUFFER |
|
246 | ;mov edi,[0x3010] ; BUTTON IN BUFFER |
486 | test [edi+TASKDATA.event_mask],dword 4 |
247 | test [edi+TASKDATA.event_mask],dword 4 |
487 | jz no_eventoccur3 |
248 | jz no_eventoccur3 |
488 | cmp [0xf500],byte 0 |
249 | cmp [0xf500],byte 0 |
489 | je no_eventoccur3 |
250 | je no_eventoccur3 |
490 | mov ecx, [0x3000] |
251 | mov ecx, [0x3000] |
491 | movzx edx, word [0xC000+ecx*2] |
252 | movzx edx, word [0xC000+ecx*2] |
492 | mov eax, [0x3004] |
253 | mov eax, [0x3004] |
493 | cmp eax,edx |
254 | cmp eax,edx |
494 | jnz no_eventoccur3 |
255 | jnz no_eventoccur3 |
495 | popad |
256 | popad |
496 | mov eax,[0xf501] |
257 | mov eax,[0xf501] |
497 | cmp eax,65535 |
258 | cmp eax,65535 |
498 | je no_event_1 |
259 | je no_event_1 |
499 | mov eax,3 |
260 | mov eax,3 |
500 | ret |
261 | ret |
501 | |
262 | 502 | no_event_1: |
|
263 | no_event_1: |
503 | mov [window_minimize],1 |
264 | mov [window_minimize],1 |
504 | mov [0xf500],byte 0 |
265 | mov [0xf500],byte 0 |
505 | xor eax, eax |
266 | xor eax, eax |
506 | ret |
267 | ret |
507 | |
268 | 508 | no_eventoccur3: |
|
269 | no_eventoccur3: |
509 | |
270 | 510 | ||
271 | 511 | ;mov edi,[0x3010] ; mouse event |
|
272 | ;mov edi,[0x3010] ; mouse event |
512 | test [edi+TASKDATA.event_mask],dword 00100000b |
273 | test [edi+TASKDATA.event_mask],dword 00100000b |
513 | jz no_mouse_event |
274 | jz no_mouse_event |
514 | mov eax,[0x3000] |
275 | mov eax,[0x3000] |
515 | shl eax,8 |
276 | shl eax,8 |
516 | test [eax+0x80000+APPDATA.event_mask],dword 00100000b |
277 | test [eax+0x80000+APPDATA.event_mask],dword 00100000b |
517 | jz no_mouse_event |
278 | jz no_mouse_event |
518 | and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-00100000b |
279 | and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-00100000b |
519 | popad |
280 | popad |
520 | mov eax,6 |
281 | mov eax,6 |
521 | ret |
282 | ret |
522 | no_mouse_event: |
283 | no_mouse_event: |
523 | |
284 | 524 | ||
285 | 525 | ;mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW |
|
286 | ;mov edi,[0x3010] ; DESKTOP BACKGROUND REDRAW |
526 | test [edi+TASKDATA.event_mask],dword 16 |
287 | test [edi+TASKDATA.event_mask],dword 16 |
527 | jz no_eventoccur5 |
288 | jz no_eventoccur5 |
528 | cmp [0xfff0],byte 2 |
289 | cmp [0xfff0],byte 2 |
529 | jnz no_eventoccur5 |
290 | jnz no_eventoccur5 |
530 | popad |
291 | popad |
531 | mov eax,5 |
292 | mov eax,5 |
532 | ret |
293 | ret |
533 | no_eventoccur5: |
294 | no_eventoccur5: |
534 | |
295 | 535 | ;mov edi,[0x3010] ; IPC |
|
296 | ;mov edi,[0x3010] ; IPC |
536 | test [edi+TASKDATA.event_mask],dword 01000000b |
297 | test [edi+TASKDATA.event_mask],dword 01000000b |
537 | jz no_ipc |
298 | jz no_ipc |
538 | mov eax,[0x3000] |
299 | mov eax,[0x3000] |
539 | shl eax,8 |
300 | shl eax,8 |
540 | test [eax+0x80000+APPDATA.event_mask],dword 01000000b |
301 | test [eax+0x80000+APPDATA.event_mask],dword 01000000b |
541 | jz no_ipc |
302 | jz no_ipc |
542 | and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-01000000b |
303 | and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-01000000b |
543 | popad |
304 | popad |
544 | mov eax,7 |
305 | mov eax,7 |
545 | ret |
306 | ret |
546 | no_ipc: |
307 | no_ipc: |
547 | |
308 | 548 | ||
309 | 549 | ;mov edi,[0x3010] ; STACK |
|
310 | ;mov edi,[0x3010] ; STACK |
550 | test [edi+TASKDATA.event_mask],dword 10000000b |
311 | test [edi+TASKDATA.event_mask],dword 10000000b |
551 | jz no_stack_event |
312 | jz no_stack_event |
552 | mov eax,[0x3000] |
313 | mov eax,[0x3000] |
553 | shl eax,8 |
314 | shl eax,8 |
554 | test [eax+0x80000+APPDATA.event_mask],dword 10000000b |
315 | test [eax+0x80000+APPDATA.event_mask],dword 10000000b |
555 | jz no_stack_event |
316 | jz no_stack_event |
556 | and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-10000000b |
317 | and [eax+0x80000+APPDATA.event_mask],dword 0xffffffff-10000000b |
557 | popad |
318 | popad |
558 | mov eax,8 |
319 | mov eax,8 |
559 | ret |
320 | ret |
560 | no_stack_event: |
321 | no_stack_event: |
561 | |
322 | 562 | test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG |
|
323 | test byte [edi+TASKDATA.event_mask+1], 1 ; DEBUG |
563 | jz .test_IRQ |
324 | jz .test_ext |
564 | mov eax, [0x3000] |
325 | mov eax, [0x3000] |
565 | shl eax, 8 |
326 | shl eax, 8 |
566 | test byte [eax+0x80000+APPDATA.event_mask+1], byte 1 |
327 | test byte [eax+0x80000+APPDATA.event_mask+1], byte 1 |
567 | jz .test_IRQ |
328 | jz .test_ext |
568 | and byte [eax+0x80000+APPDATA.event_mask+1], not 1 |
329 | and byte [eax+0x80000+APPDATA.event_mask+1], not 1 |
569 | popad |
330 | popad |
570 | mov eax, 9 |
331 | mov eax, 9 |
571 | ret |
332 | ret |
572 | |
333 | 573 | ;.test_ext: |
|
334 | .test_ext: |
574 | ; mov eax, [0x3000] |
335 | mov eax, [0x3000] |
575 | ; shl eax, 8 |
336 | shl eax, 8 |
576 | ; test dword [eax+0x80000+APPDATA.event_mask], EVENT_EXTENDED |
337 | test dword [eax+0x80000+APPDATA.event_mask], EVENT_EXTENDED |
577 | ; jz .test_IRQ |
- | 578 | ; popad |
|
338 | jz .test_IRQ |
579 | ; mov eax, 10 |
339 | mov eax, 10 |
580 | ; ret |
340 | ret |
581 | |
341 | - | ||
342 | .test_IRQ: |
- | |
343 | 582 | .test_IRQ: |
|
344 | 583 | cmp dword [edi+TASKDATA.event_mask], 0xFFFF |
|
345 | cmp dword [edi+TASKDATA.event_mask], 0xFFFF |
584 | jbe no_events |
346 | jbe no_events |
585 | |
347 | 586 | mov esi,0x2e0000 ; IRQ'S AND DATA |
|
348 | mov esi,0x2e0000 ; IRQ'S AND DATA |
587 | mov ebx,0x00010000 |
349 | mov ebx,0x00010000 |
588 | xor ecx, ecx |
350 | xor ecx, ecx |
589 | irq_event_test: |
351 | irq_event_test: |
590 | mov edi,[0x3010] |
352 | mov edi,[0x3010] |
591 | test [edi+TASKDATA.event_mask],ebx |
353 | test [edi+TASKDATA.event_mask],ebx |
592 | jz no_irq_event |
354 | jz no_irq_event |
593 | mov edi,ecx |
355 | mov edi,ecx |
594 | shl edi,2 |
356 | shl edi,2 |
595 | add edi,irq_owner |
357 | add edi,irq_owner |
596 | mov edx,[edi] |
358 | mov edx,[edi] |
597 | mov eax,[0x3010] |
359 | mov eax,[0x3010] |
598 | mov eax,[eax+TASKDATA.pid] |
360 | mov eax,[eax+TASKDATA.pid] |
599 | cmp edx,eax |
361 | cmp edx,eax |
600 | jne no_irq_event |
362 | jne no_irq_event |
601 | cmp [esi],dword 0 |
363 | cmp [esi],dword 0 |
602 | jz no_irq_event |
364 | jz no_irq_event |
603 | mov eax,ecx |
365 | mov eax,ecx |
604 | add eax,16 |
366 | add eax,16 |
605 | mov [esp+28],eax |
367 | mov [esp+28],eax |
606 | popad |
368 | popad |
607 | ret |
369 | ret |
608 | no_irq_event: |
370 | no_irq_event: |
609 | add esi,0x1000 |
371 | add esi,0x1000 |
610 | shl ebx,1 |
372 | shl ebx,1 |
611 | inc ecx |
373 | inc ecx |
612 | cmp ecx,16 |
374 | cmp ecx,16 |
613 | jb irq_event_test |
375 | jb irq_event_test |
614 | |
376 | 615 | no_events: |
|
377 | no_events: |
616 | popad |
378 | popad |
617 | xor eax, eax |
379 | xor eax, eax |
618 | ret |
380 | ret |
- |