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