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