Rev 847 | Rev 849 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
||
709 | diamond | 3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. |
431 | serge | 4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
||
6 | ;; Marat Zakiyanov (Mario79) |
||
7 | ;; VaStaNi |
||
8 | ;; Trans |
||
9 | ;; Mihail Semenyako (mike.dld) |
||
10 | ;; Sergey Kuzmin (Wildwest) |
||
11 | ;; Andrey Halyavin (halyavin) |
||
12 | ;; Mihail Lisovin (Mihasik) |
||
13 | ;; Andrey Ignatiev (andrew_programmer) |
||
14 | ;; NoName |
||
15 | ;; Evgeny Grechnikov (Diamond) |
||
16 | ;; Iliya Mihailov (Ghost) |
||
17 | ;; Sergey Semyonov (Serge) |
||
18 | ;; Johnny_B |
||
543 | spraid | 19 | ;; SPraid (simba) |
1 | ha | 20 | ;; |
431 | serge | 21 | ;; Data in this file was originally part of MenuetOS project which is |
22 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
||
23 | ;; part of KolibriOS project under the terms of GNU GPL. |
||
1 | ha | 24 | ;; |
431 | serge | 25 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
26 | ;; PROGRAMMING: |
||
1 | ha | 27 | ;; |
431 | serge | 28 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
29 | ;; - main os coding/design |
||
30 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
||
31 | ;; Felix Kaiser, info@felix-kaiser.de |
||
32 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
||
33 | ;; quickcode@mail.ru |
||
34 | ;; Alexey, kgaz@crosswinds.net |
||
35 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
||
36 | ;; kristol@nic.fi |
||
37 | ;; Mike Hibbett, mikeh@oceanfree.net |
||
38 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
||
39 | ;; Jarek Pelczar, jarekp3@wp.pl |
||
1 | ha | 40 | ;; |
431 | serge | 41 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
42 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
||
43 | ;; consequences of using it or for whether it serves any particular purpose or |
||
44 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
||
45 | ;; License (the "GPL") for full details. |
||
46 | ; |
||
47 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
||
48 | ;; but only under the conditions described in the GPL. A copy of this license |
||
49 | ;; is supposed to have been given to you along with KolibriOS so you can know |
||
50 | ;; your rights and responsibilities. It should be in a file named COPYING. |
||
51 | ;; Among other things, the copyright notice and this notice must be preserved |
||
52 | ;; on all copies. |
||
53 | ;; |
||
1 | ha | 54 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
426 | mikedld | 55 | |
56 | include 'macros.inc' |
||
57 | |||
425 | victor | 58 | $Revision: 848 $ |
426 | mikedld | 59 | |
593 | mikedld | 60 | |
841 | serge | 61 | fastcall equ call |
62 | |||
769 | Rus | 63 | USE_COM_IRQ equ 1 ;make irq 3 and irq 4 available for PCI devices |
566 | serge | 64 | |
164 | serge | 65 | include "proc32.inc" |
7 | me_root | 66 | include "kglobals.inc" |
1 | ha | 67 | include "lang.inc" |
68 | |||
164 | serge | 69 | include "const.inc" |
742 | Rus | 70 | max_processes equ 255 |
71 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
||
1 | ha | 72 | |
164 | serge | 73 | |
742 | Rus | 74 | os_stack equ (os_data_l-gdts) ; GDTs |
465 | serge | 75 | os_code equ (os_code_l-gdts) |
76 | graph_data equ (3+graph_data_l-gdts) |
||
742 | Rus | 77 | tss0 equ (tss0_l-gdts) |
465 | serge | 78 | app_code equ (3+app_code_l-gdts) |
79 | app_data equ (3+app_data_l-gdts) |
||
586 | serge | 80 | pci_code_sel equ (pci_code_32-gdts) |
81 | pci_data_sel equ (pci_data_32-gdts) |
||
1 | ha | 82 | |
83 | |||
84 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
85 | ;; |
||
86 | ;; Included files: |
||
87 | ;; |
||
88 | ;; Kernel16.inc |
||
89 | ;; - Booteng.inc English text for bootup |
||
90 | ;; - Bootcode.inc Hardware setup |
||
91 | ;; - Pci16.inc PCI functions |
||
92 | ;; |
||
93 | ;; Kernel32.inc |
||
94 | ;; - Sys32.inc Process management |
||
95 | ;; - Shutdown.inc Shutdown and restart |
||
96 | ;; - Fat32.inc Read / write hd |
||
97 | ;; - Vesa12.inc Vesa 1.2 driver |
||
98 | ;; - Vesa20.inc Vesa 2.0 driver |
||
99 | ;; - Vga.inc VGA driver |
||
100 | ;; - Stack.inc Network interface |
||
101 | ;; - Mouse.inc Mouse pointer |
||
102 | ;; - Scincode.inc Window skinning |
||
103 | ;; - Pci32.inc PCI functions |
||
104 | ;; |
||
105 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
106 | |||
107 | |||
847 | serge | 108 | use32 |
109 | org 0x100000 |
||
1 | ha | 110 | |
847 | serge | 111 | mboot: |
112 | dd 0x1BADB002 |
||
113 | dd 0x00010003 |
||
114 | dd -(0x1BADB002 + 0x00010003) |
||
115 | dd mboot |
||
116 | dd 0x100000 |
||
117 | dd __edata - OS_BASE |
||
118 | dd LAST_PAGE |
||
119 | dd __start |
||
1 | ha | 120 | |
847 | serge | 121 | align 16 |
122 | __start: |
||
123 | cld |
||
1 | ha | 124 | |
847 | serge | 125 | mov esp, __os_stack-OS_BASE |
126 | push 0 |
||
127 | popf |
||
1 | ha | 128 | |
847 | serge | 129 | cmp eax, 0x2BADB002 |
130 | mov ecx, sz_invboot |
||
131 | jne .fault |
||
1 | ha | 132 | |
847 | serge | 133 | bt dword [ebx], 3 |
134 | mov ecx, sz_nomods |
||
135 | jnc .fault |
||
1 | ha | 136 | |
847 | serge | 137 | bt dword [ebx], 6 |
138 | mov ecx, sz_nommap |
||
139 | jnc .fault |
||
1 | ha | 140 | |
847 | serge | 141 | mov [_boot_mbi-OS_BASE], ebx |
1 | ha | 142 | |
847 | serge | 143 | xor eax, eax |
144 | cpuid |
||
145 | cmp eax, 0 |
||
146 | mov ecx, sz_nopse |
||
147 | jbe .fault |
||
1 | ha | 148 | |
847 | serge | 149 | mov eax, 1 |
150 | cpuid |
||
151 | bt edx, 3 |
||
152 | mov ecx, sz_nopse |
||
153 | jnc .fault |
||
1 | ha | 154 | |
847 | serge | 155 | ; ENABLE PAGING |
1 | ha | 156 | |
847 | serge | 157 | mov ecx, 32 |
158 | mov edi, _sys_pdbr+(OS_BASE shr 20)-OS_BASE |
||
159 | mov eax, PG_LARGE+PG_SW |
||
160 | @@: |
||
161 | stosd |
||
162 | add eax, 4*1024*1024 |
||
163 | loop @B |
||
465 | serge | 164 | |
847 | serge | 165 | mov dword [_sys_pdbr-OS_BASE], PG_LARGE+PG_SW |
166 | mov dword [_sys_pdbr-OS_BASE+4], PG_LARGE+PG_SW+4*1024*1024 |
||
848 | serge | 167 | mov dword [_sys_pdbr-OS_BASE+(page_tabs shr 20)], _sys_pdbr+PG_SW-OS_BASE |
1 | ha | 168 | |
847 | serge | 169 | mov ebx, cr4 |
170 | or ebx, CR4_PSE |
||
171 | and ebx, not CR4_PAE |
||
172 | mov cr4, ebx |
||
1 | ha | 173 | |
847 | serge | 174 | mov eax, _sys_pdbr-OS_BASE |
175 | mov ebx, cr0 |
||
176 | or ebx,CR0_PG+CR0_WP |
||
183 | diamond | 177 | |
847 | serge | 178 | mov cr3, eax |
179 | mov cr0, ebx |
||
375 | Ghost | 180 | |
847 | serge | 181 | mov ebx, [_boot_mbi] |
1 | ha | 182 | |
847 | serge | 183 | mov edx, [ebx+20] |
184 | mov esi, [ebx+24] |
||
185 | mov ecx, LAST_PAGE |
||
186 | test edx, edx |
||
187 | jz .no_mods |
||
188 | .scan_mod: |
||
189 | mov ecx, [esi+4] |
||
190 | add esi, 16 |
||
191 | dec edx |
||
192 | jnz .scan_mod |
||
1 | ha | 193 | |
847 | serge | 194 | .no_mods: |
195 | add ecx, 4095 |
||
196 | and ecx, not 4095 |
||
1 | ha | 197 | |
847 | serge | 198 | lgdt [gdts] |
199 | jmp pword os_code:high_code |
||
1 | ha | 200 | |
847 | serge | 201 | |
202 | .fault: |
||
203 | ; push ecx |
||
204 | ; call _lcls |
||
205 | ; call __bprintf |
||
206 | _hlt: |
||
207 | hlt |
||
208 | jmp _hlt |
||
209 | |||
210 | sz_invboot db 'Invalid multiboot loader magic value',0x0A |
||
211 | db 'Halted',0 |
||
212 | |||
213 | sz_nomods db 'No modules loaded',0x0A |
||
214 | db 'Halted',0 |
||
215 | |||
216 | sz_nommap db 'No memory table', 0x0A |
||
217 | db 'Halted',0 |
||
218 | |||
219 | sz_nopse db 'Page size extensions not supported',0x0A |
||
220 | db 'Halted',0 |
||
221 | |||
848 | serge | 222 | org $-0x100000 |
847 | serge | 223 | |
848 | serge | 224 | align 4 |
847 | serge | 225 | |
848 | serge | 226 | _enter_bootscreen: |
227 | |||
228 | use16 |
||
229 | mov eax, cr0 |
||
230 | and eax, not 0x80000001 |
||
231 | mov cr0, eax |
||
232 | jmp far 0x1000:start_of_code |
||
233 | |||
234 | version db 'Kolibri OS version 0.7.1.0 ',13,10,13,10,0 |
||
235 | |||
236 | include "boot/bootstr.inc" ; language-independent boot messages |
||
237 | include "boot/preboot.inc" |
||
238 | |||
239 | if lang eq en |
||
240 | include "boot/booteng.inc" ; english system boot messages |
||
241 | else if lang eq ru |
||
242 | include "boot/bootru.inc" ; russian system boot messages |
||
243 | include "boot/ru.inc" ; Russian font |
||
244 | else if lang eq et |
||
245 | include "boot/bootet.inc" ; estonian system boot messages |
||
246 | include "boot/et.inc" ; Estonian font |
||
247 | else |
||
248 | include "boot/bootge.inc" ; german system boot messages |
||
249 | end if |
||
250 | |||
251 | include "data16.inc" |
||
252 | |||
253 | include "boot/bootcode.inc" ; 16 bit system boot code |
||
254 | include "bus/pci/pci16.inc" |
||
255 | include "detect/biosdisk.inc" |
||
256 | |||
257 | ;include "boot/shutdown.inc" ; shutdown or restart |
||
258 | |||
259 | cli |
||
260 | |||
261 | mov eax, cr0 |
||
262 | or eax, 0x80000001 |
||
263 | mov cr0, eax |
||
264 | |||
265 | jmp pword os_code:__setvars |
||
266 | |||
267 | org $+0x100000 |
||
268 | |||
269 | align 4 |
||
270 | _leave_bootscreen: |
||
271 | |||
272 | use32 |
||
273 | |||
274 | |||
465 | serge | 275 | ; CLEAR 0x280000 - HEAP_BASE |
1 | ha | 276 | |
847 | serge | 277 | ; xor eax,eax |
278 | ; mov edi,0x280000 |
||
279 | ; mov ecx,(0x800000-0x280000) / 4 |
||
280 | ; cld |
||
281 | ; rep stosd |
||
1 | ha | 282 | |
847 | serge | 283 | ; mov edi,0x40000 |
284 | ; mov ecx,(0x90000-0x40000)/4 |
||
285 | ; rep stosd |
||
1 | ha | 286 | |
465 | serge | 287 | ; CLEAR KERNEL UNDEFINED GLOBALS |
847 | serge | 288 | ; mov edi, endofcode-OS_BASE |
289 | ; mov ecx, (uglobals_size/4)+4 |
||
290 | ; rep stosd |
||
1 | ha | 291 | |
292 | |||
847 | serge | 293 | ; call test_cpu |
742 | Rus | 294 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
424 | spraid | 295 | |
847 | serge | 296 | ; call init_BIOS32 |
837 | serge | 297 | |
848 | serge | 298 | ; mov dword [sys_pgdir-OS_BASE], PG_LARGE+PG_SW |
299 | ; mov dword [sys_pgdir-OS_BASE+4], PG_LARGE+PG_SW+4*1024*1024 |
||
1 | ha | 300 | |
848 | serge | 301 | ; mov ecx, 32 |
302 | ; lea edi, [sys_pgdir-OS_BASE+0xE00] |
||
303 | ; mov eax, PG_LARGE+PG_SW |
||
304 | ;@@: |
||
305 | ; stosd |
||
306 | ; add eax, 4*1024*1024 |
||
307 | ; loop @B |
||
837 | serge | 308 | |
848 | serge | 309 | ; mov ebx, cr4 |
310 | ; or ebx, CR4_PSE |
||
311 | ; and ebx, not CR4_PAE |
||
312 | ; mov cr4, ebx |
||
839 | serge | 313 | |
1 | ha | 314 | |
848 | serge | 315 | ; mov eax, sys_pgdir-OS_BASE |
316 | ; mov ebx, cr0 |
||
317 | ; or ebx,CR0_PG+CR0_WP |
||
1 | ha | 318 | |
848 | serge | 319 | ; mov cr3, eax |
320 | ; mov cr0, ebx |
||
1 | ha | 321 | |
848 | serge | 322 | ; lgdt [gdts] |
323 | ; jmp pword os_code:high_code |
||
1 | ha | 324 | |
513 | serge | 325 | align 4 |
742 | Rus | 326 | bios32_entry dd ? |
327 | tmp_page_tabs dd ? |
||
586 | serge | 328 | |
498 | diamond | 329 | |
465 | serge | 330 | __DEBUG__ fix 1 |
331 | __DEBUG_LEVEL__ fix 1 |
||
380 | serge | 332 | |
848 | serge | 333 | |
465 | serge | 334 | org OS_BASE+$ |
1 | ha | 335 | |
839 | serge | 336 | MEM_WB equ 6 ;write-back memory |
337 | MEM_WC equ 1 ;write combined memory |
||
338 | MEM_UC equ 0 ;uncached memory |
||
339 | |||
340 | |||
846 | serge | 341 | include 'printf.inc' |
843 | serge | 342 | include 'core/mm.asm' |
839 | serge | 343 | |
847 | serge | 344 | include 'core/init.asm' |
839 | serge | 345 | |
346 | align 4 |
||
847 | serge | 347 | proc test_cpu |
348 | locals |
||
349 | cpu_type dd ? |
||
350 | cpu_id dd ? |
||
351 | cpu_Intel dd ? |
||
352 | cpu_AMD dd ? |
||
353 | endl |
||
354 | |||
355 | mov [cpu_type], 0 |
||
356 | xor eax, eax |
||
357 | mov [cpu_caps], eax |
||
358 | mov [cpu_caps+4], eax |
||
359 | |||
360 | pushfd |
||
361 | pop eax |
||
362 | mov ecx, eax |
||
363 | xor eax, 0x40000 |
||
364 | push eax |
||
365 | popfd |
||
366 | pushfd |
||
367 | pop eax |
||
368 | xor eax, ecx |
||
369 | mov [cpu_type], CPU_386 |
||
370 | jz .end_cpuid |
||
371 | push ecx |
||
372 | popfd |
||
373 | |||
374 | mov [cpu_type], CPU_486 |
||
375 | mov eax, ecx |
||
376 | xor eax, 0x200000 |
||
377 | push eax |
||
378 | popfd |
||
379 | pushfd |
||
380 | pop eax |
||
381 | xor eax, ecx |
||
382 | je .end_cpuid |
||
383 | mov [cpu_id], 1 |
||
384 | |||
385 | xor eax, eax |
||
386 | cpuid |
||
387 | |||
388 | mov [cpu_vendor], ebx |
||
389 | mov [cpu_vendor+4], edx |
||
390 | mov [cpu_vendor+8], ecx |
||
391 | cmp ebx, dword [intel_str] |
||
392 | jne .check_AMD |
||
393 | cmp edx, dword [intel_str+4] |
||
394 | jne .check_AMD |
||
395 | cmp ecx, dword [intel_str+8] |
||
396 | jne .check_AMD |
||
397 | mov [cpu_Intel], 1 |
||
398 | cmp eax, 1 |
||
399 | jl .end_cpuid |
||
400 | mov eax, 1 |
||
401 | cpuid |
||
402 | mov [cpu_sign], eax |
||
403 | mov [cpu_info], ebx |
||
404 | mov [cpu_caps], edx |
||
405 | mov [cpu_caps+4],ecx |
||
406 | |||
407 | shr eax, 8 |
||
408 | and eax, 0x0f |
||
409 | ret |
||
410 | .end_cpuid: |
||
411 | mov eax, [cpu_type] |
||
412 | ret |
||
413 | |||
414 | .check_AMD: |
||
415 | cmp ebx, dword [AMD_str] |
||
416 | jne .unknown |
||
417 | cmp edx, dword [AMD_str+4] |
||
418 | jne .unknown |
||
419 | cmp ecx, dword [AMD_str+8] |
||
420 | jne .unknown |
||
421 | mov [cpu_AMD], 1 |
||
422 | cmp eax, 1 |
||
423 | jl .unknown |
||
424 | mov eax, 1 |
||
425 | cpuid |
||
426 | mov [cpu_sign], eax |
||
427 | mov [cpu_info], ebx |
||
428 | mov [cpu_caps], edx |
||
429 | mov [cpu_caps+4],ecx |
||
430 | shr eax, 8 |
||
431 | and eax, 0x0f |
||
432 | ret |
||
433 | .unknown: |
||
434 | mov eax, 1 |
||
435 | cpuid |
||
436 | mov [cpu_sign], eax |
||
437 | mov [cpu_info], ebx |
||
438 | mov [cpu_caps], edx |
||
439 | mov [cpu_caps+4],ecx |
||
440 | shr eax, 8 |
||
441 | and eax, 0x0f |
||
442 | ret |
||
443 | endp |
||
444 | |||
445 | align 4 |
||
465 | serge | 446 | high_code: |
742 | Rus | 447 | mov ax,os_stack |
847 | serge | 448 | mov dx,app_data |
742 | Rus | 449 | mov ss,ax |
847 | serge | 450 | mov esp, __os_stack |
1 | ha | 451 | |
847 | serge | 452 | mov ds, dx |
453 | mov es, dx |
||
454 | mov fs, dx |
||
455 | mov gs, dx |
||
1 | ha | 456 | |
847 | serge | 457 | push ecx |
458 | push ebx |
||
839 | serge | 459 | |
847 | serge | 460 | ; mov dword [sys_pgdir-OS_BASE+(page_tabs shr 20)], sys_pgdir+PG_SW-OS_BASE |
1 | ha | 461 | |
847 | serge | 462 | ; bt [cpu_caps], CAPS_PGE |
463 | ; jnc @F |
||
519 | serge | 464 | |
847 | serge | 465 | ; or dword [sys_pgdir-OS_BASE+(OS_BASE shr 20)], PG_GLOBAL |
466 | |||
467 | ; mov ebx, cr4 |
||
468 | ; or ebx, CR4_PGE |
||
469 | ; mov cr4, ebx |
||
519 | serge | 470 | @@: |
847 | serge | 471 | ; xor eax, eax |
472 | ; mov dword [sys_pgdir], eax |
||
473 | ; mov dword [sys_pgdir+4], eax |
||
519 | serge | 474 | |
847 | serge | 475 | ; mov eax, cr3 |
476 | ; mov cr3, eax ; flush TLB |
||
465 | serge | 477 | |
846 | serge | 478 | mov edx, 0x3fB |
479 | mov eax, 3 |
||
480 | out dx, al |
||
481 | |||
847 | serge | 482 | call test_cpu |
483 | call _init |
||
839 | serge | 484 | |
841 | serge | 485 | mov [tss._ss0], os_stack |
847 | serge | 486 | mov [tss._esp0], __os_stack |
487 | mov [tss._esp], __os_stack |
||
841 | serge | 488 | mov [tss._cs],os_code |
489 | mov [tss._ss],os_stack |
||
490 | mov [tss._ds],app_data |
||
491 | mov [tss._es],app_data |
||
492 | mov [tss._fs],app_data |
||
493 | mov [tss._gs],app_data |
||
494 | mov [tss._io],128 |
||
495 | ;Add IO access table - bit array of permitted ports |
||
496 | mov edi, tss._io_map_0 |
||
497 | xor eax, eax |
||
498 | not eax |
||
499 | mov ecx, 8192/4 |
||
500 | rep stosd ; access to 4096*8=65536 ports |
||
501 | |||
502 | mov ax,tss0 |
||
503 | ltr ax |
||
504 | |||
847 | serge | 505 | mov ecx, 1280*1024 |
506 | fastcall _balloc |
||
507 | mov [_display_data], eax |
||
508 | |||
509 | mov ecx, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
||
510 | (unpack.lc+unpack.lp)))*4 |
||
511 | fastcall _balloc |
||
512 | mov [unpack.p], eax |
||
513 | |||
514 | ; MEMORY MODEL |
||
515 | |||
841 | serge | 516 | call init_kernel_heap ; FIXME initialize heap after pager |
517 | |||
843 | serge | 518 | call _init_mm |
519 | mov [pg_data.pg_mutex], 0 |
||
839 | serge | 520 | |
848 | serge | 521 | mov esi, 0x100000 |
522 | mov ecx, (_leave_bootscreen-0x100000)/4 |
||
523 | mov edi, 0x10000 |
||
524 | cld |
||
525 | rep movsd |
||
847 | serge | 526 | |
848 | serge | 527 | jmp far 0x60:_enter_bootscreen; |
847 | serge | 528 | |
848 | serge | 529 | align 4 |
530 | __setvars: |
||
531 | mov ax,os_stack |
||
532 | mov dx,app_data |
||
533 | mov ss,ax |
||
534 | mov esp, __os_stack |
||
535 | |||
536 | mov ds, dx |
||
537 | mov es, dx |
||
538 | mov fs, dx |
||
539 | mov gs, dx |
||
540 | |||
541 | ; SAVE & CLEAR 0-0xffff |
||
542 | |||
543 | xor esi, esi |
||
544 | mov edi,0x2F0000 |
||
545 | mov ecx,0x10000 / 4 |
||
546 | rep movsd |
||
547 | xor edi, edi |
||
548 | xor eax, eax |
||
549 | mov ecx,0x10000 / 4 |
||
550 | rep stosd |
||
551 | |||
1 | ha | 552 | ; SAVE REAL MODE VARIABLES |
742 | Rus | 553 | mov ax, [BOOT_VAR + 0x9031] |
554 | mov [IDEContrRegsBaseAddr], ax |
||
76 | mario79 | 555 | ; --------------- APM --------------------- |
465 | serge | 556 | |
557 | ; init selectors |
||
848 | serge | 558 | mov ebx, [BOOT_VAR +0x9040] ; offset of APM entry point |
465 | serge | 559 | movzx eax, word [BOOT_VAR+0x9050] ; real-mode segment base address of |
742 | Rus | 560 | ; protected-mode 32-bit code segment |
465 | serge | 561 | movzx ecx, word [BOOT_VAR+0x9052] ; real-mode segment base address of |
742 | Rus | 562 | ; protected-mode 16-bit code segment |
465 | serge | 563 | movzx edx, word [BOOT_VAR+0x9054] ; real-mode segment base address of |
742 | Rus | 564 | ; protected-mode 16-bit data segment |
465 | serge | 565 | |
566 | shl eax, 4 |
||
567 | mov [dword apm_code_32 + 2], ax |
||
568 | shr eax, 16 |
||
569 | mov [dword apm_code_32 + 4], al |
||
570 | |||
571 | shl ecx, 4 |
||
572 | mov [dword apm_code_16 + 2], cx |
||
573 | shr ecx, 16 |
||
574 | mov [dword apm_code_16 + 4], cl |
||
575 | |||
576 | shl edx, 4 |
||
577 | mov [dword apm_data_16 + 2], dx |
||
578 | shr edx, 16 |
||
579 | mov [dword apm_data_16 + 4], dl |
||
580 | |||
581 | mov dword[apm_entry], ebx |
||
76 | mario79 | 582 | mov word [apm_entry + 4], apm_code_32 - gdts |
583 | |||
465 | serge | 584 | mov eax, [BOOT_VAR + 0x9044] ; version & flags |
76 | mario79 | 585 | mov [apm_vf], eax |
586 | ; ----------------------------------------- |
||
465 | serge | 587 | ; movzx eax,byte [BOOT_VAR+0x9010] ; mouse port |
1 | ha | 588 | ; mov [0xF604],byte 1 ;al |
742 | Rus | 589 | mov al, [BOOT_VAR+0x901F] ; DMA access |
590 | mov [allow_dma_access], al |
||
591 | mov al,[BOOT_VAR+0x9000] ; bpp |
||
592 | mov [ScreenBPP],al |
||
753 | serge | 593 | |
742 | Rus | 594 | movzx eax,word [BOOT_VAR+0x900A] ; X max |
595 | dec eax |
||
759 | Rus | 596 | mov [Screen_Max_X],eax |
742 | Rus | 597 | mov [screen_workarea.right],eax |
598 | movzx eax,word [BOOT_VAR+0x900C] ; Y max |
||
599 | dec eax |
||
759 | Rus | 600 | mov [Screen_Max_Y],eax |
742 | Rus | 601 | mov [screen_workarea.bottom],eax |
602 | movzx eax,word [BOOT_VAR+0x9008] ; screen mode |
||
603 | mov [SCR_MODE],eax |
||
604 | mov eax,[BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
||
605 | mov [BANK_SWITCH],eax |
||
606 | mov [BytesPerScanLine],word 640*4 ; Bytes PerScanLine |
||
607 | cmp [SCR_MODE],word 0x13 ; 320x200 |
||
608 | je @f |
||
609 | cmp [SCR_MODE],word 0x12 ; VGA 640x480 |
||
610 | je @f |
||
848 | serge | 611 | |
742 | Rus | 612 | mov ax,[BOOT_VAR+0x9001] ; for other modes |
613 | mov [BytesPerScanLine],ax |
||
465 | serge | 614 | @@: |
742 | Rus | 615 | mov esi, BOOT_VAR+0x9080 |
616 | movzx ecx, byte [esi-1] |
||
617 | mov [NumBiosDisks], ecx |
||
618 | mov edi, BiosDisksData |
||
619 | rep movsd |
||
1 | ha | 620 | |
621 | ; GRAPHICS ADDRESSES |
||
622 | |||
742 | Rus | 623 | mov byte [BOOT_VAR+0x901e],0x0 |
624 | mov eax,[BOOT_VAR+0x9018] |
||
625 | mov [LFBAddress],eax |
||
1 | ha | 626 | |
742 | Rus | 627 | cmp [SCR_MODE],word 0100000000000000b |
628 | jge setvesa20 |
||
629 | cmp [SCR_MODE],word 0x13 |
||
630 | je v20ga32 |
||
631 | mov [PUTPIXEL],dword Vesa12_putpixel24 ; Vesa 1.2 |
||
632 | mov [GETPIXEL],dword Vesa12_getpixel24 |
||
633 | cmp [ScreenBPP],byte 24 |
||
634 | jz ga24 |
||
635 | mov [PUTPIXEL],dword Vesa12_putpixel32 |
||
636 | mov [GETPIXEL],dword Vesa12_getpixel32 |
||
1 | ha | 637 | ga24: |
742 | Rus | 638 | jmp v20ga24 |
1 | ha | 639 | setvesa20: |
742 | Rus | 640 | mov [PUTPIXEL],dword Vesa20_putpixel24 ; Vesa 2.0 |
641 | mov [GETPIXEL],dword Vesa20_getpixel24 |
||
642 | cmp [ScreenBPP],byte 24 |
||
643 | jz v20ga24 |
||
1 | ha | 644 | v20ga32: |
742 | Rus | 645 | mov [PUTPIXEL],dword Vesa20_putpixel32 |
646 | mov [GETPIXEL],dword Vesa20_getpixel32 |
||
1 | ha | 647 | v20ga24: |
742 | Rus | 648 | cmp [SCR_MODE],word 0x12 ; 16 C VGA 640x480 |
649 | jne no_mode_0x12 |
||
650 | mov [PUTPIXEL],dword VGA_putpixel |
||
651 | mov [GETPIXEL],dword Vesa20_getpixel32 |
||
1 | ha | 652 | no_mode_0x12: |
653 | |||
375 | Ghost | 654 | ; -------- Fast System Call init ---------- |
378 | serge | 655 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
742 | Rus | 656 | bt [cpu_caps], CAPS_SEP |
657 | jnc .SEnP ; SysEnter not Present |
||
658 | xor edx, edx |
||
659 | mov ecx, MSR_SYSENTER_CS |
||
660 | mov eax, os_code |
||
661 | wrmsr |
||
662 | mov ecx, MSR_SYSENTER_ESP |
||
434 | diamond | 663 | ; mov eax, sysenter_stack ; Check it |
742 | Rus | 664 | xor eax, eax |
665 | wrmsr |
||
666 | mov ecx, MSR_SYSENTER_EIP |
||
667 | mov eax, sysenter_entry |
||
668 | wrmsr |
||
375 | Ghost | 669 | .SEnP: |
378 | serge | 670 | ; AMD SYSCALL/SYSRET |
742 | Rus | 671 | cmp byte[cpu_vendor], 'A' |
672 | jne .noSYSCALL |
||
673 | mov eax, 0x80000001 |
||
674 | cpuid |
||
675 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
||
676 | jz .noSYSCALL |
||
677 | mov ecx, MSR_AMD_EFER |
||
678 | rdmsr |
||
679 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
||
680 | wrmsr |
||
164 | serge | 681 | |
375 | Ghost | 682 | ; !!!! It`s dirty hack, fix it !!! |
683 | ; Bits of EDX : |
||
684 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
||
685 | ; and the contents of this field, plus 8, are copied into the SS register. |
||
686 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
||
687 | ; and the contents of this field, plus 8, are copied into the SS register. |
||
688 | |||
742 | Rus | 689 | ; mov edx, (os_code + 16) * 65536 + os_code |
690 | mov edx, 0x1B0008 |
||
375 | Ghost | 691 | |
742 | Rus | 692 | mov eax, syscall_entry |
693 | mov ecx, MSR_AMD_STAR |
||
694 | wrmsr |
||
375 | Ghost | 695 | .noSYSCALL: |
696 | ; ----------------------------------------- |
||
697 | |||
465 | serge | 698 | ; LOAD IDT |
378 | serge | 699 | |
742 | Rus | 700 | call build_interrupt_table |
701 | lidt [idtreg] |
||
378 | serge | 702 | |
841 | serge | 703 | mov [LFBSize], 0x800000 |
742 | Rus | 704 | call init_LFB |
841 | serge | 705 | call init_fpu |
742 | Rus | 706 | call init_malloc |
276 | serge | 707 | |
742 | Rus | 708 | stdcall alloc_kernel_space, 0x51000 |
709 | mov [default_io_map], eax |
||
465 | serge | 710 | |
742 | Rus | 711 | add eax, 0x2000 |
712 | mov [ipc_tmp], eax |
||
713 | mov ebx, 0x1000 |
||
164 | serge | 714 | |
742 | Rus | 715 | add eax, 0x40000 |
716 | mov [proc_mem_map], eax |
||
164 | serge | 717 | |
742 | Rus | 718 | add eax, 0x8000 |
719 | mov [proc_mem_pdir], eax |
||
164 | serge | 720 | |
742 | Rus | 721 | add eax, ebx |
722 | mov [proc_mem_tab], eax |
||
164 | serge | 723 | |
742 | Rus | 724 | add eax, ebx |
725 | mov [tmp_task_pdir], eax |
||
164 | serge | 726 | |
742 | Rus | 727 | add eax, ebx |
728 | mov [tmp_task_ptab], eax |
||
164 | serge | 729 | |
742 | Rus | 730 | add eax, ebx |
731 | mov [ipc_pdir], eax |
||
164 | serge | 732 | |
742 | Rus | 733 | add eax, ebx |
734 | mov [ipc_ptab], eax |
||
164 | serge | 735 | |
742 | Rus | 736 | call init_events |
737 | mov eax, srv.fd-SRV_FD_OFFSET |
||
738 | mov [srv.fd], eax |
||
739 | mov [srv.bk], eax |
||
278 | serge | 740 | |
742 | Rus | 741 | mov edi, irq_tab |
742 | xor eax, eax |
||
743 | mov ecx, 16 |
||
744 | rep stosd |
||
164 | serge | 745 | |
41 | mikedld | 746 | ;Set base of graphic segment to linear address of LFB |
742 | Rus | 747 | mov eax,[LFBAddress] ; set for gs |
748 | mov [graph_data_l+2],ax |
||
749 | shr eax,16 |
||
750 | mov [graph_data_l+4],al |
||
751 | mov [graph_data_l+7],ah |
||
1 | ha | 752 | |
742 | Rus | 753 | mov [CURRENT_TASK],dword 1 |
754 | mov [TASK_COUNT],dword 1 |
||
755 | mov [TASK_BASE],dword TASK_DATA |
||
756 | mov [current_slot], SLOT_BASE+256 |
||
429 | serge | 757 | |
469 | serge | 758 | ; set background |
742 | Rus | 759 | xor eax,eax |
760 | inc eax |
||
761 | mov [BgrDrawMode],eax |
||
762 | mov [BgrDataWidth],eax |
||
763 | mov [BgrDataHeight],eax |
||
764 | mov [mem_BACKGROUND],4095 |
||
765 | stdcall kernel_alloc, [mem_BACKGROUND] |
||
766 | mov [img_background], eax |
||
469 | serge | 767 | |
848 | serge | 768 | mov [SLOT_BASE + 256 + APPDATA.dir_table], _sys_pdbr - OS_BASE |
469 | serge | 769 | |
709 | diamond | 770 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
771 | |||
742 | Rus | 772 | call rerouteirqs |
709 | diamond | 773 | |
774 | ; Initialize system V86 machine |
||
742 | Rus | 775 | call init_sys_v86 |
709 | diamond | 776 | |
725 | diamond | 777 | ; TIMER SET TO 1/100 S |
778 | |||
742 | Rus | 779 | mov al,0x34 ; set to 100Hz |
780 | out 0x43,al |
||
781 | mov al,0x9b ; lsb 1193180 / 1193 |
||
782 | out 0x40,al |
||
783 | mov al,0x2e ; msb |
||
784 | out 0x40,al |
||
725 | diamond | 785 | |
786 | ; Enable timer IRQ (IRQ0) and hard drives IRQs (IRQ14, IRQ15) |
||
787 | ; they are used: when partitions are scanned, hd_read relies on timer |
||
742 | Rus | 788 | mov al, 0xFE |
789 | out 0x21, al |
||
790 | mov al, 0x3F |
||
791 | out 0xA1, al |
||
725 | diamond | 792 | |
256 | diamond | 793 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
794 | include 'detect/disks.inc' |
||
795 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
796 | |||
521 | diamond | 797 | call Parser_params |
798 | |||
1 | ha | 799 | ; READ RAMDISK IMAGE FROM HD |
800 | |||
801 | ;!!!!!!!!!!!!!!!!!!!!!!! |
||
846 | serge | 802 | ;include 'boot/rdload.inc' |
1 | ha | 803 | ;!!!!!!!!!!!!!!!!!!!!!!! |
804 | ; mov [dma_hdd],1 |
||
805 | ; CALCULATE FAT CHAIN FOR RAMDISK |
||
806 | |||
742 | Rus | 807 | call calculatefatchain |
1 | ha | 808 | |
809 | |||
847 | serge | 810 | ; mov ax,[OS_BASE+0x10000+bx_from_load] |
811 | ; cmp ax,'r1' ; if using not ram disk, then load librares and parameters {SPraid.simba} |
||
812 | ; je no_lib_load |
||
488 | spraid | 813 | ; LOADING LIBRARES |
847 | serge | 814 | ; stdcall dll.Load,@IMPORT ; loading librares for kernel (.obj files) |
815 | ; call load_file_parse_table ; prepare file parse table |
||
816 | ; call set_kernel_conf ; configure devices and gui |
||
817 | ;no_lib_load: |
||
488 | spraid | 818 | |
1 | ha | 819 | ; LOAD FONTS I and II |
820 | |||
742 | Rus | 821 | stdcall read_file, char, FONT_I, 0, 2304 |
848 | serge | 822 | stdcall read_file, char2, FONT_II, 0, 2560 |
490 | serge | 823 | |
742 | Rus | 824 | mov esi,boot_fonts |
825 | call boot_log |
||
1 | ha | 826 | |
827 | ; PRINT AMOUNT OF MEMORY |
||
742 | Rus | 828 | mov esi, boot_memdetect |
829 | call boot_log |
||
1 | ha | 830 | |
742 | Rus | 831 | movzx ecx, word [boot_y] |
832 | or ecx, (10+29*6) shl 16 ; "Determining amount of memory" |
||
833 | sub ecx, 10 |
||
834 | mov edx, 0xFFFFFF |
||
846 | serge | 835 | mov ebx, [_mem_amount] |
742 | Rus | 836 | shr ebx, 20 |
837 | mov edi, 1 |
||
838 | mov eax, 0x00040000 |
||
839 | call display_number_force |
||
41 | mikedld | 840 | |
465 | serge | 841 | ; BUILD SCHEDULER |
842 | |||
742 | Rus | 843 | call build_scheduler ; sys32.inc |
465 | serge | 844 | |
742 | Rus | 845 | mov esi,boot_devices |
846 | call boot_log |
||
567 | serge | 847 | |
742 | Rus | 848 | mov [pci_access_enabled],1 |
567 | serge | 849 | |
1 | ha | 850 | |
851 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
||
852 | |||
742 | Rus | 853 | mov esi,boot_windefs |
854 | call boot_log |
||
855 | call setwindowdefaults |
||
1 | ha | 856 | |
857 | ; SET BACKGROUND DEFAULTS |
||
858 | |||
742 | Rus | 859 | mov esi,boot_bgr |
860 | call boot_log |
||
861 | call init_background |
||
862 | call calculatebackground |
||
1 | ha | 863 | |
864 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
||
865 | |||
742 | Rus | 866 | mov esi,boot_resirqports |
867 | call boot_log |
||
868 | call reserve_irqs_ports |
||
1 | ha | 869 | |
870 | ; SET PORTS FOR IRQ HANDLERS |
||
871 | |||
742 | Rus | 872 | mov esi,boot_setrports |
873 | call boot_log |
||
769 | Rus | 874 | ;call setirqreadports |
1 | ha | 875 | |
876 | ; SET UP OS TASK |
||
877 | |||
742 | Rus | 878 | mov esi,boot_setostask |
879 | call boot_log |
||
214 | serge | 880 | |
742 | Rus | 881 | xor eax, eax |
882 | mov dword [SLOT_BASE+APPDATA.fpu_state], fpu_data |
||
883 | mov dword [SLOT_BASE+APPDATA.fpu_handler], eax |
||
884 | mov dword [SLOT_BASE+APPDATA.sse_handler], eax |
||
164 | serge | 885 | |
742 | Rus | 886 | ; name for OS/IDLE process |
281 | serge | 887 | |
742 | Rus | 888 | mov dword [SLOT_BASE+256+APPDATA.app_name], dword 'OS/I' |
889 | mov dword [SLOT_BASE+256+APPDATA.app_name+4], dword 'DLE ' |
||
847 | serge | 890 | mov edi, __os_stack-8192+512 |
742 | Rus | 891 | mov dword [SLOT_BASE+256+APPDATA.pl0_stack], edi |
892 | add edi, 0x2000-512 |
||
893 | mov dword [SLOT_BASE+256+APPDATA.fpu_state], edi |
||
894 | mov dword [SLOT_BASE+256+APPDATA.saved_esp0], edi ; just for case |
||
895 | mov dword [SLOT_BASE+256+APPDATA.io_map],\ |
||
896 | (tss._io_map_0-OS_BASE+PG_MAP) |
||
897 | mov dword [SLOT_BASE+256+APPDATA.io_map+4],\ |
||
898 | (tss._io_map_1-OS_BASE+PG_MAP) |
||
357 | serge | 899 | |
742 | Rus | 900 | mov esi, fpu_data |
901 | mov ecx, 512/4 |
||
902 | cld |
||
903 | rep movsd |
||
357 | serge | 904 | |
843 | serge | 905 | mov dword [SLOT_BASE+256+APPDATA.fpu_handler], eax |
742 | Rus | 906 | mov dword [SLOT_BASE+256+APPDATA.sse_handler], eax |
214 | serge | 907 | |
742 | Rus | 908 | mov ebx, SLOT_BASE+256+APP_OBJ_OFFSET |
909 | mov dword [SLOT_BASE+256+APPDATA.fd_obj], ebx |
||
910 | mov dword [SLOT_BASE+256+APPDATA.bk_obj], ebx |
||
281 | serge | 911 | |
742 | Rus | 912 | mov dword [SLOT_BASE+256+APPDATA.cur_dir], sysdir_path |
521 | diamond | 913 | |
742 | Rus | 914 | ; task list |
915 | mov [CURRENT_TASK],dword 1 |
||
916 | mov [TASK_COUNT],dword 1 |
||
917 | mov [current_slot], SLOT_BASE+256 |
||
918 | mov [TASK_BASE],dword TASK_DATA |
||
919 | mov [TASK_DATA+TASKDATA.wnd_number], 1 ; on screen number |
||
920 | mov [TASK_DATA+TASKDATA.pid], 1 ; process id number |
||
921 | mov [TASK_DATA+TASKDATA.mem_start], 0 ; process base address |
||
1 | ha | 922 | |
843 | serge | 923 | call init_cursors |
802 | serge | 924 | mov eax, [def_cursor] |
742 | Rus | 925 | mov [SLOT_BASE+APPDATA.cursor],eax |
926 | mov [SLOT_BASE+APPDATA.cursor+256],eax |
||
281 | serge | 927 | |
839 | serge | 928 | ; stdcall load_pe_driver, szAtiHW |
837 | serge | 929 | |
465 | serge | 930 | ; READ TSC / SECOND |
281 | serge | 931 | |
742 | Rus | 932 | mov esi,boot_tsc |
933 | call boot_log |
||
848 | serge | 934 | |
742 | Rus | 935 | call _rdtsc |
936 | mov ecx,eax |
||
937 | mov esi,250 ; wait 1/4 a second |
||
938 | call delay_ms |
||
939 | call _rdtsc |
||
848 | serge | 940 | |
742 | Rus | 941 | sub eax,ecx |
942 | shl eax,2 |
||
943 | mov [CPU_FREQ],eax ; save tsc / sec |
||
944 | mov ebx, 1000000 |
||
945 | div ebx |
||
946 | mov [stall_mcs], eax |
||
1 | ha | 947 | |
948 | ; SET VARIABLES |
||
949 | |||
742 | Rus | 950 | call set_variables |
1 | ha | 951 | |
774 | Rus | 952 | ; SET MOUSE |
953 | |||
954 | ;call detect_devices |
||
955 | stdcall load_driver, szPS2MDriver |
||
839 | serge | 956 | ; stdcall load_driver, szCOM_MDriver |
774 | Rus | 957 | |
958 | mov esi,boot_setmouse |
||
959 | call boot_log |
||
960 | call setmouse |
||
961 | |||
962 | |||
1 | ha | 963 | ; STACK AND FDC |
964 | |||
839 | serge | 965 | call stack_init |
742 | Rus | 966 | call fdc_init |
1 | ha | 967 | |
968 | ; PALETTE FOR 320x200 and 640x480 16 col |
||
969 | |||
742 | Rus | 970 | cmp [SCR_MODE],word 0x12 |
971 | jne no_pal_vga |
||
972 | mov esi,boot_pal_vga |
||
973 | call boot_log |
||
974 | call paletteVGA |
||
1 | ha | 975 | no_pal_vga: |
976 | |||
742 | Rus | 977 | cmp [SCR_MODE],word 0x13 |
978 | jne no_pal_ega |
||
979 | mov esi,boot_pal_ega |
||
980 | call boot_log |
||
981 | call palette320x200 |
||
1 | ha | 982 | no_pal_ega: |
983 | |||
984 | ; LOAD DEFAULT SKIN |
||
985 | |||
742 | Rus | 986 | call load_default_skin |
1 | ha | 987 | |
465 | serge | 988 | ;protect io permission map |
989 | |||
742 | Rus | 990 | mov esi, [default_io_map] |
991 | stdcall map_page,esi,(tss._io_map_0-OS_BASE), PG_MAP |
||
992 | add esi, 0x1000 |
||
993 | stdcall map_page,esi,(tss._io_map_1-OS_BASE), PG_MAP |
||
465 | serge | 994 | |
742 | Rus | 995 | stdcall map_page,tss._io_map_0,\ |
996 | (tss._io_map_0-OS_BASE), PG_MAP |
||
997 | stdcall map_page,tss._io_map_1,\ |
||
998 | (tss._io_map_1-OS_BASE), PG_MAP |
||
465 | serge | 999 | |
847 | serge | 1000 | ; mov ax,[OS_BASE+0x10000+bx_from_load] |
1001 | ; cmp ax,'r1' ; if not rused ram disk - load network configuration from files {SPraid.simba} |
||
1002 | ; je no_st_network |
||
1003 | ; call set_network_conf |
||
1004 | ; no_st_network: |
||
512 | spraid | 1005 | |
1 | ha | 1006 | ; LOAD FIRST APPLICATION |
501 | serge | 1007 | |
742 | Rus | 1008 | cmp byte [BOOT_VAR+0x9030],1 |
1009 | jne no_load_vrr_m |
||
237 | serge | 1010 | |
742 | Rus | 1011 | mov ebp, vrr_m |
1012 | call fs_execute_from_sysdir |
||
488 | spraid | 1013 | |
742 | Rus | 1014 | cmp eax,2 ; if vrr_m app found (PID=2) |
1015 | je first_app_found |
||
41 | mikedld | 1016 | |
237 | serge | 1017 | no_load_vrr_m: |
488 | spraid | 1018 | |
837 | serge | 1019 | |
742 | Rus | 1020 | mov ebp, firstapp |
1021 | call fs_execute_from_sysdir |
||
488 | spraid | 1022 | |
742 | Rus | 1023 | cmp eax,2 ; continue if a process has been loaded |
1024 | je first_app_found |
||
501 | serge | 1025 | |
742 | Rus | 1026 | mov esi, boot_failed |
1027 | call boot_log |
||
653 | diamond | 1028 | |
742 | Rus | 1029 | mov eax, 0xDEADBEEF ; otherwise halt |
1030 | hlt |
||
501 | serge | 1031 | |
237 | serge | 1032 | first_app_found: |
501 | serge | 1033 | |
742 | Rus | 1034 | cli |
1 | ha | 1035 | |
742 | Rus | 1036 | ;mov [TASK_COUNT],dword 2 |
1037 | mov [CURRENT_TASK],dword 1 ; set OS task fisrt |
||
1 | ha | 1038 | |
21 | poddubny | 1039 | ; SET KEYBOARD PARAMETERS |
742 | Rus | 1040 | mov al, 0xf6 ; reset keyboard, scan enabled |
1041 | call kb_write |
||
1 | ha | 1042 | |
742 | Rus | 1043 | ; wait until 8042 is ready |
1044 | xor ecx,ecx |
||
841 | serge | 1045 | @@: |
742 | Rus | 1046 | in al,64h |
1047 | and al,00000010b |
||
1048 | loopnz @b |
||
1 | ha | 1049 | |
742 | Rus | 1050 | mov al, 0xF3 ; set repeat rate & delay |
1051 | call kb_write |
||
265 | diamond | 1052 | ; call kb_read |
742 | Rus | 1053 | mov al, 0 ; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1054 | call kb_write |
||
265 | diamond | 1055 | ; call kb_read |
1 | ha | 1056 | ;// mike.dld [ |
742 | Rus | 1057 | call set_lights |
1 | ha | 1058 | ;// mike.dld ] |
1059 | |||
21 | poddubny | 1060 | ; START MULTITASKING |
1 | ha | 1061 | |
847 | serge | 1062 | ;if preboot_blogesc |
1063 | ; mov esi, boot_tasking |
||
1064 | ; call boot_log |
||
1065 | ;.bll1: in al, 0x60 ; wait for ESC key press |
||
1066 | ; cmp al, 129 |
||
1067 | ; jne .bll1 |
||
1068 | ;end if |
||
767 | diamond | 1069 | |
465 | serge | 1070 | ; mov [ENABLE_TASKSWITCH],byte 1 ; multitasking enabled |
21 | poddubny | 1071 | |
1 | ha | 1072 | ; UNMASK ALL IRQ'S |
1073 | |||
742 | Rus | 1074 | mov esi,boot_allirqs |
1075 | call boot_log |
||
41 | mikedld | 1076 | |
848 | serge | 1077 | mov al,0 ; unmask all irq's |
742 | Rus | 1078 | out 0xA1,al |
1079 | out 0x21,al |
||
1 | ha | 1080 | |
742 | Rus | 1081 | mov ecx,32 |
1 | ha | 1082 | |
1083 | ready_for_irqs: |
||
1084 | |||
742 | Rus | 1085 | mov al,0x20 ; ready for irqs |
1086 | out 0x20,al |
||
1087 | out 0xa0,al |
||
1 | ha | 1088 | |
742 | Rus | 1089 | loop ready_for_irqs ; flush the queue |
1 | ha | 1090 | |
774 | Rus | 1091 | stdcall attach_int_handler, dword 1, irq1, dword 0 |
164 | serge | 1092 | |
1 | ha | 1093 | ; mov [dma_hdd],1 |
742 | Rus | 1094 | cmp [IDEContrRegsBaseAddr], 0 |
1095 | setnz [dma_hdd] |
||
1096 | mov [timer_ticks_enable],1 ; for cd driver |
||
1 | ha | 1097 | |
742 | Rus | 1098 | sti |
1099 | call change_task |
||
465 | serge | 1100 | |
742 | Rus | 1101 | jmp osloop |
465 | serge | 1102 | |
725 | diamond | 1103 | ; jmp $ ; wait here for timer to take control |
1 | ha | 1104 | |
742 | Rus | 1105 | ; Fly :) |
1 | ha | 1106 | |
465 | serge | 1107 | include 'unpacker.inc' |
1108 | include 'fdo.inc' |
||
1109 | |||
1110 | align 4 |
||
1111 | boot_log: |
||
742 | Rus | 1112 | pushad |
465 | serge | 1113 | |
742 | Rus | 1114 | mov ebx,10*65536 |
1115 | mov bx,word [boot_y] |
||
1116 | add [boot_y],dword 10 |
||
1117 | mov ecx,0x80ffffff ; ASCIIZ string with white color |
||
1118 | mov edx,esi |
||
1119 | mov edi,1 |
||
465 | serge | 1120 | |
848 | serge | 1121 | call dtext |
1122 | |||
742 | Rus | 1123 | mov [novesachecksum],1000 |
1124 | call checkVga_N13 |
||
465 | serge | 1125 | |
764 | Rus | 1126 | popad |
465 | serge | 1127 | |
742 | Rus | 1128 | ret |
465 | serge | 1129 | |
1130 | |||
1 | ha | 1131 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1132 | ; ; |
||
33 | mario79 | 1133 | ; MAIN OS LOOP START ; |
1 | ha | 1134 | ; ; |
1135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1136 | align 32 |
||
1137 | osloop: |
||
742 | Rus | 1138 | call [draw_pointer] |
1139 | call checkbuttons |
||
1140 | call checkwindows |
||
49 | mikedld | 1141 | ; call check_window_move_request |
742 | Rus | 1142 | call checkmisc |
1143 | call checkVga_N13 |
||
839 | serge | 1144 | call stack_handler |
742 | Rus | 1145 | call checkidle |
1146 | call check_fdd_motor_status |
||
1147 | call check_ATAPI_device_event |
||
1148 | jmp osloop |
||
33 | mario79 | 1149 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1150 | ; ; |
||
1151 | ; MAIN OS LOOP END ; |
||
1152 | ; ; |
||
1153 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1 | ha | 1154 | |
1155 | checkidle: |
||
742 | Rus | 1156 | pushad |
1 | ha | 1157 | |
742 | Rus | 1158 | cmp [check_idle_semaphore],0 |
1159 | jne no_idle_state |
||
1 | ha | 1160 | |
742 | Rus | 1161 | call change_task |
1162 | mov eax,[idlemem] |
||
1163 | mov ebx,[timer_ticks] ;[0xfdf0] |
||
1164 | cmp eax,ebx |
||
1165 | jnz idle_exit |
||
1166 | call _rdtsc |
||
1167 | mov ecx,eax |
||
1 | ha | 1168 | idle_loop: |
742 | Rus | 1169 | hlt |
1170 | cmp [check_idle_semaphore],0 |
||
1171 | jne idle_loop_exit |
||
1172 | mov eax,[timer_ticks] ;[0xfdf0] |
||
1173 | cmp ebx,eax |
||
1174 | jz idle_loop |
||
1 | ha | 1175 | idle_loop_exit: |
742 | Rus | 1176 | mov [idlemem],eax |
1177 | call _rdtsc |
||
1178 | sub eax,ecx |
||
1179 | mov ebx,[idleuse] |
||
1180 | add ebx,eax |
||
1181 | mov [idleuse],ebx |
||
1 | ha | 1182 | |
742 | Rus | 1183 | popad |
1184 | ret |
||
1 | ha | 1185 | |
1186 | idle_exit: |
||
1187 | |||
742 | Rus | 1188 | mov ebx,[timer_ticks] ;[0xfdf0] |
1189 | mov [idlemem],ebx |
||
1190 | call change_task |
||
1 | ha | 1191 | |
742 | Rus | 1192 | popad |
1193 | ret |
||
1 | ha | 1194 | |
1195 | no_idle_state: |
||
1196 | |||
742 | Rus | 1197 | dec [check_idle_semaphore] |
1 | ha | 1198 | |
742 | Rus | 1199 | mov ebx,[timer_ticks] ;[0xfdf0] |
1200 | mov [idlemem],ebx |
||
1201 | call change_task |
||
1 | ha | 1202 | |
742 | Rus | 1203 | popad |
1204 | ret |
||
1 | ha | 1205 | |
1206 | uglobal |
||
742 | Rus | 1207 | idlemem dd 0x0 |
1208 | idleuse dd 0x0 |
||
1209 | idleusesec dd 0x0 |
||
1210 | check_idle_semaphore dd 0x0 |
||
1 | ha | 1211 | endg |
1212 | |||
1213 | |||
1214 | |||
1215 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1216 | ; ; |
||
1217 | ; INCLUDED SYSTEM FILES ; |
||
1218 | ; ; |
||
1219 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1220 | |||
1221 | |||
7 | me_root | 1222 | include "kernel32.inc" |
1 | ha | 1223 | |
1224 | |||
1225 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1226 | ; ; |
||
1227 | ; KERNEL FUNCTIONS ; |
||
1228 | ; ; |
||
1229 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1230 | |||
1231 | reserve_irqs_ports: |
||
1232 | |||
742 | Rus | 1233 | pushad |
1 | ha | 1234 | |
742 | Rus | 1235 | mov [irq_owner+4*0], 1 ; timer |
769 | Rus | 1236 | ;mov [irq_owner+4*1], 1 ; keyboard |
742 | Rus | 1237 | mov [irq_owner+4*6], 1 ; floppy diskette |
1238 | mov [irq_owner+4*13], 1 ; math co-pros |
||
1239 | mov [irq_owner+4*14], 1 ; ide I |
||
1240 | mov [irq_owner+4*15], 1 ; ide II |
||
465 | serge | 1241 | |
671 | Ghost | 1242 | ; RESERVE PORTS |
742 | Rus | 1243 | mov edi,1 ; 0x00-0x2d |
1244 | mov [RESERVED_PORTS],edi |
||
1245 | shl edi,4 |
||
1246 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1247 | mov [RESERVED_PORTS+edi+4],dword 0x0 |
||
1248 | mov [RESERVED_PORTS+edi+8],dword 0x2d |
||
269 | serge | 1249 | |
742 | Rus | 1250 | inc dword [RESERVED_PORTS] ; 0x30-0x4d |
1251 | mov edi,[RESERVED_PORTS] |
||
1252 | shl edi,4 |
||
1253 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1254 | mov [RESERVED_PORTS+edi+4],dword 0x30 |
||
1255 | mov [RESERVED_PORTS+edi+8],dword 0x4d |
||
269 | serge | 1256 | |
742 | Rus | 1257 | inc dword [RESERVED_PORTS] ; 0x50-0xdf |
1258 | mov edi,[RESERVED_PORTS] |
||
1259 | shl edi,4 |
||
1260 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1261 | mov [RESERVED_PORTS+edi+4],dword 0x50 |
||
1262 | mov [RESERVED_PORTS+edi+8],dword 0xdf |
||
233 | serge | 1263 | |
742 | Rus | 1264 | inc dword [RESERVED_PORTS] ; 0xe5-0xff |
1265 | mov edi,[RESERVED_PORTS] |
||
1266 | shl edi,4 |
||
1267 | mov [RESERVED_PORTS+edi+0],dword 1 |
||
1268 | mov [RESERVED_PORTS+edi+4],dword 0xe5 |
||
1269 | mov [RESERVED_PORTS+edi+8],dword 0xff |
||
233 | serge | 1270 | |
742 | Rus | 1271 | popad |
1272 | ret |
||
1 | ha | 1273 | |
1274 | setirqreadports: |
||
1275 | |||
742 | Rus | 1276 | mov [irq12read+0],dword 0x60 + 0x01000000 ; read port 0x60 , byte |
1277 | mov [irq12read+4],dword 0 ; end of port list |
||
769 | Rus | 1278 | ;mov [irq04read+0],dword 0x3f8 + 0x01000000 ; read port 0x3f8 , byte |
1279 | ;mov [irq04read+4],dword 0 ; end of port list |
||
1280 | ;mov [irq03read+0],dword 0x2f8 + 0x01000000 ; read port 0x2f8 , byte |
||
1281 | ;mov [irq03read+4],dword 0 ; end of port list |
||
1 | ha | 1282 | |
742 | Rus | 1283 | ret |
1 | ha | 1284 | |
1285 | iglobal |
||
1286 | process_number dd 0x1 |
||
1287 | endg |
||
1288 | |||
1289 | set_variables: |
||
1290 | |||
742 | Rus | 1291 | mov ecx,0x100 ; flush port 0x60 |
1292 | .fl60: in al,0x60 |
||
1293 | loop .fl60 |
||
1294 | mov [MOUSE_BUFF_COUNT],byte 0 ; mouse buffer |
||
1295 | mov [KEY_COUNT],byte 0 ; keyboard buffer |
||
1296 | mov [BTN_COUNT],byte 0 ; button buffer |
||
381 | serge | 1297 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1 | ha | 1298 | |
742 | Rus | 1299 | push eax |
1300 | mov ax,[BOOT_VAR+0x900c] |
||
1301 | shr ax,1 |
||
1302 | shl eax,16 |
||
1303 | mov ax,[BOOT_VAR+0x900A] |
||
1304 | shr ax,1 |
||
1305 | mov [MOUSE_X],eax |
||
1306 | pop eax |
||
41 | mikedld | 1307 | |
802 | serge | 1308 | mov [BTN_ADDR],dword BUTTON_INFO ; address of button list |
1 | ha | 1309 | |
1310 | ;!! IP 04.02.2005: |
||
742 | Rus | 1311 | mov [next_usage_update], 100 |
1312 | mov byte [DONT_SWITCH], 0 ; change task if possible |
||
1 | ha | 1313 | |
742 | Rus | 1314 | ret |
1 | ha | 1315 | |
1316 | ;* mouse centered - start code- Mario79 |
||
1317 | mouse_centered: |
||
742 | Rus | 1318 | push eax |
759 | Rus | 1319 | mov eax,[Screen_Max_X] |
742 | Rus | 1320 | shr eax,1 |
1321 | mov [MOUSE_X],ax |
||
759 | Rus | 1322 | mov eax,[Screen_Max_Y] |
742 | Rus | 1323 | shr eax,1 |
1324 | mov [MOUSE_Y],ax |
||
1325 | pop eax |
||
1326 | ret |
||
1 | ha | 1327 | ;* mouse centered - end code- Mario79 |
1328 | |||
1329 | align 4 |
||
1330 | |||
1331 | sys_outport: |
||
1332 | |||
742 | Rus | 1333 | mov edi,ebx ; separate flag for read / write |
1 | ha | 1334 | and ebx,65535 |
1335 | |||
381 | serge | 1336 | mov ecx,[RESERVED_PORTS] |
1 | ha | 1337 | test ecx,ecx |
1338 | jne sopl8 |
||
1339 | mov [esp+36],dword 1 |
||
1340 | ret |
||
1341 | |||
1342 | sopl8: |
||
379 | serge | 1343 | mov edx,[TASK_BASE] |
1 | ha | 1344 | mov edx,[edx+0x4] |
1345 | and ebx,65535 |
||
1346 | cld |
||
1347 | sopl1: |
||
1348 | |||
1349 | mov esi,ecx |
||
1350 | shl esi,4 |
||
381 | serge | 1351 | add esi,RESERVED_PORTS |
1 | ha | 1352 | cmp edx,[esi+0] |
1353 | jne sopl2 |
||
1354 | cmp ebx,[esi+4] |
||
742 | Rus | 1355 | jb sopl2 |
1 | ha | 1356 | cmp ebx,[esi+8] |
742 | Rus | 1357 | jg sopl2 |
1 | ha | 1358 | jmp sopl3 |
1359 | |||
1360 | sopl2: |
||
1361 | |||
1362 | dec ecx |
||
1363 | jnz sopl1 |
||
1364 | mov [esp+36],dword 1 |
||
1365 | ret |
||
1366 | |||
1367 | sopl3: |
||
1368 | |||
1369 | test edi,0x80000000 ; read ? |
||
1370 | jnz sopl4 |
||
1371 | |||
742 | Rus | 1372 | mov dx,bx ; write |
1 | ha | 1373 | out dx,al |
1374 | mov [esp+36],dword 0 |
||
1375 | ret |
||
1376 | |||
1377 | sopl4: |
||
1378 | |||
742 | Rus | 1379 | mov dx,bx ; read |
1380 | in al,dx |
||
1 | ha | 1381 | and eax,0xff |
1382 | mov [esp+36],dword 0 |
||
1383 | mov [esp+24],eax |
||
1384 | ret |
||
1385 | |||
1386 | display_number: |
||
1387 | |||
1388 | ; eax = print type, al=0 -> ebx is number |
||
1389 | ; al=1 -> ebx is pointer |
||
1390 | ; ah=0 -> display decimal |
||
1391 | ; ah=1 -> display hexadecimal |
||
1392 | ; ah=2 -> display binary |
||
1393 | ; eax bits 16-21 = number of digits to display (0-32) |
||
1394 | ; eax bits 22-31 = reserved |
||
1395 | ; |
||
1396 | ; ebx = number or pointer |
||
1397 | ; ecx = x shl 16 + y |
||
1398 | ; edx = color |
||
655 | mario79 | 1399 | xor edi, edi |
211 | serge | 1400 | display_number_force: |
652 | mario79 | 1401 | push eax |
655 | mario79 | 1402 | and eax,0x3fffffff |
1403 | cmp eax,0xffff ; length > 0 ? |
||
1404 | pop eax |
||
1 | ha | 1405 | jge cont_displ |
1406 | ret |
||
1407 | cont_displ: |
||
652 | mario79 | 1408 | push eax |
655 | mario79 | 1409 | and eax,0x3fffffff |
1410 | cmp eax,61*0x10000 ; length <= 60 ? |
||
1411 | pop eax |
||
75 | diamond | 1412 | jb cont_displ2 |
1 | ha | 1413 | ret |
1414 | cont_displ2: |
||
1415 | |||
1416 | pushad |
||
1417 | |||
655 | mario79 | 1418 | cmp al,1 ; ecx is a pointer ? |
1 | ha | 1419 | jne displnl1 |
655 | mario79 | 1420 | mov ebp,ebx |
1421 | add ebp,4 |
||
840 | serge | 1422 | mov ebp,[ebp] |
1423 | mov ebx,[ebx] |
||
1 | ha | 1424 | displnl1: |
1425 | sub esp,64 |
||
1426 | |||
655 | mario79 | 1427 | cmp ah,0 ; DECIMAL |
1 | ha | 1428 | jne no_display_desnum |
1429 | shr eax,16 |
||
655 | mario79 | 1430 | and eax,0xC03f |
652 | mario79 | 1431 | ; and eax,0x3f |
1432 | push eax |
||
75 | diamond | 1433 | and eax,0x3f |
1 | ha | 1434 | mov edi,esp |
194 | diamond | 1435 | add edi,4+64-1 |
1 | ha | 1436 | mov ecx,eax |
1437 | mov eax,ebx |
||
1438 | mov ebx,10 |
||
1439 | d_desnum: |
||
1440 | xor edx,edx |
||
655 | mario79 | 1441 | call division_64_bits |
1 | ha | 1442 | div ebx |
1443 | add dl,48 |
||
1444 | mov [edi],dl |
||
1445 | dec edi |
||
1446 | loop d_desnum |
||
1447 | pop eax |
||
652 | mario79 | 1448 | call normalize_number |
1 | ha | 1449 | call draw_num_text |
1450 | add esp,64 |
||
1451 | popad |
||
1452 | ret |
||
1453 | no_display_desnum: |
||
1454 | |||
655 | mario79 | 1455 | cmp ah,0x01 ; HEXADECIMAL |
1 | ha | 1456 | jne no_display_hexnum |
1457 | shr eax,16 |
||
655 | mario79 | 1458 | and eax,0xC03f |
652 | mario79 | 1459 | ; and eax,0x3f |
1460 | push eax |
||
75 | diamond | 1461 | and eax,0x3f |
1 | ha | 1462 | mov edi,esp |
194 | diamond | 1463 | add edi,4+64-1 |
1 | ha | 1464 | mov ecx,eax |
1465 | mov eax,ebx |
||
1466 | mov ebx,16 |
||
1467 | d_hexnum: |
||
1468 | xor edx,edx |
||
655 | mario79 | 1469 | call division_64_bits |
1 | ha | 1470 | div ebx |
1471 | add edx,hexletters |
||
1472 | mov dl,[edx] |
||
1473 | mov [edi],dl |
||
1474 | dec edi |
||
1475 | loop d_hexnum |
||
1476 | pop eax |
||
652 | mario79 | 1477 | call normalize_number |
1 | ha | 1478 | call draw_num_text |
1479 | add esp,64 |
||
1480 | popad |
||
1481 | ret |
||
1482 | no_display_hexnum: |
||
1483 | |||
655 | mario79 | 1484 | cmp ah,0x02 ; BINARY |
1 | ha | 1485 | jne no_display_binnum |
1486 | shr eax,16 |
||
655 | mario79 | 1487 | and eax,0xC03f |
652 | mario79 | 1488 | ; and eax,0x3f |
1489 | push eax |
||
75 | diamond | 1490 | and eax,0x3f |
1 | ha | 1491 | mov edi,esp |
194 | diamond | 1492 | add edi,4+64-1 |
1 | ha | 1493 | mov ecx,eax |
1494 | mov eax,ebx |
||
1495 | mov ebx,2 |
||
1496 | d_binnum: |
||
1497 | xor edx,edx |
||
655 | mario79 | 1498 | call division_64_bits |
1 | ha | 1499 | div ebx |
1500 | add dl,48 |
||
1501 | mov [edi],dl |
||
1502 | dec edi |
||
1503 | loop d_binnum |
||
1504 | pop eax |
||
652 | mario79 | 1505 | call normalize_number |
1 | ha | 1506 | call draw_num_text |
1507 | add esp,64 |
||
1508 | popad |
||
1509 | ret |
||
1510 | no_display_binnum: |
||
1511 | |||
1512 | add esp,64 |
||
1513 | popad |
||
1514 | ret |
||
1515 | |||
652 | mario79 | 1516 | normalize_number: |
1517 | test ah,0x80 |
||
1518 | jz .continue |
||
1519 | mov ecx,48 |
||
1520 | and eax,0x3f |
||
1521 | @@: |
||
1522 | inc edi |
||
1523 | cmp [edi],cl |
||
1524 | jne .continue |
||
1525 | dec eax |
||
1526 | cmp eax,1 |
||
665 | diamond | 1527 | ja @r |
1528 | mov al,1 |
||
652 | mario79 | 1529 | .continue: |
1530 | and eax,0x3f |
||
1531 | ret |
||
1 | ha | 1532 | |
655 | mario79 | 1533 | division_64_bits: |
1534 | test [esp+1+4],byte 0x40 |
||
1535 | jz .continue |
||
1536 | push eax |
||
1537 | mov eax,ebp |
||
1538 | div ebx |
||
1539 | mov ebp,eax |
||
1540 | pop eax |
||
1541 | .continue: |
||
1542 | ret |
||
652 | mario79 | 1543 | |
1 | ha | 1544 | draw_num_text: |
684 | diamond | 1545 | mov esi,eax |
1546 | mov edx,64+4 |
||
1547 | sub edx,eax |
||
1548 | add edx,esp |
||
1549 | mov ebx,[esp+64+32-8+4] |
||
1550 | ; add window start x & y |
||
1551 | mov ecx,[TASK_BASE] |
||
465 | serge | 1552 | |
1553 | mov edi,[CURRENT_TASK] |
||
1554 | shl edi,8 |
||
1555 | |||
684 | diamond | 1556 | mov eax,[ecx-twdw+WDATA.box.left] |
1557 | add eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1558 | shl eax,16 |
||
1559 | add eax,[ecx-twdw+WDATA.box.top] |
||
1560 | add eax,[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1561 | add ebx,eax |
||
1562 | mov ecx,[esp+64+32-12+4] |
||
742 | Rus | 1563 | and ecx, not 0x80000000 ; force counted string |
1564 | mov eax, [esp+64+8] ; background color (if given) |
||
1565 | mov edi, [esp+64+4] |
||
139 | diamond | 1566 | jmp dtext |
1 | ha | 1567 | |
1568 | align 4 |
||
1569 | |||
1570 | sys_setup: |
||
1571 | |||
1572 | ; 1=roland mpu midi base , base io address |
||
1573 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1574 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1575 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1576 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1577 | ; 8=fat32 partition in hd |
||
1578 | ; 9 |
||
1579 | ; 10 = sound dma channel |
||
1580 | ; 11 = enable lba read |
||
1581 | ; 12 = enable pci access |
||
1582 | |||
1583 | |||
1584 | mov [esp+36],dword 0 |
||
742 | Rus | 1585 | cmp eax,1 ; MIDI |
1 | ha | 1586 | jnz nsyse1 |
1587 | cmp ebx,0x100 |
||
1588 | jb nsyse1 |
||
1589 | mov edx,65535 |
||
1590 | cmp edx,ebx |
||
1591 | jb nsyse1 |
||
1592 | mov [midi_base],bx |
||
1593 | mov word [mididp],bx |
||
1594 | inc bx |
||
1595 | mov word [midisp],bx |
||
1596 | ret |
||
1597 | |||
283 | diamond | 1598 | iglobal |
1 | ha | 1599 | midi_base dw 0 |
283 | diamond | 1600 | endg |
1 | ha | 1601 | |
1602 | nsyse1: |
||
1603 | |||
742 | Rus | 1604 | cmp eax,2 ; KEYBOARD |
1 | ha | 1605 | jnz nsyse2 |
1606 | cmp ebx,1 |
||
1607 | jnz kbnobase |
||
379 | serge | 1608 | mov edi,[TASK_BASE] |
115 | poddubny | 1609 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1610 | mov eax,ecx |
1611 | mov ebx,keymap |
||
1612 | mov ecx,128 |
||
1613 | call memmove |
||
1614 | ret |
||
1615 | kbnobase: |
||
1616 | cmp ebx,2 |
||
1617 | jnz kbnoshift |
||
379 | serge | 1618 | mov edi,[TASK_BASE] |
115 | poddubny | 1619 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1620 | mov eax,ecx |
1621 | mov ebx,keymap_shift |
||
1622 | mov ecx,128 |
||
1623 | call memmove |
||
1624 | ret |
||
1625 | kbnoshift: |
||
1626 | cmp ebx,3 |
||
1627 | jne kbnoalt |
||
379 | serge | 1628 | mov edi,[TASK_BASE] |
115 | poddubny | 1629 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1630 | mov eax,ecx |
1631 | mov ebx,keymap_alt |
||
1632 | mov ecx,128 |
||
1633 | call memmove |
||
1634 | ret |
||
1635 | kbnoalt: |
||
1636 | cmp ebx,9 |
||
1637 | jnz kbnocountry |
||
1638 | mov word [keyboard],cx |
||
1639 | ret |
||
1640 | kbnocountry: |
||
1641 | mov [esp+36],dword 1 |
||
1642 | ret |
||
1643 | nsyse2: |
||
742 | Rus | 1644 | cmp eax,3 ; CD |
802 | serge | 1645 | jnz nsyse4 |
75 | diamond | 1646 | test ebx,ebx |
1647 | jz nosesl |
||
1648 | cmp ebx, 4 |
||
1649 | ja nosesl |
||
1 | ha | 1650 | mov [cd_base],bl |
1651 | cmp ebx,1 |
||
1652 | jnz noprma |
||
1653 | mov [cdbase],0x1f0 |
||
1654 | mov [cdid],0xa0 |
||
1655 | noprma: |
||
1656 | cmp ebx,2 |
||
1657 | jnz noprsl |
||
1658 | mov [cdbase],0x1f0 |
||
1659 | mov [cdid],0xb0 |
||
1660 | noprsl: |
||
1661 | cmp ebx,3 |
||
1662 | jnz nosema |
||
1663 | mov [cdbase],0x170 |
||
1664 | mov [cdid],0xa0 |
||
1665 | nosema: |
||
1666 | cmp ebx,4 |
||
1667 | jnz nosesl |
||
1668 | mov [cdbase],0x170 |
||
1669 | mov [cdid],0xb0 |
||
1670 | nosesl: |
||
1671 | ret |
||
1672 | |||
1673 | cd_base db 0 |
||
1674 | |||
1675 | nsyse4: |
||
1676 | |||
742 | Rus | 1677 | cmp eax,5 ; SYSTEM LANGUAGE |
1 | ha | 1678 | jnz nsyse5 |
1679 | mov [syslang],ebx |
||
1680 | ret |
||
1681 | nsyse5: |
||
1682 | |||
742 | Rus | 1683 | cmp eax,7 ; HD BASE |
1 | ha | 1684 | jne nsyse7 |
75 | diamond | 1685 | test ebx,ebx |
1686 | jz nosethd |
||
1687 | cmp ebx,4 |
||
1688 | ja nosethd |
||
1 | ha | 1689 | mov [hd_base],bl |
1690 | cmp ebx,1 |
||
1691 | jnz noprmahd |
||
1692 | mov [hdbase],0x1f0 |
||
1693 | mov [hdid],0x0 |
||
1694 | mov [hdpos],1 |
||
1695 | ; call set_FAT32_variables |
||
1696 | noprmahd: |
||
1697 | cmp ebx,2 |
||
1698 | jnz noprslhd |
||
1699 | mov [hdbase],0x1f0 |
||
1700 | mov [hdid],0x10 |
||
1701 | mov [hdpos],2 |
||
1702 | ; call set_FAT32_variables |
||
1703 | noprslhd: |
||
1704 | cmp ebx,3 |
||
1705 | jnz nosemahd |
||
1706 | mov [hdbase],0x170 |
||
1707 | mov [hdid],0x0 |
||
1708 | mov [hdpos],3 |
||
1709 | ; call set_FAT32_variables |
||
1710 | nosemahd: |
||
1711 | cmp ebx,4 |
||
1712 | jnz noseslhd |
||
1713 | mov [hdbase],0x170 |
||
1714 | mov [hdid],0x10 |
||
1715 | mov [hdpos],4 |
||
1716 | ; call set_FAT32_variables |
||
1717 | noseslhd: |
||
1718 | call reserve_hd1 |
||
321 | diamond | 1719 | call reserve_hd_channel |
1720 | call free_hd_channel |
||
742 | Rus | 1721 | mov [hd1_status],0 ; free |
75 | diamond | 1722 | nosethd: |
1 | ha | 1723 | ret |
1724 | |||
283 | diamond | 1725 | iglobal |
1 | ha | 1726 | hd_base db 0 |
283 | diamond | 1727 | endg |
1 | ha | 1728 | |
802 | serge | 1729 | nsyse7: |
1 | ha | 1730 | |
742 | Rus | 1731 | cmp eax,8 ; HD PARTITION |
1 | ha | 1732 | jne nsyse8 |
1733 | mov [fat32part],ebx |
||
1734 | ; call set_FAT32_variables |
||
1735 | call reserve_hd1 |
||
321 | diamond | 1736 | call reserve_hd_channel |
1737 | call free_hd_channel |
||
1 | ha | 1738 | pusha |
1739 | call choice_necessity_partition_1 |
||
1740 | popa |
||
742 | Rus | 1741 | mov [hd1_status],0 ; free |
1 | ha | 1742 | ret |
1743 | |||
802 | serge | 1744 | nsyse8: |
742 | Rus | 1745 | cmp eax,11 ; ENABLE LBA READ |
1 | ha | 1746 | jne no_set_lba_read |
1747 | and ebx,1 |
||
1748 | mov [lba_read_enabled],ebx |
||
1749 | ret |
||
1750 | |||
802 | serge | 1751 | no_set_lba_read: |
1752 | cmp eax,12 ; ENABLE PCI ACCESS |
||
1 | ha | 1753 | jne no_set_pci_access |
1754 | and ebx,1 |
||
1755 | mov [pci_access_enabled],ebx |
||
1756 | ret |
||
1757 | no_set_pci_access: |
||
1758 | |||
1759 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
1760 | include 'vmodeint.inc' |
||
1761 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
1762 | |||
75 | diamond | 1763 | sys_setup_err: |
1 | ha | 1764 | mov [esp+36],dword -1 |
1765 | ret |
||
1766 | |||
1767 | align 4 |
||
1768 | |||
1769 | sys_getsetup: |
||
1770 | |||
1771 | ; 1=roland mpu midi base , base io address |
||
1772 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1773 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1774 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1775 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1776 | ; 8=fat32 partition in hd |
||
1777 | ; 9=get hs timer tic |
||
1778 | |||
1779 | cmp eax,1 |
||
1780 | jne ngsyse1 |
||
1781 | movzx eax,[midi_base] |
||
1782 | mov [esp+36],eax |
||
1783 | ret |
||
802 | serge | 1784 | ngsyse1: |
1 | ha | 1785 | |
1786 | cmp eax,2 |
||
1787 | jne ngsyse2 |
||
1788 | cmp ebx,1 |
||
1789 | jnz kbnobaseret |
||
379 | serge | 1790 | mov edi,[TASK_BASE] |
115 | poddubny | 1791 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1792 | mov ebx,ecx |
1793 | mov eax,keymap |
||
1794 | mov ecx,128 |
||
1795 | call memmove |
||
1796 | ret |
||
802 | serge | 1797 | kbnobaseret: |
1 | ha | 1798 | cmp ebx,2 |
1799 | jnz kbnoshiftret |
||
379 | serge | 1800 | mov edi,[TASK_BASE] |
115 | poddubny | 1801 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1802 | mov ebx,ecx |
1803 | mov eax,keymap_shift |
||
1804 | mov ecx,128 |
||
1805 | call memmove |
||
1806 | ret |
||
802 | serge | 1807 | kbnoshiftret: |
1 | ha | 1808 | cmp ebx,3 |
1809 | jne kbnoaltret |
||
379 | serge | 1810 | mov edi,[TASK_BASE] |
115 | poddubny | 1811 | add ecx,[edi+TASKDATA.mem_start] |
1 | ha | 1812 | mov ebx,ecx |
1813 | mov eax,keymap_alt |
||
1814 | mov ecx,128 |
||
1815 | call memmove |
||
1816 | ret |
||
802 | serge | 1817 | kbnoaltret: |
1 | ha | 1818 | cmp ebx,9 |
1819 | jnz ngsyse2 |
||
1820 | movzx eax,word [keyboard] |
||
1821 | mov [esp+36],eax |
||
1822 | ret |
||
802 | serge | 1823 | ngsyse2: |
1 | ha | 1824 | |
802 | serge | 1825 | cmp eax,3 |
1826 | jnz ngsyse3 |
||
1827 | movzx eax,[cd_base] |
||
1828 | mov [esp+36],eax |
||
1829 | ret |
||
1830 | ngsyse3: |
||
1831 | cmp eax,5 |
||
1832 | jnz ngsyse5 |
||
1833 | mov eax,[syslang] |
||
1834 | mov [esp+36],eax |
||
1835 | ret |
||
1836 | ngsyse5: |
||
1 | ha | 1837 | cmp eax,7 |
1838 | jnz ngsyse7 |
||
1839 | movzx eax,[hd_base] |
||
1840 | mov [esp+36],eax |
||
1841 | ret |
||
802 | serge | 1842 | ngsyse7: |
1 | ha | 1843 | cmp eax,8 |
1844 | jnz ngsyse8 |
||
1845 | mov eax,[fat32part] |
||
1846 | mov [esp+36],eax |
||
1847 | ret |
||
802 | serge | 1848 | ngsyse8: |
1 | ha | 1849 | cmp eax,9 |
1850 | jne ngsyse9 |
||
1851 | mov eax,[timer_ticks] ;[0xfdf0] |
||
1852 | mov [esp+36],eax |
||
1853 | ret |
||
802 | serge | 1854 | ngsyse9: |
1 | ha | 1855 | cmp eax,11 |
1856 | jnz ngsyse11 |
||
1857 | mov eax,[lba_read_enabled] |
||
1858 | mov [esp+36],eax |
||
1859 | ret |
||
802 | serge | 1860 | ngsyse11: |
1 | ha | 1861 | cmp eax,12 |
1862 | jnz ngsyse12 |
||
1863 | mov eax,[pci_access_enabled] |
||
1864 | mov [esp+36],eax |
||
1865 | ret |
||
802 | serge | 1866 | ngsyse12: |
1 | ha | 1867 | mov [esp+36],dword 1 |
1868 | ret |
||
1869 | |||
479 | kastigar | 1870 | get_timer_ticks: |
1871 | mov eax,[timer_ticks] |
||
1872 | ret |
||
1873 | |||
283 | diamond | 1874 | iglobal |
1 | ha | 1875 | align 4 |
221 | serge | 1876 | mousefn dd msscreen, mswin, msbutton, msset |
742 | Rus | 1877 | dd app_load_cursor |
1878 | dd app_set_cursor |
||
1879 | dd app_delete_cursor |
||
1880 | dd msz |
||
283 | diamond | 1881 | endg |
1 | ha | 1882 | |
1883 | readmousepos: |
||
1884 | |||
1885 | ; eax=0 screen relative |
||
1886 | ; eax=1 window relative |
||
1887 | ; eax=2 buttons pressed |
||
221 | serge | 1888 | ; eax=3 set mouse pos ; reserved |
1889 | ; eax=4 load cursor |
||
1890 | ; eax=5 set cursor |
||
1891 | ; eax=6 delete cursor ; reserved |
||
479 | kastigar | 1892 | ; eax=7 get mouse_z |
1 | ha | 1893 | |
742 | Rus | 1894 | cmp eax, 7 |
1895 | ja msset |
||
1896 | jmp [mousefn+eax*4] |
||
221 | serge | 1897 | msscreen: |
742 | Rus | 1898 | mov eax,[MOUSE_X] |
1899 | shl eax,16 |
||
1900 | mov ax,[MOUSE_Y] |
||
1901 | mov [esp+36],eax |
||
1902 | ret |
||
221 | serge | 1903 | mswin: |
742 | Rus | 1904 | mov eax,[MOUSE_X] |
1905 | shl eax,16 |
||
1906 | mov ax,[MOUSE_Y] |
||
1907 | mov esi,[TASK_BASE] |
||
1908 | mov bx, word [esi-twdw+WDATA.box.left] |
||
1909 | shl ebx,16 |
||
1910 | mov bx, word [esi-twdw+WDATA.box.top] |
||
1911 | sub eax,ebx |
||
1 | ha | 1912 | |
742 | Rus | 1913 | mov edi,[CURRENT_TASK] |
1914 | shl edi,8 |
||
1915 | sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1916 | rol eax,16 |
||
1917 | sub ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1918 | rol eax,16 |
||
1919 | mov [esp+36],eax |
||
1920 | ret |
||
221 | serge | 1921 | msbutton: |
742 | Rus | 1922 | movzx eax,byte [BTN_DOWN] |
1923 | mov [esp+36],eax |
||
1924 | ret |
||
479 | kastigar | 1925 | msz: |
742 | Rus | 1926 | mov edi, [TASK_COUNT] |
1927 | movzx edi, word [WIN_POS + edi*2] |
||
1928 | cmp edi, [CURRENT_TASK] |
||
1929 | jne @f |
||
1930 | mov ax,[MOUSE_SCROLL_H] |
||
1931 | shl eax,16 |
||
1932 | mov ax,[MOUSE_SCROLL_V] |
||
1933 | mov [esp+36],eax |
||
1934 | mov [MOUSE_SCROLL_H],word 0 |
||
1935 | mov [MOUSE_SCROLL_V],word 0 |
||
1936 | ret |
||
479 | kastigar | 1937 | @@: |
742 | Rus | 1938 | mov [esp+36],dword 0 |
1939 | ret |
||
221 | serge | 1940 | msset: |
742 | Rus | 1941 | ret |
164 | serge | 1942 | |
221 | serge | 1943 | app_load_cursor: |
465 | serge | 1944 | ; add ebx, new_app_base |
742 | Rus | 1945 | cmp ebx, OS_BASE |
1946 | jae msset |
||
1947 | stdcall load_cursor, ebx, ecx |
||
1948 | mov [esp+36], eax |
||
1949 | ret |
||
164 | serge | 1950 | |
221 | serge | 1951 | app_set_cursor: |
742 | Rus | 1952 | stdcall set_cursor, ebx |
1953 | mov [esp+36], eax |
||
1954 | ret |
||
1 | ha | 1955 | |
233 | serge | 1956 | app_delete_cursor: |
742 | Rus | 1957 | stdcall delete_cursor, ebx |
1958 | mov [esp+36], eax |
||
1959 | ret |
||
1 | ha | 1960 | |
1961 | is_input: |
||
1962 | |||
1963 | push edx |
||
742 | Rus | 1964 | mov dx,word [midisp] |
1965 | in al,dx |
||
1966 | and al,0x80 |
||
1967 | pop edx |
||
1 | ha | 1968 | ret |
1969 | |||
1970 | is_output: |
||
1971 | |||
1972 | push edx |
||
742 | Rus | 1973 | mov dx,word [midisp] |
1974 | in al,dx |
||
1975 | and al,0x40 |
||
1976 | pop edx |
||
1 | ha | 1977 | ret |
1978 | |||
1979 | |||
1980 | get_mpu_in: |
||
1981 | |||
1982 | push edx |
||
742 | Rus | 1983 | mov dx,word [mididp] |
1984 | in al,dx |
||
1985 | pop edx |
||
1 | ha | 1986 | ret |
1987 | |||
1988 | |||
1989 | put_mpu_out: |
||
1990 | |||
1991 | push edx |
||
742 | Rus | 1992 | mov dx,word [mididp] |
1993 | out dx,al |
||
1994 | pop edx |
||
1 | ha | 1995 | ret |
1996 | |||
1997 | |||
1998 | setuart: |
||
1999 | |||
2000 | su1: |
||
2001 | call is_output |
||
742 | Rus | 2002 | cmp al,0 |
2003 | jnz su1 |
||
2004 | mov dx,word [midisp] |
||
2005 | mov al,0xff |
||
2006 | out dx,al |
||
1 | ha | 2007 | su2: |
742 | Rus | 2008 | mov dx,word [midisp] |
2009 | mov al,0xff |
||
2010 | out dx,al |
||
1 | ha | 2011 | call is_input |
742 | Rus | 2012 | cmp al,0 |
2013 | jnz su2 |
||
1 | ha | 2014 | call get_mpu_in |
742 | Rus | 2015 | cmp al,0xfe |
2016 | jnz su2 |
||
1 | ha | 2017 | su3: |
2018 | call is_output |
||
742 | Rus | 2019 | cmp al,0 |
2020 | jnz su3 |
||
2021 | mov dx,word [midisp] |
||
2022 | mov al,0x3f |
||
2023 | out dx,al |
||
1 | ha | 2024 | |
2025 | ret |
||
2026 | |||
2027 | |||
2028 | align 4 |
||
2029 | |||
2030 | sys_midi: |
||
2031 | |||
2032 | cmp [mididp],0 |
||
2033 | jnz sm0 |
||
2034 | mov [esp+36],dword 1 |
||
2035 | ret |
||
2036 | sm0: |
||
2037 | |||
2038 | cmp eax,1 |
||
2039 | mov [esp+36],dword 0 |
||
2040 | jnz smn1 |
||
2041 | call setuart |
||
2042 | ret |
||
2043 | smn1: |
||
2044 | |||
2045 | cmp eax,2 |
||
2046 | jnz smn2 |
||
2047 | sm10: |
||
2048 | call get_mpu_in |
||
2049 | call is_output |
||
2050 | test al,al |
||
2051 | jnz sm10 |
||
2052 | mov al,bl |
||
2053 | call put_mpu_out |
||
2054 | ret |
||
2055 | smn2: |
||
2056 | |||
2057 | ret |
||
2058 | |||
2059 | |||
2060 | detect_devices: |
||
2061 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
769 | Rus | 2062 | ;include 'detect/commouse.inc' |
479 | kastigar | 2063 | ;include 'detect/ps2mouse.inc' |
1 | ha | 2064 | ;include 'detect/dev_fd.inc' |
2065 | ;include 'detect/dev_hdcd.inc' |
||
2066 | ;include 'detect/sear_par.inc' |
||
2067 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
2068 | ret |
||
2069 | |||
2070 | |||
2071 | sys_end: |
||
2072 | |||
379 | serge | 2073 | mov eax,[TASK_BASE] |
115 | poddubny | 2074 | mov [eax+TASKDATA.state], 3 ; terminate this program |
41 | mikedld | 2075 | |
742 | Rus | 2076 | waitterm: ; wait here for termination |
684 | diamond | 2077 | mov ebx,100 |
1 | ha | 2078 | call delay_hs |
2079 | jmp waitterm |
||
2080 | |||
75 | diamond | 2081 | iglobal |
170 | serge | 2082 | align 4 |
75 | diamond | 2083 | sys_system_table: |
759 | Rus | 2084 | dd exit_for_anyone ; 1 = obsolete |
742 | Rus | 2085 | dd sysfn_terminate ; 2 = terminate thread |
2086 | dd sysfn_activate ; 3 = activate window |
||
2087 | dd sysfn_getidletime ; 4 = get idle time |
||
2088 | dd sysfn_getcpuclock ; 5 = get cpu clock |
||
2089 | dd sysfn_saveramdisk ; 6 = save ramdisk |
||
2090 | dd sysfn_getactive ; 7 = get active window |
||
2091 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
||
748 | heavyiron | 2092 | dd sysfn_shutdown ; 9 = shutdown with parameter |
742 | Rus | 2093 | dd sysfn_minimize ; 10 = minimize window |
2094 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
||
2095 | dd sysfn_lastkey ; 12 = get last pressed key |
||
2096 | dd sysfn_getversion ; 13 = get kernel version |
||
2097 | dd sysfn_waitretrace ; 14 = wait retrace |
||
2098 | dd sysfn_centermouse ; 15 = center mouse cursor |
||
2099 | dd sysfn_getfreemem ; 16 = get free memory size |
||
2100 | dd sysfn_getallmem ; 17 = get total memory size |
||
2101 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
||
2102 | ; instead of slot |
||
2103 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
||
2104 | dd sysfn_meminfo ; 20 = get extended memory info |
||
2105 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
||
2106 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
||
75 | diamond | 2107 | sysfn_num = ($ - sys_system_table)/4 |
2108 | endg |
||
2109 | |||
1 | ha | 2110 | sys_system: |
742 | Rus | 2111 | dec ebx |
2112 | cmp ebx, sysfn_num |
||
2113 | jae @f |
||
2114 | jmp dword [sys_system_table + ebx*4] |
||
75 | diamond | 2115 | @@: |
742 | Rus | 2116 | ret |
1 | ha | 2117 | |
214 | serge | 2118 | |
759 | Rus | 2119 | sysfn_shutdown: ; 18.9 = system shutdown |
748 | heavyiron | 2120 | cmp ecx,1 |
2121 | jl exit_for_anyone |
||
2122 | cmp ecx,4 |
||
2123 | jg exit_for_anyone |
||
2124 | mov [BOOT_VAR+0x9030],cl |
||
2125 | |||
379 | serge | 2126 | mov eax,[TASK_COUNT] |
709 | diamond | 2127 | mov [SYS_SHUTDOWN],al |
1 | ha | 2128 | mov [shutdown_processes],eax |
684 | diamond | 2129 | and dword [esp+32], 0 |
748 | heavyiron | 2130 | exit_for_anyone: |
1 | ha | 2131 | ret |
2132 | uglobal |
||
2133 | shutdown_processes: dd 0x0 |
||
2134 | endg |
||
2135 | |||
742 | Rus | 2136 | sysfn_terminate: ; 18.2 = TERMINATE |
684 | diamond | 2137 | cmp ecx,2 |
1 | ha | 2138 | jb noprocessterminate |
379 | serge | 2139 | mov edx,[TASK_COUNT] |
684 | diamond | 2140 | cmp ecx,edx |
75 | diamond | 2141 | ja noprocessterminate |
379 | serge | 2142 | mov eax,[TASK_COUNT] |
684 | diamond | 2143 | shl ecx,5 |
2144 | mov edx,[ecx+CURRENT_TASK+TASKDATA.pid] |
||
2145 | add ecx,CURRENT_TASK+TASKDATA.state |
||
2146 | cmp byte [ecx], 9 |
||
75 | diamond | 2147 | jz noprocessterminate |
41 | mikedld | 2148 | |
1 | ha | 2149 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
742 | Rus | 2150 | mov [ecx],byte 3 ; clear possible i40's |
1 | ha | 2151 | ;call MEM_Heap_UnLock |
2152 | |||
2153 | cmp edx,[application_table_status] ; clear app table stat |
||
2154 | jne noatsc |
||
2155 | mov [application_table_status],0 |
||
2156 | noatsc: |
||
75 | diamond | 2157 | noprocessterminate: |
1 | ha | 2158 | ret |
2159 | |||
85 | halyavin | 2160 | sysfn_terminate2: |
2161 | ;lock application_table_status mutex |
||
164 | serge | 2162 | .table_status: |
85 | halyavin | 2163 | cli |
2164 | cmp [application_table_status],0 |
||
742 | Rus | 2165 | je .stf |
85 | halyavin | 2166 | sti |
2167 | call change_task |
||
2168 | jmp .table_status |
||
2169 | .stf: |
||
2170 | call set_application_table_status |
||
684 | diamond | 2171 | mov eax,ecx |
85 | halyavin | 2172 | call pid_to_slot |
2173 | test eax,eax |
||
742 | Rus | 2174 | jz .not_found |
684 | diamond | 2175 | mov ecx,eax |
848 | serge | 2176 | pushfd |
85 | halyavin | 2177 | cli |
2178 | call sysfn_terminate |
||
2179 | mov [application_table_status],0 |
||
848 | serge | 2180 | popfd |
684 | diamond | 2181 | and dword [esp+32],0 |
85 | halyavin | 2182 | ret |
2183 | .not_found: |
||
2184 | mov [application_table_status],0 |
||
742 | Rus | 2185 | or dword [esp+32],-1 |
85 | halyavin | 2186 | ret |
2187 | |||
742 | Rus | 2188 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
684 | diamond | 2189 | cmp ecx,2 |
105 | poddubny | 2190 | jb .nowindowactivate |
684 | diamond | 2191 | cmp ecx,[TASK_COUNT] |
105 | poddubny | 2192 | ja .nowindowactivate |
2193 | |||
2194 | mov [window_minimize], 2 ; restore window if minimized |
||
2195 | |||
684 | diamond | 2196 | movzx esi, word [WIN_STACK + ecx*2] |
379 | serge | 2197 | cmp esi, [TASK_COUNT] |
105 | poddubny | 2198 | je .nowindowactivate ; already active |
2199 | |||
684 | diamond | 2200 | mov edi, ecx |
105 | poddubny | 2201 | shl edi, 5 |
2202 | add edi, window_data |
||
684 | diamond | 2203 | movzx esi, word [WIN_STACK + ecx * 2] |
380 | serge | 2204 | lea esi, [WIN_POS + esi * 2] |
105 | poddubny | 2205 | call waredraw |
2206 | .nowindowactivate: |
||
1 | ha | 2207 | ret |
41 | mikedld | 2208 | |
742 | Rus | 2209 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
1 | ha | 2210 | mov eax,[idleusesec] |
684 | diamond | 2211 | mov [esp+32], eax |
1 | ha | 2212 | ret |
2213 | |||
742 | Rus | 2214 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
381 | serge | 2215 | mov eax,[CPU_FREQ] |
684 | diamond | 2216 | mov [esp+32], eax |
1 | ha | 2217 | ret |
2218 | |||
2219 | ; SAVE ramdisk to /hd/1/menuet.img |
||
2220 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2221 | include 'blkdev/rdsave.inc' |
||
2222 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
75 | diamond | 2223 | |
742 | Rus | 2224 | sysfn_getactive: ; 18.7 = get active window |
379 | serge | 2225 | mov eax, [TASK_COUNT] |
380 | serge | 2226 | movzx eax, word [WIN_POS + eax*2] |
684 | diamond | 2227 | mov [esp+32],eax |
1 | ha | 2228 | ret |
75 | diamond | 2229 | |
742 | Rus | 2230 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
684 | diamond | 2231 | cmp ecx,1 |
1 | ha | 2232 | jne nogetsoundflag |
2233 | movzx eax,byte [sound_flag] ; get sound_flag |
||
684 | diamond | 2234 | mov [esp+32],eax |
1 | ha | 2235 | ret |
2236 | nogetsoundflag: |
||
684 | diamond | 2237 | cmp ecx,2 |
1 | ha | 2238 | jnz nosoundflag |
75 | diamond | 2239 | xor byte [sound_flag], 1 |
2240 | nosoundflag: |
||
41 | mikedld | 2241 | ret |
75 | diamond | 2242 | |
742 | Rus | 2243 | sysfn_minimize: ; 18.10 = minimize window |
1 | ha | 2244 | mov [window_minimize],1 |
2245 | ret |
||
75 | diamond | 2246 | |
742 | Rus | 2247 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
684 | diamond | 2248 | cmp ecx,1 |
1 | ha | 2249 | jnz full_table |
2250 | small_table: |
||
2251 | call for_all_tables |
||
75 | diamond | 2252 | mov ecx,10 |
1 | ha | 2253 | cld |
2254 | rep movsb |
||
2255 | ret |
||
2256 | for_all_tables: |
||
684 | diamond | 2257 | mov edi,edx |
381 | serge | 2258 | mov esi,DRIVE_DATA |
1 | ha | 2259 | ret |
2260 | full_table: |
||
684 | diamond | 2261 | cmp ecx,2 |
1 | ha | 2262 | jnz exit_for_anyone |
2263 | call for_all_tables |
||
75 | diamond | 2264 | mov ecx,16384 |
1 | ha | 2265 | cld |
2266 | rep movsd |
||
2267 | ret |
||
75 | diamond | 2268 | |
742 | Rus | 2269 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2270 | and dword [esp+32], 0 |
||
2271 | ret |
||
75 | diamond | 2272 | |
742 | Rus | 2273 | sysfn_getversion: ; 18.13 = get kernel ID and version |
684 | diamond | 2274 | mov edi,ebx |
1 | ha | 2275 | mov esi,version_inf |
2276 | mov ecx,version_end-version_inf |
||
2277 | rep movsb |
||
2278 | ret |
||
75 | diamond | 2279 | |
2280 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
||
41 | mikedld | 2281 | ;wait retrace functions |
2282 | sys_wait_retrace: |
||
2283 | mov edx,0x3da |
||
2284 | WaitRetrace_loop: |
||
2285 | in al,dx |
||
2286 | test al,1000b |
||
2287 | jz WaitRetrace_loop |
||
684 | diamond | 2288 | and [esp+32],dword 0 |
1 | ha | 2289 | ret |
75 | diamond | 2290 | |
742 | Rus | 2291 | sysfn_centermouse: ; 18.15 = mouse centered |
1 | ha | 2292 | call mouse_centered |
684 | diamond | 2293 | and [esp+32],dword 0 |
1 | ha | 2294 | ret |
75 | diamond | 2295 | |
120 | mario79 | 2296 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
684 | diamond | 2297 | cmp ecx,0 ; get mouse speed factor |
120 | mario79 | 2298 | jnz .set_mouse_acceleration |
164 | serge | 2299 | xor eax,eax |
120 | mario79 | 2300 | mov ax,[mouse_speed_factor] |
684 | diamond | 2301 | mov [esp+32],eax |
120 | mario79 | 2302 | ret |
2303 | .set_mouse_acceleration: |
||
684 | diamond | 2304 | cmp ecx,1 ; set mouse speed factor |
120 | mario79 | 2305 | jnz .get_mouse_delay |
684 | diamond | 2306 | mov [mouse_speed_factor],dx |
120 | mario79 | 2307 | ret |
2308 | .get_mouse_delay: |
||
684 | diamond | 2309 | cmp ecx,2 ; get mouse delay |
120 | mario79 | 2310 | jnz .set_mouse_delay |
2311 | mov eax,[mouse_delay] |
||
684 | diamond | 2312 | mov [esp+32],eax |
120 | mario79 | 2313 | ret |
2314 | .set_mouse_delay: |
||
684 | diamond | 2315 | cmp ecx,3 ; set mouse delay |
120 | mario79 | 2316 | jnz .set_pointer_position |
684 | diamond | 2317 | mov [mouse_delay],edx |
120 | mario79 | 2318 | ret |
2319 | .set_pointer_position: |
||
684 | diamond | 2320 | cmp ecx,4 ; set mouse pointer position |
621 | mario79 | 2321 | jnz .set_mouse_button |
684 | diamond | 2322 | mov [MOUSE_Y],dx ;y |
2323 | ror edx,16 |
||
2324 | mov [MOUSE_X],dx ;x |
||
2325 | rol edx,16 |
||
621 | mario79 | 2326 | ret |
2327 | .set_mouse_button: |
||
684 | diamond | 2328 | cmp ecx,5 ; set mouse button features |
621 | mario79 | 2329 | jnz .end |
684 | diamond | 2330 | mov [BTN_DOWN],dl |
621 | mario79 | 2331 | mov [mouse_active],1 |
120 | mario79 | 2332 | .end: |
2333 | ret |
||
2334 | |||
75 | diamond | 2335 | sysfn_getfreemem: |
170 | serge | 2336 | mov eax, [pg_data.pages_free] |
2337 | shl eax, 2 |
||
684 | diamond | 2338 | mov [esp+32],eax |
1 | ha | 2339 | ret |
75 | diamond | 2340 | |
2341 | sysfn_getallmem: |
||
846 | serge | 2342 | mov eax,[_mem_amount] |
170 | serge | 2343 | shr eax, 10 |
684 | diamond | 2344 | mov [esp+32],eax |
32 | halyavin | 2345 | ret |
2346 | |||
608 | alver | 2347 | ; // Alver, 2007-22-08 // { |
2348 | sysfn_pid_to_slot: |
||
684 | diamond | 2349 | mov eax, ecx |
608 | alver | 2350 | call pid_to_slot |
684 | diamond | 2351 | mov [esp+32], eax |
608 | alver | 2352 | ret |
2353 | |||
2354 | sysfn_min_rest_window: |
||
2355 | pushad |
||
742 | Rus | 2356 | mov eax, edx ; ebx - operating |
684 | diamond | 2357 | shr ecx, 1 |
608 | alver | 2358 | jnc @f |
2359 | call pid_to_slot |
||
2360 | @@: |
||
742 | Rus | 2361 | or eax, eax ; eax - number of slot |
608 | alver | 2362 | jz .error |
742 | Rus | 2363 | cmp eax, 255 ; varify maximal slot number |
608 | alver | 2364 | ja .error |
684 | diamond | 2365 | movzx eax, word [WIN_STACK + eax*2] |
2366 | shr ecx, 1 |
||
608 | alver | 2367 | jc .restore |
2368 | ; .minimize: |
||
2369 | call minimize_window |
||
2370 | jmp .exit |
||
2371 | .restore: |
||
2372 | call restore_minimized_window |
||
2373 | .exit: |
||
2374 | popad |
||
2375 | xor eax, eax |
||
684 | diamond | 2376 | mov [esp+32], eax |
608 | alver | 2377 | ret |
2378 | .error: |
||
2379 | popad |
||
2380 | xor eax, eax |
||
2381 | dec eax |
||
684 | diamond | 2382 | mov [esp+32], eax |
608 | alver | 2383 | ret |
2384 | ; } \\ Alver, 2007-22-08 \\ |
||
2385 | |||
41 | mikedld | 2386 | uglobal |
2387 | ;// mike.dld, 2006-29-01 [ |
||
2388 | screen_workarea RECT |
||
2389 | ;// mike.dld, 2006-29-01 ] |
||
1 | ha | 2390 | window_minimize db 0 |
742 | Rus | 2391 | sound_flag db 0 |
41 | mikedld | 2392 | endg |
1 | ha | 2393 | |
41 | mikedld | 2394 | iglobal |
2395 | version_inf: |
||
641 | diamond | 2396 | db 0,7,1,0 ; version 0.7.1.0 |
41 | mikedld | 2397 | db UID_KOLIBRI |
540 | victor | 2398 | dd __REV__ |
41 | mikedld | 2399 | version_end: |
2400 | endg |
||
1 | ha | 2401 | |
41 | mikedld | 2402 | UID_NONE=0 |
742 | Rus | 2403 | UID_MENUETOS=1 ;official |
2404 | UID_KOLIBRI=2 ;russian |
||
1 | ha | 2405 | |
2406 | sys_cachetodiskette: |
||
671 | Ghost | 2407 | cmp ebx, 1 |
2408 | jne .no_floppy_a_save |
||
2409 | mov [flp_number], 1 |
||
2410 | jmp .save_image_on_floppy |
||
2411 | .no_floppy_a_save: |
||
2412 | cmp ebx, 2 |
||
2413 | jne .no_floppy_b_save |
||
2414 | mov [flp_number], 2 |
||
2415 | .save_image_on_floppy: |
||
2416 | call save_image |
||
2417 | mov [esp + 32], dword 0 |
||
2418 | cmp [FDC_Status], 0 |
||
2419 | je .yes_floppy_save |
||
2420 | .no_floppy_b_save: |
||
2421 | mov [esp + 32], dword 1 |
||
2422 | .yes_floppy_save: |
||
2423 | ret |
||
1 | ha | 2424 | |
2425 | uglobal |
||
2426 | ; bgrchanged dd 0x0 |
||
546 | diamond | 2427 | bgrlock db 0 |
2428 | bgrlockpid dd 0 |
||
1 | ha | 2429 | endg |
2430 | |||
2431 | sys_background: |
||
2432 | |||
742 | Rus | 2433 | cmp ebx,1 ; BACKGROUND SIZE |
1 | ha | 2434 | jnz nosb1 |
2435 | cmp ecx,0 |
||
742 | Rus | 2436 | je sbgrr |
684 | diamond | 2437 | cmp edx,0 |
742 | Rus | 2438 | je sbgrr |
546 | diamond | 2439 | @@: |
742 | Rus | 2440 | mov al, 1 |
2441 | xchg [bgrlock], al |
||
2442 | test al, al |
||
2443 | jz @f |
||
2444 | call change_task |
||
2445 | jmp @b |
||
546 | diamond | 2446 | @@: |
684 | diamond | 2447 | mov [BgrDataWidth],ecx |
2448 | mov [BgrDataHeight],edx |
||
1 | ha | 2449 | ; mov [bgrchanged],1 |
469 | serge | 2450 | |
2451 | pushad |
||
2452 | ; return memory for old background |
||
2453 | stdcall kernel_free, [img_background] |
||
2454 | ; calculate RAW size |
||
2455 | xor eax,eax |
||
2456 | inc eax |
||
527 | diamond | 2457 | cmp [BgrDataWidth],eax |
469 | serge | 2458 | jae @f |
527 | diamond | 2459 | mov [BgrDataWidth],eax |
469 | serge | 2460 | @@: |
527 | diamond | 2461 | cmp [BgrDataHeight],eax |
469 | serge | 2462 | jae @f |
527 | diamond | 2463 | mov [BgrDataHeight],eax |
469 | serge | 2464 | @@: |
527 | diamond | 2465 | mov eax,[BgrDataWidth] |
2466 | imul eax,[BgrDataHeight] |
||
2467 | lea eax,[eax*3] |
||
469 | serge | 2468 | mov [mem_BACKGROUND],eax |
2469 | ; get memory for new background |
||
546 | diamond | 2470 | stdcall kernel_alloc, eax |
469 | serge | 2471 | test eax, eax |
2472 | jz .exit_mem |
||
2473 | mov [img_background], eax |
||
2474 | .exit_mem: |
||
2475 | popad |
||
742 | Rus | 2476 | mov [bgrlock], 0 |
469 | serge | 2477 | |
1 | ha | 2478 | sbgrr: |
2479 | ret |
||
469 | serge | 2480 | |
1 | ha | 2481 | nosb1: |
2482 | |||
742 | Rus | 2483 | cmp ebx,2 ; SET PIXEL |
1 | ha | 2484 | jnz nosb2 |
684 | diamond | 2485 | cmp ecx,[mem_BACKGROUND] |
2486 | jae nosb2 |
||
469 | serge | 2487 | mov eax,[img_background] |
684 | diamond | 2488 | mov ebx,[eax+ecx] |
2489 | and ebx,0xFF000000 ;255*256*256*256 |
||
2490 | and edx,0x00FFFFFF ;255*256*256+255*256+255 |
||
2491 | add edx,ebx |
||
2492 | mov [eax+ecx],edx |
||
1 | ha | 2493 | ; mov [bgrchanged],1 |
2494 | ret |
||
2495 | nosb2: |
||
2496 | |||
742 | Rus | 2497 | cmp ebx,3 ; DRAW BACKGROUND |
1 | ha | 2498 | jnz nosb3 |
2499 | draw_background_temp: |
||
2500 | ; cmp [bgrchanged],1 ;0 |
||
2501 | ; je nosb31 |
||
2502 | ;draw_background_temp: |
||
2503 | ; mov [bgrchanged],1 ;0 |
||
76 | mario79 | 2504 | mov [background_defined], 1 |
709 | diamond | 2505 | call force_redraw_background |
2506 | mov [REDRAW_BACKGROUND], byte 2 |
||
1 | ha | 2507 | nosb31: |
2508 | ret |
||
2509 | nosb3: |
||
2510 | |||
742 | Rus | 2511 | cmp ebx,4 ; TILED / STRETCHED |
1 | ha | 2512 | jnz nosb4 |
684 | diamond | 2513 | cmp ecx,[BgrDrawMode] |
742 | Rus | 2514 | je nosb41 |
684 | diamond | 2515 | mov [BgrDrawMode],ecx |
1 | ha | 2516 | ; mov [bgrchanged],1 |
2517 | nosb41: |
||
2518 | ret |
||
2519 | nosb4: |
||
2520 | |||
742 | Rus | 2521 | cmp ebx,5 ; BLOCK MOVE TO BGR |
1 | ha | 2522 | jnz nosb5 |
2523 | ; bughere |
||
684 | diamond | 2524 | mov eax, ecx |
2525 | mov ebx, edx |
||
469 | serge | 2526 | add ebx, [img_background] ;IMG_BACKGROUND |
684 | diamond | 2527 | mov ecx, esi |
1 | ha | 2528 | call memmove |
2529 | .fin: |
||
2530 | ret |
||
2531 | nosb5: |
||
479 | kastigar | 2532 | |
742 | Rus | 2533 | cmp ebx, 6 |
2534 | jnz nosb6 |
||
546 | diamond | 2535 | @@: |
742 | Rus | 2536 | mov al, 1 |
2537 | xchg [bgrlock], al |
||
2538 | test al, al |
||
2539 | jz @f |
||
2540 | call change_task |
||
2541 | jmp @b |
||
546 | diamond | 2542 | @@: |
742 | Rus | 2543 | mov eax, [CURRENT_TASK] |
2544 | mov [bgrlockpid], eax |
||
2545 | stdcall user_alloc, [mem_BACKGROUND] |
||
2546 | mov [esp+32], eax |
||
2547 | test eax, eax |
||
2548 | jz .nomem |
||
2549 | mov ebx, eax |
||
2550 | shr ebx, 12 |
||
2551 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
||
2552 | mov esi, [img_background] |
||
2553 | shr esi, 12 |
||
2554 | mov ecx, [mem_BACKGROUND] |
||
2555 | add ecx, 0xFFF |
||
2556 | shr ecx, 12 |
||
546 | diamond | 2557 | .z: |
742 | Rus | 2558 | mov eax, [page_tabs+ebx*4] |
2559 | test al, 1 |
||
2560 | jz @f |
||
2561 | call free_page |
||
546 | diamond | 2562 | @@: |
742 | Rus | 2563 | mov eax, [page_tabs+esi*4] |
2564 | or al, PG_UW |
||
2565 | mov [page_tabs+ebx*4], eax |
||
2566 | mov eax, ebx |
||
2567 | shl eax, 12 |
||
2568 | invlpg [eax] |
||
2569 | inc ebx |
||
2570 | inc esi |
||
2571 | loop .z |
||
2572 | ret |
||
546 | diamond | 2573 | .nomem: |
742 | Rus | 2574 | and [bgrlockpid], 0 |
2575 | mov [bgrlock], 0 |
||
546 | diamond | 2576 | nosb6: |
742 | Rus | 2577 | cmp ebx, 7 |
2578 | jnz nosb7 |
||
2579 | cmp [bgrlock], 0 |
||
2580 | jz .err |
||
2581 | mov eax, [CURRENT_TASK] |
||
2582 | cmp [bgrlockpid], eax |
||
2583 | jnz .err |
||
2584 | mov eax, ecx |
||
2585 | mov ebx, ecx |
||
2586 | shr eax, 12 |
||
2587 | mov ecx, [page_tabs+(eax-1)*4] |
||
2588 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
||
2589 | jz .err |
||
2590 | jnp .err |
||
2591 | push eax |
||
2592 | shr ecx, 12 |
||
546 | diamond | 2593 | @@: |
742 | Rus | 2594 | and dword [page_tabs+eax*4], 0 |
2595 | mov edx, eax |
||
2596 | shl edx, 12 |
||
802 | serge | 2597 | push eax |
742 | Rus | 2598 | invlpg [edx] |
802 | serge | 2599 | pop eax |
742 | Rus | 2600 | inc eax |
2601 | loop @b |
||
2602 | pop eax |
||
2603 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
||
2604 | stdcall user_free, ebx |
||
2605 | mov [esp+32], eax |
||
2606 | and [bgrlockpid], 0 |
||
2607 | mov [bgrlock], 0 |
||
2608 | ret |
||
546 | diamond | 2609 | .err: |
742 | Rus | 2610 | and dword [esp+32], 0 |
2611 | ret |
||
546 | diamond | 2612 | |
2613 | nosb7: |
||
1 | ha | 2614 | ret |
2615 | |||
709 | diamond | 2616 | force_redraw_background: |
2617 | mov [draw_data+32 + RECT.left],dword 0 |
||
2618 | mov [draw_data+32 + RECT.top],dword 0 |
||
2619 | push eax ebx |
||
753 | serge | 2620 | mov eax,[Screen_Max_X] |
2621 | mov ebx,[Screen_Max_Y] |
||
709 | diamond | 2622 | mov [draw_data+32 + RECT.right],eax |
2623 | mov [draw_data+32 + RECT.bottom],ebx |
||
2624 | pop ebx eax |
||
2625 | mov byte [REDRAW_BACKGROUND], 1 |
||
2626 | ret |
||
479 | kastigar | 2627 | |
1 | ha | 2628 | align 4 |
2629 | |||
2630 | sys_getbackground: |
||
2631 | |||
742 | Rus | 2632 | cmp eax,1 ; SIZE |
1 | ha | 2633 | jnz nogb1 |
527 | diamond | 2634 | mov eax,[BgrDataWidth] |
1 | ha | 2635 | shl eax,16 |
531 | diamond | 2636 | mov ax,[BgrDataHeight] |
1 | ha | 2637 | mov [esp+36],eax |
2638 | ret |
||
2639 | nogb1: |
||
2640 | |||
742 | Rus | 2641 | cmp eax,2 ; PIXEL |
1 | ha | 2642 | jnz nogb2 |
469 | serge | 2643 | ; mov edx,0x160000-16 |
2644 | ; cmp edx,ebx |
||
2645 | ; jbe nogb2 |
||
2646 | ; mov eax, [ebx+IMG_BACKGROUND] |
||
2647 | mov eax,[img_background] |
||
2648 | mov eax,[ebx+eax] |
||
2649 | |||
1 | ha | 2650 | and eax, 0xFFFFFF |
2651 | mov [esp+36],eax |
||
2652 | ret |
||
2653 | nogb2: |
||
2654 | |||
742 | Rus | 2655 | cmp eax,4 ; TILED / STRETCHED |
1 | ha | 2656 | jnz nogb4 |
527 | diamond | 2657 | mov eax,[BgrDrawMode] |
1 | ha | 2658 | nogb4: |
2659 | mov [esp+36],eax |
||
2660 | ret |
||
2661 | |||
2662 | |||
2663 | align 4 |
||
2664 | |||
2665 | sys_getkey: |
||
671 | Ghost | 2666 | mov [esp + 32],dword 1 |
2667 | ; test main buffer |
||
742 | Rus | 2668 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
671 | Ghost | 2669 | movzx ecx, word [WIN_STACK + ebx * 2] |
2670 | mov edx, [TASK_COUNT] |
||
2671 | cmp ecx, edx |
||
2672 | jne .finish |
||
2673 | cmp [KEY_COUNT], byte 0 |
||
2674 | je .finish |
||
2675 | movzx eax, byte [KEY_BUFF] |
||
2676 | shl eax, 8 |
||
2677 | push eax |
||
2678 | dec byte [KEY_COUNT] |
||
2679 | and byte [KEY_COUNT], 127 |
||
2680 | movzx ecx, byte [KEY_COUNT] |
||
2681 | add ecx, 2 |
||
2682 | mov eax, KEY_BUFF + 1 |
||
2683 | mov ebx, KEY_BUFF |
||
2684 | call memmove |
||
2685 | pop eax |
||
92 | diamond | 2686 | .ret_eax: |
671 | Ghost | 2687 | mov [esp + 32], eax |
2688 | ret |
||
2689 | .finish: |
||
92 | diamond | 2690 | ; test hotkeys buffer |
671 | Ghost | 2691 | mov ecx, hotkey_buffer |
92 | diamond | 2692 | @@: |
671 | Ghost | 2693 | cmp [ecx], ebx |
2694 | jz .found |
||
2695 | add ecx, 8 |
||
2696 | cmp ecx, hotkey_buffer + 120 * 8 |
||
2697 | jb @b |
||
2698 | ret |
||
92 | diamond | 2699 | .found: |
671 | Ghost | 2700 | mov ax, [ecx + 6] |
2701 | shl eax, 16 |
||
2702 | mov ah, [ecx + 4] |
||
2703 | mov al, 2 |
||
2704 | and dword [ecx + 4], 0 |
||
2705 | and dword [ecx], 0 |
||
2706 | jmp .ret_eax |
||
1 | ha | 2707 | |
2708 | align 4 |
||
2709 | |||
2710 | sys_getbutton: |
||
2711 | |||
742 | Rus | 2712 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
671 | Ghost | 2713 | mov [esp + 32], dword 1 |
2714 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
2715 | mov edx, [TASK_COUNT] ; less than 256 processes |
||
2716 | cmp ecx, edx |
||
2717 | jne .exit |
||
2718 | movzx eax, byte [BTN_COUNT] |
||
2719 | test eax, eax |
||
2720 | jz .exit |
||
2721 | mov eax, [BTN_BUFF] |
||
2722 | shl eax, 8 |
||
803 | alver | 2723 | ; // Alver 22.06.2008 // { |
2724 | mov al, byte [btn_down_determ] |
||
2725 | and al,0xFE ; delete left button bit |
||
2726 | ; } \\ Alver \\ |
||
671 | Ghost | 2727 | mov [BTN_COUNT], byte 0 |
2728 | mov [esp + 32], eax |
||
2729 | .exit: |
||
2730 | ret |
||
1 | ha | 2731 | |
2732 | |||
2733 | align 4 |
||
2734 | |||
2735 | sys_cpuusage: |
||
2736 | |||
2737 | ; RETURN: |
||
2738 | ; |
||
2739 | ; +00 dword process cpu usage |
||
2740 | ; +04 word position in windowing stack |
||
2741 | ; +06 word windowing stack value at current position (cpu nro) |
||
2742 | ; +10 12 bytes name |
||
2743 | ; +22 dword start in mem |
||
2744 | ; +26 dword used mem |
||
2745 | ; +30 dword PID , process idenfification number |
||
2746 | ; |
||
2747 | |||
742 | Rus | 2748 | cmp ecx,-1 ; who am I ? |
684 | diamond | 2749 | jne .no_who_am_i |
2750 | mov ecx,[CURRENT_TASK] |
||
2751 | .no_who_am_i: |
||
742 | Rus | 2752 | cmp ecx, max_processes |
2753 | ja .nofillbuf |
||
1 | ha | 2754 | |
684 | diamond | 2755 | ; +4: word: position of the window of thread in the window stack |
742 | Rus | 2756 | mov ax, [WIN_STACK + ecx * 2] |
2757 | mov [ebx+4], ax |
||
684 | diamond | 2758 | ; +6: word: number of the thread slot, which window has in the window stack |
2759 | ; position ecx (has no relation to the specific thread) |
||
742 | Rus | 2760 | mov ax, [WIN_POS + ecx * 2] |
2761 | mov [ebx+6], ax |
||
1 | ha | 2762 | |
742 | Rus | 2763 | shl ecx, 5 |
1 | ha | 2764 | |
684 | diamond | 2765 | ; +0: dword: memory usage |
742 | Rus | 2766 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2767 | mov [ebx], eax |
||
684 | diamond | 2768 | ; +10: 11 bytes: name of the process |
742 | Rus | 2769 | push ecx |
2770 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
||
2771 | add ebx, 10 |
||
2772 | mov ecx, 11 |
||
2773 | call memmove |
||
2774 | pop ecx |
||
1 | ha | 2775 | |
684 | diamond | 2776 | ; +22: address of the process in memory |
2777 | ; +26: size of used memory - 1 |
||
742 | Rus | 2778 | push edi |
2779 | lea edi, [ebx+12] |
||
2780 | xor eax, eax |
||
2781 | mov edx, 0x100000*16 |
||
2782 | cmp ecx, 1 shl 5 |
||
2783 | je .os_mem |
||
2784 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
||
840 | serge | 2785 | xor eax, eax |
684 | diamond | 2786 | .os_mem: |
742 | Rus | 2787 | stosd |
2788 | lea eax, [edx-1] |
||
2789 | stosd |
||
1 | ha | 2790 | |
684 | diamond | 2791 | ; +30: PID/TID |
742 | Rus | 2792 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2793 | stosd |
||
1 | ha | 2794 | |
2795 | ; window position and size |
||
742 | Rus | 2796 | push esi |
2797 | lea esi, [ecx + window_data + WDATA.box] |
||
2798 | movsd |
||
2799 | movsd |
||
2800 | movsd |
||
2801 | movsd |
||
1 | ha | 2802 | |
2803 | ; Process state (+50) |
||
742 | Rus | 2804 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
2805 | stosd |
||
1 | ha | 2806 | |
138 | mikedld | 2807 | ; Window client area box |
742 | Rus | 2808 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
2809 | movsd |
||
2810 | movsd |
||
2811 | movsd |
||
2812 | movsd |
||
1 | ha | 2813 | |
164 | serge | 2814 | ; Window state |
742 | Rus | 2815 | mov al, [ecx+window_data+WDATA.fl_wstate] |
2816 | stosb |
||
164 | serge | 2817 | |
742 | Rus | 2818 | pop esi |
2819 | pop edi |
||
138 | mikedld | 2820 | |
684 | diamond | 2821 | .nofillbuf: |
1 | ha | 2822 | ; return number of processes |
2823 | |||
379 | serge | 2824 | mov eax,[TASK_COUNT] |
684 | diamond | 2825 | mov [esp+32],eax |
1 | ha | 2826 | ret |
2827 | |||
2828 | align 4 |
||
2829 | sys_clock: |
||
742 | Rus | 2830 | cli |
1 | ha | 2831 | ; Mikhail Lisovin xx Jan 2005 |
742 | Rus | 2832 | @@: mov al, 10 |
2833 | out 0x70, al |
||
2834 | in al, 0x71 |
||
2835 | test al, al |
||
2836 | jns @f |
||
2837 | mov esi, 1 |
||
2838 | call delay_ms |
||
2839 | jmp @b |
||
1 | ha | 2840 | @@: |
2841 | ; end Lisovin's fix |
||
2842 | |||
742 | Rus | 2843 | xor al,al ; seconds |
2844 | out 0x70,al |
||
2845 | in al,0x71 |
||
2846 | movzx ecx,al |
||
2847 | mov al,02 ; minutes |
||
2848 | shl ecx,16 |
||
2849 | out 0x70,al |
||
2850 | in al,0x71 |
||
2851 | movzx edx,al |
||
2852 | mov al,04 ; hours |
||
2853 | shl edx,8 |
||
2854 | out 0x70,al |
||
2855 | in al,0x71 |
||
2856 | add ecx,edx |
||
2857 | movzx edx,al |
||
2858 | add ecx,edx |
||
2859 | sti |
||
671 | Ghost | 2860 | mov [esp + 32], ecx |
742 | Rus | 2861 | ret |
1 | ha | 2862 | |
2863 | |||
2864 | align 4 |
||
2865 | |||
2866 | sys_date: |
||
2867 | |||
742 | Rus | 2868 | cli |
2869 | @@: mov al, 10 |
||
2870 | out 0x70, al |
||
2871 | in al, 0x71 |
||
2872 | test al, al |
||
2873 | jns @f |
||
2874 | mov esi, 1 |
||
2875 | call delay_ms |
||
2876 | jmp @b |
||
75 | diamond | 2877 | @@: |
2878 | |||
742 | Rus | 2879 | mov ch,0 |
2880 | mov al,7 ; date |
||
2881 | out 0x70,al |
||
2882 | in al,0x71 |
||
2883 | mov cl,al |
||
2884 | mov al,8 ; month |
||
2885 | shl ecx,16 |
||
2886 | out 0x70,al |
||
2887 | in al,0x71 |
||
2888 | mov ch,al |
||
2889 | mov al,9 ; year |
||
2890 | out 0x70,al |
||
2891 | in al,0x71 |
||
2892 | mov cl,al |
||
2893 | sti |
||
2894 | mov [esp+32], ecx |
||
2895 | ret |
||
1 | ha | 2896 | |
2897 | |||
2898 | ; redraw status |
||
2899 | |||
2900 | sys_redrawstat: |
||
671 | Ghost | 2901 | cmp ebx, 1 |
2902 | jne no_widgets_away |
||
2903 | ; buttons away |
||
2904 | mov ecx,[CURRENT_TASK] |
||
1 | ha | 2905 | sys_newba2: |
671 | Ghost | 2906 | mov edi,[BTN_ADDR] |
742 | Rus | 2907 | cmp [edi], dword 0 ; empty button list ? |
671 | Ghost | 2908 | je end_of_buttons_away |
2909 | movzx ebx, word [edi] |
||
2910 | inc ebx |
||
2911 | mov eax,edi |
||
1 | ha | 2912 | sys_newba: |
671 | Ghost | 2913 | dec ebx |
2914 | jz end_of_buttons_away |
||
1 | ha | 2915 | |
671 | Ghost | 2916 | add eax, 0x10 |
2917 | cmp cx, [eax] |
||
2918 | jnz sys_newba |
||
1 | ha | 2919 | |
671 | Ghost | 2920 | push eax ebx ecx |
2921 | mov ecx,ebx |
||
2922 | inc ecx |
||
2923 | shl ecx, 4 |
||
2924 | mov ebx, eax |
||
2925 | add eax, 0x10 |
||
2926 | call memmove |
||
2927 | dec dword [edi] |
||
2928 | pop ecx ebx eax |
||
1 | ha | 2929 | |
671 | Ghost | 2930 | jmp sys_newba2 |
1 | ha | 2931 | |
2932 | end_of_buttons_away: |
||
2933 | |||
671 | Ghost | 2934 | ret |
1 | ha | 2935 | |
2936 | no_widgets_away: |
||
2937 | |||
671 | Ghost | 2938 | cmp ebx, 2 |
2939 | jnz srl1 |
||
1 | ha | 2940 | |
671 | Ghost | 2941 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
2942 | add edx, draw_data - CURRENT_TASK |
||
2943 | mov [edx + RECT.left], 0 |
||
2944 | mov [edx + RECT.top], 0 |
||
759 | Rus | 2945 | mov eax, [Screen_Max_X] |
671 | Ghost | 2946 | mov [edx + RECT.right], eax |
759 | Rus | 2947 | mov eax, [Screen_Max_Y] |
671 | Ghost | 2948 | mov [edx + RECT.bottom], eax |
1 | ha | 2949 | |
671 | Ghost | 2950 | mov edi, [TASK_BASE] |
2951 | or [edi - twdw + WDATA.fl_wdrawn], 1 ; no new position & buttons from app |
||
2952 | call sys_window_mouse |
||
2953 | ret |
||
1 | ha | 2954 | |
2955 | srl1: |
||
671 | Ghost | 2956 | ret |
1 | ha | 2957 | |
2958 | |||
2959 | sys_drawwindow: |
||
2960 | |||
684 | diamond | 2961 | mov eax,edx |
2962 | shr eax,16+8 |
||
2963 | and eax,15 |
||
1 | ha | 2964 | |
684 | diamond | 2965 | ; cmp eax,0 ; type I - original style |
1 | ha | 2966 | jne nosyswI |
33 | mario79 | 2967 | inc [mouse_pause] |
36 | mario79 | 2968 | call [disable_mouse] |
1 | ha | 2969 | call sys_set_window |
36 | mario79 | 2970 | call [disable_mouse] |
1 | ha | 2971 | call drawwindow_I |
114 | mikedld | 2972 | ;dec [mouse_pause] |
2973 | ;call [draw_pointer] |
||
2974 | ;ret |
||
2975 | jmp draw_window_caption.2 |
||
1 | ha | 2976 | nosyswI: |
2977 | |||
742 | Rus | 2978 | cmp al,1 ; type II - only reserve area, no draw |
1 | ha | 2979 | jne nosyswII |
33 | mario79 | 2980 | inc [mouse_pause] |
36 | mario79 | 2981 | call [disable_mouse] |
1 | ha | 2982 | call sys_set_window |
36 | mario79 | 2983 | call [disable_mouse] |
1 | ha | 2984 | call sys_window_mouse |
33 | mario79 | 2985 | dec [mouse_pause] |
36 | mario79 | 2986 | call [draw_pointer] |
1 | ha | 2987 | ret |
2988 | nosyswII: |
||
2989 | |||
742 | Rus | 2990 | cmp al,2 ; type III - new style |
1 | ha | 2991 | jne nosyswIII |
33 | mario79 | 2992 | inc [mouse_pause] |
36 | mario79 | 2993 | call [disable_mouse] |
1 | ha | 2994 | call sys_set_window |
36 | mario79 | 2995 | call [disable_mouse] |
1 | ha | 2996 | call drawwindow_III |
114 | mikedld | 2997 | ;dec [mouse_pause] |
2998 | ;call [draw_pointer] |
||
2999 | ;ret |
||
3000 | jmp draw_window_caption.2 |
||
1 | ha | 3001 | nosyswIII: |
3002 | |||
742 | Rus | 3003 | cmp al,3 ; type IV - skinned window |
3004 | je draw_skin_window |
||
3005 | cmp al,4 ; type V - skinned window not sized! {not_sized_skin_window} |
||
549 | spraid | 3006 | jne nosyswV |
3007 | draw_skin_window: |
||
567 | serge | 3008 | |
569 | diamond | 3009 | inc [mouse_pause] |
3010 | call [disable_mouse] |
||
3011 | call sys_set_window |
||
3012 | call [disable_mouse] |
||
684 | diamond | 3013 | mov eax, [TASK_COUNT] |
3014 | movzx eax, word [WIN_POS + eax*2] |
||
3015 | cmp eax, [CURRENT_TASK] |
||
3016 | setz al |
||
3017 | movzx eax, al |
||
3018 | push eax |
||
36 | mario79 | 3019 | call drawwindow_IV |
114 | mikedld | 3020 | ;dec [mouse_pause] |
3021 | ;call [draw_pointer] |
||
3022 | ;ret |
||
3023 | jmp draw_window_caption.2 |
||
549 | spraid | 3024 | nosyswV: |
1 | ha | 3025 | |
3026 | ret |
||
3027 | |||
3028 | |||
114 | mikedld | 3029 | draw_window_caption: |
742 | Rus | 3030 | inc [mouse_pause] |
3031 | call [disable_mouse] |
||
114 | mikedld | 3032 | |
742 | Rus | 3033 | xor eax,eax |
3034 | mov edx,[TASK_COUNT] |
||
3035 | movzx edx,word[WIN_POS+edx*2] |
||
3036 | cmp edx,[CURRENT_TASK] |
||
3037 | jne @f |
||
3038 | inc eax |
||
3039 | @@: mov edx,[CURRENT_TASK] |
||
3040 | shl edx,5 |
||
3041 | add edx,window_data |
||
3042 | movzx ebx,[edx+WDATA.fl_wstyle] |
||
3043 | and bl,0x0F |
||
3044 | cmp bl,3 |
||
3045 | je .draw_caption_style_3 ;{for 3 and 4 style write caption} |
||
3046 | cmp bl,4 |
||
3047 | je .draw_caption_style_3 |
||
567 | serge | 3048 | |
742 | Rus | 3049 | jmp .not_style_3 |
549 | spraid | 3050 | .draw_caption_style_3: |
114 | mikedld | 3051 | |
742 | Rus | 3052 | push edx |
3053 | call drawwindow_IV_caption |
||
3054 | add esp,4 |
||
3055 | jmp .2 |
||
114 | mikedld | 3056 | |
3057 | .not_style_3: |
||
742 | Rus | 3058 | cmp bl,2 |
3059 | jne .not_style_2 |
||
114 | mikedld | 3060 | |
742 | Rus | 3061 | call drawwindow_III_caption |
3062 | jmp .2 |
||
114 | mikedld | 3063 | |
3064 | .not_style_2: |
||
742 | Rus | 3065 | cmp bl,0 |
3066 | jne .2 |
||
114 | mikedld | 3067 | |
742 | Rus | 3068 | call drawwindow_I_caption |
114 | mikedld | 3069 | |
3070 | ;-------------------------------------------------------------- |
||
742 | Rus | 3071 | .2: ;jmp @f |
3072 | mov edi,[CURRENT_TASK] |
||
3073 | shl edi,5 |
||
3074 | test [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION |
||
3075 | jz @f |
||
3076 | mov edx,[edi*8+SLOT_BASE+APPDATA.wnd_caption] |
||
3077 | or edx,edx |
||
3078 | jz @f |
||
114 | mikedld | 3079 | |
742 | Rus | 3080 | movzx eax,[edi+window_data+WDATA.fl_wstyle] |
3081 | and al,0x0F |
||
3082 | cmp al,3 |
||
3083 | je .skinned |
||
3084 | cmp al,4 |
||
3085 | je .skinned |
||
567 | serge | 3086 | |
742 | Rus | 3087 | jmp .not_skinned |
567 | serge | 3088 | .skinned: |
742 | Rus | 3089 | mov ebp,[edi+window_data+WDATA.box.left-2] |
3090 | mov bp,word[edi+window_data+WDATA.box.top] |
||
3091 | movzx eax,word[edi+window_data+WDATA.box.width] |
||
3092 | sub ax,[_skinmargins.left] |
||
3093 | sub ax,[_skinmargins.right] |
||
3094 | push edx |
||
3095 | cwde |
||
3096 | cdq |
||
3097 | mov ebx,6 |
||
3098 | idiv ebx |
||
3099 | pop edx |
||
3100 | or eax,eax |
||
3101 | js @f |
||
3102 | mov esi,eax |
||
3103 | mov ebx,dword[_skinmargins.left-2] |
||
3104 | mov bx,word[_skinh] |
||
3105 | sub bx,[_skinmargins.bottom] |
||
3106 | sub bx,[_skinmargins.top] |
||
3107 | sar bx,1 |
||
3108 | adc bx,0 |
||
3109 | add bx,[_skinmargins.top] |
||
3110 | add bx,-3 |
||
3111 | add ebx,ebp |
||
3112 | jmp .dodraw |
||
114 | mikedld | 3113 | |
3114 | .not_skinned: |
||
742 | Rus | 3115 | cmp al,1 |
3116 | je @f |
||
114 | mikedld | 3117 | |
742 | Rus | 3118 | mov ebp,[edi+window_data+WDATA.box.left-2] |
3119 | mov bp,word[edi+window_data+WDATA.box.top] |
||
3120 | movzx eax,word[edi+window_data+WDATA.box.width] |
||
3121 | sub eax,16 |
||
3122 | push edx |
||
3123 | cwde |
||
3124 | cdq |
||
3125 | mov ebx,6 |
||
3126 | idiv ebx |
||
3127 | pop edx |
||
3128 | or eax,eax |
||
3129 | js @f |
||
3130 | mov esi,eax |
||
3131 | mov ebx,0x00080007 |
||
3132 | add ebx,ebp |
||
139 | diamond | 3133 | .dodraw: |
742 | Rus | 3134 | mov ecx,[common_colours+16];0x00FFFFFF |
3135 | or ecx, 0x80000000 |
||
3136 | xor edi,edi |
||
803 | alver | 3137 | ; // Alver 22.06.2008 // { |
3138 | ; call dtext |
||
3139 | call dtext_asciiz_esi |
||
3140 | ; } \\ Alver \\ |
||
114 | mikedld | 3141 | |
3142 | @@: |
||
3143 | ;-------------------------------------------------------------- |
||
742 | Rus | 3144 | dec [mouse_pause] |
3145 | call [draw_pointer] |
||
3146 | ret |
||
114 | mikedld | 3147 | |
3148 | iglobal |
||
3149 | align 4 |
||
3150 | window_topleft dd \ |
||
549 | spraid | 3151 | 1, 21,\ ;type 0 |
742 | Rus | 3152 | 0, 0,\ ;type 1 |
3153 | 5, 20,\ ;type 2 |
||
3154 | 5, ?,\ ;type 3 {set by skin} |
||
3155 | 5, ? ;type 4 {set by skin} |
||
114 | mikedld | 3156 | endg |
3157 | |||
3158 | set_window_clientbox: |
||
742 | Rus | 3159 | push eax ecx edi |
114 | mikedld | 3160 | |
742 | Rus | 3161 | mov eax,[_skinh] |
3162 | mov [window_topleft+4*7],eax |
||
3163 | mov [window_topleft+4*9],eax |
||
114 | mikedld | 3164 | |
742 | Rus | 3165 | mov ecx,edi |
3166 | sub edi,window_data |
||
3167 | shl edi,3 |
||
3168 | test [ecx+WDATA.fl_wstyle],WSTYLE_CLIENTRELATIVE |
||
3169 | jz @f |
||
114 | mikedld | 3170 | |
742 | Rus | 3171 | movzx eax,[ecx+WDATA.fl_wstyle] |
3172 | and eax,0x0F |
||
3173 | mov eax,[eax*8+window_topleft+0] |
||
3174 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax |
||
3175 | shl eax,1 |
||
3176 | neg eax |
||
3177 | add eax,[ecx+WDATA.box.width] |
||
3178 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax |
||
114 | mikedld | 3179 | |
742 | Rus | 3180 | movzx eax,[ecx+WDATA.fl_wstyle] |
3181 | and eax,0x0F |
||
3182 | push [eax*8+window_topleft+0] |
||
3183 | mov eax,[eax*8+window_topleft+4] |
||
3184 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax |
||
3185 | neg eax |
||
3186 | sub eax,[esp] |
||
3187 | add eax,[ecx+WDATA.box.height] |
||
3188 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax |
||
3189 | add esp,4 |
||
114 | mikedld | 3190 | |
742 | Rus | 3191 | pop edi ecx eax |
3192 | ret |
||
114 | mikedld | 3193 | @@: |
742 | Rus | 3194 | xor eax,eax |
3195 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.left],eax |
||
3196 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.top],eax |
||
3197 | mov eax,[ecx+WDATA.box.width] |
||
3198 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.width],eax |
||
3199 | mov eax,[ecx+WDATA.box.height] |
||
3200 | mov [edi+SLOT_BASE+APPDATA.wnd_clientbox.height],eax |
||
114 | mikedld | 3201 | |
742 | Rus | 3202 | pop edi ecx eax |
3203 | ret |
||
114 | mikedld | 3204 | |
1 | ha | 3205 | sys_set_window: |
3206 | |||
684 | diamond | 3207 | mov eax,[CURRENT_TASK] |
3208 | shl eax,5 |
||
3209 | add eax,window_data |
||
1 | ha | 3210 | |
3211 | ; colors |
||
684 | diamond | 3212 | mov [eax+WDATA.cl_workarea],edx |
3213 | mov [eax+WDATA.cl_titlebar],esi |
||
3214 | mov [eax+WDATA.cl_frames],edi |
||
1 | ha | 3215 | |
684 | diamond | 3216 | mov edi, eax |
3217 | |||
1 | ha | 3218 | ; check flag (?) |
186 | diamond | 3219 | test [edi+WDATA.fl_wdrawn],1 |
3220 | jnz newd |
||
1 | ha | 3221 | |
3222 | mov eax,[timer_ticks] ;[0xfdf0] |
||
3223 | add eax,100 |
||
3224 | mov [new_window_starting],eax |
||
3225 | |||
684 | diamond | 3226 | mov word[edi+WDATA.box.width],bx |
3227 | mov word[edi+WDATA.box.height],cx |
||
114 | mikedld | 3228 | sar ebx,16 |
684 | diamond | 3229 | sar ecx,16 |
3230 | mov word[edi+WDATA.box.left],bx |
||
3231 | mov word[edi+WDATA.box.top],cx |
||
1 | ha | 3232 | |
3233 | call check_window_position |
||
3234 | |||
164 | serge | 3235 | call set_window_clientbox |
1 | ha | 3236 | |
742 | Rus | 3237 | push ecx esi edi ; save for window fullscreen/resize |
114 | mikedld | 3238 | ;mov esi,edi |
3239 | |||
742 | Rus | 3240 | mov cl, [edi+WDATA.fl_wstyle] |
3241 | mov eax, [edi+WDATA.cl_frames] |
||
114 | mikedld | 3242 | |
1 | ha | 3243 | sub edi,window_data |
114 | mikedld | 3244 | shl edi,3 |
380 | serge | 3245 | add edi,SLOT_BASE |
114 | mikedld | 3246 | |
742 | Rus | 3247 | and cl,0x0F |
3248 | mov [edi+APPDATA.wnd_caption],0 |
||
3249 | cmp cl,3 |
||
3250 | je set_APPDATA_wnd_caption |
||
3251 | cmp cl,4 ; {SPraid.simba} |
||
3252 | je set_APPDATA_wnd_caption |
||
567 | serge | 3253 | |
742 | Rus | 3254 | jmp @f |
549 | spraid | 3255 | set_APPDATA_wnd_caption: |
742 | Rus | 3256 | mov [edi+APPDATA.wnd_caption],eax |
3257 | @@: mov esi,[esp+0] |
||
114 | mikedld | 3258 | |
115 | poddubny | 3259 | add edi, APPDATA.saved_box |
742 | Rus | 3260 | movsd |
3261 | movsd |
||
3262 | movsd |
||
3263 | movsd |
||
1 | ha | 3264 | pop edi esi ecx |
3265 | |||
742 | Rus | 3266 | mov esi, [CURRENT_TASK] |
3267 | movzx esi, word [WIN_STACK+esi*2] |
||
3268 | lea esi, [WIN_POS+esi*2] |
||
3269 | call waredraw |
||
569 | diamond | 3270 | |
684 | diamond | 3271 | ;;; mov ebx, 1 |
1 | ha | 3272 | ;;; call delay_hs |
115 | poddubny | 3273 | mov eax, [edi+WDATA.box.left] |
3274 | mov ebx, [edi+WDATA.box.top] |
||
3275 | mov ecx, [edi+WDATA.box.width] |
||
3276 | mov edx, [edi+WDATA.box.height] |
||
1 | ha | 3277 | add ecx, eax |
3278 | add edx, ebx |
||
3279 | call calculatescreen |
||
3280 | |||
742 | Rus | 3281 | mov [KEY_COUNT],byte 0 ; empty keyboard buffer |
3282 | mov [BTN_COUNT],byte 0 ; empty button buffer |
||
1 | ha | 3283 | |
3284 | newd: |
||
742 | Rus | 3285 | mov [edi+WDATA.fl_redraw],byte 0 ; no redraw |
1 | ha | 3286 | mov edx,edi |
3287 | |||
3288 | ret |
||
3289 | |||
114 | mikedld | 3290 | syscall_windowsettings: |
1 | ha | 3291 | |
114 | mikedld | 3292 | .set_window_caption: |
742 | Rus | 3293 | dec eax ; subfunction #1 - set window caption |
3294 | jnz .get_window_caption |
||
114 | mikedld | 3295 | |
742 | Rus | 3296 | ; NOTE: only window owner thread can set its caption, |
3297 | ; so there's no parameter for PID/TID |
||
114 | mikedld | 3298 | |
742 | Rus | 3299 | mov edi,[CURRENT_TASK] |
3300 | shl edi,5 |
||
114 | mikedld | 3301 | |
742 | Rus | 3302 | ; have to check if caption is within application memory limit |
3303 | ; check is trivial, and if application resizes its memory, |
||
3304 | ; caption still can become over bounds |
||
202 | diamond | 3305 | ; diamond, 31.10.2006: check removed because with new memory manager |
3306 | ; there can be valid data after APPDATA.mem_size bound |
||
380 | serge | 3307 | ; mov ecx,[edi*8+SLOT_BASE+APPDATA.mem_size] |
202 | diamond | 3308 | ; add ecx,255 ; max caption length |
3309 | ; cmp ebx,ecx |
||
3310 | ; ja .exit_fail |
||
114 | mikedld | 3311 | |
742 | Rus | 3312 | mov [edi*8+SLOT_BASE+APPDATA.wnd_caption],ebx |
3313 | or [edi+window_data+WDATA.fl_wstyle],WSTYLE_HASCAPTION |
||
114 | mikedld | 3314 | |
742 | Rus | 3315 | call draw_window_caption |
114 | mikedld | 3316 | |
742 | Rus | 3317 | xor eax,eax ; eax = 0 (success) |
3318 | ret |
||
114 | mikedld | 3319 | |
3320 | .get_window_caption: |
||
742 | Rus | 3321 | dec eax ; subfunction #2 - get window caption |
3322 | jnz .exit_fail |
||
114 | mikedld | 3323 | |
742 | Rus | 3324 | ; not implemented yet |
114 | mikedld | 3325 | |
3326 | .exit_fail: |
||
742 | Rus | 3327 | xor eax,eax |
3328 | inc eax ; eax = 1 (fail) |
||
3329 | ret |
||
114 | mikedld | 3330 | |
3331 | |||
1 | ha | 3332 | sys_window_move: |
3333 | |||
742 | Rus | 3334 | mov edi,[CURRENT_TASK] |
3335 | shl edi,5 |
||
3336 | add edi,window_data |
||
1 | ha | 3337 | |
742 | Rus | 3338 | test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED |
3339 | jnz .window_move_return |
||
1 | ha | 3340 | |
742 | Rus | 3341 | push dword [edi + WDATA.box.left] ; save old coordinates |
3342 | push dword [edi + WDATA.box.top] |
||
3343 | push dword [edi + WDATA.box.width] |
||
3344 | push dword [edi + WDATA.box.height] |
||
1 | ha | 3345 | |
742 | Rus | 3346 | cmp eax,-1 ; set new position and size |
3347 | je .no_x_reposition |
||
3348 | mov [edi + WDATA.box.left], eax |
||
49 | mikedld | 3349 | .no_x_reposition: |
742 | Rus | 3350 | cmp ebx,-1 |
3351 | je .no_y_reposition |
||
3352 | mov [edi + WDATA.box.top], ebx |
||
49 | mikedld | 3353 | .no_y_reposition: |
1 | ha | 3354 | |
742 | Rus | 3355 | test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP |
3356 | jnz .no_y_resizing |
||
1 | ha | 3357 | |
742 | Rus | 3358 | cmp ecx,-1 |
3359 | je .no_x_resizing |
||
3360 | mov [edi + WDATA.box.width], ecx |
||
49 | mikedld | 3361 | .no_x_resizing: |
742 | Rus | 3362 | cmp edx,-1 |
3363 | je .no_y_resizing |
||
3364 | mov [edi + WDATA.box.height], edx |
||
49 | mikedld | 3365 | .no_y_resizing: |
1 | ha | 3366 | |
742 | Rus | 3367 | call check_window_position |
3368 | call set_window_clientbox |
||
1 | ha | 3369 | |
742 | Rus | 3370 | pushad ; save for window fullscreen/resize |
3371 | mov esi,edi |
||
3372 | sub edi,window_data |
||
3373 | shr edi,5 |
||
3374 | shl edi,8 |
||
3375 | add edi, SLOT_BASE + APPDATA.saved_box |
||
3376 | mov ecx,4 |
||
3377 | cld |
||
3378 | rep movsd |
||
3379 | popad |
||
49 | mikedld | 3380 | |
742 | Rus | 3381 | pushad ; calculcate screen at new position |
3382 | mov eax, [edi + WDATA.box.left] |
||
3383 | mov ebx, [edi + WDATA.box.top] |
||
3384 | mov ecx, [edi + WDATA.box.width] |
||
3385 | mov edx, [edi + WDATA.box.height] |
||
3386 | add ecx,eax |
||
3387 | add edx,ebx |
||
221 | serge | 3388 | |
742 | Rus | 3389 | call calculatescreen |
3390 | popad |
||
49 | mikedld | 3391 | |
742 | Rus | 3392 | pop edx ; calculcate screen at old position |
3393 | pop ecx |
||
3394 | pop ebx |
||
3395 | pop eax |
||
3396 | add ecx,eax |
||
3397 | add edx,ebx |
||
3398 | mov [dlx],eax ; save for drawlimits |
||
3399 | mov [dly],ebx |
||
3400 | mov [dlxe],ecx |
||
3401 | mov [dlye],edx |
||
3402 | call calculatescreen |
||
49 | mikedld | 3403 | |
742 | Rus | 3404 | mov [edi + WDATA.fl_redraw], 1 ; flag the process as redraw |
49 | mikedld | 3405 | |
742 | Rus | 3406 | mov eax,edi ; redraw screen at old position |
3407 | xor esi,esi |
||
3408 | call redrawscreen |
||
49 | mikedld | 3409 | |
742 | Rus | 3410 | mov [DONT_DRAW_MOUSE],byte 0 ; mouse pointer |
3411 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse under |
||
3412 | mov [MOUSE_DOWN],byte 0 ; react to mouse up/down |
||
49 | mikedld | 3413 | |
742 | Rus | 3414 | call [draw_pointer] |
49 | mikedld | 3415 | |
742 | Rus | 3416 | mov [window_move_pr],0 |
49 | mikedld | 3417 | |
3418 | .window_move_return: |
||
3419 | |||
742 | Rus | 3420 | ret |
1 | ha | 3421 | |
3422 | uglobal |
||
3423 | window_move_pr dd 0x0 |
||
3424 | window_move_eax dd 0x0 |
||
3425 | window_move_ebx dd 0x0 |
||
3426 | window_move_ecx dd 0x0 |
||
3427 | window_move_edx dd 0x0 |
||
3428 | endg |
||
3429 | |||
3430 | ;ok - 100% work |
||
3431 | ;nt - not tested |
||
3432 | ;--------------------------------------------------------------------------------------------- |
||
3433 | ;eax |
||
3434 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
||
3435 | ;1 - change task. Ret nothing. Block. ok. |
||
3436 | ;2 - performance control |
||
3437 | ; ebx |
||
3438 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
||
3439 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
||
3440 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
||
3441 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
||
3442 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
||
3443 | ;eax |
||
3444 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3445 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3446 | ;--------------------------------------------------------------------------------------------- |
||
3447 | sys_sheduler: ;noname & halyavin |
||
3448 | cmp eax,0 |
||
3449 | je shed_counter |
||
3450 | cmp eax,2 |
||
3451 | je perf_control |
||
3452 | cmp eax,3 |
||
3453 | je rdmsr_instr |
||
3454 | cmp eax,4 |
||
3455 | je wrmsr_instr |
||
3456 | cmp eax,1 |
||
3457 | jne not_supported |
||
3458 | call change_task ;delay,0 |
||
3459 | ret |
||
3460 | shed_counter: |
||
3461 | mov eax,[context_counter] |
||
3462 | mov [esp+36],eax |
||
3463 | not_supported: |
||
3464 | ret |
||
3465 | perf_control: |
||
3466 | inc eax ;now eax=3 |
||
3467 | cmp ebx,eax |
||
3468 | je cache_disable |
||
3469 | dec eax |
||
3470 | cmp ebx,eax |
||
3471 | je cache_enable |
||
3472 | dec eax |
||
3473 | cmp ebx,eax |
||
3474 | je is_cache_enabled |
||
3475 | dec eax |
||
3476 | cmp ebx,eax |
||
3477 | je modify_pce |
||
3478 | ret |
||
3479 | |||
3480 | rdmsr_instr: |
||
3481 | ;now counter in ecx |
||
3482 | ;(edx:eax) esi:edi => edx:esi |
||
3483 | mov eax,esi |
||
3484 | rdmsr |
||
3485 | mov [esp+36],eax |
||
3486 | mov [esp+24],edx ;ret in ebx? |
||
3487 | ret |
||
3488 | |||
3489 | wrmsr_instr: |
||
3490 | ;now counter in ecx |
||
3491 | ;(edx:eax) esi:edi => edx:esi |
||
482 | Ghost | 3492 | ; Fast Call MSR can't be destroy |
3493 | ; Íî MSR_AMD_EFER ìîæíî èçìåíÿòü, ò.ê. â ýòîì ðåãèñòðå ëèø |
||
3494 | ; âêëþ÷àþòñÿ/âûêëþ÷àþòñÿ ðàñøèðåííûå âîçìîæíîñòè |
||
3495 | cmp ecx, MSR_SYSENTER_CS |
||
3496 | je @f |
||
3497 | cmp ecx, MSR_SYSENTER_ESP |
||
3498 | je @f |
||
3499 | cmp ecx, MSR_SYSENTER_EIP |
||
3500 | je @f |
||
3501 | cmp ecx, MSR_AMD_STAR |
||
3502 | je @f |
||
3503 | |||
3504 | mov eax, esi |
||
3505 | wrmsr |
||
742 | Rus | 3506 | ; mov [esp + 36], eax |
3507 | ; mov [esp + 24], edx ;ret in ebx? |
||
482 | Ghost | 3508 | @@: |
1 | ha | 3509 | ret |
3510 | |||
3511 | cache_disable: |
||
3512 | mov eax,cr0 |
||
3513 | or eax,01100000000000000000000000000000b |
||
3514 | mov cr0,eax |
||
3515 | wbinvd ;set MESI |
||
3516 | ret |
||
3517 | |||
3518 | cache_enable: |
||
3519 | mov eax,cr0 |
||
3520 | and eax,10011111111111111111111111111111b |
||
3521 | mov cr0,eax |
||
3522 | ret |
||
3523 | |||
3524 | is_cache_enabled: |
||
3525 | mov eax,cr0 |
||
3526 | mov ebx,eax |
||
3527 | and eax,01100000000000000000000000000000b |
||
3528 | jz cache_disabled |
||
3529 | mov [esp+36],ebx |
||
3530 | cache_disabled: |
||
3531 | mov dword [esp+36],eax ;0 |
||
3532 | ret |
||
3533 | |||
3534 | modify_pce: |
||
3535 | mov eax,cr4 |
||
3536 | ; mov ebx,0 |
||
3537 | ; or bx,100000000b ;pce |
||
3538 | ; xor eax,ebx ;invert pce |
||
17 | me_root | 3539 | bts eax,8 ;pce=cr4[8] |
1 | ha | 3540 | mov cr4,eax |
3541 | mov [esp+36],eax |
||
3542 | ret |
||
3543 | ;--------------------------------------------------------------------------------------------- |
||
3544 | |||
3545 | |||
3546 | ; check if pixel is allowed to be drawn |
||
3547 | |||
3548 | checkpixel: |
||
742 | Rus | 3549 | push eax edx |
1 | ha | 3550 | |
759 | Rus | 3551 | mov edx,[Screen_Max_X] ; screen x size |
840 | serge | 3552 | mov ecx, [_display_data] |
3553 | |||
3554 | inc edx |
||
742 | Rus | 3555 | imul edx, ebx |
1 | ha | 3556 | |
840 | serge | 3557 | add edx, ecx |
3558 | mov dl, [eax+edx] ; lea eax, [...] |
||
3559 | |||
742 | Rus | 3560 | xor ecx, ecx |
3561 | mov eax, [CURRENT_TASK] |
||
3562 | cmp al, dl |
||
3563 | setne cl |
||
1 | ha | 3564 | |
742 | Rus | 3565 | pop edx eax |
3566 | ret |
||
1 | ha | 3567 | |
3568 | iglobal |
||
521 | diamond | 3569 | cpustring db 'CPU',0 |
1 | ha | 3570 | endg |
3571 | |||
67 | diamond | 3572 | uglobal |
742 | Rus | 3573 | background_defined db 0 ; diamond, 11.04.2006 |
67 | diamond | 3574 | endg |
1 | ha | 3575 | |
3576 | align 4 |
||
3577 | ; check misc |
||
3578 | |||
3579 | checkmisc: |
||
3580 | |||
3581 | cmp [ctrl_alt_del], 1 |
||
3582 | jne nocpustart |
||
501 | serge | 3583 | |
742 | Rus | 3584 | mov ebp, cpustring |
3585 | call fs_execute_from_sysdir |
||
501 | serge | 3586 | |
1 | ha | 3587 | mov [ctrl_alt_del], 0 |
465 | serge | 3588 | |
3589 | nocpustart: |
||
1 | ha | 3590 | cmp [mouse_active], 1 |
3591 | jne mouse_not_active |
||
3592 | mov [mouse_active], 0 |
||
3593 | xor edi, edi |
||
742 | Rus | 3594 | mov ecx, [TASK_COUNT] |
465 | serge | 3595 | set_mouse_event: |
1 | ha | 3596 | add edi, 256 |
742 | Rus | 3597 | or [edi+SLOT_BASE+APPDATA.event_mask], dword 100000b |
1 | ha | 3598 | loop set_mouse_event |
3599 | |||
465 | serge | 3600 | mouse_not_active: |
742 | Rus | 3601 | cmp [REDRAW_BACKGROUND],byte 0 ; background update ? |
3602 | jz nobackgr |
||
76 | mario79 | 3603 | cmp [background_defined], 0 |
742 | Rus | 3604 | jz nobackgr |
709 | diamond | 3605 | cmp [REDRAW_BACKGROUND], byte 2 |
3606 | jnz no_set_bgr_event |
||
473 | diamond | 3607 | xor edi, edi |
742 | Rus | 3608 | mov ecx, [TASK_COUNT] |
473 | diamond | 3609 | set_bgr_event: |
3610 | add edi, 256 |
||
742 | Rus | 3611 | or [edi+SLOT_BASE+APPDATA.event_mask], 16 |
473 | diamond | 3612 | loop set_bgr_event |
709 | diamond | 3613 | no_set_bgr_event: |
3614 | ; mov [draw_data+32 + RECT.left],dword 0 |
||
3615 | ; mov [draw_data+32 + RECT.top],dword 0 |
||
753 | serge | 3616 | ; mov eax,[Screen_Max_X] |
3617 | ; mov ebx,[Screen_Max_Y] |
||
709 | diamond | 3618 | ; mov [draw_data+32 + RECT.right],eax |
3619 | ; mov [draw_data+32 + RECT.bottom],ebx |
||
1 | ha | 3620 | call drawbackground |
381 | serge | 3621 | mov [REDRAW_BACKGROUND],byte 0 |
3622 | mov [MOUSE_BACKGROUND],byte 0 |
||
1 | ha | 3623 | |
465 | serge | 3624 | nobackgr: |
1 | ha | 3625 | |
3626 | ; system shutdown request |
||
3627 | |||
381 | serge | 3628 | cmp [SYS_SHUTDOWN],byte 0 |
742 | Rus | 3629 | je noshutdown |
1 | ha | 3630 | |
3631 | mov edx,[shutdown_processes] |
||
3632 | |||
381 | serge | 3633 | cmp [SYS_SHUTDOWN],dl |
1 | ha | 3634 | jne no_mark_system_shutdown |
3635 | |||
709 | diamond | 3636 | lea ecx,[edx-1] |
465 | serge | 3637 | mov edx,OS_BASE+0x3040 |
709 | diamond | 3638 | jecxz @f |
465 | serge | 3639 | markz: |
115 | poddubny | 3640 | mov [edx+TASKDATA.state],byte 3 |
1 | ha | 3641 | add edx,0x20 |
3642 | loop markz |
||
709 | diamond | 3643 | @@: |
1 | ha | 3644 | |
3645 | no_mark_system_shutdown: |
||
3646 | |||
3647 | call [disable_mouse] |
||
3648 | |||
381 | serge | 3649 | dec byte [SYS_SHUTDOWN] |
742 | Rus | 3650 | je system_shutdown |
1 | ha | 3651 | |
465 | serge | 3652 | noshutdown: |
1 | ha | 3653 | |
3654 | |||
742 | Rus | 3655 | mov eax,[TASK_COUNT] ; termination |
379 | serge | 3656 | mov ebx,TASK_DATA+TASKDATA.state |
1 | ha | 3657 | mov esi,1 |
3658 | |||
465 | serge | 3659 | newct: |
1 | ha | 3660 | mov cl,[ebx] |
3661 | cmp cl,byte 3 |
||
742 | Rus | 3662 | jz terminate |
1 | ha | 3663 | cmp cl,byte 4 |
742 | Rus | 3664 | jz terminate |
1 | ha | 3665 | |
3666 | add ebx,0x20 |
||
3667 | inc esi |
||
3668 | dec eax |
||
3669 | jnz newct |
||
3670 | ret |
||
3671 | |||
3672 | ; redraw screen |
||
3673 | |||
3674 | redrawscreen: |
||
3675 | |||
3676 | ; eax , if process window_data base is eax, do not set flag/limits |
||
3677 | |||
742 | Rus | 3678 | pushad |
3679 | push eax |
||
1 | ha | 3680 | |
684 | diamond | 3681 | ;;; mov ebx,2 |
1 | ha | 3682 | ;;; call delay_hs |
3683 | |||
742 | Rus | 3684 | ;mov ecx,0 ; redraw flags for apps |
3685 | xor ecx,ecx |
||
1 | ha | 3686 | newdw2: |
3687 | |||
742 | Rus | 3688 | inc ecx |
3689 | push ecx |
||
1 | ha | 3690 | |
742 | Rus | 3691 | mov eax,ecx |
3692 | shl eax,5 |
||
3693 | add eax,window_data |
||
1 | ha | 3694 | |
742 | Rus | 3695 | cmp eax,[esp+4] |
3696 | je not_this_task |
||
3697 | ; check if window in redraw area |
||
3698 | mov edi,eax |
||
1 | ha | 3699 | |
742 | Rus | 3700 | cmp ecx,1 ; limit for background |
3701 | jz bgli |
||
1 | ha | 3702 | |
742 | Rus | 3703 | mov eax, [edi + WDATA.box.left] |
3704 | mov ebx, [edi + WDATA.box.top] |
||
3705 | mov ecx, [edi + WDATA.box.width] |
||
3706 | mov edx, [edi + WDATA.box.height] |
||
3707 | add ecx,eax |
||
3708 | add edx,ebx |
||
1 | ha | 3709 | |
742 | Rus | 3710 | mov ecx,[dlye] ; ecx = area y end ebx = window y start |
3711 | cmp ecx,ebx |
||
3712 | jb ricino |
||
1 | ha | 3713 | |
742 | Rus | 3714 | mov ecx,[dlxe] ; ecx = area x end eax = window x start |
3715 | cmp ecx,eax |
||
3716 | jb ricino |
||
1 | ha | 3717 | |
742 | Rus | 3718 | mov eax, [edi + WDATA.box.left] |
3719 | mov ebx, [edi + WDATA.box.top] |
||
3720 | mov ecx, [edi + WDATA.box.width] |
||
3721 | mov edx, [edi + WDATA.box.height] |
||
3722 | add ecx, eax |
||
3723 | add edx, ebx |
||
164 | serge | 3724 | |
742 | Rus | 3725 | mov eax,[dly] ; eax = area y start edx = window y end |
3726 | cmp edx,eax |
||
3727 | jb ricino |
||
1 | ha | 3728 | |
742 | Rus | 3729 | mov eax,[dlx] ; eax = area x start ecx = window x end |
3730 | cmp ecx,eax |
||
3731 | jb ricino |
||
1 | ha | 3732 | |
742 | Rus | 3733 | bgli: |
1 | ha | 3734 | |
742 | Rus | 3735 | cmp ecx,1 |
3736 | jnz .az |
||
3737 | mov al,[REDRAW_BACKGROUND] |
||
3738 | cmp al,2 |
||
3739 | jz newdw8 |
||
3740 | test al,al |
||
3741 | jz .az |
||
3742 | lea eax,[edi+draw_data-window_data] |
||
3743 | mov ebx,[dlx] |
||
3744 | cmp ebx,[eax+RECT.left] |
||
3745 | jae @f |
||
3746 | mov [eax+RECT.left],ebx |
||
3747 | @@: |
||
3748 | mov ebx,[dly] |
||
3749 | cmp ebx,[eax+RECT.top] |
||
3750 | jae @f |
||
3751 | mov [eax+RECT.top],ebx |
||
3752 | @@: |
||
3753 | mov ebx,[dlxe] |
||
3754 | cmp ebx,[eax+RECT.right] |
||
3755 | jbe @f |
||
3756 | mov [eax+RECT.right],ebx |
||
3757 | @@: |
||
3758 | mov ebx,[dlye] |
||
3759 | cmp ebx,[eax+RECT.bottom] |
||
3760 | jbe @f |
||
3761 | mov [eax+RECT.bottom],ebx |
||
3762 | @@: |
||
3763 | jmp newdw8 |
||
3764 | .az: |
||
1 | ha | 3765 | |
742 | Rus | 3766 | mov eax,edi |
3767 | add eax,draw_data-window_data |
||
1 | ha | 3768 | |
742 | Rus | 3769 | mov ebx,[dlx] ; set limits |
3770 | mov [eax + RECT.left], ebx |
||
3771 | mov ebx,[dly] |
||
3772 | mov [eax + RECT.top], ebx |
||
3773 | mov ebx,[dlxe] |
||
3774 | mov [eax + RECT.right], ebx |
||
3775 | mov ebx,[dlye] |
||
3776 | mov [eax + RECT.bottom], ebx |
||
1 | ha | 3777 | |
742 | Rus | 3778 | sub eax,draw_data-window_data |
1 | ha | 3779 | |
742 | Rus | 3780 | cmp dword [esp],1 |
3781 | jne nobgrd |
||
3782 | mov byte [REDRAW_BACKGROUND], 1 |
||
1 | ha | 3783 | |
3784 | newdw8: |
||
3785 | nobgrd: |
||
3786 | |||
742 | Rus | 3787 | mov [eax + WDATA.fl_redraw],byte 1 ; mark as redraw |
1 | ha | 3788 | |
3789 | ricino: |
||
3790 | |||
3791 | not_this_task: |
||
3792 | |||
742 | Rus | 3793 | pop ecx |
1 | ha | 3794 | |
742 | Rus | 3795 | cmp ecx,[TASK_COUNT] |
3796 | jle newdw2 |
||
1 | ha | 3797 | |
742 | Rus | 3798 | pop eax |
3799 | popad |
||
1 | ha | 3800 | |
742 | Rus | 3801 | ret |
1 | ha | 3802 | |
3803 | calculatebackground: ; background |
||
3804 | |||
742 | Rus | 3805 | ; all black |
1 | ha | 3806 | |
742 | Rus | 3807 | mov edi, [img_background] ;IMG_BACKGROUND ; set background to black |
3808 | xor eax, eax |
||
3809 | mov ecx, 1023 ;0x0fff00 / 4 |
||
3810 | cld |
||
3811 | rep stosd |
||
1 | ha | 3812 | |
840 | serge | 3813 | mov edi, [_display_data] ; set os to use all pixels |
742 | Rus | 3814 | mov eax,0x01010101 |
3815 | mov ecx,1280*1024 / 4 |
||
3816 | rep stosd |
||
1 | ha | 3817 | |
742 | Rus | 3818 | mov byte [REDRAW_BACKGROUND], 0 ; do not draw background! |
1 | ha | 3819 | |
742 | Rus | 3820 | ret |
1 | ha | 3821 | |
3822 | uglobal |
||
742 | Rus | 3823 | imax dd 0x0 |
1 | ha | 3824 | endg |
3825 | |||
3826 | |||
3827 | |||
3828 | delay_ms: ; delay in 1/1000 sec |
||
3829 | |||
3830 | |||
742 | Rus | 3831 | push eax |
3832 | push ecx |
||
1 | ha | 3833 | |
742 | Rus | 3834 | mov ecx,esi |
3835 | ; |
||
3836 | imul ecx, 33941 |
||
3837 | shr ecx, 9 |
||
3838 | ; |
||
1 | ha | 3839 | |
742 | Rus | 3840 | in al,0x61 |
3841 | and al,0x10 |
||
3842 | mov ah,al |
||
3843 | cld |
||
1 | ha | 3844 | |
742 | Rus | 3845 | cnt1: in al,0x61 |
3846 | and al,0x10 |
||
3847 | cmp al,ah |
||
3848 | jz cnt1 |
||
1 | ha | 3849 | |
742 | Rus | 3850 | mov ah,al |
3851 | loop cnt1 |
||
1 | ha | 3852 | |
742 | Rus | 3853 | pop ecx |
3854 | pop eax |
||
1 | ha | 3855 | |
742 | Rus | 3856 | ret |
1 | ha | 3857 | |
3858 | |||
3859 | set_app_param: |
||
742 | Rus | 3860 | mov edi, [TASK_BASE] |
3861 | mov [edi + TASKDATA.event_mask], ebx |
||
3862 | ret |
||
1 | ha | 3863 | |
3864 | |||
3865 | |||
3866 | delay_hs: ; delay in 1/100 secs |
||
684 | diamond | 3867 | ; ebx = delay time |
742 | Rus | 3868 | push ecx |
3869 | push edx |
||
1 | ha | 3870 | |
742 | Rus | 3871 | mov edx,[timer_ticks] |
1 | ha | 3872 | |
3873 | newtic: |
||
742 | Rus | 3874 | mov ecx,[timer_ticks] |
3875 | sub ecx,edx |
||
3876 | cmp ecx,ebx |
||
3877 | jae zerodelay |
||
1 | ha | 3878 | |
742 | Rus | 3879 | call change_task |
1 | ha | 3880 | |
742 | Rus | 3881 | jmp newtic |
1 | ha | 3882 | |
3883 | zerodelay: |
||
742 | Rus | 3884 | pop edx |
3885 | pop ecx |
||
1 | ha | 3886 | |
742 | Rus | 3887 | ret |
1 | ha | 3888 | |
3889 | |||
3890 | memmove: ; memory move in bytes |
||
3891 | |||
3892 | ; eax = from |
||
3893 | ; ebx = to |
||
3894 | ; ecx = no of bytes |
||
3895 | test ecx, ecx |
||
3896 | jle .ret |
||
3897 | |||
3898 | |||
3899 | push esi edi ecx |
||
3900 | |||
3901 | mov edi, ebx |
||
3902 | mov esi, eax |
||
3903 | |||
3904 | test ecx, not 11b |
||
742 | Rus | 3905 | jz @f |
1 | ha | 3906 | |
3907 | push ecx |
||
3908 | shr ecx, 2 |
||
3909 | rep movsd |
||
3910 | pop ecx |
||
3911 | and ecx, 11b |
||
742 | Rus | 3912 | jz .finish |
1 | ha | 3913 | @@: |
3914 | rep movsb |
||
3915 | |||
3916 | .finish: |
||
3917 | pop ecx edi esi |
||
3918 | .ret: |
||
3919 | ret |
||
3920 | |||
3921 | |||
75 | diamond | 3922 | ; |
3923 | ;align 4 |
||
1 | ha | 3924 | ; |
75 | diamond | 3925 | ;read_floppy_file: |
1 | ha | 3926 | ; |
75 | diamond | 3927 | ;; as input |
3928 | ;; |
||
3929 | ;; eax pointer to file |
||
3930 | ;; ebx file lenght |
||
3931 | ;; ecx start 512 byte block number |
||
3932 | ;; edx number of blocks to read |
||
3933 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
||
3934 | ;; |
||
3935 | ;; |
||
3936 | ;; on return |
||
3937 | ;; |
||
3938 | ;; eax = 0 command succesful |
||
3939 | ;; 1 no fd base and/or partition defined |
||
3940 | ;; 2 yet unsupported FS |
||
3941 | ;; 3 unknown FS |
||
3942 | ;; 4 partition not defined at hd |
||
3943 | ;; 5 file not found |
||
3944 | ;; ebx = size of file |
||
1 | ha | 3945 | ; |
379 | serge | 3946 | ; mov edi,[TASK_BASE] |
75 | diamond | 3947 | ; add edi,0x10 |
3948 | ; add esi,[edi] |
||
3949 | ; add eax,[edi] |
||
1 | ha | 3950 | ; |
75 | diamond | 3951 | ; pushad |
3952 | ; mov edi,esi |
||
3953 | ; add edi,1024 |
||
3954 | ; mov esi,0x100000+19*512 |
||
3955 | ; sub ecx,1 |
||
3956 | ; shl ecx,9 |
||
3957 | ; add esi,ecx |
||
3958 | ; shl edx,9 |
||
3959 | ; mov ecx,edx |
||
3960 | ; cld |
||
3961 | ; rep movsb |
||
3962 | ; popad |
||
3963 | ; |
||
3964 | ; mov [esp+36],eax |
||
3965 | ; mov [esp+24],ebx |
||
3966 | ; ret |
||
1 | ha | 3967 | |
3968 | |||
3969 | |||
3970 | align 4 |
||
3971 | |||
3972 | sys_programirq: |
||
3973 | |||
765 | Rus | 3974 | mov eax, [TASK_BASE] |
3975 | add ebx, [eax + TASKDATA.mem_start] |
||
1 | ha | 3976 | |
765 | Rus | 3977 | cmp ecx, 16 |
75 | diamond | 3978 | jae .not_owner |
765 | Rus | 3979 | mov edi, [eax + TASKDATA.pid] |
3980 | cmp edi, [irq_owner + 4 * ecx] |
||
3981 | je .spril1 |
||
75 | diamond | 3982 | .not_owner: |
765 | Rus | 3983 | xor ecx, ecx |
3984 | jmp .end |
||
3985 | .spril1: |
||
1 | ha | 3986 | |
765 | Rus | 3987 | shl ecx, 6 |
3988 | mov esi, ebx |
||
3989 | lea edi, [irq00read + ecx] |
||
3990 | push 16 |
||
3991 | pop ecx |
||
3992 | |||
1 | ha | 3993 | cld |
3994 | rep movsd |
||
765 | Rus | 3995 | .end: |
3996 | mov [esp+32], ecx |
||
1 | ha | 3997 | ret |
3998 | |||
3999 | |||
4000 | align 4 |
||
4001 | |||
4002 | get_irq_data: |
||
760 | Rus | 4003 | movzx esi, bh ; save number of subfunction, if bh = 1, return data size, otherwise, read data |
4004 | xor bh, bh |
||
4005 | cmp ebx, 16 |
||
75 | diamond | 4006 | jae .not_owner |
760 | Rus | 4007 | mov edx, [4 * ebx + irq_owner] ; check for irq owner |
742 | Rus | 4008 | |
760 | Rus | 4009 | mov eax,[TASK_BASE] |
742 | Rus | 4010 | |
760 | Rus | 4011 | cmp edx,[eax+TASKDATA.pid] |
1 | ha | 4012 | je gidril1 |
75 | diamond | 4013 | .not_owner: |
760 | Rus | 4014 | xor edx, edx |
4015 | dec edx |
||
4016 | jmp gid1 |
||
1 | ha | 4017 | |
4018 | gidril1: |
||
4019 | |||
760 | Rus | 4020 | shl ebx, 12 |
4021 | lea eax, [ebx + IRQ_SAVE] ; calculate address of the beginning of buffer + 0x0 - data size |
||
4022 | mov edx, [eax] ; + 0x4 - data offset |
||
4023 | dec esi |
||
1 | ha | 4024 | jz gid1 |
760 | Rus | 4025 | test edx, edx ; check if buffer is empty |
4026 | jz gid1 |
||
1 | ha | 4027 | |
760 | Rus | 4028 | mov ebx, [eax + 0x4] |
4029 | mov edi, ecx |
||
742 | Rus | 4030 | |
760 | Rus | 4031 | mov ecx, 4000 ; buffer size, used frequently |
742 | Rus | 4032 | |
760 | Rus | 4033 | cmp ebx, ecx ; check for the end of buffer, if end of buffer, begin cycle again |
759 | Rus | 4034 | jb @f |
742 | Rus | 4035 | |
760 | Rus | 4036 | xor ebx, ebx |
759 | Rus | 4037 | |
4038 | @@: |
||
4039 | |||
760 | Rus | 4040 | lea esi, [ebx + edx] ; calculate data size and offset |
4041 | cld |
||
4042 | cmp esi, ecx ; if greater than the buffer size, begin cycle again |
||
4043 | jbe @f |
||
759 | Rus | 4044 | |
760 | Rus | 4045 | sub ecx, ebx |
4046 | sub edx, ecx |
||
759 | Rus | 4047 | |
760 | Rus | 4048 | lea esi, [eax + ebx + 0x10] |
4049 | rep movsb |
||
4050 | |||
4051 | xor ebx, ebx |
||
4052 | @@: |
||
4053 | lea esi, [eax + ebx + 0x10] |
||
4054 | mov ecx, edx |
||
4055 | add ebx, edx |
||
4056 | |||
4057 | rep movsb |
||
4058 | mov edx, [eax] |
||
4059 | mov [eax], ecx ; set data size to zero |
||
4060 | mov [eax + 0x4], ebx ; set data offset |
||
4061 | |||
1 | ha | 4062 | gid1: |
760 | Rus | 4063 | mov [esp+32], edx ; eax |
1 | ha | 4064 | ret |
4065 | |||
4066 | |||
4067 | set_io_access_rights: |
||
4068 | |||
4069 | pushad |
||
4070 | |||
465 | serge | 4071 | mov edi, tss._io_map_0 |
1 | ha | 4072 | |
465 | serge | 4073 | ; mov ecx,eax |
4074 | ; and ecx,7 ; offset in byte |
||
1 | ha | 4075 | |
465 | serge | 4076 | ; shr eax,3 ; number of byte |
4077 | ; add edi,eax |
||
1 | ha | 4078 | |
465 | serge | 4079 | ; mov ebx,1 |
4080 | ; shl ebx,cl |
||
1 | ha | 4081 | |
742 | Rus | 4082 | cmp ebp,0 ; enable access - ebp = 0 |
1 | ha | 4083 | jne siar1 |
4084 | |||
465 | serge | 4085 | ; not ebx |
4086 | ; and [edi],byte bl |
||
4087 | btr [edi], eax |
||
1 | ha | 4088 | |
4089 | popad |
||
4090 | |||
4091 | ret |
||
4092 | |||
465 | serge | 4093 | siar1: |
1 | ha | 4094 | |
465 | serge | 4095 | bts [edi], eax |
4096 | ; or [edi],byte bl ; disable access - ebp = 1 |
||
1 | ha | 4097 | |
4098 | popad |
||
4099 | |||
4100 | ret |
||
4101 | |||
4102 | r_f_port_area: |
||
4103 | |||
4104 | test eax, eax |
||
4105 | jnz free_port_area |
||
4106 | ; je r_port_area |
||
4107 | ; jmp free_port_area |
||
4108 | |||
4109 | ; r_port_area: |
||
4110 | |||
4111 | pushad |
||
4112 | |||
742 | Rus | 4113 | cmp ebx,ecx ; beginning > end ? |
75 | diamond | 4114 | ja rpal1 |
4115 | cmp ecx,65536 |
||
4116 | jae rpal1 |
||
381 | serge | 4117 | mov esi,[RESERVED_PORTS] |
742 | Rus | 4118 | test esi,esi ; no reserved areas ? |
1 | ha | 4119 | je rpal2 |
742 | Rus | 4120 | cmp esi,255 ; max reserved |
75 | diamond | 4121 | jae rpal1 |
465 | serge | 4122 | rpal3: |
1 | ha | 4123 | mov edi,esi |
4124 | shl edi,4 |
||
381 | serge | 4125 | add edi,RESERVED_PORTS |
1 | ha | 4126 | cmp ebx,[edi+8] |
75 | diamond | 4127 | ja rpal4 |
1 | ha | 4128 | cmp ecx,[edi+4] |
4129 | jae rpal1 |
||
4130 | ; jb rpal4 |
||
4131 | ; jmp rpal1 |
||
465 | serge | 4132 | rpal4: |
1 | ha | 4133 | |
4134 | dec esi |
||
4135 | jnz rpal3 |
||
4136 | jmp rpal2 |
||
4137 | rpal1: |
||
4138 | popad |
||
4139 | mov eax,1 |
||
4140 | ret |
||
4141 | |||
4142 | rpal2: |
||
4143 | popad |
||
4144 | |||
4145 | |||
4146 | ; enable port access at port IO map |
||
4147 | cli |
||
742 | Rus | 4148 | pushad ; start enable io map |
1 | ha | 4149 | |
4150 | cmp ecx,65536 ;16384 |
||
4151 | jae no_unmask_io ; jge |
||
4152 | |||
4153 | mov eax,ebx |
||
4154 | |||
4155 | new_port_access: |
||
4156 | |||
4157 | pushad |
||
4158 | |||
742 | Rus | 4159 | xor ebp,ebp ; enable - eax = port |
1 | ha | 4160 | call set_io_access_rights |
4161 | |||
4162 | popad |
||
4163 | |||
4164 | inc eax |
||
4165 | cmp eax,ecx |
||
4166 | jbe new_port_access |
||
4167 | |||
4168 | no_unmask_io: |
||
4169 | |||
742 | Rus | 4170 | popad ; end enable io map |
1 | ha | 4171 | sti |
4172 | |||
381 | serge | 4173 | mov edi,[RESERVED_PORTS] |
1 | ha | 4174 | add edi,1 |
381 | serge | 4175 | mov [RESERVED_PORTS],edi |
1 | ha | 4176 | shl edi,4 |
381 | serge | 4177 | add edi,RESERVED_PORTS |
379 | serge | 4178 | mov esi,[TASK_BASE] |
115 | poddubny | 4179 | mov esi,[esi+TASKDATA.pid] |
1 | ha | 4180 | mov [edi],esi |
4181 | mov [edi+4],ebx |
||
4182 | mov [edi+8],ecx |
||
4183 | |||
4184 | xor eax, eax |
||
4185 | ret |
||
4186 | |||
4187 | free_port_area: |
||
4188 | |||
4189 | pushad |
||
4190 | |||
381 | serge | 4191 | mov esi,[RESERVED_PORTS] ; no reserved areas ? |
75 | diamond | 4192 | test esi,esi |
1 | ha | 4193 | je frpal2 |
379 | serge | 4194 | mov edx,[TASK_BASE] |
115 | poddubny | 4195 | mov edx,[edx+TASKDATA.pid] |
1 | ha | 4196 | frpal3: |
4197 | mov edi,esi |
||
4198 | shl edi,4 |
||
381 | serge | 4199 | add edi,RESERVED_PORTS |
1 | ha | 4200 | cmp edx,[edi] |
4201 | jne frpal4 |
||
4202 | cmp ebx,[edi+4] |
||
4203 | jne frpal4 |
||
4204 | cmp ecx,[edi+8] |
||
4205 | jne frpal4 |
||
4206 | jmp frpal1 |
||
4207 | frpal4: |
||
4208 | dec esi |
||
4209 | jnz frpal3 |
||
4210 | frpal2: |
||
4211 | popad |
||
4212 | mov eax,1 |
||
4213 | ret |
||
4214 | frpal1: |
||
4215 | mov ecx,256 |
||
4216 | sub ecx,esi |
||
4217 | shl ecx,4 |
||
4218 | mov esi,edi |
||
4219 | add esi,16 |
||
4220 | cld |
||
4221 | rep movsb |
||
4222 | |||
381 | serge | 4223 | dec dword [RESERVED_PORTS] |
1 | ha | 4224 | |
4225 | popad |
||
4226 | |||
4227 | |||
4228 | ; disable port access at port IO map |
||
4229 | |||
742 | Rus | 4230 | pushad ; start disable io map |
1 | ha | 4231 | |
4232 | cmp ecx,65536 ;16384 |
||
4233 | jge no_mask_io |
||
4234 | |||
4235 | mov eax,ebx |
||
4236 | |||
4237 | new_port_access_disable: |
||
4238 | |||
4239 | pushad |
||
4240 | |||
742 | Rus | 4241 | mov ebp,1 ; disable - eax = port |
1 | ha | 4242 | call set_io_access_rights |
4243 | |||
4244 | popad |
||
4245 | |||
4246 | inc eax |
||
4247 | cmp eax,ecx |
||
4248 | jbe new_port_access_disable |
||
4249 | |||
4250 | no_mask_io: |
||
4251 | |||
742 | Rus | 4252 | popad ; end disable io map |
1 | ha | 4253 | |
4254 | xor eax, eax |
||
4255 | ret |
||
4256 | |||
4257 | |||
4258 | reserve_free_irq: |
||
4259 | |||
765 | Rus | 4260 | xor esi, esi |
4261 | inc esi |
||
4262 | cmp ecx, 16 |
||
4263 | jae ril1 |
||
1 | ha | 4264 | |
769 | Rus | 4265 | push ecx |
765 | Rus | 4266 | lea ecx, [irq_owner + 4 * ecx] |
4267 | mov edx, [ecx] |
||
4268 | mov eax, [TASK_BASE] |
||
4269 | mov edi, [eax + TASKDATA.pid] |
||
769 | Rus | 4270 | pop eax |
765 | Rus | 4271 | dec ebx |
4272 | jnz reserve_irq |
||
1 | ha | 4273 | |
765 | Rus | 4274 | cmp edx, edi |
4275 | jne ril1 |
||
4276 | dec esi |
||
4277 | mov [ecx], esi |
||
4278 | |||
4279 | jmp ril1 |
||
4280 | |||
1 | ha | 4281 | reserve_irq: |
4282 | |||
765 | Rus | 4283 | cmp dword [ecx], 0 |
4284 | jne ril1 |
||
1 | ha | 4285 | |
769 | Rus | 4286 | mov ebx, [f_irqs + 4 * eax] |
4287 | |||
774 | Rus | 4288 | stdcall attach_int_handler, eax, ebx, dword 0 |
769 | Rus | 4289 | |
765 | Rus | 4290 | mov [ecx], edi |
769 | Rus | 4291 | |
765 | Rus | 4292 | dec esi |
1 | ha | 4293 | ril1: |
765 | Rus | 4294 | mov [esp+32], esi ; return in eax |
1 | ha | 4295 | ret |
4296 | |||
769 | Rus | 4297 | iglobal |
4298 | f_irqs: |
||
4299 | dd 0x0 |
||
4300 | dd 0x0 |
||
4301 | dd p_irq2 |
||
4302 | dd p_irq3 |
||
4303 | dd p_irq4 |
||
4304 | dd p_irq5 |
||
4305 | dd p_irq6 |
||
4306 | dd p_irq7 |
||
4307 | dd p_irq8 |
||
4308 | dd p_irq9 |
||
4309 | dd p_irq10 |
||
4310 | dd p_irq11 |
||
4311 | dd 0x0 |
||
4312 | dd 0x0 |
||
4313 | dd p_irq14 |
||
4314 | dd p_irq15 |
||
4315 | |||
4316 | endg |
||
4317 | |||
1 | ha | 4318 | drawbackground: |
33 | mario79 | 4319 | inc [mouse_pause] |
381 | serge | 4320 | cmp [SCR_MODE],word 0x12 |
117 | mario79 | 4321 | je dbrv20 |
1 | ha | 4322 | dbrv12: |
381 | serge | 4323 | cmp [SCR_MODE],word 0100000000000000b |
1 | ha | 4324 | jge dbrv20 |
381 | serge | 4325 | cmp [SCR_MODE],word 0x13 |
1 | ha | 4326 | je dbrv20 |
4327 | call vesa12_drawbackground |
||
33 | mario79 | 4328 | dec [mouse_pause] |
36 | mario79 | 4329 | call [draw_pointer] |
1 | ha | 4330 | ret |
4331 | dbrv20: |
||
527 | diamond | 4332 | cmp [BgrDrawMode],dword 1 |
1 | ha | 4333 | jne bgrstr |
4334 | call vesa20_drawbackground_tiled |
||
33 | mario79 | 4335 | dec [mouse_pause] |
36 | mario79 | 4336 | call [draw_pointer] |
1 | ha | 4337 | ret |
4338 | bgrstr: |
||
4339 | call vesa20_drawbackground_stretch |
||
33 | mario79 | 4340 | dec [mouse_pause] |
36 | mario79 | 4341 | call [draw_pointer] |
1 | ha | 4342 | ret |
4343 | |||
75 | diamond | 4344 | align 4 |
1 | ha | 4345 | |
742 | Rus | 4346 | syscall_putimage: ; PutImage |
1 | ha | 4347 | sys_putimage: |
53 | mikedld | 4348 | test ecx,0x80008000 |
4349 | jnz .exit |
||
4350 | test ecx,0x0000FFFF |
||
4351 | jz .exit |
||
4352 | test ecx,0xFFFF0000 |
||
4353 | jnz @f |
||
4354 | .exit: |
||
4355 | ret |
||
4356 | @@: |
||
742 | Rus | 4357 | mov edi,[current_slot] |
4358 | add dx,word[edi+APPDATA.wnd_clientbox.top] |
||
4359 | rol edx,16 |
||
4360 | add dx,word[edi+APPDATA.wnd_clientbox.left] |
||
4361 | rol edx,16 |
||
114 | mikedld | 4362 | .forced: |
742 | Rus | 4363 | push ebp esi 0 |
4364 | mov ebp, putimage_get24bpp |
||
4365 | mov esi, putimage_init24bpp |
||
283 | diamond | 4366 | sys_putimage_bpp: |
4367 | ; call [disable_mouse] ; this will be done in xxx_putimage |
||
117 | mario79 | 4368 | ; mov eax, vga_putimage |
742 | Rus | 4369 | cmp [SCR_MODE], word 0x12 |
4370 | jz @f ;.doit |
||
4371 | mov eax, vesa12_putimage |
||
4372 | cmp [SCR_MODE], word 0100000000000000b |
||
4373 | jae @f |
||
4374 | cmp [SCR_MODE], word 0x13 |
||
4375 | jnz .doit |
||
75 | diamond | 4376 | @@: |
742 | Rus | 4377 | mov eax, vesa20_putimage |
75 | diamond | 4378 | .doit: |
742 | Rus | 4379 | inc [mouse_pause] |
4380 | call eax |
||
4381 | dec [mouse_pause] |
||
4382 | pop ebp esi ebp |
||
4383 | jmp [draw_pointer] |
||
1 | ha | 4384 | |
283 | diamond | 4385 | syscall_putimage_palette: |
742 | Rus | 4386 | mov edi, esi |
4387 | mov esi, edx |
||
4388 | mov edx, ecx |
||
4389 | mov ecx, ebx |
||
4390 | mov ebx, eax |
||
283 | diamond | 4391 | sys_putimage_palette: |
4392 | ; ebx = pointer to image |
||
4393 | ; ecx = [xsize]*65536 + [ysize] |
||
4394 | ; edx = [xstart]*65536 + [ystart] |
||
314 | diamond | 4395 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
283 | diamond | 4396 | ; edi = pointer to palette |
314 | diamond | 4397 | ; ebp = row delta |
742 | Rus | 4398 | mov eax, [CURRENT_TASK] |
4399 | shl eax, 8 |
||
4400 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
4401 | rol edx, 16 |
||
4402 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
4403 | rol edx, 16 |
||
283 | diamond | 4404 | .forced: |
742 | Rus | 4405 | push ebp esi ebp |
4406 | cmp esi, 8 |
||
4407 | jnz @f |
||
4408 | mov ebp, putimage_get8bpp |
||
4409 | mov esi, putimage_init8bpp |
||
4410 | jmp sys_putimage_bpp |
||
314 | diamond | 4411 | @@: |
844 | serge | 4412 | cmp esi, 16 |
4413 | jnz @f |
||
4414 | mov ebp, putimage_get16bpp |
||
4415 | mov esi, putimage_init16bpp |
||
4416 | jmp sys_putimage_bpp |
||
4417 | @@: |
||
742 | Rus | 4418 | cmp esi, 24 |
4419 | jnz @f |
||
4420 | mov ebp, putimage_get24bpp |
||
4421 | mov esi, putimage_init24bpp |
||
4422 | jmp sys_putimage_bpp |
||
314 | diamond | 4423 | @@: |
742 | Rus | 4424 | cmp esi, 32 |
4425 | jnz @f |
||
4426 | mov ebp, putimage_get32bpp |
||
4427 | mov esi, putimage_init32bpp |
||
4428 | jmp sys_putimage_bpp |
||
314 | diamond | 4429 | @@: |
844 | serge | 4430 | pop ebp esi ebp |
742 | Rus | 4431 | ret |
283 | diamond | 4432 | |
4433 | putimage_init24bpp: |
||
742 | Rus | 4434 | lea eax, [eax*3] |
283 | diamond | 4435 | putimage_init8bpp: |
742 | Rus | 4436 | ret |
283 | diamond | 4437 | |
4438 | putimage_get24bpp: |
||
742 | Rus | 4439 | mov eax, [esi] |
4440 | add esi, 3 |
||
4441 | ret 4 |
||
283 | diamond | 4442 | putimage_get8bpp: |
742 | Rus | 4443 | movzx eax, byte [esi] |
4444 | push edx |
||
4445 | mov edx, [esp+8] |
||
4446 | mov eax, [edx+eax*4] |
||
4447 | pop edx |
||
4448 | inc esi |
||
4449 | ret 4 |
||
283 | diamond | 4450 | |
314 | diamond | 4451 | putimage_init32bpp: |
742 | Rus | 4452 | shl eax, 2 |
4453 | ret |
||
314 | diamond | 4454 | putimage_get32bpp: |
742 | Rus | 4455 | lodsd |
4456 | ret 4 |
||
314 | diamond | 4457 | |
844 | serge | 4458 | putimage_init16bpp: |
4459 | add eax, eax |
||
4460 | ret |
||
4461 | putimage_get16bpp: |
||
4462 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
||
4463 | push ecx edx |
||
4464 | movzx eax, word [esi] |
||
4465 | add esi, 2 |
||
4466 | mov ecx, eax |
||
4467 | mov edx, eax |
||
4468 | and eax, 0x1F |
||
4469 | and ecx, 0x1F shl 5 |
||
4470 | and edx, 0x1F shl 10 |
||
4471 | shl eax, 3 |
||
4472 | shl ecx, 6 |
||
4473 | shl edx, 9 |
||
4474 | or eax, ecx |
||
4475 | or eax, edx |
||
4476 | pop edx ecx |
||
4477 | ret |
||
4478 | |||
1 | ha | 4479 | ; eax x beginning |
4480 | ; ebx y beginning |
||
4481 | ; ecx x end |
||
283 | diamond | 4482 | ; edx y end |
1 | ha | 4483 | ; edi color |
4484 | |||
4485 | __sys_drawbar: |
||
742 | Rus | 4486 | mov esi,[current_slot] |
4487 | add eax,[esi+APPDATA.wnd_clientbox.left] |
||
4488 | add ecx,[esi+APPDATA.wnd_clientbox.left] |
||
4489 | add ebx,[esi+APPDATA.wnd_clientbox.top] |
||
4490 | add edx,[esi+APPDATA.wnd_clientbox.top] |
||
114 | mikedld | 4491 | .forced: |
33 | mario79 | 4492 | inc [mouse_pause] |
283 | diamond | 4493 | ; call [disable_mouse] |
381 | serge | 4494 | cmp [SCR_MODE],word 0x12 |
742 | Rus | 4495 | je dbv20 |
1 | ha | 4496 | sdbv20: |
381 | serge | 4497 | cmp [SCR_MODE],word 0100000000000000b |
1 | ha | 4498 | jge dbv20 |
381 | serge | 4499 | cmp [SCR_MODE],word 0x13 |
742 | Rus | 4500 | je dbv20 |
1 | ha | 4501 | call vesa12_drawbar |
33 | mario79 | 4502 | dec [mouse_pause] |
36 | mario79 | 4503 | call [draw_pointer] |
1 | ha | 4504 | ret |
4505 | dbv20: |
||
4506 | call vesa20_drawbar |
||
33 | mario79 | 4507 | dec [mouse_pause] |
36 | mario79 | 4508 | call [draw_pointer] |
1 | ha | 4509 | ret |
4510 | |||
4511 | |||
4512 | |||
4513 | kb_read: |
||
4514 | |||
742 | Rus | 4515 | push ecx edx |
1 | ha | 4516 | |
742 | Rus | 4517 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
1 | ha | 4518 | kr_loop: |
742 | Rus | 4519 | in al,0x64 |
4520 | test al,1 |
||
4521 | jnz kr_ready |
||
4522 | loop kr_loop |
||
4523 | mov ah,1 |
||
4524 | jmp kr_exit |
||
1 | ha | 4525 | kr_ready: |
742 | Rus | 4526 | push ecx |
4527 | mov ecx,32 |
||
1 | ha | 4528 | kr_delay: |
742 | Rus | 4529 | loop kr_delay |
4530 | pop ecx |
||
4531 | in al,0x60 |
||
4532 | xor ah,ah |
||
1 | ha | 4533 | kr_exit: |
4534 | |||
742 | Rus | 4535 | pop edx ecx |
1 | ha | 4536 | |
742 | Rus | 4537 | ret |
1 | ha | 4538 | |
4539 | |||
4540 | kb_write: |
||
4541 | |||
742 | Rus | 4542 | push ecx edx |
1 | ha | 4543 | |
742 | Rus | 4544 | mov dl,al |
265 | diamond | 4545 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4546 | ; kw_loop1: |
||
4547 | ; in al,0x64 |
||
4548 | ; test al,0x20 |
||
4549 | ; jz kw_ok1 |
||
4550 | ; loop kw_loop1 |
||
4551 | ; mov ah,1 |
||
4552 | ; jmp kw_exit |
||
4553 | ; kw_ok1: |
||
742 | Rus | 4554 | in al,0x60 |
4555 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4556 | kw_loop: |
742 | Rus | 4557 | in al,0x64 |
4558 | test al,2 |
||
4559 | jz kw_ok |
||
4560 | loop kw_loop |
||
4561 | mov ah,1 |
||
4562 | jmp kw_exit |
||
1 | ha | 4563 | kw_ok: |
742 | Rus | 4564 | mov al,dl |
4565 | out 0x60,al |
||
4566 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4567 | kw_loop3: |
742 | Rus | 4568 | in al,0x64 |
4569 | test al,2 |
||
4570 | jz kw_ok3 |
||
4571 | loop kw_loop3 |
||
4572 | mov ah,1 |
||
4573 | jmp kw_exit |
||
1 | ha | 4574 | kw_ok3: |
742 | Rus | 4575 | mov ah,8 |
1 | ha | 4576 | kw_loop4: |
742 | Rus | 4577 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
1 | ha | 4578 | kw_loop5: |
742 | Rus | 4579 | in al,0x64 |
4580 | test al,1 |
||
4581 | jnz kw_ok4 |
||
4582 | loop kw_loop5 |
||
4583 | dec ah |
||
4584 | jnz kw_loop4 |
||
1 | ha | 4585 | kw_ok4: |
742 | Rus | 4586 | xor ah,ah |
1 | ha | 4587 | kw_exit: |
4588 | |||
742 | Rus | 4589 | pop edx ecx |
1 | ha | 4590 | |
742 | Rus | 4591 | ret |
1 | ha | 4592 | |
4593 | |||
4594 | kb_cmd: |
||
4595 | |||
742 | Rus | 4596 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
1 | ha | 4597 | c_wait: |
742 | Rus | 4598 | in al,0x64 |
4599 | test al,2 |
||
4600 | jz c_send |
||
4601 | loop c_wait |
||
4602 | jmp c_error |
||
1 | ha | 4603 | c_send: |
742 | Rus | 4604 | mov al,bl |
4605 | out 0x64,al |
||
4606 | mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4607 | c_accept: |
742 | Rus | 4608 | in al,0x64 |
4609 | test al,2 |
||
4610 | jz c_ok |
||
4611 | loop c_accept |
||
1 | ha | 4612 | c_error: |
742 | Rus | 4613 | mov ah,1 |
4614 | jmp c_exit |
||
1 | ha | 4615 | c_ok: |
742 | Rus | 4616 | xor ah,ah |
1 | ha | 4617 | c_exit: |
742 | Rus | 4618 | ret |
1 | ha | 4619 | |
4620 | |||
4621 | setmouse: ; set mousepicture -pointer |
||
742 | Rus | 4622 | ; ps2 mouse enable |
1 | ha | 4623 | |
381 | serge | 4624 | mov [MOUSE_PICTURE],dword mousepointer |
1 | ha | 4625 | |
4626 | cli |
||
4627 | |||
4628 | ret |
||
4629 | |||
4630 | |||
4631 | _rdtsc: |
||
164 | serge | 4632 | bt [cpu_caps], CAPS_TSC |
4633 | jnc ret_rdtsc |
||
1 | ha | 4634 | rdtsc |
4635 | ret |
||
4636 | ret_rdtsc: |
||
4637 | mov edx,0xffffffff |
||
4638 | mov eax,0xffffffff |
||
4639 | ret |
||
4640 | |||
4641 | rerouteirqs: |
||
4642 | |||
742 | Rus | 4643 | mov al,0x11 ; icw4, edge triggered |
4644 | out 0x20,al |
||
4645 | call pic_delay |
||
4646 | out 0xA0,al |
||
4647 | call pic_delay |
||
1 | ha | 4648 | |
742 | Rus | 4649 | mov al,0x20 ; generate 0x20 + |
4650 | out 0x21,al |
||
4651 | call pic_delay |
||
4652 | mov al,0x28 ; generate 0x28 + |
||
4653 | out 0xA1,al |
||
4654 | call pic_delay |
||
1 | ha | 4655 | |
742 | Rus | 4656 | mov al,0x04 ; slave at irq2 |
4657 | out 0x21,al |
||
4658 | call pic_delay |
||
4659 | mov al,0x02 ; at irq9 |
||
4660 | out 0xA1,al |
||
4661 | call pic_delay |
||
1 | ha | 4662 | |
742 | Rus | 4663 | mov al,0x01 ; 8086 mode |
4664 | out 0x21,al |
||
4665 | call pic_delay |
||
4666 | out 0xA1,al |
||
4667 | call pic_delay |
||
1 | ha | 4668 | |
742 | Rus | 4669 | mov al,255 ; mask all irq's |
4670 | out 0xA1,al |
||
4671 | call pic_delay |
||
4672 | out 0x21,al |
||
4673 | call pic_delay |
||
1 | ha | 4674 | |
742 | Rus | 4675 | mov ecx,0x1000 |
4676 | cld |
||
4677 | picl1: call pic_delay |
||
4678 | loop picl1 |
||
1 | ha | 4679 | |
742 | Rus | 4680 | mov al,255 ; mask all irq's |
4681 | out 0xA1,al |
||
4682 | call pic_delay |
||
4683 | out 0x21,al |
||
4684 | call pic_delay |
||
1 | ha | 4685 | |
742 | Rus | 4686 | ret |
1 | ha | 4687 | |
4688 | |||
4689 | pic_delay: |
||
4690 | |||
742 | Rus | 4691 | jmp pdl1 |
4692 | pdl1: ret |
||
1 | ha | 4693 | |
4694 | |||
4695 | sys_msg_board_str: |
||
4696 | |||
4697 | pushad |
||
4698 | @@: |
||
4699 | cmp [esi],byte 0 |
||
4700 | je @f |
||
4701 | mov eax,1 |
||
4702 | movzx ebx,byte [esi] |
||
4703 | call sys_msg_board |
||
4704 | inc esi |
||
4705 | jmp @b |
||
4706 | @@: |
||
4707 | popad |
||
4708 | ret |
||
4709 | |||
709 | diamond | 4710 | sys_msg_board_byte: |
4711 | ; in: al = byte to display |
||
4712 | ; out: nothing |
||
4713 | ; destroys: nothing |
||
742 | Rus | 4714 | pushad |
4715 | mov ecx, 2 |
||
4716 | shl eax, 24 |
||
4717 | jmp @f |
||
709 | diamond | 4718 | |
4719 | sys_msg_board_word: |
||
4720 | ; in: ax = word to display |
||
4721 | ; out: nothing |
||
4722 | ; destroys: nothing |
||
742 | Rus | 4723 | pushad |
4724 | mov ecx, 4 |
||
4725 | shl eax, 16 |
||
4726 | jmp @f |
||
709 | diamond | 4727 | |
4728 | sys_msg_board_dword: |
||
4729 | ; in: eax = dword to display |
||
4730 | ; out: nothing |
||
4731 | ; destroys: nothing |
||
742 | Rus | 4732 | pushad |
4733 | mov ecx, 8 |
||
709 | diamond | 4734 | @@: |
742 | Rus | 4735 | push ecx |
4736 | rol eax, 4 |
||
4737 | push eax |
||
4738 | and al, 0xF |
||
4739 | cmp al, 10 |
||
4740 | sbb al, 69h |
||
4741 | das |
||
4742 | mov bl, al |
||
4743 | xor eax, eax |
||
4744 | inc eax |
||
4745 | call sys_msg_board |
||
4746 | pop eax |
||
4747 | pop ecx |
||
4748 | loop @b |
||
4749 | popad |
||
4750 | ret |
||
709 | diamond | 4751 | |
1 | ha | 4752 | uglobal |
373 | mikedld | 4753 | msg_board_data: times 4096 db 0 |
1 | ha | 4754 | msg_board_count dd 0x0 |
4755 | endg |
||
4756 | |||
4757 | sys_msg_board: |
||
4758 | |||
4759 | ; eax=1 : write : bl byte to write |
||
4760 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
||
4761 | |||
671 | Ghost | 4762 | mov ecx, [msg_board_count] |
4763 | cmp eax, 1 |
||
4764 | jne .smbl1 |
||
1 | ha | 4765 | |
4766 | |||
671 | Ghost | 4767 | mov [msg_board_data+ecx],bl |
4768 | inc ecx |
||
4769 | and ecx, 4095 |
||
4770 | mov [msg_board_count], ecx |
||
4771 | mov [check_idle_semaphore], 5 |
||
4772 | ret |
||
4773 | .smbl1: |
||
4774 | cmp eax, 2 |
||
4775 | jne .smbl2 |
||
4776 | test ecx, ecx |
||
4777 | jz .smbl21 |
||
4778 | mov eax, msg_board_data+1 |
||
4779 | mov ebx, msg_board_data |
||
4780 | movzx edx, byte [ebx] |
||
4781 | call memmove |
||
4782 | dec [msg_board_count] |
||
4783 | mov [esp + 36], edx ;eax |
||
4784 | mov [esp + 24], dword 1 |
||
4785 | ret |
||
4786 | .smbl21: |
||
4787 | mov [esp+36], ecx |
||
4788 | mov [esp+24], ecx |
||
4789 | .smbl2: |
||
4790 | ret |
||
1 | ha | 4791 | |
4792 | |||
4793 | |||
4794 | sys_process_def: |
||
742 | Rus | 4795 | mov edi, [CURRENT_TASK] |
1 | ha | 4796 | |
742 | Rus | 4797 | dec eax ; 1 = set keyboard mode |
1 | ha | 4798 | jne no_set_keyboard_setup |
4799 | |||
4800 | shl edi,8 |
||
380 | serge | 4801 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode],bl |
1 | ha | 4802 | |
4803 | ret |
||
4804 | |||
4805 | no_set_keyboard_setup: |
||
4806 | |||
742 | Rus | 4807 | dec eax ; 2 = get keyboard mode |
1 | ha | 4808 | jne no_get_keyboard_setup |
4809 | |||
4810 | shl edi,8 |
||
380 | serge | 4811 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
1 | ha | 4812 | |
4813 | mov [esp+36],eax |
||
4814 | |||
4815 | ret |
||
4816 | |||
4817 | no_get_keyboard_setup: |
||
4818 | |||
742 | Rus | 4819 | dec eax ; 3 = get keyboard ctrl, alt, shift |
1 | ha | 4820 | jne no_get_keyboard_cas |
4821 | |||
4822 | ; xor eax,eax |
||
4823 | ; movzx eax,byte [shift] |
||
4824 | ; movzx ebx,byte [ctrl] |
||
4825 | ; shl ebx,2 |
||
4826 | ; add eax,ebx |
||
4827 | ; movzx ebx,byte [alt] |
||
4828 | ; shl ebx,3 |
||
4829 | ; add eax,ebx |
||
4830 | |||
4831 | ;// mike.dld [ |
||
4832 | mov eax, [kb_state] |
||
4833 | ;// mike.dld ] |
||
4834 | |||
4835 | mov [esp+36],eax |
||
4836 | |||
4837 | ret |
||
4838 | |||
4839 | no_get_keyboard_cas: |
||
4840 | |||
742 | Rus | 4841 | dec eax |
4842 | jnz no_add_keyboard_hotkey |
||
1 | ha | 4843 | |
742 | Rus | 4844 | mov eax, hotkey_list |
92 | diamond | 4845 | @@: |
742 | Rus | 4846 | cmp dword [eax+8], 0 |
4847 | jz .found_free |
||
4848 | add eax, 16 |
||
4849 | cmp eax, hotkey_list+16*256 |
||
4850 | jb @b |
||
4851 | mov dword [esp+36], 1 |
||
4852 | ret |
||
92 | diamond | 4853 | .found_free: |
742 | Rus | 4854 | mov [eax+8], edi |
4855 | mov [eax+4], ecx |
||
4856 | movzx ebx, bl |
||
4857 | lea ebx, [hotkey_scancodes+ebx*4] |
||
4858 | mov ecx, [ebx] |
||
4859 | mov [eax], ecx |
||
4860 | mov [ebx], eax |
||
4861 | mov [eax+12], ebx |
||
4862 | jecxz @f |
||
4863 | mov [ecx+12], eax |
||
92 | diamond | 4864 | @@: |
742 | Rus | 4865 | and dword [esp+36], 0 |
4866 | ret |
||
92 | diamond | 4867 | |
4868 | no_add_keyboard_hotkey: |
||
4869 | |||
742 | Rus | 4870 | dec eax |
4871 | jnz no_del_keyboard_hotkey |
||
92 | diamond | 4872 | |
742 | Rus | 4873 | movzx ebx, bl |
4874 | lea ebx, [hotkey_scancodes+ebx*4] |
||
4875 | mov eax, [ebx] |
||
92 | diamond | 4876 | .scan: |
742 | Rus | 4877 | test eax, eax |
4878 | jz .notfound |
||
4879 | cmp [eax+8], edi |
||
4880 | jnz .next |
||
4881 | cmp [eax+4], ecx |
||
4882 | jz .found |
||
92 | diamond | 4883 | .next: |
742 | Rus | 4884 | mov eax, [eax] |
4885 | jmp .scan |
||
92 | diamond | 4886 | .notfound: |
742 | Rus | 4887 | mov dword [esp+36], 1 |
4888 | ret |
||
92 | diamond | 4889 | .found: |
742 | Rus | 4890 | mov ecx, [eax] |
4891 | jecxz @f |
||
4892 | mov edx, [eax+12] |
||
4893 | mov [ecx+12], edx |
||
92 | diamond | 4894 | @@: |
742 | Rus | 4895 | mov ecx, [eax+12] |
4896 | mov edx, [eax] |
||
4897 | mov [ecx], edx |
||
4898 | xor edx, edx |
||
4899 | mov [eax+4], edx |
||
4900 | mov [eax+8], edx |
||
4901 | mov [eax+12], edx |
||
4902 | mov [eax], edx |
||
4903 | mov [esp+36], edx |
||
4904 | ret |
||
92 | diamond | 4905 | |
4906 | no_del_keyboard_hotkey: |
||
1 | ha | 4907 | ret |
4908 | |||
4909 | |||
4910 | align 4 |
||
4911 | |||
742 | Rus | 4912 | sys_gs: ; direct screen access |
1 | ha | 4913 | |
742 | Rus | 4914 | cmp eax,1 ; resolution |
1 | ha | 4915 | jne no_gs1 |
753 | serge | 4916 | mov eax,[Screen_Max_X] |
1 | ha | 4917 | shl eax,16 |
753 | serge | 4918 | mov ax,[Screen_Max_Y] |
1 | ha | 4919 | add eax,0x00010001 |
4920 | mov [esp+36],eax |
||
4921 | ret |
||
4922 | no_gs1: |
||
4923 | |||
742 | Rus | 4924 | cmp eax,2 ; bits per pixel |
1 | ha | 4925 | jne no_gs2 |
381 | serge | 4926 | movzx eax,byte [ScreenBPP] |
1 | ha | 4927 | mov [esp+36],eax |
4928 | ret |
||
4929 | no_gs2: |
||
4930 | |||
742 | Rus | 4931 | cmp eax,3 ; bytes per scanline |
1 | ha | 4932 | jne no_gs3 |
381 | serge | 4933 | mov eax,[BytesPerScanLine] |
1 | ha | 4934 | mov [esp+36],eax |
4935 | ret |
||
4936 | no_gs3: |
||
4937 | |||
4938 | mov [esp+36],dword -1 |
||
4939 | ret |
||
4940 | |||
4941 | |||
4942 | align 4 ; PCI functions |
||
4943 | |||
4944 | sys_pci: |
||
4945 | |||
4946 | call pci_api |
||
4947 | mov [esp+36],eax |
||
4948 | ret |
||
4949 | |||
4950 | |||
4951 | align 4 ; system functions |
||
4952 | |||
742 | Rus | 4953 | syscall_setpixel: ; SetPixel |
1 | ha | 4954 | |
742 | Rus | 4955 | mov eax, ebx |
4956 | mov ebx, ecx |
||
4957 | mov ecx, edx |
||
4958 | mov edx, [TASK_BASE] |
||
4959 | add eax, [edx-twdw+WDATA.box.left] |
||
4960 | add ebx, [edx-twdw+WDATA.box.top] |
||
4961 | mov edi, [current_slot] |
||
4962 | add eax, [edi+APPDATA.wnd_clientbox.left] |
||
4963 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
||
4964 | xor edi, edi ; no force |
||
684 | diamond | 4965 | ; mov edi, 1 |
742 | Rus | 4966 | call [disable_mouse] |
4967 | jmp [putpixel] |
||
1 | ha | 4968 | |
4969 | align 4 |
||
4970 | |||
742 | Rus | 4971 | syscall_writetext: ; WriteText |
1 | ha | 4972 | |
742 | Rus | 4973 | mov eax,[TASK_BASE] |
4974 | mov ebp,[eax-twdw+WDATA.box.left] |
||
4975 | push esi |
||
4976 | mov esi,[current_slot] |
||
4977 | add ebp,[esi+APPDATA.wnd_clientbox.left] |
||
4978 | shl ebp,16 |
||
4979 | add ebp,[eax-twdw+WDATA.box.top] |
||
4980 | add bp,word[esi+APPDATA.wnd_clientbox.top] |
||
4981 | pop esi |
||
4982 | add ebx,ebp |
||
4983 | mov eax,edi |
||
4984 | xor edi,edi |
||
4985 | jmp dtext |
||
1 | ha | 4986 | |
4987 | align 4 |
||
4988 | |||
742 | Rus | 4989 | syscall_openramdiskfile: ; OpenRamdiskFile |
1 | ha | 4990 | |
742 | Rus | 4991 | mov eax, ebx |
4992 | mov ebx, ecx |
||
4993 | mov ecx, edx |
||
4994 | mov edx, esi |
||
4995 | mov esi, 12 |
||
4996 | call fileread |
||
4997 | mov [esp+32], eax |
||
4998 | ret |
||
1 | ha | 4999 | |
5000 | align 4 |
||
5001 | |||
742 | Rus | 5002 | syscall_drawrect: ; DrawRect |
1 | ha | 5003 | |
671 | Ghost | 5004 | mov edi, edx ; color + gradient |
5005 | and edi, 0x80FFFFFF |
||
5006 | test bx, bx ; x.size |
||
5007 | je .drectr |
||
5008 | test cx, cx ; y.size |
||
5009 | je .drectr |
||
1 | ha | 5010 | |
671 | Ghost | 5011 | mov eax, ebx ; bad idea |
5012 | mov ebx, ecx |
||
1 | ha | 5013 | |
671 | Ghost | 5014 | movzx ecx, ax ; ecx - x.size |
5015 | shr eax, 16 ; eax - x.coord |
||
5016 | movzx edx, bx ; edx - y.size |
||
5017 | shr ebx, 16 ; ebx - y.coord |
||
5018 | mov esi, [current_slot] |
||
1 | ha | 5019 | |
671 | Ghost | 5020 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5021 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
||
5022 | add ecx, eax |
||
5023 | add edx, ebx |
||
5024 | jmp [drawbar] |
||
5025 | .drectr: |
||
5026 | ret |
||
1 | ha | 5027 | |
5028 | align 4 |
||
742 | Rus | 5029 | syscall_getscreensize: ; GetScreenSize |
759 | Rus | 5030 | mov ax, [Screen_Max_X] |
671 | Ghost | 5031 | shl eax, 16 |
759 | Rus | 5032 | mov ax, [Screen_Max_Y] |
671 | Ghost | 5033 | mov [esp + 32], eax |
5034 | ret |
||
1 | ha | 5035 | |
671 | Ghost | 5036 | align 4 |
5037 | |||
742 | Rus | 5038 | syscall_cdaudio: ; CD |
1 | ha | 5039 | |
742 | Rus | 5040 | cmp eax, 4 |
5041 | jb .audio |
||
5042 | jz .eject |
||
5043 | cmp eax, 5 |
||
5044 | jnz .ret |
||
588 | diamond | 5045 | .load: |
742 | Rus | 5046 | call .reserve |
5047 | call LoadMedium |
||
5048 | call .free |
||
5049 | ret |
||
588 | diamond | 5050 | .eject: |
742 | Rus | 5051 | call .reserve |
5052 | call clear_CD_cache |
||
5053 | call allow_medium_removal |
||
5054 | call EjectMedium |
||
5055 | call .free |
||
5056 | ret |
||
588 | diamond | 5057 | .audio: |
1 | ha | 5058 | call sys_cd_audio |
5059 | mov [esp+36],eax |
||
588 | diamond | 5060 | .ret: |
1 | ha | 5061 | ret |
5062 | |||
588 | diamond | 5063 | .reserve: |
742 | Rus | 5064 | call reserve_cd |
5065 | mov eax, ebx |
||
5066 | shr eax, 1 |
||
5067 | and eax, 1 |
||
5068 | inc eax |
||
5069 | mov [ChannelNumber], ax |
||
5070 | mov eax, ebx |
||
5071 | and eax, 1 |
||
5072 | mov [DiskNumber], al |
||
5073 | call reserve_cd_channel |
||
5074 | and ebx, 3 |
||
5075 | inc ebx |
||
5076 | mov [cdpos], ebx |
||
5077 | add ebx, ebx |
||
5078 | mov cl, 8 |
||
5079 | sub cl, bl |
||
5080 | mov al, [DRIVE_DATA+1] |
||
5081 | shr al, cl |
||
5082 | test al, 2 |
||
5083 | jz .err |
||
5084 | ret |
||
588 | diamond | 5085 | .free: |
742 | Rus | 5086 | call free_cd_channel |
5087 | and [cd_status], 0 |
||
5088 | ret |
||
590 | diamond | 5089 | .err: |
742 | Rus | 5090 | call .free |
5091 | pop eax |
||
5092 | ret |
||
588 | diamond | 5093 | |
1 | ha | 5094 | align 4 |
5095 | |||
742 | Rus | 5096 | syscall_getpixel: ; GetPixel |
753 | serge | 5097 | mov ecx, [Screen_Max_X] |
1 | ha | 5098 | inc ecx |
671 | Ghost | 5099 | xor edx, edx |
5100 | mov eax, ebx |
||
1 | ha | 5101 | div ecx |
671 | Ghost | 5102 | mov ebx, edx |
5103 | xchg eax, ebx |
||
5104 | call dword [GETPIXEL] ; eax - x, ebx - y |
||
5105 | mov [esp + 32], ecx |
||
1 | ha | 5106 | ret |
5107 | |||
5108 | |||
5109 | align 4 |
||
5110 | |||
742 | Rus | 5111 | syscall_drawline: ; DrawLine |
1 | ha | 5112 | |
671 | Ghost | 5113 | mov edi, [TASK_BASE] |
752 | Lrz | 5114 | movzx eax, word[edi-twdw+WDATA.box.left] |
5115 | mov ebp, eax |
||
671 | Ghost | 5116 | mov esi, [current_slot] |
5117 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
||
752 | Lrz | 5118 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5119 | add ebp,ebx |
||
5120 | shl eax, 16 |
||
5121 | movzx ebx, word[edi-twdw+WDATA.box.top] |
||
671 | Ghost | 5122 | add eax, ebp |
752 | Lrz | 5123 | mov ebp, ebx |
671 | Ghost | 5124 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
752 | Lrz | 5125 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
759 | Rus | 5126 | add ebp, ecx |
752 | Lrz | 5127 | shl ebx, 16 |
671 | Ghost | 5128 | xor edi, edi |
752 | Lrz | 5129 | add ebx, ebp |
5130 | mov ecx, edx |
||
671 | Ghost | 5131 | jmp [draw_line] |
1 | ha | 5132 | |
5133 | align 4 |
||
5134 | |||
742 | Rus | 5135 | syscall_getirqowner: ; GetIrqOwner |
5136 | |||
5137 | cmp ebx,16 |
||
75 | diamond | 5138 | jae .err |
742 | Rus | 5139 | |
774 | Rus | 5140 | cmp [irq_rights + 4 * ebx], dword 2 |
5141 | je .err |
||
5142 | |||
742 | Rus | 5143 | mov eax,[4 * ebx + irq_owner] |
5144 | mov [esp+32],eax |
||
5145 | |||
1 | ha | 5146 | ret |
75 | diamond | 5147 | .err: |
742 | Rus | 5148 | or dword [esp+32], -1 |
75 | diamond | 5149 | ret |
1 | ha | 5150 | |
5151 | align 4 |
||
5152 | |||
742 | Rus | 5153 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
1 | ha | 5154 | |
5155 | call r_f_port_area |
||
5156 | mov [esp+36],eax |
||
5157 | ret |
||
5158 | |||
5159 | align 4 |
||
5160 | |||
742 | Rus | 5161 | syscall_threads: ; CreateThreads |
1 | ha | 5162 | |
5163 | call sys_threads |
||
5164 | mov [esp+36],eax |
||
5165 | ret |
||
5166 | |||
5167 | align 4 |
||
5168 | |||
5169 | stack_driver_stat: |
||
5170 | |||
742 | Rus | 5171 | call app_stack_handler ; Stack status |
1 | ha | 5172 | |
5173 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
||
5174 | ; call change_task ; between sent packet |
||
5175 | |||
5176 | mov [esp+36],eax |
||
5177 | ret |
||
5178 | |||
5179 | align 4 |
||
5180 | |||
742 | Rus | 5181 | socket: ; Socket interface |
1 | ha | 5182 | call app_socket_handler |
5183 | |||
5184 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
||
5185 | ; call change_task ; between sent packet |
||
5186 | |||
5187 | mov [esp+36],eax |
||
5188 | mov [esp+24],ebx |
||
5189 | ret |
||
5190 | |||
5191 | align 4 |
||
5192 | |||
742 | Rus | 5193 | read_from_hd: ; Read from hd - fn not in use |
1 | ha | 5194 | |
379 | serge | 5195 | mov edi,[TASK_BASE] |
115 | poddubny | 5196 | add edi,TASKDATA.mem_start |
1 | ha | 5197 | add eax,[edi] |
5198 | add ecx,[edi] |
||
5199 | add edx,[edi] |
||
5200 | call file_read |
||
5201 | |||
5202 | mov [esp+36],eax |
||
5203 | mov [esp+24],ebx |
||
5204 | |||
5205 | ret |
||
5206 | |||
375 | Ghost | 5207 | paleholder: |
742 | Rus | 5208 | ret |
378 | serge | 5209 | |
757 | serge | 5210 | align 4 |
5211 | set_screen: |
||
759 | Rus | 5212 | cmp eax, [Screen_Max_X] |
5213 | jne .set |
||
709 | diamond | 5214 | |
759 | Rus | 5215 | cmp edx, [Screen_Max_Y] |
5216 | jne .set |
||
5217 | ret |
||
757 | serge | 5218 | .set: |
759 | Rus | 5219 | pushfd |
5220 | cli |
||
757 | serge | 5221 | |
759 | Rus | 5222 | mov [Screen_Max_X], eax |
5223 | mov [Screen_Max_Y], edx |
||
757 | serge | 5224 | |
759 | Rus | 5225 | mov [screen_workarea.right],eax |
5226 | mov [screen_workarea.bottom], edx |
||
5227 | inc eax |
||
5228 | shl eax, 2 ;32 bpp |
||
5229 | mov [BytesPerScanLine], eax |
||
5230 | push ebx |
||
5231 | push esi |
||
5232 | push edi |
||
5233 | call repos_windows |
||
5234 | mov eax, 0 |
||
5235 | mov ebx, 0 |
||
5236 | mov ecx, [Screen_Max_X] |
||
5237 | mov edx, [Screen_Max_Y] |
||
5238 | call calculatescreen |
||
5239 | pop edi |
||
5240 | pop esi |
||
5241 | pop ebx |
||
757 | serge | 5242 | |
759 | Rus | 5243 | popfd |
5244 | ret |
||
757 | serge | 5245 | |
76 | mario79 | 5246 | ; --------------- APM --------------------- |
5247 | apm_entry dp 0 |
||
742 | Rus | 5248 | apm_vf dd 0 |
1 | ha | 5249 | align 4 |
76 | mario79 | 5250 | sys_apm: |
5251 | cmp word [apm_vf], 0 ; Check APM BIOS enable |
||
5252 | jne @f |
||
742 | Rus | 5253 | or [esp + 56], byte 1 ; error |
5254 | mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported |
||
76 | mario79 | 5255 | ret |
164 | serge | 5256 | |
465 | serge | 5257 | @@: |
5258 | xchg eax, ecx |
||
76 | mario79 | 5259 | xchg ebx, ecx |
164 | serge | 5260 | |
76 | mario79 | 5261 | cmp al, 3 |
742 | Rus | 5262 | ja @f |
78 | diamond | 5263 | and [esp + 56], byte 0xfe ; emulate func 0..3 as func 0 |
76 | mario79 | 5264 | mov eax, [apm_vf] |
5265 | mov [esp + 36], eax |
||
5266 | shr eax, 16 |
||
5267 | mov [esp + 32], eax |
||
5268 | ret |
||
78 | diamond | 5269 | |
465 | serge | 5270 | @@: |
5271 | |||
5272 | mov esi, [master_tab+(OS_BASE shr 20)] |
||
5273 | xchg [master_tab], esi |
||
5274 | push esi |
||
5275 | mov edi, cr3 |
||
742 | Rus | 5276 | mov cr3, edi ;flush TLB |
465 | serge | 5277 | |
742 | Rus | 5278 | call pword [apm_entry] ; call APM BIOS |
465 | serge | 5279 | |
5280 | xchg eax, [esp] |
||
5281 | mov [master_tab], eax |
||
5282 | mov eax, cr3 |
||
5283 | mov cr3, eax |
||
5284 | pop eax |
||
5285 | |||
76 | mario79 | 5286 | mov [esp + 8 ], edi |
5287 | mov [esp + 12], esi |
||
5288 | mov [esp + 24], ebx |
||
5289 | mov [esp + 28], edx |
||
5290 | mov [esp + 32], ecx |
||
5291 | mov [esp + 36], eax |
||
5292 | setc al |
||
78 | diamond | 5293 | and [esp + 56], byte 0xfe |
742 | Rus | 5294 | or [esp + 56], al |
465 | serge | 5295 | |
5296 | |||
76 | mario79 | 5297 | ret |
5298 | ; ----------------------------------------- |
||
1 | ha | 5299 | |
76 | mario79 | 5300 | align 4 |
5301 | |||
742 | Rus | 5302 | undefined_syscall: ; Undefined system call |
671 | Ghost | 5303 | mov [esp + 32], dword -1 |
1 | ha | 5304 | ret |
5305 | |||
465 | serge | 5306 | align 4 |
742 | Rus | 5307 | system_shutdown: ; shut down the system |
1 | ha | 5308 | |
742 | Rus | 5309 | cmp byte [BOOT_VAR+0x9030], 1 |
5310 | jne @F |
||
5311 | ret |
||
465 | serge | 5312 | @@: |
742 | Rus | 5313 | call stop_all_services |
5314 | push 3 ; stop playing cd |
||
5315 | pop eax |
||
5316 | call sys_cd_audio |
||
1 | ha | 5317 | |
465 | serge | 5318 | yes_shutdown_param: |
742 | Rus | 5319 | cli |
1 | ha | 5320 | |
742 | Rus | 5321 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5322 | push 12 |
||
5323 | pop esi |
||
5324 | xor ebx,ebx |
||
5325 | or ecx,-1 |
||
5326 | mov edx, OS_BASE+0x70000 |
||
5327 | call fileread |
||
1 | ha | 5328 | |
847 | serge | 5329 | ; mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5330 | ; mov edi,OS_BASE+0x40000 |
||
5331 | ; mov ecx,1000 |
||
5332 | ; rep movsb |
||
1 | ha | 5333 | |
847 | serge | 5334 | mov esi,OS_BASE+0x2F0000 ; restore 0x0 - 0xffff |
5335 | mov edi, OS_BASE |
||
5336 | mov ecx,0x10000/4 |
||
5337 | cld |
||
5338 | rep movsd |
||
1 | ha | 5339 | |
742 | Rus | 5340 | call restorefatchain |
1 | ha | 5341 | |
742 | Rus | 5342 | mov al, 0xFF |
5343 | out 0x21, al |
||
5344 | out 0xA1, al |
||
1 | ha | 5345 | |
709 | diamond | 5346 | if 1 |
847 | serge | 5347 | ; mov word [OS_BASE+0x467+0],pr_mode_exit |
5348 | ; mov word [OS_BASE+0x467+2],0x1000 |
||
1 | ha | 5349 | |
742 | Rus | 5350 | mov al,0x0F |
5351 | out 0x70,al |
||
5352 | mov al,0x05 |
||
5353 | out 0x71,al |
||
1 | ha | 5354 | |
742 | Rus | 5355 | mov al,0xFE |
5356 | out 0x64,al |
||
709 | diamond | 5357 | |
742 | Rus | 5358 | hlt |
1 | ha | 5359 | |
709 | diamond | 5360 | else |
742 | Rus | 5361 | cmp byte [OS_BASE + 0x9030], 2 |
5362 | jnz no_acpi_power_off |
||
1 | ha | 5363 | |
709 | diamond | 5364 | ; scan for RSDP |
5365 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
||
742 | Rus | 5366 | movzx eax, word [OS_BASE + 0x40E] |
5367 | shl eax, 4 |
||
5368 | jz @f |
||
5369 | mov ecx, 1024/16 |
||
5370 | call scan_rsdp |
||
5371 | jnc .rsdp_found |
||
709 | diamond | 5372 | @@: |
5373 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
||
742 | Rus | 5374 | mov eax, 0xE0000 |
5375 | mov ecx, 0x2000 |
||
5376 | call scan_rsdp |
||
5377 | jc no_acpi_power_off |
||
709 | diamond | 5378 | .rsdp_found: |
742 | Rus | 5379 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5380 | mov ebp, [ipc_tmp] |
||
5381 | stdcall map_page, ebp, esi, PG_MAP |
||
5382 | lea eax, [esi+1000h] |
||
5383 | lea edx, [ebp+1000h] |
||
5384 | stdcall map_page, edx, eax, PG_MAP |
||
5385 | and esi, 0xFFF |
||
5386 | add esi, ebp |
||
5387 | cmp dword [esi], 'RSDT' |
||
5388 | jnz no_acpi_power_off |
||
5389 | mov ecx, [esi+4] |
||
5390 | sub ecx, 24h |
||
5391 | jbe no_acpi_power_off |
||
5392 | shr ecx, 2 |
||
5393 | add esi, 24h |
||
709 | diamond | 5394 | .scan_fadt: |
742 | Rus | 5395 | lodsd |
5396 | mov ebx, eax |
||
5397 | lea eax, [ebp+2000h] |
||
5398 | stdcall map_page, eax, ebx, PG_MAP |
||
5399 | lea eax, [ebp+3000h] |
||
5400 | add ebx, 0x1000 |
||
5401 | stdcall map_page, eax, ebx, PG_MAP |
||
5402 | and ebx, 0xFFF |
||
5403 | lea ebx, [ebx+ebp+2000h] |
||
5404 | cmp dword [ebx], 'FACP' |
||
5405 | jz .fadt_found |
||
5406 | loop .scan_fadt |
||
5407 | jmp no_acpi_power_off |
||
709 | diamond | 5408 | .fadt_found: |
5409 | ; ebx is linear address of FADT |
||
742 | Rus | 5410 | mov edx, [ebx+48] |
5411 | test edx, edx |
||
5412 | jz .nosmi |
||
5413 | mov al, [ebx+52] |
||
5414 | out dx, al |
||
5415 | mov edx, [ebx+64] |
||
709 | diamond | 5416 | @@: |
742 | Rus | 5417 | in ax, dx |
5418 | test al, 1 |
||
5419 | jz @b |
||
709 | diamond | 5420 | .nosmi: |
742 | Rus | 5421 | mov edx, [ebx+64] |
5422 | in ax, dx |
||
5423 | and ax, 203h |
||
5424 | or ax, 3C00h |
||
5425 | out dx, ax |
||
5426 | mov edx, [ebx+68] |
||
5427 | test edx, edx |
||
5428 | jz @f |
||
5429 | in ax, dx |
||
5430 | and ax, 203h |
||
5431 | or ax, 3C00h |
||
5432 | out dx, ax |
||
709 | diamond | 5433 | @@: |
742 | Rus | 5434 | jmp $ |
709 | diamond | 5435 | |
5436 | |||
5437 | no_acpi_power_off: |
||
742 | Rus | 5438 | mov word [OS_BASE+0x467+0],pr_mode_exit |
5439 | mov word [OS_BASE+0x467+2],0x1000 |
||
709 | diamond | 5440 | |
742 | Rus | 5441 | mov al,0x0F |
5442 | out 0x70,al |
||
5443 | mov al,0x05 |
||
5444 | out 0x71,al |
||
709 | diamond | 5445 | |
742 | Rus | 5446 | mov al,0xFE |
5447 | out 0x64,al |
||
709 | diamond | 5448 | |
742 | Rus | 5449 | hlt |
709 | diamond | 5450 | |
5451 | scan_rsdp: |
||
742 | Rus | 5452 | add eax, OS_BASE |
709 | diamond | 5453 | .s: |
742 | Rus | 5454 | cmp dword [eax], 'RSD ' |
5455 | jnz .n |
||
5456 | cmp dword [eax+4], 'PTR ' |
||
5457 | jnz .n |
||
5458 | xor edx, edx |
||
5459 | xor esi, esi |
||
709 | diamond | 5460 | @@: |
742 | Rus | 5461 | add dl, [eax+esi] |
5462 | inc esi |
||
5463 | cmp esi, 20 |
||
5464 | jnz @b |
||
5465 | test dl, dl |
||
5466 | jz .ok |
||
709 | diamond | 5467 | .n: |
742 | Rus | 5468 | add eax, 10h |
5469 | loop .s |
||
5470 | stc |
||
709 | diamond | 5471 | .ok: |
742 | Rus | 5472 | ret |
709 | diamond | 5473 | end if |
5474 | |||
465 | serge | 5475 | include "data32.inc" |
1 | ha | 5476 | |
465 | serge | 5477 | __REV__ = __REV |
1 | ha | 5478 | |
5479 | uglobals_size = $ - endofcode |
||
41 | mikedld | 5480 | diff16 "end of kernel code",0,$ |
426 | mikedld | 5481 | |
847 | serge | 5482 | align 16 |
5483 | |||
5484 | __end:=> |
||
5485 |