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