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