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