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