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