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