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