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