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