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