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