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