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