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