Rev 9709 | Rev 9715 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2288 | clevermous | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
||
8858 | rgimad | 3 | ;; Copyright (C) KolibriOS team 2004-2021. 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: 9710 $ |
||
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 |
||
198 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
||
199 | cld |
||
200 | rep stosd |
||
201 | |||
202 | ; CLEAR KERNEL UNDEFINED GLOBALS |
||
203 | mov edi, endofcode-OS_BASE |
||
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 |
||
219 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
||
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 | |||
5130 | serge | 230 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
2288 | clevermous | 231 | mov cr3, eax |
232 | |||
233 | mov eax, cr0 |
||
234 | or eax, CR0_PG+CR0_WP |
||
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 |
||
246 | lgdt [cs:gdts_ap-ap_init16] |
||
247 | mov eax, [cs:cr3_ap-ap_init16] |
||
248 | mov cr3, eax |
||
249 | mov eax, [cs:cr4_ap-ap_init16] |
||
250 | mov cr4, eax |
||
251 | mov eax, CR0_PE+CR0_PG+CR0_WP |
||
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 |
286 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
||
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 | |||
5359 | serge | 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 |
5130 | serge | 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 | |||
459 | lea esp, [eax+RING0_STACK_SIZE] |
||
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 | |||
518 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
||
519 | (unpack.lc+unpack.lp)))*4 |
||
520 | |||
521 | mov [unpack.p], eax |
||
522 | |||
523 | call init_events |
||
2384 | hidnplayr | 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 |
||
567 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
||
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 | |||
6263 | serge | 578 | mov edi, sys_proc+PROC.heap_lock |
5595 | serge | 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 | |||
596 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
||
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 | |||
8093 | dunkaist | 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' |
||
617 | sub [edx+APPDATA.saved_esp], 4 |
||
618 | mov eax, [edx+APPDATA.saved_esp] |
||
619 | mov dword [eax], idle_thread |
||
620 | mov ecx, IDLE_PRIORITY |
||
621 | call scheduler_add_thread |
||
3296 | clevermous | 622 | |
8093 | dunkaist | 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 |
||
648 | mov [cr3_ap+OS_BASE], eax |
||
649 | mov eax, cr4 |
||
650 | mov [cr4_ap+OS_BASE], eax |
||
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 |
||
5359 | serge | 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 | @@: |
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 |
||
697 | mov eax, [cr3_ap+OS_BASE] |
||
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] |
||
8093 | dunkaist | 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 |
||
8111 | dunkaist | 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] |
||
919 | sbb edx, [hpet_tsc_start+4] |
||
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 |
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] |
||
8093 | dunkaist | 999 | stdcall map_page, esi, [SLOT_BASE+sizeof.APPDATA+APPDATA.io_map], PG_READ |
2288 | clevermous | 1000 | add esi, 0x1000 |
8093 | dunkaist | 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, \ |
||
8093 | dunkaist | 1004 | [SLOT_BASE+sizeof.APPDATA+APPDATA.io_map], PG_READ |
2288 | clevermous | 1005 | stdcall map_page, tss._io_map_1, \ |
8093 | dunkaist | 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 |
||
5130 | serge | 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 |
||
1148 | mov [edx+APPDATA.io_map], eax |
||
1149 | mov eax, tss+0x1080 |
||
1150 | call get_pg_addr |
||
1151 | inc eax |
||
1152 | mov [edx+APPDATA.io_map+4], eax |
||
1153 | |||
3534 | clevermous | 1154 | mov dword [edx+APPDATA.pl0_stack], ebx |
7124 | dunkaist | 1155 | lea edi, [ebx+RING0_STACK_SIZE] |
3534 | clevermous | 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 |
||
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 | |||
8087 | dunkaist | 1167 | lea eax, [edx+APP_EV_OFFSET] |
1168 | mov dword [edx+APPDATA.fd_ev], eax |
||
1169 | mov dword [edx+APPDATA.bk_ev], eax |
||
1170 | |||
3534 | clevermous | 1171 | lea eax, [edx+APP_OBJ_OFFSET] |
1172 | mov dword [edx+APPDATA.fd_obj], eax |
||
1173 | mov dword [edx+APPDATA.bk_obj], eax |
||
1174 | |||
6502 | pathoswith | 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 | |
5130 | serge | 1179 | lea ebx, [edx+APPDATA.list] |
1180 | lea ecx, [sys_proc+PROC.thr_list] |
||
1181 | list_add_tail ebx, ecx |
||
1182 | |||
9608 | Doczom | 1183 | mov [edx+APPDATA.wnd_number], dh |
9692 | Doczom | 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 |
||
1366 | stdcall is_region_userspace, ecx, 1 |
||
9045 | dunkaist | 1367 | jz @f |
8713 | Doczom | 1368 | ret |
1369 | @@: |
||
1370 | test esi, 0x08000000 |
||
1371 | jz @f |
||
1372 | stdcall is_region_userspace, edi, 1 |
||
9045 | dunkaist | 1373 | jz @f |
8713 | Doczom | 1374 | ret |
1375 | @@: |
||
2288 | clevermous | 1376 | ;It is not optimization |
1377 | mov eax, ebx |
||
1378 | mov ebx, ecx |
||
1379 | mov ecx, edx |
||
1380 | mov edx, esi |
||
1381 | mov esi, edi |
||
1382 | ; eax = print type, al=0 -> ebx is number |
||
1383 | ; al=1 -> ebx is pointer |
||
1384 | ; ah=0 -> display decimal |
||
1385 | ; ah=1 -> display hexadecimal |
||
1386 | ; ah=2 -> display binary |
||
1387 | ; eax bits 16-21 = number of digits to display (0-32) |
||
1388 | ; eax bits 22-31 = reserved |
||
1389 | ; |
||
1390 | ; ebx = number or pointer |
||
1391 | ; ecx = x shl 16 + y |
||
1392 | ; edx = color |
||
1393 | xor edi, edi |
||
1394 | display_number_force: |
||
1395 | push eax |
||
1396 | and eax, 0x3fffffff |
||
1397 | cmp eax, 0xffff ; length > 0 ? |
||
1398 | pop eax |
||
1399 | jge cont_displ |
||
1400 | ret |
||
1401 | cont_displ: |
||
1402 | push eax |
||
1403 | and eax, 0x3fffffff |
||
1404 | cmp eax, 61*0x10000 ; length <= 60 ? |
||
1405 | pop eax |
||
1406 | jb cont_displ2 |
||
1407 | ret |
||
1408 | cont_displ2: |
||
1409 | |||
1410 | pushad |
||
1411 | |||
1412 | cmp al, 1 ; ecx is a pointer ? |
||
1413 | jne displnl1 |
||
1414 | mov ebp, ebx |
||
1415 | add ebp, 4 |
||
1416 | mov ebp, [ebp+std_application_base_address] |
||
1417 | mov ebx, [ebx+std_application_base_address] |
||
1418 | displnl1: |
||
1419 | sub esp, 64 |
||
1420 | |||
1421 | test ah, ah ; DECIMAL |
||
1422 | jnz no_display_desnum |
||
1423 | shr eax, 16 |
||
1424 | and eax, 0xC03f |
||
1425 | ; and eax,0x3f |
||
1426 | push eax |
||
1427 | and eax, 0x3f |
||
1428 | mov edi, esp |
||
1429 | add edi, 4+64-1 |
||
1430 | mov ecx, eax |
||
1431 | mov eax, ebx |
||
1432 | mov ebx, 10 |
||
1433 | d_desnum: |
||
1434 | xor edx, edx |
||
1435 | call division_64_bits |
||
1436 | div ebx |
||
1437 | add dl, 48 |
||
1438 | mov [edi], dl |
||
1439 | dec edi |
||
1440 | loop d_desnum |
||
1441 | pop eax |
||
1442 | call normalize_number |
||
1443 | call draw_num_text |
||
1444 | add esp, 64 |
||
1445 | popad |
||
1446 | ret |
||
1447 | no_display_desnum: |
||
1448 | |||
1449 | cmp ah, 0x01 ; HEXADECIMAL |
||
1450 | jne no_display_hexnum |
||
1451 | shr eax, 16 |
||
1452 | and eax, 0xC03f |
||
1453 | ; and eax,0x3f |
||
1454 | push eax |
||
1455 | and eax, 0x3f |
||
1456 | mov edi, esp |
||
1457 | add edi, 4+64-1 |
||
1458 | mov ecx, eax |
||
1459 | mov eax, ebx |
||
1460 | mov ebx, 16 |
||
1461 | d_hexnum: |
||
1462 | xor edx, edx |
||
1463 | call division_64_bits |
||
1464 | div ebx |
||
1465 | hexletters = __fdo_hexdigits |
||
1466 | add edx, hexletters |
||
1467 | mov dl, [edx] |
||
1468 | mov [edi], dl |
||
1469 | dec edi |
||
1470 | loop d_hexnum |
||
1471 | pop eax |
||
1472 | call normalize_number |
||
1473 | call draw_num_text |
||
1474 | add esp, 64 |
||
1475 | popad |
||
1476 | ret |
||
1477 | no_display_hexnum: |
||
1478 | |||
1479 | cmp ah, 0x02 ; BINARY |
||
1480 | jne no_display_binnum |
||
1481 | shr eax, 16 |
||
1482 | and eax, 0xC03f |
||
1483 | ; and eax,0x3f |
||
1484 | push eax |
||
1485 | and eax, 0x3f |
||
1486 | mov edi, esp |
||
1487 | add edi, 4+64-1 |
||
1488 | mov ecx, eax |
||
1489 | mov eax, ebx |
||
1490 | mov ebx, 2 |
||
1491 | d_binnum: |
||
1492 | xor edx, edx |
||
1493 | call division_64_bits |
||
1494 | div ebx |
||
1495 | add dl, 48 |
||
1496 | mov [edi], dl |
||
1497 | dec edi |
||
1498 | loop d_binnum |
||
1499 | pop eax |
||
1500 | call normalize_number |
||
1501 | call draw_num_text |
||
1502 | add esp, 64 |
||
1503 | popad |
||
1504 | ret |
||
1505 | no_display_binnum: |
||
1506 | |||
1507 | add esp, 64 |
||
1508 | popad |
||
1509 | ret |
||
1510 | |||
1511 | normalize_number: |
||
1512 | test ah, 0x80 |
||
1513 | jz .continue |
||
1514 | mov ecx, 48 |
||
1515 | and eax, 0x3f |
||
1516 | @@: |
||
1517 | inc edi |
||
1518 | cmp [edi], cl |
||
1519 | jne .continue |
||
1520 | dec eax |
||
1521 | cmp eax, 1 |
||
1522 | ja @r |
||
1523 | mov al, 1 |
||
1524 | .continue: |
||
1525 | and eax, 0x3f |
||
1526 | ret |
||
1527 | |||
1528 | division_64_bits: |
||
1529 | test [esp+1+4], byte 0x40 |
||
1530 | jz .continue |
||
1531 | push eax |
||
1532 | mov eax, ebp |
||
1533 | div ebx |
||
1534 | mov ebp, eax |
||
1535 | pop eax |
||
1536 | .continue: |
||
1537 | ret |
||
1538 | |||
1539 | draw_num_text: |
||
1540 | mov esi, eax |
||
1541 | mov edx, 64+4 |
||
1542 | sub edx, eax |
||
1543 | add edx, esp |
||
1544 | mov ebx, [esp+64+32-8+4] |
||
1545 | ; add window start x & y |
||
1546 | |||
8869 | rgimad | 1547 | mov edi, [current_slot_idx] |
9592 | Doczom | 1548 | mov ecx, edi |
2288 | clevermous | 1549 | shl edi, 8 |
9592 | Doczom | 1550 | shl ecx, 5 |
2288 | clevermous | 1551 | |
9592 | Doczom | 1552 | mov eax, [ecx+window_data+WDATA.box.left] |
2288 | clevermous | 1553 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1554 | shl eax, 16 |
||
9592 | Doczom | 1555 | add eax, [ecx+window_data+WDATA.box.top] |
2288 | clevermous | 1556 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1557 | add ebx, eax |
||
1558 | mov ecx, [esp+64+32-12+4] |
||
1559 | mov eax, [esp+64+8] ; background color (if given) |
||
1560 | mov edi, [esp+64+4] |
||
6272 | pathoswith | 1561 | and ecx, 5FFFFFFFh |
1562 | bt ecx, 27 |
||
1563 | jnc @f |
||
1564 | mov edi, eax |
||
1565 | @@: |
||
2288 | clevermous | 1566 | jmp dtext |
4700 | mario79 | 1567 | ;----------------------------------------------------------------------------- |
1568 | iglobal |
||
1569 | midi_base dw 0 |
||
1570 | endg |
||
1571 | ;----------------------------------------------------------------------------- |
||
2288 | clevermous | 1572 | align 4 |
1573 | sys_setup: |
||
4700 | mario79 | 1574 | ; 1 = roland mpu midi base , base io address |
1575 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1576 | ; 3 = not used |
||
1577 | ; 4 = not used |
||
1578 | ; 5 = system language, 1eng 2fi 3ger 4rus |
||
1579 | ; 6 = not used |
||
1580 | ; 7 = not used |
||
1581 | ; 8 = not used |
||
1582 | ; 9 = not used |
||
1583 | ; 10 = not used |
||
2288 | clevermous | 1584 | ; 11 = enable lba read |
1585 | ; 12 = enable pci access |
||
4700 | mario79 | 1586 | ;----------------------------------------------------------------------------- |
1587 | and [esp+32], dword 0 |
||
1588 | ; F.21.1 - set MPU MIDI base port |
||
1589 | dec ebx |
||
1590 | jnz @f |
||
2288 | clevermous | 1591 | |
1592 | cmp ecx, 0x100 |
||
4700 | mario79 | 1593 | jb @f |
2288 | clevermous | 1594 | |
1595 | mov esi, 65535 |
||
1596 | cmp esi, ecx |
||
4700 | mario79 | 1597 | jb @f |
2288 | clevermous | 1598 | |
4700 | mario79 | 1599 | mov [midi_base], cx |
1600 | mov word [mididp], cx |
||
1601 | inc cx |
||
1602 | mov word [midisp], cx |
||
2288 | clevermous | 1603 | ret |
4700 | mario79 | 1604 | ;-------------------------------------- |
1605 | @@: |
||
1606 | ; F.21.2 - set keyboard layout |
||
1607 | dec ebx |
||
1608 | jnz @f |
||
2288 | clevermous | 1609 | |
9710 | Doczom | 1610 | mov eax, edx |
4700 | mario79 | 1611 | ; 1 = normal layout |
1612 | dec ecx |
||
1613 | jnz .shift |
||
2288 | clevermous | 1614 | |
1615 | mov ebx, keymap |
||
1616 | mov ecx, 128 |
||
1617 | call memmove |
||
1618 | ret |
||
4700 | mario79 | 1619 | ;-------------------------------------- |
1620 | .shift: |
||
1621 | ; 2 = layout at pressed Shift |
||
2288 | clevermous | 1622 | dec ecx |
4700 | mario79 | 1623 | jnz .alt |
2288 | clevermous | 1624 | |
1625 | mov ebx, keymap_shift |
||
1626 | mov ecx, 128 |
||
1627 | call memmove |
||
1628 | ret |
||
4700 | mario79 | 1629 | ;-------------------------------------- |
1630 | .alt: |
||
1631 | ; 3 = layout at pressed Alt |
||
2288 | clevermous | 1632 | dec ecx |
4700 | mario79 | 1633 | jnz .country |
1634 | |||
2288 | clevermous | 1635 | mov ebx, keymap_alt |
1636 | mov ecx, 128 |
||
1637 | call memmove |
||
1638 | ret |
||
4700 | mario79 | 1639 | ;-------------------------------------- |
1640 | .country: |
||
1641 | ; country identifier |
||
2288 | clevermous | 1642 | sub ecx, 6 |
4700 | mario79 | 1643 | jnz .error |
1644 | |||
2288 | clevermous | 1645 | mov word [keyboard], dx |
1646 | ret |
||
4700 | mario79 | 1647 | ;-------------------------------------- |
1648 | @@: |
||
1649 | ; F.21.5 - set system language |
||
1650 | sub ebx, 3 |
||
1651 | jnz @f |
||
2288 | clevermous | 1652 | |
1653 | mov [syslang], ecx |
||
1654 | ret |
||
4700 | mario79 | 1655 | ;-------------------------------------- |
1656 | @@: |
||
1657 | ; F.21.11 - enable/disable low-level access to HD |
||
1658 | and ecx, 1 |
||
1659 | sub ebx, 6 |
||
1660 | jnz @f |
||
2288 | clevermous | 1661 | |
4700 | mario79 | 1662 | mov [lba_read_enabled], ecx |
2288 | clevermous | 1663 | ret |
4700 | mario79 | 1664 | ;-------------------------------------- |
1665 | @@: |
||
1666 | ; F.21.12 - enable/disable low-level access to PCI |
||
2288 | clevermous | 1667 | dec ebx |
4700 | mario79 | 1668 | jnz .error |
2288 | clevermous | 1669 | |
1670 | mov [pci_access_enabled], ecx |
||
1671 | ret |
||
4700 | mario79 | 1672 | ;-------------------------------------- |
1673 | .error: |
||
2288 | clevermous | 1674 | or [esp+32], dword -1 |
1675 | ret |
||
4700 | mario79 | 1676 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 1677 | align 4 |
1678 | sys_getsetup: |
||
4700 | mario79 | 1679 | ; 1 = roland mpu midi base , base io address |
1680 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
||
1681 | ; 3 = not used |
||
1682 | ; 4 = not used |
||
1683 | ; 5 = system language, 1eng 2fi 3ger 4rus |
||
1684 | ; 6 = not used |
||
1685 | ; 7 = not used |
||
1686 | ; 8 = not used |
||
1687 | ; 9 = get hs timer tic |
||
1688 | ; 10 = not used |
||
1689 | ; 11 = get the state "lba read" |
||
1690 | ; 12 = get the state "pci access" |
||
1691 | ;----------------------------------------------------------------------------- |
||
1692 | ; F.26.1 - get MPU MIDI base port |
||
1693 | dec ebx |
||
1694 | jnz @f |
||
2288 | clevermous | 1695 | |
1696 | movzx eax, [midi_base] |
||
1697 | mov [esp+32], eax |
||
1698 | ret |
||
4700 | mario79 | 1699 | ;-------------------------------------- |
1700 | @@: |
||
1701 | ; F.26.2 - get keyboard layout |
||
2288 | clevermous | 1702 | dec ebx |
4700 | mario79 | 1703 | jnz @f |
2288 | clevermous | 1704 | |
9710 | Doczom | 1705 | mov ebx, edx |
1706 | ; if given memory address belongs to kernel then error |
||
1707 | stdcall is_region_userspace, ebx, 128 |
||
1708 | jnz .addr_error |
||
4700 | mario79 | 1709 | ; 1 = normal layout |
1710 | dec ecx |
||
1711 | jnz .shift |
||
2288 | clevermous | 1712 | |
1713 | mov eax, keymap |
||
1714 | mov ecx, 128 |
||
1715 | call memmove |
||
1716 | ret |
||
4700 | mario79 | 1717 | ;-------------------------------------- |
1718 | .shift: |
||
1719 | ; 2 = layout with pressed Shift |
||
2288 | clevermous | 1720 | dec ecx |
4700 | mario79 | 1721 | jnz .alt |
2288 | clevermous | 1722 | |
1723 | mov eax, keymap_shift |
||
1724 | mov ecx, 128 |
||
1725 | call memmove |
||
1726 | ret |
||
4700 | mario79 | 1727 | ;-------------------------------------- |
1728 | .alt: |
||
1729 | ; 3 = layout with pressed Alt |
||
2288 | clevermous | 1730 | dec ecx |
4700 | mario79 | 1731 | jne .country |
2288 | clevermous | 1732 | |
1733 | mov eax, keymap_alt |
||
1734 | mov ecx, 128 |
||
1735 | call memmove |
||
1736 | ret |
||
4700 | mario79 | 1737 | ;-------------------------------------- |
1738 | .country: |
||
1739 | ; 9 = country identifier |
||
2288 | clevermous | 1740 | sub ecx, 6 |
4700 | mario79 | 1741 | jnz .error |
1742 | |||
2288 | clevermous | 1743 | movzx eax, word [keyboard] |
1744 | mov [esp+32], eax |
||
1745 | ret |
||
8158 | rgimad | 1746 | |
1747 | .addr_error: ; if given memory address is illegal |
||
8249 | rgimad | 1748 | mov dword [esp+32], -1 |
8158 | rgimad | 1749 | ret |
4700 | mario79 | 1750 | ;-------------------------------------- |
1751 | @@: |
||
1752 | ; F.26.5 - get system language |
||
1753 | sub ebx, 3 |
||
1754 | jnz @f |
||
2288 | clevermous | 1755 | |
1756 | mov eax, [syslang] |
||
1757 | mov [esp+32], eax |
||
1758 | ret |
||
4700 | mario79 | 1759 | ;-------------------------------------- |
1760 | @@: |
||
1761 | ; F.26.9 - get the value of the time counter |
||
4573 | clevermous | 1762 | sub ebx, 4 |
4700 | mario79 | 1763 | jnz @f |
1764 | |||
1765 | mov eax, [timer_ticks] |
||
2288 | clevermous | 1766 | mov [esp+32], eax |
1767 | ret |
||
4700 | mario79 | 1768 | ;-------------------------------------- |
1769 | @@: |
||
5794 | serge | 1770 | ; F.26.10 - get the time from kernel launch in nanoseconds |
9571 | Doczom | 1771 | dec ebx |
5794 | serge | 1772 | jnz @f |
1773 | |||
1774 | call get_clock_ns |
||
1775 | mov [esp+24], edx |
||
1776 | mov [esp+32], eax |
||
1777 | ret |
||
1778 | ;-------------------------------------- |
||
1779 | @@: |
||
4700 | mario79 | 1780 | ; F.26.11 - Find out whether low-level HD access is enabled |
9571 | Doczom | 1781 | dec ebx |
4700 | mario79 | 1782 | jnz @f |
1783 | |||
2288 | clevermous | 1784 | mov eax, [lba_read_enabled] |
1785 | mov [esp+32], eax |
||
1786 | ret |
||
4700 | mario79 | 1787 | ;-------------------------------------- |
1788 | @@: |
||
1789 | ; F.26.12 - Find out whether low-level PCI access is enabled |
||
2288 | clevermous | 1790 | dec ebx |
4700 | mario79 | 1791 | jnz .error |
1792 | |||
2288 | clevermous | 1793 | mov eax, [pci_access_enabled] |
1794 | mov [esp+32], eax |
||
1795 | ret |
||
4700 | mario79 | 1796 | ;-------------------------------------- |
1797 | .error: |
||
1798 | or [esp+32], dword -1 |
||
2288 | clevermous | 1799 | ret |
4700 | mario79 | 1800 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 1801 | get_timer_ticks: |
1802 | mov eax, [timer_ticks] |
||
1803 | ret |
||
4700 | mario79 | 1804 | ;----------------------------------------------------------------------------- |
5851 | pathoswith | 1805 | |
2288 | clevermous | 1806 | is_input: |
1807 | push edx |
||
1808 | mov dx, word [midisp] |
||
1809 | in al, dx |
||
1810 | and al, 0x80 |
||
1811 | pop edx |
||
1812 | ret |
||
1813 | |||
1814 | is_output: |
||
1815 | push edx |
||
1816 | mov dx, word [midisp] |
||
1817 | in al, dx |
||
1818 | and al, 0x40 |
||
1819 | pop edx |
||
1820 | ret |
||
1821 | |||
1822 | get_mpu_in: |
||
1823 | push edx |
||
1824 | mov dx, word [mididp] |
||
1825 | in al, dx |
||
1826 | pop edx |
||
1827 | ret |
||
1828 | |||
1829 | put_mpu_out: |
||
1830 | push edx |
||
1831 | mov dx, word [mididp] |
||
1832 | out dx, al |
||
1833 | pop edx |
||
1834 | ret |
||
1835 | |||
1836 | align 4 |
||
1837 | sys_midi: |
||
1838 | cmp [mididp], 0 |
||
1839 | jnz sm0 |
||
1840 | mov [esp+36], dword 1 |
||
1841 | ret |
||
1842 | sm0: |
||
1843 | and [esp+36], dword 0 |
||
1844 | dec ebx |
||
1845 | jnz smn1 |
||
1846 | ; call setuart |
||
1847 | su1: |
||
1848 | call is_output |
||
1849 | test al, al |
||
1850 | jnz su1 |
||
1851 | mov dx, word [midisp] |
||
1852 | mov al, 0xff |
||
1853 | out dx, al |
||
1854 | su2: |
||
1855 | mov dx, word [midisp] |
||
1856 | mov al, 0xff |
||
1857 | out dx, al |
||
1858 | call is_input |
||
1859 | test al, al |
||
1860 | jnz su2 |
||
1861 | call get_mpu_in |
||
1862 | cmp al, 0xfe |
||
1863 | jnz su2 |
||
1864 | su3: |
||
1865 | call is_output |
||
1866 | test al, al |
||
1867 | jnz su3 |
||
1868 | mov dx, word [midisp] |
||
1869 | mov al, 0x3f |
||
1870 | out dx, al |
||
1871 | ret |
||
1872 | smn1: |
||
1873 | dec ebx |
||
1874 | jnz smn2 |
||
1875 | sm10: |
||
1876 | call get_mpu_in |
||
1877 | call is_output |
||
1878 | test al, al |
||
1879 | jnz sm10 |
||
1880 | mov al, bl |
||
1881 | call put_mpu_out |
||
1882 | smn2: |
||
1883 | ret |
||
1884 | |||
1885 | detect_devices: |
||
1886 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
1887 | ;include 'detect/commouse.inc' |
||
1888 | ;include 'detect/ps2mouse.inc' |
||
1889 | ;include 'detect/dev_fd.inc' |
||
1890 | ;include 'detect/dev_hdcd.inc' |
||
1891 | ;include 'detect/sear_par.inc' |
||
1892 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
||
1893 | ret |
||
1894 | |||
1895 | sys_end: |
||
2430 | mario79 | 1896 | ;-------------------------------------- |
1897 | cmp [_display.select_cursor], 0 |
||
1898 | je @f |
||
1899 | ; restore default cursor before killing |
||
1900 | pusha |
||
1901 | mov ecx, [current_slot] |
||
2435 | mario79 | 1902 | call restore_default_cursor_before_killing |
2430 | mario79 | 1903 | popa |
1904 | @@: |
||
1905 | ;-------------------------------------- |
||
3545 | hidnplayr | 1906 | ; kill all sockets this process owns |
1907 | pusha |
||
9612 | Doczom | 1908 | mov edx, [current_slot] |
1909 | mov edx, [edx+APPDATA.tid] |
||
6011 | hidnplayr | 1910 | call socket_process_end |
3545 | hidnplayr | 1911 | popa |
1912 | ;-------------------------------------- |
||
2288 | clevermous | 1913 | mov ecx, [current_slot] |
1914 | mov eax, [ecx+APPDATA.tls_base] |
||
1915 | test eax, eax |
||
1916 | jz @F |
||
1917 | |||
1918 | stdcall user_free, eax |
||
1919 | @@: |
||
1920 | |||
9612 | Doczom | 1921 | mov eax, [current_slot] |
1922 | mov [eax+APPDATA.state], TSTATE_ZOMBIE |
||
3534 | clevermous | 1923 | call wakeup_osloop |
2288 | clevermous | 1924 | |
3597 | Serge | 1925 | .waitterm: ; wait here for termination |
1926 | call change_task |
||
1927 | jmp .waitterm |
||
2435 | mario79 | 1928 | ;------------------------------------------------------------------------------ |
2452 | mario79 | 1929 | align 4 |
2435 | mario79 | 1930 | restore_default_cursor_before_killing: |
2468 | mario79 | 1931 | pushfd |
1932 | cli |
||
2435 | mario79 | 1933 | mov eax, [def_cursor] |
1934 | mov [ecx+APPDATA.cursor], eax |
||
2288 | clevermous | 1935 | |
2435 | mario79 | 1936 | movzx eax, word [MOUSE_Y] |
1937 | movzx ebx, word [MOUSE_X] |
||
2446 | mario79 | 1938 | mov eax, [d_width_calc_area + eax*4] |
1939 | |||
5351 | serge | 1940 | add eax, [_display.win_map] |
2435 | mario79 | 1941 | movzx edx, byte [ebx+eax] |
9709 | Doczom | 1942 | shl edx, BSF sizeof.APPDATA |
2435 | mario79 | 1943 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2452 | mario79 | 1944 | |
1945 | cmp esi, [current_cursor] |
||
1946 | je @f |
||
1947 | |||
2435 | mario79 | 1948 | push esi |
1949 | call [_display.select_cursor] |
||
1950 | mov [current_cursor], esi |
||
2452 | mario79 | 1951 | @@: |
2450 | mario79 | 1952 | mov [redrawmouse_unconditional], 1 |
3534 | clevermous | 1953 | call wakeup_osloop |
2468 | mario79 | 1954 | popfd |
2435 | mario79 | 1955 | ret |
1956 | ;------------------------------------------------------------------------------ |
||
2288 | clevermous | 1957 | iglobal |
1958 | align 4 |
||
1959 | sys_system_table: |
||
1960 | dd sysfn_deactivate ; 1 = deactivate window |
||
1961 | dd sysfn_terminate ; 2 = terminate thread |
||
1962 | dd sysfn_activate ; 3 = activate window |
||
1963 | dd sysfn_getidletime ; 4 = get idle time |
||
1964 | dd sysfn_getcpuclock ; 5 = get cpu clock |
||
1965 | dd sysfn_saveramdisk ; 6 = save ramdisk |
||
1966 | dd sysfn_getactive ; 7 = get active window |
||
1967 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
||
1968 | dd sysfn_shutdown ; 9 = shutdown with parameter |
||
1969 | dd sysfn_minimize ; 10 = minimize window |
||
1970 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
||
9268 | Doczom | 1971 | dd undefined_syscall ; 12 = get last pressed key. function removed. sysfn_lastkey |
2288 | clevermous | 1972 | dd sysfn_getversion ; 13 = get kernel version |
1973 | dd sysfn_waitretrace ; 14 = wait retrace |
||
1974 | dd sysfn_centermouse ; 15 = center mouse cursor |
||
1975 | dd sysfn_getfreemem ; 16 = get free memory size |
||
1976 | dd sysfn_getallmem ; 17 = get total memory size |
||
1977 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
||
1978 | ; instead of slot |
||
1979 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
||
1980 | dd sysfn_meminfo ; 20 = get extended memory info |
||
1981 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
||
1982 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
||
2648 | mario79 | 1983 | dd sysfn_min_windows ; 23 = minimize all windows |
2654 | mario79 | 1984 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
5836 | GerdtR | 1985 | |
1986 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
||
2288 | clevermous | 1987 | sysfn_num = ($ - sys_system_table)/4 |
1988 | endg |
||
1989 | ;------------------------------------------------------------------------------ |
||
1990 | sys_system: |
||
1991 | dec ebx |
||
1992 | cmp ebx, sysfn_num |
||
1993 | jae @f |
||
1994 | jmp dword [sys_system_table + ebx*4] |
||
1995 | @@: |
||
1996 | ret |
||
1997 | ;------------------------------------------------------------------------------ |
||
1998 | sysfn_shutdown: ; 18.9 = system shutdown |
||
7122 | dunkaist | 1999 | cmp ecx, SYSTEM_SHUTDOWN |
2288 | clevermous | 2000 | jl exit_for_anyone |
7122 | dunkaist | 2001 | cmp ecx, SYSTEM_RESTART |
2288 | clevermous | 2002 | jg exit_for_anyone |
7132 | dunkaist | 2003 | mov [BOOT.shutdown_type], cl |
2288 | clevermous | 2004 | |
8866 | rgimad | 2005 | mov eax, [thread_count] |
2288 | clevermous | 2006 | mov [SYS_SHUTDOWN], al |
2007 | mov [shutdown_processes], eax |
||
3534 | clevermous | 2008 | call wakeup_osloop |
2288 | clevermous | 2009 | and dword [esp+32], 0 |
2010 | exit_for_anyone: |
||
2011 | ret |
||
2012 | uglobal |
||
2013 | shutdown_processes: |
||
2014 | dd 0x0 |
||
2015 | endg |
||
2016 | ;------------------------------------------------------------------------------ |
||
8270 | dunkaist | 2017 | ; in: eax -- APPDATA ptr |
2018 | ; out: Z/z -- is/not kernel thread |
||
2019 | is_kernel_thread: |
||
2020 | mov eax, [eax+APPDATA.process] |
||
2021 | cmp eax, [SLOT_BASE+2*sizeof.APPDATA+APPDATA.process] ; OS |
||
2022 | ret |
||
2023 | ;------------------------------------------------------------------------------ |
||
2288 | clevermous | 2024 | sysfn_terminate: ; 18.2 = TERMINATE |
2472 | mario79 | 2025 | push ecx |
2288 | clevermous | 2026 | cmp ecx, 2 |
2027 | jb noprocessterminate |
||
8866 | rgimad | 2028 | mov edx, [thread_count] |
2288 | clevermous | 2029 | cmp ecx, edx |
2030 | ja noprocessterminate |
||
8866 | rgimad | 2031 | mov eax, [thread_count] |
9709 | Doczom | 2032 | shl ecx, BSF sizeof.APPDATA |
2033 | add ecx, SLOT_BASE |
||
2034 | mov edx, [ecx + APPDATA.tid] |
||
2035 | cmp byte [ecx + APPDATA.state], TSTATE_FREE |
||
2288 | clevermous | 2036 | jz noprocessterminate |
8270 | dunkaist | 2037 | push eax |
9709 | Doczom | 2038 | mov eax, ecx |
8270 | dunkaist | 2039 | call is_kernel_thread |
2040 | pop eax |
||
2041 | jz noprocessterminate |
||
3296 | clevermous | 2042 | push ecx edx |
9709 | Doczom | 2043 | mov edx, ecx |
3296 | clevermous | 2044 | call request_terminate |
2045 | pop edx ecx |
||
2046 | test eax, eax |
||
2047 | jz noprocessterminate |
||
2430 | mario79 | 2048 | ;-------------------------------------- |
3545 | hidnplayr | 2049 | ; terminate all network sockets it used |
2050 | pusha |
||
9709 | Doczom | 2051 | mov eax, edx ;TODO: check function |
6011 | hidnplayr | 2052 | call socket_process_end |
3545 | hidnplayr | 2053 | popa |
2054 | ;-------------------------------------- |
||
2430 | mario79 | 2055 | cmp [_display.select_cursor], 0 |
2452 | mario79 | 2056 | je .restore_end |
2430 | mario79 | 2057 | ; restore default cursor before killing |
2058 | pusha |
||
2059 | mov ecx, [esp+32] |
||
2060 | shl ecx, 8 |
||
2435 | mario79 | 2061 | add ecx, SLOT_BASE |
2452 | mario79 | 2062 | mov eax, [def_cursor] |
2063 | cmp [ecx+APPDATA.cursor], eax |
||
2064 | je @f |
||
2435 | mario79 | 2065 | call restore_default_cursor_before_killing |
2452 | mario79 | 2066 | @@: |
2430 | mario79 | 2067 | popa |
2452 | mario79 | 2068 | .restore_end: |
2430 | mario79 | 2069 | ;-------------------------------------- |
2288 | clevermous | 2070 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
9709 | Doczom | 2071 | mov [ecx + APPDATA.state], TSTATE_ZOMBIE; clear possible i40's |
3534 | clevermous | 2072 | call wakeup_osloop |
2288 | clevermous | 2073 | ;call MEM_Heap_UnLock |
2074 | |||
3534 | clevermous | 2075 | cmp edx, [application_table_owner]; clear app table stat |
2288 | clevermous | 2076 | jne noatsc |
3534 | clevermous | 2077 | call unlock_application_table |
2468 | mario79 | 2078 | noatsc: |
2079 | noprocessterminate: |
||
2472 | mario79 | 2080 | add esp, 4 |
2288 | clevermous | 2081 | ret |
2082 | ;------------------------------------------------------------------------------ |
||
2083 | sysfn_terminate2: |
||
2084 | ;lock application_table_status mutex |
||
2085 | .table_status: |
||
3534 | clevermous | 2086 | call lock_application_table |
2288 | clevermous | 2087 | mov eax, ecx |
2088 | call pid_to_slot |
||
2089 | test eax, eax |
||
2090 | jz .not_found |
||
2091 | mov ecx, eax |
||
2092 | cli |
||
2093 | call sysfn_terminate |
||
3534 | clevermous | 2094 | call unlock_application_table |
2288 | clevermous | 2095 | sti |
2096 | and dword [esp+32], 0 |
||
2097 | ret |
||
2098 | .not_found: |
||
3534 | clevermous | 2099 | call unlock_application_table |
2288 | clevermous | 2100 | or dword [esp+32], -1 |
2101 | ret |
||
2102 | ;------------------------------------------------------------------------------ |
||
2103 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
||
2104 | cmp ecx, 2 |
||
2105 | jb .nowindowdeactivate |
||
8866 | rgimad | 2106 | cmp ecx, [thread_count] |
2288 | clevermous | 2107 | ja .nowindowdeactivate |
2408 | Serge | 2108 | |
2288 | clevermous | 2109 | movzx esi, word [WIN_STACK + ecx*2] |
2110 | cmp esi, 1 |
||
2111 | je .nowindowdeactivate ; already deactive |
||
2112 | |||
2113 | mov edi, ecx |
||
2114 | shl edi, 5 |
||
2115 | add edi, window_data |
||
2116 | movzx esi, word [WIN_STACK + ecx * 2] |
||
2117 | lea esi, [WIN_POS + esi * 2] |
||
2118 | call window._.window_deactivate |
||
6800 | pathoswith | 2119 | call syscall_display_settings.calculateScreen |
2120 | call syscall_display_settings.redrawScreen |
||
2288 | clevermous | 2121 | .nowindowdeactivate: |
2122 | ret |
||
3455 | mario79 | 2123 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2124 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
5675 | leency | 2125 | cmp ecx, 2 |
2126 | jb .nowindowactivate |
||
8866 | rgimad | 2127 | cmp ecx, [thread_count] |
2288 | clevermous | 2128 | ja .nowindowactivate |
3455 | mario79 | 2129 | ;------------------------------------- |
2130 | @@: |
||
2131 | ; If the window is captured and moved by the user, |
||
2132 | ; then you can't change the position in window stack!!! |
||
2133 | mov al, [mouse.active_sys_window.action] |
||
2134 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
||
2135 | test al, al |
||
2136 | jz @f |
||
2137 | call change_task |
||
2138 | jmp @b |
||
2139 | @@: |
||
2140 | ;------------------------------------- |
||
2288 | clevermous | 2141 | mov [window_minimize], 2; restore window if minimized |
3534 | clevermous | 2142 | call wakeup_osloop |
2288 | clevermous | 2143 | |
2144 | movzx esi, word [WIN_STACK + ecx*2] |
||
8866 | rgimad | 2145 | cmp esi, [thread_count] |
2288 | clevermous | 2146 | je .nowindowactivate; already active |
2147 | |||
2148 | mov edi, ecx |
||
2149 | shl edi, 5 |
||
2150 | add edi, window_data |
||
2151 | movzx esi, word [WIN_STACK + ecx * 2] |
||
2152 | lea esi, [WIN_POS + esi * 2] |
||
2153 | call waredraw |
||
2154 | .nowindowactivate: |
||
2155 | ret |
||
2156 | ;------------------------------------------------------------------------------ |
||
5865 | GerdtR | 2157 | align 4 |
5836 | GerdtR | 2158 | sysfn_zmodif: |
2159 | ;18,25,1 - get z_modif |
||
2160 | ;18,25,2 - set z_modif |
||
2161 | ;edx = -1(for current task) or TID |
||
2162 | ;esi(for 2) = new value z_modif |
||
2163 | ;return: |
||
2164 | ;1: eax = z_modif |
||
2165 | ;2: eax=0(fail),1(success) for set z_modif |
||
2166 | |||
2167 | cmp edx, -1 |
||
2168 | jne @f |
||
8869 | rgimad | 2169 | mov edx, [current_slot_idx] |
5836 | GerdtR | 2170 | @@: |
8866 | rgimad | 2171 | cmp edx, [thread_count] |
5865 | GerdtR | 2172 | ja .fail |
5836 | GerdtR | 2173 | cmp edx, 1 |
5865 | GerdtR | 2174 | je .fail |
5836 | GerdtR | 2175 | |
5865 | GerdtR | 2176 | mov eax, edx |
5836 | GerdtR | 2177 | shl edx, 5 |
2178 | |||
9709 | Doczom | 2179 | cmp [edx*8 + SLOT_BASE + APPDATA.state], TSTATE_FREE |
5865 | GerdtR | 2180 | je .fail |
5836 | GerdtR | 2181 | |
2182 | cmp ecx, 1 |
||
2183 | jnz .set_zmod |
||
2184 | |||
2185 | mov al, [edx + window_data + WDATA.z_modif] |
||
5865 | GerdtR | 2186 | jmp .exit |
5836 | GerdtR | 2187 | |
2188 | .set_zmod: |
||
2189 | cmp ecx, 2 |
||
5865 | GerdtR | 2190 | jnz .fail |
5836 | GerdtR | 2191 | |
5865 | GerdtR | 2192 | mov ebx, esi |
2193 | mov esi, eax |
||
5836 | GerdtR | 2194 | |
5865 | GerdtR | 2195 | cmp bl, ZPOS_ALWAYS_TOP |
2196 | jg .fail |
||
5836 | GerdtR | 2197 | |
5865 | GerdtR | 2198 | mov [edx + window_data + WDATA.z_modif], bl |
5836 | GerdtR | 2199 | |
2200 | mov eax, [edx + window_data + WDATA.box.left] |
||
2201 | mov ebx, [edx + window_data + WDATA.box.top] |
||
2202 | mov ecx, [edx + window_data + WDATA.box.width] |
||
2203 | mov edx, [edx + window_data + WDATA.box.height] |
||
2204 | add ecx, eax |
||
2205 | add edx, ebx |
||
5865 | GerdtR | 2206 | call window._.set_screen |
5836 | GerdtR | 2207 | call window._.set_top_wnd |
5865 | GerdtR | 2208 | call window._.redraw_top_wnd |
5836 | GerdtR | 2209 | |
5865 | GerdtR | 2210 | shl esi, 5 |
2211 | mov [esi + window_data + WDATA.fl_redraw], 1 |
||
2212 | |||
2213 | |||
5836 | GerdtR | 2214 | mov eax, 1 |
5865 | GerdtR | 2215 | jmp .exit |
2216 | .fail: |
||
2217 | xor eax, eax |
||
5836 | GerdtR | 2218 | .exit: |
2219 | mov [esp+32], eax |
||
2220 | ret |
||
2221 | |||
2222 | ;------------------------------------------------------------------------------ |
||
2288 | clevermous | 2223 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
9590 | Doczom | 2224 | ;mov eax, [TASK_TABLE+32+TASKDATA.cpu_usage] |
2225 | mov eax, [SLOT_BASE+APPDATA.cpu_usage] |
||
2288 | clevermous | 2226 | mov [esp+32], eax |
2227 | ret |
||
2228 | ;------------------------------------------------------------------------------ |
||
2229 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
||
3481 | Serge | 2230 | mov eax, dword [cpu_freq] |
2288 | clevermous | 2231 | mov [esp+32], eax |
2232 | ret |
||
2233 | ;------------------------------------------------------------------------------ |
||
3481 | Serge | 2234 | get_cpu_freq: |
2235 | mov eax, dword [cpu_freq] |
||
2236 | mov edx, dword [cpu_freq+4] |
||
2237 | ret |
||
9268 | Doczom | 2238 | ; SAVE ramdisk to /hd/1/kolibri.img |
2288 | clevermous | 2239 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2240 | include 'blkdev/rdsave.inc' |
||
2241 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
||
2242 | ;------------------------------------------------------------------------------ |
||
2243 | align 4 |
||
2244 | sysfn_getactive: ; 18.7 = get active window |
||
8866 | rgimad | 2245 | mov eax, [thread_count] |
2288 | clevermous | 2246 | movzx eax, word [WIN_POS + eax*2] |
2247 | mov [esp+32], eax |
||
2248 | ret |
||
2249 | ;------------------------------------------------------------------------------ |
||
2250 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
||
2251 | ; cmp ecx,1 |
||
2252 | dec ecx |
||
2253 | jnz nogetsoundflag |
||
2254 | movzx eax, byte [sound_flag]; get sound_flag |
||
2255 | mov [esp+32], eax |
||
2256 | ret |
||
2257 | nogetsoundflag: |
||
2258 | ; cmp ecx,2 |
||
2259 | dec ecx |
||
2260 | jnz nosoundflag |
||
2261 | xor byte [sound_flag], 1 |
||
2262 | nosoundflag: |
||
2263 | ret |
||
2264 | ;------------------------------------------------------------------------------ |
||
2265 | sysfn_minimize: ; 18.10 = minimize window |
||
2266 | mov [window_minimize], 1 |
||
3534 | clevermous | 2267 | call wakeup_osloop |
2288 | clevermous | 2268 | ret |
2269 | ;------------------------------------------------------------------------------ |
||
2270 | align 4 |
||
2271 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
||
2272 | dec ecx |
||
4641 | mario79 | 2273 | jnz .exit |
2274 | .small_table: |
||
8598 | rgimad | 2275 | stdcall is_region_userspace, edx, DRIVE_DATA_SIZE |
9045 | dunkaist | 2276 | jnz .exit |
2288 | clevermous | 2277 | mov edi, edx |
2278 | mov esi, DRIVE_DATA |
||
4641 | mario79 | 2279 | mov ecx, DRIVE_DATA_SIZE ;10 |
2288 | clevermous | 2280 | cld |
4641 | mario79 | 2281 | rep movsb |
2282 | .exit: |
||
2288 | clevermous | 2283 | ret |
2284 | ;------------------------------------------------------------------------------ |
||
2285 | sysfn_getversion: ; 18.13 = get kernel ID and version |
||
8247 | rgimad | 2286 | ; if given memory address belongs to kernel then error |
8329 | rgimad | 2287 | stdcall is_region_userspace, ecx, version_end-version_inf |
9045 | dunkaist | 2288 | jnz .addr_error |
8247 | rgimad | 2289 | |
2288 | clevermous | 2290 | mov edi, ecx |
2291 | mov esi, version_inf |
||
2292 | mov ecx, version_end-version_inf |
||
2293 | rep movsb |
||
2294 | ret |
||
8247 | rgimad | 2295 | .addr_error: ; if given memory address is illegal |
8248 | rgimad | 2296 | mov dword [esp+32], -1 |
8247 | rgimad | 2297 | ret |
2288 | clevermous | 2298 | ;------------------------------------------------------------------------------ |
2299 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
||
2300 | ;wait retrace functions |
||
2301 | sys_wait_retrace: |
||
2302 | mov edx, 0x3da |
||
2303 | WaitRetrace_loop: |
||
2304 | in al, dx |
||
2305 | test al, 1000b |
||
2306 | jz WaitRetrace_loop |
||
2307 | and [esp+32], dword 0 |
||
2308 | ret |
||
2309 | ;------------------------------------------------------------------------------ |
||
2310 | align 4 |
||
2311 | sysfn_centermouse: ; 18.15 = mouse centered |
||
5350 | serge | 2312 | mov eax, [_display.width] |
2288 | clevermous | 2313 | shr eax, 1 |
2314 | mov [MOUSE_X], ax |
||
5350 | serge | 2315 | mov eax, [_display.height] |
2288 | clevermous | 2316 | shr eax, 1 |
2317 | mov [MOUSE_Y], ax |
||
3534 | clevermous | 2318 | call wakeup_osloop |
2288 | clevermous | 2319 | xor eax, eax |
2320 | and [esp+32], eax |
||
2321 | ret |
||
2322 | ;------------------------------------------------------------------------------ |
||
5851 | pathoswith | 2323 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2324 | cmp ecx, 8 |
||
2325 | jnc @f |
||
2326 | jmp dword [.table+ecx*4] |
||
2327 | .get_mouse_acceleration: |
||
2288 | clevermous | 2328 | xor eax, eax |
2329 | mov ax, [mouse_speed_factor] |
||
2330 | mov [esp+32], eax |
||
2331 | ret |
||
5851 | pathoswith | 2332 | .set_mouse_acceleration: |
2288 | clevermous | 2333 | mov [mouse_speed_factor], dx |
2334 | ret |
||
5851 | pathoswith | 2335 | .get_mouse_delay: |
5853 | pathoswith | 2336 | xor eax, eax |
2337 | mov al, [mouse_delay] |
||
2288 | clevermous | 2338 | mov [esp+32], eax |
2339 | ret |
||
5851 | pathoswith | 2340 | .set_mouse_delay: |
5853 | pathoswith | 2341 | mov [mouse_delay], dl |
5851 | pathoswith | 2342 | @@: |
2288 | clevermous | 2343 | ret |
5851 | pathoswith | 2344 | .set_pointer_position: |
5350 | serge | 2345 | cmp dx, word[_display.height] |
5851 | pathoswith | 2346 | jae @b |
2288 | clevermous | 2347 | rol edx, 16 |
5350 | serge | 2348 | cmp dx, word[_display.width] |
5851 | pathoswith | 2349 | jae @b |
2288 | clevermous | 2350 | mov [MOUSE_X], edx |
4381 | hidnplayr | 2351 | mov [mouse_active], 1 |
5851 | pathoswith | 2352 | jmp wakeup_osloop |
2353 | .set_mouse_button: |
||
2354 | mov [BTN_DOWN], edx |
||
2288 | clevermous | 2355 | mov [mouse_active], 1 |
5851 | pathoswith | 2356 | jmp wakeup_osloop |
2357 | .get_doubleclick_delay: |
||
2358 | xor eax, eax |
||
2359 | mov al, [mouse_doubleclick_delay] |
||
2360 | mov [esp+32], eax |
||
2288 | clevermous | 2361 | ret |
5851 | pathoswith | 2362 | .set_doubleclick_delay: |
2363 | mov [mouse_doubleclick_delay], dl |
||
2364 | ret |
||
2365 | align 4 |
||
2366 | .table: |
||
2367 | dd .get_mouse_acceleration |
||
2368 | dd .set_mouse_acceleration |
||
2369 | dd .get_mouse_delay |
||
2370 | dd .set_mouse_delay |
||
2371 | dd .set_pointer_position |
||
2372 | dd .set_mouse_button |
||
2373 | dd .get_doubleclick_delay |
||
2374 | dd .set_doubleclick_delay |
||
2288 | clevermous | 2375 | ;------------------------------------------------------------------------------ |
2376 | sysfn_getfreemem: |
||
2377 | mov eax, [pg_data.pages_free] |
||
2378 | shl eax, 2 |
||
2379 | mov [esp+32], eax |
||
2380 | ret |
||
2648 | mario79 | 2381 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2382 | sysfn_getallmem: |
2383 | mov eax, [MEM_AMOUNT] |
||
2384 | shr eax, 10 |
||
2385 | mov [esp+32], eax |
||
2386 | ret |
||
2648 | mario79 | 2387 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2388 | sysfn_pid_to_slot: |
2389 | mov eax, ecx |
||
2390 | call pid_to_slot |
||
2391 | mov [esp+32], eax |
||
2392 | ret |
||
2648 | mario79 | 2393 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2394 | sysfn_min_rest_window: |
2395 | pushad |
||
2396 | mov eax, edx ; ebx - operating |
||
2397 | shr ecx, 1 |
||
2398 | jnc @f |
||
2399 | call pid_to_slot |
||
2400 | @@: |
||
2401 | or eax, eax ; eax - number of slot |
||
2402 | jz .error |
||
2403 | cmp eax, 255 ; varify maximal slot number |
||
2404 | ja .error |
||
2405 | movzx eax, word [WIN_STACK + eax*2] |
||
2406 | shr ecx, 1 |
||
2407 | jc .restore |
||
2408 | ; .minimize: |
||
2409 | call minimize_window |
||
2410 | jmp .exit |
||
2411 | .restore: |
||
2412 | call restore_minimized_window |
||
2413 | .exit: |
||
2414 | popad |
||
2415 | xor eax, eax |
||
2416 | mov [esp+32], eax |
||
2417 | ret |
||
2418 | .error: |
||
2419 | popad |
||
2420 | xor eax, eax |
||
2421 | dec eax |
||
2422 | mov [esp+32], eax |
||
2423 | ret |
||
2648 | mario79 | 2424 | ;------------------------------------------------------------------------------ |
2425 | sysfn_min_windows: |
||
2426 | call minimize_all_window |
||
2427 | mov [esp+32], eax |
||
2428 | call change_task |
||
2429 | ret |
||
2430 | ;------------------------------------------------------------------------------ |
||
2654 | mario79 | 2431 | sysfn_set_screen_sizes: |
2432 | cmp [SCR_MODE], word 0x13 |
||
2433 | jbe .exit |
||
2434 | |||
2435 | cmp [_display.select_cursor], select_cursor |
||
2436 | jne .exit |
||
2437 | |||
2438 | cmp ecx, [display_width_standard] |
||
2439 | ja .exit |
||
2440 | |||
2441 | cmp edx, [display_height_standard] |
||
2442 | ja .exit |
||
2443 | |||
2444 | pushfd |
||
2445 | cli |
||
2446 | mov eax, ecx |
||
5351 | serge | 2447 | mov ecx, [_display.lfb_pitch] |
2654 | mario79 | 2448 | mov [_display.width], eax |
2449 | dec eax |
||
2450 | mov [_display.height], edx |
||
2451 | dec edx |
||
2452 | ; eax - new Screen_Max_X |
||
2453 | ; edx - new Screen_Max_Y |
||
2454 | mov [do_not_touch_winmap], 1 |
||
2455 | call set_screen |
||
2456 | mov [do_not_touch_winmap], 0 |
||
2457 | popfd |
||
2458 | call change_task |
||
2459 | .exit: |
||
2460 | ret |
||
2461 | ;------------------------------------------------------------------------------ |
||
2288 | clevermous | 2462 | uglobal |
2463 | screen_workarea RECT |
||
2654 | mario79 | 2464 | display_width_standard dd 0 |
2465 | display_height_standard dd 0 |
||
2466 | do_not_touch_winmap db 0 |
||
2288 | clevermous | 2467 | window_minimize db 0 |
2468 | sound_flag db 0 |
||
2654 | mario79 | 2469 | |
2288 | clevermous | 2470 | endg |
2471 | |||
9279 | Doczom | 2472 | ;UID_NONE=0 |
2473 | ;UID_KOLIBRI=2 ;russian |
||
2288 | clevermous | 2474 | |
2475 | iglobal |
||
2476 | version_inf: |
||
3454 | mario79 | 2477 | db 0,7,7,0 ; version 0.7.7.0 |
2478 | db 0 |
||
2479 | .rev dd __REV__ |
||
2288 | clevermous | 2480 | version_end: |
2481 | endg |
||
2515 | mario79 | 2482 | ;------------------------------------------------------------------------------ |
2483 | align 4 |
||
2288 | clevermous | 2484 | sys_cachetodiskette: |
2485 | cmp ebx, 1 |
||
4273 | clevermous | 2486 | jb .no_floppy_save |
2288 | clevermous | 2487 | cmp ebx, 2 |
4273 | clevermous | 2488 | ja .no_floppy_save |
2288 | clevermous | 2489 | call save_image |
4273 | clevermous | 2490 | mov [esp + 32], eax |
2491 | ret |
||
2492 | .no_floppy_save: |
||
2288 | clevermous | 2493 | mov [esp + 32], dword 1 |
2494 | ret |
||
2515 | mario79 | 2495 | ;------------------------------------------------------------------------------ |
2547 | mario79 | 2496 | |
2515 | mario79 | 2497 | align 4 |
2288 | clevermous | 2498 | sys_getkey: |
2499 | mov [esp + 32], dword 1 |
||
2500 | ; test main buffer |
||
8869 | rgimad | 2501 | mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK |
2288 | clevermous | 2502 | movzx ecx, word [WIN_STACK + ebx * 2] |
8866 | rgimad | 2503 | mov edx, [thread_count] |
2288 | clevermous | 2504 | cmp ecx, edx |
2505 | jne .finish |
||
2506 | cmp [KEY_COUNT], byte 0 |
||
2507 | je .finish |
||
4588 | mario79 | 2508 | movzx ax, byte [KEY_BUFF + 120 + 2] |
2288 | clevermous | 2509 | shl eax, 8 |
4588 | mario79 | 2510 | mov al, byte [KEY_BUFF] |
2511 | shl eax, 8 |
||
2288 | clevermous | 2512 | push eax |
2513 | dec byte [KEY_COUNT] |
||
2514 | and byte [KEY_COUNT], 127 |
||
2515 | movzx ecx, byte [KEY_COUNT] |
||
2516 | add ecx, 2 |
||
2517 | mov eax, KEY_BUFF + 1 |
||
2518 | mov ebx, KEY_BUFF |
||
2519 | call memmove |
||
4588 | mario79 | 2520 | add eax, 120 + 2 |
2521 | add ebx, 120 + 2 |
||
2522 | call memmove |
||
2288 | clevermous | 2523 | pop eax |
2515 | mario79 | 2524 | ;-------------------------------------- |
2525 | align 4 |
||
2288 | clevermous | 2526 | .ret_eax: |
2527 | mov [esp + 32], eax |
||
2528 | ret |
||
2515 | mario79 | 2529 | ;-------------------------------------- |
2530 | align 4 |
||
2288 | clevermous | 2531 | .finish: |
2532 | ; test hotkeys buffer |
||
2533 | mov ecx, hotkey_buffer |
||
2515 | mario79 | 2534 | ;-------------------------------------- |
2535 | align 4 |
||
2288 | clevermous | 2536 | @@: |
2537 | cmp [ecx], ebx |
||
2538 | jz .found |
||
2539 | add ecx, 8 |
||
2540 | cmp ecx, hotkey_buffer + 120 * 8 |
||
2541 | jb @b |
||
2542 | ret |
||
2515 | mario79 | 2543 | ;-------------------------------------- |
2544 | align 4 |
||
2288 | clevermous | 2545 | .found: |
2546 | mov ax, [ecx + 6] |
||
2547 | shl eax, 16 |
||
2548 | mov ah, [ecx + 4] |
||
2549 | mov al, 2 |
||
2550 | and dword [ecx + 4], 0 |
||
2551 | and dword [ecx], 0 |
||
2552 | jmp .ret_eax |
||
2515 | mario79 | 2553 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2554 | align 4 |
2555 | sys_getbutton: |
||
8869 | rgimad | 2556 | mov ebx, [current_slot_idx] ; TOP OF WINDOW STACK |
2288 | clevermous | 2557 | mov [esp + 32], dword 1 |
2558 | movzx ecx, word [WIN_STACK + ebx * 2] |
||
8866 | rgimad | 2559 | mov edx, [thread_count] ; less than 256 processes |
2288 | clevermous | 2560 | cmp ecx, edx |
2561 | jne .exit |
||
2562 | movzx eax, byte [BTN_COUNT] |
||
2563 | test eax, eax |
||
2564 | jz .exit |
||
2565 | mov eax, [BTN_BUFF] |
||
2566 | and al, 0xFE ; delete left button bit |
||
2567 | mov [BTN_COUNT], byte 0 |
||
2568 | mov [esp + 32], eax |
||
2515 | mario79 | 2569 | ;-------------------------------------- |
2570 | align 4 |
||
2288 | clevermous | 2571 | .exit: |
2572 | ret |
||
2515 | mario79 | 2573 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 2574 | align 4 |
2575 | sys_cpuusage: |
||
2576 | |||
2577 | ; RETURN: |
||
2578 | ; |
||
2579 | ; +00 dword process cpu usage |
||
2580 | ; +04 word position in windowing stack |
||
2581 | ; +06 word windowing stack value at current position (cpu nro) |
||
2582 | ; +10 12 bytes name |
||
2583 | ; +22 dword start in mem |
||
2584 | ; +26 dword used mem |
||
2585 | ; +30 dword PID , process idenfification number |
||
2586 | ; |
||
8246 | rgimad | 2587 | ; if given memory address belongs to kernel then error |
8329 | rgimad | 2588 | stdcall is_region_userspace, ebx, 0x4C |
9045 | dunkaist | 2589 | jnz .addr_error |
2288 | clevermous | 2590 | |
2591 | cmp ecx, -1 ; who am I ? |
||
2592 | jne .no_who_am_i |
||
8869 | rgimad | 2593 | mov ecx, [current_slot_idx] |
2288 | clevermous | 2594 | .no_who_am_i: |
2595 | cmp ecx, max_processes |
||
2596 | ja .nofillbuf |
||
2597 | |||
2598 | ; +4: word: position of the window of thread in the window stack |
||
2599 | mov ax, [WIN_STACK + ecx * 2] |
||
2600 | mov [ebx+4], ax |
||
2601 | ; +6: word: number of the thread slot, which window has in the window stack |
||
2602 | ; position ecx (has no relation to the specific thread) |
||
2603 | mov ax, [WIN_POS + ecx * 2] |
||
2604 | mov [ebx+6], ax |
||
2605 | |||
9590 | Doczom | 2606 | shl ecx, 8 ;5=32 8=256 |
2288 | clevermous | 2607 | |
2608 | ; +0: dword: memory usage |
||
9590 | Doczom | 2609 | ;mov eax, [ecx+TASK_TABLE+TASKDATA.cpu_usage] |
9592 | Doczom | 2610 | mov eax, [ecx-sizeof.APPDATA+SLOT_BASE+APPDATA.cpu_usage] |
2288 | clevermous | 2611 | mov [ebx], eax |
2612 | ; +10: 11 bytes: name of the process |
||
2613 | push ecx |
||
9591 | Doczom | 2614 | lea eax, [ecx+SLOT_BASE+APPDATA.app_name] |
2288 | clevermous | 2615 | add ebx, 10 |
2616 | mov ecx, 11 |
||
2617 | call memmove |
||
2618 | pop ecx |
||
2619 | |||
9591 | Doczom | 2620 | shr ecx, 3 |
2288 | clevermous | 2621 | ; +22: address of the process in memory |
2622 | ; +26: size of used memory - 1 |
||
2623 | push edi |
||
2624 | lea edi, [ebx+12] |
||
2625 | xor eax, eax |
||
2626 | mov edx, 0x100000*16 |
||
2627 | cmp ecx, 1 shl 5 |
||
2628 | je .os_mem |
||
5130 | serge | 2629 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
2630 | mov edx, [edx+PROC.mem_used] |
||
2288 | clevermous | 2631 | mov eax, std_application_base_address |
2632 | .os_mem: |
||
2633 | stosd |
||
2634 | lea eax, [edx-1] |
||
2635 | stosd |
||
2636 | |||
2637 | ; +30: PID/TID |
||
9613 | Doczom | 2638 | mov eax, [ecx*8 + SLOT_BASE + APPDATA.tid] |
2288 | clevermous | 2639 | stosd |
2640 | |||
2641 | ; window position and size |
||
2642 | push esi |
||
2643 | lea esi, [ecx + window_data + WDATA.box] |
||
2644 | movsd |
||
2645 | movsd |
||
2646 | movsd |
||
2647 | movsd |
||
2648 | |||
2649 | ; Process state (+50) |
||
9613 | Doczom | 2650 | movzx eax, byte [ecx*8 + SLOT_BASE + APPDATA.state] |
2288 | clevermous | 2651 | stosd |
2652 | |||
2653 | ; Window client area box |
||
2654 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
||
2655 | movsd |
||
2656 | movsd |
||
2657 | movsd |
||
2658 | movsd |
||
2659 | |||
2660 | ; Window state |
||
2661 | mov al, [ecx+window_data+WDATA.fl_wstate] |
||
2662 | stosb |
||
2663 | |||
2664 | ; Event mask (+71) |
||
9613 | Doczom | 2665 | mov EAX, dword [ecx*8 + SLOT_BASE + APPDATA.event_mask] |
2288 | clevermous | 2666 | stosd |
4286 | Serge | 2667 | |
4262 | 0CodErr | 2668 | ; Keyboard mode (+75) |
2669 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
||
4286 | Serge | 2670 | stosb |
2288 | clevermous | 2671 | |
2672 | pop esi |
||
2673 | pop edi |
||
2674 | |||
2675 | .nofillbuf: |
||
2676 | ; return number of processes |
||
2677 | |||
8866 | rgimad | 2678 | mov eax, [thread_count] |
2288 | clevermous | 2679 | mov [esp+32], eax |
2680 | ret |
||
2681 | |||
8246 | rgimad | 2682 | .addr_error: ; if given memory address is illegal |
8249 | rgimad | 2683 | mov dword [esp+32], -1 |
8246 | rgimad | 2684 | ret |
2685 | |||
2288 | clevermous | 2686 | |
9612 | Doczom | 2687 | ; redraw status |
2288 | clevermous | 2688 | align 4 |
2689 | sys_redrawstat: |
||
2690 | cmp ebx, 1 |
||
2691 | jne no_widgets_away |
||
2692 | ; buttons away |
||
8869 | rgimad | 2693 | mov ecx, [current_slot_idx] |
2288 | clevermous | 2694 | sys_newba2: |
2695 | mov edi, [BTN_ADDR] |
||
2696 | cmp [edi], dword 0 ; empty button list ? |
||
2697 | je end_of_buttons_away |
||
2698 | movzx ebx, word [edi] |
||
2699 | inc ebx |
||
2700 | mov eax, edi |
||
2701 | sys_newba: |
||
2702 | dec ebx |
||
2703 | jz end_of_buttons_away |
||
2704 | |||
2705 | add eax, 0x10 |
||
2706 | cmp cx, [eax] |
||
2707 | jnz sys_newba |
||
2708 | |||
2709 | push eax ebx ecx |
||
2710 | mov ecx, ebx |
||
2711 | inc ecx |
||
2712 | shl ecx, 4 |
||
2713 | mov ebx, eax |
||
2714 | add eax, 0x10 |
||
2715 | call memmove |
||
2716 | dec dword [edi] |
||
2717 | pop ecx ebx eax |
||
2718 | |||
2719 | jmp sys_newba2 |
||
2720 | |||
2721 | end_of_buttons_away: |
||
2722 | |||
2723 | ret |
||
2724 | |||
2725 | no_widgets_away: |
||
2726 | |||
2727 | cmp ebx, 2 |
||
2728 | jnz srl1 |
||
2729 | |||
9709 | Doczom | 2730 | mov edx, [current_slot_idx] ; return whole screen draw area for this app |
2731 | shl edx, 5 |
||
2732 | add edx, draw_data |
||
2288 | clevermous | 2733 | mov [edx + RECT.left], 0 |
2734 | mov [edx + RECT.top], 0 |
||
5350 | serge | 2735 | mov eax, [_display.width] |
2736 | dec eax |
||
2288 | clevermous | 2737 | mov [edx + RECT.right], eax |
5350 | serge | 2738 | mov eax, [_display.height] |
2739 | dec eax |
||
2288 | clevermous | 2740 | mov [edx + RECT.bottom], eax |
2741 | |||
2742 | srl1: |
||
2743 | ret |
||
2744 | |||
2745 | ;ok - 100% work |
||
2746 | ;nt - not tested |
||
2747 | ;--------------------------------------------------------------------------------------------- |
||
2748 | ;eax |
||
2749 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
||
2750 | ;1 - change task. Ret nothing. Block. ok. |
||
2751 | ;2 - performance control |
||
2752 | ; ebx |
||
2753 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
||
2754 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
||
2755 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
||
2756 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
||
2757 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
||
2758 | ;eax |
||
2759 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
2760 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
||
2761 | ;--------------------------------------------------------------------------------------------- |
||
2762 | iglobal |
||
2763 | align 4 |
||
2764 | sheduler: |
||
2765 | dd sys_sheduler.00 |
||
2766 | dd change_task |
||
2767 | dd sys_sheduler.02 |
||
2768 | dd sys_sheduler.03 |
||
2769 | dd sys_sheduler.04 |
||
2770 | endg |
||
2771 | sys_sheduler: |
||
2772 | ;rewritten by |
||
2773 | jmp dword [sheduler+ebx*4] |
||
2774 | ;.shed_counter: |
||
2775 | .00: |
||
2776 | mov eax, [context_counter] |
||
2777 | mov [esp+32], eax |
||
2778 | ret |
||
2779 | |||
2780 | .02: |
||
2781 | ;.perf_control: |
||
2782 | inc ebx ;before ebx=2, ebx=3 |
||
2783 | cmp ebx, ecx ;if ecx=3, ebx=3 |
||
2784 | jz cache_disable |
||
2785 | |||
2786 | dec ebx ;ebx=2 |
||
2787 | cmp ebx, ecx ; |
||
2788 | jz cache_enable ;if ecx=2 and ebx=2 |
||
2789 | |||
2790 | dec ebx ;ebx=1 |
||
2791 | cmp ebx, ecx |
||
2792 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
||
2793 | |||
2794 | dec ebx |
||
2795 | test ebx, ecx ;ebx=0 and ecx=0 |
||
2796 | jz modify_pce ;if ecx=0 |
||
2797 | |||
2798 | ret |
||
2799 | |||
2800 | .03: |
||
2801 | ;.rdmsr_instr: |
||
2802 | ;now counter in ecx |
||
2803 | ;(edx:eax) esi:edi => edx:esi |
||
2804 | mov eax, esi |
||
2805 | mov ecx, edx |
||
2806 | rdmsr |
||
2807 | mov [esp+32], eax |
||
2808 | mov [esp+20], edx ;ret in ebx? |
||
2809 | ret |
||
2810 | |||
2811 | .04: |
||
2812 | ;.wrmsr_instr: |
||
2813 | ;now counter in ecx |
||
2814 | ;(edx:eax) esi:edi => edx:esi |
||
2815 | ; Fast Call MSR can't be destroy |
||
3539 | clevermous | 2816 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
2817 | ; включаются/выключаются расширенные возможности |
||
2288 | clevermous | 2818 | cmp edx, MSR_SYSENTER_CS |
2819 | je @f |
||
2820 | cmp edx, MSR_SYSENTER_ESP |
||
2821 | je @f |
||
2822 | cmp edx, MSR_SYSENTER_EIP |
||
2823 | je @f |
||
2824 | cmp edx, MSR_AMD_STAR |
||
2825 | je @f |
||
2826 | |||
2827 | mov eax, esi |
||
2828 | mov ecx, edx |
||
2829 | wrmsr |
||
2830 | ; mov [esp + 32], eax |
||
2831 | ; mov [esp + 20], edx ;ret in ebx? |
||
2832 | @@: |
||
2833 | ret |
||
2834 | |||
2835 | cache_disable: |
||
2836 | mov eax, cr0 |
||
2837 | or eax, 01100000000000000000000000000000b |
||
2838 | mov cr0, eax |
||
2839 | wbinvd ;set MESI |
||
2840 | ret |
||
2841 | |||
2842 | cache_enable: |
||
2843 | mov eax, cr0 |
||
2844 | and eax, 10011111111111111111111111111111b |
||
2845 | mov cr0, eax |
||
2846 | ret |
||
2847 | |||
2848 | is_cache_enabled: |
||
2849 | mov eax, cr0 |
||
2850 | mov ebx, eax |
||
2851 | and eax, 01100000000000000000000000000000b |
||
2852 | jz cache_disabled |
||
2853 | mov [esp+32], ebx |
||
2854 | cache_disabled: |
||
2855 | mov dword [esp+32], eax;0 |
||
2856 | ret |
||
2857 | |||
2858 | modify_pce: |
||
2859 | mov eax, cr4 |
||
2860 | ; mov ebx,0 |
||
2861 | ; or bx,100000000b ;pce |
||
2862 | ; xor eax,ebx ;invert pce |
||
2863 | bts eax, 8;pce=cr4[8] |
||
2864 | mov cr4, eax |
||
2865 | mov [esp+32], eax |
||
2866 | ret |
||
2867 | ;--------------------------------------------------------------------------------------------- |
||
2868 | |||
2869 | |||
2870 | iglobal |
||
2871 | cpustring db 'CPU',0 |
||
2872 | endg |
||
2873 | |||
2874 | uglobal |
||
2875 | background_defined db 0 ; diamond, 11.04.2006 |
||
2876 | endg |
||
2513 | mario79 | 2877 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 2878 | align 4 |
2879 | checkmisc: |
||
2880 | cmp [ctrl_alt_del], 1 |
||
2881 | jne nocpustart |
||
2882 | |||
2883 | mov ebp, cpustring |
||
2884 | call fs_execute_from_sysdir |
||
2885 | |||
2886 | mov [ctrl_alt_del], 0 |
||
2513 | mario79 | 2887 | ;-------------------------------------- |
2888 | align 4 |
||
2288 | clevermous | 2889 | nocpustart: |
2890 | cmp [mouse_active], 1 |
||
2891 | jne mouse_not_active |
||
2892 | mov [mouse_active], 0 |
||
2411 | Serge | 2893 | |
2288 | clevermous | 2894 | xor edi, edi |
9709 | Doczom | 2895 | mov ebx, window_data |
2411 | Serge | 2896 | |
8866 | rgimad | 2897 | mov ecx, [thread_count] |
2408 | Serge | 2898 | movzx eax, word [WIN_POS + ecx*2] ; active window |
2899 | shl eax, 8 |
||
2414 | Serge | 2900 | push eax |
2408 | Serge | 2901 | |
2414 | Serge | 2902 | movzx eax, word [MOUSE_X] |
2903 | movzx edx, word [MOUSE_Y] |
||
2513 | mario79 | 2904 | ;-------------------------------------- |
2408 | Serge | 2905 | align 4 |
2906 | .set_mouse_event: |
||
8093 | dunkaist | 2907 | add edi, sizeof.APPDATA |
9709 | Doczom | 2908 | add ebx, sizeof.WDATA |
9614 | Doczom | 2909 | test [edi + SLOT_BASE + APPDATA.event_mask], 0x80000000 |
2414 | Serge | 2910 | jz .pos_filter |
2911 | |||
2912 | cmp edi, [esp] ; skip if filtration active |
||
2913 | jne .skip |
||
2513 | mario79 | 2914 | ;-------------------------------------- |
2915 | align 4 |
||
2414 | Serge | 2916 | .pos_filter: |
9614 | Doczom | 2917 | test [edi + SLOT_BASE + APPDATA.event_mask], 0x40000000 |
2411 | Serge | 2918 | jz .set |
2288 | clevermous | 2919 | |
9709 | Doczom | 2920 | mov esi, [ebx + WDATA.box.left] |
2414 | Serge | 2921 | cmp eax, esi |
2922 | jb .skip |
||
9709 | Doczom | 2923 | add esi, [ebx + WDATA.box.width] |
2414 | Serge | 2924 | cmp eax, esi |
2925 | ja .skip |
||
2926 | |||
9709 | Doczom | 2927 | mov esi, [ebx + WDATA.box.top] |
2414 | Serge | 2928 | cmp edx, esi |
2929 | jb .skip |
||
9709 | Doczom | 2930 | add esi, [ebx + WDATA.box.height] |
2414 | Serge | 2931 | cmp edx, esi |
2932 | ja .skip |
||
2513 | mario79 | 2933 | ;-------------------------------------- |
2934 | align 4 |
||
2411 | Serge | 2935 | .set: |
8876 | rgimad | 2936 | or [edi+SLOT_BASE+APPDATA.occurred_events], EVENT_MOUSE |
2513 | mario79 | 2937 | ;-------------------------------------- |
2938 | align 4 |
||
2411 | Serge | 2939 | .skip: |
2408 | Serge | 2940 | loop .set_mouse_event |
2941 | |||
2414 | Serge | 2942 | pop eax |
2513 | mario79 | 2943 | ;-------------------------------------- |
2944 | align 4 |
||
2288 | clevermous | 2945 | mouse_not_active: |
6585 | pathoswith | 2946 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
2288 | clevermous | 2947 | jz nobackgr |
2524 | mario79 | 2948 | |
2288 | clevermous | 2949 | cmp [background_defined], 0 |
2950 | jz nobackgr |
||
2513 | mario79 | 2951 | ;-------------------------------------- |
2952 | align 4 |
||
3536 | clevermous | 2953 | backgr: |
2537 | mario79 | 2954 | mov eax, [draw_data+32 + RECT.left] |
2955 | shl eax, 16 |
||
2956 | add eax, [draw_data+32 + RECT.right] |
||
2957 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
||
2958 | |||
2959 | mov eax, [draw_data+32 + RECT.top] |
||
2960 | shl eax, 16 |
||
2961 | add eax, [draw_data+32 + RECT.bottom] |
||
2962 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
||
2963 | |||
2288 | clevermous | 2964 | call drawbackground |
2580 | mario79 | 2965 | ; DEBUGF 1, "K : drawbackground\n" |
2620 | mario79 | 2966 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
2967 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
||
2513 | mario79 | 2968 | ;--------- set event 5 start ---------- |
2969 | push ecx edi |
||
2970 | xor edi, edi |
||
8866 | rgimad | 2971 | mov ecx, [thread_count] |
2513 | mario79 | 2972 | ;-------------------------------------- |
2973 | align 4 |
||
2974 | set_bgr_event: |
||
8093 | dunkaist | 2975 | add edi, sizeof.APPDATA |
3536 | clevermous | 2976 | mov eax, [BG_Rect_X_left_right] |
2977 | mov edx, [BG_Rect_Y_top_bottom] |
||
2978 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
||
2979 | jz .set |
||
2980 | .join: |
||
3611 | clevermous | 2981 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
2982 | jae @f |
||
2983 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
||
2984 | @@: |
||
2985 | shr eax, 16 |
||
3536 | clevermous | 2986 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
2987 | jbe @f |
||
2988 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
||
2989 | @@: |
||
3611 | clevermous | 2990 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3536 | clevermous | 2991 | jae @f |
3611 | clevermous | 2992 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3536 | clevermous | 2993 | @@: |
3611 | clevermous | 2994 | shr edx, 16 |
3536 | clevermous | 2995 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
2996 | jbe @f |
||
2997 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
||
2998 | @@: |
||
2999 | jmp .common |
||
3000 | .set: |
||
3001 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
||
3002 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
||
3003 | .common: |
||
8876 | rgimad | 3004 | or [edi+SLOT_BASE+APPDATA.occurred_events], EVENT_BACKGROUND |
2513 | mario79 | 3005 | loop set_bgr_event |
3006 | pop edi ecx |
||
3007 | ;--------- set event 5 stop ----------- |
||
6585 | pathoswith | 3008 | dec [REDRAW_BACKGROUND] ; got new update request? |
3536 | clevermous | 3009 | jnz backgr |
2513 | mario79 | 3010 | |
3536 | clevermous | 3011 | xor eax, eax |
2288 | clevermous | 3012 | mov [draw_data+32 + RECT.left], eax |
3013 | mov [draw_data+32 + RECT.top], eax |
||
3014 | mov [draw_data+32 + RECT.right], eax |
||
3015 | mov [draw_data+32 + RECT.bottom], eax |
||
2513 | mario79 | 3016 | ;-------------------------------------- |
3017 | align 4 |
||
2288 | clevermous | 3018 | nobackgr: |
2513 | mario79 | 3019 | ; system shutdown request |
2288 | clevermous | 3020 | cmp [SYS_SHUTDOWN], byte 0 |
3021 | je noshutdown |
||
3022 | |||
3023 | mov edx, [shutdown_processes] |
||
3024 | |||
3025 | cmp [SYS_SHUTDOWN], dl |
||
3325 | clevermous | 3026 | jne noshutdown |
2288 | clevermous | 3027 | |
3028 | lea ecx, [edx-1] |
||
9709 | Doczom | 3029 | mov edx, SLOT_BASE + sizeof.APPDATA ;OS_BASE+0x3040 |
3325 | clevermous | 3030 | jecxz no_mark_system_shutdown |
2513 | mario79 | 3031 | ;-------------------------------------- |
3032 | align 4 |
||
2288 | clevermous | 3033 | markz: |
3296 | clevermous | 3034 | push ecx edx |
9709 | Doczom | 3035 | cmp [edx + APPDATA.state], TSTATE_FREE |
3325 | clevermous | 3036 | jz .nokill |
5130 | serge | 3037 | cmp [edx+APPDATA.process], sys_proc |
3325 | clevermous | 3038 | jz .nokill |
3296 | clevermous | 3039 | call request_terminate |
3325 | clevermous | 3040 | jmp .common |
3041 | .nokill: |
||
3042 | dec byte [SYS_SHUTDOWN] |
||
3043 | xor eax, eax |
||
3044 | .common: |
||
3296 | clevermous | 3045 | pop edx ecx |
3046 | test eax, eax |
||
3047 | jz @f |
||
9709 | Doczom | 3048 | mov [edx + APPDATA.state], TSTATE_ZOMBIE |
3296 | clevermous | 3049 | @@: |
9709 | Doczom | 3050 | add edx, sizeof.APPDATA |
2288 | clevermous | 3051 | loop markz |
3534 | clevermous | 3052 | call wakeup_osloop |
2513 | mario79 | 3053 | ;-------------------------------------- |
3054 | align 4 |
||
2288 | clevermous | 3055 | @@: |
2513 | mario79 | 3056 | no_mark_system_shutdown: |
2288 | clevermous | 3057 | dec byte [SYS_SHUTDOWN] |
3058 | je system_shutdown |
||
2513 | mario79 | 3059 | ;-------------------------------------- |
3060 | align 4 |
||
2288 | clevermous | 3061 | noshutdown: |
8866 | rgimad | 3062 | mov eax, [thread_count] ; termination |
9709 | Doczom | 3063 | mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state |
2288 | clevermous | 3064 | mov esi, 1 |
2513 | mario79 | 3065 | ;-------------------------------------- |
3066 | align 4 |
||
2288 | clevermous | 3067 | newct: |
3068 | mov cl, [ebx] |
||
3069 | cmp cl, byte 3 |
||
3325 | clevermous | 3070 | jz .terminate |
2513 | mario79 | 3071 | |
2288 | clevermous | 3072 | cmp cl, byte 4 |
3325 | clevermous | 3073 | jnz .noterminate |
3074 | .terminate: |
||
3075 | pushad |
||
3493 | mario79 | 3076 | mov ecx, eax |
3077 | shl ecx, 8 |
||
3078 | add ecx, SLOT_BASE |
||
3079 | call restore_default_cursor_before_killing |
||
3080 | popad |
||
3081 | |||
3082 | pushad |
||
3325 | clevermous | 3083 | call terminate |
3084 | popad |
||
3085 | cmp byte [SYS_SHUTDOWN], 0 |
||
3086 | jz .noterminate |
||
3087 | dec byte [SYS_SHUTDOWN] |
||
3088 | je system_shutdown |
||
2288 | clevermous | 3089 | |
3325 | clevermous | 3090 | .noterminate: |
9709 | Doczom | 3091 | add ebx, sizeof.APPDATA |
2288 | clevermous | 3092 | inc esi |
3093 | dec eax |
||
3094 | jnz newct |
||
3095 | ret |
||
2513 | mario79 | 3096 | ;----------------------------------------------------------------------------- |
3097 | align 4 |
||
2288 | clevermous | 3098 | redrawscreen: |
3099 | ; eax , if process window_data base is eax, do not set flag/limits |
||
3100 | |||
3101 | pushad |
||
3102 | push eax |
||
3103 | |||
3104 | ;;; mov ebx,2 |
||
3105 | ;;; call delay_hs |
||
3106 | |||
3107 | ;mov ecx,0 ; redraw flags for apps |
||
3108 | xor ecx, ecx |
||
2513 | mario79 | 3109 | ;-------------------------------------- |
3110 | align 4 |
||
3111 | newdw2: |
||
2288 | clevermous | 3112 | inc ecx |
3113 | push ecx |
||
3114 | |||
3115 | mov eax, ecx |
||
3116 | shl eax, 5 |
||
3117 | add eax, window_data |
||
3118 | |||
3119 | cmp eax, [esp+4] |
||
3120 | je not_this_task |
||
3121 | ; check if window in redraw area |
||
3122 | mov edi, eax |
||
3123 | |||
3124 | cmp ecx, 1 ; limit for background |
||
3125 | jz bgli |
||
3126 | |||
5870 | GerdtR | 3127 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3128 | test eax, eax |
||
3129 | jz @f |
||
3130 | mov al, [eax + WDATA.z_modif] |
||
3131 | cmp [edi + WDATA.z_modif], al |
||
3132 | jg ricino |
||
3133 | @@: |
||
3134 | |||
2288 | clevermous | 3135 | mov eax, [edi + WDATA.box.left] |
3136 | mov ebx, [edi + WDATA.box.top] |
||
3137 | |||
3138 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
||
3139 | cmp ecx, ebx |
||
3140 | jb ricino |
||
3141 | |||
3142 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
||
3143 | cmp ecx, eax |
||
3144 | jb ricino |
||
3145 | |||
3146 | mov eax, [edi + WDATA.box.left] |
||
3147 | mov ebx, [edi + WDATA.box.top] |
||
3148 | mov ecx, [edi + WDATA.box.width] |
||
3149 | mov edx, [edi + WDATA.box.height] |
||
3150 | add ecx, eax |
||
3151 | add edx, ebx |
||
3152 | |||
3153 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
||
3154 | cmp edx, eax |
||
3155 | jb ricino |
||
3156 | |||
3157 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
||
3158 | cmp ecx, eax |
||
3159 | jb ricino |
||
2513 | mario79 | 3160 | ;-------------------------------------- |
3161 | align 4 |
||
3162 | bgli: |
||
2288 | clevermous | 3163 | cmp dword[esp], 1 |
3164 | jnz .az |
||
2513 | mario79 | 3165 | |
6585 | pathoswith | 3166 | cmp [REDRAW_BACKGROUND], 0 |
2288 | clevermous | 3167 | jz .az |
2513 | mario79 | 3168 | |
2288 | clevermous | 3169 | mov dl, 0 |
3170 | lea eax, [edi+draw_data-window_data] |
||
3171 | mov ebx, [draw_limits.left] |
||
3172 | cmp ebx, [eax+RECT.left] |
||
3173 | jae @f |
||
2513 | mario79 | 3174 | |
2288 | clevermous | 3175 | mov [eax+RECT.left], ebx |
3176 | mov dl, 1 |
||
2513 | mario79 | 3177 | ;-------------------------------------- |
3178 | align 4 |
||
3179 | @@: |
||
2288 | clevermous | 3180 | mov ebx, [draw_limits.top] |
3181 | cmp ebx, [eax+RECT.top] |
||
3182 | jae @f |
||
2513 | mario79 | 3183 | |
2288 | clevermous | 3184 | mov [eax+RECT.top], ebx |
3185 | mov dl, 1 |
||
2513 | mario79 | 3186 | ;-------------------------------------- |
3187 | align 4 |
||
3188 | @@: |
||
2288 | clevermous | 3189 | mov ebx, [draw_limits.right] |
3190 | cmp ebx, [eax+RECT.right] |
||
3191 | jbe @f |
||
2513 | mario79 | 3192 | |
2288 | clevermous | 3193 | mov [eax+RECT.right], ebx |
3194 | mov dl, 1 |
||
2513 | mario79 | 3195 | ;-------------------------------------- |
3196 | align 4 |
||
3197 | @@: |
||
2288 | clevermous | 3198 | mov ebx, [draw_limits.bottom] |
3199 | cmp ebx, [eax+RECT.bottom] |
||
3200 | jbe @f |
||
2513 | mario79 | 3201 | |
2288 | clevermous | 3202 | mov [eax+RECT.bottom], ebx |
3203 | mov dl, 1 |
||
2513 | mario79 | 3204 | ;-------------------------------------- |
3205 | align 4 |
||
3206 | @@: |
||
6585 | pathoswith | 3207 | add [REDRAW_BACKGROUND], dl |
3534 | clevermous | 3208 | call wakeup_osloop |
2288 | clevermous | 3209 | jmp newdw8 |
2513 | mario79 | 3210 | ;-------------------------------------- |
3211 | align 4 |
||
3212 | .az: |
||
2288 | clevermous | 3213 | mov eax, edi |
3214 | add eax, draw_data-window_data |
||
3215 | |||
3216 | mov ebx, [draw_limits.left] ; set limits |
||
3217 | mov [eax + RECT.left], ebx |
||
3218 | mov ebx, [draw_limits.top] |
||
3219 | mov [eax + RECT.top], ebx |
||
3220 | mov ebx, [draw_limits.right] |
||
3221 | mov [eax + RECT.right], ebx |
||
3222 | mov ebx, [draw_limits.bottom] |
||
3223 | mov [eax + RECT.bottom], ebx |
||
3224 | |||
3225 | sub eax, draw_data-window_data |
||
3226 | |||
3227 | cmp dword [esp], 1 |
||
3228 | jne nobgrd |
||
6585 | pathoswith | 3229 | inc [REDRAW_BACKGROUND] |
3534 | clevermous | 3230 | call wakeup_osloop |
2513 | mario79 | 3231 | ;-------------------------------------- |
3232 | align 4 |
||
3233 | newdw8: |
||
3234 | nobgrd: |
||
3936 | mario79 | 3235 | ;-------------------------------------- |
3236 | push eax edi ebp |
||
3237 | mov edi, [esp+12] |
||
3238 | cmp edi, 1 |
||
3239 | je .found |
||
2288 | clevermous | 3240 | |
3936 | mario79 | 3241 | mov eax, [draw_limits.left] |
3242 | mov ebx, [draw_limits.top] |
||
3243 | mov ecx, [draw_limits.right] |
||
3244 | sub ecx, eax |
||
3245 | test ecx, ecx |
||
3246 | jz .not_found |
||
3247 | |||
3248 | mov edx, [draw_limits.bottom] |
||
3249 | sub edx, ebx |
||
3250 | test edx, edx |
||
3251 | jz .not_found |
||
3252 | |||
3253 | ; eax - x, ebx - y |
||
3254 | ; ecx - size x, edx - size y |
||
3255 | add ebx, edx |
||
3256 | ;-------------------------------------- |
||
3257 | align 4 |
||
3258 | .start_y: |
||
3259 | push ecx |
||
3260 | ;-------------------------------------- |
||
3261 | align 4 |
||
3262 | .start_x: |
||
3263 | add eax, ecx |
||
3264 | mov ebp, [d_width_calc_area + ebx*4] |
||
5351 | serge | 3265 | add ebp, [_display.win_map] |
3936 | mario79 | 3266 | movzx ebp, byte[eax+ebp] ; get value for current point |
3267 | cmp ebp, edi |
||
3268 | jne @f |
||
3269 | |||
3270 | pop ecx |
||
3271 | jmp .found |
||
3272 | ;-------------------------------------- |
||
3273 | align 4 |
||
3274 | @@: |
||
3275 | sub eax, ecx |
||
3276 | |||
3277 | dec ecx |
||
9221 | dunkaist | 3278 | jns .start_x |
3936 | mario79 | 3279 | |
3280 | pop ecx |
||
3281 | dec ebx |
||
3282 | dec edx |
||
9221 | dunkaist | 3283 | jns .start_y |
3936 | mario79 | 3284 | ;-------------------------------------- |
3285 | align 4 |
||
3286 | .not_found: |
||
3287 | pop ebp edi eax |
||
3288 | jmp ricino |
||
3289 | ;-------------------------------------- |
||
3290 | align 4 |
||
3291 | .found: |
||
3292 | pop ebp edi eax |
||
3293 | |||
2288 | clevermous | 3294 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
2513 | mario79 | 3295 | ;-------------------------------------- |
3296 | align 4 |
||
3297 | ricino: |
||
3298 | not_this_task: |
||
2288 | clevermous | 3299 | pop ecx |
3300 | |||
8866 | rgimad | 3301 | cmp ecx, [thread_count] |
2288 | clevermous | 3302 | jle newdw2 |
3303 | |||
3304 | pop eax |
||
3305 | popad |
||
3306 | ret |
||
2513 | mario79 | 3307 | ;----------------------------------------------------------------------------- |
3308 | align 4 |
||
2288 | clevermous | 3309 | calculatebackground: ; background |
5351 | serge | 3310 | mov edi, [_display.win_map] ; set os to use all pixels |
2288 | clevermous | 3311 | mov eax, 0x01010101 |
5351 | serge | 3312 | mov ecx, [_display.win_map_size] |
2288 | clevermous | 3313 | shr ecx, 2 |
3314 | rep stosd |
||
6585 | pathoswith | 3315 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3316 | mov [REDRAW_BACKGROUND], 0 |
||
2288 | clevermous | 3317 | ret |
2513 | mario79 | 3318 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3319 | uglobal |
3320 | imax dd 0x0 |
||
3321 | endg |
||
2513 | mario79 | 3322 | ;----------------------------------------------------------------------------- |
3323 | align 4 |
||
2288 | clevermous | 3324 | delay_ms: ; delay in 1/1000 sec |
8139 | dunkaist | 3325 | pushad |
3326 | |||
3327 | cmp [hpet_base], 0 |
||
3328 | jz .no_hpet |
||
3329 | mov eax, esi |
||
8176 | dunkaist | 3330 | mov edx, 1_000_000 ; ms to ns |
8139 | dunkaist | 3331 | mul edx |
3332 | mov ebx, edx |
||
3333 | mov ecx, eax |
||
3334 | |||
2288 | clevermous | 3335 | push ecx |
8139 | dunkaist | 3336 | call get_clock_ns |
3337 | pop ecx |
||
3338 | mov edi, edx |
||
3339 | mov esi, eax |
||
3340 | .wait: |
||
3341 | push ecx |
||
3342 | call get_clock_ns |
||
3343 | pop ecx |
||
3344 | sub eax, esi |
||
3345 | sbb edx, edi |
||
3346 | sub eax, ecx |
||
3347 | sbb edx, ebx |
||
3348 | jc .wait |
||
3349 | jmp .done |
||
2288 | clevermous | 3350 | |
8139 | dunkaist | 3351 | .no_hpet: |
2288 | clevermous | 3352 | mov ecx, esi |
3353 | ; |
||
3354 | imul ecx, 33941 |
||
3355 | shr ecx, 9 |
||
3356 | ; |
||
3357 | |||
3358 | in al, 0x61 |
||
3359 | and al, 0x10 |
||
3360 | mov ah, al |
||
3361 | cld |
||
8139 | dunkaist | 3362 | |
3363 | .cnt1: |
||
2288 | clevermous | 3364 | in al, 0x61 |
3365 | and al, 0x10 |
||
3366 | cmp al, ah |
||
8139 | dunkaist | 3367 | jz .cnt1 |
2288 | clevermous | 3368 | |
3369 | mov ah, al |
||
8139 | dunkaist | 3370 | loop .cnt1 |
2288 | clevermous | 3371 | |
8139 | dunkaist | 3372 | .done: |
3373 | popad |
||
2288 | clevermous | 3374 | ret |
2513 | mario79 | 3375 | ;----------------------------------------------------------------------------- |
2411 | Serge | 3376 | align 4 |
2288 | clevermous | 3377 | set_app_param: |
9612 | Doczom | 3378 | mov edi, [current_slot] |
9614 | Doczom | 3379 | xchg ebx, [edi + APPDATA.event_mask] ; set new event mask |
3380 | mov [esp+32], ebx ; return old mask value |
||
2288 | clevermous | 3381 | ret |
2513 | mario79 | 3382 | ;----------------------------------------------------------------------------- |
3303 | clevermous | 3383 | |
3384 | ; this is for syscall |
||
3385 | proc delay_hs_unprotected |
||
3386 | call unprotect_from_terminate |
||
3387 | call delay_hs |
||
3388 | call protect_from_terminate |
||
3389 | ret |
||
3390 | endp |
||
3391 | |||
3597 | Serge | 3392 | if 1 |
2513 | mario79 | 3393 | align 4 |
2288 | clevermous | 3394 | delay_hs: ; delay in 1/100 secs |
3395 | ; ebx = delay time |
||
3396 | |||
3595 | Serge | 3397 | pushad |
3398 | push ebx |
||
3399 | xor esi, esi |
||
3400 | mov ecx, MANUAL_DESTROY |
||
3401 | call create_event |
||
3402 | test eax, eax |
||
3403 | jz .done |
||
2288 | clevermous | 3404 | |
3595 | Serge | 3405 | mov ebx, edx |
3406 | mov ecx, [esp] |
||
3597 | Serge | 3407 | push edx |
3595 | Serge | 3408 | push eax |
3409 | call wait_event_timeout |
||
3410 | pop eax |
||
3597 | Serge | 3411 | pop ebx |
3595 | Serge | 3412 | call destroy_event |
3413 | .done: |
||
3414 | add esp, 4 |
||
3415 | popad |
||
2288 | clevermous | 3416 | ret |
3596 | Serge | 3417 | |
3418 | else |
||
3419 | |||
3420 | align 4 |
||
3421 | delay_hs: ; delay in 1/100 secs |
||
3422 | ; ebx = delay time |
||
3423 | push ecx |
||
3424 | push edx |
||
3425 | |||
3426 | mov edx, [timer_ticks] |
||
3427 | ;-------------------------------------- |
||
3428 | align 4 |
||
3429 | newtic: |
||
3430 | mov ecx, [timer_ticks] |
||
3431 | sub ecx, edx |
||
3432 | cmp ecx, ebx |
||
3433 | jae zerodelay |
||
3434 | |||
3435 | call change_task |
||
3436 | |||
3437 | jmp newtic |
||
3438 | ;-------------------------------------- |
||
3439 | align 4 |
||
3440 | zerodelay: |
||
3441 | pop edx |
||
3442 | pop ecx |
||
3443 | ret |
||
3444 | end if |
||
3445 | |||
2513 | mario79 | 3446 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3447 | align 16 ;very often call this subrutine |
3448 | memmove: ; memory move in bytes |
||
3449 | ; eax = from |
||
3450 | ; ebx = to |
||
3451 | ; ecx = no of bytes |
||
3452 | test ecx, ecx |
||
3453 | jle .ret |
||
3454 | |||
3455 | push esi edi ecx |
||
3456 | |||
3457 | mov edi, ebx |
||
3458 | mov esi, eax |
||
3459 | |||
3460 | test ecx, not 11b |
||
3461 | jz @f |
||
3462 | |||
3463 | push ecx |
||
3464 | shr ecx, 2 |
||
3465 | rep movsd |
||
3466 | pop ecx |
||
3467 | and ecx, 11b |
||
3468 | jz .finish |
||
2513 | mario79 | 3469 | ;-------------------------------------- |
3470 | align 4 |
||
3471 | @@: |
||
2288 | clevermous | 3472 | rep movsb |
2513 | mario79 | 3473 | ;-------------------------------------- |
3474 | align 4 |
||
3475 | .finish: |
||
2288 | clevermous | 3476 | pop ecx edi esi |
2513 | mario79 | 3477 | ;-------------------------------------- |
3478 | align 4 |
||
3479 | .ret: |
||
2288 | clevermous | 3480 | ret |
2513 | mario79 | 3481 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3482 | |
3483 | align 4 |
||
3484 | set_io_access_rights: |
||
3485 | push edi eax |
||
3486 | mov edi, tss._io_map_0 |
||
3487 | ; mov ecx,eax |
||
3488 | ; and ecx,7 ; offset in byte |
||
3489 | ; shr eax,3 ; number of byte |
||
3490 | ; add edi,eax |
||
3491 | ; mov ebx,1 |
||
3492 | ; shl ebx,cl |
||
3493 | test ebp, ebp |
||
3494 | ; cmp ebp,0 ; enable access - ebp = 0 |
||
3495 | jnz .siar1 |
||
3496 | ; not ebx |
||
3497 | ; and [edi],byte bl |
||
3498 | btr [edi], eax |
||
3499 | pop eax edi |
||
3500 | ret |
||
3501 | .siar1: |
||
3502 | bts [edi], eax |
||
3503 | ; or [edi],byte bl ; disable access - ebp = 1 |
||
3504 | pop eax edi |
||
3505 | ret |
||
9279 | Doczom | 3506 | |
3507 | align 4 |
||
3508 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
||
3509 | |||
3510 | call r_f_port_area |
||
3511 | mov [esp+32], eax |
||
3512 | ret |
||
3513 | |||
2288 | clevermous | 3514 | ;reserve/free group of ports |
3515 | ; * eax = 46 - number function |
||
3516 | ; * ebx = 0 - reserve, 1 - free |
||
3517 | ; * ecx = number start arrea of ports |
||
3518 | ; * edx = number end arrea of ports (include last number of port) |
||
3519 | ;Return value: |
||
3520 | ; * eax = 0 - succesful |
||
3521 | ; * eax = 1 - error |
||
3522 | ; * The system has reserve this ports: |
||
3523 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
||
3524 | ;destroys eax,ebx, ebp |
||
3525 | r_f_port_area: |
||
3526 | |||
3527 | test ebx, ebx |
||
3528 | jnz free_port_area |
||
3529 | ; je r_port_area |
||
3530 | ; jmp free_port_area |
||
3531 | |||
3532 | ; r_port_area: |
||
3533 | |||
3534 | ; pushad |
||
3535 | |||
3536 | cmp ecx, edx ; beginning > end ? |
||
3537 | ja rpal1 |
||
3538 | cmp edx, 65536 |
||
3539 | jae rpal1 |
||
3540 | mov eax, [RESERVED_PORTS] |
||
3541 | test eax, eax ; no reserved areas ? |
||
3542 | je rpal2 |
||
3543 | cmp eax, 255 ; max reserved |
||
3544 | jae rpal1 |
||
3545 | rpal3: |
||
3546 | mov ebx, eax |
||
3547 | shl ebx, 4 |
||
3548 | add ebx, RESERVED_PORTS |
||
3549 | cmp ecx, [ebx+8] |
||
3550 | ja rpal4 |
||
3551 | cmp edx, [ebx+4] |
||
3552 | jae rpal1 |
||
3553 | ; jb rpal4 |
||
3554 | ; jmp rpal1 |
||
3555 | rpal4: |
||
3556 | dec eax |
||
3557 | jnz rpal3 |
||
3558 | jmp rpal2 |
||
3559 | rpal1: |
||
3560 | ; popad |
||
3561 | ; mov eax,1 |
||
3562 | xor eax, eax |
||
3563 | inc eax |
||
3564 | ret |
||
3565 | rpal2: |
||
3566 | ; popad |
||
3567 | ; enable port access at port IO map |
||
3568 | cli |
||
3569 | pushad ; start enable io map |
||
3570 | |||
3571 | cmp edx, 65536;16384 |
||
3572 | jae no_unmask_io; jge |
||
3573 | mov eax, ecx |
||
3574 | ; push ebp |
||
3575 | xor ebp, ebp ; enable - eax = port |
||
3576 | new_port_access: |
||
3577 | ; pushad |
||
3578 | call set_io_access_rights |
||
3579 | ; popad |
||
3580 | inc eax |
||
3581 | cmp eax, edx |
||
3582 | jbe new_port_access |
||
3583 | ; pop ebp |
||
3584 | no_unmask_io: |
||
3585 | popad ; end enable io map |
||
3586 | sti |
||
3587 | |||
3588 | mov eax, [RESERVED_PORTS] |
||
3589 | add eax, 1 |
||
3590 | mov [RESERVED_PORTS], eax |
||
3591 | shl eax, 4 |
||
3592 | add eax, RESERVED_PORTS |
||
9692 | Doczom | 3593 | mov ebx, [current_slot] |
3594 | mov ebx, [ebx+APPDATA.tid] |
||
2288 | clevermous | 3595 | mov [eax], ebx |
3596 | mov [eax+4], ecx |
||
3597 | mov [eax+8], edx |
||
3598 | |||
3599 | xor eax, eax |
||
3600 | ret |
||
3601 | |||
3602 | free_port_area: |
||
3603 | |||
3604 | ; pushad |
||
3605 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
||
3606 | test eax, eax |
||
3607 | jz frpal2 |
||
9692 | Doczom | 3608 | mov ebx, [current_slot] |
3609 | mov ebx, [ebx+APPDATA.tid] |
||
2288 | clevermous | 3610 | frpal3: |
3611 | mov edi, eax |
||
3612 | shl edi, 4 |
||
3613 | add edi, RESERVED_PORTS |
||
3614 | cmp ebx, [edi] |
||
3615 | jne frpal4 |
||
3616 | cmp ecx, [edi+4] |
||
3617 | jne frpal4 |
||
3618 | cmp edx, [edi+8] |
||
3619 | jne frpal4 |
||
3620 | jmp frpal1 |
||
3621 | frpal4: |
||
3622 | dec eax |
||
3623 | jnz frpal3 |
||
3624 | frpal2: |
||
3625 | ; popad |
||
3626 | inc eax |
||
3627 | ret |
||
3628 | frpal1: |
||
3629 | push ecx |
||
3630 | mov ecx, 256 |
||
3631 | sub ecx, eax |
||
3632 | shl ecx, 4 |
||
3633 | mov esi, edi |
||
3634 | add esi, 16 |
||
3635 | cld |
||
3636 | rep movsb |
||
3637 | |||
3638 | dec dword [RESERVED_PORTS] |
||
3639 | ;popad |
||
3640 | ;disable port access at port IO map |
||
3641 | |||
3642 | ; pushad ; start disable io map |
||
3643 | pop eax ;start port |
||
3644 | cmp edx, 65536;16384 |
||
3645 | jge no_mask_io |
||
3646 | |||
3647 | ; mov eax,ecx |
||
3648 | xor ebp, ebp |
||
3649 | inc ebp |
||
3650 | new_port_access_disable: |
||
3651 | ; pushad |
||
3652 | ; mov ebp,1 ; disable - eax = port |
||
3653 | call set_io_access_rights |
||
3654 | ; popad |
||
3655 | inc eax |
||
3656 | cmp eax, edx |
||
3657 | jbe new_port_access_disable |
||
3658 | no_mask_io: |
||
3659 | ; popad ; end disable io map |
||
3660 | xor eax, eax |
||
3661 | ret |
||
2430 | mario79 | 3662 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3663 | align 4 |
3664 | drawbackground: |
||
2430 | mario79 | 3665 | dbrv20: |
2288 | clevermous | 3666 | cmp [BgrDrawMode], dword 1 |
3667 | jne bgrstr |
||
3668 | call vesa20_drawbackground_tiled |
||
2453 | mario79 | 3669 | ; call [draw_pointer] |
3670 | call __sys_draw_pointer |
||
2288 | clevermous | 3671 | ret |
2430 | mario79 | 3672 | ;-------------------------------------- |
3673 | align 4 |
||
3674 | bgrstr: |
||
2288 | clevermous | 3675 | call vesa20_drawbackground_stretch |
2453 | mario79 | 3676 | ; call [draw_pointer] |
3677 | call __sys_draw_pointer |
||
2288 | clevermous | 3678 | ret |
2430 | mario79 | 3679 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3680 | align 4 |
3681 | syscall_putimage: ; PutImage |
||
8714 | Doczom | 3682 | ; add check pointer |
3683 | push ecx |
||
3684 | mov ax, cx |
||
3685 | shr ecx, 16 |
||
3686 | imul eax, ecx |
||
3687 | lea eax, [eax*3] |
||
3688 | stdcall is_region_userspace, ebx, eax |
||
3689 | pop ecx |
||
9045 | dunkaist | 3690 | jnz sys_putimage.exit |
8714 | Doczom | 3691 | |
2288 | clevermous | 3692 | sys_putimage: |
3693 | test ecx, 0x80008000 |
||
3694 | jnz .exit |
||
3695 | test ecx, 0x0000FFFF |
||
3696 | jz .exit |
||
3697 | test ecx, 0xFFFF0000 |
||
3698 | jnz @f |
||
2430 | mario79 | 3699 | ;-------------------------------------- |
3700 | align 4 |
||
3701 | .exit: |
||
2288 | clevermous | 3702 | ret |
2430 | mario79 | 3703 | ;-------------------------------------- |
3704 | align 4 |
||
3705 | @@: |
||
2288 | clevermous | 3706 | mov edi, [current_slot] |
3707 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
||
3708 | rol edx, 16 |
||
3709 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
||
3710 | rol edx, 16 |
||
2430 | mario79 | 3711 | ;-------------------------------------- |
3712 | align 4 |
||
3713 | .forced: |
||
2288 | clevermous | 3714 | push ebp esi 0 |
3715 | mov ebp, putimage_get24bpp |
||
3716 | mov esi, putimage_init24bpp |
||
2430 | mario79 | 3717 | ;-------------------------------------- |
3718 | align 4 |
||
2288 | clevermous | 3719 | sys_putimage_bpp: |
2430 | mario79 | 3720 | call vesa20_putimage |
2288 | clevermous | 3721 | pop ebp esi ebp |
2430 | mario79 | 3722 | ret |
3723 | ; jmp [draw_pointer] |
||
3724 | ;----------------------------------------------------------------------------- |
||
2288 | clevermous | 3725 | align 4 |
3726 | sys_putimage_palette: |
||
3727 | ; ebx = pointer to image |
||
3728 | ; ecx = [xsize]*65536 + [ysize] |
||
3729 | ; edx = [xstart]*65536 + [ystart] |
||
3730 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
||
3731 | ; edi = pointer to palette |
||
3732 | ; ebp = row delta |
||
8715 | Doczom | 3733 | ; check pointer |
3734 | push ecx |
||
3735 | mov ax, cx |
||
3736 | shr ecx, 16 |
||
3737 | imul eax, ecx |
||
3738 | stdcall is_region_userspace, ebx, eax |
||
3739 | pop ecx |
||
9045 | dunkaist | 3740 | jnz sys_putimage.exit |
8715 | Doczom | 3741 | |
8869 | rgimad | 3742 | mov eax, [current_slot_idx] |
2288 | clevermous | 3743 | shl eax, 8 |
3744 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
||
3745 | rol edx, 16 |
||
3746 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
||
3747 | rol edx, 16 |
||
2430 | mario79 | 3748 | ;-------------------------------------- |
3749 | align 4 |
||
2288 | clevermous | 3750 | .forced: |
3751 | cmp esi, 1 |
||
3752 | jnz @f |
||
3753 | push edi |
||
3754 | mov eax, [edi+4] |
||
3755 | sub eax, [edi] |
||
3756 | push eax |
||
3757 | push dword [edi] |
||
3758 | push 0ffffff80h |
||
3759 | mov edi, esp |
||
3760 | call put_mono_image |
||
3761 | add esp, 12 |
||
3762 | pop edi |
||
3763 | ret |
||
2430 | mario79 | 3764 | ;-------------------------------------- |
3765 | align 4 |
||
2288 | clevermous | 3766 | @@: |
3767 | cmp esi, 2 |
||
3768 | jnz @f |
||
3769 | push edi |
||
3770 | push 0ffffff80h |
||
3771 | mov edi, esp |
||
3772 | call put_2bit_image |
||
3773 | pop eax |
||
3774 | pop edi |
||
3775 | ret |
||
2430 | mario79 | 3776 | ;-------------------------------------- |
3777 | align 4 |
||
2288 | clevermous | 3778 | @@: |
3779 | cmp esi, 4 |
||
3780 | jnz @f |
||
3781 | push edi |
||
3782 | push 0ffffff80h |
||
3783 | mov edi, esp |
||
3784 | call put_4bit_image |
||
3785 | pop eax |
||
3786 | pop edi |
||
3787 | ret |
||
2430 | mario79 | 3788 | ;-------------------------------------- |
3789 | align 4 |
||
2288 | clevermous | 3790 | @@: |
3791 | push ebp esi ebp |
||
3792 | cmp esi, 8 |
||
3793 | jnz @f |
||
3794 | mov ebp, putimage_get8bpp |
||
3795 | mov esi, putimage_init8bpp |
||
3796 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3797 | ;-------------------------------------- |
3798 | align 4 |
||
2288 | clevermous | 3799 | @@: |
2727 | dunkaist | 3800 | cmp esi, 9 |
3801 | jnz @f |
||
3802 | mov ebp, putimage_get9bpp |
||
3803 | mov esi, putimage_init9bpp |
||
3804 | jmp sys_putimage_bpp |
||
3805 | ;-------------------------------------- |
||
3806 | align 4 |
||
3807 | @@: |
||
2288 | clevermous | 3808 | cmp esi, 15 |
3809 | jnz @f |
||
3810 | mov ebp, putimage_get15bpp |
||
3811 | mov esi, putimage_init15bpp |
||
3812 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3813 | ;-------------------------------------- |
3814 | align 4 |
||
2288 | clevermous | 3815 | @@: |
3816 | cmp esi, 16 |
||
3817 | jnz @f |
||
3818 | mov ebp, putimage_get16bpp |
||
3819 | mov esi, putimage_init16bpp |
||
3820 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3821 | ;-------------------------------------- |
3822 | align 4 |
||
2288 | clevermous | 3823 | @@: |
3824 | cmp esi, 24 |
||
3825 | jnz @f |
||
3826 | mov ebp, putimage_get24bpp |
||
3827 | mov esi, putimage_init24bpp |
||
3828 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3829 | ;-------------------------------------- |
3830 | align 4 |
||
2288 | clevermous | 3831 | @@: |
3832 | cmp esi, 32 |
||
3833 | jnz @f |
||
3834 | mov ebp, putimage_get32bpp |
||
3835 | mov esi, putimage_init32bpp |
||
3836 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3837 | ;-------------------------------------- |
3838 | align 4 |
||
2288 | clevermous | 3839 | @@: |
3840 | pop ebp esi ebp |
||
3841 | ret |
||
2430 | mario79 | 3842 | ;----------------------------------------------------------------------------- |
3843 | align 4 |
||
2288 | clevermous | 3844 | put_mono_image: |
3845 | push ebp esi ebp |
||
3846 | mov ebp, putimage_get1bpp |
||
3847 | mov esi, putimage_init1bpp |
||
3848 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3849 | ;----------------------------------------------------------------------------- |
3850 | align 4 |
||
2288 | clevermous | 3851 | put_2bit_image: |
3852 | push ebp esi ebp |
||
3853 | mov ebp, putimage_get2bpp |
||
3854 | mov esi, putimage_init2bpp |
||
3855 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3856 | ;----------------------------------------------------------------------------- |
3857 | align 4 |
||
2288 | clevermous | 3858 | put_4bit_image: |
3859 | push ebp esi ebp |
||
3860 | mov ebp, putimage_get4bpp |
||
3861 | mov esi, putimage_init4bpp |
||
3862 | jmp sys_putimage_bpp |
||
2430 | mario79 | 3863 | ;----------------------------------------------------------------------------- |
3864 | align 4 |
||
2288 | clevermous | 3865 | putimage_init24bpp: |
3866 | lea eax, [eax*3] |
||
3867 | putimage_init8bpp: |
||
2727 | dunkaist | 3868 | putimage_init9bpp: |
2288 | clevermous | 3869 | ret |
2430 | mario79 | 3870 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3871 | align 16 |
3872 | putimage_get24bpp: |
||
3873 | movzx eax, byte [esi+2] |
||
3874 | shl eax, 16 |
||
3875 | mov ax, [esi] |
||
3876 | add esi, 3 |
||
3877 | ret 4 |
||
2430 | mario79 | 3878 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3879 | align 16 |
3880 | putimage_get8bpp: |
||
3881 | movzx eax, byte [esi] |
||
3882 | push edx |
||
3883 | mov edx, [esp+8] |
||
3884 | mov eax, [edx+eax*4] |
||
3885 | pop edx |
||
3886 | inc esi |
||
3887 | ret 4 |
||
2430 | mario79 | 3888 | ;----------------------------------------------------------------------------- |
2727 | dunkaist | 3889 | align 16 |
3890 | putimage_get9bpp: |
||
3891 | lodsb |
||
3892 | mov ah, al |
||
3893 | shl eax, 8 |
||
3894 | mov al, ah |
||
3895 | ret 4 |
||
3896 | ;----------------------------------------------------------------------------- |
||
2430 | mario79 | 3897 | align 4 |
2288 | clevermous | 3898 | putimage_init1bpp: |
3899 | add eax, ecx |
||
3900 | push ecx |
||
3901 | add eax, 7 |
||
3902 | add ecx, 7 |
||
3903 | shr eax, 3 |
||
3904 | shr ecx, 3 |
||
3905 | sub eax, ecx |
||
3906 | pop ecx |
||
3907 | ret |
||
2430 | mario79 | 3908 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3909 | align 16 |
3910 | putimage_get1bpp: |
||
3911 | push edx |
||
3912 | mov edx, [esp+8] |
||
3913 | mov al, [edx] |
||
3914 | add al, al |
||
3915 | jnz @f |
||
3916 | lodsb |
||
3917 | adc al, al |
||
3918 | @@: |
||
3919 | mov [edx], al |
||
3920 | sbb eax, eax |
||
3921 | and eax, [edx+8] |
||
3922 | add eax, [edx+4] |
||
3923 | pop edx |
||
3924 | ret 4 |
||
2430 | mario79 | 3925 | ;----------------------------------------------------------------------------- |
3926 | align 4 |
||
2288 | clevermous | 3927 | putimage_init2bpp: |
3928 | add eax, ecx |
||
3929 | push ecx |
||
3930 | add ecx, 3 |
||
3931 | add eax, 3 |
||
3932 | shr ecx, 2 |
||
3933 | shr eax, 2 |
||
3934 | sub eax, ecx |
||
3935 | pop ecx |
||
3936 | ret |
||
2430 | mario79 | 3937 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3938 | align 16 |
3939 | putimage_get2bpp: |
||
3940 | push edx |
||
3941 | mov edx, [esp+8] |
||
3942 | mov al, [edx] |
||
3943 | mov ah, al |
||
3944 | shr al, 6 |
||
3945 | shl ah, 2 |
||
3946 | jnz .nonewbyte |
||
3947 | lodsb |
||
3948 | mov ah, al |
||
3949 | shr al, 6 |
||
3950 | shl ah, 2 |
||
3951 | add ah, 1 |
||
3952 | .nonewbyte: |
||
3953 | mov [edx], ah |
||
3954 | mov edx, [edx+4] |
||
3955 | movzx eax, al |
||
3956 | mov eax, [edx+eax*4] |
||
3957 | pop edx |
||
3958 | ret 4 |
||
2430 | mario79 | 3959 | ;----------------------------------------------------------------------------- |
3960 | align 4 |
||
2288 | clevermous | 3961 | putimage_init4bpp: |
3962 | add eax, ecx |
||
3963 | push ecx |
||
3964 | add ecx, 1 |
||
9268 | Doczom | 3965 | inc eax ;add eax, 1 |
2288 | clevermous | 3966 | shr ecx, 1 |
3967 | shr eax, 1 |
||
3968 | sub eax, ecx |
||
3969 | pop ecx |
||
3970 | ret |
||
2430 | mario79 | 3971 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3972 | align 16 |
3973 | putimage_get4bpp: |
||
3974 | push edx |
||
3975 | mov edx, [esp+8] |
||
3976 | add byte [edx], 80h |
||
3977 | jc @f |
||
3978 | movzx eax, byte [edx+1] |
||
3979 | mov edx, [edx+4] |
||
3980 | and eax, 0x0F |
||
3981 | mov eax, [edx+eax*4] |
||
3982 | pop edx |
||
3983 | ret 4 |
||
3984 | @@: |
||
3985 | movzx eax, byte [esi] |
||
3986 | add esi, 1 |
||
3987 | mov [edx+1], al |
||
3988 | shr eax, 4 |
||
3989 | mov edx, [edx+4] |
||
3990 | mov eax, [edx+eax*4] |
||
3991 | pop edx |
||
3992 | ret 4 |
||
2430 | mario79 | 3993 | ;----------------------------------------------------------------------------- |
3994 | align 4 |
||
2288 | clevermous | 3995 | putimage_init32bpp: |
3996 | shl eax, 2 |
||
3997 | ret |
||
2430 | mario79 | 3998 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 3999 | align 16 |
4000 | putimage_get32bpp: |
||
4001 | lodsd |
||
4002 | ret 4 |
||
2430 | mario79 | 4003 | ;----------------------------------------------------------------------------- |
4004 | align 4 |
||
2288 | clevermous | 4005 | putimage_init15bpp: |
4006 | putimage_init16bpp: |
||
4007 | add eax, eax |
||
4008 | ret |
||
2430 | mario79 | 4009 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4010 | align 16 |
4011 | putimage_get15bpp: |
||
4012 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
||
4013 | push ecx edx |
||
4014 | movzx eax, word [esi] |
||
4015 | add esi, 2 |
||
4016 | mov ecx, eax |
||
4017 | mov edx, eax |
||
4018 | and eax, 0x1F |
||
4019 | and ecx, 0x1F shl 5 |
||
4020 | and edx, 0x1F shl 10 |
||
4021 | shl eax, 3 |
||
4022 | shl ecx, 6 |
||
4023 | shl edx, 9 |
||
4024 | or eax, ecx |
||
4025 | or eax, edx |
||
4026 | pop edx ecx |
||
4027 | ret 4 |
||
2430 | mario79 | 4028 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4029 | align 16 |
4030 | putimage_get16bpp: |
||
4031 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
||
4032 | push ecx edx |
||
4033 | movzx eax, word [esi] |
||
4034 | add esi, 2 |
||
4035 | mov ecx, eax |
||
4036 | mov edx, eax |
||
4037 | and eax, 0x1F |
||
4038 | and ecx, 0x3F shl 5 |
||
4039 | and edx, 0x1F shl 11 |
||
4040 | shl eax, 3 |
||
4041 | shl ecx, 5 |
||
4042 | shl edx, 8 |
||
4043 | or eax, ecx |
||
4044 | or eax, edx |
||
4045 | pop edx ecx |
||
4046 | ret 4 |
||
2430 | mario79 | 4047 | ;----------------------------------------------------------------------------- |
4048 | ;align 4 |
||
2288 | clevermous | 4049 | ; eax x beginning |
4050 | ; ebx y beginning |
||
4051 | ; ecx x end |
||
4052 | ; edx y end |
||
4053 | ; edi color |
||
2430 | mario79 | 4054 | ;__sys_drawbar: |
4055 | ; mov esi, [current_slot] |
||
4056 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
||
4057 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
||
4058 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
||
4059 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
||
4060 | ;-------------------------------------- |
||
4061 | ;align 4 |
||
4062 | ;.forced: |
||
4063 | ; call vesa20_drawbar |
||
2407 | mario79 | 4064 | ; call [draw_pointer] |
4065 | ; ret |
||
2430 | mario79 | 4066 | ;----------------------------------------------------------------------------- |
4067 | align 4 |
||
5012 | clevermous | 4068 | kb_write_wait_ack: |
2288 | clevermous | 4069 | |
4070 | push ecx edx |
||
4071 | |||
4072 | mov dl, al |
||
4073 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
||
5012 | clevermous | 4074 | .wait_output_ready: |
2288 | clevermous | 4075 | in al, 0x64 |
4076 | test al, 2 |
||
5012 | clevermous | 4077 | jz @f |
4078 | loop .wait_output_ready |
||
2288 | clevermous | 4079 | mov ah, 1 |
5012 | clevermous | 4080 | jmp .nothing |
4081 | @@: |
||
2288 | clevermous | 4082 | mov al, dl |
4083 | out 0x60, al |
||
5012 | clevermous | 4084 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4085 | .wait_ack: |
||
2288 | clevermous | 4086 | in al, 0x64 |
5012 | clevermous | 4087 | test al, 1 |
4088 | jnz @f |
||
4089 | loop .wait_ack |
||
2288 | clevermous | 4090 | mov ah, 1 |
5012 | clevermous | 4091 | jmp .nothing |
4092 | @@: |
||
4093 | in al, 0x60 |
||
2288 | clevermous | 4094 | xor ah, ah |
4095 | |||
5012 | clevermous | 4096 | .nothing: |
2288 | clevermous | 4097 | pop edx ecx |
4098 | |||
4099 | ret |
||
2430 | mario79 | 4100 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4101 | |
4102 | if used _rdtsc |
||
4103 | _rdtsc: |
||
4104 | bt [cpu_caps], CAPS_TSC |
||
4105 | jnc ret_rdtsc |
||
4106 | rdtsc |
||
4107 | ret |
||
4108 | ret_rdtsc: |
||
4109 | mov edx, 0xffffffff |
||
4110 | mov eax, 0xffffffff |
||
4111 | ret |
||
4112 | end if |
||
4113 | |||
4114 | sys_msg_board_str: |
||
4115 | |||
4116 | pushad |
||
4117 | @@: |
||
4118 | cmp [esi], byte 0 |
||
4119 | je @f |
||
3614 | shikhin | 4120 | mov ebx, 1 |
4121 | movzx ecx, byte [esi] |
||
2288 | clevermous | 4122 | call sys_msg_board |
4123 | inc esi |
||
4124 | jmp @b |
||
4125 | @@: |
||
4126 | popad |
||
4127 | ret |
||
4128 | |||
4129 | sys_msg_board_byte: |
||
4130 | ; in: al = byte to display |
||
4131 | ; out: nothing |
||
4132 | ; destroys: nothing |
||
4133 | pushad |
||
4134 | mov ecx, 2 |
||
4135 | shl eax, 24 |
||
4136 | jmp @f |
||
4137 | |||
4138 | sys_msg_board_word: |
||
4139 | ; in: ax = word to display |
||
4140 | ; out: nothing |
||
4141 | ; destroys: nothing |
||
4142 | pushad |
||
4143 | mov ecx, 4 |
||
4144 | shl eax, 16 |
||
4145 | jmp @f |
||
4146 | |||
4147 | sys_msg_board_dword: |
||
4148 | ; in: eax = dword to display |
||
4149 | ; out: nothing |
||
4150 | ; destroys: nothing |
||
4151 | pushad |
||
4152 | mov ecx, 8 |
||
4153 | @@: |
||
4154 | push ecx |
||
4155 | rol eax, 4 |
||
4156 | push eax |
||
4157 | and al, 0xF |
||
4158 | cmp al, 10 |
||
4159 | sbb al, 69h |
||
4160 | das |
||
3614 | shikhin | 4161 | mov cl, al |
4162 | xor ebx, ebx |
||
4163 | inc ebx |
||
2288 | clevermous | 4164 | call sys_msg_board |
4165 | pop eax |
||
4166 | pop ecx |
||
4167 | loop @b |
||
4168 | popad |
||
4169 | ret |
||
4170 | |||
3392 | clevermous | 4171 | msg_board_data_size = 65536 ; Must be power of two |
4172 | |||
2288 | clevermous | 4173 | uglobal |
6501 | pathoswith | 4174 | msg_board_data rb msg_board_data_size |
4175 | msg_board_count dd ? |
||
2288 | clevermous | 4176 | endg |
4177 | |||
6501 | pathoswith | 4178 | iglobal |
4179 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
||
4180 | endg |
||
4181 | |||
2288 | clevermous | 4182 | sys_msg_board: |
6501 | pathoswith | 4183 | ; ebx=1 -> write, cl = byte to write |
4184 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
||
4185 | push eax ebx |
||
3614 | shikhin | 4186 | mov eax, ebx |
4187 | mov ebx, ecx |
||
2288 | clevermous | 4188 | mov ecx, [msg_board_count] |
4189 | cmp eax, 1 |
||
6501 | pathoswith | 4190 | jne .read |
2288 | clevermous | 4191 | |
4192 | if defined debug_com_base |
||
4193 | push dx ax |
||
6501 | pathoswith | 4194 | @@: ; wait for empty transmit register |
2288 | clevermous | 4195 | mov dx, debug_com_base+5 |
4196 | in al, dx |
||
4197 | test al, 1 shl 5 |
||
4198 | jz @r |
||
4199 | mov dx, debug_com_base ; Output the byte |
||
4200 | mov al, bl |
||
4201 | out dx, al |
||
4202 | pop ax dx |
||
4203 | end if |
||
4204 | |||
4205 | mov [msg_board_data+ecx], bl |
||
3777 | yogev_ezra | 4206 | cmp byte [debug_direct_print], 1 |
6501 | pathoswith | 4207 | jnz .end |
3507 | clevermous | 4208 | pusha |
4209 | lea edx, [msg_board_data+ecx] |
||
4210 | mov ecx, 0x40FFFFFF |
||
4211 | mov ebx, [msg_board_pos] |
||
4212 | mov edi, 1 |
||
9268 | Doczom | 4213 | mov esi, edi ;1 |
3507 | clevermous | 4214 | call dtext |
4215 | popa |
||
4216 | add word [msg_board_pos+2], 6 |
||
6501 | pathoswith | 4217 | cmp word [msg_board_pos+2], 105*6 |
4218 | jnc @f |
||
3507 | clevermous | 4219 | cmp bl, 10 |
6501 | pathoswith | 4220 | jnz .end |
4221 | @@: |
||
4222 | mov word [msg_board_pos+2], 42*6 |
||
3507 | clevermous | 4223 | add word [msg_board_pos], 10 |
6501 | pathoswith | 4224 | mov eax, [_display.height] |
4225 | sub eax, 10 |
||
4226 | cmp ax, word [msg_board_pos] |
||
4227 | jnc @f |
||
3507 | clevermous | 4228 | mov word [msg_board_pos], 10 |
4229 | @@: |
||
3534 | clevermous | 4230 | pusha |
6501 | pathoswith | 4231 | mov eax, [msg_board_pos] |
4232 | movzx ebx, ax |
||
4233 | shr eax, 16 |
||
4234 | mov edx, 105*6 |
||
4235 | xor ecx, ecx |
||
4236 | mov edi, 1 |
||
4237 | mov esi, 9 |
||
4238 | @@: |
||
4239 | call hline |
||
4240 | inc ebx |
||
4241 | dec esi |
||
4242 | jnz @b |
||
3534 | clevermous | 4243 | popa |
6501 | pathoswith | 4244 | .end: |
2288 | clevermous | 4245 | inc ecx |
3392 | clevermous | 4246 | and ecx, msg_board_data_size - 1 |
2288 | clevermous | 4247 | mov [msg_board_count], ecx |
6501 | pathoswith | 4248 | .ret: |
3614 | shikhin | 4249 | pop ebx eax |
2288 | clevermous | 4250 | ret |
6501 | pathoswith | 4251 | |
4252 | @@: |
||
4253 | mov [esp+32], ecx |
||
4254 | mov [esp+20], ecx |
||
4255 | jmp .ret |
||
4256 | |||
4257 | .read: |
||
2288 | clevermous | 4258 | cmp eax, 2 |
6501 | pathoswith | 4259 | jne .ret |
2288 | clevermous | 4260 | test ecx, ecx |
6501 | pathoswith | 4261 | jz @b |
4262 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
||
2288 | clevermous | 4263 | mov eax, msg_board_data+1 |
4264 | mov ebx, msg_board_data |
||
4265 | movzx edx, byte [ebx] |
||
4266 | call memmove |
||
4267 | dec [msg_board_count] |
||
3614 | shikhin | 4268 | mov [esp + 32], edx ;eax |
4269 | mov [esp + 20], dword 1 |
||
2288 | clevermous | 4270 | ret |
4271 | |||
4272 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4273 | ;; 66 sys function. ;; |
||
4274 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
||
4275 | ;; out eax ;; |
||
4276 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4277 | iglobal |
||
4278 | align 4 |
||
4279 | f66call: |
||
4280 | dd sys_process_def.1 ; 1 = set keyboard mode |
||
4281 | dd sys_process_def.2 ; 2 = get keyboard mode |
||
4282 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
||
2709 | mario79 | 4283 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4284 | dd sys_process_def.5 ; 5 = delete installed hotkey |
||
4285 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
||
4286 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
||
2288 | clevermous | 4287 | endg |
2709 | mario79 | 4288 | ;----------------------------------------------------------------------------- |
4289 | align 4 |
||
2288 | clevermous | 4290 | sys_process_def: |
4291 | dec ebx |
||
2709 | mario79 | 4292 | cmp ebx, 7 |
4293 | jae .not_support ;if >=8 then or eax,-1 |
||
2288 | clevermous | 4294 | |
8869 | rgimad | 4295 | mov edi, [current_slot_idx] |
2288 | clevermous | 4296 | jmp dword [f66call+ebx*4] |
4297 | |||
4298 | .not_support: |
||
4299 | or eax, -1 |
||
4300 | ret |
||
2709 | mario79 | 4301 | ;----------------------------------------------------------------------------- |
4302 | align 4 |
||
2288 | clevermous | 4303 | .1: |
4304 | shl edi, 8 |
||
4305 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
||
4306 | |||
4307 | ret |
||
2709 | mario79 | 4308 | ;----------------------------------------------------------------------------- |
4309 | align 4 |
||
2288 | clevermous | 4310 | .2: ; 2 = get keyboard mode |
4311 | shl edi, 8 |
||
4312 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
||
4313 | mov [esp+32], eax |
||
4314 | ret |
||
2709 | mario79 | 4315 | ;----------------------------------------------------------------------------- |
4316 | align 4 |
||
2288 | clevermous | 4317 | .3: ;3 = get keyboard ctrl, alt, shift |
4318 | mov eax, [kb_state] |
||
4319 | mov [esp+32], eax |
||
4320 | ret |
||
2709 | mario79 | 4321 | ;----------------------------------------------------------------------------- |
4322 | align 4 |
||
2288 | clevermous | 4323 | .4: |
4324 | mov eax, hotkey_list |
||
4325 | @@: |
||
4326 | cmp dword [eax+8], 0 |
||
4327 | jz .found_free |
||
4328 | add eax, 16 |
||
4329 | cmp eax, hotkey_list+16*256 |
||
4330 | jb @b |
||
4331 | mov dword [esp+32], 1 |
||
4332 | ret |
||
4333 | .found_free: |
||
4334 | mov [eax+8], edi |
||
4335 | mov [eax+4], edx |
||
4336 | movzx ecx, cl |
||
4337 | lea ecx, [hotkey_scancodes+ecx*4] |
||
4338 | mov edx, [ecx] |
||
4339 | mov [eax], edx |
||
4340 | mov [ecx], eax |
||
4341 | mov [eax+12], ecx |
||
3383 | hidnplayr | 4342 | test edx, edx |
4343 | jz @f |
||
2288 | clevermous | 4344 | mov [edx+12], eax |
4345 | @@: |
||
4346 | and dword [esp+32], 0 |
||
4347 | ret |
||
2709 | mario79 | 4348 | ;----------------------------------------------------------------------------- |
4349 | align 4 |
||
2288 | clevermous | 4350 | .5: |
4351 | movzx ebx, cl |
||
4352 | lea ebx, [hotkey_scancodes+ebx*4] |
||
4353 | mov eax, [ebx] |
||
4354 | .scan: |
||
4355 | test eax, eax |
||
4356 | jz .notfound |
||
4357 | cmp [eax+8], edi |
||
4358 | jnz .next |
||
4359 | cmp [eax+4], edx |
||
4360 | jz .found |
||
4361 | .next: |
||
4362 | mov eax, [eax] |
||
4363 | jmp .scan |
||
4364 | .notfound: |
||
4365 | mov dword [esp+32], 1 |
||
4366 | ret |
||
4367 | .found: |
||
4368 | mov ecx, [eax] |
||
4369 | jecxz @f |
||
4370 | mov edx, [eax+12] |
||
4371 | mov [ecx+12], edx |
||
4372 | @@: |
||
4373 | mov ecx, [eax+12] |
||
4374 | mov edx, [eax] |
||
4375 | mov [ecx], edx |
||
4376 | xor edx, edx |
||
4377 | mov [eax+4], edx |
||
4378 | mov [eax+8], edx |
||
4379 | mov [eax+12], edx |
||
4380 | mov [eax], edx |
||
4381 | mov [esp+32], edx |
||
4382 | ret |
||
2709 | mario79 | 4383 | ;----------------------------------------------------------------------------- |
4384 | align 4 |
||
4385 | .6: |
||
4386 | pushfd |
||
4387 | cli |
||
4388 | mov eax, [PID_lock_input] |
||
4389 | test eax, eax |
||
4390 | jnz @f |
||
4391 | ; get current PID |
||
8869 | rgimad | 4392 | mov eax, [current_slot_idx] |
9692 | Doczom | 4393 | shl eax, BSF sizeof.APPDATA |
4394 | mov eax, [eax+SLOT_BASE+APPDATA.tid] |
||
2709 | mario79 | 4395 | ; set current PID for lock input |
4396 | mov [PID_lock_input], eax |
||
4397 | @@: |
||
4398 | popfd |
||
4399 | ret |
||
4400 | ;----------------------------------------------------------------------------- |
||
4401 | align 4 |
||
4402 | .7: |
||
4403 | mov eax, [PID_lock_input] |
||
4404 | test eax, eax |
||
4405 | jz @f |
||
4406 | ; get current PID |
||
8869 | rgimad | 4407 | mov ebx, [current_slot_idx] |
9692 | Doczom | 4408 | shl ebx, BSF sizeof.APPDATA |
4409 | mov ebx, [ebx+SLOT_BASE+APPDATA.tid] |
||
2709 | mario79 | 4410 | ; compare current lock input with current PID |
4411 | cmp ebx, eax |
||
4412 | jne @f |
||
2288 | clevermous | 4413 | |
2709 | mario79 | 4414 | xor eax, eax |
4415 | mov [PID_lock_input], eax |
||
4416 | @@: |
||
4417 | ret |
||
4418 | ;----------------------------------------------------------------------------- |
||
4419 | uglobal |
||
4420 | PID_lock_input dd 0x0 |
||
4421 | endg |
||
2288 | clevermous | 4422 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4423 | ;; 61 sys function. ;; |
||
4424 | ;; in eax=61,ebx in [1..3] ;; |
||
4425 | ;; out eax ;; |
||
4426 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
4427 | iglobal |
||
4428 | align 4 |
||
4429 | f61call: |
||
4430 | dd sys_gs.1 ; resolution |
||
4431 | dd sys_gs.2 ; bits per pixel |
||
4432 | dd sys_gs.3 ; bytes per scanline |
||
4433 | endg |
||
4434 | |||
4435 | |||
4436 | align 4 |
||
4437 | |||
4438 | sys_gs: ; direct screen access |
||
4439 | dec ebx |
||
4440 | cmp ebx, 2 |
||
4441 | ja .not_support |
||
4442 | jmp dword [f61call+ebx*4] |
||
4443 | .not_support: |
||
4444 | or [esp+32], dword -1 |
||
4445 | ret |
||
4446 | |||
4447 | |||
4448 | .1: ; resolution |
||
5350 | serge | 4449 | mov eax, [_display.width] |
2288 | clevermous | 4450 | shl eax, 16 |
5350 | serge | 4451 | mov ax, word [_display.height] |
2288 | clevermous | 4452 | mov [esp+32], eax |
4453 | ret |
||
4454 | .2: ; bits per pixel |
||
5154 | hidnplayr | 4455 | mov eax, [_display.bits_per_pixel] |
2288 | clevermous | 4456 | mov [esp+32], eax |
4457 | ret |
||
4458 | .3: ; bytes per scanline |
||
5351 | serge | 4459 | mov eax, [_display.lfb_pitch] |
2288 | clevermous | 4460 | mov [esp+32], eax |
4461 | ret |
||
4462 | |||
4463 | align 4 |
||
4464 | syscall_getscreensize: ; GetScreenSize |
||
5350 | serge | 4465 | mov ax, word [_display.width] |
4466 | dec ax |
||
2288 | clevermous | 4467 | shl eax, 16 |
5350 | serge | 4468 | mov ax, word [_display.height] |
4469 | dec ax |
||
2288 | clevermous | 4470 | mov [esp + 32], eax |
4471 | ret |
||
4700 | mario79 | 4472 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4473 | align 4 |
4713 | mario79 | 4474 | syscall_cdaudio: |
4711 | mario79 | 4475 | ; ECX - position of CD/DVD-drive |
4476 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
||
4477 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
||
4478 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
||
4479 | cmp ecx, 11 |
||
4480 | ja .exit |
||
4481 | |||
4482 | mov eax, ecx |
||
4483 | shr eax, 2 |
||
4484 | lea eax, [eax*5] |
||
4485 | mov al, [eax+DRIVE_DATA+1] |
||
4486 | |||
4487 | push ecx ebx |
||
4488 | mov ebx, ecx |
||
4489 | and ebx, 11b |
||
4490 | shl ebx, 1 |
||
4491 | mov cl, 6 |
||
4492 | sub cl, bl |
||
4493 | shr al, cl |
||
4494 | test al, 2 ; it's not an ATAPI device |
||
4495 | pop ebx ecx |
||
4496 | |||
4497 | jz .exit |
||
4498 | |||
4700 | mario79 | 4499 | cmp ebx, 4 |
4500 | je .eject |
||
2288 | clevermous | 4501 | |
4502 | cmp ebx, 5 |
||
4700 | mario79 | 4503 | je .load |
4711 | mario79 | 4504 | ;-------------------------------------- |
4505 | .exit: |
||
4700 | mario79 | 4506 | ret |
4507 | ;-------------------------------------- |
||
2288 | clevermous | 4508 | .load: |
4509 | call .reserve |
||
4510 | call LoadMedium |
||
4511 | jmp .free |
||
4700 | mario79 | 4512 | ;-------------------------------------- |
2288 | clevermous | 4513 | .eject: |
4514 | call .reserve |
||
4515 | call clear_CD_cache |
||
4516 | call allow_medium_removal |
||
4517 | call EjectMedium |
||
4518 | jmp .free |
||
4700 | mario79 | 4519 | ;-------------------------------------- |
2288 | clevermous | 4520 | .reserve: |
4521 | call reserve_cd |
||
4700 | mario79 | 4522 | |
4523 | mov ebx, ecx |
||
4524 | inc ebx |
||
4525 | mov [cdpos], ebx |
||
4526 | |||
2288 | clevermous | 4527 | mov eax, ecx |
4528 | shr eax, 1 |
||
4529 | and eax, 1 |
||
4530 | inc eax |
||
6464 | pathoswith | 4531 | mov [ChannelNumber], al |
2288 | clevermous | 4532 | mov eax, ecx |
4533 | and eax, 1 |
||
4534 | mov [DiskNumber], al |
||
4535 | call reserve_cd_channel |
||
4536 | ret |
||
4700 | mario79 | 4537 | ;-------------------------------------- |
2288 | clevermous | 4538 | .free: |
4539 | call free_cd_channel |
||
4540 | and [cd_status], 0 |
||
4541 | ret |
||
2511 | mario79 | 4542 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4543 | align 4 |
2511 | mario79 | 4544 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5350 | serge | 4545 | cmp ebx, [_display.width] |
4546 | jb @f |
||
4547 | cmp ecx, [_display.height] |
||
4548 | jb @f |
||
2511 | mario79 | 4549 | xor eax, eax |
4550 | jmp .store |
||
4551 | ;-------------------------------------- |
||
4552 | align 4 |
||
4553 | @@: |
||
4554 | mov eax, [d_width_calc_area + ecx*4] |
||
5351 | serge | 4555 | add eax, [_display.win_map] |
2511 | mario79 | 4556 | movzx eax, byte[eax+ebx] ; get value for current point |
4557 | ;-------------------------------------- |
||
4558 | align 4 |
||
4559 | .store: |
||
4560 | mov [esp + 32], eax |
||
4561 | ret |
||
4562 | ;----------------------------------------------------------------------------- |
||
4563 | align 4 |
||
2288 | clevermous | 4564 | syscall_getpixel: ; GetPixel |
5350 | serge | 4565 | mov ecx, [_display.width] |
2288 | clevermous | 4566 | xor edx, edx |
4567 | mov eax, ebx |
||
4568 | div ecx |
||
4569 | mov ebx, edx |
||
4570 | xchg eax, ebx |
||
2430 | mario79 | 4571 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
2288 | clevermous | 4572 | call dword [GETPIXEL]; eax - x, ebx - y |
4573 | mov [esp + 32], ecx |
||
4574 | ret |
||
2509 | mario79 | 4575 | ;----------------------------------------------------------------------------- |
2288 | clevermous | 4576 | align 4 |
4577 | syscall_getarea: |
||
4578 | ;eax = 36 |
||
4579 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
||
4580 | ;ecx = [size x]*65536 + [size y] |
||
4581 | ;edx = [start x]*65536 + [start y] |
||
4582 | pushad |
||
4583 | mov edi, ebx |
||
4584 | mov eax, edx |
||
4585 | shr eax, 16 |
||
4586 | mov ebx, edx |
||
4587 | and ebx, 0xffff |
||
4588 | dec eax |
||
4589 | dec ebx |
||
4590 | ; eax - x, ebx - y |
||
4591 | mov edx, ecx |
||
4592 | |||
4593 | shr ecx, 16 |
||
4594 | and edx, 0xffff |
||
4595 | mov esi, ecx |
||
4596 | ; ecx - size x, edx - size y |
||
4597 | |||
4598 | mov ebp, edx |
||
8598 | rgimad | 4599 | lea ebp, [ebp*3] |
4600 | imul ebp, esi |
||
4601 | stdcall is_region_userspace, edi, ebp |
||
9045 | dunkaist | 4602 | jnz .exit |
8598 | rgimad | 4603 | |
4604 | mov ebp, edx |
||
2288 | clevermous | 4605 | dec ebp |
4606 | lea ebp, [ebp*3] |
||
4607 | |||
4608 | imul ebp, esi |
||
4609 | |||
4610 | mov esi, ecx |
||
4611 | dec esi |
||
4612 | lea esi, [esi*3] |
||
4613 | |||
4614 | add ebp, esi |
||
4615 | add ebp, edi |
||
4616 | |||
4617 | add ebx, edx |
||
2509 | mario79 | 4618 | ;-------------------------------------- |
4619 | align 4 |
||
2288 | clevermous | 4620 | .start_y: |
4621 | push ecx edx |
||
2509 | mario79 | 4622 | ;-------------------------------------- |
4623 | align 4 |
||
2288 | clevermous | 4624 | .start_x: |
4625 | push eax ebx ecx |
||
4626 | add eax, ecx |
||
4627 | |||
2430 | mario79 | 4628 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
2288 | clevermous | 4629 | call dword [GETPIXEL]; eax - x, ebx - y |
4630 | |||
4631 | mov [ebp], cx |
||
4632 | shr ecx, 16 |
||
4633 | mov [ebp+2], cl |
||
4634 | |||
4635 | pop ecx ebx eax |
||
4636 | sub ebp, 3 |
||
4637 | dec ecx |
||
4638 | jnz .start_x |
||
4639 | pop edx ecx |
||
4640 | dec ebx |
||
4641 | dec edx |
||
4642 | jnz .start_y |
||
8598 | rgimad | 4643 | |
4644 | .exit: |
||
2288 | clevermous | 4645 | popad |
4646 | ret |
||
2509 | mario79 | 4647 | ;----------------------------------------------------------------------------- |
8675 | rgimad | 4648 | |
2288 | clevermous | 4649 | align 4 |
4650 | syscall_threads: ; CreateThreads |
||
4651 | ; |
||
4105 | Serge | 4652 | ; ecx=thread entry point |
4653 | ; edx=thread stack pointer |
||
2288 | clevermous | 4654 | ; |
4655 | ; on return : eax = pid |
||
4656 | |||
4105 | Serge | 4657 | xor ebx, ebx |
2288 | clevermous | 4658 | call new_sys_threads |
4659 | |||
4660 | mov [esp+32], eax |
||
4661 | ret |
||
4662 | |||
2438 | mario79 | 4663 | ;------------------------------------------------------------------------------ |
2288 | clevermous | 4664 | align 4 |
2438 | mario79 | 4665 | calculate_fast_getting_offset_for_WinMapAddress: |
4666 | ; calculate data area for fast getting offset to _WinMapAddress |
||
2446 | mario79 | 4667 | xor eax, eax |
2438 | mario79 | 4668 | mov ecx, [_display.height] |
4669 | mov edi, d_width_calc_area |
||
4670 | cld |
||
4671 | @@: |
||
4672 | stosd |
||
4673 | add eax, [_display.width] |
||
4674 | dec ecx |
||
4675 | jnz @r |
||
4676 | ret |
||
4677 | ;------------------------------------------------------------------------------ |
||
4678 | align 4 |
||
2480 | mario79 | 4679 | calculate_fast_getting_offset_for_LFB: |
4680 | ; calculate data area for fast getting offset to LFB |
||
4681 | xor eax, eax |
||
4682 | mov ecx, [_display.height] |
||
4683 | mov edi, BPSLine_calc_area |
||
4684 | cld |
||
4685 | @@: |
||
4686 | stosd |
||
5351 | serge | 4687 | add eax, [_display.lfb_pitch] |
2480 | mario79 | 4688 | dec ecx |
4689 | jnz @r |
||
4690 | ret |
||
4691 | ;------------------------------------------------------------------------------ |
||
4692 | align 4 |
||
2288 | clevermous | 4693 | set_screen: |
2654 | mario79 | 4694 | ; in: |
4695 | ; eax - new Screen_Max_X |
||
4696 | ; ecx - new BytesPerScanLine |
||
4697 | ; edx - new Screen_Max_Y |
||
2288 | clevermous | 4698 | |
4699 | pushfd |
||
4700 | cli |
||
4701 | |||
5351 | serge | 4702 | mov [_display.lfb_pitch], ecx |
2288 | clevermous | 4703 | |
4704 | mov [screen_workarea.right], eax |
||
4705 | mov [screen_workarea.bottom], edx |
||
4706 | |||
4707 | push ebx |
||
4708 | push esi |
||
4709 | push edi |
||
4710 | |||
4711 | pushad |
||
4712 | |||
2654 | mario79 | 4713 | cmp [do_not_touch_winmap], 1 |
4714 | je @f |
||
4715 | |||
5351 | serge | 4716 | stdcall kernel_free, [_display.win_map] |
2288 | clevermous | 4717 | |
4718 | mov eax, [_display.width] |
||
4719 | mul [_display.height] |
||
5351 | serge | 4720 | mov [_display.win_map_size], eax |
2288 | clevermous | 4721 | |
4722 | stdcall kernel_alloc, eax |
||
5351 | serge | 4723 | mov [_display.win_map], eax |
2288 | clevermous | 4724 | test eax, eax |
4725 | jz .epic_fail |
||
2654 | mario79 | 4726 | ; store for f.18.24 |
4727 | mov eax, [_display.width] |
||
4728 | mov [display_width_standard], eax |
||
2288 | clevermous | 4729 | |
2654 | mario79 | 4730 | mov eax, [_display.height] |
4731 | mov [display_height_standard], eax |
||
4732 | @@: |
||
2438 | mario79 | 4733 | call calculate_fast_getting_offset_for_WinMapAddress |
2545 | mario79 | 4734 | ; for Qemu or non standart video cards |
2991 | Serge | 4735 | ; Unfortunately [BytesPerScanLine] does not always |
2545 | mario79 | 4736 | ; equal to [_display.width] * [ScreenBPP] / 8 |
4737 | call calculate_fast_getting_offset_for_LFB |
||
2288 | clevermous | 4738 | popad |
4739 | |||
4740 | call repos_windows |
||
4741 | xor eax, eax |
||
4742 | xor ebx, ebx |
||
5350 | serge | 4743 | mov ecx, [_display.width] |
4744 | mov edx, [_display.height] |
||
4745 | dec ecx |
||
4746 | dec edx |
||
2288 | clevermous | 4747 | call calculatescreen |
4748 | pop edi |
||
4749 | pop esi |
||
4750 | pop ebx |
||
4751 | |||
4752 | popfd |
||
4753 | ret |
||
4754 | |||
4755 | .epic_fail: |
||
4756 | hlt ; Houston, we've had a problem |
||
4757 | |||
4758 | ; --------------- APM --------------------- |
||
4759 | uglobal |
||
4760 | apm_entry dp 0 |
||
4761 | apm_vf dd 0 |
||
4762 | endg |
||
4763 | |||
4764 | align 4 |
||
4765 | sys_apm: |
||
4766 | xor eax, eax |
||
4767 | cmp word [apm_vf], ax ; Check APM BIOS enable |
||
4768 | jne @f |
||
4769 | inc eax |
||
4770 | or dword [esp + 44], eax ; error |
||
4771 | add eax, 7 |
||
4772 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
||
4773 | ret |
||
4774 | |||
4775 | @@: |
||
4776 | ; xchg eax, ecx |
||
4777 | ; xchg ebx, ecx |
||
4778 | |||
4779 | cmp dx, 3 |
||
4780 | ja @f |
||
4781 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
||
4782 | mov eax, [apm_vf] |
||
4783 | mov [esp + 32], eax |
||
4784 | shr eax, 16 |
||
4785 | mov [esp + 28], eax |
||
4786 | ret |
||
4787 | |||
4788 | @@: |
||
4789 | |||
4790 | mov esi, [master_tab+(OS_BASE shr 20)] |
||
4791 | xchg [master_tab], esi |
||
4792 | push esi |
||
4793 | mov edi, cr3 |
||
4794 | mov cr3, edi ;flush TLB |
||
4795 | |||
4796 | call pword [apm_entry] ;call APM BIOS |
||
4797 | |||
4798 | xchg eax, [esp] |
||
4799 | mov [master_tab], eax |
||
4800 | mov eax, cr3 |
||
4801 | mov cr3, eax |
||
4802 | pop eax |
||
4803 | |||
4804 | mov [esp + 4 ], edi |
||
4805 | mov [esp + 8], esi |
||
4806 | mov [esp + 20], ebx |
||
4807 | mov [esp + 24], edx |
||
4808 | mov [esp + 28], ecx |
||
4809 | mov [esp + 32], eax |
||
4810 | setc al |
||
4811 | and [esp + 44], byte 0xfe |
||
4812 | or [esp + 44], al |
||
4813 | ret |
||
4814 | ; ----------------------------------------- |
||
4815 | |||
4816 | align 4 |
||
4817 | undefined_syscall: ; Undefined system call |
||
4818 | mov [esp + 32], dword -1 |
||
4819 | ret |
||
4820 | |||
8160 | rgimad | 4821 | align 4 |
8962 | Boppan | 4822 | ; @brief Check if given memory region lays in lower 2gb (userspace memory) or not |
4823 | ; @param base Base address of region |
||
4824 | ; @param len Lenght of region |
||
4825 | ; @return ZF = 1 if region in userspace memory, |
||
4826 | ; ZF = 0 otherwise |
||
8329 | rgimad | 4827 | proc is_region_userspace stdcall, base:dword, len:dword |
9045 | dunkaist | 4828 | push eax |
8329 | rgimad | 4829 | mov eax, [base] |
8216 | rgimad | 4830 | |
9045 | dunkaist | 4831 | cmp eax, OS_BASE-1 |
4832 | ja @f ; zf |
||
8216 | rgimad | 4833 | |
8329 | rgimad | 4834 | add eax, [len] |
9045 | dunkaist | 4835 | jc @f ; zf |
8160 | rgimad | 4836 | cmp eax, OS_BASE |
9045 | dunkaist | 4837 | ja @f ; zf |
2288 | clevermous | 4838 | |
9045 | dunkaist | 4839 | cmp eax, eax ; ZF |
8160 | rgimad | 4840 | @@: |
9045 | dunkaist | 4841 | pop eax |
8160 | rgimad | 4842 | ret |
8329 | rgimad | 4843 | endp |
8160 | rgimad | 4844 | |
3627 | Serge | 4845 | if ~ lang eq sp |
4846 | diff16 "end of .text segment",0,$ |
||
4847 | end if |
||
4848 | |||
2288 | clevermous | 4849 | include "data32.inc" |
4850 | |||
4851 | __REV__ = __REV |
||
4852 | |||
3341 | yogev_ezra | 4853 | if ~ lang eq sp |
2288 | clevermous | 4854 | diff16 "end of kernel code",0,$ |
3287 | esevece | 4855 | end if=> |