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