Rev 4434 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4434 | Rev 4457 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. |
4 | ;; PROGRAMMING: |
4 | ;; PROGRAMMING: |
5 | ;; Ivan Poddubny |
5 | ;; Ivan Poddubny |
6 | ;; Marat Zakiyanov (Mario79) |
6 | ;; Marat Zakiyanov (Mario79) |
7 | ;; VaStaNi |
7 | ;; VaStaNi |
8 | ;; Trans |
8 | ;; Trans |
9 | ;; Mihail Semenyako (mike.dld) |
9 | ;; Mihail Semenyako (mike.dld) |
10 | ;; Sergey Kuzmin (Wildwest) |
10 | ;; Sergey Kuzmin (Wildwest) |
11 | ;; Andrey Halyavin (halyavin) |
11 | ;; Andrey Halyavin (halyavin) |
12 | ;; Mihail Lisovin (Mihasik) |
12 | ;; Mihail Lisovin (Mihasik) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
13 | ;; Andrey Ignatiev (andrew_programmer) |
14 | ;; NoName |
14 | ;; NoName |
15 | ;; Evgeny Grechnikov (Diamond) |
15 | ;; Evgeny Grechnikov (Diamond) |
16 | ;; Iliya Mihailov (Ghost) |
16 | ;; Iliya Mihailov (Ghost) |
17 | ;; Sergey Semyonov (Serge) |
17 | ;; Sergey Semyonov (Serge) |
18 | ;; Johnny_B |
18 | ;; Johnny_B |
19 | ;; SPraid (simba) |
19 | ;; SPraid (simba) |
20 | ;; Hidnplayr |
20 | ;; Hidnplayr |
21 | ;; Alexey Teplov ( |
21 | ;; Alexey Teplov ( |
22 | ;; Rus |
22 | ;; Rus |
23 | ;; Nable |
23 | ;; Nable |
24 | ;; shurf |
24 | ;; shurf |
25 | ;; Alver |
25 | ;; Alver |
26 | ;; Maxis |
26 | ;; Maxis |
27 | ;; Galkov |
27 | ;; Galkov |
28 | ;; CleverMouse |
28 | ;; CleverMouse |
29 | ;; tsdima |
29 | ;; tsdima |
30 | ;; turbanoff |
30 | ;; turbanoff |
31 | ;; Asper |
31 | ;; Asper |
32 | ;; art_zh |
32 | ;; art_zh |
33 | ;; |
33 | ;; |
34 | ;; Data in this file was originally part of MenuetOS project which is |
34 | ;; Data in this file was originally part of MenuetOS project which is |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
35 | ;; distributed under the terms of GNU GPL. It is modified and redistributed as |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
36 | ;; part of KolibriOS project under the terms of GNU GPL. |
37 | ;; |
37 | ;; |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
38 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa |
39 | ;; PROGRAMMING: |
39 | ;; PROGRAMMING: |
40 | ;; |
40 | ;; |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
41 | ;; Ville Mikael Turjanmaa, villemt@itu.jyu.fi |
42 | ;; - main os coding/design |
42 | ;; - main os coding/design |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
43 | ;; Jan-Michael Brummer, BUZZ2@gmx.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
44 | ;; Felix Kaiser, info@felix-kaiser.de |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
45 | ;; Paolo Minazzi, paolo.minazzi@inwind.it |
46 | ;; quickcode@mail.ru |
46 | ;; quickcode@mail.ru |
47 | ;; Alexey, kgaz@crosswinds.net |
47 | ;; Alexey, kgaz@crosswinds.net |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
48 | ;; Juan M. Caravaca, bitrider@wanadoo.es |
49 | ;; kristol@nic.fi |
49 | ;; kristol@nic.fi |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
50 | ;; Mike Hibbett, mikeh@oceanfree.net |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
51 | ;; Lasse Kuusijarvi, kuusijar@lut.fi |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
52 | ;; Jarek Pelczar, jarekp3@wp.pl |
53 | ;; |
53 | ;; |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
54 | ;; KolibriOS is distributed in the hope that it will be useful, but WITHOUT ANY |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
55 | ;; WARRANTY. No author or distributor accepts responsibility to anyone for the |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
56 | ;; consequences of using it or for whether it serves any particular purpose or |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
57 | ;; works at all, unless he says so in writing. Refer to the GNU General Public |
58 | ;; License (the "GPL") for full details. |
58 | ;; License (the "GPL") for full details. |
59 | ; |
59 | ; |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
60 | ;; Everyone is granted permission to copy, modify and redistribute KolibriOS, |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
61 | ;; but only under the conditions described in the GPL. A copy of this license |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
62 | ;; is supposed to have been given to you along with KolibriOS so you can know |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
63 | ;; your rights and responsibilities. It should be in a file named COPYING. |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
64 | ;; Among other things, the copyright notice and this notice must be preserved |
65 | ;; on all copies. |
65 | ;; on all copies. |
66 | ;; |
66 | ;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
68 | 68 | ||
69 | format binary as "mnt" |
69 | format binary as "mnt" |
70 | 70 | ||
71 | include 'macros.inc' |
71 | include 'macros.inc' |
72 | include 'struct.inc' |
72 | include 'struct.inc' |
73 | 73 | ||
74 | $Revision: 4381 $ |
74 | $Revision: 4381 $ |
75 | 75 | ||
- | 76 | ||
- | 77 | USE_FIX_FOR_INVALID_MS_VIRTUAL_PC_2007 equ 0 |
|
76 | 78 | ||
77 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
79 | USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices |
78 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
80 | VESA_1_2_VIDEO equ 0 ; enable vesa 1.2 bank switch functions |
79 | 81 | ||
80 | ; Enabling the next line will enable serial output console |
82 | ; Enabling the next line will enable serial output console |
81 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
83 | ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
82 | 84 | ||
83 | include "proc32.inc" |
85 | include "proc32.inc" |
84 | include "kglobals.inc" |
86 | include "kglobals.inc" |
85 | include "lang.inc" |
87 | include "lang.inc" |
86 | include "encoding.inc" |
88 | include "encoding.inc" |
87 | 89 | ||
88 | include "const.inc" |
90 | include "const.inc" |
89 | 91 | ||
90 | iglobal |
92 | iglobal |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
93 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
92 | debug_direct_print db 0 |
94 | debug_direct_print db 0 |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
95 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
94 | launcher_start db 1 |
96 | launcher_start db 1 |
95 | endg |
97 | endg |
96 | 98 | ||
97 | max_processes equ 255 |
99 | max_processes equ 255 |
98 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
100 | tss_step equ (128+8192) ; tss & i/o - 65535 ports, * 256=557056*4 |
99 | 101 | ||
100 | os_stack equ (os_data_l-gdts) ; GDTs |
102 | os_stack equ (os_data_l-gdts) ; GDTs |
101 | os_code equ (os_code_l-gdts) |
103 | os_code equ (os_code_l-gdts) |
102 | graph_data equ (3+graph_data_l-gdts) |
104 | graph_data equ (3+graph_data_l-gdts) |
103 | tss0 equ (tss0_l-gdts) |
105 | tss0 equ (tss0_l-gdts) |
104 | app_code equ (3+app_code_l-gdts) |
106 | app_code equ (3+app_code_l-gdts) |
105 | app_data equ (3+app_data_l-gdts) |
107 | app_data equ (3+app_data_l-gdts) |
106 | app_tls equ (3+tls_data_l-gdts) |
108 | app_tls equ (3+tls_data_l-gdts) |
107 | pci_code_sel equ (pci_code_32-gdts) |
109 | pci_code_sel equ (pci_code_32-gdts) |
108 | pci_data_sel equ (pci_data_32-gdts) |
110 | pci_data_sel equ (pci_data_32-gdts) |
109 | 111 | ||
110 | 112 | ||
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
113 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
112 | ;; |
114 | ;; |
113 | ;; Included files: |
115 | ;; Included files: |
114 | ;; |
116 | ;; |
115 | ;; Kernel16.inc |
117 | ;; Kernel16.inc |
116 | ;; - Booteng.inc English text for bootup |
118 | ;; - Booteng.inc English text for bootup |
117 | ;; - Bootcode.inc Hardware setup |
119 | ;; - Bootcode.inc Hardware setup |
118 | ;; - Pci16.inc PCI functions |
120 | ;; - Pci16.inc PCI functions |
119 | ;; |
121 | ;; |
120 | ;; Kernel32.inc |
122 | ;; Kernel32.inc |
121 | ;; - Sys32.inc Process management |
123 | ;; - Sys32.inc Process management |
122 | ;; - Shutdown.inc Shutdown and restart |
124 | ;; - Shutdown.inc Shutdown and restart |
123 | ;; - Fat32.inc Read / write hd |
125 | ;; - Fat32.inc Read / write hd |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
126 | ;; - Vesa12.inc Vesa 1.2 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
127 | ;; - Vesa20.inc Vesa 2.0 driver |
126 | ;; - Vga.inc VGA driver |
128 | ;; - Vga.inc VGA driver |
127 | ;; - Stack.inc Network interface |
129 | ;; - Stack.inc Network interface |
128 | ;; - Mouse.inc Mouse pointer |
130 | ;; - Mouse.inc Mouse pointer |
129 | ;; - Scincode.inc Window skinning |
131 | ;; - Scincode.inc Window skinning |
130 | ;; - Pci32.inc PCI functions |
132 | ;; - Pci32.inc PCI functions |
131 | ;; |
133 | ;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
134 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | 135 | ||
134 | 136 | ||
135 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
137 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
136 | ;; ;; |
138 | ;; ;; |
137 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
139 | ;; 16 BIT ENTRY FROM BOOTSECTOR ;; |
138 | ;; ;; |
140 | ;; ;; |
139 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
140 | 142 | ||
141 | use16 |
143 | use16 |
142 | org 0x0 |
144 | org 0x0 |
143 | jmp start_of_code |
145 | jmp start_of_code |
144 | 146 | ||
145 | if lang eq sp |
147 | if lang eq sp |
146 | include "kernelsp.inc" ; spanish kernel messages |
148 | include "kernelsp.inc" ; spanish kernel messages |
147 | else if lang eq et |
149 | else if lang eq et |
148 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
150 | version db 'Kolibri OS versioon 0.7.7.0+ ',13,10,13,10,0 |
149 | else |
151 | else |
150 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
152 | version db 'Kolibri OS version 0.7.7.0+ ',13,10,13,10,0 |
151 | end if |
153 | end if |
152 | 154 | ||
153 | include "boot/bootstr.inc" ; language-independent boot messages |
155 | include "boot/bootstr.inc" ; language-independent boot messages |
154 | include "boot/preboot.inc" |
156 | include "boot/preboot.inc" |
155 | 157 | ||
156 | if lang eq ge |
158 | if lang eq ge |
157 | include "boot/bootge.inc" ; german system boot messages |
159 | include "boot/bootge.inc" ; german system boot messages |
158 | else if lang eq sp |
160 | else if lang eq sp |
159 | include "boot/bootsp.inc" ; spanish system boot messages |
161 | include "boot/bootsp.inc" ; spanish system boot messages |
160 | else if lang eq ru |
162 | else if lang eq ru |
161 | include "boot/bootru.inc" ; russian system boot messages |
163 | include "boot/bootru.inc" ; russian system boot messages |
162 | include "boot/ru.inc" ; Russian font |
164 | include "boot/ru.inc" ; Russian font |
163 | else if lang eq et |
165 | else if lang eq et |
164 | include "boot/bootet.inc" ; estonian system boot messages |
166 | include "boot/bootet.inc" ; estonian system boot messages |
165 | include "boot/et.inc" ; Estonian font |
167 | include "boot/et.inc" ; Estonian font |
166 | else |
168 | else |
167 | include "boot/booten.inc" ; english system boot messages |
169 | include "boot/booten.inc" ; english system boot messages |
168 | end if |
170 | end if |
169 | 171 | ||
170 | include "boot/bootcode.inc" ; 16 bit system boot code |
172 | include "boot/bootcode.inc" ; 16 bit system boot code |
171 | include "bus/pci/pci16.inc" |
173 | include "bus/pci/pci16.inc" |
172 | include "detect/biosdisk.inc" |
174 | include "detect/biosdisk.inc" |
173 | 175 | ||
174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
175 | ;; ;; |
177 | ;; ;; |
176 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
178 | ;; SWITCH TO 32 BIT PROTECTED MODE ;; |
177 | ;; ;; |
179 | ;; ;; |
178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
179 | 181 | ||
180 | cld |
182 | cld |
181 | 183 | ||
182 | ; Enabling 32 bit protected mode |
184 | ; Enabling 32 bit protected mode |
183 | 185 | ||
184 | mov ecx, CR0_PE ; CR0 Flags - Protected mode and Paging |
186 | mov ecx, CR0_PE ; CR0 Flags - Protected mode and Paging |
185 | lgdt [cs:tmp_gdt] ; Load GDT |
187 | lgdt [cs:tmp_gdt] ; Load GDT |
186 | mov eax, cr0 ; protected mode |
188 | mov eax, cr0 ; protected mode |
187 | or eax, ecx |
189 | or eax, ecx |
188 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
190 | and eax, 10011111b *65536*256 + 0xffffff ; caching enabled |
189 | mov cr0, eax |
191 | mov cr0, eax |
190 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
192 | jmp pword os_code:B32 ; jmp to enable 32 bit mode |
191 | 193 | ||
192 | align 8 |
194 | align 8 |
193 | tmp_gdt: |
195 | tmp_gdt: |
194 | 196 | ||
195 | dw 23 |
197 | dw 23 |
196 | dd tmp_gdt+0x10000 |
198 | dd tmp_gdt+0x10000 |
197 | dw 0 |
199 | dw 0 |
198 | 200 | ||
199 | dw 0xffff |
201 | dw 0xffff |
200 | dw 0x0000 |
202 | dw 0x0000 |
201 | db 0x00 |
203 | db 0x00 |
202 | dw 11011111b *256 +10011010b |
204 | dw 11011111b *256 +10011010b |
203 | db 0x00 |
205 | db 0x00 |
204 | 206 | ||
205 | dw 0xffff |
207 | dw 0xffff |
206 | dw 0x0000 |
208 | dw 0x0000 |
207 | db 0x00 |
209 | db 0x00 |
208 | dw 11011111b *256 +10010010b |
210 | dw 11011111b *256 +10010010b |
209 | db 0x00 |
211 | db 0x00 |
210 | 212 | ||
211 | include "data16.inc" |
213 | include "data16.inc" |
212 | 214 | ||
213 | if ~ lang eq sp |
215 | if ~ lang eq sp |
214 | diff16 "end of bootcode",0,$+0x10000 |
216 | diff16 "end of bootcode",0,$+0x10000 |
215 | end if |
217 | end if |
216 | 218 | ||
217 | use32 |
219 | use32 |
218 | org $+0x10000 |
220 | org $+0x10000 |
219 | 221 | ||
220 | align 4 |
222 | align 4 |
221 | B32: |
223 | B32: |
222 | mov ax, os_stack ; Selector for os |
224 | mov ax, os_stack ; Selector for os |
223 | mov ds, ax |
225 | mov ds, ax |
224 | mov es, ax |
226 | mov es, ax |
225 | mov fs, ax |
227 | mov fs, ax |
226 | mov gs, ax |
228 | mov gs, ax |
227 | mov ss, ax |
229 | mov ss, ax |
228 | mov esp, 0x006CC00 ; Set stack |
230 | mov esp, 0x006CC00 ; Set stack |
229 | 231 | ||
230 | ; CLEAR 0x280000 - HEAP_BASE |
232 | ; CLEAR 0x280000 - HEAP_BASE |
231 | 233 | ||
232 | xor eax, eax |
234 | xor eax, eax |
233 | mov edi, CLEAN_ZONE |
235 | mov edi, CLEAN_ZONE |
234 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
236 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
235 | cld |
237 | cld |
236 | rep stosd |
238 | rep stosd |
237 | 239 | ||
238 | ; CLEAR KERNEL UNDEFINED GLOBALS |
240 | ; CLEAR KERNEL UNDEFINED GLOBALS |
239 | mov edi, endofcode-OS_BASE |
241 | mov edi, endofcode-OS_BASE |
240 | mov ecx, 0x90000 |
242 | mov ecx, 0x90000 |
241 | sub ecx, edi |
243 | sub ecx, edi |
242 | shr ecx, 2 |
244 | shr ecx, 2 |
243 | rep stosd |
245 | rep stosd |
244 | 246 | ||
245 | ; SAVE & CLEAR 0-0xffff |
247 | ; SAVE & CLEAR 0-0xffff |
246 | 248 | ||
247 | mov edi, 0x1000 |
249 | mov edi, 0x1000 |
248 | mov ecx, 0x8000 / 4 |
250 | mov ecx, 0x8000 / 4 |
249 | rep stosd |
251 | rep stosd |
250 | mov edi, 0xa000 |
252 | mov edi, 0xa000 |
251 | mov ecx, 0x6000 / 4 |
253 | mov ecx, 0x6000 / 4 |
252 | rep stosd |
254 | rep stosd |
253 | 255 | ||
254 | call test_cpu |
256 | call test_cpu |
255 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
257 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
256 | 258 | ||
257 | call check_acpi |
259 | call check_acpi |
258 | call init_BIOS32 |
260 | call init_BIOS32 |
259 | ; MEMORY MODEL |
261 | ; MEMORY MODEL |
260 | call mem_test |
262 | call mem_test |
261 | call init_mem |
263 | call init_mem |
262 | call init_page_map |
264 | call init_page_map |
263 | 265 | ||
264 | ; ENABLE PAGING |
266 | ; ENABLE PAGING |
265 | 267 | ||
266 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
268 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
267 | mov cr3, eax |
269 | mov cr3, eax |
268 | 270 | ||
269 | mov eax, cr0 |
271 | mov eax, cr0 |
270 | or eax, CR0_PG+CR0_WP |
272 | or eax, CR0_PG+CR0_WP |
271 | mov cr0, eax |
273 | mov cr0, eax |
272 | 274 | ||
273 | lgdt [gdts] |
275 | lgdt [gdts] |
274 | jmp pword os_code:high_code |
276 | jmp pword os_code:high_code |
275 | 277 | ||
276 | align 4 |
278 | align 4 |
277 | bios32_entry dd ? |
279 | bios32_entry dd ? |
278 | tmp_page_tabs dd ? |
280 | tmp_page_tabs dd ? |
279 | 281 | ||
280 | use16 |
282 | use16 |
281 | org $-0x10000 |
283 | org $-0x10000 |
282 | include "boot/shutdown.inc" ; shutdown or restart |
284 | include "boot/shutdown.inc" ; shutdown or restart |
283 | org $+0x10000 |
285 | org $+0x10000 |
284 | use32 |
286 | use32 |
285 | 287 | ||
286 | __DEBUG__ fix 1 |
288 | __DEBUG__ fix 1 |
287 | __DEBUG_LEVEL__ fix 1 |
289 | __DEBUG_LEVEL__ fix 1 |
288 | include 'init.inc' |
290 | include 'init.inc' |
289 | 291 | ||
290 | org OS_BASE+$ |
292 | org OS_BASE+$ |
291 | 293 | ||
292 | include 'fdo.inc' |
294 | include 'fdo.inc' |
293 | 295 | ||
294 | align 4 |
296 | align 4 |
295 | high_code: |
297 | high_code: |
296 | mov ax, os_stack |
298 | mov ax, os_stack |
297 | mov bx, app_data |
299 | mov bx, app_data |
298 | mov cx, app_tls |
300 | mov cx, app_tls |
299 | mov ss, ax |
301 | mov ss, ax |
300 | add esp, OS_BASE |
302 | add esp, OS_BASE |
301 | 303 | ||
302 | mov ds, bx |
304 | mov ds, bx |
303 | mov es, bx |
305 | mov es, bx |
304 | mov fs, cx |
306 | mov fs, cx |
305 | mov gs, bx |
307 | mov gs, bx |
306 | 308 | ||
307 | bt [cpu_caps], CAPS_PGE |
309 | bt [cpu_caps], CAPS_PGE |
308 | jnc @F |
310 | jnc @F |
309 | 311 | ||
310 | or dword [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], PG_GLOBAL |
312 | or dword [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], PG_GLOBAL |
311 | 313 | ||
312 | mov ebx, cr4 |
314 | mov ebx, cr4 |
313 | or ebx, CR4_PGE |
315 | or ebx, CR4_PGE |
314 | mov cr4, ebx |
316 | mov cr4, ebx |
315 | @@: |
317 | @@: |
316 | xor eax, eax |
318 | xor eax, eax |
317 | mov dword [sys_proc+PROC.pdt_0], eax |
319 | mov dword [sys_proc+PROC.pdt_0], eax |
318 | mov dword [sys_proc+PROC.pdt_0+4], eax |
320 | mov dword [sys_proc+PROC.pdt_0+4], eax |
319 | 321 | ||
320 | mov eax, cr3 |
322 | mov eax, cr3 |
321 | mov cr3, eax ; flush TLB |
323 | mov cr3, eax ; flush TLB |
322 | 324 | ||
323 | mov ecx, pg_data.mutex |
325 | mov ecx, pg_data.mutex |
324 | call mutex_init |
326 | call mutex_init |
325 | 327 | ||
326 | mov ecx, disk_list_mutex |
328 | mov ecx, disk_list_mutex |
327 | call mutex_init |
329 | call mutex_init |
328 | 330 | ||
329 | mov ecx, keyboard_list_mutex |
331 | mov ecx, keyboard_list_mutex |
330 | call mutex_init |
332 | call mutex_init |
331 | 333 | ||
332 | mov ecx, unpack_mutex |
334 | mov ecx, unpack_mutex |
333 | call mutex_init |
335 | call mutex_init |
334 | 336 | ||
335 | mov ecx, application_table_mutex |
337 | mov ecx, application_table_mutex |
336 | call mutex_init |
338 | call mutex_init |
337 | 339 | ||
338 | mov ecx, ide_mutex |
340 | mov ecx, ide_mutex |
339 | call mutex_init |
341 | call mutex_init |
340 | mov ecx, ide_channel1_mutex |
342 | mov ecx, ide_channel1_mutex |
341 | call mutex_init |
343 | call mutex_init |
342 | mov ecx, ide_channel2_mutex |
344 | mov ecx, ide_channel2_mutex |
343 | call mutex_init |
345 | call mutex_init |
344 | ;----------------------------------------------------------------------------- |
346 | ;----------------------------------------------------------------------------- |
345 | ; SAVE REAL MODE VARIABLES |
347 | ; SAVE REAL MODE VARIABLES |
346 | ;----------------------------------------------------------------------------- |
348 | ;----------------------------------------------------------------------------- |
347 | save_variables_IDE_controller: |
349 | save_variables_IDE_controller: |
348 | xor eax, eax |
350 | xor eax, eax |
349 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
351 | mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] |
350 | mov [IDE_Interrupt], ax |
352 | mov [IDE_Interrupt], ax |
351 | ;-------------------------------------- |
353 | ;-------------------------------------- |
352 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
354 | mov ax, [BOOT_VARS + BOOT_IDE_PI_16] |
353 | mov [IDEContrProgrammingInterface], ax |
355 | mov [IDEContrProgrammingInterface], ax |
354 | ;-------------------------------------- |
356 | ;-------------------------------------- |
355 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
357 | mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] |
356 | mov [IDEContrRegsBaseAddr], ax |
358 | mov [IDEContrRegsBaseAddr], ax |
357 | ;-------------------------------------- |
359 | ;-------------------------------------- |
358 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
360 | mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] |
359 | cmp ax, 0 |
361 | cmp ax, 0 |
360 | je @f |
362 | je @f |
361 | cmp ax, 1 |
363 | cmp ax, 1 |
362 | jne .no_PATA_BAR0 |
364 | jne .no_PATA_BAR0 |
363 | @@: |
365 | @@: |
364 | mov ax, 0x1F0 |
366 | mov ax, 0x1F0 |
365 | jmp @f |
367 | jmp @f |
366 | .no_PATA_BAR0: |
368 | .no_PATA_BAR0: |
367 | and ax, 0xFFFC |
369 | and ax, 0xFFFC |
368 | @@: |
370 | @@: |
369 | mov [StandardATABases], ax |
371 | mov [StandardATABases], ax |
370 | mov [hd_address_table], eax |
372 | mov [hd_address_table], eax |
371 | mov [hd_address_table+8], eax |
373 | mov [hd_address_table+8], eax |
372 | mov [IDE_BAR0_val], ax |
374 | mov [IDE_BAR0_val], ax |
373 | ;-------------------------------------- |
375 | ;-------------------------------------- |
374 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
376 | mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16] |
375 | cmp ax, 0 |
377 | cmp ax, 0 |
376 | je @f |
378 | je @f |
377 | cmp ax, 1 |
379 | cmp ax, 1 |
378 | jne .no_PATA_BAR1 |
380 | jne .no_PATA_BAR1 |
379 | @@: |
381 | @@: |
380 | mov ax, 0x3F4 |
382 | mov ax, 0x3F4 |
381 | jmp @f |
383 | jmp @f |
382 | .no_PATA_BAR1: |
384 | .no_PATA_BAR1: |
383 | and ax, 0xFFFC |
385 | and ax, 0xFFFC |
384 | @@: |
386 | @@: |
385 | mov [IDE_BAR1_val], ax |
387 | mov [IDE_BAR1_val], ax |
386 | ;-------------------------------------- |
388 | ;-------------------------------------- |
387 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
389 | mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16] |
388 | cmp ax, 0 |
390 | cmp ax, 0 |
389 | je @f |
391 | je @f |
390 | cmp ax, 1 |
392 | cmp ax, 1 |
391 | jne .no_PATA_BAR2 |
393 | jne .no_PATA_BAR2 |
392 | @@: |
394 | @@: |
393 | mov ax, 0x170 |
395 | mov ax, 0x170 |
394 | jmp @f |
396 | jmp @f |
395 | .no_PATA_BAR2: |
397 | .no_PATA_BAR2: |
396 | and ax, 0xFFFC |
398 | and ax, 0xFFFC |
397 | @@: |
399 | @@: |
398 | mov [StandardATABases+2], ax |
400 | mov [StandardATABases+2], ax |
399 | mov [hd_address_table+16], eax |
401 | mov [hd_address_table+16], eax |
400 | mov [hd_address_table+24], eax |
402 | mov [hd_address_table+24], eax |
401 | mov [IDE_BAR2_val], ax |
403 | mov [IDE_BAR2_val], ax |
402 | ;-------------------------------------- |
404 | ;-------------------------------------- |
403 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
405 | mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16] |
404 | cmp ax, 0 |
406 | cmp ax, 0 |
405 | je @f |
407 | je @f |
406 | cmp ax, 1 |
408 | cmp ax, 1 |
407 | jne .no_PATA_BAR3 |
409 | jne .no_PATA_BAR3 |
408 | @@: |
410 | @@: |
409 | mov ax, 0x374 |
411 | mov ax, 0x374 |
410 | jmp @f |
412 | jmp @f |
411 | .no_PATA_BAR3: |
413 | .no_PATA_BAR3: |
412 | and ax, 0xFFFC |
414 | and ax, 0xFFFC |
413 | @@: |
415 | @@: |
414 | mov [IDE_BAR3_val], ax |
416 | mov [IDE_BAR3_val], ax |
415 | 417 | ||
416 | ; --------------- APM --------------------- |
418 | ; --------------- APM --------------------- |
417 | 419 | ||
418 | ; init selectors |
420 | ; init selectors |
419 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
421 | mov ebx, [BOOT_VARS+BOOT_APM_ENTRY] ; offset of APM entry point |
420 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
422 | movzx eax, word [BOOT_VARS+BOOT_APM_CODE_32] ; real-mode segment base address of |
421 | ; protected-mode 32-bit code segment |
423 | ; protected-mode 32-bit code segment |
422 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
424 | movzx ecx, word [BOOT_VARS+BOOT_APM_CODE_16]; real-mode segment base address of |
423 | ; protected-mode 16-bit code segment |
425 | ; protected-mode 16-bit code segment |
424 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
426 | movzx edx, word [BOOT_VARS+BOOT_APM_DATA_16]; real-mode segment base address of |
425 | ; protected-mode 16-bit data segment |
427 | ; protected-mode 16-bit data segment |
426 | 428 | ||
427 | shl eax, 4 |
429 | shl eax, 4 |
428 | mov [dword apm_code_32 + 2], ax |
430 | mov [dword apm_code_32 + 2], ax |
429 | shr eax, 16 |
431 | shr eax, 16 |
430 | mov [dword apm_code_32 + 4], al |
432 | mov [dword apm_code_32 + 4], al |
431 | 433 | ||
432 | shl ecx, 4 |
434 | shl ecx, 4 |
433 | mov [dword apm_code_16 + 2], cx |
435 | mov [dword apm_code_16 + 2], cx |
434 | shr ecx, 16 |
436 | shr ecx, 16 |
435 | mov [dword apm_code_16 + 4], cl |
437 | mov [dword apm_code_16 + 4], cl |
436 | 438 | ||
437 | shl edx, 4 |
439 | shl edx, 4 |
438 | mov [dword apm_data_16 + 2], dx |
440 | mov [dword apm_data_16 + 2], dx |
439 | shr edx, 16 |
441 | shr edx, 16 |
440 | mov [dword apm_data_16 + 4], dl |
442 | mov [dword apm_data_16 + 4], dl |
441 | 443 | ||
442 | mov dword[apm_entry], ebx |
444 | mov dword[apm_entry], ebx |
443 | mov word [apm_entry + 4], apm_code_32 - gdts |
445 | mov word [apm_entry + 4], apm_code_32 - gdts |
444 | 446 | ||
445 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
447 | mov eax, [BOOT_VARS + BOOT_APM_VERSION] ; version & flags |
446 | mov [apm_vf], eax |
448 | mov [apm_vf], eax |
447 | ; ----------------------------------------- |
449 | ; ----------------------------------------- |
448 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
450 | mov al, [BOOT_VARS+BOOT_DMA] ; DMA access |
449 | mov [allow_dma_access], al |
451 | mov [allow_dma_access], al |
450 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
452 | movzx eax, byte [BOOT_VARS+BOOT_BPP] ; bpp |
451 | mov [_display.bpp], eax |
453 | mov [_display.bpp], eax |
452 | mov [_display.vrefresh], 60 |
454 | mov [_display.vrefresh], 60 |
453 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
455 | mov al, [BOOT_VARS+BOOT_DEBUG_PRINT] ; If nonzero, duplicates debug output to the screen |
454 | mov [debug_direct_print], al |
456 | mov [debug_direct_print], al |
455 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
457 | mov al, [BOOT_VARS+BOOT_LAUNCHER_START] ; Start the first app (LAUNCHER) after kernel is loaded? |
456 | mov [launcher_start], al |
458 | mov [launcher_start], al |
457 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
459 | movzx eax, word [BOOT_VARS+BOOT_X_RES]; X max |
458 | mov [_display.width], eax |
460 | mov [_display.width], eax |
459 | mov [display_width_standard], eax |
461 | mov [display_width_standard], eax |
460 | dec eax |
462 | dec eax |
461 | mov [Screen_Max_X], eax |
463 | mov [Screen_Max_X], eax |
462 | mov [screen_workarea.right], eax |
464 | mov [screen_workarea.right], eax |
463 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
465 | movzx eax, word [BOOT_VARS+BOOT_Y_RES]; Y max |
464 | mov [_display.height], eax |
466 | mov [_display.height], eax |
465 | mov [display_height_standard], eax |
467 | mov [display_height_standard], eax |
466 | dec eax |
468 | dec eax |
467 | mov [Screen_Max_Y], eax |
469 | mov [Screen_Max_Y], eax |
468 | mov [screen_workarea.bottom], eax |
470 | mov [screen_workarea.bottom], eax |
469 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
471 | movzx eax, word [BOOT_VARS+BOOT_VESA_MODE] ; screen mode |
470 | mov dword [SCR_MODE], eax |
472 | mov dword [SCR_MODE], eax |
471 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
473 | ; mov eax, [BOOT_VAR+0x9014] ; Vesa 1.2 bnk sw add |
472 | ; mov [BANK_SWITCH], eax |
474 | ; mov [BANK_SWITCH], eax |
473 | mov eax, 640 *4 ; Bytes PerScanLine |
475 | mov eax, 640 *4 ; Bytes PerScanLine |
474 | cmp [SCR_MODE], word 0x13 ; 320x200 |
476 | cmp [SCR_MODE], word 0x13 ; 320x200 |
475 | je @f |
477 | je @f |
476 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
478 | cmp [SCR_MODE], word 0x12 ; VGA 640x480 |
477 | je @f |
479 | je @f |
478 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
480 | movzx eax, word[BOOT_VARS+BOOT_PITCH] ; for other modes |
479 | @@: |
481 | @@: |
480 | mov [_display.pitch], eax |
482 | mov [_display.pitch], eax |
481 | mov eax, [_display.width] |
483 | mov eax, [_display.width] |
482 | mul [_display.height] |
484 | mul [_display.height] |
483 | mov [_WinMapSize], eax |
485 | mov [_WinMapSize], eax |
484 | 486 | ||
485 | call calculate_fast_getting_offset_for_WinMapAddress |
487 | call calculate_fast_getting_offset_for_WinMapAddress |
486 | ; for Qemu or non standart video cards |
488 | ; for Qemu or non standart video cards |
487 | ; Unfortunately [BytesPerScanLine] does not always |
489 | ; Unfortunately [BytesPerScanLine] does not always |
488 | ; equal to [_display.width] * [ScreenBPP] / 8 |
490 | ; equal to [_display.width] * [ScreenBPP] / 8 |
489 | call calculate_fast_getting_offset_for_LFB |
491 | call calculate_fast_getting_offset_for_LFB |
490 | 492 | ||
491 | mov esi, BOOT_VARS+0x9080 |
493 | mov esi, BOOT_VARS+0x9080 |
492 | movzx ecx, byte [esi-1] |
494 | movzx ecx, byte [esi-1] |
493 | mov [NumBiosDisks], ecx |
495 | mov [NumBiosDisks], ecx |
494 | mov edi, BiosDisksData |
496 | mov edi, BiosDisksData |
495 | rep movsd |
497 | rep movsd |
496 | 498 | ||
497 | ; GRAPHICS ADDRESSES |
499 | ; GRAPHICS ADDRESSES |
498 | 500 | ||
499 | mov eax, [BOOT_VARS+BOOT_LFB] |
501 | mov eax, [BOOT_VARS+BOOT_LFB] |
500 | mov [LFBAddress], eax |
502 | mov [LFBAddress], eax |
501 | 503 | ||
502 | cmp [SCR_MODE], word 0100000000000000b |
504 | cmp [SCR_MODE], word 0100000000000000b |
503 | jge setvesa20 |
505 | jge setvesa20 |
504 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
506 | cmp [SCR_MODE], word 0x13 ; EGA 320*200 256 colors |
505 | je v20ga32 |
507 | je v20ga32 |
506 | jmp v20ga24 |
508 | jmp v20ga24 |
507 | 509 | ||
508 | setvesa20: |
510 | setvesa20: |
509 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
511 | mov [PUTPIXEL], dword Vesa20_putpixel24 ; Vesa 2.0 |
510 | mov [GETPIXEL], dword Vesa20_getpixel24 |
512 | mov [GETPIXEL], dword Vesa20_getpixel24 |
511 | cmp byte [_display.bpp], 24 |
513 | cmp byte [_display.bpp], 24 |
512 | jz v20ga24 |
514 | jz v20ga24 |
513 | v20ga32: |
515 | v20ga32: |
514 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
516 | mov [PUTPIXEL], dword Vesa20_putpixel32 |
515 | mov [GETPIXEL], dword Vesa20_getpixel32 |
517 | mov [GETPIXEL], dword Vesa20_getpixel32 |
516 | jmp no_mode_0x12 |
518 | jmp no_mode_0x12 |
517 | v20ga24: |
519 | v20ga24: |
518 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
520 | cmp [SCR_MODE], word 0x12 ; 16 C VGA 640x480 |
519 | jne no_mode_0x12 |
521 | jne no_mode_0x12 |
520 | mov [PUTPIXEL], dword VGA_putpixel |
522 | mov [PUTPIXEL], dword VGA_putpixel |
521 | mov [GETPIXEL], dword Vesa20_getpixel32 |
523 | mov [GETPIXEL], dword Vesa20_getpixel32 |
522 | no_mode_0x12: |
524 | no_mode_0x12: |
523 | 525 | ||
524 | mov [MOUSE_PICTURE], dword mousepointer |
526 | mov [MOUSE_PICTURE], dword mousepointer |
525 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
527 | mov [_display.check_mouse], check_mouse_area_for_putpixel |
526 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
528 | mov [_display.check_m_pixel], check_mouse_area_for_getpixel |
527 | 529 | ||
528 | ; -------- Fast System Call init ---------- |
530 | ; -------- Fast System Call init ---------- |
529 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
531 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
530 | bt [cpu_caps], CAPS_SEP |
532 | bt [cpu_caps], CAPS_SEP |
531 | jnc .SEnP ; SysEnter not Present |
533 | jnc .SEnP ; SysEnter not Present |
532 | xor edx, edx |
534 | xor edx, edx |
533 | mov ecx, MSR_SYSENTER_CS |
535 | mov ecx, MSR_SYSENTER_CS |
534 | mov eax, os_code |
536 | mov eax, os_code |
535 | wrmsr |
537 | wrmsr |
536 | mov ecx, MSR_SYSENTER_ESP |
538 | mov ecx, MSR_SYSENTER_ESP |
537 | ; mov eax, sysenter_stack ; Check it |
539 | ; mov eax, sysenter_stack ; Check it |
538 | xor eax, eax |
540 | xor eax, eax |
539 | wrmsr |
541 | wrmsr |
540 | mov ecx, MSR_SYSENTER_EIP |
542 | mov ecx, MSR_SYSENTER_EIP |
541 | mov eax, sysenter_entry |
543 | mov eax, sysenter_entry |
542 | wrmsr |
544 | wrmsr |
543 | .SEnP: |
545 | .SEnP: |
544 | ; AMD SYSCALL/SYSRET |
546 | ; AMD SYSCALL/SYSRET |
545 | cmp byte[cpu_vendor], 'A' |
547 | cmp byte[cpu_vendor], 'A' |
546 | jne .noSYSCALL |
548 | jne .noSYSCALL |
547 | mov eax, 0x80000001 |
549 | mov eax, 0x80000001 |
548 | cpuid |
550 | cpuid |
549 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
551 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
550 | jz .noSYSCALL |
552 | jz .noSYSCALL |
551 | mov ecx, MSR_AMD_EFER |
553 | mov ecx, MSR_AMD_EFER |
552 | rdmsr |
554 | rdmsr |
553 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
555 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
554 | wrmsr |
556 | wrmsr |
555 | 557 | ||
556 | ; !!!! It`s dirty hack, fix it !!! |
558 | ; !!!! It`s dirty hack, fix it !!! |
557 | ; Bits of EDX : |
559 | ; Bits of EDX : |
558 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
560 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
559 | ; and the contents of this field, plus 8, are copied into the SS register. |
561 | ; and the contents of this field, plus 8, are copied into the SS register. |
560 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
562 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
561 | ; and the contents of this field, plus 8, are copied into the SS register. |
563 | ; and the contents of this field, plus 8, are copied into the SS register. |
562 | 564 | ||
563 | ; mov edx, (os_code + 16) * 65536 + os_code |
565 | ; mov edx, (os_code + 16) * 65536 + os_code |
564 | mov edx, 0x1B0008 |
566 | mov edx, 0x1B0008 |
565 | 567 | ||
566 | mov eax, syscall_entry |
568 | mov eax, syscall_entry |
567 | mov ecx, MSR_AMD_STAR |
569 | mov ecx, MSR_AMD_STAR |
568 | wrmsr |
570 | wrmsr |
569 | .noSYSCALL: |
571 | .noSYSCALL: |
570 | ; ----------------------------------------- |
572 | ; ----------------------------------------- |
571 | stdcall alloc_page |
573 | stdcall alloc_page |
572 | stdcall map_page, tss-0xF80, eax, PG_SW |
574 | stdcall map_page, tss-0xF80, eax, PG_SW |
573 | stdcall alloc_page |
575 | stdcall alloc_page |
574 | stdcall map_page, tss+0x80, eax, PG_SW |
576 | stdcall map_page, tss+0x80, eax, PG_SW |
575 | stdcall alloc_page |
577 | stdcall alloc_page |
576 | stdcall map_page, tss+0x1080, eax, PG_SW |
578 | stdcall map_page, tss+0x1080, eax, PG_SW |
577 | 579 | ||
578 | ; LOAD IDT |
580 | ; LOAD IDT |
579 | 581 | ||
580 | call build_interrupt_table ;lidt is executed |
582 | call build_interrupt_table ;lidt is executed |
581 | ;lidt [idtreg] |
583 | ;lidt [idtreg] |
582 | 584 | ||
583 | call init_kernel_heap |
585 | call init_kernel_heap |
584 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
586 | stdcall kernel_alloc, (RING0_STACK_SIZE+512) * 2 |
585 | mov [os_stack_seg], eax |
587 | mov [os_stack_seg], eax |
586 | 588 | ||
587 | lea esp, [eax+RING0_STACK_SIZE] |
589 | lea esp, [eax+RING0_STACK_SIZE] |
588 | 590 | ||
589 | mov [tss._ss0], os_stack |
591 | mov [tss._ss0], os_stack |
590 | mov [tss._esp0], esp |
592 | mov [tss._esp0], esp |
591 | mov [tss._esp], esp |
593 | mov [tss._esp], esp |
592 | mov [tss._cs], os_code |
594 | mov [tss._cs], os_code |
593 | mov [tss._ss], os_stack |
595 | mov [tss._ss], os_stack |
594 | mov [tss._ds], app_data |
596 | mov [tss._ds], app_data |
595 | mov [tss._es], app_data |
597 | mov [tss._es], app_data |
596 | mov [tss._fs], app_data |
598 | mov [tss._fs], app_data |
597 | mov [tss._gs], app_data |
599 | mov [tss._gs], app_data |
598 | mov [tss._io], 128 |
600 | mov [tss._io], 128 |
599 | ;Add IO access table - bit array of permitted ports |
601 | ;Add IO access table - bit array of permitted ports |
600 | mov edi, tss._io_map_0 |
602 | mov edi, tss._io_map_0 |
601 | xor eax, eax |
603 | xor eax, eax |
602 | not eax |
604 | not eax |
603 | mov ecx, 8192/4 |
605 | mov ecx, 8192/4 |
604 | rep stosd ; access to 4096*8=65536 ports |
606 | rep stosd ; access to 4096*8=65536 ports |
605 | 607 | ||
606 | mov ax, tss0 |
608 | mov ax, tss0 |
607 | ltr ax |
609 | ltr ax |
608 | 610 | ||
609 | mov [LFBSize], 0xC00000 |
611 | mov [LFBSize], 0xC00000 |
610 | call init_LFB |
612 | call init_LFB |
611 | call init_fpu |
613 | call init_fpu |
612 | call init_malloc |
614 | call init_malloc |
613 | 615 | ||
614 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
616 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
615 | mov [default_io_map], eax |
617 | mov [default_io_map], eax |
616 | 618 | ||
617 | add eax, 0x2000 |
619 | add eax, 0x2000 |
618 | mov [ipc_tmp], eax |
620 | mov [ipc_tmp], eax |
619 | mov ebx, 0x1000 |
621 | mov ebx, 0x1000 |
620 | 622 | ||
621 | add eax, 0x40000 |
623 | add eax, 0x40000 |
622 | mov [proc_mem_map], eax |
624 | mov [proc_mem_map], eax |
623 | 625 | ||
624 | add eax, 0x8000 |
626 | add eax, 0x8000 |
625 | mov [proc_mem_pdir], eax |
627 | mov [proc_mem_pdir], eax |
626 | 628 | ||
627 | add eax, ebx |
629 | add eax, ebx |
628 | mov [proc_mem_tab], eax |
630 | mov [proc_mem_tab], eax |
629 | 631 | ||
630 | add eax, ebx |
632 | add eax, ebx |
631 | mov [tmp_task_ptab], eax |
633 | mov [tmp_task_ptab], eax |
632 | 634 | ||
633 | add eax, ebx |
635 | add eax, ebx |
634 | mov [ipc_pdir], eax |
636 | mov [ipc_pdir], eax |
635 | 637 | ||
636 | add eax, ebx |
638 | add eax, ebx |
637 | mov [ipc_ptab], eax |
639 | mov [ipc_ptab], eax |
638 | 640 | ||
639 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
641 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
640 | (unpack.lc+unpack.lp)))*4 |
642 | (unpack.lc+unpack.lp)))*4 |
641 | 643 | ||
642 | mov [unpack.p], eax |
644 | mov [unpack.p], eax |
643 | 645 | ||
644 | call init_events |
646 | call init_events |
645 | mov eax, srv.fd-SRV.fd |
647 | mov eax, srv.fd-SRV.fd |
646 | mov [srv.fd], eax |
648 | mov [srv.fd], eax |
647 | mov [srv.bk], eax |
649 | mov [srv.bk], eax |
648 | 650 | ||
649 | ;Set base of graphic segment to linear address of LFB |
651 | ;Set base of graphic segment to linear address of LFB |
650 | mov eax, [LFBAddress] ; set for gs |
652 | mov eax, [LFBAddress] ; set for gs |
651 | mov [graph_data_l+2], ax |
653 | mov [graph_data_l+2], ax |
652 | shr eax, 16 |
654 | shr eax, 16 |
653 | mov [graph_data_l+4], al |
655 | mov [graph_data_l+4], al |
654 | mov [graph_data_l+7], ah |
656 | mov [graph_data_l+7], ah |
655 | 657 | ||
656 | stdcall kernel_alloc, [_WinMapSize] |
658 | stdcall kernel_alloc, [_WinMapSize] |
657 | mov [_WinMapAddress], eax |
659 | mov [_WinMapAddress], eax |
658 | 660 | ||
659 | xor eax, eax |
661 | xor eax, eax |
660 | inc eax |
662 | inc eax |
661 | 663 | ||
662 | ; set background |
664 | ; set background |
663 | 665 | ||
664 | mov [BgrDrawMode], eax |
666 | mov [BgrDrawMode], eax |
665 | mov [BgrDataWidth], eax |
667 | mov [BgrDataWidth], eax |
666 | mov [BgrDataHeight], eax |
668 | mov [BgrDataHeight], eax |
667 | mov [mem_BACKGROUND], 4 |
669 | mov [mem_BACKGROUND], 4 |
668 | mov [img_background], static_background_data |
670 | mov [img_background], static_background_data |
669 | 671 | ||
670 | ; set clipboard |
672 | ; set clipboard |
671 | 673 | ||
672 | xor eax, eax |
674 | xor eax, eax |
673 | mov [clipboard_slots], eax |
675 | mov [clipboard_slots], eax |
674 | mov [clipboard_write_lock], eax |
676 | mov [clipboard_write_lock], eax |
675 | stdcall kernel_alloc, 4096 |
677 | stdcall kernel_alloc, 4096 |
676 | test eax, eax |
678 | test eax, eax |
677 | jnz @f |
679 | jnz @f |
678 | 680 | ||
679 | dec eax |
681 | dec eax |
680 | @@: |
682 | @@: |
681 | mov [clipboard_main_list], eax |
683 | mov [clipboard_main_list], eax |
682 | 684 | ||
683 | ; SET UP OS TASK |
685 | ; SET UP OS TASK |
684 | 686 | ||
685 | mov esi, boot_setostask |
687 | mov esi, boot_setostask |
686 | call boot_log |
688 | call boot_log |
687 | 689 | ||
688 | mov edi, sys_proc |
690 | mov edi, sys_proc |
689 | list_init edi |
691 | list_init edi |
690 | lea ecx, [edi+PROC.thr_list] |
692 | lea ecx, [edi+PROC.thr_list] |
691 | list_init ecx |
693 | list_init ecx |
692 | mov [edi+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
694 | mov [edi+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
693 | 695 | ||
694 | mov eax, -1 |
696 | mov eax, -1 |
695 | mov edi, thr_slot_map+4 |
697 | mov edi, thr_slot_map+4 |
696 | mov [edi-4], dword 0xFFFFFFF8 |
698 | mov [edi-4], dword 0xFFFFFFF8 |
697 | stosd |
699 | stosd |
698 | stosd |
700 | stosd |
699 | stosd |
701 | stosd |
700 | stosd |
702 | stosd |
701 | stosd |
703 | stosd |
702 | stosd |
704 | stosd |
703 | stosd |
705 | stosd |
704 | 706 | ||
705 | mov [current_process], sys_proc |
707 | mov [current_process], sys_proc |
706 | 708 | ||
707 | mov edx, SLOT_BASE+256*1 |
709 | mov edx, SLOT_BASE+256*1 |
708 | mov ebx, [os_stack_seg] |
710 | mov ebx, [os_stack_seg] |
709 | add ebx, 0x2000 |
711 | add ebx, 0x2000 |
710 | call setup_os_slot |
712 | call setup_os_slot |
711 | mov dword [edx], 'IDLE' |
713 | mov dword [edx], 'IDLE' |
712 | sub [edx+APPDATA.saved_esp], 4 |
714 | sub [edx+APPDATA.saved_esp], 4 |
713 | mov eax, [edx+APPDATA.saved_esp] |
715 | mov eax, [edx+APPDATA.saved_esp] |
714 | mov dword [eax], idle_thread |
716 | mov dword [eax], idle_thread |
715 | mov ecx, IDLE_PRIORITY |
717 | mov ecx, IDLE_PRIORITY |
716 | call scheduler_add_thread |
718 | call scheduler_add_thread |
717 | 719 | ||
718 | mov edx, SLOT_BASE+256*2 |
720 | mov edx, SLOT_BASE+256*2 |
719 | mov ebx, [os_stack_seg] |
721 | mov ebx, [os_stack_seg] |
720 | call setup_os_slot |
722 | call setup_os_slot |
721 | mov dword [edx], 'OS' |
723 | mov dword [edx], 'OS' |
722 | xor ecx, ecx |
724 | xor ecx, ecx |
723 | call scheduler_add_thread |
725 | call scheduler_add_thread |
724 | 726 | ||
725 | mov dword [CURRENT_TASK], 2 |
727 | mov dword [CURRENT_TASK], 2 |
726 | mov dword [TASK_COUNT], 2 |
728 | mov dword [TASK_COUNT], 2 |
727 | mov dword [current_slot], SLOT_BASE + 256*2 |
729 | mov dword [current_slot], SLOT_BASE + 256*2 |
728 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
730 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
729 | 731 | ||
730 | 732 | ||
731 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
733 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
732 | mov esi, boot_initirq |
734 | mov esi, boot_initirq |
733 | call boot_log |
735 | call boot_log |
734 | call init_irqs |
736 | call init_irqs |
735 | 737 | ||
736 | mov esi, boot_picinit |
738 | mov esi, boot_picinit |
737 | call boot_log |
739 | call boot_log |
738 | call PIC_init |
740 | call PIC_init |
739 | 741 | ||
740 | mov esi, boot_v86machine |
742 | mov esi, boot_v86machine |
741 | call boot_log |
743 | call boot_log |
742 | ; Initialize system V86 machine |
744 | ; Initialize system V86 machine |
743 | call init_sys_v86 |
745 | call init_sys_v86 |
744 | 746 | ||
745 | mov esi, boot_inittimer |
747 | mov esi, boot_inittimer |
746 | call boot_log |
748 | call boot_log |
747 | ; Initialize system timer (IRQ0) |
749 | ; Initialize system timer (IRQ0) |
748 | call PIT_init |
750 | call PIT_init |
749 | 751 | ||
750 | ; Register ramdisk file system |
752 | ; Register ramdisk file system |
751 | mov esi, boot_initramdisk |
753 | mov esi, boot_initramdisk |
752 | call boot_log |
754 | call boot_log |
753 | call ramdisk_init |
755 | call ramdisk_init |
754 | 756 | ||
755 | mov esi, boot_initapic |
757 | mov esi, boot_initapic |
756 | call boot_log |
758 | call boot_log |
757 | ; Try to Initialize APIC |
759 | ; Try to Initialize APIC |
758 | call APIC_init |
760 | call APIC_init |
759 | 761 | ||
760 | mov esi, boot_enableirq |
762 | mov esi, boot_enableirq |
761 | call boot_log |
763 | call boot_log |
762 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
764 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
763 | ; they are used: when partitions are scanned, hd_read relies on timer |
765 | ; they are used: when partitions are scanned, hd_read relies on timer |
764 | call unmask_timer |
766 | call unmask_timer |
765 | stdcall enable_irq, 2 ; @#$%! PIC |
767 | stdcall enable_irq, 2 ; @#$%! PIC |
766 | stdcall enable_irq, 13 ; co-processor |
768 | stdcall enable_irq, 13 ; co-processor |
767 | 769 | ||
768 | cmp [IDEContrProgrammingInterface], 0 |
770 | cmp [IDEContrProgrammingInterface], 0 |
769 | je @f |
771 | je @f |
770 | 772 | ||
771 | mov esi, boot_disabling_ide |
773 | mov esi, boot_disabling_ide |
772 | call boot_log |
774 | call boot_log |
773 | ;-------------------------------------- |
775 | ;-------------------------------------- |
774 | ; Disable IDE interrupts, because the search |
776 | ; Disable IDE interrupts, because the search |
775 | ; for IDE partitions is in the PIO mode. |
777 | ; for IDE partitions is in the PIO mode. |
776 | ;-------------------------------------- |
778 | ;-------------------------------------- |
777 | .disable_IDE_interrupt: |
779 | .disable_IDE_interrupt: |
778 | ; Disable interrupts in IDE controller for PIO |
780 | ; Disable interrupts in IDE controller for PIO |
779 | mov al, 2 |
781 | mov al, 2 |
780 | mov dx, [IDE_BAR1_val] ;0x3F4 |
782 | mov dx, [IDE_BAR1_val] ;0x3F4 |
781 | add dx, 2 ;0x3F6 |
783 | add dx, 2 ;0x3F6 |
782 | out dx, al |
784 | out dx, al |
783 | mov dx, [IDE_BAR3_val] ;0x374 |
785 | mov dx, [IDE_BAR3_val] ;0x374 |
784 | add dx, 2 ;0x376 |
786 | add dx, 2 ;0x376 |
785 | out dx, al |
787 | out dx, al |
786 | @@: |
788 | @@: |
787 | ;----------------------------------------------------------------------------- |
789 | ;----------------------------------------------------------------------------- |
788 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
790 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
789 | ; mov esi, boot_detectdisks |
791 | ; mov esi, boot_detectdisks |
790 | ; call boot_log |
792 | ; call boot_log |
791 | ;include 'detect/disks.inc' |
793 | ;include 'detect/disks.inc' |
792 | mov esi, boot_detectfloppy |
794 | mov esi, boot_detectfloppy |
793 | call boot_log |
795 | call boot_log |
794 | include 'detect/dev_fd.inc' |
796 | include 'detect/dev_fd.inc' |
795 | mov esi, boot_detecthdcd |
797 | mov esi, boot_detecthdcd |
796 | call boot_log |
798 | call boot_log |
797 | include 'detect/dev_hdcd.inc' |
799 | include 'detect/dev_hdcd.inc' |
798 | mov esi, boot_getcache |
800 | mov esi, boot_getcache |
799 | call boot_log |
801 | call boot_log |
800 | include 'detect/getcache.inc' |
802 | include 'detect/getcache.inc' |
801 | mov esi, boot_detectpart |
803 | mov esi, boot_detectpart |
802 | call boot_log |
804 | call boot_log |
803 | include 'detect/sear_par.inc' |
805 | include 'detect/sear_par.inc' |
804 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
806 | ;!!!!!!!!!!!!!!!!!!!!!!!!!! |
805 | 807 | ||
806 | mov esi, boot_init_sys |
808 | mov esi, boot_init_sys |
807 | call boot_log |
809 | call boot_log |
808 | call Parser_params |
810 | call Parser_params |
809 | 811 | ||
810 | if ~ defined extended_primary_loader |
812 | if ~ defined extended_primary_loader |
811 | ; ramdisk image should be loaded by extended primary loader if it exists |
813 | ; ramdisk image should be loaded by extended primary loader if it exists |
812 | ; READ RAMDISK IMAGE FROM HD |
814 | ; READ RAMDISK IMAGE FROM HD |
813 | 815 | ||
814 | ;!!!!!!!!!!!!!!!!!!!!!!! |
816 | ;!!!!!!!!!!!!!!!!!!!!!!! |
815 | include 'boot/rdload.inc' |
817 | include 'boot/rdload.inc' |
816 | ;!!!!!!!!!!!!!!!!!!!!!!! |
818 | ;!!!!!!!!!!!!!!!!!!!!!!! |
817 | end if |
819 | end if |
818 | ; mov [dma_hdd],1 |
820 | ; mov [dma_hdd],1 |
819 | 821 | ||
820 | if 0 |
822 | if 0 |
821 | mov ax, [OS_BASE+0x10000+bx_from_load] |
823 | mov ax, [OS_BASE+0x10000+bx_from_load] |
822 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
824 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
823 | je no_lib_load |
825 | je no_lib_load |
824 | 826 | ||
825 | mov esi, boot_loadlibs |
827 | mov esi, boot_loadlibs |
826 | call boot_log |
828 | call boot_log |
827 | ; LOADING LIBRARES |
829 | ; LOADING LIBRARES |
828 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
830 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
829 | call load_file_parse_table ; prepare file parse table |
831 | call load_file_parse_table ; prepare file parse table |
830 | call set_kernel_conf ; configure devices and gui |
832 | call set_kernel_conf ; configure devices and gui |
831 | no_lib_load: |
833 | no_lib_load: |
832 | end if |
834 | end if |
833 | 835 | ||
834 | ; Display APIC status |
836 | ; Display APIC status |
835 | mov esi, boot_APIC_found |
837 | mov esi, boot_APIC_found |
836 | cmp [irq_mode], IRQ_APIC |
838 | cmp [irq_mode], IRQ_APIC |
837 | je @f |
839 | je @f |
838 | mov esi, boot_APIC_nfound |
840 | mov esi, boot_APIC_nfound |
839 | @@: |
841 | @@: |
840 | call boot_log |
842 | call boot_log |
841 | 843 | ||
842 | ; PRINT AMOUNT OF MEMORY |
844 | ; PRINT AMOUNT OF MEMORY |
843 | mov esi, boot_memdetect |
845 | mov esi, boot_memdetect |
844 | call boot_log |
846 | call boot_log |
845 | 847 | ||
846 | movzx ecx, word [boot_y] |
848 | movzx ecx, word [boot_y] |
847 | if lang eq ru |
849 | if lang eq ru |
848 | or ecx, (10+30*6) shl 16 |
850 | or ecx, (10+30*6) shl 16 |
849 | else if lang eq sp |
851 | else if lang eq sp |
850 | or ecx, (10+33*6) shl 16 |
852 | or ecx, (10+33*6) shl 16 |
851 | else |
853 | else |
852 | or ecx, (10+29*6) shl 16 |
854 | or ecx, (10+29*6) shl 16 |
853 | end if |
855 | end if |
854 | sub ecx, 10 |
856 | sub ecx, 10 |
855 | mov edx, 0xFFFFFF |
857 | mov edx, 0xFFFFFF |
856 | mov ebx, [MEM_AMOUNT] |
858 | mov ebx, [MEM_AMOUNT] |
857 | shr ebx, 20 |
859 | shr ebx, 20 |
858 | xor edi, edi |
860 | xor edi, edi |
859 | mov eax, 0x00040000 |
861 | mov eax, 0x00040000 |
860 | inc edi |
862 | inc edi |
861 | call display_number_force |
863 | call display_number_force |
862 | 864 | ||
863 | ; BUILD SCHEDULER |
865 | ; BUILD SCHEDULER |
864 | 866 | ||
865 | ; call build_scheduler; sys32.inc |
867 | ; call build_scheduler; sys32.inc |
866 | 868 | ||
867 | ; mov esi, boot_devices |
869 | ; mov esi, boot_devices |
868 | ; call boot_log |
870 | ; call boot_log |
869 | 871 | ||
870 | mov [pci_access_enabled], 1 |
872 | mov [pci_access_enabled], 1 |
871 | call pci_enum |
873 | call pci_enum |
872 | ;----------------------------------------------------------------------------- |
874 | ;----------------------------------------------------------------------------- |
873 | mov dx, [IDEContrRegsBaseAddr] |
875 | mov dx, [IDEContrRegsBaseAddr] |
874 | ; test whether it is our interrupt? |
876 | ; test whether it is our interrupt? |
875 | add dx, 2 |
877 | add dx, 2 |
876 | in al, dx |
878 | in al, dx |
877 | test al, 100b |
879 | test al, 100b |
878 | jz @f |
880 | jz @f |
879 | ; clear Bus Master IDE Status register |
881 | ; clear Bus Master IDE Status register |
880 | ; clear Interrupt bit |
882 | ; clear Interrupt bit |
881 | out dx, al |
883 | out dx, al |
882 | @@: |
884 | @@: |
883 | add dx, 8 |
885 | add dx, 8 |
884 | ; test whether it is our interrupt? |
886 | ; test whether it is our interrupt? |
885 | in al, dx |
887 | in al, dx |
886 | test al, 100b |
888 | test al, 100b |
887 | jz @f |
889 | jz @f |
888 | ; clear Bus Master IDE Status register |
890 | ; clear Bus Master IDE Status register |
889 | ; clear Interrupt bit |
891 | ; clear Interrupt bit |
890 | out dx, al |
892 | out dx, al |
891 | @@: |
893 | @@: |
892 | ; read status register and remove the interrupt request |
894 | ; read status register and remove the interrupt request |
893 | mov dx, [IDE_BAR0_val] ;0x1F0 |
895 | mov dx, [IDE_BAR0_val] ;0x1F0 |
894 | add dx, 0x7 ;0x1F7 |
896 | add dx, 0x7 ;0x1F7 |
895 | in al, dx |
897 | in al, dx |
896 | mov dx, [IDE_BAR2_val] ;0x170 |
898 | mov dx, [IDE_BAR2_val] ;0x170 |
897 | add dx, 0x7 ;0x177 |
899 | add dx, 0x7 ;0x177 |
898 | in al, dx |
900 | in al, dx |
899 | ;----------------------------------------------------------------------------- |
901 | ;----------------------------------------------------------------------------- |
900 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
902 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
901 | 903 | ||
902 | stdcall load_driver, szVidintel |
904 | stdcall load_driver, szVidintel |
903 | 905 | ||
904 | call usb_init |
906 | call usb_init |
905 | 907 | ||
906 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
908 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
907 | 909 | ||
908 | mov esi, boot_windefs |
910 | mov esi, boot_windefs |
909 | call boot_log |
911 | call boot_log |
910 | call set_window_defaults |
912 | call set_window_defaults |
911 | 913 | ||
912 | ; SET BACKGROUND DEFAULTS |
914 | ; SET BACKGROUND DEFAULTS |
913 | 915 | ||
914 | mov esi, boot_bgr |
916 | mov esi, boot_bgr |
915 | call boot_log |
917 | call boot_log |
916 | call init_background |
918 | call init_background |
917 | call calculatebackground |
919 | call calculatebackground |
918 | 920 | ||
919 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
921 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
920 | 922 | ||
921 | mov esi, boot_resirqports |
923 | mov esi, boot_resirqports |
922 | call boot_log |
924 | call boot_log |
923 | call reserve_irqs_ports |
925 | call reserve_irqs_ports |
924 | 926 | ||
925 | call init_display |
927 | call init_display |
926 | mov eax, [def_cursor] |
928 | mov eax, [def_cursor] |
927 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
929 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
928 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
930 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
929 | 931 | ||
930 | ; PRINT CPU FREQUENCY |
932 | ; PRINT CPU FREQUENCY |
931 | 933 | ||
932 | mov esi, boot_cpufreq |
934 | mov esi, boot_cpufreq |
933 | call boot_log |
935 | call boot_log |
934 | 936 | ||
935 | cli ;FIXME check IF |
937 | cli ;FIXME check IF |
936 | rdtsc |
938 | rdtsc |
937 | mov ecx, eax |
939 | mov ecx, eax |
938 | mov esi, 250 ; wait 1/4 a second |
940 | mov esi, 250 ; wait 1/4 a second |
939 | call delay_ms |
941 | call delay_ms |
940 | rdtsc |
942 | rdtsc |
941 | 943 | ||
942 | sub eax, ecx |
944 | sub eax, ecx |
943 | xor edx, edx |
945 | xor edx, edx |
944 | shld edx, eax, 2 |
946 | shld edx, eax, 2 |
945 | shl eax, 2 |
947 | shl eax, 2 |
946 | mov dword [cpu_freq], eax |
948 | mov dword [cpu_freq], eax |
947 | mov dword [cpu_freq+4], edx |
949 | mov dword [cpu_freq+4], edx |
948 | mov ebx, 1000000 |
950 | mov ebx, 1000000 |
949 | div ebx |
951 | div ebx |
950 | mov ebx, eax |
952 | mov ebx, eax |
951 | 953 | ||
952 | movzx ecx, word [boot_y] |
954 | movzx ecx, word [boot_y] |
953 | if lang eq ru |
955 | if lang eq ru |
954 | add ecx, (10+19*6) shl 16 - 10 |
956 | add ecx, (10+19*6) shl 16 - 10 |
955 | else if lang eq sp |
957 | else if lang eq sp |
956 | add ecx, (10+25*6) shl 16 - 10 |
958 | add ecx, (10+25*6) shl 16 - 10 |
957 | else |
959 | else |
958 | add ecx, (10+17*6) shl 16 - 10 |
960 | add ecx, (10+17*6) shl 16 - 10 |
959 | end if |
961 | end if |
960 | 962 | ||
961 | mov edx, 0xFFFFFF |
963 | mov edx, 0xFFFFFF |
962 | xor edi, edi |
964 | xor edi, edi |
963 | mov eax, 0x00040000 |
965 | mov eax, 0x00040000 |
964 | inc edi |
966 | inc edi |
965 | call display_number_force |
967 | call display_number_force |
966 | 968 | ||
967 | ; SET VARIABLES |
969 | ; SET VARIABLES |
968 | 970 | ||
969 | call set_variables |
971 | call set_variables |
970 | 972 | ||
971 | ; STACK AND FDC |
973 | ; STACK AND FDC |
972 | 974 | ||
973 | ; call stack_init |
975 | ; call stack_init |
974 | call fdc_init |
976 | call fdc_init |
975 | 977 | ||
976 | ; PALETTE FOR 320x200 and 640x480 16 col |
978 | ; PALETTE FOR 320x200 and 640x480 16 col |
977 | 979 | ||
978 | cmp [SCR_MODE], word 0x12 |
980 | cmp [SCR_MODE], word 0x12 |
979 | jne no_pal_vga |
981 | jne no_pal_vga |
980 | mov esi, boot_pal_vga |
982 | mov esi, boot_pal_vga |
981 | call boot_log |
983 | call boot_log |
982 | call paletteVGA |
984 | call paletteVGA |
983 | no_pal_vga: |
985 | no_pal_vga: |
984 | 986 | ||
985 | cmp [SCR_MODE], word 0x13 |
987 | cmp [SCR_MODE], word 0x13 |
986 | jne no_pal_ega |
988 | jne no_pal_ega |
987 | mov esi, boot_pal_ega |
989 | mov esi, boot_pal_ega |
988 | call boot_log |
990 | call boot_log |
989 | call palette320x200 |
991 | call palette320x200 |
990 | no_pal_ega: |
992 | no_pal_ega: |
991 | 993 | ||
992 | ; LOAD DEFAULT SKIN |
994 | ; LOAD DEFAULT SKIN |
993 | 995 | ||
994 | call load_default_skin |
996 | call load_default_skin |
995 | 997 | ||
996 | ;protect io permission map |
998 | ;protect io permission map |
997 | 999 | ||
998 | mov esi, [default_io_map] |
1000 | mov esi, [default_io_map] |
999 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1001 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1000 | add esi, 0x1000 |
1002 | add esi, 0x1000 |
1001 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1003 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1002 | 1004 | ||
1003 | stdcall map_page, tss._io_map_0, \ |
1005 | stdcall map_page, tss._io_map_0, \ |
1004 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1006 | [SLOT_BASE+256+APPDATA.io_map], PG_MAP |
1005 | stdcall map_page, tss._io_map_1, \ |
1007 | stdcall map_page, tss._io_map_1, \ |
1006 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1008 | [SLOT_BASE+256+APPDATA.io_map+4], PG_MAP |
1007 | 1009 | ||
1008 | ; LOAD FIRST APPLICATION |
1010 | ; LOAD FIRST APPLICATION |
1009 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1011 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1010 | jnz first_app_found |
1012 | jnz first_app_found |
1011 | 1013 | ||
1012 | cli |
1014 | cli |
1013 | mov ebp, firstapp |
1015 | mov ebp, firstapp |
1014 | call fs_execute_from_sysdir |
1016 | call fs_execute_from_sysdir |
1015 | test eax, eax |
1017 | test eax, eax |
1016 | jnz first_app_found |
1018 | jnz first_app_found |
1017 | 1019 | ||
1018 | mov esi, boot_failed |
1020 | mov esi, boot_failed |
1019 | call boot_log |
1021 | call boot_log |
1020 | 1022 | ||
1021 | mov eax, 0xDEADBEEF ; otherwise halt |
1023 | mov eax, 0xDEADBEEF ; otherwise halt |
1022 | hlt |
1024 | hlt |
1023 | 1025 | ||
1024 | first_app_found: |
1026 | first_app_found: |
1025 | 1027 | ||
1026 | cli |
1028 | cli |
1027 | 1029 | ||
1028 | ; SET KEYBOARD PARAMETERS |
1030 | ; SET KEYBOARD PARAMETERS |
1029 | mov al, 0xf6 ; reset keyboard, scan enabled |
1031 | mov al, 0xf6 ; reset keyboard, scan enabled |
1030 | call kb_write |
1032 | call kb_write |
1031 | test ah, ah |
1033 | test ah, ah |
1032 | jnz .no_keyboard |
1034 | jnz .no_keyboard |
1033 | 1035 | ||
1034 | ; wait until 8042 is ready |
1036 | ; wait until 8042 is ready |
1035 | xor ecx, ecx |
1037 | xor ecx, ecx |
1036 | @@: |
1038 | @@: |
1037 | in al, 64h |
1039 | in al, 64h |
1038 | and al, 00000010b |
1040 | and al, 00000010b |
1039 | loopnz @b |
1041 | loopnz @b |
1040 | 1042 | ||
1041 | iglobal |
1043 | iglobal |
1042 | align 4 |
1044 | align 4 |
1043 | ps2_keyboard_functions: |
1045 | ps2_keyboard_functions: |
1044 | dd .end - $ |
1046 | dd .end - $ |
1045 | dd 0 ; no close |
1047 | dd 0 ; no close |
1046 | dd ps2_set_lights |
1048 | dd ps2_set_lights |
1047 | .end: |
1049 | .end: |
1048 | endg |
1050 | endg |
1049 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1051 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
1050 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1052 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
1051 | ; call kb_write |
1053 | ; call kb_write |
1052 | ; call kb_read |
1054 | ; call kb_read |
1053 | ; mov al, 111b |
1055 | ; mov al, 111b |
1054 | ; call kb_write |
1056 | ; call kb_write |
1055 | ; call kb_read |
1057 | ; call kb_read |
1056 | 1058 | ||
1057 | mov al, 0xF3 ; set repeat rate & delay |
1059 | mov al, 0xF3 ; set repeat rate & delay |
1058 | call kb_write |
1060 | call kb_write |
1059 | ; call kb_read |
1061 | ; call kb_read |
1060 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1062 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1061 | call kb_write |
1063 | call kb_write |
1062 | ; call kb_read |
1064 | ; call kb_read |
1063 | ;// mike.dld [ |
1065 | ;// mike.dld [ |
1064 | call set_lights |
1066 | call set_lights |
1065 | ;// mike.dld ] |
1067 | ;// mike.dld ] |
1066 | stdcall attach_int_handler, 1, irq1, 0 |
1068 | stdcall attach_int_handler, 1, irq1, 0 |
1067 | DEBUGF 1, "K : IRQ1 error code %x\n", eax |
1069 | DEBUGF 1, "K : IRQ1 error code %x\n", eax |
1068 | .no_keyboard: |
1070 | .no_keyboard: |
1069 | 1071 | ||
1070 | ; SET MOUSE |
1072 | ; SET MOUSE |
1071 | 1073 | ||
1072 | stdcall load_driver, szPS2MDriver |
1074 | stdcall load_driver, szPS2MDriver |
1073 | ; stdcall load_driver, szCOM_MDriver |
1075 | ; stdcall load_driver, szCOM_MDriver |
1074 | 1076 | ||
1075 | mov esi, boot_setmouse |
1077 | mov esi, boot_setmouse |
1076 | call boot_log |
1078 | call boot_log |
1077 | call setmouse |
1079 | call setmouse |
1078 | 1080 | ||
1079 | ; Setup serial output console (if enabled) |
1081 | ; Setup serial output console (if enabled) |
1080 | 1082 | ||
1081 | if defined debug_com_base |
1083 | if defined debug_com_base |
1082 | 1084 | ||
1083 | ; enable Divisor latch |
1085 | ; enable Divisor latch |
1084 | 1086 | ||
1085 | mov dx, debug_com_base+3 |
1087 | mov dx, debug_com_base+3 |
1086 | mov al, 1 shl 7 |
1088 | mov al, 1 shl 7 |
1087 | out dx, al |
1089 | out dx, al |
1088 | 1090 | ||
1089 | ; Set speed to 115200 baud (max speed) |
1091 | ; Set speed to 115200 baud (max speed) |
1090 | 1092 | ||
1091 | mov dx, debug_com_base |
1093 | mov dx, debug_com_base |
1092 | mov al, 0x01 |
1094 | mov al, 0x01 |
1093 | out dx, al |
1095 | out dx, al |
1094 | 1096 | ||
1095 | mov dx, debug_com_base+1 |
1097 | mov dx, debug_com_base+1 |
1096 | mov al, 0x00 |
1098 | mov al, 0x00 |
1097 | out dx, al |
1099 | out dx, al |
1098 | 1100 | ||
1099 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1101 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
1100 | 1102 | ||
1101 | mov dx, debug_com_base+3 |
1103 | mov dx, debug_com_base+3 |
1102 | mov al, 3 |
1104 | mov al, 3 |
1103 | out dx, al |
1105 | out dx, al |
1104 | 1106 | ||
1105 | ; disable interrupts |
1107 | ; disable interrupts |
1106 | 1108 | ||
1107 | mov dx, debug_com_base+1 |
1109 | mov dx, debug_com_base+1 |
1108 | mov al, 0 |
1110 | mov al, 0 |
1109 | out dx, al |
1111 | out dx, al |
1110 | 1112 | ||
1111 | ; clear + enable fifo (64 bits) |
1113 | ; clear + enable fifo (64 bits) |
1112 | 1114 | ||
1113 | mov dx, debug_com_base+2 |
1115 | mov dx, debug_com_base+2 |
1114 | mov al, 0x7 + 1 shl 5 |
1116 | mov al, 0x7 + 1 shl 5 |
1115 | out dx, al |
1117 | out dx, al |
1116 | 1118 | ||
1117 | 1119 | ||
1118 | end if |
1120 | end if |
1119 | mov eax, [version_inf.rev] |
1121 | mov eax, [version_inf.rev] |
1120 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1122 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
1121 | 1123 | ||
1122 | mov eax, [cpu_count] |
1124 | mov eax, [cpu_count] |
1123 | test eax, eax |
1125 | test eax, eax |
1124 | jnz @F |
1126 | jnz @F |
1125 | mov al, 1 ; at least one CPU |
1127 | mov al, 1 ; at least one CPU |
1126 | @@: |
1128 | @@: |
1127 | DEBUGF 1, "K : %d CPU detected\n", eax |
1129 | DEBUGF 1, "K : %d CPU detected\n", eax |
1128 | 1130 | ||
1129 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
1131 | DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4 |
1130 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
1132 | DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4 |
1131 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
1133 | DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4 |
1132 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
1134 | DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4 |
1133 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
1135 | DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4 |
1134 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
1136 | DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4 |
1135 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
1137 | DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4 |
1136 | 1138 | ||
1137 | ; START MULTITASKING |
1139 | ; START MULTITASKING |
1138 | 1140 | ||
1139 | ; A 'All set - press ESC to start' messages if need |
1141 | ; A 'All set - press ESC to start' messages if need |
1140 | if preboot_blogesc |
1142 | if preboot_blogesc |
1141 | mov esi, boot_tasking |
1143 | mov esi, boot_tasking |
1142 | call boot_log |
1144 | call boot_log |
1143 | .bll1: |
1145 | .bll1: |
1144 | in al, 0x60 ; wait for ESC key press |
1146 | in al, 0x60 ; wait for ESC key press |
1145 | cmp al, 129 |
1147 | cmp al, 129 |
1146 | jne .bll1 |
1148 | jne .bll1 |
1147 | end if |
1149 | end if |
1148 | 1150 | ||
1149 | push eax edx |
1151 | push eax edx |
1150 | mov dx, [IDEContrRegsBaseAddr] |
1152 | mov dx, [IDEContrRegsBaseAddr] |
1151 | xor eax, eax |
1153 | xor eax, eax |
1152 | add dx, 2 |
1154 | add dx, 2 |
1153 | in al, dx |
1155 | in al, dx |
1154 | DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax |
1156 | DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax |
1155 | 1157 | ||
1156 | add dx, 8 |
1158 | add dx, 8 |
1157 | in al, dx |
1159 | in al, dx |
1158 | DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax |
1160 | DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax |
1159 | pop edx eax |
1161 | pop edx eax |
1160 | 1162 | ||
1161 | cmp [IDEContrRegsBaseAddr], 0 |
1163 | cmp [IDEContrRegsBaseAddr], 0 |
1162 | setnz [dma_hdd] |
1164 | setnz [dma_hdd] |
1163 | 1165 | ||
1164 | cmp [IDEContrProgrammingInterface], 0 |
1166 | cmp [IDEContrProgrammingInterface], 0 |
1165 | je set_interrupts_for_IDE_controllers.continue |
1167 | je set_interrupts_for_IDE_controllers.continue |
1166 | ;----------------------------------------------------------------------------- |
1168 | ;----------------------------------------------------------------------------- |
1167 | ; set interrupts for IDE Controller |
1169 | ; set interrupts for IDE Controller |
1168 | ;----------------------------------------------------------------------------- |
1170 | ;----------------------------------------------------------------------------- |
1169 | mov esi, boot_set_int_IDE |
1171 | mov esi, boot_set_int_IDE |
1170 | call boot_log |
1172 | call boot_log |
1171 | set_interrupts_for_IDE_controllers: |
1173 | set_interrupts_for_IDE_controllers: |
1172 | mov ax, [IDEContrProgrammingInterface] |
1174 | mov ax, [IDEContrProgrammingInterface] |
1173 | cmp ax, 0x0180 |
1175 | cmp ax, 0x0180 |
1174 | je .pata_ide |
1176 | je .pata_ide |
1175 | 1177 | ||
1176 | cmp ax, 0x018a |
1178 | cmp ax, 0x018a |
1177 | jne .sata_ide |
1179 | jne .sata_ide |
1178 | ;-------------------------------------- |
1180 | ;-------------------------------------- |
1179 | .pata_ide: |
1181 | .pata_ide: |
1180 | cmp [IDEContrRegsBaseAddr], 0 |
1182 | cmp [IDEContrRegsBaseAddr], 0 |
1181 | je .end_set_interrupts |
1183 | je .end_set_interrupts |
1182 | 1184 | ||
1183 | stdcall attach_int_handler, 14, IDE_irq_14_handler, 0 |
1185 | stdcall attach_int_handler, 14, IDE_irq_14_handler, 0 |
1184 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
1186 | DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax |
1185 | stdcall attach_int_handler, 15, IDE_irq_15_handler, 0 |
1187 | stdcall attach_int_handler, 15, IDE_irq_15_handler, 0 |
1186 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
1188 | DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax |
1187 | jmp .enable_IDE_interrupt |
1189 | jmp .enable_IDE_interrupt |
1188 | ;-------------------------------------- |
1190 | ;-------------------------------------- |
1189 | .sata_ide: |
1191 | .sata_ide: |
1190 | cmp ax, 0x0185 |
1192 | cmp ax, 0x0185 |
1191 | je .sata_ide_1 |
1193 | je .sata_ide_1 |
1192 | 1194 | ||
1193 | cmp ax, 0x018f |
1195 | cmp ax, 0x018f |
1194 | jne .end_set_interrupts |
1196 | jne .end_set_interrupts |
1195 | ;-------------------------------------- |
1197 | ;-------------------------------------- |
1196 | .sata_ide_1: |
1198 | .sata_ide_1: |
1197 | cmp [IDEContrRegsBaseAddr], 0 |
1199 | cmp [IDEContrRegsBaseAddr], 0 |
1198 | je .end_set_interrupts |
1200 | je .end_set_interrupts |
1199 | 1201 | ||
1200 | mov ax, [IDE_Interrupt] |
1202 | mov ax, [IDE_Interrupt] |
1201 | movzx eax, al |
1203 | movzx eax, al |
1202 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
1204 | stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 |
1203 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax |
1205 | DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax |
1204 | ;-------------------------------------- |
1206 | ;-------------------------------------- |
1205 | .enable_IDE_interrupt: |
1207 | .enable_IDE_interrupt: |
1206 | mov esi, boot_enabling_ide |
1208 | mov esi, boot_enabling_ide |
1207 | call boot_log |
1209 | call boot_log |
1208 | ; Enable interrupts in IDE controller for DMA |
1210 | ; Enable interrupts in IDE controller for DMA |
1209 | mov al, 0 |
1211 | mov al, 0 |
1210 | mov ah, [DRIVE_DATA+1] |
1212 | mov ah, [DRIVE_DATA+1] |
1211 | test ah, 10100000b |
1213 | test ah, 10100000b |
1212 | jz @f |
1214 | jz @f |
1213 | 1215 | ||
1214 | DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n" |
1216 | DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n" |
1215 | jmp .ch2_check |
1217 | jmp .ch2_check |
1216 | @@: |
1218 | @@: |
1217 | mov dx, [IDE_BAR1_val] ;0x3F4 |
1219 | mov dx, [IDE_BAR1_val] ;0x3F4 |
1218 | add dx, 2 ;0x3F6 |
1220 | add dx, 2 ;0x3F6 |
1219 | out dx, al |
1221 | out dx, al |
1220 | DEBUGF 1, "K : IDE CH1 DMA enabled\n" |
1222 | DEBUGF 1, "K : IDE CH1 DMA enabled\n" |
1221 | .ch2_check: |
1223 | .ch2_check: |
1222 | test ah, 1010b |
1224 | test ah, 1010b |
1223 | jz @f |
1225 | jz @f |
1224 | 1226 | ||
1225 | DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n" |
1227 | DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n" |
1226 | jmp .end_set_interrupts |
1228 | jmp .end_set_interrupts |
1227 | @@: |
1229 | @@: |
1228 | mov dx, [IDE_BAR3_val] ;0x374 |
1230 | mov dx, [IDE_BAR3_val] ;0x374 |
1229 | add dx, 2 ;0x376 |
1231 | add dx, 2 ;0x376 |
1230 | out dx, al |
1232 | out dx, al |
1231 | DEBUGF 1, "K : IDE CH2 DMA enabled\n" |
1233 | DEBUGF 1, "K : IDE CH2 DMA enabled\n" |
1232 | ;-------------------------------------- |
1234 | ;-------------------------------------- |
1233 | .end_set_interrupts: |
1235 | .end_set_interrupts: |
1234 | ;----------------------------------------------------------------------------- |
1236 | ;----------------------------------------------------------------------------- |
1235 | cmp [dma_hdd], 0 |
1237 | cmp [dma_hdd], 0 |
1236 | je .print_pio |
1238 | je .print_pio |
1237 | .print_dma: |
1239 | .print_dma: |
1238 | DEBUGF 1, "K : IDE DMA mode\n" |
1240 | DEBUGF 1, "K : IDE DMA mode\n" |
1239 | jmp .continue |
1241 | jmp .continue |
1240 | 1242 | ||
1241 | .print_pio: |
1243 | .print_pio: |
1242 | DEBUGF 1, "K : IDE PIO mode\n" |
1244 | DEBUGF 1, "K : IDE PIO mode\n" |
1243 | .continue: |
1245 | .continue: |
1244 | 1246 | ||
1245 | mov [timer_ticks_enable], 1 ; for cd driver |
1247 | mov [timer_ticks_enable], 1 ; for cd driver |
1246 | 1248 | ||
1247 | sti |
1249 | sti |
1248 | ; call change_task |
1250 | ; call change_task |
1249 | 1251 | ||
1250 | jmp osloop |
1252 | jmp osloop |
1251 | 1253 | ||
1252 | 1254 | ||
1253 | ; Fly :) |
1255 | ; Fly :) |
1254 | 1256 | ||
1255 | include 'unpacker.inc' |
1257 | include 'unpacker.inc' |
1256 | 1258 | ||
1257 | align 4 |
1259 | align 4 |
1258 | boot_log: |
1260 | boot_log: |
1259 | pushad |
1261 | pushad |
1260 | 1262 | ||
1261 | mov ebx, 10*65536 |
1263 | mov ebx, 10*65536 |
1262 | mov bx, word [boot_y] |
1264 | mov bx, word [boot_y] |
1263 | add [boot_y], dword 10 |
1265 | add [boot_y], dword 10 |
1264 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1266 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1265 | xor edi, edi |
1267 | xor edi, edi |
1266 | mov edx, esi |
1268 | mov edx, esi |
1267 | inc edi |
1269 | inc edi |
1268 | call dtext |
1270 | call dtext |
1269 | 1271 | ||
1270 | mov [novesachecksum], 1000 |
1272 | mov [novesachecksum], 1000 |
1271 | call checkVga_N13 |
1273 | call checkVga_N13 |
1272 | 1274 | ||
1273 | popad |
1275 | popad |
1274 | 1276 | ||
1275 | ret |
1277 | ret |
1276 | 1278 | ||
1277 | ; in: edx -> APPDATA for OS/IDLE slot |
1279 | ; in: edx -> APPDATA for OS/IDLE slot |
1278 | ; in: ebx = stack base |
1280 | ; in: ebx = stack base |
1279 | proc setup_os_slot |
1281 | proc setup_os_slot |
1280 | xor eax, eax |
1282 | xor eax, eax |
1281 | mov ecx, 256/4 |
1283 | mov ecx, 256/4 |
1282 | mov edi, edx |
1284 | mov edi, edx |
1283 | rep stosd |
1285 | rep stosd |
1284 | 1286 | ||
1285 | mov eax, tss+0x80 |
1287 | mov eax, tss+0x80 |
1286 | call get_pg_addr |
1288 | call get_pg_addr |
1287 | inc eax |
1289 | inc eax |
1288 | mov [edx+APPDATA.io_map], eax |
1290 | mov [edx+APPDATA.io_map], eax |
1289 | mov eax, tss+0x1080 |
1291 | mov eax, tss+0x1080 |
1290 | call get_pg_addr |
1292 | call get_pg_addr |
1291 | inc eax |
1293 | inc eax |
1292 | mov [edx+APPDATA.io_map+4], eax |
1294 | mov [edx+APPDATA.io_map+4], eax |
1293 | 1295 | ||
1294 | mov dword [edx+APPDATA.pl0_stack], ebx |
1296 | mov dword [edx+APPDATA.pl0_stack], ebx |
1295 | lea edi, [ebx+0x2000-512] |
1297 | lea edi, [ebx+0x2000-512] |
1296 | mov dword [edx+APPDATA.fpu_state], edi |
1298 | mov dword [edx+APPDATA.fpu_state], edi |
1297 | mov dword [edx+APPDATA.saved_esp0], edi |
1299 | mov dword [edx+APPDATA.saved_esp0], edi |
1298 | mov dword [edx+APPDATA.saved_esp], edi |
1300 | mov dword [edx+APPDATA.saved_esp], edi |
1299 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1301 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1300 | 1302 | ||
1301 | mov esi, fpu_data |
1303 | mov esi, fpu_data |
1302 | mov ecx, 512/4 |
1304 | mov ecx, 512/4 |
1303 | cld |
1305 | cld |
1304 | rep movsd |
1306 | rep movsd |
1305 | 1307 | ||
1306 | lea eax, [edx+APP_OBJ_OFFSET] |
1308 | lea eax, [edx+APP_OBJ_OFFSET] |
1307 | mov dword [edx+APPDATA.fd_obj], eax |
1309 | mov dword [edx+APPDATA.fd_obj], eax |
1308 | mov dword [edx+APPDATA.bk_obj], eax |
1310 | mov dword [edx+APPDATA.bk_obj], eax |
1309 | 1311 | ||
1310 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1312 | mov dword [edx+APPDATA.cur_dir], sysdir_path |
1311 | 1313 | ||
1312 | mov [edx + APPDATA.process], sys_proc |
1314 | mov [edx + APPDATA.process], sys_proc |
1313 | 1315 | ||
1314 | mov eax, edx |
1316 | mov eax, edx |
1315 | shr eax, 3 |
1317 | shr eax, 3 |
1316 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1318 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1317 | mov [eax+TASKDATA.wnd_number], dh |
1319 | mov [eax+TASKDATA.wnd_number], dh |
1318 | mov byte [eax+TASKDATA.pid], dh |
1320 | mov byte [eax+TASKDATA.pid], dh |
1319 | 1321 | ||
1320 | ret |
1322 | ret |
1321 | endp |
1323 | endp |
1322 | 1324 | ||
1323 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1325 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1324 | ; ; |
1326 | ; ; |
1325 | ; MAIN OS LOOP START ; |
1327 | ; MAIN OS LOOP START ; |
1326 | ; ; |
1328 | ; ; |
1327 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1329 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1328 | align 32 |
1330 | align 32 |
1329 | osloop: |
1331 | osloop: |
1330 | mov edx, osloop_has_work? |
1332 | mov edx, osloop_has_work? |
1331 | xor ecx, ecx |
1333 | xor ecx, ecx |
1332 | call Wait_events |
1334 | call Wait_events |
1333 | xor eax, eax |
1335 | xor eax, eax |
1334 | xchg eax, [osloop_nonperiodic_work] |
1336 | xchg eax, [osloop_nonperiodic_work] |
1335 | test eax, eax |
1337 | test eax, eax |
1336 | jz .no_periodic |
1338 | jz .no_periodic |
1337 | ; call [draw_pointer] |
1339 | ; call [draw_pointer] |
1338 | call __sys_draw_pointer |
1340 | call __sys_draw_pointer |
1339 | call window_check_events |
1341 | call window_check_events |
1340 | call mouse_check_events |
1342 | call mouse_check_events |
1341 | call checkmisc |
1343 | call checkmisc |
1342 | call checkVga_N13 |
1344 | call checkVga_N13 |
1343 | .no_periodic: |
1345 | .no_periodic: |
1344 | call stack_handler |
1346 | call stack_handler |
1345 | call check_fdd_motor_status |
1347 | call check_fdd_motor_status |
1346 | call check_ATAPI_device_event |
1348 | call check_ATAPI_device_event |
1347 | call check_lights_state |
1349 | call check_lights_state |
1348 | call check_timers |
1350 | call check_timers |
1349 | jmp osloop |
1351 | jmp osloop |
1350 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1352 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1351 | ; ; |
1353 | ; ; |
1352 | ; MAIN OS LOOP END ; |
1354 | ; MAIN OS LOOP END ; |
1353 | ; ; |
1355 | ; ; |
1354 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1356 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1355 | proc osloop_has_work? |
1357 | proc osloop_has_work? |
1356 | cmp [osloop_nonperiodic_work], 0 |
1358 | cmp [osloop_nonperiodic_work], 0 |
1357 | jnz .yes |
1359 | jnz .yes |
1358 | call stack_handler_has_work? |
1360 | call stack_handler_has_work? |
1359 | jnz .yes |
1361 | jnz .yes |
1360 | call check_fdd_motor_status_has_work? |
1362 | call check_fdd_motor_status_has_work? |
1361 | jnz .yes |
1363 | jnz .yes |
1362 | call check_ATAPI_device_event_has_work? |
1364 | call check_ATAPI_device_event_has_work? |
1363 | jnz .yes |
1365 | jnz .yes |
1364 | call check_lights_state_has_work? |
1366 | call check_lights_state_has_work? |
1365 | jnz .yes |
1367 | jnz .yes |
1366 | call check_timers_has_work? |
1368 | call check_timers_has_work? |
1367 | jnz .yes |
1369 | jnz .yes |
1368 | .no: |
1370 | .no: |
1369 | xor eax, eax |
1371 | xor eax, eax |
1370 | ret |
1372 | ret |
1371 | .yes: |
1373 | .yes: |
1372 | xor eax, eax |
1374 | xor eax, eax |
1373 | inc eax |
1375 | inc eax |
1374 | ret |
1376 | ret |
1375 | endp |
1377 | endp |
1376 | 1378 | ||
1377 | proc wakeup_osloop |
1379 | proc wakeup_osloop |
1378 | mov [osloop_nonperiodic_work], 1 |
1380 | mov [osloop_nonperiodic_work], 1 |
1379 | ret |
1381 | ret |
1380 | endp |
1382 | endp |
1381 | 1383 | ||
1382 | uglobal |
1384 | uglobal |
1383 | align 4 |
1385 | align 4 |
1384 | osloop_nonperiodic_work dd ? |
1386 | osloop_nonperiodic_work dd ? |
1385 | endg |
1387 | endg |
1386 | 1388 | ||
1387 | align 4 |
1389 | align 4 |
1388 | idle_thread: |
1390 | idle_thread: |
1389 | sti |
1391 | sti |
1390 | idle_loop: |
1392 | idle_loop: |
1391 | hlt |
1393 | hlt |
1392 | jmp idle_loop |
1394 | jmp idle_loop |
1393 | 1395 | ||
1394 | 1396 | ||
1395 | 1397 | ||
1396 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1398 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1397 | ; ; |
1399 | ; ; |
1398 | ; INCLUDED SYSTEM FILES ; |
1400 | ; INCLUDED SYSTEM FILES ; |
1399 | ; ; |
1401 | ; ; |
1400 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1402 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1401 | 1403 | ||
1402 | 1404 | ||
1403 | include "kernel32.inc" |
1405 | include "kernel32.inc" |
1404 | 1406 | ||
1405 | 1407 | ||
1406 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1408 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1407 | ; ; |
1409 | ; ; |
1408 | ; KERNEL FUNCTIONS ; |
1410 | ; KERNEL FUNCTIONS ; |
1409 | ; ; |
1411 | ; ; |
1410 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1412 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1411 | 1413 | ||
1412 | reserve_irqs_ports: |
1414 | reserve_irqs_ports: |
1413 | 1415 | ||
1414 | 1416 | ||
1415 | ; RESERVE PORTS |
1417 | ; RESERVE PORTS |
1416 | mov eax, RESERVED_PORTS |
1418 | mov eax, RESERVED_PORTS |
1417 | mov ecx, 1 |
1419 | mov ecx, 1 |
1418 | 1420 | ||
1419 | mov [eax], dword 4 |
1421 | mov [eax], dword 4 |
1420 | 1422 | ||
1421 | mov [eax+16], ecx |
1423 | mov [eax+16], ecx |
1422 | mov [eax+16+4], dword 0 |
1424 | mov [eax+16+4], dword 0 |
1423 | mov [eax+16+8], dword 0x2D |
1425 | mov [eax+16+8], dword 0x2D |
1424 | 1426 | ||
1425 | mov [eax+32], ecx |
1427 | mov [eax+32], ecx |
1426 | mov [eax+32+4], dword 0x30 |
1428 | mov [eax+32+4], dword 0x30 |
1427 | mov [eax+32+8], dword 0x4D |
1429 | mov [eax+32+8], dword 0x4D |
1428 | 1430 | ||
1429 | mov [eax+48], ecx |
1431 | mov [eax+48], ecx |
1430 | mov [eax+48+4], dword 0x50 |
1432 | mov [eax+48+4], dword 0x50 |
1431 | mov [eax+48+8], dword 0xDF |
1433 | mov [eax+48+8], dword 0xDF |
1432 | 1434 | ||
1433 | mov [eax+64], ecx |
1435 | mov [eax+64], ecx |
1434 | mov [eax+64+4], dword 0xE5 |
1436 | mov [eax+64+4], dword 0xE5 |
1435 | mov [eax+64+8], dword 0xFF |
1437 | mov [eax+64+8], dword 0xFF |
1436 | 1438 | ||
1437 | ret |
1439 | ret |
1438 | 1440 | ||
1439 | 1441 | ||
1440 | iglobal |
1442 | iglobal |
1441 | process_number dd 0x2 |
1443 | process_number dd 0x2 |
1442 | endg |
1444 | endg |
1443 | 1445 | ||
1444 | set_variables: |
1446 | set_variables: |
1445 | 1447 | ||
1446 | mov ecx, 0x16 ; flush port 0x60 |
1448 | mov ecx, 0x16 ; flush port 0x60 |
1447 | .fl60: |
1449 | .fl60: |
1448 | in al, 0x60 |
1450 | in al, 0x60 |
1449 | loop .fl60 |
1451 | loop .fl60 |
1450 | push eax |
1452 | push eax |
1451 | 1453 | ||
1452 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1454 | mov ax, [BOOT_VARS+BOOT_Y_RES] |
1453 | shr ax, 1 |
1455 | shr ax, 1 |
1454 | shl eax, 16 |
1456 | shl eax, 16 |
1455 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1457 | mov ax, [BOOT_VARS+BOOT_X_RES] |
1456 | shr ax, 1 |
1458 | shr ax, 1 |
1457 | mov [MOUSE_X], eax |
1459 | mov [MOUSE_X], eax |
1458 | call wakeup_osloop |
1460 | call wakeup_osloop |
1459 | 1461 | ||
1460 | xor eax, eax |
1462 | xor eax, eax |
1461 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1463 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1462 | 1464 | ||
1463 | mov byte [KEY_COUNT], al ; keyboard buffer |
1465 | mov byte [KEY_COUNT], al ; keyboard buffer |
1464 | mov byte [BTN_COUNT], al ; button buffer |
1466 | mov byte [BTN_COUNT], al ; button buffer |
1465 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1467 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1466 | 1468 | ||
1467 | pop eax |
1469 | pop eax |
1468 | ret |
1470 | ret |
1469 | 1471 | ||
1470 | align 4 |
1472 | align 4 |
1471 | ;input eax=43,bl-byte of output, ecx - number of port |
1473 | ;input eax=43,bl-byte of output, ecx - number of port |
1472 | sys_outport: |
1474 | sys_outport: |
1473 | 1475 | ||
1474 | mov edi, ecx ; separate flag for read / write |
1476 | mov edi, ecx ; separate flag for read / write |
1475 | and ecx, 65535 |
1477 | and ecx, 65535 |
1476 | 1478 | ||
1477 | mov eax, [RESERVED_PORTS] |
1479 | mov eax, [RESERVED_PORTS] |
1478 | test eax, eax |
1480 | test eax, eax |
1479 | jnz .sopl8 |
1481 | jnz .sopl8 |
1480 | inc eax |
1482 | inc eax |
1481 | mov [esp+32], eax |
1483 | mov [esp+32], eax |
1482 | ret |
1484 | ret |
1483 | 1485 | ||
1484 | .sopl8: |
1486 | .sopl8: |
1485 | mov edx, [TASK_BASE] |
1487 | mov edx, [TASK_BASE] |
1486 | mov edx, [edx+0x4] |
1488 | mov edx, [edx+0x4] |
1487 | ;and ecx,65535 |
1489 | ;and ecx,65535 |
1488 | ;cld - set on interrupt 0x40 |
1490 | ;cld - set on interrupt 0x40 |
1489 | .sopl1: |
1491 | .sopl1: |
1490 | 1492 | ||
1491 | mov esi, eax |
1493 | mov esi, eax |
1492 | shl esi, 4 |
1494 | shl esi, 4 |
1493 | add esi, RESERVED_PORTS |
1495 | add esi, RESERVED_PORTS |
1494 | cmp edx, [esi+0] |
1496 | cmp edx, [esi+0] |
1495 | jne .sopl2 |
1497 | jne .sopl2 |
1496 | cmp ecx, [esi+4] |
1498 | cmp ecx, [esi+4] |
1497 | jb .sopl2 |
1499 | jb .sopl2 |
1498 | cmp ecx, [esi+8] |
1500 | cmp ecx, [esi+8] |
1499 | jg .sopl2 |
1501 | jg .sopl2 |
1500 | .sopl3: |
1502 | .sopl3: |
1501 | 1503 | ||
1502 | test edi, 0x80000000; read ? |
1504 | test edi, 0x80000000; read ? |
1503 | jnz .sopl4 |
1505 | jnz .sopl4 |
1504 | 1506 | ||
1505 | mov eax, ebx |
1507 | mov eax, ebx |
1506 | mov dx, cx ; write |
1508 | mov dx, cx ; write |
1507 | out dx, al |
1509 | out dx, al |
1508 | and [esp+32], dword 0 |
1510 | and [esp+32], dword 0 |
1509 | ret |
1511 | ret |
1510 | 1512 | ||
1511 | .sopl2: |
1513 | .sopl2: |
1512 | 1514 | ||
1513 | dec eax |
1515 | dec eax |
1514 | jnz .sopl1 |
1516 | jnz .sopl1 |
1515 | inc eax |
1517 | inc eax |
1516 | mov [esp+32], eax |
1518 | mov [esp+32], eax |
1517 | ret |
1519 | ret |
1518 | 1520 | ||
1519 | 1521 | ||
1520 | .sopl4: |
1522 | .sopl4: |
1521 | 1523 | ||
1522 | mov dx, cx ; read |
1524 | mov dx, cx ; read |
1523 | in al, dx |
1525 | in al, dx |
1524 | and eax, 0xff |
1526 | and eax, 0xff |
1525 | and [esp+32], dword 0 |
1527 | and [esp+32], dword 0 |
1526 | mov [esp+20], eax |
1528 | mov [esp+20], eax |
1527 | ret |
1529 | ret |
1528 | 1530 | ||
1529 | display_number: |
1531 | display_number: |
1530 | ;It is not optimization |
1532 | ;It is not optimization |
1531 | mov eax, ebx |
1533 | mov eax, ebx |
1532 | mov ebx, ecx |
1534 | mov ebx, ecx |
1533 | mov ecx, edx |
1535 | mov ecx, edx |
1534 | mov edx, esi |
1536 | mov edx, esi |
1535 | mov esi, edi |
1537 | mov esi, edi |
1536 | ; eax = print type, al=0 -> ebx is number |
1538 | ; eax = print type, al=0 -> ebx is number |
1537 | ; al=1 -> ebx is pointer |
1539 | ; al=1 -> ebx is pointer |
1538 | ; ah=0 -> display decimal |
1540 | ; ah=0 -> display decimal |
1539 | ; ah=1 -> display hexadecimal |
1541 | ; ah=1 -> display hexadecimal |
1540 | ; ah=2 -> display binary |
1542 | ; ah=2 -> display binary |
1541 | ; eax bits 16-21 = number of digits to display (0-32) |
1543 | ; eax bits 16-21 = number of digits to display (0-32) |
1542 | ; eax bits 22-31 = reserved |
1544 | ; eax bits 22-31 = reserved |
1543 | ; |
1545 | ; |
1544 | ; ebx = number or pointer |
1546 | ; ebx = number or pointer |
1545 | ; ecx = x shl 16 + y |
1547 | ; ecx = x shl 16 + y |
1546 | ; edx = color |
1548 | ; edx = color |
1547 | xor edi, edi |
1549 | xor edi, edi |
1548 | display_number_force: |
1550 | display_number_force: |
1549 | push eax |
1551 | push eax |
1550 | and eax, 0x3fffffff |
1552 | and eax, 0x3fffffff |
1551 | cmp eax, 0xffff ; length > 0 ? |
1553 | cmp eax, 0xffff ; length > 0 ? |
1552 | pop eax |
1554 | pop eax |
1553 | jge cont_displ |
1555 | jge cont_displ |
1554 | ret |
1556 | ret |
1555 | cont_displ: |
1557 | cont_displ: |
1556 | push eax |
1558 | push eax |
1557 | and eax, 0x3fffffff |
1559 | and eax, 0x3fffffff |
1558 | cmp eax, 61*0x10000 ; length <= 60 ? |
1560 | cmp eax, 61*0x10000 ; length <= 60 ? |
1559 | pop eax |
1561 | pop eax |
1560 | jb cont_displ2 |
1562 | jb cont_displ2 |
1561 | ret |
1563 | ret |
1562 | cont_displ2: |
1564 | cont_displ2: |
1563 | 1565 | ||
1564 | pushad |
1566 | pushad |
1565 | 1567 | ||
1566 | cmp al, 1 ; ecx is a pointer ? |
1568 | cmp al, 1 ; ecx is a pointer ? |
1567 | jne displnl1 |
1569 | jne displnl1 |
1568 | mov ebp, ebx |
1570 | mov ebp, ebx |
1569 | add ebp, 4 |
1571 | add ebp, 4 |
1570 | mov ebp, [ebp+std_application_base_address] |
1572 | mov ebp, [ebp+std_application_base_address] |
1571 | mov ebx, [ebx+std_application_base_address] |
1573 | mov ebx, [ebx+std_application_base_address] |
1572 | displnl1: |
1574 | displnl1: |
1573 | sub esp, 64 |
1575 | sub esp, 64 |
1574 | 1576 | ||
1575 | test ah, ah ; DECIMAL |
1577 | test ah, ah ; DECIMAL |
1576 | jnz no_display_desnum |
1578 | jnz no_display_desnum |
1577 | shr eax, 16 |
1579 | shr eax, 16 |
1578 | and eax, 0xC03f |
1580 | and eax, 0xC03f |
1579 | ; and eax,0x3f |
1581 | ; and eax,0x3f |
1580 | push eax |
1582 | push eax |
1581 | and eax, 0x3f |
1583 | and eax, 0x3f |
1582 | mov edi, esp |
1584 | mov edi, esp |
1583 | add edi, 4+64-1 |
1585 | add edi, 4+64-1 |
1584 | mov ecx, eax |
1586 | mov ecx, eax |
1585 | mov eax, ebx |
1587 | mov eax, ebx |
1586 | mov ebx, 10 |
1588 | mov ebx, 10 |
1587 | d_desnum: |
1589 | d_desnum: |
1588 | xor edx, edx |
1590 | xor edx, edx |
1589 | call division_64_bits |
1591 | call division_64_bits |
1590 | div ebx |
1592 | div ebx |
1591 | add dl, 48 |
1593 | add dl, 48 |
1592 | mov [edi], dl |
1594 | mov [edi], dl |
1593 | dec edi |
1595 | dec edi |
1594 | loop d_desnum |
1596 | loop d_desnum |
1595 | pop eax |
1597 | pop eax |
1596 | call normalize_number |
1598 | call normalize_number |
1597 | call draw_num_text |
1599 | call draw_num_text |
1598 | add esp, 64 |
1600 | add esp, 64 |
1599 | popad |
1601 | popad |
1600 | ret |
1602 | ret |
1601 | no_display_desnum: |
1603 | no_display_desnum: |
1602 | 1604 | ||
1603 | cmp ah, 0x01 ; HEXADECIMAL |
1605 | cmp ah, 0x01 ; HEXADECIMAL |
1604 | jne no_display_hexnum |
1606 | jne no_display_hexnum |
1605 | shr eax, 16 |
1607 | shr eax, 16 |
1606 | and eax, 0xC03f |
1608 | and eax, 0xC03f |
1607 | ; and eax,0x3f |
1609 | ; and eax,0x3f |
1608 | push eax |
1610 | push eax |
1609 | and eax, 0x3f |
1611 | and eax, 0x3f |
1610 | mov edi, esp |
1612 | mov edi, esp |
1611 | add edi, 4+64-1 |
1613 | add edi, 4+64-1 |
1612 | mov ecx, eax |
1614 | mov ecx, eax |
1613 | mov eax, ebx |
1615 | mov eax, ebx |
1614 | mov ebx, 16 |
1616 | mov ebx, 16 |
1615 | d_hexnum: |
1617 | d_hexnum: |
1616 | xor edx, edx |
1618 | xor edx, edx |
1617 | call division_64_bits |
1619 | call division_64_bits |
1618 | div ebx |
1620 | div ebx |
1619 | hexletters = __fdo_hexdigits |
1621 | hexletters = __fdo_hexdigits |
1620 | add edx, hexletters |
1622 | add edx, hexletters |
1621 | mov dl, [edx] |
1623 | mov dl, [edx] |
1622 | mov [edi], dl |
1624 | mov [edi], dl |
1623 | dec edi |
1625 | dec edi |
1624 | loop d_hexnum |
1626 | loop d_hexnum |
1625 | pop eax |
1627 | pop eax |
1626 | call normalize_number |
1628 | call normalize_number |
1627 | call draw_num_text |
1629 | call draw_num_text |
1628 | add esp, 64 |
1630 | add esp, 64 |
1629 | popad |
1631 | popad |
1630 | ret |
1632 | ret |
1631 | no_display_hexnum: |
1633 | no_display_hexnum: |
1632 | 1634 | ||
1633 | cmp ah, 0x02 ; BINARY |
1635 | cmp ah, 0x02 ; BINARY |
1634 | jne no_display_binnum |
1636 | jne no_display_binnum |
1635 | shr eax, 16 |
1637 | shr eax, 16 |
1636 | and eax, 0xC03f |
1638 | and eax, 0xC03f |
1637 | ; and eax,0x3f |
1639 | ; and eax,0x3f |
1638 | push eax |
1640 | push eax |
1639 | and eax, 0x3f |
1641 | and eax, 0x3f |
1640 | mov edi, esp |
1642 | mov edi, esp |
1641 | add edi, 4+64-1 |
1643 | add edi, 4+64-1 |
1642 | mov ecx, eax |
1644 | mov ecx, eax |
1643 | mov eax, ebx |
1645 | mov eax, ebx |
1644 | mov ebx, 2 |
1646 | mov ebx, 2 |
1645 | d_binnum: |
1647 | d_binnum: |
1646 | xor edx, edx |
1648 | xor edx, edx |
1647 | call division_64_bits |
1649 | call division_64_bits |
1648 | div ebx |
1650 | div ebx |
1649 | add dl, 48 |
1651 | add dl, 48 |
1650 | mov [edi], dl |
1652 | mov [edi], dl |
1651 | dec edi |
1653 | dec edi |
1652 | loop d_binnum |
1654 | loop d_binnum |
1653 | pop eax |
1655 | pop eax |
1654 | call normalize_number |
1656 | call normalize_number |
1655 | call draw_num_text |
1657 | call draw_num_text |
1656 | add esp, 64 |
1658 | add esp, 64 |
1657 | popad |
1659 | popad |
1658 | ret |
1660 | ret |
1659 | no_display_binnum: |
1661 | no_display_binnum: |
1660 | 1662 | ||
1661 | add esp, 64 |
1663 | add esp, 64 |
1662 | popad |
1664 | popad |
1663 | ret |
1665 | ret |
1664 | 1666 | ||
1665 | normalize_number: |
1667 | normalize_number: |
1666 | test ah, 0x80 |
1668 | test ah, 0x80 |
1667 | jz .continue |
1669 | jz .continue |
1668 | mov ecx, 48 |
1670 | mov ecx, 48 |
1669 | and eax, 0x3f |
1671 | and eax, 0x3f |
1670 | @@: |
1672 | @@: |
1671 | inc edi |
1673 | inc edi |
1672 | cmp [edi], cl |
1674 | cmp [edi], cl |
1673 | jne .continue |
1675 | jne .continue |
1674 | dec eax |
1676 | dec eax |
1675 | cmp eax, 1 |
1677 | cmp eax, 1 |
1676 | ja @r |
1678 | ja @r |
1677 | mov al, 1 |
1679 | mov al, 1 |
1678 | .continue: |
1680 | .continue: |
1679 | and eax, 0x3f |
1681 | and eax, 0x3f |
1680 | ret |
1682 | ret |
1681 | 1683 | ||
1682 | division_64_bits: |
1684 | division_64_bits: |
1683 | test [esp+1+4], byte 0x40 |
1685 | test [esp+1+4], byte 0x40 |
1684 | jz .continue |
1686 | jz .continue |
1685 | push eax |
1687 | push eax |
1686 | mov eax, ebp |
1688 | mov eax, ebp |
1687 | div ebx |
1689 | div ebx |
1688 | mov ebp, eax |
1690 | mov ebp, eax |
1689 | pop eax |
1691 | pop eax |
1690 | .continue: |
1692 | .continue: |
1691 | ret |
1693 | ret |
1692 | 1694 | ||
1693 | draw_num_text: |
1695 | draw_num_text: |
1694 | mov esi, eax |
1696 | mov esi, eax |
1695 | mov edx, 64+4 |
1697 | mov edx, 64+4 |
1696 | sub edx, eax |
1698 | sub edx, eax |
1697 | add edx, esp |
1699 | add edx, esp |
1698 | mov ebx, [esp+64+32-8+4] |
1700 | mov ebx, [esp+64+32-8+4] |
1699 | ; add window start x & y |
1701 | ; add window start x & y |
1700 | mov ecx, [TASK_BASE] |
1702 | mov ecx, [TASK_BASE] |
1701 | 1703 | ||
1702 | mov edi, [CURRENT_TASK] |
1704 | mov edi, [CURRENT_TASK] |
1703 | shl edi, 8 |
1705 | shl edi, 8 |
1704 | 1706 | ||
1705 | mov eax, [ecx-twdw+WDATA.box.left] |
1707 | mov eax, [ecx-twdw+WDATA.box.left] |
1706 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1708 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1707 | shl eax, 16 |
1709 | shl eax, 16 |
1708 | add eax, [ecx-twdw+WDATA.box.top] |
1710 | add eax, [ecx-twdw+WDATA.box.top] |
1709 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1711 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1710 | add ebx, eax |
1712 | add ebx, eax |
1711 | mov ecx, [esp+64+32-12+4] |
1713 | mov ecx, [esp+64+32-12+4] |
1712 | and ecx, not 0x80000000 ; force counted string |
1714 | and ecx, not 0x80000000 ; force counted string |
1713 | mov eax, [esp+64+8] ; background color (if given) |
1715 | mov eax, [esp+64+8] ; background color (if given) |
1714 | mov edi, [esp+64+4] |
1716 | mov edi, [esp+64+4] |
1715 | jmp dtext |
1717 | jmp dtext |
1716 | 1718 | ||
1717 | align 4 |
1719 | align 4 |
1718 | 1720 | ||
1719 | sys_setup: |
1721 | sys_setup: |
1720 | 1722 | ||
1721 | ; 1=roland mpu midi base , base io address |
1723 | ; 1=roland mpu midi base , base io address |
1722 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1724 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1723 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1725 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1724 | ; 5=system language, 1eng 2fi 3ger 4rus |
1726 | ; 5=system language, 1eng 2fi 3ger 4rus |
1725 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1727 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1726 | ; 8=fat32 partition in hd |
1728 | ; 8=fat32 partition in hd |
1727 | ; 9 |
1729 | ; 9 |
1728 | ; 10 = sound dma channel |
1730 | ; 10 = sound dma channel |
1729 | ; 11 = enable lba read |
1731 | ; 11 = enable lba read |
1730 | ; 12 = enable pci access |
1732 | ; 12 = enable pci access |
1731 | 1733 | ||
1732 | 1734 | ||
1733 | and [esp+32], dword 0 |
1735 | and [esp+32], dword 0 |
1734 | dec ebx ; MIDI |
1736 | dec ebx ; MIDI |
1735 | jnz nsyse1 |
1737 | jnz nsyse1 |
1736 | cmp ecx, 0x100 |
1738 | cmp ecx, 0x100 |
1737 | 1739 | ||
1738 | jb nsyse1 |
1740 | jb nsyse1 |
1739 | mov esi, 65535 |
1741 | mov esi, 65535 |
1740 | cmp esi, ecx |
1742 | cmp esi, ecx |
1741 | 1743 | ||
1742 | jb nsyse1 |
1744 | jb nsyse1 |
1743 | mov [midi_base], cx ;bx |
1745 | mov [midi_base], cx ;bx |
1744 | mov word [mididp], cx;bx |
1746 | mov word [mididp], cx;bx |
1745 | inc cx ;bx |
1747 | inc cx ;bx |
1746 | mov word [midisp], cx;bx |
1748 | mov word [midisp], cx;bx |
1747 | ret |
1749 | ret |
1748 | 1750 | ||
1749 | iglobal |
1751 | iglobal |
1750 | midi_base dw 0 |
1752 | midi_base dw 0 |
1751 | endg |
1753 | endg |
1752 | 1754 | ||
1753 | nsyse1: |
1755 | nsyse1: |
1754 | dec ebx ; KEYBOARD |
1756 | dec ebx ; KEYBOARD |
1755 | jnz nsyse2 |
1757 | jnz nsyse2 |
1756 | mov edi, [TASK_BASE] |
1758 | mov edi, [TASK_BASE] |
1757 | mov eax, [edi+TASKDATA.mem_start] |
1759 | mov eax, [edi+TASKDATA.mem_start] |
1758 | add eax, edx |
1760 | add eax, edx |
1759 | 1761 | ||
1760 | dec ecx |
1762 | dec ecx |
1761 | jnz kbnobase |
1763 | jnz kbnobase |
1762 | mov ebx, keymap |
1764 | mov ebx, keymap |
1763 | mov ecx, 128 |
1765 | mov ecx, 128 |
1764 | call memmove |
1766 | call memmove |
1765 | ret |
1767 | ret |
1766 | kbnobase: |
1768 | kbnobase: |
1767 | dec ecx |
1769 | dec ecx |
1768 | jnz kbnoshift |
1770 | jnz kbnoshift |
1769 | 1771 | ||
1770 | mov ebx, keymap_shift |
1772 | mov ebx, keymap_shift |
1771 | mov ecx, 128 |
1773 | mov ecx, 128 |
1772 | call memmove |
1774 | call memmove |
1773 | ret |
1775 | ret |
1774 | kbnoshift: |
1776 | kbnoshift: |
1775 | dec ecx |
1777 | dec ecx |
1776 | jnz kbnoalt |
1778 | jnz kbnoalt |
1777 | mov ebx, keymap_alt |
1779 | mov ebx, keymap_alt |
1778 | mov ecx, 128 |
1780 | mov ecx, 128 |
1779 | call memmove |
1781 | call memmove |
1780 | ret |
1782 | ret |
1781 | kbnoalt: |
1783 | kbnoalt: |
1782 | sub ecx, 6 |
1784 | sub ecx, 6 |
1783 | jnz kbnocountry |
1785 | jnz kbnocountry |
1784 | mov word [keyboard], dx |
1786 | mov word [keyboard], dx |
1785 | ret |
1787 | ret |
1786 | kbnocountry: |
1788 | kbnocountry: |
1787 | mov [esp+32], dword 1 |
1789 | mov [esp+32], dword 1 |
1788 | ret |
1790 | ret |
1789 | nsyse2: |
1791 | nsyse2: |
1790 | dec ebx ; CD |
1792 | dec ebx ; CD |
1791 | jnz nsyse4 |
1793 | jnz nsyse4 |
1792 | 1794 | ||
1793 | test ecx, ecx |
1795 | test ecx, ecx |
1794 | jz nosesl |
1796 | jz nosesl |
1795 | 1797 | ||
1796 | cmp ecx, 4 |
1798 | cmp ecx, 4 |
1797 | ja nosesl |
1799 | ja nosesl |
1798 | mov [cd_base], cl |
1800 | mov [cd_base], cl |
1799 | 1801 | ||
1800 | dec ecx |
1802 | dec ecx |
1801 | jnz noprma |
1803 | jnz noprma |
1802 | mov eax, [hd_address_table] |
1804 | mov eax, [hd_address_table] |
1803 | mov [cdbase], eax ;0x1f0 |
1805 | mov [cdbase], eax ;0x1f0 |
1804 | mov [cdid], 0xa0 |
1806 | mov [cdid], 0xa0 |
1805 | noprma: |
1807 | noprma: |
1806 | 1808 | ||
1807 | dec ecx |
1809 | dec ecx |
1808 | jnz noprsl |
1810 | jnz noprsl |
1809 | mov eax, [hd_address_table] |
1811 | mov eax, [hd_address_table] |
1810 | mov [cdbase], eax ;0x1f0 |
1812 | mov [cdbase], eax ;0x1f0 |
1811 | mov [cdid], 0xb0 |
1813 | mov [cdid], 0xb0 |
1812 | noprsl: |
1814 | noprsl: |
1813 | dec ecx |
1815 | dec ecx |
1814 | jnz nosema |
1816 | jnz nosema |
1815 | mov eax, [hd_address_table+16] |
1817 | mov eax, [hd_address_table+16] |
1816 | mov [cdbase], eax ;0x170 |
1818 | mov [cdbase], eax ;0x170 |
1817 | mov [cdid], 0xa0 |
1819 | mov [cdid], 0xa0 |
1818 | nosema: |
1820 | nosema: |
1819 | dec ecx |
1821 | dec ecx |
1820 | jnz nosesl |
1822 | jnz nosesl |
1821 | mov eax, [hd_address_table+16] |
1823 | mov eax, [hd_address_table+16] |
1822 | mov [cdbase], eax ;0x170 |
1824 | mov [cdbase], eax ;0x170 |
1823 | mov [cdid], 0xb0 |
1825 | mov [cdid], 0xb0 |
1824 | nosesl: |
1826 | nosesl: |
1825 | ret |
1827 | ret |
1826 | 1828 | ||
1827 | iglobal |
1829 | iglobal |
1828 | cd_base db 0 |
1830 | cd_base db 0 |
1829 | 1831 | ||
1830 | endg |
1832 | endg |
1831 | nsyse4: |
1833 | nsyse4: |
1832 | 1834 | ||
1833 | sub ebx, 2 ; SYSTEM LANGUAGE |
1835 | sub ebx, 2 ; SYSTEM LANGUAGE |
1834 | jnz nsyse5 |
1836 | jnz nsyse5 |
1835 | mov [syslang], ecx |
1837 | mov [syslang], ecx |
1836 | ret |
1838 | ret |
1837 | nsyse5: |
1839 | nsyse5: |
1838 | 1840 | ||
1839 | sub ebx, 2 ; HD BASE - obsolete |
1841 | sub ebx, 2 ; HD BASE - obsolete |
1840 | jnz nsyse7 |
1842 | jnz nsyse7 |
1841 | 1843 | ||
1842 | nosethd: |
1844 | nosethd: |
1843 | ret |
1845 | ret |
1844 | 1846 | ||
1845 | nsyse7: |
1847 | nsyse7: |
1846 | 1848 | ||
1847 | ; cmp eax,8 ; HD PARTITION - obsolete |
1849 | ; cmp eax,8 ; HD PARTITION - obsolete |
1848 | dec ebx |
1850 | dec ebx |
1849 | jnz nsyse8 |
1851 | jnz nsyse8 |
1850 | ret |
1852 | ret |
1851 | 1853 | ||
1852 | nsyse8: |
1854 | nsyse8: |
1853 | ; cmp eax,11 ; ENABLE LBA READ |
1855 | ; cmp eax,11 ; ENABLE LBA READ |
1854 | and ecx, 1 |
1856 | and ecx, 1 |
1855 | sub ebx, 3 |
1857 | sub ebx, 3 |
1856 | jnz no_set_lba_read |
1858 | jnz no_set_lba_read |
1857 | mov [lba_read_enabled], ecx |
1859 | mov [lba_read_enabled], ecx |
1858 | ret |
1860 | ret |
1859 | 1861 | ||
1860 | no_set_lba_read: |
1862 | no_set_lba_read: |
1861 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1863 | ; cmp eax,12 ; ENABLE PCI ACCESS |
1862 | dec ebx |
1864 | dec ebx |
1863 | jnz sys_setup_err |
1865 | jnz sys_setup_err |
1864 | mov [pci_access_enabled], ecx |
1866 | mov [pci_access_enabled], ecx |
1865 | ret |
1867 | ret |
1866 | 1868 | ||
1867 | sys_setup_err: |
1869 | sys_setup_err: |
1868 | or [esp+32], dword -1 |
1870 | or [esp+32], dword -1 |
1869 | ret |
1871 | ret |
1870 | 1872 | ||
1871 | align 4 |
1873 | align 4 |
1872 | 1874 | ||
1873 | sys_getsetup: |
1875 | sys_getsetup: |
1874 | 1876 | ||
1875 | ; 1=roland mpu midi base , base io address |
1877 | ; 1=roland mpu midi base , base io address |
1876 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1878 | ; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1877 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1879 | ; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1878 | ; 5=system language, 1eng 2fi 3ger 4rus |
1880 | ; 5=system language, 1eng 2fi 3ger 4rus |
1879 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1881 | ; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave |
1880 | ; 8=fat32 partition in hd |
1882 | ; 8=fat32 partition in hd |
1881 | ; 9=get hs timer tic |
1883 | ; 9=get hs timer tic |
1882 | 1884 | ||
1883 | ; cmp eax,1 |
1885 | ; cmp eax,1 |
1884 | dec ebx |
1886 | dec ebx |
1885 | jnz ngsyse1 |
1887 | jnz ngsyse1 |
1886 | movzx eax, [midi_base] |
1888 | movzx eax, [midi_base] |
1887 | mov [esp+32], eax |
1889 | mov [esp+32], eax |
1888 | ret |
1890 | ret |
1889 | ngsyse1: |
1891 | ngsyse1: |
1890 | ; cmp eax,2 |
1892 | ; cmp eax,2 |
1891 | dec ebx |
1893 | dec ebx |
1892 | jnz ngsyse2 |
1894 | jnz ngsyse2 |
1893 | 1895 | ||
1894 | mov edi, [TASK_BASE] |
1896 | mov edi, [TASK_BASE] |
1895 | mov ebx, [edi+TASKDATA.mem_start] |
1897 | mov ebx, [edi+TASKDATA.mem_start] |
1896 | add ebx, edx |
1898 | add ebx, edx |
1897 | 1899 | ||
1898 | ; cmp ebx,1 |
1900 | ; cmp ebx,1 |
1899 | dec ecx |
1901 | dec ecx |
1900 | jnz kbnobaseret |
1902 | jnz kbnobaseret |
1901 | mov eax, keymap |
1903 | mov eax, keymap |
1902 | mov ecx, 128 |
1904 | mov ecx, 128 |
1903 | call memmove |
1905 | call memmove |
1904 | ret |
1906 | ret |
1905 | kbnobaseret: |
1907 | kbnobaseret: |
1906 | ; cmp ebx,2 |
1908 | ; cmp ebx,2 |
1907 | dec ecx |
1909 | dec ecx |
1908 | jnz kbnoshiftret |
1910 | jnz kbnoshiftret |
1909 | 1911 | ||
1910 | mov eax, keymap_shift |
1912 | mov eax, keymap_shift |
1911 | mov ecx, 128 |
1913 | mov ecx, 128 |
1912 | call memmove |
1914 | call memmove |
1913 | ret |
1915 | ret |
1914 | kbnoshiftret: |
1916 | kbnoshiftret: |
1915 | ; cmp ebx,3 |
1917 | ; cmp ebx,3 |
1916 | dec ecx |
1918 | dec ecx |
1917 | jne kbnoaltret |
1919 | jne kbnoaltret |
1918 | 1920 | ||
1919 | mov eax, keymap_alt |
1921 | mov eax, keymap_alt |
1920 | mov ecx, 128 |
1922 | mov ecx, 128 |
1921 | call memmove |
1923 | call memmove |
1922 | ret |
1924 | ret |
1923 | kbnoaltret: |
1925 | kbnoaltret: |
1924 | ; cmp ebx,9 |
1926 | ; cmp ebx,9 |
1925 | sub ecx, 6 |
1927 | sub ecx, 6 |
1926 | jnz ngsyse2 |
1928 | jnz ngsyse2 |
1927 | movzx eax, word [keyboard] |
1929 | movzx eax, word [keyboard] |
1928 | mov [esp+32], eax |
1930 | mov [esp+32], eax |
1929 | ret |
1931 | ret |
1930 | 1932 | ||
1931 | 1933 | ||
1932 | ngsyse2: |
1934 | ngsyse2: |
1933 | ; cmp eax,3 |
1935 | ; cmp eax,3 |
1934 | dec ebx |
1936 | dec ebx |
1935 | jnz ngsyse3 |
1937 | jnz ngsyse3 |
1936 | movzx eax, [cd_base] |
1938 | movzx eax, [cd_base] |
1937 | mov [esp+32], eax |
1939 | mov [esp+32], eax |
1938 | ret |
1940 | ret |
1939 | ngsyse3: |
1941 | ngsyse3: |
1940 | ; cmp eax,5 |
1942 | ; cmp eax,5 |
1941 | sub ebx, 2 |
1943 | sub ebx, 2 |
1942 | jnz ngsyse5 |
1944 | jnz ngsyse5 |
1943 | mov eax, [syslang] |
1945 | mov eax, [syslang] |
1944 | mov [esp+32], eax |
1946 | mov [esp+32], eax |
1945 | ret |
1947 | ret |
1946 | ngsyse5: |
1948 | ngsyse5: |
1947 | ; cmp eax,7 |
1949 | ; cmp eax,7 |
1948 | sub ebx, 2 |
1950 | sub ebx, 2 |
1949 | jnz ngsyse7 |
1951 | jnz ngsyse7 |
1950 | xor eax, eax |
1952 | xor eax, eax |
1951 | mov [esp+32], eax |
1953 | mov [esp+32], eax |
1952 | ret |
1954 | ret |
1953 | ngsyse7: |
1955 | ngsyse7: |
1954 | ; cmp eax,8 |
1956 | ; cmp eax,8 |
1955 | dec ebx |
1957 | dec ebx |
1956 | jnz ngsyse8 |
1958 | jnz ngsyse8 |
1957 | mov eax, [fat32part] |
1959 | mov eax, [fat32part] |
1958 | mov [esp+32], eax |
1960 | mov [esp+32], eax |
1959 | ret |
1961 | ret |
1960 | ngsyse8: |
1962 | ngsyse8: |
1961 | ; cmp eax,9 |
1963 | ; cmp eax,9 |
1962 | dec ebx |
1964 | dec ebx |
1963 | jnz ngsyse9 |
1965 | jnz ngsyse9 |
1964 | mov eax, [timer_ticks];[0xfdf0] |
1966 | mov eax, [timer_ticks];[0xfdf0] |
1965 | mov [esp+32], eax |
1967 | mov [esp+32], eax |
1966 | ret |
1968 | ret |
1967 | ngsyse9: |
1969 | ngsyse9: |
1968 | ; cmp eax,11 |
1970 | ; cmp eax,11 |
1969 | sub ebx, 2 |
1971 | sub ebx, 2 |
1970 | jnz ngsyse11 |
1972 | jnz ngsyse11 |
1971 | mov eax, [lba_read_enabled] |
1973 | mov eax, [lba_read_enabled] |
1972 | mov [esp+32], eax |
1974 | mov [esp+32], eax |
1973 | ret |
1975 | ret |
1974 | ngsyse11: |
1976 | ngsyse11: |
1975 | ; cmp eax,12 |
1977 | ; cmp eax,12 |
1976 | dec ebx |
1978 | dec ebx |
1977 | jnz ngsyse12 |
1979 | jnz ngsyse12 |
1978 | mov eax, [pci_access_enabled] |
1980 | mov eax, [pci_access_enabled] |
1979 | mov [esp+32], eax |
1981 | mov [esp+32], eax |
1980 | ret |
1982 | ret |
1981 | ngsyse12: |
1983 | ngsyse12: |
1982 | mov [esp+32], dword 1 |
1984 | mov [esp+32], dword 1 |
1983 | ret |
1985 | ret |
1984 | 1986 | ||
1985 | 1987 | ||
1986 | get_timer_ticks: |
1988 | get_timer_ticks: |
1987 | mov eax, [timer_ticks] |
1989 | mov eax, [timer_ticks] |
1988 | ret |
1990 | ret |
1989 | 1991 | ||
1990 | iglobal |
1992 | iglobal |
1991 | align 4 |
1993 | align 4 |
1992 | mousefn dd msscreen, mswin, msbutton, msset |
1994 | mousefn dd msscreen, mswin, msbutton, msset |
1993 | dd app_load_cursor |
1995 | dd app_load_cursor |
1994 | dd app_set_cursor |
1996 | dd app_set_cursor |
1995 | dd app_delete_cursor |
1997 | dd app_delete_cursor |
1996 | dd msz |
1998 | dd msz |
1997 | endg |
1999 | endg |
1998 | 2000 | ||
1999 | readmousepos: |
2001 | readmousepos: |
2000 | 2002 | ||
2001 | ; eax=0 screen relative |
2003 | ; eax=0 screen relative |
2002 | ; eax=1 window relative |
2004 | ; eax=1 window relative |
2003 | ; eax=2 buttons pressed |
2005 | ; eax=2 buttons pressed |
2004 | ; eax=3 set mouse pos ; reserved |
2006 | ; eax=3 set mouse pos ; reserved |
2005 | ; eax=4 load cursor |
2007 | ; eax=4 load cursor |
2006 | ; eax=5 set cursor |
2008 | ; eax=5 set cursor |
2007 | ; eax=6 delete cursor ; reserved |
2009 | ; eax=6 delete cursor ; reserved |
2008 | ; eax=7 get mouse_z |
2010 | ; eax=7 get mouse_z |
2009 | 2011 | ||
2010 | cmp ebx, 7 |
2012 | cmp ebx, 7 |
2011 | ja msset |
2013 | ja msset |
2012 | jmp [mousefn+ebx*4] |
2014 | jmp [mousefn+ebx*4] |
2013 | msscreen: |
2015 | msscreen: |
2014 | mov eax, [MOUSE_X] |
2016 | mov eax, [MOUSE_X] |
2015 | shl eax, 16 |
2017 | shl eax, 16 |
2016 | mov ax, [MOUSE_Y] |
2018 | mov ax, [MOUSE_Y] |
2017 | mov [esp+36-4], eax |
2019 | mov [esp+36-4], eax |
2018 | ret |
2020 | ret |
2019 | mswin: |
2021 | mswin: |
2020 | mov eax, [MOUSE_X] |
2022 | mov eax, [MOUSE_X] |
2021 | shl eax, 16 |
2023 | shl eax, 16 |
2022 | mov ax, [MOUSE_Y] |
2024 | mov ax, [MOUSE_Y] |
2023 | mov esi, [TASK_BASE] |
2025 | mov esi, [TASK_BASE] |
2024 | mov bx, word [esi-twdw+WDATA.box.left] |
2026 | mov bx, word [esi-twdw+WDATA.box.left] |
2025 | shl ebx, 16 |
2027 | shl ebx, 16 |
2026 | mov bx, word [esi-twdw+WDATA.box.top] |
2028 | mov bx, word [esi-twdw+WDATA.box.top] |
2027 | sub eax, ebx |
2029 | sub eax, ebx |
2028 | 2030 | ||
2029 | mov edi, [CURRENT_TASK] |
2031 | mov edi, [CURRENT_TASK] |
2030 | shl edi, 8 |
2032 | shl edi, 8 |
2031 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
2033 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
2032 | rol eax, 16 |
2034 | rol eax, 16 |
2033 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
2035 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
2034 | rol eax, 16 |
2036 | rol eax, 16 |
2035 | mov [esp+36-4], eax |
2037 | mov [esp+36-4], eax |
2036 | ret |
2038 | ret |
2037 | msbutton: |
2039 | msbutton: |
2038 | movzx eax, byte [BTN_DOWN] |
2040 | movzx eax, byte [BTN_DOWN] |
2039 | mov [esp+36-4], eax |
2041 | mov [esp+36-4], eax |
2040 | ret |
2042 | ret |
2041 | msz: |
2043 | msz: |
2042 | mov edi, [TASK_COUNT] |
2044 | mov edi, [TASK_COUNT] |
2043 | movzx edi, word [WIN_POS + edi*2] |
2045 | movzx edi, word [WIN_POS + edi*2] |
2044 | cmp edi, [CURRENT_TASK] |
2046 | cmp edi, [CURRENT_TASK] |
2045 | jne @f |
2047 | jne @f |
2046 | mov ax, [MOUSE_SCROLL_H] |
2048 | mov ax, [MOUSE_SCROLL_H] |
2047 | shl eax, 16 |
2049 | shl eax, 16 |
2048 | mov ax, [MOUSE_SCROLL_V] |
2050 | mov ax, [MOUSE_SCROLL_V] |
2049 | mov [esp+36-4], eax |
2051 | mov [esp+36-4], eax |
2050 | and [MOUSE_SCROLL_H], word 0 |
2052 | and [MOUSE_SCROLL_H], word 0 |
2051 | and [MOUSE_SCROLL_V], word 0 |
2053 | and [MOUSE_SCROLL_V], word 0 |
2052 | ret |
2054 | ret |
2053 | @@: |
2055 | @@: |
2054 | and [esp+36-4], dword 0 |
2056 | and [esp+36-4], dword 0 |
2055 | ; ret |
2057 | ; ret |
2056 | msset: |
2058 | msset: |
2057 | ret |
2059 | ret |
2058 | 2060 | ||
2059 | app_load_cursor: |
2061 | app_load_cursor: |
2060 | cmp ecx, OS_BASE |
2062 | cmp ecx, OS_BASE |
2061 | jae msset |
2063 | jae msset |
2062 | stdcall load_cursor, ecx, edx |
2064 | stdcall load_cursor, ecx, edx |
2063 | mov [esp+36-4], eax |
2065 | mov [esp+36-4], eax |
2064 | ret |
2066 | ret |
2065 | 2067 | ||
2066 | app_set_cursor: |
2068 | app_set_cursor: |
2067 | stdcall set_cursor, ecx |
2069 | stdcall set_cursor, ecx |
2068 | mov [esp+36-4], eax |
2070 | mov [esp+36-4], eax |
2069 | ret |
2071 | ret |
2070 | 2072 | ||
2071 | app_delete_cursor: |
2073 | app_delete_cursor: |
2072 | stdcall delete_cursor, ecx |
2074 | stdcall delete_cursor, ecx |
2073 | mov [esp+36-4], eax |
2075 | mov [esp+36-4], eax |
2074 | ret |
2076 | ret |
2075 | 2077 | ||
2076 | is_input: |
2078 | is_input: |
2077 | 2079 | ||
2078 | push edx |
2080 | push edx |
2079 | mov dx, word [midisp] |
2081 | mov dx, word [midisp] |
2080 | in al, dx |
2082 | in al, dx |
2081 | and al, 0x80 |
2083 | and al, 0x80 |
2082 | pop edx |
2084 | pop edx |
2083 | ret |
2085 | ret |
2084 | 2086 | ||
2085 | is_output: |
2087 | is_output: |
2086 | 2088 | ||
2087 | push edx |
2089 | push edx |
2088 | mov dx, word [midisp] |
2090 | mov dx, word [midisp] |
2089 | in al, dx |
2091 | in al, dx |
2090 | and al, 0x40 |
2092 | and al, 0x40 |
2091 | pop edx |
2093 | pop edx |
2092 | ret |
2094 | ret |
2093 | 2095 | ||
2094 | 2096 | ||
2095 | get_mpu_in: |
2097 | get_mpu_in: |
2096 | 2098 | ||
2097 | push edx |
2099 | push edx |
2098 | mov dx, word [mididp] |
2100 | mov dx, word [mididp] |
2099 | in al, dx |
2101 | in al, dx |
2100 | pop edx |
2102 | pop edx |
2101 | ret |
2103 | ret |
2102 | 2104 | ||
2103 | 2105 | ||
2104 | put_mpu_out: |
2106 | put_mpu_out: |
2105 | 2107 | ||
2106 | push edx |
2108 | push edx |
2107 | mov dx, word [mididp] |
2109 | mov dx, word [mididp] |
2108 | out dx, al |
2110 | out dx, al |
2109 | pop edx |
2111 | pop edx |
2110 | ret |
2112 | ret |
2111 | 2113 | ||
2112 | 2114 | ||
2113 | 2115 | ||
2114 | align 4 |
2116 | align 4 |
2115 | 2117 | ||
2116 | sys_midi: |
2118 | sys_midi: |
2117 | cmp [mididp], 0 |
2119 | cmp [mididp], 0 |
2118 | jnz sm0 |
2120 | jnz sm0 |
2119 | mov [esp+36], dword 1 |
2121 | mov [esp+36], dword 1 |
2120 | ret |
2122 | ret |
2121 | sm0: |
2123 | sm0: |
2122 | and [esp+36], dword 0 |
2124 | and [esp+36], dword 0 |
2123 | dec ebx |
2125 | dec ebx |
2124 | jnz smn1 |
2126 | jnz smn1 |
2125 | ; call setuart |
2127 | ; call setuart |
2126 | su1: |
2128 | su1: |
2127 | call is_output |
2129 | call is_output |
2128 | test al, al |
2130 | test al, al |
2129 | jnz su1 |
2131 | jnz su1 |
2130 | mov dx, word [midisp] |
2132 | mov dx, word [midisp] |
2131 | mov al, 0xff |
2133 | mov al, 0xff |
2132 | out dx, al |
2134 | out dx, al |
2133 | su2: |
2135 | su2: |
2134 | mov dx, word [midisp] |
2136 | mov dx, word [midisp] |
2135 | mov al, 0xff |
2137 | mov al, 0xff |
2136 | out dx, al |
2138 | out dx, al |
2137 | call is_input |
2139 | call is_input |
2138 | test al, al |
2140 | test al, al |
2139 | jnz su2 |
2141 | jnz su2 |
2140 | call get_mpu_in |
2142 | call get_mpu_in |
2141 | cmp al, 0xfe |
2143 | cmp al, 0xfe |
2142 | jnz su2 |
2144 | jnz su2 |
2143 | su3: |
2145 | su3: |
2144 | call is_output |
2146 | call is_output |
2145 | test al, al |
2147 | test al, al |
2146 | jnz su3 |
2148 | jnz su3 |
2147 | mov dx, word [midisp] |
2149 | mov dx, word [midisp] |
2148 | mov al, 0x3f |
2150 | mov al, 0x3f |
2149 | out dx, al |
2151 | out dx, al |
2150 | ret |
2152 | ret |
2151 | smn1: |
2153 | smn1: |
2152 | dec ebx |
2154 | dec ebx |
2153 | jnz smn2 |
2155 | jnz smn2 |
2154 | sm10: |
2156 | sm10: |
2155 | call get_mpu_in |
2157 | call get_mpu_in |
2156 | call is_output |
2158 | call is_output |
2157 | test al, al |
2159 | test al, al |
2158 | jnz sm10 |
2160 | jnz sm10 |
2159 | mov al, bl |
2161 | mov al, bl |
2160 | call put_mpu_out |
2162 | call put_mpu_out |
2161 | smn2: |
2163 | smn2: |
2162 | ret |
2164 | ret |
2163 | 2165 | ||
2164 | detect_devices: |
2166 | detect_devices: |
2165 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2167 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2166 | ;include 'detect/commouse.inc' |
2168 | ;include 'detect/commouse.inc' |
2167 | ;include 'detect/ps2mouse.inc' |
2169 | ;include 'detect/ps2mouse.inc' |
2168 | ;include 'detect/dev_fd.inc' |
2170 | ;include 'detect/dev_fd.inc' |
2169 | ;include 'detect/dev_hdcd.inc' |
2171 | ;include 'detect/dev_hdcd.inc' |
2170 | ;include 'detect/sear_par.inc' |
2172 | ;include 'detect/sear_par.inc' |
2171 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2173 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2172 | ret |
2174 | ret |
2173 | 2175 | ||
2174 | sys_end: |
2176 | sys_end: |
2175 | ;-------------------------------------- |
2177 | ;-------------------------------------- |
2176 | cmp [_display.select_cursor], 0 |
2178 | cmp [_display.select_cursor], 0 |
2177 | je @f |
2179 | je @f |
2178 | ; restore default cursor before killing |
2180 | ; restore default cursor before killing |
2179 | pusha |
2181 | pusha |
2180 | mov ecx, [current_slot] |
2182 | mov ecx, [current_slot] |
2181 | call restore_default_cursor_before_killing |
2183 | call restore_default_cursor_before_killing |
2182 | popa |
2184 | popa |
2183 | @@: |
2185 | @@: |
2184 | ;-------------------------------------- |
2186 | ;-------------------------------------- |
2185 | ; kill all sockets this process owns |
2187 | ; kill all sockets this process owns |
2186 | pusha |
2188 | pusha |
2187 | mov edx, [TASK_BASE] |
2189 | mov edx, [TASK_BASE] |
2188 | mov edx, [edx+TASKDATA.pid] |
2190 | mov edx, [edx+TASKDATA.pid] |
2189 | call SOCKET_process_end |
2191 | call SOCKET_process_end |
2190 | popa |
2192 | popa |
2191 | ;-------------------------------------- |
2193 | ;-------------------------------------- |
2192 | mov ecx, [current_slot] |
2194 | mov ecx, [current_slot] |
2193 | mov eax, [ecx+APPDATA.tls_base] |
2195 | mov eax, [ecx+APPDATA.tls_base] |
2194 | test eax, eax |
2196 | test eax, eax |
2195 | jz @F |
2197 | jz @F |
2196 | 2198 | ||
2197 | stdcall user_free, eax |
2199 | stdcall user_free, eax |
2198 | @@: |
2200 | @@: |
2199 | 2201 | ||
2200 | mov eax, [TASK_BASE] |
2202 | mov eax, [TASK_BASE] |
2201 | mov [eax+TASKDATA.state], 3; terminate this program |
2203 | mov [eax+TASKDATA.state], 3; terminate this program |
2202 | call wakeup_osloop |
2204 | call wakeup_osloop |
2203 | 2205 | ||
2204 | .waitterm: ; wait here for termination |
2206 | .waitterm: ; wait here for termination |
2205 | call change_task |
2207 | call change_task |
2206 | jmp .waitterm |
2208 | jmp .waitterm |
2207 | ;------------------------------------------------------------------------------ |
2209 | ;------------------------------------------------------------------------------ |
2208 | align 4 |
2210 | align 4 |
2209 | restore_default_cursor_before_killing: |
2211 | restore_default_cursor_before_killing: |
2210 | pushfd |
2212 | pushfd |
2211 | cli |
2213 | cli |
2212 | mov eax, [def_cursor] |
2214 | mov eax, [def_cursor] |
2213 | mov [ecx+APPDATA.cursor], eax |
2215 | mov [ecx+APPDATA.cursor], eax |
2214 | 2216 | ||
2215 | movzx eax, word [MOUSE_Y] |
2217 | movzx eax, word [MOUSE_Y] |
2216 | movzx ebx, word [MOUSE_X] |
2218 | movzx ebx, word [MOUSE_X] |
2217 | ; mov ecx, [Screen_Max_X] |
2219 | ; mov ecx, [Screen_Max_X] |
2218 | ; inc ecx |
2220 | ; inc ecx |
2219 | ; mul ecx |
2221 | ; mul ecx |
2220 | mov eax, [d_width_calc_area + eax*4] |
2222 | mov eax, [d_width_calc_area + eax*4] |
2221 | 2223 | ||
2222 | add eax, [_WinMapAddress] |
2224 | add eax, [_WinMapAddress] |
2223 | movzx edx, byte [ebx+eax] |
2225 | movzx edx, byte [ebx+eax] |
2224 | shl edx, 8 |
2226 | shl edx, 8 |
2225 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2227 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2226 | 2228 | ||
2227 | cmp esi, [current_cursor] |
2229 | cmp esi, [current_cursor] |
2228 | je @f |
2230 | je @f |
2229 | 2231 | ||
2230 | push esi |
2232 | push esi |
2231 | call [_display.select_cursor] |
2233 | call [_display.select_cursor] |
2232 | mov [current_cursor], esi |
2234 | mov [current_cursor], esi |
2233 | @@: |
2235 | @@: |
2234 | mov [redrawmouse_unconditional], 1 |
2236 | mov [redrawmouse_unconditional], 1 |
2235 | call wakeup_osloop |
2237 | call wakeup_osloop |
2236 | popfd |
2238 | popfd |
2237 | ret |
2239 | ret |
2238 | ;------------------------------------------------------------------------------ |
2240 | ;------------------------------------------------------------------------------ |
2239 | iglobal |
2241 | iglobal |
2240 | align 4 |
2242 | align 4 |
2241 | sys_system_table: |
2243 | sys_system_table: |
2242 | dd sysfn_deactivate ; 1 = deactivate window |
2244 | dd sysfn_deactivate ; 1 = deactivate window |
2243 | dd sysfn_terminate ; 2 = terminate thread |
2245 | dd sysfn_terminate ; 2 = terminate thread |
2244 | dd sysfn_activate ; 3 = activate window |
2246 | dd sysfn_activate ; 3 = activate window |
2245 | dd sysfn_getidletime ; 4 = get idle time |
2247 | dd sysfn_getidletime ; 4 = get idle time |
2246 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2248 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2247 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2249 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2248 | dd sysfn_getactive ; 7 = get active window |
2250 | dd sysfn_getactive ; 7 = get active window |
2249 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2251 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2250 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2252 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2251 | dd sysfn_minimize ; 10 = minimize window |
2253 | dd sysfn_minimize ; 10 = minimize window |
2252 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2254 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2253 | dd sysfn_lastkey ; 12 = get last pressed key |
2255 | dd sysfn_lastkey ; 12 = get last pressed key |
2254 | dd sysfn_getversion ; 13 = get kernel version |
2256 | dd sysfn_getversion ; 13 = get kernel version |
2255 | dd sysfn_waitretrace ; 14 = wait retrace |
2257 | dd sysfn_waitretrace ; 14 = wait retrace |
2256 | dd sysfn_centermouse ; 15 = center mouse cursor |
2258 | dd sysfn_centermouse ; 15 = center mouse cursor |
2257 | dd sysfn_getfreemem ; 16 = get free memory size |
2259 | dd sysfn_getfreemem ; 16 = get free memory size |
2258 | dd sysfn_getallmem ; 17 = get total memory size |
2260 | dd sysfn_getallmem ; 17 = get total memory size |
2259 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2261 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2260 | ; instead of slot |
2262 | ; instead of slot |
2261 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2263 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2262 | dd sysfn_meminfo ; 20 = get extended memory info |
2264 | dd sysfn_meminfo ; 20 = get extended memory info |
2263 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2265 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2264 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2266 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2265 | dd sysfn_min_windows ; 23 = minimize all windows |
2267 | dd sysfn_min_windows ; 23 = minimize all windows |
2266 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2268 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2267 | sysfn_num = ($ - sys_system_table)/4 |
2269 | sysfn_num = ($ - sys_system_table)/4 |
2268 | endg |
2270 | endg |
2269 | ;------------------------------------------------------------------------------ |
2271 | ;------------------------------------------------------------------------------ |
2270 | sys_system: |
2272 | sys_system: |
2271 | dec ebx |
2273 | dec ebx |
2272 | cmp ebx, sysfn_num |
2274 | cmp ebx, sysfn_num |
2273 | jae @f |
2275 | jae @f |
2274 | jmp dword [sys_system_table + ebx*4] |
2276 | jmp dword [sys_system_table + ebx*4] |
2275 | @@: |
2277 | @@: |
2276 | ret |
2278 | ret |
2277 | ;------------------------------------------------------------------------------ |
2279 | ;------------------------------------------------------------------------------ |
2278 | sysfn_shutdown: ; 18.9 = system shutdown |
2280 | sysfn_shutdown: ; 18.9 = system shutdown |
2279 | cmp ecx, 1 |
2281 | cmp ecx, 1 |
2280 | jl exit_for_anyone |
2282 | jl exit_for_anyone |
2281 | cmp ecx, 4 |
2283 | cmp ecx, 4 |
2282 | jg exit_for_anyone |
2284 | jg exit_for_anyone |
2283 | mov [BOOT_VARS+0x9030], cl |
2285 | mov [BOOT_VARS+0x9030], cl |
2284 | 2286 | ||
2285 | mov eax, [TASK_COUNT] |
2287 | mov eax, [TASK_COUNT] |
2286 | mov [SYS_SHUTDOWN], al |
2288 | mov [SYS_SHUTDOWN], al |
2287 | mov [shutdown_processes], eax |
2289 | mov [shutdown_processes], eax |
2288 | call wakeup_osloop |
2290 | call wakeup_osloop |
2289 | and dword [esp+32], 0 |
2291 | and dword [esp+32], 0 |
2290 | exit_for_anyone: |
2292 | exit_for_anyone: |
2291 | ret |
2293 | ret |
2292 | uglobal |
2294 | uglobal |
2293 | shutdown_processes: |
2295 | shutdown_processes: |
2294 | dd 0x0 |
2296 | dd 0x0 |
2295 | endg |
2297 | endg |
2296 | ;------------------------------------------------------------------------------ |
2298 | ;------------------------------------------------------------------------------ |
2297 | sysfn_terminate: ; 18.2 = TERMINATE |
2299 | sysfn_terminate: ; 18.2 = TERMINATE |
2298 | push ecx |
2300 | push ecx |
2299 | cmp ecx, 2 |
2301 | cmp ecx, 2 |
2300 | jb noprocessterminate |
2302 | jb noprocessterminate |
2301 | mov edx, [TASK_COUNT] |
2303 | mov edx, [TASK_COUNT] |
2302 | cmp ecx, edx |
2304 | cmp ecx, edx |
2303 | ja noprocessterminate |
2305 | ja noprocessterminate |
2304 | mov eax, [TASK_COUNT] |
2306 | mov eax, [TASK_COUNT] |
2305 | shl ecx, 5 |
2307 | shl ecx, 5 |
2306 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2308 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2307 | add ecx, CURRENT_TASK+TASKDATA.state |
2309 | add ecx, CURRENT_TASK+TASKDATA.state |
2308 | cmp byte [ecx], 9 |
2310 | cmp byte [ecx], 9 |
2309 | jz noprocessterminate |
2311 | jz noprocessterminate |
2310 | push ecx edx |
2312 | push ecx edx |
2311 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2313 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2312 | call request_terminate |
2314 | call request_terminate |
2313 | pop edx ecx |
2315 | pop edx ecx |
2314 | test eax, eax |
2316 | test eax, eax |
2315 | jz noprocessterminate |
2317 | jz noprocessterminate |
2316 | ;-------------------------------------- |
2318 | ;-------------------------------------- |
2317 | ; terminate all network sockets it used |
2319 | ; terminate all network sockets it used |
2318 | pusha |
2320 | pusha |
2319 | mov eax, edx |
2321 | mov eax, edx |
2320 | call SOCKET_process_end |
2322 | call SOCKET_process_end |
2321 | popa |
2323 | popa |
2322 | ;-------------------------------------- |
2324 | ;-------------------------------------- |
2323 | cmp [_display.select_cursor], 0 |
2325 | cmp [_display.select_cursor], 0 |
2324 | je .restore_end |
2326 | je .restore_end |
2325 | ; restore default cursor before killing |
2327 | ; restore default cursor before killing |
2326 | pusha |
2328 | pusha |
2327 | mov ecx, [esp+32] |
2329 | mov ecx, [esp+32] |
2328 | shl ecx, 8 |
2330 | shl ecx, 8 |
2329 | add ecx, SLOT_BASE |
2331 | add ecx, SLOT_BASE |
2330 | mov eax, [def_cursor] |
2332 | mov eax, [def_cursor] |
2331 | cmp [ecx+APPDATA.cursor], eax |
2333 | cmp [ecx+APPDATA.cursor], eax |
2332 | je @f |
2334 | je @f |
2333 | call restore_default_cursor_before_killing |
2335 | call restore_default_cursor_before_killing |
2334 | @@: |
2336 | @@: |
2335 | popa |
2337 | popa |
2336 | .restore_end: |
2338 | .restore_end: |
2337 | ;-------------------------------------- |
2339 | ;-------------------------------------- |
2338 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2340 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2339 | mov [ecx], byte 3; clear possible i40's |
2341 | mov [ecx], byte 3; clear possible i40's |
2340 | call wakeup_osloop |
2342 | call wakeup_osloop |
2341 | ;call MEM_Heap_UnLock |
2343 | ;call MEM_Heap_UnLock |
2342 | 2344 | ||
2343 | cmp edx, [application_table_owner]; clear app table stat |
2345 | cmp edx, [application_table_owner]; clear app table stat |
2344 | jne noatsc |
2346 | jne noatsc |
2345 | call unlock_application_table |
2347 | call unlock_application_table |
2346 | noatsc: |
2348 | noatsc: |
2347 | noprocessterminate: |
2349 | noprocessterminate: |
2348 | add esp, 4 |
2350 | add esp, 4 |
2349 | ret |
2351 | ret |
2350 | ;------------------------------------------------------------------------------ |
2352 | ;------------------------------------------------------------------------------ |
2351 | sysfn_terminate2: |
2353 | sysfn_terminate2: |
2352 | ;lock application_table_status mutex |
2354 | ;lock application_table_status mutex |
2353 | .table_status: |
2355 | .table_status: |
2354 | call lock_application_table |
2356 | call lock_application_table |
2355 | mov eax, ecx |
2357 | mov eax, ecx |
2356 | call pid_to_slot |
2358 | call pid_to_slot |
2357 | test eax, eax |
2359 | test eax, eax |
2358 | jz .not_found |
2360 | jz .not_found |
2359 | mov ecx, eax |
2361 | mov ecx, eax |
2360 | cli |
2362 | cli |
2361 | call sysfn_terminate |
2363 | call sysfn_terminate |
2362 | call unlock_application_table |
2364 | call unlock_application_table |
2363 | sti |
2365 | sti |
2364 | and dword [esp+32], 0 |
2366 | and dword [esp+32], 0 |
2365 | ret |
2367 | ret |
2366 | .not_found: |
2368 | .not_found: |
2367 | call unlock_application_table |
2369 | call unlock_application_table |
2368 | or dword [esp+32], -1 |
2370 | or dword [esp+32], -1 |
2369 | ret |
2371 | ret |
2370 | ;------------------------------------------------------------------------------ |
2372 | ;------------------------------------------------------------------------------ |
2371 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2373 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2372 | cmp ecx, 2 |
2374 | cmp ecx, 2 |
2373 | jb .nowindowdeactivate |
2375 | jb .nowindowdeactivate |
2374 | cmp ecx, [TASK_COUNT] |
2376 | cmp ecx, [TASK_COUNT] |
2375 | ja .nowindowdeactivate |
2377 | ja .nowindowdeactivate |
2376 | 2378 | ||
2377 | movzx esi, word [WIN_STACK + ecx*2] |
2379 | movzx esi, word [WIN_STACK + ecx*2] |
2378 | cmp esi, 1 |
2380 | cmp esi, 1 |
2379 | je .nowindowdeactivate ; already deactive |
2381 | je .nowindowdeactivate ; already deactive |
2380 | 2382 | ||
2381 | mov edi, ecx |
2383 | mov edi, ecx |
2382 | shl edi, 5 |
2384 | shl edi, 5 |
2383 | add edi, window_data |
2385 | add edi, window_data |
2384 | movzx esi, word [WIN_STACK + ecx * 2] |
2386 | movzx esi, word [WIN_STACK + ecx * 2] |
2385 | lea esi, [WIN_POS + esi * 2] |
2387 | lea esi, [WIN_POS + esi * 2] |
2386 | call window._.window_deactivate |
2388 | call window._.window_deactivate |
2387 | 2389 | ||
2388 | call syscall_display_settings._.calculate_whole_screen |
2390 | call syscall_display_settings._.calculate_whole_screen |
2389 | call syscall_display_settings._.redraw_whole_screen |
2391 | call syscall_display_settings._.redraw_whole_screen |
2390 | .nowindowdeactivate: |
2392 | .nowindowdeactivate: |
2391 | ret |
2393 | ret |
2392 | ;------------------------------------------------------------------------------ |
2394 | ;------------------------------------------------------------------------------ |
2393 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2395 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2394 | cmp ecx, 2 |
2396 | cmp ecx, 2 |
2395 | jb .nowindowactivate |
2397 | jb .nowindowactivate |
2396 | cmp ecx, [TASK_COUNT] |
2398 | cmp ecx, [TASK_COUNT] |
2397 | ja .nowindowactivate |
2399 | ja .nowindowactivate |
2398 | ;------------------------------------- |
2400 | ;------------------------------------- |
2399 | @@: |
2401 | @@: |
2400 | ; If the window is captured and moved by the user, |
2402 | ; If the window is captured and moved by the user, |
2401 | ; then you can't change the position in window stack!!! |
2403 | ; then you can't change the position in window stack!!! |
2402 | mov al, [mouse.active_sys_window.action] |
2404 | mov al, [mouse.active_sys_window.action] |
2403 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2405 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2404 | test al, al |
2406 | test al, al |
2405 | jz @f |
2407 | jz @f |
2406 | call change_task |
2408 | call change_task |
2407 | jmp @b |
2409 | jmp @b |
2408 | @@: |
2410 | @@: |
2409 | ;------------------------------------- |
2411 | ;------------------------------------- |
2410 | mov [window_minimize], 2; restore window if minimized |
2412 | mov [window_minimize], 2; restore window if minimized |
2411 | call wakeup_osloop |
2413 | call wakeup_osloop |
2412 | 2414 | ||
2413 | movzx esi, word [WIN_STACK + ecx*2] |
2415 | movzx esi, word [WIN_STACK + ecx*2] |
2414 | cmp esi, [TASK_COUNT] |
2416 | cmp esi, [TASK_COUNT] |
2415 | je .nowindowactivate; already active |
2417 | je .nowindowactivate; already active |
2416 | 2418 | ||
2417 | mov edi, ecx |
2419 | mov edi, ecx |
2418 | shl edi, 5 |
2420 | shl edi, 5 |
2419 | add edi, window_data |
2421 | add edi, window_data |
2420 | movzx esi, word [WIN_STACK + ecx * 2] |
2422 | movzx esi, word [WIN_STACK + ecx * 2] |
2421 | lea esi, [WIN_POS + esi * 2] |
2423 | lea esi, [WIN_POS + esi * 2] |
2422 | call waredraw |
2424 | call waredraw |
2423 | .nowindowactivate: |
2425 | .nowindowactivate: |
2424 | ret |
2426 | ret |
2425 | ;------------------------------------------------------------------------------ |
2427 | ;------------------------------------------------------------------------------ |
2426 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2428 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2427 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2429 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2428 | mov [esp+32], eax |
2430 | mov [esp+32], eax |
2429 | ret |
2431 | ret |
2430 | ;------------------------------------------------------------------------------ |
2432 | ;------------------------------------------------------------------------------ |
2431 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2433 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2432 | mov eax, dword [cpu_freq] |
2434 | mov eax, dword [cpu_freq] |
2433 | mov [esp+32], eax |
2435 | mov [esp+32], eax |
2434 | ret |
2436 | ret |
2435 | ;------------------------------------------------------------------------------ |
2437 | ;------------------------------------------------------------------------------ |
2436 | get_cpu_freq: |
2438 | get_cpu_freq: |
2437 | mov eax, dword [cpu_freq] |
2439 | mov eax, dword [cpu_freq] |
2438 | mov edx, dword [cpu_freq+4] |
2440 | mov edx, dword [cpu_freq+4] |
2439 | ret |
2441 | ret |
2440 | ; SAVE ramdisk to /hd/1/menuet.img |
2442 | ; SAVE ramdisk to /hd/1/menuet.img |
2441 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2443 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2442 | include 'blkdev/rdsave.inc' |
2444 | include 'blkdev/rdsave.inc' |
2443 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2445 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2444 | ;------------------------------------------------------------------------------ |
2446 | ;------------------------------------------------------------------------------ |
2445 | align 4 |
2447 | align 4 |
2446 | sysfn_getactive: ; 18.7 = get active window |
2448 | sysfn_getactive: ; 18.7 = get active window |
2447 | mov eax, [TASK_COUNT] |
2449 | mov eax, [TASK_COUNT] |
2448 | movzx eax, word [WIN_POS + eax*2] |
2450 | movzx eax, word [WIN_POS + eax*2] |
2449 | mov [esp+32], eax |
2451 | mov [esp+32], eax |
2450 | ret |
2452 | ret |
2451 | ;------------------------------------------------------------------------------ |
2453 | ;------------------------------------------------------------------------------ |
2452 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2454 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2453 | ; cmp ecx,1 |
2455 | ; cmp ecx,1 |
2454 | dec ecx |
2456 | dec ecx |
2455 | jnz nogetsoundflag |
2457 | jnz nogetsoundflag |
2456 | movzx eax, byte [sound_flag]; get sound_flag |
2458 | movzx eax, byte [sound_flag]; get sound_flag |
2457 | mov [esp+32], eax |
2459 | mov [esp+32], eax |
2458 | ret |
2460 | ret |
2459 | nogetsoundflag: |
2461 | nogetsoundflag: |
2460 | ; cmp ecx,2 |
2462 | ; cmp ecx,2 |
2461 | dec ecx |
2463 | dec ecx |
2462 | jnz nosoundflag |
2464 | jnz nosoundflag |
2463 | xor byte [sound_flag], 1 |
2465 | xor byte [sound_flag], 1 |
2464 | nosoundflag: |
2466 | nosoundflag: |
2465 | ret |
2467 | ret |
2466 | ;------------------------------------------------------------------------------ |
2468 | ;------------------------------------------------------------------------------ |
2467 | sysfn_minimize: ; 18.10 = minimize window |
2469 | sysfn_minimize: ; 18.10 = minimize window |
2468 | mov [window_minimize], 1 |
2470 | mov [window_minimize], 1 |
2469 | call wakeup_osloop |
2471 | call wakeup_osloop |
2470 | ret |
2472 | ret |
2471 | ;------------------------------------------------------------------------------ |
2473 | ;------------------------------------------------------------------------------ |
2472 | align 4 |
2474 | align 4 |
2473 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2475 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2474 | ; cmp ecx,1 |
2476 | ; cmp ecx,1 |
2475 | dec ecx |
2477 | dec ecx |
2476 | jnz full_table |
2478 | jnz full_table |
2477 | small_table: |
2479 | small_table: |
2478 | call for_all_tables |
2480 | call for_all_tables |
2479 | mov ecx, 10 |
2481 | mov ecx, 10 |
2480 | cld |
2482 | cld |
2481 | rep movsb |
2483 | rep movsb |
2482 | ret |
2484 | ret |
2483 | for_all_tables: |
2485 | for_all_tables: |
2484 | mov edi, edx |
2486 | mov edi, edx |
2485 | mov esi, DRIVE_DATA |
2487 | mov esi, DRIVE_DATA |
2486 | ret |
2488 | ret |
2487 | full_table: |
2489 | full_table: |
2488 | ; cmp ecx,2 |
2490 | ; cmp ecx,2 |
2489 | dec ecx |
2491 | dec ecx |
2490 | jnz exit_for_anyone |
2492 | jnz exit_for_anyone |
2491 | call for_all_tables |
2493 | call for_all_tables |
2492 | mov ecx, DRIVE_DATA_SIZE/4 |
2494 | mov ecx, DRIVE_DATA_SIZE/4 |
2493 | cld |
2495 | cld |
2494 | rep movsd |
2496 | rep movsd |
2495 | ret |
2497 | ret |
2496 | ;------------------------------------------------------------------------------ |
2498 | ;------------------------------------------------------------------------------ |
2497 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2499 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2498 | and dword [esp+32], 0 |
2500 | and dword [esp+32], 0 |
2499 | ret |
2501 | ret |
2500 | ;------------------------------------------------------------------------------ |
2502 | ;------------------------------------------------------------------------------ |
2501 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2503 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2502 | mov edi, ecx |
2504 | mov edi, ecx |
2503 | mov esi, version_inf |
2505 | mov esi, version_inf |
2504 | mov ecx, version_end-version_inf |
2506 | mov ecx, version_end-version_inf |
2505 | rep movsb |
2507 | rep movsb |
2506 | ret |
2508 | ret |
2507 | ;------------------------------------------------------------------------------ |
2509 | ;------------------------------------------------------------------------------ |
2508 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2510 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2509 | ;wait retrace functions |
2511 | ;wait retrace functions |
2510 | sys_wait_retrace: |
2512 | sys_wait_retrace: |
2511 | mov edx, 0x3da |
2513 | mov edx, 0x3da |
2512 | WaitRetrace_loop: |
2514 | WaitRetrace_loop: |
2513 | in al, dx |
2515 | in al, dx |
2514 | test al, 1000b |
2516 | test al, 1000b |
2515 | jz WaitRetrace_loop |
2517 | jz WaitRetrace_loop |
2516 | and [esp+32], dword 0 |
2518 | and [esp+32], dword 0 |
2517 | ret |
2519 | ret |
2518 | ;------------------------------------------------------------------------------ |
2520 | ;------------------------------------------------------------------------------ |
2519 | align 4 |
2521 | align 4 |
2520 | sysfn_centermouse: ; 18.15 = mouse centered |
2522 | sysfn_centermouse: ; 18.15 = mouse centered |
2521 | ; removed here by |
2523 | ; removed here by |
2522 | ; call mouse_centered |
2524 | ; call mouse_centered |
2523 | ;* mouse centered - start code- Mario79 |
2525 | ;* mouse centered - start code- Mario79 |
2524 | ;mouse_centered: |
2526 | ;mouse_centered: |
2525 | ; push eax |
2527 | ; push eax |
2526 | mov eax, [Screen_Max_X] |
2528 | mov eax, [Screen_Max_X] |
2527 | shr eax, 1 |
2529 | shr eax, 1 |
2528 | mov [MOUSE_X], ax |
2530 | mov [MOUSE_X], ax |
2529 | mov eax, [Screen_Max_Y] |
2531 | mov eax, [Screen_Max_Y] |
2530 | shr eax, 1 |
2532 | shr eax, 1 |
2531 | mov [MOUSE_Y], ax |
2533 | mov [MOUSE_Y], ax |
2532 | call wakeup_osloop |
2534 | call wakeup_osloop |
2533 | ; ret |
2535 | ; ret |
2534 | ;* mouse centered - end code- Mario79 |
2536 | ;* mouse centered - end code- Mario79 |
2535 | xor eax, eax |
2537 | xor eax, eax |
2536 | and [esp+32], eax |
2538 | and [esp+32], eax |
2537 | ; pop eax |
2539 | ; pop eax |
2538 | ret |
2540 | ret |
2539 | ;------------------------------------------------------------------------------ |
2541 | ;------------------------------------------------------------------------------ |
2540 | align 4 |
2542 | align 4 |
2541 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2543 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2542 | test ecx, ecx; get mouse speed factor |
2544 | test ecx, ecx; get mouse speed factor |
2543 | jnz .set_mouse_acceleration |
2545 | jnz .set_mouse_acceleration |
2544 | xor eax, eax |
2546 | xor eax, eax |
2545 | mov ax, [mouse_speed_factor] |
2547 | mov ax, [mouse_speed_factor] |
2546 | mov [esp+32], eax |
2548 | mov [esp+32], eax |
2547 | ret |
2549 | ret |
2548 | .set_mouse_acceleration: |
2550 | .set_mouse_acceleration: |
2549 | ; cmp ecx,1 ; set mouse speed factor |
2551 | ; cmp ecx,1 ; set mouse speed factor |
2550 | dec ecx |
2552 | dec ecx |
2551 | jnz .get_mouse_delay |
2553 | jnz .get_mouse_delay |
2552 | mov [mouse_speed_factor], dx |
2554 | mov [mouse_speed_factor], dx |
2553 | ret |
2555 | ret |
2554 | .get_mouse_delay: |
2556 | .get_mouse_delay: |
2555 | ; cmp ecx,2 ; get mouse delay |
2557 | ; cmp ecx,2 ; get mouse delay |
2556 | dec ecx |
2558 | dec ecx |
2557 | jnz .set_mouse_delay |
2559 | jnz .set_mouse_delay |
2558 | mov eax, [mouse_delay] |
2560 | mov eax, [mouse_delay] |
2559 | mov [esp+32], eax |
2561 | mov [esp+32], eax |
2560 | ret |
2562 | ret |
2561 | .set_mouse_delay: |
2563 | .set_mouse_delay: |
2562 | ; cmp ecx,3 ; set mouse delay |
2564 | ; cmp ecx,3 ; set mouse delay |
2563 | dec ecx |
2565 | dec ecx |
2564 | jnz .set_pointer_position |
2566 | jnz .set_pointer_position |
2565 | mov [mouse_delay], edx |
2567 | mov [mouse_delay], edx |
2566 | ret |
2568 | ret |
2567 | .set_pointer_position: |
2569 | .set_pointer_position: |
2568 | ; cmp ecx,4 ; set mouse pointer position |
2570 | ; cmp ecx,4 ; set mouse pointer position |
2569 | dec ecx |
2571 | dec ecx |
2570 | jnz .set_mouse_button |
2572 | jnz .set_mouse_button |
2571 | cmp dx, word[Screen_Max_Y] |
2573 | cmp dx, word[Screen_Max_Y] |
2572 | ja .end |
2574 | ja .end |
2573 | rol edx, 16 |
2575 | rol edx, 16 |
2574 | cmp dx, word[Screen_Max_X] |
2576 | cmp dx, word[Screen_Max_X] |
2575 | ja .end |
2577 | ja .end |
2576 | mov [MOUSE_X], edx |
2578 | mov [MOUSE_X], edx |
2577 | mov [mouse_active], 1 |
2579 | mov [mouse_active], 1 |
2578 | call wakeup_osloop |
2580 | call wakeup_osloop |
2579 | ret |
2581 | ret |
2580 | .set_mouse_button: |
2582 | .set_mouse_button: |
2581 | ; cmp ecx,5 ; set mouse button features |
2583 | ; cmp ecx,5 ; set mouse button features |
2582 | dec ecx |
2584 | dec ecx |
2583 | jnz .end |
2585 | jnz .end |
2584 | mov [BTN_DOWN], dl |
2586 | mov [BTN_DOWN], dl |
2585 | mov [mouse_active], 1 |
2587 | mov [mouse_active], 1 |
2586 | call wakeup_osloop |
2588 | call wakeup_osloop |
2587 | .end: |
2589 | .end: |
2588 | ret |
2590 | ret |
2589 | ;------------------------------------------------------------------------------ |
2591 | ;------------------------------------------------------------------------------ |
2590 | sysfn_getfreemem: |
2592 | sysfn_getfreemem: |
2591 | mov eax, [pg_data.pages_free] |
2593 | mov eax, [pg_data.pages_free] |
2592 | shl eax, 2 |
2594 | shl eax, 2 |
2593 | mov [esp+32], eax |
2595 | mov [esp+32], eax |
2594 | ret |
2596 | ret |
2595 | ;------------------------------------------------------------------------------ |
2597 | ;------------------------------------------------------------------------------ |
2596 | sysfn_getallmem: |
2598 | sysfn_getallmem: |
2597 | mov eax, [MEM_AMOUNT] |
2599 | mov eax, [MEM_AMOUNT] |
2598 | shr eax, 10 |
2600 | shr eax, 10 |
2599 | mov [esp+32], eax |
2601 | mov [esp+32], eax |
2600 | ret |
2602 | ret |
2601 | ;------------------------------------------------------------------------------ |
2603 | ;------------------------------------------------------------------------------ |
2602 | sysfn_pid_to_slot: |
2604 | sysfn_pid_to_slot: |
2603 | mov eax, ecx |
2605 | mov eax, ecx |
2604 | call pid_to_slot |
2606 | call pid_to_slot |
2605 | mov [esp+32], eax |
2607 | mov [esp+32], eax |
2606 | ret |
2608 | ret |
2607 | ;------------------------------------------------------------------------------ |
2609 | ;------------------------------------------------------------------------------ |
2608 | sysfn_min_rest_window: |
2610 | sysfn_min_rest_window: |
2609 | pushad |
2611 | pushad |
2610 | mov eax, edx ; ebx - operating |
2612 | mov eax, edx ; ebx - operating |
2611 | shr ecx, 1 |
2613 | shr ecx, 1 |
2612 | jnc @f |
2614 | jnc @f |
2613 | call pid_to_slot |
2615 | call pid_to_slot |
2614 | @@: |
2616 | @@: |
2615 | or eax, eax ; eax - number of slot |
2617 | or eax, eax ; eax - number of slot |
2616 | jz .error |
2618 | jz .error |
2617 | cmp eax, 255 ; varify maximal slot number |
2619 | cmp eax, 255 ; varify maximal slot number |
2618 | ja .error |
2620 | ja .error |
2619 | movzx eax, word [WIN_STACK + eax*2] |
2621 | movzx eax, word [WIN_STACK + eax*2] |
2620 | shr ecx, 1 |
2622 | shr ecx, 1 |
2621 | jc .restore |
2623 | jc .restore |
2622 | ; .minimize: |
2624 | ; .minimize: |
2623 | call minimize_window |
2625 | call minimize_window |
2624 | jmp .exit |
2626 | jmp .exit |
2625 | .restore: |
2627 | .restore: |
2626 | call restore_minimized_window |
2628 | call restore_minimized_window |
2627 | .exit: |
2629 | .exit: |
2628 | popad |
2630 | popad |
2629 | xor eax, eax |
2631 | xor eax, eax |
2630 | mov [esp+32], eax |
2632 | mov [esp+32], eax |
2631 | ret |
2633 | ret |
2632 | .error: |
2634 | .error: |
2633 | popad |
2635 | popad |
2634 | xor eax, eax |
2636 | xor eax, eax |
2635 | dec eax |
2637 | dec eax |
2636 | mov [esp+32], eax |
2638 | mov [esp+32], eax |
2637 | ret |
2639 | ret |
2638 | ;------------------------------------------------------------------------------ |
2640 | ;------------------------------------------------------------------------------ |
2639 | sysfn_min_windows: |
2641 | sysfn_min_windows: |
2640 | call minimize_all_window |
2642 | call minimize_all_window |
2641 | mov [esp+32], eax |
2643 | mov [esp+32], eax |
2642 | call change_task |
2644 | call change_task |
2643 | ret |
2645 | ret |
2644 | ;------------------------------------------------------------------------------ |
2646 | ;------------------------------------------------------------------------------ |
2645 | sysfn_set_screen_sizes: |
2647 | sysfn_set_screen_sizes: |
2646 | cmp [SCR_MODE], word 0x13 |
2648 | cmp [SCR_MODE], word 0x13 |
2647 | jbe .exit |
2649 | jbe .exit |
2648 | 2650 | ||
2649 | cmp [_display.select_cursor], select_cursor |
2651 | cmp [_display.select_cursor], select_cursor |
2650 | jne .exit |
2652 | jne .exit |
2651 | 2653 | ||
2652 | cmp ecx, [display_width_standard] |
2654 | cmp ecx, [display_width_standard] |
2653 | ja .exit |
2655 | ja .exit |
2654 | 2656 | ||
2655 | cmp edx, [display_height_standard] |
2657 | cmp edx, [display_height_standard] |
2656 | ja .exit |
2658 | ja .exit |
2657 | 2659 | ||
2658 | pushfd |
2660 | pushfd |
2659 | cli |
2661 | cli |
2660 | mov eax, ecx |
2662 | mov eax, ecx |
2661 | mov ecx, [_display.pitch] |
2663 | mov ecx, [_display.pitch] |
2662 | mov [_display.width], eax |
2664 | mov [_display.width], eax |
2663 | dec eax |
2665 | dec eax |
2664 | mov [_display.height], edx |
2666 | mov [_display.height], edx |
2665 | dec edx |
2667 | dec edx |
2666 | ; eax - new Screen_Max_X |
2668 | ; eax - new Screen_Max_X |
2667 | ; edx - new Screen_Max_Y |
2669 | ; edx - new Screen_Max_Y |
2668 | mov [do_not_touch_winmap], 1 |
2670 | mov [do_not_touch_winmap], 1 |
2669 | call set_screen |
2671 | call set_screen |
2670 | mov [do_not_touch_winmap], 0 |
2672 | mov [do_not_touch_winmap], 0 |
2671 | popfd |
2673 | popfd |
2672 | call change_task |
2674 | call change_task |
2673 | .exit: |
2675 | .exit: |
2674 | ret |
2676 | ret |
2675 | ;------------------------------------------------------------------------------ |
2677 | ;------------------------------------------------------------------------------ |
2676 | uglobal |
2678 | uglobal |
2677 | screen_workarea RECT |
2679 | screen_workarea RECT |
2678 | display_width_standard dd 0 |
2680 | display_width_standard dd 0 |
2679 | display_height_standard dd 0 |
2681 | display_height_standard dd 0 |
2680 | do_not_touch_winmap db 0 |
2682 | do_not_touch_winmap db 0 |
2681 | window_minimize db 0 |
2683 | window_minimize db 0 |
2682 | sound_flag db 0 |
2684 | sound_flag db 0 |
2683 | 2685 | ||
2684 | endg |
2686 | endg |
2685 | 2687 | ||
2686 | UID_NONE=0 |
2688 | UID_NONE=0 |
2687 | UID_MENUETOS=1 ;official |
2689 | UID_MENUETOS=1 ;official |
2688 | UID_KOLIBRI=2 ;russian |
2690 | UID_KOLIBRI=2 ;russian |
2689 | 2691 | ||
2690 | iglobal |
2692 | iglobal |
2691 | version_inf: |
2693 | version_inf: |
2692 | db 0,7,7,0 ; version 0.7.7.0 |
2694 | db 0,7,7,0 ; version 0.7.7.0 |
2693 | db 0 |
2695 | db 0 |
2694 | .rev dd __REV__ |
2696 | .rev dd __REV__ |
2695 | version_end: |
2697 | version_end: |
2696 | endg |
2698 | endg |
2697 | ;------------------------------------------------------------------------------ |
2699 | ;------------------------------------------------------------------------------ |
2698 | align 4 |
2700 | align 4 |
2699 | sys_cachetodiskette: |
2701 | sys_cachetodiskette: |
2700 | cmp ebx, 1 |
2702 | cmp ebx, 1 |
2701 | jb .no_floppy_save |
2703 | jb .no_floppy_save |
2702 | cmp ebx, 2 |
2704 | cmp ebx, 2 |
2703 | ja .no_floppy_save |
2705 | ja .no_floppy_save |
2704 | call save_image |
2706 | call save_image |
2705 | mov [esp + 32], eax |
2707 | mov [esp + 32], eax |
2706 | ret |
2708 | ret |
2707 | .no_floppy_save: |
2709 | .no_floppy_save: |
2708 | mov [esp + 32], dword 1 |
2710 | mov [esp + 32], dword 1 |
2709 | ret |
2711 | ret |
2710 | ;------------------------------------------------------------------------------ |
2712 | ;------------------------------------------------------------------------------ |
2711 | uglobal |
2713 | uglobal |
2712 | ; bgrchanged dd 0x0 |
2714 | ; bgrchanged dd 0x0 |
2713 | align 4 |
2715 | align 4 |
2714 | bgrlockpid dd 0 |
2716 | bgrlockpid dd 0 |
2715 | bgrlock db 0 |
2717 | bgrlock db 0 |
2716 | endg |
2718 | endg |
2717 | ;------------------------------------------------------------------------------ |
2719 | ;------------------------------------------------------------------------------ |
2718 | align 4 |
2720 | align 4 |
2719 | sys_background: |
2721 | sys_background: |
2720 | cmp ebx, 1 ; BACKGROUND SIZE |
2722 | cmp ebx, 1 ; BACKGROUND SIZE |
2721 | jnz nosb1 |
2723 | jnz nosb1 |
2722 | test ecx, ecx |
2724 | test ecx, ecx |
2723 | jz sbgrr |
2725 | jz sbgrr |
2724 | 2726 | ||
2725 | test edx, edx |
2727 | test edx, edx |
2726 | jz sbgrr |
2728 | jz sbgrr |
2727 | ;-------------------------------------- |
2729 | ;-------------------------------------- |
2728 | align 4 |
2730 | align 4 |
2729 | @@: |
2731 | @@: |
2730 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2732 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2731 | bts dword [bgrlock], 0 |
2733 | bts dword [bgrlock], 0 |
2732 | jnc @f |
2734 | jnc @f |
2733 | call change_task |
2735 | call change_task |
2734 | jmp @b |
2736 | jmp @b |
2735 | ;-------------------------------------- |
2737 | ;-------------------------------------- |
2736 | align 4 |
2738 | align 4 |
2737 | @@: |
2739 | @@: |
2738 | mov [BgrDataWidth], ecx |
2740 | mov [BgrDataWidth], ecx |
2739 | mov [BgrDataHeight], edx |
2741 | mov [BgrDataHeight], edx |
2740 | ; mov [bgrchanged],1 |
2742 | ; mov [bgrchanged],1 |
2741 | 2743 | ||
2742 | pushad |
2744 | pushad |
2743 | ; return memory for old background |
2745 | ; return memory for old background |
2744 | mov eax, [img_background] |
2746 | mov eax, [img_background] |
2745 | cmp eax, static_background_data |
2747 | cmp eax, static_background_data |
2746 | jz @f |
2748 | jz @f |
2747 | stdcall kernel_free, eax |
2749 | stdcall kernel_free, eax |
2748 | ;-------------------------------------- |
2750 | ;-------------------------------------- |
2749 | align 4 |
2751 | align 4 |
2750 | @@: |
2752 | @@: |
2751 | ; calculate RAW size |
2753 | ; calculate RAW size |
2752 | xor eax, eax |
2754 | xor eax, eax |
2753 | inc eax |
2755 | inc eax |
2754 | cmp [BgrDataWidth], eax |
2756 | cmp [BgrDataWidth], eax |
2755 | jae @f |
2757 | jae @f |
2756 | mov [BgrDataWidth], eax |
2758 | mov [BgrDataWidth], eax |
2757 | ;-------------------------------------- |
2759 | ;-------------------------------------- |
2758 | align 4 |
2760 | align 4 |
2759 | @@: |
2761 | @@: |
2760 | cmp [BgrDataHeight], eax |
2762 | cmp [BgrDataHeight], eax |
2761 | jae @f |
2763 | jae @f |
2762 | mov [BgrDataHeight], eax |
2764 | mov [BgrDataHeight], eax |
2763 | ;-------------------------------------- |
2765 | ;-------------------------------------- |
2764 | align 4 |
2766 | align 4 |
2765 | @@: |
2767 | @@: |
2766 | mov eax, [BgrDataWidth] |
2768 | mov eax, [BgrDataWidth] |
2767 | imul eax, [BgrDataHeight] |
2769 | imul eax, [BgrDataHeight] |
2768 | lea eax, [eax*3] |
2770 | lea eax, [eax*3] |
2769 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2771 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2770 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2772 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2771 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2773 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2772 | shr eax, 12 |
2774 | shr eax, 12 |
2773 | inc eax |
2775 | inc eax |
2774 | shl eax, 12 |
2776 | shl eax, 12 |
2775 | mov [mem_BACKGROUND], eax |
2777 | mov [mem_BACKGROUND], eax |
2776 | ; get memory for new background |
2778 | ; get memory for new background |
2777 | stdcall kernel_alloc, eax |
2779 | stdcall kernel_alloc, eax |
2778 | test eax, eax |
2780 | test eax, eax |
2779 | jz .memfailed |
2781 | jz .memfailed |
2780 | mov [img_background], eax |
2782 | mov [img_background], eax |
2781 | jmp .exit |
2783 | jmp .exit |
2782 | ;-------------------------------------- |
2784 | ;-------------------------------------- |
2783 | align 4 |
2785 | align 4 |
2784 | .memfailed: |
2786 | .memfailed: |
2785 | ; revert to static monotone data |
2787 | ; revert to static monotone data |
2786 | mov [img_background], static_background_data |
2788 | mov [img_background], static_background_data |
2787 | xor eax, eax |
2789 | xor eax, eax |
2788 | inc eax |
2790 | inc eax |
2789 | mov [BgrDataWidth], eax |
2791 | mov [BgrDataWidth], eax |
2790 | mov [BgrDataHeight], eax |
2792 | mov [BgrDataHeight], eax |
2791 | mov [mem_BACKGROUND], 4 |
2793 | mov [mem_BACKGROUND], 4 |
2792 | ;-------------------------------------- |
2794 | ;-------------------------------------- |
2793 | align 4 |
2795 | align 4 |
2794 | .exit: |
2796 | .exit: |
2795 | popad |
2797 | popad |
2796 | mov [bgrlock], 0 |
2798 | mov [bgrlock], 0 |
2797 | ;-------------------------------------- |
2799 | ;-------------------------------------- |
2798 | align 4 |
2800 | align 4 |
2799 | sbgrr: |
2801 | sbgrr: |
2800 | ret |
2802 | ret |
2801 | ;------------------------------------------------------------------------------ |
2803 | ;------------------------------------------------------------------------------ |
2802 | align 4 |
2804 | align 4 |
2803 | nosb1: |
2805 | nosb1: |
2804 | cmp ebx, 2 ; SET PIXEL |
2806 | cmp ebx, 2 ; SET PIXEL |
2805 | jnz nosb2 |
2807 | jnz nosb2 |
2806 | 2808 | ||
2807 | mov eax, [img_background] |
2809 | mov eax, [img_background] |
2808 | test ecx, ecx |
2810 | test ecx, ecx |
2809 | jz @f |
2811 | jz @f |
2810 | cmp eax, static_background_data |
2812 | cmp eax, static_background_data |
2811 | jz .ret |
2813 | jz .ret |
2812 | ;-------------------------------------- |
2814 | ;-------------------------------------- |
2813 | align 4 |
2815 | align 4 |
2814 | @@: |
2816 | @@: |
2815 | mov ebx, [mem_BACKGROUND] |
2817 | mov ebx, [mem_BACKGROUND] |
2816 | add ebx, 4095 |
2818 | add ebx, 4095 |
2817 | and ebx, -4096 |
2819 | and ebx, -4096 |
2818 | sub ebx, 4 |
2820 | sub ebx, 4 |
2819 | cmp ecx, ebx |
2821 | cmp ecx, ebx |
2820 | ja .ret |
2822 | ja .ret |
2821 | 2823 | ||
2822 | mov ebx, [eax+ecx] |
2824 | mov ebx, [eax+ecx] |
2823 | and ebx, 0xFF000000;255*256*256*256 |
2825 | and ebx, 0xFF000000;255*256*256*256 |
2824 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2826 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2825 | add edx, ebx |
2827 | add edx, ebx |
2826 | mov [eax+ecx], edx |
2828 | mov [eax+ecx], edx |
2827 | ;-------------------------------------- |
2829 | ;-------------------------------------- |
2828 | align 4 |
2830 | align 4 |
2829 | .ret: |
2831 | .ret: |
2830 | ret |
2832 | ret |
2831 | ;------------------------------------------------------------------------------ |
2833 | ;------------------------------------------------------------------------------ |
2832 | align 4 |
2834 | align 4 |
2833 | nosb2: |
2835 | nosb2: |
2834 | cmp ebx, 3 ; DRAW BACKGROUND |
2836 | cmp ebx, 3 ; DRAW BACKGROUND |
2835 | jnz nosb3 |
2837 | jnz nosb3 |
2836 | ;-------------------------------------- |
2838 | ;-------------------------------------- |
2837 | align 4 |
2839 | align 4 |
2838 | draw_background_temp: |
2840 | draw_background_temp: |
2839 | mov [background_defined], 1 |
2841 | mov [background_defined], 1 |
2840 | call force_redraw_background |
2842 | call force_redraw_background |
2841 | ;-------------------------------------- |
2843 | ;-------------------------------------- |
2842 | align 4 |
2844 | align 4 |
2843 | nosb31: |
2845 | nosb31: |
2844 | ret |
2846 | ret |
2845 | ;------------------------------------------------------------------------------ |
2847 | ;------------------------------------------------------------------------------ |
2846 | align 4 |
2848 | align 4 |
2847 | nosb3: |
2849 | nosb3: |
2848 | cmp ebx, 4 ; TILED / STRETCHED |
2850 | cmp ebx, 4 ; TILED / STRETCHED |
2849 | jnz nosb4 |
2851 | jnz nosb4 |
2850 | cmp ecx, [BgrDrawMode] |
2852 | cmp ecx, [BgrDrawMode] |
2851 | je nosb41 |
2853 | je nosb41 |
2852 | mov [BgrDrawMode], ecx |
2854 | mov [BgrDrawMode], ecx |
2853 | ;-------------------------------------- |
2855 | ;-------------------------------------- |
2854 | align 4 |
2856 | align 4 |
2855 | nosb41: |
2857 | nosb41: |
2856 | ret |
2858 | ret |
2857 | ;------------------------------------------------------------------------------ |
2859 | ;------------------------------------------------------------------------------ |
2858 | align 4 |
2860 | align 4 |
2859 | nosb4: |
2861 | nosb4: |
2860 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2862 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2861 | jnz nosb5 |
2863 | jnz nosb5 |
2862 | cmp [img_background], static_background_data |
2864 | cmp [img_background], static_background_data |
2863 | jnz @f |
2865 | jnz @f |
2864 | test edx, edx |
2866 | test edx, edx |
2865 | jnz .fin |
2867 | jnz .fin |
2866 | cmp esi, 4 |
2868 | cmp esi, 4 |
2867 | ja .fin |
2869 | ja .fin |
2868 | ;-------------------------------------- |
2870 | ;-------------------------------------- |
2869 | align 4 |
2871 | align 4 |
2870 | @@: |
2872 | @@: |
2871 | ; bughere |
2873 | ; bughere |
2872 | mov eax, ecx |
2874 | mov eax, ecx |
2873 | mov ebx, edx |
2875 | mov ebx, edx |
2874 | add ebx, [img_background];IMG_BACKGROUND |
2876 | add ebx, [img_background];IMG_BACKGROUND |
2875 | mov ecx, esi |
2877 | mov ecx, esi |
2876 | call memmove |
2878 | call memmove |
2877 | ;-------------------------------------- |
2879 | ;-------------------------------------- |
2878 | align 4 |
2880 | align 4 |
2879 | .fin: |
2881 | .fin: |
2880 | ret |
2882 | ret |
2881 | ;------------------------------------------------------------------------------ |
2883 | ;------------------------------------------------------------------------------ |
2882 | align 4 |
2884 | align 4 |
2883 | nosb5: |
2885 | nosb5: |
2884 | cmp ebx, 6 |
2886 | cmp ebx, 6 |
2885 | jnz nosb6 |
2887 | jnz nosb6 |
2886 | ;-------------------------------------- |
2888 | ;-------------------------------------- |
2887 | align 4 |
2889 | align 4 |
2888 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2890 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2889 | @@: |
2891 | @@: |
2890 | bts dword [bgrlock], 0 |
2892 | bts dword [bgrlock], 0 |
2891 | jnc @f |
2893 | jnc @f |
2892 | call change_task |
2894 | call change_task |
2893 | jmp @b |
2895 | jmp @b |
2894 | ;-------------------------------------- |
2896 | ;-------------------------------------- |
2895 | align 4 |
2897 | align 4 |
2896 | @@: |
2898 | @@: |
2897 | mov eax, [CURRENT_TASK] |
2899 | mov eax, [CURRENT_TASK] |
2898 | mov [bgrlockpid], eax |
2900 | mov [bgrlockpid], eax |
2899 | cmp [img_background], static_background_data |
2901 | cmp [img_background], static_background_data |
2900 | jz .nomem |
2902 | jz .nomem |
2901 | stdcall user_alloc, [mem_BACKGROUND] |
2903 | stdcall user_alloc, [mem_BACKGROUND] |
2902 | mov [esp+32], eax |
2904 | mov [esp+32], eax |
2903 | test eax, eax |
2905 | test eax, eax |
2904 | jz .nomem |
2906 | jz .nomem |
2905 | mov ebx, eax |
2907 | mov ebx, eax |
2906 | shr ebx, 12 |
2908 | shr ebx, 12 |
2907 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2909 | or dword [page_tabs+(ebx-1)*4], DONT_FREE_BLOCK |
2908 | mov esi, [img_background] |
2910 | mov esi, [img_background] |
2909 | shr esi, 12 |
2911 | shr esi, 12 |
2910 | mov ecx, [mem_BACKGROUND] |
2912 | mov ecx, [mem_BACKGROUND] |
2911 | add ecx, 0xFFF |
2913 | add ecx, 0xFFF |
2912 | shr ecx, 12 |
2914 | shr ecx, 12 |
2913 | ;-------------------------------------- |
2915 | ;-------------------------------------- |
2914 | align 4 |
2916 | align 4 |
2915 | .z: |
2917 | .z: |
2916 | mov eax, [page_tabs+ebx*4] |
2918 | mov eax, [page_tabs+ebx*4] |
2917 | test al, 1 |
2919 | test al, 1 |
2918 | jz @f |
2920 | jz @f |
2919 | call free_page |
2921 | call free_page |
2920 | ;-------------------------------------- |
2922 | ;-------------------------------------- |
2921 | align 4 |
2923 | align 4 |
2922 | @@: |
2924 | @@: |
2923 | mov eax, [page_tabs+esi*4] |
2925 | mov eax, [page_tabs+esi*4] |
2924 | or al, PG_UW |
2926 | or al, PG_UW |
2925 | mov [page_tabs+ebx*4], eax |
2927 | mov [page_tabs+ebx*4], eax |
2926 | mov eax, ebx |
2928 | mov eax, ebx |
2927 | shl eax, 12 |
2929 | shl eax, 12 |
2928 | invlpg [eax] |
2930 | invlpg [eax] |
2929 | inc ebx |
2931 | inc ebx |
2930 | inc esi |
2932 | inc esi |
2931 | loop .z |
2933 | loop .z |
2932 | ret |
2934 | ret |
2933 | ;-------------------------------------- |
2935 | ;-------------------------------------- |
2934 | align 4 |
2936 | align 4 |
2935 | .nomem: |
2937 | .nomem: |
2936 | and [bgrlockpid], 0 |
2938 | and [bgrlockpid], 0 |
2937 | mov [bgrlock], 0 |
2939 | mov [bgrlock], 0 |
2938 | ;------------------------------------------------------------------------------ |
2940 | ;------------------------------------------------------------------------------ |
2939 | align 4 |
2941 | align 4 |
2940 | nosb6: |
2942 | nosb6: |
2941 | cmp ebx, 7 |
2943 | cmp ebx, 7 |
2942 | jnz nosb7 |
2944 | jnz nosb7 |
2943 | cmp [bgrlock], 0 |
2945 | cmp [bgrlock], 0 |
2944 | jz .err |
2946 | jz .err |
2945 | mov eax, [CURRENT_TASK] |
2947 | mov eax, [CURRENT_TASK] |
2946 | cmp [bgrlockpid], eax |
2948 | cmp [bgrlockpid], eax |
2947 | jnz .err |
2949 | jnz .err |
2948 | mov eax, ecx |
2950 | mov eax, ecx |
2949 | mov ebx, ecx |
2951 | mov ebx, ecx |
2950 | shr eax, 12 |
2952 | shr eax, 12 |
2951 | mov ecx, [page_tabs+(eax-1)*4] |
2953 | mov ecx, [page_tabs+(eax-1)*4] |
2952 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2954 | test cl, USED_BLOCK+DONT_FREE_BLOCK |
2953 | jz .err |
2955 | jz .err |
2954 | jnp .err |
2956 | jnp .err |
2955 | push eax |
2957 | push eax |
2956 | shr ecx, 12 |
2958 | shr ecx, 12 |
2957 | dec ecx |
2959 | dec ecx |
2958 | ;-------------------------------------- |
2960 | ;-------------------------------------- |
2959 | align 4 |
2961 | align 4 |
2960 | @@: |
2962 | @@: |
2961 | and dword [page_tabs+eax*4], 0 |
2963 | and dword [page_tabs+eax*4], 0 |
2962 | mov edx, eax |
2964 | mov edx, eax |
2963 | shl edx, 12 |
2965 | shl edx, 12 |
2964 | push eax |
2966 | push eax |
2965 | invlpg [edx] |
2967 | invlpg [edx] |
2966 | pop eax |
2968 | pop eax |
2967 | inc eax |
2969 | inc eax |
2968 | loop @b |
2970 | loop @b |
2969 | pop eax |
2971 | pop eax |
2970 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2972 | and dword [page_tabs+(eax-1)*4], not DONT_FREE_BLOCK |
2971 | stdcall user_free, ebx |
2973 | stdcall user_free, ebx |
2972 | mov [esp+32], eax |
2974 | mov [esp+32], eax |
2973 | and [bgrlockpid], 0 |
2975 | and [bgrlockpid], 0 |
2974 | mov [bgrlock], 0 |
2976 | mov [bgrlock], 0 |
2975 | ret |
2977 | ret |
2976 | ;-------------------------------------- |
2978 | ;-------------------------------------- |
2977 | align 4 |
2979 | align 4 |
2978 | .err: |
2980 | .err: |
2979 | and dword [esp+32], 0 |
2981 | and dword [esp+32], 0 |
2980 | ret |
2982 | ret |
2981 | ;------------------------------------------------------------------------------ |
2983 | ;------------------------------------------------------------------------------ |
2982 | align 4 |
2984 | align 4 |
2983 | nosb7: |
2985 | nosb7: |
2984 | cmp ebx, 8 |
2986 | cmp ebx, 8 |
2985 | jnz nosb8 |
2987 | jnz nosb8 |
2986 | 2988 | ||
2987 | mov ecx, [current_slot] |
2989 | mov ecx, [current_slot] |
2988 | xor eax, eax |
2990 | xor eax, eax |
2989 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2991 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2990 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2992 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2991 | xor eax, eax |
2993 | xor eax, eax |
2992 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2994 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2993 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2995 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2994 | ret |
2996 | ret |
2995 | ;------------------------------------------------------------------------------ |
2997 | ;------------------------------------------------------------------------------ |
2996 | align 4 |
2998 | align 4 |
2997 | nosb8: |
2999 | nosb8: |
2998 | cmp ebx, 9 |
3000 | cmp ebx, 9 |
2999 | jnz nosb9 |
3001 | jnz nosb9 |
3000 | ; ecx = [left]*65536 + [right] |
3002 | ; ecx = [left]*65536 + [right] |
3001 | ; edx = [top]*65536 + [bottom] |
3003 | ; edx = [top]*65536 + [bottom] |
3002 | mov eax, [Screen_Max_X] |
3004 | mov eax, [Screen_Max_X] |
3003 | mov ebx, [Screen_Max_Y] |
3005 | mov ebx, [Screen_Max_Y] |
3004 | ; check [right] |
3006 | ; check [right] |
3005 | cmp cx, ax |
3007 | cmp cx, ax |
3006 | ja .exit |
3008 | ja .exit |
3007 | ; check [left] |
3009 | ; check [left] |
3008 | ror ecx, 16 |
3010 | ror ecx, 16 |
3009 | cmp cx, ax |
3011 | cmp cx, ax |
3010 | ja .exit |
3012 | ja .exit |
3011 | ; check [bottom] |
3013 | ; check [bottom] |
3012 | cmp dx, bx |
3014 | cmp dx, bx |
3013 | ja .exit |
3015 | ja .exit |
3014 | ; check [top] |
3016 | ; check [top] |
3015 | ror edx, 16 |
3017 | ror edx, 16 |
3016 | cmp dx, bx |
3018 | cmp dx, bx |
3017 | ja .exit |
3019 | ja .exit |
3018 | 3020 | ||
3019 | movzx eax, cx ; [left] |
3021 | movzx eax, cx ; [left] |
3020 | movzx ebx, dx ; [top] |
3022 | movzx ebx, dx ; [top] |
3021 | 3023 | ||
3022 | shr ecx, 16 ; [right] |
3024 | shr ecx, 16 ; [right] |
3023 | shr edx, 16 ; [bottom] |
3025 | shr edx, 16 ; [bottom] |
3024 | 3026 | ||
3025 | mov [background_defined], 1 |
3027 | mov [background_defined], 1 |
3026 | 3028 | ||
3027 | mov [draw_data+32 + RECT.left], eax |
3029 | mov [draw_data+32 + RECT.left], eax |
3028 | mov [draw_data+32 + RECT.top], ebx |
3030 | mov [draw_data+32 + RECT.top], ebx |
3029 | 3031 | ||
3030 | mov [draw_data+32 + RECT.right], ecx |
3032 | mov [draw_data+32 + RECT.right], ecx |
3031 | mov [draw_data+32 + RECT.bottom], edx |
3033 | mov [draw_data+32 + RECT.bottom], edx |
3032 | 3034 | ||
3033 | inc byte[REDRAW_BACKGROUND] |
3035 | inc byte[REDRAW_BACKGROUND] |
3034 | call wakeup_osloop |
3036 | call wakeup_osloop |
3035 | ;-------------------------------------- |
3037 | ;-------------------------------------- |
3036 | align 4 |
3038 | align 4 |
3037 | .exit: |
3039 | .exit: |
3038 | ret |
3040 | ret |
3039 | ;------------------------------------------------------------------------------ |
3041 | ;------------------------------------------------------------------------------ |
3040 | align 4 |
3042 | align 4 |
3041 | nosb9: |
3043 | nosb9: |
3042 | ret |
3044 | ret |
3043 | ;------------------------------------------------------------------------------ |
3045 | ;------------------------------------------------------------------------------ |
3044 | align 4 |
3046 | align 4 |
3045 | uglobal |
3047 | uglobal |
3046 | BG_Rect_X_left_right dd 0x0 |
3048 | BG_Rect_X_left_right dd 0x0 |
3047 | BG_Rect_Y_top_bottom dd 0x0 |
3049 | BG_Rect_Y_top_bottom dd 0x0 |
3048 | endg |
3050 | endg |
3049 | ;------------------------------------------------------------------------------ |
3051 | ;------------------------------------------------------------------------------ |
3050 | align 4 |
3052 | align 4 |
3051 | force_redraw_background: |
3053 | force_redraw_background: |
3052 | and [draw_data+32 + RECT.left], 0 |
3054 | and [draw_data+32 + RECT.left], 0 |
3053 | and [draw_data+32 + RECT.top], 0 |
3055 | and [draw_data+32 + RECT.top], 0 |
3054 | push eax ebx |
3056 | push eax ebx |
3055 | mov eax, [Screen_Max_X] |
3057 | mov eax, [Screen_Max_X] |
3056 | mov ebx, [Screen_Max_Y] |
3058 | mov ebx, [Screen_Max_Y] |
3057 | mov [draw_data+32 + RECT.right], eax |
3059 | mov [draw_data+32 + RECT.right], eax |
3058 | mov [draw_data+32 + RECT.bottom], ebx |
3060 | mov [draw_data+32 + RECT.bottom], ebx |
3059 | pop ebx eax |
3061 | pop ebx eax |
3060 | inc byte[REDRAW_BACKGROUND] |
3062 | inc byte[REDRAW_BACKGROUND] |
3061 | call wakeup_osloop |
3063 | call wakeup_osloop |
3062 | ret |
3064 | ret |
3063 | ;------------------------------------------------------------------------------ |
3065 | ;------------------------------------------------------------------------------ |
3064 | align 4 |
3066 | align 4 |
3065 | sys_getbackground: |
3067 | sys_getbackground: |
3066 | ; cmp eax,1 ; SIZE |
3068 | ; cmp eax,1 ; SIZE |
3067 | dec ebx |
3069 | dec ebx |
3068 | jnz nogb1 |
3070 | jnz nogb1 |
3069 | mov eax, [BgrDataWidth] |
3071 | mov eax, [BgrDataWidth] |
3070 | shl eax, 16 |
3072 | shl eax, 16 |
3071 | mov ax, word [BgrDataHeight] |
3073 | mov ax, word [BgrDataHeight] |
3072 | mov [esp+32], eax |
3074 | mov [esp+32], eax |
3073 | ret |
3075 | ret |
3074 | ;------------------------------------------------------------------------------ |
3076 | ;------------------------------------------------------------------------------ |
3075 | align 4 |
3077 | align 4 |
3076 | nogb1: |
3078 | nogb1: |
3077 | ; cmp eax,2 ; PIXEL |
3079 | ; cmp eax,2 ; PIXEL |
3078 | dec ebx |
3080 | dec ebx |
3079 | jnz nogb2 |
3081 | jnz nogb2 |
3080 | 3082 | ||
3081 | mov eax, [img_background] |
3083 | mov eax, [img_background] |
3082 | test ecx, ecx |
3084 | test ecx, ecx |
3083 | jz @f |
3085 | jz @f |
3084 | cmp eax, static_background_data |
3086 | cmp eax, static_background_data |
3085 | jz .ret |
3087 | jz .ret |
3086 | ;-------------------------------------- |
3088 | ;-------------------------------------- |
3087 | align 4 |
3089 | align 4 |
3088 | @@: |
3090 | @@: |
3089 | mov ebx, [mem_BACKGROUND] |
3091 | mov ebx, [mem_BACKGROUND] |
3090 | add ebx, 4095 |
3092 | add ebx, 4095 |
3091 | and ebx, -4096 |
3093 | and ebx, -4096 |
3092 | sub ebx, 4 |
3094 | sub ebx, 4 |
3093 | cmp ecx, ebx |
3095 | cmp ecx, ebx |
3094 | ja .ret |
3096 | ja .ret |
3095 | 3097 | ||
3096 | mov eax, [ecx+eax] |
3098 | mov eax, [ecx+eax] |
3097 | 3099 | ||
3098 | and eax, 0xFFFFFF |
3100 | and eax, 0xFFFFFF |
3099 | mov [esp+32], eax |
3101 | mov [esp+32], eax |
3100 | ;-------------------------------------- |
3102 | ;-------------------------------------- |
3101 | align 4 |
3103 | align 4 |
3102 | .ret: |
3104 | .ret: |
3103 | ret |
3105 | ret |
3104 | ;------------------------------------------------------------------------------ |
3106 | ;------------------------------------------------------------------------------ |
3105 | align 4 |
3107 | align 4 |
3106 | nogb2: |
3108 | nogb2: |
3107 | 3109 | ||
3108 | ; cmp eax,4 ; TILED / STRETCHED |
3110 | ; cmp eax,4 ; TILED / STRETCHED |
3109 | dec ebx |
3111 | dec ebx |
3110 | dec ebx |
3112 | dec ebx |
3111 | jnz nogb4 |
3113 | jnz nogb4 |
3112 | mov eax, [BgrDrawMode] |
3114 | mov eax, [BgrDrawMode] |
3113 | ;-------------------------------------- |
3115 | ;-------------------------------------- |
3114 | align 4 |
3116 | align 4 |
3115 | nogb4: |
3117 | nogb4: |
3116 | mov [esp+32], eax |
3118 | mov [esp+32], eax |
3117 | ret |
3119 | ret |
3118 | ;------------------------------------------------------------------------------ |
3120 | ;------------------------------------------------------------------------------ |
3119 | align 4 |
3121 | align 4 |
3120 | sys_getkey: |
3122 | sys_getkey: |
3121 | mov [esp + 32], dword 1 |
3123 | mov [esp + 32], dword 1 |
3122 | ; test main buffer |
3124 | ; test main buffer |
3123 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3125 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3124 | movzx ecx, word [WIN_STACK + ebx * 2] |
3126 | movzx ecx, word [WIN_STACK + ebx * 2] |
3125 | mov edx, [TASK_COUNT] |
3127 | mov edx, [TASK_COUNT] |
3126 | cmp ecx, edx |
3128 | cmp ecx, edx |
3127 | jne .finish |
3129 | jne .finish |
3128 | cmp [KEY_COUNT], byte 0 |
3130 | cmp [KEY_COUNT], byte 0 |
3129 | je .finish |
3131 | je .finish |
3130 | movzx eax, byte [KEY_BUFF] |
3132 | movzx eax, byte [KEY_BUFF] |
3131 | shl eax, 8 |
3133 | shl eax, 8 |
3132 | push eax |
3134 | push eax |
3133 | dec byte [KEY_COUNT] |
3135 | dec byte [KEY_COUNT] |
3134 | and byte [KEY_COUNT], 127 |
3136 | and byte [KEY_COUNT], 127 |
3135 | movzx ecx, byte [KEY_COUNT] |
3137 | movzx ecx, byte [KEY_COUNT] |
3136 | add ecx, 2 |
3138 | add ecx, 2 |
3137 | mov eax, KEY_BUFF + 1 |
3139 | mov eax, KEY_BUFF + 1 |
3138 | mov ebx, KEY_BUFF |
3140 | mov ebx, KEY_BUFF |
3139 | call memmove |
3141 | call memmove |
3140 | pop eax |
3142 | pop eax |
3141 | ;-------------------------------------- |
3143 | ;-------------------------------------- |
3142 | align 4 |
3144 | align 4 |
3143 | .ret_eax: |
3145 | .ret_eax: |
3144 | mov [esp + 32], eax |
3146 | mov [esp + 32], eax |
3145 | ret |
3147 | ret |
3146 | ;-------------------------------------- |
3148 | ;-------------------------------------- |
3147 | align 4 |
3149 | align 4 |
3148 | .finish: |
3150 | .finish: |
3149 | ; test hotkeys buffer |
3151 | ; test hotkeys buffer |
3150 | mov ecx, hotkey_buffer |
3152 | mov ecx, hotkey_buffer |
3151 | ;-------------------------------------- |
3153 | ;-------------------------------------- |
3152 | align 4 |
3154 | align 4 |
3153 | @@: |
3155 | @@: |
3154 | cmp [ecx], ebx |
3156 | cmp [ecx], ebx |
3155 | jz .found |
3157 | jz .found |
3156 | add ecx, 8 |
3158 | add ecx, 8 |
3157 | cmp ecx, hotkey_buffer + 120 * 8 |
3159 | cmp ecx, hotkey_buffer + 120 * 8 |
3158 | jb @b |
3160 | jb @b |
3159 | ret |
3161 | ret |
3160 | ;-------------------------------------- |
3162 | ;-------------------------------------- |
3161 | align 4 |
3163 | align 4 |
3162 | .found: |
3164 | .found: |
3163 | mov ax, [ecx + 6] |
3165 | mov ax, [ecx + 6] |
3164 | shl eax, 16 |
3166 | shl eax, 16 |
3165 | mov ah, [ecx + 4] |
3167 | mov ah, [ecx + 4] |
3166 | mov al, 2 |
3168 | mov al, 2 |
3167 | and dword [ecx + 4], 0 |
3169 | and dword [ecx + 4], 0 |
3168 | and dword [ecx], 0 |
3170 | and dword [ecx], 0 |
3169 | jmp .ret_eax |
3171 | jmp .ret_eax |
3170 | ;------------------------------------------------------------------------------ |
3172 | ;------------------------------------------------------------------------------ |
3171 | align 4 |
3173 | align 4 |
3172 | sys_getbutton: |
3174 | sys_getbutton: |
3173 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3175 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3174 | mov [esp + 32], dword 1 |
3176 | mov [esp + 32], dword 1 |
3175 | movzx ecx, word [WIN_STACK + ebx * 2] |
3177 | movzx ecx, word [WIN_STACK + ebx * 2] |
3176 | mov edx, [TASK_COUNT] ; less than 256 processes |
3178 | mov edx, [TASK_COUNT] ; less than 256 processes |
3177 | cmp ecx, edx |
3179 | cmp ecx, edx |
3178 | jne .exit |
3180 | jne .exit |
3179 | movzx eax, byte [BTN_COUNT] |
3181 | movzx eax, byte [BTN_COUNT] |
3180 | test eax, eax |
3182 | test eax, eax |
3181 | jz .exit |
3183 | jz .exit |
3182 | mov eax, [BTN_BUFF] |
3184 | mov eax, [BTN_BUFF] |
3183 | and al, 0xFE ; delete left button bit |
3185 | and al, 0xFE ; delete left button bit |
3184 | mov [BTN_COUNT], byte 0 |
3186 | mov [BTN_COUNT], byte 0 |
3185 | mov [esp + 32], eax |
3187 | mov [esp + 32], eax |
3186 | ;-------------------------------------- |
3188 | ;-------------------------------------- |
3187 | align 4 |
3189 | align 4 |
3188 | .exit: |
3190 | .exit: |
3189 | ret |
3191 | ret |
3190 | ;------------------------------------------------------------------------------ |
3192 | ;------------------------------------------------------------------------------ |
3191 | align 4 |
3193 | align 4 |
3192 | sys_cpuusage: |
3194 | sys_cpuusage: |
3193 | 3195 | ||
3194 | ; RETURN: |
3196 | ; RETURN: |
3195 | ; |
3197 | ; |
3196 | ; +00 dword process cpu usage |
3198 | ; +00 dword process cpu usage |
3197 | ; +04 word position in windowing stack |
3199 | ; +04 word position in windowing stack |
3198 | ; +06 word windowing stack value at current position (cpu nro) |
3200 | ; +06 word windowing stack value at current position (cpu nro) |
3199 | ; +10 12 bytes name |
3201 | ; +10 12 bytes name |
3200 | ; +22 dword start in mem |
3202 | ; +22 dword start in mem |
3201 | ; +26 dword used mem |
3203 | ; +26 dword used mem |
3202 | ; +30 dword PID , process idenfification number |
3204 | ; +30 dword PID , process idenfification number |
3203 | ; |
3205 | ; |
3204 | 3206 | ||
3205 | cmp ecx, -1 ; who am I ? |
3207 | cmp ecx, -1 ; who am I ? |
3206 | jne .no_who_am_i |
3208 | jne .no_who_am_i |
3207 | mov ecx, [CURRENT_TASK] |
3209 | mov ecx, [CURRENT_TASK] |
3208 | .no_who_am_i: |
3210 | .no_who_am_i: |
3209 | cmp ecx, max_processes |
3211 | cmp ecx, max_processes |
3210 | ja .nofillbuf |
3212 | ja .nofillbuf |
3211 | 3213 | ||
3212 | ; +4: word: position of the window of thread in the window stack |
3214 | ; +4: word: position of the window of thread in the window stack |
3213 | mov ax, [WIN_STACK + ecx * 2] |
3215 | mov ax, [WIN_STACK + ecx * 2] |
3214 | mov [ebx+4], ax |
3216 | mov [ebx+4], ax |
3215 | ; +6: word: number of the thread slot, which window has in the window stack |
3217 | ; +6: word: number of the thread slot, which window has in the window stack |
3216 | ; position ecx (has no relation to the specific thread) |
3218 | ; position ecx (has no relation to the specific thread) |
3217 | mov ax, [WIN_POS + ecx * 2] |
3219 | mov ax, [WIN_POS + ecx * 2] |
3218 | mov [ebx+6], ax |
3220 | mov [ebx+6], ax |
3219 | 3221 | ||
3220 | shl ecx, 5 |
3222 | shl ecx, 5 |
3221 | 3223 | ||
3222 | ; +0: dword: memory usage |
3224 | ; +0: dword: memory usage |
3223 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3225 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3224 | mov [ebx], eax |
3226 | mov [ebx], eax |
3225 | ; +10: 11 bytes: name of the process |
3227 | ; +10: 11 bytes: name of the process |
3226 | push ecx |
3228 | push ecx |
3227 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3229 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3228 | add ebx, 10 |
3230 | add ebx, 10 |
3229 | mov ecx, 11 |
3231 | mov ecx, 11 |
3230 | call memmove |
3232 | call memmove |
3231 | pop ecx |
3233 | pop ecx |
3232 | 3234 | ||
3233 | ; +22: address of the process in memory |
3235 | ; +22: address of the process in memory |
3234 | ; +26: size of used memory - 1 |
3236 | ; +26: size of used memory - 1 |
3235 | push edi |
3237 | push edi |
3236 | lea edi, [ebx+12] |
3238 | lea edi, [ebx+12] |
3237 | xor eax, eax |
3239 | xor eax, eax |
3238 | mov edx, 0x100000*16 |
3240 | mov edx, 0x100000*16 |
3239 | cmp ecx, 1 shl 5 |
3241 | cmp ecx, 1 shl 5 |
3240 | je .os_mem |
3242 | je .os_mem |
3241 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3243 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3242 | mov edx, [edx+PROC.mem_used] |
3244 | mov edx, [edx+PROC.mem_used] |
3243 | mov eax, std_application_base_address |
3245 | mov eax, std_application_base_address |
3244 | .os_mem: |
3246 | .os_mem: |
3245 | stosd |
3247 | stosd |
3246 | lea eax, [edx-1] |
3248 | lea eax, [edx-1] |
3247 | stosd |
3249 | stosd |
3248 | 3250 | ||
3249 | ; +30: PID/TID |
3251 | ; +30: PID/TID |
3250 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3252 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3251 | stosd |
3253 | stosd |
3252 | 3254 | ||
3253 | ; window position and size |
3255 | ; window position and size |
3254 | push esi |
3256 | push esi |
3255 | lea esi, [ecx + window_data + WDATA.box] |
3257 | lea esi, [ecx + window_data + WDATA.box] |
3256 | movsd |
3258 | movsd |
3257 | movsd |
3259 | movsd |
3258 | movsd |
3260 | movsd |
3259 | movsd |
3261 | movsd |
3260 | 3262 | ||
3261 | ; Process state (+50) |
3263 | ; Process state (+50) |
3262 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3264 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3263 | stosd |
3265 | stosd |
3264 | 3266 | ||
3265 | ; Window client area box |
3267 | ; Window client area box |
3266 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3268 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3267 | movsd |
3269 | movsd |
3268 | movsd |
3270 | movsd |
3269 | movsd |
3271 | movsd |
3270 | movsd |
3272 | movsd |
3271 | 3273 | ||
3272 | ; Window state |
3274 | ; Window state |
3273 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3275 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3274 | stosb |
3276 | stosb |
3275 | 3277 | ||
3276 | ; Event mask (+71) |
3278 | ; Event mask (+71) |
3277 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3279 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3278 | stosd |
3280 | stosd |
3279 | 3281 | ||
3280 | ; Keyboard mode (+75) |
3282 | ; Keyboard mode (+75) |
3281 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3283 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3282 | stosb |
3284 | stosb |
3283 | 3285 | ||
3284 | pop esi |
3286 | pop esi |
3285 | pop edi |
3287 | pop edi |
3286 | 3288 | ||
3287 | .nofillbuf: |
3289 | .nofillbuf: |
3288 | ; return number of processes |
3290 | ; return number of processes |
3289 | 3291 | ||
3290 | mov eax, [TASK_COUNT] |
3292 | mov eax, [TASK_COUNT] |
3291 | mov [esp+32], eax |
3293 | mov [esp+32], eax |
3292 | ret |
3294 | ret |
3293 | 3295 | ||
3294 | align 4 |
3296 | align 4 |
3295 | sys_clock: |
3297 | sys_clock: |
3296 | cli |
3298 | cli |
3297 | ; Mikhail Lisovin xx Jan 2005 |
3299 | ; Mikhail Lisovin xx Jan 2005 |
3298 | @@: |
3300 | @@: |
3299 | mov al, 10 |
3301 | mov al, 10 |
3300 | out 0x70, al |
3302 | out 0x70, al |
3301 | in al, 0x71 |
3303 | in al, 0x71 |
3302 | test al, al |
3304 | test al, al |
3303 | jns @f |
3305 | jns @f |
3304 | mov esi, 1 |
3306 | mov esi, 1 |
3305 | call delay_ms |
3307 | call delay_ms |
3306 | jmp @b |
3308 | jmp @b |
3307 | @@: |
3309 | @@: |
3308 | ; end Lisovin's fix |
3310 | ; end Lisovin's fix |
3309 | 3311 | ||
3310 | xor al, al ; seconds |
3312 | xor al, al ; seconds |
3311 | out 0x70, al |
3313 | out 0x70, al |
3312 | in al, 0x71 |
3314 | in al, 0x71 |
3313 | movzx ecx, al |
3315 | movzx ecx, al |
3314 | mov al, 02 ; minutes |
3316 | mov al, 02 ; minutes |
3315 | shl ecx, 16 |
3317 | shl ecx, 16 |
3316 | out 0x70, al |
3318 | out 0x70, al |
3317 | in al, 0x71 |
3319 | in al, 0x71 |
3318 | movzx edx, al |
3320 | movzx edx, al |
3319 | mov al, 04 ; hours |
3321 | mov al, 04 ; hours |
3320 | shl edx, 8 |
3322 | shl edx, 8 |
3321 | out 0x70, al |
3323 | out 0x70, al |
3322 | in al, 0x71 |
3324 | in al, 0x71 |
3323 | add ecx, edx |
3325 | add ecx, edx |
3324 | movzx edx, al |
3326 | movzx edx, al |
3325 | add ecx, edx |
3327 | add ecx, edx |
3326 | sti |
3328 | sti |
3327 | mov [esp + 32], ecx |
3329 | mov [esp + 32], ecx |
3328 | ret |
3330 | ret |
3329 | 3331 | ||
3330 | 3332 | ||
3331 | align 4 |
3333 | align 4 |
3332 | 3334 | ||
3333 | sys_date: |
3335 | sys_date: |
3334 | 3336 | ||
3335 | cli |
3337 | cli |
3336 | @@: |
3338 | @@: |
3337 | mov al, 10 |
3339 | mov al, 10 |
3338 | out 0x70, al |
3340 | out 0x70, al |
3339 | in al, 0x71 |
3341 | in al, 0x71 |
3340 | test al, al |
3342 | test al, al |
3341 | jns @f |
3343 | jns @f |
3342 | mov esi, 1 |
3344 | mov esi, 1 |
3343 | call delay_ms |
3345 | call delay_ms |
3344 | jmp @b |
3346 | jmp @b |
3345 | @@: |
3347 | @@: |
3346 | 3348 | ||
3347 | mov ch, 0 |
3349 | mov ch, 0 |
3348 | mov al, 7 ; date |
3350 | mov al, 7 ; date |
3349 | out 0x70, al |
3351 | out 0x70, al |
3350 | in al, 0x71 |
3352 | in al, 0x71 |
3351 | mov cl, al |
3353 | mov cl, al |
3352 | mov al, 8 ; month |
3354 | mov al, 8 ; month |
3353 | shl ecx, 16 |
3355 | shl ecx, 16 |
3354 | out 0x70, al |
3356 | out 0x70, al |
3355 | in al, 0x71 |
3357 | in al, 0x71 |
3356 | mov ch, al |
3358 | mov ch, al |
3357 | mov al, 9 ; year |
3359 | mov al, 9 ; year |
3358 | out 0x70, al |
3360 | out 0x70, al |
3359 | in al, 0x71 |
3361 | in al, 0x71 |
3360 | mov cl, al |
3362 | mov cl, al |
3361 | sti |
3363 | sti |
3362 | mov [esp+32], ecx |
3364 | mov [esp+32], ecx |
3363 | ret |
3365 | ret |
3364 | 3366 | ||
3365 | 3367 | ||
3366 | ; redraw status |
3368 | ; redraw status |
3367 | 3369 | ||
3368 | sys_redrawstat: |
3370 | sys_redrawstat: |
3369 | cmp ebx, 1 |
3371 | cmp ebx, 1 |
3370 | jne no_widgets_away |
3372 | jne no_widgets_away |
3371 | ; buttons away |
3373 | ; buttons away |
3372 | mov ecx, [CURRENT_TASK] |
3374 | mov ecx, [CURRENT_TASK] |
3373 | sys_newba2: |
3375 | sys_newba2: |
3374 | mov edi, [BTN_ADDR] |
3376 | mov edi, [BTN_ADDR] |
3375 | cmp [edi], dword 0 ; empty button list ? |
3377 | cmp [edi], dword 0 ; empty button list ? |
3376 | je end_of_buttons_away |
3378 | je end_of_buttons_away |
3377 | movzx ebx, word [edi] |
3379 | movzx ebx, word [edi] |
3378 | inc ebx |
3380 | inc ebx |
3379 | mov eax, edi |
3381 | mov eax, edi |
3380 | sys_newba: |
3382 | sys_newba: |
3381 | dec ebx |
3383 | dec ebx |
3382 | jz end_of_buttons_away |
3384 | jz end_of_buttons_away |
3383 | 3385 | ||
3384 | add eax, 0x10 |
3386 | add eax, 0x10 |
3385 | cmp cx, [eax] |
3387 | cmp cx, [eax] |
3386 | jnz sys_newba |
3388 | jnz sys_newba |
3387 | 3389 | ||
3388 | push eax ebx ecx |
3390 | push eax ebx ecx |
3389 | mov ecx, ebx |
3391 | mov ecx, ebx |
3390 | inc ecx |
3392 | inc ecx |
3391 | shl ecx, 4 |
3393 | shl ecx, 4 |
3392 | mov ebx, eax |
3394 | mov ebx, eax |
3393 | add eax, 0x10 |
3395 | add eax, 0x10 |
3394 | call memmove |
3396 | call memmove |
3395 | dec dword [edi] |
3397 | dec dword [edi] |
3396 | pop ecx ebx eax |
3398 | pop ecx ebx eax |
3397 | 3399 | ||
3398 | jmp sys_newba2 |
3400 | jmp sys_newba2 |
3399 | 3401 | ||
3400 | end_of_buttons_away: |
3402 | end_of_buttons_away: |
3401 | 3403 | ||
3402 | ret |
3404 | ret |
3403 | 3405 | ||
3404 | no_widgets_away: |
3406 | no_widgets_away: |
3405 | 3407 | ||
3406 | cmp ebx, 2 |
3408 | cmp ebx, 2 |
3407 | jnz srl1 |
3409 | jnz srl1 |
3408 | 3410 | ||
3409 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3411 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3410 | add edx, draw_data - CURRENT_TASK |
3412 | add edx, draw_data - CURRENT_TASK |
3411 | mov [edx + RECT.left], 0 |
3413 | mov [edx + RECT.left], 0 |
3412 | mov [edx + RECT.top], 0 |
3414 | mov [edx + RECT.top], 0 |
3413 | mov eax, [Screen_Max_X] |
3415 | mov eax, [Screen_Max_X] |
3414 | mov [edx + RECT.right], eax |
3416 | mov [edx + RECT.right], eax |
3415 | mov eax, [Screen_Max_Y] |
3417 | mov eax, [Screen_Max_Y] |
3416 | mov [edx + RECT.bottom], eax |
3418 | mov [edx + RECT.bottom], eax |
3417 | 3419 | ||
3418 | srl1: |
3420 | srl1: |
3419 | ret |
3421 | ret |
3420 | 3422 | ||
3421 | ;ok - 100% work |
3423 | ;ok - 100% work |
3422 | ;nt - not tested |
3424 | ;nt - not tested |
3423 | ;--------------------------------------------------------------------------------------------- |
3425 | ;--------------------------------------------------------------------------------------------- |
3424 | ;eax |
3426 | ;eax |
3425 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3427 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3426 | ;1 - change task. Ret nothing. Block. ok. |
3428 | ;1 - change task. Ret nothing. Block. ok. |
3427 | ;2 - performance control |
3429 | ;2 - performance control |
3428 | ; ebx |
3430 | ; ebx |
3429 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3431 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3430 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3432 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3431 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3433 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3432 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3434 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3433 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3435 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3434 | ;eax |
3436 | ;eax |
3435 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3437 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3436 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3438 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3437 | ;--------------------------------------------------------------------------------------------- |
3439 | ;--------------------------------------------------------------------------------------------- |
3438 | iglobal |
3440 | iglobal |
3439 | align 4 |
3441 | align 4 |
3440 | sheduler: |
3442 | sheduler: |
3441 | dd sys_sheduler.00 |
3443 | dd sys_sheduler.00 |
3442 | dd change_task |
3444 | dd change_task |
3443 | dd sys_sheduler.02 |
3445 | dd sys_sheduler.02 |
3444 | dd sys_sheduler.03 |
3446 | dd sys_sheduler.03 |
3445 | dd sys_sheduler.04 |
3447 | dd sys_sheduler.04 |
3446 | endg |
3448 | endg |
3447 | sys_sheduler: |
3449 | sys_sheduler: |
3448 | ;rewritten by |
3450 | ;rewritten by |
3449 | jmp dword [sheduler+ebx*4] |
3451 | jmp dword [sheduler+ebx*4] |
3450 | ;.shed_counter: |
3452 | ;.shed_counter: |
3451 | .00: |
3453 | .00: |
3452 | mov eax, [context_counter] |
3454 | mov eax, [context_counter] |
3453 | mov [esp+32], eax |
3455 | mov [esp+32], eax |
3454 | ret |
3456 | ret |
3455 | 3457 | ||
3456 | .02: |
3458 | .02: |
3457 | ;.perf_control: |
3459 | ;.perf_control: |
3458 | inc ebx ;before ebx=2, ebx=3 |
3460 | inc ebx ;before ebx=2, ebx=3 |
3459 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3461 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3460 | jz cache_disable |
3462 | jz cache_disable |
3461 | 3463 | ||
3462 | dec ebx ;ebx=2 |
3464 | dec ebx ;ebx=2 |
3463 | cmp ebx, ecx ; |
3465 | cmp ebx, ecx ; |
3464 | jz cache_enable ;if ecx=2 and ebx=2 |
3466 | jz cache_enable ;if ecx=2 and ebx=2 |
3465 | 3467 | ||
3466 | dec ebx ;ebx=1 |
3468 | dec ebx ;ebx=1 |
3467 | cmp ebx, ecx |
3469 | cmp ebx, ecx |
3468 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3470 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3469 | 3471 | ||
3470 | dec ebx |
3472 | dec ebx |
3471 | test ebx, ecx ;ebx=0 and ecx=0 |
3473 | test ebx, ecx ;ebx=0 and ecx=0 |
3472 | jz modify_pce ;if ecx=0 |
3474 | jz modify_pce ;if ecx=0 |
3473 | 3475 | ||
3474 | ret |
3476 | ret |
3475 | 3477 | ||
3476 | .03: |
3478 | .03: |
3477 | ;.rdmsr_instr: |
3479 | ;.rdmsr_instr: |
3478 | ;now counter in ecx |
3480 | ;now counter in ecx |
3479 | ;(edx:eax) esi:edi => edx:esi |
3481 | ;(edx:eax) esi:edi => edx:esi |
3480 | mov eax, esi |
3482 | mov eax, esi |
3481 | mov ecx, edx |
3483 | mov ecx, edx |
3482 | rdmsr |
3484 | rdmsr |
3483 | mov [esp+32], eax |
3485 | mov [esp+32], eax |
3484 | mov [esp+20], edx ;ret in ebx? |
3486 | mov [esp+20], edx ;ret in ebx? |
3485 | ret |
3487 | ret |
3486 | 3488 | ||
3487 | .04: |
3489 | .04: |
3488 | ;.wrmsr_instr: |
3490 | ;.wrmsr_instr: |
3489 | ;now counter in ecx |
3491 | ;now counter in ecx |
3490 | ;(edx:eax) esi:edi => edx:esi |
3492 | ;(edx:eax) esi:edi => edx:esi |
3491 | ; Fast Call MSR can't be destroy |
3493 | ; Fast Call MSR can't be destroy |
3492 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3494 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3493 | ; включаются/выключаются расширенные возможности |
3495 | ; включаются/выключаются расширенные возможности |
3494 | cmp edx, MSR_SYSENTER_CS |
3496 | cmp edx, MSR_SYSENTER_CS |
3495 | je @f |
3497 | je @f |
3496 | cmp edx, MSR_SYSENTER_ESP |
3498 | cmp edx, MSR_SYSENTER_ESP |
3497 | je @f |
3499 | je @f |
3498 | cmp edx, MSR_SYSENTER_EIP |
3500 | cmp edx, MSR_SYSENTER_EIP |
3499 | je @f |
3501 | je @f |
3500 | cmp edx, MSR_AMD_STAR |
3502 | cmp edx, MSR_AMD_STAR |
3501 | je @f |
3503 | je @f |
3502 | 3504 | ||
3503 | mov eax, esi |
3505 | mov eax, esi |
3504 | mov ecx, edx |
3506 | mov ecx, edx |
3505 | wrmsr |
3507 | wrmsr |
3506 | ; mov [esp + 32], eax |
3508 | ; mov [esp + 32], eax |
3507 | ; mov [esp + 20], edx ;ret in ebx? |
3509 | ; mov [esp + 20], edx ;ret in ebx? |
3508 | @@: |
3510 | @@: |
3509 | ret |
3511 | ret |
3510 | 3512 | ||
3511 | cache_disable: |
3513 | cache_disable: |
3512 | mov eax, cr0 |
3514 | mov eax, cr0 |
3513 | or eax, 01100000000000000000000000000000b |
3515 | or eax, 01100000000000000000000000000000b |
3514 | mov cr0, eax |
3516 | mov cr0, eax |
3515 | wbinvd ;set MESI |
3517 | wbinvd ;set MESI |
3516 | ret |
3518 | ret |
3517 | 3519 | ||
3518 | cache_enable: |
3520 | cache_enable: |
3519 | mov eax, cr0 |
3521 | mov eax, cr0 |
3520 | and eax, 10011111111111111111111111111111b |
3522 | and eax, 10011111111111111111111111111111b |
3521 | mov cr0, eax |
3523 | mov cr0, eax |
3522 | ret |
3524 | ret |
3523 | 3525 | ||
3524 | is_cache_enabled: |
3526 | is_cache_enabled: |
3525 | mov eax, cr0 |
3527 | mov eax, cr0 |
3526 | mov ebx, eax |
3528 | mov ebx, eax |
3527 | and eax, 01100000000000000000000000000000b |
3529 | and eax, 01100000000000000000000000000000b |
3528 | jz cache_disabled |
3530 | jz cache_disabled |
3529 | mov [esp+32], ebx |
3531 | mov [esp+32], ebx |
3530 | cache_disabled: |
3532 | cache_disabled: |
3531 | mov dword [esp+32], eax;0 |
3533 | mov dword [esp+32], eax;0 |
3532 | ret |
3534 | ret |
3533 | 3535 | ||
3534 | modify_pce: |
3536 | modify_pce: |
3535 | mov eax, cr4 |
3537 | mov eax, cr4 |
3536 | ; mov ebx,0 |
3538 | ; mov ebx,0 |
3537 | ; or bx,100000000b ;pce |
3539 | ; or bx,100000000b ;pce |
3538 | ; xor eax,ebx ;invert pce |
3540 | ; xor eax,ebx ;invert pce |
3539 | bts eax, 8;pce=cr4[8] |
3541 | bts eax, 8;pce=cr4[8] |
3540 | mov cr4, eax |
3542 | mov cr4, eax |
3541 | mov [esp+32], eax |
3543 | mov [esp+32], eax |
3542 | ret |
3544 | ret |
3543 | ;--------------------------------------------------------------------------------------------- |
3545 | ;--------------------------------------------------------------------------------------------- |
3544 | 3546 | ||
3545 | 3547 | ||
3546 | iglobal |
3548 | iglobal |
3547 | cpustring db 'CPU',0 |
3549 | cpustring db 'CPU',0 |
3548 | endg |
3550 | endg |
3549 | 3551 | ||
3550 | uglobal |
3552 | uglobal |
3551 | background_defined db 0 ; diamond, 11.04.2006 |
3553 | background_defined db 0 ; diamond, 11.04.2006 |
3552 | endg |
3554 | endg |
3553 | ;----------------------------------------------------------------------------- |
3555 | ;----------------------------------------------------------------------------- |
3554 | align 4 |
3556 | align 4 |
3555 | checkmisc: |
3557 | checkmisc: |
3556 | cmp [ctrl_alt_del], 1 |
3558 | cmp [ctrl_alt_del], 1 |
3557 | jne nocpustart |
3559 | jne nocpustart |
3558 | 3560 | ||
3559 | mov ebp, cpustring |
3561 | mov ebp, cpustring |
3560 | call fs_execute_from_sysdir |
3562 | call fs_execute_from_sysdir |
3561 | 3563 | ||
3562 | mov [ctrl_alt_del], 0 |
3564 | mov [ctrl_alt_del], 0 |
3563 | ;-------------------------------------- |
3565 | ;-------------------------------------- |
3564 | align 4 |
3566 | align 4 |
3565 | nocpustart: |
3567 | nocpustart: |
3566 | cmp [mouse_active], 1 |
3568 | cmp [mouse_active], 1 |
3567 | jne mouse_not_active |
3569 | jne mouse_not_active |
3568 | mov [mouse_active], 0 |
3570 | mov [mouse_active], 0 |
3569 | 3571 | ||
3570 | xor edi, edi |
3572 | xor edi, edi |
3571 | mov ebx, CURRENT_TASK |
3573 | mov ebx, CURRENT_TASK |
3572 | 3574 | ||
3573 | mov ecx, [TASK_COUNT] |
3575 | mov ecx, [TASK_COUNT] |
3574 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3576 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3575 | shl eax, 8 |
3577 | shl eax, 8 |
3576 | push eax |
3578 | push eax |
3577 | 3579 | ||
3578 | movzx eax, word [MOUSE_X] |
3580 | movzx eax, word [MOUSE_X] |
3579 | movzx edx, word [MOUSE_Y] |
3581 | movzx edx, word [MOUSE_Y] |
3580 | ;-------------------------------------- |
3582 | ;-------------------------------------- |
3581 | align 4 |
3583 | align 4 |
3582 | .set_mouse_event: |
3584 | .set_mouse_event: |
3583 | add edi, 256 |
3585 | add edi, 256 |
3584 | add ebx, 32 |
3586 | add ebx, 32 |
3585 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3587 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3586 | jz .pos_filter |
3588 | jz .pos_filter |
3587 | 3589 | ||
3588 | cmp edi, [esp] ; skip if filtration active |
3590 | cmp edi, [esp] ; skip if filtration active |
3589 | jne .skip |
3591 | jne .skip |
3590 | ;-------------------------------------- |
3592 | ;-------------------------------------- |
3591 | align 4 |
3593 | align 4 |
3592 | .pos_filter: |
3594 | .pos_filter: |
3593 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3595 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3594 | jz .set |
3596 | jz .set |
3595 | 3597 | ||
3596 | mov esi, [ebx-twdw+WDATA.box.left] |
3598 | mov esi, [ebx-twdw+WDATA.box.left] |
3597 | cmp eax, esi |
3599 | cmp eax, esi |
3598 | jb .skip |
3600 | jb .skip |
3599 | add esi, [ebx-twdw+WDATA.box.width] |
3601 | add esi, [ebx-twdw+WDATA.box.width] |
3600 | cmp eax, esi |
3602 | cmp eax, esi |
3601 | ja .skip |
3603 | ja .skip |
3602 | 3604 | ||
3603 | mov esi, [ebx-twdw+WDATA.box.top] |
3605 | mov esi, [ebx-twdw+WDATA.box.top] |
3604 | cmp edx, esi |
3606 | cmp edx, esi |
3605 | jb .skip |
3607 | jb .skip |
3606 | add esi, [ebx-twdw+WDATA.box.height] |
3608 | add esi, [ebx-twdw+WDATA.box.height] |
3607 | cmp edx, esi |
3609 | cmp edx, esi |
3608 | ja .skip |
3610 | ja .skip |
3609 | ;-------------------------------------- |
3611 | ;-------------------------------------- |
3610 | align 4 |
3612 | align 4 |
3611 | .set: |
3613 | .set: |
3612 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3614 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3613 | ;-------------------------------------- |
3615 | ;-------------------------------------- |
3614 | align 4 |
3616 | align 4 |
3615 | .skip: |
3617 | .skip: |
3616 | loop .set_mouse_event |
3618 | loop .set_mouse_event |
3617 | 3619 | ||
3618 | pop eax |
3620 | pop eax |
3619 | ;-------------------------------------- |
3621 | ;-------------------------------------- |
3620 | align 4 |
3622 | align 4 |
3621 | mouse_not_active: |
3623 | mouse_not_active: |
3622 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3624 | cmp byte[REDRAW_BACKGROUND], 0 ; background update ? |
3623 | jz nobackgr |
3625 | jz nobackgr |
3624 | 3626 | ||
3625 | cmp [background_defined], 0 |
3627 | cmp [background_defined], 0 |
3626 | jz nobackgr |
3628 | jz nobackgr |
3627 | ;-------------------------------------- |
3629 | ;-------------------------------------- |
3628 | align 4 |
3630 | align 4 |
3629 | backgr: |
3631 | backgr: |
3630 | mov eax, [draw_data+32 + RECT.left] |
3632 | mov eax, [draw_data+32 + RECT.left] |
3631 | shl eax, 16 |
3633 | shl eax, 16 |
3632 | add eax, [draw_data+32 + RECT.right] |
3634 | add eax, [draw_data+32 + RECT.right] |
3633 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3635 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3634 | 3636 | ||
3635 | mov eax, [draw_data+32 + RECT.top] |
3637 | mov eax, [draw_data+32 + RECT.top] |
3636 | shl eax, 16 |
3638 | shl eax, 16 |
3637 | add eax, [draw_data+32 + RECT.bottom] |
3639 | add eax, [draw_data+32 + RECT.bottom] |
3638 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3640 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3639 | 3641 | ||
3640 | call drawbackground |
3642 | call drawbackground |
3641 | ; DEBUGF 1, "K : drawbackground\n" |
3643 | ; DEBUGF 1, "K : drawbackground\n" |
3642 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3644 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3643 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3645 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3644 | ;--------- set event 5 start ---------- |
3646 | ;--------- set event 5 start ---------- |
3645 | push ecx edi |
3647 | push ecx edi |
3646 | xor edi, edi |
3648 | xor edi, edi |
3647 | mov ecx, [TASK_COUNT] |
3649 | mov ecx, [TASK_COUNT] |
3648 | ;-------------------------------------- |
3650 | ;-------------------------------------- |
3649 | align 4 |
3651 | align 4 |
3650 | set_bgr_event: |
3652 | set_bgr_event: |
3651 | add edi, 256 |
3653 | add edi, 256 |
3652 | mov eax, [BG_Rect_X_left_right] |
3654 | mov eax, [BG_Rect_X_left_right] |
3653 | mov edx, [BG_Rect_Y_top_bottom] |
3655 | mov edx, [BG_Rect_Y_top_bottom] |
3654 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3656 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3655 | jz .set |
3657 | jz .set |
3656 | .join: |
3658 | .join: |
3657 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3659 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3658 | jae @f |
3660 | jae @f |
3659 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3661 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3660 | @@: |
3662 | @@: |
3661 | shr eax, 16 |
3663 | shr eax, 16 |
3662 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3664 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3663 | jbe @f |
3665 | jbe @f |
3664 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3666 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3665 | @@: |
3667 | @@: |
3666 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3668 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3667 | jae @f |
3669 | jae @f |
3668 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3670 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3669 | @@: |
3671 | @@: |
3670 | shr edx, 16 |
3672 | shr edx, 16 |
3671 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3673 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3672 | jbe @f |
3674 | jbe @f |
3673 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3675 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3674 | @@: |
3676 | @@: |
3675 | jmp .common |
3677 | jmp .common |
3676 | .set: |
3678 | .set: |
3677 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3679 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3678 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3680 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3679 | .common: |
3681 | .common: |
3680 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3682 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3681 | loop set_bgr_event |
3683 | loop set_bgr_event |
3682 | pop edi ecx |
3684 | pop edi ecx |
3683 | ;--------- set event 5 stop ----------- |
3685 | ;--------- set event 5 stop ----------- |
3684 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3686 | dec byte[REDRAW_BACKGROUND] ; got new update request? |
3685 | jnz backgr |
3687 | jnz backgr |
3686 | 3688 | ||
3687 | xor eax, eax |
3689 | xor eax, eax |
3688 | mov [draw_data+32 + RECT.left], eax |
3690 | mov [draw_data+32 + RECT.left], eax |
3689 | mov [draw_data+32 + RECT.top], eax |
3691 | mov [draw_data+32 + RECT.top], eax |
3690 | mov [draw_data+32 + RECT.right], eax |
3692 | mov [draw_data+32 + RECT.right], eax |
3691 | mov [draw_data+32 + RECT.bottom], eax |
3693 | mov [draw_data+32 + RECT.bottom], eax |
3692 | ;-------------------------------------- |
3694 | ;-------------------------------------- |
3693 | align 4 |
3695 | align 4 |
3694 | nobackgr: |
3696 | nobackgr: |
3695 | ; system shutdown request |
3697 | ; system shutdown request |
3696 | cmp [SYS_SHUTDOWN], byte 0 |
3698 | cmp [SYS_SHUTDOWN], byte 0 |
3697 | je noshutdown |
3699 | je noshutdown |
3698 | 3700 | ||
3699 | mov edx, [shutdown_processes] |
3701 | mov edx, [shutdown_processes] |
3700 | 3702 | ||
3701 | cmp [SYS_SHUTDOWN], dl |
3703 | cmp [SYS_SHUTDOWN], dl |
3702 | jne noshutdown |
3704 | jne noshutdown |
3703 | 3705 | ||
3704 | lea ecx, [edx-1] |
3706 | lea ecx, [edx-1] |
3705 | mov edx, OS_BASE+0x3040 |
3707 | mov edx, OS_BASE+0x3040 |
3706 | jecxz no_mark_system_shutdown |
3708 | jecxz no_mark_system_shutdown |
3707 | ;-------------------------------------- |
3709 | ;-------------------------------------- |
3708 | align 4 |
3710 | align 4 |
3709 | markz: |
3711 | markz: |
3710 | push ecx edx |
3712 | push ecx edx |
3711 | cmp [edx+TASKDATA.state], 9 |
3713 | cmp [edx+TASKDATA.state], 9 |
3712 | jz .nokill |
3714 | jz .nokill |
3713 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3715 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3714 | cmp [edx+APPDATA.process], sys_proc |
3716 | cmp [edx+APPDATA.process], sys_proc |
3715 | jz .nokill |
3717 | jz .nokill |
3716 | call request_terminate |
3718 | call request_terminate |
3717 | jmp .common |
3719 | jmp .common |
3718 | .nokill: |
3720 | .nokill: |
3719 | dec byte [SYS_SHUTDOWN] |
3721 | dec byte [SYS_SHUTDOWN] |
3720 | xor eax, eax |
3722 | xor eax, eax |
3721 | .common: |
3723 | .common: |
3722 | pop edx ecx |
3724 | pop edx ecx |
3723 | test eax, eax |
3725 | test eax, eax |
3724 | jz @f |
3726 | jz @f |
3725 | mov [edx+TASKDATA.state], byte 3 |
3727 | mov [edx+TASKDATA.state], byte 3 |
3726 | @@: |
3728 | @@: |
3727 | add edx, 0x20 |
3729 | add edx, 0x20 |
3728 | loop markz |
3730 | loop markz |
3729 | call wakeup_osloop |
3731 | call wakeup_osloop |
3730 | ;-------------------------------------- |
3732 | ;-------------------------------------- |
3731 | align 4 |
3733 | align 4 |
3732 | @@: |
3734 | @@: |
3733 | no_mark_system_shutdown: |
3735 | no_mark_system_shutdown: |
3734 | dec byte [SYS_SHUTDOWN] |
3736 | dec byte [SYS_SHUTDOWN] |
3735 | je system_shutdown |
3737 | je system_shutdown |
3736 | ;-------------------------------------- |
3738 | ;-------------------------------------- |
3737 | align 4 |
3739 | align 4 |
3738 | noshutdown: |
3740 | noshutdown: |
3739 | mov eax, [TASK_COUNT] ; termination |
3741 | mov eax, [TASK_COUNT] ; termination |
3740 | mov ebx, TASK_DATA+TASKDATA.state |
3742 | mov ebx, TASK_DATA+TASKDATA.state |
3741 | mov esi, 1 |
3743 | mov esi, 1 |
3742 | ;-------------------------------------- |
3744 | ;-------------------------------------- |
3743 | align 4 |
3745 | align 4 |
3744 | newct: |
3746 | newct: |
3745 | mov cl, [ebx] |
3747 | mov cl, [ebx] |
3746 | cmp cl, byte 3 |
3748 | cmp cl, byte 3 |
3747 | jz .terminate |
3749 | jz .terminate |
3748 | 3750 | ||
3749 | cmp cl, byte 4 |
3751 | cmp cl, byte 4 |
3750 | jnz .noterminate |
3752 | jnz .noterminate |
3751 | .terminate: |
3753 | .terminate: |
3752 | pushad |
3754 | pushad |
3753 | mov ecx, eax |
3755 | mov ecx, eax |
3754 | shl ecx, 8 |
3756 | shl ecx, 8 |
3755 | add ecx, SLOT_BASE |
3757 | add ecx, SLOT_BASE |
3756 | call restore_default_cursor_before_killing |
3758 | call restore_default_cursor_before_killing |
3757 | popad |
3759 | popad |
3758 | 3760 | ||
3759 | pushad |
3761 | pushad |
3760 | call terminate |
3762 | call terminate |
3761 | popad |
3763 | popad |
3762 | cmp byte [SYS_SHUTDOWN], 0 |
3764 | cmp byte [SYS_SHUTDOWN], 0 |
3763 | jz .noterminate |
3765 | jz .noterminate |
3764 | dec byte [SYS_SHUTDOWN] |
3766 | dec byte [SYS_SHUTDOWN] |
3765 | je system_shutdown |
3767 | je system_shutdown |
3766 | 3768 | ||
3767 | .noterminate: |
3769 | .noterminate: |
3768 | add ebx, 0x20 |
3770 | add ebx, 0x20 |
3769 | inc esi |
3771 | inc esi |
3770 | dec eax |
3772 | dec eax |
3771 | jnz newct |
3773 | jnz newct |
3772 | ret |
3774 | ret |
3773 | ;----------------------------------------------------------------------------- |
3775 | ;----------------------------------------------------------------------------- |
3774 | align 4 |
3776 | align 4 |
3775 | redrawscreen: |
3777 | redrawscreen: |
3776 | ; eax , if process window_data base is eax, do not set flag/limits |
3778 | ; eax , if process window_data base is eax, do not set flag/limits |
3777 | 3779 | ||
3778 | pushad |
3780 | pushad |
3779 | push eax |
3781 | push eax |
3780 | 3782 | ||
3781 | ;;; mov ebx,2 |
3783 | ;;; mov ebx,2 |
3782 | ;;; call delay_hs |
3784 | ;;; call delay_hs |
3783 | 3785 | ||
3784 | ;mov ecx,0 ; redraw flags for apps |
3786 | ;mov ecx,0 ; redraw flags for apps |
3785 | xor ecx, ecx |
3787 | xor ecx, ecx |
3786 | ;-------------------------------------- |
3788 | ;-------------------------------------- |
3787 | align 4 |
3789 | align 4 |
3788 | newdw2: |
3790 | newdw2: |
3789 | inc ecx |
3791 | inc ecx |
3790 | push ecx |
3792 | push ecx |
3791 | 3793 | ||
3792 | mov eax, ecx |
3794 | mov eax, ecx |
3793 | shl eax, 5 |
3795 | shl eax, 5 |
3794 | add eax, window_data |
3796 | add eax, window_data |
3795 | 3797 | ||
3796 | cmp eax, [esp+4] |
3798 | cmp eax, [esp+4] |
3797 | je not_this_task |
3799 | je not_this_task |
3798 | ; check if window in redraw area |
3800 | ; check if window in redraw area |
3799 | mov edi, eax |
3801 | mov edi, eax |
3800 | 3802 | ||
3801 | cmp ecx, 1 ; limit for background |
3803 | cmp ecx, 1 ; limit for background |
3802 | jz bgli |
3804 | jz bgli |
3803 | 3805 | ||
3804 | mov eax, [edi + WDATA.box.left] |
3806 | mov eax, [edi + WDATA.box.left] |
3805 | mov ebx, [edi + WDATA.box.top] |
3807 | mov ebx, [edi + WDATA.box.top] |
3806 | 3808 | ||
3807 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3809 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3808 | cmp ecx, ebx |
3810 | cmp ecx, ebx |
3809 | jb ricino |
3811 | jb ricino |
3810 | 3812 | ||
3811 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3813 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3812 | cmp ecx, eax |
3814 | cmp ecx, eax |
3813 | jb ricino |
3815 | jb ricino |
3814 | 3816 | ||
3815 | mov eax, [edi + WDATA.box.left] |
3817 | mov eax, [edi + WDATA.box.left] |
3816 | mov ebx, [edi + WDATA.box.top] |
3818 | mov ebx, [edi + WDATA.box.top] |
3817 | mov ecx, [edi + WDATA.box.width] |
3819 | mov ecx, [edi + WDATA.box.width] |
3818 | mov edx, [edi + WDATA.box.height] |
3820 | mov edx, [edi + WDATA.box.height] |
3819 | add ecx, eax |
3821 | add ecx, eax |
3820 | add edx, ebx |
3822 | add edx, ebx |
3821 | 3823 | ||
3822 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3824 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3823 | cmp edx, eax |
3825 | cmp edx, eax |
3824 | jb ricino |
3826 | jb ricino |
3825 | 3827 | ||
3826 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3828 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3827 | cmp ecx, eax |
3829 | cmp ecx, eax |
3828 | jb ricino |
3830 | jb ricino |
3829 | ;-------------------------------------- |
3831 | ;-------------------------------------- |
3830 | align 4 |
3832 | align 4 |
3831 | bgli: |
3833 | bgli: |
3832 | cmp dword[esp], 1 |
3834 | cmp dword[esp], 1 |
3833 | jnz .az |
3835 | jnz .az |
3834 | 3836 | ||
3835 | cmp byte[REDRAW_BACKGROUND], 0 |
3837 | cmp byte[REDRAW_BACKGROUND], 0 |
3836 | jz .az |
3838 | jz .az |
3837 | 3839 | ||
3838 | mov dl, 0 |
3840 | mov dl, 0 |
3839 | lea eax, [edi+draw_data-window_data] |
3841 | lea eax, [edi+draw_data-window_data] |
3840 | mov ebx, [draw_limits.left] |
3842 | mov ebx, [draw_limits.left] |
3841 | cmp ebx, [eax+RECT.left] |
3843 | cmp ebx, [eax+RECT.left] |
3842 | jae @f |
3844 | jae @f |
3843 | 3845 | ||
3844 | mov [eax+RECT.left], ebx |
3846 | mov [eax+RECT.left], ebx |
3845 | mov dl, 1 |
3847 | mov dl, 1 |
3846 | ;-------------------------------------- |
3848 | ;-------------------------------------- |
3847 | align 4 |
3849 | align 4 |
3848 | @@: |
3850 | @@: |
3849 | mov ebx, [draw_limits.top] |
3851 | mov ebx, [draw_limits.top] |
3850 | cmp ebx, [eax+RECT.top] |
3852 | cmp ebx, [eax+RECT.top] |
3851 | jae @f |
3853 | jae @f |
3852 | 3854 | ||
3853 | mov [eax+RECT.top], ebx |
3855 | mov [eax+RECT.top], ebx |
3854 | mov dl, 1 |
3856 | mov dl, 1 |
3855 | ;-------------------------------------- |
3857 | ;-------------------------------------- |
3856 | align 4 |
3858 | align 4 |
3857 | @@: |
3859 | @@: |
3858 | mov ebx, [draw_limits.right] |
3860 | mov ebx, [draw_limits.right] |
3859 | cmp ebx, [eax+RECT.right] |
3861 | cmp ebx, [eax+RECT.right] |
3860 | jbe @f |
3862 | jbe @f |
3861 | 3863 | ||
3862 | mov [eax+RECT.right], ebx |
3864 | mov [eax+RECT.right], ebx |
3863 | mov dl, 1 |
3865 | mov dl, 1 |
3864 | ;-------------------------------------- |
3866 | ;-------------------------------------- |
3865 | align 4 |
3867 | align 4 |
3866 | @@: |
3868 | @@: |
3867 | mov ebx, [draw_limits.bottom] |
3869 | mov ebx, [draw_limits.bottom] |
3868 | cmp ebx, [eax+RECT.bottom] |
3870 | cmp ebx, [eax+RECT.bottom] |
3869 | jbe @f |
3871 | jbe @f |
3870 | 3872 | ||
3871 | mov [eax+RECT.bottom], ebx |
3873 | mov [eax+RECT.bottom], ebx |
3872 | mov dl, 1 |
3874 | mov dl, 1 |
3873 | ;-------------------------------------- |
3875 | ;-------------------------------------- |
3874 | align 4 |
3876 | align 4 |
3875 | @@: |
3877 | @@: |
3876 | add byte[REDRAW_BACKGROUND], dl |
3878 | add byte[REDRAW_BACKGROUND], dl |
3877 | call wakeup_osloop |
3879 | call wakeup_osloop |
3878 | jmp newdw8 |
3880 | jmp newdw8 |
3879 | ;-------------------------------------- |
3881 | ;-------------------------------------- |
3880 | align 4 |
3882 | align 4 |
3881 | .az: |
3883 | .az: |
3882 | mov eax, edi |
3884 | mov eax, edi |
3883 | add eax, draw_data-window_data |
3885 | add eax, draw_data-window_data |
3884 | 3886 | ||
3885 | mov ebx, [draw_limits.left] ; set limits |
3887 | mov ebx, [draw_limits.left] ; set limits |
3886 | mov [eax + RECT.left], ebx |
3888 | mov [eax + RECT.left], ebx |
3887 | mov ebx, [draw_limits.top] |
3889 | mov ebx, [draw_limits.top] |
3888 | mov [eax + RECT.top], ebx |
3890 | mov [eax + RECT.top], ebx |
3889 | mov ebx, [draw_limits.right] |
3891 | mov ebx, [draw_limits.right] |
3890 | mov [eax + RECT.right], ebx |
3892 | mov [eax + RECT.right], ebx |
3891 | mov ebx, [draw_limits.bottom] |
3893 | mov ebx, [draw_limits.bottom] |
3892 | mov [eax + RECT.bottom], ebx |
3894 | mov [eax + RECT.bottom], ebx |
3893 | 3895 | ||
3894 | sub eax, draw_data-window_data |
3896 | sub eax, draw_data-window_data |
3895 | 3897 | ||
3896 | cmp dword [esp], 1 |
3898 | cmp dword [esp], 1 |
3897 | jne nobgrd |
3899 | jne nobgrd |
3898 | inc byte[REDRAW_BACKGROUND] |
3900 | inc byte[REDRAW_BACKGROUND] |
3899 | call wakeup_osloop |
3901 | call wakeup_osloop |
3900 | ;-------------------------------------- |
3902 | ;-------------------------------------- |
3901 | align 4 |
3903 | align 4 |
3902 | newdw8: |
3904 | newdw8: |
3903 | nobgrd: |
3905 | nobgrd: |
3904 | ;-------------------------------------- |
3906 | ;-------------------------------------- |
3905 | push eax edi ebp |
3907 | push eax edi ebp |
3906 | mov edi, [esp+12] |
3908 | mov edi, [esp+12] |
3907 | cmp edi, 1 |
3909 | cmp edi, 1 |
3908 | je .found |
3910 | je .found |
3909 | 3911 | ||
3910 | mov eax, [draw_limits.left] |
3912 | mov eax, [draw_limits.left] |
3911 | mov ebx, [draw_limits.top] |
3913 | mov ebx, [draw_limits.top] |
3912 | mov ecx, [draw_limits.right] |
3914 | mov ecx, [draw_limits.right] |
3913 | sub ecx, eax |
3915 | sub ecx, eax |
3914 | test ecx, ecx |
3916 | test ecx, ecx |
3915 | jz .not_found |
3917 | jz .not_found |
3916 | 3918 | ||
3917 | mov edx, [draw_limits.bottom] |
3919 | mov edx, [draw_limits.bottom] |
3918 | sub edx, ebx |
3920 | sub edx, ebx |
3919 | test edx, edx |
3921 | test edx, edx |
3920 | jz .not_found |
3922 | jz .not_found |
3921 | 3923 | ||
3922 | ; eax - x, ebx - y |
3924 | ; eax - x, ebx - y |
3923 | ; ecx - size x, edx - size y |
3925 | ; ecx - size x, edx - size y |
3924 | add ebx, edx |
3926 | add ebx, edx |
3925 | ;-------------------------------------- |
3927 | ;-------------------------------------- |
3926 | align 4 |
3928 | align 4 |
3927 | .start_y: |
3929 | .start_y: |
3928 | push ecx |
3930 | push ecx |
3929 | ;-------------------------------------- |
3931 | ;-------------------------------------- |
3930 | align 4 |
3932 | align 4 |
3931 | .start_x: |
3933 | .start_x: |
3932 | add eax, ecx |
3934 | add eax, ecx |
3933 | mov ebp, [d_width_calc_area + ebx*4] |
3935 | mov ebp, [d_width_calc_area + ebx*4] |
3934 | add ebp, [_WinMapAddress] |
3936 | add ebp, [_WinMapAddress] |
3935 | movzx ebp, byte[eax+ebp] ; get value for current point |
3937 | movzx ebp, byte[eax+ebp] ; get value for current point |
3936 | cmp ebp, edi |
3938 | cmp ebp, edi |
3937 | jne @f |
3939 | jne @f |
3938 | 3940 | ||
3939 | pop ecx |
3941 | pop ecx |
3940 | jmp .found |
3942 | jmp .found |
3941 | ;-------------------------------------- |
3943 | ;-------------------------------------- |
3942 | align 4 |
3944 | align 4 |
3943 | @@: |
3945 | @@: |
3944 | sub eax, ecx |
3946 | sub eax, ecx |
3945 | 3947 | ||
3946 | dec ecx |
3948 | dec ecx |
3947 | jnz .start_x |
3949 | jnz .start_x |
3948 | 3950 | ||
3949 | pop ecx |
3951 | pop ecx |
3950 | dec ebx |
3952 | dec ebx |
3951 | dec edx |
3953 | dec edx |
3952 | jnz .start_y |
3954 | jnz .start_y |
3953 | ;-------------------------------------- |
3955 | ;-------------------------------------- |
3954 | align 4 |
3956 | align 4 |
3955 | .not_found: |
3957 | .not_found: |
3956 | pop ebp edi eax |
3958 | pop ebp edi eax |
3957 | jmp ricino |
3959 | jmp ricino |
3958 | ;-------------------------------------- |
3960 | ;-------------------------------------- |
3959 | align 4 |
3961 | align 4 |
3960 | .found: |
3962 | .found: |
3961 | pop ebp edi eax |
3963 | pop ebp edi eax |
3962 | 3964 | ||
3963 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3965 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3964 | ;-------------------------------------- |
3966 | ;-------------------------------------- |
3965 | align 4 |
3967 | align 4 |
3966 | ricino: |
3968 | ricino: |
3967 | not_this_task: |
3969 | not_this_task: |
3968 | pop ecx |
3970 | pop ecx |
3969 | 3971 | ||
3970 | cmp ecx, [TASK_COUNT] |
3972 | cmp ecx, [TASK_COUNT] |
3971 | jle newdw2 |
3973 | jle newdw2 |
3972 | 3974 | ||
3973 | pop eax |
3975 | pop eax |
3974 | popad |
3976 | popad |
3975 | ret |
3977 | ret |
3976 | ;----------------------------------------------------------------------------- |
3978 | ;----------------------------------------------------------------------------- |
3977 | align 4 |
3979 | align 4 |
3978 | calculatebackground: ; background |
3980 | calculatebackground: ; background |
3979 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3981 | mov edi, [_WinMapAddress] ; set os to use all pixels |
3980 | mov eax, 0x01010101 |
3982 | mov eax, 0x01010101 |
3981 | mov ecx, [_WinMapSize] |
3983 | mov ecx, [_WinMapSize] |
3982 | shr ecx, 2 |
3984 | shr ecx, 2 |
3983 | rep stosd |
3985 | rep stosd |
3984 | 3986 | ||
3985 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3987 | mov byte[REDRAW_BACKGROUND], 0 ; do not draw background! |
3986 | ret |
3988 | ret |
3987 | ;----------------------------------------------------------------------------- |
3989 | ;----------------------------------------------------------------------------- |
3988 | uglobal |
3990 | uglobal |
3989 | imax dd 0x0 |
3991 | imax dd 0x0 |
3990 | endg |
3992 | endg |
3991 | ;----------------------------------------------------------------------------- |
3993 | ;----------------------------------------------------------------------------- |
3992 | align 4 |
3994 | align 4 |
3993 | delay_ms: ; delay in 1/1000 sec |
3995 | delay_ms: ; delay in 1/1000 sec |
3994 | push eax |
3996 | push eax |
3995 | push ecx |
3997 | push ecx |
3996 | 3998 | ||
3997 | mov ecx, esi |
3999 | mov ecx, esi |
3998 | ; |
4000 | ; |
3999 | imul ecx, 33941 |
4001 | imul ecx, 33941 |
4000 | shr ecx, 9 |
4002 | shr ecx, 9 |
4001 | ; |
4003 | ; |
4002 | 4004 | ||
4003 | in al, 0x61 |
4005 | in al, 0x61 |
4004 | and al, 0x10 |
4006 | and al, 0x10 |
4005 | mov ah, al |
4007 | mov ah, al |
4006 | cld |
4008 | cld |
4007 | ;-------------------------------------- |
4009 | ;-------------------------------------- |
4008 | align 4 |
4010 | align 4 |
4009 | cnt1: |
4011 | cnt1: |
4010 | in al, 0x61 |
4012 | in al, 0x61 |
4011 | and al, 0x10 |
4013 | and al, 0x10 |
4012 | cmp al, ah |
4014 | cmp al, ah |
4013 | jz cnt1 |
4015 | jz cnt1 |
4014 | 4016 | ||
4015 | mov ah, al |
4017 | mov ah, al |
4016 | loop cnt1 |
4018 | loop cnt1 |
4017 | 4019 | ||
4018 | pop ecx |
4020 | pop ecx |
4019 | pop eax |
4021 | pop eax |
4020 | ret |
4022 | ret |
4021 | ;----------------------------------------------------------------------------- |
4023 | ;----------------------------------------------------------------------------- |
4022 | align 4 |
4024 | align 4 |
4023 | set_app_param: |
4025 | set_app_param: |
4024 | mov edi, [TASK_BASE] |
4026 | mov edi, [TASK_BASE] |
4025 | mov eax, ebx |
4027 | mov eax, ebx |
4026 | btr eax, 3 ; move MOUSE_FILTRATION |
4028 | btr eax, 3 ; move MOUSE_FILTRATION |
4027 | mov ebx, [current_slot] ; bit into event_filter |
4029 | mov ebx, [current_slot] ; bit into event_filter |
4028 | setc byte [ebx+APPDATA.event_filter] |
4030 | setc byte [ebx+APPDATA.event_filter] |
4029 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
4031 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
4030 | mov [esp+32], eax ; return old mask value |
4032 | mov [esp+32], eax ; return old mask value |
4031 | ret |
4033 | ret |
4032 | ;----------------------------------------------------------------------------- |
4034 | ;----------------------------------------------------------------------------- |
4033 | 4035 | ||
4034 | ; this is for syscall |
4036 | ; this is for syscall |
4035 | proc delay_hs_unprotected |
4037 | proc delay_hs_unprotected |
4036 | call unprotect_from_terminate |
4038 | call unprotect_from_terminate |
4037 | call delay_hs |
4039 | call delay_hs |
4038 | call protect_from_terminate |
4040 | call protect_from_terminate |
4039 | ret |
4041 | ret |
4040 | endp |
4042 | endp |
4041 | 4043 | ||
4042 | if 1 |
4044 | if 1 |
4043 | align 4 |
4045 | align 4 |
4044 | delay_hs: ; delay in 1/100 secs |
4046 | delay_hs: ; delay in 1/100 secs |
4045 | ; ebx = delay time |
4047 | ; ebx = delay time |
4046 | 4048 | ||
4047 | pushad |
4049 | pushad |
4048 | push ebx |
4050 | push ebx |
4049 | xor esi, esi |
4051 | xor esi, esi |
4050 | mov ecx, MANUAL_DESTROY |
4052 | mov ecx, MANUAL_DESTROY |
4051 | call create_event |
4053 | call create_event |
4052 | test eax, eax |
4054 | test eax, eax |
4053 | jz .done |
4055 | jz .done |
4054 | 4056 | ||
4055 | mov ebx, edx |
4057 | mov ebx, edx |
4056 | mov ecx, [esp] |
4058 | mov ecx, [esp] |
4057 | push edx |
4059 | push edx |
4058 | push eax |
4060 | push eax |
4059 | call wait_event_timeout |
4061 | call wait_event_timeout |
4060 | pop eax |
4062 | pop eax |
4061 | pop ebx |
4063 | pop ebx |
4062 | call destroy_event |
4064 | call destroy_event |
4063 | .done: |
4065 | .done: |
4064 | add esp, 4 |
4066 | add esp, 4 |
4065 | popad |
4067 | popad |
4066 | ret |
4068 | ret |
4067 | 4069 | ||
4068 | else |
4070 | else |
4069 | 4071 | ||
4070 | align 4 |
4072 | align 4 |
4071 | delay_hs: ; delay in 1/100 secs |
4073 | delay_hs: ; delay in 1/100 secs |
4072 | ; ebx = delay time |
4074 | ; ebx = delay time |
4073 | push ecx |
4075 | push ecx |
4074 | push edx |
4076 | push edx |
4075 | 4077 | ||
4076 | mov edx, [timer_ticks] |
4078 | mov edx, [timer_ticks] |
4077 | ;-------------------------------------- |
4079 | ;-------------------------------------- |
4078 | align 4 |
4080 | align 4 |
4079 | newtic: |
4081 | newtic: |
4080 | mov ecx, [timer_ticks] |
4082 | mov ecx, [timer_ticks] |
4081 | sub ecx, edx |
4083 | sub ecx, edx |
4082 | cmp ecx, ebx |
4084 | cmp ecx, ebx |
4083 | jae zerodelay |
4085 | jae zerodelay |
4084 | 4086 | ||
4085 | call change_task |
4087 | call change_task |
4086 | 4088 | ||
4087 | jmp newtic |
4089 | jmp newtic |
4088 | ;-------------------------------------- |
4090 | ;-------------------------------------- |
4089 | align 4 |
4091 | align 4 |
4090 | zerodelay: |
4092 | zerodelay: |
4091 | pop edx |
4093 | pop edx |
4092 | pop ecx |
4094 | pop ecx |
4093 | ret |
4095 | ret |
4094 | end if |
4096 | end if |
4095 | 4097 | ||
4096 | ;----------------------------------------------------------------------------- |
4098 | ;----------------------------------------------------------------------------- |
4097 | align 16 ;very often call this subrutine |
4099 | align 16 ;very often call this subrutine |
4098 | memmove: ; memory move in bytes |
4100 | memmove: ; memory move in bytes |
4099 | ; eax = from |
4101 | ; eax = from |
4100 | ; ebx = to |
4102 | ; ebx = to |
4101 | ; ecx = no of bytes |
4103 | ; ecx = no of bytes |
4102 | test ecx, ecx |
4104 | test ecx, ecx |
4103 | jle .ret |
4105 | jle .ret |
4104 | 4106 | ||
4105 | push esi edi ecx |
4107 | push esi edi ecx |
4106 | 4108 | ||
4107 | mov edi, ebx |
4109 | mov edi, ebx |
4108 | mov esi, eax |
4110 | mov esi, eax |
4109 | 4111 | ||
4110 | test ecx, not 11b |
4112 | test ecx, not 11b |
4111 | jz @f |
4113 | jz @f |
4112 | 4114 | ||
4113 | push ecx |
4115 | push ecx |
4114 | shr ecx, 2 |
4116 | shr ecx, 2 |
4115 | rep movsd |
4117 | rep movsd |
4116 | pop ecx |
4118 | pop ecx |
4117 | and ecx, 11b |
4119 | and ecx, 11b |
4118 | jz .finish |
4120 | jz .finish |
4119 | ;-------------------------------------- |
4121 | ;-------------------------------------- |
4120 | align 4 |
4122 | align 4 |
4121 | @@: |
4123 | @@: |
4122 | rep movsb |
4124 | rep movsb |
4123 | ;-------------------------------------- |
4125 | ;-------------------------------------- |
4124 | align 4 |
4126 | align 4 |
4125 | .finish: |
4127 | .finish: |
4126 | pop ecx edi esi |
4128 | pop ecx edi esi |
4127 | ;-------------------------------------- |
4129 | ;-------------------------------------- |
4128 | align 4 |
4130 | align 4 |
4129 | .ret: |
4131 | .ret: |
4130 | ret |
4132 | ret |
4131 | ;----------------------------------------------------------------------------- |
4133 | ;----------------------------------------------------------------------------- |
4132 | ; |
4134 | ; |
4133 | ;align 4 |
4135 | ;align 4 |
4134 | ; |
4136 | ; |
4135 | ;read_floppy_file: |
4137 | ;read_floppy_file: |
4136 | ; |
4138 | ; |
4137 | ;; as input |
4139 | ;; as input |
4138 | ;; |
4140 | ;; |
4139 | ;; eax pointer to file |
4141 | ;; eax pointer to file |
4140 | ;; ebx file lenght |
4142 | ;; ebx file lenght |
4141 | ;; ecx start 512 byte block number |
4143 | ;; ecx start 512 byte block number |
4142 | ;; edx number of blocks to read |
4144 | ;; edx number of blocks to read |
4143 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4145 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4144 | ;; |
4146 | ;; |
4145 | ;; |
4147 | ;; |
4146 | ;; on return |
4148 | ;; on return |
4147 | ;; |
4149 | ;; |
4148 | ;; eax = 0 command succesful |
4150 | ;; eax = 0 command succesful |
4149 | ;; 1 no fd base and/or partition defined |
4151 | ;; 1 no fd base and/or partition defined |
4150 | ;; 2 yet unsupported FS |
4152 | ;; 2 yet unsupported FS |
4151 | ;; 3 unknown FS |
4153 | ;; 3 unknown FS |
4152 | ;; 4 partition not defined at hd |
4154 | ;; 4 partition not defined at hd |
4153 | ;; 5 file not found |
4155 | ;; 5 file not found |
4154 | ;; ebx = size of file |
4156 | ;; ebx = size of file |
4155 | ; |
4157 | ; |
4156 | ; mov edi,[TASK_BASE] |
4158 | ; mov edi,[TASK_BASE] |
4157 | ; add edi,0x10 |
4159 | ; add edi,0x10 |
4158 | ; add esi,[edi] |
4160 | ; add esi,[edi] |
4159 | ; add eax,[edi] |
4161 | ; add eax,[edi] |
4160 | ; |
4162 | ; |
4161 | ; pushad |
4163 | ; pushad |
4162 | ; mov edi,esi |
4164 | ; mov edi,esi |
4163 | ; add edi,1024 |
4165 | ; add edi,1024 |
4164 | ; mov esi,0x100000+19*512 |
4166 | ; mov esi,0x100000+19*512 |
4165 | ; sub ecx,1 |
4167 | ; sub ecx,1 |
4166 | ; shl ecx,9 |
4168 | ; shl ecx,9 |
4167 | ; add esi,ecx |
4169 | ; add esi,ecx |
4168 | ; shl edx,9 |
4170 | ; shl edx,9 |
4169 | ; mov ecx,edx |
4171 | ; mov ecx,edx |
4170 | ; cld |
4172 | ; cld |
4171 | ; rep movsb |
4173 | ; rep movsb |
4172 | ; popad |
4174 | ; popad |
4173 | ; |
4175 | ; |
4174 | ; mov [esp+36],eax |
4176 | ; mov [esp+36],eax |
4175 | ; mov [esp+24],ebx |
4177 | ; mov [esp+24],ebx |
4176 | ; ret |
4178 | ; ret |
4177 | 4179 | ||
4178 | 4180 | ||
4179 | 4181 | ||
4180 | align 4 |
4182 | align 4 |
4181 | set_io_access_rights: |
4183 | set_io_access_rights: |
4182 | push edi eax |
4184 | push edi eax |
4183 | mov edi, tss._io_map_0 |
4185 | mov edi, tss._io_map_0 |
4184 | ; mov ecx,eax |
4186 | ; mov ecx,eax |
4185 | ; and ecx,7 ; offset in byte |
4187 | ; and ecx,7 ; offset in byte |
4186 | ; shr eax,3 ; number of byte |
4188 | ; shr eax,3 ; number of byte |
4187 | ; add edi,eax |
4189 | ; add edi,eax |
4188 | ; mov ebx,1 |
4190 | ; mov ebx,1 |
4189 | ; shl ebx,cl |
4191 | ; shl ebx,cl |
4190 | test ebp, ebp |
4192 | test ebp, ebp |
4191 | ; cmp ebp,0 ; enable access - ebp = 0 |
4193 | ; cmp ebp,0 ; enable access - ebp = 0 |
4192 | jnz .siar1 |
4194 | jnz .siar1 |
4193 | ; not ebx |
4195 | ; not ebx |
4194 | ; and [edi],byte bl |
4196 | ; and [edi],byte bl |
4195 | btr [edi], eax |
4197 | btr [edi], eax |
4196 | pop eax edi |
4198 | pop eax edi |
4197 | ret |
4199 | ret |
4198 | .siar1: |
4200 | .siar1: |
4199 | bts [edi], eax |
4201 | bts [edi], eax |
4200 | ; or [edi],byte bl ; disable access - ebp = 1 |
4202 | ; or [edi],byte bl ; disable access - ebp = 1 |
4201 | pop eax edi |
4203 | pop eax edi |
4202 | ret |
4204 | ret |
4203 | ;reserve/free group of ports |
4205 | ;reserve/free group of ports |
4204 | ; * eax = 46 - number function |
4206 | ; * eax = 46 - number function |
4205 | ; * ebx = 0 - reserve, 1 - free |
4207 | ; * ebx = 0 - reserve, 1 - free |
4206 | ; * ecx = number start arrea of ports |
4208 | ; * ecx = number start arrea of ports |
4207 | ; * edx = number end arrea of ports (include last number of port) |
4209 | ; * edx = number end arrea of ports (include last number of port) |
4208 | ;Return value: |
4210 | ;Return value: |
4209 | ; * eax = 0 - succesful |
4211 | ; * eax = 0 - succesful |
4210 | ; * eax = 1 - error |
4212 | ; * eax = 1 - error |
4211 | ; * The system has reserve this ports: |
4213 | ; * The system has reserve this ports: |
4212 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4214 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4213 | ;destroys eax,ebx, ebp |
4215 | ;destroys eax,ebx, ebp |
4214 | r_f_port_area: |
4216 | r_f_port_area: |
4215 | 4217 | ||
4216 | test ebx, ebx |
4218 | test ebx, ebx |
4217 | jnz free_port_area |
4219 | jnz free_port_area |
4218 | ; je r_port_area |
4220 | ; je r_port_area |
4219 | ; jmp free_port_area |
4221 | ; jmp free_port_area |
4220 | 4222 | ||
4221 | ; r_port_area: |
4223 | ; r_port_area: |
4222 | 4224 | ||
4223 | ; pushad |
4225 | ; pushad |
4224 | 4226 | ||
4225 | cmp ecx, edx ; beginning > end ? |
4227 | cmp ecx, edx ; beginning > end ? |
4226 | ja rpal1 |
4228 | ja rpal1 |
4227 | cmp edx, 65536 |
4229 | cmp edx, 65536 |
4228 | jae rpal1 |
4230 | jae rpal1 |
4229 | mov eax, [RESERVED_PORTS] |
4231 | mov eax, [RESERVED_PORTS] |
4230 | test eax, eax ; no reserved areas ? |
4232 | test eax, eax ; no reserved areas ? |
4231 | je rpal2 |
4233 | je rpal2 |
4232 | cmp eax, 255 ; max reserved |
4234 | cmp eax, 255 ; max reserved |
4233 | jae rpal1 |
4235 | jae rpal1 |
4234 | rpal3: |
4236 | rpal3: |
4235 | mov ebx, eax |
4237 | mov ebx, eax |
4236 | shl ebx, 4 |
4238 | shl ebx, 4 |
4237 | add ebx, RESERVED_PORTS |
4239 | add ebx, RESERVED_PORTS |
4238 | cmp ecx, [ebx+8] |
4240 | cmp ecx, [ebx+8] |
4239 | ja rpal4 |
4241 | ja rpal4 |
4240 | cmp edx, [ebx+4] |
4242 | cmp edx, [ebx+4] |
4241 | jae rpal1 |
4243 | jae rpal1 |
4242 | ; jb rpal4 |
4244 | ; jb rpal4 |
4243 | ; jmp rpal1 |
4245 | ; jmp rpal1 |
4244 | rpal4: |
4246 | rpal4: |
4245 | dec eax |
4247 | dec eax |
4246 | jnz rpal3 |
4248 | jnz rpal3 |
4247 | jmp rpal2 |
4249 | jmp rpal2 |
4248 | rpal1: |
4250 | rpal1: |
4249 | ; popad |
4251 | ; popad |
4250 | ; mov eax,1 |
4252 | ; mov eax,1 |
4251 | xor eax, eax |
4253 | xor eax, eax |
4252 | inc eax |
4254 | inc eax |
4253 | ret |
4255 | ret |
4254 | rpal2: |
4256 | rpal2: |
4255 | ; popad |
4257 | ; popad |
4256 | ; enable port access at port IO map |
4258 | ; enable port access at port IO map |
4257 | cli |
4259 | cli |
4258 | pushad ; start enable io map |
4260 | pushad ; start enable io map |
4259 | 4261 | ||
4260 | cmp edx, 65536;16384 |
4262 | cmp edx, 65536;16384 |
4261 | jae no_unmask_io; jge |
4263 | jae no_unmask_io; jge |
4262 | mov eax, ecx |
4264 | mov eax, ecx |
4263 | ; push ebp |
4265 | ; push ebp |
4264 | xor ebp, ebp ; enable - eax = port |
4266 | xor ebp, ebp ; enable - eax = port |
4265 | new_port_access: |
4267 | new_port_access: |
4266 | ; pushad |
4268 | ; pushad |
4267 | call set_io_access_rights |
4269 | call set_io_access_rights |
4268 | ; popad |
4270 | ; popad |
4269 | inc eax |
4271 | inc eax |
4270 | cmp eax, edx |
4272 | cmp eax, edx |
4271 | jbe new_port_access |
4273 | jbe new_port_access |
4272 | ; pop ebp |
4274 | ; pop ebp |
4273 | no_unmask_io: |
4275 | no_unmask_io: |
4274 | popad ; end enable io map |
4276 | popad ; end enable io map |
4275 | sti |
4277 | sti |
4276 | 4278 | ||
4277 | mov eax, [RESERVED_PORTS] |
4279 | mov eax, [RESERVED_PORTS] |
4278 | add eax, 1 |
4280 | add eax, 1 |
4279 | mov [RESERVED_PORTS], eax |
4281 | mov [RESERVED_PORTS], eax |
4280 | shl eax, 4 |
4282 | shl eax, 4 |
4281 | add eax, RESERVED_PORTS |
4283 | add eax, RESERVED_PORTS |
4282 | mov ebx, [TASK_BASE] |
4284 | mov ebx, [TASK_BASE] |
4283 | mov ebx, [ebx+TASKDATA.pid] |
4285 | mov ebx, [ebx+TASKDATA.pid] |
4284 | mov [eax], ebx |
4286 | mov [eax], ebx |
4285 | mov [eax+4], ecx |
4287 | mov [eax+4], ecx |
4286 | mov [eax+8], edx |
4288 | mov [eax+8], edx |
4287 | 4289 | ||
4288 | xor eax, eax |
4290 | xor eax, eax |
4289 | ret |
4291 | ret |
4290 | 4292 | ||
4291 | free_port_area: |
4293 | free_port_area: |
4292 | 4294 | ||
4293 | ; pushad |
4295 | ; pushad |
4294 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4296 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4295 | test eax, eax |
4297 | test eax, eax |
4296 | jz frpal2 |
4298 | jz frpal2 |
4297 | mov ebx, [TASK_BASE] |
4299 | mov ebx, [TASK_BASE] |
4298 | mov ebx, [ebx+TASKDATA.pid] |
4300 | mov ebx, [ebx+TASKDATA.pid] |
4299 | frpal3: |
4301 | frpal3: |
4300 | mov edi, eax |
4302 | mov edi, eax |
4301 | shl edi, 4 |
4303 | shl edi, 4 |
4302 | add edi, RESERVED_PORTS |
4304 | add edi, RESERVED_PORTS |
4303 | cmp ebx, [edi] |
4305 | cmp ebx, [edi] |
4304 | jne frpal4 |
4306 | jne frpal4 |
4305 | cmp ecx, [edi+4] |
4307 | cmp ecx, [edi+4] |
4306 | jne frpal4 |
4308 | jne frpal4 |
4307 | cmp edx, [edi+8] |
4309 | cmp edx, [edi+8] |
4308 | jne frpal4 |
4310 | jne frpal4 |
4309 | jmp frpal1 |
4311 | jmp frpal1 |
4310 | frpal4: |
4312 | frpal4: |
4311 | dec eax |
4313 | dec eax |
4312 | jnz frpal3 |
4314 | jnz frpal3 |
4313 | frpal2: |
4315 | frpal2: |
4314 | ; popad |
4316 | ; popad |
4315 | inc eax |
4317 | inc eax |
4316 | ret |
4318 | ret |
4317 | frpal1: |
4319 | frpal1: |
4318 | push ecx |
4320 | push ecx |
4319 | mov ecx, 256 |
4321 | mov ecx, 256 |
4320 | sub ecx, eax |
4322 | sub ecx, eax |
4321 | shl ecx, 4 |
4323 | shl ecx, 4 |
4322 | mov esi, edi |
4324 | mov esi, edi |
4323 | add esi, 16 |
4325 | add esi, 16 |
4324 | cld |
4326 | cld |
4325 | rep movsb |
4327 | rep movsb |
4326 | 4328 | ||
4327 | dec dword [RESERVED_PORTS] |
4329 | dec dword [RESERVED_PORTS] |
4328 | ;popad |
4330 | ;popad |
4329 | ;disable port access at port IO map |
4331 | ;disable port access at port IO map |
4330 | 4332 | ||
4331 | ; pushad ; start disable io map |
4333 | ; pushad ; start disable io map |
4332 | pop eax ;start port |
4334 | pop eax ;start port |
4333 | cmp edx, 65536;16384 |
4335 | cmp edx, 65536;16384 |
4334 | jge no_mask_io |
4336 | jge no_mask_io |
4335 | 4337 | ||
4336 | ; mov eax,ecx |
4338 | ; mov eax,ecx |
4337 | xor ebp, ebp |
4339 | xor ebp, ebp |
4338 | inc ebp |
4340 | inc ebp |
4339 | new_port_access_disable: |
4341 | new_port_access_disable: |
4340 | ; pushad |
4342 | ; pushad |
4341 | ; mov ebp,1 ; disable - eax = port |
4343 | ; mov ebp,1 ; disable - eax = port |
4342 | call set_io_access_rights |
4344 | call set_io_access_rights |
4343 | ; popad |
4345 | ; popad |
4344 | inc eax |
4346 | inc eax |
4345 | cmp eax, edx |
4347 | cmp eax, edx |
4346 | jbe new_port_access_disable |
4348 | jbe new_port_access_disable |
4347 | no_mask_io: |
4349 | no_mask_io: |
4348 | ; popad ; end disable io map |
4350 | ; popad ; end disable io map |
4349 | xor eax, eax |
4351 | xor eax, eax |
4350 | ret |
4352 | ret |
4351 | ;----------------------------------------------------------------------------- |
4353 | ;----------------------------------------------------------------------------- |
4352 | align 4 |
4354 | align 4 |
4353 | drawbackground: |
4355 | drawbackground: |
4354 | dbrv20: |
4356 | dbrv20: |
4355 | cmp [BgrDrawMode], dword 1 |
4357 | cmp [BgrDrawMode], dword 1 |
4356 | jne bgrstr |
4358 | jne bgrstr |
4357 | call vesa20_drawbackground_tiled |
4359 | call vesa20_drawbackground_tiled |
4358 | ; call [draw_pointer] |
4360 | ; call [draw_pointer] |
4359 | call __sys_draw_pointer |
4361 | call __sys_draw_pointer |
4360 | ret |
4362 | ret |
4361 | ;-------------------------------------- |
4363 | ;-------------------------------------- |
4362 | align 4 |
4364 | align 4 |
4363 | bgrstr: |
4365 | bgrstr: |
4364 | call vesa20_drawbackground_stretch |
4366 | call vesa20_drawbackground_stretch |
4365 | ; call [draw_pointer] |
4367 | ; call [draw_pointer] |
4366 | call __sys_draw_pointer |
4368 | call __sys_draw_pointer |
4367 | ret |
4369 | ret |
4368 | ;----------------------------------------------------------------------------- |
4370 | ;----------------------------------------------------------------------------- |
4369 | align 4 |
4371 | align 4 |
4370 | syscall_putimage: ; PutImage |
4372 | syscall_putimage: ; PutImage |
4371 | sys_putimage: |
4373 | sys_putimage: |
4372 | test ecx, 0x80008000 |
4374 | test ecx, 0x80008000 |
4373 | jnz .exit |
4375 | jnz .exit |
4374 | test ecx, 0x0000FFFF |
4376 | test ecx, 0x0000FFFF |
4375 | jz .exit |
4377 | jz .exit |
4376 | test ecx, 0xFFFF0000 |
4378 | test ecx, 0xFFFF0000 |
4377 | jnz @f |
4379 | jnz @f |
4378 | ;-------------------------------------- |
4380 | ;-------------------------------------- |
4379 | align 4 |
4381 | align 4 |
4380 | .exit: |
4382 | .exit: |
4381 | ret |
4383 | ret |
4382 | ;-------------------------------------- |
4384 | ;-------------------------------------- |
4383 | align 4 |
4385 | align 4 |
4384 | @@: |
4386 | @@: |
4385 | mov edi, [current_slot] |
4387 | mov edi, [current_slot] |
4386 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4388 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4387 | rol edx, 16 |
4389 | rol edx, 16 |
4388 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4390 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4389 | rol edx, 16 |
4391 | rol edx, 16 |
4390 | ;-------------------------------------- |
4392 | ;-------------------------------------- |
4391 | align 4 |
4393 | align 4 |
4392 | .forced: |
4394 | .forced: |
4393 | push ebp esi 0 |
4395 | push ebp esi 0 |
4394 | mov ebp, putimage_get24bpp |
4396 | mov ebp, putimage_get24bpp |
4395 | mov esi, putimage_init24bpp |
4397 | mov esi, putimage_init24bpp |
4396 | ;-------------------------------------- |
4398 | ;-------------------------------------- |
4397 | align 4 |
4399 | align 4 |
4398 | sys_putimage_bpp: |
4400 | sys_putimage_bpp: |
4399 | call vesa20_putimage |
4401 | call vesa20_putimage |
4400 | pop ebp esi ebp |
4402 | pop ebp esi ebp |
4401 | ret |
4403 | ret |
4402 | ; jmp [draw_pointer] |
4404 | ; jmp [draw_pointer] |
4403 | ;----------------------------------------------------------------------------- |
4405 | ;----------------------------------------------------------------------------- |
4404 | align 4 |
4406 | align 4 |
4405 | sys_putimage_palette: |
4407 | sys_putimage_palette: |
4406 | ; ebx = pointer to image |
4408 | ; ebx = pointer to image |
4407 | ; ecx = [xsize]*65536 + [ysize] |
4409 | ; ecx = [xsize]*65536 + [ysize] |
4408 | ; edx = [xstart]*65536 + [ystart] |
4410 | ; edx = [xstart]*65536 + [ystart] |
4409 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4411 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4410 | ; edi = pointer to palette |
4412 | ; edi = pointer to palette |
4411 | ; ebp = row delta |
4413 | ; ebp = row delta |
4412 | mov eax, [CURRENT_TASK] |
4414 | mov eax, [CURRENT_TASK] |
4413 | shl eax, 8 |
4415 | shl eax, 8 |
4414 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4416 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4415 | rol edx, 16 |
4417 | rol edx, 16 |
4416 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4418 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4417 | rol edx, 16 |
4419 | rol edx, 16 |
4418 | ;-------------------------------------- |
4420 | ;-------------------------------------- |
4419 | align 4 |
4421 | align 4 |
4420 | .forced: |
4422 | .forced: |
4421 | cmp esi, 1 |
4423 | cmp esi, 1 |
4422 | jnz @f |
4424 | jnz @f |
4423 | push edi |
4425 | push edi |
4424 | mov eax, [edi+4] |
4426 | mov eax, [edi+4] |
4425 | sub eax, [edi] |
4427 | sub eax, [edi] |
4426 | push eax |
4428 | push eax |
4427 | push dword [edi] |
4429 | push dword [edi] |
4428 | push 0ffffff80h |
4430 | push 0ffffff80h |
4429 | mov edi, esp |
4431 | mov edi, esp |
4430 | call put_mono_image |
4432 | call put_mono_image |
4431 | add esp, 12 |
4433 | add esp, 12 |
4432 | pop edi |
4434 | pop edi |
4433 | ret |
4435 | ret |
4434 | ;-------------------------------------- |
4436 | ;-------------------------------------- |
4435 | align 4 |
4437 | align 4 |
4436 | @@: |
4438 | @@: |
4437 | cmp esi, 2 |
4439 | cmp esi, 2 |
4438 | jnz @f |
4440 | jnz @f |
4439 | push edi |
4441 | push edi |
4440 | push 0ffffff80h |
4442 | push 0ffffff80h |
4441 | mov edi, esp |
4443 | mov edi, esp |
4442 | call put_2bit_image |
4444 | call put_2bit_image |
4443 | pop eax |
4445 | pop eax |
4444 | pop edi |
4446 | pop edi |
4445 | ret |
4447 | ret |
4446 | ;-------------------------------------- |
4448 | ;-------------------------------------- |
4447 | align 4 |
4449 | align 4 |
4448 | @@: |
4450 | @@: |
4449 | cmp esi, 4 |
4451 | cmp esi, 4 |
4450 | jnz @f |
4452 | jnz @f |
4451 | push edi |
4453 | push edi |
4452 | push 0ffffff80h |
4454 | push 0ffffff80h |
4453 | mov edi, esp |
4455 | mov edi, esp |
4454 | call put_4bit_image |
4456 | call put_4bit_image |
4455 | pop eax |
4457 | pop eax |
4456 | pop edi |
4458 | pop edi |
4457 | ret |
4459 | ret |
4458 | ;-------------------------------------- |
4460 | ;-------------------------------------- |
4459 | align 4 |
4461 | align 4 |
4460 | @@: |
4462 | @@: |
4461 | push ebp esi ebp |
4463 | push ebp esi ebp |
4462 | cmp esi, 8 |
4464 | cmp esi, 8 |
4463 | jnz @f |
4465 | jnz @f |
4464 | mov ebp, putimage_get8bpp |
4466 | mov ebp, putimage_get8bpp |
4465 | mov esi, putimage_init8bpp |
4467 | mov esi, putimage_init8bpp |
4466 | jmp sys_putimage_bpp |
4468 | jmp sys_putimage_bpp |
4467 | ;-------------------------------------- |
4469 | ;-------------------------------------- |
4468 | align 4 |
4470 | align 4 |
4469 | @@: |
4471 | @@: |
4470 | cmp esi, 9 |
4472 | cmp esi, 9 |
4471 | jnz @f |
4473 | jnz @f |
4472 | mov ebp, putimage_get9bpp |
4474 | mov ebp, putimage_get9bpp |
4473 | mov esi, putimage_init9bpp |
4475 | mov esi, putimage_init9bpp |
4474 | jmp sys_putimage_bpp |
4476 | jmp sys_putimage_bpp |
4475 | ;-------------------------------------- |
4477 | ;-------------------------------------- |
4476 | align 4 |
4478 | align 4 |
4477 | @@: |
4479 | @@: |
4478 | cmp esi, 15 |
4480 | cmp esi, 15 |
4479 | jnz @f |
4481 | jnz @f |
4480 | mov ebp, putimage_get15bpp |
4482 | mov ebp, putimage_get15bpp |
4481 | mov esi, putimage_init15bpp |
4483 | mov esi, putimage_init15bpp |
4482 | jmp sys_putimage_bpp |
4484 | jmp sys_putimage_bpp |
4483 | ;-------------------------------------- |
4485 | ;-------------------------------------- |
4484 | align 4 |
4486 | align 4 |
4485 | @@: |
4487 | @@: |
4486 | cmp esi, 16 |
4488 | cmp esi, 16 |
4487 | jnz @f |
4489 | jnz @f |
4488 | mov ebp, putimage_get16bpp |
4490 | mov ebp, putimage_get16bpp |
4489 | mov esi, putimage_init16bpp |
4491 | mov esi, putimage_init16bpp |
4490 | jmp sys_putimage_bpp |
4492 | jmp sys_putimage_bpp |
4491 | ;-------------------------------------- |
4493 | ;-------------------------------------- |
4492 | align 4 |
4494 | align 4 |
4493 | @@: |
4495 | @@: |
4494 | cmp esi, 24 |
4496 | cmp esi, 24 |
4495 | jnz @f |
4497 | jnz @f |
4496 | mov ebp, putimage_get24bpp |
4498 | mov ebp, putimage_get24bpp |
4497 | mov esi, putimage_init24bpp |
4499 | mov esi, putimage_init24bpp |
4498 | jmp sys_putimage_bpp |
4500 | jmp sys_putimage_bpp |
4499 | ;-------------------------------------- |
4501 | ;-------------------------------------- |
4500 | align 4 |
4502 | align 4 |
4501 | @@: |
4503 | @@: |
4502 | cmp esi, 32 |
4504 | cmp esi, 32 |
4503 | jnz @f |
4505 | jnz @f |
4504 | mov ebp, putimage_get32bpp |
4506 | mov ebp, putimage_get32bpp |
4505 | mov esi, putimage_init32bpp |
4507 | mov esi, putimage_init32bpp |
4506 | jmp sys_putimage_bpp |
4508 | jmp sys_putimage_bpp |
4507 | ;-------------------------------------- |
4509 | ;-------------------------------------- |
4508 | align 4 |
4510 | align 4 |
4509 | @@: |
4511 | @@: |
4510 | pop ebp esi ebp |
4512 | pop ebp esi ebp |
4511 | ret |
4513 | ret |
4512 | ;----------------------------------------------------------------------------- |
4514 | ;----------------------------------------------------------------------------- |
4513 | align 4 |
4515 | align 4 |
4514 | put_mono_image: |
4516 | put_mono_image: |
4515 | push ebp esi ebp |
4517 | push ebp esi ebp |
4516 | mov ebp, putimage_get1bpp |
4518 | mov ebp, putimage_get1bpp |
4517 | mov esi, putimage_init1bpp |
4519 | mov esi, putimage_init1bpp |
4518 | jmp sys_putimage_bpp |
4520 | jmp sys_putimage_bpp |
4519 | ;----------------------------------------------------------------------------- |
4521 | ;----------------------------------------------------------------------------- |
4520 | align 4 |
4522 | align 4 |
4521 | put_2bit_image: |
4523 | put_2bit_image: |
4522 | push ebp esi ebp |
4524 | push ebp esi ebp |
4523 | mov ebp, putimage_get2bpp |
4525 | mov ebp, putimage_get2bpp |
4524 | mov esi, putimage_init2bpp |
4526 | mov esi, putimage_init2bpp |
4525 | jmp sys_putimage_bpp |
4527 | jmp sys_putimage_bpp |
4526 | ;----------------------------------------------------------------------------- |
4528 | ;----------------------------------------------------------------------------- |
4527 | align 4 |
4529 | align 4 |
4528 | put_4bit_image: |
4530 | put_4bit_image: |
4529 | push ebp esi ebp |
4531 | push ebp esi ebp |
4530 | mov ebp, putimage_get4bpp |
4532 | mov ebp, putimage_get4bpp |
4531 | mov esi, putimage_init4bpp |
4533 | mov esi, putimage_init4bpp |
4532 | jmp sys_putimage_bpp |
4534 | jmp sys_putimage_bpp |
4533 | ;----------------------------------------------------------------------------- |
4535 | ;----------------------------------------------------------------------------- |
4534 | align 4 |
4536 | align 4 |
4535 | putimage_init24bpp: |
4537 | putimage_init24bpp: |
4536 | lea eax, [eax*3] |
4538 | lea eax, [eax*3] |
4537 | putimage_init8bpp: |
4539 | putimage_init8bpp: |
4538 | putimage_init9bpp: |
4540 | putimage_init9bpp: |
4539 | ret |
4541 | ret |
4540 | ;----------------------------------------------------------------------------- |
4542 | ;----------------------------------------------------------------------------- |
4541 | align 16 |
4543 | align 16 |
4542 | putimage_get24bpp: |
4544 | putimage_get24bpp: |
4543 | movzx eax, byte [esi+2] |
4545 | movzx eax, byte [esi+2] |
4544 | shl eax, 16 |
4546 | shl eax, 16 |
4545 | mov ax, [esi] |
4547 | mov ax, [esi] |
4546 | add esi, 3 |
4548 | add esi, 3 |
4547 | ret 4 |
4549 | ret 4 |
4548 | ;----------------------------------------------------------------------------- |
4550 | ;----------------------------------------------------------------------------- |
4549 | align 16 |
4551 | align 16 |
4550 | putimage_get8bpp: |
4552 | putimage_get8bpp: |
4551 | movzx eax, byte [esi] |
4553 | movzx eax, byte [esi] |
4552 | push edx |
4554 | push edx |
4553 | mov edx, [esp+8] |
4555 | mov edx, [esp+8] |
4554 | mov eax, [edx+eax*4] |
4556 | mov eax, [edx+eax*4] |
4555 | pop edx |
4557 | pop edx |
4556 | inc esi |
4558 | inc esi |
4557 | ret 4 |
4559 | ret 4 |
4558 | ;----------------------------------------------------------------------------- |
4560 | ;----------------------------------------------------------------------------- |
4559 | align 16 |
4561 | align 16 |
4560 | putimage_get9bpp: |
4562 | putimage_get9bpp: |
4561 | lodsb |
4563 | lodsb |
4562 | mov ah, al |
4564 | mov ah, al |
4563 | shl eax, 8 |
4565 | shl eax, 8 |
4564 | mov al, ah |
4566 | mov al, ah |
4565 | ret 4 |
4567 | ret 4 |
4566 | ;----------------------------------------------------------------------------- |
4568 | ;----------------------------------------------------------------------------- |
4567 | align 4 |
4569 | align 4 |
4568 | putimage_init1bpp: |
4570 | putimage_init1bpp: |
4569 | add eax, ecx |
4571 | add eax, ecx |
4570 | push ecx |
4572 | push ecx |
4571 | add eax, 7 |
4573 | add eax, 7 |
4572 | add ecx, 7 |
4574 | add ecx, 7 |
4573 | shr eax, 3 |
4575 | shr eax, 3 |
4574 | shr ecx, 3 |
4576 | shr ecx, 3 |
4575 | sub eax, ecx |
4577 | sub eax, ecx |
4576 | pop ecx |
4578 | pop ecx |
4577 | ret |
4579 | ret |
4578 | ;----------------------------------------------------------------------------- |
4580 | ;----------------------------------------------------------------------------- |
4579 | align 16 |
4581 | align 16 |
4580 | putimage_get1bpp: |
4582 | putimage_get1bpp: |
4581 | push edx |
4583 | push edx |
4582 | mov edx, [esp+8] |
4584 | mov edx, [esp+8] |
4583 | mov al, [edx] |
4585 | mov al, [edx] |
4584 | add al, al |
4586 | add al, al |
4585 | jnz @f |
4587 | jnz @f |
4586 | lodsb |
4588 | lodsb |
4587 | adc al, al |
4589 | adc al, al |
4588 | @@: |
4590 | @@: |
4589 | mov [edx], al |
4591 | mov [edx], al |
4590 | sbb eax, eax |
4592 | sbb eax, eax |
4591 | and eax, [edx+8] |
4593 | and eax, [edx+8] |
4592 | add eax, [edx+4] |
4594 | add eax, [edx+4] |
4593 | pop edx |
4595 | pop edx |
4594 | ret 4 |
4596 | ret 4 |
4595 | ;----------------------------------------------------------------------------- |
4597 | ;----------------------------------------------------------------------------- |
4596 | align 4 |
4598 | align 4 |
4597 | putimage_init2bpp: |
4599 | putimage_init2bpp: |
4598 | add eax, ecx |
4600 | add eax, ecx |
4599 | push ecx |
4601 | push ecx |
4600 | add ecx, 3 |
4602 | add ecx, 3 |
4601 | add eax, 3 |
4603 | add eax, 3 |
4602 | shr ecx, 2 |
4604 | shr ecx, 2 |
4603 | shr eax, 2 |
4605 | shr eax, 2 |
4604 | sub eax, ecx |
4606 | sub eax, ecx |
4605 | pop ecx |
4607 | pop ecx |
4606 | ret |
4608 | ret |
4607 | ;----------------------------------------------------------------------------- |
4609 | ;----------------------------------------------------------------------------- |
4608 | align 16 |
4610 | align 16 |
4609 | putimage_get2bpp: |
4611 | putimage_get2bpp: |
4610 | push edx |
4612 | push edx |
4611 | mov edx, [esp+8] |
4613 | mov edx, [esp+8] |
4612 | mov al, [edx] |
4614 | mov al, [edx] |
4613 | mov ah, al |
4615 | mov ah, al |
4614 | shr al, 6 |
4616 | shr al, 6 |
4615 | shl ah, 2 |
4617 | shl ah, 2 |
4616 | jnz .nonewbyte |
4618 | jnz .nonewbyte |
4617 | lodsb |
4619 | lodsb |
4618 | mov ah, al |
4620 | mov ah, al |
4619 | shr al, 6 |
4621 | shr al, 6 |
4620 | shl ah, 2 |
4622 | shl ah, 2 |
4621 | add ah, 1 |
4623 | add ah, 1 |
4622 | .nonewbyte: |
4624 | .nonewbyte: |
4623 | mov [edx], ah |
4625 | mov [edx], ah |
4624 | mov edx, [edx+4] |
4626 | mov edx, [edx+4] |
4625 | movzx eax, al |
4627 | movzx eax, al |
4626 | mov eax, [edx+eax*4] |
4628 | mov eax, [edx+eax*4] |
4627 | pop edx |
4629 | pop edx |
4628 | ret 4 |
4630 | ret 4 |
4629 | ;----------------------------------------------------------------------------- |
4631 | ;----------------------------------------------------------------------------- |
4630 | align 4 |
4632 | align 4 |
4631 | putimage_init4bpp: |
4633 | putimage_init4bpp: |
4632 | add eax, ecx |
4634 | add eax, ecx |
4633 | push ecx |
4635 | push ecx |
4634 | add ecx, 1 |
4636 | add ecx, 1 |
4635 | add eax, 1 |
4637 | add eax, 1 |
4636 | shr ecx, 1 |
4638 | shr ecx, 1 |
4637 | shr eax, 1 |
4639 | shr eax, 1 |
4638 | sub eax, ecx |
4640 | sub eax, ecx |
4639 | pop ecx |
4641 | pop ecx |
4640 | ret |
4642 | ret |
4641 | ;----------------------------------------------------------------------------- |
4643 | ;----------------------------------------------------------------------------- |
4642 | align 16 |
4644 | align 16 |
4643 | putimage_get4bpp: |
4645 | putimage_get4bpp: |
4644 | push edx |
4646 | push edx |
4645 | mov edx, [esp+8] |
4647 | mov edx, [esp+8] |
4646 | add byte [edx], 80h |
4648 | add byte [edx], 80h |
4647 | jc @f |
4649 | jc @f |
4648 | movzx eax, byte [edx+1] |
4650 | movzx eax, byte [edx+1] |
4649 | mov edx, [edx+4] |
4651 | mov edx, [edx+4] |
4650 | and eax, 0x0F |
4652 | and eax, 0x0F |
4651 | mov eax, [edx+eax*4] |
4653 | mov eax, [edx+eax*4] |
4652 | pop edx |
4654 | pop edx |
4653 | ret 4 |
4655 | ret 4 |
4654 | @@: |
4656 | @@: |
4655 | movzx eax, byte [esi] |
4657 | movzx eax, byte [esi] |
4656 | add esi, 1 |
4658 | add esi, 1 |
4657 | mov [edx+1], al |
4659 | mov [edx+1], al |
4658 | shr eax, 4 |
4660 | shr eax, 4 |
4659 | mov edx, [edx+4] |
4661 | mov edx, [edx+4] |
4660 | mov eax, [edx+eax*4] |
4662 | mov eax, [edx+eax*4] |
4661 | pop edx |
4663 | pop edx |
4662 | ret 4 |
4664 | ret 4 |
4663 | ;----------------------------------------------------------------------------- |
4665 | ;----------------------------------------------------------------------------- |
4664 | align 4 |
4666 | align 4 |
4665 | putimage_init32bpp: |
4667 | putimage_init32bpp: |
4666 | shl eax, 2 |
4668 | shl eax, 2 |
4667 | ret |
4669 | ret |
4668 | ;----------------------------------------------------------------------------- |
4670 | ;----------------------------------------------------------------------------- |
4669 | align 16 |
4671 | align 16 |
4670 | putimage_get32bpp: |
4672 | putimage_get32bpp: |
4671 | lodsd |
4673 | lodsd |
4672 | ret 4 |
4674 | ret 4 |
4673 | ;----------------------------------------------------------------------------- |
4675 | ;----------------------------------------------------------------------------- |
4674 | align 4 |
4676 | align 4 |
4675 | putimage_init15bpp: |
4677 | putimage_init15bpp: |
4676 | putimage_init16bpp: |
4678 | putimage_init16bpp: |
4677 | add eax, eax |
4679 | add eax, eax |
4678 | ret |
4680 | ret |
4679 | ;----------------------------------------------------------------------------- |
4681 | ;----------------------------------------------------------------------------- |
4680 | align 16 |
4682 | align 16 |
4681 | putimage_get15bpp: |
4683 | putimage_get15bpp: |
4682 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4684 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4683 | push ecx edx |
4685 | push ecx edx |
4684 | movzx eax, word [esi] |
4686 | movzx eax, word [esi] |
4685 | add esi, 2 |
4687 | add esi, 2 |
4686 | mov ecx, eax |
4688 | mov ecx, eax |
4687 | mov edx, eax |
4689 | mov edx, eax |
4688 | and eax, 0x1F |
4690 | and eax, 0x1F |
4689 | and ecx, 0x1F shl 5 |
4691 | and ecx, 0x1F shl 5 |
4690 | and edx, 0x1F shl 10 |
4692 | and edx, 0x1F shl 10 |
4691 | shl eax, 3 |
4693 | shl eax, 3 |
4692 | shl ecx, 6 |
4694 | shl ecx, 6 |
4693 | shl edx, 9 |
4695 | shl edx, 9 |
4694 | or eax, ecx |
4696 | or eax, ecx |
4695 | or eax, edx |
4697 | or eax, edx |
4696 | pop edx ecx |
4698 | pop edx ecx |
4697 | ret 4 |
4699 | ret 4 |
4698 | ;----------------------------------------------------------------------------- |
4700 | ;----------------------------------------------------------------------------- |
4699 | align 16 |
4701 | align 16 |
4700 | putimage_get16bpp: |
4702 | putimage_get16bpp: |
4701 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4703 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4702 | push ecx edx |
4704 | push ecx edx |
4703 | movzx eax, word [esi] |
4705 | movzx eax, word [esi] |
4704 | add esi, 2 |
4706 | add esi, 2 |
4705 | mov ecx, eax |
4707 | mov ecx, eax |
4706 | mov edx, eax |
4708 | mov edx, eax |
4707 | and eax, 0x1F |
4709 | and eax, 0x1F |
4708 | and ecx, 0x3F shl 5 |
4710 | and ecx, 0x3F shl 5 |
4709 | and edx, 0x1F shl 11 |
4711 | and edx, 0x1F shl 11 |
4710 | shl eax, 3 |
4712 | shl eax, 3 |
4711 | shl ecx, 5 |
4713 | shl ecx, 5 |
4712 | shl edx, 8 |
4714 | shl edx, 8 |
4713 | or eax, ecx |
4715 | or eax, ecx |
4714 | or eax, edx |
4716 | or eax, edx |
4715 | pop edx ecx |
4717 | pop edx ecx |
4716 | ret 4 |
4718 | ret 4 |
4717 | ;----------------------------------------------------------------------------- |
4719 | ;----------------------------------------------------------------------------- |
4718 | ;align 4 |
4720 | ;align 4 |
4719 | ; eax x beginning |
4721 | ; eax x beginning |
4720 | ; ebx y beginning |
4722 | ; ebx y beginning |
4721 | ; ecx x end |
4723 | ; ecx x end |
4722 | ; edx y end |
4724 | ; edx y end |
4723 | ; edi color |
4725 | ; edi color |
4724 | ;__sys_drawbar: |
4726 | ;__sys_drawbar: |
4725 | ; mov esi, [current_slot] |
4727 | ; mov esi, [current_slot] |
4726 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4728 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4727 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4729 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4728 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4730 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4729 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4731 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4730 | ;-------------------------------------- |
4732 | ;-------------------------------------- |
4731 | ;align 4 |
4733 | ;align 4 |
4732 | ;.forced: |
4734 | ;.forced: |
4733 | ; call vesa20_drawbar |
4735 | ; call vesa20_drawbar |
4734 | ; call [draw_pointer] |
4736 | ; call [draw_pointer] |
4735 | ; ret |
4737 | ; ret |
4736 | ;----------------------------------------------------------------------------- |
4738 | ;----------------------------------------------------------------------------- |
4737 | align 4 |
4739 | align 4 |
4738 | kb_read: |
4740 | kb_read: |
4739 | 4741 | ||
4740 | push ecx edx |
4742 | push ecx edx |
4741 | 4743 | ||
4742 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4744 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4743 | kr_loop: |
4745 | kr_loop: |
4744 | in al, 0x64 |
4746 | in al, 0x64 |
4745 | test al, 1 |
4747 | test al, 1 |
4746 | jnz kr_ready |
4748 | jnz kr_ready |
4747 | loop kr_loop |
4749 | loop kr_loop |
4748 | mov ah, 1 |
4750 | mov ah, 1 |
4749 | jmp kr_exit |
4751 | jmp kr_exit |
4750 | kr_ready: |
4752 | kr_ready: |
4751 | push ecx |
4753 | push ecx |
4752 | mov ecx, 32 |
4754 | mov ecx, 32 |
4753 | kr_delay: |
4755 | kr_delay: |
4754 | loop kr_delay |
4756 | loop kr_delay |
4755 | pop ecx |
4757 | pop ecx |
4756 | in al, 0x60 |
4758 | in al, 0x60 |
4757 | xor ah, ah |
4759 | xor ah, ah |
4758 | kr_exit: |
4760 | kr_exit: |
4759 | 4761 | ||
4760 | pop edx ecx |
4762 | pop edx ecx |
4761 | 4763 | ||
4762 | ret |
4764 | ret |
4763 | ;----------------------------------------------------------------------------- |
4765 | ;----------------------------------------------------------------------------- |
4764 | align 4 |
4766 | align 4 |
4765 | kb_write: |
4767 | kb_write: |
4766 | 4768 | ||
4767 | push ecx edx |
4769 | push ecx edx |
4768 | 4770 | ||
4769 | mov dl, al |
4771 | mov dl, al |
4770 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4772 | ; mov ecx,0x1ffff ; last 0xffff, new value in view of fast CPU's |
4771 | ; kw_loop1: |
4773 | ; kw_loop1: |
4772 | ; in al,0x64 |
4774 | ; in al,0x64 |
4773 | ; test al,0x20 |
4775 | ; test al,0x20 |
4774 | ; jz kw_ok1 |
4776 | ; jz kw_ok1 |
4775 | ; loop kw_loop1 |
4777 | ; loop kw_loop1 |
4776 | ; mov ah,1 |
4778 | ; mov ah,1 |
4777 | ; jmp kw_exit |
4779 | ; jmp kw_exit |
4778 | ; kw_ok1: |
4780 | ; kw_ok1: |
4779 | in al, 0x60 |
4781 | in al, 0x60 |
4780 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4782 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4781 | kw_loop: |
4783 | kw_loop: |
4782 | in al, 0x64 |
4784 | in al, 0x64 |
4783 | test al, 2 |
4785 | test al, 2 |
4784 | jz kw_ok |
4786 | jz kw_ok |
4785 | loop kw_loop |
4787 | loop kw_loop |
4786 | mov ah, 1 |
4788 | mov ah, 1 |
4787 | jmp kw_exit |
4789 | jmp kw_exit |
4788 | kw_ok: |
4790 | kw_ok: |
4789 | mov al, dl |
4791 | mov al, dl |
4790 | out 0x60, al |
4792 | out 0x60, al |
4791 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4793 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4792 | kw_loop3: |
4794 | kw_loop3: |
4793 | in al, 0x64 |
4795 | in al, 0x64 |
4794 | test al, 2 |
4796 | test al, 2 |
4795 | jz kw_ok3 |
4797 | jz kw_ok3 |
4796 | loop kw_loop3 |
4798 | loop kw_loop3 |
4797 | mov ah, 1 |
4799 | mov ah, 1 |
4798 | jmp kw_exit |
4800 | jmp kw_exit |
4799 | kw_ok3: |
4801 | kw_ok3: |
4800 | mov ah, 8 |
4802 | mov ah, 8 |
4801 | kw_loop4: |
4803 | kw_loop4: |
4802 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4804 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4803 | kw_loop5: |
4805 | kw_loop5: |
4804 | in al, 0x64 |
4806 | in al, 0x64 |
4805 | test al, 1 |
4807 | test al, 1 |
4806 | jnz kw_ok4 |
4808 | jnz kw_ok4 |
4807 | loop kw_loop5 |
4809 | loop kw_loop5 |
4808 | dec ah |
4810 | dec ah |
4809 | jnz kw_loop4 |
4811 | jnz kw_loop4 |
4810 | kw_ok4: |
4812 | kw_ok4: |
4811 | xor ah, ah |
4813 | xor ah, ah |
4812 | kw_exit: |
4814 | kw_exit: |
4813 | 4815 | ||
4814 | pop edx ecx |
4816 | pop edx ecx |
4815 | 4817 | ||
4816 | ret |
4818 | ret |
4817 | ;----------------------------------------------------------------------------- |
4819 | ;----------------------------------------------------------------------------- |
4818 | align 4 |
4820 | align 4 |
4819 | kb_cmd: |
4821 | kb_cmd: |
4820 | 4822 | ||
4821 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4823 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4822 | c_wait: |
4824 | c_wait: |
4823 | in al, 0x64 |
4825 | in al, 0x64 |
4824 | test al, 2 |
4826 | test al, 2 |
4825 | jz c_send |
4827 | jz c_send |
4826 | loop c_wait |
4828 | loop c_wait |
4827 | jmp c_error |
4829 | jmp c_error |
4828 | c_send: |
4830 | c_send: |
4829 | mov al, bl |
4831 | mov al, bl |
4830 | out 0x64, al |
4832 | out 0x64, al |
4831 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4833 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4832 | c_accept: |
4834 | c_accept: |
4833 | in al, 0x64 |
4835 | in al, 0x64 |
4834 | test al, 2 |
4836 | test al, 2 |
4835 | jz c_ok |
4837 | jz c_ok |
4836 | loop c_accept |
4838 | loop c_accept |
4837 | c_error: |
4839 | c_error: |
4838 | mov ah, 1 |
4840 | mov ah, 1 |
4839 | jmp c_exit |
4841 | jmp c_exit |
4840 | c_ok: |
4842 | c_ok: |
4841 | xor ah, ah |
4843 | xor ah, ah |
4842 | c_exit: |
4844 | c_exit: |
4843 | ret |
4845 | ret |
4844 | 4846 | ||
4845 | 4847 | ||
4846 | setmouse: ; set mousepicture -pointer |
4848 | setmouse: ; set mousepicture -pointer |
4847 | ; ps2 mouse enable |
4849 | ; ps2 mouse enable |
4848 | 4850 | ||
4849 | ; mov [MOUSE_PICTURE], dword mousepointer |
4851 | ; mov [MOUSE_PICTURE], dword mousepointer |
4850 | 4852 | ||
4851 | cli |
4853 | cli |
4852 | 4854 | ||
4853 | ret |
4855 | ret |
4854 | 4856 | ||
4855 | if used _rdtsc |
4857 | if used _rdtsc |
4856 | _rdtsc: |
4858 | _rdtsc: |
4857 | bt [cpu_caps], CAPS_TSC |
4859 | bt [cpu_caps], CAPS_TSC |
4858 | jnc ret_rdtsc |
4860 | jnc ret_rdtsc |
4859 | rdtsc |
4861 | rdtsc |
4860 | ret |
4862 | ret |
4861 | ret_rdtsc: |
4863 | ret_rdtsc: |
4862 | mov edx, 0xffffffff |
4864 | mov edx, 0xffffffff |
4863 | mov eax, 0xffffffff |
4865 | mov eax, 0xffffffff |
4864 | ret |
4866 | ret |
4865 | end if |
4867 | end if |
4866 | 4868 | ||
4867 | sys_msg_board_str: |
4869 | sys_msg_board_str: |
4868 | 4870 | ||
4869 | pushad |
4871 | pushad |
4870 | @@: |
4872 | @@: |
4871 | cmp [esi], byte 0 |
4873 | cmp [esi], byte 0 |
4872 | je @f |
4874 | je @f |
4873 | mov ebx, 1 |
4875 | mov ebx, 1 |
4874 | movzx ecx, byte [esi] |
4876 | movzx ecx, byte [esi] |
4875 | call sys_msg_board |
4877 | call sys_msg_board |
4876 | inc esi |
4878 | inc esi |
4877 | jmp @b |
4879 | jmp @b |
4878 | @@: |
4880 | @@: |
4879 | popad |
4881 | popad |
4880 | ret |
4882 | ret |
4881 | 4883 | ||
4882 | sys_msg_board_byte: |
4884 | sys_msg_board_byte: |
4883 | ; in: al = byte to display |
4885 | ; in: al = byte to display |
4884 | ; out: nothing |
4886 | ; out: nothing |
4885 | ; destroys: nothing |
4887 | ; destroys: nothing |
4886 | pushad |
4888 | pushad |
4887 | mov ecx, 2 |
4889 | mov ecx, 2 |
4888 | shl eax, 24 |
4890 | shl eax, 24 |
4889 | jmp @f |
4891 | jmp @f |
4890 | 4892 | ||
4891 | sys_msg_board_word: |
4893 | sys_msg_board_word: |
4892 | ; in: ax = word to display |
4894 | ; in: ax = word to display |
4893 | ; out: nothing |
4895 | ; out: nothing |
4894 | ; destroys: nothing |
4896 | ; destroys: nothing |
4895 | pushad |
4897 | pushad |
4896 | mov ecx, 4 |
4898 | mov ecx, 4 |
4897 | shl eax, 16 |
4899 | shl eax, 16 |
4898 | jmp @f |
4900 | jmp @f |
4899 | 4901 | ||
4900 | sys_msg_board_dword: |
4902 | sys_msg_board_dword: |
4901 | ; in: eax = dword to display |
4903 | ; in: eax = dword to display |
4902 | ; out: nothing |
4904 | ; out: nothing |
4903 | ; destroys: nothing |
4905 | ; destroys: nothing |
4904 | pushad |
4906 | pushad |
4905 | mov ecx, 8 |
4907 | mov ecx, 8 |
4906 | @@: |
4908 | @@: |
4907 | push ecx |
4909 | push ecx |
4908 | rol eax, 4 |
4910 | rol eax, 4 |
4909 | push eax |
4911 | push eax |
4910 | and al, 0xF |
4912 | and al, 0xF |
4911 | cmp al, 10 |
4913 | cmp al, 10 |
4912 | sbb al, 69h |
4914 | sbb al, 69h |
4913 | das |
4915 | das |
4914 | mov cl, al |
4916 | mov cl, al |
4915 | xor ebx, ebx |
4917 | xor ebx, ebx |
4916 | inc ebx |
4918 | inc ebx |
4917 | call sys_msg_board |
4919 | call sys_msg_board |
4918 | pop eax |
4920 | pop eax |
4919 | pop ecx |
4921 | pop ecx |
4920 | loop @b |
4922 | loop @b |
4921 | popad |
4923 | popad |
4922 | ret |
4924 | ret |
4923 | 4925 | ||
4924 | msg_board_data_size = 65536 ; Must be power of two |
4926 | msg_board_data_size = 65536 ; Must be power of two |
4925 | 4927 | ||
4926 | uglobal |
4928 | uglobal |
4927 | msg_board_data rb msg_board_data_size |
4929 | msg_board_data rb msg_board_data_size |
4928 | msg_board_count dd 0x0 |
4930 | msg_board_count dd 0x0 |
4929 | endg |
4931 | endg |
4930 | 4932 | ||
4931 | sys_msg_board: |
4933 | sys_msg_board: |
4932 | 4934 | ||
4933 | ; ebx=1 : write : bl byte to write |
4935 | ; ebx=1 : write : bl byte to write |
4934 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4936 | ; ebx=2 : read : ebx=0 -> no data, ebx=1 -> data in al |
4935 | 4937 | ||
4936 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4938 | push eax ebx ; Save eax and ebx, since we're restoring their order required. |
4937 | mov eax, ebx |
4939 | mov eax, ebx |
4938 | mov ebx, ecx |
4940 | mov ebx, ecx |
4939 | 4941 | ||
4940 | mov ecx, [msg_board_count] |
4942 | mov ecx, [msg_board_count] |
4941 | cmp eax, 1 |
4943 | cmp eax, 1 |
4942 | jne .smbl1 |
4944 | jne .smbl1 |
4943 | 4945 | ||
4944 | if defined debug_com_base |
4946 | if defined debug_com_base |
4945 | 4947 | ||
4946 | push dx ax |
4948 | push dx ax |
4947 | 4949 | ||
4948 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4950 | @@: ; Wait for empty transmit register (yes, this slows down system..) |
4949 | mov dx, debug_com_base+5 |
4951 | mov dx, debug_com_base+5 |
4950 | in al, dx |
4952 | in al, dx |
4951 | test al, 1 shl 5 |
4953 | test al, 1 shl 5 |
4952 | jz @r |
4954 | jz @r |
4953 | 4955 | ||
4954 | mov dx, debug_com_base ; Output the byte |
4956 | mov dx, debug_com_base ; Output the byte |
4955 | mov al, bl |
4957 | mov al, bl |
4956 | out dx, al |
4958 | out dx, al |
4957 | 4959 | ||
4958 | pop ax dx |
4960 | pop ax dx |
4959 | 4961 | ||
4960 | end if |
4962 | end if |
4961 | 4963 | ||
4962 | mov [msg_board_data+ecx], bl |
4964 | mov [msg_board_data+ecx], bl |
4963 | ; // if debug_direct_print == 1 |
4965 | ; // if debug_direct_print == 1 |
4964 | cmp byte [debug_direct_print], 1 |
4966 | cmp byte [debug_direct_print], 1 |
4965 | jnz @f |
4967 | jnz @f |
4966 | pusha |
4968 | pusha |
4967 | iglobal |
4969 | iglobal |
4968 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4970 | msg_board_pos dd (42*6)*65536+10 ; for printing debug output on the screen |
4969 | endg |
4971 | endg |
4970 | lea edx, [msg_board_data+ecx] |
4972 | lea edx, [msg_board_data+ecx] |
4971 | mov ecx, 0x40FFFFFF |
4973 | mov ecx, 0x40FFFFFF |
4972 | mov ebx, [msg_board_pos] |
4974 | mov ebx, [msg_board_pos] |
4973 | mov edi, 1 |
4975 | mov edi, 1 |
4974 | mov esi, 1 |
4976 | mov esi, 1 |
4975 | call dtext |
4977 | call dtext |
4976 | popa |
4978 | popa |
4977 | add word [msg_board_pos+2], 6 |
4979 | add word [msg_board_pos+2], 6 |
4978 | cmp bl, 10 |
4980 | cmp bl, 10 |
4979 | jnz @f |
4981 | jnz @f |
4980 | mov word [msg_board_pos+2], (42*6) |
4982 | mov word [msg_board_pos+2], (42*6) |
4981 | add word [msg_board_pos], 10 |
4983 | add word [msg_board_pos], 10 |
4982 | mov ax, word [Screen_Max_Y] |
4984 | mov ax, word [Screen_Max_Y] |
4983 | cmp word [msg_board_pos], ax |
4985 | cmp word [msg_board_pos], ax |
4984 | jbe @f |
4986 | jbe @f |
4985 | mov word [msg_board_pos], 10 |
4987 | mov word [msg_board_pos], 10 |
4986 | @@: |
4988 | @@: |
4987 | ; // end if |
4989 | ; // end if |
4988 | 4990 | ||
4989 | if 0 |
4991 | if 0 |
4990 | pusha |
4992 | pusha |
4991 | mov al, bl |
4993 | mov al, bl |
4992 | mov edx, 402h |
4994 | mov edx, 402h |
4993 | out dx, al |
4995 | out dx, al |
4994 | popa |
4996 | popa |
4995 | end if |
4997 | end if |
4996 | inc ecx |
4998 | inc ecx |
4997 | and ecx, msg_board_data_size - 1 |
4999 | and ecx, msg_board_data_size - 1 |
4998 | mov [msg_board_count], ecx |
5000 | mov [msg_board_count], ecx |
4999 | 5001 | ||
5000 | pop ebx eax |
5002 | pop ebx eax |
5001 | ret |
5003 | ret |
5002 | .smbl1: |
5004 | .smbl1: |
5003 | cmp eax, 2 |
5005 | cmp eax, 2 |
5004 | jne .smbl2 |
5006 | jne .smbl2 |
5005 | test ecx, ecx |
5007 | test ecx, ecx |
5006 | jz .smbl21 |
5008 | jz .smbl21 |
5007 | 5009 | ||
5008 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
5010 | add esp, 8 ; Returning data in ebx and eax, so no need to restore them. |
5009 | mov eax, msg_board_data+1 |
5011 | mov eax, msg_board_data+1 |
5010 | mov ebx, msg_board_data |
5012 | mov ebx, msg_board_data |
5011 | movzx edx, byte [ebx] |
5013 | movzx edx, byte [ebx] |
5012 | call memmove |
5014 | call memmove |
5013 | dec [msg_board_count] |
5015 | dec [msg_board_count] |
5014 | mov [esp + 32], edx ;eax |
5016 | mov [esp + 32], edx ;eax |
5015 | mov [esp + 20], dword 1 |
5017 | mov [esp + 20], dword 1 |
5016 | ret |
5018 | ret |
5017 | .smbl21: |
5019 | .smbl21: |
5018 | mov [esp+32], ecx |
5020 | mov [esp+32], ecx |
5019 | mov [esp+20], ecx |
5021 | mov [esp+20], ecx |
5020 | .smbl2: |
5022 | .smbl2: |
5021 | pop ebx eax |
5023 | pop ebx eax |
5022 | ret |
5024 | ret |
5023 | 5025 | ||
5024 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5026 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5025 | ;; 66 sys function. ;; |
5027 | ;; 66 sys function. ;; |
5026 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
5028 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
5027 | ;; out eax ;; |
5029 | ;; out eax ;; |
5028 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5030 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5029 | iglobal |
5031 | iglobal |
5030 | align 4 |
5032 | align 4 |
5031 | f66call: |
5033 | f66call: |
5032 | dd sys_process_def.1 ; 1 = set keyboard mode |
5034 | dd sys_process_def.1 ; 1 = set keyboard mode |
5033 | dd sys_process_def.2 ; 2 = get keyboard mode |
5035 | dd sys_process_def.2 ; 2 = get keyboard mode |
5034 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
5036 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
5035 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
5037 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
5036 | dd sys_process_def.5 ; 5 = delete installed hotkey |
5038 | dd sys_process_def.5 ; 5 = delete installed hotkey |
5037 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
5039 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
5038 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
5040 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
5039 | endg |
5041 | endg |
5040 | ;----------------------------------------------------------------------------- |
5042 | ;----------------------------------------------------------------------------- |
5041 | align 4 |
5043 | align 4 |
5042 | sys_process_def: |
5044 | sys_process_def: |
5043 | dec ebx |
5045 | dec ebx |
5044 | cmp ebx, 7 |
5046 | cmp ebx, 7 |
5045 | jae .not_support ;if >=8 then or eax,-1 |
5047 | jae .not_support ;if >=8 then or eax,-1 |
5046 | 5048 | ||
5047 | mov edi, [CURRENT_TASK] |
5049 | mov edi, [CURRENT_TASK] |
5048 | jmp dword [f66call+ebx*4] |
5050 | jmp dword [f66call+ebx*4] |
5049 | 5051 | ||
5050 | .not_support: |
5052 | .not_support: |
5051 | or eax, -1 |
5053 | or eax, -1 |
5052 | ret |
5054 | ret |
5053 | ;----------------------------------------------------------------------------- |
5055 | ;----------------------------------------------------------------------------- |
5054 | align 4 |
5056 | align 4 |
5055 | .1: |
5057 | .1: |
5056 | shl edi, 8 |
5058 | shl edi, 8 |
5057 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
5059 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
5058 | 5060 | ||
5059 | ret |
5061 | ret |
5060 | ;----------------------------------------------------------------------------- |
5062 | ;----------------------------------------------------------------------------- |
5061 | align 4 |
5063 | align 4 |
5062 | .2: ; 2 = get keyboard mode |
5064 | .2: ; 2 = get keyboard mode |
5063 | shl edi, 8 |
5065 | shl edi, 8 |
5064 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
5066 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
5065 | mov [esp+32], eax |
5067 | mov [esp+32], eax |
5066 | ret |
5068 | ret |
5067 | ;----------------------------------------------------------------------------- |
5069 | ;----------------------------------------------------------------------------- |
5068 | align 4 |
5070 | align 4 |
5069 | .3: ;3 = get keyboard ctrl, alt, shift |
5071 | .3: ;3 = get keyboard ctrl, alt, shift |
5070 | mov eax, [kb_state] |
5072 | mov eax, [kb_state] |
5071 | mov [esp+32], eax |
5073 | mov [esp+32], eax |
5072 | ret |
5074 | ret |
5073 | ;----------------------------------------------------------------------------- |
5075 | ;----------------------------------------------------------------------------- |
5074 | align 4 |
5076 | align 4 |
5075 | .4: |
5077 | .4: |
5076 | mov eax, hotkey_list |
5078 | mov eax, hotkey_list |
5077 | @@: |
5079 | @@: |
5078 | cmp dword [eax+8], 0 |
5080 | cmp dword [eax+8], 0 |
5079 | jz .found_free |
5081 | jz .found_free |
5080 | add eax, 16 |
5082 | add eax, 16 |
5081 | cmp eax, hotkey_list+16*256 |
5083 | cmp eax, hotkey_list+16*256 |
5082 | jb @b |
5084 | jb @b |
5083 | mov dword [esp+32], 1 |
5085 | mov dword [esp+32], 1 |
5084 | ret |
5086 | ret |
5085 | .found_free: |
5087 | .found_free: |
5086 | mov [eax+8], edi |
5088 | mov [eax+8], edi |
5087 | mov [eax+4], edx |
5089 | mov [eax+4], edx |
5088 | movzx ecx, cl |
5090 | movzx ecx, cl |
5089 | lea ecx, [hotkey_scancodes+ecx*4] |
5091 | lea ecx, [hotkey_scancodes+ecx*4] |
5090 | mov edx, [ecx] |
5092 | mov edx, [ecx] |
5091 | mov [eax], edx |
5093 | mov [eax], edx |
5092 | mov [ecx], eax |
5094 | mov [ecx], eax |
5093 | mov [eax+12], ecx |
5095 | mov [eax+12], ecx |
5094 | test edx, edx |
5096 | test edx, edx |
5095 | jz @f |
5097 | jz @f |
5096 | mov [edx+12], eax |
5098 | mov [edx+12], eax |
5097 | @@: |
5099 | @@: |
5098 | and dword [esp+32], 0 |
5100 | and dword [esp+32], 0 |
5099 | ret |
5101 | ret |
5100 | ;----------------------------------------------------------------------------- |
5102 | ;----------------------------------------------------------------------------- |
5101 | align 4 |
5103 | align 4 |
5102 | .5: |
5104 | .5: |
5103 | movzx ebx, cl |
5105 | movzx ebx, cl |
5104 | lea ebx, [hotkey_scancodes+ebx*4] |
5106 | lea ebx, [hotkey_scancodes+ebx*4] |
5105 | mov eax, [ebx] |
5107 | mov eax, [ebx] |
5106 | .scan: |
5108 | .scan: |
5107 | test eax, eax |
5109 | test eax, eax |
5108 | jz .notfound |
5110 | jz .notfound |
5109 | cmp [eax+8], edi |
5111 | cmp [eax+8], edi |
5110 | jnz .next |
5112 | jnz .next |
5111 | cmp [eax+4], edx |
5113 | cmp [eax+4], edx |
5112 | jz .found |
5114 | jz .found |
5113 | .next: |
5115 | .next: |
5114 | mov eax, [eax] |
5116 | mov eax, [eax] |
5115 | jmp .scan |
5117 | jmp .scan |
5116 | .notfound: |
5118 | .notfound: |
5117 | mov dword [esp+32], 1 |
5119 | mov dword [esp+32], 1 |
5118 | ret |
5120 | ret |
5119 | .found: |
5121 | .found: |
5120 | mov ecx, [eax] |
5122 | mov ecx, [eax] |
5121 | jecxz @f |
5123 | jecxz @f |
5122 | mov edx, [eax+12] |
5124 | mov edx, [eax+12] |
5123 | mov [ecx+12], edx |
5125 | mov [ecx+12], edx |
5124 | @@: |
5126 | @@: |
5125 | mov ecx, [eax+12] |
5127 | mov ecx, [eax+12] |
5126 | mov edx, [eax] |
5128 | mov edx, [eax] |
5127 | mov [ecx], edx |
5129 | mov [ecx], edx |
5128 | xor edx, edx |
5130 | xor edx, edx |
5129 | mov [eax+4], edx |
5131 | mov [eax+4], edx |
5130 | mov [eax+8], edx |
5132 | mov [eax+8], edx |
5131 | mov [eax+12], edx |
5133 | mov [eax+12], edx |
5132 | mov [eax], edx |
5134 | mov [eax], edx |
5133 | mov [esp+32], edx |
5135 | mov [esp+32], edx |
5134 | ret |
5136 | ret |
5135 | ;----------------------------------------------------------------------------- |
5137 | ;----------------------------------------------------------------------------- |
5136 | align 4 |
5138 | align 4 |
5137 | .6: |
5139 | .6: |
5138 | pushfd |
5140 | pushfd |
5139 | cli |
5141 | cli |
5140 | mov eax, [PID_lock_input] |
5142 | mov eax, [PID_lock_input] |
5141 | test eax, eax |
5143 | test eax, eax |
5142 | jnz @f |
5144 | jnz @f |
5143 | ; get current PID |
5145 | ; get current PID |
5144 | mov eax, [CURRENT_TASK] |
5146 | mov eax, [CURRENT_TASK] |
5145 | shl eax, 5 |
5147 | shl eax, 5 |
5146 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5148 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
5147 | ; set current PID for lock input |
5149 | ; set current PID for lock input |
5148 | mov [PID_lock_input], eax |
5150 | mov [PID_lock_input], eax |
5149 | @@: |
5151 | @@: |
5150 | popfd |
5152 | popfd |
5151 | ret |
5153 | ret |
5152 | ;----------------------------------------------------------------------------- |
5154 | ;----------------------------------------------------------------------------- |
5153 | align 4 |
5155 | align 4 |
5154 | .7: |
5156 | .7: |
5155 | mov eax, [PID_lock_input] |
5157 | mov eax, [PID_lock_input] |
5156 | test eax, eax |
5158 | test eax, eax |
5157 | jz @f |
5159 | jz @f |
5158 | ; get current PID |
5160 | ; get current PID |
5159 | mov ebx, [CURRENT_TASK] |
5161 | mov ebx, [CURRENT_TASK] |
5160 | shl ebx, 5 |
5162 | shl ebx, 5 |
5161 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5163 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5162 | ; compare current lock input with current PID |
5164 | ; compare current lock input with current PID |
5163 | cmp ebx, eax |
5165 | cmp ebx, eax |
5164 | jne @f |
5166 | jne @f |
5165 | 5167 | ||
5166 | xor eax, eax |
5168 | xor eax, eax |
5167 | mov [PID_lock_input], eax |
5169 | mov [PID_lock_input], eax |
5168 | @@: |
5170 | @@: |
5169 | ret |
5171 | ret |
5170 | ;----------------------------------------------------------------------------- |
5172 | ;----------------------------------------------------------------------------- |
5171 | uglobal |
5173 | uglobal |
5172 | PID_lock_input dd 0x0 |
5174 | PID_lock_input dd 0x0 |
5173 | endg |
5175 | endg |
5174 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5175 | ;; 61 sys function. ;; |
5177 | ;; 61 sys function. ;; |
5176 | ;; in eax=61,ebx in [1..3] ;; |
5178 | ;; in eax=61,ebx in [1..3] ;; |
5177 | ;; out eax ;; |
5179 | ;; out eax ;; |
5178 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5180 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5179 | iglobal |
5181 | iglobal |
5180 | align 4 |
5182 | align 4 |
5181 | f61call: |
5183 | f61call: |
5182 | dd sys_gs.1 ; resolution |
5184 | dd sys_gs.1 ; resolution |
5183 | dd sys_gs.2 ; bits per pixel |
5185 | dd sys_gs.2 ; bits per pixel |
5184 | dd sys_gs.3 ; bytes per scanline |
5186 | dd sys_gs.3 ; bytes per scanline |
5185 | endg |
5187 | endg |
5186 | 5188 | ||
5187 | 5189 | ||
5188 | align 4 |
5190 | align 4 |
5189 | 5191 | ||
5190 | sys_gs: ; direct screen access |
5192 | sys_gs: ; direct screen access |
5191 | dec ebx |
5193 | dec ebx |
5192 | cmp ebx, 2 |
5194 | cmp ebx, 2 |
5193 | ja .not_support |
5195 | ja .not_support |
5194 | jmp dword [f61call+ebx*4] |
5196 | jmp dword [f61call+ebx*4] |
5195 | .not_support: |
5197 | .not_support: |
5196 | or [esp+32], dword -1 |
5198 | or [esp+32], dword -1 |
5197 | ret |
5199 | ret |
5198 | 5200 | ||
5199 | 5201 | ||
5200 | .1: ; resolution |
5202 | .1: ; resolution |
5201 | mov eax, [Screen_Max_X] |
5203 | mov eax, [Screen_Max_X] |
5202 | shl eax, 16 |
5204 | shl eax, 16 |
5203 | mov ax, word [Screen_Max_Y] |
5205 | mov ax, word [Screen_Max_Y] |
5204 | add eax, 0x00010001 |
5206 | add eax, 0x00010001 |
5205 | mov [esp+32], eax |
5207 | mov [esp+32], eax |
5206 | ret |
5208 | ret |
5207 | .2: ; bits per pixel |
5209 | .2: ; bits per pixel |
5208 | mov eax, [_display.bpp] |
5210 | mov eax, [_display.bpp] |
5209 | mov [esp+32], eax |
5211 | mov [esp+32], eax |
5210 | ret |
5212 | ret |
5211 | .3: ; bytes per scanline |
5213 | .3: ; bytes per scanline |
5212 | mov eax, [_display.pitch] |
5214 | mov eax, [_display.pitch] |
5213 | mov [esp+32], eax |
5215 | mov [esp+32], eax |
5214 | ret |
5216 | ret |
5215 | 5217 | ||
5216 | align 4 ; system functions |
5218 | align 4 ; system functions |
5217 | 5219 | ||
5218 | syscall_setpixel: ; SetPixel |
5220 | syscall_setpixel: ; SetPixel |
5219 | 5221 | ||
5220 | mov eax, ebx |
5222 | mov eax, ebx |
5221 | mov ebx, ecx |
5223 | mov ebx, ecx |
5222 | mov ecx, edx |
5224 | mov ecx, edx |
5223 | mov edx, [TASK_BASE] |
5225 | mov edx, [TASK_BASE] |
5224 | add eax, [edx-twdw+WDATA.box.left] |
5226 | add eax, [edx-twdw+WDATA.box.left] |
5225 | add ebx, [edx-twdw+WDATA.box.top] |
5227 | add ebx, [edx-twdw+WDATA.box.top] |
5226 | mov edi, [current_slot] |
5228 | mov edi, [current_slot] |
5227 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5229 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5228 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5230 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5229 | xor edi, edi ; no force |
5231 | xor edi, edi ; no force |
5230 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5232 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5231 | ; jmp [putpixel] |
5233 | ; jmp [putpixel] |
5232 | jmp __sys_putpixel |
5234 | jmp __sys_putpixel |
5233 | 5235 | ||
5234 | align 4 |
5236 | align 4 |
5235 | 5237 | ||
5236 | syscall_writetext: ; WriteText |
5238 | syscall_writetext: ; WriteText |
5237 | 5239 | ||
5238 | mov eax, [TASK_BASE] |
5240 | mov eax, [TASK_BASE] |
5239 | mov ebp, [eax-twdw+WDATA.box.left] |
5241 | mov ebp, [eax-twdw+WDATA.box.left] |
5240 | push esi |
5242 | push esi |
5241 | mov esi, [current_slot] |
5243 | mov esi, [current_slot] |
5242 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5244 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5243 | shl ebp, 16 |
5245 | shl ebp, 16 |
5244 | add ebp, [eax-twdw+WDATA.box.top] |
5246 | add ebp, [eax-twdw+WDATA.box.top] |
5245 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5247 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5246 | pop esi |
5248 | pop esi |
5247 | test ecx, 0x08000000 ; redirect the output to the user area |
5249 | test ecx, 0x08000000 ; redirect the output to the user area |
5248 | jnz @f |
5250 | jnz @f |
5249 | add ebx, ebp |
5251 | add ebx, ebp |
5250 | align 4 |
5252 | align 4 |
5251 | @@: |
5253 | @@: |
5252 | mov eax, edi |
5254 | mov eax, edi |
5253 | test ecx, 0x08000000 ; redirect the output to the user area |
5255 | test ecx, 0x08000000 ; redirect the output to the user area |
5254 | jnz dtext |
5256 | jnz dtext |
5255 | xor edi, edi |
5257 | xor edi, edi |
5256 | jmp dtext |
5258 | jmp dtext |
5257 | 5259 | ||
5258 | align 4 |
5260 | align 4 |
5259 | 5261 | ||
5260 | syscall_drawrect: ; DrawRect |
5262 | syscall_drawrect: ; DrawRect |
5261 | 5263 | ||
5262 | mov edi, edx ; color + gradient |
5264 | mov edi, edx ; color + gradient |
5263 | and edi, 0x80FFFFFF |
5265 | and edi, 0x80FFFFFF |
5264 | test bx, bx ; x.size |
5266 | test bx, bx ; x.size |
5265 | je .drectr |
5267 | je .drectr |
5266 | test cx, cx ; y.size |
5268 | test cx, cx ; y.size |
5267 | je .drectr |
5269 | je .drectr |
5268 | 5270 | ||
5269 | mov eax, ebx ; bad idea |
5271 | mov eax, ebx ; bad idea |
5270 | mov ebx, ecx |
5272 | mov ebx, ecx |
5271 | 5273 | ||
5272 | movzx ecx, ax ; ecx - x.size |
5274 | movzx ecx, ax ; ecx - x.size |
5273 | shr eax, 16 ; eax - x.coord |
5275 | shr eax, 16 ; eax - x.coord |
5274 | movzx edx, bx ; edx - y.size |
5276 | movzx edx, bx ; edx - y.size |
5275 | shr ebx, 16 ; ebx - y.coord |
5277 | shr ebx, 16 ; ebx - y.coord |
5276 | mov esi, [current_slot] |
5278 | mov esi, [current_slot] |
5277 | 5279 | ||
5278 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5280 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5279 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5281 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5280 | add ecx, eax |
5282 | add ecx, eax |
5281 | add edx, ebx |
5283 | add edx, ebx |
5282 | ; jmp [drawbar] |
5284 | ; jmp [drawbar] |
5283 | jmp vesa20_drawbar |
5285 | jmp vesa20_drawbar |
5284 | .drectr: |
5286 | .drectr: |
5285 | ret |
5287 | ret |
5286 | 5288 | ||
5287 | align 4 |
5289 | align 4 |
5288 | syscall_getscreensize: ; GetScreenSize |
5290 | syscall_getscreensize: ; GetScreenSize |
5289 | mov ax, word [Screen_Max_X] |
5291 | mov ax, word [Screen_Max_X] |
5290 | shl eax, 16 |
5292 | shl eax, 16 |
5291 | mov ax, word [Screen_Max_Y] |
5293 | mov ax, word [Screen_Max_Y] |
5292 | mov [esp + 32], eax |
5294 | mov [esp + 32], eax |
5293 | ret |
5295 | ret |
5294 | 5296 | ||
5295 | align 4 |
5297 | align 4 |
5296 | 5298 | ||
5297 | syscall_cdaudio: ; CD |
5299 | syscall_cdaudio: ; CD |
5298 | 5300 | ||
5299 | cmp ebx, 4 |
5301 | cmp ebx, 4 |
5300 | jb .audio |
5302 | jb .audio |
5301 | jz .eject |
5303 | jz .eject |
5302 | cmp ebx, 5 |
5304 | cmp ebx, 5 |
5303 | jnz .ret |
5305 | jnz .ret |
5304 | .load: |
5306 | .load: |
5305 | call .reserve |
5307 | call .reserve |
5306 | call LoadMedium |
5308 | call LoadMedium |
5307 | ;call .free |
5309 | ;call .free |
5308 | jmp .free |
5310 | jmp .free |
5309 | ; ret |
5311 | ; ret |
5310 | .eject: |
5312 | .eject: |
5311 | call .reserve |
5313 | call .reserve |
5312 | call clear_CD_cache |
5314 | call clear_CD_cache |
5313 | call allow_medium_removal |
5315 | call allow_medium_removal |
5314 | call EjectMedium |
5316 | call EjectMedium |
5315 | ; call .free |
5317 | ; call .free |
5316 | jmp .free |
5318 | jmp .free |
5317 | ; ret |
5319 | ; ret |
5318 | .audio: |
5320 | .audio: |
5319 | call sys_cd_audio |
5321 | call sys_cd_audio |
5320 | mov [esp+36-4], eax |
5322 | mov [esp+36-4], eax |
5321 | .ret: |
5323 | .ret: |
5322 | ret |
5324 | ret |
5323 | 5325 | ||
5324 | .reserve: |
5326 | .reserve: |
5325 | call reserve_cd |
5327 | call reserve_cd |
5326 | mov eax, ecx |
5328 | mov eax, ecx |
5327 | shr eax, 1 |
5329 | shr eax, 1 |
5328 | and eax, 1 |
5330 | and eax, 1 |
5329 | inc eax |
5331 | inc eax |
5330 | mov [ChannelNumber], ax |
5332 | mov [ChannelNumber], ax |
5331 | mov eax, ecx |
5333 | mov eax, ecx |
5332 | and eax, 1 |
5334 | and eax, 1 |
5333 | mov [DiskNumber], al |
5335 | mov [DiskNumber], al |
5334 | call reserve_cd_channel |
5336 | call reserve_cd_channel |
5335 | and ebx, 3 |
5337 | and ebx, 3 |
5336 | inc ebx |
5338 | inc ebx |
5337 | mov [cdpos], ebx |
5339 | mov [cdpos], ebx |
5338 | add ebx, ebx |
5340 | add ebx, ebx |
5339 | mov cl, 8 |
5341 | mov cl, 8 |
5340 | sub cl, bl |
5342 | sub cl, bl |
5341 | mov al, [DRIVE_DATA+1] |
5343 | mov al, [DRIVE_DATA+1] |
5342 | shr al, cl |
5344 | shr al, cl |
5343 | test al, 2 |
5345 | test al, 2 |
5344 | jz .free;.err |
5346 | jz .free;.err |
5345 | ret |
5347 | ret |
5346 | .free: |
5348 | .free: |
5347 | call free_cd_channel |
5349 | call free_cd_channel |
5348 | and [cd_status], 0 |
5350 | and [cd_status], 0 |
5349 | ret |
5351 | ret |
5350 | .err: |
5352 | .err: |
5351 | call .free |
5353 | call .free |
5352 | ; pop eax |
5354 | ; pop eax |
5353 | ret |
5355 | ret |
5354 | ;----------------------------------------------------------------------------- |
5356 | ;----------------------------------------------------------------------------- |
5355 | align 4 |
5357 | align 4 |
5356 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5358 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5357 | cmp ebx, [Screen_Max_X] |
5359 | cmp ebx, [Screen_Max_X] |
5358 | jbe @f |
5360 | jbe @f |
5359 | cmp ecx, [Screen_Max_Y] |
5361 | cmp ecx, [Screen_Max_Y] |
5360 | jbe @f |
5362 | jbe @f |
5361 | xor eax, eax |
5363 | xor eax, eax |
5362 | jmp .store |
5364 | jmp .store |
5363 | ;-------------------------------------- |
5365 | ;-------------------------------------- |
5364 | align 4 |
5366 | align 4 |
5365 | @@: |
5367 | @@: |
5366 | mov eax, [d_width_calc_area + ecx*4] |
5368 | mov eax, [d_width_calc_area + ecx*4] |
5367 | add eax, [_WinMapAddress] |
5369 | add eax, [_WinMapAddress] |
5368 | movzx eax, byte[eax+ebx] ; get value for current point |
5370 | movzx eax, byte[eax+ebx] ; get value for current point |
5369 | ;-------------------------------------- |
5371 | ;-------------------------------------- |
5370 | align 4 |
5372 | align 4 |
5371 | .store: |
5373 | .store: |
5372 | mov [esp + 32], eax |
5374 | mov [esp + 32], eax |
5373 | ret |
5375 | ret |
5374 | ;----------------------------------------------------------------------------- |
5376 | ;----------------------------------------------------------------------------- |
5375 | align 4 |
5377 | align 4 |
5376 | syscall_getpixel: ; GetPixel |
5378 | syscall_getpixel: ; GetPixel |
5377 | mov ecx, [Screen_Max_X] |
5379 | mov ecx, [Screen_Max_X] |
5378 | inc ecx |
5380 | inc ecx |
5379 | xor edx, edx |
5381 | xor edx, edx |
5380 | mov eax, ebx |
5382 | mov eax, ebx |
5381 | div ecx |
5383 | div ecx |
5382 | mov ebx, edx |
5384 | mov ebx, edx |
5383 | xchg eax, ebx |
5385 | xchg eax, ebx |
5384 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5386 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5385 | call dword [GETPIXEL]; eax - x, ebx - y |
5387 | call dword [GETPIXEL]; eax - x, ebx - y |
5386 | mov [esp + 32], ecx |
5388 | mov [esp + 32], ecx |
5387 | ret |
5389 | ret |
5388 | ;----------------------------------------------------------------------------- |
5390 | ;----------------------------------------------------------------------------- |
5389 | align 4 |
5391 | align 4 |
5390 | syscall_getarea: |
5392 | syscall_getarea: |
5391 | ;eax = 36 |
5393 | ;eax = 36 |
5392 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5394 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5393 | ;ecx = [size x]*65536 + [size y] |
5395 | ;ecx = [size x]*65536 + [size y] |
5394 | ;edx = [start x]*65536 + [start y] |
5396 | ;edx = [start x]*65536 + [start y] |
5395 | pushad |
5397 | pushad |
5396 | mov edi, ebx |
5398 | mov edi, ebx |
5397 | mov eax, edx |
5399 | mov eax, edx |
5398 | shr eax, 16 |
5400 | shr eax, 16 |
5399 | mov ebx, edx |
5401 | mov ebx, edx |
5400 | and ebx, 0xffff |
5402 | and ebx, 0xffff |
5401 | dec eax |
5403 | dec eax |
5402 | dec ebx |
5404 | dec ebx |
5403 | ; eax - x, ebx - y |
5405 | ; eax - x, ebx - y |
5404 | mov edx, ecx |
5406 | mov edx, ecx |
5405 | 5407 | ||
5406 | shr ecx, 16 |
5408 | shr ecx, 16 |
5407 | and edx, 0xffff |
5409 | and edx, 0xffff |
5408 | mov esi, ecx |
5410 | mov esi, ecx |
5409 | ; ecx - size x, edx - size y |
5411 | ; ecx - size x, edx - size y |
5410 | 5412 | ||
5411 | mov ebp, edx |
5413 | mov ebp, edx |
5412 | dec ebp |
5414 | dec ebp |
5413 | lea ebp, [ebp*3] |
5415 | lea ebp, [ebp*3] |
5414 | 5416 | ||
5415 | imul ebp, esi |
5417 | imul ebp, esi |
5416 | 5418 | ||
5417 | mov esi, ecx |
5419 | mov esi, ecx |
5418 | dec esi |
5420 | dec esi |
5419 | lea esi, [esi*3] |
5421 | lea esi, [esi*3] |
5420 | 5422 | ||
5421 | add ebp, esi |
5423 | add ebp, esi |
5422 | add ebp, edi |
5424 | add ebp, edi |
5423 | 5425 | ||
5424 | add ebx, edx |
5426 | add ebx, edx |
5425 | ;-------------------------------------- |
5427 | ;-------------------------------------- |
5426 | align 4 |
5428 | align 4 |
5427 | .start_y: |
5429 | .start_y: |
5428 | push ecx edx |
5430 | push ecx edx |
5429 | ;-------------------------------------- |
5431 | ;-------------------------------------- |
5430 | align 4 |
5432 | align 4 |
5431 | .start_x: |
5433 | .start_x: |
5432 | push eax ebx ecx |
5434 | push eax ebx ecx |
5433 | add eax, ecx |
5435 | add eax, ecx |
5434 | 5436 | ||
5435 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5437 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5436 | call dword [GETPIXEL]; eax - x, ebx - y |
5438 | call dword [GETPIXEL]; eax - x, ebx - y |
5437 | 5439 | ||
5438 | mov [ebp], cx |
5440 | mov [ebp], cx |
5439 | shr ecx, 16 |
5441 | shr ecx, 16 |
5440 | mov [ebp+2], cl |
5442 | mov [ebp+2], cl |
5441 | 5443 | ||
5442 | pop ecx ebx eax |
5444 | pop ecx ebx eax |
5443 | sub ebp, 3 |
5445 | sub ebp, 3 |
5444 | dec ecx |
5446 | dec ecx |
5445 | jnz .start_x |
5447 | jnz .start_x |
5446 | pop edx ecx |
5448 | pop edx ecx |
5447 | dec ebx |
5449 | dec ebx |
5448 | dec edx |
5450 | dec edx |
5449 | jnz .start_y |
5451 | jnz .start_y |
5450 | popad |
5452 | popad |
5451 | ret |
5453 | ret |
5452 | ;----------------------------------------------------------------------------- |
5454 | ;----------------------------------------------------------------------------- |
5453 | align 4 |
5455 | align 4 |
5454 | syscall_putarea_backgr: |
5456 | syscall_putarea_backgr: |
5455 | ;eax = 25 |
5457 | ;eax = 25 |
5456 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5458 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5457 | ;ecx = [size x]*65536 + [size y] |
5459 | ;ecx = [size x]*65536 + [size y] |
5458 | ;edx = [start x]*65536 + [start y] |
5460 | ;edx = [start x]*65536 + [start y] |
5459 | pushad |
5461 | pushad |
5460 | mov edi, ebx |
5462 | mov edi, ebx |
5461 | mov eax, edx |
5463 | mov eax, edx |
5462 | shr eax, 16 |
5464 | shr eax, 16 |
5463 | mov ebx, edx |
5465 | mov ebx, edx |
5464 | and ebx, 0xffff |
5466 | and ebx, 0xffff |
5465 | dec eax |
5467 | dec eax |
5466 | dec ebx |
5468 | dec ebx |
5467 | ; eax - x, ebx - y |
5469 | ; eax - x, ebx - y |
5468 | mov edx, ecx |
5470 | mov edx, ecx |
5469 | shr ecx, 16 |
5471 | shr ecx, 16 |
5470 | and edx, 0xffff |
5472 | and edx, 0xffff |
5471 | mov esi, ecx |
5473 | mov esi, ecx |
5472 | ; ecx - size x, edx - size y |
5474 | ; ecx - size x, edx - size y |
5473 | mov ebp, edx |
5475 | mov ebp, edx |
5474 | dec ebp |
5476 | dec ebp |
5475 | shl ebp, 2 |
5477 | shl ebp, 2 |
5476 | 5478 | ||
5477 | imul ebp, esi |
5479 | imul ebp, esi |
5478 | 5480 | ||
5479 | mov esi, ecx |
5481 | mov esi, ecx |
5480 | dec esi |
5482 | dec esi |
5481 | shl esi, 2 |
5483 | shl esi, 2 |
5482 | 5484 | ||
5483 | add ebp, esi |
5485 | add ebp, esi |
5484 | add ebp, edi |
5486 | add ebp, edi |
5485 | 5487 | ||
5486 | add ebx, edx |
5488 | add ebx, edx |
5487 | ;-------------------------------------- |
5489 | ;-------------------------------------- |
5488 | align 4 |
5490 | align 4 |
5489 | .start_y: |
5491 | .start_y: |
5490 | push ecx edx |
5492 | push ecx edx |
5491 | ;-------------------------------------- |
5493 | ;-------------------------------------- |
5492 | align 4 |
5494 | align 4 |
5493 | .start_x: |
5495 | .start_x: |
5494 | push eax ecx |
5496 | push eax ecx |
5495 | add eax, ecx |
5497 | add eax, ecx |
5496 | 5498 | ||
5497 | mov ecx, [ebp] |
5499 | mov ecx, [ebp] |
5498 | rol ecx, 8 |
5500 | rol ecx, 8 |
5499 | test cl, cl ; transparensy = 0 |
5501 | test cl, cl ; transparensy = 0 |
5500 | jz .no_put |
5502 | jz .no_put |
5501 | 5503 | ||
5502 | xor cl, cl |
5504 | xor cl, cl |
5503 | ror ecx, 8 |
5505 | ror ecx, 8 |
5504 | 5506 | ||
5505 | pushad |
5507 | pushad |
5506 | mov edx, [d_width_calc_area + ebx*4] |
5508 | mov edx, [d_width_calc_area + ebx*4] |
5507 | add edx, [_WinMapAddress] |
5509 | add edx, [_WinMapAddress] |
5508 | movzx edx, byte [eax+edx] |
5510 | movzx edx, byte [eax+edx] |
5509 | cmp dl, byte 1 |
5511 | cmp dl, byte 1 |
5510 | jne @f |
5512 | jne @f |
5511 | 5513 | ||
5512 | call dword [PUTPIXEL]; eax - x, ebx - y |
5514 | call dword [PUTPIXEL]; eax - x, ebx - y |
5513 | ;-------------------------------------- |
5515 | ;-------------------------------------- |
5514 | align 4 |
5516 | align 4 |
5515 | @@: |
5517 | @@: |
5516 | popad |
5518 | popad |
5517 | ;-------------------------------------- |
5519 | ;-------------------------------------- |
5518 | align 4 |
5520 | align 4 |
5519 | .no_put: |
5521 | .no_put: |
5520 | pop ecx eax |
5522 | pop ecx eax |
5521 | 5523 | ||
5522 | sub ebp, 4 |
5524 | sub ebp, 4 |
5523 | dec ecx |
5525 | dec ecx |
5524 | jnz .start_x |
5526 | jnz .start_x |
5525 | 5527 | ||
5526 | pop edx ecx |
5528 | pop edx ecx |
5527 | dec ebx |
5529 | dec ebx |
5528 | dec edx |
5530 | dec edx |
5529 | jnz .start_y |
5531 | jnz .start_y |
5530 | 5532 | ||
5531 | popad |
5533 | popad |
5532 | ret |
5534 | ret |
5533 | ;----------------------------------------------------------------------------- |
5535 | ;----------------------------------------------------------------------------- |
5534 | align 4 |
5536 | align 4 |
5535 | syscall_drawline: ; DrawLine |
5537 | syscall_drawline: ; DrawLine |
5536 | 5538 | ||
5537 | mov edi, [TASK_BASE] |
5539 | mov edi, [TASK_BASE] |
5538 | movzx eax, word[edi-twdw+WDATA.box.left] |
5540 | movzx eax, word[edi-twdw+WDATA.box.left] |
5539 | mov ebp, eax |
5541 | mov ebp, eax |
5540 | mov esi, [current_slot] |
5542 | mov esi, [current_slot] |
5541 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5543 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5542 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5544 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5543 | add ebp, ebx |
5545 | add ebp, ebx |
5544 | shl eax, 16 |
5546 | shl eax, 16 |
5545 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5547 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5546 | add eax, ebp |
5548 | add eax, ebp |
5547 | mov ebp, ebx |
5549 | mov ebp, ebx |
5548 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5550 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5549 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5551 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5550 | add ebp, ecx |
5552 | add ebp, ecx |
5551 | shl ebx, 16 |
5553 | shl ebx, 16 |
5552 | xor edi, edi |
5554 | xor edi, edi |
5553 | add ebx, ebp |
5555 | add ebx, ebp |
5554 | mov ecx, edx |
5556 | mov ecx, edx |
5555 | ; jmp [draw_line] |
5557 | ; jmp [draw_line] |
5556 | jmp __sys_draw_line |
5558 | jmp __sys_draw_line |
5557 | 5559 | ||
5558 | 5560 | ||
5559 | align 4 |
5561 | align 4 |
5560 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5562 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5561 | 5563 | ||
5562 | call r_f_port_area |
5564 | call r_f_port_area |
5563 | mov [esp+32], eax |
5565 | mov [esp+32], eax |
5564 | ret |
5566 | ret |
5565 | 5567 | ||
5566 | align 4 |
5568 | align 4 |
5567 | syscall_threads: ; CreateThreads |
5569 | syscall_threads: ; CreateThreads |
5568 | ; |
5570 | ; |
5569 | ; ecx=thread entry point |
5571 | ; ecx=thread entry point |
5570 | ; edx=thread stack pointer |
5572 | ; edx=thread stack pointer |
5571 | ; |
5573 | ; |
5572 | ; on return : eax = pid |
5574 | ; on return : eax = pid |
5573 | 5575 | ||
5574 | xor ebx, ebx |
5576 | xor ebx, ebx |
5575 | call new_sys_threads |
5577 | call new_sys_threads |
5576 | 5578 | ||
5577 | mov [esp+32], eax |
5579 | mov [esp+32], eax |
5578 | ret |
5580 | ret |
5579 | 5581 | ||
5580 | align 4 |
5582 | align 4 |
5581 | 5583 | ||
5582 | paleholder: |
5584 | paleholder: |
5583 | ret |
5585 | ret |
5584 | ;------------------------------------------------------------------------------ |
5586 | ;------------------------------------------------------------------------------ |
5585 | align 4 |
5587 | align 4 |
5586 | calculate_fast_getting_offset_for_WinMapAddress: |
5588 | calculate_fast_getting_offset_for_WinMapAddress: |
5587 | ; calculate data area for fast getting offset to _WinMapAddress |
5589 | ; calculate data area for fast getting offset to _WinMapAddress |
5588 | xor eax, eax |
5590 | xor eax, eax |
5589 | mov ecx, [_display.height] |
5591 | mov ecx, [_display.height] |
5590 | mov edi, d_width_calc_area |
5592 | mov edi, d_width_calc_area |
5591 | cld |
5593 | cld |
5592 | @@: |
5594 | @@: |
5593 | stosd |
5595 | stosd |
5594 | add eax, [_display.width] |
5596 | add eax, [_display.width] |
5595 | dec ecx |
5597 | dec ecx |
5596 | jnz @r |
5598 | jnz @r |
5597 | ret |
5599 | ret |
5598 | ;------------------------------------------------------------------------------ |
5600 | ;------------------------------------------------------------------------------ |
5599 | align 4 |
5601 | align 4 |
5600 | calculate_fast_getting_offset_for_LFB: |
5602 | calculate_fast_getting_offset_for_LFB: |
5601 | ; calculate data area for fast getting offset to LFB |
5603 | ; calculate data area for fast getting offset to LFB |
5602 | xor eax, eax |
5604 | xor eax, eax |
5603 | mov ecx, [_display.height] |
5605 | mov ecx, [_display.height] |
5604 | mov edi, BPSLine_calc_area |
5606 | mov edi, BPSLine_calc_area |
5605 | cld |
5607 | cld |
5606 | @@: |
5608 | @@: |
5607 | stosd |
5609 | stosd |
5608 | add eax, [_display.pitch] |
5610 | add eax, [_display.pitch] |
5609 | dec ecx |
5611 | dec ecx |
5610 | jnz @r |
5612 | jnz @r |
5611 | ret |
5613 | ret |
5612 | ;------------------------------------------------------------------------------ |
5614 | ;------------------------------------------------------------------------------ |
5613 | align 4 |
5615 | align 4 |
5614 | set_screen: |
5616 | set_screen: |
5615 | ; in: |
5617 | ; in: |
5616 | ; eax - new Screen_Max_X |
5618 | ; eax - new Screen_Max_X |
5617 | ; ecx - new BytesPerScanLine |
5619 | ; ecx - new BytesPerScanLine |
5618 | ; edx - new Screen_Max_Y |
5620 | ; edx - new Screen_Max_Y |
5619 | 5621 | ||
5620 | pushfd |
5622 | pushfd |
5621 | cli |
5623 | cli |
5622 | 5624 | ||
5623 | mov [Screen_Max_X], eax |
5625 | mov [Screen_Max_X], eax |
5624 | mov [Screen_Max_Y], edx |
5626 | mov [Screen_Max_Y], edx |
5625 | mov [_display.pitch], ecx |
5627 | mov [_display.pitch], ecx |
5626 | 5628 | ||
5627 | mov [screen_workarea.right], eax |
5629 | mov [screen_workarea.right], eax |
5628 | mov [screen_workarea.bottom], edx |
5630 | mov [screen_workarea.bottom], edx |
5629 | 5631 | ||
5630 | push ebx |
5632 | push ebx |
5631 | push esi |
5633 | push esi |
5632 | push edi |
5634 | push edi |
5633 | 5635 | ||
5634 | pushad |
5636 | pushad |
5635 | 5637 | ||
5636 | cmp [do_not_touch_winmap], 1 |
5638 | cmp [do_not_touch_winmap], 1 |
5637 | je @f |
5639 | je @f |
5638 | 5640 | ||
5639 | stdcall kernel_free, [_WinMapAddress] |
5641 | stdcall kernel_free, [_WinMapAddress] |
5640 | 5642 | ||
5641 | mov eax, [_display.width] |
5643 | mov eax, [_display.width] |
5642 | mul [_display.height] |
5644 | mul [_display.height] |
5643 | mov [_WinMapSize], eax |
5645 | mov [_WinMapSize], eax |
5644 | 5646 | ||
5645 | stdcall kernel_alloc, eax |
5647 | stdcall kernel_alloc, eax |
5646 | mov [_WinMapAddress], eax |
5648 | mov [_WinMapAddress], eax |
5647 | test eax, eax |
5649 | test eax, eax |
5648 | jz .epic_fail |
5650 | jz .epic_fail |
5649 | ; store for f.18.24 |
5651 | ; store for f.18.24 |
5650 | mov eax, [_display.width] |
5652 | mov eax, [_display.width] |
5651 | mov [display_width_standard], eax |
5653 | mov [display_width_standard], eax |
5652 | 5654 | ||
5653 | mov eax, [_display.height] |
5655 | mov eax, [_display.height] |
5654 | mov [display_height_standard], eax |
5656 | mov [display_height_standard], eax |
5655 | @@: |
5657 | @@: |
5656 | call calculate_fast_getting_offset_for_WinMapAddress |
5658 | call calculate_fast_getting_offset_for_WinMapAddress |
5657 | ; for Qemu or non standart video cards |
5659 | ; for Qemu or non standart video cards |
5658 | ; Unfortunately [BytesPerScanLine] does not always |
5660 | ; Unfortunately [BytesPerScanLine] does not always |
5659 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5661 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5660 | call calculate_fast_getting_offset_for_LFB |
5662 | call calculate_fast_getting_offset_for_LFB |
5661 | popad |
5663 | popad |
5662 | 5664 | ||
5663 | call repos_windows |
5665 | call repos_windows |
5664 | xor eax, eax |
5666 | xor eax, eax |
5665 | xor ebx, ebx |
5667 | xor ebx, ebx |
5666 | mov ecx, [Screen_Max_X] |
5668 | mov ecx, [Screen_Max_X] |
5667 | mov edx, [Screen_Max_Y] |
5669 | mov edx, [Screen_Max_Y] |
5668 | call calculatescreen |
5670 | call calculatescreen |
5669 | pop edi |
5671 | pop edi |
5670 | pop esi |
5672 | pop esi |
5671 | pop ebx |
5673 | pop ebx |
5672 | 5674 | ||
5673 | popfd |
5675 | popfd |
5674 | ret |
5676 | ret |
5675 | 5677 | ||
5676 | .epic_fail: |
5678 | .epic_fail: |
5677 | hlt ; Houston, we've had a problem |
5679 | hlt ; Houston, we've had a problem |
5678 | 5680 | ||
5679 | ; --------------- APM --------------------- |
5681 | ; --------------- APM --------------------- |
5680 | uglobal |
5682 | uglobal |
5681 | apm_entry dp 0 |
5683 | apm_entry dp 0 |
5682 | apm_vf dd 0 |
5684 | apm_vf dd 0 |
5683 | endg |
5685 | endg |
5684 | 5686 | ||
5685 | align 4 |
5687 | align 4 |
5686 | sys_apm: |
5688 | sys_apm: |
5687 | xor eax, eax |
5689 | xor eax, eax |
5688 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5690 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5689 | jne @f |
5691 | jne @f |
5690 | inc eax |
5692 | inc eax |
5691 | or dword [esp + 44], eax ; error |
5693 | or dword [esp + 44], eax ; error |
5692 | add eax, 7 |
5694 | add eax, 7 |
5693 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5695 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5694 | ret |
5696 | ret |
5695 | 5697 | ||
5696 | @@: |
5698 | @@: |
5697 | ; xchg eax, ecx |
5699 | ; xchg eax, ecx |
5698 | ; xchg ebx, ecx |
5700 | ; xchg ebx, ecx |
5699 | 5701 | ||
5700 | cmp dx, 3 |
5702 | cmp dx, 3 |
5701 | ja @f |
5703 | ja @f |
5702 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5704 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5703 | mov eax, [apm_vf] |
5705 | mov eax, [apm_vf] |
5704 | mov [esp + 32], eax |
5706 | mov [esp + 32], eax |
5705 | shr eax, 16 |
5707 | shr eax, 16 |
5706 | mov [esp + 28], eax |
5708 | mov [esp + 28], eax |
5707 | ret |
5709 | ret |
5708 | 5710 | ||
5709 | @@: |
5711 | @@: |
5710 | 5712 | ||
5711 | mov esi, [master_tab+(OS_BASE shr 20)] |
5713 | mov esi, [master_tab+(OS_BASE shr 20)] |
5712 | xchg [master_tab], esi |
5714 | xchg [master_tab], esi |
5713 | push esi |
5715 | push esi |
5714 | mov edi, cr3 |
5716 | mov edi, cr3 |
5715 | mov cr3, edi ;flush TLB |
5717 | mov cr3, edi ;flush TLB |
5716 | 5718 | ||
5717 | call pword [apm_entry] ;call APM BIOS |
5719 | call pword [apm_entry] ;call APM BIOS |
5718 | 5720 | ||
5719 | xchg eax, [esp] |
5721 | xchg eax, [esp] |
5720 | mov [master_tab], eax |
5722 | mov [master_tab], eax |
5721 | mov eax, cr3 |
5723 | mov eax, cr3 |
5722 | mov cr3, eax |
5724 | mov cr3, eax |
5723 | pop eax |
5725 | pop eax |
5724 | 5726 | ||
5725 | mov [esp + 4 ], edi |
5727 | mov [esp + 4 ], edi |
5726 | mov [esp + 8], esi |
5728 | mov [esp + 8], esi |
5727 | mov [esp + 20], ebx |
5729 | mov [esp + 20], ebx |
5728 | mov [esp + 24], edx |
5730 | mov [esp + 24], edx |
5729 | mov [esp + 28], ecx |
5731 | mov [esp + 28], ecx |
5730 | mov [esp + 32], eax |
5732 | mov [esp + 32], eax |
5731 | setc al |
5733 | setc al |
5732 | and [esp + 44], byte 0xfe |
5734 | and [esp + 44], byte 0xfe |
5733 | or [esp + 44], al |
5735 | or [esp + 44], al |
5734 | ret |
5736 | ret |
5735 | ; ----------------------------------------- |
5737 | ; ----------------------------------------- |
5736 | 5738 | ||
5737 | align 4 |
5739 | align 4 |
5738 | 5740 | ||
5739 | undefined_syscall: ; Undefined system call |
5741 | undefined_syscall: ; Undefined system call |
5740 | mov [esp + 32], dword -1 |
5742 | mov [esp + 32], dword -1 |
5741 | ret |
5743 | ret |
5742 | 5744 | ||
5743 | align 4 |
5745 | align 4 |
5744 | system_shutdown: ; shut down the system |
5746 | system_shutdown: ; shut down the system |
5745 | 5747 | ||
5746 | cmp byte [BOOT_VARS+0x9030], 1 |
5748 | cmp byte [BOOT_VARS+0x9030], 1 |
5747 | jne @F |
5749 | jne @F |
5748 | ret |
5750 | ret |
5749 | @@: |
5751 | @@: |
5750 | call stop_all_services |
5752 | call stop_all_services |
5751 | movi eax, 3 |
5753 | movi eax, 3 |
5752 | call sys_cd_audio |
5754 | call sys_cd_audio |
5753 | 5755 | ||
5754 | yes_shutdown_param: |
5756 | yes_shutdown_param: |
5755 | cli |
5757 | cli |
5756 | 5758 | ||
5757 | if ~ defined extended_primary_loader |
5759 | if ~ defined extended_primary_loader |
5758 | ; load kernel.mnt to 0x7000:0 |
5760 | ; load kernel.mnt to 0x7000:0 |
5759 | mov ebx, kernel_file_load |
5761 | mov ebx, kernel_file_load |
5760 | pushad |
5762 | pushad |
5761 | call file_system_lfn |
5763 | call file_system_lfn |
5762 | popad |
5764 | popad |
5763 | 5765 | ||
5764 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5766 | mov esi, restart_kernel_4000+OS_BASE+0x10000 ; move kernel re-starter to 0x4000:0 |
5765 | mov edi, OS_BASE+0x40000 |
5767 | mov edi, OS_BASE+0x40000 |
5766 | mov ecx, 1000 |
5768 | mov ecx, 1000 |
5767 | rep movsb |
5769 | rep movsb |
5768 | end if |
5770 | end if |
5769 | 5771 | ||
5770 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5772 | ; mov esi, BOOT_VAR ; restore 0x0 - 0xffff |
5771 | ; mov edi, OS_BASE |
5773 | ; mov edi, OS_BASE |
5772 | ; mov ecx, 0x10000/4 |
5774 | ; mov ecx, 0x10000/4 |
5773 | ; cld |
5775 | ; cld |
5774 | ; rep movsd |
5776 | ; rep movsd |
5775 | 5777 | ||
5776 | call IRQ_mask_all |
5778 | call IRQ_mask_all |
5777 | 5779 | ||
5778 | if 0 |
5780 | if 0 |
5779 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5781 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5780 | mov word [OS_BASE+0x467+2], 0x1000 |
5782 | mov word [OS_BASE+0x467+2], 0x1000 |
5781 | 5783 | ||
5782 | mov al, 0x0F |
5784 | mov al, 0x0F |
5783 | out 0x70, al |
5785 | out 0x70, al |
5784 | mov al, 0x05 |
5786 | mov al, 0x05 |
5785 | out 0x71, al |
5787 | out 0x71, al |
5786 | 5788 | ||
5787 | mov al, 0xFE |
5789 | mov al, 0xFE |
5788 | out 0x64, al |
5790 | out 0x64, al |
5789 | 5791 | ||
5790 | hlt |
5792 | hlt |
5791 | jmp $-1 |
5793 | jmp $-1 |
5792 | 5794 | ||
5793 | else |
5795 | else |
5794 | cmp byte [OS_BASE + 0x9030], 2 |
5796 | cmp byte [OS_BASE + 0x9030], 2 |
5795 | jnz no_acpi_power_off |
5797 | jnz no_acpi_power_off |
5796 | 5798 | ||
5797 | ; scan for RSDP |
5799 | ; scan for RSDP |
5798 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5800 | ; 1) The first 1 Kb of the Extended BIOS Data Area (EBDA). |
5799 | movzx eax, word [OS_BASE + 0x40E] |
5801 | movzx eax, word [OS_BASE + 0x40E] |
5800 | shl eax, 4 |
5802 | shl eax, 4 |
5801 | jz @f |
5803 | jz @f |
5802 | mov ecx, 1024/16 |
5804 | mov ecx, 1024/16 |
5803 | call scan_rsdp |
5805 | call scan_rsdp |
5804 | jnc .rsdp_found |
5806 | jnc .rsdp_found |
5805 | @@: |
5807 | @@: |
5806 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5808 | ; 2) The BIOS read-only memory space between 0E0000h and 0FFFFFh. |
5807 | mov eax, 0xE0000 |
5809 | mov eax, 0xE0000 |
5808 | mov ecx, 0x2000 |
5810 | mov ecx, 0x2000 |
5809 | call scan_rsdp |
5811 | call scan_rsdp |
5810 | jc no_acpi_power_off |
5812 | jc no_acpi_power_off |
5811 | .rsdp_found: |
5813 | .rsdp_found: |
5812 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5814 | mov esi, [eax+16] ; esi contains physical address of the RSDT |
5813 | mov ebp, [ipc_tmp] |
5815 | mov ebp, [ipc_tmp] |
5814 | stdcall map_page, ebp, esi, PG_MAP |
5816 | stdcall map_page, ebp, esi, PG_MAP |
5815 | lea eax, [esi+1000h] |
5817 | lea eax, [esi+1000h] |
5816 | lea edx, [ebp+1000h] |
5818 | lea edx, [ebp+1000h] |
5817 | stdcall map_page, edx, eax, PG_MAP |
5819 | stdcall map_page, edx, eax, PG_MAP |
5818 | and esi, 0xFFF |
5820 | and esi, 0xFFF |
5819 | add esi, ebp |
5821 | add esi, ebp |
5820 | cmp dword [esi], 'RSDT' |
5822 | cmp dword [esi], 'RSDT' |
5821 | jnz no_acpi_power_off |
5823 | jnz no_acpi_power_off |
5822 | mov ecx, [esi+4] |
5824 | mov ecx, [esi+4] |
5823 | sub ecx, 24h |
5825 | sub ecx, 24h |
5824 | jbe no_acpi_power_off |
5826 | jbe no_acpi_power_off |
5825 | shr ecx, 2 |
5827 | shr ecx, 2 |
5826 | add esi, 24h |
5828 | add esi, 24h |
5827 | .scan_fadt: |
5829 | .scan_fadt: |
5828 | lodsd |
5830 | lodsd |
5829 | mov ebx, eax |
5831 | mov ebx, eax |
5830 | lea eax, [ebp+2000h] |
5832 | lea eax, [ebp+2000h] |
5831 | stdcall map_page, eax, ebx, PG_MAP |
5833 | stdcall map_page, eax, ebx, PG_MAP |
5832 | lea eax, [ebp+3000h] |
5834 | lea eax, [ebp+3000h] |
5833 | add ebx, 0x1000 |
5835 | add ebx, 0x1000 |
5834 | stdcall map_page, eax, ebx, PG_MAP |
5836 | stdcall map_page, eax, ebx, PG_MAP |
5835 | and ebx, 0xFFF |
5837 | and ebx, 0xFFF |
5836 | lea ebx, [ebx+ebp+2000h] |
5838 | lea ebx, [ebx+ebp+2000h] |
5837 | cmp dword [ebx], 'FACP' |
5839 | cmp dword [ebx], 'FACP' |
5838 | jz .fadt_found |
5840 | jz .fadt_found |
5839 | loop .scan_fadt |
5841 | loop .scan_fadt |
5840 | jmp no_acpi_power_off |
5842 | jmp no_acpi_power_off |
5841 | .fadt_found: |
5843 | .fadt_found: |
5842 | ; ebx is linear address of FADT |
5844 | ; ebx is linear address of FADT |
5843 | mov edi, [ebx+40] ; physical address of the DSDT |
5845 | mov edi, [ebx+40] ; physical address of the DSDT |
5844 | lea eax, [ebp+4000h] |
5846 | lea eax, [ebp+4000h] |
5845 | stdcall map_page, eax, edi, PG_MAP |
5847 | stdcall map_page, eax, edi, PG_MAP |
5846 | lea eax, [ebp+5000h] |
5848 | lea eax, [ebp+5000h] |
5847 | lea esi, [edi+0x1000] |
5849 | lea esi, [edi+0x1000] |
5848 | stdcall map_page, eax, esi, PG_MAP |
5850 | stdcall map_page, eax, esi, PG_MAP |
5849 | and esi, 0xFFF |
5851 | and esi, 0xFFF |
5850 | sub edi, esi |
5852 | sub edi, esi |
5851 | cmp dword [esi+ebp+4000h], 'DSDT' |
5853 | cmp dword [esi+ebp+4000h], 'DSDT' |
5852 | jnz no_acpi_power_off |
5854 | jnz no_acpi_power_off |
5853 | mov eax, [esi+ebp+4004h] ; DSDT length |
5855 | mov eax, [esi+ebp+4004h] ; DSDT length |
5854 | sub eax, 36+4 |
5856 | sub eax, 36+4 |
5855 | jbe no_acpi_power_off |
5857 | jbe no_acpi_power_off |
5856 | add esi, 36 |
5858 | add esi, 36 |
5857 | .scan_dsdt: |
5859 | .scan_dsdt: |
5858 | cmp dword [esi+ebp+4000h], '_S5_' |
5860 | cmp dword [esi+ebp+4000h], '_S5_' |
5859 | jnz .scan_dsdt_cont |
5861 | jnz .scan_dsdt_cont |
5860 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5862 | cmp byte [esi+ebp+4000h+4], 12h ; DefPackage opcode |
5861 | jnz .scan_dsdt_cont |
5863 | jnz .scan_dsdt_cont |
5862 | mov dl, [esi+ebp+4000h+6] |
5864 | mov dl, [esi+ebp+4000h+6] |
5863 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5865 | cmp dl, 4 ; _S5_ package must contain 4 bytes |
5864 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5866 | ; ...in theory; in practice, VirtualBox has 2 bytes |
5865 | ja .scan_dsdt_cont |
5867 | ja .scan_dsdt_cont |
5866 | cmp dl, 1 |
5868 | cmp dl, 1 |
5867 | jb .scan_dsdt_cont |
5869 | jb .scan_dsdt_cont |
5868 | lea esi, [esi+ebp+4000h+7] |
5870 | lea esi, [esi+ebp+4000h+7] |
5869 | xor ecx, ecx |
5871 | xor ecx, ecx |
5870 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5872 | cmp byte [esi], 0 ; 0 means zero byte, 0Ah xx means byte xx |
5871 | jz @f |
5873 | jz @f |
5872 | cmp byte [esi], 0xA |
5874 | cmp byte [esi], 0xA |
5873 | jnz no_acpi_power_off |
5875 | jnz no_acpi_power_off |
5874 | inc esi |
5876 | inc esi |
5875 | mov cl, [esi] |
5877 | mov cl, [esi] |
5876 | @@: |
5878 | @@: |
5877 | inc esi |
5879 | inc esi |
5878 | cmp dl, 2 |
5880 | cmp dl, 2 |
5879 | jb @f |
5881 | jb @f |
5880 | cmp byte [esi], 0 |
5882 | cmp byte [esi], 0 |
5881 | jz @f |
5883 | jz @f |
5882 | cmp byte [esi], 0xA |
5884 | cmp byte [esi], 0xA |
5883 | jnz no_acpi_power_off |
5885 | jnz no_acpi_power_off |
5884 | inc esi |
5886 | inc esi |
5885 | mov ch, [esi] |
5887 | mov ch, [esi] |
5886 | @@: |
5888 | @@: |
5887 | jmp do_acpi_power_off |
5889 | jmp do_acpi_power_off |
5888 | .scan_dsdt_cont: |
5890 | .scan_dsdt_cont: |
5889 | inc esi |
5891 | inc esi |
5890 | cmp esi, 0x1000 |
5892 | cmp esi, 0x1000 |
5891 | jb @f |
5893 | jb @f |
5892 | sub esi, 0x1000 |
5894 | sub esi, 0x1000 |
5893 | add edi, 0x1000 |
5895 | add edi, 0x1000 |
5894 | push eax |
5896 | push eax |
5895 | lea eax, [ebp+4000h] |
5897 | lea eax, [ebp+4000h] |
5896 | stdcall map_page, eax, edi, PG_MAP |
5898 | stdcall map_page, eax, edi, PG_MAP |
5897 | push PG_MAP |
5899 | push PG_MAP |
5898 | lea eax, [edi+1000h] |
5900 | lea eax, [edi+1000h] |
5899 | push eax |
5901 | push eax |
5900 | lea eax, [ebp+5000h] |
5902 | lea eax, [ebp+5000h] |
5901 | push eax |
5903 | push eax |
5902 | stdcall map_page |
5904 | stdcall map_page |
5903 | pop eax |
5905 | pop eax |
5904 | @@: |
5906 | @@: |
5905 | dec eax |
5907 | dec eax |
5906 | jnz .scan_dsdt |
5908 | jnz .scan_dsdt |
5907 | jmp no_acpi_power_off |
5909 | jmp no_acpi_power_off |
5908 | do_acpi_power_off: |
5910 | do_acpi_power_off: |
5909 | mov edx, [ebx+48] |
5911 | mov edx, [ebx+48] |
5910 | test edx, edx |
5912 | test edx, edx |
5911 | jz .nosmi |
5913 | jz .nosmi |
5912 | mov al, [ebx+52] |
5914 | mov al, [ebx+52] |
5913 | out dx, al |
5915 | out dx, al |
5914 | mov edx, [ebx+64] |
5916 | mov edx, [ebx+64] |
5915 | @@: |
5917 | @@: |
5916 | in ax, dx |
5918 | in ax, dx |
5917 | test al, 1 |
5919 | test al, 1 |
5918 | jz @b |
5920 | jz @b |
5919 | .nosmi: |
5921 | .nosmi: |
5920 | and cx, 0x0707 |
5922 | and cx, 0x0707 |
5921 | shl cx, 2 |
5923 | shl cx, 2 |
5922 | or cx, 0x2020 |
5924 | or cx, 0x2020 |
5923 | mov edx, [ebx+64] |
5925 | mov edx, [ebx+64] |
5924 | in ax, dx |
5926 | in ax, dx |
5925 | and ax, 203h |
5927 | and ax, 203h |
5926 | or ah, cl |
5928 | or ah, cl |
5927 | out dx, ax |
5929 | out dx, ax |
5928 | mov edx, [ebx+68] |
5930 | mov edx, [ebx+68] |
5929 | test edx, edx |
5931 | test edx, edx |
5930 | jz @f |
5932 | jz @f |
5931 | in ax, dx |
5933 | in ax, dx |
5932 | and ax, 203h |
5934 | and ax, 203h |
5933 | or ah, ch |
5935 | or ah, ch |
5934 | out dx, ax |
5936 | out dx, ax |
5935 | @@: |
5937 | @@: |
5936 | jmp $ |
5938 | jmp $ |
5937 | 5939 | ||
5938 | 5940 | ||
5939 | no_acpi_power_off: |
5941 | no_acpi_power_off: |
5940 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5942 | mov word [OS_BASE+0x467+0], pr_mode_exit |
5941 | mov word [OS_BASE+0x467+2], 0x1000 |
5943 | mov word [OS_BASE+0x467+2], 0x1000 |
5942 | 5944 | ||
5943 | mov al, 0x0F |
5945 | mov al, 0x0F |
5944 | out 0x70, al |
5946 | out 0x70, al |
5945 | mov al, 0x05 |
5947 | mov al, 0x05 |
5946 | out 0x71, al |
5948 | out 0x71, al |
5947 | 5949 | ||
5948 | mov al, 0xFE |
5950 | mov al, 0xFE |
5949 | out 0x64, al |
5951 | out 0x64, al |
5950 | 5952 | ||
5951 | hlt |
5953 | hlt |
5952 | jmp $-1 |
5954 | jmp $-1 |
5953 | 5955 | ||
5954 | scan_rsdp: |
5956 | scan_rsdp: |
5955 | add eax, OS_BASE |
5957 | add eax, OS_BASE |
5956 | .s: |
5958 | .s: |
5957 | cmp dword [eax], 'RSD ' |
5959 | cmp dword [eax], 'RSD ' |
5958 | jnz .n |
5960 | jnz .n |
5959 | cmp dword [eax+4], 'PTR ' |
5961 | cmp dword [eax+4], 'PTR ' |
5960 | jnz .n |
5962 | jnz .n |
5961 | xor edx, edx |
5963 | xor edx, edx |
5962 | xor esi, esi |
5964 | xor esi, esi |
5963 | @@: |
5965 | @@: |
5964 | add dl, [eax+esi] |
5966 | add dl, [eax+esi] |
5965 | inc esi |
5967 | inc esi |
5966 | cmp esi, 20 |
5968 | cmp esi, 20 |
5967 | jnz @b |
5969 | jnz @b |
5968 | test dl, dl |
5970 | test dl, dl |
5969 | jz .ok |
5971 | jz .ok |
5970 | .n: |
5972 | .n: |
5971 | add eax, 10h |
5973 | add eax, 10h |
5972 | loop .s |
5974 | loop .s |
5973 | stc |
5975 | stc |
5974 | .ok: |
5976 | .ok: |
5975 | ret |
5977 | ret |
5976 | end if |
5978 | end if |
5977 | 5979 | ||
5978 | if ~ lang eq sp |
5980 | if ~ lang eq sp |
5979 | diff16 "end of .text segment",0,$ |
5981 | diff16 "end of .text segment",0,$ |
5980 | end if |
5982 | end if |
5981 | 5983 | ||
5982 | include "data32.inc" |
5984 | include "data32.inc" |
5983 | 5985 | ||
5984 | __REV__ = __REV |
5986 | __REV__ = __REV |
5985 | 5987 | ||
5986 | if ~ lang eq sp |
5988 | if ~ lang eq sp |
5987 | diff16 "end of kernel code",0,$ |
5989 | diff16 "end of kernel code",0,$ |
5988 | end if=> |
5990 | end if=> |