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