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