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