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