Rev 3810 | Rev 3870 | 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: 3825 $ |
||
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 |
||
3810 | mario79 | 1120 | |
1121 | mov ax, [IDE_Interrupt] |
||
1122 | cmp al, 0xff |
||
3825 | mario79 | 1123 | jne @f |
1124 | |||
1125 | mov [dma_hdd], 0 |
||
1126 | jmp set_interrupts_for_IDE_controllers.end_set_interrupts |
||
1127 | @@: |
||
3762 | mario79 | 1128 | ;----------------------------------------------------------------------------- |
1129 | ; set interrupts for IDE Controller |
||
1130 | ;----------------------------------------------------------------------------- |
||
1131 | mov esi, boot_set_int_IDE |
||
1132 | call boot_log |
||
1133 | set_interrupts_for_IDE_controllers: |
||
1134 | mov ax, [IDEContrProgrammingInterface] |
||
1135 | cmp ax, 0x0180 |
||
1136 | je .pata_ide |
||
1137 | |||
1138 | cmp ax, 0x018a |
||
1139 | jne .sata_ide |
||
1140 | ;-------------------------------------- |
||
1141 | .pata_ide: |
||
1142 | cmp [IDEContrRegsBaseAddr], 0 |
||
1143 | je .end_set_interrupts |
||
1144 | |||
1145 | stdcall attach_int_handler, 14, IDE_common_irq_handler, 0 |
||
1146 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
||
1147 | stdcall attach_int_handler, 15, IDE_common_irq_handler, 0 |
||
1148 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
||
1149 | jmp .enable_IDE_interrupt |
||
1150 | ;-------------------------------------- |
||
1151 | .sata_ide: |
||
1152 | cmp ax, 0x0185 |
||
1153 | je .sata_ide_1 |
||
1154 | |||
1155 | cmp ax, 0x018f |
||
1156 | jne .end_set_interrupts |
||
1157 | ;-------------------------------------- |
||
1158 | .sata_ide_1: |
||
1159 | cmp [IDEContrRegsBaseAddr], 0 |
||
1160 | je .end_set_interrupts |
||
1161 | |||
1162 | mov ax, [IDE_Interrupt] |
||
1163 | movzx eax, al |
||
1164 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
||
3774 | mario79 | 1165 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax |
3762 | mario79 | 1166 | ;-------------------------------------- |
1167 | .enable_IDE_interrupt: |
||
1168 | mov esi, boot_enabling_ide |
||
1169 | call boot_log |
||
1170 | ; Enable interrupts in IDE controller for DMA |
||
1171 | mov al, 0 |
||
3774 | mario79 | 1172 | mov dx, [IDE_BAR1_val] ;0x3F4 |
1173 | add dx, 2 ;0x3F6 |
||
3762 | mario79 | 1174 | out dx, al |
3774 | mario79 | 1175 | mov dx, [IDE_BAR3_val] ;0x374 |
1176 | add dx, 2 ;0x376 |
||
3762 | mario79 | 1177 | out dx, al |
1178 | ;-------------------------------------- |
||
1179 | .end_set_interrupts: |
||
1180 | ;----------------------------------------------------------------------------- |
||
3726 | clevermous | 1181 | cmp [dma_hdd], 0 |
3702 | mario79 | 1182 | je .print_pio |
1183 | .print_dma: |
||
1184 | DEBUGF 1, "K : IDE DMA mode\n" |
||
1185 | jmp .continue |
||
3732 | Serge | 1186 | |
3702 | mario79 | 1187 | .print_pio: |
1188 | DEBUGF 1, "K : IDE PIO mode\n" |
||
1189 | .continue: |
||
3732 | Serge | 1190 | |
2288 | clevermous | 1191 | mov [timer_ticks_enable], 1 ; for cd driver |
1192 | |||
1193 | sti |
||
3534 | clevermous | 1194 | ; call change_task |
2288 | clevermous | 1195 | |
1196 | jmp osloop |
||
1197 | |||
1198 | |||
1199 | ; Fly :) |
||
1200 | |||
1201 | include 'unpacker.inc' |
||
1202 | |||
1203 | align 4 |
||
1204 | boot_log: |
||
1205 | pushad |
||
1206 | |||
1207 | mov ebx, 10*65536 |
||
1208 | mov bx, word [boot_y] |
||
1209 | add [boot_y], dword 10 |
||
1210 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
||
1211 | xor edi, edi |
||
1212 | mov edx, esi |
||
1213 | inc edi |
||
1214 | call dtext |
||
1215 | |||
1216 | mov [novesachecksum], 1000 |
||
1217 | call checkVga_N13 |
||
1218 | |||
1219 | popad |
||
1220 | |||
1221 | ret |
||
1222 | |||
3534 | clevermous | 1223 | ; in: edx -> APPDATA for OS/IDLE slot |
1224 | ; in: ebx = stack base |
||
1225 | proc setup_os_slot |
||
1226 | xor eax, eax |
||
1227 | mov ecx, 256/4 |
||
1228 | mov edi, edx |
||
1229 | rep stosd |
||
1230 | |||
3535 | clevermous | 1231 | mov eax, tss+0x80 |
1232 | call get_pg_addr |
||
1233 | inc eax |
||
1234 | mov [edx+APPDATA.io_map], eax |
||
1235 | mov eax, tss+0x1080 |
||
1236 | call get_pg_addr |
||
1237 | inc eax |
||
1238 | mov [edx+APPDATA.io_map+4], eax |
||
1239 | |||
3534 | clevermous | 1240 | mov dword [edx+APPDATA.pl0_stack], ebx |
1241 | lea edi, [ebx+0x2000-512] |
||
1242 | mov dword [edx+APPDATA.fpu_state], edi |
||
1243 | mov dword [edx+APPDATA.saved_esp0], edi |
||
1244 | mov dword [edx+APPDATA.saved_esp], edi |
||
1245 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
||
1246 | |||
1247 | mov esi, fpu_data |
||
1248 | mov ecx, 512/4 |
||
1249 | cld |
||
1250 | rep movsd |
||
1251 | |||
1252 | lea eax, [edx+APP_OBJ_OFFSET] |
||
1253 | mov dword [edx+APPDATA.fd_obj], eax |
||
1254 | mov dword [edx+APPDATA.bk_obj], eax |
||
1255 | |||
1256 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
||
1257 | |||
1258 | mov [edx + APPDATA.dir_table], sys_pgdir - OS_BASE |
||
1259 | |||
1260 | mov eax, edx |
||
1261 | shr eax, 3 |
||
1262 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
||
1263 | mov [eax+TASKDATA.wnd_number], dh |
||
1264 | mov byte [eax+TASKDATA.pid], dh |
||
1265 | |||
1266 | ret |
||
1267 | endp |
||
1268 | |||
2288 | clevermous | 1269 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1270 | ; ; |
||
1271 | ; MAIN OS LOOP START ; |
||
1272 | ; ; |
||
1273 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1274 | align 32 |
||
1275 | osloop: |
||
3534 | clevermous | 1276 | mov edx, osloop_has_work? |
1277 | xor ecx, ecx |
||
1278 | call Wait_events |
||
1279 | xor eax, eax |
||
1280 | xchg eax, [osloop_nonperiodic_work] |
||
1281 | test eax, eax |
||
1282 | jz .no_periodic |
||
2453 | mario79 | 1283 | ; call [draw_pointer] |
1284 | call __sys_draw_pointer |
||
2288 | clevermous | 1285 | call window_check_events |
1286 | call mouse_check_events |
||
1287 | call checkmisc |
||
1288 | call checkVga_N13 |
||
3534 | clevermous | 1289 | .no_periodic: |
2288 | clevermous | 1290 | call stack_handler |
1291 | call check_fdd_motor_status |
||
1292 | call check_ATAPI_device_event |
||
2601 | clevermous | 1293 | call check_lights_state |
2288 | clevermous | 1294 | call check_timers |
1295 | jmp osloop |
||
1296 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1297 | ; ; |
||
1298 | ; MAIN OS LOOP END ; |
||
1299 | ; ; |
||
1300 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
3534 | clevermous | 1301 | proc osloop_has_work? |
1302 | cmp [osloop_nonperiodic_work], 0 |
||
1303 | jnz .yes |
||
1304 | call stack_handler_has_work? |
||
1305 | jnz .yes |
||
3771 | mario79 | 1306 | ; call check_fdd_motor_status_has_work? |
1307 | ; jnz .yes |
||
3534 | clevermous | 1308 | call check_ATAPI_device_event_has_work? |
1309 | jnz .yes |
||
1310 | call check_lights_state_has_work? |
||
1311 | jnz .yes |
||
1312 | call check_timers_has_work? |
||
1313 | jnz .yes |
||
1314 | .no: |
||
1315 | xor eax, eax |
||
2288 | clevermous | 1316 | ret |
3534 | clevermous | 1317 | .yes: |
1318 | xor eax, eax |
||
1319 | inc eax |
||
1320 | ret |
||
1321 | endp |
||
2288 | clevermous | 1322 | |
3534 | clevermous | 1323 | proc wakeup_osloop |
1324 | mov [osloop_nonperiodic_work], 1 |
||
1325 | ret |
||
1326 | endp |
||
1327 | |||
2288 | clevermous | 1328 | uglobal |
3534 | clevermous | 1329 | align 4 |
1330 | osloop_nonperiodic_work dd ? |
||
2288 | clevermous | 1331 | endg |
1332 | |||
3534 | clevermous | 1333 | align 4 |
1334 | idle_thread: |
||
1335 | sti |
||
1336 | idle_loop: |
||
1337 | hlt |
||
1338 | jmp idle_loop |
||
2288 | clevermous | 1339 | |
1340 | |||
3534 | clevermous | 1341 | |
2288 | clevermous | 1342 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1343 | ; ; |
||
1344 | ; INCLUDED SYSTEM FILES ; |
||
1345 | ; ; |
||
1346 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1347 | |||
1348 | |||
1349 | include "kernel32.inc" |
||
1350 | |||
1351 | |||
1352 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1353 | ; ; |
||
1354 | ; KERNEL FUNCTIONS ; |
||
1355 | ; ; |
||
1356 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1357 | |||
1358 | reserve_irqs_ports: |
||
1359 | |||
1360 | |||
1361 | ; RESERVE PORTS |
||
1362 | mov eax, RESERVED_PORTS |
||
1363 | mov ecx, 1 |
||
1364 | |||
1365 | mov [eax], dword 4 |
||
1366 | |||
1367 | mov [eax+16], ecx |
||
1368 | mov [eax+16+4], dword 0 |
||
3426 | hidnplayr | 1369 | mov [eax+16+8], dword 0x2D |
2288 | clevermous | 1370 | |
1371 | mov [eax+32], ecx |
||
1372 | mov [eax+32+4], dword 0x30 |
||
1373 | mov [eax+32+8], dword 0x4D |
||
1374 | |||
1375 | mov [eax+48], ecx |
||
1376 | mov [eax+48+4], dword 0x50 |
||
3426 | hidnplayr | 1377 | mov [eax+48+8], dword 0xDF |
2288 | clevermous | 1378 | |
1379 | mov [eax+64], ecx |
||
1380 | mov [eax+64+4], dword 0xE5 |
||
1381 | mov [eax+64+8], dword 0xFF |
||
1382 | |||
1383 | ret |
||
1384 | |||
1385 | |||
1386 | iglobal |
||
3534 | clevermous | 1387 | process_number dd 0x2 |
2288 | clevermous | 1388 | endg |
1389 | |||
1390 | set_variables: |
||
1391 | |||
1392 | mov ecx, 0x16 ; flush port 0x60 |
||
1393 | .fl60: |
||
1394 | in al, 0x60 |
||
1395 | loop .fl60 |
||
1396 | push eax |
||
1397 | |||
3732 | Serge | 1398 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
2288 | clevermous | 1399 | shr ax, 1 |
1400 | shl eax, 16 |
||
3732 | Serge | 1401 | mov ax, [BOOT_VARS+BOOT_X_RES] |
2288 | clevermous | 1402 | shr ax, 1 |
1403 | mov [MOUSE_X], eax |
||
3534 | clevermous | 1404 | call wakeup_osloop |
2288 | clevermous | 1405 | |
1406 | xor eax, eax |
||
1407 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
||
1408 | |||
1409 | mov byte [KEY_COUNT], al ; keyboard buffer |
||
1410 | mov byte [BTN_COUNT], al ; button buffer |
||
1411 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
||
1412 | |||
1413 | pop eax |
||
1414 | ret |
||
1415 | |||
1416 | align 4 |
||
1417 | ;input eax=43,bl-byte of output, ecx - number of port |
||
1418 | sys_outport: |
||
1419 | |||
1420 | mov edi, ecx ; separate flag for read / write |
||
1421 | and ecx, 65535 |
||
1422 | |||
1423 | mov eax, [RESERVED_PORTS] |
||
1424 | test eax, eax |
||
1425 | jnz .sopl8 |
||
1426 | inc eax |
||
1427 | mov [esp+32], eax |
||
1428 | ret |
||
1429 | |||
1430 | .sopl8: |
||
1431 | mov edx, [TASK_BASE] |
||
1432 | mov edx, [edx+0x4] |
||
1433 | ;and ecx,65535 |
||
1434 | ;cld - set on interrupt 0x40 |
||
1435 | .sopl1: |
||
1436 | |||
1437 | mov esi, eax |
||
1438 | shl esi, 4 |
||
1439 | add esi, RESERVED_PORTS |
||
1440 | cmp edx, [esi+0] |
||
1441 | jne .sopl2 |
||
1442 | cmp ecx, [esi+4] |
||
1443 | jb .sopl2 |
||
1444 | cmp ecx, [esi+8] |
||
1445 | jg .sopl2 |
||
1446 | .sopl3: |
||
1447 | |||
1448 | test edi, 0x80000000; read ? |
||
1449 | jnz .sopl4 |
||
1450 | |||
1451 | mov eax, ebx |
||
1452 | mov dx, cx ; write |
||
1453 | out dx, al |
||
1454 | and [esp+32], dword 0 |
||
1455 | ret |
||
1456 | |||
1457 | .sopl2: |
||
1458 | |||
1459 | dec eax |
||
1460 | jnz .sopl1 |
||
1461 | inc eax |
||
1462 | mov [esp+32], eax |
||
1463 | ret |
||
1464 | |||
1465 | |||
1466 | .sopl4: |
||
1467 | |||
1468 | mov dx, cx ; read |
||
1469 | in al, dx |
||
1470 | and eax, 0xff |
||
1471 | and [esp+32], dword 0 |
||
1472 | mov [esp+20], eax |
||
1473 | ret |
||
1474 | |||
1475 | display_number: |
||
1476 | ;It is not optimization |
||
1477 | mov eax, ebx |
||
1478 | mov ebx, ecx |
||
1479 | mov ecx, edx |
||
1480 | mov edx, esi |
||
1481 | mov esi, edi |
||
1482 | ; eax = print type, al=0 -> ebx is number |
||
1483 | ; al=1 -> ebx is pointer |
||
1484 | ; ah=0 -> display decimal |
||
1485 | ; ah=1 -> display hexadecimal |
||
1486 | ; ah=2 -> display binary |
||
1487 | ; eax bits 16-21 = number of digits to display (0-32) |
||
1488 | ; eax bits 22-31 = reserved |
||
1489 | ; |
||
1490 | ; ebx = number or pointer |
||
1491 | ; ecx = x shl 16 + y |
||
1492 | ; edx = color |
||
1493 | xor edi, edi |
||
1494 | display_number_force: |
||
1495 | push eax |
||
1496 | and eax, 0x3fffffff |
||
1497 | cmp eax, 0xffff ; length > 0 ? |
||
1498 | pop eax |
||
1499 | jge cont_displ |
||
1500 | ret |
||
1501 | cont_displ: |
||
1502 | push eax |
||
1503 | and eax, 0x3fffffff |
||
1504 | cmp eax, 61*0x10000 ; length <= 60 ? |
||
1505 | pop eax |
||
1506 | jb cont_displ2 |
||
1507 | ret |
||
1508 | cont_displ2: |
||
1509 | |||
1510 | pushad |
||
1511 | |||
1512 | cmp al, 1 ; ecx is a pointer ? |
||
1513 | jne displnl1 |
||
1514 | mov ebp, ebx |
||
1515 | add ebp, 4 |
||
1516 | mov ebp, [ebp+std_application_base_address] |
||
1517 | mov ebx, [ebx+std_application_base_address] |
||
1518 | displnl1: |
||
1519 | sub esp, 64 |
||
1520 | |||
1521 | test ah, ah ; DECIMAL |
||
1522 | jnz no_display_desnum |
||
1523 | shr eax, 16 |
||
1524 | and eax, 0xC03f |
||
1525 | ; and eax,0x3f |
||
1526 | push eax |
||
1527 | and eax, 0x3f |
||
1528 | mov edi, esp |
||
1529 | add edi, 4+64-1 |
||
1530 | mov ecx, eax |
||
1531 | mov eax, ebx |
||
1532 | mov ebx, 10 |
||
1533 | d_desnum: |
||
1534 | xor edx, edx |
||
1535 | call division_64_bits |
||
1536 | div ebx |
||
1537 | add dl, 48 |
||
1538 | mov [edi], dl |
||
1539 | dec edi |
||
1540 | loop d_desnum |
||
1541 | pop eax |
||
1542 | call normalize_number |
||
1543 | call draw_num_text |
||
1544 | add esp, 64 |
||
1545 | popad |
||
1546 | ret |
||
1547 | no_display_desnum: |
||
1548 | |||
1549 | cmp ah, 0x01 ; HEXADECIMAL |
||
1550 | jne no_display_hexnum |
||
1551 | shr eax, 16 |
||
1552 | and eax, 0xC03f |
||
1553 | ; and eax,0x3f |
||
1554 | push eax |
||
1555 | and eax, 0x3f |
||
1556 | mov edi, esp |
||
1557 | add edi, 4+64-1 |
||
1558 | mov ecx, eax |
||
1559 | mov eax, ebx |
||
1560 | mov ebx, 16 |
||
1561 | d_hexnum: |
||
1562 | xor edx, edx |
||
1563 | call division_64_bits |
||
1564 | div ebx |
||
1565 | hexletters = __fdo_hexdigits |
||
1566 | add edx, hexletters |
||
1567 | mov dl, [edx] |
||
1568 | mov [edi], dl |
||
1569 | dec edi |
||
1570 | loop d_hexnum |
||
1571 | pop eax |
||
1572 | call normalize_number |
||
1573 | call draw_num_text |
||
1574 | add esp, 64 |
||
1575 | popad |
||
1576 | ret |
||
1577 | no_display_hexnum: |
||
1578 | |||
1579 | cmp ah, 0x02 ; BINARY |
||
1580 | jne no_display_binnum |
||
1581 | shr eax, 16 |
||
1582 | and eax, 0xC03f |
||
1583 | ; and eax,0x3f |
||
1584 | push eax |
||
1585 | and eax, 0x3f |
||
1586 | mov edi, esp |
||
1587 | add edi, 4+64-1 |
||
1588 | mov ecx, eax |
||
1589 | mov eax, ebx |
||
1590 | mov ebx, 2 |
||
1591 | d_binnum: |
||
1592 | xor edx, edx |
||
1593 | call division_64_bits |
||
1594 | div ebx |
||
1595 | add dl, 48 |
||
1596 | mov [edi], dl |
||
1597 | dec edi |
||
1598 | loop d_binnum |
||
1599 | pop eax |
||
1600 | call normalize_number |
||
1601 | call draw_num_text |
||
1602 | add esp, 64 |
||
1603 | popad |
||
1604 | ret |
||
1605 | no_display_binnum: |
||
1606 | |||
1607 | add esp, 64 |
||
1608 | popad |
||
1609 | ret |
||
1610 | |||
1611 | normalize_number: |
||
1612 | test ah, 0x80 |
||
1613 | jz .continue |
||
1614 | mov ecx, 48 |
||
1615 | and eax, 0x3f |
||
1616 | @@: |
||
1617 | inc edi |
||
1618 | cmp [edi], cl |
||
1619 | jne .continue |
||
1620 | dec eax |
||
1621 | cmp eax, 1 |
||
1622 | ja @r |
||
1623 | mov al, 1 |
||
1624 | .continue: |
||
1625 | and eax, 0x3f |
||
1626 | ret |
||
1627 | |||
1628 | division_64_bits: |
||
1629 | test [esp+1+4], byte 0x40 |
||
1630 | jz .continue |
||
1631 | push eax |
||
1632 | mov eax, ebp |
||
1633 | div ebx |
||
1634 | mov ebp, eax |
||
1635 | pop eax |
||
1636 | .continue: |
||
1637 | ret |
||
1638 | |||
1639 | draw_num_text: |
||
1640 | mov esi, eax |
||
1641 | mov edx, 64+4 |
||
1642 | sub edx, eax |
||
1643 | add edx, esp |
||
1644 | mov ebx, [esp+64+32-8+4] |
||
1645 | ; add window start x & y |
||
1646 | mov ecx, [TASK_BASE] |
||
1647 | |||
1648 | mov edi, [CURRENT_TASK] |
||
1649 | shl edi, 8 |
||
1650 | |||
1651 | mov eax, [ecx-twdw+WDATA.box.left] |
||
1652 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1653 | shl eax, 16 |
||
1654 | add eax, [ecx-twdw+WDATA.box.top] |
||
1655 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1656 | add ebx, eax |
||
1657 | mov ecx, [esp+64+32-12+4] |
||
1658 | and ecx, not 0x80000000 ; force counted string |
||
1659 | mov eax, [esp+64+8] ; background color (if given) |
||
1660 | mov edi, [esp+64+4] |
||
1661 | jmp dtext |
||
1662 | |||
1663 | align 4 |
||
1664 | |||
1665 | sys_setup: |
||
1666 | |||
1667 | ; 1=roland mpu midi base , base io address |
||
1668 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1669 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1670 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1671 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1672 | ; 8=fat32 partition in hd |
||
1673 | ; 9 |
||
1674 | ; 10 = sound dma channel |
||
1675 | ; 11 = enable lba read |
||
1676 | ; 12 = enable pci access |
||
1677 | |||
1678 | |||
1679 | and [esp+32], dword 0 |
||
1680 | dec ebx ; MIDI |
||
1681 | jnz nsyse1 |
||
1682 | cmp ecx, 0x100 |
||
1683 | |||
1684 | jb nsyse1 |
||
1685 | mov esi, 65535 |
||
1686 | cmp esi, ecx |
||
1687 | |||
1688 | jb nsyse1 |
||
1689 | mov [midi_base], cx ;bx |
||
1690 | mov word [mididp], cx;bx |
||
1691 | inc cx ;bx |
||
1692 | mov word [midisp], cx;bx |
||
1693 | ret |
||
1694 | |||
1695 | iglobal |
||
1696 | midi_base dw 0 |
||
1697 | endg |
||
1698 | |||
1699 | nsyse1: |
||
1700 | dec ebx ; KEYBOARD |
||
1701 | jnz nsyse2 |
||
1702 | mov edi, [TASK_BASE] |
||
1703 | mov eax, [edi+TASKDATA.mem_start] |
||
1704 | add eax, edx |
||
1705 | |||
1706 | dec ecx |
||
1707 | jnz kbnobase |
||
1708 | mov ebx, keymap |
||
1709 | mov ecx, 128 |
||
1710 | call memmove |
||
1711 | ret |
||
1712 | kbnobase: |
||
1713 | dec ecx |
||
1714 | jnz kbnoshift |
||
1715 | |||
1716 | mov ebx, keymap_shift |
||
1717 | mov ecx, 128 |
||
1718 | call memmove |
||
1719 | ret |
||
1720 | kbnoshift: |
||
1721 | dec ecx |
||
1722 | jnz kbnoalt |
||
1723 | mov ebx, keymap_alt |
||
1724 | mov ecx, 128 |
||
1725 | call memmove |
||
1726 | ret |
||
1727 | kbnoalt: |
||
1728 | sub ecx, 6 |
||
1729 | jnz kbnocountry |
||
1730 | mov word [keyboard], dx |
||
1731 | ret |
||
1732 | kbnocountry: |
||
1733 | mov [esp+32], dword 1 |
||
1734 | ret |
||
1735 | nsyse2: |
||
1736 | dec ebx ; CD |
||
1737 | jnz nsyse4 |
||
1738 | |||
1739 | test ecx, ecx |
||
1740 | jz nosesl |
||
1741 | |||
1742 | cmp ecx, 4 |
||
1743 | ja nosesl |
||
1744 | mov [cd_base], cl |
||
1745 | |||
1746 | dec ecx |
||
1747 | jnz noprma |
||
3726 | clevermous | 1748 | mov eax, [hd_address_table] |
1749 | mov [cdbase], eax ;0x1f0 |
||
2288 | clevermous | 1750 | mov [cdid], 0xa0 |
1751 | noprma: |
||
1752 | |||
1753 | dec ecx |
||
1754 | jnz noprsl |
||
3726 | clevermous | 1755 | mov eax, [hd_address_table] |
1756 | mov [cdbase], eax ;0x1f0 |
||
2288 | clevermous | 1757 | mov [cdid], 0xb0 |
1758 | noprsl: |
||
1759 | dec ecx |
||
1760 | jnz nosema |
||
3726 | clevermous | 1761 | mov eax, [hd_address_table+16] |
1762 | mov [cdbase], eax ;0x170 |
||
2288 | clevermous | 1763 | mov [cdid], 0xa0 |
1764 | nosema: |
||
1765 | dec ecx |
||
1766 | jnz nosesl |
||
3726 | clevermous | 1767 | mov eax, [hd_address_table+16] |
1768 | mov [cdbase], eax ;0x170 |
||
2288 | clevermous | 1769 | mov [cdid], 0xb0 |
1770 | nosesl: |
||
1771 | ret |
||
1772 | |||
1773 | iglobal |
||
1774 | cd_base db 0 |
||
1775 | |||
1776 | endg |
||
1777 | nsyse4: |
||
1778 | |||
1779 | sub ebx, 2 ; SYSTEM LANGUAGE |
||
1780 | jnz nsyse5 |
||
1781 | mov [syslang], ecx |
||
1782 | ret |
||
1783 | nsyse5: |
||
1784 | |||
3742 | clevermous | 1785 | sub ebx, 2 ; HD BASE - obsolete |
2288 | clevermous | 1786 | jnz nsyse7 |
1787 | |||
1788 | nosethd: |
||
1789 | ret |
||
1790 | |||
1791 | nsyse7: |
||
1792 | |||
3742 | clevermous | 1793 | ; cmp eax,8 ; HD PARTITION - obsolete |
2288 | clevermous | 1794 | dec ebx |
1795 | jnz nsyse8 |
||
1796 | ret |
||
1797 | |||
1798 | nsyse8: |
||
1799 | ; cmp eax,11 ; ENABLE LBA READ |
||
1800 | and ecx, 1 |
||
1801 | sub ebx, 3 |
||
1802 | jnz no_set_lba_read |
||
1803 | mov [lba_read_enabled], ecx |
||
1804 | ret |
||
1805 | |||
1806 | no_set_lba_read: |
||
1807 | ; cmp eax,12 ; ENABLE PCI ACCESS |
||
1808 | dec ebx |
||
1809 | jnz sys_setup_err |
||
1810 | mov [pci_access_enabled], ecx |
||
1811 | ret |
||
1812 | |||
1813 | sys_setup_err: |
||
1814 | or [esp+32], dword -1 |
||
1815 | ret |
||
1816 | |||
1817 | align 4 |
||
1818 | |||
1819 | sys_getsetup: |
||
1820 | |||
1821 | ; 1=roland mpu midi base , base io address |
||
1822 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1823 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1824 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1825 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1826 | ; 8=fat32 partition in hd |
||
1827 | ; 9=get hs timer tic |
||
1828 | |||
1829 | ; cmp eax,1 |
||
1830 | dec ebx |
||
1831 | jnz ngsyse1 |
||
1832 | movzx eax, [midi_base] |
||
1833 | mov [esp+32], eax |
||
1834 | ret |
||
1835 | ngsyse1: |
||
1836 | ; cmp eax,2 |
||
1837 | dec ebx |
||
1838 | jnz ngsyse2 |
||
1839 | |||
1840 | mov edi, [TASK_BASE] |
||
1841 | mov ebx, [edi+TASKDATA.mem_start] |
||
1842 | add ebx, edx |
||
1843 | |||
1844 | ; cmp ebx,1 |
||
1845 | dec ecx |
||
1846 | jnz kbnobaseret |
||
1847 | mov eax, keymap |
||
1848 | mov ecx, 128 |
||
1849 | call memmove |
||
1850 | ret |
||
1851 | kbnobaseret: |
||
1852 | ; cmp ebx,2 |
||
1853 | dec ecx |
||
1854 | jnz kbnoshiftret |
||
1855 | |||
1856 | mov eax, keymap_shift |
||
1857 | mov ecx, 128 |
||
1858 | call memmove |
||
1859 | ret |
||
1860 | kbnoshiftret: |
||
1861 | ; cmp ebx,3 |
||
1862 | dec ecx |
||
1863 | jne kbnoaltret |
||
1864 | |||
1865 | mov eax, keymap_alt |
||
1866 | mov ecx, 128 |
||
1867 | call memmove |
||
1868 | ret |
||
1869 | kbnoaltret: |
||
1870 | ; cmp ebx,9 |
||
1871 | sub ecx, 6 |
||
1872 | jnz ngsyse2 |
||
1873 | movzx eax, word [keyboard] |
||
1874 | mov [esp+32], eax |
||
1875 | ret |
||
1876 | |||
1877 | |||
1878 | ngsyse2: |
||
1879 | ; cmp eax,3 |
||
1880 | dec ebx |
||
1881 | jnz ngsyse3 |
||
1882 | movzx eax, [cd_base] |
||
1883 | mov [esp+32], eax |
||
1884 | ret |
||
1885 | ngsyse3: |
||
1886 | ; cmp eax,5 |
||
1887 | sub ebx, 2 |
||
1888 | jnz ngsyse5 |
||
1889 | mov eax, [syslang] |
||
1890 | mov [esp+32], eax |
||
1891 | ret |
||
1892 | ngsyse5: |
||
1893 | ; cmp eax,7 |
||
1894 | sub ebx, 2 |
||
1895 | jnz ngsyse7 |
||
3742 | clevermous | 1896 | xor eax, eax |
2288 | clevermous | 1897 | mov [esp+32], eax |
1898 | ret |
||
1899 | ngsyse7: |
||
1900 | ; cmp eax,8 |
||
1901 | dec ebx |
||
1902 | jnz ngsyse8 |
||
1903 | mov eax, [fat32part] |
||
1904 | mov [esp+32], eax |
||
1905 | ret |
||
1906 | ngsyse8: |
||
1907 | ; cmp eax,9 |
||
1908 | dec ebx |
||
1909 | jnz ngsyse9 |
||
1910 | mov eax, [timer_ticks];[0xfdf0] |
||
1911 | mov [esp+32], eax |
||
1912 | ret |
||
1913 | ngsyse9: |
||
1914 | ; cmp eax,11 |
||
1915 | sub ebx, 2 |
||
1916 | jnz ngsyse11 |
||
1917 | mov eax, [lba_read_enabled] |
||
1918 | mov [esp+32], eax |
||
1919 | ret |
||
1920 | ngsyse11: |
||
1921 | ; cmp eax,12 |
||
1922 | dec ebx |
||
1923 | jnz ngsyse12 |
||
1924 | mov eax, [pci_access_enabled] |
||
1925 | mov [esp+32], eax |
||
1926 | ret |
||
1927 | ngsyse12: |
||
1928 | mov [esp+32], dword 1 |
||
1929 | ret |
||
1930 | |||
1931 | |||
1932 | get_timer_ticks: |
||
1933 | mov eax, [timer_ticks] |
||
1934 | ret |
||
1935 | |||
1936 | iglobal |
||
1937 | align 4 |
||
1938 | mousefn dd msscreen, mswin, msbutton, msset |
||
1939 | dd app_load_cursor |
||
1940 | dd app_set_cursor |
||
1941 | dd app_delete_cursor |
||
1942 | dd msz |
||
1943 | endg |
||
1944 | |||
1945 | readmousepos: |
||
1946 | |||
1947 | ; eax=0 screen relative |
||
1948 | ; eax=1 window relative |
||
1949 | ; eax=2 buttons pressed |
||
1950 | ; eax=3 set mouse pos ; reserved |
||
1951 | ; eax=4 load cursor |
||
1952 | ; eax=5 set cursor |
||
1953 | ; eax=6 delete cursor ; reserved |
||
1954 | ; eax=7 get mouse_z |
||
1955 | |||
1956 | cmp ebx, 7 |
||
1957 | ja msset |
||
1958 | jmp [mousefn+ebx*4] |
||
1959 | msscreen: |
||
1960 | mov eax, [MOUSE_X] |
||
1961 | shl eax, 16 |
||
1962 | mov ax, [MOUSE_Y] |
||
1963 | mov [esp+36-4], eax |
||
1964 | ret |
||
1965 | mswin: |
||
1966 | mov eax, [MOUSE_X] |
||
1967 | shl eax, 16 |
||
1968 | mov ax, [MOUSE_Y] |
||
1969 | mov esi, [TASK_BASE] |
||
1970 | mov bx, word [esi-twdw+WDATA.box.left] |
||
1971 | shl ebx, 16 |
||
1972 | mov bx, word [esi-twdw+WDATA.box.top] |
||
1973 | sub eax, ebx |
||
1974 | |||
1975 | mov edi, [CURRENT_TASK] |
||
1976 | shl edi, 8 |
||
1977 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1978 | rol eax, 16 |
||
1979 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1980 | rol eax, 16 |
||
1981 | mov [esp+36-4], eax |
||
1982 | ret |
||
1983 | msbutton: |
||
1984 | movzx eax, byte [BTN_DOWN] |
||
1985 | mov [esp+36-4], eax |
||
1986 | ret |
||
1987 | msz: |
||
1988 | mov edi, [TASK_COUNT] |
||
1989 | movzx edi, word [WIN_POS + edi*2] |
||
1990 | cmp edi, [CURRENT_TASK] |
||
1991 | jne @f |
||
1992 | mov ax, [MOUSE_SCROLL_H] |
||
1993 | shl eax, 16 |
||
1994 | mov ax, [MOUSE_SCROLL_V] |
||
1995 | mov [esp+36-4], eax |
||
1996 | and [MOUSE_SCROLL_H], word 0 |
||
1997 | and [MOUSE_SCROLL_V], word 0 |
||
1998 | ret |
||
1999 | @@: |
||
2000 | and [esp+36-4], dword 0 |
||
2001 | ; ret |
||
2002 | msset: |
||
2003 | ret |
||
2004 | |||
2005 | app_load_cursor: |
||
2006 | cmp ecx, OS_BASE |
||
2007 | jae msset |
||
2008 | stdcall load_cursor, ecx, edx |
||
2009 | mov [esp+36-4], eax |
||
2010 | ret |
||
2011 | |||
2012 | app_set_cursor: |
||
2013 | stdcall set_cursor, ecx |
||
2014 | mov [esp+36-4], eax |
||
2015 | ret |
||
2016 | |||
2017 | app_delete_cursor: |
||
2018 | stdcall delete_cursor, ecx |
||
2019 | mov [esp+36-4], eax |
||
2020 | ret |
||
2021 | |||
2022 | is_input: |
||
2023 | |||
2024 | push edx |
||
2025 | mov dx, word [midisp] |
||
2026 | in al, dx |
||
2027 | and al, 0x80 |
||
2028 | pop edx |
||
2029 | ret |
||
2030 | |||
2031 | is_output: |
||
2032 | |||
2033 | push edx |
||
2034 | mov dx, word [midisp] |
||
2035 | in al, dx |
||
2036 | and al, 0x40 |
||
2037 | pop edx |
||
2038 | ret |
||
2039 | |||
2040 | |||
2041 | get_mpu_in: |
||
2042 | |||
2043 | push edx |
||
2044 | mov dx, word [mididp] |
||
2045 | in al, dx |
||
2046 | pop edx |
||
2047 | ret |
||
2048 | |||
2049 | |||
2050 | put_mpu_out: |
||
2051 | |||
2052 | push edx |
||
2053 | mov dx, word [mididp] |
||
2054 | out dx, al |
||
2055 | pop edx |
||
2056 | ret |
||
2057 | |||
2058 | |||
2059 | |||
2060 | align 4 |
||
2061 | |||
2062 | sys_midi: |
||
2063 | cmp [mididp], 0 |
||
2064 | jnz sm0 |
||
2065 | mov [esp+36], dword 1 |
||
2066 | ret |
||
2067 | sm0: |
||
2068 | and [esp+36], dword 0 |
||
2069 | dec ebx |
||
2070 | jnz smn1 |
||
2071 | ; call setuart |
||
2072 | su1: |
||
2073 | call is_output |
||
2074 | test al, al |
||
2075 | jnz su1 |
||
2076 | mov dx, word [midisp] |
||
2077 | mov al, 0xff |
||
2078 | out dx, al |
||
2079 | su2: |
||
2080 | mov dx, word [midisp] |
||
2081 | mov al, 0xff |
||
2082 | out dx, al |
||
2083 | call is_input |
||
2084 | test al, al |
||
2085 | jnz su2 |
||
2086 | call get_mpu_in |
||
2087 | cmp al, 0xfe |
||
2088 | jnz su2 |
||
2089 | su3: |
||
2090 | call is_output |
||
2091 | test al, al |
||
2092 | jnz su3 |
||
2093 | mov dx, word [midisp] |
||
2094 | mov al, 0x3f |
||
2095 | out dx, al |
||
2096 | ret |
||
2097 | smn1: |
||
2098 | dec ebx |
||
2099 | jnz smn2 |
||
2100 | sm10: |
||
2101 | call get_mpu_in |
||
2102 | call is_output |
||
2103 | test al, al |
||
2104 | jnz sm10 |
||
2105 | mov al, bl |
||
2106 | call put_mpu_out |
||
2107 | smn2: |
||
2108 | ret |
||
2109 | |||
2110 | detect_devices: |
||
2111 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
2112 | ;include 'detect/commouse.inc' |
||
2113 | ;include 'detect/ps2mouse.inc' |
||
2114 | ;include 'detect/dev_fd.inc' |
||
2115 | ;include 'detect/dev_hdcd.inc' |
||
2116 | ;include 'detect/sear_par.inc' |
||
2117 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
2118 | ret |
||
2119 | |||
2120 | sys_end: |
||
2430 | mario79 | 2121 | ;-------------------------------------- |
2122 | cmp [_display.select_cursor], 0 |
||
2123 | je @f |
||
2124 | ; restore default cursor before killing |
||
2125 | pusha |
||
2126 | mov ecx, [current_slot] |
||
2435 | mario79 | 2127 | call restore_default_cursor_before_killing |
2430 | mario79 | 2128 | popa |
2129 | @@: |
||
2130 | ;-------------------------------------- |
||
3545 | hidnplayr | 2131 | ; kill all sockets this process owns |
2132 | pusha |
||
2133 | mov edx, [TASK_BASE] |
||
2134 | mov edx, [edx+TASKDATA.pid] |
||
2135 | call SOCKET_process_end |
||
2136 | popa |
||
2137 | ;-------------------------------------- |
||
2288 | clevermous | 2138 | mov ecx, [current_slot] |
2139 | mov eax, [ecx+APPDATA.tls_base] |
||
2140 | test eax, eax |
||
2141 | jz @F |
||
2142 | |||
2143 | stdcall user_free, eax |
||
2144 | @@: |
||
2145 | |||
2146 | mov eax, [TASK_BASE] |
||
2147 | mov [eax+TASKDATA.state], 3; terminate this program |
||
3534 | clevermous | 2148 | call wakeup_osloop |
2288 | clevermous | 2149 | |
3597 | Serge | 2150 | .waitterm: ; wait here for termination |
2151 | call change_task |
||
2152 | jmp .waitterm |
||
2435 | mario79 | 2153 | ;------------------------------------------------------------------------------ |
2452 | mario79 | 2154 | align 4 |
2435 | mario79 | 2155 | restore_default_cursor_before_killing: |
2468 | mario79 | 2156 | pushfd |
2157 | cli |
||
2435 | mario79 | 2158 | mov eax, [def_cursor] |
2159 | mov [ecx+APPDATA.cursor], eax |
||
2288 | clevermous | 2160 | |
2435 | mario79 | 2161 | movzx eax, word [MOUSE_Y] |
2162 | movzx ebx, word [MOUSE_X] |
||
2446 | mario79 | 2163 | ; mov ecx, [Screen_Max_X] |
2164 | ; inc ecx |
||
2165 | ; mul ecx |
||
2166 | mov eax, [d_width_calc_area + eax*4] |
||
2167 | |||
2435 | mario79 | 2168 | add eax, [_WinMapAddress] |
2169 | movzx edx, byte [ebx+eax] |
||
2170 | shl edx, 8 |
||
2171 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
||
2452 | mario79 | 2172 | |
2173 | cmp esi, [current_cursor] |
||
2174 | je @f |
||
2175 | |||
2435 | mario79 | 2176 | push esi |
2177 | call [_display.select_cursor] |
||
2178 | mov [current_cursor], esi |
||
2452 | mario79 | 2179 | @@: |
2450 | mario79 | 2180 | mov [redrawmouse_unconditional], 1 |
3534 | clevermous | 2181 | call wakeup_osloop |
2468 | mario79 | 2182 | popfd |
2435 | mario79 | 2183 | ret |
2184 | ;------------------------------------------------------------------------------ |
||
2288 | clevermous | 2185 | iglobal |
2186 | align 4 |
||
2187 | sys_system_table: |
||
2188 | dd sysfn_deactivate ; 1 = deactivate window |
||
2189 | dd sysfn_terminate ; 2 = terminate thread |
||
2190 | dd sysfn_activate ; 3 = activate window |
||
2191 | dd sysfn_getidletime ; 4 = get idle time |
||
2192 | dd sysfn_getcpuclock ; 5 = get cpu clock |
||
2193 | dd sysfn_saveramdisk ; 6 = save ramdisk |
||
2194 | dd sysfn_getactive ; 7 = get active window |
||
2195 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
||
2196 | dd sysfn_shutdown ; 9 = shutdown with parameter |
||
2197 | dd sysfn_minimize ; 10 = minimize window |
||
2198 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
||
2199 | dd sysfn_lastkey ; 12 = get last pressed key |
||
2200 | dd sysfn_getversion ; 13 = get kernel version |
||
2201 | dd sysfn_waitretrace ; 14 = wait retrace |
||
2202 | dd sysfn_centermouse ; 15 = center mouse cursor |
||
2203 | dd sysfn_getfreemem ; 16 = get free memory size |
||
2204 | dd sysfn_getallmem ; 17 = get total memory size |
||
2205 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
||
2206 | ; instead of slot |
||
2207 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
||
2208 | dd sysfn_meminfo ; 20 = get extended memory info |
||
2209 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
||
2210 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
||
2648 | mario79 | 2211 | dd sysfn_min_windows ; 23 = minimize all windows |
2654 | mario79 | 2212 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2288 | clevermous | 2213 | sysfn_num = ($ - sys_system_table)/4 |
2214 | endg |
||
2215 | ;------------------------------------------------------------------------------ |
||
2216 | sys_system: |
||
2217 | dec ebx |
||
2218 | cmp ebx, sysfn_num |
||
2219 | jae @f |
||
2220 | jmp dword [sys_system_table + ebx*4] |
||
2221 | @@: |
||
2222 | ret |
||
2223 | ;------------------------------------------------------------------------------ |
||
2224 | sysfn_shutdown: ; 18.9 = system shutdown |
||
2225 | cmp ecx, 1 |
||
2226 | jl exit_for_anyone |
||
2227 | cmp ecx, 4 |
||
2228 | jg exit_for_anyone |
||
3732 | Serge | 2229 | mov [BOOT_VARS+0x9030], cl |
2288 | clevermous | 2230 | |
2231 | mov eax, [TASK_COUNT] |
||
2232 | mov [SYS_SHUTDOWN], al |
||
2233 | mov [shutdown_processes], eax |
||
3534 | clevermous | 2234 | call wakeup_osloop |
2288 | clevermous | 2235 | and dword [esp+32], 0 |
2236 | exit_for_anyone: |
||
2237 | ret |
||
2238 | uglobal |
||
2239 | shutdown_processes: |
||
2240 | dd 0x0 |
||
2241 | endg |
||
2242 | ;------------------------------------------------------------------------------ |
||
2243 | sysfn_terminate: ; 18.2 = TERMINATE |
||
2472 | mario79 | 2244 | push ecx |
2288 | clevermous | 2245 | cmp ecx, 2 |
2246 | jb noprocessterminate |
||
2247 | mov edx, [TASK_COUNT] |
||
2248 | cmp ecx, edx |
||
2249 | ja noprocessterminate |
||
2250 | mov eax, [TASK_COUNT] |
||
2251 | shl ecx, 5 |
||
2252 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
||
2253 | add ecx, CURRENT_TASK+TASKDATA.state |
||
2254 | cmp byte [ecx], 9 |
||
2255 | jz noprocessterminate |
||
3296 | clevermous | 2256 | push ecx edx |
2257 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
||
2258 | call request_terminate |
||
2259 | pop edx ecx |
||
2260 | test eax, eax |
||
2261 | jz noprocessterminate |
||
2430 | mario79 | 2262 | ;-------------------------------------- |
3545 | hidnplayr | 2263 | ; terminate all network sockets it used |
2264 | pusha |
||
2265 | mov eax, edx |
||
2266 | call SOCKET_process_end |
||
2267 | popa |
||
2268 | ;-------------------------------------- |
||
2430 | mario79 | 2269 | cmp [_display.select_cursor], 0 |
2452 | mario79 | 2270 | je .restore_end |
2430 | mario79 | 2271 | ; restore default cursor before killing |
2272 | pusha |
||
2273 | mov ecx, [esp+32] |
||
2274 | shl ecx, 8 |
||
2435 | mario79 | 2275 | add ecx, SLOT_BASE |
2452 | mario79 | 2276 | mov eax, [def_cursor] |
2277 | cmp [ecx+APPDATA.cursor], eax |
||
2278 | je @f |
||
2435 | mario79 | 2279 | call restore_default_cursor_before_killing |
2452 | mario79 | 2280 | @@: |
2430 | mario79 | 2281 | popa |
2452 | mario79 | 2282 | .restore_end: |
2430 | mario79 | 2283 | ;-------------------------------------- |
2288 | clevermous | 2284 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2285 | mov [ecx], byte 3; clear possible i40's |
||
3534 | clevermous | 2286 | call wakeup_osloop |
2288 | clevermous | 2287 | ;call MEM_Heap_UnLock |
2288 | |||
3534 | clevermous | 2289 | cmp edx, [application_table_owner]; clear app table stat |
2288 | clevermous | 2290 | jne noatsc |
3534 | clevermous | 2291 | call unlock_application_table |
2468 | mario79 | 2292 | noatsc: |
2293 | noprocessterminate: |
||
2472 | mario79 | 2294 | add esp, 4 |
2288 | clevermous | 2295 | ret |
2296 | ;------------------------------------------------------------------------------ |
||
2297 | sysfn_terminate2: |
||
2298 | ;lock application_table_status mutex |
||
2299 | .table_status: |
||
3534 | clevermous | 2300 | call lock_application_table |
2288 | clevermous | 2301 | mov eax, ecx |
2302 | call pid_to_slot |
||
2303 | test eax, eax |
||
2304 | jz .not_found |
||
2305 | mov ecx, eax |
||
2306 | cli |
||
2307 | call sysfn_terminate |
||
3534 | clevermous | 2308 | call unlock_application_table |
2288 | clevermous | 2309 | sti |
2310 | and dword [esp+32], 0 |
||
2311 | ret |
||
2312 | .not_found: |
||
3534 | clevermous | 2313 | call unlock_application_table |
2288 | clevermous | 2314 | or dword [esp+32], -1 |
2315 | ret |
||
2316 | ;------------------------------------------------------------------------------ |
||
2317 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
||
2318 | cmp ecx, 2 |
||
2319 | jb .nowindowdeactivate |
||
2320 | cmp ecx, [TASK_COUNT] |
||
2321 | ja .nowindowdeactivate |
||
2408 | Serge | 2322 | |
2288 | clevermous | 2323 | movzx esi, word [WIN_STACK + ecx*2] |
2324 | cmp esi, 1 |
||
2325 | je .nowindowdeactivate ; already deactive |
||
2326 | |||
2327 | mov edi, ecx |
||
2328 | shl edi, 5 |
||
2329 | add edi, window_data |
||
2330 | movzx esi, word [WIN_STACK + ecx * 2] |
||
2331 | lea esi, [WIN_POS + esi * 2] |
||
2332 | call window._.window_deactivate |
||
2408 | Serge | 2333 | |
2288 | clevermous | 2334 | call syscall_display_settings._.calculate_whole_screen |
2335 | call syscall_display_settings._.redraw_whole_screen |
||
2336 | .nowindowdeactivate: |
||
2337 | ret |
||
3455 | mario79 | 2338 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2339 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2340 | cmp ecx, 2 |
||
2341 | jb .nowindowactivate |
||
2342 | cmp ecx, [TASK_COUNT] |
||
2343 | ja .nowindowactivate |
||
3455 | mario79 | 2344 | ;------------------------------------- |
2345 | @@: |
||
2346 | ; If the window is captured and moved by the user, |
||
2347 | ; then you can't change the position in window stack!!! |
||
2348 | mov al, [mouse.active_sys_window.action] |
||
2349 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
||
2350 | test al, al |
||
2351 | jz @f |
||
2352 | call change_task |
||
2353 | jmp @b |
||
2354 | @@: |
||
2355 | ;------------------------------------- |
||
2288 | clevermous | 2356 | mov [window_minimize], 2; restore window if minimized |
3534 | clevermous | 2357 | call wakeup_osloop |
2288 | clevermous | 2358 | |
2359 | movzx esi, word [WIN_STACK + ecx*2] |
||
2360 | cmp esi, [TASK_COUNT] |
||
2361 | je .nowindowactivate; already active |
||
2362 | |||
2363 | mov edi, ecx |
||
2364 | shl edi, 5 |
||
2365 | add edi, window_data |
||
2366 | movzx esi, word [WIN_STACK + ecx * 2] |
||
2367 | lea esi, [WIN_POS + esi * 2] |
||
2368 | call waredraw |
||
2369 | .nowindowactivate: |
||
2370 | ret |
||
2371 | ;------------------------------------------------------------------------------ |
||
2372 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
||
3534 | clevermous | 2373 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2288 | clevermous | 2374 | mov [esp+32], eax |
2375 | ret |
||
2376 | ;------------------------------------------------------------------------------ |
||
2377 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
||
3481 | Serge | 2378 | mov eax, dword [cpu_freq] |
2288 | clevermous | 2379 | mov [esp+32], eax |
2380 | ret |
||
2381 | ;------------------------------------------------------------------------------ |
||
3481 | Serge | 2382 | get_cpu_freq: |
2383 | mov eax, dword [cpu_freq] |
||
2384 | mov edx, dword [cpu_freq+4] |
||
2385 | ret |
||
2288 | clevermous | 2386 | ; SAVE ramdisk to /hd/1/menuet.img |
2387 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2388 | include 'blkdev/rdsave.inc' |
||
2389 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2390 | ;------------------------------------------------------------------------------ |
||
2391 | align 4 |
||
2392 | sysfn_getactive: ; 18.7 = get active window |
||
2393 | mov eax, [TASK_COUNT] |
||
2394 | movzx eax, word [WIN_POS + eax*2] |
||
2395 | mov [esp+32], eax |
||
2396 | ret |
||
2397 | ;------------------------------------------------------------------------------ |
||
2398 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
||
2399 | ; cmp ecx,1 |
||
2400 | dec ecx |
||
2401 | jnz nogetsoundflag |
||
2402 | movzx eax, byte [sound_flag]; get sound_flag |
||
2403 | mov [esp+32], eax |
||
2404 | ret |
||
2405 | nogetsoundflag: |
||
2406 | ; cmp ecx,2 |
||
2407 | dec ecx |
||
2408 | jnz nosoundflag |
||
2409 | xor byte [sound_flag], 1 |
||
2410 | nosoundflag: |
||
2411 | ret |
||
2412 | ;------------------------------------------------------------------------------ |
||
2413 | sysfn_minimize: ; 18.10 = minimize window |
||
2414 | mov [window_minimize], 1 |
||
3534 | clevermous | 2415 | call wakeup_osloop |
2288 | clevermous | 2416 | ret |
2417 | ;------------------------------------------------------------------------------ |
||
2418 | align 4 |
||
2419 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
||
2420 | ; cmp ecx,1 |
||
2421 | dec ecx |
||
2422 | jnz full_table |
||
2423 | small_table: |
||
2424 | call for_all_tables |
||
2425 | mov ecx, 10 |
||
2426 | cld |
||
2427 | rep movsb |
||
2428 | ret |
||
2429 | for_all_tables: |
||
2430 | mov edi, edx |
||
2431 | mov esi, DRIVE_DATA |
||
2432 | ret |
||
2433 | full_table: |
||
2434 | ; cmp ecx,2 |
||
2435 | dec ecx |
||
2436 | jnz exit_for_anyone |
||
2437 | call for_all_tables |
||
3627 | Serge | 2438 | mov ecx, DRIVE_DATA_SIZE/4 |
2288 | clevermous | 2439 | cld |
2440 | rep movsd |
||
2441 | ret |
||
2442 | ;------------------------------------------------------------------------------ |
||
2443 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
||
2444 | and dword [esp+32], 0 |
||
2445 | ret |
||
2446 | ;------------------------------------------------------------------------------ |
||
2447 | sysfn_getversion: ; 18.13 = get kernel ID and version |
||
2448 | mov edi, ecx |
||
2449 | mov esi, version_inf |
||
2450 | mov ecx, version_end-version_inf |
||
2451 | rep movsb |
||
2452 | ret |
||
2453 | ;------------------------------------------------------------------------------ |
||
2454 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
||
2455 | ;wait retrace functions |
||
2456 | sys_wait_retrace: |
||
2457 | mov edx, 0x3da |
||
2458 | WaitRetrace_loop: |
||
2459 | in al, dx |
||
2460 | test al, 1000b |
||
2461 | jz WaitRetrace_loop |
||
2462 | and [esp+32], dword 0 |
||
2463 | ret |
||
2464 | ;------------------------------------------------------------------------------ |
||
2465 | align 4 |
||
2466 | sysfn_centermouse: ; 18.15 = mouse centered |
||
2467 | ; removed here by |
||
2468 | ; call mouse_centered |
||
2469 | ;* mouse centered - start code- Mario79 |
||
2470 | ;mouse_centered: |
||
2471 | ; push eax |
||
2472 | mov eax, [Screen_Max_X] |
||
2473 | shr eax, 1 |
||
2474 | mov [MOUSE_X], ax |
||
2475 | mov eax, [Screen_Max_Y] |
||
2476 | shr eax, 1 |
||
2477 | mov [MOUSE_Y], ax |
||
3534 | clevermous | 2478 | call wakeup_osloop |
2288 | clevermous | 2479 | ; ret |
2480 | ;* mouse centered - end code- Mario79 |
||
2481 | xor eax, eax |
||
2482 | and [esp+32], eax |
||
2483 | ; pop eax |
||
2484 | ret |
||
2485 | ;------------------------------------------------------------------------------ |
||
2486 | align 4 |
||
2487 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
||
2488 | test ecx, ecx; get mouse speed factor |
||
2489 | jnz .set_mouse_acceleration |
||
2490 | xor eax, eax |
||
2491 | mov ax, [mouse_speed_factor] |
||
2492 | mov [esp+32], eax |
||
2493 | ret |
||
2494 | .set_mouse_acceleration: |
||
2495 | ; cmp ecx,1 ; set mouse speed factor |
||
2496 | dec ecx |
||
2497 | jnz .get_mouse_delay |
||
2498 | mov [mouse_speed_factor], dx |
||
2499 | ret |
||
2500 | .get_mouse_delay: |
||
2501 | ; cmp ecx,2 ; get mouse delay |
||
2502 | dec ecx |
||
2503 | jnz .set_mouse_delay |
||
2504 | mov eax, [mouse_delay] |
||
2505 | mov [esp+32], eax |
||
2506 | ret |
||
2507 | .set_mouse_delay: |
||
2508 | ; cmp ecx,3 ; set mouse delay |
||
2509 | dec ecx |
||
2510 | jnz .set_pointer_position |
||
2511 | mov [mouse_delay], edx |
||
2512 | ret |
||
2513 | .set_pointer_position: |
||
2514 | ; cmp ecx,4 ; set mouse pointer position |
||
2515 | dec ecx |
||
2516 | jnz .set_mouse_button |
||
2517 | cmp dx, word[Screen_Max_Y] |
||
2518 | ja .end |
||
2519 | rol edx, 16 |
||
2520 | cmp dx, word[Screen_Max_X] |
||
2521 | ja .end |
||
2522 | mov [MOUSE_X], edx |
||
3534 | clevermous | 2523 | call wakeup_osloop |
2288 | clevermous | 2524 | ret |
2525 | .set_mouse_button: |
||
2526 | ; cmp ecx,5 ; set mouse button features |
||
2527 | dec ecx |
||
2528 | jnz .end |
||
2529 | mov [BTN_DOWN], dl |
||
2530 | mov [mouse_active], 1 |
||
3534 | clevermous | 2531 | call wakeup_osloop |
2288 | clevermous | 2532 | .end: |
2533 | ret |
||
2534 | ;------------------------------------------------------------------------------ |
||
2535 | sysfn_getfreemem: |
||
2536 | mov eax, [pg_data.pages_free] |
||
2537 | shl eax, 2 |
||
2538 | mov [esp+32], eax |
||
2539 | ret |
||
2648 | mario79 | 2540 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2541 | sysfn_getallmem: |
2542 | mov eax, [MEM_AMOUNT] |
||
2543 | shr eax, 10 |
||
2544 | mov [esp+32], eax |
||
2545 | ret |
||
2648 | mario79 | 2546 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2547 | sysfn_pid_to_slot: |
2548 | mov eax, ecx |
||
2549 | call pid_to_slot |
||
2550 | mov [esp+32], eax |
||
2551 | ret |
||
2648 | mario79 | 2552 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2553 | sysfn_min_rest_window: |
2554 | pushad |
||
2555 | mov eax, edx ; ebx - operating |
||
2556 | shr ecx, 1 |
||
2557 | jnc @f |
||
2558 | call pid_to_slot |
||
2559 | @@: |
||
2560 | or eax, eax ; eax - number of slot |
||
2561 | jz .error |
||
2562 | cmp eax, 255 ; varify maximal slot number |
||
2563 | ja .error |
||
2564 | movzx eax, word [WIN_STACK + eax*2] |
||
2565 | shr ecx, 1 |
||
2566 | jc .restore |
||
2567 | ; .minimize: |
||
2568 | call minimize_window |
||
2569 | jmp .exit |
||
2570 | .restore: |
||
2571 | call restore_minimized_window |
||
2572 | .exit: |
||
2573 | popad |
||
2574 | xor eax, eax |
||
2575 | mov [esp+32], eax |
||
2576 | ret |
||
2577 | .error: |
||
2578 | popad |
||
2579 | xor eax, eax |
||
2580 | dec eax |
||
2581 | mov [esp+32], eax |
||
2582 | ret |
||
2648 | mario79 | 2583 | ;------------------------------------------------------------------------------ |
2584 | sysfn_min_windows: |
||
2585 | call minimize_all_window |
||
2586 | mov [esp+32], eax |
||
2587 | call change_task |
||
2588 | ret |
||
2589 | ;------------------------------------------------------------------------------ |
||
2654 | mario79 | 2590 | sysfn_set_screen_sizes: |
2591 | cmp [SCR_MODE], word 0x13 |
||
2592 | jbe .exit |
||
2593 | |||
2594 | cmp [_display.select_cursor], select_cursor |
||
2595 | jne .exit |
||
2596 | |||
2597 | cmp ecx, [display_width_standard] |
||
2598 | ja .exit |
||
2599 | |||
2600 | cmp edx, [display_height_standard] |
||
2601 | ja .exit |
||
2602 | |||
2603 | pushfd |
||
2604 | cli |
||
2605 | mov eax, ecx |
||
3606 | Serge | 2606 | mov ecx, [_display.pitch] |
2654 | mario79 | 2607 | mov [_display.width], eax |
2608 | dec eax |
||
2609 | mov [_display.height], edx |
||
2610 | dec edx |
||
2611 | ; eax - new Screen_Max_X |
||
2612 | ; edx - new Screen_Max_Y |
||
2613 | mov [do_not_touch_winmap], 1 |
||
2614 | call set_screen |
||
2615 | mov [do_not_touch_winmap], 0 |
||
2616 | popfd |
||
2617 | call change_task |
||
2618 | .exit: |
||
2619 | ret |
||
2620 | ;------------------------------------------------------------------------------ |
||
2288 | clevermous | 2621 | uglobal |
2622 | screen_workarea RECT |
||
2654 | mario79 | 2623 | display_width_standard dd 0 |
2624 | display_height_standard dd 0 |
||
2625 | do_not_touch_winmap db 0 |
||
2288 | clevermous | 2626 | window_minimize db 0 |
2627 | sound_flag db 0 |
||
2654 | mario79 | 2628 | |
2288 | clevermous | 2629 | endg |
2630 | |||
2631 | UID_NONE=0 |
||
2632 | UID_MENUETOS=1 ;official |
||
2633 | UID_KOLIBRI=2 ;russian |
||
2634 | |||
2635 | iglobal |
||
2636 | version_inf: |
||
3454 | mario79 | 2637 | db 0,7,7,0 ; version 0.7.7.0 |
2638 | db 0 |
||
2639 | .rev dd __REV__ |
||
2288 | clevermous | 2640 | version_end: |
2641 | endg |
||
2515 | mario79 | 2642 | ;------------------------------------------------------------------------------ |
2643 | align 4 |
||
2288 | clevermous | 2644 | sys_cachetodiskette: |
2645 | cmp ebx, 1 |
||
2646 | jne .no_floppy_a_save |
||
2647 | mov [flp_number], 1 |
||
2648 | jmp .save_image_on_floppy |
||
2515 | mario79 | 2649 | ;-------------------------------------- |
2650 | align 4 |
||
2288 | clevermous | 2651 | .no_floppy_a_save: |
2652 | cmp ebx, 2 |
||
2653 | jne .no_floppy_b_save |
||
2654 | mov [flp_number], 2 |
||
2515 | mario79 | 2655 | ;-------------------------------------- |
2656 | align 4 |
||
2288 | clevermous | 2657 | .save_image_on_floppy: |
2658 | call save_image |
||
2659 | mov [esp + 32], dword 0 |
||
2660 | cmp [FDC_Status], 0 |
||
2661 | je .yes_floppy_save |
||
2515 | mario79 | 2662 | ;-------------------------------------- |
2663 | align 4 |
||
2288 | clevermous | 2664 | .no_floppy_b_save: |
2665 | mov [esp + 32], dword 1 |
||
2515 | mario79 | 2666 | ;-------------------------------------- |
2667 | align 4 |
||
2288 | clevermous | 2668 | .yes_floppy_save: |
2669 | ret |
||
2515 | mario79 | 2670 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2671 | uglobal |
2672 | ; bgrchanged dd 0x0 |
||
2673 | align 4 |
||
2674 | bgrlockpid dd 0 |
||
2675 | bgrlock db 0 |
||
2676 | endg |
||
2515 | mario79 | 2677 | ;------------------------------------------------------------------------------ |
2678 | align 4 |
||
2288 | clevermous | 2679 | sys_background: |
2680 | cmp ebx, 1 ; BACKGROUND SIZE |
||
2681 | jnz nosb1 |
||
2682 | test ecx, ecx |
||
2683 | jz sbgrr |
||
2547 | mario79 | 2684 | |
2288 | clevermous | 2685 | test edx, edx |
2686 | jz sbgrr |
||
2515 | mario79 | 2687 | ;-------------------------------------- |
2688 | align 4 |
||
2288 | clevermous | 2689 | @@: |
2690 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
||
2691 | bts dword [bgrlock], 0 |
||
2692 | jnc @f |
||
2693 | call change_task |
||
2694 | jmp @b |
||
2515 | mario79 | 2695 | ;-------------------------------------- |
2696 | align 4 |
||
2288 | clevermous | 2697 | @@: |
2698 | mov [BgrDataWidth], ecx |
||
2699 | mov [BgrDataHeight], edx |
||
2700 | ; mov [bgrchanged],1 |
||
2701 | |||
2702 | pushad |
||
2703 | ; return memory for old background |
||
2704 | mov eax, [img_background] |
||
2705 | cmp eax, static_background_data |
||
2706 | jz @f |
||
2707 | stdcall kernel_free, eax |
||
2515 | mario79 | 2708 | ;-------------------------------------- |
2709 | align 4 |
||
2288 | clevermous | 2710 | @@: |
2711 | ; calculate RAW size |
||
2712 | xor eax, eax |
||
2713 | inc eax |
||
2714 | cmp [BgrDataWidth], eax |
||
2715 | jae @f |
||
2716 | mov [BgrDataWidth], eax |
||
2515 | mario79 | 2717 | ;-------------------------------------- |
2718 | align 4 |
||
2288 | clevermous | 2719 | @@: |
2720 | cmp [BgrDataHeight], eax |
||
2721 | jae @f |
||
2722 | mov [BgrDataHeight], eax |
||
2515 | mario79 | 2723 | ;-------------------------------------- |
2724 | align 4 |
||
2288 | clevermous | 2725 | @@: |
2726 | mov eax, [BgrDataWidth] |
||
2727 | imul eax, [BgrDataHeight] |
||
2728 | lea eax, [eax*3] |
||
2464 | mario79 | 2729 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2730 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
||
2731 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
||
2732 | shr eax, 12 |
||
2733 | inc eax |
||
2734 | shl eax, 12 |
||
2288 | clevermous | 2735 | mov [mem_BACKGROUND], eax |
2736 | ; get memory for new background |
||
2737 | stdcall kernel_alloc, eax |
||
2738 | test eax, eax |
||
2739 | jz .memfailed |
||
2740 | mov [img_background], eax |
||
2741 | jmp .exit |
||
2515 | mario79 | 2742 | ;-------------------------------------- |
2743 | align 4 |
||
2288 | clevermous | 2744 | .memfailed: |
2745 | ; revert to static monotone data |
||
2746 | mov [img_background], static_background_data |
||
2747 | xor eax, eax |
||
2748 | inc eax |
||
2749 | mov [BgrDataWidth], eax |
||
2750 | mov [BgrDataHeight], eax |
||
2751 | mov [mem_BACKGROUND], 4 |
||
2515 | mario79 | 2752 | ;-------------------------------------- |
2753 | align 4 |
||
2288 | clevermous | 2754 | .exit: |
2755 | popad |
||
2756 | mov [bgrlock], 0 |
||
2515 | mario79 | 2757 | ;-------------------------------------- |
2758 | align 4 |
||
2759 | sbgrr: |
||
2288 | clevermous | 2760 | ret |
2515 | mario79 | 2761 | ;------------------------------------------------------------------------------ |
2762 | align 4 |
||
2288 | clevermous | 2763 | nosb1: |
2764 | cmp ebx, 2 ; SET PIXEL |
||
2765 | jnz nosb2 |
||
2766 | |||
2767 | mov eax, [img_background] |
||
2768 | test ecx, ecx |
||
2769 | jz @f |
||
2770 | cmp eax, static_background_data |
||
2771 | jz .ret |
||
2515 | mario79 | 2772 | ;-------------------------------------- |
2773 | align 4 |
||
2288 | clevermous | 2774 | @@: |
2775 | mov ebx, [mem_BACKGROUND] |
||
2776 | add ebx, 4095 |
||
2777 | and ebx, -4096 |
||
2778 | sub ebx, 4 |
||
2779 | cmp ecx, ebx |
||
2780 | ja .ret |
||
2781 | |||
2782 | mov ebx, [eax+ecx] |
||
2783 | and ebx, 0xFF000000;255*256*256*256 |
||
2784 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
||
2785 | add edx, ebx |
||
2786 | mov [eax+ecx], edx |
||
2515 | mario79 | 2787 | ;-------------------------------------- |
2788 | align 4 |
||
2288 | clevermous | 2789 | .ret: |
2790 | ret |
||
2515 | mario79 | 2791 | ;------------------------------------------------------------------------------ |
2792 | align 4 |
||
2288 | clevermous | 2793 | nosb2: |
2794 | cmp ebx, 3 ; DRAW BACKGROUND |
||
2795 | jnz nosb3 |
||
2515 | mario79 | 2796 | ;-------------------------------------- |
2797 | align 4 |
||
2288 | clevermous | 2798 | draw_background_temp: |
2799 | mov [background_defined], 1 |
||
2800 | call force_redraw_background |
||
2515 | mario79 | 2801 | ;-------------------------------------- |
2802 | align 4 |
||
2803 | nosb31: |
||
2288 | clevermous | 2804 | ret |
2515 | mario79 | 2805 | ;------------------------------------------------------------------------------ |
2806 | align 4 |
||
2807 | nosb3: |
||
2288 | clevermous | 2808 | cmp ebx, 4 ; TILED / STRETCHED |
2809 | jnz nosb4 |
||
2810 | cmp ecx, [BgrDrawMode] |
||
2811 | je nosb41 |
||
2812 | mov [BgrDrawMode], ecx |
||
2515 | mario79 | 2813 | ;-------------------------------------- |
2814 | align 4 |
||
2815 | nosb41: |
||
2288 | clevermous | 2816 | ret |
2515 | mario79 | 2817 | ;------------------------------------------------------------------------------ |
2818 | align 4 |
||
2819 | nosb4: |
||
2288 | clevermous | 2820 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2821 | jnz nosb5 |
||
2822 | cmp [img_background], static_background_data |
||
2823 | jnz @f |
||
2824 | test edx, edx |
||
2825 | jnz .fin |
||
2826 | cmp esi, 4 |
||
2827 | ja .fin |
||
2515 | mario79 | 2828 | ;-------------------------------------- |
2829 | align 4 |
||
2830 | @@: |
||
2288 | clevermous | 2831 | ; bughere |
2832 | mov eax, ecx |
||
2833 | mov ebx, edx |
||
2834 | add ebx, [img_background];IMG_BACKGROUND |
||
2835 | mov ecx, esi |
||
2836 | call memmove |
||
2515 | mario79 | 2837 | ;-------------------------------------- |
2838 | align 4 |
||
2839 | .fin: |
||
2288 | clevermous | 2840 | ret |
2515 | mario79 | 2841 | ;------------------------------------------------------------------------------ |
2842 | align 4 |
||
2843 | nosb5: |
||
2288 | clevermous | 2844 | cmp ebx, 6 |
2845 | jnz nosb6 |
||
2515 | mario79 | 2846 | ;-------------------------------------- |
2847 | align 4 |
||
2288 | clevermous | 2848 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2849 | @@: |
||
2850 | bts dword [bgrlock], 0 |
||
2851 | jnc @f |
||
2852 | call change_task |
||
2853 | jmp @b |
||
2515 | mario79 | 2854 | ;-------------------------------------- |
2855 | align 4 |
||
2288 | clevermous | 2856 | @@: |
2857 | mov eax, [CURRENT_TASK] |
||
2858 | mov [bgrlockpid], eax |
||
2859 | cmp [img_background], static_background_data |
||
2860 | jz .nomem |
||
2861 | stdcall user_alloc, [mem_BACKGROUND] |
||
2862 | mov [esp+32], eax |
||
2863 | test eax, eax |
||
2864 | jz .nomem |
||
2865 | mov ebx, eax |
||
2866 | shr ebx, 12 |
||
2867 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
||
2868 | mov esi, [img_background] |
||
2869 | shr esi, 12 |
||
2870 | mov ecx, [mem_BACKGROUND] |
||
2871 | add ecx, 0xFFF |
||
2872 | shr ecx, 12 |
||
2515 | mario79 | 2873 | ;-------------------------------------- |
2874 | align 4 |
||
2288 | clevermous | 2875 | .z: |
2876 | mov eax, [page_tabs+ebx*4] |
||
2877 | test al, 1 |
||
2878 | jz @f |
||
2879 | call free_page |
||
2515 | mario79 | 2880 | ;-------------------------------------- |
2881 | align 4 |
||
2288 | clevermous | 2882 | @@: |
2883 | mov eax, [page_tabs+esi*4] |
||
2884 | or al, PG_UW |
||
2885 | mov [page_tabs+ebx*4], eax |
||
2886 | mov eax, ebx |
||
2887 | shl eax, 12 |
||
2888 | invlpg [eax] |
||
2889 | inc ebx |
||
2890 | inc esi |
||
2891 | loop .z |
||
2892 | ret |
||
2515 | mario79 | 2893 | ;-------------------------------------- |
2894 | align 4 |
||
2288 | clevermous | 2895 | .nomem: |
2896 | and [bgrlockpid], 0 |
||
2897 | mov [bgrlock], 0 |
||
2515 | mario79 | 2898 | ;------------------------------------------------------------------------------ |
2899 | align 4 |
||
2288 | clevermous | 2900 | nosb6: |
2901 | cmp ebx, 7 |
||
2902 | jnz nosb7 |
||
2903 | cmp [bgrlock], 0 |
||
2904 | jz .err |
||
2905 | mov eax, [CURRENT_TASK] |
||
2906 | cmp [bgrlockpid], eax |
||
2907 | jnz .err |
||
2908 | mov eax, ecx |
||
2909 | mov ebx, ecx |
||
2910 | shr eax, 12 |
||
2911 | mov ecx, [page_tabs+(eax-1)*4] |
||
2912 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
||
2913 | jz .err |
||
2914 | jnp .err |
||
2915 | push eax |
||
2916 | shr ecx, 12 |
||
2917 | dec ecx |
||
2515 | mario79 | 2918 | ;-------------------------------------- |
2919 | align 4 |
||
2288 | clevermous | 2920 | @@: |
2921 | and dword [page_tabs+eax*4], 0 |
||
2922 | mov edx, eax |
||
2923 | shl edx, 12 |
||
2924 | push eax |
||
2925 | invlpg [edx] |
||
2926 | pop eax |
||
2927 | inc eax |
||
2928 | loop @b |
||
2929 | pop eax |
||
2930 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
||
2931 | stdcall user_free, ebx |
||
2932 | mov [esp+32], eax |
||
2933 | and [bgrlockpid], 0 |
||
2934 | mov [bgrlock], 0 |
||
2935 | ret |
||
2515 | mario79 | 2936 | ;-------------------------------------- |
2937 | align 4 |
||
2288 | clevermous | 2938 | .err: |
2939 | and dword [esp+32], 0 |
||
2940 | ret |
||
2515 | mario79 | 2941 | ;------------------------------------------------------------------------------ |
2942 | align 4 |
||
2288 | clevermous | 2943 | nosb7: |
2515 | mario79 | 2944 | cmp ebx, 8 |
2945 | jnz nosb8 |
||
2537 | mario79 | 2946 | |
3536 | clevermous | 2947 | mov ecx, [current_slot] |
2948 | xor eax, eax |
||
2949 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
||
2515 | mario79 | 2950 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
3536 | clevermous | 2951 | xor eax, eax |
2952 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
||
2515 | mario79 | 2953 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2288 | clevermous | 2954 | ret |
2515 | mario79 | 2955 | ;------------------------------------------------------------------------------ |
2956 | align 4 |
||
2957 | nosb8: |
||
2547 | mario79 | 2958 | cmp ebx, 9 |
2959 | jnz nosb9 |
||
2960 | ; ecx = [left]*65536 + [right] |
||
2961 | ; edx = [top]*65536 + [bottom] |
||
2962 | mov eax, [Screen_Max_X] |
||
2963 | mov ebx, [Screen_Max_Y] |
||
2964 | ; check [right] |
||
2965 | cmp cx, ax |
||
2966 | ja .exit |
||
2967 | ; check [left] |
||
2968 | ror ecx, 16 |
||
2969 | cmp cx, ax |
||
2970 | ja .exit |
||
2971 | ; check [bottom] |
||
2972 | cmp dx, bx |
||
2973 | ja .exit |
||
2974 | ; check [top] |
||
2975 | ror edx, 16 |
||
2976 | cmp dx, bx |
||
2977 | ja .exit |
||
2978 | |||
2979 | movzx eax, cx ; [left] |
||
2980 | movzx ebx, dx ; [top] |
||
2981 | |||
2982 | shr ecx, 16 ; [right] |
||
2983 | shr edx, 16 ; [bottom] |
||
2984 | |||
2985 | mov [background_defined], 1 |
||
2986 | |||
2987 | mov [draw_data+32 + RECT.left], eax |
||
2988 | mov [draw_data+32 + RECT.top], ebx |
||
2989 | |||
2990 | mov [draw_data+32 + RECT.right], ecx |
||
2991 | mov [draw_data+32 + RECT.bottom], edx |
||
2992 | |||
2993 | inc byte[REDRAW_BACKGROUND] |
||
3534 | clevermous | 2994 | call wakeup_osloop |
2547 | mario79 | 2995 | ;-------------------------------------- |
2996 | align 4 |
||
2997 | .exit: |
||
2515 | mario79 | 2998 | ret |
2999 | ;------------------------------------------------------------------------------ |
||
3000 | align 4 |
||
2547 | mario79 | 3001 | nosb9: |
3002 | ret |
||
3003 | ;------------------------------------------------------------------------------ |
||
3004 | align 4 |
||
2537 | mario79 | 3005 | uglobal |
3006 | BG_Rect_X_left_right dd 0x0 |
||
3007 | BG_Rect_Y_top_bottom dd 0x0 |
||
3008 | endg |
||
3009 | ;------------------------------------------------------------------------------ |
||
3010 | align 4 |
||
2288 | clevermous | 3011 | force_redraw_background: |
3012 | and [draw_data+32 + RECT.left], 0 |
||
3013 | and [draw_data+32 + RECT.top], 0 |
||
3014 | push eax ebx |
||
3015 | mov eax, [Screen_Max_X] |
||
3016 | mov ebx, [Screen_Max_Y] |
||
3017 | mov [draw_data+32 + RECT.right], eax |
||
3018 | mov [draw_data+32 + RECT.bottom], ebx |
||
3019 | pop ebx eax |
||
3020 | inc byte[REDRAW_BACKGROUND] |
||
3534 | clevermous | 3021 | call wakeup_osloop |
2288 | clevermous | 3022 | ret |
2515 | mario79 | 3023 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 3024 | align 4 |
3025 | sys_getbackground: |
||
3026 | ; cmp eax,1 ; SIZE |
||
3027 | dec ebx |
||
3028 | jnz nogb1 |
||
3029 | mov eax, [BgrDataWidth] |
||
3030 | shl eax, 16 |
||
3588 | Serge | 3031 | mov ax, word [BgrDataHeight] |
2288 | clevermous | 3032 | mov [esp+32], eax |
3033 | ret |
||
2515 | mario79 | 3034 | ;------------------------------------------------------------------------------ |
3035 | align 4 |
||
2288 | clevermous | 3036 | nogb1: |
3037 | ; cmp eax,2 ; PIXEL |
||
3038 | dec ebx |
||
3039 | jnz nogb2 |
||
3040 | |||
3041 | mov eax, [img_background] |
||
3042 | test ecx, ecx |
||
3043 | jz @f |
||
3044 | cmp eax, static_background_data |
||
3045 | jz .ret |
||
2515 | mario79 | 3046 | ;-------------------------------------- |
3047 | align 4 |
||
2288 | clevermous | 3048 | @@: |
3049 | mov ebx, [mem_BACKGROUND] |
||
3050 | add ebx, 4095 |
||
3051 | and ebx, -4096 |
||
3052 | sub ebx, 4 |
||
3053 | cmp ecx, ebx |
||
3054 | ja .ret |
||
3055 | |||
3056 | mov eax, [ecx+eax] |
||
3057 | |||
3058 | and eax, 0xFFFFFF |
||
3059 | mov [esp+32], eax |
||
2515 | mario79 | 3060 | ;-------------------------------------- |
3061 | align 4 |
||
2288 | clevermous | 3062 | .ret: |
3063 | ret |
||
2515 | mario79 | 3064 | ;------------------------------------------------------------------------------ |
3065 | align 4 |
||
3066 | nogb2: |
||
2288 | clevermous | 3067 | |
3068 | ; cmp eax,4 ; TILED / STRETCHED |
||
3069 | dec ebx |
||
3070 | dec ebx |
||
3071 | jnz nogb4 |
||
3072 | mov eax, [BgrDrawMode] |
||
2515 | mario79 | 3073 | ;-------------------------------------- |
3074 | align 4 |
||
3075 | nogb4: |
||
2288 | clevermous | 3076 | mov [esp+32], eax |
3077 | ret |
||
2515 | mario79 | 3078 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 3079 | align 4 |
3080 | sys_getkey: |
||
3081 | mov [esp + 32], dword 1 |
||
3082 | ; test main buffer |
||
3083 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
||
3084 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
3085 | mov edx, [TASK_COUNT] |
||
3086 | cmp ecx, edx |
||
3087 | jne .finish |
||
3088 | cmp [KEY_COUNT], byte 0 |
||
3089 | je .finish |
||
3090 | movzx eax, byte [KEY_BUFF] |
||
3091 | shl eax, 8 |
||
3092 | push eax |
||
3093 | dec byte [KEY_COUNT] |
||
3094 | and byte [KEY_COUNT], 127 |
||
3095 | movzx ecx, byte [KEY_COUNT] |
||
3096 | add ecx, 2 |
||
3097 | mov eax, KEY_BUFF + 1 |
||
3098 | mov ebx, KEY_BUFF |
||
3099 | call memmove |
||
3100 | pop eax |
||
2515 | mario79 | 3101 | ;-------------------------------------- |
3102 | align 4 |
||
2288 | clevermous | 3103 | .ret_eax: |
3104 | mov [esp + 32], eax |
||
3105 | ret |
||
2515 | mario79 | 3106 | ;-------------------------------------- |
3107 | align 4 |
||
2288 | clevermous | 3108 | .finish: |
3109 | ; test hotkeys buffer |
||
3110 | mov ecx, hotkey_buffer |
||
2515 | mario79 | 3111 | ;-------------------------------------- |
3112 | align 4 |
||
2288 | clevermous | 3113 | @@: |
3114 | cmp [ecx], ebx |
||
3115 | jz .found |
||
3116 | add ecx, 8 |
||
3117 | cmp ecx, hotkey_buffer + 120 * 8 |
||
3118 | jb @b |
||
3119 | ret |
||
2515 | mario79 | 3120 | ;-------------------------------------- |
3121 | align 4 |
||
2288 | clevermous | 3122 | .found: |
3123 | mov ax, [ecx + 6] |
||
3124 | shl eax, 16 |
||
3125 | mov ah, [ecx + 4] |
||
3126 | mov al, 2 |
||
3127 | and dword [ecx + 4], 0 |
||
3128 | and dword [ecx], 0 |
||
3129 | jmp .ret_eax |
||
2515 | mario79 | 3130 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 3131 | align 4 |
3132 | sys_getbutton: |
||
3133 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
||
3134 | mov [esp + 32], dword 1 |
||
3135 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
3136 | mov edx, [TASK_COUNT] ; less than 256 processes |
||
3137 | cmp ecx, edx |
||
3138 | jne .exit |
||
3139 | movzx eax, byte [BTN_COUNT] |
||
3140 | test eax, eax |
||
3141 | jz .exit |
||
3142 | mov eax, [BTN_BUFF] |
||
3143 | and al, 0xFE ; delete left button bit |
||
3144 | mov [BTN_COUNT], byte 0 |
||
3145 | mov [esp + 32], eax |
||
2515 | mario79 | 3146 | ;-------------------------------------- |
3147 | align 4 |
||
2288 | clevermous | 3148 | .exit: |
3149 | ret |
||
2515 | mario79 | 3150 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 3151 | align 4 |
3152 | sys_cpuusage: |
||
3153 | |||
3154 | ; RETURN: |
||
3155 | ; |
||
3156 | ; +00 dword process cpu usage |
||
3157 | ; +04 word position in windowing stack |
||
3158 | ; +06 word windowing stack value at current position (cpu nro) |
||
3159 | ; +10 12 bytes name |
||
3160 | ; +22 dword start in mem |
||
3161 | ; +26 dword used mem |
||
3162 | ; +30 dword PID , process idenfification number |
||
3163 | ; |
||
3164 | |||
3165 | cmp ecx, -1 ; who am I ? |
||
3166 | jne .no_who_am_i |
||
3167 | mov ecx, [CURRENT_TASK] |
||
3168 | .no_who_am_i: |
||
3169 | cmp ecx, max_processes |
||
3170 | ja .nofillbuf |
||
3171 | |||
3172 | ; +4: word: position of the window of thread in the window stack |
||
3173 | mov ax, [WIN_STACK + ecx * 2] |
||
3174 | mov [ebx+4], ax |
||
3175 | ; +6: word: number of the thread slot, which window has in the window stack |
||
3176 | ; position ecx (has no relation to the specific thread) |
||
3177 | mov ax, [WIN_POS + ecx * 2] |
||
3178 | mov [ebx+6], ax |
||
3179 | |||
3180 | shl ecx, 5 |
||
3181 | |||
3182 | ; +0: dword: memory usage |
||
3183 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
||
3184 | mov [ebx], eax |
||
3185 | ; +10: 11 bytes: name of the process |
||
3186 | push ecx |
||
3187 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
||
3188 | add ebx, 10 |
||
3189 | mov ecx, 11 |
||
3190 | call memmove |
||
3191 | pop ecx |
||
3192 | |||
3193 | ; +22: address of the process in memory |
||
3194 | ; +26: size of used memory - 1 |
||
3195 | push edi |
||
3196 | lea edi, [ebx+12] |
||
3197 | xor eax, eax |
||
3198 | mov edx, 0x100000*16 |
||
3199 | cmp ecx, 1 shl 5 |
||
3200 | je .os_mem |
||
3201 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
||
3202 | mov eax, std_application_base_address |
||
3203 | .os_mem: |
||
3204 | stosd |
||
3205 | lea eax, [edx-1] |
||
3206 | stosd |
||
3207 | |||
3208 | ; +30: PID/TID |
||
3209 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
||
3210 | stosd |
||
3211 | |||
3212 | ; window position and size |
||
3213 | push esi |
||
3214 | lea esi, [ecx + window_data + WDATA.box] |
||
3215 | movsd |
||
3216 | movsd |
||
3217 | movsd |
||
3218 | movsd |
||
3219 | |||
3220 | ; Process state (+50) |
||
3221 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
||
3222 | stosd |
||
3223 | |||
3224 | ; Window client area box |
||
3225 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
||
3226 | movsd |
||
3227 | movsd |
||
3228 | movsd |
||
3229 | movsd |
||
3230 | |||
3231 | ; Window state |
||
3232 | mov al, [ecx+window_data+WDATA.fl_wstate] |
||
3233 | stosb |
||
3234 | |||
3235 | ; Event mask (+71) |
||
3236 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
||
3237 | stosd |
||
3238 | |||
3239 | pop esi |
||
3240 | pop edi |
||
3241 | |||
3242 | .nofillbuf: |
||
3243 | ; return number of processes |
||
3244 | |||
3245 | mov eax, [TASK_COUNT] |
||
3246 | mov [esp+32], eax |
||
3247 | ret |
||
3248 | |||
3249 | align 4 |
||
3250 | sys_clock: |
||
3251 | cli |
||
3252 | ; Mikhail Lisovin xx Jan 2005 |
||
3253 | @@: |
||
3254 | mov al, 10 |
||
3255 | out 0x70, al |
||
3256 | in al, 0x71 |
||
3257 | test al, al |
||
3258 | jns @f |
||
3259 | mov esi, 1 |
||
3260 | call delay_ms |
||
3261 | jmp @b |
||
3262 | @@: |
||
3263 | ; end Lisovin's fix |
||
3264 | |||
3265 | xor al, al ; seconds |
||
3266 | out 0x70, al |
||
3267 | in al, 0x71 |
||
3268 | movzx ecx, al |
||
3269 | mov al, 02 ; minutes |
||
3270 | shl ecx, 16 |
||
3271 | out 0x70, al |
||
3272 | in al, 0x71 |
||
3273 | movzx edx, al |
||
3274 | mov al, 04 ; hours |
||
3275 | shl edx, 8 |
||
3276 | out 0x70, al |
||
3277 | in al, 0x71 |
||
3278 | add ecx, edx |
||
3279 | movzx edx, al |
||
3280 | add ecx, edx |
||
3281 | sti |
||
3282 | mov [esp + 32], ecx |
||
3283 | ret |
||
3284 | |||
3285 | |||
3286 | align 4 |
||
3287 | |||
3288 | sys_date: |
||
3289 | |||
3290 | cli |
||
3291 | @@: |
||
3292 | mov al, 10 |
||
3293 | out 0x70, al |
||
3294 | in al, 0x71 |
||
3295 | test al, al |
||
3296 | jns @f |
||
3297 | mov esi, 1 |
||
3298 | call delay_ms |
||
3299 | jmp @b |
||
3300 | @@: |
||
3301 | |||
3302 | mov ch, 0 |
||
3303 | mov al, 7 ; date |
||
3304 | out 0x70, al |
||
3305 | in al, 0x71 |
||
3306 | mov cl, al |
||
3307 | mov al, 8 ; month |
||
3308 | shl ecx, 16 |
||
3309 | out 0x70, al |
||
3310 | in al, 0x71 |
||
3311 | mov ch, al |
||
3312 | mov al, 9 ; year |
||
3313 | out 0x70, al |
||
3314 | in al, 0x71 |
||
3315 | mov cl, al |
||
3316 | sti |
||
3317 | mov [esp+32], ecx |
||
3318 | ret |
||
3319 | |||
3320 | |||
3321 | ; redraw status |
||
3322 | |||
3323 | sys_redrawstat: |
||
3324 | cmp ebx, 1 |
||
3325 | jne no_widgets_away |
||
3326 | ; buttons away |
||
3327 | mov ecx, [CURRENT_TASK] |
||
3328 | sys_newba2: |
||
3329 | mov edi, [BTN_ADDR] |
||
3330 | cmp [edi], dword 0 ; empty button list ? |
||
3331 | je end_of_buttons_away |
||
3332 | movzx ebx, word [edi] |
||
3333 | inc ebx |
||
3334 | mov eax, edi |
||
3335 | sys_newba: |
||
3336 | dec ebx |
||
3337 | jz end_of_buttons_away |
||
3338 | |||
3339 | add eax, 0x10 |
||
3340 | cmp cx, [eax] |
||
3341 | jnz sys_newba |
||
3342 | |||
3343 | push eax ebx ecx |
||
3344 | mov ecx, ebx |
||
3345 | inc ecx |
||
3346 | shl ecx, 4 |
||
3347 | mov ebx, eax |
||
3348 | add eax, 0x10 |
||
3349 | call memmove |
||
3350 | dec dword [edi] |
||
3351 | pop ecx ebx eax |
||
3352 | |||
3353 | jmp sys_newba2 |
||
3354 | |||
3355 | end_of_buttons_away: |
||
3356 | |||
3357 | ret |
||
3358 | |||
3359 | no_widgets_away: |
||
3360 | |||
3361 | cmp ebx, 2 |
||
3362 | jnz srl1 |
||
3363 | |||
3364 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
||
3365 | add edx, draw_data - CURRENT_TASK |
||
3366 | mov [edx + RECT.left], 0 |
||
3367 | mov [edx + RECT.top], 0 |
||
3368 | mov eax, [Screen_Max_X] |
||
3369 | mov [edx + RECT.right], eax |
||
3370 | mov eax, [Screen_Max_Y] |
||
3371 | mov [edx + RECT.bottom], eax |
||
3372 | |||
3373 | srl1: |
||
3374 | ret |
||
3375 | |||
3376 | ;ok - 100% work |
||
3377 | ;nt - not tested |
||
3378 | ;--------------------------------------------------------------------------------------------- |
||
3379 | ;eax |
||
3380 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
||
3381 | ;1 - change task. Ret nothing. Block. ok. |
||
3382 | ;2 - performance control |
||
3383 | ; ebx |
||
3384 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
||
3385 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
||
3386 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
||
3387 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
||
3388 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
||
3389 | ;eax |
||
3390 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3391 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3392 | ;--------------------------------------------------------------------------------------------- |
||
3393 | iglobal |
||
3394 | align 4 |
||
3395 | sheduler: |
||
3396 | dd sys_sheduler.00 |
||
3397 | dd change_task |
||
3398 | dd sys_sheduler.02 |
||
3399 | dd sys_sheduler.03 |
||
3400 | dd sys_sheduler.04 |
||
3401 | endg |
||
3402 | sys_sheduler: |
||
3403 | ;rewritten by |
||
3404 | jmp dword [sheduler+ebx*4] |
||
3405 | ;.shed_counter: |
||
3406 | .00: |
||
3407 | mov eax, [context_counter] |
||
3408 | mov [esp+32], eax |
||
3409 | ret |
||
3410 | |||
3411 | .02: |
||
3412 | ;.perf_control: |
||
3413 | inc ebx ;before ebx=2, ebx=3 |
||
3414 | cmp ebx, ecx ;if ecx=3, ebx=3 |
||
3415 | jz cache_disable |
||
3416 | |||
3417 | dec ebx ;ebx=2 |
||
3418 | cmp ebx, ecx ; |
||
3419 | jz cache_enable ;if ecx=2 and ebx=2 |
||
3420 | |||
3421 | dec ebx ;ebx=1 |
||
3422 | cmp ebx, ecx |
||
3423 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
||
3424 | |||
3425 | dec ebx |
||
3426 | test ebx, ecx ;ebx=0 and ecx=0 |
||
3427 | jz modify_pce ;if ecx=0 |
||
3428 | |||
3429 | ret |
||
3430 | |||
3431 | .03: |
||
3432 | ;.rdmsr_instr: |
||
3433 | ;now counter in ecx |
||
3434 | ;(edx:eax) esi:edi => edx:esi |
||
3435 | mov eax, esi |
||
3436 | mov ecx, edx |
||
3437 | rdmsr |
||
3438 | mov [esp+32], eax |
||
3439 | mov [esp+20], edx ;ret in ebx? |
||
3440 | ret |
||
3441 | |||
3442 | .04: |
||
3443 | ;.wrmsr_instr: |
||
3444 | ;now counter in ecx |
||
3445 | ;(edx:eax) esi:edi => edx:esi |
||
3446 | ; Fast Call MSR can't be destroy |
||
3539 | clevermous | 3447 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3448 | ; включаются/выключаются расширенные возможности |
||
2288 | clevermous | 3449 | cmp edx, MSR_SYSENTER_CS |
3450 | je @f |
||
3451 | cmp edx, MSR_SYSENTER_ESP |
||
3452 | je @f |
||
3453 | cmp edx, MSR_SYSENTER_EIP |
||
3454 | je @f |
||
3455 | cmp edx, MSR_AMD_STAR |
||
3456 | je @f |
||
3457 | |||
3458 | mov eax, esi |
||
3459 | mov ecx, edx |
||
3460 | wrmsr |
||
3461 | ; mov [esp + 32], eax |
||
3462 | ; mov [esp + 20], edx ;ret in ebx? |
||
3463 | @@: |
||
3464 | ret |
||
3465 | |||
3466 | cache_disable: |
||
3467 | mov eax, cr0 |
||
3468 | or eax, 01100000000000000000000000000000b |
||
3469 | mov cr0, eax |
||
3470 | wbinvd ;set MESI |
||
3471 | ret |
||
3472 | |||
3473 | cache_enable: |
||
3474 | mov eax, cr0 |
||
3475 | and eax, 10011111111111111111111111111111b |
||
3476 | mov cr0, eax |
||
3477 | ret |
||
3478 | |||
3479 | is_cache_enabled: |
||
3480 | mov eax, cr0 |
||
3481 | mov ebx, eax |
||
3482 | and eax, 01100000000000000000000000000000b |
||
3483 | jz cache_disabled |
||
3484 | mov [esp+32], ebx |
||
3485 | cache_disabled: |
||
3486 | mov dword [esp+32], eax;0 |
||
3487 | ret |
||
3488 | |||
3489 | modify_pce: |
||
3490 | mov eax, cr4 |
||
3491 | ; mov ebx,0 |
||
3492 | ; or bx,100000000b ;pce |
||
3493 | ; xor eax,ebx ;invert pce |
||
3494 | bts eax, 8;pce=cr4[8] |
||
3495 | mov cr4, eax |
||
3496 | mov [esp+32], eax |
||
3497 | ret |
||
3498 | ;--------------------------------------------------------------------------------------------- |
||
3499 | |||
3500 | |||
3501 | ; check if pixel is allowed to be drawn |
||
3502 | |||
2446 | mario79 | 3503 | ;checkpixel: |
3504 | ; push eax edx |
||
2288 | clevermous | 3505 | |
2446 | mario79 | 3506 | ;; mov edx, [Screen_Max_X] ; screen x size |
3507 | ;; inc edx |
||
3508 | ;; imul edx, ebx |
||
3509 | ; mov edx, [d_width_calc_area + ebx*4] |
||
3510 | ; add eax, [_WinMapAddress] |
||
3511 | ; mov dl, [eax+edx]; lea eax, [...] |
||
2288 | clevermous | 3512 | |
2446 | mario79 | 3513 | ; xor ecx, ecx |
3514 | ; mov eax, [CURRENT_TASK] |
||
3515 | ; cmp al, dl |
||
3516 | ; setne cl |
||
2288 | clevermous | 3517 | |
2446 | mario79 | 3518 | ; pop edx eax |
3519 | ; ret |
||
2288 | clevermous | 3520 | |
3521 | iglobal |
||
3522 | cpustring db 'CPU',0 |
||
3523 | endg |
||
3524 | |||
3525 | uglobal |
||
3526 | background_defined db 0 ; diamond, 11.04.2006 |
||
3527 | endg |
||
2513 | mario79 | 3528 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3529 | align 4 |
3530 | checkmisc: |
||
3531 | cmp [ctrl_alt_del], 1 |
||
3532 | jne nocpustart |
||
3533 | |||
3534 | mov ebp, cpustring |
||
3535 | call fs_execute_from_sysdir |
||
3536 | |||
3537 | mov [ctrl_alt_del], 0 |
||
2513 | mario79 | 3538 | ;-------------------------------------- |
3539 | align 4 |
||
2288 | clevermous | 3540 | nocpustart: |
3541 | cmp [mouse_active], 1 |
||
3542 | jne mouse_not_active |
||
3543 | mov [mouse_active], 0 |
||
2411 | Serge | 3544 | |
2288 | clevermous | 3545 | xor edi, edi |
2411 | Serge | 3546 | mov ebx, CURRENT_TASK |
3547 | |||
2288 | clevermous | 3548 | mov ecx, [TASK_COUNT] |
2408 | Serge | 3549 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3550 | shl eax, 8 |
||
2414 | Serge | 3551 | push eax |
2408 | Serge | 3552 | |
2414 | Serge | 3553 | movzx eax, word [MOUSE_X] |
3554 | movzx edx, word [MOUSE_Y] |
||
2513 | mario79 | 3555 | ;-------------------------------------- |
2408 | Serge | 3556 | align 4 |
3557 | .set_mouse_event: |
||
2288 | clevermous | 3558 | add edi, 256 |
2411 | Serge | 3559 | add ebx, 32 |
3560 | test [ebx+TASKDATA.event_mask], 0x80000000 |
||
2414 | Serge | 3561 | jz .pos_filter |
3562 | |||
3563 | cmp edi, [esp] ; skip if filtration active |
||
3564 | jne .skip |
||
2513 | mario79 | 3565 | ;-------------------------------------- |
3566 | align 4 |
||
2414 | Serge | 3567 | .pos_filter: |
3568 | test [ebx+TASKDATA.event_mask], 0x40000000 |
||
2411 | Serge | 3569 | jz .set |
2288 | clevermous | 3570 | |
2414 | Serge | 3571 | mov esi, [ebx-twdw+WDATA.box.left] |
3572 | cmp eax, esi |
||
3573 | jb .skip |
||
3574 | add esi, [ebx-twdw+WDATA.box.width] |
||
3575 | cmp eax, esi |
||
3576 | ja .skip |
||
3577 | |||
3578 | mov esi, [ebx-twdw+WDATA.box.top] |
||
3579 | cmp edx, esi |
||
3580 | jb .skip |
||
3581 | add esi, [ebx-twdw+WDATA.box.height] |
||
3582 | cmp edx, esi |
||
3583 | ja .skip |
||
2513 | mario79 | 3584 | ;-------------------------------------- |
3585 | align 4 |
||
2411 | Serge | 3586 | .set: |
2513 | mario79 | 3587 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3588 | ;-------------------------------------- |
||
3589 | align 4 |
||
2411 | Serge | 3590 | .skip: |
2408 | Serge | 3591 | loop .set_mouse_event |
3592 | |||
2414 | Serge | 3593 | pop eax |
2513 | mario79 | 3594 | ;-------------------------------------- |
3595 | align 4 |
||
2288 | clevermous | 3596 | mouse_not_active: |
2580 | mario79 | 3597 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
2288 | clevermous | 3598 | jz nobackgr |
2524 | mario79 | 3599 | |
2288 | clevermous | 3600 | cmp [background_defined], 0 |
3601 | jz nobackgr |
||
2513 | mario79 | 3602 | ;-------------------------------------- |
3603 | align 4 |
||
3536 | clevermous | 3604 | backgr: |
2537 | mario79 | 3605 | mov eax, [draw_data+32 + RECT.left] |
3606 | shl eax, 16 |
||
3607 | add eax, [draw_data+32 + RECT.right] |
||
3608 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
||
3609 | |||
3610 | mov eax, [draw_data+32 + RECT.top] |
||
3611 | shl eax, 16 |
||
3612 | add eax, [draw_data+32 + RECT.bottom] |
||
3613 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
||
3614 | |||
2288 | clevermous | 3615 | call drawbackground |
2580 | mario79 | 3616 | ; DEBUGF 1, "K : drawbackground\n" |
2620 | mario79 | 3617 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3618 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
||
2513 | mario79 | 3619 | ;--------- set event 5 start ---------- |
3620 | push ecx edi |
||
3621 | xor edi, edi |
||
3622 | mov ecx, [TASK_COUNT] |
||
3623 | ;-------------------------------------- |
||
3624 | align 4 |
||
3625 | set_bgr_event: |
||
3626 | add edi, 256 |
||
3536 | clevermous | 3627 | mov eax, [BG_Rect_X_left_right] |
3628 | mov edx, [BG_Rect_Y_top_bottom] |
||
3629 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
||
3630 | jz .set |
||
3631 | .join: |
||
3611 | clevermous | 3632 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3633 | jae @f |
||
3634 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
||
3635 | @@: |
||
3636 | shr eax, 16 |
||
3536 | clevermous | 3637 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3638 | jbe @f |
||
3639 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
||
3640 | @@: |
||
3611 | clevermous | 3641 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3536 | clevermous | 3642 | jae @f |
3611 | clevermous | 3643 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3536 | clevermous | 3644 | @@: |
3611 | clevermous | 3645 | shr edx, 16 |
3536 | clevermous | 3646 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3647 | jbe @f |
||
3648 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
||
3649 | @@: |
||
3650 | jmp .common |
||
3651 | .set: |
||
3652 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
||
3653 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
||
3654 | .common: |
||
2513 | mario79 | 3655 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3656 | loop set_bgr_event |
||
3657 | pop edi ecx |
||
3658 | ;--------- set event 5 stop ----------- |
||
2580 | mario79 | 3659 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3536 | clevermous | 3660 | jnz backgr |
2513 | mario79 | 3661 | |
3536 | clevermous | 3662 | xor eax, eax |
2288 | clevermous | 3663 | mov [draw_data+32 + RECT.left], eax |
3664 | mov [draw_data+32 + RECT.top], eax |
||
3665 | mov [draw_data+32 + RECT.right], eax |
||
3666 | mov [draw_data+32 + RECT.bottom], eax |
||
2513 | mario79 | 3667 | ;-------------------------------------- |
3668 | align 4 |
||
2288 | clevermous | 3669 | nobackgr: |
2513 | mario79 | 3670 | ; system shutdown request |
2288 | clevermous | 3671 | cmp [SYS_SHUTDOWN], byte 0 |
3672 | je noshutdown |
||
3673 | |||
3674 | mov edx, [shutdown_processes] |
||
3675 | |||
3676 | cmp [SYS_SHUTDOWN], dl |
||
3325 | clevermous | 3677 | jne noshutdown |
2288 | clevermous | 3678 | |
3679 | lea ecx, [edx-1] |
||
3680 | mov edx, OS_BASE+0x3040 |
||
3325 | clevermous | 3681 | jecxz no_mark_system_shutdown |
2513 | mario79 | 3682 | ;-------------------------------------- |
3683 | align 4 |
||
2288 | clevermous | 3684 | markz: |
3296 | clevermous | 3685 | push ecx edx |
3325 | clevermous | 3686 | cmp [edx+TASKDATA.state], 9 |
3687 | jz .nokill |
||
3688 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
||
3689 | cmp [edx+APPDATA.dir_table], sys_pgdir - OS_BASE |
||
3690 | jz .nokill |
||
3296 | clevermous | 3691 | call request_terminate |
3325 | clevermous | 3692 | jmp .common |
3693 | .nokill: |
||
3694 | dec byte [SYS_SHUTDOWN] |
||
3695 | xor eax, eax |
||
3696 | .common: |
||
3296 | clevermous | 3697 | pop edx ecx |
3698 | test eax, eax |
||
3699 | jz @f |
||
2288 | clevermous | 3700 | mov [edx+TASKDATA.state], byte 3 |
3296 | clevermous | 3701 | @@: |
2288 | clevermous | 3702 | add edx, 0x20 |
3703 | loop markz |
||
3534 | clevermous | 3704 | call wakeup_osloop |
2513 | mario79 | 3705 | ;-------------------------------------- |
3706 | align 4 |
||
2288 | clevermous | 3707 | @@: |
2513 | mario79 | 3708 | no_mark_system_shutdown: |
2288 | clevermous | 3709 | dec byte [SYS_SHUTDOWN] |
3710 | je system_shutdown |
||
2513 | mario79 | 3711 | ;-------------------------------------- |
3712 | align 4 |
||
2288 | clevermous | 3713 | noshutdown: |
3714 | mov eax, [TASK_COUNT] ; termination |
||
3715 | mov ebx, TASK_DATA+TASKDATA.state |
||
3716 | mov esi, 1 |
||
2513 | mario79 | 3717 | ;-------------------------------------- |
3718 | align 4 |
||
2288 | clevermous | 3719 | newct: |
3720 | mov cl, [ebx] |
||
3721 | cmp cl, byte 3 |
||
3325 | clevermous | 3722 | jz .terminate |
2513 | mario79 | 3723 | |
2288 | clevermous | 3724 | cmp cl, byte 4 |
3325 | clevermous | 3725 | jnz .noterminate |
3726 | .terminate: |
||
3727 | pushad |
||
3493 | mario79 | 3728 | mov ecx, eax |
3729 | shl ecx, 8 |
||
3730 | add ecx, SLOT_BASE |
||
3731 | call restore_default_cursor_before_killing |
||
3732 | popad |
||
3733 | |||
3734 | pushad |
||
3325 | clevermous | 3735 | call terminate |
3736 | popad |
||
3737 | cmp byte [SYS_SHUTDOWN], 0 |
||
3738 | jz .noterminate |
||
3739 | dec byte [SYS_SHUTDOWN] |
||
3740 | je system_shutdown |
||
2288 | clevermous | 3741 | |
3325 | clevermous | 3742 | .noterminate: |
2288 | clevermous | 3743 | add ebx, 0x20 |
3744 | inc esi |
||
3745 | dec eax |
||
3746 | jnz newct |
||
3747 | ret |
||
2513 | mario79 | 3748 | ;----------------------------------------------------------------------------- |
3749 | align 4 |
||
2288 | clevermous | 3750 | redrawscreen: |
3751 | ; eax , if process window_data base is eax, do not set flag/limits |
||
3752 | |||
3753 | pushad |
||
3754 | push eax |
||
3755 | |||
3756 | ;;; mov ebx,2 |
||
3757 | ;;; call delay_hs |
||
3758 | |||
3759 | ;mov ecx,0 ; redraw flags for apps |
||
3760 | xor ecx, ecx |
||
2513 | mario79 | 3761 | ;-------------------------------------- |
3762 | align 4 |
||
3763 | newdw2: |
||
2288 | clevermous | 3764 | inc ecx |
3765 | push ecx |
||
3766 | |||
3767 | mov eax, ecx |
||
3768 | shl eax, 5 |
||
3769 | add eax, window_data |
||
3770 | |||
3771 | cmp eax, [esp+4] |
||
3772 | je not_this_task |
||
3773 | ; check if window in redraw area |
||
3774 | mov edi, eax |
||
3775 | |||
3776 | cmp ecx, 1 ; limit for background |
||
3777 | jz bgli |
||
3778 | |||
3779 | mov eax, [edi + WDATA.box.left] |
||
3780 | mov ebx, [edi + WDATA.box.top] |
||
3781 | mov ecx, [edi + WDATA.box.width] |
||
3782 | mov edx, [edi + WDATA.box.height] |
||
3783 | add ecx, eax |
||
3784 | add edx, ebx |
||
3785 | |||
3786 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
||
3787 | cmp ecx, ebx |
||
3788 | jb ricino |
||
3789 | |||
3790 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
||
3791 | cmp ecx, eax |
||
3792 | jb ricino |
||
3793 | |||
3794 | mov eax, [edi + WDATA.box.left] |
||
3795 | mov ebx, [edi + WDATA.box.top] |
||
3796 | mov ecx, [edi + WDATA.box.width] |
||
3797 | mov edx, [edi + WDATA.box.height] |
||
3798 | add ecx, eax |
||
3799 | add edx, ebx |
||
3800 | |||
3801 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
||
3802 | cmp edx, eax |
||
3803 | jb ricino |
||
3804 | |||
3805 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
||
3806 | cmp ecx, eax |
||
3807 | jb ricino |
||
2513 | mario79 | 3808 | ;-------------------------------------- |
3809 | align 4 |
||
3810 | bgli: |
||
2288 | clevermous | 3811 | cmp dword[esp], 1 |
3812 | jnz .az |
||
2513 | mario79 | 3813 | |
2288 | clevermous | 3814 | cmp byte[REDRAW_BACKGROUND], 0 |
3815 | jz .az |
||
2513 | mario79 | 3816 | |
2288 | clevermous | 3817 | mov dl, 0 |
3818 | lea eax, [edi+draw_data-window_data] |
||
3819 | mov ebx, [draw_limits.left] |
||
3820 | cmp ebx, [eax+RECT.left] |
||
3821 | jae @f |
||
2513 | mario79 | 3822 | |
2288 | clevermous | 3823 | mov [eax+RECT.left], ebx |
3824 | mov dl, 1 |
||
2513 | mario79 | 3825 | ;-------------------------------------- |
3826 | align 4 |
||
3827 | @@: |
||
2288 | clevermous | 3828 | mov ebx, [draw_limits.top] |
3829 | cmp ebx, [eax+RECT.top] |
||
3830 | jae @f |
||
2513 | mario79 | 3831 | |
2288 | clevermous | 3832 | mov [eax+RECT.top], ebx |
3833 | mov dl, 1 |
||
2513 | mario79 | 3834 | ;-------------------------------------- |
3835 | align 4 |
||
3836 | @@: |
||
2288 | clevermous | 3837 | mov ebx, [draw_limits.right] |
3838 | cmp ebx, [eax+RECT.right] |
||
3839 | jbe @f |
||
2513 | mario79 | 3840 | |
2288 | clevermous | 3841 | mov [eax+RECT.right], ebx |
3842 | mov dl, 1 |
||
2513 | mario79 | 3843 | ;-------------------------------------- |
3844 | align 4 |
||
3845 | @@: |
||
2288 | clevermous | 3846 | mov ebx, [draw_limits.bottom] |
3847 | cmp ebx, [eax+RECT.bottom] |
||
3848 | jbe @f |
||
2513 | mario79 | 3849 | |
2288 | clevermous | 3850 | mov [eax+RECT.bottom], ebx |
3851 | mov dl, 1 |
||
2513 | mario79 | 3852 | ;-------------------------------------- |
3853 | align 4 |
||
3854 | @@: |
||
2288 | clevermous | 3855 | add byte[REDRAW_BACKGROUND], dl |
3534 | clevermous | 3856 | call wakeup_osloop |
2288 | clevermous | 3857 | jmp newdw8 |
2513 | mario79 | 3858 | ;-------------------------------------- |
3859 | align 4 |
||
3860 | .az: |
||
2288 | clevermous | 3861 | mov eax, edi |
3862 | add eax, draw_data-window_data |
||
3863 | |||
3864 | mov ebx, [draw_limits.left] ; set limits |
||
3865 | mov [eax + RECT.left], ebx |
||
3866 | mov ebx, [draw_limits.top] |
||
3867 | mov [eax + RECT.top], ebx |
||
3868 | mov ebx, [draw_limits.right] |
||
3869 | mov [eax + RECT.right], ebx |
||
3870 | mov ebx, [draw_limits.bottom] |
||
3871 | mov [eax + RECT.bottom], ebx |
||
3872 | |||
3873 | sub eax, draw_data-window_data |
||
3874 | |||
3875 | cmp dword [esp], 1 |
||
3876 | jne nobgrd |
||
3877 | inc byte[REDRAW_BACKGROUND] |
||
3534 | clevermous | 3878 | call wakeup_osloop |
2513 | mario79 | 3879 | ;-------------------------------------- |
3880 | align 4 |
||
3881 | newdw8: |
||
3882 | nobgrd: |
||
2288 | clevermous | 3883 | |
3884 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
||
2513 | mario79 | 3885 | ;-------------------------------------- |
3886 | align 4 |
||
3887 | ricino: |
||
3888 | not_this_task: |
||
2288 | clevermous | 3889 | pop ecx |
3890 | |||
3891 | cmp ecx, [TASK_COUNT] |
||
3892 | jle newdw2 |
||
3893 | |||
3894 | pop eax |
||
3895 | popad |
||
3896 | ret |
||
2513 | mario79 | 3897 | ;----------------------------------------------------------------------------- |
3898 | align 4 |
||
2288 | clevermous | 3899 | calculatebackground: ; background |
3900 | mov edi, [_WinMapAddress] ; set os to use all pixels |
||
3901 | mov eax, 0x01010101 |
||
3902 | mov ecx, [_WinMapSize] |
||
3903 | shr ecx, 2 |
||
3904 | rep stosd |
||
3905 | |||
3906 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
||
3907 | ret |
||
2513 | mario79 | 3908 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3909 | uglobal |
3910 | imax dd 0x0 |
||
3911 | endg |
||
2513 | mario79 | 3912 | ;----------------------------------------------------------------------------- |
3913 | align 4 |
||
2288 | clevermous | 3914 | delay_ms: ; delay in 1/1000 sec |
3915 | push eax |
||
3916 | push ecx |
||
3917 | |||
3918 | mov ecx, esi |
||
3919 | ; |
||
3920 | imul ecx, 33941 |
||
3921 | shr ecx, 9 |
||
3922 | ; |
||
3923 | |||
3924 | in al, 0x61 |
||
3925 | and al, 0x10 |
||
3926 | mov ah, al |
||
3927 | cld |
||
2513 | mario79 | 3928 | ;-------------------------------------- |
3929 | align 4 |
||
3930 | cnt1: |
||
2288 | clevermous | 3931 | in al, 0x61 |
3932 | and al, 0x10 |
||
3933 | cmp al, ah |
||
3934 | jz cnt1 |
||
3935 | |||
3936 | mov ah, al |
||
3937 | loop cnt1 |
||
3938 | |||
3939 | pop ecx |
||
3940 | pop eax |
||
3941 | ret |
||
2513 | mario79 | 3942 | ;----------------------------------------------------------------------------- |
2411 | Serge | 3943 | align 4 |
2288 | clevermous | 3944 | set_app_param: |
3945 | mov edi, [TASK_BASE] |
||
2408 | Serge | 3946 | mov eax, ebx |
3947 | btr eax, 3 ; move MOUSE_FILTRATION |
||
3948 | mov ebx, [current_slot] ; bit into event_filter |
||
3949 | setc byte [ebx+APPDATA.event_filter] |
||
3950 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
||
3951 | mov [esp+32], eax ; return old mask value |
||
2288 | clevermous | 3952 | ret |
2513 | mario79 | 3953 | ;----------------------------------------------------------------------------- |
3303 | clevermous | 3954 | |
3955 | ; this is for syscall |
||
3956 | proc delay_hs_unprotected |
||
3957 | call unprotect_from_terminate |
||
3958 | call delay_hs |
||
3959 | call protect_from_terminate |
||
3960 | ret |
||
3961 | endp |
||
3962 | |||
3597 | Serge | 3963 | if 1 |
2513 | mario79 | 3964 | align 4 |
2288 | clevermous | 3965 | delay_hs: ; delay in 1/100 secs |
3966 | ; ebx = delay time |
||
3967 | |||
3595 | Serge | 3968 | pushad |
3969 | push ebx |
||
3970 | xor esi, esi |
||
3971 | mov ecx, MANUAL_DESTROY |
||
3972 | call create_event |
||
3973 | test eax, eax |
||
3974 | jz .done |
||
2288 | clevermous | 3975 | |
3595 | Serge | 3976 | mov ebx, edx |
3977 | mov ecx, [esp] |
||
3597 | Serge | 3978 | push edx |
3595 | Serge | 3979 | push eax |
3980 | call wait_event_timeout |
||
3981 | pop eax |
||
3597 | Serge | 3982 | pop ebx |
3595 | Serge | 3983 | call destroy_event |
3984 | .done: |
||
3985 | add esp, 4 |
||
3986 | popad |
||
2288 | clevermous | 3987 | ret |
3596 | Serge | 3988 | |
3989 | else |
||
3990 | |||
3991 | align 4 |
||
3992 | delay_hs: ; delay in 1/100 secs |
||
3993 | ; ebx = delay time |
||
3994 | push ecx |
||
3995 | push edx |
||
3996 | |||
3997 | mov edx, [timer_ticks] |
||
3998 | ;-------------------------------------- |
||
3999 | align 4 |
||
4000 | newtic: |
||
4001 | mov ecx, [timer_ticks] |
||
4002 | sub ecx, edx |
||
4003 | cmp ecx, ebx |
||
4004 | jae zerodelay |
||
4005 | |||
4006 | call change_task |
||
4007 | |||
4008 | jmp newtic |
||
4009 | ;-------------------------------------- |
||
4010 | align 4 |
||
4011 | zerodelay: |
||
4012 | pop edx |
||
4013 | pop ecx |
||
4014 | ret |
||
4015 | end if |
||
4016 | |||
2513 | mario79 | 4017 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4018 | align 16 ;very often call this subrutine |
4019 | memmove: ; memory move in bytes |
||
4020 | ; eax = from |
||
4021 | ; ebx = to |
||
4022 | ; ecx = no of bytes |
||
4023 | test ecx, ecx |
||
4024 | jle .ret |
||
4025 | |||
4026 | push esi edi ecx |
||
4027 | |||
4028 | mov edi, ebx |
||
4029 | mov esi, eax |
||
4030 | |||
4031 | test ecx, not 11b |
||
4032 | jz @f |
||
4033 | |||
4034 | push ecx |
||
4035 | shr ecx, 2 |
||
4036 | rep movsd |
||
4037 | pop ecx |
||
4038 | and ecx, 11b |
||
4039 | jz .finish |
||
2513 | mario79 | 4040 | ;-------------------------------------- |
4041 | align 4 |
||
4042 | @@: |
||
2288 | clevermous | 4043 | rep movsb |
2513 | mario79 | 4044 | ;-------------------------------------- |
4045 | align 4 |
||
4046 | .finish: |
||
2288 | clevermous | 4047 | pop ecx edi esi |
2513 | mario79 | 4048 | ;-------------------------------------- |
4049 | align 4 |
||
4050 | .ret: |
||
2288 | clevermous | 4051 | ret |
2513 | mario79 | 4052 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4053 | ; |
4054 | ;align 4 |
||
4055 | ; |
||
4056 | ;read_floppy_file: |
||
4057 | ; |
||
4058 | ;; as input |
||
4059 | ;; |
||
4060 | ;; eax pointer to file |
||
4061 | ;; ebx file lenght |
||
4062 | ;; ecx start 512 byte block number |
||
4063 | ;; edx number of blocks to read |
||
4064 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
||
4065 | ;; |
||
4066 | ;; |
||
4067 | ;; on return |
||
4068 | ;; |
||
4069 | ;; eax = 0 command succesful |
||
4070 | ;; 1 no fd base and/or partition defined |
||
4071 | ;; 2 yet unsupported FS |
||
4072 | ;; 3 unknown FS |
||
4073 | ;; 4 partition not defined at hd |
||
4074 | ;; 5 file not found |
||
4075 | ;; ebx = size of file |
||
4076 | ; |
||
4077 | ; mov edi,[TASK_BASE] |
||
4078 | ; add edi,0x10 |
||
4079 | ; add esi,[edi] |
||
4080 | ; add eax,[edi] |
||
4081 | ; |
||
4082 | ; pushad |
||
4083 | ; mov edi,esi |
||
4084 | ; add edi,1024 |
||
4085 | ; mov esi,0x100000+19*512 |
||
4086 | ; sub ecx,1 |
||
4087 | ; shl ecx,9 |
||
4088 | ; add esi,ecx |
||
4089 | ; shl edx,9 |
||
4090 | ; mov ecx,edx |
||
4091 | ; cld |
||
4092 | ; rep movsb |
||
4093 | ; popad |
||
4094 | ; |
||
4095 | ; mov [esp+36],eax |
||
4096 | ; mov [esp+24],ebx |
||
4097 | ; ret |
||
4098 | |||
4099 | |||
4100 | |||
4101 | align 4 |
||
4102 | set_io_access_rights: |
||
4103 | push edi eax |
||
4104 | mov edi, tss._io_map_0 |
||
4105 | ; mov ecx,eax |
||
4106 | ; and ecx,7 ; offset in byte |
||
4107 | ; shr eax,3 ; number of byte |
||
4108 | ; add edi,eax |
||
4109 | ; mov ebx,1 |
||
4110 | ; shl ebx,cl |
||
4111 | test ebp, ebp |
||
4112 | ; cmp ebp,0 ; enable access - ebp = 0 |
||
4113 | jnz .siar1 |
||
4114 | ; not ebx |
||
4115 | ; and [edi],byte bl |
||
4116 | btr [edi], eax |
||
4117 | pop eax edi |
||
4118 | ret |
||
4119 | .siar1: |
||
4120 | bts [edi], eax |
||
4121 | ; or [edi],byte bl ; disable access - ebp = 1 |
||
4122 | pop eax edi |
||
4123 | ret |
||
4124 | ;reserve/free group of ports |
||
4125 | ; * eax = 46 - number function |
||
4126 | ; * ebx = 0 - reserve, 1 - free |
||
4127 | ; * ecx = number start arrea of ports |
||
4128 | ; * edx = number end arrea of ports (include last number of port) |
||
4129 | ;Return value: |
||
4130 | ; * eax = 0 - succesful |
||
4131 | ; * eax = 1 - error |
||
4132 | ; * The system has reserve this ports: |
||
4133 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
||
4134 | ;destroys eax,ebx, ebp |
||
4135 | r_f_port_area: |
||
4136 | |||
4137 | test ebx, ebx |
||
4138 | jnz free_port_area |
||
4139 | ; je r_port_area |
||
4140 | ; jmp free_port_area |
||
4141 | |||
4142 | ; r_port_area: |
||
4143 | |||
4144 | ; pushad |
||
4145 | |||
4146 | cmp ecx, edx ; beginning > end ? |
||
4147 | ja rpal1 |
||
4148 | cmp edx, 65536 |
||
4149 | jae rpal1 |
||
4150 | mov eax, [RESERVED_PORTS] |
||
4151 | test eax, eax ; no reserved areas ? |
||
4152 | je rpal2 |
||
4153 | cmp eax, 255 ; max reserved |
||
4154 | jae rpal1 |
||
4155 | rpal3: |
||
4156 | mov ebx, eax |
||
4157 | shl ebx, 4 |
||
4158 | add ebx, RESERVED_PORTS |
||
4159 | cmp ecx, [ebx+8] |
||
4160 | ja rpal4 |
||
4161 | cmp edx, [ebx+4] |
||
4162 | jae rpal1 |
||
4163 | ; jb rpal4 |
||
4164 | ; jmp rpal1 |
||
4165 | rpal4: |
||
4166 | dec eax |
||
4167 | jnz rpal3 |
||
4168 | jmp rpal2 |
||
4169 | rpal1: |
||
4170 | ; popad |
||
4171 | ; mov eax,1 |
||
4172 | xor eax, eax |
||
4173 | inc eax |
||
4174 | ret |
||
4175 | rpal2: |
||
4176 | ; popad |
||
4177 | ; enable port access at port IO map |
||
4178 | cli |
||
4179 | pushad ; start enable io map |
||
4180 | |||
4181 | cmp edx, 65536;16384 |
||
4182 | jae no_unmask_io; jge |
||
4183 | mov eax, ecx |
||
4184 | ; push ebp |
||
4185 | xor ebp, ebp ; enable - eax = port |
||
4186 | new_port_access: |
||
4187 | ; pushad |
||
4188 | call set_io_access_rights |
||
4189 | ; popad |
||
4190 | inc eax |
||
4191 | cmp eax, edx |
||
4192 | jbe new_port_access |
||
4193 | ; pop ebp |
||
4194 | no_unmask_io: |
||
4195 | popad ; end enable io map |
||
4196 | sti |
||
4197 | |||
4198 | mov eax, [RESERVED_PORTS] |
||
4199 | add eax, 1 |
||
4200 | mov [RESERVED_PORTS], eax |
||
4201 | shl eax, 4 |
||
4202 | add eax, RESERVED_PORTS |
||
4203 | mov ebx, [TASK_BASE] |
||
4204 | mov ebx, [ebx+TASKDATA.pid] |
||
4205 | mov [eax], ebx |
||
4206 | mov [eax+4], ecx |
||
4207 | mov [eax+8], edx |
||
4208 | |||
4209 | xor eax, eax |
||
4210 | ret |
||
4211 | |||
4212 | free_port_area: |
||
4213 | |||
4214 | ; pushad |
||
4215 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
||
4216 | test eax, eax |
||
4217 | jz frpal2 |
||
4218 | mov ebx, [TASK_BASE] |
||
4219 | mov ebx, [ebx+TASKDATA.pid] |
||
4220 | frpal3: |
||
4221 | mov edi, eax |
||
4222 | shl edi, 4 |
||
4223 | add edi, RESERVED_PORTS |
||
4224 | cmp ebx, [edi] |
||
4225 | jne frpal4 |
||
4226 | cmp ecx, [edi+4] |
||
4227 | jne frpal4 |
||
4228 | cmp edx, [edi+8] |
||
4229 | jne frpal4 |
||
4230 | jmp frpal1 |
||
4231 | frpal4: |
||
4232 | dec eax |
||
4233 | jnz frpal3 |
||
4234 | frpal2: |
||
4235 | ; popad |
||
4236 | inc eax |
||
4237 | ret |
||
4238 | frpal1: |
||
4239 | push ecx |
||
4240 | mov ecx, 256 |
||
4241 | sub ecx, eax |
||
4242 | shl ecx, 4 |
||
4243 | mov esi, edi |
||
4244 | add esi, 16 |
||
4245 | cld |
||
4246 | rep movsb |
||
4247 | |||
4248 | dec dword [RESERVED_PORTS] |
||
4249 | ;popad |
||
4250 | ;disable port access at port IO map |
||
4251 | |||
4252 | ; pushad ; start disable io map |
||
4253 | pop eax ;start port |
||
4254 | cmp edx, 65536;16384 |
||
4255 | jge no_mask_io |
||
4256 | |||
4257 | ; mov eax,ecx |
||
4258 | xor ebp, ebp |
||
4259 | inc ebp |
||
4260 | new_port_access_disable: |
||
4261 | ; pushad |
||
4262 | ; mov ebp,1 ; disable - eax = port |
||
4263 | call set_io_access_rights |
||
4264 | ; popad |
||
4265 | inc eax |
||
4266 | cmp eax, edx |
||
4267 | jbe new_port_access_disable |
||
4268 | no_mask_io: |
||
4269 | ; popad ; end disable io map |
||
4270 | xor eax, eax |
||
4271 | ret |
||
2430 | mario79 | 4272 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4273 | align 4 |
4274 | drawbackground: |
||
2430 | mario79 | 4275 | dbrv20: |
2288 | clevermous | 4276 | cmp [BgrDrawMode], dword 1 |
4277 | jne bgrstr |
||
4278 | call vesa20_drawbackground_tiled |
||
2453 | mario79 | 4279 | ; call [draw_pointer] |
4280 | call __sys_draw_pointer |
||
2288 | clevermous | 4281 | ret |
2430 | mario79 | 4282 | ;-------------------------------------- |
4283 | align 4 |
||
4284 | bgrstr: |
||
2288 | clevermous | 4285 | call vesa20_drawbackground_stretch |
2453 | mario79 | 4286 | ; call [draw_pointer] |
4287 | call __sys_draw_pointer |
||
2288 | clevermous | 4288 | ret |
2430 | mario79 | 4289 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4290 | align 4 |
4291 | syscall_putimage: ; PutImage |
||
4292 | sys_putimage: |
||
4293 | test ecx, 0x80008000 |
||
4294 | jnz .exit |
||
4295 | test ecx, 0x0000FFFF |
||
4296 | jz .exit |
||
4297 | test ecx, 0xFFFF0000 |
||
4298 | jnz @f |
||
2430 | mario79 | 4299 | ;-------------------------------------- |
4300 | align 4 |
||
4301 | .exit: |
||
2288 | clevermous | 4302 | ret |
2430 | mario79 | 4303 | ;-------------------------------------- |
4304 | align 4 |
||
4305 | @@: |
||
2288 | clevermous | 4306 | mov edi, [current_slot] |
4307 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
||
4308 | rol edx, 16 |
||
4309 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
||
4310 | rol edx, 16 |
||
2430 | mario79 | 4311 | ;-------------------------------------- |
4312 | align 4 |
||
4313 | .forced: |
||
2288 | clevermous | 4314 | push ebp esi 0 |
4315 | mov ebp, putimage_get24bpp |
||
4316 | mov esi, putimage_init24bpp |
||
2430 | mario79 | 4317 | ;-------------------------------------- |
4318 | align 4 |
||
2288 | clevermous | 4319 | sys_putimage_bpp: |
2430 | mario79 | 4320 | call vesa20_putimage |
2288 | clevermous | 4321 | pop ebp esi ebp |
2430 | mario79 | 4322 | ret |
4323 | ; jmp [draw_pointer] |
||
4324 | ;----------------------------------------------------------------------------- |
||
2288 | clevermous | 4325 | align 4 |
4326 | sys_putimage_palette: |
||
4327 | ; ebx = pointer to image |
||
4328 | ; ecx = [xsize]*65536 + [ysize] |
||
4329 | ; edx = [xstart]*65536 + [ystart] |
||
4330 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
||
4331 | ; edi = pointer to palette |
||
4332 | ; ebp = row delta |
||
4333 | mov eax, [CURRENT_TASK] |
||
4334 | shl eax, 8 |
||
4335 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
4336 | rol edx, 16 |
||
4337 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
4338 | rol edx, 16 |
||
2430 | mario79 | 4339 | ;-------------------------------------- |
4340 | align 4 |
||
2288 | clevermous | 4341 | .forced: |
4342 | cmp esi, 1 |
||
4343 | jnz @f |
||
4344 | push edi |
||
4345 | mov eax, [edi+4] |
||
4346 | sub eax, [edi] |
||
4347 | push eax |
||
4348 | push dword [edi] |
||
4349 | push 0ffffff80h |
||
4350 | mov edi, esp |
||
4351 | call put_mono_image |
||
4352 | add esp, 12 |
||
4353 | pop edi |
||
4354 | ret |
||
2430 | mario79 | 4355 | ;-------------------------------------- |
4356 | align 4 |
||
2288 | clevermous | 4357 | @@: |
4358 | cmp esi, 2 |
||
4359 | jnz @f |
||
4360 | push edi |
||
4361 | push 0ffffff80h |
||
4362 | mov edi, esp |
||
4363 | call put_2bit_image |
||
4364 | pop eax |
||
4365 | pop edi |
||
4366 | ret |
||
2430 | mario79 | 4367 | ;-------------------------------------- |
4368 | align 4 |
||
2288 | clevermous | 4369 | @@: |
4370 | cmp esi, 4 |
||
4371 | jnz @f |
||
4372 | push edi |
||
4373 | push 0ffffff80h |
||
4374 | mov edi, esp |
||
4375 | call put_4bit_image |
||
4376 | pop eax |
||
4377 | pop edi |
||
4378 | ret |
||
2430 | mario79 | 4379 | ;-------------------------------------- |
4380 | align 4 |
||
2288 | clevermous | 4381 | @@: |
4382 | push ebp esi ebp |
||
4383 | cmp esi, 8 |
||
4384 | jnz @f |
||
4385 | mov ebp, putimage_get8bpp |
||
4386 | mov esi, putimage_init8bpp |
||
4387 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4388 | ;-------------------------------------- |
4389 | align 4 |
||
2288 | clevermous | 4390 | @@: |
2727 | dunkaist | 4391 | cmp esi, 9 |
4392 | jnz @f |
||
4393 | mov ebp, putimage_get9bpp |
||
4394 | mov esi, putimage_init9bpp |
||
4395 | jmp sys_putimage_bpp |
||
4396 | ;-------------------------------------- |
||
4397 | align 4 |
||
4398 | @@: |
||
2288 | clevermous | 4399 | cmp esi, 15 |
4400 | jnz @f |
||
4401 | mov ebp, putimage_get15bpp |
||
4402 | mov esi, putimage_init15bpp |
||
4403 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4404 | ;-------------------------------------- |
4405 | align 4 |
||
2288 | clevermous | 4406 | @@: |
4407 | cmp esi, 16 |
||
4408 | jnz @f |
||
4409 | mov ebp, putimage_get16bpp |
||
4410 | mov esi, putimage_init16bpp |
||
4411 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4412 | ;-------------------------------------- |
4413 | align 4 |
||
2288 | clevermous | 4414 | @@: |
4415 | cmp esi, 24 |
||
4416 | jnz @f |
||
4417 | mov ebp, putimage_get24bpp |
||
4418 | mov esi, putimage_init24bpp |
||
4419 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4420 | ;-------------------------------------- |
4421 | align 4 |
||
2288 | clevermous | 4422 | @@: |
4423 | cmp esi, 32 |
||
4424 | jnz @f |
||
4425 | mov ebp, putimage_get32bpp |
||
4426 | mov esi, putimage_init32bpp |
||
4427 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4428 | ;-------------------------------------- |
4429 | align 4 |
||
2288 | clevermous | 4430 | @@: |
4431 | pop ebp esi ebp |
||
4432 | ret |
||
2430 | mario79 | 4433 | ;----------------------------------------------------------------------------- |
4434 | align 4 |
||
2288 | clevermous | 4435 | put_mono_image: |
4436 | push ebp esi ebp |
||
4437 | mov ebp, putimage_get1bpp |
||
4438 | mov esi, putimage_init1bpp |
||
4439 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4440 | ;----------------------------------------------------------------------------- |
4441 | align 4 |
||
2288 | clevermous | 4442 | put_2bit_image: |
4443 | push ebp esi ebp |
||
4444 | mov ebp, putimage_get2bpp |
||
4445 | mov esi, putimage_init2bpp |
||
4446 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4447 | ;----------------------------------------------------------------------------- |
4448 | align 4 |
||
2288 | clevermous | 4449 | put_4bit_image: |
4450 | push ebp esi ebp |
||
4451 | mov ebp, putimage_get4bpp |
||
4452 | mov esi, putimage_init4bpp |
||
4453 | jmp sys_putimage_bpp |
||
2430 | mario79 | 4454 | ;----------------------------------------------------------------------------- |
4455 | align 4 |
||
2288 | clevermous | 4456 | putimage_init24bpp: |
4457 | lea eax, [eax*3] |
||
4458 | putimage_init8bpp: |
||
2727 | dunkaist | 4459 | putimage_init9bpp: |
2288 | clevermous | 4460 | ret |
2430 | mario79 | 4461 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4462 | align 16 |
4463 | putimage_get24bpp: |
||
4464 | movzx eax, byte [esi+2] |
||
4465 | shl eax, 16 |
||
4466 | mov ax, [esi] |
||
4467 | add esi, 3 |
||
4468 | ret 4 |
||
2430 | mario79 | 4469 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4470 | align 16 |
4471 | putimage_get8bpp: |
||
4472 | movzx eax, byte [esi] |
||
4473 | push edx |
||
4474 | mov edx, [esp+8] |
||
4475 | mov eax, [edx+eax*4] |
||
4476 | pop edx |
||
4477 | inc esi |
||
4478 | ret 4 |
||
2430 | mario79 | 4479 | ;----------------------------------------------------------------------------- |
2727 | dunkaist | 4480 | align 16 |
4481 | putimage_get9bpp: |
||
4482 | lodsb |
||
4483 | mov ah, al |
||
4484 | shl eax, 8 |
||
4485 | mov al, ah |
||
4486 | ret 4 |
||
4487 | ;----------------------------------------------------------------------------- |
||
2430 | mario79 | 4488 | align 4 |
2288 | clevermous | 4489 | putimage_init1bpp: |
4490 | add eax, ecx |
||
4491 | push ecx |
||
4492 | add eax, 7 |
||
4493 | add ecx, 7 |
||
4494 | shr eax, 3 |
||
4495 | shr ecx, 3 |
||
4496 | sub eax, ecx |
||
4497 | pop ecx |
||
4498 | ret |
||
2430 | mario79 | 4499 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4500 | align 16 |
4501 | putimage_get1bpp: |
||
4502 | push edx |
||
4503 | mov edx, [esp+8] |
||
4504 | mov al, [edx] |
||
4505 | add al, al |
||
4506 | jnz @f |
||
4507 | lodsb |
||
4508 | adc al, al |
||
4509 | @@: |
||
4510 | mov [edx], al |
||
4511 | sbb eax, eax |
||
4512 | and eax, [edx+8] |
||
4513 | add eax, [edx+4] |
||
4514 | pop edx |
||
4515 | ret 4 |
||
2430 | mario79 | 4516 | ;----------------------------------------------------------------------------- |
4517 | align 4 |
||
2288 | clevermous | 4518 | putimage_init2bpp: |
4519 | add eax, ecx |
||
4520 | push ecx |
||
4521 | add ecx, 3 |
||
4522 | add eax, 3 |
||
4523 | shr ecx, 2 |
||
4524 | shr eax, 2 |
||
4525 | sub eax, ecx |
||
4526 | pop ecx |
||
4527 | ret |
||
2430 | mario79 | 4528 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4529 | align 16 |
4530 | putimage_get2bpp: |
||
4531 | push edx |
||
4532 | mov edx, [esp+8] |
||
4533 | mov al, [edx] |
||
4534 | mov ah, al |
||
4535 | shr al, 6 |
||
4536 | shl ah, 2 |
||
4537 | jnz .nonewbyte |
||
4538 | lodsb |
||
4539 | mov ah, al |
||
4540 | shr al, 6 |
||
4541 | shl ah, 2 |
||
4542 | add ah, 1 |
||
4543 | .nonewbyte: |
||
4544 | mov [edx], ah |
||
4545 | mov edx, [edx+4] |
||
4546 | movzx eax, al |
||
4547 | mov eax, [edx+eax*4] |
||
4548 | pop edx |
||
4549 | ret 4 |
||
2430 | mario79 | 4550 | ;----------------------------------------------------------------------------- |
4551 | align 4 |
||
2288 | clevermous | 4552 | putimage_init4bpp: |
4553 | add eax, ecx |
||
4554 | push ecx |
||
4555 | add ecx, 1 |
||
4556 | add eax, 1 |
||
4557 | shr ecx, 1 |
||
4558 | shr eax, 1 |
||
4559 | sub eax, ecx |
||
4560 | pop ecx |
||
4561 | ret |
||
2430 | mario79 | 4562 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4563 | align 16 |
4564 | putimage_get4bpp: |
||
4565 | push edx |
||
4566 | mov edx, [esp+8] |
||
4567 | add byte [edx], 80h |
||
4568 | jc @f |
||
4569 | movzx eax, byte [edx+1] |
||
4570 | mov edx, [edx+4] |
||
4571 | and eax, 0x0F |
||
4572 | mov eax, [edx+eax*4] |
||
4573 | pop edx |
||
4574 | ret 4 |
||
4575 | @@: |
||
4576 | movzx eax, byte [esi] |
||
4577 | add esi, 1 |
||
4578 | mov [edx+1], al |
||
4579 | shr eax, 4 |
||
4580 | mov edx, [edx+4] |
||
4581 | mov eax, [edx+eax*4] |
||
4582 | pop edx |
||
4583 | ret 4 |
||
2430 | mario79 | 4584 | ;----------------------------------------------------------------------------- |
4585 | align 4 |
||
2288 | clevermous | 4586 | putimage_init32bpp: |
4587 | shl eax, 2 |
||
4588 | ret |
||
2430 | mario79 | 4589 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4590 | align 16 |
4591 | putimage_get32bpp: |
||
4592 | lodsd |
||
4593 | ret 4 |
||
2430 | mario79 | 4594 | ;----------------------------------------------------------------------------- |
4595 | align 4 |
||
2288 | clevermous | 4596 | putimage_init15bpp: |
4597 | putimage_init16bpp: |
||
4598 | add eax, eax |
||
4599 | ret |
||
2430 | mario79 | 4600 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4601 | align 16 |
4602 | putimage_get15bpp: |
||
4603 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
||
4604 | push ecx edx |
||
4605 | movzx eax, word [esi] |
||
4606 | add esi, 2 |
||
4607 | mov ecx, eax |
||
4608 | mov edx, eax |
||
4609 | and eax, 0x1F |
||
4610 | and ecx, 0x1F shl 5 |
||
4611 | and edx, 0x1F shl 10 |
||
4612 | shl eax, 3 |
||
4613 | shl ecx, 6 |
||
4614 | shl edx, 9 |
||
4615 | or eax, ecx |
||
4616 | or eax, edx |
||
4617 | pop edx ecx |
||
4618 | ret 4 |
||
2430 | mario79 | 4619 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4620 | align 16 |
4621 | putimage_get16bpp: |
||
4622 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
||
4623 | push ecx edx |
||
4624 | movzx eax, word [esi] |
||
4625 | add esi, 2 |
||
4626 | mov ecx, eax |
||
4627 | mov edx, eax |
||
4628 | and eax, 0x1F |
||
4629 | and ecx, 0x3F shl 5 |
||
4630 | and edx, 0x1F shl 11 |
||
4631 | shl eax, 3 |
||
4632 | shl ecx, 5 |
||
4633 | shl edx, 8 |
||
4634 | or eax, ecx |
||
4635 | or eax, edx |
||
4636 | pop edx ecx |
||
4637 | ret 4 |
||
2430 | mario79 | 4638 | ;----------------------------------------------------------------------------- |
4639 | ;align 4 |
||
2288 | clevermous | 4640 | ; eax x beginning |
4641 | ; ebx y beginning |
||
4642 | ; ecx x end |
||
4643 | ; edx y end |
||
4644 | ; edi color |
||
2430 | mario79 | 4645 | ;__sys_drawbar: |
4646 | ; mov esi, [current_slot] |
||
4647 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
||
4648 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
||
4649 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
||
4650 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
||
4651 | ;-------------------------------------- |
||
4652 | ;align 4 |
||
4653 | ;.forced: |
||
4654 | ; call vesa20_drawbar |
||
2407 | mario79 | 4655 | ; call [draw_pointer] |
4656 | ; ret |
||
2430 | mario79 | 4657 | ;----------------------------------------------------------------------------- |
4658 | align 4 |
||
2288 | clevermous | 4659 | kb_read: |
4660 | |||
4661 | push ecx edx |
||
4662 | |||
4663 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
4664 | kr_loop: |
||
4665 | in al, 0x64 |
||
4666 | test al, 1 |
||
4667 | jnz kr_ready |
||
4668 | loop kr_loop |
||
4669 | mov ah, 1 |
||
4670 | jmp kr_exit |
||
4671 | kr_ready: |
||
4672 | push ecx |
||
4673 | mov ecx, 32 |
||
4674 | kr_delay: |
||
4675 | loop kr_delay |
||
4676 | pop ecx |
||
4677 | in al, 0x60 |
||
4678 | xor ah, ah |
||
4679 | kr_exit: |
||
4680 | |||
4681 | pop edx ecx |
||
4682 | |||
4683 | ret |
||
2430 | mario79 | 4684 | ;----------------------------------------------------------------------------- |
4685 | align 4 |
||
2288 | clevermous | 4686 | kb_write: |
4687 | |||
4688 | push ecx edx |
||
4689 | |||
4690 | mov dl, al |
||
4691 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
||
4692 | ; kw_loop1: |
||
4693 | ; in al,0x64 |
||
4694 | ; test al,0x20 |
||
4695 | ; jz kw_ok1 |
||
4696 | ; loop kw_loop1 |
||
4697 | ; mov ah,1 |
||
4698 | ; jmp kw_exit |
||
4699 | ; kw_ok1: |
||
4700 | in al, 0x60 |
||
4701 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
4702 | kw_loop: |
||
4703 | in al, 0x64 |
||
4704 | test al, 2 |
||
4705 | jz kw_ok |
||
4706 | loop kw_loop |
||
4707 | mov ah, 1 |
||
4708 | jmp kw_exit |
||
4709 | kw_ok: |
||
4710 | mov al, dl |
||
4711 | out 0x60, al |
||
4712 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
4713 | kw_loop3: |
||
4714 | in al, 0x64 |
||
4715 | test al, 2 |
||
4716 | jz kw_ok3 |
||
4717 | loop kw_loop3 |
||
4718 | mov ah, 1 |
||
4719 | jmp kw_exit |
||
4720 | kw_ok3: |
||
4721 | mov ah, 8 |
||
4722 | kw_loop4: |
||
4723 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
4724 | kw_loop5: |
||
4725 | in al, 0x64 |
||
4726 | test al, 1 |
||
4727 | jnz kw_ok4 |
||
4728 | loop kw_loop5 |
||
4729 | dec ah |
||
4730 | jnz kw_loop4 |
||
4731 | kw_ok4: |
||
4732 | xor ah, ah |
||
4733 | kw_exit: |
||
4734 | |||
4735 | pop edx ecx |
||
4736 | |||
4737 | ret |
||
2430 | mario79 | 4738 | ;----------------------------------------------------------------------------- |
4739 | align 4 |
||
2288 | clevermous | 4740 | kb_cmd: |
4741 | |||
4742 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
4743 | c_wait: |
||
4744 | in al, 0x64 |
||
4745 | test al, 2 |
||
4746 | jz c_send |
||
4747 | loop c_wait |
||
4748 | jmp c_error |
||
4749 | c_send: |
||
4750 | mov al, bl |
||
4751 | out 0x64, al |
||
4752 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
4753 | c_accept: |
||
4754 | in al, 0x64 |
||
4755 | test al, 2 |
||
4756 | jz c_ok |
||
4757 | loop c_accept |
||
4758 | c_error: |
||
4759 | mov ah, 1 |
||
4760 | jmp c_exit |
||
4761 | c_ok: |
||
4762 | xor ah, ah |
||
4763 | c_exit: |
||
4764 | ret |
||
4765 | |||
4766 | |||
4767 | setmouse: ; set mousepicture -pointer |
||
4768 | ; ps2 mouse enable |
||
4769 | |||
2430 | mario79 | 4770 | ; mov [MOUSE_PICTURE], dword mousepointer |
2288 | clevermous | 4771 | |
4772 | cli |
||
4773 | |||
4774 | ret |
||
4775 | |||
4776 | if used _rdtsc |
||
4777 | _rdtsc: |
||
4778 | bt [cpu_caps], CAPS_TSC |
||
4779 | jnc ret_rdtsc |
||
4780 | rdtsc |
||
4781 | ret |
||
4782 | ret_rdtsc: |
||
4783 | mov edx, 0xffffffff |
||
4784 | mov eax, 0xffffffff |
||
4785 | ret |
||
4786 | end if |
||
4787 | |||
4788 | sys_msg_board_str: |
||
4789 | |||
4790 | pushad |
||
4791 | @@: |
||
4792 | cmp [esi], byte 0 |
||
4793 | je @f |
||
3614 | shikhin | 4794 | mov ebx, 1 |
4795 | movzx ecx, byte [esi] |
||
2288 | clevermous | 4796 | call sys_msg_board |
4797 | inc esi |
||
4798 | jmp @b |
||
4799 | @@: |
||
4800 | popad |
||
4801 | ret |
||
4802 | |||
4803 | sys_msg_board_byte: |
||
4804 | ; in: al = byte to display |
||
4805 | ; out: nothing |
||
4806 | ; destroys: nothing |
||
4807 | pushad |
||
4808 | mov ecx, 2 |
||
4809 | shl eax, 24 |
||
4810 | jmp @f |
||
4811 | |||
4812 | sys_msg_board_word: |
||
4813 | ; in: ax = word to display |
||
4814 | ; out: nothing |
||
4815 | ; destroys: nothing |
||
4816 | pushad |
||
4817 | mov ecx, 4 |
||
4818 | shl eax, 16 |
||
4819 | jmp @f |
||
4820 | |||
4821 | sys_msg_board_dword: |
||
4822 | ; in: eax = dword to display |
||
4823 | ; out: nothing |
||
4824 | ; destroys: nothing |
||
4825 | pushad |
||
4826 | mov ecx, 8 |
||
4827 | @@: |
||
4828 | push ecx |
||
4829 | rol eax, 4 |
||
4830 | push eax |
||
4831 | and al, 0xF |
||
4832 | cmp al, 10 |
||
4833 | sbb al, 69h |
||
4834 | das |
||
3614 | shikhin | 4835 | mov cl, al |
4836 | xor ebx, ebx |
||
4837 | inc ebx |
||
2288 | clevermous | 4838 | call sys_msg_board |
4839 | pop eax |
||
4840 | pop ecx |
||
4841 | loop @b |
||
4842 | popad |
||
4843 | ret |
||
4844 | |||
3392 | clevermous | 4845 | msg_board_data_size = 65536 ; Must be power of two |
4846 | |||
2288 | clevermous | 4847 | uglobal |
3392 | clevermous | 4848 | msg_board_data rb msg_board_data_size |
2288 | clevermous | 4849 | msg_board_count dd 0x0 |
4850 | endg |
||
4851 | |||
4852 | sys_msg_board: |
||
4853 | |||
3614 | shikhin | 4854 | ; ebx=1 : write : bl byte to write |
4855 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
||
2288 | clevermous | 4856 | |
3614 | shikhin | 4857 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4858 | mov eax, ebx |
||
4859 | mov ebx, ecx |
||
4860 | |||
2288 | clevermous | 4861 | mov ecx, [msg_board_count] |
4862 | cmp eax, 1 |
||
4863 | jne .smbl1 |
||
4864 | |||
4865 | if defined debug_com_base |
||
4866 | |||
4867 | push dx ax |
||
4868 | |||
4869 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
||
4870 | mov dx, debug_com_base+5 |
||
4871 | in al, dx |
||
4872 | test al, 1 shl 5 |
||
4873 | jz @r |
||
4874 | |||
4875 | mov dx, debug_com_base ; Output the byte |
||
4876 | mov al, bl |
||
4877 | out dx, al |
||
4878 | |||
4879 | pop ax dx |
||
4880 | |||
4881 | end if |
||
4882 | |||
4883 | mov [msg_board_data+ecx], bl |
||
3777 | yogev_ezra | 4884 | ; // if debug_direct_print == 1 |
4885 | cmp byte [debug_direct_print], 1 |
||
4886 | jnz @f |
||
3507 | clevermous | 4887 | pusha |
4888 | iglobal |
||
3778 | mario79 | 4889 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
3507 | clevermous | 4890 | endg |
4891 | lea edx, [msg_board_data+ecx] |
||
4892 | mov ecx, 0x40FFFFFF |
||
4893 | mov ebx, [msg_board_pos] |
||
4894 | mov edi, 1 |
||
4895 | mov esi, 1 |
||
4896 | call dtext |
||
4897 | popa |
||
4898 | add word [msg_board_pos+2], 6 |
||
4899 | cmp bl, 10 |
||
4900 | jnz @f |
||
3778 | mario79 | 4901 | mov word [msg_board_pos+2], (42*6) |
3507 | clevermous | 4902 | add word [msg_board_pos], 10 |
3613 | clevermous | 4903 | mov ax, word [Screen_Max_Y] |
3507 | clevermous | 4904 | cmp word [msg_board_pos], ax |
4905 | jbe @f |
||
4906 | mov word [msg_board_pos], 10 |
||
4907 | @@: |
||
3777 | yogev_ezra | 4908 | ; // end if |
4909 | |||
3534 | clevermous | 4910 | if 0 |
4911 | pusha |
||
4912 | mov al, bl |
||
4913 | mov edx, 402h |
||
4914 | out dx, al |
||
4915 | popa |
||
4916 | end if |
||
2288 | clevermous | 4917 | inc ecx |
3392 | clevermous | 4918 | and ecx, msg_board_data_size - 1 |
2288 | clevermous | 4919 | mov [msg_board_count], ecx |
3614 | shikhin | 4920 | |
4921 | pop ebx eax |
||
2288 | clevermous | 4922 | ret |
4923 | .smbl1: |
||
4924 | cmp eax, 2 |
||
4925 | jne .smbl2 |
||
4926 | test ecx, ecx |
||
4927 | jz .smbl21 |
||
3614 | shikhin | 4928 | |
4929 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
||
2288 | clevermous | 4930 | mov eax, msg_board_data+1 |
4931 | mov ebx, msg_board_data |
||
4932 | movzx edx, byte [ebx] |
||
4933 | call memmove |
||
4934 | dec [msg_board_count] |
||
3614 | shikhin | 4935 | mov [esp + 32], edx ;eax |
4936 | mov [esp + 20], dword 1 |
||
2288 | clevermous | 4937 | ret |
4938 | .smbl21: |
||
3614 | shikhin | 4939 | mov [esp+32], ecx |
4940 | mov [esp+20], ecx |
||
2288 | clevermous | 4941 | .smbl2: |
3614 | shikhin | 4942 | pop ebx eax |
2288 | clevermous | 4943 | ret |
4944 | |||
4945 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4946 | ;; 66 sys function. ;; |
||
4947 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
||
4948 | ;; out eax ;; |
||
4949 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4950 | iglobal |
||
4951 | align 4 |
||
4952 | f66call: |
||
4953 | dd sys_process_def.1 ; 1 = set keyboard mode |
||
4954 | dd sys_process_def.2 ; 2 = get keyboard mode |
||
4955 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
||
2709 | mario79 | 4956 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4957 | dd sys_process_def.5 ; 5 = delete installed hotkey |
||
4958 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
||
4959 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
||
2288 | clevermous | 4960 | endg |
2709 | mario79 | 4961 | ;----------------------------------------------------------------------------- |
4962 | align 4 |
||
2288 | clevermous | 4963 | sys_process_def: |
4964 | dec ebx |
||
2709 | mario79 | 4965 | cmp ebx, 7 |
4966 | jae .not_support ;if >=8 then or eax,-1 |
||
2288 | clevermous | 4967 | |
4968 | mov edi, [CURRENT_TASK] |
||
4969 | jmp dword [f66call+ebx*4] |
||
4970 | |||
4971 | .not_support: |
||
4972 | or eax, -1 |
||
4973 | ret |
||
2709 | mario79 | 4974 | ;----------------------------------------------------------------------------- |
4975 | align 4 |
||
2288 | clevermous | 4976 | .1: |
4977 | shl edi, 8 |
||
4978 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
||
4979 | |||
4980 | ret |
||
2709 | mario79 | 4981 | ;----------------------------------------------------------------------------- |
4982 | align 4 |
||
2288 | clevermous | 4983 | .2: ; 2 = get keyboard mode |
4984 | shl edi, 8 |
||
4985 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
||
4986 | mov [esp+32], eax |
||
4987 | ret |
||
2709 | mario79 | 4988 | ;----------------------------------------------------------------------------- |
4989 | align 4 |
||
2288 | clevermous | 4990 | .3: ;3 = get keyboard ctrl, alt, shift |
4991 | mov eax, [kb_state] |
||
4992 | mov [esp+32], eax |
||
4993 | ret |
||
2709 | mario79 | 4994 | ;----------------------------------------------------------------------------- |
4995 | align 4 |
||
2288 | clevermous | 4996 | .4: |
4997 | mov eax, hotkey_list |
||
4998 | @@: |
||
4999 | cmp dword [eax+8], 0 |
||
5000 | jz .found_free |
||
5001 | add eax, 16 |
||
5002 | cmp eax, hotkey_list+16*256 |
||
5003 | jb @b |
||
5004 | mov dword [esp+32], 1 |
||
5005 | ret |
||
5006 | .found_free: |
||
5007 | mov [eax+8], edi |
||
5008 | mov [eax+4], edx |
||
5009 | movzx ecx, cl |
||
5010 | lea ecx, [hotkey_scancodes+ecx*4] |
||
5011 | mov edx, [ecx] |
||
5012 | mov [eax], edx |
||
5013 | mov [ecx], eax |
||
5014 | mov [eax+12], ecx |
||
3383 | hidnplayr | 5015 | test edx, edx |
5016 | jz @f |
||
2288 | clevermous | 5017 | mov [edx+12], eax |
5018 | @@: |
||
5019 | and dword [esp+32], 0 |
||
5020 | ret |
||
2709 | mario79 | 5021 | ;----------------------------------------------------------------------------- |
5022 | align 4 |
||
2288 | clevermous | 5023 | .5: |
5024 | movzx ebx, cl |
||
5025 | lea ebx, [hotkey_scancodes+ebx*4] |
||
5026 | mov eax, [ebx] |
||
5027 | .scan: |
||
5028 | test eax, eax |
||
5029 | jz .notfound |
||
5030 | cmp [eax+8], edi |
||
5031 | jnz .next |
||
5032 | cmp [eax+4], edx |
||
5033 | jz .found |
||
5034 | .next: |
||
5035 | mov eax, [eax] |
||
5036 | jmp .scan |
||
5037 | .notfound: |
||
5038 | mov dword [esp+32], 1 |
||
5039 | ret |
||
5040 | .found: |
||
5041 | mov ecx, [eax] |
||
5042 | jecxz @f |
||
5043 | mov edx, [eax+12] |
||
5044 | mov [ecx+12], edx |
||
5045 | @@: |
||
5046 | mov ecx, [eax+12] |
||
5047 | mov edx, [eax] |
||
5048 | mov [ecx], edx |
||
5049 | xor edx, edx |
||
5050 | mov [eax+4], edx |
||
5051 | mov [eax+8], edx |
||
5052 | mov [eax+12], edx |
||
5053 | mov [eax], edx |
||
5054 | mov [esp+32], edx |
||
5055 | ret |
||
2709 | mario79 | 5056 | ;----------------------------------------------------------------------------- |
5057 | align 4 |
||
5058 | .6: |
||
5059 | pushfd |
||
5060 | cli |
||
5061 | mov eax, [PID_lock_input] |
||
5062 | test eax, eax |
||
5063 | jnz @f |
||
5064 | ; get current PID |
||
5065 | mov eax, [CURRENT_TASK] |
||
5066 | shl eax, 5 |
||
5067 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
||
5068 | ; set current PID for lock input |
||
5069 | mov [PID_lock_input], eax |
||
5070 | @@: |
||
5071 | popfd |
||
5072 | ret |
||
5073 | ;----------------------------------------------------------------------------- |
||
5074 | align 4 |
||
5075 | .7: |
||
5076 | mov eax, [PID_lock_input] |
||
5077 | test eax, eax |
||
5078 | jz @f |
||
5079 | ; get current PID |
||
5080 | mov ebx, [CURRENT_TASK] |
||
5081 | shl ebx, 5 |
||
5082 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
||
5083 | ; compare current lock input with current PID |
||
5084 | cmp ebx, eax |
||
5085 | jne @f |
||
2288 | clevermous | 5086 | |
2709 | mario79 | 5087 | xor eax, eax |
5088 | mov [PID_lock_input], eax |
||
5089 | @@: |
||
5090 | ret |
||
5091 | ;----------------------------------------------------------------------------- |
||
5092 | uglobal |
||
5093 | PID_lock_input dd 0x0 |
||
5094 | endg |
||
2288 | clevermous | 5095 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5096 | ;; 61 sys function. ;; |
||
5097 | ;; in eax=61,ebx in [1..3] ;; |
||
5098 | ;; out eax ;; |
||
5099 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
5100 | iglobal |
||
5101 | align 4 |
||
5102 | f61call: |
||
5103 | dd sys_gs.1 ; resolution |
||
5104 | dd sys_gs.2 ; bits per pixel |
||
5105 | dd sys_gs.3 ; bytes per scanline |
||
5106 | endg |
||
5107 | |||
5108 | |||
5109 | align 4 |
||
5110 | |||
5111 | sys_gs: ; direct screen access |
||
5112 | dec ebx |
||
5113 | cmp ebx, 2 |
||
5114 | ja .not_support |
||
5115 | jmp dword [f61call+ebx*4] |
||
5116 | .not_support: |
||
5117 | or [esp+32], dword -1 |
||
5118 | ret |
||
5119 | |||
5120 | |||
5121 | .1: ; resolution |
||
5122 | mov eax, [Screen_Max_X] |
||
5123 | shl eax, 16 |
||
3606 | Serge | 5124 | mov ax, word [Screen_Max_Y] |
2288 | clevermous | 5125 | add eax, 0x00010001 |
5126 | mov [esp+32], eax |
||
5127 | ret |
||
5128 | .2: ; bits per pixel |
||
3537 | Serge | 5129 | mov eax, [_display.bpp] |
2288 | clevermous | 5130 | mov [esp+32], eax |
5131 | ret |
||
5132 | .3: ; bytes per scanline |
||
3606 | Serge | 5133 | mov eax, [_display.pitch] |
2288 | clevermous | 5134 | mov [esp+32], eax |
5135 | ret |
||
5136 | |||
5137 | align 4 ; system functions |
||
5138 | |||
5139 | syscall_setpixel: ; SetPixel |
||
5140 | |||
5141 | mov eax, ebx |
||
5142 | mov ebx, ecx |
||
5143 | mov ecx, edx |
||
5144 | mov edx, [TASK_BASE] |
||
5145 | add eax, [edx-twdw+WDATA.box.left] |
||
5146 | add ebx, [edx-twdw+WDATA.box.top] |
||
5147 | mov edi, [current_slot] |
||
5148 | add eax, [edi+APPDATA.wnd_clientbox.left] |
||
5149 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
||
5150 | xor edi, edi ; no force |
||
2430 | mario79 | 5151 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
2453 | mario79 | 5152 | ; jmp [putpixel] |
5153 | jmp __sys_putpixel |
||
2288 | clevermous | 5154 | |
5155 | align 4 |
||
5156 | |||
5157 | syscall_writetext: ; WriteText |
||
5158 | |||
5159 | mov eax, [TASK_BASE] |
||
5160 | mov ebp, [eax-twdw+WDATA.box.left] |
||
5161 | push esi |
||
5162 | mov esi, [current_slot] |
||
5163 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
||
5164 | shl ebp, 16 |
||
5165 | add ebp, [eax-twdw+WDATA.box.top] |
||
5166 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
||
5167 | pop esi |
||
3462 | mario79 | 5168 | test ecx, 0x08000000 ; redirect the output to the user area |
5169 | jnz @f |
||
2288 | clevermous | 5170 | add ebx, ebp |
3462 | mario79 | 5171 | align 4 |
5172 | @@: |
||
2288 | clevermous | 5173 | mov eax, edi |
2536 | mario79 | 5174 | test ecx, 0x08000000 ; redirect the output to the user area |
5175 | jnz dtext |
||
2288 | clevermous | 5176 | xor edi, edi |
5177 | jmp dtext |
||
5178 | |||
5179 | align 4 |
||
5180 | |||
5181 | syscall_openramdiskfile: ; OpenRamdiskFile |
||
5182 | |||
5183 | mov eax, ebx |
||
5184 | mov ebx, ecx |
||
5185 | mov ecx, edx |
||
5186 | mov edx, esi |
||
5187 | mov esi, 12 |
||
5188 | call fileread |
||
5189 | mov [esp+32], eax |
||
5190 | ret |
||
5191 | |||
5192 | align 4 |
||
5193 | |||
5194 | syscall_drawrect: ; DrawRect |
||
5195 | |||
5196 | mov edi, edx ; color + gradient |
||
5197 | and edi, 0x80FFFFFF |
||
5198 | test bx, bx ; x.size |
||
5199 | je .drectr |
||
5200 | test cx, cx ; y.size |
||
5201 | je .drectr |
||
5202 | |||
5203 | mov eax, ebx ; bad idea |
||
5204 | mov ebx, ecx |
||
5205 | |||
5206 | movzx ecx, ax ; ecx - x.size |
||
5207 | shr eax, 16 ; eax - x.coord |
||
5208 | movzx edx, bx ; edx - y.size |
||
5209 | shr ebx, 16 ; ebx - y.coord |
||
5210 | mov esi, [current_slot] |
||
5211 | |||
5212 | add eax, [esi + APPDATA.wnd_clientbox.left] |
||
5213 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
||
5214 | add ecx, eax |
||
5215 | add edx, ebx |
||
2453 | mario79 | 5216 | ; jmp [drawbar] |
5217 | jmp vesa20_drawbar |
||
2288 | clevermous | 5218 | .drectr: |
5219 | ret |
||
5220 | |||
5221 | align 4 |
||
5222 | syscall_getscreensize: ; GetScreenSize |
||
3606 | Serge | 5223 | mov ax, word [Screen_Max_X] |
2288 | clevermous | 5224 | shl eax, 16 |
3606 | Serge | 5225 | mov ax, word [Screen_Max_Y] |
2288 | clevermous | 5226 | mov [esp + 32], eax |
5227 | ret |
||
5228 | |||
5229 | align 4 |
||
5230 | |||
5231 | syscall_cdaudio: ; CD |
||
5232 | |||
5233 | cmp ebx, 4 |
||
5234 | jb .audio |
||
5235 | jz .eject |
||
5236 | cmp ebx, 5 |
||
5237 | jnz .ret |
||
5238 | .load: |
||
5239 | call .reserve |
||
5240 | call LoadMedium |
||
5241 | ;call .free |
||
5242 | jmp .free |
||
5243 | ; ret |
||
5244 | .eject: |
||
5245 | call .reserve |
||
5246 | call clear_CD_cache |
||
5247 | call allow_medium_removal |
||
5248 | call EjectMedium |
||
5249 | ; call .free |
||
5250 | jmp .free |
||
5251 | ; ret |
||
5252 | .audio: |
||
5253 | call sys_cd_audio |
||
5254 | mov [esp+36-4], eax |
||
5255 | .ret: |
||
5256 | ret |
||
5257 | |||
5258 | .reserve: |
||
5259 | call reserve_cd |
||
5260 | mov eax, ecx |
||
5261 | shr eax, 1 |
||
5262 | and eax, 1 |
||
5263 | inc eax |
||
5264 | mov [ChannelNumber], ax |
||
5265 | mov eax, ecx |
||
5266 | and eax, 1 |
||
5267 | mov [DiskNumber], al |
||
5268 | call reserve_cd_channel |
||
5269 | and ebx, 3 |
||
5270 | inc ebx |
||
5271 | mov [cdpos], ebx |
||
5272 | add ebx, ebx |
||
5273 | mov cl, 8 |
||
5274 | sub cl, bl |
||
5275 | mov al, [DRIVE_DATA+1] |
||
5276 | shr al, cl |
||
5277 | test al, 2 |
||
5278 | jz .free;.err |
||
5279 | ret |
||
5280 | .free: |
||
5281 | call free_cd_channel |
||
5282 | and [cd_status], 0 |
||
5283 | ret |
||
5284 | .err: |
||
5285 | call .free |
||
5286 | ; pop eax |
||
5287 | ret |
||
2511 | mario79 | 5288 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 5289 | align 4 |
2511 | mario79 | 5290 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5291 | cmp ebx, [Screen_Max_X] |
||
5292 | jbe @f |
||
5293 | cmp ecx, [Screen_Max_Y] |
||
5294 | jbe @f |
||
5295 | xor eax, eax |
||
5296 | jmp .store |
||
5297 | ;-------------------------------------- |
||
5298 | align 4 |
||
5299 | @@: |
||
5300 | mov eax, [d_width_calc_area + ecx*4] |
||
5301 | add eax, [_WinMapAddress] |
||
5302 | movzx eax, byte[eax+ebx] ; get value for current point |
||
5303 | ;-------------------------------------- |
||
5304 | align 4 |
||
5305 | .store: |
||
5306 | mov [esp + 32], eax |
||
5307 | ret |
||
5308 | ;----------------------------------------------------------------------------- |
||
5309 | align 4 |
||
2288 | clevermous | 5310 | syscall_getpixel: ; GetPixel |
5311 | mov ecx, [Screen_Max_X] |
||
5312 | inc ecx |
||
5313 | xor edx, edx |
||
5314 | mov eax, ebx |
||
5315 | div ecx |
||
5316 | mov ebx, edx |
||
5317 | xchg eax, ebx |
||
2430 | mario79 | 5318 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
2288 | clevermous | 5319 | call dword [GETPIXEL]; eax - x, ebx - y |
5320 | mov [esp + 32], ecx |
||
5321 | ret |
||
2509 | mario79 | 5322 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 5323 | align 4 |
5324 | syscall_getarea: |
||
5325 | ;eax = 36 |
||
5326 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
||
5327 | ;ecx = [size x]*65536 + [size y] |
||
5328 | ;edx = [start x]*65536 + [start y] |
||
5329 | pushad |
||
5330 | mov edi, ebx |
||
5331 | mov eax, edx |
||
5332 | shr eax, 16 |
||
5333 | mov ebx, edx |
||
5334 | and ebx, 0xffff |
||
5335 | dec eax |
||
5336 | dec ebx |
||
5337 | ; eax - x, ebx - y |
||
5338 | mov edx, ecx |
||
5339 | |||
5340 | shr ecx, 16 |
||
5341 | and edx, 0xffff |
||
5342 | mov esi, ecx |
||
5343 | ; ecx - size x, edx - size y |
||
5344 | |||
5345 | mov ebp, edx |
||
5346 | dec ebp |
||
5347 | lea ebp, [ebp*3] |
||
5348 | |||
5349 | imul ebp, esi |
||
5350 | |||
5351 | mov esi, ecx |
||
5352 | dec esi |
||
5353 | lea esi, [esi*3] |
||
5354 | |||
5355 | add ebp, esi |
||
5356 | add ebp, edi |
||
5357 | |||
5358 | add ebx, edx |
||
2509 | mario79 | 5359 | ;-------------------------------------- |
5360 | align 4 |
||
2288 | clevermous | 5361 | .start_y: |
5362 | push ecx edx |
||
2509 | mario79 | 5363 | ;-------------------------------------- |
5364 | align 4 |
||
2288 | clevermous | 5365 | .start_x: |
5366 | push eax ebx ecx |
||
5367 | add eax, ecx |
||
5368 | |||
2430 | mario79 | 5369 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
2288 | clevermous | 5370 | call dword [GETPIXEL]; eax - x, ebx - y |
5371 | |||
5372 | mov [ebp], cx |
||
5373 | shr ecx, 16 |
||
5374 | mov [ebp+2], cl |
||
5375 | |||
5376 | pop ecx ebx eax |
||
5377 | sub ebp, 3 |
||
5378 | dec ecx |
||
5379 | jnz .start_x |
||
5380 | pop edx ecx |
||
5381 | dec ebx |
||
5382 | dec edx |
||
5383 | jnz .start_y |
||
5384 | popad |
||
5385 | ret |
||
2509 | mario79 | 5386 | ;----------------------------------------------------------------------------- |
5387 | align 4 |
||
5388 | syscall_putarea_backgr: |
||
5389 | ;eax = 25 |
||
5390 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
||
5391 | ;ecx = [size x]*65536 + [size y] |
||
5392 | ;edx = [start x]*65536 + [start y] |
||
5393 | pushad |
||
5394 | mov edi, ebx |
||
5395 | mov eax, edx |
||
5396 | shr eax, 16 |
||
5397 | mov ebx, edx |
||
5398 | and ebx, 0xffff |
||
5399 | dec eax |
||
5400 | dec ebx |
||
5401 | ; eax - x, ebx - y |
||
5402 | mov edx, ecx |
||
5403 | shr ecx, 16 |
||
5404 | and edx, 0xffff |
||
5405 | mov esi, ecx |
||
5406 | ; ecx - size x, edx - size y |
||
5407 | mov ebp, edx |
||
5408 | dec ebp |
||
5409 | shl ebp, 2 |
||
2288 | clevermous | 5410 | |
2509 | mario79 | 5411 | imul ebp, esi |
5412 | |||
5413 | mov esi, ecx |
||
5414 | dec esi |
||
5415 | shl esi, 2 |
||
5416 | |||
5417 | add ebp, esi |
||
5418 | add ebp, edi |
||
5419 | |||
5420 | add ebx, edx |
||
5421 | ;-------------------------------------- |
||
2288 | clevermous | 5422 | align 4 |
2509 | mario79 | 5423 | .start_y: |
5424 | push ecx edx |
||
5425 | ;-------------------------------------- |
||
5426 | align 4 |
||
5427 | .start_x: |
||
5428 | push eax ecx |
||
5429 | add eax, ecx |
||
2288 | clevermous | 5430 | |
2509 | mario79 | 5431 | mov ecx, [ebp] |
5432 | rol ecx, 8 |
||
5433 | test cl, cl ; transparensy = 0 |
||
5434 | jz .no_put |
||
5435 | |||
5436 | xor cl, cl |
||
5437 | ror ecx, 8 |
||
5438 | |||
5439 | pushad |
||
5440 | mov edx, [d_width_calc_area + ebx*4] |
||
5441 | add edx, [_WinMapAddress] |
||
5442 | movzx edx, byte [eax+edx] |
||
5443 | cmp dl, byte 1 |
||
5444 | jne @f |
||
5445 | |||
5446 | call dword [PUTPIXEL]; eax - x, ebx - y |
||
5447 | ;-------------------------------------- |
||
5448 | align 4 |
||
5449 | @@: |
||
5450 | popad |
||
5451 | ;-------------------------------------- |
||
5452 | align 4 |
||
5453 | .no_put: |
||
5454 | pop ecx eax |
||
2991 | Serge | 5455 | |
2509 | mario79 | 5456 | sub ebp, 4 |
5457 | dec ecx |
||
5458 | jnz .start_x |
||
5459 | |||
5460 | pop edx ecx |
||
5461 | dec ebx |
||
5462 | dec edx |
||
5463 | jnz .start_y |
||
5464 | |||
5465 | popad |
||
5466 | ret |
||
5467 | ;----------------------------------------------------------------------------- |
||
5468 | align 4 |
||
2288 | clevermous | 5469 | syscall_drawline: ; DrawLine |
5470 | |||
5471 | mov edi, [TASK_BASE] |
||
5472 | movzx eax, word[edi-twdw+WDATA.box.left] |
||
5473 | mov ebp, eax |
||
5474 | mov esi, [current_slot] |
||
5475 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
||
5476 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
||
5477 | add ebp, ebx |
||
5478 | shl eax, 16 |
||
5479 | movzx ebx, word[edi-twdw+WDATA.box.top] |
||
5480 | add eax, ebp |
||
5481 | mov ebp, ebx |
||
5482 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
||
5483 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
||
5484 | add ebp, ecx |
||
5485 | shl ebx, 16 |
||
5486 | xor edi, edi |
||
5487 | add ebx, ebp |
||
5488 | mov ecx, edx |
||
2453 | mario79 | 5489 | ; jmp [draw_line] |
5490 | jmp __sys_draw_line |
||
2288 | clevermous | 5491 | |
5492 | |||
5493 | align 4 |
||
5494 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
||
5495 | |||
5496 | call r_f_port_area |
||
5497 | mov [esp+32], eax |
||
5498 | ret |
||
5499 | |||
5500 | align 4 |
||
5501 | syscall_threads: ; CreateThreads |
||
5502 | ; eax=1 create thread |
||
5503 | ; |
||
5504 | ; ebx=thread start |
||
5505 | ; ecx=thread stack value |
||
5506 | ; |
||
5507 | ; on return : eax = pid |
||
5508 | |||
5509 | call new_sys_threads |
||
5510 | |||
5511 | mov [esp+32], eax |
||
5512 | ret |
||
5513 | |||
5514 | align 4 |
||
5515 | |||
5516 | paleholder: |
||
5517 | ret |
||
2438 | mario79 | 5518 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 5519 | align 4 |
2438 | mario79 | 5520 | calculate_fast_getting_offset_for_WinMapAddress: |
5521 | ; calculate data area for fast getting offset to _WinMapAddress |
||
2446 | mario79 | 5522 | xor eax, eax |
2438 | mario79 | 5523 | mov ecx, [_display.height] |
5524 | mov edi, d_width_calc_area |
||
5525 | cld |
||
5526 | @@: |
||
5527 | stosd |
||
5528 | add eax, [_display.width] |
||
5529 | dec ecx |
||
5530 | jnz @r |
||
5531 | ret |
||
5532 | ;------------------------------------------------------------------------------ |
||
5533 | align 4 |
||
2480 | mario79 | 5534 | calculate_fast_getting_offset_for_LFB: |
5535 | ; calculate data area for fast getting offset to LFB |
||
5536 | xor eax, eax |
||
5537 | mov ecx, [_display.height] |
||
5538 | mov edi, BPSLine_calc_area |
||
5539 | cld |
||
5540 | @@: |
||
5541 | stosd |
||
3606 | Serge | 5542 | add eax, [_display.pitch] |
2480 | mario79 | 5543 | dec ecx |
5544 | jnz @r |
||
5545 | ret |
||
5546 | ;------------------------------------------------------------------------------ |
||
5547 | align 4 |
||
2288 | clevermous | 5548 | set_screen: |
2654 | mario79 | 5549 | ; in: |
5550 | ; eax - new Screen_Max_X |
||
5551 | ; ecx - new BytesPerScanLine |
||
5552 | ; edx - new Screen_Max_Y |
||
2288 | clevermous | 5553 | cmp eax, [Screen_Max_X] |
5554 | jne .set |
||
5555 | |||
5556 | cmp edx, [Screen_Max_Y] |
||
5557 | jne .set |
||
5558 | ret |
||
5559 | .set: |
||
5560 | pushfd |
||
5561 | cli |
||
5562 | |||
5563 | mov [Screen_Max_X], eax |
||
5564 | mov [Screen_Max_Y], edx |
||
3606 | Serge | 5565 | mov [_display.pitch], ecx |
2288 | clevermous | 5566 | |
5567 | mov [screen_workarea.right], eax |
||
5568 | mov [screen_workarea.bottom], edx |
||
5569 | |||
5570 | push ebx |
||
5571 | push esi |
||
5572 | push edi |
||
5573 | |||
5574 | pushad |
||
5575 | |||
2654 | mario79 | 5576 | cmp [do_not_touch_winmap], 1 |
5577 | je @f |
||
5578 | |||
2288 | clevermous | 5579 | stdcall kernel_free, [_WinMapAddress] |
5580 | |||
5581 | mov eax, [_display.width] |
||
5582 | mul [_display.height] |
||
5583 | mov [_WinMapSize], eax |
||
5584 | |||
5585 | stdcall kernel_alloc, eax |
||
5586 | mov [_WinMapAddress], eax |
||
5587 | test eax, eax |
||
5588 | jz .epic_fail |
||
2654 | mario79 | 5589 | ; store for f.18.24 |
5590 | mov eax, [_display.width] |
||
5591 | mov [display_width_standard], eax |
||
2288 | clevermous | 5592 | |
2654 | mario79 | 5593 | mov eax, [_display.height] |
5594 | mov [display_height_standard], eax |
||
5595 | @@: |
||
2438 | mario79 | 5596 | call calculate_fast_getting_offset_for_WinMapAddress |
2545 | mario79 | 5597 | ; for Qemu or non standart video cards |
2991 | Serge | 5598 | ; Unfortunately [BytesPerScanLine] does not always |
2545 | mario79 | 5599 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5600 | call calculate_fast_getting_offset_for_LFB |
||
2288 | clevermous | 5601 | popad |
5602 | |||
5603 | call repos_windows |
||
5604 | xor eax, eax |
||
5605 | xor ebx, ebx |
||
5606 | mov ecx, [Screen_Max_X] |
||
5607 | mov edx, [Screen_Max_Y] |
||
5608 | call calculatescreen |
||
5609 | pop edi |
||
5610 | pop esi |
||
5611 | pop ebx |
||
5612 | |||
5613 | popfd |
||
5614 | ret |
||
5615 | |||
5616 | .epic_fail: |
||
5617 | hlt ; Houston, we've had a problem |
||
5618 | |||
5619 | ; --------------- APM --------------------- |
||
5620 | uglobal |
||
5621 | apm_entry dp 0 |
||
5622 | apm_vf dd 0 |
||
5623 | endg |
||
5624 | |||
5625 | align 4 |
||
5626 | sys_apm: |
||
5627 | xor eax, eax |
||
5628 | cmp word [apm_vf], ax ; Check APM BIOS enable |
||
5629 | jne @f |
||
5630 | inc eax |
||
5631 | or dword [esp + 44], eax ; error |
||
5632 | add eax, 7 |
||
5633 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
||
5634 | ret |
||
5635 | |||
5636 | @@: |
||
5637 | ; xchg eax, ecx |
||
5638 | ; xchg ebx, ecx |
||
5639 | |||
5640 | cmp dx, 3 |
||
5641 | ja @f |
||
5642 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
||
5643 | mov eax, [apm_vf] |
||
5644 | mov [esp + 32], eax |
||
5645 | shr eax, 16 |
||
5646 | mov [esp + 28], eax |
||
5647 | ret |
||
5648 | |||
5649 | @@: |
||
5650 | |||
5651 | mov esi, [master_tab+(OS_BASE shr 20)] |
||
5652 | xchg [master_tab], esi |
||
5653 | push esi |
||
5654 | mov edi, cr3 |
||
5655 | mov cr3, edi ;flush TLB |
||
5656 | |||
5657 | call pword [apm_entry] ;call APM BIOS |
||
5658 | |||
5659 | xchg eax, [esp] |
||
5660 | mov [master_tab], eax |
||
5661 | mov eax, cr3 |
||
5662 | mov cr3, eax |
||
5663 | pop eax |
||
5664 | |||
5665 | mov [esp + 4 ], edi |
||
5666 | mov [esp + 8], esi |
||
5667 | mov [esp + 20], ebx |
||
5668 | mov [esp + 24], edx |
||
5669 | mov [esp + 28], ecx |
||
5670 | mov [esp + 32], eax |
||
5671 | setc al |
||
5672 | and [esp + 44], byte 0xfe |
||
5673 | or [esp + 44], al |
||
5674 | ret |
||
5675 | ; ----------------------------------------- |
||
5676 | |||
5677 | align 4 |
||
5678 | |||
5679 | undefined_syscall: ; Undefined system call |
||
5680 | mov [esp + 32], dword -1 |
||
5681 | ret |
||
5682 | |||
5683 | align 4 |
||
5684 | system_shutdown: ; shut down the system |
||
5685 | |||
3732 | Serge | 5686 | cmp byte [BOOT_VARS+0x9030], 1 |
2288 | clevermous | 5687 | jne @F |
5688 | ret |
||
5689 | @@: |
||
5690 | call stop_all_services |
||
3598 | clevermous | 5691 | movi eax, 3 |
2288 | clevermous | 5692 | call sys_cd_audio |
5693 | |||
5694 | yes_shutdown_param: |
||
5695 | cli |
||
5696 | |||
5697 | if ~ defined extended_primary_loader |
||
5698 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
||
3598 | clevermous | 5699 | movi esi, 12 |
2288 | clevermous | 5700 | xor ebx, ebx |
5701 | or ecx, -1 |
||
5702 | mov edx, OS_BASE+0x70000 |
||
5703 | call fileread |
||
5704 | |||
5705 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
||
5706 | mov edi, OS_BASE+0x40000 |
||
5707 | mov ecx, 1000 |
||
5708 | rep movsb |
||
5709 | end if |
||
5710 | |||
3732 | Serge | 5711 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5712 | ; mov edi, OS_BASE |
||
5713 | ; mov ecx, 0x10000/4 |
||
5714 | ; cld |
||
5715 | ; rep movsd |
||
2288 | clevermous | 5716 | |
5717 | call restorefatchain |
||
5718 | |||
5719 | call IRQ_mask_all |
||
5720 | |||
5721 | if 0 |
||
5722 | mov word [OS_BASE+0x467+0], pr_mode_exit |
||
5723 | mov word [OS_BASE+0x467+2], 0x1000 |
||
5724 | |||
5725 | mov al, 0x0F |
||
5726 | out 0x70, al |
||
5727 | mov al, 0x05 |
||
5728 | out 0x71, al |
||
5729 | |||
5730 | mov al, 0xFE |
||
5731 | out 0x64, al |
||
5732 | |||
5733 | hlt |
||
5734 | jmp $-1 |
||
5735 | |||
5736 | else |
||
5737 | cmp byte [OS_BASE + 0x9030], 2 |
||
5738 | jnz no_acpi_power_off |
||
5739 | |||
5740 | ; scan for RSDP |
||
5741 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
||
5742 | movzx eax, word [OS_BASE + 0x40E] |
||
5743 | shl eax, 4 |
||
5744 | jz @f |
||
5745 | mov ecx, 1024/16 |
||
5746 | call scan_rsdp |
||
5747 | jnc .rsdp_found |
||
5748 | @@: |
||
5749 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
||
5750 | mov eax, 0xE0000 |
||
5751 | mov ecx, 0x2000 |
||
5752 | call scan_rsdp |
||
5753 | jc no_acpi_power_off |
||
5754 | .rsdp_found: |
||
5755 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
||
5756 | mov ebp, [ipc_tmp] |
||
5757 | stdcall map_page, ebp, esi, PG_MAP |
||
5758 | lea eax, [esi+1000h] |
||
5759 | lea edx, [ebp+1000h] |
||
5760 | stdcall map_page, edx, eax, PG_MAP |
||
5761 | and esi, 0xFFF |
||
5762 | add esi, ebp |
||
5763 | cmp dword [esi], 'RSDT' |
||
5764 | jnz no_acpi_power_off |
||
5765 | mov ecx, [esi+4] |
||
5766 | sub ecx, 24h |
||
5767 | jbe no_acpi_power_off |
||
5768 | shr ecx, 2 |
||
5769 | add esi, 24h |
||
5770 | .scan_fadt: |
||
5771 | lodsd |
||
5772 | mov ebx, eax |
||
5773 | lea eax, [ebp+2000h] |
||
5774 | stdcall map_page, eax, ebx, PG_MAP |
||
5775 | lea eax, [ebp+3000h] |
||
5776 | add ebx, 0x1000 |
||
5777 | stdcall map_page, eax, ebx, PG_MAP |
||
5778 | and ebx, 0xFFF |
||
5779 | lea ebx, [ebx+ebp+2000h] |
||
5780 | cmp dword [ebx], 'FACP' |
||
5781 | jz .fadt_found |
||
5782 | loop .scan_fadt |
||
5783 | jmp no_acpi_power_off |
||
5784 | .fadt_found: |
||
5785 | ; ebx is linear address of FADT |
||
5786 | mov edi, [ebx+40] ; physical address of the DSDT |
||
5787 | lea eax, [ebp+4000h] |
||
5788 | stdcall map_page, eax, edi, PG_MAP |
||
5789 | lea eax, [ebp+5000h] |
||
5790 | lea esi, [edi+0x1000] |
||
5791 | stdcall map_page, eax, esi, PG_MAP |
||
5792 | and esi, 0xFFF |
||
5793 | sub edi, esi |
||
5794 | cmp dword [esi+ebp+4000h], 'DSDT' |
||
5795 | jnz no_acpi_power_off |
||
5796 | mov eax, [esi+ebp+4004h] ; DSDT length |
||
5797 | sub eax, 36+4 |
||
5798 | jbe no_acpi_power_off |
||
5799 | add esi, 36 |
||
5800 | .scan_dsdt: |
||
5801 | cmp dword [esi+ebp+4000h], '_S5_' |
||
5802 | jnz .scan_dsdt_cont |
||
5803 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
||
5804 | jnz .scan_dsdt_cont |
||
5805 | mov dl, [esi+ebp+4000h+6] |
||
5806 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
||
5807 | ; ...in theory; in practice, VirtualBox has 2 bytes |
||
5808 | ja .scan_dsdt_cont |
||
5809 | cmp dl, 1 |
||
5810 | jb .scan_dsdt_cont |
||
5811 | lea esi, [esi+ebp+4000h+7] |
||
5812 | xor ecx, ecx |
||
5813 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
||
5814 | jz @f |
||
5815 | cmp byte [esi], 0xA |
||
5816 | jnz no_acpi_power_off |
||
5817 | inc esi |
||
5818 | mov cl, [esi] |
||
5819 | @@: |
||
5820 | inc esi |
||
5821 | cmp dl, 2 |
||
5822 | jb @f |
||
5823 | cmp byte [esi], 0 |
||
5824 | jz @f |
||
5825 | cmp byte [esi], 0xA |
||
5826 | jnz no_acpi_power_off |
||
5827 | inc esi |
||
5828 | mov ch, [esi] |
||
5829 | @@: |
||
5830 | jmp do_acpi_power_off |
||
5831 | .scan_dsdt_cont: |
||
5832 | inc esi |
||
5833 | cmp esi, 0x1000 |
||
5834 | jb @f |
||
5835 | sub esi, 0x1000 |
||
5836 | add edi, 0x1000 |
||
5837 | push eax |
||
5838 | lea eax, [ebp+4000h] |
||
5839 | stdcall map_page, eax, edi, PG_MAP |
||
5840 | push PG_MAP |
||
5841 | lea eax, [edi+1000h] |
||
5842 | push eax |
||
5843 | lea eax, [ebp+5000h] |
||
5844 | push eax |
||
5845 | stdcall map_page |
||
5846 | pop eax |
||
5847 | @@: |
||
5848 | dec eax |
||
5849 | jnz .scan_dsdt |
||
5850 | jmp no_acpi_power_off |
||
5851 | do_acpi_power_off: |
||
5852 | mov edx, [ebx+48] |
||
5853 | test edx, edx |
||
5854 | jz .nosmi |
||
5855 | mov al, [ebx+52] |
||
5856 | out dx, al |
||
5857 | mov edx, [ebx+64] |
||
5858 | @@: |
||
5859 | in ax, dx |
||
5860 | test al, 1 |
||
5861 | jz @b |
||
5862 | .nosmi: |
||
5863 | and cx, 0x0707 |
||
5864 | shl cx, 2 |
||
5865 | or cx, 0x2020 |
||
5866 | mov edx, [ebx+64] |
||
5867 | in ax, dx |
||
5868 | and ax, 203h |
||
5869 | or ah, cl |
||
5870 | out dx, ax |
||
5871 | mov edx, [ebx+68] |
||
5872 | test edx, edx |
||
5873 | jz @f |
||
5874 | in ax, dx |
||
5875 | and ax, 203h |
||
5876 | or ah, ch |
||
5877 | out dx, ax |
||
5878 | @@: |
||
5879 | jmp $ |
||
5880 | |||
5881 | |||
5882 | no_acpi_power_off: |
||
5883 | mov word [OS_BASE+0x467+0], pr_mode_exit |
||
5884 | mov word [OS_BASE+0x467+2], 0x1000 |
||
5885 | |||
5886 | mov al, 0x0F |
||
5887 | out 0x70, al |
||
5888 | mov al, 0x05 |
||
5889 | out 0x71, al |
||
5890 | |||
5891 | mov al, 0xFE |
||
5892 | out 0x64, al |
||
5893 | |||
5894 | hlt |
||
5895 | jmp $-1 |
||
5896 | |||
5897 | scan_rsdp: |
||
5898 | add eax, OS_BASE |
||
5899 | .s: |
||
5900 | cmp dword [eax], 'RSD ' |
||
5901 | jnz .n |
||
5902 | cmp dword [eax+4], 'PTR ' |
||
5903 | jnz .n |
||
5904 | xor edx, edx |
||
5905 | xor esi, esi |
||
5906 | @@: |
||
5907 | add dl, [eax+esi] |
||
5908 | inc esi |
||
5909 | cmp esi, 20 |
||
5910 | jnz @b |
||
5911 | test dl, dl |
||
5912 | jz .ok |
||
5913 | .n: |
||
5914 | add eax, 10h |
||
5915 | loop .s |
||
5916 | stc |
||
5917 | .ok: |
||
5918 | ret |
||
5919 | end if |
||
5920 | |||
3627 | Serge | 5921 | if ~ lang eq sp |
5922 | diff16 "end of .text segment",0,$ |
||
5923 | end if |
||
5924 | |||
2288 | clevermous | 5925 | include "data32.inc" |
5926 | |||
5927 | __REV__ = __REV |
||
5928 | |||
3341 | yogev_ezra | 5929 | if ~ lang eq sp |
2288 | clevermous | 5930 | diff16 "end of kernel code",0,$ |
3287 | esevece | 5931 | end if=> |