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