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