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