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