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