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