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