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