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