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