Rev 2439 | Rev 2442 | 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: 2441 $ |
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 |
||
1059 | mov al, 1 ; at least one CPU |
||
1060 | @@: |
||
1061 | DEBUGF 1, "K : %d CPU detected\n", eax |
||
1043 | hidnplayr | 1062 | |
2010 | serge | 1063 | ; START MULTITASKING |
1 | ha | 1064 | |
1638 | serge | 1065 | ; A 'All set - press ESC to start' messages if need |
767 | diamond | 1066 | if preboot_blogesc |
1055 | Galkov | 1067 | mov esi, boot_tasking |
1068 | call boot_log |
||
2434 | Serge | 1069 | .bll1: |
1070 | in al, 0x60 ; wait for ESC key press |
||
1055 | Galkov | 1071 | cmp al, 129 |
1072 | jne .bll1 |
||
767 | diamond | 1073 | end if |
1074 | |||
1055 | Galkov | 1075 | cmp [IDEContrRegsBaseAddr], 0 |
1076 | setnz [dma_hdd] |
||
2434 | Serge | 1077 | mov [timer_ticks_enable], 1 ; for cd driver |
1 | ha | 1078 | |
1055 | Galkov | 1079 | sti |
2434 | Serge | 1080 | call change_task |
465 | serge | 1081 | |
2434 | Serge | 1082 | jmp osloop |
465 | serge | 1083 | |
1 | ha | 1084 | |
1055 | Galkov | 1085 | ; Fly :) |
1 | ha | 1086 | |
465 | serge | 1087 | include 'unpacker.inc' |
1088 | |||
1089 | align 4 |
||
1090 | boot_log: |
||
2217 | Serge | 1091 | pushad |
465 | serge | 1092 | |
2434 | Serge | 1093 | mov ebx, 10*65536 |
1094 | mov bx, word [boot_y] |
||
1095 | add [boot_y], dword 10 |
||
1096 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
||
1097 | xor edi, edi |
||
1098 | mov edx, esi |
||
1099 | inc edi |
||
1100 | call dtext |
||
465 | serge | 1101 | |
2434 | Serge | 1102 | mov [novesachecksum], 1000 |
1103 | call checkVga_N13 |
||
465 | serge | 1104 | |
1276 | Lrz | 1105 | popad |
465 | serge | 1106 | |
1276 | Lrz | 1107 | ret |
465 | serge | 1108 | |
1 | ha | 1109 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1110 | ; ; |
||
33 | mario79 | 1111 | ; MAIN OS LOOP START ; |
1 | ha | 1112 | ; ; |
1113 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1114 | align 32 |
||
1115 | osloop: |
||
2434 | Serge | 1116 | call [draw_pointer] |
1117 | call window_check_events |
||
1118 | call mouse_check_events |
||
1119 | call checkmisc |
||
1120 | call checkVga_N13 |
||
1121 | call stack_handler |
||
1122 | call checkidle |
||
1123 | call check_fdd_motor_status |
||
1124 | call check_ATAPI_device_event |
||
1125 | call check_timers |
||
1126 | jmp osloop |
||
33 | mario79 | 1127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1128 | ; ; |
||
1129 | ; MAIN OS LOOP END ; |
||
1130 | ; ; |
||
1131 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1168 | Lrz | 1132 | align 4 |
1 | ha | 1133 | checkidle: |
1055 | Galkov | 1134 | pushad |
1067 | Galkov | 1135 | call change_task |
1136 | jmp idle_loop_entry |
||
1137 | idle_loop: |
||
2434 | Serge | 1138 | cmp eax, [idlemem] ; eax == [timer_ticks] |
1067 | Galkov | 1139 | jne idle_exit |
1140 | rdtsc ;call _rdtsc |
||
2434 | Serge | 1141 | mov ecx, eax |
1055 | Galkov | 1142 | hlt |
1067 | Galkov | 1143 | rdtsc ;call _rdtsc |
2434 | Serge | 1144 | sub eax, ecx |
1145 | add [idleuse], eax |
||
1067 | Galkov | 1146 | idle_loop_entry: |
2434 | Serge | 1147 | mov eax, [timer_ticks]; eax = [timer_ticks] |
1148 | cmp [check_idle_semaphore], 0 |
||
1067 | Galkov | 1149 | je idle_loop |
1150 | dec [check_idle_semaphore] |
||
1151 | idle_exit: |
||
2434 | Serge | 1152 | mov [idlemem], eax ; eax == [timer_ticks] |
1055 | Galkov | 1153 | popad |
1154 | ret |
||
1 | ha | 1155 | |
1156 | uglobal |
||
1067 | Galkov | 1157 | idlemem dd 0x0 |
1055 | Galkov | 1158 | idleuse dd 0x0 |
1159 | idleusesec dd 0x0 |
||
1160 | check_idle_semaphore dd 0x0 |
||
1 | ha | 1161 | endg |
1162 | |||
1163 | |||
1164 | |||
1165 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1166 | ; ; |
||
1167 | ; INCLUDED SYSTEM FILES ; |
||
1168 | ; ; |
||
1169 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1170 | |||
1171 | |||
7 | me_root | 1172 | include "kernel32.inc" |
1 | ha | 1173 | |
1174 | |||
1175 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1176 | ; ; |
||
1177 | ; KERNEL FUNCTIONS ; |
||
1178 | ; ; |
||
1179 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
1180 | |||
1181 | reserve_irqs_ports: |
||
1182 | |||
1273 | Lrz | 1183 | |
1184 | ; RESERVE PORTS |
||
2434 | Serge | 1185 | mov eax, RESERVED_PORTS |
1186 | mov ecx, 1 |
||
1273 | Lrz | 1187 | |
2434 | Serge | 1188 | mov [eax], dword 4 |
269 | serge | 1189 | |
2434 | Serge | 1190 | mov [eax+16], ecx |
1191 | mov [eax+16+4], dword 0 |
||
1192 | mov [eax+16+4], dword 0x2D |
||
269 | serge | 1193 | |
2434 | Serge | 1194 | mov [eax+32], ecx |
1195 | mov [eax+32+4], dword 0x30 |
||
1196 | mov [eax+32+8], dword 0x4D |
||
233 | serge | 1197 | |
2434 | Serge | 1198 | mov [eax+48], ecx |
1199 | mov [eax+48+4], dword 0x50 |
||
1200 | mov [eax+28+8], dword 0xDF |
||
233 | serge | 1201 | |
2434 | Serge | 1202 | mov [eax+64], ecx |
1203 | mov [eax+64+4], dword 0xE5 |
||
1204 | mov [eax+64+8], dword 0xFF |
||
1273 | Lrz | 1205 | |
1055 | Galkov | 1206 | ret |
1 | ha | 1207 | |
1208 | |||
1209 | iglobal |
||
1210 | process_number dd 0x1 |
||
1211 | endg |
||
1212 | |||
1213 | set_variables: |
||
1214 | |||
2434 | Serge | 1215 | mov ecx, 0x16 ; flush port 0x60 |
2141 | serge | 1216 | .fl60: |
2434 | Serge | 1217 | in al, 0x60 |
1218 | loop .fl60 |
||
1219 | push eax |
||
1 | ha | 1220 | |
2441 | Serge | 1221 | mov ax, [BOOT_VAR+BOOT_Y_RES] |
2434 | Serge | 1222 | shr ax, 1 |
1223 | shl eax, 16 |
||
2441 | Serge | 1224 | mov ax, [BOOT_VAR+BOOT_X_RES] |
2434 | Serge | 1225 | shr ax, 1 |
1226 | mov [MOUSE_X], eax |
||
41 | mikedld | 1227 | |
2434 | Serge | 1228 | xor eax, eax |
1229 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
||
1 | ha | 1230 | |
2434 | Serge | 1231 | mov byte [MOUSE_BUFF_COUNT], al ; mouse buffer |
1232 | mov byte [KEY_COUNT], al ; keyboard buffer |
||
1233 | mov byte [BTN_COUNT], al ; button buffer |
||
1267 | Lrz | 1234 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1235 | |||
1 | ha | 1236 | ;!! IP 04.02.2005: |
2434 | Serge | 1237 | mov byte [DONT_SWITCH], al; change task if possible |
1238 | pop eax |
||
1055 | Galkov | 1239 | ret |
1 | ha | 1240 | |
1241 | align 4 |
||
1304 | Lrz | 1242 | ;input eax=43,bl-byte of output, ecx - number of port |
1 | ha | 1243 | sys_outport: |
1244 | |||
2434 | Serge | 1245 | mov edi, ecx ; separate flag for read / write |
1246 | and ecx, 65535 |
||
1 | ha | 1247 | |
2434 | Serge | 1248 | mov eax, [RESERVED_PORTS] |
1249 | test eax, eax |
||
1250 | jnz .sopl8 |
||
1251 | inc eax |
||
1252 | mov [esp+32], eax |
||
1253 | ret |
||
1 | ha | 1254 | |
1304 | Lrz | 1255 | .sopl8: |
2434 | Serge | 1256 | mov edx, [TASK_BASE] |
1257 | mov edx, [edx+0x4] |
||
1304 | Lrz | 1258 | ;and ecx,65535 |
1259 | ;cld - set on interrupt 0x40 |
||
1260 | .sopl1: |
||
1 | ha | 1261 | |
2434 | Serge | 1262 | mov esi, eax |
1263 | shl esi, 4 |
||
1264 | add esi, RESERVED_PORTS |
||
1265 | cmp edx, [esi+0] |
||
1266 | jne .sopl2 |
||
1267 | cmp ecx, [esi+4] |
||
1268 | jb .sopl2 |
||
1269 | cmp ecx, [esi+8] |
||
1270 | jg .sopl2 |
||
1304 | Lrz | 1271 | .sopl3: |
1 | ha | 1272 | |
2434 | Serge | 1273 | test edi, 0x80000000; read ? |
1274 | jnz .sopl4 |
||
1 | ha | 1275 | |
2434 | Serge | 1276 | mov eax, ebx |
1277 | mov dx, cx ; write |
||
1278 | out dx, al |
||
1279 | and [esp+32], dword 0 |
||
1280 | ret |
||
1 | ha | 1281 | |
2434 | Serge | 1282 | .sopl2: |
1 | ha | 1283 | |
2434 | Serge | 1284 | dec eax |
1285 | jnz .sopl1 |
||
1286 | inc eax |
||
1287 | mov [esp+32], eax |
||
1288 | ret |
||
1 | ha | 1289 | |
1638 | serge | 1290 | |
1304 | Lrz | 1291 | .sopl4: |
1 | ha | 1292 | |
2434 | Serge | 1293 | mov dx, cx ; read |
1294 | in al, dx |
||
1295 | and eax, 0xff |
||
1296 | and [esp+32], dword 0 |
||
1297 | mov [esp+20], eax |
||
1298 | ret |
||
1 | ha | 1299 | |
1300 | display_number: |
||
1369 | Lrz | 1301 | ;It is not optimization |
1302 | mov eax, ebx |
||
1303 | mov ebx, ecx |
||
1304 | mov ecx, edx |
||
1305 | mov edx, esi |
||
1306 | mov esi, edi |
||
1 | ha | 1307 | ; eax = print type, al=0 -> ebx is number |
1308 | ; al=1 -> ebx is pointer |
||
1309 | ; ah=0 -> display decimal |
||
1310 | ; ah=1 -> display hexadecimal |
||
1311 | ; ah=2 -> display binary |
||
1312 | ; eax bits 16-21 = number of digits to display (0-32) |
||
1313 | ; eax bits 22-31 = reserved |
||
1314 | ; |
||
1315 | ; ebx = number or pointer |
||
1316 | ; ecx = x shl 16 + y |
||
1317 | ; edx = color |
||
2434 | Serge | 1318 | xor edi, edi |
211 | serge | 1319 | display_number_force: |
2434 | Serge | 1320 | push eax |
1321 | and eax, 0x3fffffff |
||
1322 | cmp eax, 0xffff ; length > 0 ? |
||
1323 | pop eax |
||
1324 | jge cont_displ |
||
1325 | ret |
||
1 | ha | 1326 | cont_displ: |
2434 | Serge | 1327 | push eax |
1328 | and eax, 0x3fffffff |
||
1329 | cmp eax, 61*0x10000 ; length <= 60 ? |
||
1330 | pop eax |
||
1331 | jb cont_displ2 |
||
1332 | ret |
||
1 | ha | 1333 | cont_displ2: |
1334 | |||
2434 | Serge | 1335 | pushad |
1 | ha | 1336 | |
2434 | Serge | 1337 | cmp al, 1 ; ecx is a pointer ? |
1338 | jne displnl1 |
||
1339 | mov ebp, ebx |
||
1340 | add ebp, 4 |
||
1341 | mov ebp, [ebp+std_application_base_address] |
||
1342 | mov ebx, [ebx+std_application_base_address] |
||
1276 | Lrz | 1343 | displnl1: |
2434 | Serge | 1344 | sub esp, 64 |
1 | ha | 1345 | |
2434 | Serge | 1346 | test ah, ah ; DECIMAL |
1347 | jnz no_display_desnum |
||
1348 | shr eax, 16 |
||
1349 | and eax, 0xC03f |
||
652 | mario79 | 1350 | ; and eax,0x3f |
2434 | Serge | 1351 | push eax |
1352 | and eax, 0x3f |
||
1353 | mov edi, esp |
||
1354 | add edi, 4+64-1 |
||
1355 | mov ecx, eax |
||
1356 | mov eax, ebx |
||
1357 | mov ebx, 10 |
||
1276 | Lrz | 1358 | d_desnum: |
2434 | Serge | 1359 | xor edx, edx |
1360 | call division_64_bits |
||
1361 | div ebx |
||
1362 | add dl, 48 |
||
1363 | mov [edi], dl |
||
1364 | dec edi |
||
1365 | loop d_desnum |
||
1366 | pop eax |
||
1367 | call normalize_number |
||
1368 | call draw_num_text |
||
1369 | add esp, 64 |
||
1370 | popad |
||
1371 | ret |
||
1 | ha | 1372 | no_display_desnum: |
1373 | |||
2434 | Serge | 1374 | cmp ah, 0x01 ; HEXADECIMAL |
1375 | jne no_display_hexnum |
||
1376 | shr eax, 16 |
||
1377 | and eax, 0xC03f |
||
652 | mario79 | 1378 | ; and eax,0x3f |
2434 | Serge | 1379 | push eax |
1380 | and eax, 0x3f |
||
1381 | mov edi, esp |
||
1382 | add edi, 4+64-1 |
||
1383 | mov ecx, eax |
||
1384 | mov eax, ebx |
||
1385 | mov ebx, 16 |
||
1 | ha | 1386 | d_hexnum: |
2434 | Serge | 1387 | xor edx, edx |
1388 | call division_64_bits |
||
1389 | div ebx |
||
1056 | Galkov | 1390 | hexletters = __fdo_hexdigits |
2434 | Serge | 1391 | add edx, hexletters |
1392 | mov dl, [edx] |
||
1393 | mov [edi], dl |
||
1394 | dec edi |
||
1395 | loop d_hexnum |
||
1396 | pop eax |
||
1397 | call normalize_number |
||
1398 | call draw_num_text |
||
1399 | add esp, 64 |
||
1400 | popad |
||
1401 | ret |
||
1 | ha | 1402 | no_display_hexnum: |
1403 | |||
2434 | Serge | 1404 | cmp ah, 0x02 ; BINARY |
1405 | jne no_display_binnum |
||
1406 | shr eax, 16 |
||
1407 | and eax, 0xC03f |
||
652 | mario79 | 1408 | ; and eax,0x3f |
2434 | Serge | 1409 | push eax |
1410 | and eax, 0x3f |
||
1411 | mov edi, esp |
||
1412 | add edi, 4+64-1 |
||
1413 | mov ecx, eax |
||
1414 | mov eax, ebx |
||
1415 | mov ebx, 2 |
||
1 | ha | 1416 | d_binnum: |
2434 | Serge | 1417 | xor edx, edx |
1418 | call division_64_bits |
||
1419 | div ebx |
||
1420 | add dl, 48 |
||
1421 | mov [edi], dl |
||
1422 | dec edi |
||
1423 | loop d_binnum |
||
1424 | pop eax |
||
1425 | call normalize_number |
||
1426 | call draw_num_text |
||
1427 | add esp, 64 |
||
1428 | popad |
||
1429 | ret |
||
1 | ha | 1430 | no_display_binnum: |
1431 | |||
2434 | Serge | 1432 | add esp, 64 |
1433 | popad |
||
1434 | ret |
||
1 | ha | 1435 | |
652 | mario79 | 1436 | normalize_number: |
2434 | Serge | 1437 | test ah, 0x80 |
1438 | jz .continue |
||
1439 | mov ecx, 48 |
||
1440 | and eax, 0x3f |
||
652 | mario79 | 1441 | @@: |
2434 | Serge | 1442 | inc edi |
1443 | cmp [edi], cl |
||
1444 | jne .continue |
||
1445 | dec eax |
||
1446 | cmp eax, 1 |
||
1447 | ja @r |
||
1448 | mov al, 1 |
||
652 | mario79 | 1449 | .continue: |
2434 | Serge | 1450 | and eax, 0x3f |
1451 | ret |
||
1 | ha | 1452 | |
655 | mario79 | 1453 | division_64_bits: |
2434 | Serge | 1454 | test [esp+1+4], byte 0x40 |
1455 | jz .continue |
||
1456 | push eax |
||
1457 | mov eax, ebp |
||
1458 | div ebx |
||
1459 | mov ebp, eax |
||
1460 | pop eax |
||
655 | mario79 | 1461 | .continue: |
2434 | Serge | 1462 | ret |
652 | mario79 | 1463 | |
1 | ha | 1464 | draw_num_text: |
2434 | Serge | 1465 | mov esi, eax |
1466 | mov edx, 64+4 |
||
1467 | sub edx, eax |
||
1468 | add edx, esp |
||
1469 | mov ebx, [esp+64+32-8+4] |
||
684 | diamond | 1470 | ; add window start x & y |
2434 | Serge | 1471 | mov ecx, [TASK_BASE] |
465 | serge | 1472 | |
2434 | Serge | 1473 | mov edi, [CURRENT_TASK] |
1474 | shl edi, 8 |
||
465 | serge | 1475 | |
2434 | Serge | 1476 | mov eax, [ecx-twdw+WDATA.box.left] |
1477 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1478 | shl eax, 16 |
||
1479 | add eax, [ecx-twdw+WDATA.box.top] |
||
1480 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1481 | add ebx, eax |
||
1482 | mov ecx, [esp+64+32-12+4] |
||
1055 | Galkov | 1483 | and ecx, not 0x80000000 ; force counted string |
1484 | mov eax, [esp+64+8] ; background color (if given) |
||
1485 | mov edi, [esp+64+4] |
||
2434 | Serge | 1486 | jmp dtext |
1 | ha | 1487 | |
1488 | align 4 |
||
1489 | |||
1490 | sys_setup: |
||
1491 | |||
1492 | ; 1=roland mpu midi base , base io address |
||
1493 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1494 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1495 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1496 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1497 | ; 8=fat32 partition in hd |
||
1498 | ; 9 |
||
1499 | ; 10 = sound dma channel |
||
1500 | ; 11 = enable lba read |
||
1501 | ; 12 = enable pci access |
||
1502 | |||
1503 | |||
2434 | Serge | 1504 | and [esp+32], dword 0 |
1505 | dec ebx ; MIDI |
||
1506 | jnz nsyse1 |
||
1507 | cmp ecx, 0x100 |
||
1 | ha | 1508 | |
2434 | Serge | 1509 | jb nsyse1 |
1510 | mov esi, 65535 |
||
1511 | cmp esi, ecx |
||
1276 | Lrz | 1512 | |
2434 | Serge | 1513 | jb nsyse1 |
1514 | mov [midi_base], cx ;bx |
||
1515 | mov word [mididp], cx;bx |
||
1516 | inc cx ;bx |
||
1517 | mov word [midisp], cx;bx |
||
1518 | ret |
||
1276 | Lrz | 1519 | |
283 | diamond | 1520 | iglobal |
1 | ha | 1521 | midi_base dw 0 |
283 | diamond | 1522 | endg |
1 | ha | 1523 | |
1524 | nsyse1: |
||
2434 | Serge | 1525 | dec ebx ; KEYBOARD |
1526 | jnz nsyse2 |
||
1527 | mov edi, [TASK_BASE] |
||
1528 | mov eax, [edi+TASKDATA.mem_start] |
||
1529 | add eax, edx |
||
1 | ha | 1530 | |
2434 | Serge | 1531 | dec ecx |
1532 | jnz kbnobase |
||
1533 | mov ebx, keymap |
||
1534 | mov ecx, 128 |
||
1535 | call memmove |
||
1536 | ret |
||
1 | ha | 1537 | kbnobase: |
2434 | Serge | 1538 | dec ecx |
1539 | jnz kbnoshift |
||
1276 | Lrz | 1540 | |
2434 | Serge | 1541 | mov ebx, keymap_shift |
1542 | mov ecx, 128 |
||
1543 | call memmove |
||
1544 | ret |
||
1 | ha | 1545 | kbnoshift: |
2434 | Serge | 1546 | dec ecx |
1547 | jnz kbnoalt |
||
1548 | mov ebx, keymap_alt |
||
1549 | mov ecx, 128 |
||
1550 | call memmove |
||
1551 | ret |
||
1 | ha | 1552 | kbnoalt: |
2434 | Serge | 1553 | sub ecx, 6 |
1554 | jnz kbnocountry |
||
1555 | mov word [keyboard], dx |
||
1556 | ret |
||
1 | ha | 1557 | kbnocountry: |
2434 | Serge | 1558 | mov [esp+32], dword 1 |
1559 | ret |
||
1 | ha | 1560 | nsyse2: |
2434 | Serge | 1561 | dec ebx ; CD |
1562 | jnz nsyse4 |
||
1276 | Lrz | 1563 | |
2434 | Serge | 1564 | test ecx, ecx |
1565 | jz nosesl |
||
1276 | Lrz | 1566 | |
2434 | Serge | 1567 | cmp ecx, 4 |
1568 | ja nosesl |
||
1569 | mov [cd_base], cl |
||
1276 | Lrz | 1570 | |
2434 | Serge | 1571 | dec ecx |
1572 | jnz noprma |
||
1573 | mov [cdbase], 0x1f0 |
||
1574 | mov [cdid], 0xa0 |
||
1 | ha | 1575 | noprma: |
1276 | Lrz | 1576 | |
2434 | Serge | 1577 | dec ecx |
1578 | jnz noprsl |
||
1579 | mov [cdbase], 0x1f0 |
||
1580 | mov [cdid], 0xb0 |
||
1 | ha | 1581 | noprsl: |
2434 | Serge | 1582 | dec ecx |
1583 | jnz nosema |
||
1584 | mov [cdbase], 0x170 |
||
1585 | mov [cdid], 0xa0 |
||
1 | ha | 1586 | nosema: |
2434 | Serge | 1587 | dec ecx |
1588 | jnz nosesl |
||
1589 | mov [cdbase], 0x170 |
||
1590 | mov [cdid], 0xb0 |
||
1 | ha | 1591 | nosesl: |
2434 | Serge | 1592 | ret |
1 | ha | 1593 | |
1276 | Lrz | 1594 | iglobal |
1 | ha | 1595 | cd_base db 0 |
1596 | |||
1276 | Lrz | 1597 | endg |
1 | ha | 1598 | nsyse4: |
1638 | serge | 1599 | |
2434 | Serge | 1600 | sub ebx, 2 ; SYSTEM LANGUAGE |
1601 | jnz nsyse5 |
||
1602 | mov [syslang], ecx |
||
1603 | ret |
||
1 | ha | 1604 | nsyse5: |
1638 | serge | 1605 | |
2434 | Serge | 1606 | sub ebx, 2 ; HD BASE |
1607 | jnz nsyse7 |
||
1 | ha | 1608 | |
2434 | Serge | 1609 | test ecx, ecx |
1610 | jz nosethd |
||
1276 | Lrz | 1611 | |
2434 | Serge | 1612 | cmp ecx, 4 |
1613 | ja nosethd |
||
1614 | mov [hd_base], cl |
||
1276 | Lrz | 1615 | |
2434 | Serge | 1616 | cmp ecx, 1 |
1617 | jnz noprmahd |
||
1618 | mov [hdbase], 0x1f0 |
||
1619 | and dword [hdid], 0x0 |
||
1620 | mov dword [hdpos], ecx |
||
1 | ha | 1621 | ; call set_FAT32_variables |
1622 | noprmahd: |
||
1276 | Lrz | 1623 | |
2434 | Serge | 1624 | cmp ecx, 2 |
1625 | jnz noprslhd |
||
1626 | mov [hdbase], 0x1f0 |
||
1627 | mov [hdid], 0x10 |
||
1628 | mov dword [hdpos], ecx |
||
1 | ha | 1629 | ; call set_FAT32_variables |
1630 | noprslhd: |
||
1276 | Lrz | 1631 | |
2434 | Serge | 1632 | cmp ecx, 3 |
1633 | jnz nosemahd |
||
1634 | mov [hdbase], 0x170 |
||
1635 | and dword [hdid], 0x0 |
||
1636 | mov dword [hdpos], ecx |
||
1 | ha | 1637 | ; call set_FAT32_variables |
1638 | nosemahd: |
||
1276 | Lrz | 1639 | |
2434 | Serge | 1640 | cmp ecx, 4 |
1641 | jnz noseslhd |
||
1642 | mov [hdbase], 0x170 |
||
1643 | mov [hdid], 0x10 |
||
1644 | mov dword [hdpos], ecx |
||
1 | ha | 1645 | ; call set_FAT32_variables |
1646 | noseslhd: |
||
2434 | Serge | 1647 | call reserve_hd1 |
1648 | call reserve_hd_channel |
||
1649 | call free_hd_channel |
||
1650 | and dword [hd1_status], 0 ; free |
||
75 | diamond | 1651 | nosethd: |
2434 | Serge | 1652 | ret |
1 | ha | 1653 | |
283 | diamond | 1654 | iglobal |
1 | ha | 1655 | hd_base db 0 |
283 | diamond | 1656 | endg |
1 | ha | 1657 | |
802 | serge | 1658 | nsyse7: |
1 | ha | 1659 | |
1260 | Lrz | 1660 | ; cmp eax,8 ; HD PARTITION |
2434 | Serge | 1661 | dec ebx |
1662 | jnz nsyse8 |
||
1663 | mov [fat32part], ecx |
||
1 | ha | 1664 | ; call set_FAT32_variables |
2434 | Serge | 1665 | call reserve_hd1 |
1666 | call reserve_hd_channel |
||
1667 | call free_hd_channel |
||
1668 | ; pusha |
||
1669 | call choice_necessity_partition_1 |
||
1670 | ; popa |
||
1671 | and dword [hd1_status], 0 ; free |
||
1672 | ret |
||
1 | ha | 1673 | |
802 | serge | 1674 | nsyse8: |
1260 | Lrz | 1675 | ; cmp eax,11 ; ENABLE LBA READ |
2434 | Serge | 1676 | and ecx, 1 |
1677 | sub ebx, 3 |
||
1678 | jnz no_set_lba_read |
||
1679 | mov [lba_read_enabled], ecx |
||
1680 | ret |
||
1 | ha | 1681 | |
802 | serge | 1682 | no_set_lba_read: |
1260 | Lrz | 1683 | ; cmp eax,12 ; ENABLE PCI ACCESS |
2434 | Serge | 1684 | dec ebx |
1685 | jnz sys_setup_err |
||
1686 | mov [pci_access_enabled], ecx |
||
1687 | ret |
||
1 | ha | 1688 | |
75 | diamond | 1689 | sys_setup_err: |
2434 | Serge | 1690 | or [esp+32], dword -1 |
1691 | ret |
||
1 | ha | 1692 | |
1693 | align 4 |
||
1694 | |||
1695 | sys_getsetup: |
||
1696 | |||
1697 | ; 1=roland mpu midi base , base io address |
||
1698 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1699 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1700 | ; 5=system language, 1eng 2fi 3ger 4rus |
||
1701 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
||
1702 | ; 8=fat32 partition in hd |
||
1703 | ; 9=get hs timer tic |
||
1704 | |||
1276 | Lrz | 1705 | ; cmp eax,1 |
2434 | Serge | 1706 | dec ebx |
1707 | jnz ngsyse1 |
||
1708 | movzx eax, [midi_base] |
||
1709 | mov [esp+32], eax |
||
1710 | ret |
||
802 | serge | 1711 | ngsyse1: |
1276 | Lrz | 1712 | ; cmp eax,2 |
2434 | Serge | 1713 | dec ebx |
1714 | jnz ngsyse2 |
||
1 | ha | 1715 | |
2434 | Serge | 1716 | mov edi, [TASK_BASE] |
1717 | mov ebx, [edi+TASKDATA.mem_start] |
||
1718 | add ebx, edx |
||
1276 | Lrz | 1719 | |
1720 | ; cmp ebx,1 |
||
2434 | Serge | 1721 | dec ecx |
1722 | jnz kbnobaseret |
||
1723 | mov eax, keymap |
||
1724 | mov ecx, 128 |
||
1725 | call memmove |
||
1726 | ret |
||
802 | serge | 1727 | kbnobaseret: |
1276 | Lrz | 1728 | ; cmp ebx,2 |
2434 | Serge | 1729 | dec ecx |
1730 | jnz kbnoshiftret |
||
1276 | Lrz | 1731 | |
2434 | Serge | 1732 | mov eax, keymap_shift |
1733 | mov ecx, 128 |
||
1734 | call memmove |
||
1735 | ret |
||
802 | serge | 1736 | kbnoshiftret: |
1276 | Lrz | 1737 | ; cmp ebx,3 |
2434 | Serge | 1738 | dec ecx |
1739 | jne kbnoaltret |
||
1276 | Lrz | 1740 | |
2434 | Serge | 1741 | mov eax, keymap_alt |
1742 | mov ecx, 128 |
||
1743 | call memmove |
||
1744 | ret |
||
802 | serge | 1745 | kbnoaltret: |
1276 | Lrz | 1746 | ; cmp ebx,9 |
2434 | Serge | 1747 | sub ecx, 6 |
1748 | jnz ngsyse2 |
||
1749 | movzx eax, word [keyboard] |
||
1750 | mov [esp+32], eax |
||
1751 | ret |
||
1276 | Lrz | 1752 | |
1753 | |||
802 | serge | 1754 | ngsyse2: |
1276 | Lrz | 1755 | ; cmp eax,3 |
2434 | Serge | 1756 | dec ebx |
1757 | jnz ngsyse3 |
||
1758 | movzx eax, [cd_base] |
||
1759 | mov [esp+32], eax |
||
1276 | Lrz | 1760 | ret |
802 | serge | 1761 | ngsyse3: |
1276 | Lrz | 1762 | ; cmp eax,5 |
2434 | Serge | 1763 | sub ebx, 2 |
1764 | jnz ngsyse5 |
||
1765 | mov eax, [syslang] |
||
1766 | mov [esp+32], eax |
||
1276 | Lrz | 1767 | ret |
802 | serge | 1768 | ngsyse5: |
1276 | Lrz | 1769 | ; cmp eax,7 |
2434 | Serge | 1770 | sub ebx, 2 |
1771 | jnz ngsyse7 |
||
1772 | movzx eax, [hd_base] |
||
1773 | mov [esp+32], eax |
||
1774 | ret |
||
802 | serge | 1775 | ngsyse7: |
1276 | Lrz | 1776 | ; cmp eax,8 |
2434 | Serge | 1777 | dec ebx |
1778 | jnz ngsyse8 |
||
1779 | mov eax, [fat32part] |
||
1780 | mov [esp+32], eax |
||
1781 | ret |
||
802 | serge | 1782 | ngsyse8: |
1276 | Lrz | 1783 | ; cmp eax,9 |
2434 | Serge | 1784 | dec ebx |
1785 | jnz ngsyse9 |
||
1786 | mov eax, [timer_ticks];[0xfdf0] |
||
1787 | mov [esp+32], eax |
||
1788 | ret |
||
802 | serge | 1789 | ngsyse9: |
1276 | Lrz | 1790 | ; cmp eax,11 |
2434 | Serge | 1791 | sub ebx, 2 |
1792 | jnz ngsyse11 |
||
1793 | mov eax, [lba_read_enabled] |
||
1794 | mov [esp+32], eax |
||
1795 | ret |
||
802 | serge | 1796 | ngsyse11: |
1276 | Lrz | 1797 | ; cmp eax,12 |
2434 | Serge | 1798 | dec ebx |
1799 | jnz ngsyse12 |
||
1800 | mov eax, [pci_access_enabled] |
||
1801 | mov [esp+32], eax |
||
1802 | ret |
||
802 | serge | 1803 | ngsyse12: |
2434 | Serge | 1804 | mov [esp+32], dword 1 |
1805 | ret |
||
1 | ha | 1806 | |
1638 | serge | 1807 | |
479 | kastigar | 1808 | get_timer_ticks: |
2434 | Serge | 1809 | mov eax, [timer_ticks] |
1810 | ret |
||
479 | kastigar | 1811 | |
283 | diamond | 1812 | iglobal |
1 | ha | 1813 | align 4 |
221 | serge | 1814 | mousefn dd msscreen, mswin, msbutton, msset |
1055 | Galkov | 1815 | dd app_load_cursor |
1816 | dd app_set_cursor |
||
1817 | dd app_delete_cursor |
||
1818 | dd msz |
||
283 | diamond | 1819 | endg |
1 | ha | 1820 | |
1821 | readmousepos: |
||
1822 | |||
1823 | ; eax=0 screen relative |
||
1824 | ; eax=1 window relative |
||
1825 | ; eax=2 buttons pressed |
||
221 | serge | 1826 | ; eax=3 set mouse pos ; reserved |
1827 | ; eax=4 load cursor |
||
1828 | ; eax=5 set cursor |
||
1829 | ; eax=6 delete cursor ; reserved |
||
479 | kastigar | 1830 | ; eax=7 get mouse_z |
1 | ha | 1831 | |
2434 | Serge | 1832 | cmp ebx, 7 |
1833 | ja msset |
||
1834 | jmp [mousefn+ebx*4] |
||
221 | serge | 1835 | msscreen: |
2434 | Serge | 1836 | mov eax, [MOUSE_X] |
1837 | shl eax, 16 |
||
1838 | mov ax, [MOUSE_Y] |
||
1839 | mov [esp+36-4], eax |
||
1840 | ret |
||
221 | serge | 1841 | mswin: |
2434 | Serge | 1842 | mov eax, [MOUSE_X] |
1843 | shl eax, 16 |
||
1844 | mov ax, [MOUSE_Y] |
||
1845 | mov esi, [TASK_BASE] |
||
1846 | mov bx, word [esi-twdw+WDATA.box.left] |
||
1847 | shl ebx, 16 |
||
1848 | mov bx, word [esi-twdw+WDATA.box.top] |
||
1849 | sub eax, ebx |
||
1 | ha | 1850 | |
2434 | Serge | 1851 | mov edi, [CURRENT_TASK] |
1852 | shl edi, 8 |
||
1853 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
1854 | rol eax, 16 |
||
1855 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
1856 | rol eax, 16 |
||
1857 | mov [esp+36-4], eax |
||
1858 | ret |
||
221 | serge | 1859 | msbutton: |
2434 | Serge | 1860 | movzx eax, byte [BTN_DOWN] |
1861 | mov [esp+36-4], eax |
||
1862 | ret |
||
479 | kastigar | 1863 | msz: |
2434 | Serge | 1864 | mov edi, [TASK_COUNT] |
1865 | movzx edi, word [WIN_POS + edi*2] |
||
1866 | cmp edi, [CURRENT_TASK] |
||
1867 | jne @f |
||
1868 | mov ax, [MOUSE_SCROLL_H] |
||
1869 | shl eax, 16 |
||
1870 | mov ax, [MOUSE_SCROLL_V] |
||
1871 | mov [esp+36-4], eax |
||
1872 | and [MOUSE_SCROLL_H], word 0 |
||
1873 | and [MOUSE_SCROLL_V], word 0 |
||
1874 | ret |
||
479 | kastigar | 1875 | @@: |
2434 | Serge | 1876 | and [esp+36-4], dword 0 |
1276 | Lrz | 1877 | ; ret |
221 | serge | 1878 | msset: |
2434 | Serge | 1879 | ret |
164 | serge | 1880 | |
221 | serge | 1881 | app_load_cursor: |
2434 | Serge | 1882 | cmp ecx, OS_BASE |
1883 | jae msset |
||
1884 | stdcall load_cursor, ecx, edx |
||
1885 | mov [esp+36-4], eax |
||
1886 | ret |
||
164 | serge | 1887 | |
221 | serge | 1888 | app_set_cursor: |
2434 | Serge | 1889 | stdcall set_cursor, ecx |
1890 | mov [esp+36-4], eax |
||
1891 | ret |
||
1 | ha | 1892 | |
233 | serge | 1893 | app_delete_cursor: |
2434 | Serge | 1894 | stdcall delete_cursor, ecx |
1895 | mov [esp+36-4], eax |
||
1896 | ret |
||
1 | ha | 1897 | |
1898 | is_input: |
||
1899 | |||
2434 | Serge | 1900 | push edx |
1901 | mov dx, word [midisp] |
||
1902 | in al, dx |
||
1903 | and al, 0x80 |
||
1904 | pop edx |
||
1905 | ret |
||
1 | ha | 1906 | |
1907 | is_output: |
||
1908 | |||
2434 | Serge | 1909 | push edx |
1910 | mov dx, word [midisp] |
||
1911 | in al, dx |
||
1912 | and al, 0x40 |
||
1913 | pop edx |
||
1914 | ret |
||
1 | ha | 1915 | |
1916 | |||
1917 | get_mpu_in: |
||
1918 | |||
2434 | Serge | 1919 | push edx |
1920 | mov dx, word [mididp] |
||
1921 | in al, dx |
||
1922 | pop edx |
||
1923 | ret |
||
1 | ha | 1924 | |
1925 | |||
1926 | put_mpu_out: |
||
1927 | |||
2434 | Serge | 1928 | push edx |
1929 | mov dx, word [mididp] |
||
1930 | out dx, al |
||
1931 | pop edx |
||
1932 | ret |
||
1 | ha | 1933 | |
1934 | |||
1935 | |||
1936 | align 4 |
||
1937 | |||
1938 | sys_midi: |
||
2434 | Serge | 1939 | cmp [mididp], 0 |
1940 | jnz sm0 |
||
1941 | mov [esp+36], dword 1 |
||
1942 | ret |
||
1276 | Lrz | 1943 | sm0: |
2434 | Serge | 1944 | and [esp+36], dword 0 |
1945 | dec ebx |
||
1946 | jnz smn1 |
||
1276 | Lrz | 1947 | ; call setuart |
1948 | su1: |
||
2434 | Serge | 1949 | call is_output |
1950 | test al, al |
||
1951 | jnz su1 |
||
1952 | mov dx, word [midisp] |
||
1953 | mov al, 0xff |
||
1954 | out dx, al |
||
1276 | Lrz | 1955 | su2: |
2434 | Serge | 1956 | mov dx, word [midisp] |
1957 | mov al, 0xff |
||
1958 | out dx, al |
||
1959 | call is_input |
||
1960 | test al, al |
||
1961 | jnz su2 |
||
1962 | call get_mpu_in |
||
1963 | cmp al, 0xfe |
||
1964 | jnz su2 |
||
1276 | Lrz | 1965 | su3: |
2434 | Serge | 1966 | call is_output |
1967 | test al, al |
||
1968 | jnz su3 |
||
1969 | mov dx, word [midisp] |
||
1970 | mov al, 0x3f |
||
1971 | out dx, al |
||
1972 | ret |
||
1276 | Lrz | 1973 | smn1: |
2434 | Serge | 1974 | dec ebx |
1975 | jnz smn2 |
||
1276 | Lrz | 1976 | sm10: |
2434 | Serge | 1977 | call get_mpu_in |
1978 | call is_output |
||
1979 | test al, al |
||
1980 | jnz sm10 |
||
1981 | mov al, bl |
||
1982 | call put_mpu_out |
||
1983 | smn2: |
||
1984 | ret |
||
1 | ha | 1985 | |
1986 | detect_devices: |
||
1987 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
769 | Rus | 1988 | ;include 'detect/commouse.inc' |
479 | kastigar | 1989 | ;include 'detect/ps2mouse.inc' |
1 | ha | 1990 | ;include 'detect/dev_fd.inc' |
1991 | ;include 'detect/dev_hdcd.inc' |
||
1992 | ;include 'detect/sear_par.inc' |
||
1993 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
2434 | Serge | 1994 | ret |
1 | ha | 1995 | |
1996 | sys_end: |
||
2434 | Serge | 1997 | ;-------------------------------------- |
1998 | cmp [_display.select_cursor], 0 |
||
1999 | je @f |
||
2000 | ; restore default cursor before killing |
||
2001 | pusha |
||
2002 | mov ecx, [current_slot] |
||
2439 | Serge | 2003 | call restore_default_cursor_before_killing |
2434 | Serge | 2004 | popa |
2005 | @@: |
||
2006 | ;-------------------------------------- |
||
2007 | mov ecx, [current_slot] |
||
2008 | mov eax, [ecx+APPDATA.tls_base] |
||
2009 | test eax, eax |
||
2010 | jz @F |
||
1220 | serge | 2011 | |
2434 | Serge | 2012 | stdcall user_free, eax |
1220 | serge | 2013 | @@: |
2014 | |||
2434 | Serge | 2015 | mov eax, [TASK_BASE] |
2016 | mov [eax+TASKDATA.state], 3; terminate this program |
||
41 | mikedld | 2017 | |
1055 | Galkov | 2018 | waitterm: ; wait here for termination |
2434 | Serge | 2019 | mov ebx, 100 |
2020 | call delay_hs |
||
2021 | jmp waitterm |
||
2439 | Serge | 2022 | ;------------------------------------------------------------------------------ |
2023 | restore_default_cursor_before_killing: |
||
2024 | mov eax, [def_cursor] |
||
2025 | mov [ecx+APPDATA.cursor], eax |
||
1 | ha | 2026 | |
2439 | Serge | 2027 | movzx eax, word [MOUSE_Y] |
2028 | movzx ebx, word [MOUSE_X] |
||
2029 | mov ecx, [Screen_Max_X] |
||
2030 | inc ecx |
||
2031 | mul ecx |
||
2032 | add eax, [_WinMapAddress] |
||
2033 | movzx edx, byte [ebx+eax] |
||
2034 | shl edx, 8 |
||
2035 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
||
2036 | push esi |
||
2037 | call [_display.select_cursor] |
||
2038 | mov [current_cursor], esi |
||
2039 | ret |
||
2040 | ;------------------------------------------------------------------------------ |
||
75 | diamond | 2041 | iglobal |
170 | serge | 2042 | align 4 |
75 | diamond | 2043 | sys_system_table: |
2268 | Serge | 2044 | dd sysfn_deactivate ; 1 = deactivate window |
1055 | Galkov | 2045 | dd sysfn_terminate ; 2 = terminate thread |
2046 | dd sysfn_activate ; 3 = activate window |
||
2047 | dd sysfn_getidletime ; 4 = get idle time |
||
2048 | dd sysfn_getcpuclock ; 5 = get cpu clock |
||
2049 | dd sysfn_saveramdisk ; 6 = save ramdisk |
||
2050 | dd sysfn_getactive ; 7 = get active window |
||
2051 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
||
2052 | dd sysfn_shutdown ; 9 = shutdown with parameter |
||
2053 | dd sysfn_minimize ; 10 = minimize window |
||
2054 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
||
2055 | dd sysfn_lastkey ; 12 = get last pressed key |
||
2056 | dd sysfn_getversion ; 13 = get kernel version |
||
2057 | dd sysfn_waitretrace ; 14 = wait retrace |
||
2058 | dd sysfn_centermouse ; 15 = center mouse cursor |
||
2059 | dd sysfn_getfreemem ; 16 = get free memory size |
||
2060 | dd sysfn_getallmem ; 17 = get total memory size |
||
2061 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
||
2062 | ; instead of slot |
||
2063 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
||
2064 | dd sysfn_meminfo ; 20 = get extended memory info |
||
2065 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
||
2066 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
||
75 | diamond | 2067 | sysfn_num = ($ - sys_system_table)/4 |
2068 | endg |
||
2268 | Serge | 2069 | ;------------------------------------------------------------------------------ |
1 | ha | 2070 | sys_system: |
1055 | Galkov | 2071 | dec ebx |
2072 | cmp ebx, sysfn_num |
||
2073 | jae @f |
||
2074 | jmp dword [sys_system_table + ebx*4] |
||
75 | diamond | 2075 | @@: |
1055 | Galkov | 2076 | ret |
2268 | Serge | 2077 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2078 | sysfn_shutdown: ; 18.9 = system shutdown |
2434 | Serge | 2079 | cmp ecx, 1 |
2080 | jl exit_for_anyone |
||
2081 | cmp ecx, 4 |
||
2082 | jg exit_for_anyone |
||
2083 | mov [BOOT_VAR+0x9030], cl |
||
748 | heavyiron | 2084 | |
2434 | Serge | 2085 | mov eax, [TASK_COUNT] |
2086 | mov [SYS_SHUTDOWN], al |
||
2087 | mov [shutdown_processes], eax |
||
2088 | and dword [esp+32], 0 |
||
748 | heavyiron | 2089 | exit_for_anyone: |
2434 | Serge | 2090 | ret |
1 | ha | 2091 | uglobal |
2434 | Serge | 2092 | shutdown_processes: |
2093 | dd 0x0 |
||
1 | ha | 2094 | endg |
2268 | Serge | 2095 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2096 | sysfn_terminate: ; 18.2 = TERMINATE |
2434 | Serge | 2097 | cmp ecx, 2 |
2098 | jb noprocessterminate |
||
2099 | mov edx, [TASK_COUNT] |
||
2100 | cmp ecx, edx |
||
2101 | ja noprocessterminate |
||
2102 | mov eax, [TASK_COUNT] |
||
2103 | push ecx |
||
2104 | shl ecx, 5 |
||
2105 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
||
2106 | add ecx, CURRENT_TASK+TASKDATA.state |
||
2107 | cmp byte [ecx], 9 |
||
2108 | jz noprocessterminate |
||
2109 | ;-------------------------------------- |
||
2110 | cmp [_display.select_cursor], 0 |
||
2111 | je @f |
||
2112 | ; restore default cursor before killing |
||
2113 | pusha |
||
2114 | mov ecx, [esp+32] |
||
2115 | shl ecx, 8 |
||
2439 | Serge | 2116 | add ecx, SLOT_BASE |
2117 | call restore_default_cursor_before_killing |
||
2434 | Serge | 2118 | popa |
2119 | @@: |
||
2120 | add esp, 4 |
||
2121 | ;-------------------------------------- |
||
1 | ha | 2122 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2434 | Serge | 2123 | mov [ecx], byte 3; clear possible i40's |
1 | ha | 2124 | ;call MEM_Heap_UnLock |
2125 | |||
2434 | Serge | 2126 | cmp edx, [application_table_status]; clear app table stat |
2127 | jne noatsc |
||
2128 | and [application_table_status], 0 |
||
1 | ha | 2129 | noatsc: |
75 | diamond | 2130 | noprocessterminate: |
2434 | Serge | 2131 | ret |
2268 | Serge | 2132 | ;------------------------------------------------------------------------------ |
85 | halyavin | 2133 | sysfn_terminate2: |
2134 | ;lock application_table_status mutex |
||
164 | serge | 2135 | .table_status: |
2434 | Serge | 2136 | cli |
2137 | cmp [application_table_status], 0 |
||
2138 | je .stf |
||
2139 | sti |
||
2140 | call change_task |
||
2141 | jmp .table_status |
||
85 | halyavin | 2142 | .stf: |
2434 | Serge | 2143 | call set_application_table_status |
2144 | mov eax, ecx |
||
2145 | call pid_to_slot |
||
2146 | test eax, eax |
||
2147 | jz .not_found |
||
2148 | mov ecx, eax |
||
2149 | cli |
||
2150 | call sysfn_terminate |
||
2151 | and [application_table_status], 0 |
||
2152 | sti |
||
2153 | and dword [esp+32], 0 |
||
2154 | ret |
||
85 | halyavin | 2155 | .not_found: |
2434 | Serge | 2156 | mov [application_table_status], 0 |
2157 | or dword [esp+32], -1 |
||
2158 | ret |
||
2268 | Serge | 2159 | ;------------------------------------------------------------------------------ |
2160 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
||
2434 | Serge | 2161 | cmp ecx, 2 |
2162 | jb .nowindowdeactivate |
||
2163 | cmp ecx, [TASK_COUNT] |
||
2164 | ja .nowindowdeactivate |
||
85 | halyavin | 2165 | |
2434 | Serge | 2166 | movzx esi, word [WIN_STACK + ecx*2] |
2167 | cmp esi, 1 |
||
2168 | je .nowindowdeactivate ; already deactive |
||
2268 | Serge | 2169 | |
2434 | Serge | 2170 | mov edi, ecx |
2171 | shl edi, 5 |
||
2172 | add edi, window_data |
||
2173 | movzx esi, word [WIN_STACK + ecx * 2] |
||
2174 | lea esi, [WIN_POS + esi * 2] |
||
2175 | call window._.window_deactivate |
||
2268 | Serge | 2176 | |
2434 | Serge | 2177 | xor eax, eax |
2178 | mov byte[MOUSE_BACKGROUND], al |
||
2179 | mov byte[DONT_DRAW_MOUSE], al |
||
2180 | mov byte[MOUSE_DOWN], 0 |
||
2181 | |||
2182 | call syscall_display_settings._.calculate_whole_screen |
||
2183 | call syscall_display_settings._.redraw_whole_screen |
||
2268 | Serge | 2184 | .nowindowdeactivate: |
2434 | Serge | 2185 | ret |
2186 | ;------------------------------------------------------------------------------ |
||
1055 | Galkov | 2187 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2434 | Serge | 2188 | cmp ecx, 2 |
2189 | jb .nowindowactivate |
||
2190 | cmp ecx, [TASK_COUNT] |
||
2191 | ja .nowindowactivate |
||
105 | poddubny | 2192 | |
2434 | Serge | 2193 | mov [window_minimize], 2; restore window if minimized |
105 | poddubny | 2194 | |
2434 | Serge | 2195 | movzx esi, word [WIN_STACK + ecx*2] |
2196 | cmp esi, [TASK_COUNT] |
||
2197 | je .nowindowactivate; already active |
||
105 | poddubny | 2198 | |
2434 | Serge | 2199 | mov edi, ecx |
2200 | shl edi, 5 |
||
2201 | add edi, window_data |
||
2202 | movzx esi, word [WIN_STACK + ecx * 2] |
||
2203 | lea esi, [WIN_POS + esi * 2] |
||
2204 | call waredraw |
||
105 | poddubny | 2205 | .nowindowactivate: |
2434 | Serge | 2206 | ret |
2268 | Serge | 2207 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2208 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2434 | Serge | 2209 | mov eax, [idleusesec] |
2210 | mov [esp+32], eax |
||
2211 | ret |
||
2268 | Serge | 2212 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2213 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2434 | Serge | 2214 | mov eax, [CPU_FREQ] |
2215 | mov [esp+32], eax |
||
2216 | ret |
||
2268 | Serge | 2217 | ;------------------------------------------------------------------------------ |
1 | ha | 2218 | ; SAVE ramdisk to /hd/1/menuet.img |
2219 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2220 | include 'blkdev/rdsave.inc' |
||
2221 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2268 | Serge | 2222 | ;------------------------------------------------------------------------------ |
1232 | Lrz | 2223 | align 4 |
1055 | Galkov | 2224 | sysfn_getactive: ; 18.7 = get active window |
2434 | Serge | 2225 | mov eax, [TASK_COUNT] |
2226 | movzx eax, word [WIN_POS + eax*2] |
||
2227 | mov [esp+32], eax |
||
2228 | ret |
||
2268 | Serge | 2229 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2230 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
1232 | Lrz | 2231 | ; cmp ecx,1 |
2434 | Serge | 2232 | dec ecx |
2233 | jnz nogetsoundflag |
||
2234 | movzx eax, byte [sound_flag]; get sound_flag |
||
2235 | mov [esp+32], eax |
||
2236 | ret |
||
1 | ha | 2237 | nogetsoundflag: |
1232 | Lrz | 2238 | ; cmp ecx,2 |
2434 | Serge | 2239 | dec ecx |
2240 | jnz nosoundflag |
||
2241 | xor byte [sound_flag], 1 |
||
75 | diamond | 2242 | nosoundflag: |
2434 | Serge | 2243 | ret |
2268 | Serge | 2244 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2245 | sysfn_minimize: ; 18.10 = minimize window |
2434 | Serge | 2246 | mov [window_minimize], 1 |
2247 | ret |
||
2268 | Serge | 2248 | ;------------------------------------------------------------------------------ |
1232 | Lrz | 2249 | align 4 |
1055 | Galkov | 2250 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
1232 | Lrz | 2251 | ; cmp ecx,1 |
2434 | Serge | 2252 | dec ecx |
2253 | jnz full_table |
||
1 | ha | 2254 | small_table: |
2434 | Serge | 2255 | call for_all_tables |
2256 | mov ecx, 10 |
||
2257 | cld |
||
2258 | rep movsb |
||
2259 | ret |
||
1 | ha | 2260 | for_all_tables: |
2434 | Serge | 2261 | mov edi, edx |
2262 | mov esi, DRIVE_DATA |
||
2263 | ret |
||
1 | ha | 2264 | full_table: |
1232 | Lrz | 2265 | ; cmp ecx,2 |
2434 | Serge | 2266 | dec ecx |
2267 | jnz exit_for_anyone |
||
2268 | call for_all_tables |
||
2269 | mov ecx, 16384 |
||
2270 | cld |
||
2271 | rep movsd |
||
2272 | ret |
||
2268 | Serge | 2273 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2274 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2275 | and dword [esp+32], 0 |
||
2276 | ret |
||
2268 | Serge | 2277 | ;------------------------------------------------------------------------------ |
1055 | Galkov | 2278 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2434 | Serge | 2279 | mov edi, ecx |
2280 | mov esi, version_inf |
||
2281 | mov ecx, version_end-version_inf |
||
2282 | rep movsb |
||
2283 | ret |
||
2268 | Serge | 2284 | ;------------------------------------------------------------------------------ |
75 | diamond | 2285 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
41 | mikedld | 2286 | ;wait retrace functions |
2287 | sys_wait_retrace: |
||
2434 | Serge | 2288 | mov edx, 0x3da |
41 | mikedld | 2289 | WaitRetrace_loop: |
2434 | Serge | 2290 | in al, dx |
2291 | test al, 1000b |
||
2292 | jz WaitRetrace_loop |
||
2293 | and [esp+32], dword 0 |
||
2294 | ret |
||
2268 | Serge | 2295 | ;------------------------------------------------------------------------------ |
1232 | Lrz | 2296 | align 4 |
1055 | Galkov | 2297 | sysfn_centermouse: ; 18.15 = mouse centered |
1232 | Lrz | 2298 | ; removed here by |
2299 | ; call mouse_centered |
||
2300 | ;* mouse centered - start code- Mario79 |
||
2301 | ;mouse_centered: |
||
2302 | ; push eax |
||
2434 | Serge | 2303 | mov eax, [Screen_Max_X] |
2304 | shr eax, 1 |
||
2305 | mov [MOUSE_X], ax |
||
2306 | mov eax, [Screen_Max_Y] |
||
2307 | shr eax, 1 |
||
2308 | mov [MOUSE_Y], ax |
||
1232 | Lrz | 2309 | ; ret |
2310 | ;* mouse centered - end code- Mario79 |
||
2434 | Serge | 2311 | xor eax, eax |
2312 | and [esp+32], eax |
||
1232 | Lrz | 2313 | ; pop eax |
2434 | Serge | 2314 | ret |
2268 | Serge | 2315 | ;------------------------------------------------------------------------------ |
1232 | Lrz | 2316 | align 4 |
120 | mario79 | 2317 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2434 | Serge | 2318 | test ecx, ecx; get mouse speed factor |
2319 | jnz .set_mouse_acceleration |
||
2320 | xor eax, eax |
||
2321 | mov ax, [mouse_speed_factor] |
||
2322 | mov [esp+32], eax |
||
2323 | ret |
||
120 | mario79 | 2324 | .set_mouse_acceleration: |
1232 | Lrz | 2325 | ; cmp ecx,1 ; set mouse speed factor |
2434 | Serge | 2326 | dec ecx |
2327 | jnz .get_mouse_delay |
||
2328 | mov [mouse_speed_factor], dx |
||
2329 | ret |
||
120 | mario79 | 2330 | .get_mouse_delay: |
1232 | Lrz | 2331 | ; cmp ecx,2 ; get mouse delay |
2434 | Serge | 2332 | dec ecx |
2333 | jnz .set_mouse_delay |
||
2334 | mov eax, [mouse_delay] |
||
2335 | mov [esp+32], eax |
||
2336 | ret |
||
120 | mario79 | 2337 | .set_mouse_delay: |
1232 | Lrz | 2338 | ; cmp ecx,3 ; set mouse delay |
2434 | Serge | 2339 | dec ecx |
2340 | jnz .set_pointer_position |
||
2341 | mov [mouse_delay], edx |
||
2342 | ret |
||
120 | mario79 | 2343 | .set_pointer_position: |
1232 | Lrz | 2344 | ; cmp ecx,4 ; set mouse pointer position |
2434 | Serge | 2345 | dec ecx |
2346 | jnz .set_mouse_button |
||
2347 | cmp dx, word[Screen_Max_Y] |
||
2348 | ja .end |
||
2349 | rol edx, 16 |
||
2350 | cmp dx, word[Screen_Max_X] |
||
2351 | ja .end |
||
2352 | mov [MOUSE_X], edx |
||
2353 | ret |
||
621 | mario79 | 2354 | .set_mouse_button: |
1232 | Lrz | 2355 | ; cmp ecx,5 ; set mouse button features |
2434 | Serge | 2356 | dec ecx |
2357 | jnz .end |
||
2358 | mov [BTN_DOWN], dl |
||
2359 | mov [mouse_active], 1 |
||
120 | mario79 | 2360 | .end: |
2434 | Serge | 2361 | ret |
2268 | Serge | 2362 | ;------------------------------------------------------------------------------ |
75 | diamond | 2363 | sysfn_getfreemem: |
2434 | Serge | 2364 | mov eax, [pg_data.pages_free] |
2365 | shl eax, 2 |
||
2366 | mov [esp+32], eax |
||
2367 | ret |
||
75 | diamond | 2368 | |
2369 | sysfn_getallmem: |
||
2434 | Serge | 2370 | mov eax, [MEM_AMOUNT] |
2371 | shr eax, 10 |
||
2372 | mov [esp+32], eax |
||
2373 | ret |
||
32 | halyavin | 2374 | |
608 | alver | 2375 | ; // Alver, 2007-22-08 // { |
2376 | sysfn_pid_to_slot: |
||
2434 | Serge | 2377 | mov eax, ecx |
2378 | call pid_to_slot |
||
2379 | mov [esp+32], eax |
||
2380 | ret |
||
608 | alver | 2381 | |
2382 | sysfn_min_rest_window: |
||
2434 | Serge | 2383 | pushad |
2384 | mov eax, edx ; ebx - operating |
||
2385 | shr ecx, 1 |
||
2386 | jnc @f |
||
2387 | call pid_to_slot |
||
608 | alver | 2388 | @@: |
2434 | Serge | 2389 | or eax, eax ; eax - number of slot |
2390 | jz .error |
||
2391 | cmp eax, 255 ; varify maximal slot number |
||
2392 | ja .error |
||
2393 | movzx eax, word [WIN_STACK + eax*2] |
||
2394 | shr ecx, 1 |
||
2395 | jc .restore |
||
608 | alver | 2396 | ; .minimize: |
2434 | Serge | 2397 | call minimize_window |
2398 | jmp .exit |
||
608 | alver | 2399 | .restore: |
2434 | Serge | 2400 | call restore_minimized_window |
608 | alver | 2401 | .exit: |
2434 | Serge | 2402 | popad |
2403 | xor eax, eax |
||
2404 | mov [esp+32], eax |
||
2405 | ret |
||
608 | alver | 2406 | .error: |
2434 | Serge | 2407 | popad |
2408 | xor eax, eax |
||
2409 | dec eax |
||
2410 | mov [esp+32], eax |
||
2411 | ret |
||
608 | alver | 2412 | ; } \\ Alver, 2007-22-08 \\ |
2413 | |||
41 | mikedld | 2414 | uglobal |
2415 | ;// mike.dld, 2006-29-01 [ |
||
2416 | screen_workarea RECT |
||
2417 | ;// mike.dld, 2006-29-01 ] |
||
1 | ha | 2418 | window_minimize db 0 |
1055 | Galkov | 2419 | sound_flag db 0 |
41 | mikedld | 2420 | endg |
1 | ha | 2421 | |
2130 | serge | 2422 | UID_NONE=0 |
2423 | UID_MENUETOS=1 ;official |
||
2424 | UID_KOLIBRI=2 ;russian |
||
2425 | |||
41 | mikedld | 2426 | iglobal |
2427 | version_inf: |
||
1319 | diamond | 2428 | db 0,7,7,0 ; version 0.7.7.0 |
2130 | serge | 2429 | db 0 |
540 | victor | 2430 | dd __REV__ |
41 | mikedld | 2431 | version_end: |
2432 | endg |
||
1 | ha | 2433 | |
2434 | sys_cachetodiskette: |
||
1055 | Galkov | 2435 | cmp ebx, 1 |
2436 | jne .no_floppy_a_save |
||
2437 | mov [flp_number], 1 |
||
2438 | jmp .save_image_on_floppy |
||
671 | Ghost | 2439 | .no_floppy_a_save: |
1055 | Galkov | 2440 | cmp ebx, 2 |
2441 | jne .no_floppy_b_save |
||
2442 | mov [flp_number], 2 |
||
671 | Ghost | 2443 | .save_image_on_floppy: |
1055 | Galkov | 2444 | call save_image |
2445 | mov [esp + 32], dword 0 |
||
2446 | cmp [FDC_Status], 0 |
||
2447 | je .yes_floppy_save |
||
671 | Ghost | 2448 | .no_floppy_b_save: |
1055 | Galkov | 2449 | mov [esp + 32], dword 1 |
671 | Ghost | 2450 | .yes_floppy_save: |
1055 | Galkov | 2451 | ret |
1 | ha | 2452 | |
2453 | uglobal |
||
2454 | ; bgrchanged dd 0x0 |
||
1071 | diamond | 2455 | align 4 |
2456 | bgrlockpid dd 0 |
||
546 | diamond | 2457 | bgrlock db 0 |
1 | ha | 2458 | endg |
2459 | |||
2460 | sys_background: |
||
2461 | |||
2434 | Serge | 2462 | cmp ebx, 1 ; BACKGROUND SIZE |
2463 | jnz nosb1 |
||
2464 | test ecx, ecx |
||
1232 | Lrz | 2465 | ; cmp ecx,0 |
2434 | Serge | 2466 | jz sbgrr |
2467 | test edx, edx |
||
1232 | Lrz | 2468 | ; cmp edx,0 |
2434 | Serge | 2469 | jz sbgrr |
546 | diamond | 2470 | @@: |
1071 | diamond | 2471 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2472 | bts dword [bgrlock], 0 |
||
2473 | jnc @f |
||
1055 | Galkov | 2474 | call change_task |
2475 | jmp @b |
||
546 | diamond | 2476 | @@: |
2434 | Serge | 2477 | mov [BgrDataWidth], ecx |
2478 | mov [BgrDataHeight], edx |
||
1 | ha | 2479 | ; mov [bgrchanged],1 |
469 | serge | 2480 | |
2434 | Serge | 2481 | pushad |
469 | serge | 2482 | ; return memory for old background |
1107 | diamond | 2483 | mov eax, [img_background] |
2484 | cmp eax, static_background_data |
||
2485 | jz @f |
||
2486 | stdcall kernel_free, eax |
||
2487 | @@: |
||
469 | serge | 2488 | ; calculate RAW size |
2434 | Serge | 2489 | xor eax, eax |
2490 | inc eax |
||
2491 | cmp [BgrDataWidth], eax |
||
2492 | jae @f |
||
2493 | mov [BgrDataWidth], eax |
||
469 | serge | 2494 | @@: |
2434 | Serge | 2495 | cmp [BgrDataHeight], eax |
2496 | jae @f |
||
2497 | mov [BgrDataHeight], eax |
||
469 | serge | 2498 | @@: |
2434 | Serge | 2499 | mov eax, [BgrDataWidth] |
2500 | imul eax, [BgrDataHeight] |
||
2501 | lea eax, [eax*3] |
||
2502 | mov [mem_BACKGROUND], eax |
||
469 | serge | 2503 | ; get memory for new background |
2434 | Serge | 2504 | stdcall kernel_alloc, eax |
2505 | test eax, eax |
||
2506 | jz .memfailed |
||
2507 | mov [img_background], eax |
||
2508 | jmp .exit |
||
1107 | diamond | 2509 | .memfailed: |
2510 | ; revert to static monotone data |
||
2511 | mov [img_background], static_background_data |
||
2512 | xor eax, eax |
||
2513 | inc eax |
||
2514 | mov [BgrDataWidth], eax |
||
2515 | mov [BgrDataHeight], eax |
||
2516 | mov [mem_BACKGROUND], 4 |
||
2517 | .exit: |
||
2434 | Serge | 2518 | popad |
1055 | Galkov | 2519 | mov [bgrlock], 0 |
469 | serge | 2520 | |
1 | ha | 2521 | sbgrr: |
2434 | Serge | 2522 | ret |
469 | serge | 2523 | |
875 | serge | 2524 | nosb1: |
1 | ha | 2525 | |
2434 | Serge | 2526 | cmp ebx, 2 ; SET PIXEL |
2527 | jnz nosb2 |
||
875 | serge | 2528 | |
2434 | Serge | 2529 | mov eax, [img_background] |
2530 | test ecx, ecx |
||
2531 | jz @f |
||
2532 | cmp eax, static_background_data |
||
2533 | jz .ret |
||
1107 | diamond | 2534 | @@: |
2434 | Serge | 2535 | mov ebx, [mem_BACKGROUND] |
2536 | add ebx, 4095 |
||
2537 | and ebx, -4096 |
||
2538 | sub ebx, 4 |
||
2539 | cmp ecx, ebx |
||
2540 | ja .ret |
||
875 | serge | 2541 | |
2434 | Serge | 2542 | mov ebx, [eax+ecx] |
2543 | and ebx, 0xFF000000;255*256*256*256 |
||
2544 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
||
2545 | add edx, ebx |
||
2546 | mov [eax+ecx], edx |
||
1107 | diamond | 2547 | .ret: |
2434 | Serge | 2548 | ret |
875 | serge | 2549 | nosb2: |
1 | ha | 2550 | |
2434 | Serge | 2551 | cmp ebx, 3 ; DRAW BACKGROUND |
2552 | jnz nosb3 |
||
1 | ha | 2553 | draw_background_temp: |
2554 | ; cmp [bgrchanged],1 ;0 |
||
2555 | ; je nosb31 |
||
2556 | ;draw_background_temp: |
||
2557 | ; mov [bgrchanged],1 ;0 |
||
2434 | Serge | 2558 | mov [background_defined], 1 |
2559 | mov byte[BACKGROUND_CHANGED], 1 |
||
2560 | call force_redraw_background |
||
1 | ha | 2561 | nosb31: |
2434 | Serge | 2562 | ret |
1 | ha | 2563 | nosb3: |
2564 | |||
2434 | Serge | 2565 | cmp ebx, 4 ; TILED / STRETCHED |
2566 | jnz nosb4 |
||
2567 | cmp ecx, [BgrDrawMode] |
||
2568 | je nosb41 |
||
2569 | mov [BgrDrawMode], ecx |
||
1 | ha | 2570 | ; mov [bgrchanged],1 |
2571 | nosb41: |
||
2434 | Serge | 2572 | ret |
1 | ha | 2573 | nosb4: |
2574 | |||
2434 | Serge | 2575 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2576 | jnz nosb5 |
||
2577 | cmp [img_background], static_background_data |
||
2578 | jnz @f |
||
2579 | test edx, edx |
||
2580 | jnz .fin |
||
2581 | cmp esi, 4 |
||
2582 | ja .fin |
||
1107 | diamond | 2583 | @@: |
1 | ha | 2584 | ; bughere |
2434 | Serge | 2585 | mov eax, ecx |
2586 | mov ebx, edx |
||
2587 | add ebx, [img_background];IMG_BACKGROUND |
||
2588 | mov ecx, esi |
||
2589 | call memmove |
||
1 | ha | 2590 | .fin: |
2434 | Serge | 2591 | ret |
1 | ha | 2592 | nosb5: |
479 | kastigar | 2593 | |
1055 | Galkov | 2594 | cmp ebx, 6 |
2595 | jnz nosb6 |
||
1071 | diamond | 2596 | ;;Maxis use atomic bts for mutex 4.4.2009 |
546 | diamond | 2597 | @@: |
1073 | heavyiron | 2598 | bts dword [bgrlock], 0 |
1071 | diamond | 2599 | jnc @f |
1055 | Galkov | 2600 | call change_task |
2601 | jmp @b |
||
546 | diamond | 2602 | @@: |
1055 | Galkov | 2603 | mov eax, [CURRENT_TASK] |
2604 | mov [bgrlockpid], eax |
||
1107 | diamond | 2605 | cmp [img_background], static_background_data |
2606 | jz .nomem |
||
1055 | Galkov | 2607 | stdcall user_alloc, [mem_BACKGROUND] |
2608 | mov [esp+32], eax |
||
2609 | test eax, eax |
||
2610 | jz .nomem |
||
2611 | mov ebx, eax |
||
2612 | shr ebx, 12 |
||
2613 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
||
2614 | mov esi, [img_background] |
||
2615 | shr esi, 12 |
||
2616 | mov ecx, [mem_BACKGROUND] |
||
2617 | add ecx, 0xFFF |
||
2618 | shr ecx, 12 |
||
546 | diamond | 2619 | .z: |
1055 | Galkov | 2620 | mov eax, [page_tabs+ebx*4] |
2621 | test al, 1 |
||
2622 | jz @f |
||
2623 | call free_page |
||
546 | diamond | 2624 | @@: |
1055 | Galkov | 2625 | mov eax, [page_tabs+esi*4] |
2626 | or al, PG_UW |
||
2627 | mov [page_tabs+ebx*4], eax |
||
2628 | mov eax, ebx |
||
2629 | shl eax, 12 |
||
2630 | invlpg [eax] |
||
2631 | inc ebx |
||
2632 | inc esi |
||
2633 | loop .z |
||
2634 | ret |
||
546 | diamond | 2635 | .nomem: |
1055 | Galkov | 2636 | and [bgrlockpid], 0 |
2637 | mov [bgrlock], 0 |
||
546 | diamond | 2638 | nosb6: |
1055 | Galkov | 2639 | cmp ebx, 7 |
2640 | jnz nosb7 |
||
2641 | cmp [bgrlock], 0 |
||
2642 | jz .err |
||
2643 | mov eax, [CURRENT_TASK] |
||
2644 | cmp [bgrlockpid], eax |
||
2645 | jnz .err |
||
2646 | mov eax, ecx |
||
2647 | mov ebx, ecx |
||
2648 | shr eax, 12 |
||
2649 | mov ecx, [page_tabs+(eax-1)*4] |
||
2650 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
||
2651 | jz .err |
||
2652 | jnp .err |
||
2653 | push eax |
||
2654 | shr ecx, 12 |
||
1312 | diamond | 2655 | dec ecx |
546 | diamond | 2656 | @@: |
1055 | Galkov | 2657 | and dword [page_tabs+eax*4], 0 |
2658 | mov edx, eax |
||
2659 | shl edx, 12 |
||
2434 | Serge | 2660 | push eax |
1055 | Galkov | 2661 | invlpg [edx] |
2434 | Serge | 2662 | pop eax |
1055 | Galkov | 2663 | inc eax |
2664 | loop @b |
||
2665 | pop eax |
||
2666 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
||
2667 | stdcall user_free, ebx |
||
2668 | mov [esp+32], eax |
||
2669 | and [bgrlockpid], 0 |
||
2670 | mov [bgrlock], 0 |
||
2671 | ret |
||
546 | diamond | 2672 | .err: |
1055 | Galkov | 2673 | and dword [esp+32], 0 |
2674 | ret |
||
546 | diamond | 2675 | |
2676 | nosb7: |
||
2434 | Serge | 2677 | ret |
1 | ha | 2678 | |
709 | diamond | 2679 | force_redraw_background: |
2434 | Serge | 2680 | and [draw_data+32 + RECT.left], 0 |
2681 | and [draw_data+32 + RECT.top], 0 |
||
2682 | push eax ebx |
||
2683 | mov eax, [Screen_Max_X] |
||
2684 | mov ebx, [Screen_Max_Y] |
||
2685 | mov [draw_data+32 + RECT.right], eax |
||
2686 | mov [draw_data+32 + RECT.bottom], ebx |
||
2687 | pop ebx eax |
||
2688 | inc byte[REDRAW_BACKGROUND] |
||
2689 | ret |
||
479 | kastigar | 2690 | |
1 | ha | 2691 | align 4 |
2692 | |||
2693 | sys_getbackground: |
||
1304 | Lrz | 2694 | ; cmp eax,1 ; SIZE |
2434 | Serge | 2695 | dec ebx |
2696 | jnz nogb1 |
||
2697 | mov eax, [BgrDataWidth] |
||
2698 | shl eax, 16 |
||
2699 | mov ax, [BgrDataHeight] |
||
2700 | mov [esp+32], eax |
||
2701 | ret |
||
1 | ha | 2702 | |
875 | serge | 2703 | nogb1: |
1304 | Lrz | 2704 | ; cmp eax,2 ; PIXEL |
2434 | Serge | 2705 | dec ebx |
2706 | jnz nogb2 |
||
875 | serge | 2707 | |
1107 | diamond | 2708 | mov eax, [img_background] |
1304 | Lrz | 2709 | test ecx, ecx |
1107 | diamond | 2710 | jz @f |
2711 | cmp eax, static_background_data |
||
2712 | jz .ret |
||
2713 | @@: |
||
2434 | Serge | 2714 | mov ebx, [mem_BACKGROUND] |
2715 | add ebx, 4095 |
||
2716 | and ebx, -4096 |
||
2717 | sub ebx, 4 |
||
2718 | cmp ecx, ebx |
||
2719 | ja .ret |
||
875 | serge | 2720 | |
2434 | Serge | 2721 | mov eax, [ecx+eax] |
469 | serge | 2722 | |
2434 | Serge | 2723 | and eax, 0xFFFFFF |
2724 | mov [esp+32], eax |
||
1107 | diamond | 2725 | .ret: |
2434 | Serge | 2726 | ret |
1 | ha | 2727 | nogb2: |
2728 | |||
1304 | Lrz | 2729 | ; cmp eax,4 ; TILED / STRETCHED |
2434 | Serge | 2730 | dec ebx |
2731 | dec ebx |
||
2732 | jnz nogb4 |
||
2733 | mov eax, [BgrDrawMode] |
||
1 | ha | 2734 | nogb4: |
2434 | Serge | 2735 | mov [esp+32], eax |
2736 | ret |
||
1 | ha | 2737 | |
2738 | align 4 |
||
2739 | |||
2740 | sys_getkey: |
||
2434 | Serge | 2741 | mov [esp + 32], dword 1 |
1055 | Galkov | 2742 | ; test main buffer |
2743 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
||
2744 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
2745 | mov edx, [TASK_COUNT] |
||
2746 | cmp ecx, edx |
||
2747 | jne .finish |
||
2748 | cmp [KEY_COUNT], byte 0 |
||
2749 | je .finish |
||
2750 | movzx eax, byte [KEY_BUFF] |
||
2751 | shl eax, 8 |
||
2752 | push eax |
||
2753 | dec byte [KEY_COUNT] |
||
2754 | and byte [KEY_COUNT], 127 |
||
2755 | movzx ecx, byte [KEY_COUNT] |
||
2756 | add ecx, 2 |
||
2757 | mov eax, KEY_BUFF + 1 |
||
2758 | mov ebx, KEY_BUFF |
||
2759 | call memmove |
||
2760 | pop eax |
||
92 | diamond | 2761 | .ret_eax: |
1055 | Galkov | 2762 | mov [esp + 32], eax |
2763 | ret |
||
671 | Ghost | 2764 | .finish: |
92 | diamond | 2765 | ; test hotkeys buffer |
1055 | Galkov | 2766 | mov ecx, hotkey_buffer |
92 | diamond | 2767 | @@: |
1055 | Galkov | 2768 | cmp [ecx], ebx |
2769 | jz .found |
||
2770 | add ecx, 8 |
||
2771 | cmp ecx, hotkey_buffer + 120 * 8 |
||
2772 | jb @b |
||
2773 | ret |
||
92 | diamond | 2774 | .found: |
1055 | Galkov | 2775 | mov ax, [ecx + 6] |
2776 | shl eax, 16 |
||
2777 | mov ah, [ecx + 4] |
||
2778 | mov al, 2 |
||
2779 | and dword [ecx + 4], 0 |
||
2780 | and dword [ecx], 0 |
||
2781 | jmp .ret_eax |
||
1 | ha | 2782 | |
2783 | align 4 |
||
2784 | |||
2785 | sys_getbutton: |
||
2786 | |||
1055 | Galkov | 2787 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
2788 | mov [esp + 32], dword 1 |
||
2789 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
2790 | mov edx, [TASK_COUNT] ; less than 256 processes |
||
2791 | cmp ecx, edx |
||
2792 | jne .exit |
||
2793 | movzx eax, byte [BTN_COUNT] |
||
2794 | test eax, eax |
||
2795 | jz .exit |
||
2796 | mov eax, [BTN_BUFF] |
||
1391 | mikedld | 2797 | and al, 0xFE ; delete left button bit |
1055 | Galkov | 2798 | mov [BTN_COUNT], byte 0 |
2799 | mov [esp + 32], eax |
||
671 | Ghost | 2800 | .exit: |
1055 | Galkov | 2801 | ret |
1 | ha | 2802 | |
2803 | |||
2804 | align 4 |
||
2805 | |||
2806 | sys_cpuusage: |
||
2807 | |||
2808 | ; RETURN: |
||
2809 | ; |
||
2810 | ; +00 dword process cpu usage |
||
2811 | ; +04 word position in windowing stack |
||
2812 | ; +06 word windowing stack value at current position (cpu nro) |
||
2813 | ; +10 12 bytes name |
||
2814 | ; +22 dword start in mem |
||
2815 | ; +26 dword used mem |
||
2816 | ; +30 dword PID , process idenfification number |
||
2817 | ; |
||
2818 | |||
2434 | Serge | 2819 | cmp ecx, -1 ; who am I ? |
2820 | jne .no_who_am_i |
||
2821 | mov ecx, [CURRENT_TASK] |
||
684 | diamond | 2822 | .no_who_am_i: |
1055 | Galkov | 2823 | cmp ecx, max_processes |
2824 | ja .nofillbuf |
||
1 | ha | 2825 | |
684 | diamond | 2826 | ; +4: word: position of the window of thread in the window stack |
1055 | Galkov | 2827 | mov ax, [WIN_STACK + ecx * 2] |
2828 | mov [ebx+4], ax |
||
684 | diamond | 2829 | ; +6: word: number of the thread slot, which window has in the window stack |
2830 | ; position ecx (has no relation to the specific thread) |
||
1055 | Galkov | 2831 | mov ax, [WIN_POS + ecx * 2] |
2832 | mov [ebx+6], ax |
||
1 | ha | 2833 | |
1055 | Galkov | 2834 | shl ecx, 5 |
1 | ha | 2835 | |
684 | diamond | 2836 | ; +0: dword: memory usage |
1055 | Galkov | 2837 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
2838 | mov [ebx], eax |
||
684 | diamond | 2839 | ; +10: 11 bytes: name of the process |
1055 | Galkov | 2840 | push ecx |
2841 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
||
2842 | add ebx, 10 |
||
2843 | mov ecx, 11 |
||
2844 | call memmove |
||
2845 | pop ecx |
||
1 | ha | 2846 | |
684 | diamond | 2847 | ; +22: address of the process in memory |
2848 | ; +26: size of used memory - 1 |
||
1055 | Galkov | 2849 | push edi |
2850 | lea edi, [ebx+12] |
||
2851 | xor eax, eax |
||
2852 | mov edx, 0x100000*16 |
||
2853 | cmp ecx, 1 shl 5 |
||
2854 | je .os_mem |
||
2855 | mov edx, [SLOT_BASE+ecx*8+APPDATA.mem_size] |
||
2856 | mov eax, std_application_base_address |
||
684 | diamond | 2857 | .os_mem: |
1055 | Galkov | 2858 | stosd |
2859 | lea eax, [edx-1] |
||
2860 | stosd |
||
1 | ha | 2861 | |
684 | diamond | 2862 | ; +30: PID/TID |
1055 | Galkov | 2863 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
2864 | stosd |
||
1 | ha | 2865 | |
2866 | ; window position and size |
||
1055 | Galkov | 2867 | push esi |
2868 | lea esi, [ecx + window_data + WDATA.box] |
||
2869 | movsd |
||
2870 | movsd |
||
2871 | movsd |
||
2872 | movsd |
||
1 | ha | 2873 | |
2874 | ; Process state (+50) |
||
1055 | Galkov | 2875 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
2876 | stosd |
||
1 | ha | 2877 | |
138 | mikedld | 2878 | ; Window client area box |
1055 | Galkov | 2879 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
2880 | movsd |
||
2881 | movsd |
||
2882 | movsd |
||
2883 | movsd |
||
1 | ha | 2884 | |
164 | serge | 2885 | ; Window state |
1055 | Galkov | 2886 | mov al, [ecx+window_data+WDATA.fl_wstate] |
2887 | stosb |
||
164 | serge | 2888 | |
2010 | serge | 2889 | ; Event mask (+71) |
2890 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
||
2891 | stosd |
||
2892 | |||
1055 | Galkov | 2893 | pop esi |
2894 | pop edi |
||
138 | mikedld | 2895 | |
684 | diamond | 2896 | .nofillbuf: |
1 | ha | 2897 | ; return number of processes |
2898 | |||
2434 | Serge | 2899 | mov eax, [TASK_COUNT] |
2900 | mov [esp+32], eax |
||
2901 | ret |
||
1 | ha | 2902 | |
2903 | align 4 |
||
2904 | sys_clock: |
||
1055 | Galkov | 2905 | cli |
1 | ha | 2906 | ; Mikhail Lisovin xx Jan 2005 |
2907 | @@: |
||
2434 | Serge | 2908 | mov al, 10 |
2909 | out 0x70, al |
||
2910 | in al, 0x71 |
||
2911 | test al, al |
||
2912 | jns @f |
||
2913 | mov esi, 1 |
||
2914 | call delay_ms |
||
2915 | jmp @b |
||
2916 | @@: |
||
1 | ha | 2917 | ; end Lisovin's fix |
2918 | |||
2434 | Serge | 2919 | xor al, al ; seconds |
2920 | out 0x70, al |
||
2921 | in al, 0x71 |
||
2922 | movzx ecx, al |
||
2923 | mov al, 02 ; minutes |
||
2924 | shl ecx, 16 |
||
2925 | out 0x70, al |
||
2926 | in al, 0x71 |
||
2927 | movzx edx, al |
||
2928 | mov al, 04 ; hours |
||
2929 | shl edx, 8 |
||
2930 | out 0x70, al |
||
2931 | in al, 0x71 |
||
2932 | add ecx, edx |
||
2933 | movzx edx, al |
||
2934 | add ecx, edx |
||
1055 | Galkov | 2935 | sti |
2936 | mov [esp + 32], ecx |
||
2937 | ret |
||
1 | ha | 2938 | |
2939 | |||
2940 | align 4 |
||
2941 | |||
2942 | sys_date: |
||
2943 | |||
1055 | Galkov | 2944 | cli |
75 | diamond | 2945 | @@: |
2434 | Serge | 2946 | mov al, 10 |
2947 | out 0x70, al |
||
2948 | in al, 0x71 |
||
2949 | test al, al |
||
2950 | jns @f |
||
2951 | mov esi, 1 |
||
2952 | call delay_ms |
||
2953 | jmp @b |
||
2954 | @@: |
||
75 | diamond | 2955 | |
2434 | Serge | 2956 | mov ch, 0 |
2957 | mov al, 7 ; date |
||
2958 | out 0x70, al |
||
2959 | in al, 0x71 |
||
2960 | mov cl, al |
||
2961 | mov al, 8 ; month |
||
2962 | shl ecx, 16 |
||
2963 | out 0x70, al |
||
2964 | in al, 0x71 |
||
2965 | mov ch, al |
||
2966 | mov al, 9 ; year |
||
2967 | out 0x70, al |
||
2968 | in al, 0x71 |
||
2969 | mov cl, al |
||
1055 | Galkov | 2970 | sti |
2971 | mov [esp+32], ecx |
||
2972 | ret |
||
1 | ha | 2973 | |
2974 | |||
2975 | ; redraw status |
||
2976 | |||
2977 | sys_redrawstat: |
||
1055 | Galkov | 2978 | cmp ebx, 1 |
2979 | jne no_widgets_away |
||
2980 | ; buttons away |
||
2434 | Serge | 2981 | mov ecx, [CURRENT_TASK] |
1 | ha | 2982 | sys_newba2: |
2434 | Serge | 2983 | mov edi, [BTN_ADDR] |
1055 | Galkov | 2984 | cmp [edi], dword 0 ; empty button list ? |
2985 | je end_of_buttons_away |
||
2986 | movzx ebx, word [edi] |
||
2987 | inc ebx |
||
2434 | Serge | 2988 | mov eax, edi |
1 | ha | 2989 | sys_newba: |
1055 | Galkov | 2990 | dec ebx |
2991 | jz end_of_buttons_away |
||
1 | ha | 2992 | |
1055 | Galkov | 2993 | add eax, 0x10 |
2994 | cmp cx, [eax] |
||
2995 | jnz sys_newba |
||
1 | ha | 2996 | |
1055 | Galkov | 2997 | push eax ebx ecx |
2434 | Serge | 2998 | mov ecx, ebx |
1055 | Galkov | 2999 | inc ecx |
3000 | shl ecx, 4 |
||
3001 | mov ebx, eax |
||
3002 | add eax, 0x10 |
||
3003 | call memmove |
||
3004 | dec dword [edi] |
||
3005 | pop ecx ebx eax |
||
1 | ha | 3006 | |
1055 | Galkov | 3007 | jmp sys_newba2 |
1 | ha | 3008 | |
3009 | end_of_buttons_away: |
||
3010 | |||
1055 | Galkov | 3011 | ret |
1 | ha | 3012 | |
3013 | no_widgets_away: |
||
3014 | |||
1055 | Galkov | 3015 | cmp ebx, 2 |
3016 | jnz srl1 |
||
1 | ha | 3017 | |
1055 | Galkov | 3018 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3019 | add edx, draw_data - CURRENT_TASK |
||
3020 | mov [edx + RECT.left], 0 |
||
3021 | mov [edx + RECT.top], 0 |
||
3022 | mov eax, [Screen_Max_X] |
||
3023 | mov [edx + RECT.right], eax |
||
3024 | mov eax, [Screen_Max_Y] |
||
3025 | mov [edx + RECT.bottom], eax |
||
1 | ha | 3026 | |
3027 | srl1: |
||
1055 | Galkov | 3028 | ret |
1 | ha | 3029 | |
3030 | ;ok - 100% work |
||
3031 | ;nt - not tested |
||
3032 | ;--------------------------------------------------------------------------------------------- |
||
3033 | ;eax |
||
3034 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
||
3035 | ;1 - change task. Ret nothing. Block. ok. |
||
3036 | ;2 - performance control |
||
3037 | ; ebx |
||
3038 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
||
3039 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
||
3040 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
||
3041 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
||
3042 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
||
3043 | ;eax |
||
3044 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3045 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
3046 | ;--------------------------------------------------------------------------------------------- |
||
1344 | Lrz | 3047 | iglobal |
3048 | align 4 |
||
3049 | sheduler: |
||
2434 | Serge | 3050 | dd sys_sheduler.00 |
3051 | dd change_task |
||
3052 | dd sys_sheduler.02 |
||
3053 | dd sys_sheduler.03 |
||
3054 | dd sys_sheduler.04 |
||
1344 | Lrz | 3055 | endg |
1638 | serge | 3056 | sys_sheduler: |
1344 | Lrz | 3057 | ;rewritten by |
2434 | Serge | 3058 | jmp dword [sheduler+ebx*4] |
1344 | Lrz | 3059 | ;.shed_counter: |
3060 | .00: |
||
2434 | Serge | 3061 | mov eax, [context_counter] |
3062 | mov [esp+32], eax |
||
3063 | ret |
||
1273 | Lrz | 3064 | |
1344 | Lrz | 3065 | .02: |
3066 | ;.perf_control: |
||
2434 | Serge | 3067 | inc ebx ;before ebx=2, ebx=3 |
3068 | cmp ebx, ecx ;if ecx=3, ebx=3 |
||
3069 | jz cache_disable |
||
1365 | Lrz | 3070 | |
2434 | Serge | 3071 | dec ebx ;ebx=2 |
3072 | cmp ebx, ecx ; |
||
3073 | jz cache_enable ;if ecx=2 and ebx=2 |
||
1365 | Lrz | 3074 | |
2434 | Serge | 3075 | dec ebx ;ebx=1 |
3076 | cmp ebx, ecx |
||
3077 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
||
1365 | Lrz | 3078 | |
2434 | Serge | 3079 | dec ebx |
3080 | test ebx, ecx ;ebx=0 and ecx=0 |
||
3081 | jz modify_pce ;if ecx=0 |
||
1365 | Lrz | 3082 | |
2434 | Serge | 3083 | ret |
1345 | Lrz | 3084 | |
1638 | serge | 3085 | .03: |
1344 | Lrz | 3086 | ;.rdmsr_instr: |
3087 | ;now counter in ecx |
||
3088 | ;(edx:eax) esi:edi => edx:esi |
||
2434 | Serge | 3089 | mov eax, esi |
3090 | mov ecx, edx |
||
3091 | rdmsr |
||
3092 | mov [esp+32], eax |
||
3093 | mov [esp+20], edx ;ret in ebx? |
||
3094 | ret |
||
1344 | Lrz | 3095 | |
3096 | .04: |
||
1273 | Lrz | 3097 | ;.wrmsr_instr: |
3098 | ;now counter in ecx |
||
3099 | ;(edx:eax) esi:edi => edx:esi |
||
3100 | ; Fast Call MSR can't be destroy |
||
3101 | ; ® MSR_AMD_EFER ¬®¦® ¨§¬¥ïâì, â.ª. ¢ í⮬ ॣ¨áâॠ«¨è |
||
3102 | ; ¢ª«îç îâáï/¢ëª«îç îâáï à áè¨à¥ë¥ ¢®§¬®¦®á⨠|
||
2434 | Serge | 3103 | cmp edx, MSR_SYSENTER_CS |
1273 | Lrz | 3104 | je @f |
2434 | Serge | 3105 | cmp edx, MSR_SYSENTER_ESP |
1273 | Lrz | 3106 | je @f |
2434 | Serge | 3107 | cmp edx, MSR_SYSENTER_EIP |
1273 | Lrz | 3108 | je @f |
2434 | Serge | 3109 | cmp edx, MSR_AMD_STAR |
1273 | Lrz | 3110 | je @f |
3111 | |||
2434 | Serge | 3112 | mov eax, esi |
3113 | mov ecx, edx |
||
1273 | Lrz | 3114 | wrmsr |
1344 | Lrz | 3115 | ; mov [esp + 32], eax |
3116 | ; mov [esp + 20], edx ;ret in ebx? |
||
1273 | Lrz | 3117 | @@: |
2434 | Serge | 3118 | ret |
1273 | Lrz | 3119 | |
1 | ha | 3120 | cache_disable: |
2434 | Serge | 3121 | mov eax, cr0 |
3122 | or eax, 01100000000000000000000000000000b |
||
3123 | mov cr0, eax |
||
3124 | wbinvd ;set MESI |
||
3125 | ret |
||
1 | ha | 3126 | |
3127 | cache_enable: |
||
2434 | Serge | 3128 | mov eax, cr0 |
3129 | and eax, 10011111111111111111111111111111b |
||
3130 | mov cr0, eax |
||
3131 | ret |
||
1 | ha | 3132 | |
3133 | is_cache_enabled: |
||
2434 | Serge | 3134 | mov eax, cr0 |
3135 | mov ebx, eax |
||
3136 | and eax, 01100000000000000000000000000000b |
||
3137 | jz cache_disabled |
||
3138 | mov [esp+32], ebx |
||
1 | ha | 3139 | cache_disabled: |
2434 | Serge | 3140 | mov dword [esp+32], eax;0 |
3141 | ret |
||
1 | ha | 3142 | |
3143 | modify_pce: |
||
2434 | Serge | 3144 | mov eax, cr4 |
1 | ha | 3145 | ; mov ebx,0 |
3146 | ; or bx,100000000b ;pce |
||
3147 | ; xor eax,ebx ;invert pce |
||
2434 | Serge | 3148 | bts eax, 8;pce=cr4[8] |
3149 | mov cr4, eax |
||
3150 | mov [esp+32], eax |
||
3151 | ret |
||
1 | ha | 3152 | ;--------------------------------------------------------------------------------------------- |
3153 | |||
3154 | |||
3155 | ; check if pixel is allowed to be drawn |
||
3156 | |||
3157 | checkpixel: |
||
2434 | Serge | 3158 | push eax edx |
1 | ha | 3159 | |
2434 | Serge | 3160 | mov edx, [Screen_Max_X] ; screen x size |
3161 | inc edx |
||
3162 | imul edx, ebx |
||
3163 | add eax, [_WinMapAddress] |
||
3164 | mov dl, [eax+edx]; lea eax, [...] |
||
1 | ha | 3165 | |
2434 | Serge | 3166 | xor ecx, ecx |
3167 | mov eax, [CURRENT_TASK] |
||
3168 | cmp al, dl |
||
3169 | setne cl |
||
1 | ha | 3170 | |
2434 | Serge | 3171 | pop edx eax |
1055 | Galkov | 3172 | ret |
1 | ha | 3173 | |
3174 | iglobal |
||
521 | diamond | 3175 | cpustring db 'CPU',0 |
1 | ha | 3176 | endg |
3177 | |||
67 | diamond | 3178 | uglobal |
1055 | Galkov | 3179 | background_defined db 0 ; diamond, 11.04.2006 |
67 | diamond | 3180 | endg |
1 | ha | 3181 | |
3182 | align 4 |
||
3183 | ; check misc |
||
3184 | |||
3185 | checkmisc: |
||
3186 | |||
2434 | Serge | 3187 | cmp [ctrl_alt_del], 1 |
3188 | jne nocpustart |
||
501 | serge | 3189 | |
1055 | Galkov | 3190 | mov ebp, cpustring |
3191 | call fs_execute_from_sysdir |
||
501 | serge | 3192 | |
2434 | Serge | 3193 | mov [ctrl_alt_del], 0 |
465 | serge | 3194 | |
3195 | nocpustart: |
||
2434 | Serge | 3196 | cmp [mouse_active], 1 |
3197 | jne mouse_not_active |
||
3198 | mov [mouse_active], 0 |
||
1 | ha | 3199 | |
2434 | Serge | 3200 | xor edi, edi |
3201 | mov ebx, CURRENT_TASK |
||
3202 | |||
3203 | mov ecx, [TASK_COUNT] |
||
3204 | movzx eax, word [WIN_POS + ecx*2] ; active window |
||
3205 | shl eax, 8 |
||
3206 | push eax |
||
3207 | |||
3208 | movzx eax, word [MOUSE_X] |
||
3209 | movzx edx, word [MOUSE_Y] |
||
3210 | |||
3211 | align 4 |
||
3212 | .set_mouse_event: |
||
3213 | add edi, 256 |
||
3214 | add ebx, 32 |
||
3215 | test [ebx+TASKDATA.event_mask], 0x80000000 |
||
3216 | jz .pos_filter |
||
3217 | |||
3218 | cmp edi, [esp] ; skip if filtration active |
||
3219 | jne .skip |
||
3220 | |||
3221 | .pos_filter: |
||
3222 | test [ebx+TASKDATA.event_mask], 0x40000000 |
||
3223 | jz .set |
||
3224 | |||
3225 | mov esi, [ebx-twdw+WDATA.box.left] |
||
3226 | cmp eax, esi |
||
3227 | jb .skip |
||
3228 | add esi, [ebx-twdw+WDATA.box.width] |
||
3229 | cmp eax, esi |
||
3230 | ja .skip |
||
3231 | |||
3232 | mov esi, [ebx-twdw+WDATA.box.top] |
||
3233 | cmp edx, esi |
||
3234 | jb .skip |
||
3235 | add esi, [ebx-twdw+WDATA.box.height] |
||
3236 | cmp edx, esi |
||
3237 | ja .skip |
||
3238 | .set: |
||
3239 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b |
||
3240 | .skip: |
||
3241 | loop .set_mouse_event |
||
3242 | |||
3243 | pop eax |
||
3244 | |||
465 | serge | 3245 | mouse_not_active: |
2434 | Serge | 3246 | cmp byte[BACKGROUND_CHANGED], 0 |
3247 | jz no_set_bgr_event |
||
3248 | xor edi, edi |
||
3249 | mov ecx, [TASK_COUNT] |
||
473 | diamond | 3250 | set_bgr_event: |
2434 | Serge | 3251 | add edi, 256 |
3252 | or [edi+SLOT_BASE+APPDATA.event_mask], 16 |
||
3253 | loop set_bgr_event |
||
3254 | mov byte[BACKGROUND_CHANGED], 0 |
||
709 | diamond | 3255 | no_set_bgr_event: |
2434 | Serge | 3256 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3257 | jz nobackgr |
||
3258 | cmp [background_defined], 0 |
||
3259 | jz nobackgr |
||
709 | diamond | 3260 | ; mov [draw_data+32 + RECT.left],dword 0 |
3261 | ; mov [draw_data+32 + RECT.top],dword 0 |
||
753 | serge | 3262 | ; mov eax,[Screen_Max_X] |
3263 | ; mov ebx,[Screen_Max_Y] |
||
709 | diamond | 3264 | ; mov [draw_data+32 + RECT.right],eax |
3265 | ; mov [draw_data+32 + RECT.bottom],ebx |
||
1392 | diamond | 3266 | @@: |
2434 | Serge | 3267 | call drawbackground |
3268 | xor eax, eax |
||
3269 | xchg al, [REDRAW_BACKGROUND] |
||
3270 | test al, al ; got new update request? |
||
3271 | jnz @b |
||
3272 | mov [draw_data+32 + RECT.left], eax |
||
3273 | mov [draw_data+32 + RECT.top], eax |
||
3274 | mov [draw_data+32 + RECT.right], eax |
||
3275 | mov [draw_data+32 + RECT.bottom], eax |
||
3276 | mov [MOUSE_BACKGROUND], byte 0 |
||
1 | ha | 3277 | |
465 | serge | 3278 | nobackgr: |
1 | ha | 3279 | |
3280 | ; system shutdown request |
||
3281 | |||
2434 | Serge | 3282 | cmp [SYS_SHUTDOWN], byte 0 |
3283 | je noshutdown |
||
1 | ha | 3284 | |
2434 | Serge | 3285 | mov edx, [shutdown_processes] |
1 | ha | 3286 | |
2434 | Serge | 3287 | cmp [SYS_SHUTDOWN], dl |
3288 | jne no_mark_system_shutdown |
||
1 | ha | 3289 | |
2434 | Serge | 3290 | lea ecx, [edx-1] |
3291 | mov edx, OS_BASE+0x3040 |
||
3292 | jecxz @f |
||
465 | serge | 3293 | markz: |
2434 | Serge | 3294 | mov [edx+TASKDATA.state], byte 3 |
3295 | add edx, 0x20 |
||
3296 | loop markz |
||
709 | diamond | 3297 | @@: |
1 | ha | 3298 | |
3299 | no_mark_system_shutdown: |
||
3300 | |||
2434 | Serge | 3301 | dec byte [SYS_SHUTDOWN] |
3302 | je system_shutdown |
||
1 | ha | 3303 | |
465 | serge | 3304 | noshutdown: |
1 | ha | 3305 | |
3306 | |||
2434 | Serge | 3307 | mov eax, [TASK_COUNT] ; termination |
3308 | mov ebx, TASK_DATA+TASKDATA.state |
||
3309 | mov esi, 1 |
||
1 | ha | 3310 | |
465 | serge | 3311 | newct: |
2434 | Serge | 3312 | mov cl, [ebx] |
3313 | cmp cl, byte 3 |
||
3314 | jz terminate |
||
3315 | cmp cl, byte 4 |
||
3316 | jz terminate |
||
1 | ha | 3317 | |
2434 | Serge | 3318 | add ebx, 0x20 |
3319 | inc esi |
||
3320 | dec eax |
||
3321 | jnz newct |
||
3322 | ret |
||
1 | ha | 3323 | |
3324 | ; redraw screen |
||
3325 | |||
3326 | redrawscreen: |
||
3327 | |||
3328 | ; eax , if process window_data base is eax, do not set flag/limits |
||
3329 | |||
2434 | Serge | 3330 | pushad |
3331 | push eax |
||
1 | ha | 3332 | |
684 | diamond | 3333 | ;;; mov ebx,2 |
1 | ha | 3334 | ;;; call delay_hs |
3335 | |||
1055 | Galkov | 3336 | ;mov ecx,0 ; redraw flags for apps |
2434 | Serge | 3337 | xor ecx, ecx |
1 | ha | 3338 | newdw2: |
3339 | |||
2434 | Serge | 3340 | inc ecx |
3341 | push ecx |
||
1 | ha | 3342 | |
2434 | Serge | 3343 | mov eax, ecx |
3344 | shl eax, 5 |
||
3345 | add eax, window_data |
||
1 | ha | 3346 | |
2434 | Serge | 3347 | cmp eax, [esp+4] |
3348 | je not_this_task |
||
1055 | Galkov | 3349 | ; check if window in redraw area |
2434 | Serge | 3350 | mov edi, eax |
1 | ha | 3351 | |
2434 | Serge | 3352 | cmp ecx, 1 ; limit for background |
3353 | jz bgli |
||
1 | ha | 3354 | |
2434 | Serge | 3355 | mov eax, [edi + WDATA.box.left] |
3356 | mov ebx, [edi + WDATA.box.top] |
||
3357 | mov ecx, [edi + WDATA.box.width] |
||
3358 | mov edx, [edi + WDATA.box.height] |
||
3359 | add ecx, eax |
||
3360 | add edx, ebx |
||
1 | ha | 3361 | |
2434 | Serge | 3362 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3363 | cmp ecx, ebx |
||
3364 | jb ricino |
||
1 | ha | 3365 | |
2434 | Serge | 3366 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3367 | cmp ecx, eax |
||
3368 | jb ricino |
||
1 | ha | 3369 | |
2434 | Serge | 3370 | mov eax, [edi + WDATA.box.left] |
3371 | mov ebx, [edi + WDATA.box.top] |
||
3372 | mov ecx, [edi + WDATA.box.width] |
||
3373 | mov edx, [edi + WDATA.box.height] |
||
3374 | add ecx, eax |
||
3375 | add edx, ebx |
||
164 | serge | 3376 | |
2434 | Serge | 3377 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3378 | cmp edx, eax |
||
3379 | jb ricino |
||
1 | ha | 3380 | |
2434 | Serge | 3381 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3382 | cmp ecx, eax |
||
3383 | jb ricino |
||
1 | ha | 3384 | |
1055 | Galkov | 3385 | bgli: |
1 | ha | 3386 | |
2434 | Serge | 3387 | cmp dword[esp], 1 |
3388 | jnz .az |
||
1392 | diamond | 3389 | ; cmp byte[BACKGROUND_CHANGED], 0 |
3390 | ; jnz newdw8 |
||
2434 | Serge | 3391 | cmp byte[REDRAW_BACKGROUND], 0 |
3392 | jz .az |
||
3393 | mov dl, 0 |
||
3394 | lea eax, [edi+draw_data-window_data] |
||
3395 | mov ebx, [draw_limits.left] |
||
3396 | cmp ebx, [eax+RECT.left] |
||
3397 | jae @f |
||
3398 | mov [eax+RECT.left], ebx |
||
3399 | mov dl, 1 |
||
1055 | Galkov | 3400 | @@: |
2434 | Serge | 3401 | mov ebx, [draw_limits.top] |
3402 | cmp ebx, [eax+RECT.top] |
||
3403 | jae @f |
||
3404 | mov [eax+RECT.top], ebx |
||
3405 | mov dl, 1 |
||
1055 | Galkov | 3406 | @@: |
2434 | Serge | 3407 | mov ebx, [draw_limits.right] |
3408 | cmp ebx, [eax+RECT.right] |
||
3409 | jbe @f |
||
3410 | mov [eax+RECT.right], ebx |
||
3411 | mov dl, 1 |
||
1055 | Galkov | 3412 | @@: |
2434 | Serge | 3413 | mov ebx, [draw_limits.bottom] |
3414 | cmp ebx, [eax+RECT.bottom] |
||
3415 | jbe @f |
||
3416 | mov [eax+RECT.bottom], ebx |
||
3417 | mov dl, 1 |
||
1055 | Galkov | 3418 | @@: |
2434 | Serge | 3419 | add byte[REDRAW_BACKGROUND], dl |
3420 | jmp newdw8 |
||
1055 | Galkov | 3421 | .az: |
1 | ha | 3422 | |
2434 | Serge | 3423 | mov eax, edi |
3424 | add eax, draw_data-window_data |
||
1 | ha | 3425 | |
2434 | Serge | 3426 | mov ebx, [draw_limits.left] ; set limits |
3427 | mov [eax + RECT.left], ebx |
||
3428 | mov ebx, [draw_limits.top] |
||
3429 | mov [eax + RECT.top], ebx |
||
3430 | mov ebx, [draw_limits.right] |
||
3431 | mov [eax + RECT.right], ebx |
||
3432 | mov ebx, [draw_limits.bottom] |
||
3433 | mov [eax + RECT.bottom], ebx |
||
1 | ha | 3434 | |
2434 | Serge | 3435 | sub eax, draw_data-window_data |
1 | ha | 3436 | |
2434 | Serge | 3437 | cmp dword [esp], 1 |
3438 | jne nobgrd |
||
3439 | inc byte[REDRAW_BACKGROUND] |
||
1 | ha | 3440 | |
3441 | newdw8: |
||
3442 | nobgrd: |
||
3443 | |||
2434 | Serge | 3444 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
1 | ha | 3445 | |
3446 | ricino: |
||
3447 | |||
3448 | not_this_task: |
||
3449 | |||
2434 | Serge | 3450 | pop ecx |
1 | ha | 3451 | |
2434 | Serge | 3452 | cmp ecx, [TASK_COUNT] |
3453 | jle newdw2 |
||
1 | ha | 3454 | |
2434 | Serge | 3455 | pop eax |
3456 | popad |
||
1 | ha | 3457 | |
2434 | Serge | 3458 | ret |
1 | ha | 3459 | |
3460 | calculatebackground: ; background |
||
3461 | |||
2434 | Serge | 3462 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3463 | mov eax, 0x01010101 |
||
3464 | mov ecx, [_WinMapSize] |
||
3465 | shr ecx, 2 |
||
3466 | rep stosd |
||
1 | ha | 3467 | |
2434 | Serge | 3468 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3469 | mov byte[BACKGROUND_CHANGED], 0 |
||
1 | ha | 3470 | |
1055 | Galkov | 3471 | ret |
1 | ha | 3472 | |
3473 | uglobal |
||
1055 | Galkov | 3474 | imax dd 0x0 |
1 | ha | 3475 | endg |
3476 | |||
3477 | |||
3478 | |||
3479 | delay_ms: ; delay in 1/1000 sec |
||
3480 | |||
3481 | |||
2434 | Serge | 3482 | push eax |
3483 | push ecx |
||
1 | ha | 3484 | |
2434 | Serge | 3485 | mov ecx, esi |
1055 | Galkov | 3486 | ; |
2434 | Serge | 3487 | imul ecx, 33941 |
3488 | shr ecx, 9 |
||
1055 | Galkov | 3489 | ; |
1 | ha | 3490 | |
2434 | Serge | 3491 | in al, 0x61 |
3492 | and al, 0x10 |
||
3493 | mov ah, al |
||
1055 | Galkov | 3494 | cld |
1 | ha | 3495 | |
2434 | Serge | 3496 | cnt1: |
3497 | in al, 0x61 |
||
3498 | and al, 0x10 |
||
3499 | cmp al, ah |
||
3500 | jz cnt1 |
||
1 | ha | 3501 | |
2434 | Serge | 3502 | mov ah, al |
3503 | loop cnt1 |
||
1 | ha | 3504 | |
2434 | Serge | 3505 | pop ecx |
3506 | pop eax |
||
1 | ha | 3507 | |
1055 | Galkov | 3508 | ret |
1 | ha | 3509 | |
2434 | Serge | 3510 | align 4 |
1 | ha | 3511 | set_app_param: |
1055 | Galkov | 3512 | mov edi, [TASK_BASE] |
2434 | Serge | 3513 | mov eax, ebx |
3514 | btr eax, 3 ; move MOUSE_FILTRATION |
||
3515 | mov ebx, [current_slot] ; bit into event_filter |
||
3516 | setc byte [ebx+APPDATA.event_filter] |
||
3517 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
||
3518 | mov [esp+32], eax ; return old mask value |
||
1055 | Galkov | 3519 | ret |
1 | ha | 3520 | |
3521 | |||
3522 | |||
3523 | delay_hs: ; delay in 1/100 secs |
||
684 | diamond | 3524 | ; ebx = delay time |
2434 | Serge | 3525 | push ecx |
3526 | push edx |
||
1 | ha | 3527 | |
2434 | Serge | 3528 | mov edx, [timer_ticks] |
1 | ha | 3529 | |
3530 | newtic: |
||
2434 | Serge | 3531 | mov ecx, [timer_ticks] |
3532 | sub ecx, edx |
||
3533 | cmp ecx, ebx |
||
3534 | jae zerodelay |
||
1 | ha | 3535 | |
2434 | Serge | 3536 | call change_task |
1 | ha | 3537 | |
2434 | Serge | 3538 | jmp newtic |
1 | ha | 3539 | |
3540 | zerodelay: |
||
2434 | Serge | 3541 | pop edx |
3542 | pop ecx |
||
1 | ha | 3543 | |
1055 | Galkov | 3544 | ret |
1 | ha | 3545 | |
2434 | Serge | 3546 | align 16 ;very often call this subrutine |
1 | ha | 3547 | memmove: ; memory move in bytes |
3548 | |||
3549 | ; eax = from |
||
3550 | ; ebx = to |
||
3551 | ; ecx = no of bytes |
||
2434 | Serge | 3552 | test ecx, ecx |
3553 | jle .ret |
||
1 | ha | 3554 | |
2434 | Serge | 3555 | push esi edi ecx |
1 | ha | 3556 | |
2434 | Serge | 3557 | mov edi, ebx |
3558 | mov esi, eax |
||
1 | ha | 3559 | |
2434 | Serge | 3560 | test ecx, not 11b |
3561 | jz @f |
||
1 | ha | 3562 | |
2434 | Serge | 3563 | push ecx |
3564 | shr ecx, 2 |
||
3565 | rep movsd |
||
3566 | pop ecx |
||
3567 | and ecx, 11b |
||
3568 | jz .finish |
||
1 | ha | 3569 | @@: |
2434 | Serge | 3570 | rep movsb |
1 | ha | 3571 | |
3572 | .finish: |
||
2434 | Serge | 3573 | pop ecx edi esi |
1 | ha | 3574 | .ret: |
2434 | Serge | 3575 | ret |
1 | ha | 3576 | |
3577 | |||
75 | diamond | 3578 | ; |
3579 | ;align 4 |
||
1 | ha | 3580 | ; |
75 | diamond | 3581 | ;read_floppy_file: |
1 | ha | 3582 | ; |
75 | diamond | 3583 | ;; as input |
3584 | ;; |
||
3585 | ;; eax pointer to file |
||
3586 | ;; ebx file lenght |
||
3587 | ;; ecx start 512 byte block number |
||
3588 | ;; edx number of blocks to read |
||
3589 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
||
3590 | ;; |
||
3591 | ;; |
||
3592 | ;; on return |
||
3593 | ;; |
||
3594 | ;; eax = 0 command succesful |
||
3595 | ;; 1 no fd base and/or partition defined |
||
3596 | ;; 2 yet unsupported FS |
||
3597 | ;; 3 unknown FS |
||
3598 | ;; 4 partition not defined at hd |
||
3599 | ;; 5 file not found |
||
3600 | ;; ebx = size of file |
||
1 | ha | 3601 | ; |
379 | serge | 3602 | ; mov edi,[TASK_BASE] |
75 | diamond | 3603 | ; add edi,0x10 |
3604 | ; add esi,[edi] |
||
3605 | ; add eax,[edi] |
||
1 | ha | 3606 | ; |
75 | diamond | 3607 | ; pushad |
3608 | ; mov edi,esi |
||
3609 | ; add edi,1024 |
||
3610 | ; mov esi,0x100000+19*512 |
||
3611 | ; sub ecx,1 |
||
3612 | ; shl ecx,9 |
||
3613 | ; add esi,ecx |
||
3614 | ; shl edx,9 |
||
3615 | ; mov ecx,edx |
||
3616 | ; cld |
||
3617 | ; rep movsb |
||
3618 | ; popad |
||
3619 | ; |
||
3620 | ; mov [esp+36],eax |
||
3621 | ; mov [esp+24],ebx |
||
3622 | ; ret |
||
1 | ha | 3623 | |
3624 | |||
3625 | |||
3626 | align 4 |
||
3627 | set_io_access_rights: |
||
2434 | Serge | 3628 | push edi eax |
3629 | mov edi, tss._io_map_0 |
||
465 | serge | 3630 | ; mov ecx,eax |
3631 | ; and ecx,7 ; offset in byte |
||
3632 | ; shr eax,3 ; number of byte |
||
3633 | ; add edi,eax |
||
3634 | ; mov ebx,1 |
||
3635 | ; shl ebx,cl |
||
2434 | Serge | 3636 | test ebp, ebp |
1232 | Lrz | 3637 | ; cmp ebp,0 ; enable access - ebp = 0 |
2434 | Serge | 3638 | jnz .siar1 |
465 | serge | 3639 | ; not ebx |
3640 | ; and [edi],byte bl |
||
2434 | Serge | 3641 | btr [edi], eax |
3642 | pop eax edi |
||
3643 | ret |
||
2106 | serge | 3644 | .siar1: |
2434 | Serge | 3645 | bts [edi], eax |
465 | serge | 3646 | ; or [edi],byte bl ; disable access - ebp = 1 |
2434 | Serge | 3647 | pop eax edi |
3648 | ret |
||
1306 | Lrz | 3649 | ;reserve/free group of ports |
3650 | ; * eax = 46 - number function |
||
3651 | ; * ebx = 0 - reserve, 1 - free |
||
3652 | ; * ecx = number start arrea of ports |
||
3653 | ; * edx = number end arrea of ports (include last number of port) |
||
3654 | ;Return value: |
||
1638 | serge | 3655 | ; * eax = 0 - succesful |
1306 | Lrz | 3656 | ; * eax = 1 - error |
3657 | ; * The system has reserve this ports: |
||
3658 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
||
3659 | ;destroys eax,ebx, ebp |
||
1 | ha | 3660 | r_f_port_area: |
3661 | |||
2434 | Serge | 3662 | test ebx, ebx |
3663 | jnz free_port_area |
||
1 | ha | 3664 | ; je r_port_area |
3665 | ; jmp free_port_area |
||
3666 | |||
3667 | ; r_port_area: |
||
3668 | |||
1306 | Lrz | 3669 | ; pushad |
1 | ha | 3670 | |
2434 | Serge | 3671 | cmp ecx, edx ; beginning > end ? |
3672 | ja rpal1 |
||
3673 | cmp edx, 65536 |
||
3674 | jae rpal1 |
||
3675 | mov eax, [RESERVED_PORTS] |
||
3676 | test eax, eax ; no reserved areas ? |
||
3677 | je rpal2 |
||
3678 | cmp eax, 255 ; max reserved |
||
3679 | jae rpal1 |
||
465 | serge | 3680 | rpal3: |
2434 | Serge | 3681 | mov ebx, eax |
3682 | shl ebx, 4 |
||
3683 | add ebx, RESERVED_PORTS |
||
3684 | cmp ecx, [ebx+8] |
||
3685 | ja rpal4 |
||
3686 | cmp edx, [ebx+4] |
||
3687 | jae rpal1 |
||
1 | ha | 3688 | ; jb rpal4 |
3689 | ; jmp rpal1 |
||
465 | serge | 3690 | rpal4: |
2434 | Serge | 3691 | dec eax |
3692 | jnz rpal3 |
||
3693 | jmp rpal2 |
||
1 | ha | 3694 | rpal1: |
1306 | Lrz | 3695 | ; popad |
3696 | ; mov eax,1 |
||
2434 | Serge | 3697 | xor eax, eax |
3698 | inc eax |
||
3699 | ret |
||
1 | ha | 3700 | rpal2: |
1306 | Lrz | 3701 | ; popad |
1 | ha | 3702 | ; enable port access at port IO map |
2434 | Serge | 3703 | cli |
3704 | pushad ; start enable io map |
||
1 | ha | 3705 | |
2434 | Serge | 3706 | cmp edx, 65536;16384 |
3707 | jae no_unmask_io; jge |
||
3708 | mov eax, ecx |
||
3709 | ; push ebp |
||
3710 | xor ebp, ebp ; enable - eax = port |
||
1306 | Lrz | 3711 | new_port_access: |
3712 | ; pushad |
||
2434 | Serge | 3713 | call set_io_access_rights |
1306 | Lrz | 3714 | ; popad |
2434 | Serge | 3715 | inc eax |
3716 | cmp eax, edx |
||
3717 | jbe new_port_access |
||
3718 | ; pop ebp |
||
1306 | Lrz | 3719 | no_unmask_io: |
2434 | Serge | 3720 | popad ; end enable io map |
3721 | sti |
||
1 | ha | 3722 | |
2434 | Serge | 3723 | mov eax, [RESERVED_PORTS] |
3724 | add eax, 1 |
||
3725 | mov [RESERVED_PORTS], eax |
||
3726 | shl eax, 4 |
||
3727 | add eax, RESERVED_PORTS |
||
3728 | mov ebx, [TASK_BASE] |
||
3729 | mov ebx, [ebx+TASKDATA.pid] |
||
3730 | mov [eax], ebx |
||
3731 | mov [eax+4], ecx |
||
3732 | mov [eax+8], edx |
||
1 | ha | 3733 | |
2434 | Serge | 3734 | xor eax, eax |
3735 | ret |
||
1 | ha | 3736 | |
3737 | free_port_area: |
||
3738 | |||
1306 | Lrz | 3739 | ; pushad |
2434 | Serge | 3740 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
3741 | test eax, eax |
||
3742 | jz frpal2 |
||
3743 | mov ebx, [TASK_BASE] |
||
3744 | mov ebx, [ebx+TASKDATA.pid] |
||
1 | ha | 3745 | frpal3: |
2434 | Serge | 3746 | mov edi, eax |
3747 | shl edi, 4 |
||
3748 | add edi, RESERVED_PORTS |
||
3749 | cmp ebx, [edi] |
||
3750 | jne frpal4 |
||
3751 | cmp ecx, [edi+4] |
||
3752 | jne frpal4 |
||
3753 | cmp edx, [edi+8] |
||
3754 | jne frpal4 |
||
3755 | jmp frpal1 |
||
1 | ha | 3756 | frpal4: |
2434 | Serge | 3757 | dec eax |
3758 | jnz frpal3 |
||
1 | ha | 3759 | frpal2: |
1306 | Lrz | 3760 | ; popad |
2434 | Serge | 3761 | inc eax |
3762 | ret |
||
1 | ha | 3763 | frpal1: |
2434 | Serge | 3764 | push ecx |
3765 | mov ecx, 256 |
||
3766 | sub ecx, eax |
||
3767 | shl ecx, 4 |
||
3768 | mov esi, edi |
||
3769 | add esi, 16 |
||
3770 | cld |
||
3771 | rep movsb |
||
1 | ha | 3772 | |
2434 | Serge | 3773 | dec dword [RESERVED_PORTS] |
1306 | Lrz | 3774 | ;popad |
3775 | ;disable port access at port IO map |
||
1 | ha | 3776 | |
1306 | Lrz | 3777 | ; pushad ; start disable io map |
2434 | Serge | 3778 | pop eax ;start port |
3779 | cmp edx, 65536;16384 |
||
3780 | jge no_mask_io |
||
1 | ha | 3781 | |
1306 | Lrz | 3782 | ; mov eax,ecx |
2434 | Serge | 3783 | xor ebp, ebp |
3784 | inc ebp |
||
1306 | Lrz | 3785 | new_port_access_disable: |
3786 | ; pushad |
||
3787 | ; mov ebp,1 ; disable - eax = port |
||
2434 | Serge | 3788 | call set_io_access_rights |
1306 | Lrz | 3789 | ; popad |
2434 | Serge | 3790 | inc eax |
3791 | cmp eax, edx |
||
3792 | jbe new_port_access_disable |
||
1306 | Lrz | 3793 | no_mask_io: |
3794 | ; popad ; end disable io map |
||
2434 | Serge | 3795 | xor eax, eax |
3796 | ret |
||
3797 | ;----------------------------------------------------------------------------- |
||
2106 | serge | 3798 | align 4 |
1 | ha | 3799 | drawbackground: |
2434 | Serge | 3800 | dbrv20: |
3801 | cmp [BgrDrawMode], dword 1 |
||
3802 | jne bgrstr |
||
3803 | call vesa20_drawbackground_tiled |
||
3804 | call [draw_pointer] |
||
3805 | ret |
||
3806 | ;-------------------------------------- |
||
75 | diamond | 3807 | align 4 |
2434 | Serge | 3808 | bgrstr: |
3809 | call vesa20_drawbackground_stretch |
||
3810 | call [draw_pointer] |
||
3811 | ret |
||
3812 | ;----------------------------------------------------------------------------- |
||
3813 | align 4 |
||
1055 | Galkov | 3814 | syscall_putimage: ; PutImage |
1 | ha | 3815 | sys_putimage: |
2434 | Serge | 3816 | test ecx, 0x80008000 |
3817 | jnz .exit |
||
3818 | test ecx, 0x0000FFFF |
||
3819 | jz .exit |
||
3820 | test ecx, 0xFFFF0000 |
||
3821 | jnz @f |
||
3822 | ;-------------------------------------- |
||
3823 | align 4 |
||
3824 | .exit: |
||
3825 | ret |
||
3826 | ;-------------------------------------- |
||
3827 | align 4 |
||
3828 | @@: |
||
3829 | mov edi, [current_slot] |
||
3830 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
||
3831 | rol edx, 16 |
||
3832 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
||
3833 | rol edx, 16 |
||
3834 | ;-------------------------------------- |
||
3835 | align 4 |
||
3836 | .forced: |
||
1055 | Galkov | 3837 | push ebp esi 0 |
3838 | mov ebp, putimage_get24bpp |
||
3839 | mov esi, putimage_init24bpp |
||
2434 | Serge | 3840 | ;-------------------------------------- |
3841 | align 4 |
||
283 | diamond | 3842 | sys_putimage_bpp: |
2434 | Serge | 3843 | call vesa20_putimage |
1055 | Galkov | 3844 | pop ebp esi ebp |
2434 | Serge | 3845 | ret |
3846 | ; jmp [draw_pointer] |
||
3847 | ;----------------------------------------------------------------------------- |
||
1495 | Lrz | 3848 | align 4 |
283 | diamond | 3849 | sys_putimage_palette: |
3850 | ; ebx = pointer to image |
||
3851 | ; ecx = [xsize]*65536 + [ysize] |
||
3852 | ; edx = [xstart]*65536 + [ystart] |
||
314 | diamond | 3853 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
283 | diamond | 3854 | ; edi = pointer to palette |
314 | diamond | 3855 | ; ebp = row delta |
1055 | Galkov | 3856 | mov eax, [CURRENT_TASK] |
3857 | shl eax, 8 |
||
3858 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
3859 | rol edx, 16 |
||
3860 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
3861 | rol edx, 16 |
||
2434 | Serge | 3862 | ;-------------------------------------- |
3863 | align 4 |
||
283 | diamond | 3864 | .forced: |
1055 | Galkov | 3865 | cmp esi, 1 |
3866 | jnz @f |
||
3867 | push edi |
||
3868 | mov eax, [edi+4] |
||
3869 | sub eax, [edi] |
||
3870 | push eax |
||
3871 | push dword [edi] |
||
3872 | push 0ffffff80h |
||
3873 | mov edi, esp |
||
3874 | call put_mono_image |
||
3875 | add esp, 12 |
||
3876 | pop edi |
||
3877 | ret |
||
2434 | Serge | 3878 | ;-------------------------------------- |
3879 | align 4 |
||
911 | diamond | 3880 | @@: |
1055 | Galkov | 3881 | cmp esi, 2 |
3882 | jnz @f |
||
3883 | push edi |
||
3884 | push 0ffffff80h |
||
3885 | mov edi, esp |
||
3886 | call put_2bit_image |
||
3887 | pop eax |
||
3888 | pop edi |
||
3889 | ret |
||
2434 | Serge | 3890 | ;-------------------------------------- |
3891 | align 4 |
||
911 | diamond | 3892 | @@: |
1055 | Galkov | 3893 | cmp esi, 4 |
3894 | jnz @f |
||
3895 | push edi |
||
3896 | push 0ffffff80h |
||
3897 | mov edi, esp |
||
3898 | call put_4bit_image |
||
3899 | pop eax |
||
3900 | pop edi |
||
3901 | ret |
||
2434 | Serge | 3902 | ;-------------------------------------- |
3903 | align 4 |
||
314 | diamond | 3904 | @@: |
1055 | Galkov | 3905 | push ebp esi ebp |
3906 | cmp esi, 8 |
||
3907 | jnz @f |
||
3908 | mov ebp, putimage_get8bpp |
||
3909 | mov esi, putimage_init8bpp |
||
3910 | jmp sys_putimage_bpp |
||
2434 | Serge | 3911 | ;-------------------------------------- |
3912 | align 4 |
||
918 | diamond | 3913 | @@: |
1055 | Galkov | 3914 | cmp esi, 15 |
3915 | jnz @f |
||
3916 | mov ebp, putimage_get15bpp |
||
3917 | mov esi, putimage_init15bpp |
||
3918 | jmp sys_putimage_bpp |
||
2434 | Serge | 3919 | ;-------------------------------------- |
3920 | align 4 |
||
906 | diamond | 3921 | @@: |
1055 | Galkov | 3922 | cmp esi, 16 |
3923 | jnz @f |
||
3924 | mov ebp, putimage_get16bpp |
||
3925 | mov esi, putimage_init16bpp |
||
3926 | jmp sys_putimage_bpp |
||
2434 | Serge | 3927 | ;-------------------------------------- |
3928 | align 4 |
||
842 | diamond | 3929 | @@: |
1055 | Galkov | 3930 | cmp esi, 24 |
3931 | jnz @f |
||
3932 | mov ebp, putimage_get24bpp |
||
3933 | mov esi, putimage_init24bpp |
||
3934 | jmp sys_putimage_bpp |
||
2434 | Serge | 3935 | ;-------------------------------------- |
3936 | align 4 |
||
314 | diamond | 3937 | @@: |
1055 | Galkov | 3938 | cmp esi, 32 |
3939 | jnz @f |
||
3940 | mov ebp, putimage_get32bpp |
||
3941 | mov esi, putimage_init32bpp |
||
3942 | jmp sys_putimage_bpp |
||
2434 | Serge | 3943 | ;-------------------------------------- |
3944 | align 4 |
||
314 | diamond | 3945 | @@: |
1055 | Galkov | 3946 | pop ebp esi ebp |
3947 | ret |
||
2434 | Serge | 3948 | ;----------------------------------------------------------------------------- |
3949 | align 4 |
||
911 | diamond | 3950 | put_mono_image: |
1055 | Galkov | 3951 | push ebp esi ebp |
3952 | mov ebp, putimage_get1bpp |
||
3953 | mov esi, putimage_init1bpp |
||
3954 | jmp sys_putimage_bpp |
||
2434 | Serge | 3955 | ;----------------------------------------------------------------------------- |
3956 | align 4 |
||
918 | diamond | 3957 | put_2bit_image: |
1055 | Galkov | 3958 | push ebp esi ebp |
3959 | mov ebp, putimage_get2bpp |
||
3960 | mov esi, putimage_init2bpp |
||
3961 | jmp sys_putimage_bpp |
||
2434 | Serge | 3962 | ;----------------------------------------------------------------------------- |
3963 | align 4 |
||
911 | diamond | 3964 | put_4bit_image: |
1055 | Galkov | 3965 | push ebp esi ebp |
3966 | mov ebp, putimage_get4bpp |
||
3967 | mov esi, putimage_init4bpp |
||
3968 | jmp sys_putimage_bpp |
||
2434 | Serge | 3969 | ;----------------------------------------------------------------------------- |
3970 | align 4 |
||
283 | diamond | 3971 | putimage_init24bpp: |
1055 | Galkov | 3972 | lea eax, [eax*3] |
283 | diamond | 3973 | putimage_init8bpp: |
1055 | Galkov | 3974 | ret |
2434 | Serge | 3975 | ;----------------------------------------------------------------------------- |
911 | diamond | 3976 | align 16 |
283 | diamond | 3977 | putimage_get24bpp: |
1055 | Galkov | 3978 | movzx eax, byte [esi+2] |
3979 | shl eax, 16 |
||
3980 | mov ax, [esi] |
||
3981 | add esi, 3 |
||
3982 | ret 4 |
||
2434 | Serge | 3983 | ;----------------------------------------------------------------------------- |
911 | diamond | 3984 | align 16 |
283 | diamond | 3985 | putimage_get8bpp: |
1055 | Galkov | 3986 | movzx eax, byte [esi] |
3987 | push edx |
||
3988 | mov edx, [esp+8] |
||
3989 | mov eax, [edx+eax*4] |
||
3990 | pop edx |
||
3991 | inc esi |
||
3992 | ret 4 |
||
2434 | Serge | 3993 | ;----------------------------------------------------------------------------- |
3994 | align 4 |
||
911 | diamond | 3995 | putimage_init1bpp: |
1055 | Galkov | 3996 | add eax, ecx |
3997 | push ecx |
||
3998 | add eax, 7 |
||
3999 | add ecx, 7 |
||
4000 | shr eax, 3 |
||
4001 | shr ecx, 3 |
||
4002 | sub eax, ecx |
||
4003 | pop ecx |
||
4004 | ret |
||
2434 | Serge | 4005 | ;----------------------------------------------------------------------------- |
911 | diamond | 4006 | align 16 |
4007 | putimage_get1bpp: |
||
1055 | Galkov | 4008 | push edx |
4009 | mov edx, [esp+8] |
||
4010 | mov al, [edx] |
||
4011 | add al, al |
||
4012 | jnz @f |
||
4013 | lodsb |
||
4014 | adc al, al |
||
911 | diamond | 4015 | @@: |
1055 | Galkov | 4016 | mov [edx], al |
4017 | sbb eax, eax |
||
4018 | and eax, [edx+8] |
||
4019 | add eax, [edx+4] |
||
4020 | pop edx |
||
4021 | ret 4 |
||
2434 | Serge | 4022 | ;----------------------------------------------------------------------------- |
4023 | align 4 |
||
918 | diamond | 4024 | putimage_init2bpp: |
1055 | Galkov | 4025 | add eax, ecx |
4026 | push ecx |
||
4027 | add ecx, 3 |
||
4028 | add eax, 3 |
||
4029 | shr ecx, 2 |
||
4030 | shr eax, 2 |
||
4031 | sub eax, ecx |
||
4032 | pop ecx |
||
4033 | ret |
||
2434 | Serge | 4034 | ;----------------------------------------------------------------------------- |
918 | diamond | 4035 | align 16 |
4036 | putimage_get2bpp: |
||
1055 | Galkov | 4037 | push edx |
4038 | mov edx, [esp+8] |
||
4039 | mov al, [edx] |
||
4040 | mov ah, al |
||
4041 | shr al, 6 |
||
4042 | shl ah, 2 |
||
4043 | jnz .nonewbyte |
||
4044 | lodsb |
||
4045 | mov ah, al |
||
4046 | shr al, 6 |
||
4047 | shl ah, 2 |
||
4048 | add ah, 1 |
||
918 | diamond | 4049 | .nonewbyte: |
1055 | Galkov | 4050 | mov [edx], ah |
4051 | mov edx, [edx+4] |
||
4052 | movzx eax, al |
||
4053 | mov eax, [edx+eax*4] |
||
4054 | pop edx |
||
4055 | ret 4 |
||
2434 | Serge | 4056 | ;----------------------------------------------------------------------------- |
4057 | align 4 |
||
911 | diamond | 4058 | putimage_init4bpp: |
1055 | Galkov | 4059 | add eax, ecx |
4060 | push ecx |
||
4061 | add ecx, 1 |
||
4062 | add eax, 1 |
||
4063 | shr ecx, 1 |
||
4064 | shr eax, 1 |
||
4065 | sub eax, ecx |
||
4066 | pop ecx |
||
4067 | ret |
||
2434 | Serge | 4068 | ;----------------------------------------------------------------------------- |
911 | diamond | 4069 | align 16 |
4070 | putimage_get4bpp: |
||
1055 | Galkov | 4071 | push edx |
4072 | mov edx, [esp+8] |
||
4073 | add byte [edx], 80h |
||
4074 | jc @f |
||
4075 | movzx eax, byte [edx+1] |
||
4076 | mov edx, [edx+4] |
||
4077 | and eax, 0x0F |
||
4078 | mov eax, [edx+eax*4] |
||
4079 | pop edx |
||
4080 | ret 4 |
||
911 | diamond | 4081 | @@: |
1055 | Galkov | 4082 | movzx eax, byte [esi] |
4083 | add esi, 1 |
||
4084 | mov [edx+1], al |
||
4085 | shr eax, 4 |
||
4086 | mov edx, [edx+4] |
||
4087 | mov eax, [edx+eax*4] |
||
4088 | pop edx |
||
4089 | ret 4 |
||
2434 | Serge | 4090 | ;----------------------------------------------------------------------------- |
4091 | align 4 |
||
314 | diamond | 4092 | putimage_init32bpp: |
1055 | Galkov | 4093 | shl eax, 2 |
4094 | ret |
||
2434 | Serge | 4095 | ;----------------------------------------------------------------------------- |
911 | diamond | 4096 | align 16 |
314 | diamond | 4097 | putimage_get32bpp: |
1055 | Galkov | 4098 | lodsd |
4099 | ret 4 |
||
2434 | Serge | 4100 | ;----------------------------------------------------------------------------- |
4101 | align 4 |
||
906 | diamond | 4102 | putimage_init15bpp: |
911 | diamond | 4103 | putimage_init16bpp: |
1055 | Galkov | 4104 | add eax, eax |
4105 | ret |
||
2434 | Serge | 4106 | ;----------------------------------------------------------------------------- |
911 | diamond | 4107 | align 16 |
906 | diamond | 4108 | putimage_get15bpp: |
842 | diamond | 4109 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
1055 | Galkov | 4110 | push ecx edx |
4111 | movzx eax, word [esi] |
||
4112 | add esi, 2 |
||
4113 | mov ecx, eax |
||
4114 | mov edx, eax |
||
4115 | and eax, 0x1F |
||
4116 | and ecx, 0x1F shl 5 |
||
4117 | and edx, 0x1F shl 10 |
||
4118 | shl eax, 3 |
||
4119 | shl ecx, 6 |
||
4120 | shl edx, 9 |
||
4121 | or eax, ecx |
||
4122 | or eax, edx |
||
4123 | pop edx ecx |
||
4124 | ret 4 |
||
2434 | Serge | 4125 | ;----------------------------------------------------------------------------- |
911 | diamond | 4126 | align 16 |
906 | diamond | 4127 | putimage_get16bpp: |
4128 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
||
1055 | Galkov | 4129 | push ecx edx |
4130 | movzx eax, word [esi] |
||
4131 | add esi, 2 |
||
4132 | mov ecx, eax |
||
4133 | mov edx, eax |
||
4134 | and eax, 0x1F |
||
4135 | and ecx, 0x3F shl 5 |
||
4136 | and edx, 0x1F shl 11 |
||
4137 | shl eax, 3 |
||
4138 | shl ecx, 5 |
||
4139 | shl edx, 8 |
||
4140 | or eax, ecx |
||
4141 | or eax, edx |
||
4142 | pop edx ecx |
||
4143 | ret 4 |
||
2434 | Serge | 4144 | ;----------------------------------------------------------------------------- |
4145 | ;align 4 |
||
1 | ha | 4146 | ; eax x beginning |
4147 | ; ebx y beginning |
||
4148 | ; ecx x end |
||
1055 | Galkov | 4149 | ; edx y end |
1 | ha | 4150 | ; edi color |
2434 | Serge | 4151 | ;__sys_drawbar: |
4152 | ; mov esi, [current_slot] |
||
4153 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
||
4154 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
||
4155 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
||
4156 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
||
4157 | ;-------------------------------------- |
||
4158 | ;align 4 |
||
4159 | ;.forced: |
||
4160 | ; call vesa20_drawbar |
||
4161 | ; call [draw_pointer] |
||
4162 | ; ret |
||
4163 | ;----------------------------------------------------------------------------- |
||
4164 | align 4 |
||
1 | ha | 4165 | kb_read: |
4166 | |||
1055 | Galkov | 4167 | push ecx edx |
1 | ha | 4168 | |
2434 | Serge | 4169 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
1 | ha | 4170 | kr_loop: |
2434 | Serge | 4171 | in al, 0x64 |
4172 | test al, 1 |
||
1055 | Galkov | 4173 | jnz kr_ready |
4174 | loop kr_loop |
||
2434 | Serge | 4175 | mov ah, 1 |
1055 | Galkov | 4176 | jmp kr_exit |
1 | ha | 4177 | kr_ready: |
1055 | Galkov | 4178 | push ecx |
2434 | Serge | 4179 | mov ecx, 32 |
1 | ha | 4180 | kr_delay: |
1055 | Galkov | 4181 | loop kr_delay |
4182 | pop ecx |
||
2434 | Serge | 4183 | in al, 0x60 |
4184 | xor ah, ah |
||
1 | ha | 4185 | kr_exit: |
4186 | |||
1055 | Galkov | 4187 | pop edx ecx |
1 | ha | 4188 | |
1055 | Galkov | 4189 | ret |
2434 | Serge | 4190 | ;----------------------------------------------------------------------------- |
4191 | align 4 |
||
1 | ha | 4192 | kb_write: |
4193 | |||
1055 | Galkov | 4194 | push ecx edx |
1 | ha | 4195 | |
2434 | Serge | 4196 | mov dl, al |
265 | diamond | 4197 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4198 | ; kw_loop1: |
||
4199 | ; in al,0x64 |
||
4200 | ; test al,0x20 |
||
4201 | ; jz kw_ok1 |
||
4202 | ; loop kw_loop1 |
||
4203 | ; mov ah,1 |
||
4204 | ; jmp kw_exit |
||
4205 | ; kw_ok1: |
||
2434 | Serge | 4206 | in al, 0x60 |
4207 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4208 | kw_loop: |
2434 | Serge | 4209 | in al, 0x64 |
4210 | test al, 2 |
||
1055 | Galkov | 4211 | jz kw_ok |
4212 | loop kw_loop |
||
2434 | Serge | 4213 | mov ah, 1 |
1055 | Galkov | 4214 | jmp kw_exit |
1 | ha | 4215 | kw_ok: |
2434 | Serge | 4216 | mov al, dl |
4217 | out 0x60, al |
||
4218 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4219 | kw_loop3: |
2434 | Serge | 4220 | in al, 0x64 |
4221 | test al, 2 |
||
1055 | Galkov | 4222 | jz kw_ok3 |
4223 | loop kw_loop3 |
||
2434 | Serge | 4224 | mov ah, 1 |
1055 | Galkov | 4225 | jmp kw_exit |
1 | ha | 4226 | kw_ok3: |
2434 | Serge | 4227 | mov ah, 8 |
1 | ha | 4228 | kw_loop4: |
2434 | Serge | 4229 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
1 | ha | 4230 | kw_loop5: |
2434 | Serge | 4231 | in al, 0x64 |
4232 | test al, 1 |
||
1055 | Galkov | 4233 | jnz kw_ok4 |
4234 | loop kw_loop5 |
||
4235 | dec ah |
||
4236 | jnz kw_loop4 |
||
1 | ha | 4237 | kw_ok4: |
2434 | Serge | 4238 | xor ah, ah |
1 | ha | 4239 | kw_exit: |
4240 | |||
1055 | Galkov | 4241 | pop edx ecx |
1 | ha | 4242 | |
1055 | Galkov | 4243 | ret |
2434 | Serge | 4244 | ;----------------------------------------------------------------------------- |
4245 | align 4 |
||
1 | ha | 4246 | kb_cmd: |
4247 | |||
2434 | Serge | 4248 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
1 | ha | 4249 | c_wait: |
2434 | Serge | 4250 | in al, 0x64 |
4251 | test al, 2 |
||
1055 | Galkov | 4252 | jz c_send |
4253 | loop c_wait |
||
4254 | jmp c_error |
||
1 | ha | 4255 | c_send: |
2434 | Serge | 4256 | mov al, bl |
4257 | out 0x64, al |
||
4258 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
1 | ha | 4259 | c_accept: |
2434 | Serge | 4260 | in al, 0x64 |
4261 | test al, 2 |
||
1055 | Galkov | 4262 | jz c_ok |
4263 | loop c_accept |
||
1 | ha | 4264 | c_error: |
2434 | Serge | 4265 | mov ah, 1 |
1055 | Galkov | 4266 | jmp c_exit |
1 | ha | 4267 | c_ok: |
2434 | Serge | 4268 | xor ah, ah |
1 | ha | 4269 | c_exit: |
1055 | Galkov | 4270 | ret |
1 | ha | 4271 | |
4272 | |||
4273 | setmouse: ; set mousepicture -pointer |
||
1055 | Galkov | 4274 | ; ps2 mouse enable |
1 | ha | 4275 | |
2434 | Serge | 4276 | ; mov [MOUSE_PICTURE], dword mousepointer |
1 | ha | 4277 | |
2434 | Serge | 4278 | cli |
1 | ha | 4279 | |
2434 | Serge | 4280 | ret |
1 | ha | 4281 | |
1055 | Galkov | 4282 | if used _rdtsc |
1 | ha | 4283 | _rdtsc: |
2434 | Serge | 4284 | bt [cpu_caps], CAPS_TSC |
4285 | jnc ret_rdtsc |
||
4286 | rdtsc |
||
4287 | ret |
||
1 | ha | 4288 | ret_rdtsc: |
2434 | Serge | 4289 | mov edx, 0xffffffff |
4290 | mov eax, 0xffffffff |
||
4291 | ret |
||
1055 | Galkov | 4292 | end if |
1 | ha | 4293 | |
4294 | sys_msg_board_str: |
||
4295 | |||
2434 | Serge | 4296 | pushad |
1 | ha | 4297 | @@: |
2434 | Serge | 4298 | cmp [esi], byte 0 |
4299 | je @f |
||
4300 | mov eax, 1 |
||
4301 | movzx ebx, byte [esi] |
||
4302 | call sys_msg_board |
||
4303 | inc esi |
||
4304 | jmp @b |
||
1 | ha | 4305 | @@: |
2434 | Serge | 4306 | popad |
4307 | ret |
||
1 | ha | 4308 | |
709 | diamond | 4309 | sys_msg_board_byte: |
4310 | ; in: al = byte to display |
||
4311 | ; out: nothing |
||
4312 | ; destroys: nothing |
||
1055 | Galkov | 4313 | pushad |
4314 | mov ecx, 2 |
||
4315 | shl eax, 24 |
||
4316 | jmp @f |
||
709 | diamond | 4317 | |
4318 | sys_msg_board_word: |
||
4319 | ; in: ax = word to display |
||
4320 | ; out: nothing |
||
4321 | ; destroys: nothing |
||
1055 | Galkov | 4322 | pushad |
4323 | mov ecx, 4 |
||
4324 | shl eax, 16 |
||
4325 | jmp @f |
||
709 | diamond | 4326 | |
4327 | sys_msg_board_dword: |
||
4328 | ; in: eax = dword to display |
||
4329 | ; out: nothing |
||
4330 | ; destroys: nothing |
||
1055 | Galkov | 4331 | pushad |
4332 | mov ecx, 8 |
||
709 | diamond | 4333 | @@: |
1055 | Galkov | 4334 | push ecx |
4335 | rol eax, 4 |
||
4336 | push eax |
||
4337 | and al, 0xF |
||
4338 | cmp al, 10 |
||
4339 | sbb al, 69h |
||
4340 | das |
||
4341 | mov bl, al |
||
4342 | xor eax, eax |
||
4343 | inc eax |
||
4344 | call sys_msg_board |
||
4345 | pop eax |
||
4346 | pop ecx |
||
4347 | loop @b |
||
4348 | popad |
||
4349 | ret |
||
709 | diamond | 4350 | |
1 | ha | 4351 | uglobal |
2434 | Serge | 4352 | msg_board_data: |
4353 | times 4096 db 0 |
||
1 | ha | 4354 | msg_board_count dd 0x0 |
4355 | endg |
||
4356 | |||
4357 | sys_msg_board: |
||
4358 | |||
4359 | ; eax=1 : write : bl byte to write |
||
4360 | ; eax=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
||
4361 | |||
1055 | Galkov | 4362 | mov ecx, [msg_board_count] |
4363 | cmp eax, 1 |
||
4364 | jne .smbl1 |
||
1 | ha | 4365 | |
1043 | hidnplayr | 4366 | if defined debug_com_base |
1 | ha | 4367 | |
1055 | Galkov | 4368 | push dx ax |
1043 | hidnplayr | 4369 | |
1055 | Galkov | 4370 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4371 | mov dx, debug_com_base+5 |
||
4372 | in al, dx |
||
4373 | test al, 1 shl 5 |
||
4374 | jz @r |
||
1043 | hidnplayr | 4375 | |
1055 | Galkov | 4376 | mov dx, debug_com_base ; Output the byte |
4377 | mov al, bl |
||
4378 | out dx, al |
||
1043 | hidnplayr | 4379 | |
1055 | Galkov | 4380 | pop ax dx |
1043 | hidnplayr | 4381 | |
4382 | end if |
||
4383 | |||
2434 | Serge | 4384 | mov [msg_board_data+ecx], bl |
1055 | Galkov | 4385 | inc ecx |
4386 | and ecx, 4095 |
||
4387 | mov [msg_board_count], ecx |
||
4388 | mov [check_idle_semaphore], 5 |
||
4389 | ret |
||
671 | Ghost | 4390 | .smbl1: |
1055 | Galkov | 4391 | cmp eax, 2 |
4392 | jne .smbl2 |
||
4393 | test ecx, ecx |
||
4394 | jz .smbl21 |
||
4395 | mov eax, msg_board_data+1 |
||
4396 | mov ebx, msg_board_data |
||
4397 | movzx edx, byte [ebx] |
||
4398 | call memmove |
||
4399 | dec [msg_board_count] |
||
4400 | mov [esp + 36], edx ;eax |
||
4401 | mov [esp + 24], dword 1 |
||
4402 | ret |
||
671 | Ghost | 4403 | .smbl21: |
1055 | Galkov | 4404 | mov [esp+36], ecx |
4405 | mov [esp+24], ecx |
||
671 | Ghost | 4406 | .smbl2: |
1055 | Galkov | 4407 | ret |
1 | ha | 4408 | |
1494 | Lrz | 4409 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4410 | ;; 66 sys function. ;; |
||
4411 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
||
4412 | ;; out eax ;; |
||
4413 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4414 | iglobal |
||
4415 | align 4 |
||
4416 | f66call: |
||
4417 | dd sys_process_def.1 ; 1 = set keyboard mode |
||
4418 | dd sys_process_def.2 ; 2 = get keyboard mode |
||
4419 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
||
4420 | dd sys_process_def.4 |
||
4421 | dd sys_process_def.5 |
||
4422 | endg |
||
1 | ha | 4423 | |
4424 | |||
1494 | Lrz | 4425 | |
4426 | |||
1 | ha | 4427 | sys_process_def: |
2434 | Serge | 4428 | dec ebx |
4429 | cmp ebx, 5 |
||
4430 | jae .not_support ;if >=6 then or eax,-1 |
||
1494 | Lrz | 4431 | |
1055 | Galkov | 4432 | mov edi, [CURRENT_TASK] |
2434 | Serge | 4433 | jmp dword [f66call+ebx*4] |
1 | ha | 4434 | |
1494 | Lrz | 4435 | .not_support: |
2434 | Serge | 4436 | or eax, -1 |
4437 | ret |
||
1 | ha | 4438 | |
1494 | Lrz | 4439 | .1: |
2434 | Serge | 4440 | shl edi, 8 |
4441 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
||
1 | ha | 4442 | |
2434 | Serge | 4443 | ret |
1 | ha | 4444 | |
2434 | Serge | 4445 | .2: ; 2 = get keyboard mode |
4446 | shl edi, 8 |
||
4447 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
||
4448 | mov [esp+32], eax |
||
4449 | ret |
||
1 | ha | 4450 | ; xor eax,eax |
4451 | ; movzx eax,byte [shift] |
||
4452 | ; movzx ebx,byte [ctrl] |
||
4453 | ; shl ebx,2 |
||
4454 | ; add eax,ebx |
||
4455 | ; movzx ebx,byte [alt] |
||
4456 | ; shl ebx,3 |
||
4457 | ; add eax,ebx |
||
2434 | Serge | 4458 | .3: ;3 = get keyboard ctrl, alt, shift |
1 | ha | 4459 | ;// mike.dld [ |
2434 | Serge | 4460 | mov eax, [kb_state] |
1 | ha | 4461 | ;// mike.dld ] |
2434 | Serge | 4462 | mov [esp+32], eax |
4463 | ret |
||
1 | ha | 4464 | |
1494 | Lrz | 4465 | .4: |
1055 | Galkov | 4466 | mov eax, hotkey_list |
92 | diamond | 4467 | @@: |
1055 | Galkov | 4468 | cmp dword [eax+8], 0 |
4469 | jz .found_free |
||
4470 | add eax, 16 |
||
4471 | cmp eax, hotkey_list+16*256 |
||
4472 | jb @b |
||
1494 | Lrz | 4473 | mov dword [esp+32], 1 |
1055 | Galkov | 4474 | ret |
92 | diamond | 4475 | .found_free: |
1055 | Galkov | 4476 | mov [eax+8], edi |
1494 | Lrz | 4477 | mov [eax+4], edx |
4478 | movzx ecx, cl |
||
4479 | lea ecx, [hotkey_scancodes+ecx*4] |
||
4480 | mov edx, [ecx] |
||
4481 | mov [eax], edx |
||
4482 | mov [ecx], eax |
||
4483 | mov [eax+12], ecx |
||
1055 | Galkov | 4484 | jecxz @f |
1494 | Lrz | 4485 | mov [edx+12], eax |
92 | diamond | 4486 | @@: |
1494 | Lrz | 4487 | and dword [esp+32], 0 |
1055 | Galkov | 4488 | ret |
92 | diamond | 4489 | |
1494 | Lrz | 4490 | .5: |
4491 | movzx ebx, cl |
||
1055 | Galkov | 4492 | lea ebx, [hotkey_scancodes+ebx*4] |
4493 | mov eax, [ebx] |
||
92 | diamond | 4494 | .scan: |
1055 | Galkov | 4495 | test eax, eax |
4496 | jz .notfound |
||
4497 | cmp [eax+8], edi |
||
4498 | jnz .next |
||
1494 | Lrz | 4499 | cmp [eax+4], edx |
1055 | Galkov | 4500 | jz .found |
92 | diamond | 4501 | .next: |
1055 | Galkov | 4502 | mov eax, [eax] |
4503 | jmp .scan |
||
92 | diamond | 4504 | .notfound: |
1494 | Lrz | 4505 | mov dword [esp+32], 1 |
1055 | Galkov | 4506 | ret |
92 | diamond | 4507 | .found: |
1055 | Galkov | 4508 | mov ecx, [eax] |
4509 | jecxz @f |
||
4510 | mov edx, [eax+12] |
||
4511 | mov [ecx+12], edx |
||
92 | diamond | 4512 | @@: |
1055 | Galkov | 4513 | mov ecx, [eax+12] |
4514 | mov edx, [eax] |
||
4515 | mov [ecx], edx |
||
4516 | xor edx, edx |
||
4517 | mov [eax+4], edx |
||
4518 | mov [eax+8], edx |
||
4519 | mov [eax+12], edx |
||
4520 | mov [eax], edx |
||
1494 | Lrz | 4521 | mov [esp+32], edx |
1055 | Galkov | 4522 | ret |
92 | diamond | 4523 | |
1497 | Lrz | 4524 | |
4525 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4526 | ;; 61 sys function. ;; |
||
4527 | ;; in eax=61,ebx in [1..3] ;; |
||
4528 | ;; out eax ;; |
||
4529 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4530 | iglobal |
||
1 | ha | 4531 | align 4 |
1497 | Lrz | 4532 | f61call: |
4533 | dd sys_gs.1 ; resolution |
||
4534 | dd sys_gs.2 ; bits per pixel |
||
4535 | dd sys_gs.3 ; bytes per scanline |
||
4536 | endg |
||
1 | ha | 4537 | |
1497 | Lrz | 4538 | |
4539 | align 4 |
||
4540 | |||
1055 | Galkov | 4541 | sys_gs: ; direct screen access |
2434 | Serge | 4542 | dec ebx |
4543 | cmp ebx, 2 |
||
4544 | ja .not_support |
||
4545 | jmp dword [f61call+ebx*4] |
||
1497 | Lrz | 4546 | .not_support: |
2434 | Serge | 4547 | or [esp+32], dword -1 |
1497 | Lrz | 4548 | ret |
1 | ha | 4549 | |
1497 | Lrz | 4550 | |
4551 | .1: ; resolution |
||
2434 | Serge | 4552 | mov eax, [Screen_Max_X] |
4553 | shl eax, 16 |
||
4554 | mov ax, [Screen_Max_Y] |
||
4555 | add eax, 0x00010001 |
||
4556 | mov [esp+32], eax |
||
4557 | ret |
||
4558 | .2: ; bits per pixel |
||
4559 | movzx eax, byte [ScreenBPP] |
||
4560 | mov [esp+32], eax |
||
4561 | ret |
||
1497 | Lrz | 4562 | .3: ; bytes per scanline |
2434 | Serge | 4563 | mov eax, [BytesPerScanLine] |
4564 | mov [esp+32], eax |
||
4565 | ret |
||
1 | ha | 4566 | |
4567 | align 4 ; system functions |
||
4568 | |||
1055 | Galkov | 4569 | syscall_setpixel: ; SetPixel |
1 | ha | 4570 | |
1055 | Galkov | 4571 | mov eax, ebx |
4572 | mov ebx, ecx |
||
4573 | mov ecx, edx |
||
4574 | mov edx, [TASK_BASE] |
||
4575 | add eax, [edx-twdw+WDATA.box.left] |
||
4576 | add ebx, [edx-twdw+WDATA.box.top] |
||
4577 | mov edi, [current_slot] |
||
4578 | add eax, [edi+APPDATA.wnd_clientbox.left] |
||
4579 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
||
4580 | xor edi, edi ; no force |
||
2434 | Serge | 4581 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
1055 | Galkov | 4582 | jmp [putpixel] |
1 | ha | 4583 | |
4584 | align 4 |
||
4585 | |||
1055 | Galkov | 4586 | syscall_writetext: ; WriteText |
1 | ha | 4587 | |
2434 | Serge | 4588 | mov eax, [TASK_BASE] |
4589 | mov ebp, [eax-twdw+WDATA.box.left] |
||
4590 | push esi |
||
4591 | mov esi, [current_slot] |
||
4592 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
||
4593 | shl ebp, 16 |
||
4594 | add ebp, [eax-twdw+WDATA.box.top] |
||
4595 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
||
4596 | pop esi |
||
4597 | add ebx, ebp |
||
4598 | mov eax, edi |
||
4599 | xor edi, edi |
||
4600 | jmp dtext |
||
1 | ha | 4601 | |
4602 | align 4 |
||
4603 | |||
1055 | Galkov | 4604 | syscall_openramdiskfile: ; OpenRamdiskFile |
1 | ha | 4605 | |
1055 | Galkov | 4606 | mov eax, ebx |
4607 | mov ebx, ecx |
||
4608 | mov ecx, edx |
||
4609 | mov edx, esi |
||
4610 | mov esi, 12 |
||
4611 | call fileread |
||
4612 | mov [esp+32], eax |
||
4613 | ret |
||
1 | ha | 4614 | |
4615 | align 4 |
||
4616 | |||
1055 | Galkov | 4617 | syscall_drawrect: ; DrawRect |
1 | ha | 4618 | |
1055 | Galkov | 4619 | mov edi, edx ; color + gradient |
4620 | and edi, 0x80FFFFFF |
||
4621 | test bx, bx ; x.size |
||
4622 | je .drectr |
||
4623 | test cx, cx ; y.size |
||
4624 | je .drectr |
||
1 | ha | 4625 | |
1055 | Galkov | 4626 | mov eax, ebx ; bad idea |
4627 | mov ebx, ecx |
||
1 | ha | 4628 | |
1055 | Galkov | 4629 | movzx ecx, ax ; ecx - x.size |
4630 | shr eax, 16 ; eax - x.coord |
||
4631 | movzx edx, bx ; edx - y.size |
||
4632 | shr ebx, 16 ; ebx - y.coord |
||
4633 | mov esi, [current_slot] |
||
1 | ha | 4634 | |
1055 | Galkov | 4635 | add eax, [esi + APPDATA.wnd_clientbox.left] |
4636 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
||
4637 | add ecx, eax |
||
4638 | add edx, ebx |
||
4639 | jmp [drawbar] |
||
671 | Ghost | 4640 | .drectr: |
1055 | Galkov | 4641 | ret |
1 | ha | 4642 | |
4643 | align 4 |
||
1055 | Galkov | 4644 | syscall_getscreensize: ; GetScreenSize |
4645 | mov ax, [Screen_Max_X] |
||
4646 | shl eax, 16 |
||
4647 | mov ax, [Screen_Max_Y] |
||
4648 | mov [esp + 32], eax |
||
4649 | ret |
||
1 | ha | 4650 | |
671 | Ghost | 4651 | align 4 |
4652 | |||
1055 | Galkov | 4653 | syscall_cdaudio: ; CD |
1 | ha | 4654 | |
1290 | Lrz | 4655 | cmp ebx, 4 |
1055 | Galkov | 4656 | jb .audio |
4657 | jz .eject |
||
1290 | Lrz | 4658 | cmp ebx, 5 |
1055 | Galkov | 4659 | jnz .ret |
588 | diamond | 4660 | .load: |
1055 | Galkov | 4661 | call .reserve |
4662 | call LoadMedium |
||
1290 | Lrz | 4663 | ;call .free |
2434 | Serge | 4664 | jmp .free |
1290 | Lrz | 4665 | ; ret |
588 | diamond | 4666 | .eject: |
1055 | Galkov | 4667 | call .reserve |
4668 | call clear_CD_cache |
||
4669 | call allow_medium_removal |
||
4670 | call EjectMedium |
||
1290 | Lrz | 4671 | ; call .free |
2434 | Serge | 4672 | jmp .free |
1290 | Lrz | 4673 | ; ret |
588 | diamond | 4674 | .audio: |
2434 | Serge | 4675 | call sys_cd_audio |
4676 | mov [esp+36-4], eax |
||
588 | diamond | 4677 | .ret: |
2434 | Serge | 4678 | ret |
1 | ha | 4679 | |
588 | diamond | 4680 | .reserve: |
1055 | Galkov | 4681 | call reserve_cd |
1290 | Lrz | 4682 | mov eax, ecx |
1055 | Galkov | 4683 | shr eax, 1 |
4684 | and eax, 1 |
||
4685 | inc eax |
||
4686 | mov [ChannelNumber], ax |
||
1290 | Lrz | 4687 | mov eax, ecx |
1055 | Galkov | 4688 | and eax, 1 |
4689 | mov [DiskNumber], al |
||
4690 | call reserve_cd_channel |
||
4691 | and ebx, 3 |
||
4692 | inc ebx |
||
4693 | mov [cdpos], ebx |
||
4694 | add ebx, ebx |
||
4695 | mov cl, 8 |
||
4696 | sub cl, bl |
||
4697 | mov al, [DRIVE_DATA+1] |
||
4698 | shr al, cl |
||
4699 | test al, 2 |
||
1290 | Lrz | 4700 | jz .free;.err |
1055 | Galkov | 4701 | ret |
588 | diamond | 4702 | .free: |
1055 | Galkov | 4703 | call free_cd_channel |
4704 | and [cd_status], 0 |
||
4705 | ret |
||
590 | diamond | 4706 | .err: |
1055 | Galkov | 4707 | call .free |
1290 | Lrz | 4708 | ; pop eax |
1055 | Galkov | 4709 | ret |
588 | diamond | 4710 | |
1 | ha | 4711 | align 4 |
4712 | |||
1055 | Galkov | 4713 | syscall_getpixel: ; GetPixel |
2434 | Serge | 4714 | mov ecx, [Screen_Max_X] |
4715 | inc ecx |
||
4716 | xor edx, edx |
||
4717 | mov eax, ebx |
||
4718 | div ecx |
||
4719 | mov ebx, edx |
||
4720 | xchg eax, ebx |
||
4721 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
||
4722 | call dword [GETPIXEL]; eax - x, ebx - y |
||
4723 | mov [esp + 32], ecx |
||
4724 | ret |
||
1 | ha | 4725 | |
921 | mario79 | 4726 | align 4 |
1 | ha | 4727 | |
921 | mario79 | 4728 | syscall_getarea: |
4729 | ;eax = 36 |
||
1055 | Galkov | 4730 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
4731 | ;ecx = [size x]*65536 + [size y] |
||
4732 | ;edx = [start x]*65536 + [start y] |
||
2434 | Serge | 4733 | pushad |
4734 | mov edi, ebx |
||
4735 | mov eax, edx |
||
4736 | shr eax, 16 |
||
4737 | mov ebx, edx |
||
4738 | and ebx, 0xffff |
||
4739 | dec eax |
||
4740 | dec ebx |
||
921 | mario79 | 4741 | ; eax - x, ebx - y |
2434 | Serge | 4742 | mov edx, ecx |
1638 | serge | 4743 | |
2434 | Serge | 4744 | shr ecx, 16 |
4745 | and edx, 0xffff |
||
4746 | mov esi, ecx |
||
921 | mario79 | 4747 | ; ecx - size x, edx - size y |
1638 | serge | 4748 | |
2434 | Serge | 4749 | mov ebp, edx |
4750 | dec ebp |
||
4751 | lea ebp, [ebp*3] |
||
1638 | serge | 4752 | |
2434 | Serge | 4753 | imul ebp, esi |
1638 | serge | 4754 | |
2434 | Serge | 4755 | mov esi, ecx |
4756 | dec esi |
||
4757 | lea esi, [esi*3] |
||
1638 | serge | 4758 | |
2434 | Serge | 4759 | add ebp, esi |
4760 | add ebp, edi |
||
927 | mario79 | 4761 | |
2434 | Serge | 4762 | add ebx, edx |
1638 | serge | 4763 | |
921 | mario79 | 4764 | .start_y: |
2434 | Serge | 4765 | push ecx edx |
921 | mario79 | 4766 | .start_x: |
2434 | Serge | 4767 | push eax ebx ecx |
4768 | add eax, ecx |
||
927 | mario79 | 4769 | |
2434 | Serge | 4770 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
4771 | call dword [GETPIXEL]; eax - x, ebx - y |
||
1638 | serge | 4772 | |
2434 | Serge | 4773 | mov [ebp], cx |
4774 | shr ecx, 16 |
||
4775 | mov [ebp+2], cl |
||
921 | mario79 | 4776 | |
2434 | Serge | 4777 | pop ecx ebx eax |
4778 | sub ebp, 3 |
||
4779 | dec ecx |
||
4780 | jnz .start_x |
||
4781 | pop edx ecx |
||
4782 | dec ebx |
||
4783 | dec edx |
||
4784 | jnz .start_y |
||
4785 | popad |
||
4786 | ret |
||
921 | mario79 | 4787 | |
1 | ha | 4788 | align 4 |
4789 | |||
1055 | Galkov | 4790 | syscall_drawline: ; DrawLine |
1 | ha | 4791 | |
1055 | Galkov | 4792 | mov edi, [TASK_BASE] |
4793 | movzx eax, word[edi-twdw+WDATA.box.left] |
||
4794 | mov ebp, eax |
||
4795 | mov esi, [current_slot] |
||
4796 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
||
4797 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
||
2434 | Serge | 4798 | add ebp, ebx |
1055 | Galkov | 4799 | shl eax, 16 |
4800 | movzx ebx, word[edi-twdw+WDATA.box.top] |
||
4801 | add eax, ebp |
||
4802 | mov ebp, ebx |
||
4803 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
||
4804 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
||
4805 | add ebp, ecx |
||
4806 | shl ebx, 16 |
||
4807 | xor edi, edi |
||
4808 | add ebx, ebp |
||
4809 | mov ecx, edx |
||
4810 | jmp [draw_line] |
||
1 | ha | 4811 | |
4812 | |||
742 | Rus | 4813 | |
1 | ha | 4814 | align 4 |
1055 | Galkov | 4815 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
1 | ha | 4816 | |
2434 | Serge | 4817 | call r_f_port_area |
4818 | mov [esp+32], eax |
||
4819 | ret |
||
1 | ha | 4820 | |
4821 | align 4 |
||
1055 | Galkov | 4822 | syscall_threads: ; CreateThreads |
1369 | Lrz | 4823 | ; eax=1 create thread |
4824 | ; |
||
4825 | ; ebx=thread start |
||
4826 | ; ecx=thread stack value |
||
4827 | ; |
||
4828 | ; on return : eax = pid |
||
1 | ha | 4829 | |
2434 | Serge | 4830 | call new_sys_threads |
1369 | Lrz | 4831 | |
2434 | Serge | 4832 | mov [esp+32], eax |
4833 | ret |
||
1 | ha | 4834 | |
4835 | align 4 |
||
4836 | |||
4837 | stack_driver_stat: |
||
4838 | |||
2434 | Serge | 4839 | call app_stack_handler ; Stack status |
1 | ha | 4840 | |
4841 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
||
4842 | ; call change_task ; between sent packet |
||
4843 | |||
2434 | Serge | 4844 | mov [esp+32], eax |
4845 | ret |
||
1 | ha | 4846 | |
4847 | align 4 |
||
4848 | |||
1055 | Galkov | 4849 | socket: ; Socket interface |
2434 | Serge | 4850 | call app_socket_handler |
1 | ha | 4851 | |
4852 | ; mov [check_idle_semaphore],5 ; enable these for zero delay |
||
4853 | ; call change_task ; between sent packet |
||
4854 | |||
2434 | Serge | 4855 | mov [esp+36], eax |
4856 | mov [esp+24], ebx |
||
4857 | ret |
||
1 | ha | 4858 | |
4859 | align 4 |
||
4860 | |||
1055 | Galkov | 4861 | read_from_hd: ; Read from hd - fn not in use |
1 | ha | 4862 | |
2434 | Serge | 4863 | mov edi, [TASK_BASE] |
4864 | add edi, TASKDATA.mem_start |
||
4865 | add eax, [edi] |
||
4866 | add ecx, [edi] |
||
4867 | add edx, [edi] |
||
4868 | call file_read |
||
1 | ha | 4869 | |
2434 | Serge | 4870 | mov [esp+36], eax |
4871 | mov [esp+24], ebx |
||
1 | ha | 4872 | |
2434 | Serge | 4873 | ret |
1 | ha | 4874 | |
375 | Ghost | 4875 | paleholder: |
1055 | Galkov | 4876 | ret |
2439 | Serge | 4877 | ;------------------------------------------------------------------------------ |
757 | serge | 4878 | align 4 |
2439 | Serge | 4879 | calculate_fast_getting_offset_for_WinMapAddress: |
4880 | ; calculate data area for fast getting offset to _WinMapAddress |
||
4881 | mov eax, [_display.width] |
||
4882 | mov ecx, [_display.height] |
||
4883 | inc ecx |
||
4884 | mov edi, d_width_calc_area |
||
4885 | cld |
||
4886 | @@: |
||
4887 | stosd |
||
4888 | add eax, [_display.width] |
||
4889 | dec ecx |
||
4890 | jnz @r |
||
4891 | ret |
||
4892 | ;------------------------------------------------------------------------------ |
||
4893 | align 4 |
||
757 | serge | 4894 | set_screen: |
2434 | Serge | 4895 | cmp eax, [Screen_Max_X] |
4896 | jne .set |
||
709 | diamond | 4897 | |
2434 | Serge | 4898 | cmp edx, [Screen_Max_Y] |
4899 | jne .set |
||
1055 | Galkov | 4900 | ret |
757 | serge | 4901 | .set: |
1055 | Galkov | 4902 | pushfd |
4903 | cli |
||
757 | serge | 4904 | |
2434 | Serge | 4905 | mov [Screen_Max_X], eax |
4906 | mov [Screen_Max_Y], edx |
||
4907 | mov [BytesPerScanLine], ecx |
||
757 | serge | 4908 | |
2434 | Serge | 4909 | mov [screen_workarea.right], eax |
4910 | mov [screen_workarea.bottom], edx |
||
1300 | serge | 4911 | |
2434 | Serge | 4912 | push ebx |
4913 | push esi |
||
4914 | push edi |
||
1300 | serge | 4915 | |
4916 | pushad |
||
4917 | |||
4918 | stdcall kernel_free, [_WinMapAddress] |
||
4919 | |||
2434 | Serge | 4920 | mov eax, [_display.width] |
4921 | mul [_display.height] |
||
4922 | mov [_WinMapSize], eax |
||
1300 | serge | 4923 | |
4924 | stdcall kernel_alloc, eax |
||
2434 | Serge | 4925 | mov [_WinMapAddress], eax |
4926 | test eax, eax |
||
4927 | jz .epic_fail |
||
1300 | serge | 4928 | |
2439 | Serge | 4929 | call calculate_fast_getting_offset_for_WinMapAddress |
4930 | |||
1300 | serge | 4931 | popad |
4932 | |||
1055 | Galkov | 4933 | call repos_windows |
2434 | Serge | 4934 | xor eax, eax |
4935 | xor ebx, ebx |
||
1055 | Galkov | 4936 | mov ecx, [Screen_Max_X] |
4937 | mov edx, [Screen_Max_Y] |
||
4938 | call calculatescreen |
||
2434 | Serge | 4939 | pop edi |
4940 | pop esi |
||
4941 | pop ebx |
||
757 | serge | 4942 | |
1055 | Galkov | 4943 | popfd |
4944 | ret |
||
757 | serge | 4945 | |
1300 | serge | 4946 | .epic_fail: |
4947 | hlt ; Houston, we've had a problem |
||
4948 | |||
76 | mario79 | 4949 | ; --------------- APM --------------------- |
1330 | Lrz | 4950 | uglobal |
2434 | Serge | 4951 | apm_entry dp 0 |
4952 | apm_vf dd 0 |
||
1330 | Lrz | 4953 | endg |
4954 | |||
1 | ha | 4955 | align 4 |
76 | mario79 | 4956 | sys_apm: |
2434 | Serge | 4957 | xor eax, eax |
4958 | cmp word [apm_vf], ax ; Check APM BIOS enable |
||
4959 | jne @f |
||
4960 | inc eax |
||
4961 | or dword [esp + 44], eax ; error |
||
4962 | add eax, 7 |
||
4963 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
||
4964 | ret |
||
164 | serge | 4965 | |
465 | serge | 4966 | @@: |
2434 | Serge | 4967 | ; xchg eax, ecx |
4968 | ; xchg ebx, ecx |
||
164 | serge | 4969 | |
2434 | Serge | 4970 | cmp dx, 3 |
4971 | ja @f |
||
4972 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
||
4973 | mov eax, [apm_vf] |
||
4974 | mov [esp + 32], eax |
||
4975 | shr eax, 16 |
||
4976 | mov [esp + 28], eax |
||
4977 | ret |
||
78 | diamond | 4978 | |
465 | serge | 4979 | @@: |
4980 | |||
2434 | Serge | 4981 | mov esi, [master_tab+(OS_BASE shr 20)] |
4982 | xchg [master_tab], esi |
||
4983 | push esi |
||
4984 | mov edi, cr3 |
||
4985 | mov cr3, edi ;flush TLB |
||
465 | serge | 4986 | |
2434 | Serge | 4987 | call pword [apm_entry] ;call APM BIOS |
465 | serge | 4988 | |
2434 | Serge | 4989 | xchg eax, [esp] |
4990 | mov [master_tab], eax |
||
4991 | mov eax, cr3 |
||
4992 | mov cr3, eax |
||
4993 | pop eax |
||
465 | serge | 4994 | |
2434 | Serge | 4995 | mov [esp + 4 ], edi |
4996 | mov [esp + 8], esi |
||
4997 | mov [esp + 20], ebx |
||
4998 | mov [esp + 24], edx |
||
4999 | mov [esp + 28], ecx |
||
5000 | mov [esp + 32], eax |
||
5001 | setc al |
||
5002 | and [esp + 44], byte 0xfe |
||
5003 | or [esp + 44], al |
||
5004 | ret |
||
76 | mario79 | 5005 | ; ----------------------------------------- |
1 | ha | 5006 | |
76 | mario79 | 5007 | align 4 |
5008 | |||
1055 | Galkov | 5009 | undefined_syscall: ; Undefined system call |
2434 | Serge | 5010 | mov [esp + 32], dword -1 |
5011 | ret |
||
1 | ha | 5012 | |
465 | serge | 5013 | align 4 |
1055 | Galkov | 5014 | system_shutdown: ; shut down the system |
1 | ha | 5015 | |
2434 | Serge | 5016 | cmp byte [BOOT_VAR+0x9030], 1 |
5017 | jne @F |
||
5018 | ret |
||
465 | serge | 5019 | @@: |
2434 | Serge | 5020 | call stop_all_services |
5021 | push 3 ; stop playing cd |
||
5022 | pop eax |
||
5023 | call sys_cd_audio |
||
1 | ha | 5024 | |
465 | serge | 5025 | yes_shutdown_param: |
2434 | Serge | 5026 | cli |
1 | ha | 5027 | |
2010 | serge | 5028 | if ~ defined extended_primary_loader |
2434 | Serge | 5029 | mov eax, kernel_file ; load kernel.mnt to 0x7000:0 |
5030 | push 12 |
||
5031 | pop esi |
||
5032 | xor ebx, ebx |
||
5033 | or ecx, -1 |
||
5034 | mov edx, OS_BASE+0x70000 |
||
5035 | call fileread |
||
1 | ha | 5036 | |
2434 | Serge | 5037 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5038 | mov edi, OS_BASE+0x40000 |
||
5039 | mov ecx, 1000 |
||
5040 | rep movsb |
||
2010 | serge | 5041 | end if |
1 | ha | 5042 | |
2434 | Serge | 5043 | mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5044 | mov edi, OS_BASE |
||
5045 | mov ecx, 0x10000/4 |
||
5046 | cld |
||
5047 | rep movsd |
||
1 | ha | 5048 | |
2434 | Serge | 5049 | call restorefatchain |
1 | ha | 5050 | |
2434 | Serge | 5051 | call IRQ_mask_all |
1 | ha | 5052 | |
1085 | diamond | 5053 | if 0 |
2434 | Serge | 5054 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5055 | mov word [OS_BASE+0x467+2], 0x1000 |
||
1 | ha | 5056 | |
2434 | Serge | 5057 | mov al, 0x0F |
5058 | out 0x70, al |
||
5059 | mov al, 0x05 |
||
5060 | out 0x71, al |
||
1 | ha | 5061 | |
2434 | Serge | 5062 | mov al, 0xFE |
5063 | out 0x64, al |
||
709 | diamond | 5064 | |
2434 | Serge | 5065 | hlt |
5066 | jmp $-1 |
||
1 | ha | 5067 | |
709 | diamond | 5068 | else |
1055 | Galkov | 5069 | cmp byte [OS_BASE + 0x9030], 2 |
5070 | jnz no_acpi_power_off |
||
1 | ha | 5071 | |
709 | diamond | 5072 | ; scan for RSDP |
5073 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
||
1055 | Galkov | 5074 | movzx eax, word [OS_BASE + 0x40E] |
5075 | shl eax, 4 |
||
5076 | jz @f |
||
5077 | mov ecx, 1024/16 |
||
5078 | call scan_rsdp |
||
5079 | jnc .rsdp_found |
||
709 | diamond | 5080 | @@: |
5081 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
||
1055 | Galkov | 5082 | mov eax, 0xE0000 |
5083 | mov ecx, 0x2000 |
||
5084 | call scan_rsdp |
||
5085 | jc no_acpi_power_off |
||
709 | diamond | 5086 | .rsdp_found: |
1055 | Galkov | 5087 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5088 | mov ebp, [ipc_tmp] |
||
5089 | stdcall map_page, ebp, esi, PG_MAP |
||
5090 | lea eax, [esi+1000h] |
||
5091 | lea edx, [ebp+1000h] |
||
5092 | stdcall map_page, edx, eax, PG_MAP |
||
5093 | and esi, 0xFFF |
||
5094 | add esi, ebp |
||
5095 | cmp dword [esi], 'RSDT' |
||
5096 | jnz no_acpi_power_off |
||
5097 | mov ecx, [esi+4] |
||
5098 | sub ecx, 24h |
||
5099 | jbe no_acpi_power_off |
||
5100 | shr ecx, 2 |
||
5101 | add esi, 24h |
||
709 | diamond | 5102 | .scan_fadt: |
1055 | Galkov | 5103 | lodsd |
5104 | mov ebx, eax |
||
5105 | lea eax, [ebp+2000h] |
||
5106 | stdcall map_page, eax, ebx, PG_MAP |
||
5107 | lea eax, [ebp+3000h] |
||
5108 | add ebx, 0x1000 |
||
5109 | stdcall map_page, eax, ebx, PG_MAP |
||
5110 | and ebx, 0xFFF |
||
5111 | lea ebx, [ebx+ebp+2000h] |
||
5112 | cmp dword [ebx], 'FACP' |
||
5113 | jz .fadt_found |
||
5114 | loop .scan_fadt |
||
5115 | jmp no_acpi_power_off |
||
709 | diamond | 5116 | .fadt_found: |
5117 | ; ebx is linear address of FADT |
||
1085 | diamond | 5118 | mov edi, [ebx+40] ; physical address of the DSDT |
5119 | lea eax, [ebp+4000h] |
||
5120 | stdcall map_page, eax, edi, PG_MAP |
||
5121 | lea eax, [ebp+5000h] |
||
5122 | lea esi, [edi+0x1000] |
||
5123 | stdcall map_page, eax, esi, PG_MAP |
||
5124 | and esi, 0xFFF |
||
5125 | sub edi, esi |
||
5126 | cmp dword [esi+ebp+4000h], 'DSDT' |
||
5127 | jnz no_acpi_power_off |
||
5128 | mov eax, [esi+ebp+4004h] ; DSDT length |
||
5129 | sub eax, 36+4 |
||
5130 | jbe no_acpi_power_off |
||
5131 | add esi, 36 |
||
5132 | .scan_dsdt: |
||
5133 | cmp dword [esi+ebp+4000h], '_S5_' |
||
5134 | jnz .scan_dsdt_cont |
||
5135 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
||
5136 | jnz .scan_dsdt_cont |
||
5137 | mov dl, [esi+ebp+4000h+6] |
||
5138 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
||
5139 | ; ...in theory; in practice, VirtualBox has 2 bytes |
||
5140 | ja .scan_dsdt_cont |
||
5141 | cmp dl, 1 |
||
5142 | jb .scan_dsdt_cont |
||
5143 | lea esi, [esi+ebp+4000h+7] |
||
5144 | xor ecx, ecx |
||
5145 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
||
5146 | jz @f |
||
5147 | cmp byte [esi], 0xA |
||
5148 | jnz no_acpi_power_off |
||
5149 | inc esi |
||
5150 | mov cl, [esi] |
||
5151 | @@: |
||
5152 | inc esi |
||
5153 | cmp dl, 2 |
||
5154 | jb @f |
||
5155 | cmp byte [esi], 0 |
||
5156 | jz @f |
||
5157 | cmp byte [esi], 0xA |
||
5158 | jnz no_acpi_power_off |
||
5159 | inc esi |
||
5160 | mov ch, [esi] |
||
5161 | @@: |
||
5162 | jmp do_acpi_power_off |
||
5163 | .scan_dsdt_cont: |
||
5164 | inc esi |
||
5165 | cmp esi, 0x1000 |
||
5166 | jb @f |
||
5167 | sub esi, 0x1000 |
||
5168 | add edi, 0x1000 |
||
5169 | push eax |
||
5170 | lea eax, [ebp+4000h] |
||
5171 | stdcall map_page, eax, edi, PG_MAP |
||
5172 | push PG_MAP |
||
5173 | lea eax, [edi+1000h] |
||
5174 | push eax |
||
5175 | lea eax, [ebp+5000h] |
||
5176 | push eax |
||
5177 | stdcall map_page |
||
5178 | pop eax |
||
5179 | @@: |
||
5180 | dec eax |
||
5181 | jnz .scan_dsdt |
||
5182 | jmp no_acpi_power_off |
||
5183 | do_acpi_power_off: |
||
1055 | Galkov | 5184 | mov edx, [ebx+48] |
5185 | test edx, edx |
||
5186 | jz .nosmi |
||
5187 | mov al, [ebx+52] |
||
5188 | out dx, al |
||
5189 | mov edx, [ebx+64] |
||
709 | diamond | 5190 | @@: |
1055 | Galkov | 5191 | in ax, dx |
5192 | test al, 1 |
||
5193 | jz @b |
||
709 | diamond | 5194 | .nosmi: |
1085 | diamond | 5195 | and cx, 0x0707 |
5196 | shl cx, 2 |
||
5197 | or cx, 0x2020 |
||
1055 | Galkov | 5198 | mov edx, [ebx+64] |
5199 | in ax, dx |
||
5200 | and ax, 203h |
||
1085 | diamond | 5201 | or ah, cl |
1055 | Galkov | 5202 | out dx, ax |
5203 | mov edx, [ebx+68] |
||
5204 | test edx, edx |
||
5205 | jz @f |
||
5206 | in ax, dx |
||
5207 | and ax, 203h |
||
1085 | diamond | 5208 | or ah, ch |
1055 | Galkov | 5209 | out dx, ax |
709 | diamond | 5210 | @@: |
1055 | Galkov | 5211 | jmp $ |
709 | diamond | 5212 | |
5213 | |||
5214 | no_acpi_power_off: |
||
2434 | Serge | 5215 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5216 | mov word [OS_BASE+0x467+2], 0x1000 |
||
709 | diamond | 5217 | |
2434 | Serge | 5218 | mov al, 0x0F |
5219 | out 0x70, al |
||
5220 | mov al, 0x05 |
||
5221 | out 0x71, al |
||
709 | diamond | 5222 | |
2434 | Serge | 5223 | mov al, 0xFE |
5224 | out 0x64, al |
||
709 | diamond | 5225 | |
2434 | Serge | 5226 | hlt |
5227 | jmp $-1 |
||
709 | diamond | 5228 | |
5229 | scan_rsdp: |
||
1055 | Galkov | 5230 | add eax, OS_BASE |
709 | diamond | 5231 | .s: |
1055 | Galkov | 5232 | cmp dword [eax], 'RSD ' |
5233 | jnz .n |
||
5234 | cmp dword [eax+4], 'PTR ' |
||
5235 | jnz .n |
||
5236 | xor edx, edx |
||
5237 | xor esi, esi |
||
709 | diamond | 5238 | @@: |
1055 | Galkov | 5239 | add dl, [eax+esi] |
5240 | inc esi |
||
5241 | cmp esi, 20 |
||
5242 | jnz @b |
||
5243 | test dl, dl |
||
5244 | jz .ok |
||
709 | diamond | 5245 | .n: |
1055 | Galkov | 5246 | add eax, 10h |
5247 | loop .s |
||
5248 | stc |
||
709 | diamond | 5249 | .ok: |
1055 | Galkov | 5250 | ret |
709 | diamond | 5251 | end if |
5252 | |||
465 | serge | 5253 | include "data32.inc" |
1 | ha | 5254 | |
465 | serge | 5255 | __REV__ = __REV |
1 | ha | 5256 | |
5257 | uglobals_size = $ - endofcode |
||
41 | mikedld | 5258 | diff16 "end of kernel code",0,$=> |