Rev 8087 | Rev 8091 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8087 | Rev 8089 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; |
2 | ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2020. All rights reserved. |
3 | ;; Copyright (C) KolibriOS team 2004-2020. 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: 8087 $ |
74 | $Revision: 8089 $ |
75 | 75 | ||
76 | 76 | ||
77 | USE_COM_IRQ = 1 ; make irq 3 and irq 4 available for PCI devices |
77 | USE_COM_IRQ = 1 ; make irq 3 and irq 4 available for PCI devices |
78 | VESA_1_2_VIDEO = 0 ; enable vesa 1.2 bank switch functions |
78 | VESA_1_2_VIDEO = 0 ; enable vesa 1.2 bank switch functions |
79 | 79 | ||
80 | ; Enabling the next line will enable serial output console |
80 | ; Enabling the next line will enable serial output console |
81 | ;debug_com_base = 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
81 | ;debug_com_base = 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used |
82 | 82 | ||
83 | include "proc32.inc" |
83 | include "proc32.inc" |
84 | include "kglobals.inc" |
84 | include "kglobals.inc" |
85 | include "lang.inc" |
85 | include "lang.inc" |
86 | include "encoding.inc" |
86 | include "encoding.inc" |
87 | 87 | ||
88 | include "const.inc" |
88 | include "const.inc" |
89 | 89 | ||
90 | iglobal |
90 | iglobal |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
91 | ; The following variable, if equal to 1, duplicates debug output to the screen. |
92 | debug_direct_print db 0 |
92 | debug_direct_print db 0 |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
93 | ; Start the first app (LAUNCHER) after kernel is loaded? (1=yes, 2 or 0=no) |
94 | launcher_start db 1 |
94 | launcher_start db 1 |
95 | endg |
95 | endg |
96 | 96 | ||
97 | max_processes = 255 |
97 | max_processes = 255 |
98 | tss_step = 128 + 8192 ; tss & i/o - 65535 ports, * 256=557056*4 |
98 | tss_step = 128 + 8192 ; tss & i/o - 65535 ports, * 256=557056*4 |
99 | 99 | ||
100 | os_stack = os_data_l - gdts ; GDTs |
100 | os_stack = os_data_l - gdts ; GDTs |
101 | os_code = os_code_l - gdts |
101 | os_code = os_code_l - gdts |
102 | graph_data = 3 + graph_data_l - gdts |
102 | graph_data = 3 + graph_data_l - gdts |
103 | tss0 = tss0_l - gdts |
103 | tss0 = tss0_l - gdts |
104 | app_code = 3 + app_code_l - gdts |
104 | app_code = 3 + app_code_l - gdts |
105 | app_data = 3 + app_data_l - gdts |
105 | app_data = 3 + app_data_l - gdts |
106 | app_tls = 3 + tls_data_l - gdts |
106 | app_tls = 3 + tls_data_l - gdts |
107 | pci_code_sel = pci_code_32-gdts |
107 | pci_code_sel = pci_code_32-gdts |
108 | pci_data_sel = pci_data_32-gdts |
108 | pci_data_sel = pci_data_32-gdts |
109 | 109 | ||
110 | 110 | ||
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
111 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
112 | ;; |
112 | ;; |
113 | ;; Included files: |
113 | ;; Included files: |
114 | ;; |
114 | ;; |
115 | ;; Kernel16.inc |
115 | ;; Kernel16.inc |
116 | ;; - Booteng.inc English text for bootup |
116 | ;; - Booteng.inc English text for bootup |
117 | ;; - Bootcode.inc Hardware setup |
117 | ;; - Bootcode.inc Hardware setup |
118 | ;; - Pci16.inc PCI functions |
118 | ;; - Pci16.inc PCI functions |
119 | ;; |
119 | ;; |
120 | ;; Kernel32.inc |
120 | ;; Kernel32.inc |
121 | ;; - Sys32.inc Process management |
121 | ;; - Sys32.inc Process management |
122 | ;; - Shutdown.inc Shutdown and restart |
122 | ;; - Shutdown.inc Shutdown and restart |
123 | ;; - Fat32.inc Read / write hd |
123 | ;; - Fat32.inc Read / write hd |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
124 | ;; - Vesa12.inc Vesa 1.2 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
125 | ;; - Vesa20.inc Vesa 2.0 driver |
126 | ;; - Vga.inc VGA driver |
126 | ;; - Vga.inc VGA driver |
127 | ;; - Stack.inc Network interface |
127 | ;; - Stack.inc Network interface |
128 | ;; - Mouse.inc Mouse pointer |
128 | ;; - Mouse.inc Mouse pointer |
129 | ;; - Scincode.inc Window skinning |
129 | ;; - Scincode.inc Window skinning |
130 | ;; - Pci32.inc PCI functions |
130 | ;; - Pci32.inc PCI functions |
131 | ;; |
131 | ;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
132 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
133 | 133 | ||
134 | ; In bios boot mode the kernel code below is appended to bootbios.bin file. |
134 | ; In bios boot mode the kernel code below is appended to bootbios.bin file. |
135 | ; That is a loading and initialization code that also draws the blue screen |
135 | ; That is a loading and initialization code that also draws the blue screen |
136 | ; menu with svn revision number near top right corner of the screen. This fasm |
136 | ; menu with svn revision number near top right corner of the screen. This fasm |
137 | ; preprocessor code searches for '****' signature inside bootbios.bin and |
137 | ; preprocessor code searches for '****' signature inside bootbios.bin and |
138 | ; places revision number there. |
138 | ; places revision number there. |
139 | if ~ defined UEFI |
139 | if ~ defined UEFI |
140 | bootbios: |
140 | bootbios: |
141 | file 'bootbios.bin' |
141 | file 'bootbios.bin' |
142 | if __REV__ > 0 |
142 | if __REV__ > 0 |
143 | cur_pos = 0 |
143 | cur_pos = 0 |
144 | cnt = 0 |
144 | cnt = 0 |
145 | repeat $ - bootbios |
145 | repeat $ - bootbios |
146 | load a byte from % |
146 | load a byte from % |
147 | if a = '*' |
147 | if a = '*' |
148 | cnt = cnt + 1 |
148 | cnt = cnt + 1 |
149 | else |
149 | else |
150 | cnt = 0 |
150 | cnt = 0 |
151 | end if |
151 | end if |
152 | if cnt = 4 |
152 | if cnt = 4 |
153 | cur_pos = % - 1 |
153 | cur_pos = % - 1 |
154 | break |
154 | break |
155 | end if |
155 | end if |
156 | end repeat |
156 | end repeat |
157 | store byte ' ' at cur_pos + 1 |
157 | store byte ' ' at cur_pos + 1 |
158 | rev_var = __REV__ |
158 | rev_var = __REV__ |
159 | while rev_var > 0 |
159 | while rev_var > 0 |
160 | store byte rev_var mod 10 + '0' at cur_pos |
160 | store byte rev_var mod 10 + '0' at cur_pos |
161 | cur_pos = cur_pos - 1 |
161 | cur_pos = cur_pos - 1 |
162 | rev_var = rev_var / 10 |
162 | rev_var = rev_var / 10 |
163 | end while |
163 | end while |
164 | store byte ' ' at cur_pos |
164 | store byte ' ' at cur_pos |
165 | store dword ' SVN' at cur_pos - 4 |
165 | store dword ' SVN' at cur_pos - 4 |
166 | end if |
166 | end if |
167 | end if |
167 | end if |
168 | 168 | ||
169 | use32 |
169 | use32 |
170 | org $+0x10000 |
170 | org $+0x10000 |
171 | 171 | ||
172 | align 4 |
172 | align 4 |
173 | B32: |
173 | B32: |
174 | mov ax, os_stack ; Selector for os |
174 | mov ax, os_stack ; Selector for os |
175 | mov ds, ax |
175 | mov ds, ax |
176 | mov es, ax |
176 | mov es, ax |
177 | mov fs, ax |
177 | mov fs, ax |
178 | mov gs, ax |
178 | mov gs, ax |
179 | mov ss, ax |
179 | mov ss, ax |
180 | mov esp, TMP_STACK_TOP ; Set stack |
180 | mov esp, TMP_STACK_TOP ; Set stack |
181 | 181 | ||
182 | ; CLEAR 0x280000 - HEAP_BASE |
182 | ; CLEAR 0x280000 - HEAP_BASE |
183 | 183 | ||
184 | xor eax, eax |
184 | xor eax, eax |
185 | mov edi, CLEAN_ZONE |
185 | mov edi, CLEAN_ZONE |
186 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
186 | mov ecx, (HEAP_BASE-OS_BASE-CLEAN_ZONE) / 4 |
187 | cld |
187 | cld |
188 | rep stosd |
188 | rep stosd |
189 | 189 | ||
190 | ; CLEAR KERNEL UNDEFINED GLOBALS |
190 | ; CLEAR KERNEL UNDEFINED GLOBALS |
191 | mov edi, endofcode-OS_BASE |
191 | mov edi, endofcode-OS_BASE |
192 | mov ecx, 0x90000 |
192 | mov ecx, 0x90000 |
193 | sub ecx, edi |
193 | sub ecx, edi |
194 | shr ecx, 2 |
194 | shr ecx, 2 |
195 | rep stosd |
195 | rep stosd |
196 | 196 | ||
197 | ; SAVE & CLEAR 0-0xffff |
197 | ; SAVE & CLEAR 0-0xffff |
198 | 198 | ||
199 | mov edi, 0x1000 |
199 | mov edi, 0x1000 |
200 | mov ecx, 0x8000 / 4 |
200 | mov ecx, 0x8000 / 4 |
201 | rep stosd |
201 | rep stosd |
202 | mov edi, 0xa000 |
202 | mov edi, 0xa000 |
203 | mov ecx, 0x6000 / 4 |
203 | mov ecx, 0x6000 / 4 |
204 | rep stosd |
204 | rep stosd |
205 | 205 | ||
206 | call test_cpu |
206 | call test_cpu |
207 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
207 | bts [cpu_caps-OS_BASE], CAPS_TSC ;force use rdtsc |
208 | 208 | ||
209 | call check_acpi |
209 | call check_acpi |
210 | call init_hpet |
210 | call init_hpet |
211 | call init_BIOS32 |
211 | call init_BIOS32 |
212 | ; MEMORY MODEL |
212 | ; MEMORY MODEL |
213 | call mem_test |
213 | call mem_test |
214 | call init_mem |
214 | call init_mem |
215 | call init_page_map |
215 | call init_page_map |
216 | 216 | ||
217 | ; ENABLE PAGING |
217 | ; ENABLE PAGING |
218 | 218 | ||
219 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
219 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
220 | mov cr3, eax |
220 | mov cr3, eax |
221 | 221 | ||
222 | mov eax, cr0 |
222 | mov eax, cr0 |
223 | or eax, CR0_PG+CR0_WP |
223 | or eax, CR0_PG+CR0_WP |
224 | mov cr0, eax |
224 | mov cr0, eax |
225 | 225 | ||
226 | lgdt [gdts] |
226 | lgdt [gdts] |
227 | jmp pword os_code:high_code |
227 | jmp pword os_code:high_code |
228 | 228 | ||
229 | align 4 |
229 | align 4 |
230 | bios32_entry dd ? |
230 | bios32_entry dd ? |
231 | tmp_page_tabs dd ? |
231 | tmp_page_tabs dd ? |
232 | use16 |
232 | use16 |
233 | ap_init16: |
233 | ap_init16: |
234 | cli |
234 | cli |
235 | lgdt [cs:gdts_ap-ap_init16] |
235 | lgdt [cs:gdts_ap-ap_init16] |
236 | mov eax, [cs:cr3_ap-ap_init16] |
236 | mov eax, [cs:cr3_ap-ap_init16] |
237 | mov cr3, eax |
237 | mov cr3, eax |
238 | mov eax, [cs:cr4_ap-ap_init16] |
238 | mov eax, [cs:cr4_ap-ap_init16] |
239 | mov cr4, eax |
239 | mov cr4, eax |
240 | mov eax, CR0_PE+CR0_PG+CR0_WP |
240 | mov eax, CR0_PE+CR0_PG+CR0_WP |
241 | mov cr0, eax |
241 | mov cr0, eax |
242 | jmp pword os_code:ap_init_high |
242 | jmp pword os_code:ap_init_high |
243 | align 16 |
243 | align 16 |
244 | gdts_ap: |
244 | gdts_ap: |
245 | dw gdte-gdts-1 |
245 | dw gdte-gdts-1 |
246 | dd gdts |
246 | dd gdts |
247 | dw 0 |
247 | dw 0 |
248 | cr3_ap dd ? |
248 | cr3_ap dd ? |
249 | cr4_ap dd ? |
249 | cr4_ap dd ? |
250 | ap_init16_size = $ - ap_init16 |
250 | ap_init16_size = $ - ap_init16 |
251 | use32 |
251 | use32 |
252 | 252 | ||
253 | __DEBUG__ fix 1 |
253 | __DEBUG__ fix 1 |
254 | __DEBUG_LEVEL__ fix 1 |
254 | __DEBUG_LEVEL__ fix 1 |
255 | include 'init.inc' |
255 | include 'init.inc' |
256 | 256 | ||
257 | org OS_BASE+$ |
257 | org OS_BASE+$ |
258 | 258 | ||
259 | include 'fdo.inc' |
259 | include 'fdo.inc' |
260 | 260 | ||
261 | align 4 |
261 | align 4 |
262 | high_code: |
262 | high_code: |
263 | mov ax, os_stack |
263 | mov ax, os_stack |
264 | mov bx, app_data |
264 | mov bx, app_data |
265 | mov cx, app_tls |
265 | mov cx, app_tls |
266 | mov ss, ax |
266 | mov ss, ax |
267 | add esp, OS_BASE |
267 | add esp, OS_BASE |
268 | 268 | ||
269 | mov ds, bx |
269 | mov ds, bx |
270 | mov es, bx |
270 | mov es, bx |
271 | mov fs, cx |
271 | mov fs, cx |
272 | mov gs, bx |
272 | mov gs, bx |
273 | 273 | ||
274 | xor eax, eax |
274 | xor eax, eax |
275 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
275 | mov ebx, 0xFFFFF000+PG_SHARED+PG_NOCACHE+PG_UWR |
276 | bt [cpu_caps], CAPS_PAT |
276 | bt [cpu_caps], CAPS_PAT |
277 | setc al |
277 | setc al |
278 | shl eax, 7 |
278 | shl eax, 7 |
279 | or ebx, eax |
279 | or ebx, eax |
280 | 280 | ||
281 | mov eax, PG_GLOBAL |
281 | mov eax, PG_GLOBAL |
282 | bt [cpu_caps], CAPS_PGE |
282 | bt [cpu_caps], CAPS_PGE |
283 | jnc @F |
283 | jnc @F |
284 | 284 | ||
285 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
285 | or [sys_proc+PROC.pdt_0+(OS_BASE shr 20)], eax |
286 | or ebx, eax |
286 | or ebx, eax |
287 | 287 | ||
288 | mov eax, cr4 |
288 | mov eax, cr4 |
289 | or eax, CR4_PGE |
289 | or eax, CR4_PGE |
290 | mov cr4, eax |
290 | mov cr4, eax |
291 | @@: |
291 | @@: |
292 | mov [pte_valid_mask], ebx |
292 | mov [pte_valid_mask], ebx |
293 | 293 | ||
294 | xor eax, eax |
294 | xor eax, eax |
295 | mov dword [sys_proc+PROC.pdt_0], eax |
295 | mov dword [sys_proc+PROC.pdt_0], eax |
296 | mov dword [sys_proc+PROC.pdt_0+4], eax |
296 | mov dword [sys_proc+PROC.pdt_0+4], eax |
297 | 297 | ||
298 | mov eax, cr3 |
298 | mov eax, cr3 |
299 | mov cr3, eax ; flush TLB |
299 | mov cr3, eax ; flush TLB |
300 | 300 | ||
301 | mov ecx, pg_data.mutex |
301 | mov ecx, pg_data.mutex |
302 | call mutex_init |
302 | call mutex_init |
303 | 303 | ||
304 | mov ecx, disk_list_mutex |
304 | mov ecx, disk_list_mutex |
305 | call mutex_init |
305 | call mutex_init |
306 | 306 | ||
307 | mov ecx, keyboard_list_mutex |
307 | mov ecx, keyboard_list_mutex |
308 | call mutex_init |
308 | call mutex_init |
309 | 309 | ||
310 | mov ecx, unpack_mutex |
310 | mov ecx, unpack_mutex |
311 | call mutex_init |
311 | call mutex_init |
312 | 312 | ||
313 | mov ecx, application_table_mutex |
313 | mov ecx, application_table_mutex |
314 | call mutex_init |
314 | call mutex_init |
315 | 315 | ||
316 | mov ecx, ide_mutex |
316 | mov ecx, ide_mutex |
317 | call mutex_init |
317 | call mutex_init |
318 | mov ecx, ide_channel1_mutex |
318 | mov ecx, ide_channel1_mutex |
319 | call mutex_init |
319 | call mutex_init |
320 | mov ecx, ide_channel2_mutex |
320 | mov ecx, ide_channel2_mutex |
321 | call mutex_init |
321 | call mutex_init |
322 | mov ecx, ide_channel3_mutex |
322 | mov ecx, ide_channel3_mutex |
323 | call mutex_init |
323 | call mutex_init |
324 | mov ecx, ide_channel4_mutex |
324 | mov ecx, ide_channel4_mutex |
325 | call mutex_init |
325 | call mutex_init |
326 | mov ecx, ide_channel5_mutex |
326 | mov ecx, ide_channel5_mutex |
327 | call mutex_init |
327 | call mutex_init |
328 | mov ecx, ide_channel6_mutex |
328 | mov ecx, ide_channel6_mutex |
329 | call mutex_init |
329 | call mutex_init |
330 | ;----------------------------------------------------------------------------- |
330 | ;----------------------------------------------------------------------------- |
331 | ; SAVE REAL MODE VARIABLES |
331 | ; SAVE REAL MODE VARIABLES |
332 | ;----------------------------------------------------------------------------- |
332 | ;----------------------------------------------------------------------------- |
333 | ; --------------- APM --------------------- |
333 | ; --------------- APM --------------------- |
334 | 334 | ||
335 | ; init selectors |
335 | ; init selectors |
336 | mov ebx, [BOOT.apm_entry] ; offset of APM entry point |
336 | mov ebx, [BOOT.apm_entry] ; offset of APM entry point |
337 | movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of |
337 | movzx eax, word [BOOT.apm_code_32] ; real-mode segment base address of |
338 | ; protected-mode 32-bit code segment |
338 | ; protected-mode 32-bit code segment |
339 | movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of |
339 | movzx ecx, word [BOOT.apm_code_16] ; real-mode segment base address of |
340 | ; protected-mode 16-bit code segment |
340 | ; protected-mode 16-bit code segment |
341 | movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of |
341 | movzx edx, word [BOOT.apm_data_16] ; real-mode segment base address of |
342 | ; protected-mode 16-bit data segment |
342 | ; protected-mode 16-bit data segment |
343 | 343 | ||
344 | shl eax, 4 |
344 | shl eax, 4 |
345 | mov [dword apm_code_32 + 2], ax |
345 | mov [dword apm_code_32 + 2], ax |
346 | shr eax, 16 |
346 | shr eax, 16 |
347 | mov [dword apm_code_32 + 4], al |
347 | mov [dword apm_code_32 + 4], al |
348 | 348 | ||
349 | shl ecx, 4 |
349 | shl ecx, 4 |
350 | mov [dword apm_code_16 + 2], cx |
350 | mov [dword apm_code_16 + 2], cx |
351 | shr ecx, 16 |
351 | shr ecx, 16 |
352 | mov [dword apm_code_16 + 4], cl |
352 | mov [dword apm_code_16 + 4], cl |
353 | 353 | ||
354 | shl edx, 4 |
354 | shl edx, 4 |
355 | mov [dword apm_data_16 + 2], dx |
355 | mov [dword apm_data_16 + 2], dx |
356 | shr edx, 16 |
356 | shr edx, 16 |
357 | mov [dword apm_data_16 + 4], dl |
357 | mov [dword apm_data_16 + 4], dl |
358 | 358 | ||
359 | mov dword[apm_entry], ebx |
359 | mov dword[apm_entry], ebx |
360 | mov word [apm_entry + 4], apm_code_32 - gdts |
360 | mov word [apm_entry + 4], apm_code_32 - gdts |
361 | 361 | ||
362 | mov eax, dword[BOOT.apm_version] ; version & flags |
362 | mov eax, dword[BOOT.apm_version] ; version & flags |
363 | mov [apm_vf], eax |
363 | mov [apm_vf], eax |
364 | ; ----------------------------------------- |
364 | ; ----------------------------------------- |
365 | mov al, [BOOT.dma] ; DMA access |
365 | mov al, [BOOT.dma] ; DMA access |
366 | mov [allow_dma_access], al |
366 | mov [allow_dma_access], al |
367 | 367 | ||
368 | mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen |
368 | mov al, [BOOT.debug_print] ; If nonzero, duplicates debug output to the screen |
369 | mov [debug_direct_print], al |
369 | mov [debug_direct_print], al |
370 | 370 | ||
371 | mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded? |
371 | mov al, [BOOT.launcher_start] ; Start the first app (LAUNCHER) after kernel is loaded? |
372 | mov [launcher_start], al |
372 | mov [launcher_start], al |
373 | 373 | ||
374 | mov esi, BOOT.bios_hd |
374 | mov esi, BOOT.bios_hd |
375 | movzx ecx, byte [esi-1] |
375 | movzx ecx, byte [esi-1] |
376 | mov [NumBiosDisks], ecx |
376 | mov [NumBiosDisks], ecx |
377 | mov edi, BiosDisksData |
377 | mov edi, BiosDisksData |
378 | shl ecx, 2 |
378 | shl ecx, 2 |
379 | rep movsd |
379 | rep movsd |
380 | 380 | ||
381 | ; -------- Fast System Call init ---------- |
381 | ; -------- Fast System Call init ---------- |
382 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
382 | ; Intel SYSENTER/SYSEXIT (AMD CPU support it too) |
383 | bt [cpu_caps], CAPS_SEP |
383 | bt [cpu_caps], CAPS_SEP |
384 | jnc .SEnP ; SysEnter not Present |
384 | jnc .SEnP ; SysEnter not Present |
385 | xor edx, edx |
385 | xor edx, edx |
386 | mov ecx, MSR_SYSENTER_CS |
386 | mov ecx, MSR_SYSENTER_CS |
387 | mov eax, os_code |
387 | mov eax, os_code |
388 | wrmsr |
388 | wrmsr |
389 | mov ecx, MSR_SYSENTER_ESP |
389 | mov ecx, MSR_SYSENTER_ESP |
390 | ; mov eax, sysenter_stack ; Check it |
390 | ; mov eax, sysenter_stack ; Check it |
391 | xor eax, eax |
391 | xor eax, eax |
392 | wrmsr |
392 | wrmsr |
393 | mov ecx, MSR_SYSENTER_EIP |
393 | mov ecx, MSR_SYSENTER_EIP |
394 | mov eax, sysenter_entry |
394 | mov eax, sysenter_entry |
395 | wrmsr |
395 | wrmsr |
396 | .SEnP: |
396 | .SEnP: |
397 | ; AMD SYSCALL/SYSRET |
397 | ; AMD SYSCALL/SYSRET |
398 | cmp byte[cpu_vendor], 'A' |
398 | cmp byte[cpu_vendor], 'A' |
399 | jne .noSYSCALL |
399 | jne .noSYSCALL |
400 | mov eax, 0x80000001 |
400 | mov eax, 0x80000001 |
401 | cpuid |
401 | cpuid |
402 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
402 | test edx, 0x800 ; bit_11 - SYSCALL/SYSRET support |
403 | jz .noSYSCALL |
403 | jz .noSYSCALL |
404 | mov ecx, MSR_AMD_EFER |
404 | mov ecx, MSR_AMD_EFER |
405 | rdmsr |
405 | rdmsr |
406 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
406 | or eax, 1 ; bit_0 - System Call Extension (SCE) |
407 | wrmsr |
407 | wrmsr |
408 | 408 | ||
409 | ; !!!! It`s dirty hack, fix it !!! |
409 | ; !!!! It`s dirty hack, fix it !!! |
410 | ; Bits of EDX : |
410 | ; Bits of EDX : |
411 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
411 | ; Bit 31–16 During the SYSRET instruction, this field is copied into the CS register |
412 | ; and the contents of this field, plus 8, are copied into the SS register. |
412 | ; and the contents of this field, plus 8, are copied into the SS register. |
413 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
413 | ; Bit 15–0 During the SYSCALL instruction, this field is copied into the CS register |
414 | ; and the contents of this field, plus 8, are copied into the SS register. |
414 | ; and the contents of this field, plus 8, are copied into the SS register. |
415 | 415 | ||
416 | ; mov edx, (os_code + 16) * 65536 + os_code |
416 | ; mov edx, (os_code + 16) * 65536 + os_code |
417 | mov edx, 0x1B0008 |
417 | mov edx, 0x1B0008 |
418 | 418 | ||
419 | mov eax, syscall_entry |
419 | mov eax, syscall_entry |
420 | mov ecx, MSR_AMD_STAR |
420 | mov ecx, MSR_AMD_STAR |
421 | wrmsr |
421 | wrmsr |
422 | .noSYSCALL: |
422 | .noSYSCALL: |
423 | ; ----------------------------------------- |
423 | ; ----------------------------------------- |
424 | stdcall alloc_page |
424 | stdcall alloc_page |
425 | stdcall map_page, tss-0xF80, eax, PG_SWR |
425 | stdcall map_page, tss-0xF80, eax, PG_SWR |
426 | stdcall alloc_page |
426 | stdcall alloc_page |
427 | stdcall map_page, tss+0x80, eax, PG_SWR |
427 | stdcall map_page, tss+0x80, eax, PG_SWR |
428 | stdcall alloc_page |
428 | stdcall alloc_page |
429 | stdcall map_page, tss+0x1080, eax, PG_SWR |
429 | stdcall map_page, tss+0x1080, eax, PG_SWR |
430 | 430 | ||
431 | ; LOAD IDT |
431 | ; LOAD IDT |
432 | 432 | ||
433 | call build_interrupt_table ;lidt is executed |
433 | call build_interrupt_table ;lidt is executed |
434 | ;lidt [idtreg] |
434 | ;lidt [idtreg] |
435 | 435 | ||
436 | call init_kernel_heap |
436 | call init_kernel_heap |
437 | call init_fpu |
437 | call init_fpu |
438 | mov eax, [xsave_area_size] |
438 | mov eax, [xsave_area_size] |
439 | lea eax, [eax*2 + RING0_STACK_SIZE*2] |
439 | lea eax, [eax*2 + RING0_STACK_SIZE*2] |
440 | stdcall kernel_alloc, eax |
440 | stdcall kernel_alloc, eax |
441 | mov [os_stack_seg], eax |
441 | mov [os_stack_seg], eax |
442 | 442 | ||
443 | lea esp, [eax+RING0_STACK_SIZE] |
443 | lea esp, [eax+RING0_STACK_SIZE] |
444 | 444 | ||
445 | mov [tss._ss0], os_stack |
445 | mov [tss._ss0], os_stack |
446 | mov [tss._esp0], esp |
446 | mov [tss._esp0], esp |
447 | mov [tss._esp], esp |
447 | mov [tss._esp], esp |
448 | mov [tss._cs], os_code |
448 | mov [tss._cs], os_code |
449 | mov [tss._ss], os_stack |
449 | mov [tss._ss], os_stack |
450 | mov [tss._ds], app_data |
450 | mov [tss._ds], app_data |
451 | mov [tss._es], app_data |
451 | mov [tss._es], app_data |
452 | mov [tss._fs], app_data |
452 | mov [tss._fs], app_data |
453 | mov [tss._gs], app_data |
453 | mov [tss._gs], app_data |
454 | mov [tss._io], 128 |
454 | mov [tss._io], 128 |
455 | ;Add IO access table - bit array of permitted ports |
455 | ;Add IO access table - bit array of permitted ports |
456 | mov edi, tss._io_map_0 |
456 | mov edi, tss._io_map_0 |
457 | xor eax, eax |
457 | xor eax, eax |
458 | not eax |
458 | not eax |
459 | mov ecx, 8192/4 |
459 | mov ecx, 8192/4 |
460 | rep stosd ; access to 4096*8=65536 ports |
460 | rep stosd ; access to 4096*8=65536 ports |
461 | 461 | ||
462 | mov ax, tss0 |
462 | mov ax, tss0 |
463 | ltr ax |
463 | ltr ax |
464 | 464 | ||
465 | mov eax, sys_proc |
465 | mov eax, sys_proc |
466 | list_init eax |
466 | list_init eax |
467 | add eax, PROC.thr_list |
467 | add eax, PROC.thr_list |
468 | list_init eax |
468 | list_init eax |
469 | 469 | ||
470 | call init_video |
470 | call init_video |
471 | call init_mtrr |
471 | call init_mtrr |
472 | mov [LFBAddress], LFB_BASE |
472 | mov [LFBAddress], LFB_BASE |
473 | mov ecx, bios_fb |
473 | mov ecx, bios_fb |
474 | call set_framebuffer |
474 | call set_framebuffer |
475 | call init_malloc |
475 | call init_malloc |
476 | 476 | ||
477 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
477 | stdcall alloc_kernel_space, 0x50000 ; FIXME check size |
478 | mov [default_io_map], eax |
478 | mov [default_io_map], eax |
479 | 479 | ||
480 | add eax, 0x2000 |
480 | add eax, 0x2000 |
481 | mov [ipc_tmp], eax |
481 | mov [ipc_tmp], eax |
482 | mov ebx, 0x1000 |
482 | mov ebx, 0x1000 |
483 | 483 | ||
484 | add eax, 0x40000 |
484 | add eax, 0x40000 |
485 | mov [proc_mem_map], eax |
485 | mov [proc_mem_map], eax |
486 | 486 | ||
487 | add eax, 0x8000 |
487 | add eax, 0x8000 |
488 | mov [proc_mem_pdir], eax |
488 | mov [proc_mem_pdir], eax |
489 | 489 | ||
490 | add eax, ebx |
490 | add eax, ebx |
491 | mov [proc_mem_tab], eax |
491 | mov [proc_mem_tab], eax |
492 | 492 | ||
493 | add eax, ebx |
493 | add eax, ebx |
494 | mov [tmp_task_ptab], eax |
494 | mov [tmp_task_ptab], eax |
495 | 495 | ||
496 | add eax, ebx |
496 | add eax, ebx |
497 | mov [ipc_pdir], eax |
497 | mov [ipc_pdir], eax |
498 | 498 | ||
499 | add eax, ebx |
499 | add eax, ebx |
500 | mov [ipc_ptab], eax |
500 | mov [ipc_ptab], eax |
501 | 501 | ||
502 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
502 | stdcall kernel_alloc, (unpack.LZMA_BASE_SIZE+(unpack.LZMA_LIT_SIZE shl \ |
503 | (unpack.lc+unpack.lp)))*4 |
503 | (unpack.lc+unpack.lp)))*4 |
504 | 504 | ||
505 | mov [unpack.p], eax |
505 | mov [unpack.p], eax |
506 | 506 | ||
507 | call init_events |
507 | call init_events |
508 | mov eax, srv.fd-SRV.fd |
508 | mov eax, srv.fd-SRV.fd |
509 | mov [srv.fd], eax |
509 | mov [srv.fd], eax |
510 | mov [srv.bk], eax |
510 | mov [srv.bk], eax |
511 | 511 | ||
512 | ;Set base of graphic segment to linear address of LFB |
512 | ;Set base of graphic segment to linear address of LFB |
513 | mov eax, [LFBAddress] ; set for gs |
513 | mov eax, [LFBAddress] ; set for gs |
514 | mov [graph_data_l+2], ax |
514 | mov [graph_data_l+2], ax |
515 | shr eax, 16 |
515 | shr eax, 16 |
516 | mov [graph_data_l+4], al |
516 | mov [graph_data_l+4], al |
517 | mov [graph_data_l+7], ah |
517 | mov [graph_data_l+7], ah |
518 | 518 | ||
519 | stdcall kernel_alloc, [_display.win_map_size] |
519 | stdcall kernel_alloc, [_display.win_map_size] |
520 | mov [_display.win_map], eax |
520 | mov [_display.win_map], eax |
521 | 521 | ||
522 | xor eax, eax |
522 | xor eax, eax |
523 | inc eax |
523 | inc eax |
524 | 524 | ||
525 | ; set background |
525 | ; set background |
526 | 526 | ||
527 | mov [BgrDrawMode], eax |
527 | mov [BgrDrawMode], eax |
528 | mov [BgrDataWidth], eax |
528 | mov [BgrDataWidth], eax |
529 | mov [BgrDataHeight], eax |
529 | mov [BgrDataHeight], eax |
530 | mov [mem_BACKGROUND], 4 |
530 | mov [mem_BACKGROUND], 4 |
531 | mov [img_background], static_background_data |
531 | mov [img_background], static_background_data |
532 | 532 | ||
533 | ; set clipboard |
533 | ; set clipboard |
534 | 534 | ||
535 | xor eax, eax |
535 | xor eax, eax |
536 | mov [clipboard_slots], eax |
536 | mov [clipboard_slots], eax |
537 | mov [clipboard_write_lock], eax |
537 | mov [clipboard_write_lock], eax |
538 | stdcall kernel_alloc, 4096 |
538 | stdcall kernel_alloc, 4096 |
539 | test eax, eax |
539 | test eax, eax |
540 | jnz @f |
540 | jnz @f |
541 | 541 | ||
542 | dec eax |
542 | dec eax |
543 | @@: |
543 | @@: |
544 | mov [clipboard_main_list], eax |
544 | mov [clipboard_main_list], eax |
545 | 545 | ||
546 | mov eax, [hpet_base] |
546 | mov eax, [hpet_base] |
547 | test eax, eax |
547 | test eax, eax |
548 | jz @F |
548 | jz @F |
549 | mov eax, [hpet_base] |
549 | mov eax, [hpet_base] |
550 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
550 | stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR |
551 | mov [hpet_base], eax |
551 | mov [hpet_base], eax |
552 | mov eax, [eax] |
552 | mov eax, [eax] |
553 | DEBUGF 1, "K : HPET caps %x\n", eax |
553 | DEBUGF 1, "K : HPET caps %x\n", eax |
554 | @@: |
554 | @@: |
555 | ; SET UP OS TASK |
555 | ; SET UP OS TASK |
556 | 556 | ||
557 | mov esi, boot_setostask |
557 | mov esi, boot_setostask |
558 | call boot_log |
558 | call boot_log |
559 | 559 | ||
560 | mov edi, sys_proc+PROC.heap_lock |
560 | mov edi, sys_proc+PROC.heap_lock |
561 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
561 | mov ecx, (PROC.ht_free-PROC.heap_lock)/4 |
562 | 562 | ||
563 | xor eax, eax |
563 | xor eax, eax |
564 | cld |
564 | cld |
565 | rep stosd |
565 | rep stosd |
566 | 566 | ||
567 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
567 | mov [edi], dword (PROC.pdt_0 - PROC.htab)/4 - 3 |
568 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
568 | mov [edi+4], dword 3 ;reserve handles for stdin stdout and stderr |
569 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
569 | mov ecx, (PROC.pdt_0 - PROC.htab)/4 |
570 | add edi, 8 |
570 | add edi, 8 |
571 | inc eax |
571 | inc eax |
572 | @@: |
572 | @@: |
573 | stosd |
573 | stosd |
574 | inc eax |
574 | inc eax |
575 | cmp eax, ecx |
575 | cmp eax, ecx |
576 | jbe @B |
576 | jbe @B |
577 | 577 | ||
578 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
578 | mov [sys_proc+PROC.pdt_0_phys], sys_proc-OS_BASE+PROC.pdt_0 |
579 | 579 | ||
580 | mov eax, -1 |
580 | mov eax, -1 |
581 | mov edi, thr_slot_map+4 |
581 | mov edi, thr_slot_map+4 |
582 | mov [edi-4], dword 0xFFFFFFF8 |
582 | mov [edi-4], dword 0xFFFFFFF8 |
583 | stosd |
583 | stosd |
584 | stosd |
584 | stosd |
585 | stosd |
585 | stosd |
586 | stosd |
586 | stosd |
587 | stosd |
587 | stosd |
588 | stosd |
588 | stosd |
589 | stosd |
589 | stosd |
590 | 590 | ||
591 | mov [current_process], sys_proc |
591 | mov [current_process], sys_proc |
592 | 592 | ||
593 | mov edx, SLOT_BASE+256*1 |
593 | mov edx, SLOT_BASE+256*1 |
594 | mov ebx, [os_stack_seg] |
594 | mov ebx, [os_stack_seg] |
595 | add ebx, RING0_STACK_SIZE |
595 | add ebx, RING0_STACK_SIZE |
596 | add ebx, [xsave_area_size] |
596 | add ebx, [xsave_area_size] |
597 | call setup_os_slot |
597 | call setup_os_slot |
598 | mov dword [edx], 'IDLE' |
598 | mov dword [edx], 'IDLE' |
599 | sub [edx+APPDATA.saved_esp], 4 |
599 | sub [edx+APPDATA.saved_esp], 4 |
600 | mov eax, [edx+APPDATA.saved_esp] |
600 | mov eax, [edx+APPDATA.saved_esp] |
601 | mov dword [eax], idle_thread |
601 | mov dword [eax], idle_thread |
602 | mov ecx, IDLE_PRIORITY |
602 | mov ecx, IDLE_PRIORITY |
603 | call scheduler_add_thread |
603 | call scheduler_add_thread |
604 | 604 | ||
605 | mov edx, SLOT_BASE+256*2 |
605 | mov edx, SLOT_BASE+256*2 |
606 | mov ebx, [os_stack_seg] |
606 | mov ebx, [os_stack_seg] |
607 | call setup_os_slot |
607 | call setup_os_slot |
608 | mov dword [edx], 'OS' |
608 | mov dword [edx], 'OS' |
609 | xor ecx, ecx |
609 | xor ecx, ecx |
610 | call scheduler_add_thread |
610 | call scheduler_add_thread |
611 | 611 | ||
612 | mov dword [CURRENT_TASK], 2 |
612 | mov dword [CURRENT_TASK], 2 |
613 | mov dword [TASK_COUNT], 2 |
613 | mov dword [TASK_COUNT], 2 |
614 | mov dword [current_slot], SLOT_BASE + 256*2 |
614 | mov dword [current_slot], SLOT_BASE + 256*2 |
615 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
615 | mov dword [TASK_BASE], CURRENT_TASK + 32*2 |
616 | 616 | ||
617 | ; Move other CPUs to deep sleep, if it is useful |
617 | ; Move other CPUs to deep sleep, if it is useful |
618 | uglobal |
618 | uglobal |
619 | use_mwait_for_idle db 0 |
619 | use_mwait_for_idle db 0 |
620 | endg |
620 | endg |
621 | cmp [cpu_vendor+8], 'ntel' |
621 | cmp [cpu_vendor+8], 'ntel' |
622 | jnz .no_wake_cpus |
622 | jnz .no_wake_cpus |
623 | bt [cpu_caps+4], CAPS_MONITOR-32 |
623 | bt [cpu_caps+4], CAPS_MONITOR-32 |
624 | jnc .no_wake_cpus |
624 | jnc .no_wake_cpus |
625 | dbgstr 'using mwait for idle loop' |
625 | dbgstr 'using mwait for idle loop' |
626 | inc [use_mwait_for_idle] |
626 | inc [use_mwait_for_idle] |
627 | mov ebx, [cpu_count] |
627 | mov ebx, [cpu_count] |
628 | cmp ebx, 1 |
628 | cmp ebx, 1 |
629 | jbe .no_wake_cpus |
629 | jbe .no_wake_cpus |
630 | call create_trampoline_pgmap |
630 | call create_trampoline_pgmap |
631 | mov [cr3_ap+OS_BASE], eax |
631 | mov [cr3_ap+OS_BASE], eax |
632 | mov eax, cr4 |
632 | mov eax, cr4 |
633 | mov [cr4_ap+OS_BASE], eax |
633 | mov [cr4_ap+OS_BASE], eax |
634 | mov esi, OS_BASE + ap_init16 |
634 | mov esi, OS_BASE + ap_init16 |
635 | mov edi, OS_BASE + 8000h |
635 | mov edi, OS_BASE + 8000h |
636 | mov ecx, (ap_init16_size + 3) / 4 |
636 | mov ecx, (ap_init16_size + 3) / 4 |
637 | rep movsd |
637 | rep movsd |
638 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
638 | stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_GLOBAL+PG_NOCACHE+PG_SWR |
639 | mov [LAPIC_BASE], eax |
639 | mov [LAPIC_BASE], eax |
640 | lea edi, [eax+300h] |
640 | lea edi, [eax+300h] |
641 | mov esi, smpt+4 |
641 | mov esi, smpt+4 |
642 | dec ebx |
642 | dec ebx |
643 | .wake_cpus_loop: |
643 | .wake_cpus_loop: |
644 | lodsd |
644 | lodsd |
645 | push esi |
645 | push esi |
646 | xor esi, esi |
646 | xor esi, esi |
647 | inc esi |
647 | inc esi |
648 | shl eax, 24 |
648 | shl eax, 24 |
649 | mov [edi+10h], eax |
649 | mov [edi+10h], eax |
650 | ; assert INIT IPI |
650 | ; assert INIT IPI |
651 | mov dword [edi], 0C500h |
651 | mov dword [edi], 0C500h |
652 | call delay_ms |
652 | call delay_ms |
653 | @@: |
653 | @@: |
654 | test dword [edi], 1000h |
654 | test dword [edi], 1000h |
655 | jnz @b |
655 | jnz @b |
656 | ; deassert INIT IPI |
656 | ; deassert INIT IPI |
657 | mov dword [edi], 8500h |
657 | mov dword [edi], 8500h |
658 | call delay_ms |
658 | call delay_ms |
659 | @@: |
659 | @@: |
660 | test dword [edi], 1000h |
660 | test dword [edi], 1000h |
661 | jnz @b |
661 | jnz @b |
662 | ; send STARTUP IPI |
662 | ; send STARTUP IPI |
663 | mov dword [edi], 600h + (8000h shr 12) |
663 | mov dword [edi], 600h + (8000h shr 12) |
664 | call delay_ms |
664 | call delay_ms |
665 | @@: |
665 | @@: |
666 | test dword [edi], 1000h |
666 | test dword [edi], 1000h |
667 | jnz @b |
667 | jnz @b |
668 | pop esi |
668 | pop esi |
669 | dec ebx |
669 | dec ebx |
670 | jnz .wake_cpus_loop |
670 | jnz .wake_cpus_loop |
671 | mov eax, [cpu_count] |
671 | mov eax, [cpu_count] |
672 | dec eax |
672 | dec eax |
673 | @@: |
673 | @@: |
674 | cmp [ap_initialized], eax |
674 | cmp [ap_initialized], eax |
675 | jnz @b |
675 | jnz @b |
676 | mov eax, [cr3_ap+OS_BASE] |
676 | mov eax, [cr3_ap+OS_BASE] |
677 | call free_page |
677 | call free_page |
678 | .no_wake_cpus: |
678 | .no_wake_cpus: |
679 | 679 | ||
680 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
680 | ; REDIRECT ALL IRQ'S TO INT'S 0x20-0x2f |
681 | mov esi, boot_initirq |
681 | mov esi, boot_initirq |
682 | call boot_log |
682 | call boot_log |
683 | call init_irqs |
683 | call init_irqs |
684 | 684 | ||
685 | mov esi, boot_picinit |
685 | mov esi, boot_picinit |
686 | call boot_log |
686 | call boot_log |
687 | call PIC_init |
687 | call PIC_init |
688 | 688 | ||
689 | mov esi, boot_v86machine |
689 | mov esi, boot_v86machine |
690 | call boot_log |
690 | call boot_log |
691 | ; Initialize system V86 machine |
691 | ; Initialize system V86 machine |
692 | call init_sys_v86 |
692 | call init_sys_v86 |
693 | 693 | ||
694 | mov esi, boot_inittimer |
694 | mov esi, boot_inittimer |
695 | call boot_log |
695 | call boot_log |
696 | ; Initialize system timer (IRQ0) |
696 | ; Initialize system timer (IRQ0) |
697 | call PIT_init |
697 | call PIT_init |
698 | 698 | ||
699 | ; Register ramdisk file system |
699 | ; Register ramdisk file system |
700 | cmp byte [BOOT.dev], 1 |
700 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_HD ; will be loaded later |
701 | je @f |
701 | je @f |
702 | - | ||
703 | mov esi, boot_initramdisk |
702 | cmp [BOOT.rd_load_from], RD_LOAD_FROM_NONE |
704 | call boot_log |
703 | je @f |
705 | call ramdisk_init |
704 | call register_ramdisk |
706 | ;-------------------------------------- |
705 | ;-------------------------------------- |
707 | @@: |
706 | @@: |
708 | mov esi, boot_initapic |
707 | mov esi, boot_initapic |
709 | call boot_log |
708 | call boot_log |
710 | ; Try to Initialize APIC |
709 | ; Try to Initialize APIC |
711 | call APIC_init |
710 | call APIC_init |
712 | 711 | ||
713 | mov esi, boot_enableirq |
712 | mov esi, boot_enableirq |
714 | call boot_log |
713 | call boot_log |
715 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
714 | ; Enable timer IRQ (IRQ0) and co-processor IRQ (IRQ13) |
716 | ; they are used: when partitions are scanned, hd_read relies on timer |
715 | ; they are used: when partitions are scanned, hd_read relies on timer |
717 | call unmask_timer |
716 | call unmask_timer |
718 | ; Prevent duplicate timer IRQs in APIC mode |
717 | ; Prevent duplicate timer IRQs in APIC mode |
719 | cmp [irq_mode], IRQ_APIC |
718 | cmp [irq_mode], IRQ_APIC |
720 | jz @f |
719 | jz @f |
721 | stdcall enable_irq, 2 ; @#$%! PIC |
720 | stdcall enable_irq, 2 ; @#$%! PIC |
722 | @@: |
721 | @@: |
723 | stdcall enable_irq, 13 ; co-processor |
722 | stdcall enable_irq, 13 ; co-processor |
724 | 723 | ||
725 | ; Setup serial output console (if enabled) |
724 | ; Setup serial output console (if enabled) |
726 | if defined debug_com_base |
725 | if defined debug_com_base |
727 | 726 | ||
728 | ; reserve port so nobody else will use it |
727 | ; reserve port so nobody else will use it |
729 | xor ebx, ebx |
728 | xor ebx, ebx |
730 | mov ecx, debug_com_base |
729 | mov ecx, debug_com_base |
731 | mov edx, debug_com_base+7 |
730 | mov edx, debug_com_base+7 |
732 | call r_f_port_area |
731 | call r_f_port_area |
733 | 732 | ||
734 | ; enable Divisor latch |
733 | ; enable Divisor latch |
735 | mov dx, debug_com_base+3 |
734 | mov dx, debug_com_base+3 |
736 | mov al, 1 shl 7 |
735 | mov al, 1 shl 7 |
737 | out dx, al |
736 | out dx, al |
738 | 737 | ||
739 | ; Set speed to 115200 baud (max speed) |
738 | ; Set speed to 115200 baud (max speed) |
740 | mov dx, debug_com_base |
739 | mov dx, debug_com_base |
741 | mov al, 0x01 |
740 | mov al, 0x01 |
742 | out dx, al |
741 | out dx, al |
743 | 742 | ||
744 | mov dx, debug_com_base+1 |
743 | mov dx, debug_com_base+1 |
745 | mov al, 0x00 |
744 | mov al, 0x00 |
746 | out dx, al |
745 | out dx, al |
747 | 746 | ||
748 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
747 | ; No parity, 8bits words, one stop bit, dlab bit back to 0 |
749 | mov dx, debug_com_base+3 |
748 | mov dx, debug_com_base+3 |
750 | mov al, 3 |
749 | mov al, 3 |
751 | out dx, al |
750 | out dx, al |
752 | 751 | ||
753 | ; disable interrupts |
752 | ; disable interrupts |
754 | mov dx, debug_com_base+1 |
753 | mov dx, debug_com_base+1 |
755 | mov al, 0 |
754 | mov al, 0 |
756 | out dx, al |
755 | out dx, al |
757 | 756 | ||
758 | ; clear + enable fifo (64 bits) |
757 | ; clear + enable fifo (64 bits) |
759 | mov dx, debug_com_base+2 |
758 | mov dx, debug_com_base+2 |
760 | mov al, 0x7 + 1 shl 5 |
759 | mov al, 0x7 + 1 shl 5 |
761 | out dx, al |
760 | out dx, al |
762 | 761 | ||
763 | end if |
762 | end if |
764 | 763 | ||
765 | 764 | ||
766 | ;----------------------------------------------------------------------------- |
765 | ;----------------------------------------------------------------------------- |
767 | ; show SVN version of kernel on the message board |
766 | ; show SVN version of kernel on the message board |
768 | ;----------------------------------------------------------------------------- |
767 | ;----------------------------------------------------------------------------- |
769 | mov eax, [version_inf.rev] |
768 | mov eax, [version_inf.rev] |
770 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
769 | DEBUGF 1, "K : kernel SVN r%d\n", eax |
771 | ;----------------------------------------------------------------------------- |
770 | ;----------------------------------------------------------------------------- |
772 | ; show CPU count on the message board |
771 | ; show CPU count on the message board |
773 | ;----------------------------------------------------------------------------- |
772 | ;----------------------------------------------------------------------------- |
774 | mov eax, [cpu_count] |
773 | mov eax, [cpu_count] |
775 | test eax, eax |
774 | test eax, eax |
776 | jnz @F |
775 | jnz @F |
777 | mov al, 1 ; at least one CPU |
776 | mov al, 1 ; at least one CPU |
778 | @@: |
777 | @@: |
779 | DEBUGF 1, "K : %d CPU detected\n", eax |
778 | DEBUGF 1, "K : %d CPU detected\n", eax |
780 | ;----------------------------------------------------------------------------- |
779 | ;----------------------------------------------------------------------------- |
781 | ; detect Floppy drives |
780 | ; detect Floppy drives |
782 | ;----------------------------------------------------------------------------- |
781 | ;----------------------------------------------------------------------------- |
783 | mov esi, boot_detectfloppy |
782 | mov esi, boot_detectfloppy |
784 | call boot_log |
783 | call boot_log |
785 | include 'detect/dev_fd.inc' |
784 | include 'detect/dev_fd.inc' |
786 | ;----------------------------------------------------------------------------- |
785 | ;----------------------------------------------------------------------------- |
787 | ; create pci-devices list |
786 | ; create pci-devices list |
788 | ;----------------------------------------------------------------------------- |
787 | ;----------------------------------------------------------------------------- |
789 | mov [pci_access_enabled], 1 |
788 | mov [pci_access_enabled], 1 |
790 | call pci_enum |
789 | call pci_enum |
791 | ;----------------------------------------------------------------------------- |
790 | ;----------------------------------------------------------------------------- |
792 | ; initialisation IDE ATA code |
791 | ; initialisation IDE ATA code |
793 | ;----------------------------------------------------------------------------- |
792 | ;----------------------------------------------------------------------------- |
794 | include 'detect/init_ata.inc' |
793 | include 'detect/init_ata.inc' |
795 | ;----------------------------------------------------------------------------- |
794 | ;----------------------------------------------------------------------------- |
796 | if 0 |
795 | if 0 |
797 | mov ax, [BOOT.bx_from_load] |
796 | mov ax, [BOOT.sys_disk] |
798 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
797 | cmp ax, 'r1'; if using not ram disk, then load librares and parameters {SPraid.simba} |
799 | je no_lib_load |
798 | je no_lib_load |
800 | 799 | ||
801 | mov esi, boot_loadlibs |
800 | mov esi, boot_loadlibs |
802 | call boot_log |
801 | call boot_log |
803 | ; LOADING LIBRARES |
802 | ; LOADING LIBRARES |
804 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
803 | stdcall dll.Load, @IMPORT ; loading librares for kernel (.obj files) |
805 | call load_file_parse_table ; prepare file parse table |
804 | call load_file_parse_table ; prepare file parse table |
806 | call set_kernel_conf ; configure devices and gui |
805 | call set_kernel_conf ; configure devices and gui |
807 | no_lib_load: |
806 | no_lib_load: |
808 | end if |
807 | end if |
809 | 808 | ||
810 | ; Display APIC status |
809 | ; Display APIC status |
811 | mov esi, boot_APIC_found |
810 | mov esi, boot_APIC_found |
812 | cmp [irq_mode], IRQ_APIC |
811 | cmp [irq_mode], IRQ_APIC |
813 | je @f |
812 | je @f |
814 | mov esi, boot_APIC_nfound |
813 | mov esi, boot_APIC_nfound |
815 | @@: |
814 | @@: |
816 | call boot_log |
815 | call boot_log |
817 | 816 | ||
818 | ; PRINT AMOUNT OF MEMORY |
817 | ; PRINT AMOUNT OF MEMORY |
819 | mov esi, boot_memdetect |
818 | mov esi, boot_memdetect |
820 | call boot_log |
819 | call boot_log |
821 | 820 | ||
822 | movzx ecx, word [boot_y] |
821 | movzx ecx, word [boot_y] |
823 | if lang eq ru |
822 | if lang eq ru |
824 | or ecx, (10+30*6) shl 16 |
823 | or ecx, (10+30*6) shl 16 |
825 | else if lang eq sp |
824 | else if lang eq sp |
826 | or ecx, (10+33*6) shl 16 |
825 | or ecx, (10+33*6) shl 16 |
827 | else |
826 | else |
828 | or ecx, (10+29*6) shl 16 |
827 | or ecx, (10+29*6) shl 16 |
829 | end if |
828 | end if |
830 | sub ecx, 10 |
829 | sub ecx, 10 |
831 | mov edx, 0xFFFFFF |
830 | mov edx, 0xFFFFFF |
832 | mov ebx, [MEM_AMOUNT] |
831 | mov ebx, [MEM_AMOUNT] |
833 | shr ebx, 20 |
832 | shr ebx, 20 |
834 | xor edi, edi |
833 | xor edi, edi |
835 | mov eax, 0x00040000 |
834 | mov eax, 0x00040000 |
836 | inc edi |
835 | inc edi |
837 | call display_number_force |
836 | call display_number_force |
838 | 837 | ||
839 | ; BUILD SCHEDULER |
838 | ; BUILD SCHEDULER |
840 | 839 | ||
841 | ; call build_scheduler; sys32.inc |
840 | ; call build_scheduler; sys32.inc |
842 | 841 | ||
843 | ; mov esi, boot_devices |
842 | ; mov esi, boot_devices |
844 | ; call boot_log |
843 | ; call boot_log |
845 | 844 | ||
846 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
845 | include "detect/vortex86.inc" ; Vortex86 SoC detection code |
847 | 846 | ||
848 | stdcall load_pe_driver, szVidintel, 0 |
847 | stdcall load_pe_driver, szVidintel, 0 |
849 | 848 | ||
850 | call usb_init |
849 | call usb_init |
851 | 850 | ||
852 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
851 | ; SET PRELIMINARY WINDOW STACK AND POSITIONS |
853 | 852 | ||
854 | mov esi, boot_windefs |
853 | mov esi, boot_windefs |
855 | call boot_log |
854 | call boot_log |
856 | call set_window_defaults |
855 | call set_window_defaults |
857 | 856 | ||
858 | ; SET BACKGROUND DEFAULTS |
857 | ; SET BACKGROUND DEFAULTS |
859 | 858 | ||
860 | mov esi, boot_bgr |
859 | mov esi, boot_bgr |
861 | call boot_log |
860 | call boot_log |
862 | call init_background |
861 | call init_background |
863 | call calculatebackground |
862 | call calculatebackground |
864 | 863 | ||
865 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
864 | ; RESERVE SYSTEM IRQ'S JA PORT'S |
866 | 865 | ||
867 | mov esi, boot_resirqports |
866 | mov esi, boot_resirqports |
868 | call boot_log |
867 | call boot_log |
869 | call reserve_irqs_ports |
868 | call reserve_irqs_ports |
870 | 869 | ||
871 | call init_display |
870 | call init_display |
872 | mov eax, [def_cursor] |
871 | mov eax, [def_cursor] |
873 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
872 | mov [SLOT_BASE+APPDATA.cursor+256], eax |
874 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
873 | mov [SLOT_BASE+APPDATA.cursor+256*2], eax |
875 | 874 | ||
876 | ; PRINT CPU FREQUENCY |
875 | ; PRINT CPU FREQUENCY |
877 | 876 | ||
878 | mov esi, boot_cpufreq |
877 | mov esi, boot_cpufreq |
879 | call boot_log |
878 | call boot_log |
880 | 879 | ||
881 | cli |
880 | cli |
882 | mov ebx, [hpet_base] |
881 | mov ebx, [hpet_base] |
883 | test ebx, ebx |
882 | test ebx, ebx |
884 | jz @F |
883 | jz @F |
885 | mov ebx, [ebx+0xF0] |
884 | mov ebx, [ebx+0xF0] |
886 | 885 | ||
887 | rdtsc |
886 | rdtsc |
888 | mov ecx, 1000 |
887 | mov ecx, 1000 |
889 | sub eax, [hpet_tsc_start] |
888 | sub eax, [hpet_tsc_start] |
890 | sbb edx, [hpet_tsc_start+4] |
889 | sbb edx, [hpet_tsc_start+4] |
891 | shld edx, eax, 10 |
890 | shld edx, eax, 10 |
892 | shl eax, 10 |
891 | shl eax, 10 |
893 | mov esi, eax |
892 | mov esi, eax |
894 | mov eax, edx |
893 | mov eax, edx |
895 | mul ecx |
894 | mul ecx |
896 | xchg eax, esi |
895 | xchg eax, esi |
897 | mul ecx |
896 | mul ecx |
898 | adc edx, esi |
897 | adc edx, esi |
899 | div ebx |
898 | div ebx |
900 | mul ecx |
899 | mul ecx |
901 | div [hpet_period] |
900 | div [hpet_period] |
902 | mul ecx |
901 | mul ecx |
903 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
902 | DEBUGF 1, "K : cpu frequency %u Hz\n", eax |
904 | jmp .next |
903 | jmp .next |
905 | @@: |
904 | @@: |
906 | rdtsc |
905 | rdtsc |
907 | mov ecx, eax |
906 | mov ecx, eax |
908 | mov esi, 250 ; wait 1/4 a second |
907 | mov esi, 250 ; wait 1/4 a second |
909 | call delay_ms |
908 | call delay_ms |
910 | rdtsc |
909 | rdtsc |
911 | 910 | ||
912 | sub eax, ecx |
911 | sub eax, ecx |
913 | xor edx, edx |
912 | xor edx, edx |
914 | shld edx, eax, 2 |
913 | shld edx, eax, 2 |
915 | shl eax, 2 |
914 | shl eax, 2 |
916 | .next: |
915 | .next: |
917 | mov dword [cpu_freq], eax |
916 | mov dword [cpu_freq], eax |
918 | mov dword [cpu_freq+4], edx |
917 | mov dword [cpu_freq+4], edx |
919 | mov ebx, 1000000 |
918 | mov ebx, 1000000 |
920 | div ebx |
919 | div ebx |
921 | mov ebx, eax |
920 | mov ebx, eax |
922 | 921 | ||
923 | movzx ecx, word [boot_y] |
922 | movzx ecx, word [boot_y] |
924 | if lang eq ru |
923 | if lang eq ru |
925 | add ecx, (10+19*6) shl 16 - 10 |
924 | add ecx, (10+19*6) shl 16 - 10 |
926 | else if lang eq sp |
925 | else if lang eq sp |
927 | add ecx, (10+25*6) shl 16 - 10 |
926 | add ecx, (10+25*6) shl 16 - 10 |
928 | else |
927 | else |
929 | add ecx, (10+17*6) shl 16 - 10 |
928 | add ecx, (10+17*6) shl 16 - 10 |
930 | end if |
929 | end if |
931 | 930 | ||
932 | mov edx, 0xFFFFFF |
931 | mov edx, 0xFFFFFF |
933 | xor edi, edi |
932 | xor edi, edi |
934 | mov eax, 0x00040000 |
933 | mov eax, 0x00040000 |
935 | inc edi |
934 | inc edi |
936 | call display_number_force |
935 | call display_number_force |
937 | 936 | ||
938 | ; SET VARIABLES |
937 | ; SET VARIABLES |
939 | 938 | ||
940 | call set_variables |
939 | call set_variables |
941 | 940 | ||
942 | ; STACK AND FDC |
941 | ; STACK AND FDC |
943 | 942 | ||
944 | call stack_init |
943 | call stack_init |
945 | call fdc_init |
944 | call fdc_init |
946 | 945 | ||
947 | ; PALETTE FOR 320x200 and 640x480 16 col |
946 | ; PALETTE FOR 320x200 and 640x480 16 col |
948 | 947 | ||
949 | cmp [SCR_MODE], word 0x12 |
948 | cmp [SCR_MODE], word 0x12 |
950 | jne no_pal_vga |
949 | jne no_pal_vga |
951 | mov esi, boot_pal_vga |
950 | mov esi, boot_pal_vga |
952 | call boot_log |
951 | call boot_log |
953 | call paletteVGA |
952 | call paletteVGA |
954 | no_pal_vga: |
953 | no_pal_vga: |
955 | 954 | ||
956 | cmp [SCR_MODE], word 0x13 |
955 | cmp [SCR_MODE], word 0x13 |
957 | jne no_pal_ega |
956 | jne no_pal_ega |
958 | mov esi, boot_pal_ega |
957 | mov esi, boot_pal_ega |
959 | call boot_log |
958 | call boot_log |
960 | call palette320x200 |
959 | call palette320x200 |
961 | no_pal_ega: |
960 | no_pal_ega: |
962 | 961 | ||
963 | ; LOAD DEFAULT SKIN |
962 | ; LOAD DEFAULT SKIN |
964 | 963 | ||
965 | call load_default_skin |
964 | call load_default_skin |
966 | 965 | ||
967 | ; Protect I/O permission map |
966 | ; Protect I/O permission map |
968 | 967 | ||
969 | mov esi, [default_io_map] |
968 | mov esi, [default_io_map] |
970 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
969 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map], PG_READ |
971 | add esi, 0x1000 |
970 | add esi, 0x1000 |
972 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
971 | stdcall map_page, esi, [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
973 | 972 | ||
974 | stdcall map_page, tss._io_map_0, \ |
973 | stdcall map_page, tss._io_map_0, \ |
975 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
974 | [SLOT_BASE+256+APPDATA.io_map], PG_READ |
976 | stdcall map_page, tss._io_map_1, \ |
975 | stdcall map_page, tss._io_map_1, \ |
977 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
976 | [SLOT_BASE+256+APPDATA.io_map+4], PG_READ |
978 | 977 | ||
979 | ; SET KEYBOARD PARAMETERS |
978 | ; SET KEYBOARD PARAMETERS |
980 | mov al, 0xf6 ; reset keyboard, scan enabled |
979 | mov al, 0xf6 ; reset keyboard, scan enabled |
981 | call kb_write_wait_ack |
980 | call kb_write_wait_ack |
982 | test ah, ah |
981 | test ah, ah |
983 | jnz .no_keyboard |
982 | jnz .no_keyboard |
984 | 983 | ||
985 | iglobal |
984 | iglobal |
986 | align 4 |
985 | align 4 |
987 | ps2_keyboard_functions: |
986 | ps2_keyboard_functions: |
988 | dd .end - $ |
987 | dd .end - $ |
989 | dd 0 ; no close |
988 | dd 0 ; no close |
990 | dd ps2_set_lights |
989 | dd ps2_set_lights |
991 | .end: |
990 | .end: |
992 | endg |
991 | endg |
993 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
992 | stdcall register_keyboard, ps2_keyboard_functions, 0 |
994 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
993 | ; mov al, 0xED ; Keyboard LEDs - only for testing! |
995 | ; call kb_write_wait_ack |
994 | ; call kb_write_wait_ack |
996 | ; mov al, 111b |
995 | ; mov al, 111b |
997 | ; call kb_write_wait_ack |
996 | ; call kb_write_wait_ack |
998 | 997 | ||
999 | mov al, 0xF3 ; set repeat rate & delay |
998 | mov al, 0xF3 ; set repeat rate & delay |
1000 | call kb_write_wait_ack |
999 | call kb_write_wait_ack |
1001 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1000 | mov al, 0; 30 250 ;00100010b ; 24 500 ;00100100b ; 20 500 |
1002 | call kb_write_wait_ack |
1001 | call kb_write_wait_ack |
1003 | ;// mike.dld [ |
1002 | ;// mike.dld [ |
1004 | call set_lights |
1003 | call set_lights |
1005 | ;// mike.dld ] |
1004 | ;// mike.dld ] |
1006 | stdcall attach_int_handler, 1, irq1, 0 |
1005 | stdcall attach_int_handler, 1, irq1, 0 |
1007 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1006 | DEBUGF 1, "K : IRQ1 return code %x\n", eax |
1008 | .no_keyboard: |
1007 | .no_keyboard: |
1009 | 1008 | ||
1010 | ; Load PS/2 mouse driver |
1009 | ; Load PS/2 mouse driver |
1011 | 1010 | ||
1012 | stdcall load_pe_driver, szPS2MDriver, 0 |
1011 | stdcall load_pe_driver, szPS2MDriver, 0 |
1013 | 1012 | ||
1014 | mov esi, boot_setmouse |
1013 | mov esi, boot_setmouse |
1015 | call boot_log |
1014 | call boot_log |
1016 | call setmouse |
1015 | call setmouse |
1017 | 1016 | ||
1018 | ; LOAD FIRST APPLICATION |
1017 | ; LOAD FIRST APPLICATION |
1019 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1018 | cmp byte [launcher_start], 1 ; Check if starting LAUNCHER is selected on blue screen (1 = yes) |
1020 | jnz first_app_found |
1019 | jnz first_app_found |
1021 | 1020 | ||
1022 | cli |
1021 | cli |
1023 | mov ebp, firstapp |
1022 | mov ebp, firstapp |
1024 | call fs_execute_from_sysdir |
1023 | call fs_execute_from_sysdir |
1025 | test eax, eax |
1024 | test eax, eax |
1026 | jns first_app_found |
1025 | jns first_app_found |
1027 | 1026 | ||
1028 | mov esi, boot_failed |
1027 | mov esi, boot_failed |
1029 | call boot_log |
1028 | call boot_log |
1030 | 1029 | ||
1031 | mov eax, 0xDEADBEEF ; otherwise halt |
1030 | mov eax, 0xDEADBEEF ; otherwise halt |
1032 | hlt |
1031 | hlt |
1033 | 1032 | ||
1034 | first_app_found: |
1033 | first_app_found: |
1035 | 1034 | ||
1036 | ; START MULTITASKING |
1035 | ; START MULTITASKING |
1037 | preboot_blogesc = 0 ; start immediately after bootlog |
1036 | preboot_blogesc = 0 ; start immediately after bootlog |
1038 | 1037 | ||
1039 | ; A 'All set - press ESC to start' messages if need |
1038 | ; A 'All set - press ESC to start' messages if need |
1040 | if preboot_blogesc |
1039 | if preboot_blogesc |
1041 | mov esi, boot_tasking |
1040 | mov esi, boot_tasking |
1042 | call boot_log |
1041 | call boot_log |
1043 | .bll1: |
1042 | .bll1: |
1044 | in al, 0x60 ; wait for ESC key press |
1043 | in al, 0x60 ; wait for ESC key press |
1045 | cmp al, 129 |
1044 | cmp al, 129 |
1046 | jne .bll1 |
1045 | jne .bll1 |
1047 | end if |
1046 | end if |
1048 | 1047 | ||
1049 | mov [timer_ticks_enable], 1 ; for cd driver |
1048 | mov [timer_ticks_enable], 1 ; for cd driver |
1050 | 1049 | ||
1051 | sti |
1050 | sti |
1052 | 1051 | ||
1053 | call mtrr_validate |
1052 | call mtrr_validate |
1054 | 1053 | ||
1055 | jmp osloop |
1054 | jmp osloop |
1056 | 1055 | ||
1057 | 1056 | ||
1058 | ; Fly :) |
1057 | ; Fly :) |
1059 | 1058 | ||
1060 | uglobal |
1059 | uglobal |
1061 | align 4 |
1060 | align 4 |
1062 | ap_initialized dd 0 |
1061 | ap_initialized dd 0 |
1063 | endg |
1062 | endg |
1064 | 1063 | ||
1065 | ap_init_high: |
1064 | ap_init_high: |
1066 | mov ax, os_stack |
1065 | mov ax, os_stack |
1067 | mov bx, app_data |
1066 | mov bx, app_data |
1068 | mov cx, app_tls |
1067 | mov cx, app_tls |
1069 | mov ss, ax |
1068 | mov ss, ax |
1070 | mov ds, bx |
1069 | mov ds, bx |
1071 | mov es, bx |
1070 | mov es, bx |
1072 | mov fs, cx |
1071 | mov fs, cx |
1073 | mov gs, bx |
1072 | mov gs, bx |
1074 | xor esp, esp |
1073 | xor esp, esp |
1075 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1074 | mov eax, sys_proc-OS_BASE+PROC.pdt_0 |
1076 | mov cr3, eax |
1075 | mov cr3, eax |
1077 | lock inc [ap_initialized] |
1076 | lock inc [ap_initialized] |
1078 | jmp idle_loop |
1077 | jmp idle_loop |
1079 | 1078 | ||
1080 | 1079 | ||
1081 | include 'unpacker.inc' |
1080 | include 'unpacker.inc' |
1082 | 1081 | ||
1083 | align 4 |
1082 | align 4 |
1084 | boot_log: |
1083 | boot_log: |
1085 | pushad |
1084 | pushad |
1086 | 1085 | ||
1087 | mov ebx, 10*65536 |
1086 | mov ebx, 10*65536 |
1088 | mov bx, word [boot_y] |
1087 | mov bx, word [boot_y] |
1089 | add [boot_y], dword 10 |
1088 | add [boot_y], dword 10 |
1090 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1089 | mov ecx, 0x80ffffff; ASCIIZ string with white color |
1091 | xor edi, edi |
1090 | xor edi, edi |
1092 | mov edx, esi |
1091 | mov edx, esi |
1093 | inc edi |
1092 | inc edi |
1094 | call dtext |
1093 | call dtext |
1095 | 1094 | ||
1096 | mov [novesachecksum], 1000 |
1095 | mov [novesachecksum], 1000 |
1097 | call checkVga_N13 |
1096 | call checkVga_N13 |
1098 | 1097 | ||
1099 | popad |
1098 | popad |
1100 | 1099 | ||
1101 | ret |
1100 | ret |
1102 | 1101 | ||
1103 | ; in: edx -> APPDATA for OS/IDLE slot |
1102 | ; in: edx -> APPDATA for OS/IDLE slot |
1104 | ; in: ebx = stack base |
1103 | ; in: ebx = stack base |
1105 | proc setup_os_slot |
1104 | proc setup_os_slot |
1106 | xor eax, eax |
1105 | xor eax, eax |
1107 | mov ecx, 256/4 |
1106 | mov ecx, 256/4 |
1108 | mov edi, edx |
1107 | mov edi, edx |
1109 | rep stosd |
1108 | rep stosd |
1110 | 1109 | ||
1111 | mov eax, tss+0x80 |
1110 | mov eax, tss+0x80 |
1112 | call get_pg_addr |
1111 | call get_pg_addr |
1113 | inc eax |
1112 | inc eax |
1114 | mov [edx+APPDATA.io_map], eax |
1113 | mov [edx+APPDATA.io_map], eax |
1115 | mov eax, tss+0x1080 |
1114 | mov eax, tss+0x1080 |
1116 | call get_pg_addr |
1115 | call get_pg_addr |
1117 | inc eax |
1116 | inc eax |
1118 | mov [edx+APPDATA.io_map+4], eax |
1117 | mov [edx+APPDATA.io_map+4], eax |
1119 | 1118 | ||
1120 | mov dword [edx+APPDATA.pl0_stack], ebx |
1119 | mov dword [edx+APPDATA.pl0_stack], ebx |
1121 | lea edi, [ebx+RING0_STACK_SIZE] |
1120 | lea edi, [ebx+RING0_STACK_SIZE] |
1122 | mov dword [edx+APPDATA.fpu_state], edi |
1121 | mov dword [edx+APPDATA.fpu_state], edi |
1123 | mov dword [edx+APPDATA.saved_esp0], edi |
1122 | mov dword [edx+APPDATA.saved_esp0], edi |
1124 | mov dword [edx+APPDATA.saved_esp], edi |
1123 | mov dword [edx+APPDATA.saved_esp], edi |
1125 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1124 | mov dword [edx+APPDATA.terminate_protection], 1 ; make unkillable |
1126 | 1125 | ||
1127 | mov esi, fpu_data |
1126 | mov esi, fpu_data |
1128 | mov ecx, [xsave_area_size] |
1127 | mov ecx, [xsave_area_size] |
1129 | add ecx, 3 |
1128 | add ecx, 3 |
1130 | shr ecx, 2 |
1129 | shr ecx, 2 |
1131 | rep movsd |
1130 | rep movsd |
1132 | 1131 | ||
1133 | lea eax, [edx+APP_EV_OFFSET] |
1132 | lea eax, [edx+APP_EV_OFFSET] |
1134 | mov dword [edx+APPDATA.fd_ev], eax |
1133 | mov dword [edx+APPDATA.fd_ev], eax |
1135 | mov dword [edx+APPDATA.bk_ev], eax |
1134 | mov dword [edx+APPDATA.bk_ev], eax |
1136 | 1135 | ||
1137 | lea eax, [edx+APP_OBJ_OFFSET] |
1136 | lea eax, [edx+APP_OBJ_OFFSET] |
1138 | mov dword [edx+APPDATA.fd_obj], eax |
1137 | mov dword [edx+APPDATA.fd_obj], eax |
1139 | mov dword [edx+APPDATA.bk_obj], eax |
1138 | mov dword [edx+APPDATA.bk_obj], eax |
1140 | 1139 | ||
1141 | mov dword [edx+APPDATA.cur_dir], sysdir_path-2 |
1140 | mov dword [edx+APPDATA.cur_dir], sysdir_path-2 |
1142 | 1141 | ||
1143 | mov [edx + APPDATA.process], sys_proc |
1142 | mov [edx + APPDATA.process], sys_proc |
1144 | 1143 | ||
1145 | lea ebx, [edx+APPDATA.list] |
1144 | lea ebx, [edx+APPDATA.list] |
1146 | lea ecx, [sys_proc+PROC.thr_list] |
1145 | lea ecx, [sys_proc+PROC.thr_list] |
1147 | list_add_tail ebx, ecx |
1146 | list_add_tail ebx, ecx |
1148 | 1147 | ||
1149 | mov eax, edx |
1148 | mov eax, edx |
1150 | shr eax, 3 |
1149 | shr eax, 3 |
1151 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1150 | add eax, CURRENT_TASK - (SLOT_BASE shr 3) |
1152 | mov [eax+TASKDATA.wnd_number], dh |
1151 | mov [eax+TASKDATA.wnd_number], dh |
1153 | mov byte [eax+TASKDATA.pid], dh |
1152 | mov byte [eax+TASKDATA.pid], dh |
1154 | 1153 | ||
1155 | ret |
1154 | ret |
1156 | endp |
1155 | endp |
1157 | 1156 | ||
1158 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1157 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1159 | ; ; |
1158 | ; ; |
1160 | ; MAIN OS LOOP START ; |
1159 | ; MAIN OS LOOP START ; |
1161 | ; ; |
1160 | ; ; |
1162 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1161 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1163 | align 32 |
1162 | align 32 |
1164 | osloop: |
1163 | osloop: |
1165 | mov edx, osloop_has_work? |
1164 | mov edx, osloop_has_work? |
1166 | xor ecx, ecx |
1165 | xor ecx, ecx |
1167 | call Wait_events |
1166 | call Wait_events |
1168 | xor eax, eax |
1167 | xor eax, eax |
1169 | xchg eax, [osloop_nonperiodic_work] |
1168 | xchg eax, [osloop_nonperiodic_work] |
1170 | test eax, eax |
1169 | test eax, eax |
1171 | jz .no_periodic |
1170 | jz .no_periodic |
1172 | 1171 | ||
1173 | call __sys_draw_pointer |
1172 | call __sys_draw_pointer |
1174 | call window_check_events |
1173 | call window_check_events |
1175 | call mouse_check_events |
1174 | call mouse_check_events |
1176 | call checkmisc |
1175 | call checkmisc |
1177 | call checkVga_N13 |
1176 | call checkVga_N13 |
1178 | ;-------------------------------------- |
1177 | ;-------------------------------------- |
1179 | .no_periodic: |
1178 | .no_periodic: |
1180 | call stack_handler |
1179 | call stack_handler |
1181 | call check_fdd_motor_status |
1180 | call check_fdd_motor_status |
1182 | call check_ATAPI_device_event |
1181 | call check_ATAPI_device_event |
1183 | call check_lights_state |
1182 | call check_lights_state |
1184 | call check_timers |
1183 | call check_timers |
1185 | 1184 | ||
1186 | jmp osloop |
1185 | jmp osloop |
1187 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1186 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1188 | ; ; |
1187 | ; ; |
1189 | ; MAIN OS LOOP END ; |
1188 | ; MAIN OS LOOP END ; |
1190 | ; ; |
1189 | ; ; |
1191 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1190 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1192 | proc osloop_has_work? |
1191 | proc osloop_has_work? |
1193 | cmp [osloop_nonperiodic_work], 0 |
1192 | cmp [osloop_nonperiodic_work], 0 |
1194 | jnz .yes |
1193 | jnz .yes |
1195 | call stack_handler_has_work? |
1194 | call stack_handler_has_work? |
1196 | jnz .yes |
1195 | jnz .yes |
1197 | call check_fdd_motor_status_has_work? |
1196 | call check_fdd_motor_status_has_work? |
1198 | jnz .yes |
1197 | jnz .yes |
1199 | call check_ATAPI_device_event_has_work? |
1198 | call check_ATAPI_device_event_has_work? |
1200 | jnz .yes |
1199 | jnz .yes |
1201 | call check_lights_state_has_work? |
1200 | call check_lights_state_has_work? |
1202 | jnz .yes |
1201 | jnz .yes |
1203 | call check_timers_has_work? |
1202 | call check_timers_has_work? |
1204 | jnz .yes |
1203 | jnz .yes |
1205 | .no: |
1204 | .no: |
1206 | xor eax, eax |
1205 | xor eax, eax |
1207 | ret |
1206 | ret |
1208 | .yes: |
1207 | .yes: |
1209 | xor eax, eax |
1208 | xor eax, eax |
1210 | inc eax |
1209 | inc eax |
1211 | ret |
1210 | ret |
1212 | endp |
1211 | endp |
1213 | 1212 | ||
1214 | proc wakeup_osloop |
1213 | proc wakeup_osloop |
1215 | mov [osloop_nonperiodic_work], 1 |
1214 | mov [osloop_nonperiodic_work], 1 |
1216 | ret |
1215 | ret |
1217 | endp |
1216 | endp |
1218 | 1217 | ||
1219 | uglobal |
1218 | uglobal |
1220 | align 4 |
1219 | align 4 |
1221 | osloop_nonperiodic_work dd ? |
1220 | osloop_nonperiodic_work dd ? |
1222 | endg |
1221 | endg |
1223 | 1222 | ||
1224 | uglobal |
1223 | uglobal |
1225 | align 64 |
1224 | align 64 |
1226 | idle_addr rb 64 |
1225 | idle_addr rb 64 |
1227 | endg |
1226 | endg |
1228 | 1227 | ||
1229 | idle_thread: |
1228 | idle_thread: |
1230 | sti |
1229 | sti |
1231 | 1230 | ||
1232 | ; The following code can be executed by all CPUs in the system. |
1231 | ; The following code can be executed by all CPUs in the system. |
1233 | ; All other parts of the kernel do not expect multi-CPU. |
1232 | ; All other parts of the kernel do not expect multi-CPU. |
1234 | ; Also, APs don't even have a stack here. |
1233 | ; Also, APs don't even have a stack here. |
1235 | ; Beware. Don't do anything here. Anything at all. |
1234 | ; Beware. Don't do anything here. Anything at all. |
1236 | idle_loop: |
1235 | idle_loop: |
1237 | cmp [use_mwait_for_idle], 0 |
1236 | cmp [use_mwait_for_idle], 0 |
1238 | jnz idle_loop_mwait |
1237 | jnz idle_loop_mwait |
1239 | 1238 | ||
1240 | idle_loop_hlt: |
1239 | idle_loop_hlt: |
1241 | hlt |
1240 | hlt |
1242 | jmp idle_loop_hlt |
1241 | jmp idle_loop_hlt |
1243 | 1242 | ||
1244 | idle_loop_mwait: |
1243 | idle_loop_mwait: |
1245 | mov eax, idle_addr |
1244 | mov eax, idle_addr |
1246 | xor ecx, ecx |
1245 | xor ecx, ecx |
1247 | xor edx, edx |
1246 | xor edx, edx |
1248 | monitor |
1247 | monitor |
1249 | xor ecx, ecx |
1248 | xor ecx, ecx |
1250 | mov eax, 20h ; or 10h |
1249 | mov eax, 20h ; or 10h |
1251 | mwait |
1250 | mwait |
1252 | jmp idle_loop_mwait |
1251 | jmp idle_loop_mwait |
1253 | 1252 | ||
1254 | 1253 | ||
1255 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1254 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1256 | ; ; |
1255 | ; ; |
1257 | ; INCLUDED SYSTEM FILES ; |
1256 | ; INCLUDED SYSTEM FILES ; |
1258 | ; ; |
1257 | ; ; |
1259 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1258 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1260 | 1259 | ||
1261 | 1260 | ||
1262 | include "kernel32.inc" |
1261 | include "kernel32.inc" |
1263 | 1262 | ||
1264 | 1263 | ||
1265 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1264 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1266 | ; ; |
1265 | ; ; |
1267 | ; KERNEL FUNCTIONS ; |
1266 | ; KERNEL FUNCTIONS ; |
1268 | ; ; |
1267 | ; ; |
1269 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1268 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1270 | 1269 | ||
1271 | reserve_irqs_ports: |
1270 | reserve_irqs_ports: |
1272 | 1271 | ||
1273 | 1272 | ||
1274 | ; RESERVE PORTS |
1273 | ; RESERVE PORTS |
1275 | mov eax, RESERVED_PORTS |
1274 | mov eax, RESERVED_PORTS |
1276 | mov ecx, 1 |
1275 | mov ecx, 1 |
1277 | 1276 | ||
1278 | mov [eax], dword 4 |
1277 | mov [eax], dword 4 |
1279 | 1278 | ||
1280 | mov [eax+16], ecx |
1279 | mov [eax+16], ecx |
1281 | mov [eax+16+4], dword 0 |
1280 | mov [eax+16+4], dword 0 |
1282 | mov [eax+16+8], dword 0x2D |
1281 | mov [eax+16+8], dword 0x2D |
1283 | 1282 | ||
1284 | mov [eax+32], ecx |
1283 | mov [eax+32], ecx |
1285 | mov [eax+32+4], dword 0x30 |
1284 | mov [eax+32+4], dword 0x30 |
1286 | mov [eax+32+8], dword 0x4D |
1285 | mov [eax+32+8], dword 0x4D |
1287 | 1286 | ||
1288 | mov [eax+48], ecx |
1287 | mov [eax+48], ecx |
1289 | mov [eax+48+4], dword 0x50 |
1288 | mov [eax+48+4], dword 0x50 |
1290 | mov [eax+48+8], dword 0xDF |
1289 | mov [eax+48+8], dword 0xDF |
1291 | 1290 | ||
1292 | mov [eax+64], ecx |
1291 | mov [eax+64], ecx |
1293 | mov [eax+64+4], dword 0xE5 |
1292 | mov [eax+64+4], dword 0xE5 |
1294 | mov [eax+64+8], dword 0xFF |
1293 | mov [eax+64+8], dword 0xFF |
1295 | 1294 | ||
1296 | ret |
1295 | ret |
1297 | 1296 | ||
1298 | 1297 | ||
1299 | iglobal |
1298 | iglobal |
1300 | process_number dd 0x2 |
1299 | process_number dd 0x2 |
1301 | endg |
1300 | endg |
1302 | 1301 | ||
1303 | set_variables: |
1302 | set_variables: |
1304 | 1303 | ||
1305 | mov ecx, 0x16 ; flush port 0x60 |
1304 | mov ecx, 0x16 ; flush port 0x60 |
1306 | .fl60: |
1305 | .fl60: |
1307 | in al, 0x60 |
1306 | in al, 0x60 |
1308 | loop .fl60 |
1307 | loop .fl60 |
1309 | push eax |
1308 | push eax |
1310 | 1309 | ||
1311 | mov ax, [BOOT.y_res] |
1310 | mov ax, [BOOT.y_res] |
1312 | shr ax, 1 |
1311 | shr ax, 1 |
1313 | shl eax, 16 |
1312 | shl eax, 16 |
1314 | mov ax, [BOOT.x_res] |
1313 | mov ax, [BOOT.x_res] |
1315 | shr ax, 1 |
1314 | shr ax, 1 |
1316 | mov [MOUSE_X], eax |
1315 | mov [MOUSE_X], eax |
1317 | call wakeup_osloop |
1316 | call wakeup_osloop |
1318 | 1317 | ||
1319 | xor eax, eax |
1318 | xor eax, eax |
1320 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1319 | mov [BTN_ADDR], dword BUTTON_INFO ; address of button list |
1321 | 1320 | ||
1322 | mov byte [KEY_COUNT], al ; keyboard buffer |
1321 | mov byte [KEY_COUNT], al ; keyboard buffer |
1323 | mov byte [BTN_COUNT], al ; button buffer |
1322 | mov byte [BTN_COUNT], al ; button buffer |
1324 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1323 | ; mov [MOUSE_X],dword 100*65536+100 ; mouse x/y |
1325 | 1324 | ||
1326 | pop eax |
1325 | pop eax |
1327 | ret |
1326 | ret |
1328 | 1327 | ||
1329 | align 4 |
1328 | align 4 |
1330 | ;input eax=43,bl-byte of output, ecx - number of port |
1329 | ;input eax=43,bl-byte of output, ecx - number of port |
1331 | sys_outport: |
1330 | sys_outport: |
1332 | 1331 | ||
1333 | mov edi, ecx ; separate flag for read / write |
1332 | mov edi, ecx ; separate flag for read / write |
1334 | and ecx, 65535 |
1333 | and ecx, 65535 |
1335 | 1334 | ||
1336 | mov eax, [RESERVED_PORTS] |
1335 | mov eax, [RESERVED_PORTS] |
1337 | test eax, eax |
1336 | test eax, eax |
1338 | jnz .sopl8 |
1337 | jnz .sopl8 |
1339 | inc eax |
1338 | inc eax |
1340 | mov [esp+32], eax |
1339 | mov [esp+32], eax |
1341 | ret |
1340 | ret |
1342 | 1341 | ||
1343 | .sopl8: |
1342 | .sopl8: |
1344 | mov edx, [TASK_BASE] |
1343 | mov edx, [TASK_BASE] |
1345 | mov edx, [edx+0x4] |
1344 | mov edx, [edx+0x4] |
1346 | ;and ecx,65535 |
1345 | ;and ecx,65535 |
1347 | ;cld - set on interrupt 0x40 |
1346 | ;cld - set on interrupt 0x40 |
1348 | .sopl1: |
1347 | .sopl1: |
1349 | 1348 | ||
1350 | mov esi, eax |
1349 | mov esi, eax |
1351 | shl esi, 4 |
1350 | shl esi, 4 |
1352 | add esi, RESERVED_PORTS |
1351 | add esi, RESERVED_PORTS |
1353 | cmp edx, [esi+0] |
1352 | cmp edx, [esi+0] |
1354 | jne .sopl2 |
1353 | jne .sopl2 |
1355 | cmp ecx, [esi+4] |
1354 | cmp ecx, [esi+4] |
1356 | jb .sopl2 |
1355 | jb .sopl2 |
1357 | cmp ecx, [esi+8] |
1356 | cmp ecx, [esi+8] |
1358 | jg .sopl2 |
1357 | jg .sopl2 |
1359 | .sopl3: |
1358 | .sopl3: |
1360 | 1359 | ||
1361 | test edi, 0x80000000; read ? |
1360 | test edi, 0x80000000; read ? |
1362 | jnz .sopl4 |
1361 | jnz .sopl4 |
1363 | 1362 | ||
1364 | mov eax, ebx |
1363 | mov eax, ebx |
1365 | mov dx, cx ; write |
1364 | mov dx, cx ; write |
1366 | out dx, al |
1365 | out dx, al |
1367 | and [esp+32], dword 0 |
1366 | and [esp+32], dword 0 |
1368 | ret |
1367 | ret |
1369 | 1368 | ||
1370 | .sopl2: |
1369 | .sopl2: |
1371 | 1370 | ||
1372 | dec eax |
1371 | dec eax |
1373 | jnz .sopl1 |
1372 | jnz .sopl1 |
1374 | inc eax |
1373 | inc eax |
1375 | mov [esp+32], eax |
1374 | mov [esp+32], eax |
1376 | ret |
1375 | ret |
1377 | 1376 | ||
1378 | 1377 | ||
1379 | .sopl4: |
1378 | .sopl4: |
1380 | 1379 | ||
1381 | mov dx, cx ; read |
1380 | mov dx, cx ; read |
1382 | in al, dx |
1381 | in al, dx |
1383 | and eax, 0xff |
1382 | and eax, 0xff |
1384 | and [esp+32], dword 0 |
1383 | and [esp+32], dword 0 |
1385 | mov [esp+20], eax |
1384 | mov [esp+20], eax |
1386 | ret |
1385 | ret |
1387 | 1386 | ||
1388 | display_number: |
1387 | display_number: |
1389 | ;It is not optimization |
1388 | ;It is not optimization |
1390 | mov eax, ebx |
1389 | mov eax, ebx |
1391 | mov ebx, ecx |
1390 | mov ebx, ecx |
1392 | mov ecx, edx |
1391 | mov ecx, edx |
1393 | mov edx, esi |
1392 | mov edx, esi |
1394 | mov esi, edi |
1393 | mov esi, edi |
1395 | ; eax = print type, al=0 -> ebx is number |
1394 | ; eax = print type, al=0 -> ebx is number |
1396 | ; al=1 -> ebx is pointer |
1395 | ; al=1 -> ebx is pointer |
1397 | ; ah=0 -> display decimal |
1396 | ; ah=0 -> display decimal |
1398 | ; ah=1 -> display hexadecimal |
1397 | ; ah=1 -> display hexadecimal |
1399 | ; ah=2 -> display binary |
1398 | ; ah=2 -> display binary |
1400 | ; eax bits 16-21 = number of digits to display (0-32) |
1399 | ; eax bits 16-21 = number of digits to display (0-32) |
1401 | ; eax bits 22-31 = reserved |
1400 | ; eax bits 22-31 = reserved |
1402 | ; |
1401 | ; |
1403 | ; ebx = number or pointer |
1402 | ; ebx = number or pointer |
1404 | ; ecx = x shl 16 + y |
1403 | ; ecx = x shl 16 + y |
1405 | ; edx = color |
1404 | ; edx = color |
1406 | xor edi, edi |
1405 | xor edi, edi |
1407 | display_number_force: |
1406 | display_number_force: |
1408 | push eax |
1407 | push eax |
1409 | and eax, 0x3fffffff |
1408 | and eax, 0x3fffffff |
1410 | cmp eax, 0xffff ; length > 0 ? |
1409 | cmp eax, 0xffff ; length > 0 ? |
1411 | pop eax |
1410 | pop eax |
1412 | jge cont_displ |
1411 | jge cont_displ |
1413 | ret |
1412 | ret |
1414 | cont_displ: |
1413 | cont_displ: |
1415 | push eax |
1414 | push eax |
1416 | and eax, 0x3fffffff |
1415 | and eax, 0x3fffffff |
1417 | cmp eax, 61*0x10000 ; length <= 60 ? |
1416 | cmp eax, 61*0x10000 ; length <= 60 ? |
1418 | pop eax |
1417 | pop eax |
1419 | jb cont_displ2 |
1418 | jb cont_displ2 |
1420 | ret |
1419 | ret |
1421 | cont_displ2: |
1420 | cont_displ2: |
1422 | 1421 | ||
1423 | pushad |
1422 | pushad |
1424 | 1423 | ||
1425 | cmp al, 1 ; ecx is a pointer ? |
1424 | cmp al, 1 ; ecx is a pointer ? |
1426 | jne displnl1 |
1425 | jne displnl1 |
1427 | mov ebp, ebx |
1426 | mov ebp, ebx |
1428 | add ebp, 4 |
1427 | add ebp, 4 |
1429 | mov ebp, [ebp+std_application_base_address] |
1428 | mov ebp, [ebp+std_application_base_address] |
1430 | mov ebx, [ebx+std_application_base_address] |
1429 | mov ebx, [ebx+std_application_base_address] |
1431 | displnl1: |
1430 | displnl1: |
1432 | sub esp, 64 |
1431 | sub esp, 64 |
1433 | 1432 | ||
1434 | test ah, ah ; DECIMAL |
1433 | test ah, ah ; DECIMAL |
1435 | jnz no_display_desnum |
1434 | jnz no_display_desnum |
1436 | shr eax, 16 |
1435 | shr eax, 16 |
1437 | and eax, 0xC03f |
1436 | and eax, 0xC03f |
1438 | ; and eax,0x3f |
1437 | ; and eax,0x3f |
1439 | push eax |
1438 | push eax |
1440 | and eax, 0x3f |
1439 | and eax, 0x3f |
1441 | mov edi, esp |
1440 | mov edi, esp |
1442 | add edi, 4+64-1 |
1441 | add edi, 4+64-1 |
1443 | mov ecx, eax |
1442 | mov ecx, eax |
1444 | mov eax, ebx |
1443 | mov eax, ebx |
1445 | mov ebx, 10 |
1444 | mov ebx, 10 |
1446 | d_desnum: |
1445 | d_desnum: |
1447 | xor edx, edx |
1446 | xor edx, edx |
1448 | call division_64_bits |
1447 | call division_64_bits |
1449 | div ebx |
1448 | div ebx |
1450 | add dl, 48 |
1449 | add dl, 48 |
1451 | mov [edi], dl |
1450 | mov [edi], dl |
1452 | dec edi |
1451 | dec edi |
1453 | loop d_desnum |
1452 | loop d_desnum |
1454 | pop eax |
1453 | pop eax |
1455 | call normalize_number |
1454 | call normalize_number |
1456 | call draw_num_text |
1455 | call draw_num_text |
1457 | add esp, 64 |
1456 | add esp, 64 |
1458 | popad |
1457 | popad |
1459 | ret |
1458 | ret |
1460 | no_display_desnum: |
1459 | no_display_desnum: |
1461 | 1460 | ||
1462 | cmp ah, 0x01 ; HEXADECIMAL |
1461 | cmp ah, 0x01 ; HEXADECIMAL |
1463 | jne no_display_hexnum |
1462 | jne no_display_hexnum |
1464 | shr eax, 16 |
1463 | shr eax, 16 |
1465 | and eax, 0xC03f |
1464 | and eax, 0xC03f |
1466 | ; and eax,0x3f |
1465 | ; and eax,0x3f |
1467 | push eax |
1466 | push eax |
1468 | and eax, 0x3f |
1467 | and eax, 0x3f |
1469 | mov edi, esp |
1468 | mov edi, esp |
1470 | add edi, 4+64-1 |
1469 | add edi, 4+64-1 |
1471 | mov ecx, eax |
1470 | mov ecx, eax |
1472 | mov eax, ebx |
1471 | mov eax, ebx |
1473 | mov ebx, 16 |
1472 | mov ebx, 16 |
1474 | d_hexnum: |
1473 | d_hexnum: |
1475 | xor edx, edx |
1474 | xor edx, edx |
1476 | call division_64_bits |
1475 | call division_64_bits |
1477 | div ebx |
1476 | div ebx |
1478 | hexletters = __fdo_hexdigits |
1477 | hexletters = __fdo_hexdigits |
1479 | add edx, hexletters |
1478 | add edx, hexletters |
1480 | mov dl, [edx] |
1479 | mov dl, [edx] |
1481 | mov [edi], dl |
1480 | mov [edi], dl |
1482 | dec edi |
1481 | dec edi |
1483 | loop d_hexnum |
1482 | loop d_hexnum |
1484 | pop eax |
1483 | pop eax |
1485 | call normalize_number |
1484 | call normalize_number |
1486 | call draw_num_text |
1485 | call draw_num_text |
1487 | add esp, 64 |
1486 | add esp, 64 |
1488 | popad |
1487 | popad |
1489 | ret |
1488 | ret |
1490 | no_display_hexnum: |
1489 | no_display_hexnum: |
1491 | 1490 | ||
1492 | cmp ah, 0x02 ; BINARY |
1491 | cmp ah, 0x02 ; BINARY |
1493 | jne no_display_binnum |
1492 | jne no_display_binnum |
1494 | shr eax, 16 |
1493 | shr eax, 16 |
1495 | and eax, 0xC03f |
1494 | and eax, 0xC03f |
1496 | ; and eax,0x3f |
1495 | ; and eax,0x3f |
1497 | push eax |
1496 | push eax |
1498 | and eax, 0x3f |
1497 | and eax, 0x3f |
1499 | mov edi, esp |
1498 | mov edi, esp |
1500 | add edi, 4+64-1 |
1499 | add edi, 4+64-1 |
1501 | mov ecx, eax |
1500 | mov ecx, eax |
1502 | mov eax, ebx |
1501 | mov eax, ebx |
1503 | mov ebx, 2 |
1502 | mov ebx, 2 |
1504 | d_binnum: |
1503 | d_binnum: |
1505 | xor edx, edx |
1504 | xor edx, edx |
1506 | call division_64_bits |
1505 | call division_64_bits |
1507 | div ebx |
1506 | div ebx |
1508 | add dl, 48 |
1507 | add dl, 48 |
1509 | mov [edi], dl |
1508 | mov [edi], dl |
1510 | dec edi |
1509 | dec edi |
1511 | loop d_binnum |
1510 | loop d_binnum |
1512 | pop eax |
1511 | pop eax |
1513 | call normalize_number |
1512 | call normalize_number |
1514 | call draw_num_text |
1513 | call draw_num_text |
1515 | add esp, 64 |
1514 | add esp, 64 |
1516 | popad |
1515 | popad |
1517 | ret |
1516 | ret |
1518 | no_display_binnum: |
1517 | no_display_binnum: |
1519 | 1518 | ||
1520 | add esp, 64 |
1519 | add esp, 64 |
1521 | popad |
1520 | popad |
1522 | ret |
1521 | ret |
1523 | 1522 | ||
1524 | normalize_number: |
1523 | normalize_number: |
1525 | test ah, 0x80 |
1524 | test ah, 0x80 |
1526 | jz .continue |
1525 | jz .continue |
1527 | mov ecx, 48 |
1526 | mov ecx, 48 |
1528 | and eax, 0x3f |
1527 | and eax, 0x3f |
1529 | @@: |
1528 | @@: |
1530 | inc edi |
1529 | inc edi |
1531 | cmp [edi], cl |
1530 | cmp [edi], cl |
1532 | jne .continue |
1531 | jne .continue |
1533 | dec eax |
1532 | dec eax |
1534 | cmp eax, 1 |
1533 | cmp eax, 1 |
1535 | ja @r |
1534 | ja @r |
1536 | mov al, 1 |
1535 | mov al, 1 |
1537 | .continue: |
1536 | .continue: |
1538 | and eax, 0x3f |
1537 | and eax, 0x3f |
1539 | ret |
1538 | ret |
1540 | 1539 | ||
1541 | division_64_bits: |
1540 | division_64_bits: |
1542 | test [esp+1+4], byte 0x40 |
1541 | test [esp+1+4], byte 0x40 |
1543 | jz .continue |
1542 | jz .continue |
1544 | push eax |
1543 | push eax |
1545 | mov eax, ebp |
1544 | mov eax, ebp |
1546 | div ebx |
1545 | div ebx |
1547 | mov ebp, eax |
1546 | mov ebp, eax |
1548 | pop eax |
1547 | pop eax |
1549 | .continue: |
1548 | .continue: |
1550 | ret |
1549 | ret |
1551 | 1550 | ||
1552 | draw_num_text: |
1551 | draw_num_text: |
1553 | mov esi, eax |
1552 | mov esi, eax |
1554 | mov edx, 64+4 |
1553 | mov edx, 64+4 |
1555 | sub edx, eax |
1554 | sub edx, eax |
1556 | add edx, esp |
1555 | add edx, esp |
1557 | mov ebx, [esp+64+32-8+4] |
1556 | mov ebx, [esp+64+32-8+4] |
1558 | ; add window start x & y |
1557 | ; add window start x & y |
1559 | mov ecx, [TASK_BASE] |
1558 | mov ecx, [TASK_BASE] |
1560 | 1559 | ||
1561 | mov edi, [CURRENT_TASK] |
1560 | mov edi, [CURRENT_TASK] |
1562 | shl edi, 8 |
1561 | shl edi, 8 |
1563 | 1562 | ||
1564 | mov eax, [ecx-twdw+WDATA.box.left] |
1563 | mov eax, [ecx-twdw+WDATA.box.left] |
1565 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1564 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1566 | shl eax, 16 |
1565 | shl eax, 16 |
1567 | add eax, [ecx-twdw+WDATA.box.top] |
1566 | add eax, [ecx-twdw+WDATA.box.top] |
1568 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1567 | add eax, [edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1569 | add ebx, eax |
1568 | add ebx, eax |
1570 | mov ecx, [esp+64+32-12+4] |
1569 | mov ecx, [esp+64+32-12+4] |
1571 | mov eax, [esp+64+8] ; background color (if given) |
1570 | mov eax, [esp+64+8] ; background color (if given) |
1572 | mov edi, [esp+64+4] |
1571 | mov edi, [esp+64+4] |
1573 | and ecx, 5FFFFFFFh |
1572 | and ecx, 5FFFFFFFh |
1574 | bt ecx, 27 |
1573 | bt ecx, 27 |
1575 | jnc @f |
1574 | jnc @f |
1576 | mov edi, eax |
1575 | mov edi, eax |
1577 | @@: |
1576 | @@: |
1578 | jmp dtext |
1577 | jmp dtext |
1579 | ;----------------------------------------------------------------------------- |
1578 | ;----------------------------------------------------------------------------- |
1580 | iglobal |
1579 | iglobal |
1581 | midi_base dw 0 |
1580 | midi_base dw 0 |
1582 | endg |
1581 | endg |
1583 | ;----------------------------------------------------------------------------- |
1582 | ;----------------------------------------------------------------------------- |
1584 | align 4 |
1583 | align 4 |
1585 | sys_setup: |
1584 | sys_setup: |
1586 | ; 1 = roland mpu midi base , base io address |
1585 | ; 1 = roland mpu midi base , base io address |
1587 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1586 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1588 | ; 3 = not used |
1587 | ; 3 = not used |
1589 | ; 4 = not used |
1588 | ; 4 = not used |
1590 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1589 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1591 | ; 6 = not used |
1590 | ; 6 = not used |
1592 | ; 7 = not used |
1591 | ; 7 = not used |
1593 | ; 8 = not used |
1592 | ; 8 = not used |
1594 | ; 9 = not used |
1593 | ; 9 = not used |
1595 | ; 10 = not used |
1594 | ; 10 = not used |
1596 | ; 11 = enable lba read |
1595 | ; 11 = enable lba read |
1597 | ; 12 = enable pci access |
1596 | ; 12 = enable pci access |
1598 | ;----------------------------------------------------------------------------- |
1597 | ;----------------------------------------------------------------------------- |
1599 | and [esp+32], dword 0 |
1598 | and [esp+32], dword 0 |
1600 | ; F.21.1 - set MPU MIDI base port |
1599 | ; F.21.1 - set MPU MIDI base port |
1601 | dec ebx |
1600 | dec ebx |
1602 | jnz @f |
1601 | jnz @f |
1603 | 1602 | ||
1604 | cmp ecx, 0x100 |
1603 | cmp ecx, 0x100 |
1605 | jb @f |
1604 | jb @f |
1606 | 1605 | ||
1607 | mov esi, 65535 |
1606 | mov esi, 65535 |
1608 | cmp esi, ecx |
1607 | cmp esi, ecx |
1609 | jb @f |
1608 | jb @f |
1610 | 1609 | ||
1611 | mov [midi_base], cx |
1610 | mov [midi_base], cx |
1612 | mov word [mididp], cx |
1611 | mov word [mididp], cx |
1613 | inc cx |
1612 | inc cx |
1614 | mov word [midisp], cx |
1613 | mov word [midisp], cx |
1615 | ret |
1614 | ret |
1616 | ;-------------------------------------- |
1615 | ;-------------------------------------- |
1617 | @@: |
1616 | @@: |
1618 | ; F.21.2 - set keyboard layout |
1617 | ; F.21.2 - set keyboard layout |
1619 | dec ebx |
1618 | dec ebx |
1620 | jnz @f |
1619 | jnz @f |
1621 | 1620 | ||
1622 | mov edi, [TASK_BASE] |
1621 | mov edi, [TASK_BASE] |
1623 | mov eax, [edi+TASKDATA.mem_start] |
1622 | mov eax, [edi+TASKDATA.mem_start] |
1624 | add eax, edx |
1623 | add eax, edx |
1625 | ; 1 = normal layout |
1624 | ; 1 = normal layout |
1626 | dec ecx |
1625 | dec ecx |
1627 | jnz .shift |
1626 | jnz .shift |
1628 | 1627 | ||
1629 | mov ebx, keymap |
1628 | mov ebx, keymap |
1630 | mov ecx, 128 |
1629 | mov ecx, 128 |
1631 | call memmove |
1630 | call memmove |
1632 | ret |
1631 | ret |
1633 | ;-------------------------------------- |
1632 | ;-------------------------------------- |
1634 | .shift: |
1633 | .shift: |
1635 | ; 2 = layout at pressed Shift |
1634 | ; 2 = layout at pressed Shift |
1636 | dec ecx |
1635 | dec ecx |
1637 | jnz .alt |
1636 | jnz .alt |
1638 | 1637 | ||
1639 | mov ebx, keymap_shift |
1638 | mov ebx, keymap_shift |
1640 | mov ecx, 128 |
1639 | mov ecx, 128 |
1641 | call memmove |
1640 | call memmove |
1642 | ret |
1641 | ret |
1643 | ;-------------------------------------- |
1642 | ;-------------------------------------- |
1644 | .alt: |
1643 | .alt: |
1645 | ; 3 = layout at pressed Alt |
1644 | ; 3 = layout at pressed Alt |
1646 | dec ecx |
1645 | dec ecx |
1647 | jnz .country |
1646 | jnz .country |
1648 | 1647 | ||
1649 | mov ebx, keymap_alt |
1648 | mov ebx, keymap_alt |
1650 | mov ecx, 128 |
1649 | mov ecx, 128 |
1651 | call memmove |
1650 | call memmove |
1652 | ret |
1651 | ret |
1653 | ;-------------------------------------- |
1652 | ;-------------------------------------- |
1654 | .country: |
1653 | .country: |
1655 | ; country identifier |
1654 | ; country identifier |
1656 | sub ecx, 6 |
1655 | sub ecx, 6 |
1657 | jnz .error |
1656 | jnz .error |
1658 | 1657 | ||
1659 | mov word [keyboard], dx |
1658 | mov word [keyboard], dx |
1660 | ret |
1659 | ret |
1661 | ;-------------------------------------- |
1660 | ;-------------------------------------- |
1662 | @@: |
1661 | @@: |
1663 | ; F.21.5 - set system language |
1662 | ; F.21.5 - set system language |
1664 | sub ebx, 3 |
1663 | sub ebx, 3 |
1665 | jnz @f |
1664 | jnz @f |
1666 | 1665 | ||
1667 | mov [syslang], ecx |
1666 | mov [syslang], ecx |
1668 | ret |
1667 | ret |
1669 | ;-------------------------------------- |
1668 | ;-------------------------------------- |
1670 | @@: |
1669 | @@: |
1671 | ; F.21.11 - enable/disable low-level access to HD |
1670 | ; F.21.11 - enable/disable low-level access to HD |
1672 | and ecx, 1 |
1671 | and ecx, 1 |
1673 | sub ebx, 6 |
1672 | sub ebx, 6 |
1674 | jnz @f |
1673 | jnz @f |
1675 | 1674 | ||
1676 | mov [lba_read_enabled], ecx |
1675 | mov [lba_read_enabled], ecx |
1677 | ret |
1676 | ret |
1678 | ;-------------------------------------- |
1677 | ;-------------------------------------- |
1679 | @@: |
1678 | @@: |
1680 | ; F.21.12 - enable/disable low-level access to PCI |
1679 | ; F.21.12 - enable/disable low-level access to PCI |
1681 | dec ebx |
1680 | dec ebx |
1682 | jnz .error |
1681 | jnz .error |
1683 | 1682 | ||
1684 | mov [pci_access_enabled], ecx |
1683 | mov [pci_access_enabled], ecx |
1685 | ret |
1684 | ret |
1686 | ;-------------------------------------- |
1685 | ;-------------------------------------- |
1687 | .error: |
1686 | .error: |
1688 | or [esp+32], dword -1 |
1687 | or [esp+32], dword -1 |
1689 | ret |
1688 | ret |
1690 | ;----------------------------------------------------------------------------- |
1689 | ;----------------------------------------------------------------------------- |
1691 | align 4 |
1690 | align 4 |
1692 | sys_getsetup: |
1691 | sys_getsetup: |
1693 | ; 1 = roland mpu midi base , base io address |
1692 | ; 1 = roland mpu midi base , base io address |
1694 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1693 | ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus |
1695 | ; 3 = not used |
1694 | ; 3 = not used |
1696 | ; 4 = not used |
1695 | ; 4 = not used |
1697 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1696 | ; 5 = system language, 1eng 2fi 3ger 4rus |
1698 | ; 6 = not used |
1697 | ; 6 = not used |
1699 | ; 7 = not used |
1698 | ; 7 = not used |
1700 | ; 8 = not used |
1699 | ; 8 = not used |
1701 | ; 9 = get hs timer tic |
1700 | ; 9 = get hs timer tic |
1702 | ; 10 = not used |
1701 | ; 10 = not used |
1703 | ; 11 = get the state "lba read" |
1702 | ; 11 = get the state "lba read" |
1704 | ; 12 = get the state "pci access" |
1703 | ; 12 = get the state "pci access" |
1705 | ;----------------------------------------------------------------------------- |
1704 | ;----------------------------------------------------------------------------- |
1706 | ; F.26.1 - get MPU MIDI base port |
1705 | ; F.26.1 - get MPU MIDI base port |
1707 | dec ebx |
1706 | dec ebx |
1708 | jnz @f |
1707 | jnz @f |
1709 | 1708 | ||
1710 | movzx eax, [midi_base] |
1709 | movzx eax, [midi_base] |
1711 | mov [esp+32], eax |
1710 | mov [esp+32], eax |
1712 | ret |
1711 | ret |
1713 | ;-------------------------------------- |
1712 | ;-------------------------------------- |
1714 | @@: |
1713 | @@: |
1715 | ; F.26.2 - get keyboard layout |
1714 | ; F.26.2 - get keyboard layout |
1716 | dec ebx |
1715 | dec ebx |
1717 | jnz @f |
1716 | jnz @f |
1718 | 1717 | ||
1719 | mov edi, [TASK_BASE] |
1718 | mov edi, [TASK_BASE] |
1720 | mov ebx, [edi+TASKDATA.mem_start] |
1719 | mov ebx, [edi+TASKDATA.mem_start] |
1721 | add ebx, edx |
1720 | add ebx, edx |
1722 | ; 1 = normal layout |
1721 | ; 1 = normal layout |
1723 | dec ecx |
1722 | dec ecx |
1724 | jnz .shift |
1723 | jnz .shift |
1725 | 1724 | ||
1726 | mov eax, keymap |
1725 | mov eax, keymap |
1727 | mov ecx, 128 |
1726 | mov ecx, 128 |
1728 | call memmove |
1727 | call memmove |
1729 | ret |
1728 | ret |
1730 | ;-------------------------------------- |
1729 | ;-------------------------------------- |
1731 | .shift: |
1730 | .shift: |
1732 | ; 2 = layout with pressed Shift |
1731 | ; 2 = layout with pressed Shift |
1733 | dec ecx |
1732 | dec ecx |
1734 | jnz .alt |
1733 | jnz .alt |
1735 | 1734 | ||
1736 | mov eax, keymap_shift |
1735 | mov eax, keymap_shift |
1737 | mov ecx, 128 |
1736 | mov ecx, 128 |
1738 | call memmove |
1737 | call memmove |
1739 | ret |
1738 | ret |
1740 | ;-------------------------------------- |
1739 | ;-------------------------------------- |
1741 | .alt: |
1740 | .alt: |
1742 | ; 3 = layout with pressed Alt |
1741 | ; 3 = layout with pressed Alt |
1743 | dec ecx |
1742 | dec ecx |
1744 | jne .country |
1743 | jne .country |
1745 | 1744 | ||
1746 | mov eax, keymap_alt |
1745 | mov eax, keymap_alt |
1747 | mov ecx, 128 |
1746 | mov ecx, 128 |
1748 | call memmove |
1747 | call memmove |
1749 | ret |
1748 | ret |
1750 | ;-------------------------------------- |
1749 | ;-------------------------------------- |
1751 | .country: |
1750 | .country: |
1752 | ; 9 = country identifier |
1751 | ; 9 = country identifier |
1753 | sub ecx, 6 |
1752 | sub ecx, 6 |
1754 | jnz .error |
1753 | jnz .error |
1755 | 1754 | ||
1756 | movzx eax, word [keyboard] |
1755 | movzx eax, word [keyboard] |
1757 | mov [esp+32], eax |
1756 | mov [esp+32], eax |
1758 | ret |
1757 | ret |
1759 | ;-------------------------------------- |
1758 | ;-------------------------------------- |
1760 | @@: |
1759 | @@: |
1761 | ; F.26.5 - get system language |
1760 | ; F.26.5 - get system language |
1762 | sub ebx, 3 |
1761 | sub ebx, 3 |
1763 | jnz @f |
1762 | jnz @f |
1764 | 1763 | ||
1765 | mov eax, [syslang] |
1764 | mov eax, [syslang] |
1766 | mov [esp+32], eax |
1765 | mov [esp+32], eax |
1767 | ret |
1766 | ret |
1768 | ;-------------------------------------- |
1767 | ;-------------------------------------- |
1769 | @@: |
1768 | @@: |
1770 | ; F.26.9 - get the value of the time counter |
1769 | ; F.26.9 - get the value of the time counter |
1771 | sub ebx, 4 |
1770 | sub ebx, 4 |
1772 | jnz @f |
1771 | jnz @f |
1773 | 1772 | ||
1774 | mov eax, [timer_ticks] |
1773 | mov eax, [timer_ticks] |
1775 | mov [esp+32], eax |
1774 | mov [esp+32], eax |
1776 | ret |
1775 | ret |
1777 | ;-------------------------------------- |
1776 | ;-------------------------------------- |
1778 | @@: |
1777 | @@: |
1779 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1778 | ; F.26.10 - get the time from kernel launch in nanoseconds |
1780 | sub ebx, 1 |
1779 | sub ebx, 1 |
1781 | jnz @f |
1780 | jnz @f |
1782 | 1781 | ||
1783 | call get_clock_ns |
1782 | call get_clock_ns |
1784 | mov [esp+24], edx |
1783 | mov [esp+24], edx |
1785 | mov [esp+32], eax |
1784 | mov [esp+32], eax |
1786 | ret |
1785 | ret |
1787 | ;-------------------------------------- |
1786 | ;-------------------------------------- |
1788 | @@: |
1787 | @@: |
1789 | ; F.26.11 - Find out whether low-level HD access is enabled |
1788 | ; F.26.11 - Find out whether low-level HD access is enabled |
1790 | sub ebx, 1 |
1789 | sub ebx, 1 |
1791 | jnz @f |
1790 | jnz @f |
1792 | 1791 | ||
1793 | mov eax, [lba_read_enabled] |
1792 | mov eax, [lba_read_enabled] |
1794 | mov [esp+32], eax |
1793 | mov [esp+32], eax |
1795 | ret |
1794 | ret |
1796 | ;-------------------------------------- |
1795 | ;-------------------------------------- |
1797 | @@: |
1796 | @@: |
1798 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1797 | ; F.26.12 - Find out whether low-level PCI access is enabled |
1799 | dec ebx |
1798 | dec ebx |
1800 | jnz .error |
1799 | jnz .error |
1801 | 1800 | ||
1802 | mov eax, [pci_access_enabled] |
1801 | mov eax, [pci_access_enabled] |
1803 | mov [esp+32], eax |
1802 | mov [esp+32], eax |
1804 | ret |
1803 | ret |
1805 | ;-------------------------------------- |
1804 | ;-------------------------------------- |
1806 | .error: |
1805 | .error: |
1807 | or [esp+32], dword -1 |
1806 | or [esp+32], dword -1 |
1808 | ret |
1807 | ret |
1809 | ;----------------------------------------------------------------------------- |
1808 | ;----------------------------------------------------------------------------- |
1810 | get_timer_ticks: |
1809 | get_timer_ticks: |
1811 | mov eax, [timer_ticks] |
1810 | mov eax, [timer_ticks] |
1812 | ret |
1811 | ret |
1813 | ;----------------------------------------------------------------------------- |
1812 | ;----------------------------------------------------------------------------- |
1814 | readmousepos: |
1813 | readmousepos: |
1815 | ; eax=0 screen relative |
1814 | ; eax=0 screen relative |
1816 | ; eax=1 window relative |
1815 | ; eax=1 window relative |
1817 | ; eax=2 buttons pressed |
1816 | ; eax=2 buttons pressed |
1818 | ; eax=3 buttons pressed ext |
1817 | ; eax=3 buttons pressed ext |
1819 | ; eax=4 load cursor |
1818 | ; eax=4 load cursor |
1820 | ; eax=5 set cursor |
1819 | ; eax=5 set cursor |
1821 | ; eax=6 delete cursor |
1820 | ; eax=6 delete cursor |
1822 | ; eax=7 get mouse_z |
1821 | ; eax=7 get mouse_z |
1823 | ; eax=8 load cursor unicode |
1822 | ; eax=8 load cursor unicode |
1824 | cmp ebx, 8 |
1823 | cmp ebx, 8 |
1825 | ja @f |
1824 | ja @f |
1826 | jmp dword[.mousefn+ebx*4] |
1825 | jmp dword[.mousefn+ebx*4] |
1827 | 1826 | ||
1828 | align 4 |
1827 | align 4 |
1829 | .mousefn: |
1828 | .mousefn: |
1830 | dd .msscreen |
1829 | dd .msscreen |
1831 | dd .mswin |
1830 | dd .mswin |
1832 | dd .msbutton |
1831 | dd .msbutton |
1833 | dd .msbuttonExt |
1832 | dd .msbuttonExt |
1834 | dd .app_load_cursor |
1833 | dd .app_load_cursor |
1835 | dd .app_set_cursor |
1834 | dd .app_set_cursor |
1836 | dd .app_delete_cursor |
1835 | dd .app_delete_cursor |
1837 | dd .msz |
1836 | dd .msz |
1838 | dd .loadCursorUni |
1837 | dd .loadCursorUni |
1839 | 1838 | ||
1840 | .msscreen: |
1839 | .msscreen: |
1841 | mov eax, [MOUSE_X] |
1840 | mov eax, [MOUSE_X] |
1842 | shl eax, 16 |
1841 | shl eax, 16 |
1843 | mov ax, [MOUSE_Y] |
1842 | mov ax, [MOUSE_Y] |
1844 | mov [esp+36-4], eax |
1843 | mov [esp+36-4], eax |
1845 | @@: |
1844 | @@: |
1846 | ret |
1845 | ret |
1847 | 1846 | ||
1848 | .mswin: |
1847 | .mswin: |
1849 | mov eax, [MOUSE_X] |
1848 | mov eax, [MOUSE_X] |
1850 | shl eax, 16 |
1849 | shl eax, 16 |
1851 | mov ax, [MOUSE_Y] |
1850 | mov ax, [MOUSE_Y] |
1852 | mov esi, [TASK_BASE] |
1851 | mov esi, [TASK_BASE] |
1853 | mov bx, word [esi-twdw+WDATA.box.left] |
1852 | mov bx, word [esi-twdw+WDATA.box.left] |
1854 | shl ebx, 16 |
1853 | shl ebx, 16 |
1855 | mov bx, word [esi-twdw+WDATA.box.top] |
1854 | mov bx, word [esi-twdw+WDATA.box.top] |
1856 | sub eax, ebx |
1855 | sub eax, ebx |
1857 | mov edi, [CURRENT_TASK] |
1856 | mov edi, [CURRENT_TASK] |
1858 | shl edi, 8 |
1857 | shl edi, 8 |
1859 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1858 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] |
1860 | rol eax, 16 |
1859 | rol eax, 16 |
1861 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1860 | sub ax, word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] |
1862 | rol eax, 16 |
1861 | rol eax, 16 |
1863 | mov [esp+36-4], eax |
1862 | mov [esp+36-4], eax |
1864 | ret |
1863 | ret |
1865 | 1864 | ||
1866 | .msbutton: |
1865 | .msbutton: |
1867 | movzx eax, byte [BTN_DOWN] |
1866 | movzx eax, byte [BTN_DOWN] |
1868 | mov [esp+36-4], eax |
1867 | mov [esp+36-4], eax |
1869 | ret |
1868 | ret |
1870 | 1869 | ||
1871 | .msbuttonExt: |
1870 | .msbuttonExt: |
1872 | mov eax, [BTN_DOWN] |
1871 | mov eax, [BTN_DOWN] |
1873 | mov [esp+36-4], eax |
1872 | mov [esp+36-4], eax |
1874 | ret |
1873 | ret |
1875 | 1874 | ||
1876 | .app_load_cursor: |
1875 | .app_load_cursor: |
1877 | cmp ecx, OS_BASE |
1876 | cmp ecx, OS_BASE |
1878 | jae @f |
1877 | jae @f |
1879 | stdcall load_cursor, ecx, edx |
1878 | stdcall load_cursor, ecx, edx |
1880 | mov [esp+36-4], eax |
1879 | mov [esp+36-4], eax |
1881 | @@: |
1880 | @@: |
1882 | ret |
1881 | ret |
1883 | 1882 | ||
1884 | .loadCursorUni: |
1883 | .loadCursorUni: |
1885 | cmp ecx, OS_BASE |
1884 | cmp ecx, OS_BASE |
1886 | jae @b |
1885 | jae @b |
1887 | push ecx edx |
1886 | push ecx edx |
1888 | stdcall kernel_alloc, maxPathLength |
1887 | stdcall kernel_alloc, maxPathLength |
1889 | mov edi, eax |
1888 | mov edi, eax |
1890 | pop eax esi |
1889 | pop eax esi |
1891 | push edi |
1890 | push edi |
1892 | call getFullPath |
1891 | call getFullPath |
1893 | pop ebp |
1892 | pop ebp |
1894 | test eax, eax |
1893 | test eax, eax |
1895 | jz @f |
1894 | jz @f |
1896 | stdcall load_cursor, ebp, LOAD_FROM_FILE |
1895 | stdcall load_cursor, ebp, LOAD_FROM_FILE |
1897 | mov [esp+32], eax |
1896 | mov [esp+32], eax |
1898 | @@: |
1897 | @@: |
1899 | stdcall kernel_free, ebp |
1898 | stdcall kernel_free, ebp |
1900 | ret |
1899 | ret |
1901 | 1900 | ||
1902 | .app_set_cursor: |
1901 | .app_set_cursor: |
1903 | stdcall set_cursor, ecx |
1902 | stdcall set_cursor, ecx |
1904 | mov [esp+36-4], eax |
1903 | mov [esp+36-4], eax |
1905 | ret |
1904 | ret |
1906 | 1905 | ||
1907 | .app_delete_cursor: |
1906 | .app_delete_cursor: |
1908 | stdcall delete_cursor, ecx |
1907 | stdcall delete_cursor, ecx |
1909 | mov [esp+36-4], eax |
1908 | mov [esp+36-4], eax |
1910 | ret |
1909 | ret |
1911 | 1910 | ||
1912 | .msz: |
1911 | .msz: |
1913 | mov edi, [TASK_COUNT] |
1912 | mov edi, [TASK_COUNT] |
1914 | movzx edi, word [WIN_POS + edi*2] |
1913 | movzx edi, word [WIN_POS + edi*2] |
1915 | cmp edi, [CURRENT_TASK] |
1914 | cmp edi, [CURRENT_TASK] |
1916 | jne @f |
1915 | jne @f |
1917 | mov ax, [MOUSE_SCROLL_H] |
1916 | mov ax, [MOUSE_SCROLL_H] |
1918 | shl eax, 16 |
1917 | shl eax, 16 |
1919 | mov ax, [MOUSE_SCROLL_V] |
1918 | mov ax, [MOUSE_SCROLL_V] |
1920 | mov [esp+36-4], eax |
1919 | mov [esp+36-4], eax |
1921 | and [MOUSE_SCROLL_H], word 0 |
1920 | and [MOUSE_SCROLL_H], word 0 |
1922 | and [MOUSE_SCROLL_V], word 0 |
1921 | and [MOUSE_SCROLL_V], word 0 |
1923 | ret |
1922 | ret |
1924 | @@: |
1923 | @@: |
1925 | and [esp+36-4], dword 0 |
1924 | and [esp+36-4], dword 0 |
1926 | ret |
1925 | ret |
1927 | 1926 | ||
1928 | is_input: |
1927 | is_input: |
1929 | 1928 | ||
1930 | push edx |
1929 | push edx |
1931 | mov dx, word [midisp] |
1930 | mov dx, word [midisp] |
1932 | in al, dx |
1931 | in al, dx |
1933 | and al, 0x80 |
1932 | and al, 0x80 |
1934 | pop edx |
1933 | pop edx |
1935 | ret |
1934 | ret |
1936 | 1935 | ||
1937 | is_output: |
1936 | is_output: |
1938 | 1937 | ||
1939 | push edx |
1938 | push edx |
1940 | mov dx, word [midisp] |
1939 | mov dx, word [midisp] |
1941 | in al, dx |
1940 | in al, dx |
1942 | and al, 0x40 |
1941 | and al, 0x40 |
1943 | pop edx |
1942 | pop edx |
1944 | ret |
1943 | ret |
1945 | 1944 | ||
1946 | 1945 | ||
1947 | get_mpu_in: |
1946 | get_mpu_in: |
1948 | 1947 | ||
1949 | push edx |
1948 | push edx |
1950 | mov dx, word [mididp] |
1949 | mov dx, word [mididp] |
1951 | in al, dx |
1950 | in al, dx |
1952 | pop edx |
1951 | pop edx |
1953 | ret |
1952 | ret |
1954 | 1953 | ||
1955 | 1954 | ||
1956 | put_mpu_out: |
1955 | put_mpu_out: |
1957 | 1956 | ||
1958 | push edx |
1957 | push edx |
1959 | mov dx, word [mididp] |
1958 | mov dx, word [mididp] |
1960 | out dx, al |
1959 | out dx, al |
1961 | pop edx |
1960 | pop edx |
1962 | ret |
1961 | ret |
1963 | 1962 | ||
1964 | 1963 | ||
1965 | 1964 | ||
1966 | align 4 |
1965 | align 4 |
1967 | 1966 | ||
1968 | sys_midi: |
1967 | sys_midi: |
1969 | cmp [mididp], 0 |
1968 | cmp [mididp], 0 |
1970 | jnz sm0 |
1969 | jnz sm0 |
1971 | mov [esp+36], dword 1 |
1970 | mov [esp+36], dword 1 |
1972 | ret |
1971 | ret |
1973 | sm0: |
1972 | sm0: |
1974 | and [esp+36], dword 0 |
1973 | and [esp+36], dword 0 |
1975 | dec ebx |
1974 | dec ebx |
1976 | jnz smn1 |
1975 | jnz smn1 |
1977 | ; call setuart |
1976 | ; call setuart |
1978 | su1: |
1977 | su1: |
1979 | call is_output |
1978 | call is_output |
1980 | test al, al |
1979 | test al, al |
1981 | jnz su1 |
1980 | jnz su1 |
1982 | mov dx, word [midisp] |
1981 | mov dx, word [midisp] |
1983 | mov al, 0xff |
1982 | mov al, 0xff |
1984 | out dx, al |
1983 | out dx, al |
1985 | su2: |
1984 | su2: |
1986 | mov dx, word [midisp] |
1985 | mov dx, word [midisp] |
1987 | mov al, 0xff |
1986 | mov al, 0xff |
1988 | out dx, al |
1987 | out dx, al |
1989 | call is_input |
1988 | call is_input |
1990 | test al, al |
1989 | test al, al |
1991 | jnz su2 |
1990 | jnz su2 |
1992 | call get_mpu_in |
1991 | call get_mpu_in |
1993 | cmp al, 0xfe |
1992 | cmp al, 0xfe |
1994 | jnz su2 |
1993 | jnz su2 |
1995 | su3: |
1994 | su3: |
1996 | call is_output |
1995 | call is_output |
1997 | test al, al |
1996 | test al, al |
1998 | jnz su3 |
1997 | jnz su3 |
1999 | mov dx, word [midisp] |
1998 | mov dx, word [midisp] |
2000 | mov al, 0x3f |
1999 | mov al, 0x3f |
2001 | out dx, al |
2000 | out dx, al |
2002 | ret |
2001 | ret |
2003 | smn1: |
2002 | smn1: |
2004 | dec ebx |
2003 | dec ebx |
2005 | jnz smn2 |
2004 | jnz smn2 |
2006 | sm10: |
2005 | sm10: |
2007 | call get_mpu_in |
2006 | call get_mpu_in |
2008 | call is_output |
2007 | call is_output |
2009 | test al, al |
2008 | test al, al |
2010 | jnz sm10 |
2009 | jnz sm10 |
2011 | mov al, bl |
2010 | mov al, bl |
2012 | call put_mpu_out |
2011 | call put_mpu_out |
2013 | smn2: |
2012 | smn2: |
2014 | ret |
2013 | ret |
2015 | 2014 | ||
2016 | detect_devices: |
2015 | detect_devices: |
2017 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2016 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2018 | ;include 'detect/commouse.inc' |
2017 | ;include 'detect/commouse.inc' |
2019 | ;include 'detect/ps2mouse.inc' |
2018 | ;include 'detect/ps2mouse.inc' |
2020 | ;include 'detect/dev_fd.inc' |
2019 | ;include 'detect/dev_fd.inc' |
2021 | ;include 'detect/dev_hdcd.inc' |
2020 | ;include 'detect/dev_hdcd.inc' |
2022 | ;include 'detect/sear_par.inc' |
2021 | ;include 'detect/sear_par.inc' |
2023 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2022 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
2024 | ret |
2023 | ret |
2025 | 2024 | ||
2026 | sys_end: |
2025 | sys_end: |
2027 | ;-------------------------------------- |
2026 | ;-------------------------------------- |
2028 | cmp [_display.select_cursor], 0 |
2027 | cmp [_display.select_cursor], 0 |
2029 | je @f |
2028 | je @f |
2030 | ; restore default cursor before killing |
2029 | ; restore default cursor before killing |
2031 | pusha |
2030 | pusha |
2032 | mov ecx, [current_slot] |
2031 | mov ecx, [current_slot] |
2033 | call restore_default_cursor_before_killing |
2032 | call restore_default_cursor_before_killing |
2034 | popa |
2033 | popa |
2035 | @@: |
2034 | @@: |
2036 | ;-------------------------------------- |
2035 | ;-------------------------------------- |
2037 | ; kill all sockets this process owns |
2036 | ; kill all sockets this process owns |
2038 | pusha |
2037 | pusha |
2039 | mov edx, [TASK_BASE] |
2038 | mov edx, [TASK_BASE] |
2040 | mov edx, [edx+TASKDATA.pid] |
2039 | mov edx, [edx+TASKDATA.pid] |
2041 | call socket_process_end |
2040 | call socket_process_end |
2042 | popa |
2041 | popa |
2043 | ;-------------------------------------- |
2042 | ;-------------------------------------- |
2044 | mov ecx, [current_slot] |
2043 | mov ecx, [current_slot] |
2045 | mov eax, [ecx+APPDATA.tls_base] |
2044 | mov eax, [ecx+APPDATA.tls_base] |
2046 | test eax, eax |
2045 | test eax, eax |
2047 | jz @F |
2046 | jz @F |
2048 | 2047 | ||
2049 | stdcall user_free, eax |
2048 | stdcall user_free, eax |
2050 | @@: |
2049 | @@: |
2051 | 2050 | ||
2052 | mov eax, [TASK_BASE] |
2051 | mov eax, [TASK_BASE] |
2053 | mov [eax+TASKDATA.state], TSTATE_ZOMBIE |
2052 | mov [eax+TASKDATA.state], TSTATE_ZOMBIE |
2054 | call wakeup_osloop |
2053 | call wakeup_osloop |
2055 | 2054 | ||
2056 | .waitterm: ; wait here for termination |
2055 | .waitterm: ; wait here for termination |
2057 | call change_task |
2056 | call change_task |
2058 | jmp .waitterm |
2057 | jmp .waitterm |
2059 | ;------------------------------------------------------------------------------ |
2058 | ;------------------------------------------------------------------------------ |
2060 | align 4 |
2059 | align 4 |
2061 | restore_default_cursor_before_killing: |
2060 | restore_default_cursor_before_killing: |
2062 | pushfd |
2061 | pushfd |
2063 | cli |
2062 | cli |
2064 | mov eax, [def_cursor] |
2063 | mov eax, [def_cursor] |
2065 | mov [ecx+APPDATA.cursor], eax |
2064 | mov [ecx+APPDATA.cursor], eax |
2066 | 2065 | ||
2067 | movzx eax, word [MOUSE_Y] |
2066 | movzx eax, word [MOUSE_Y] |
2068 | movzx ebx, word [MOUSE_X] |
2067 | movzx ebx, word [MOUSE_X] |
2069 | mov eax, [d_width_calc_area + eax*4] |
2068 | mov eax, [d_width_calc_area + eax*4] |
2070 | 2069 | ||
2071 | add eax, [_display.win_map] |
2070 | add eax, [_display.win_map] |
2072 | movzx edx, byte [ebx+eax] |
2071 | movzx edx, byte [ebx+eax] |
2073 | shl edx, 8 |
2072 | shl edx, 8 |
2074 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2073 | mov esi, [edx+SLOT_BASE+APPDATA.cursor] |
2075 | 2074 | ||
2076 | cmp esi, [current_cursor] |
2075 | cmp esi, [current_cursor] |
2077 | je @f |
2076 | je @f |
2078 | 2077 | ||
2079 | push esi |
2078 | push esi |
2080 | call [_display.select_cursor] |
2079 | call [_display.select_cursor] |
2081 | mov [current_cursor], esi |
2080 | mov [current_cursor], esi |
2082 | @@: |
2081 | @@: |
2083 | mov [redrawmouse_unconditional], 1 |
2082 | mov [redrawmouse_unconditional], 1 |
2084 | call wakeup_osloop |
2083 | call wakeup_osloop |
2085 | popfd |
2084 | popfd |
2086 | ret |
2085 | ret |
2087 | ;------------------------------------------------------------------------------ |
2086 | ;------------------------------------------------------------------------------ |
2088 | iglobal |
2087 | iglobal |
2089 | align 4 |
2088 | align 4 |
2090 | sys_system_table: |
2089 | sys_system_table: |
2091 | dd sysfn_deactivate ; 1 = deactivate window |
2090 | dd sysfn_deactivate ; 1 = deactivate window |
2092 | dd sysfn_terminate ; 2 = terminate thread |
2091 | dd sysfn_terminate ; 2 = terminate thread |
2093 | dd sysfn_activate ; 3 = activate window |
2092 | dd sysfn_activate ; 3 = activate window |
2094 | dd sysfn_getidletime ; 4 = get idle time |
2093 | dd sysfn_getidletime ; 4 = get idle time |
2095 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2094 | dd sysfn_getcpuclock ; 5 = get cpu clock |
2096 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2095 | dd sysfn_saveramdisk ; 6 = save ramdisk |
2097 | dd sysfn_getactive ; 7 = get active window |
2096 | dd sysfn_getactive ; 7 = get active window |
2098 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2097 | dd sysfn_sound_flag ; 8 = get/set sound_flag |
2099 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2098 | dd sysfn_shutdown ; 9 = shutdown with parameter |
2100 | dd sysfn_minimize ; 10 = minimize window |
2099 | dd sysfn_minimize ; 10 = minimize window |
2101 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2100 | dd sysfn_getdiskinfo ; 11 = get disk subsystem info |
2102 | dd sysfn_lastkey ; 12 = get last pressed key |
2101 | dd sysfn_lastkey ; 12 = get last pressed key |
2103 | dd sysfn_getversion ; 13 = get kernel version |
2102 | dd sysfn_getversion ; 13 = get kernel version |
2104 | dd sysfn_waitretrace ; 14 = wait retrace |
2103 | dd sysfn_waitretrace ; 14 = wait retrace |
2105 | dd sysfn_centermouse ; 15 = center mouse cursor |
2104 | dd sysfn_centermouse ; 15 = center mouse cursor |
2106 | dd sysfn_getfreemem ; 16 = get free memory size |
2105 | dd sysfn_getfreemem ; 16 = get free memory size |
2107 | dd sysfn_getallmem ; 17 = get total memory size |
2106 | dd sysfn_getallmem ; 17 = get total memory size |
2108 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2107 | dd sysfn_terminate2 ; 18 = terminate thread using PID |
2109 | ; instead of slot |
2108 | ; instead of slot |
2110 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2109 | dd sysfn_mouse_acceleration; 19 = set/get mouse acceleration |
2111 | dd sysfn_meminfo ; 20 = get extended memory info |
2110 | dd sysfn_meminfo ; 20 = get extended memory info |
2112 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2111 | dd sysfn_pid_to_slot ; 21 = get slot number for pid |
2113 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2112 | dd sysfn_min_rest_window ; 22 = minimize and restore any window |
2114 | dd sysfn_min_windows ; 23 = minimize all windows |
2113 | dd sysfn_min_windows ; 23 = minimize all windows |
2115 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2114 | dd sysfn_set_screen_sizes ; 24 = set screen sizes for Vesa |
2116 | 2115 | ||
2117 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
2116 | dd sysfn_zmodif ; 25 = get/set window z modifier ;Fantomer |
2118 | sysfn_num = ($ - sys_system_table)/4 |
2117 | sysfn_num = ($ - sys_system_table)/4 |
2119 | endg |
2118 | endg |
2120 | ;------------------------------------------------------------------------------ |
2119 | ;------------------------------------------------------------------------------ |
2121 | sys_system: |
2120 | sys_system: |
2122 | dec ebx |
2121 | dec ebx |
2123 | cmp ebx, sysfn_num |
2122 | cmp ebx, sysfn_num |
2124 | jae @f |
2123 | jae @f |
2125 | jmp dword [sys_system_table + ebx*4] |
2124 | jmp dword [sys_system_table + ebx*4] |
2126 | @@: |
2125 | @@: |
2127 | ret |
2126 | ret |
2128 | ;------------------------------------------------------------------------------ |
2127 | ;------------------------------------------------------------------------------ |
2129 | sysfn_shutdown: ; 18.9 = system shutdown |
2128 | sysfn_shutdown: ; 18.9 = system shutdown |
2130 | cmp ecx, SYSTEM_SHUTDOWN |
2129 | cmp ecx, SYSTEM_SHUTDOWN |
2131 | jl exit_for_anyone |
2130 | jl exit_for_anyone |
2132 | cmp ecx, SYSTEM_RESTART |
2131 | cmp ecx, SYSTEM_RESTART |
2133 | jg exit_for_anyone |
2132 | jg exit_for_anyone |
2134 | mov [BOOT.shutdown_type], cl |
2133 | mov [BOOT.shutdown_type], cl |
2135 | 2134 | ||
2136 | mov eax, [TASK_COUNT] |
2135 | mov eax, [TASK_COUNT] |
2137 | mov [SYS_SHUTDOWN], al |
2136 | mov [SYS_SHUTDOWN], al |
2138 | mov [shutdown_processes], eax |
2137 | mov [shutdown_processes], eax |
2139 | call wakeup_osloop |
2138 | call wakeup_osloop |
2140 | and dword [esp+32], 0 |
2139 | and dword [esp+32], 0 |
2141 | exit_for_anyone: |
2140 | exit_for_anyone: |
2142 | ret |
2141 | ret |
2143 | uglobal |
2142 | uglobal |
2144 | shutdown_processes: |
2143 | shutdown_processes: |
2145 | dd 0x0 |
2144 | dd 0x0 |
2146 | endg |
2145 | endg |
2147 | ;------------------------------------------------------------------------------ |
2146 | ;------------------------------------------------------------------------------ |
2148 | sysfn_terminate: ; 18.2 = TERMINATE |
2147 | sysfn_terminate: ; 18.2 = TERMINATE |
2149 | push ecx |
2148 | push ecx |
2150 | cmp ecx, 2 |
2149 | cmp ecx, 2 |
2151 | jb noprocessterminate |
2150 | jb noprocessterminate |
2152 | mov edx, [TASK_COUNT] |
2151 | mov edx, [TASK_COUNT] |
2153 | cmp ecx, edx |
2152 | cmp ecx, edx |
2154 | ja noprocessterminate |
2153 | ja noprocessterminate |
2155 | mov eax, [TASK_COUNT] |
2154 | mov eax, [TASK_COUNT] |
2156 | shl ecx, 5 |
2155 | shl ecx, 5 |
2157 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2156 | mov edx, [ecx+CURRENT_TASK+TASKDATA.pid] |
2158 | add ecx, CURRENT_TASK+TASKDATA.state |
2157 | add ecx, CURRENT_TASK+TASKDATA.state |
2159 | cmp byte [ecx], 9 |
2158 | cmp byte [ecx], 9 |
2160 | jz noprocessterminate |
2159 | jz noprocessterminate |
2161 | push ecx edx |
2160 | push ecx edx |
2162 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2161 | lea edx, [(ecx-(CURRENT_TASK and 1FFFFFFFh)-TASKDATA.state)*8+SLOT_BASE] |
2163 | call request_terminate |
2162 | call request_terminate |
2164 | pop edx ecx |
2163 | pop edx ecx |
2165 | test eax, eax |
2164 | test eax, eax |
2166 | jz noprocessterminate |
2165 | jz noprocessterminate |
2167 | ;-------------------------------------- |
2166 | ;-------------------------------------- |
2168 | ; terminate all network sockets it used |
2167 | ; terminate all network sockets it used |
2169 | pusha |
2168 | pusha |
2170 | mov eax, edx |
2169 | mov eax, edx |
2171 | call socket_process_end |
2170 | call socket_process_end |
2172 | popa |
2171 | popa |
2173 | ;-------------------------------------- |
2172 | ;-------------------------------------- |
2174 | cmp [_display.select_cursor], 0 |
2173 | cmp [_display.select_cursor], 0 |
2175 | je .restore_end |
2174 | je .restore_end |
2176 | ; restore default cursor before killing |
2175 | ; restore default cursor before killing |
2177 | pusha |
2176 | pusha |
2178 | mov ecx, [esp+32] |
2177 | mov ecx, [esp+32] |
2179 | shl ecx, 8 |
2178 | shl ecx, 8 |
2180 | add ecx, SLOT_BASE |
2179 | add ecx, SLOT_BASE |
2181 | mov eax, [def_cursor] |
2180 | mov eax, [def_cursor] |
2182 | cmp [ecx+APPDATA.cursor], eax |
2181 | cmp [ecx+APPDATA.cursor], eax |
2183 | je @f |
2182 | je @f |
2184 | call restore_default_cursor_before_killing |
2183 | call restore_default_cursor_before_killing |
2185 | @@: |
2184 | @@: |
2186 | popa |
2185 | popa |
2187 | .restore_end: |
2186 | .restore_end: |
2188 | ;-------------------------------------- |
2187 | ;-------------------------------------- |
2189 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2188 | ;call MEM_Heap_Lock ;guarantee that process isn't working with heap |
2190 | mov [ecx], byte 3; clear possible i40's |
2189 | mov [ecx], byte 3; clear possible i40's |
2191 | call wakeup_osloop |
2190 | call wakeup_osloop |
2192 | ;call MEM_Heap_UnLock |
2191 | ;call MEM_Heap_UnLock |
2193 | 2192 | ||
2194 | cmp edx, [application_table_owner]; clear app table stat |
2193 | cmp edx, [application_table_owner]; clear app table stat |
2195 | jne noatsc |
2194 | jne noatsc |
2196 | call unlock_application_table |
2195 | call unlock_application_table |
2197 | noatsc: |
2196 | noatsc: |
2198 | noprocessterminate: |
2197 | noprocessterminate: |
2199 | add esp, 4 |
2198 | add esp, 4 |
2200 | ret |
2199 | ret |
2201 | ;------------------------------------------------------------------------------ |
2200 | ;------------------------------------------------------------------------------ |
2202 | sysfn_terminate2: |
2201 | sysfn_terminate2: |
2203 | ;lock application_table_status mutex |
2202 | ;lock application_table_status mutex |
2204 | .table_status: |
2203 | .table_status: |
2205 | call lock_application_table |
2204 | call lock_application_table |
2206 | mov eax, ecx |
2205 | mov eax, ecx |
2207 | call pid_to_slot |
2206 | call pid_to_slot |
2208 | test eax, eax |
2207 | test eax, eax |
2209 | jz .not_found |
2208 | jz .not_found |
2210 | mov ecx, eax |
2209 | mov ecx, eax |
2211 | cli |
2210 | cli |
2212 | call sysfn_terminate |
2211 | call sysfn_terminate |
2213 | call unlock_application_table |
2212 | call unlock_application_table |
2214 | sti |
2213 | sti |
2215 | and dword [esp+32], 0 |
2214 | and dword [esp+32], 0 |
2216 | ret |
2215 | ret |
2217 | .not_found: |
2216 | .not_found: |
2218 | call unlock_application_table |
2217 | call unlock_application_table |
2219 | or dword [esp+32], -1 |
2218 | or dword [esp+32], -1 |
2220 | ret |
2219 | ret |
2221 | ;------------------------------------------------------------------------------ |
2220 | ;------------------------------------------------------------------------------ |
2222 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2221 | sysfn_deactivate: ; 18.1 = DEACTIVATE WINDOW |
2223 | cmp ecx, 2 |
2222 | cmp ecx, 2 |
2224 | jb .nowindowdeactivate |
2223 | jb .nowindowdeactivate |
2225 | cmp ecx, [TASK_COUNT] |
2224 | cmp ecx, [TASK_COUNT] |
2226 | ja .nowindowdeactivate |
2225 | ja .nowindowdeactivate |
2227 | 2226 | ||
2228 | movzx esi, word [WIN_STACK + ecx*2] |
2227 | movzx esi, word [WIN_STACK + ecx*2] |
2229 | cmp esi, 1 |
2228 | cmp esi, 1 |
2230 | je .nowindowdeactivate ; already deactive |
2229 | je .nowindowdeactivate ; already deactive |
2231 | 2230 | ||
2232 | mov edi, ecx |
2231 | mov edi, ecx |
2233 | shl edi, 5 |
2232 | shl edi, 5 |
2234 | add edi, window_data |
2233 | add edi, window_data |
2235 | movzx esi, word [WIN_STACK + ecx * 2] |
2234 | movzx esi, word [WIN_STACK + ecx * 2] |
2236 | lea esi, [WIN_POS + esi * 2] |
2235 | lea esi, [WIN_POS + esi * 2] |
2237 | call window._.window_deactivate |
2236 | call window._.window_deactivate |
2238 | call syscall_display_settings.calculateScreen |
2237 | call syscall_display_settings.calculateScreen |
2239 | call syscall_display_settings.redrawScreen |
2238 | call syscall_display_settings.redrawScreen |
2240 | .nowindowdeactivate: |
2239 | .nowindowdeactivate: |
2241 | ret |
2240 | ret |
2242 | ;------------------------------------------------------------------------------ |
2241 | ;------------------------------------------------------------------------------ |
2243 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2242 | sysfn_activate: ; 18.3 = ACTIVATE WINDOW |
2244 | cmp ecx, 2 |
2243 | cmp ecx, 2 |
2245 | jb .nowindowactivate |
2244 | jb .nowindowactivate |
2246 | cmp ecx, [TASK_COUNT] |
2245 | cmp ecx, [TASK_COUNT] |
2247 | ja .nowindowactivate |
2246 | ja .nowindowactivate |
2248 | ;------------------------------------- |
2247 | ;------------------------------------- |
2249 | @@: |
2248 | @@: |
2250 | ; If the window is captured and moved by the user, |
2249 | ; If the window is captured and moved by the user, |
2251 | ; then you can't change the position in window stack!!! |
2250 | ; then you can't change the position in window stack!!! |
2252 | mov al, [mouse.active_sys_window.action] |
2251 | mov al, [mouse.active_sys_window.action] |
2253 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2252 | and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
2254 | test al, al |
2253 | test al, al |
2255 | jz @f |
2254 | jz @f |
2256 | call change_task |
2255 | call change_task |
2257 | jmp @b |
2256 | jmp @b |
2258 | @@: |
2257 | @@: |
2259 | ;------------------------------------- |
2258 | ;------------------------------------- |
2260 | mov [window_minimize], 2; restore window if minimized |
2259 | mov [window_minimize], 2; restore window if minimized |
2261 | call wakeup_osloop |
2260 | call wakeup_osloop |
2262 | 2261 | ||
2263 | movzx esi, word [WIN_STACK + ecx*2] |
2262 | movzx esi, word [WIN_STACK + ecx*2] |
2264 | cmp esi, [TASK_COUNT] |
2263 | cmp esi, [TASK_COUNT] |
2265 | je .nowindowactivate; already active |
2264 | je .nowindowactivate; already active |
2266 | 2265 | ||
2267 | mov edi, ecx |
2266 | mov edi, ecx |
2268 | shl edi, 5 |
2267 | shl edi, 5 |
2269 | add edi, window_data |
2268 | add edi, window_data |
2270 | movzx esi, word [WIN_STACK + ecx * 2] |
2269 | movzx esi, word [WIN_STACK + ecx * 2] |
2271 | lea esi, [WIN_POS + esi * 2] |
2270 | lea esi, [WIN_POS + esi * 2] |
2272 | call waredraw |
2271 | call waredraw |
2273 | .nowindowactivate: |
2272 | .nowindowactivate: |
2274 | ret |
2273 | ret |
2275 | ;------------------------------------------------------------------------------ |
2274 | ;------------------------------------------------------------------------------ |
2276 | align 4 |
2275 | align 4 |
2277 | sysfn_zmodif: |
2276 | sysfn_zmodif: |
2278 | ;18,25,1 - get z_modif |
2277 | ;18,25,1 - get z_modif |
2279 | ;18,25,2 - set z_modif |
2278 | ;18,25,2 - set z_modif |
2280 | ;edx = -1(for current task) or TID |
2279 | ;edx = -1(for current task) or TID |
2281 | ;esi(for 2) = new value z_modif |
2280 | ;esi(for 2) = new value z_modif |
2282 | ;return: |
2281 | ;return: |
2283 | ;1: eax = z_modif |
2282 | ;1: eax = z_modif |
2284 | ;2: eax=0(fail),1(success) for set z_modif |
2283 | ;2: eax=0(fail),1(success) for set z_modif |
2285 | 2284 | ||
2286 | cmp edx, -1 |
2285 | cmp edx, -1 |
2287 | jne @f |
2286 | jne @f |
2288 | mov edx, [CURRENT_TASK] |
2287 | mov edx, [CURRENT_TASK] |
2289 | @@: |
2288 | @@: |
2290 | cmp edx, [TASK_COUNT] |
2289 | cmp edx, [TASK_COUNT] |
2291 | ja .fail |
2290 | ja .fail |
2292 | cmp edx, 1 |
2291 | cmp edx, 1 |
2293 | je .fail |
2292 | je .fail |
2294 | 2293 | ||
2295 | mov eax, edx |
2294 | mov eax, edx |
2296 | shl edx, 5 |
2295 | shl edx, 5 |
2297 | 2296 | ||
2298 | cmp [edx + CURRENT_TASK + TASKDATA.state], 9 |
2297 | cmp [edx + CURRENT_TASK + TASKDATA.state], 9 |
2299 | je .fail |
2298 | je .fail |
2300 | 2299 | ||
2301 | cmp ecx, 1 |
2300 | cmp ecx, 1 |
2302 | jnz .set_zmod |
2301 | jnz .set_zmod |
2303 | 2302 | ||
2304 | mov al, [edx + window_data + WDATA.z_modif] |
2303 | mov al, [edx + window_data + WDATA.z_modif] |
2305 | jmp .exit |
2304 | jmp .exit |
2306 | 2305 | ||
2307 | .set_zmod: |
2306 | .set_zmod: |
2308 | cmp ecx, 2 |
2307 | cmp ecx, 2 |
2309 | jnz .fail |
2308 | jnz .fail |
2310 | 2309 | ||
2311 | mov ebx, esi |
2310 | mov ebx, esi |
2312 | mov esi, eax |
2311 | mov esi, eax |
2313 | 2312 | ||
2314 | cmp bl, ZPOS_ALWAYS_TOP |
2313 | cmp bl, ZPOS_ALWAYS_TOP |
2315 | jg .fail |
2314 | jg .fail |
2316 | 2315 | ||
2317 | mov [edx + window_data + WDATA.z_modif], bl |
2316 | mov [edx + window_data + WDATA.z_modif], bl |
2318 | 2317 | ||
2319 | mov eax, [edx + window_data + WDATA.box.left] |
2318 | mov eax, [edx + window_data + WDATA.box.left] |
2320 | mov ebx, [edx + window_data + WDATA.box.top] |
2319 | mov ebx, [edx + window_data + WDATA.box.top] |
2321 | mov ecx, [edx + window_data + WDATA.box.width] |
2320 | mov ecx, [edx + window_data + WDATA.box.width] |
2322 | mov edx, [edx + window_data + WDATA.box.height] |
2321 | mov edx, [edx + window_data + WDATA.box.height] |
2323 | add ecx, eax |
2322 | add ecx, eax |
2324 | add edx, ebx |
2323 | add edx, ebx |
2325 | call window._.set_screen |
2324 | call window._.set_screen |
2326 | call window._.set_top_wnd |
2325 | call window._.set_top_wnd |
2327 | call window._.redraw_top_wnd |
2326 | call window._.redraw_top_wnd |
2328 | 2327 | ||
2329 | shl esi, 5 |
2328 | shl esi, 5 |
2330 | mov [esi + window_data + WDATA.fl_redraw], 1 |
2329 | mov [esi + window_data + WDATA.fl_redraw], 1 |
2331 | 2330 | ||
2332 | 2331 | ||
2333 | mov eax, 1 |
2332 | mov eax, 1 |
2334 | jmp .exit |
2333 | jmp .exit |
2335 | .fail: |
2334 | .fail: |
2336 | xor eax, eax |
2335 | xor eax, eax |
2337 | .exit: |
2336 | .exit: |
2338 | mov [esp+32], eax |
2337 | mov [esp+32], eax |
2339 | ret |
2338 | ret |
2340 | 2339 | ||
2341 | ;------------------------------------------------------------------------------ |
2340 | ;------------------------------------------------------------------------------ |
2342 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2341 | sysfn_getidletime: ; 18.4 = GET IDLETIME |
2343 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2342 | mov eax, [CURRENT_TASK+32+TASKDATA.cpu_usage] |
2344 | mov [esp+32], eax |
2343 | mov [esp+32], eax |
2345 | ret |
2344 | ret |
2346 | ;------------------------------------------------------------------------------ |
2345 | ;------------------------------------------------------------------------------ |
2347 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2346 | sysfn_getcpuclock: ; 18.5 = GET TSC/SEC |
2348 | mov eax, dword [cpu_freq] |
2347 | mov eax, dword [cpu_freq] |
2349 | mov [esp+32], eax |
2348 | mov [esp+32], eax |
2350 | ret |
2349 | ret |
2351 | ;------------------------------------------------------------------------------ |
2350 | ;------------------------------------------------------------------------------ |
2352 | get_cpu_freq: |
2351 | get_cpu_freq: |
2353 | mov eax, dword [cpu_freq] |
2352 | mov eax, dword [cpu_freq] |
2354 | mov edx, dword [cpu_freq+4] |
2353 | mov edx, dword [cpu_freq+4] |
2355 | ret |
2354 | ret |
2356 | ; SAVE ramdisk to /hd/1/menuet.img |
2355 | ; SAVE ramdisk to /hd/1/menuet.img |
2357 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2356 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2358 | include 'blkdev/rdsave.inc' |
2357 | include 'blkdev/rdsave.inc' |
2359 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2358 | ;!!!!!!!!!!!!!!!!!!!!!!!! |
2360 | ;------------------------------------------------------------------------------ |
2359 | ;------------------------------------------------------------------------------ |
2361 | align 4 |
2360 | align 4 |
2362 | sysfn_getactive: ; 18.7 = get active window |
2361 | sysfn_getactive: ; 18.7 = get active window |
2363 | mov eax, [TASK_COUNT] |
2362 | mov eax, [TASK_COUNT] |
2364 | movzx eax, word [WIN_POS + eax*2] |
2363 | movzx eax, word [WIN_POS + eax*2] |
2365 | mov [esp+32], eax |
2364 | mov [esp+32], eax |
2366 | ret |
2365 | ret |
2367 | ;------------------------------------------------------------------------------ |
2366 | ;------------------------------------------------------------------------------ |
2368 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2367 | sysfn_sound_flag: ; 18.8 = get/set sound_flag |
2369 | ; cmp ecx,1 |
2368 | ; cmp ecx,1 |
2370 | dec ecx |
2369 | dec ecx |
2371 | jnz nogetsoundflag |
2370 | jnz nogetsoundflag |
2372 | movzx eax, byte [sound_flag]; get sound_flag |
2371 | movzx eax, byte [sound_flag]; get sound_flag |
2373 | mov [esp+32], eax |
2372 | mov [esp+32], eax |
2374 | ret |
2373 | ret |
2375 | nogetsoundflag: |
2374 | nogetsoundflag: |
2376 | ; cmp ecx,2 |
2375 | ; cmp ecx,2 |
2377 | dec ecx |
2376 | dec ecx |
2378 | jnz nosoundflag |
2377 | jnz nosoundflag |
2379 | xor byte [sound_flag], 1 |
2378 | xor byte [sound_flag], 1 |
2380 | nosoundflag: |
2379 | nosoundflag: |
2381 | ret |
2380 | ret |
2382 | ;------------------------------------------------------------------------------ |
2381 | ;------------------------------------------------------------------------------ |
2383 | sysfn_minimize: ; 18.10 = minimize window |
2382 | sysfn_minimize: ; 18.10 = minimize window |
2384 | mov [window_minimize], 1 |
2383 | mov [window_minimize], 1 |
2385 | call wakeup_osloop |
2384 | call wakeup_osloop |
2386 | ret |
2385 | ret |
2387 | ;------------------------------------------------------------------------------ |
2386 | ;------------------------------------------------------------------------------ |
2388 | align 4 |
2387 | align 4 |
2389 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2388 | sysfn_getdiskinfo: ; 18.11 = get disk info table |
2390 | dec ecx |
2389 | dec ecx |
2391 | jnz .exit |
2390 | jnz .exit |
2392 | .small_table: |
2391 | .small_table: |
2393 | mov edi, edx |
2392 | mov edi, edx |
2394 | mov esi, DRIVE_DATA |
2393 | mov esi, DRIVE_DATA |
2395 | mov ecx, DRIVE_DATA_SIZE ;10 |
2394 | mov ecx, DRIVE_DATA_SIZE ;10 |
2396 | cld |
2395 | cld |
2397 | rep movsb |
2396 | rep movsb |
2398 | .exit: |
2397 | .exit: |
2399 | ret |
2398 | ret |
2400 | ;------------------------------------------------------------------------------ |
2399 | ;------------------------------------------------------------------------------ |
2401 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2400 | sysfn_lastkey: ; 18.12 = return 0 (backward compatibility) |
2402 | and dword [esp+32], 0 |
2401 | and dword [esp+32], 0 |
2403 | ret |
2402 | ret |
2404 | ;------------------------------------------------------------------------------ |
2403 | ;------------------------------------------------------------------------------ |
2405 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2404 | sysfn_getversion: ; 18.13 = get kernel ID and version |
2406 | mov edi, ecx |
2405 | mov edi, ecx |
2407 | mov esi, version_inf |
2406 | mov esi, version_inf |
2408 | mov ecx, version_end-version_inf |
2407 | mov ecx, version_end-version_inf |
2409 | rep movsb |
2408 | rep movsb |
2410 | ret |
2409 | ret |
2411 | ;------------------------------------------------------------------------------ |
2410 | ;------------------------------------------------------------------------------ |
2412 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2411 | sysfn_waitretrace: ; 18.14 = sys wait retrace |
2413 | ;wait retrace functions |
2412 | ;wait retrace functions |
2414 | sys_wait_retrace: |
2413 | sys_wait_retrace: |
2415 | mov edx, 0x3da |
2414 | mov edx, 0x3da |
2416 | WaitRetrace_loop: |
2415 | WaitRetrace_loop: |
2417 | in al, dx |
2416 | in al, dx |
2418 | test al, 1000b |
2417 | test al, 1000b |
2419 | jz WaitRetrace_loop |
2418 | jz WaitRetrace_loop |
2420 | and [esp+32], dword 0 |
2419 | and [esp+32], dword 0 |
2421 | ret |
2420 | ret |
2422 | ;------------------------------------------------------------------------------ |
2421 | ;------------------------------------------------------------------------------ |
2423 | align 4 |
2422 | align 4 |
2424 | sysfn_centermouse: ; 18.15 = mouse centered |
2423 | sysfn_centermouse: ; 18.15 = mouse centered |
2425 | mov eax, [_display.width] |
2424 | mov eax, [_display.width] |
2426 | shr eax, 1 |
2425 | shr eax, 1 |
2427 | mov [MOUSE_X], ax |
2426 | mov [MOUSE_X], ax |
2428 | mov eax, [_display.height] |
2427 | mov eax, [_display.height] |
2429 | shr eax, 1 |
2428 | shr eax, 1 |
2430 | mov [MOUSE_Y], ax |
2429 | mov [MOUSE_Y], ax |
2431 | call wakeup_osloop |
2430 | call wakeup_osloop |
2432 | xor eax, eax |
2431 | xor eax, eax |
2433 | and [esp+32], eax |
2432 | and [esp+32], eax |
2434 | ret |
2433 | ret |
2435 | ;------------------------------------------------------------------------------ |
2434 | ;------------------------------------------------------------------------------ |
2436 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2435 | sysfn_mouse_acceleration: ; 18.19 = set/get mouse features |
2437 | cmp ecx, 8 |
2436 | cmp ecx, 8 |
2438 | jnc @f |
2437 | jnc @f |
2439 | jmp dword [.table+ecx*4] |
2438 | jmp dword [.table+ecx*4] |
2440 | .get_mouse_acceleration: |
2439 | .get_mouse_acceleration: |
2441 | xor eax, eax |
2440 | xor eax, eax |
2442 | mov ax, [mouse_speed_factor] |
2441 | mov ax, [mouse_speed_factor] |
2443 | mov [esp+32], eax |
2442 | mov [esp+32], eax |
2444 | ret |
2443 | ret |
2445 | .set_mouse_acceleration: |
2444 | .set_mouse_acceleration: |
2446 | mov [mouse_speed_factor], dx |
2445 | mov [mouse_speed_factor], dx |
2447 | ret |
2446 | ret |
2448 | .get_mouse_delay: |
2447 | .get_mouse_delay: |
2449 | xor eax, eax |
2448 | xor eax, eax |
2450 | mov al, [mouse_delay] |
2449 | mov al, [mouse_delay] |
2451 | mov [esp+32], eax |
2450 | mov [esp+32], eax |
2452 | ret |
2451 | ret |
2453 | .set_mouse_delay: |
2452 | .set_mouse_delay: |
2454 | mov [mouse_delay], dl |
2453 | mov [mouse_delay], dl |
2455 | @@: |
2454 | @@: |
2456 | ret |
2455 | ret |
2457 | .set_pointer_position: |
2456 | .set_pointer_position: |
2458 | cmp dx, word[_display.height] |
2457 | cmp dx, word[_display.height] |
2459 | jae @b |
2458 | jae @b |
2460 | rol edx, 16 |
2459 | rol edx, 16 |
2461 | cmp dx, word[_display.width] |
2460 | cmp dx, word[_display.width] |
2462 | jae @b |
2461 | jae @b |
2463 | mov [MOUSE_X], edx |
2462 | mov [MOUSE_X], edx |
2464 | mov [mouse_active], 1 |
2463 | mov [mouse_active], 1 |
2465 | jmp wakeup_osloop |
2464 | jmp wakeup_osloop |
2466 | .set_mouse_button: |
2465 | .set_mouse_button: |
2467 | mov [BTN_DOWN], edx |
2466 | mov [BTN_DOWN], edx |
2468 | mov [mouse_active], 1 |
2467 | mov [mouse_active], 1 |
2469 | jmp wakeup_osloop |
2468 | jmp wakeup_osloop |
2470 | .get_doubleclick_delay: |
2469 | .get_doubleclick_delay: |
2471 | xor eax, eax |
2470 | xor eax, eax |
2472 | mov al, [mouse_doubleclick_delay] |
2471 | mov al, [mouse_doubleclick_delay] |
2473 | mov [esp+32], eax |
2472 | mov [esp+32], eax |
2474 | ret |
2473 | ret |
2475 | .set_doubleclick_delay: |
2474 | .set_doubleclick_delay: |
2476 | mov [mouse_doubleclick_delay], dl |
2475 | mov [mouse_doubleclick_delay], dl |
2477 | ret |
2476 | ret |
2478 | align 4 |
2477 | align 4 |
2479 | .table: |
2478 | .table: |
2480 | dd .get_mouse_acceleration |
2479 | dd .get_mouse_acceleration |
2481 | dd .set_mouse_acceleration |
2480 | dd .set_mouse_acceleration |
2482 | dd .get_mouse_delay |
2481 | dd .get_mouse_delay |
2483 | dd .set_mouse_delay |
2482 | dd .set_mouse_delay |
2484 | dd .set_pointer_position |
2483 | dd .set_pointer_position |
2485 | dd .set_mouse_button |
2484 | dd .set_mouse_button |
2486 | dd .get_doubleclick_delay |
2485 | dd .get_doubleclick_delay |
2487 | dd .set_doubleclick_delay |
2486 | dd .set_doubleclick_delay |
2488 | ;------------------------------------------------------------------------------ |
2487 | ;------------------------------------------------------------------------------ |
2489 | sysfn_getfreemem: |
2488 | sysfn_getfreemem: |
2490 | mov eax, [pg_data.pages_free] |
2489 | mov eax, [pg_data.pages_free] |
2491 | shl eax, 2 |
2490 | shl eax, 2 |
2492 | mov [esp+32], eax |
2491 | mov [esp+32], eax |
2493 | ret |
2492 | ret |
2494 | ;------------------------------------------------------------------------------ |
2493 | ;------------------------------------------------------------------------------ |
2495 | sysfn_getallmem: |
2494 | sysfn_getallmem: |
2496 | mov eax, [MEM_AMOUNT] |
2495 | mov eax, [MEM_AMOUNT] |
2497 | shr eax, 10 |
2496 | shr eax, 10 |
2498 | mov [esp+32], eax |
2497 | mov [esp+32], eax |
2499 | ret |
2498 | ret |
2500 | ;------------------------------------------------------------------------------ |
2499 | ;------------------------------------------------------------------------------ |
2501 | sysfn_pid_to_slot: |
2500 | sysfn_pid_to_slot: |
2502 | mov eax, ecx |
2501 | mov eax, ecx |
2503 | call pid_to_slot |
2502 | call pid_to_slot |
2504 | mov [esp+32], eax |
2503 | mov [esp+32], eax |
2505 | ret |
2504 | ret |
2506 | ;------------------------------------------------------------------------------ |
2505 | ;------------------------------------------------------------------------------ |
2507 | sysfn_min_rest_window: |
2506 | sysfn_min_rest_window: |
2508 | pushad |
2507 | pushad |
2509 | mov eax, edx ; ebx - operating |
2508 | mov eax, edx ; ebx - operating |
2510 | shr ecx, 1 |
2509 | shr ecx, 1 |
2511 | jnc @f |
2510 | jnc @f |
2512 | call pid_to_slot |
2511 | call pid_to_slot |
2513 | @@: |
2512 | @@: |
2514 | or eax, eax ; eax - number of slot |
2513 | or eax, eax ; eax - number of slot |
2515 | jz .error |
2514 | jz .error |
2516 | cmp eax, 255 ; varify maximal slot number |
2515 | cmp eax, 255 ; varify maximal slot number |
2517 | ja .error |
2516 | ja .error |
2518 | movzx eax, word [WIN_STACK + eax*2] |
2517 | movzx eax, word [WIN_STACK + eax*2] |
2519 | shr ecx, 1 |
2518 | shr ecx, 1 |
2520 | jc .restore |
2519 | jc .restore |
2521 | ; .minimize: |
2520 | ; .minimize: |
2522 | call minimize_window |
2521 | call minimize_window |
2523 | jmp .exit |
2522 | jmp .exit |
2524 | .restore: |
2523 | .restore: |
2525 | call restore_minimized_window |
2524 | call restore_minimized_window |
2526 | .exit: |
2525 | .exit: |
2527 | popad |
2526 | popad |
2528 | xor eax, eax |
2527 | xor eax, eax |
2529 | mov [esp+32], eax |
2528 | mov [esp+32], eax |
2530 | ret |
2529 | ret |
2531 | .error: |
2530 | .error: |
2532 | popad |
2531 | popad |
2533 | xor eax, eax |
2532 | xor eax, eax |
2534 | dec eax |
2533 | dec eax |
2535 | mov [esp+32], eax |
2534 | mov [esp+32], eax |
2536 | ret |
2535 | ret |
2537 | ;------------------------------------------------------------------------------ |
2536 | ;------------------------------------------------------------------------------ |
2538 | sysfn_min_windows: |
2537 | sysfn_min_windows: |
2539 | call minimize_all_window |
2538 | call minimize_all_window |
2540 | mov [esp+32], eax |
2539 | mov [esp+32], eax |
2541 | call change_task |
2540 | call change_task |
2542 | ret |
2541 | ret |
2543 | ;------------------------------------------------------------------------------ |
2542 | ;------------------------------------------------------------------------------ |
2544 | sysfn_set_screen_sizes: |
2543 | sysfn_set_screen_sizes: |
2545 | cmp [SCR_MODE], word 0x13 |
2544 | cmp [SCR_MODE], word 0x13 |
2546 | jbe .exit |
2545 | jbe .exit |
2547 | 2546 | ||
2548 | cmp [_display.select_cursor], select_cursor |
2547 | cmp [_display.select_cursor], select_cursor |
2549 | jne .exit |
2548 | jne .exit |
2550 | 2549 | ||
2551 | cmp ecx, [display_width_standard] |
2550 | cmp ecx, [display_width_standard] |
2552 | ja .exit |
2551 | ja .exit |
2553 | 2552 | ||
2554 | cmp edx, [display_height_standard] |
2553 | cmp edx, [display_height_standard] |
2555 | ja .exit |
2554 | ja .exit |
2556 | 2555 | ||
2557 | pushfd |
2556 | pushfd |
2558 | cli |
2557 | cli |
2559 | mov eax, ecx |
2558 | mov eax, ecx |
2560 | mov ecx, [_display.lfb_pitch] |
2559 | mov ecx, [_display.lfb_pitch] |
2561 | mov [_display.width], eax |
2560 | mov [_display.width], eax |
2562 | dec eax |
2561 | dec eax |
2563 | mov [_display.height], edx |
2562 | mov [_display.height], edx |
2564 | dec edx |
2563 | dec edx |
2565 | ; eax - new Screen_Max_X |
2564 | ; eax - new Screen_Max_X |
2566 | ; edx - new Screen_Max_Y |
2565 | ; edx - new Screen_Max_Y |
2567 | mov [do_not_touch_winmap], 1 |
2566 | mov [do_not_touch_winmap], 1 |
2568 | call set_screen |
2567 | call set_screen |
2569 | mov [do_not_touch_winmap], 0 |
2568 | mov [do_not_touch_winmap], 0 |
2570 | popfd |
2569 | popfd |
2571 | call change_task |
2570 | call change_task |
2572 | .exit: |
2571 | .exit: |
2573 | ret |
2572 | ret |
2574 | ;------------------------------------------------------------------------------ |
2573 | ;------------------------------------------------------------------------------ |
2575 | uglobal |
2574 | uglobal |
2576 | screen_workarea RECT |
2575 | screen_workarea RECT |
2577 | display_width_standard dd 0 |
2576 | display_width_standard dd 0 |
2578 | display_height_standard dd 0 |
2577 | display_height_standard dd 0 |
2579 | do_not_touch_winmap db 0 |
2578 | do_not_touch_winmap db 0 |
2580 | window_minimize db 0 |
2579 | window_minimize db 0 |
2581 | sound_flag db 0 |
2580 | sound_flag db 0 |
2582 | 2581 | ||
2583 | endg |
2582 | endg |
2584 | 2583 | ||
2585 | UID_NONE=0 |
2584 | UID_NONE=0 |
2586 | UID_MENUETOS=1 ;official |
2585 | UID_MENUETOS=1 ;official |
2587 | UID_KOLIBRI=2 ;russian |
2586 | UID_KOLIBRI=2 ;russian |
2588 | 2587 | ||
2589 | iglobal |
2588 | iglobal |
2590 | version_inf: |
2589 | version_inf: |
2591 | db 0,7,7,0 ; version 0.7.7.0 |
2590 | db 0,7,7,0 ; version 0.7.7.0 |
2592 | db 0 |
2591 | db 0 |
2593 | .rev dd __REV__ |
2592 | .rev dd __REV__ |
2594 | version_end: |
2593 | version_end: |
2595 | endg |
2594 | endg |
2596 | ;------------------------------------------------------------------------------ |
2595 | ;------------------------------------------------------------------------------ |
2597 | align 4 |
2596 | align 4 |
2598 | sys_cachetodiskette: |
2597 | sys_cachetodiskette: |
2599 | cmp ebx, 1 |
2598 | cmp ebx, 1 |
2600 | jb .no_floppy_save |
2599 | jb .no_floppy_save |
2601 | cmp ebx, 2 |
2600 | cmp ebx, 2 |
2602 | ja .no_floppy_save |
2601 | ja .no_floppy_save |
2603 | call save_image |
2602 | call save_image |
2604 | mov [esp + 32], eax |
2603 | mov [esp + 32], eax |
2605 | ret |
2604 | ret |
2606 | .no_floppy_save: |
2605 | .no_floppy_save: |
2607 | mov [esp + 32], dword 1 |
2606 | mov [esp + 32], dword 1 |
2608 | ret |
2607 | ret |
2609 | ;------------------------------------------------------------------------------ |
2608 | ;------------------------------------------------------------------------------ |
2610 | uglobal |
2609 | uglobal |
2611 | ; bgrchanged dd 0x0 |
2610 | ; bgrchanged dd 0x0 |
2612 | align 4 |
2611 | align 4 |
2613 | bgrlockpid dd 0 |
2612 | bgrlockpid dd 0 |
2614 | bgrlock db 0 |
2613 | bgrlock db 0 |
2615 | endg |
2614 | endg |
2616 | ;------------------------------------------------------------------------------ |
2615 | ;------------------------------------------------------------------------------ |
2617 | align 4 |
2616 | align 4 |
2618 | sys_background: |
2617 | sys_background: |
2619 | cmp ebx, 1 ; BACKGROUND SIZE |
2618 | cmp ebx, 1 ; BACKGROUND SIZE |
2620 | jnz nosb1 |
2619 | jnz nosb1 |
2621 | test ecx, ecx |
2620 | test ecx, ecx |
2622 | jz sbgrr |
2621 | jz sbgrr |
2623 | 2622 | ||
2624 | test edx, edx |
2623 | test edx, edx |
2625 | jz sbgrr |
2624 | jz sbgrr |
2626 | ;-------------------------------------- |
2625 | ;-------------------------------------- |
2627 | align 4 |
2626 | align 4 |
2628 | @@: |
2627 | @@: |
2629 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2628 | ;;Maxis use atomic bts for mutexes 4.4.2009 |
2630 | bts dword [bgrlock], 0 |
2629 | bts dword [bgrlock], 0 |
2631 | jnc @f |
2630 | jnc @f |
2632 | call change_task |
2631 | call change_task |
2633 | jmp @b |
2632 | jmp @b |
2634 | ;-------------------------------------- |
2633 | ;-------------------------------------- |
2635 | align 4 |
2634 | align 4 |
2636 | @@: |
2635 | @@: |
2637 | mov [BgrDataWidth], ecx |
2636 | mov [BgrDataWidth], ecx |
2638 | mov [BgrDataHeight], edx |
2637 | mov [BgrDataHeight], edx |
2639 | ; mov [bgrchanged],1 |
2638 | ; mov [bgrchanged],1 |
2640 | 2639 | ||
2641 | pushad |
2640 | pushad |
2642 | ; return memory for old background |
2641 | ; return memory for old background |
2643 | mov eax, [img_background] |
2642 | mov eax, [img_background] |
2644 | cmp eax, static_background_data |
2643 | cmp eax, static_background_data |
2645 | jz @f |
2644 | jz @f |
2646 | stdcall kernel_free, eax |
2645 | stdcall kernel_free, eax |
2647 | ;-------------------------------------- |
2646 | ;-------------------------------------- |
2648 | align 4 |
2647 | align 4 |
2649 | @@: |
2648 | @@: |
2650 | ; calculate RAW size |
2649 | ; calculate RAW size |
2651 | xor eax, eax |
2650 | xor eax, eax |
2652 | inc eax |
2651 | inc eax |
2653 | cmp [BgrDataWidth], eax |
2652 | cmp [BgrDataWidth], eax |
2654 | jae @f |
2653 | jae @f |
2655 | mov [BgrDataWidth], eax |
2654 | mov [BgrDataWidth], eax |
2656 | ;-------------------------------------- |
2655 | ;-------------------------------------- |
2657 | align 4 |
2656 | align 4 |
2658 | @@: |
2657 | @@: |
2659 | cmp [BgrDataHeight], eax |
2658 | cmp [BgrDataHeight], eax |
2660 | jae @f |
2659 | jae @f |
2661 | mov [BgrDataHeight], eax |
2660 | mov [BgrDataHeight], eax |
2662 | ;-------------------------------------- |
2661 | ;-------------------------------------- |
2663 | align 4 |
2662 | align 4 |
2664 | @@: |
2663 | @@: |
2665 | mov eax, [BgrDataWidth] |
2664 | mov eax, [BgrDataWidth] |
2666 | imul eax, [BgrDataHeight] |
2665 | imul eax, [BgrDataHeight] |
2667 | lea eax, [eax*3] |
2666 | lea eax, [eax*3] |
2668 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2667 | ; it is reserved with aligned to the boundary of 4 KB pages, |
2669 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2668 | ; otherwise there may be exceptions a page fault for vesa20_drawbackground_tiled |
2670 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2669 | ; because the 32 bit read is used for high performance: "mov eax,[esi]" |
2671 | shr eax, 12 |
2670 | shr eax, 12 |
2672 | inc eax |
2671 | inc eax |
2673 | shl eax, 12 |
2672 | shl eax, 12 |
2674 | mov [mem_BACKGROUND], eax |
2673 | mov [mem_BACKGROUND], eax |
2675 | ; get memory for new background |
2674 | ; get memory for new background |
2676 | stdcall kernel_alloc, eax |
2675 | stdcall kernel_alloc, eax |
2677 | test eax, eax |
2676 | test eax, eax |
2678 | jz .memfailed |
2677 | jz .memfailed |
2679 | mov [img_background], eax |
2678 | mov [img_background], eax |
2680 | jmp .exit |
2679 | jmp .exit |
2681 | ;-------------------------------------- |
2680 | ;-------------------------------------- |
2682 | align 4 |
2681 | align 4 |
2683 | .memfailed: |
2682 | .memfailed: |
2684 | ; revert to static monotone data |
2683 | ; revert to static monotone data |
2685 | mov [img_background], static_background_data |
2684 | mov [img_background], static_background_data |
2686 | xor eax, eax |
2685 | xor eax, eax |
2687 | inc eax |
2686 | inc eax |
2688 | mov [BgrDataWidth], eax |
2687 | mov [BgrDataWidth], eax |
2689 | mov [BgrDataHeight], eax |
2688 | mov [BgrDataHeight], eax |
2690 | mov [mem_BACKGROUND], 4 |
2689 | mov [mem_BACKGROUND], 4 |
2691 | ;-------------------------------------- |
2690 | ;-------------------------------------- |
2692 | align 4 |
2691 | align 4 |
2693 | .exit: |
2692 | .exit: |
2694 | popad |
2693 | popad |
2695 | mov [bgrlock], 0 |
2694 | mov [bgrlock], 0 |
2696 | ;-------------------------------------- |
2695 | ;-------------------------------------- |
2697 | align 4 |
2696 | align 4 |
2698 | sbgrr: |
2697 | sbgrr: |
2699 | ret |
2698 | ret |
2700 | ;------------------------------------------------------------------------------ |
2699 | ;------------------------------------------------------------------------------ |
2701 | align 4 |
2700 | align 4 |
2702 | nosb1: |
2701 | nosb1: |
2703 | cmp ebx, 2 ; SET PIXEL |
2702 | cmp ebx, 2 ; SET PIXEL |
2704 | jnz nosb2 |
2703 | jnz nosb2 |
2705 | 2704 | ||
2706 | mov eax, [img_background] |
2705 | mov eax, [img_background] |
2707 | test ecx, ecx |
2706 | test ecx, ecx |
2708 | jz @f |
2707 | jz @f |
2709 | cmp eax, static_background_data |
2708 | cmp eax, static_background_data |
2710 | jz .ret |
2709 | jz .ret |
2711 | ;-------------------------------------- |
2710 | ;-------------------------------------- |
2712 | align 4 |
2711 | align 4 |
2713 | @@: |
2712 | @@: |
2714 | mov ebx, [mem_BACKGROUND] |
2713 | mov ebx, [mem_BACKGROUND] |
2715 | add ebx, 4095 |
2714 | add ebx, 4095 |
2716 | and ebx, -4096 |
2715 | and ebx, -4096 |
2717 | sub ebx, 4 |
2716 | sub ebx, 4 |
2718 | cmp ecx, ebx |
2717 | cmp ecx, ebx |
2719 | ja .ret |
2718 | ja .ret |
2720 | 2719 | ||
2721 | mov ebx, [eax+ecx] |
2720 | mov ebx, [eax+ecx] |
2722 | and ebx, 0xFF000000;255*256*256*256 |
2721 | and ebx, 0xFF000000;255*256*256*256 |
2723 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2722 | and edx, 0x00FFFFFF;255*256*256+255*256+255 |
2724 | add edx, ebx |
2723 | add edx, ebx |
2725 | mov [eax+ecx], edx |
2724 | mov [eax+ecx], edx |
2726 | ;-------------------------------------- |
2725 | ;-------------------------------------- |
2727 | align 4 |
2726 | align 4 |
2728 | .ret: |
2727 | .ret: |
2729 | ret |
2728 | ret |
2730 | ;------------------------------------------------------------------------------ |
2729 | ;------------------------------------------------------------------------------ |
2731 | align 4 |
2730 | align 4 |
2732 | nosb2: |
2731 | nosb2: |
2733 | cmp ebx, 3 ; DRAW BACKGROUND |
2732 | cmp ebx, 3 ; DRAW BACKGROUND |
2734 | jnz nosb3 |
2733 | jnz nosb3 |
2735 | ;-------------------------------------- |
2734 | ;-------------------------------------- |
2736 | align 4 |
2735 | align 4 |
2737 | draw_background_temp: |
2736 | draw_background_temp: |
2738 | mov [background_defined], 1 |
2737 | mov [background_defined], 1 |
2739 | call force_redraw_background |
2738 | call force_redraw_background |
2740 | ;-------------------------------------- |
2739 | ;-------------------------------------- |
2741 | align 4 |
2740 | align 4 |
2742 | nosb31: |
2741 | nosb31: |
2743 | ret |
2742 | ret |
2744 | ;------------------------------------------------------------------------------ |
2743 | ;------------------------------------------------------------------------------ |
2745 | align 4 |
2744 | align 4 |
2746 | nosb3: |
2745 | nosb3: |
2747 | cmp ebx, 4 ; TILED / STRETCHED |
2746 | cmp ebx, 4 ; TILED / STRETCHED |
2748 | jnz nosb4 |
2747 | jnz nosb4 |
2749 | cmp ecx, [BgrDrawMode] |
2748 | cmp ecx, [BgrDrawMode] |
2750 | je nosb41 |
2749 | je nosb41 |
2751 | mov [BgrDrawMode], ecx |
2750 | mov [BgrDrawMode], ecx |
2752 | ;-------------------------------------- |
2751 | ;-------------------------------------- |
2753 | align 4 |
2752 | align 4 |
2754 | nosb41: |
2753 | nosb41: |
2755 | ret |
2754 | ret |
2756 | ;------------------------------------------------------------------------------ |
2755 | ;------------------------------------------------------------------------------ |
2757 | align 4 |
2756 | align 4 |
2758 | nosb4: |
2757 | nosb4: |
2759 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2758 | cmp ebx, 5 ; BLOCK MOVE TO BGR |
2760 | jnz nosb5 |
2759 | jnz nosb5 |
2761 | cmp [img_background], static_background_data |
2760 | cmp [img_background], static_background_data |
2762 | jnz @f |
2761 | jnz @f |
2763 | test edx, edx |
2762 | test edx, edx |
2764 | jnz .fin |
2763 | jnz .fin |
2765 | cmp esi, 4 |
2764 | cmp esi, 4 |
2766 | ja .fin |
2765 | ja .fin |
2767 | ;-------------------------------------- |
2766 | ;-------------------------------------- |
2768 | align 4 |
2767 | align 4 |
2769 | @@: |
2768 | @@: |
2770 | ; bughere |
2769 | ; bughere |
2771 | mov eax, ecx |
2770 | mov eax, ecx |
2772 | mov ebx, edx |
2771 | mov ebx, edx |
2773 | add ebx, [img_background];IMG_BACKGROUND |
2772 | add ebx, [img_background];IMG_BACKGROUND |
2774 | mov ecx, esi |
2773 | mov ecx, esi |
2775 | call memmove |
2774 | call memmove |
2776 | ;-------------------------------------- |
2775 | ;-------------------------------------- |
2777 | align 4 |
2776 | align 4 |
2778 | .fin: |
2777 | .fin: |
2779 | ret |
2778 | ret |
2780 | ;------------------------------------------------------------------------------ |
2779 | ;------------------------------------------------------------------------------ |
2781 | align 4 |
2780 | align 4 |
2782 | nosb5: |
2781 | nosb5: |
2783 | cmp ebx, 6 |
2782 | cmp ebx, 6 |
2784 | jnz nosb6 |
2783 | jnz nosb6 |
2785 | ;-------------------------------------- |
2784 | ;-------------------------------------- |
2786 | align 4 |
2785 | align 4 |
2787 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2786 | ;;Maxis use atomic bts for mutex 4.4.2009 |
2788 | @@: |
2787 | @@: |
2789 | bts dword [bgrlock], 0 |
2788 | bts dword [bgrlock], 0 |
2790 | jnc @f |
2789 | jnc @f |
2791 | call change_task |
2790 | call change_task |
2792 | jmp @b |
2791 | jmp @b |
2793 | ;-------------------------------------- |
2792 | ;-------------------------------------- |
2794 | align 4 |
2793 | align 4 |
2795 | @@: |
2794 | @@: |
2796 | mov eax, [CURRENT_TASK] |
2795 | mov eax, [CURRENT_TASK] |
2797 | mov [bgrlockpid], eax |
2796 | mov [bgrlockpid], eax |
2798 | cmp [img_background], static_background_data |
2797 | cmp [img_background], static_background_data |
2799 | jz .nomem |
2798 | jz .nomem |
2800 | stdcall user_alloc, [mem_BACKGROUND] |
2799 | stdcall user_alloc, [mem_BACKGROUND] |
2801 | mov [esp+32], eax |
2800 | mov [esp+32], eax |
2802 | test eax, eax |
2801 | test eax, eax |
2803 | jz .nomem |
2802 | jz .nomem |
2804 | mov ebx, eax |
2803 | mov ebx, eax |
2805 | shr ebx, 12 |
2804 | shr ebx, 12 |
2806 | or dword [page_tabs+(ebx-1)*4], MEM_BLOCK_DONT_FREE |
2805 | or dword [page_tabs+(ebx-1)*4], MEM_BLOCK_DONT_FREE |
2807 | mov esi, [img_background] |
2806 | mov esi, [img_background] |
2808 | shr esi, 12 |
2807 | shr esi, 12 |
2809 | mov ecx, [mem_BACKGROUND] |
2808 | mov ecx, [mem_BACKGROUND] |
2810 | add ecx, 0xFFF |
2809 | add ecx, 0xFFF |
2811 | shr ecx, 12 |
2810 | shr ecx, 12 |
2812 | ;-------------------------------------- |
2811 | ;-------------------------------------- |
2813 | align 4 |
2812 | align 4 |
2814 | .z: |
2813 | .z: |
2815 | mov eax, [page_tabs+ebx*4] |
2814 | mov eax, [page_tabs+ebx*4] |
2816 | test al, 1 |
2815 | test al, 1 |
2817 | jz @f |
2816 | jz @f |
2818 | call free_page |
2817 | call free_page |
2819 | ;-------------------------------------- |
2818 | ;-------------------------------------- |
2820 | align 4 |
2819 | align 4 |
2821 | @@: |
2820 | @@: |
2822 | mov eax, [page_tabs+esi*4] |
2821 | mov eax, [page_tabs+esi*4] |
2823 | or al, PG_UWR |
2822 | or al, PG_UWR |
2824 | mov [page_tabs+ebx*4], eax |
2823 | mov [page_tabs+ebx*4], eax |
2825 | mov eax, ebx |
2824 | mov eax, ebx |
2826 | shl eax, 12 |
2825 | shl eax, 12 |
2827 | invlpg [eax] |
2826 | invlpg [eax] |
2828 | inc ebx |
2827 | inc ebx |
2829 | inc esi |
2828 | inc esi |
2830 | loop .z |
2829 | loop .z |
2831 | ret |
2830 | ret |
2832 | ;-------------------------------------- |
2831 | ;-------------------------------------- |
2833 | align 4 |
2832 | align 4 |
2834 | .nomem: |
2833 | .nomem: |
2835 | and [bgrlockpid], 0 |
2834 | and [bgrlockpid], 0 |
2836 | mov [bgrlock], 0 |
2835 | mov [bgrlock], 0 |
2837 | ;------------------------------------------------------------------------------ |
2836 | ;------------------------------------------------------------------------------ |
2838 | align 4 |
2837 | align 4 |
2839 | nosb6: |
2838 | nosb6: |
2840 | cmp ebx, 7 |
2839 | cmp ebx, 7 |
2841 | jnz nosb7 |
2840 | jnz nosb7 |
2842 | cmp [bgrlock], 0 |
2841 | cmp [bgrlock], 0 |
2843 | jz .err |
2842 | jz .err |
2844 | mov eax, [CURRENT_TASK] |
2843 | mov eax, [CURRENT_TASK] |
2845 | cmp [bgrlockpid], eax |
2844 | cmp [bgrlockpid], eax |
2846 | jnz .err |
2845 | jnz .err |
2847 | mov eax, ecx |
2846 | mov eax, ecx |
2848 | mov ebx, ecx |
2847 | mov ebx, ecx |
2849 | shr eax, 12 |
2848 | shr eax, 12 |
2850 | mov ecx, [page_tabs+(eax-1)*4] |
2849 | mov ecx, [page_tabs+(eax-1)*4] |
2851 | test cl, MEM_BLOCK_USED or MEM_BLOCK_DONT_FREE |
2850 | test cl, MEM_BLOCK_USED or MEM_BLOCK_DONT_FREE |
2852 | jz .err |
2851 | jz .err |
2853 | jnp .err |
2852 | jnp .err |
2854 | push eax |
2853 | push eax |
2855 | shr ecx, 12 |
2854 | shr ecx, 12 |
2856 | dec ecx |
2855 | dec ecx |
2857 | ;-------------------------------------- |
2856 | ;-------------------------------------- |
2858 | align 4 |
2857 | align 4 |
2859 | @@: |
2858 | @@: |
2860 | and dword [page_tabs+eax*4], 0 |
2859 | and dword [page_tabs+eax*4], 0 |
2861 | mov edx, eax |
2860 | mov edx, eax |
2862 | shl edx, 12 |
2861 | shl edx, 12 |
2863 | push eax |
2862 | push eax |
2864 | invlpg [edx] |
2863 | invlpg [edx] |
2865 | pop eax |
2864 | pop eax |
2866 | inc eax |
2865 | inc eax |
2867 | loop @b |
2866 | loop @b |
2868 | pop eax |
2867 | pop eax |
2869 | and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE |
2868 | and dword [page_tabs+(eax-1)*4], not MEM_BLOCK_DONT_FREE |
2870 | stdcall user_free, ebx |
2869 | stdcall user_free, ebx |
2871 | mov [esp+32], eax |
2870 | mov [esp+32], eax |
2872 | and [bgrlockpid], 0 |
2871 | and [bgrlockpid], 0 |
2873 | mov [bgrlock], 0 |
2872 | mov [bgrlock], 0 |
2874 | ret |
2873 | ret |
2875 | ;-------------------------------------- |
2874 | ;-------------------------------------- |
2876 | align 4 |
2875 | align 4 |
2877 | .err: |
2876 | .err: |
2878 | and dword [esp+32], 0 |
2877 | and dword [esp+32], 0 |
2879 | ret |
2878 | ret |
2880 | ;------------------------------------------------------------------------------ |
2879 | ;------------------------------------------------------------------------------ |
2881 | align 4 |
2880 | align 4 |
2882 | nosb7: |
2881 | nosb7: |
2883 | cmp ebx, 8 |
2882 | cmp ebx, 8 |
2884 | jnz nosb8 |
2883 | jnz nosb8 |
2885 | 2884 | ||
2886 | mov ecx, [current_slot] |
2885 | mov ecx, [current_slot] |
2887 | xor eax, eax |
2886 | xor eax, eax |
2888 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2887 | xchg eax, [ecx+APPDATA.draw_bgr_x] |
2889 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2888 | mov [esp + 32], eax ; eax = [left]*65536 + [right] |
2890 | xor eax, eax |
2889 | xor eax, eax |
2891 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2890 | xchg eax, [ecx+APPDATA.draw_bgr_y] |
2892 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2891 | mov [esp + 20], eax ; ebx = [top]*65536 + [bottom] |
2893 | ret |
2892 | ret |
2894 | ;------------------------------------------------------------------------------ |
2893 | ;------------------------------------------------------------------------------ |
2895 | align 4 |
2894 | align 4 |
2896 | nosb8: |
2895 | nosb8: |
2897 | cmp ebx, 9 |
2896 | cmp ebx, 9 |
2898 | jnz nosb9 |
2897 | jnz nosb9 |
2899 | ; ecx = [left]*65536 + [right] |
2898 | ; ecx = [left]*65536 + [right] |
2900 | ; edx = [top]*65536 + [bottom] |
2899 | ; edx = [top]*65536 + [bottom] |
2901 | mov eax, [_display.width] |
2900 | mov eax, [_display.width] |
2902 | mov ebx, [_display.height] |
2901 | mov ebx, [_display.height] |
2903 | ; check [right] |
2902 | ; check [right] |
2904 | cmp cx, ax |
2903 | cmp cx, ax |
2905 | jae .exit |
2904 | jae .exit |
2906 | ; check [left] |
2905 | ; check [left] |
2907 | ror ecx, 16 |
2906 | ror ecx, 16 |
2908 | cmp cx, ax |
2907 | cmp cx, ax |
2909 | jae .exit |
2908 | jae .exit |
2910 | ; check [bottom] |
2909 | ; check [bottom] |
2911 | cmp dx, bx |
2910 | cmp dx, bx |
2912 | jae .exit |
2911 | jae .exit |
2913 | ; check [top] |
2912 | ; check [top] |
2914 | ror edx, 16 |
2913 | ror edx, 16 |
2915 | cmp dx, bx |
2914 | cmp dx, bx |
2916 | jae .exit |
2915 | jae .exit |
2917 | 2916 | ||
2918 | movzx eax, cx ; [left] |
2917 | movzx eax, cx ; [left] |
2919 | movzx ebx, dx ; [top] |
2918 | movzx ebx, dx ; [top] |
2920 | 2919 | ||
2921 | shr ecx, 16 ; [right] |
2920 | shr ecx, 16 ; [right] |
2922 | shr edx, 16 ; [bottom] |
2921 | shr edx, 16 ; [bottom] |
2923 | 2922 | ||
2924 | mov [background_defined], 1 |
2923 | mov [background_defined], 1 |
2925 | 2924 | ||
2926 | mov [draw_data+32 + RECT.left], eax |
2925 | mov [draw_data+32 + RECT.left], eax |
2927 | mov [draw_data+32 + RECT.top], ebx |
2926 | mov [draw_data+32 + RECT.top], ebx |
2928 | 2927 | ||
2929 | mov [draw_data+32 + RECT.right], ecx |
2928 | mov [draw_data+32 + RECT.right], ecx |
2930 | mov [draw_data+32 + RECT.bottom], edx |
2929 | mov [draw_data+32 + RECT.bottom], edx |
2931 | 2930 | ||
2932 | inc [REDRAW_BACKGROUND] |
2931 | inc [REDRAW_BACKGROUND] |
2933 | call wakeup_osloop |
2932 | call wakeup_osloop |
2934 | ;-------------------------------------- |
2933 | ;-------------------------------------- |
2935 | align 4 |
2934 | align 4 |
2936 | .exit: |
2935 | .exit: |
2937 | ret |
2936 | ret |
2938 | ;------------------------------------------------------------------------------ |
2937 | ;------------------------------------------------------------------------------ |
2939 | align 4 |
2938 | align 4 |
2940 | nosb9: |
2939 | nosb9: |
2941 | ret |
2940 | ret |
2942 | ;------------------------------------------------------------------------------ |
2941 | ;------------------------------------------------------------------------------ |
2943 | align 4 |
2942 | align 4 |
2944 | uglobal |
2943 | uglobal |
2945 | BG_Rect_X_left_right dd 0x0 |
2944 | BG_Rect_X_left_right dd 0x0 |
2946 | BG_Rect_Y_top_bottom dd 0x0 |
2945 | BG_Rect_Y_top_bottom dd 0x0 |
2947 | endg |
2946 | endg |
2948 | ;------------------------------------------------------------------------------ |
2947 | ;------------------------------------------------------------------------------ |
2949 | align 4 |
2948 | align 4 |
2950 | force_redraw_background: |
2949 | force_redraw_background: |
2951 | and [draw_data+32 + RECT.left], 0 |
2950 | and [draw_data+32 + RECT.left], 0 |
2952 | and [draw_data+32 + RECT.top], 0 |
2951 | and [draw_data+32 + RECT.top], 0 |
2953 | push eax ebx |
2952 | push eax ebx |
2954 | mov eax, [_display.width] |
2953 | mov eax, [_display.width] |
2955 | mov ebx, [_display.height] |
2954 | mov ebx, [_display.height] |
2956 | dec eax |
2955 | dec eax |
2957 | dec ebx |
2956 | dec ebx |
2958 | mov [draw_data+32 + RECT.right], eax |
2957 | mov [draw_data+32 + RECT.right], eax |
2959 | mov [draw_data+32 + RECT.bottom], ebx |
2958 | mov [draw_data+32 + RECT.bottom], ebx |
2960 | pop ebx eax |
2959 | pop ebx eax |
2961 | inc [REDRAW_BACKGROUND] |
2960 | inc [REDRAW_BACKGROUND] |
2962 | call wakeup_osloop |
2961 | call wakeup_osloop |
2963 | ret |
2962 | ret |
2964 | ;------------------------------------------------------------------------------ |
2963 | ;------------------------------------------------------------------------------ |
2965 | align 4 |
2964 | align 4 |
2966 | sys_getbackground: |
2965 | sys_getbackground: |
2967 | ; cmp eax,1 ; SIZE |
2966 | ; cmp eax,1 ; SIZE |
2968 | dec ebx |
2967 | dec ebx |
2969 | jnz nogb1 |
2968 | jnz nogb1 |
2970 | mov eax, [BgrDataWidth] |
2969 | mov eax, [BgrDataWidth] |
2971 | shl eax, 16 |
2970 | shl eax, 16 |
2972 | mov ax, word [BgrDataHeight] |
2971 | mov ax, word [BgrDataHeight] |
2973 | mov [esp+32], eax |
2972 | mov [esp+32], eax |
2974 | ret |
2973 | ret |
2975 | ;------------------------------------------------------------------------------ |
2974 | ;------------------------------------------------------------------------------ |
2976 | align 4 |
2975 | align 4 |
2977 | nogb1: |
2976 | nogb1: |
2978 | ; cmp eax,2 ; PIXEL |
2977 | ; cmp eax,2 ; PIXEL |
2979 | dec ebx |
2978 | dec ebx |
2980 | jnz nogb2 |
2979 | jnz nogb2 |
2981 | 2980 | ||
2982 | mov eax, [img_background] |
2981 | mov eax, [img_background] |
2983 | test ecx, ecx |
2982 | test ecx, ecx |
2984 | jz @f |
2983 | jz @f |
2985 | cmp eax, static_background_data |
2984 | cmp eax, static_background_data |
2986 | jz .ret |
2985 | jz .ret |
2987 | ;-------------------------------------- |
2986 | ;-------------------------------------- |
2988 | align 4 |
2987 | align 4 |
2989 | @@: |
2988 | @@: |
2990 | mov ebx, [mem_BACKGROUND] |
2989 | mov ebx, [mem_BACKGROUND] |
2991 | add ebx, 4095 |
2990 | add ebx, 4095 |
2992 | and ebx, -4096 |
2991 | and ebx, -4096 |
2993 | sub ebx, 4 |
2992 | sub ebx, 4 |
2994 | cmp ecx, ebx |
2993 | cmp ecx, ebx |
2995 | ja .ret |
2994 | ja .ret |
2996 | 2995 | ||
2997 | mov eax, [ecx+eax] |
2996 | mov eax, [ecx+eax] |
2998 | 2997 | ||
2999 | and eax, 0xFFFFFF |
2998 | and eax, 0xFFFFFF |
3000 | mov [esp+32], eax |
2999 | mov [esp+32], eax |
3001 | ;-------------------------------------- |
3000 | ;-------------------------------------- |
3002 | align 4 |
3001 | align 4 |
3003 | .ret: |
3002 | .ret: |
3004 | ret |
3003 | ret |
3005 | ;------------------------------------------------------------------------------ |
3004 | ;------------------------------------------------------------------------------ |
3006 | align 4 |
3005 | align 4 |
3007 | nogb2: |
3006 | nogb2: |
3008 | 3007 | ||
3009 | ; cmp eax,4 ; TILED / STRETCHED |
3008 | ; cmp eax,4 ; TILED / STRETCHED |
3010 | dec ebx |
3009 | dec ebx |
3011 | dec ebx |
3010 | dec ebx |
3012 | jnz nogb4 |
3011 | jnz nogb4 |
3013 | mov eax, [BgrDrawMode] |
3012 | mov eax, [BgrDrawMode] |
3014 | ;-------------------------------------- |
3013 | ;-------------------------------------- |
3015 | align 4 |
3014 | align 4 |
3016 | nogb4: |
3015 | nogb4: |
3017 | mov [esp+32], eax |
3016 | mov [esp+32], eax |
3018 | ret |
3017 | ret |
3019 | ;------------------------------------------------------------------------------ |
3018 | ;------------------------------------------------------------------------------ |
3020 | align 4 |
3019 | align 4 |
3021 | sys_getkey: |
3020 | sys_getkey: |
3022 | mov [esp + 32], dword 1 |
3021 | mov [esp + 32], dword 1 |
3023 | ; test main buffer |
3022 | ; test main buffer |
3024 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3023 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3025 | movzx ecx, word [WIN_STACK + ebx * 2] |
3024 | movzx ecx, word [WIN_STACK + ebx * 2] |
3026 | mov edx, [TASK_COUNT] |
3025 | mov edx, [TASK_COUNT] |
3027 | cmp ecx, edx |
3026 | cmp ecx, edx |
3028 | jne .finish |
3027 | jne .finish |
3029 | cmp [KEY_COUNT], byte 0 |
3028 | cmp [KEY_COUNT], byte 0 |
3030 | je .finish |
3029 | je .finish |
3031 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3030 | movzx ax, byte [KEY_BUFF + 120 + 2] |
3032 | shl eax, 8 |
3031 | shl eax, 8 |
3033 | mov al, byte [KEY_BUFF] |
3032 | mov al, byte [KEY_BUFF] |
3034 | shl eax, 8 |
3033 | shl eax, 8 |
3035 | push eax |
3034 | push eax |
3036 | dec byte [KEY_COUNT] |
3035 | dec byte [KEY_COUNT] |
3037 | and byte [KEY_COUNT], 127 |
3036 | and byte [KEY_COUNT], 127 |
3038 | movzx ecx, byte [KEY_COUNT] |
3037 | movzx ecx, byte [KEY_COUNT] |
3039 | add ecx, 2 |
3038 | add ecx, 2 |
3040 | mov eax, KEY_BUFF + 1 |
3039 | mov eax, KEY_BUFF + 1 |
3041 | mov ebx, KEY_BUFF |
3040 | mov ebx, KEY_BUFF |
3042 | call memmove |
3041 | call memmove |
3043 | add eax, 120 + 2 |
3042 | add eax, 120 + 2 |
3044 | add ebx, 120 + 2 |
3043 | add ebx, 120 + 2 |
3045 | call memmove |
3044 | call memmove |
3046 | pop eax |
3045 | pop eax |
3047 | ;-------------------------------------- |
3046 | ;-------------------------------------- |
3048 | align 4 |
3047 | align 4 |
3049 | .ret_eax: |
3048 | .ret_eax: |
3050 | mov [esp + 32], eax |
3049 | mov [esp + 32], eax |
3051 | ret |
3050 | ret |
3052 | ;-------------------------------------- |
3051 | ;-------------------------------------- |
3053 | align 4 |
3052 | align 4 |
3054 | .finish: |
3053 | .finish: |
3055 | ; test hotkeys buffer |
3054 | ; test hotkeys buffer |
3056 | mov ecx, hotkey_buffer |
3055 | mov ecx, hotkey_buffer |
3057 | ;-------------------------------------- |
3056 | ;-------------------------------------- |
3058 | align 4 |
3057 | align 4 |
3059 | @@: |
3058 | @@: |
3060 | cmp [ecx], ebx |
3059 | cmp [ecx], ebx |
3061 | jz .found |
3060 | jz .found |
3062 | add ecx, 8 |
3061 | add ecx, 8 |
3063 | cmp ecx, hotkey_buffer + 120 * 8 |
3062 | cmp ecx, hotkey_buffer + 120 * 8 |
3064 | jb @b |
3063 | jb @b |
3065 | ret |
3064 | ret |
3066 | ;-------------------------------------- |
3065 | ;-------------------------------------- |
3067 | align 4 |
3066 | align 4 |
3068 | .found: |
3067 | .found: |
3069 | mov ax, [ecx + 6] |
3068 | mov ax, [ecx + 6] |
3070 | shl eax, 16 |
3069 | shl eax, 16 |
3071 | mov ah, [ecx + 4] |
3070 | mov ah, [ecx + 4] |
3072 | mov al, 2 |
3071 | mov al, 2 |
3073 | and dword [ecx + 4], 0 |
3072 | and dword [ecx + 4], 0 |
3074 | and dword [ecx], 0 |
3073 | and dword [ecx], 0 |
3075 | jmp .ret_eax |
3074 | jmp .ret_eax |
3076 | ;------------------------------------------------------------------------------ |
3075 | ;------------------------------------------------------------------------------ |
3077 | align 4 |
3076 | align 4 |
3078 | sys_getbutton: |
3077 | sys_getbutton: |
3079 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3078 | mov ebx, [CURRENT_TASK] ; TOP OF WINDOW STACK |
3080 | mov [esp + 32], dword 1 |
3079 | mov [esp + 32], dword 1 |
3081 | movzx ecx, word [WIN_STACK + ebx * 2] |
3080 | movzx ecx, word [WIN_STACK + ebx * 2] |
3082 | mov edx, [TASK_COUNT] ; less than 256 processes |
3081 | mov edx, [TASK_COUNT] ; less than 256 processes |
3083 | cmp ecx, edx |
3082 | cmp ecx, edx |
3084 | jne .exit |
3083 | jne .exit |
3085 | movzx eax, byte [BTN_COUNT] |
3084 | movzx eax, byte [BTN_COUNT] |
3086 | test eax, eax |
3085 | test eax, eax |
3087 | jz .exit |
3086 | jz .exit |
3088 | mov eax, [BTN_BUFF] |
3087 | mov eax, [BTN_BUFF] |
3089 | and al, 0xFE ; delete left button bit |
3088 | and al, 0xFE ; delete left button bit |
3090 | mov [BTN_COUNT], byte 0 |
3089 | mov [BTN_COUNT], byte 0 |
3091 | mov [esp + 32], eax |
3090 | mov [esp + 32], eax |
3092 | ;-------------------------------------- |
3091 | ;-------------------------------------- |
3093 | align 4 |
3092 | align 4 |
3094 | .exit: |
3093 | .exit: |
3095 | ret |
3094 | ret |
3096 | ;------------------------------------------------------------------------------ |
3095 | ;------------------------------------------------------------------------------ |
3097 | align 4 |
3096 | align 4 |
3098 | sys_cpuusage: |
3097 | sys_cpuusage: |
3099 | 3098 | ||
3100 | ; RETURN: |
3099 | ; RETURN: |
3101 | ; |
3100 | ; |
3102 | ; +00 dword process cpu usage |
3101 | ; +00 dword process cpu usage |
3103 | ; +04 word position in windowing stack |
3102 | ; +04 word position in windowing stack |
3104 | ; +06 word windowing stack value at current position (cpu nro) |
3103 | ; +06 word windowing stack value at current position (cpu nro) |
3105 | ; +10 12 bytes name |
3104 | ; +10 12 bytes name |
3106 | ; +22 dword start in mem |
3105 | ; +22 dword start in mem |
3107 | ; +26 dword used mem |
3106 | ; +26 dword used mem |
3108 | ; +30 dword PID , process idenfification number |
3107 | ; +30 dword PID , process idenfification number |
3109 | ; |
3108 | ; |
3110 | 3109 | ||
3111 | cmp ecx, -1 ; who am I ? |
3110 | cmp ecx, -1 ; who am I ? |
3112 | jne .no_who_am_i |
3111 | jne .no_who_am_i |
3113 | mov ecx, [CURRENT_TASK] |
3112 | mov ecx, [CURRENT_TASK] |
3114 | .no_who_am_i: |
3113 | .no_who_am_i: |
3115 | cmp ecx, max_processes |
3114 | cmp ecx, max_processes |
3116 | ja .nofillbuf |
3115 | ja .nofillbuf |
3117 | 3116 | ||
3118 | ; +4: word: position of the window of thread in the window stack |
3117 | ; +4: word: position of the window of thread in the window stack |
3119 | mov ax, [WIN_STACK + ecx * 2] |
3118 | mov ax, [WIN_STACK + ecx * 2] |
3120 | mov [ebx+4], ax |
3119 | mov [ebx+4], ax |
3121 | ; +6: word: number of the thread slot, which window has in the window stack |
3120 | ; +6: word: number of the thread slot, which window has in the window stack |
3122 | ; position ecx (has no relation to the specific thread) |
3121 | ; position ecx (has no relation to the specific thread) |
3123 | mov ax, [WIN_POS + ecx * 2] |
3122 | mov ax, [WIN_POS + ecx * 2] |
3124 | mov [ebx+6], ax |
3123 | mov [ebx+6], ax |
3125 | 3124 | ||
3126 | shl ecx, 5 |
3125 | shl ecx, 5 |
3127 | 3126 | ||
3128 | ; +0: dword: memory usage |
3127 | ; +0: dword: memory usage |
3129 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3128 | mov eax, [ecx+CURRENT_TASK+TASKDATA.cpu_usage] |
3130 | mov [ebx], eax |
3129 | mov [ebx], eax |
3131 | ; +10: 11 bytes: name of the process |
3130 | ; +10: 11 bytes: name of the process |
3132 | push ecx |
3131 | push ecx |
3133 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3132 | lea eax, [ecx*8+SLOT_BASE+APPDATA.app_name] |
3134 | add ebx, 10 |
3133 | add ebx, 10 |
3135 | mov ecx, 11 |
3134 | mov ecx, 11 |
3136 | call memmove |
3135 | call memmove |
3137 | pop ecx |
3136 | pop ecx |
3138 | 3137 | ||
3139 | ; +22: address of the process in memory |
3138 | ; +22: address of the process in memory |
3140 | ; +26: size of used memory - 1 |
3139 | ; +26: size of used memory - 1 |
3141 | push edi |
3140 | push edi |
3142 | lea edi, [ebx+12] |
3141 | lea edi, [ebx+12] |
3143 | xor eax, eax |
3142 | xor eax, eax |
3144 | mov edx, 0x100000*16 |
3143 | mov edx, 0x100000*16 |
3145 | cmp ecx, 1 shl 5 |
3144 | cmp ecx, 1 shl 5 |
3146 | je .os_mem |
3145 | je .os_mem |
3147 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3146 | mov edx, [SLOT_BASE+ecx*8+APPDATA.process] |
3148 | mov edx, [edx+PROC.mem_used] |
3147 | mov edx, [edx+PROC.mem_used] |
3149 | mov eax, std_application_base_address |
3148 | mov eax, std_application_base_address |
3150 | .os_mem: |
3149 | .os_mem: |
3151 | stosd |
3150 | stosd |
3152 | lea eax, [edx-1] |
3151 | lea eax, [edx-1] |
3153 | stosd |
3152 | stosd |
3154 | 3153 | ||
3155 | ; +30: PID/TID |
3154 | ; +30: PID/TID |
3156 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3155 | mov eax, [ecx+CURRENT_TASK+TASKDATA.pid] |
3157 | stosd |
3156 | stosd |
3158 | 3157 | ||
3159 | ; window position and size |
3158 | ; window position and size |
3160 | push esi |
3159 | push esi |
3161 | lea esi, [ecx + window_data + WDATA.box] |
3160 | lea esi, [ecx + window_data + WDATA.box] |
3162 | movsd |
3161 | movsd |
3163 | movsd |
3162 | movsd |
3164 | movsd |
3163 | movsd |
3165 | movsd |
3164 | movsd |
3166 | 3165 | ||
3167 | ; Process state (+50) |
3166 | ; Process state (+50) |
3168 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3167 | mov eax, dword [ecx+CURRENT_TASK+TASKDATA.state] |
3169 | stosd |
3168 | stosd |
3170 | 3169 | ||
3171 | ; Window client area box |
3170 | ; Window client area box |
3172 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3171 | lea esi, [ecx*8 + SLOT_BASE + APPDATA.wnd_clientbox] |
3173 | movsd |
3172 | movsd |
3174 | movsd |
3173 | movsd |
3175 | movsd |
3174 | movsd |
3176 | movsd |
3175 | movsd |
3177 | 3176 | ||
3178 | ; Window state |
3177 | ; Window state |
3179 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3178 | mov al, [ecx+window_data+WDATA.fl_wstate] |
3180 | stosb |
3179 | stosb |
3181 | 3180 | ||
3182 | ; Event mask (+71) |
3181 | ; Event mask (+71) |
3183 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3182 | mov EAX, dword [ECX+CURRENT_TASK+TASKDATA.event_mask] |
3184 | stosd |
3183 | stosd |
3185 | 3184 | ||
3186 | ; Keyboard mode (+75) |
3185 | ; Keyboard mode (+75) |
3187 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3186 | mov al, byte [ecx*8 + SLOT_BASE + APPDATA.keyboard_mode] |
3188 | stosb |
3187 | stosb |
3189 | 3188 | ||
3190 | pop esi |
3189 | pop esi |
3191 | pop edi |
3190 | pop edi |
3192 | 3191 | ||
3193 | .nofillbuf: |
3192 | .nofillbuf: |
3194 | ; return number of processes |
3193 | ; return number of processes |
3195 | 3194 | ||
3196 | mov eax, [TASK_COUNT] |
3195 | mov eax, [TASK_COUNT] |
3197 | mov [esp+32], eax |
3196 | mov [esp+32], eax |
3198 | ret |
3197 | ret |
3199 | 3198 | ||
3200 | align 4 |
3199 | align 4 |
3201 | sys_clock: |
3200 | sys_clock: |
3202 | cli |
3201 | cli |
3203 | ; Mikhail Lisovin xx Jan 2005 |
3202 | ; Mikhail Lisovin xx Jan 2005 |
3204 | @@: |
3203 | @@: |
3205 | mov al, 10 |
3204 | mov al, 10 |
3206 | out 0x70, al |
3205 | out 0x70, al |
3207 | in al, 0x71 |
3206 | in al, 0x71 |
3208 | test al, al |
3207 | test al, al |
3209 | jns @f |
3208 | jns @f |
3210 | mov esi, 1 |
3209 | mov esi, 1 |
3211 | call delay_ms |
3210 | call delay_ms |
3212 | jmp @b |
3211 | jmp @b |
3213 | @@: |
3212 | @@: |
3214 | ; end Lisovin's fix |
3213 | ; end Lisovin's fix |
3215 | 3214 | ||
3216 | xor al, al ; seconds |
3215 | xor al, al ; seconds |
3217 | out 0x70, al |
3216 | out 0x70, al |
3218 | in al, 0x71 |
3217 | in al, 0x71 |
3219 | movzx ecx, al |
3218 | movzx ecx, al |
3220 | mov al, 02 ; minutes |
3219 | mov al, 02 ; minutes |
3221 | shl ecx, 16 |
3220 | shl ecx, 16 |
3222 | out 0x70, al |
3221 | out 0x70, al |
3223 | in al, 0x71 |
3222 | in al, 0x71 |
3224 | movzx edx, al |
3223 | movzx edx, al |
3225 | mov al, 04 ; hours |
3224 | mov al, 04 ; hours |
3226 | shl edx, 8 |
3225 | shl edx, 8 |
3227 | out 0x70, al |
3226 | out 0x70, al |
3228 | in al, 0x71 |
3227 | in al, 0x71 |
3229 | add ecx, edx |
3228 | add ecx, edx |
3230 | movzx edx, al |
3229 | movzx edx, al |
3231 | add ecx, edx |
3230 | add ecx, edx |
3232 | sti |
3231 | sti |
3233 | mov [esp + 32], ecx |
3232 | mov [esp + 32], ecx |
3234 | ret |
3233 | ret |
3235 | 3234 | ||
3236 | 3235 | ||
3237 | align 4 |
3236 | align 4 |
3238 | 3237 | ||
3239 | sys_date: |
3238 | sys_date: |
3240 | 3239 | ||
3241 | cli |
3240 | cli |
3242 | @@: |
3241 | @@: |
3243 | mov al, 10 |
3242 | mov al, 10 |
3244 | out 0x70, al |
3243 | out 0x70, al |
3245 | in al, 0x71 |
3244 | in al, 0x71 |
3246 | test al, al |
3245 | test al, al |
3247 | jns @f |
3246 | jns @f |
3248 | mov esi, 1 |
3247 | mov esi, 1 |
3249 | call delay_ms |
3248 | call delay_ms |
3250 | jmp @b |
3249 | jmp @b |
3251 | @@: |
3250 | @@: |
3252 | 3251 | ||
3253 | mov ch, 0 |
3252 | mov ch, 0 |
3254 | mov al, 7 ; date |
3253 | mov al, 7 ; date |
3255 | out 0x70, al |
3254 | out 0x70, al |
3256 | in al, 0x71 |
3255 | in al, 0x71 |
3257 | mov cl, al |
3256 | mov cl, al |
3258 | mov al, 8 ; month |
3257 | mov al, 8 ; month |
3259 | shl ecx, 16 |
3258 | shl ecx, 16 |
3260 | out 0x70, al |
3259 | out 0x70, al |
3261 | in al, 0x71 |
3260 | in al, 0x71 |
3262 | mov ch, al |
3261 | mov ch, al |
3263 | mov al, 9 ; year |
3262 | mov al, 9 ; year |
3264 | out 0x70, al |
3263 | out 0x70, al |
3265 | in al, 0x71 |
3264 | in al, 0x71 |
3266 | mov cl, al |
3265 | mov cl, al |
3267 | sti |
3266 | sti |
3268 | mov [esp+32], ecx |
3267 | mov [esp+32], ecx |
3269 | ret |
3268 | ret |
3270 | 3269 | ||
3271 | 3270 | ||
3272 | ; redraw status |
3271 | ; redraw status |
3273 | 3272 | ||
3274 | sys_redrawstat: |
3273 | sys_redrawstat: |
3275 | cmp ebx, 1 |
3274 | cmp ebx, 1 |
3276 | jne no_widgets_away |
3275 | jne no_widgets_away |
3277 | ; buttons away |
3276 | ; buttons away |
3278 | mov ecx, [CURRENT_TASK] |
3277 | mov ecx, [CURRENT_TASK] |
3279 | sys_newba2: |
3278 | sys_newba2: |
3280 | mov edi, [BTN_ADDR] |
3279 | mov edi, [BTN_ADDR] |
3281 | cmp [edi], dword 0 ; empty button list ? |
3280 | cmp [edi], dword 0 ; empty button list ? |
3282 | je end_of_buttons_away |
3281 | je end_of_buttons_away |
3283 | movzx ebx, word [edi] |
3282 | movzx ebx, word [edi] |
3284 | inc ebx |
3283 | inc ebx |
3285 | mov eax, edi |
3284 | mov eax, edi |
3286 | sys_newba: |
3285 | sys_newba: |
3287 | dec ebx |
3286 | dec ebx |
3288 | jz end_of_buttons_away |
3287 | jz end_of_buttons_away |
3289 | 3288 | ||
3290 | add eax, 0x10 |
3289 | add eax, 0x10 |
3291 | cmp cx, [eax] |
3290 | cmp cx, [eax] |
3292 | jnz sys_newba |
3291 | jnz sys_newba |
3293 | 3292 | ||
3294 | push eax ebx ecx |
3293 | push eax ebx ecx |
3295 | mov ecx, ebx |
3294 | mov ecx, ebx |
3296 | inc ecx |
3295 | inc ecx |
3297 | shl ecx, 4 |
3296 | shl ecx, 4 |
3298 | mov ebx, eax |
3297 | mov ebx, eax |
3299 | add eax, 0x10 |
3298 | add eax, 0x10 |
3300 | call memmove |
3299 | call memmove |
3301 | dec dword [edi] |
3300 | dec dword [edi] |
3302 | pop ecx ebx eax |
3301 | pop ecx ebx eax |
3303 | 3302 | ||
3304 | jmp sys_newba2 |
3303 | jmp sys_newba2 |
3305 | 3304 | ||
3306 | end_of_buttons_away: |
3305 | end_of_buttons_away: |
3307 | 3306 | ||
3308 | ret |
3307 | ret |
3309 | 3308 | ||
3310 | no_widgets_away: |
3309 | no_widgets_away: |
3311 | 3310 | ||
3312 | cmp ebx, 2 |
3311 | cmp ebx, 2 |
3313 | jnz srl1 |
3312 | jnz srl1 |
3314 | 3313 | ||
3315 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3314 | mov edx, [TASK_BASE] ; return whole screen draw area for this app |
3316 | add edx, draw_data - CURRENT_TASK |
3315 | add edx, draw_data - CURRENT_TASK |
3317 | mov [edx + RECT.left], 0 |
3316 | mov [edx + RECT.left], 0 |
3318 | mov [edx + RECT.top], 0 |
3317 | mov [edx + RECT.top], 0 |
3319 | mov eax, [_display.width] |
3318 | mov eax, [_display.width] |
3320 | dec eax |
3319 | dec eax |
3321 | mov [edx + RECT.right], eax |
3320 | mov [edx + RECT.right], eax |
3322 | mov eax, [_display.height] |
3321 | mov eax, [_display.height] |
3323 | dec eax |
3322 | dec eax |
3324 | mov [edx + RECT.bottom], eax |
3323 | mov [edx + RECT.bottom], eax |
3325 | 3324 | ||
3326 | srl1: |
3325 | srl1: |
3327 | ret |
3326 | ret |
3328 | 3327 | ||
3329 | ;ok - 100% work |
3328 | ;ok - 100% work |
3330 | ;nt - not tested |
3329 | ;nt - not tested |
3331 | ;--------------------------------------------------------------------------------------------- |
3330 | ;--------------------------------------------------------------------------------------------- |
3332 | ;eax |
3331 | ;eax |
3333 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3332 | ;0 - task switch counter. Ret switch counter in eax. Block. ok. |
3334 | ;1 - change task. Ret nothing. Block. ok. |
3333 | ;1 - change task. Ret nothing. Block. ok. |
3335 | ;2 - performance control |
3334 | ;2 - performance control |
3336 | ; ebx |
3335 | ; ebx |
3337 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3336 | ; 0 - enable or disable (inversion) PCE flag on CR4 for rdmpc in user mode. |
3338 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3337 | ; returned new cr4 in eax. Ret cr4 in eax. Block. ok. |
3339 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3338 | ; 1 - is cache enabled. Ret cr0 in eax if enabled else zero in eax. Block. ok. |
3340 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3339 | ; 2 - enable cache. Ret 1 in eax. Ret nothing. Block. ok. |
3341 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3340 | ; 3 - disable cache. Ret 0 in eax. Ret nothing. Block. ok. |
3342 | ;eax |
3341 | ;eax |
3343 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3342 | ;3 - rdmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3344 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3343 | ;4 - wrmsr. Counter in edx. (edx:eax) [esi:edi, edx] => [edx:esi, ecx]. Ret in ebx:eax. Block. ok. |
3345 | ;--------------------------------------------------------------------------------------------- |
3344 | ;--------------------------------------------------------------------------------------------- |
3346 | iglobal |
3345 | iglobal |
3347 | align 4 |
3346 | align 4 |
3348 | sheduler: |
3347 | sheduler: |
3349 | dd sys_sheduler.00 |
3348 | dd sys_sheduler.00 |
3350 | dd change_task |
3349 | dd change_task |
3351 | dd sys_sheduler.02 |
3350 | dd sys_sheduler.02 |
3352 | dd sys_sheduler.03 |
3351 | dd sys_sheduler.03 |
3353 | dd sys_sheduler.04 |
3352 | dd sys_sheduler.04 |
3354 | endg |
3353 | endg |
3355 | sys_sheduler: |
3354 | sys_sheduler: |
3356 | ;rewritten by |
3355 | ;rewritten by |
3357 | jmp dword [sheduler+ebx*4] |
3356 | jmp dword [sheduler+ebx*4] |
3358 | ;.shed_counter: |
3357 | ;.shed_counter: |
3359 | .00: |
3358 | .00: |
3360 | mov eax, [context_counter] |
3359 | mov eax, [context_counter] |
3361 | mov [esp+32], eax |
3360 | mov [esp+32], eax |
3362 | ret |
3361 | ret |
3363 | 3362 | ||
3364 | .02: |
3363 | .02: |
3365 | ;.perf_control: |
3364 | ;.perf_control: |
3366 | inc ebx ;before ebx=2, ebx=3 |
3365 | inc ebx ;before ebx=2, ebx=3 |
3367 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3366 | cmp ebx, ecx ;if ecx=3, ebx=3 |
3368 | jz cache_disable |
3367 | jz cache_disable |
3369 | 3368 | ||
3370 | dec ebx ;ebx=2 |
3369 | dec ebx ;ebx=2 |
3371 | cmp ebx, ecx ; |
3370 | cmp ebx, ecx ; |
3372 | jz cache_enable ;if ecx=2 and ebx=2 |
3371 | jz cache_enable ;if ecx=2 and ebx=2 |
3373 | 3372 | ||
3374 | dec ebx ;ebx=1 |
3373 | dec ebx ;ebx=1 |
3375 | cmp ebx, ecx |
3374 | cmp ebx, ecx |
3376 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3375 | jz is_cache_enabled ;if ecx=1 and ebx=1 |
3377 | 3376 | ||
3378 | dec ebx |
3377 | dec ebx |
3379 | test ebx, ecx ;ebx=0 and ecx=0 |
3378 | test ebx, ecx ;ebx=0 and ecx=0 |
3380 | jz modify_pce ;if ecx=0 |
3379 | jz modify_pce ;if ecx=0 |
3381 | 3380 | ||
3382 | ret |
3381 | ret |
3383 | 3382 | ||
3384 | .03: |
3383 | .03: |
3385 | ;.rdmsr_instr: |
3384 | ;.rdmsr_instr: |
3386 | ;now counter in ecx |
3385 | ;now counter in ecx |
3387 | ;(edx:eax) esi:edi => edx:esi |
3386 | ;(edx:eax) esi:edi => edx:esi |
3388 | mov eax, esi |
3387 | mov eax, esi |
3389 | mov ecx, edx |
3388 | mov ecx, edx |
3390 | rdmsr |
3389 | rdmsr |
3391 | mov [esp+32], eax |
3390 | mov [esp+32], eax |
3392 | mov [esp+20], edx ;ret in ebx? |
3391 | mov [esp+20], edx ;ret in ebx? |
3393 | ret |
3392 | ret |
3394 | 3393 | ||
3395 | .04: |
3394 | .04: |
3396 | ;.wrmsr_instr: |
3395 | ;.wrmsr_instr: |
3397 | ;now counter in ecx |
3396 | ;now counter in ecx |
3398 | ;(edx:eax) esi:edi => edx:esi |
3397 | ;(edx:eax) esi:edi => edx:esi |
3399 | ; Fast Call MSR can't be destroy |
3398 | ; Fast Call MSR can't be destroy |
3400 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3399 | ; Но MSR_AMD_EFER можно изменять, т.к. в этом регистре лиш |
3401 | ; включаются/выключаются расширенные возможности |
3400 | ; включаются/выключаются расширенные возможности |
3402 | cmp edx, MSR_SYSENTER_CS |
3401 | cmp edx, MSR_SYSENTER_CS |
3403 | je @f |
3402 | je @f |
3404 | cmp edx, MSR_SYSENTER_ESP |
3403 | cmp edx, MSR_SYSENTER_ESP |
3405 | je @f |
3404 | je @f |
3406 | cmp edx, MSR_SYSENTER_EIP |
3405 | cmp edx, MSR_SYSENTER_EIP |
3407 | je @f |
3406 | je @f |
3408 | cmp edx, MSR_AMD_STAR |
3407 | cmp edx, MSR_AMD_STAR |
3409 | je @f |
3408 | je @f |
3410 | 3409 | ||
3411 | mov eax, esi |
3410 | mov eax, esi |
3412 | mov ecx, edx |
3411 | mov ecx, edx |
3413 | wrmsr |
3412 | wrmsr |
3414 | ; mov [esp + 32], eax |
3413 | ; mov [esp + 32], eax |
3415 | ; mov [esp + 20], edx ;ret in ebx? |
3414 | ; mov [esp + 20], edx ;ret in ebx? |
3416 | @@: |
3415 | @@: |
3417 | ret |
3416 | ret |
3418 | 3417 | ||
3419 | cache_disable: |
3418 | cache_disable: |
3420 | mov eax, cr0 |
3419 | mov eax, cr0 |
3421 | or eax, 01100000000000000000000000000000b |
3420 | or eax, 01100000000000000000000000000000b |
3422 | mov cr0, eax |
3421 | mov cr0, eax |
3423 | wbinvd ;set MESI |
3422 | wbinvd ;set MESI |
3424 | ret |
3423 | ret |
3425 | 3424 | ||
3426 | cache_enable: |
3425 | cache_enable: |
3427 | mov eax, cr0 |
3426 | mov eax, cr0 |
3428 | and eax, 10011111111111111111111111111111b |
3427 | and eax, 10011111111111111111111111111111b |
3429 | mov cr0, eax |
3428 | mov cr0, eax |
3430 | ret |
3429 | ret |
3431 | 3430 | ||
3432 | is_cache_enabled: |
3431 | is_cache_enabled: |
3433 | mov eax, cr0 |
3432 | mov eax, cr0 |
3434 | mov ebx, eax |
3433 | mov ebx, eax |
3435 | and eax, 01100000000000000000000000000000b |
3434 | and eax, 01100000000000000000000000000000b |
3436 | jz cache_disabled |
3435 | jz cache_disabled |
3437 | mov [esp+32], ebx |
3436 | mov [esp+32], ebx |
3438 | cache_disabled: |
3437 | cache_disabled: |
3439 | mov dword [esp+32], eax;0 |
3438 | mov dword [esp+32], eax;0 |
3440 | ret |
3439 | ret |
3441 | 3440 | ||
3442 | modify_pce: |
3441 | modify_pce: |
3443 | mov eax, cr4 |
3442 | mov eax, cr4 |
3444 | ; mov ebx,0 |
3443 | ; mov ebx,0 |
3445 | ; or bx,100000000b ;pce |
3444 | ; or bx,100000000b ;pce |
3446 | ; xor eax,ebx ;invert pce |
3445 | ; xor eax,ebx ;invert pce |
3447 | bts eax, 8;pce=cr4[8] |
3446 | bts eax, 8;pce=cr4[8] |
3448 | mov cr4, eax |
3447 | mov cr4, eax |
3449 | mov [esp+32], eax |
3448 | mov [esp+32], eax |
3450 | ret |
3449 | ret |
3451 | ;--------------------------------------------------------------------------------------------- |
3450 | ;--------------------------------------------------------------------------------------------- |
3452 | 3451 | ||
3453 | 3452 | ||
3454 | iglobal |
3453 | iglobal |
3455 | cpustring db 'CPU',0 |
3454 | cpustring db 'CPU',0 |
3456 | endg |
3455 | endg |
3457 | 3456 | ||
3458 | uglobal |
3457 | uglobal |
3459 | background_defined db 0 ; diamond, 11.04.2006 |
3458 | background_defined db 0 ; diamond, 11.04.2006 |
3460 | endg |
3459 | endg |
3461 | ;----------------------------------------------------------------------------- |
3460 | ;----------------------------------------------------------------------------- |
3462 | align 4 |
3461 | align 4 |
3463 | checkmisc: |
3462 | checkmisc: |
3464 | cmp [ctrl_alt_del], 1 |
3463 | cmp [ctrl_alt_del], 1 |
3465 | jne nocpustart |
3464 | jne nocpustart |
3466 | 3465 | ||
3467 | mov ebp, cpustring |
3466 | mov ebp, cpustring |
3468 | call fs_execute_from_sysdir |
3467 | call fs_execute_from_sysdir |
3469 | 3468 | ||
3470 | mov [ctrl_alt_del], 0 |
3469 | mov [ctrl_alt_del], 0 |
3471 | ;-------------------------------------- |
3470 | ;-------------------------------------- |
3472 | align 4 |
3471 | align 4 |
3473 | nocpustart: |
3472 | nocpustart: |
3474 | cmp [mouse_active], 1 |
3473 | cmp [mouse_active], 1 |
3475 | jne mouse_not_active |
3474 | jne mouse_not_active |
3476 | mov [mouse_active], 0 |
3475 | mov [mouse_active], 0 |
3477 | 3476 | ||
3478 | xor edi, edi |
3477 | xor edi, edi |
3479 | mov ebx, CURRENT_TASK |
3478 | mov ebx, CURRENT_TASK |
3480 | 3479 | ||
3481 | mov ecx, [TASK_COUNT] |
3480 | mov ecx, [TASK_COUNT] |
3482 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3481 | movzx eax, word [WIN_POS + ecx*2] ; active window |
3483 | shl eax, 8 |
3482 | shl eax, 8 |
3484 | push eax |
3483 | push eax |
3485 | 3484 | ||
3486 | movzx eax, word [MOUSE_X] |
3485 | movzx eax, word [MOUSE_X] |
3487 | movzx edx, word [MOUSE_Y] |
3486 | movzx edx, word [MOUSE_Y] |
3488 | ;-------------------------------------- |
3487 | ;-------------------------------------- |
3489 | align 4 |
3488 | align 4 |
3490 | .set_mouse_event: |
3489 | .set_mouse_event: |
3491 | add edi, 256 |
3490 | add edi, 256 |
3492 | add ebx, 32 |
3491 | add ebx, 32 |
3493 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3492 | test [ebx+TASKDATA.event_mask], 0x80000000 |
3494 | jz .pos_filter |
3493 | jz .pos_filter |
3495 | 3494 | ||
3496 | cmp edi, [esp] ; skip if filtration active |
3495 | cmp edi, [esp] ; skip if filtration active |
3497 | jne .skip |
3496 | jne .skip |
3498 | ;-------------------------------------- |
3497 | ;-------------------------------------- |
3499 | align 4 |
3498 | align 4 |
3500 | .pos_filter: |
3499 | .pos_filter: |
3501 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3500 | test [ebx+TASKDATA.event_mask], 0x40000000 |
3502 | jz .set |
3501 | jz .set |
3503 | 3502 | ||
3504 | mov esi, [ebx-twdw+WDATA.box.left] |
3503 | mov esi, [ebx-twdw+WDATA.box.left] |
3505 | cmp eax, esi |
3504 | cmp eax, esi |
3506 | jb .skip |
3505 | jb .skip |
3507 | add esi, [ebx-twdw+WDATA.box.width] |
3506 | add esi, [ebx-twdw+WDATA.box.width] |
3508 | cmp eax, esi |
3507 | cmp eax, esi |
3509 | ja .skip |
3508 | ja .skip |
3510 | 3509 | ||
3511 | mov esi, [ebx-twdw+WDATA.box.top] |
3510 | mov esi, [ebx-twdw+WDATA.box.top] |
3512 | cmp edx, esi |
3511 | cmp edx, esi |
3513 | jb .skip |
3512 | jb .skip |
3514 | add esi, [ebx-twdw+WDATA.box.height] |
3513 | add esi, [ebx-twdw+WDATA.box.height] |
3515 | cmp edx, esi |
3514 | cmp edx, esi |
3516 | ja .skip |
3515 | ja .skip |
3517 | ;-------------------------------------- |
3516 | ;-------------------------------------- |
3518 | align 4 |
3517 | align 4 |
3519 | .set: |
3518 | .set: |
3520 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3519 | or [edi+SLOT_BASE+APPDATA.event_mask], 100000b ; set event 6 |
3521 | ;-------------------------------------- |
3520 | ;-------------------------------------- |
3522 | align 4 |
3521 | align 4 |
3523 | .skip: |
3522 | .skip: |
3524 | loop .set_mouse_event |
3523 | loop .set_mouse_event |
3525 | 3524 | ||
3526 | pop eax |
3525 | pop eax |
3527 | ;-------------------------------------- |
3526 | ;-------------------------------------- |
3528 | align 4 |
3527 | align 4 |
3529 | mouse_not_active: |
3528 | mouse_not_active: |
3530 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
3529 | cmp [REDRAW_BACKGROUND], 0 ; background update ? |
3531 | jz nobackgr |
3530 | jz nobackgr |
3532 | 3531 | ||
3533 | cmp [background_defined], 0 |
3532 | cmp [background_defined], 0 |
3534 | jz nobackgr |
3533 | jz nobackgr |
3535 | ;-------------------------------------- |
3534 | ;-------------------------------------- |
3536 | align 4 |
3535 | align 4 |
3537 | backgr: |
3536 | backgr: |
3538 | mov eax, [draw_data+32 + RECT.left] |
3537 | mov eax, [draw_data+32 + RECT.left] |
3539 | shl eax, 16 |
3538 | shl eax, 16 |
3540 | add eax, [draw_data+32 + RECT.right] |
3539 | add eax, [draw_data+32 + RECT.right] |
3541 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3540 | mov [BG_Rect_X_left_right], eax ; [left]*65536 + [right] |
3542 | 3541 | ||
3543 | mov eax, [draw_data+32 + RECT.top] |
3542 | mov eax, [draw_data+32 + RECT.top] |
3544 | shl eax, 16 |
3543 | shl eax, 16 |
3545 | add eax, [draw_data+32 + RECT.bottom] |
3544 | add eax, [draw_data+32 + RECT.bottom] |
3546 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3545 | mov [BG_Rect_Y_top_bottom], eax ; [top]*65536 + [bottom] |
3547 | 3546 | ||
3548 | call drawbackground |
3547 | call drawbackground |
3549 | ; DEBUGF 1, "K : drawbackground\n" |
3548 | ; DEBUGF 1, "K : drawbackground\n" |
3550 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3549 | ; DEBUGF 1, "K : backg x %x\n",[BG_Rect_X_left_right] |
3551 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3550 | ; DEBUGF 1, "K : backg y %x\n",[BG_Rect_Y_top_bottom] |
3552 | ;--------- set event 5 start ---------- |
3551 | ;--------- set event 5 start ---------- |
3553 | push ecx edi |
3552 | push ecx edi |
3554 | xor edi, edi |
3553 | xor edi, edi |
3555 | mov ecx, [TASK_COUNT] |
3554 | mov ecx, [TASK_COUNT] |
3556 | ;-------------------------------------- |
3555 | ;-------------------------------------- |
3557 | align 4 |
3556 | align 4 |
3558 | set_bgr_event: |
3557 | set_bgr_event: |
3559 | add edi, 256 |
3558 | add edi, 256 |
3560 | mov eax, [BG_Rect_X_left_right] |
3559 | mov eax, [BG_Rect_X_left_right] |
3561 | mov edx, [BG_Rect_Y_top_bottom] |
3560 | mov edx, [BG_Rect_Y_top_bottom] |
3562 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3561 | cmp [edi+SLOT_BASE+APPDATA.draw_bgr_x], 0 |
3563 | jz .set |
3562 | jz .set |
3564 | .join: |
3563 | .join: |
3565 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3564 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3566 | jae @f |
3565 | jae @f |
3567 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3566 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x], ax |
3568 | @@: |
3567 | @@: |
3569 | shr eax, 16 |
3568 | shr eax, 16 |
3570 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3569 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3571 | jbe @f |
3570 | jbe @f |
3572 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3571 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_x+2], ax |
3573 | @@: |
3572 | @@: |
3574 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3573 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3575 | jae @f |
3574 | jae @f |
3576 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3575 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y], dx |
3577 | @@: |
3576 | @@: |
3578 | shr edx, 16 |
3577 | shr edx, 16 |
3579 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3578 | cmp word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3580 | jbe @f |
3579 | jbe @f |
3581 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3580 | mov word [edi+SLOT_BASE+APPDATA.draw_bgr_y+2], dx |
3582 | @@: |
3581 | @@: |
3583 | jmp .common |
3582 | jmp .common |
3584 | .set: |
3583 | .set: |
3585 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3584 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_x], eax |
3586 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3585 | mov [edi+SLOT_BASE+APPDATA.draw_bgr_y], edx |
3587 | .common: |
3586 | .common: |
3588 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3587 | or [edi+SLOT_BASE+APPDATA.event_mask], 10000b ; set event 5 |
3589 | loop set_bgr_event |
3588 | loop set_bgr_event |
3590 | pop edi ecx |
3589 | pop edi ecx |
3591 | ;--------- set event 5 stop ----------- |
3590 | ;--------- set event 5 stop ----------- |
3592 | dec [REDRAW_BACKGROUND] ; got new update request? |
3591 | dec [REDRAW_BACKGROUND] ; got new update request? |
3593 | jnz backgr |
3592 | jnz backgr |
3594 | 3593 | ||
3595 | xor eax, eax |
3594 | xor eax, eax |
3596 | mov [draw_data+32 + RECT.left], eax |
3595 | mov [draw_data+32 + RECT.left], eax |
3597 | mov [draw_data+32 + RECT.top], eax |
3596 | mov [draw_data+32 + RECT.top], eax |
3598 | mov [draw_data+32 + RECT.right], eax |
3597 | mov [draw_data+32 + RECT.right], eax |
3599 | mov [draw_data+32 + RECT.bottom], eax |
3598 | mov [draw_data+32 + RECT.bottom], eax |
3600 | ;-------------------------------------- |
3599 | ;-------------------------------------- |
3601 | align 4 |
3600 | align 4 |
3602 | nobackgr: |
3601 | nobackgr: |
3603 | ; system shutdown request |
3602 | ; system shutdown request |
3604 | cmp [SYS_SHUTDOWN], byte 0 |
3603 | cmp [SYS_SHUTDOWN], byte 0 |
3605 | je noshutdown |
3604 | je noshutdown |
3606 | 3605 | ||
3607 | mov edx, [shutdown_processes] |
3606 | mov edx, [shutdown_processes] |
3608 | 3607 | ||
3609 | cmp [SYS_SHUTDOWN], dl |
3608 | cmp [SYS_SHUTDOWN], dl |
3610 | jne noshutdown |
3609 | jne noshutdown |
3611 | 3610 | ||
3612 | lea ecx, [edx-1] |
3611 | lea ecx, [edx-1] |
3613 | mov edx, OS_BASE+0x3040 |
3612 | mov edx, OS_BASE+0x3040 |
3614 | jecxz no_mark_system_shutdown |
3613 | jecxz no_mark_system_shutdown |
3615 | ;-------------------------------------- |
3614 | ;-------------------------------------- |
3616 | align 4 |
3615 | align 4 |
3617 | markz: |
3616 | markz: |
3618 | push ecx edx |
3617 | push ecx edx |
3619 | cmp [edx+TASKDATA.state], TSTATE_FREE |
3618 | cmp [edx+TASKDATA.state], TSTATE_FREE |
3620 | jz .nokill |
3619 | jz .nokill |
3621 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3620 | lea edx, [(edx-(CURRENT_TASK and 1FFFFFFFh))*8+SLOT_BASE] |
3622 | cmp [edx+APPDATA.process], sys_proc |
3621 | cmp [edx+APPDATA.process], sys_proc |
3623 | jz .nokill |
3622 | jz .nokill |
3624 | call request_terminate |
3623 | call request_terminate |
3625 | jmp .common |
3624 | jmp .common |
3626 | .nokill: |
3625 | .nokill: |
3627 | dec byte [SYS_SHUTDOWN] |
3626 | dec byte [SYS_SHUTDOWN] |
3628 | xor eax, eax |
3627 | xor eax, eax |
3629 | .common: |
3628 | .common: |
3630 | pop edx ecx |
3629 | pop edx ecx |
3631 | test eax, eax |
3630 | test eax, eax |
3632 | jz @f |
3631 | jz @f |
3633 | mov [edx+TASKDATA.state], TSTATE_ZOMBIE |
3632 | mov [edx+TASKDATA.state], TSTATE_ZOMBIE |
3634 | @@: |
3633 | @@: |
3635 | add edx, 0x20 |
3634 | add edx, 0x20 |
3636 | loop markz |
3635 | loop markz |
3637 | call wakeup_osloop |
3636 | call wakeup_osloop |
3638 | ;-------------------------------------- |
3637 | ;-------------------------------------- |
3639 | align 4 |
3638 | align 4 |
3640 | @@: |
3639 | @@: |
3641 | no_mark_system_shutdown: |
3640 | no_mark_system_shutdown: |
3642 | dec byte [SYS_SHUTDOWN] |
3641 | dec byte [SYS_SHUTDOWN] |
3643 | je system_shutdown |
3642 | je system_shutdown |
3644 | ;-------------------------------------- |
3643 | ;-------------------------------------- |
3645 | align 4 |
3644 | align 4 |
3646 | noshutdown: |
3645 | noshutdown: |
3647 | mov eax, [TASK_COUNT] ; termination |
3646 | mov eax, [TASK_COUNT] ; termination |
3648 | mov ebx, TASK_DATA+TASKDATA.state |
3647 | mov ebx, TASK_DATA+TASKDATA.state |
3649 | mov esi, 1 |
3648 | mov esi, 1 |
3650 | ;-------------------------------------- |
3649 | ;-------------------------------------- |
3651 | align 4 |
3650 | align 4 |
3652 | newct: |
3651 | newct: |
3653 | mov cl, [ebx] |
3652 | mov cl, [ebx] |
3654 | cmp cl, byte 3 |
3653 | cmp cl, byte 3 |
3655 | jz .terminate |
3654 | jz .terminate |
3656 | 3655 | ||
3657 | cmp cl, byte 4 |
3656 | cmp cl, byte 4 |
3658 | jnz .noterminate |
3657 | jnz .noterminate |
3659 | .terminate: |
3658 | .terminate: |
3660 | pushad |
3659 | pushad |
3661 | mov ecx, eax |
3660 | mov ecx, eax |
3662 | shl ecx, 8 |
3661 | shl ecx, 8 |
3663 | add ecx, SLOT_BASE |
3662 | add ecx, SLOT_BASE |
3664 | call restore_default_cursor_before_killing |
3663 | call restore_default_cursor_before_killing |
3665 | popad |
3664 | popad |
3666 | 3665 | ||
3667 | pushad |
3666 | pushad |
3668 | call terminate |
3667 | call terminate |
3669 | popad |
3668 | popad |
3670 | cmp byte [SYS_SHUTDOWN], 0 |
3669 | cmp byte [SYS_SHUTDOWN], 0 |
3671 | jz .noterminate |
3670 | jz .noterminate |
3672 | dec byte [SYS_SHUTDOWN] |
3671 | dec byte [SYS_SHUTDOWN] |
3673 | je system_shutdown |
3672 | je system_shutdown |
3674 | 3673 | ||
3675 | .noterminate: |
3674 | .noterminate: |
3676 | add ebx, 0x20 |
3675 | add ebx, 0x20 |
3677 | inc esi |
3676 | inc esi |
3678 | dec eax |
3677 | dec eax |
3679 | jnz newct |
3678 | jnz newct |
3680 | ret |
3679 | ret |
3681 | ;----------------------------------------------------------------------------- |
3680 | ;----------------------------------------------------------------------------- |
3682 | align 4 |
3681 | align 4 |
3683 | redrawscreen: |
3682 | redrawscreen: |
3684 | ; eax , if process window_data base is eax, do not set flag/limits |
3683 | ; eax , if process window_data base is eax, do not set flag/limits |
3685 | 3684 | ||
3686 | pushad |
3685 | pushad |
3687 | push eax |
3686 | push eax |
3688 | 3687 | ||
3689 | ;;; mov ebx,2 |
3688 | ;;; mov ebx,2 |
3690 | ;;; call delay_hs |
3689 | ;;; call delay_hs |
3691 | 3690 | ||
3692 | ;mov ecx,0 ; redraw flags for apps |
3691 | ;mov ecx,0 ; redraw flags for apps |
3693 | xor ecx, ecx |
3692 | xor ecx, ecx |
3694 | ;-------------------------------------- |
3693 | ;-------------------------------------- |
3695 | align 4 |
3694 | align 4 |
3696 | newdw2: |
3695 | newdw2: |
3697 | inc ecx |
3696 | inc ecx |
3698 | push ecx |
3697 | push ecx |
3699 | 3698 | ||
3700 | mov eax, ecx |
3699 | mov eax, ecx |
3701 | shl eax, 5 |
3700 | shl eax, 5 |
3702 | add eax, window_data |
3701 | add eax, window_data |
3703 | 3702 | ||
3704 | cmp eax, [esp+4] |
3703 | cmp eax, [esp+4] |
3705 | je not_this_task |
3704 | je not_this_task |
3706 | ; check if window in redraw area |
3705 | ; check if window in redraw area |
3707 | mov edi, eax |
3706 | mov edi, eax |
3708 | 3707 | ||
3709 | cmp ecx, 1 ; limit for background |
3708 | cmp ecx, 1 ; limit for background |
3710 | jz bgli |
3709 | jz bgli |
3711 | 3710 | ||
3712 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3711 | mov eax, [esp+4] ;if upper in z-position - no redraw |
3713 | test eax, eax |
3712 | test eax, eax |
3714 | jz @f |
3713 | jz @f |
3715 | mov al, [eax + WDATA.z_modif] |
3714 | mov al, [eax + WDATA.z_modif] |
3716 | cmp [edi + WDATA.z_modif], al |
3715 | cmp [edi + WDATA.z_modif], al |
3717 | jg ricino |
3716 | jg ricino |
3718 | @@: |
3717 | @@: |
3719 | 3718 | ||
3720 | mov eax, [edi + WDATA.box.left] |
3719 | mov eax, [edi + WDATA.box.left] |
3721 | mov ebx, [edi + WDATA.box.top] |
3720 | mov ebx, [edi + WDATA.box.top] |
3722 | 3721 | ||
3723 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3722 | mov ecx, [draw_limits.bottom] ; ecx = area y end ebx = window y start |
3724 | cmp ecx, ebx |
3723 | cmp ecx, ebx |
3725 | jb ricino |
3724 | jb ricino |
3726 | 3725 | ||
3727 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3726 | mov ecx, [draw_limits.right] ; ecx = area x end eax = window x start |
3728 | cmp ecx, eax |
3727 | cmp ecx, eax |
3729 | jb ricino |
3728 | jb ricino |
3730 | 3729 | ||
3731 | mov eax, [edi + WDATA.box.left] |
3730 | mov eax, [edi + WDATA.box.left] |
3732 | mov ebx, [edi + WDATA.box.top] |
3731 | mov ebx, [edi + WDATA.box.top] |
3733 | mov ecx, [edi + WDATA.box.width] |
3732 | mov ecx, [edi + WDATA.box.width] |
3734 | mov edx, [edi + WDATA.box.height] |
3733 | mov edx, [edi + WDATA.box.height] |
3735 | add ecx, eax |
3734 | add ecx, eax |
3736 | add edx, ebx |
3735 | add edx, ebx |
3737 | 3736 | ||
3738 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3737 | mov eax, [draw_limits.top] ; eax = area y start edx = window y end |
3739 | cmp edx, eax |
3738 | cmp edx, eax |
3740 | jb ricino |
3739 | jb ricino |
3741 | 3740 | ||
3742 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3741 | mov eax, [draw_limits.left] ; eax = area x start ecx = window x end |
3743 | cmp ecx, eax |
3742 | cmp ecx, eax |
3744 | jb ricino |
3743 | jb ricino |
3745 | ;-------------------------------------- |
3744 | ;-------------------------------------- |
3746 | align 4 |
3745 | align 4 |
3747 | bgli: |
3746 | bgli: |
3748 | cmp dword[esp], 1 |
3747 | cmp dword[esp], 1 |
3749 | jnz .az |
3748 | jnz .az |
3750 | 3749 | ||
3751 | cmp [REDRAW_BACKGROUND], 0 |
3750 | cmp [REDRAW_BACKGROUND], 0 |
3752 | jz .az |
3751 | jz .az |
3753 | 3752 | ||
3754 | mov dl, 0 |
3753 | mov dl, 0 |
3755 | lea eax, [edi+draw_data-window_data] |
3754 | lea eax, [edi+draw_data-window_data] |
3756 | mov ebx, [draw_limits.left] |
3755 | mov ebx, [draw_limits.left] |
3757 | cmp ebx, [eax+RECT.left] |
3756 | cmp ebx, [eax+RECT.left] |
3758 | jae @f |
3757 | jae @f |
3759 | 3758 | ||
3760 | mov [eax+RECT.left], ebx |
3759 | mov [eax+RECT.left], ebx |
3761 | mov dl, 1 |
3760 | mov dl, 1 |
3762 | ;-------------------------------------- |
3761 | ;-------------------------------------- |
3763 | align 4 |
3762 | align 4 |
3764 | @@: |
3763 | @@: |
3765 | mov ebx, [draw_limits.top] |
3764 | mov ebx, [draw_limits.top] |
3766 | cmp ebx, [eax+RECT.top] |
3765 | cmp ebx, [eax+RECT.top] |
3767 | jae @f |
3766 | jae @f |
3768 | 3767 | ||
3769 | mov [eax+RECT.top], ebx |
3768 | mov [eax+RECT.top], ebx |
3770 | mov dl, 1 |
3769 | mov dl, 1 |
3771 | ;-------------------------------------- |
3770 | ;-------------------------------------- |
3772 | align 4 |
3771 | align 4 |
3773 | @@: |
3772 | @@: |
3774 | mov ebx, [draw_limits.right] |
3773 | mov ebx, [draw_limits.right] |
3775 | cmp ebx, [eax+RECT.right] |
3774 | cmp ebx, [eax+RECT.right] |
3776 | jbe @f |
3775 | jbe @f |
3777 | 3776 | ||
3778 | mov [eax+RECT.right], ebx |
3777 | mov [eax+RECT.right], ebx |
3779 | mov dl, 1 |
3778 | mov dl, 1 |
3780 | ;-------------------------------------- |
3779 | ;-------------------------------------- |
3781 | align 4 |
3780 | align 4 |
3782 | @@: |
3781 | @@: |
3783 | mov ebx, [draw_limits.bottom] |
3782 | mov ebx, [draw_limits.bottom] |
3784 | cmp ebx, [eax+RECT.bottom] |
3783 | cmp ebx, [eax+RECT.bottom] |
3785 | jbe @f |
3784 | jbe @f |
3786 | 3785 | ||
3787 | mov [eax+RECT.bottom], ebx |
3786 | mov [eax+RECT.bottom], ebx |
3788 | mov dl, 1 |
3787 | mov dl, 1 |
3789 | ;-------------------------------------- |
3788 | ;-------------------------------------- |
3790 | align 4 |
3789 | align 4 |
3791 | @@: |
3790 | @@: |
3792 | add [REDRAW_BACKGROUND], dl |
3791 | add [REDRAW_BACKGROUND], dl |
3793 | call wakeup_osloop |
3792 | call wakeup_osloop |
3794 | jmp newdw8 |
3793 | jmp newdw8 |
3795 | ;-------------------------------------- |
3794 | ;-------------------------------------- |
3796 | align 4 |
3795 | align 4 |
3797 | .az: |
3796 | .az: |
3798 | mov eax, edi |
3797 | mov eax, edi |
3799 | add eax, draw_data-window_data |
3798 | add eax, draw_data-window_data |
3800 | 3799 | ||
3801 | mov ebx, [draw_limits.left] ; set limits |
3800 | mov ebx, [draw_limits.left] ; set limits |
3802 | mov [eax + RECT.left], ebx |
3801 | mov [eax + RECT.left], ebx |
3803 | mov ebx, [draw_limits.top] |
3802 | mov ebx, [draw_limits.top] |
3804 | mov [eax + RECT.top], ebx |
3803 | mov [eax + RECT.top], ebx |
3805 | mov ebx, [draw_limits.right] |
3804 | mov ebx, [draw_limits.right] |
3806 | mov [eax + RECT.right], ebx |
3805 | mov [eax + RECT.right], ebx |
3807 | mov ebx, [draw_limits.bottom] |
3806 | mov ebx, [draw_limits.bottom] |
3808 | mov [eax + RECT.bottom], ebx |
3807 | mov [eax + RECT.bottom], ebx |
3809 | 3808 | ||
3810 | sub eax, draw_data-window_data |
3809 | sub eax, draw_data-window_data |
3811 | 3810 | ||
3812 | cmp dword [esp], 1 |
3811 | cmp dword [esp], 1 |
3813 | jne nobgrd |
3812 | jne nobgrd |
3814 | inc [REDRAW_BACKGROUND] |
3813 | inc [REDRAW_BACKGROUND] |
3815 | call wakeup_osloop |
3814 | call wakeup_osloop |
3816 | ;-------------------------------------- |
3815 | ;-------------------------------------- |
3817 | align 4 |
3816 | align 4 |
3818 | newdw8: |
3817 | newdw8: |
3819 | nobgrd: |
3818 | nobgrd: |
3820 | ;-------------------------------------- |
3819 | ;-------------------------------------- |
3821 | push eax edi ebp |
3820 | push eax edi ebp |
3822 | mov edi, [esp+12] |
3821 | mov edi, [esp+12] |
3823 | cmp edi, 1 |
3822 | cmp edi, 1 |
3824 | je .found |
3823 | je .found |
3825 | 3824 | ||
3826 | mov eax, [draw_limits.left] |
3825 | mov eax, [draw_limits.left] |
3827 | mov ebx, [draw_limits.top] |
3826 | mov ebx, [draw_limits.top] |
3828 | mov ecx, [draw_limits.right] |
3827 | mov ecx, [draw_limits.right] |
3829 | sub ecx, eax |
3828 | sub ecx, eax |
3830 | test ecx, ecx |
3829 | test ecx, ecx |
3831 | jz .not_found |
3830 | jz .not_found |
3832 | 3831 | ||
3833 | mov edx, [draw_limits.bottom] |
3832 | mov edx, [draw_limits.bottom] |
3834 | sub edx, ebx |
3833 | sub edx, ebx |
3835 | test edx, edx |
3834 | test edx, edx |
3836 | jz .not_found |
3835 | jz .not_found |
3837 | 3836 | ||
3838 | ; eax - x, ebx - y |
3837 | ; eax - x, ebx - y |
3839 | ; ecx - size x, edx - size y |
3838 | ; ecx - size x, edx - size y |
3840 | add ebx, edx |
3839 | add ebx, edx |
3841 | ;-------------------------------------- |
3840 | ;-------------------------------------- |
3842 | align 4 |
3841 | align 4 |
3843 | .start_y: |
3842 | .start_y: |
3844 | push ecx |
3843 | push ecx |
3845 | ;-------------------------------------- |
3844 | ;-------------------------------------- |
3846 | align 4 |
3845 | align 4 |
3847 | .start_x: |
3846 | .start_x: |
3848 | add eax, ecx |
3847 | add eax, ecx |
3849 | mov ebp, [d_width_calc_area + ebx*4] |
3848 | mov ebp, [d_width_calc_area + ebx*4] |
3850 | add ebp, [_display.win_map] |
3849 | add ebp, [_display.win_map] |
3851 | movzx ebp, byte[eax+ebp] ; get value for current point |
3850 | movzx ebp, byte[eax+ebp] ; get value for current point |
3852 | cmp ebp, edi |
3851 | cmp ebp, edi |
3853 | jne @f |
3852 | jne @f |
3854 | 3853 | ||
3855 | pop ecx |
3854 | pop ecx |
3856 | jmp .found |
3855 | jmp .found |
3857 | ;-------------------------------------- |
3856 | ;-------------------------------------- |
3858 | align 4 |
3857 | align 4 |
3859 | @@: |
3858 | @@: |
3860 | sub eax, ecx |
3859 | sub eax, ecx |
3861 | 3860 | ||
3862 | dec ecx |
3861 | dec ecx |
3863 | jnz .start_x |
3862 | jnz .start_x |
3864 | 3863 | ||
3865 | pop ecx |
3864 | pop ecx |
3866 | dec ebx |
3865 | dec ebx |
3867 | dec edx |
3866 | dec edx |
3868 | jnz .start_y |
3867 | jnz .start_y |
3869 | ;-------------------------------------- |
3868 | ;-------------------------------------- |
3870 | align 4 |
3869 | align 4 |
3871 | .not_found: |
3870 | .not_found: |
3872 | pop ebp edi eax |
3871 | pop ebp edi eax |
3873 | jmp ricino |
3872 | jmp ricino |
3874 | ;-------------------------------------- |
3873 | ;-------------------------------------- |
3875 | align 4 |
3874 | align 4 |
3876 | .found: |
3875 | .found: |
3877 | pop ebp edi eax |
3876 | pop ebp edi eax |
3878 | 3877 | ||
3879 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3878 | mov [eax + WDATA.fl_redraw], byte 1 ; mark as redraw |
3880 | ;-------------------------------------- |
3879 | ;-------------------------------------- |
3881 | align 4 |
3880 | align 4 |
3882 | ricino: |
3881 | ricino: |
3883 | not_this_task: |
3882 | not_this_task: |
3884 | pop ecx |
3883 | pop ecx |
3885 | 3884 | ||
3886 | cmp ecx, [TASK_COUNT] |
3885 | cmp ecx, [TASK_COUNT] |
3887 | jle newdw2 |
3886 | jle newdw2 |
3888 | 3887 | ||
3889 | pop eax |
3888 | pop eax |
3890 | popad |
3889 | popad |
3891 | ret |
3890 | ret |
3892 | ;----------------------------------------------------------------------------- |
3891 | ;----------------------------------------------------------------------------- |
3893 | align 4 |
3892 | align 4 |
3894 | calculatebackground: ; background |
3893 | calculatebackground: ; background |
3895 | mov edi, [_display.win_map] ; set os to use all pixels |
3894 | mov edi, [_display.win_map] ; set os to use all pixels |
3896 | mov eax, 0x01010101 |
3895 | mov eax, 0x01010101 |
3897 | mov ecx, [_display.win_map_size] |
3896 | mov ecx, [_display.win_map_size] |
3898 | shr ecx, 2 |
3897 | shr ecx, 2 |
3899 | rep stosd |
3898 | rep stosd |
3900 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3899 | mov byte[window_data+32+WDATA.z_modif], ZPOS_DESKTOP |
3901 | mov [REDRAW_BACKGROUND], 0 |
3900 | mov [REDRAW_BACKGROUND], 0 |
3902 | ret |
3901 | ret |
3903 | ;----------------------------------------------------------------------------- |
3902 | ;----------------------------------------------------------------------------- |
3904 | uglobal |
3903 | uglobal |
3905 | imax dd 0x0 |
3904 | imax dd 0x0 |
3906 | endg |
3905 | endg |
3907 | ;----------------------------------------------------------------------------- |
3906 | ;----------------------------------------------------------------------------- |
3908 | align 4 |
3907 | align 4 |
3909 | delay_ms: ; delay in 1/1000 sec |
3908 | delay_ms: ; delay in 1/1000 sec |
3910 | push eax |
3909 | push eax |
3911 | push ecx |
3910 | push ecx |
3912 | 3911 | ||
3913 | mov ecx, esi |
3912 | mov ecx, esi |
3914 | ; |
3913 | ; |
3915 | imul ecx, 33941 |
3914 | imul ecx, 33941 |
3916 | shr ecx, 9 |
3915 | shr ecx, 9 |
3917 | ; |
3916 | ; |
3918 | 3917 | ||
3919 | in al, 0x61 |
3918 | in al, 0x61 |
3920 | and al, 0x10 |
3919 | and al, 0x10 |
3921 | mov ah, al |
3920 | mov ah, al |
3922 | cld |
3921 | cld |
3923 | ;-------------------------------------- |
3922 | ;-------------------------------------- |
3924 | align 4 |
3923 | align 4 |
3925 | cnt1: |
3924 | cnt1: |
3926 | in al, 0x61 |
3925 | in al, 0x61 |
3927 | and al, 0x10 |
3926 | and al, 0x10 |
3928 | cmp al, ah |
3927 | cmp al, ah |
3929 | jz cnt1 |
3928 | jz cnt1 |
3930 | 3929 | ||
3931 | mov ah, al |
3930 | mov ah, al |
3932 | loop cnt1 |
3931 | loop cnt1 |
3933 | 3932 | ||
3934 | pop ecx |
3933 | pop ecx |
3935 | pop eax |
3934 | pop eax |
3936 | ret |
3935 | ret |
3937 | ;----------------------------------------------------------------------------- |
3936 | ;----------------------------------------------------------------------------- |
3938 | align 4 |
3937 | align 4 |
3939 | set_app_param: |
3938 | set_app_param: |
3940 | mov edi, [TASK_BASE] |
3939 | mov edi, [TASK_BASE] |
3941 | mov eax, ebx |
3940 | mov eax, ebx |
3942 | btr eax, 3 ; move MOUSE_FILTRATION |
3941 | btr eax, 3 ; move MOUSE_FILTRATION |
3943 | mov ebx, [current_slot] ; bit into event_filter |
3942 | mov ebx, [current_slot] ; bit into event_filter |
3944 | setc byte [ebx+APPDATA.event_filter] |
3943 | setc byte [ebx+APPDATA.event_filter] |
3945 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3944 | xchg eax, [edi + TASKDATA.event_mask] ; set new event mask |
3946 | mov [esp+32], eax ; return old mask value |
3945 | mov [esp+32], eax ; return old mask value |
3947 | ret |
3946 | ret |
3948 | ;----------------------------------------------------------------------------- |
3947 | ;----------------------------------------------------------------------------- |
3949 | 3948 | ||
3950 | ; this is for syscall |
3949 | ; this is for syscall |
3951 | proc delay_hs_unprotected |
3950 | proc delay_hs_unprotected |
3952 | call unprotect_from_terminate |
3951 | call unprotect_from_terminate |
3953 | call delay_hs |
3952 | call delay_hs |
3954 | call protect_from_terminate |
3953 | call protect_from_terminate |
3955 | ret |
3954 | ret |
3956 | endp |
3955 | endp |
3957 | 3956 | ||
3958 | if 1 |
3957 | if 1 |
3959 | align 4 |
3958 | align 4 |
3960 | delay_hs: ; delay in 1/100 secs |
3959 | delay_hs: ; delay in 1/100 secs |
3961 | ; ebx = delay time |
3960 | ; ebx = delay time |
3962 | 3961 | ||
3963 | pushad |
3962 | pushad |
3964 | push ebx |
3963 | push ebx |
3965 | xor esi, esi |
3964 | xor esi, esi |
3966 | mov ecx, MANUAL_DESTROY |
3965 | mov ecx, MANUAL_DESTROY |
3967 | call create_event |
3966 | call create_event |
3968 | test eax, eax |
3967 | test eax, eax |
3969 | jz .done |
3968 | jz .done |
3970 | 3969 | ||
3971 | mov ebx, edx |
3970 | mov ebx, edx |
3972 | mov ecx, [esp] |
3971 | mov ecx, [esp] |
3973 | push edx |
3972 | push edx |
3974 | push eax |
3973 | push eax |
3975 | call wait_event_timeout |
3974 | call wait_event_timeout |
3976 | pop eax |
3975 | pop eax |
3977 | pop ebx |
3976 | pop ebx |
3978 | call destroy_event |
3977 | call destroy_event |
3979 | .done: |
3978 | .done: |
3980 | add esp, 4 |
3979 | add esp, 4 |
3981 | popad |
3980 | popad |
3982 | ret |
3981 | ret |
3983 | 3982 | ||
3984 | else |
3983 | else |
3985 | 3984 | ||
3986 | align 4 |
3985 | align 4 |
3987 | delay_hs: ; delay in 1/100 secs |
3986 | delay_hs: ; delay in 1/100 secs |
3988 | ; ebx = delay time |
3987 | ; ebx = delay time |
3989 | push ecx |
3988 | push ecx |
3990 | push edx |
3989 | push edx |
3991 | 3990 | ||
3992 | mov edx, [timer_ticks] |
3991 | mov edx, [timer_ticks] |
3993 | ;-------------------------------------- |
3992 | ;-------------------------------------- |
3994 | align 4 |
3993 | align 4 |
3995 | newtic: |
3994 | newtic: |
3996 | mov ecx, [timer_ticks] |
3995 | mov ecx, [timer_ticks] |
3997 | sub ecx, edx |
3996 | sub ecx, edx |
3998 | cmp ecx, ebx |
3997 | cmp ecx, ebx |
3999 | jae zerodelay |
3998 | jae zerodelay |
4000 | 3999 | ||
4001 | call change_task |
4000 | call change_task |
4002 | 4001 | ||
4003 | jmp newtic |
4002 | jmp newtic |
4004 | ;-------------------------------------- |
4003 | ;-------------------------------------- |
4005 | align 4 |
4004 | align 4 |
4006 | zerodelay: |
4005 | zerodelay: |
4007 | pop edx |
4006 | pop edx |
4008 | pop ecx |
4007 | pop ecx |
4009 | ret |
4008 | ret |
4010 | end if |
4009 | end if |
4011 | 4010 | ||
4012 | ;----------------------------------------------------------------------------- |
4011 | ;----------------------------------------------------------------------------- |
4013 | align 16 ;very often call this subrutine |
4012 | align 16 ;very often call this subrutine |
4014 | memmove: ; memory move in bytes |
4013 | memmove: ; memory move in bytes |
4015 | ; eax = from |
4014 | ; eax = from |
4016 | ; ebx = to |
4015 | ; ebx = to |
4017 | ; ecx = no of bytes |
4016 | ; ecx = no of bytes |
4018 | test ecx, ecx |
4017 | test ecx, ecx |
4019 | jle .ret |
4018 | jle .ret |
4020 | 4019 | ||
4021 | push esi edi ecx |
4020 | push esi edi ecx |
4022 | 4021 | ||
4023 | mov edi, ebx |
4022 | mov edi, ebx |
4024 | mov esi, eax |
4023 | mov esi, eax |
4025 | 4024 | ||
4026 | test ecx, not 11b |
4025 | test ecx, not 11b |
4027 | jz @f |
4026 | jz @f |
4028 | 4027 | ||
4029 | push ecx |
4028 | push ecx |
4030 | shr ecx, 2 |
4029 | shr ecx, 2 |
4031 | rep movsd |
4030 | rep movsd |
4032 | pop ecx |
4031 | pop ecx |
4033 | and ecx, 11b |
4032 | and ecx, 11b |
4034 | jz .finish |
4033 | jz .finish |
4035 | ;-------------------------------------- |
4034 | ;-------------------------------------- |
4036 | align 4 |
4035 | align 4 |
4037 | @@: |
4036 | @@: |
4038 | rep movsb |
4037 | rep movsb |
4039 | ;-------------------------------------- |
4038 | ;-------------------------------------- |
4040 | align 4 |
4039 | align 4 |
4041 | .finish: |
4040 | .finish: |
4042 | pop ecx edi esi |
4041 | pop ecx edi esi |
4043 | ;-------------------------------------- |
4042 | ;-------------------------------------- |
4044 | align 4 |
4043 | align 4 |
4045 | .ret: |
4044 | .ret: |
4046 | ret |
4045 | ret |
4047 | ;----------------------------------------------------------------------------- |
4046 | ;----------------------------------------------------------------------------- |
4048 | ; |
4047 | ; |
4049 | ;align 4 |
4048 | ;align 4 |
4050 | ; |
4049 | ; |
4051 | ;read_floppy_file: |
4050 | ;read_floppy_file: |
4052 | ; |
4051 | ; |
4053 | ;; as input |
4052 | ;; as input |
4054 | ;; |
4053 | ;; |
4055 | ;; eax pointer to file |
4054 | ;; eax pointer to file |
4056 | ;; ebx file lenght |
4055 | ;; ebx file lenght |
4057 | ;; ecx start 512 byte block number |
4056 | ;; ecx start 512 byte block number |
4058 | ;; edx number of blocks to read |
4057 | ;; edx number of blocks to read |
4059 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4058 | ;; esi pointer to return/work area (atleast 20 000 bytes) |
4060 | ;; |
4059 | ;; |
4061 | ;; |
4060 | ;; |
4062 | ;; on return |
4061 | ;; on return |
4063 | ;; |
4062 | ;; |
4064 | ;; eax = 0 command succesful |
4063 | ;; eax = 0 command succesful |
4065 | ;; 1 no fd base and/or partition defined |
4064 | ;; 1 no fd base and/or partition defined |
4066 | ;; 2 yet unsupported FS |
4065 | ;; 2 yet unsupported FS |
4067 | ;; 3 unknown FS |
4066 | ;; 3 unknown FS |
4068 | ;; 4 partition not defined at hd |
4067 | ;; 4 partition not defined at hd |
4069 | ;; 5 file not found |
4068 | ;; 5 file not found |
4070 | ;; ebx = size of file |
4069 | ;; ebx = size of file |
4071 | ; |
4070 | ; |
4072 | ; mov edi,[TASK_BASE] |
4071 | ; mov edi,[TASK_BASE] |
4073 | ; add edi,0x10 |
4072 | ; add edi,0x10 |
4074 | ; add esi,[edi] |
4073 | ; add esi,[edi] |
4075 | ; add eax,[edi] |
4074 | ; add eax,[edi] |
4076 | ; |
4075 | ; |
4077 | ; pushad |
4076 | ; pushad |
4078 | ; mov edi,esi |
4077 | ; mov edi,esi |
4079 | ; add edi,1024 |
4078 | ; add edi,1024 |
4080 | ; mov esi,0x100000+19*512 |
4079 | ; mov esi,0x100000+19*512 |
4081 | ; sub ecx,1 |
4080 | ; sub ecx,1 |
4082 | ; shl ecx,9 |
4081 | ; shl ecx,9 |
4083 | ; add esi,ecx |
4082 | ; add esi,ecx |
4084 | ; shl edx,9 |
4083 | ; shl edx,9 |
4085 | ; mov ecx,edx |
4084 | ; mov ecx,edx |
4086 | ; cld |
4085 | ; cld |
4087 | ; rep movsb |
4086 | ; rep movsb |
4088 | ; popad |
4087 | ; popad |
4089 | ; |
4088 | ; |
4090 | ; mov [esp+36],eax |
4089 | ; mov [esp+36],eax |
4091 | ; mov [esp+24],ebx |
4090 | ; mov [esp+24],ebx |
4092 | ; ret |
4091 | ; ret |
4093 | 4092 | ||
4094 | 4093 | ||
4095 | 4094 | ||
4096 | align 4 |
4095 | align 4 |
4097 | set_io_access_rights: |
4096 | set_io_access_rights: |
4098 | push edi eax |
4097 | push edi eax |
4099 | mov edi, tss._io_map_0 |
4098 | mov edi, tss._io_map_0 |
4100 | ; mov ecx,eax |
4099 | ; mov ecx,eax |
4101 | ; and ecx,7 ; offset in byte |
4100 | ; and ecx,7 ; offset in byte |
4102 | ; shr eax,3 ; number of byte |
4101 | ; shr eax,3 ; number of byte |
4103 | ; add edi,eax |
4102 | ; add edi,eax |
4104 | ; mov ebx,1 |
4103 | ; mov ebx,1 |
4105 | ; shl ebx,cl |
4104 | ; shl ebx,cl |
4106 | test ebp, ebp |
4105 | test ebp, ebp |
4107 | ; cmp ebp,0 ; enable access - ebp = 0 |
4106 | ; cmp ebp,0 ; enable access - ebp = 0 |
4108 | jnz .siar1 |
4107 | jnz .siar1 |
4109 | ; not ebx |
4108 | ; not ebx |
4110 | ; and [edi],byte bl |
4109 | ; and [edi],byte bl |
4111 | btr [edi], eax |
4110 | btr [edi], eax |
4112 | pop eax edi |
4111 | pop eax edi |
4113 | ret |
4112 | ret |
4114 | .siar1: |
4113 | .siar1: |
4115 | bts [edi], eax |
4114 | bts [edi], eax |
4116 | ; or [edi],byte bl ; disable access - ebp = 1 |
4115 | ; or [edi],byte bl ; disable access - ebp = 1 |
4117 | pop eax edi |
4116 | pop eax edi |
4118 | ret |
4117 | ret |
4119 | ;reserve/free group of ports |
4118 | ;reserve/free group of ports |
4120 | ; * eax = 46 - number function |
4119 | ; * eax = 46 - number function |
4121 | ; * ebx = 0 - reserve, 1 - free |
4120 | ; * ebx = 0 - reserve, 1 - free |
4122 | ; * ecx = number start arrea of ports |
4121 | ; * ecx = number start arrea of ports |
4123 | ; * edx = number end arrea of ports (include last number of port) |
4122 | ; * edx = number end arrea of ports (include last number of port) |
4124 | ;Return value: |
4123 | ;Return value: |
4125 | ; * eax = 0 - succesful |
4124 | ; * eax = 0 - succesful |
4126 | ; * eax = 1 - error |
4125 | ; * eax = 1 - error |
4127 | ; * The system has reserve this ports: |
4126 | ; * The system has reserve this ports: |
4128 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4127 | ; 0..0x2d, 0x30..0x4d, 0x50..0xdf, 0xe5..0xff (include last number of port). |
4129 | ;destroys eax,ebx, ebp |
4128 | ;destroys eax,ebx, ebp |
4130 | r_f_port_area: |
4129 | r_f_port_area: |
4131 | 4130 | ||
4132 | test ebx, ebx |
4131 | test ebx, ebx |
4133 | jnz free_port_area |
4132 | jnz free_port_area |
4134 | ; je r_port_area |
4133 | ; je r_port_area |
4135 | ; jmp free_port_area |
4134 | ; jmp free_port_area |
4136 | 4135 | ||
4137 | ; r_port_area: |
4136 | ; r_port_area: |
4138 | 4137 | ||
4139 | ; pushad |
4138 | ; pushad |
4140 | 4139 | ||
4141 | cmp ecx, edx ; beginning > end ? |
4140 | cmp ecx, edx ; beginning > end ? |
4142 | ja rpal1 |
4141 | ja rpal1 |
4143 | cmp edx, 65536 |
4142 | cmp edx, 65536 |
4144 | jae rpal1 |
4143 | jae rpal1 |
4145 | mov eax, [RESERVED_PORTS] |
4144 | mov eax, [RESERVED_PORTS] |
4146 | test eax, eax ; no reserved areas ? |
4145 | test eax, eax ; no reserved areas ? |
4147 | je rpal2 |
4146 | je rpal2 |
4148 | cmp eax, 255 ; max reserved |
4147 | cmp eax, 255 ; max reserved |
4149 | jae rpal1 |
4148 | jae rpal1 |
4150 | rpal3: |
4149 | rpal3: |
4151 | mov ebx, eax |
4150 | mov ebx, eax |
4152 | shl ebx, 4 |
4151 | shl ebx, 4 |
4153 | add ebx, RESERVED_PORTS |
4152 | add ebx, RESERVED_PORTS |
4154 | cmp ecx, [ebx+8] |
4153 | cmp ecx, [ebx+8] |
4155 | ja rpal4 |
4154 | ja rpal4 |
4156 | cmp edx, [ebx+4] |
4155 | cmp edx, [ebx+4] |
4157 | jae rpal1 |
4156 | jae rpal1 |
4158 | ; jb rpal4 |
4157 | ; jb rpal4 |
4159 | ; jmp rpal1 |
4158 | ; jmp rpal1 |
4160 | rpal4: |
4159 | rpal4: |
4161 | dec eax |
4160 | dec eax |
4162 | jnz rpal3 |
4161 | jnz rpal3 |
4163 | jmp rpal2 |
4162 | jmp rpal2 |
4164 | rpal1: |
4163 | rpal1: |
4165 | ; popad |
4164 | ; popad |
4166 | ; mov eax,1 |
4165 | ; mov eax,1 |
4167 | xor eax, eax |
4166 | xor eax, eax |
4168 | inc eax |
4167 | inc eax |
4169 | ret |
4168 | ret |
4170 | rpal2: |
4169 | rpal2: |
4171 | ; popad |
4170 | ; popad |
4172 | ; enable port access at port IO map |
4171 | ; enable port access at port IO map |
4173 | cli |
4172 | cli |
4174 | pushad ; start enable io map |
4173 | pushad ; start enable io map |
4175 | 4174 | ||
4176 | cmp edx, 65536;16384 |
4175 | cmp edx, 65536;16384 |
4177 | jae no_unmask_io; jge |
4176 | jae no_unmask_io; jge |
4178 | mov eax, ecx |
4177 | mov eax, ecx |
4179 | ; push ebp |
4178 | ; push ebp |
4180 | xor ebp, ebp ; enable - eax = port |
4179 | xor ebp, ebp ; enable - eax = port |
4181 | new_port_access: |
4180 | new_port_access: |
4182 | ; pushad |
4181 | ; pushad |
4183 | call set_io_access_rights |
4182 | call set_io_access_rights |
4184 | ; popad |
4183 | ; popad |
4185 | inc eax |
4184 | inc eax |
4186 | cmp eax, edx |
4185 | cmp eax, edx |
4187 | jbe new_port_access |
4186 | jbe new_port_access |
4188 | ; pop ebp |
4187 | ; pop ebp |
4189 | no_unmask_io: |
4188 | no_unmask_io: |
4190 | popad ; end enable io map |
4189 | popad ; end enable io map |
4191 | sti |
4190 | sti |
4192 | 4191 | ||
4193 | mov eax, [RESERVED_PORTS] |
4192 | mov eax, [RESERVED_PORTS] |
4194 | add eax, 1 |
4193 | add eax, 1 |
4195 | mov [RESERVED_PORTS], eax |
4194 | mov [RESERVED_PORTS], eax |
4196 | shl eax, 4 |
4195 | shl eax, 4 |
4197 | add eax, RESERVED_PORTS |
4196 | add eax, RESERVED_PORTS |
4198 | mov ebx, [TASK_BASE] |
4197 | mov ebx, [TASK_BASE] |
4199 | mov ebx, [ebx+TASKDATA.pid] |
4198 | mov ebx, [ebx+TASKDATA.pid] |
4200 | mov [eax], ebx |
4199 | mov [eax], ebx |
4201 | mov [eax+4], ecx |
4200 | mov [eax+4], ecx |
4202 | mov [eax+8], edx |
4201 | mov [eax+8], edx |
4203 | 4202 | ||
4204 | xor eax, eax |
4203 | xor eax, eax |
4205 | ret |
4204 | ret |
4206 | 4205 | ||
4207 | free_port_area: |
4206 | free_port_area: |
4208 | 4207 | ||
4209 | ; pushad |
4208 | ; pushad |
4210 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4209 | mov eax, [RESERVED_PORTS]; no reserved areas ? |
4211 | test eax, eax |
4210 | test eax, eax |
4212 | jz frpal2 |
4211 | jz frpal2 |
4213 | mov ebx, [TASK_BASE] |
4212 | mov ebx, [TASK_BASE] |
4214 | mov ebx, [ebx+TASKDATA.pid] |
4213 | mov ebx, [ebx+TASKDATA.pid] |
4215 | frpal3: |
4214 | frpal3: |
4216 | mov edi, eax |
4215 | mov edi, eax |
4217 | shl edi, 4 |
4216 | shl edi, 4 |
4218 | add edi, RESERVED_PORTS |
4217 | add edi, RESERVED_PORTS |
4219 | cmp ebx, [edi] |
4218 | cmp ebx, [edi] |
4220 | jne frpal4 |
4219 | jne frpal4 |
4221 | cmp ecx, [edi+4] |
4220 | cmp ecx, [edi+4] |
4222 | jne frpal4 |
4221 | jne frpal4 |
4223 | cmp edx, [edi+8] |
4222 | cmp edx, [edi+8] |
4224 | jne frpal4 |
4223 | jne frpal4 |
4225 | jmp frpal1 |
4224 | jmp frpal1 |
4226 | frpal4: |
4225 | frpal4: |
4227 | dec eax |
4226 | dec eax |
4228 | jnz frpal3 |
4227 | jnz frpal3 |
4229 | frpal2: |
4228 | frpal2: |
4230 | ; popad |
4229 | ; popad |
4231 | inc eax |
4230 | inc eax |
4232 | ret |
4231 | ret |
4233 | frpal1: |
4232 | frpal1: |
4234 | push ecx |
4233 | push ecx |
4235 | mov ecx, 256 |
4234 | mov ecx, 256 |
4236 | sub ecx, eax |
4235 | sub ecx, eax |
4237 | shl ecx, 4 |
4236 | shl ecx, 4 |
4238 | mov esi, edi |
4237 | mov esi, edi |
4239 | add esi, 16 |
4238 | add esi, 16 |
4240 | cld |
4239 | cld |
4241 | rep movsb |
4240 | rep movsb |
4242 | 4241 | ||
4243 | dec dword [RESERVED_PORTS] |
4242 | dec dword [RESERVED_PORTS] |
4244 | ;popad |
4243 | ;popad |
4245 | ;disable port access at port IO map |
4244 | ;disable port access at port IO map |
4246 | 4245 | ||
4247 | ; pushad ; start disable io map |
4246 | ; pushad ; start disable io map |
4248 | pop eax ;start port |
4247 | pop eax ;start port |
4249 | cmp edx, 65536;16384 |
4248 | cmp edx, 65536;16384 |
4250 | jge no_mask_io |
4249 | jge no_mask_io |
4251 | 4250 | ||
4252 | ; mov eax,ecx |
4251 | ; mov eax,ecx |
4253 | xor ebp, ebp |
4252 | xor ebp, ebp |
4254 | inc ebp |
4253 | inc ebp |
4255 | new_port_access_disable: |
4254 | new_port_access_disable: |
4256 | ; pushad |
4255 | ; pushad |
4257 | ; mov ebp,1 ; disable - eax = port |
4256 | ; mov ebp,1 ; disable - eax = port |
4258 | call set_io_access_rights |
4257 | call set_io_access_rights |
4259 | ; popad |
4258 | ; popad |
4260 | inc eax |
4259 | inc eax |
4261 | cmp eax, edx |
4260 | cmp eax, edx |
4262 | jbe new_port_access_disable |
4261 | jbe new_port_access_disable |
4263 | no_mask_io: |
4262 | no_mask_io: |
4264 | ; popad ; end disable io map |
4263 | ; popad ; end disable io map |
4265 | xor eax, eax |
4264 | xor eax, eax |
4266 | ret |
4265 | ret |
4267 | ;----------------------------------------------------------------------------- |
4266 | ;----------------------------------------------------------------------------- |
4268 | align 4 |
4267 | align 4 |
4269 | drawbackground: |
4268 | drawbackground: |
4270 | dbrv20: |
4269 | dbrv20: |
4271 | cmp [BgrDrawMode], dword 1 |
4270 | cmp [BgrDrawMode], dword 1 |
4272 | jne bgrstr |
4271 | jne bgrstr |
4273 | call vesa20_drawbackground_tiled |
4272 | call vesa20_drawbackground_tiled |
4274 | ; call [draw_pointer] |
4273 | ; call [draw_pointer] |
4275 | call __sys_draw_pointer |
4274 | call __sys_draw_pointer |
4276 | ret |
4275 | ret |
4277 | ;-------------------------------------- |
4276 | ;-------------------------------------- |
4278 | align 4 |
4277 | align 4 |
4279 | bgrstr: |
4278 | bgrstr: |
4280 | call vesa20_drawbackground_stretch |
4279 | call vesa20_drawbackground_stretch |
4281 | ; call [draw_pointer] |
4280 | ; call [draw_pointer] |
4282 | call __sys_draw_pointer |
4281 | call __sys_draw_pointer |
4283 | ret |
4282 | ret |
4284 | ;----------------------------------------------------------------------------- |
4283 | ;----------------------------------------------------------------------------- |
4285 | align 4 |
4284 | align 4 |
4286 | syscall_putimage: ; PutImage |
4285 | syscall_putimage: ; PutImage |
4287 | sys_putimage: |
4286 | sys_putimage: |
4288 | test ecx, 0x80008000 |
4287 | test ecx, 0x80008000 |
4289 | jnz .exit |
4288 | jnz .exit |
4290 | test ecx, 0x0000FFFF |
4289 | test ecx, 0x0000FFFF |
4291 | jz .exit |
4290 | jz .exit |
4292 | test ecx, 0xFFFF0000 |
4291 | test ecx, 0xFFFF0000 |
4293 | jnz @f |
4292 | jnz @f |
4294 | ;-------------------------------------- |
4293 | ;-------------------------------------- |
4295 | align 4 |
4294 | align 4 |
4296 | .exit: |
4295 | .exit: |
4297 | ret |
4296 | ret |
4298 | ;-------------------------------------- |
4297 | ;-------------------------------------- |
4299 | align 4 |
4298 | align 4 |
4300 | @@: |
4299 | @@: |
4301 | mov edi, [current_slot] |
4300 | mov edi, [current_slot] |
4302 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4301 | add dx, word[edi+APPDATA.wnd_clientbox.top] |
4303 | rol edx, 16 |
4302 | rol edx, 16 |
4304 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4303 | add dx, word[edi+APPDATA.wnd_clientbox.left] |
4305 | rol edx, 16 |
4304 | rol edx, 16 |
4306 | ;-------------------------------------- |
4305 | ;-------------------------------------- |
4307 | align 4 |
4306 | align 4 |
4308 | .forced: |
4307 | .forced: |
4309 | push ebp esi 0 |
4308 | push ebp esi 0 |
4310 | mov ebp, putimage_get24bpp |
4309 | mov ebp, putimage_get24bpp |
4311 | mov esi, putimage_init24bpp |
4310 | mov esi, putimage_init24bpp |
4312 | ;-------------------------------------- |
4311 | ;-------------------------------------- |
4313 | align 4 |
4312 | align 4 |
4314 | sys_putimage_bpp: |
4313 | sys_putimage_bpp: |
4315 | call vesa20_putimage |
4314 | call vesa20_putimage |
4316 | pop ebp esi ebp |
4315 | pop ebp esi ebp |
4317 | ret |
4316 | ret |
4318 | ; jmp [draw_pointer] |
4317 | ; jmp [draw_pointer] |
4319 | ;----------------------------------------------------------------------------- |
4318 | ;----------------------------------------------------------------------------- |
4320 | align 4 |
4319 | align 4 |
4321 | sys_putimage_palette: |
4320 | sys_putimage_palette: |
4322 | ; ebx = pointer to image |
4321 | ; ebx = pointer to image |
4323 | ; ecx = [xsize]*65536 + [ysize] |
4322 | ; ecx = [xsize]*65536 + [ysize] |
4324 | ; edx = [xstart]*65536 + [ystart] |
4323 | ; edx = [xstart]*65536 + [ystart] |
4325 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4324 | ; esi = number of bits per pixel, must be 8, 24 or 32 |
4326 | ; edi = pointer to palette |
4325 | ; edi = pointer to palette |
4327 | ; ebp = row delta |
4326 | ; ebp = row delta |
4328 | mov eax, [CURRENT_TASK] |
4327 | mov eax, [CURRENT_TASK] |
4329 | shl eax, 8 |
4328 | shl eax, 8 |
4330 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4329 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.top] |
4331 | rol edx, 16 |
4330 | rol edx, 16 |
4332 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4331 | add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left] |
4333 | rol edx, 16 |
4332 | rol edx, 16 |
4334 | ;-------------------------------------- |
4333 | ;-------------------------------------- |
4335 | align 4 |
4334 | align 4 |
4336 | .forced: |
4335 | .forced: |
4337 | cmp esi, 1 |
4336 | cmp esi, 1 |
4338 | jnz @f |
4337 | jnz @f |
4339 | push edi |
4338 | push edi |
4340 | mov eax, [edi+4] |
4339 | mov eax, [edi+4] |
4341 | sub eax, [edi] |
4340 | sub eax, [edi] |
4342 | push eax |
4341 | push eax |
4343 | push dword [edi] |
4342 | push dword [edi] |
4344 | push 0ffffff80h |
4343 | push 0ffffff80h |
4345 | mov edi, esp |
4344 | mov edi, esp |
4346 | call put_mono_image |
4345 | call put_mono_image |
4347 | add esp, 12 |
4346 | add esp, 12 |
4348 | pop edi |
4347 | pop edi |
4349 | ret |
4348 | ret |
4350 | ;-------------------------------------- |
4349 | ;-------------------------------------- |
4351 | align 4 |
4350 | align 4 |
4352 | @@: |
4351 | @@: |
4353 | cmp esi, 2 |
4352 | cmp esi, 2 |
4354 | jnz @f |
4353 | jnz @f |
4355 | push edi |
4354 | push edi |
4356 | push 0ffffff80h |
4355 | push 0ffffff80h |
4357 | mov edi, esp |
4356 | mov edi, esp |
4358 | call put_2bit_image |
4357 | call put_2bit_image |
4359 | pop eax |
4358 | pop eax |
4360 | pop edi |
4359 | pop edi |
4361 | ret |
4360 | ret |
4362 | ;-------------------------------------- |
4361 | ;-------------------------------------- |
4363 | align 4 |
4362 | align 4 |
4364 | @@: |
4363 | @@: |
4365 | cmp esi, 4 |
4364 | cmp esi, 4 |
4366 | jnz @f |
4365 | jnz @f |
4367 | push edi |
4366 | push edi |
4368 | push 0ffffff80h |
4367 | push 0ffffff80h |
4369 | mov edi, esp |
4368 | mov edi, esp |
4370 | call put_4bit_image |
4369 | call put_4bit_image |
4371 | pop eax |
4370 | pop eax |
4372 | pop edi |
4371 | pop edi |
4373 | ret |
4372 | ret |
4374 | ;-------------------------------------- |
4373 | ;-------------------------------------- |
4375 | align 4 |
4374 | align 4 |
4376 | @@: |
4375 | @@: |
4377 | push ebp esi ebp |
4376 | push ebp esi ebp |
4378 | cmp esi, 8 |
4377 | cmp esi, 8 |
4379 | jnz @f |
4378 | jnz @f |
4380 | mov ebp, putimage_get8bpp |
4379 | mov ebp, putimage_get8bpp |
4381 | mov esi, putimage_init8bpp |
4380 | mov esi, putimage_init8bpp |
4382 | jmp sys_putimage_bpp |
4381 | jmp sys_putimage_bpp |
4383 | ;-------------------------------------- |
4382 | ;-------------------------------------- |
4384 | align 4 |
4383 | align 4 |
4385 | @@: |
4384 | @@: |
4386 | cmp esi, 9 |
4385 | cmp esi, 9 |
4387 | jnz @f |
4386 | jnz @f |
4388 | mov ebp, putimage_get9bpp |
4387 | mov ebp, putimage_get9bpp |
4389 | mov esi, putimage_init9bpp |
4388 | mov esi, putimage_init9bpp |
4390 | jmp sys_putimage_bpp |
4389 | jmp sys_putimage_bpp |
4391 | ;-------------------------------------- |
4390 | ;-------------------------------------- |
4392 | align 4 |
4391 | align 4 |
4393 | @@: |
4392 | @@: |
4394 | cmp esi, 15 |
4393 | cmp esi, 15 |
4395 | jnz @f |
4394 | jnz @f |
4396 | mov ebp, putimage_get15bpp |
4395 | mov ebp, putimage_get15bpp |
4397 | mov esi, putimage_init15bpp |
4396 | mov esi, putimage_init15bpp |
4398 | jmp sys_putimage_bpp |
4397 | jmp sys_putimage_bpp |
4399 | ;-------------------------------------- |
4398 | ;-------------------------------------- |
4400 | align 4 |
4399 | align 4 |
4401 | @@: |
4400 | @@: |
4402 | cmp esi, 16 |
4401 | cmp esi, 16 |
4403 | jnz @f |
4402 | jnz @f |
4404 | mov ebp, putimage_get16bpp |
4403 | mov ebp, putimage_get16bpp |
4405 | mov esi, putimage_init16bpp |
4404 | mov esi, putimage_init16bpp |
4406 | jmp sys_putimage_bpp |
4405 | jmp sys_putimage_bpp |
4407 | ;-------------------------------------- |
4406 | ;-------------------------------------- |
4408 | align 4 |
4407 | align 4 |
4409 | @@: |
4408 | @@: |
4410 | cmp esi, 24 |
4409 | cmp esi, 24 |
4411 | jnz @f |
4410 | jnz @f |
4412 | mov ebp, putimage_get24bpp |
4411 | mov ebp, putimage_get24bpp |
4413 | mov esi, putimage_init24bpp |
4412 | mov esi, putimage_init24bpp |
4414 | jmp sys_putimage_bpp |
4413 | jmp sys_putimage_bpp |
4415 | ;-------------------------------------- |
4414 | ;-------------------------------------- |
4416 | align 4 |
4415 | align 4 |
4417 | @@: |
4416 | @@: |
4418 | cmp esi, 32 |
4417 | cmp esi, 32 |
4419 | jnz @f |
4418 | jnz @f |
4420 | mov ebp, putimage_get32bpp |
4419 | mov ebp, putimage_get32bpp |
4421 | mov esi, putimage_init32bpp |
4420 | mov esi, putimage_init32bpp |
4422 | jmp sys_putimage_bpp |
4421 | jmp sys_putimage_bpp |
4423 | ;-------------------------------------- |
4422 | ;-------------------------------------- |
4424 | align 4 |
4423 | align 4 |
4425 | @@: |
4424 | @@: |
4426 | pop ebp esi ebp |
4425 | pop ebp esi ebp |
4427 | ret |
4426 | ret |
4428 | ;----------------------------------------------------------------------------- |
4427 | ;----------------------------------------------------------------------------- |
4429 | align 4 |
4428 | align 4 |
4430 | put_mono_image: |
4429 | put_mono_image: |
4431 | push ebp esi ebp |
4430 | push ebp esi ebp |
4432 | mov ebp, putimage_get1bpp |
4431 | mov ebp, putimage_get1bpp |
4433 | mov esi, putimage_init1bpp |
4432 | mov esi, putimage_init1bpp |
4434 | jmp sys_putimage_bpp |
4433 | jmp sys_putimage_bpp |
4435 | ;----------------------------------------------------------------------------- |
4434 | ;----------------------------------------------------------------------------- |
4436 | align 4 |
4435 | align 4 |
4437 | put_2bit_image: |
4436 | put_2bit_image: |
4438 | push ebp esi ebp |
4437 | push ebp esi ebp |
4439 | mov ebp, putimage_get2bpp |
4438 | mov ebp, putimage_get2bpp |
4440 | mov esi, putimage_init2bpp |
4439 | mov esi, putimage_init2bpp |
4441 | jmp sys_putimage_bpp |
4440 | jmp sys_putimage_bpp |
4442 | ;----------------------------------------------------------------------------- |
4441 | ;----------------------------------------------------------------------------- |
4443 | align 4 |
4442 | align 4 |
4444 | put_4bit_image: |
4443 | put_4bit_image: |
4445 | push ebp esi ebp |
4444 | push ebp esi ebp |
4446 | mov ebp, putimage_get4bpp |
4445 | mov ebp, putimage_get4bpp |
4447 | mov esi, putimage_init4bpp |
4446 | mov esi, putimage_init4bpp |
4448 | jmp sys_putimage_bpp |
4447 | jmp sys_putimage_bpp |
4449 | ;----------------------------------------------------------------------------- |
4448 | ;----------------------------------------------------------------------------- |
4450 | align 4 |
4449 | align 4 |
4451 | putimage_init24bpp: |
4450 | putimage_init24bpp: |
4452 | lea eax, [eax*3] |
4451 | lea eax, [eax*3] |
4453 | putimage_init8bpp: |
4452 | putimage_init8bpp: |
4454 | putimage_init9bpp: |
4453 | putimage_init9bpp: |
4455 | ret |
4454 | ret |
4456 | ;----------------------------------------------------------------------------- |
4455 | ;----------------------------------------------------------------------------- |
4457 | align 16 |
4456 | align 16 |
4458 | putimage_get24bpp: |
4457 | putimage_get24bpp: |
4459 | movzx eax, byte [esi+2] |
4458 | movzx eax, byte [esi+2] |
4460 | shl eax, 16 |
4459 | shl eax, 16 |
4461 | mov ax, [esi] |
4460 | mov ax, [esi] |
4462 | add esi, 3 |
4461 | add esi, 3 |
4463 | ret 4 |
4462 | ret 4 |
4464 | ;----------------------------------------------------------------------------- |
4463 | ;----------------------------------------------------------------------------- |
4465 | align 16 |
4464 | align 16 |
4466 | putimage_get8bpp: |
4465 | putimage_get8bpp: |
4467 | movzx eax, byte [esi] |
4466 | movzx eax, byte [esi] |
4468 | push edx |
4467 | push edx |
4469 | mov edx, [esp+8] |
4468 | mov edx, [esp+8] |
4470 | mov eax, [edx+eax*4] |
4469 | mov eax, [edx+eax*4] |
4471 | pop edx |
4470 | pop edx |
4472 | inc esi |
4471 | inc esi |
4473 | ret 4 |
4472 | ret 4 |
4474 | ;----------------------------------------------------------------------------- |
4473 | ;----------------------------------------------------------------------------- |
4475 | align 16 |
4474 | align 16 |
4476 | putimage_get9bpp: |
4475 | putimage_get9bpp: |
4477 | lodsb |
4476 | lodsb |
4478 | mov ah, al |
4477 | mov ah, al |
4479 | shl eax, 8 |
4478 | shl eax, 8 |
4480 | mov al, ah |
4479 | mov al, ah |
4481 | ret 4 |
4480 | ret 4 |
4482 | ;----------------------------------------------------------------------------- |
4481 | ;----------------------------------------------------------------------------- |
4483 | align 4 |
4482 | align 4 |
4484 | putimage_init1bpp: |
4483 | putimage_init1bpp: |
4485 | add eax, ecx |
4484 | add eax, ecx |
4486 | push ecx |
4485 | push ecx |
4487 | add eax, 7 |
4486 | add eax, 7 |
4488 | add ecx, 7 |
4487 | add ecx, 7 |
4489 | shr eax, 3 |
4488 | shr eax, 3 |
4490 | shr ecx, 3 |
4489 | shr ecx, 3 |
4491 | sub eax, ecx |
4490 | sub eax, ecx |
4492 | pop ecx |
4491 | pop ecx |
4493 | ret |
4492 | ret |
4494 | ;----------------------------------------------------------------------------- |
4493 | ;----------------------------------------------------------------------------- |
4495 | align 16 |
4494 | align 16 |
4496 | putimage_get1bpp: |
4495 | putimage_get1bpp: |
4497 | push edx |
4496 | push edx |
4498 | mov edx, [esp+8] |
4497 | mov edx, [esp+8] |
4499 | mov al, [edx] |
4498 | mov al, [edx] |
4500 | add al, al |
4499 | add al, al |
4501 | jnz @f |
4500 | jnz @f |
4502 | lodsb |
4501 | lodsb |
4503 | adc al, al |
4502 | adc al, al |
4504 | @@: |
4503 | @@: |
4505 | mov [edx], al |
4504 | mov [edx], al |
4506 | sbb eax, eax |
4505 | sbb eax, eax |
4507 | and eax, [edx+8] |
4506 | and eax, [edx+8] |
4508 | add eax, [edx+4] |
4507 | add eax, [edx+4] |
4509 | pop edx |
4508 | pop edx |
4510 | ret 4 |
4509 | ret 4 |
4511 | ;----------------------------------------------------------------------------- |
4510 | ;----------------------------------------------------------------------------- |
4512 | align 4 |
4511 | align 4 |
4513 | putimage_init2bpp: |
4512 | putimage_init2bpp: |
4514 | add eax, ecx |
4513 | add eax, ecx |
4515 | push ecx |
4514 | push ecx |
4516 | add ecx, 3 |
4515 | add ecx, 3 |
4517 | add eax, 3 |
4516 | add eax, 3 |
4518 | shr ecx, 2 |
4517 | shr ecx, 2 |
4519 | shr eax, 2 |
4518 | shr eax, 2 |
4520 | sub eax, ecx |
4519 | sub eax, ecx |
4521 | pop ecx |
4520 | pop ecx |
4522 | ret |
4521 | ret |
4523 | ;----------------------------------------------------------------------------- |
4522 | ;----------------------------------------------------------------------------- |
4524 | align 16 |
4523 | align 16 |
4525 | putimage_get2bpp: |
4524 | putimage_get2bpp: |
4526 | push edx |
4525 | push edx |
4527 | mov edx, [esp+8] |
4526 | mov edx, [esp+8] |
4528 | mov al, [edx] |
4527 | mov al, [edx] |
4529 | mov ah, al |
4528 | mov ah, al |
4530 | shr al, 6 |
4529 | shr al, 6 |
4531 | shl ah, 2 |
4530 | shl ah, 2 |
4532 | jnz .nonewbyte |
4531 | jnz .nonewbyte |
4533 | lodsb |
4532 | lodsb |
4534 | mov ah, al |
4533 | mov ah, al |
4535 | shr al, 6 |
4534 | shr al, 6 |
4536 | shl ah, 2 |
4535 | shl ah, 2 |
4537 | add ah, 1 |
4536 | add ah, 1 |
4538 | .nonewbyte: |
4537 | .nonewbyte: |
4539 | mov [edx], ah |
4538 | mov [edx], ah |
4540 | mov edx, [edx+4] |
4539 | mov edx, [edx+4] |
4541 | movzx eax, al |
4540 | movzx eax, al |
4542 | mov eax, [edx+eax*4] |
4541 | mov eax, [edx+eax*4] |
4543 | pop edx |
4542 | pop edx |
4544 | ret 4 |
4543 | ret 4 |
4545 | ;----------------------------------------------------------------------------- |
4544 | ;----------------------------------------------------------------------------- |
4546 | align 4 |
4545 | align 4 |
4547 | putimage_init4bpp: |
4546 | putimage_init4bpp: |
4548 | add eax, ecx |
4547 | add eax, ecx |
4549 | push ecx |
4548 | push ecx |
4550 | add ecx, 1 |
4549 | add ecx, 1 |
4551 | add eax, 1 |
4550 | add eax, 1 |
4552 | shr ecx, 1 |
4551 | shr ecx, 1 |
4553 | shr eax, 1 |
4552 | shr eax, 1 |
4554 | sub eax, ecx |
4553 | sub eax, ecx |
4555 | pop ecx |
4554 | pop ecx |
4556 | ret |
4555 | ret |
4557 | ;----------------------------------------------------------------------------- |
4556 | ;----------------------------------------------------------------------------- |
4558 | align 16 |
4557 | align 16 |
4559 | putimage_get4bpp: |
4558 | putimage_get4bpp: |
4560 | push edx |
4559 | push edx |
4561 | mov edx, [esp+8] |
4560 | mov edx, [esp+8] |
4562 | add byte [edx], 80h |
4561 | add byte [edx], 80h |
4563 | jc @f |
4562 | jc @f |
4564 | movzx eax, byte [edx+1] |
4563 | movzx eax, byte [edx+1] |
4565 | mov edx, [edx+4] |
4564 | mov edx, [edx+4] |
4566 | and eax, 0x0F |
4565 | and eax, 0x0F |
4567 | mov eax, [edx+eax*4] |
4566 | mov eax, [edx+eax*4] |
4568 | pop edx |
4567 | pop edx |
4569 | ret 4 |
4568 | ret 4 |
4570 | @@: |
4569 | @@: |
4571 | movzx eax, byte [esi] |
4570 | movzx eax, byte [esi] |
4572 | add esi, 1 |
4571 | add esi, 1 |
4573 | mov [edx+1], al |
4572 | mov [edx+1], al |
4574 | shr eax, 4 |
4573 | shr eax, 4 |
4575 | mov edx, [edx+4] |
4574 | mov edx, [edx+4] |
4576 | mov eax, [edx+eax*4] |
4575 | mov eax, [edx+eax*4] |
4577 | pop edx |
4576 | pop edx |
4578 | ret 4 |
4577 | ret 4 |
4579 | ;----------------------------------------------------------------------------- |
4578 | ;----------------------------------------------------------------------------- |
4580 | align 4 |
4579 | align 4 |
4581 | putimage_init32bpp: |
4580 | putimage_init32bpp: |
4582 | shl eax, 2 |
4581 | shl eax, 2 |
4583 | ret |
4582 | ret |
4584 | ;----------------------------------------------------------------------------- |
4583 | ;----------------------------------------------------------------------------- |
4585 | align 16 |
4584 | align 16 |
4586 | putimage_get32bpp: |
4585 | putimage_get32bpp: |
4587 | lodsd |
4586 | lodsd |
4588 | ret 4 |
4587 | ret 4 |
4589 | ;----------------------------------------------------------------------------- |
4588 | ;----------------------------------------------------------------------------- |
4590 | align 4 |
4589 | align 4 |
4591 | putimage_init15bpp: |
4590 | putimage_init15bpp: |
4592 | putimage_init16bpp: |
4591 | putimage_init16bpp: |
4593 | add eax, eax |
4592 | add eax, eax |
4594 | ret |
4593 | ret |
4595 | ;----------------------------------------------------------------------------- |
4594 | ;----------------------------------------------------------------------------- |
4596 | align 16 |
4595 | align 16 |
4597 | putimage_get15bpp: |
4596 | putimage_get15bpp: |
4598 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4597 | ; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000 |
4599 | push ecx edx |
4598 | push ecx edx |
4600 | movzx eax, word [esi] |
4599 | movzx eax, word [esi] |
4601 | add esi, 2 |
4600 | add esi, 2 |
4602 | mov ecx, eax |
4601 | mov ecx, eax |
4603 | mov edx, eax |
4602 | mov edx, eax |
4604 | and eax, 0x1F |
4603 | and eax, 0x1F |
4605 | and ecx, 0x1F shl 5 |
4604 | and ecx, 0x1F shl 5 |
4606 | and edx, 0x1F shl 10 |
4605 | and edx, 0x1F shl 10 |
4607 | shl eax, 3 |
4606 | shl eax, 3 |
4608 | shl ecx, 6 |
4607 | shl ecx, 6 |
4609 | shl edx, 9 |
4608 | shl edx, 9 |
4610 | or eax, ecx |
4609 | or eax, ecx |
4611 | or eax, edx |
4610 | or eax, edx |
4612 | pop edx ecx |
4611 | pop edx ecx |
4613 | ret 4 |
4612 | ret 4 |
4614 | ;----------------------------------------------------------------------------- |
4613 | ;----------------------------------------------------------------------------- |
4615 | align 16 |
4614 | align 16 |
4616 | putimage_get16bpp: |
4615 | putimage_get16bpp: |
4617 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4616 | ; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000 |
4618 | push ecx edx |
4617 | push ecx edx |
4619 | movzx eax, word [esi] |
4618 | movzx eax, word [esi] |
4620 | add esi, 2 |
4619 | add esi, 2 |
4621 | mov ecx, eax |
4620 | mov ecx, eax |
4622 | mov edx, eax |
4621 | mov edx, eax |
4623 | and eax, 0x1F |
4622 | and eax, 0x1F |
4624 | and ecx, 0x3F shl 5 |
4623 | and ecx, 0x3F shl 5 |
4625 | and edx, 0x1F shl 11 |
4624 | and edx, 0x1F shl 11 |
4626 | shl eax, 3 |
4625 | shl eax, 3 |
4627 | shl ecx, 5 |
4626 | shl ecx, 5 |
4628 | shl edx, 8 |
4627 | shl edx, 8 |
4629 | or eax, ecx |
4628 | or eax, ecx |
4630 | or eax, edx |
4629 | or eax, edx |
4631 | pop edx ecx |
4630 | pop edx ecx |
4632 | ret 4 |
4631 | ret 4 |
4633 | ;----------------------------------------------------------------------------- |
4632 | ;----------------------------------------------------------------------------- |
4634 | ;align 4 |
4633 | ;align 4 |
4635 | ; eax x beginning |
4634 | ; eax x beginning |
4636 | ; ebx y beginning |
4635 | ; ebx y beginning |
4637 | ; ecx x end |
4636 | ; ecx x end |
4638 | ; edx y end |
4637 | ; edx y end |
4639 | ; edi color |
4638 | ; edi color |
4640 | ;__sys_drawbar: |
4639 | ;__sys_drawbar: |
4641 | ; mov esi, [current_slot] |
4640 | ; mov esi, [current_slot] |
4642 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4641 | ; add eax, [esi+APPDATA.wnd_clientbox.left] |
4643 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4642 | ; add ecx, [esi+APPDATA.wnd_clientbox.left] |
4644 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4643 | ; add ebx, [esi+APPDATA.wnd_clientbox.top] |
4645 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4644 | ; add edx, [esi+APPDATA.wnd_clientbox.top] |
4646 | ;-------------------------------------- |
4645 | ;-------------------------------------- |
4647 | ;align 4 |
4646 | ;align 4 |
4648 | ;.forced: |
4647 | ;.forced: |
4649 | ; call vesa20_drawbar |
4648 | ; call vesa20_drawbar |
4650 | ; call [draw_pointer] |
4649 | ; call [draw_pointer] |
4651 | ; ret |
4650 | ; ret |
4652 | ;----------------------------------------------------------------------------- |
4651 | ;----------------------------------------------------------------------------- |
4653 | align 4 |
4652 | align 4 |
4654 | kb_write_wait_ack: |
4653 | kb_write_wait_ack: |
4655 | 4654 | ||
4656 | push ecx edx |
4655 | push ecx edx |
4657 | 4656 | ||
4658 | mov dl, al |
4657 | mov dl, al |
4659 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4658 | mov ecx, 0x1ffff; last 0xffff, new value in view of fast CPU's |
4660 | .wait_output_ready: |
4659 | .wait_output_ready: |
4661 | in al, 0x64 |
4660 | in al, 0x64 |
4662 | test al, 2 |
4661 | test al, 2 |
4663 | jz @f |
4662 | jz @f |
4664 | loop .wait_output_ready |
4663 | loop .wait_output_ready |
4665 | mov ah, 1 |
4664 | mov ah, 1 |
4666 | jmp .nothing |
4665 | jmp .nothing |
4667 | @@: |
4666 | @@: |
4668 | mov al, dl |
4667 | mov al, dl |
4669 | out 0x60, al |
4668 | out 0x60, al |
4670 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4669 | mov ecx, 0xfffff; last 0xffff, new value in view of fast CPU's |
4671 | .wait_ack: |
4670 | .wait_ack: |
4672 | in al, 0x64 |
4671 | in al, 0x64 |
4673 | test al, 1 |
4672 | test al, 1 |
4674 | jnz @f |
4673 | jnz @f |
4675 | loop .wait_ack |
4674 | loop .wait_ack |
4676 | mov ah, 1 |
4675 | mov ah, 1 |
4677 | jmp .nothing |
4676 | jmp .nothing |
4678 | @@: |
4677 | @@: |
4679 | in al, 0x60 |
4678 | in al, 0x60 |
4680 | xor ah, ah |
4679 | xor ah, ah |
4681 | 4680 | ||
4682 | .nothing: |
4681 | .nothing: |
4683 | pop edx ecx |
4682 | pop edx ecx |
4684 | 4683 | ||
4685 | ret |
4684 | ret |
4686 | ;----------------------------------------------------------------------------- |
4685 | ;----------------------------------------------------------------------------- |
4687 | 4686 | ||
4688 | setmouse: ; set mousepicture -pointer |
4687 | setmouse: ; set mousepicture -pointer |
4689 | ; ps2 mouse enable |
4688 | ; ps2 mouse enable |
4690 | 4689 | ||
4691 | ; mov [MOUSE_PICTURE], dword mousepointer |
4690 | ; mov [MOUSE_PICTURE], dword mousepointer |
4692 | 4691 | ||
4693 | cli |
4692 | cli |
4694 | 4693 | ||
4695 | ret |
4694 | ret |
4696 | 4695 | ||
4697 | if used _rdtsc |
4696 | if used _rdtsc |
4698 | _rdtsc: |
4697 | _rdtsc: |
4699 | bt [cpu_caps], CAPS_TSC |
4698 | bt [cpu_caps], CAPS_TSC |
4700 | jnc ret_rdtsc |
4699 | jnc ret_rdtsc |
4701 | rdtsc |
4700 | rdtsc |
4702 | ret |
4701 | ret |
4703 | ret_rdtsc: |
4702 | ret_rdtsc: |
4704 | mov edx, 0xffffffff |
4703 | mov edx, 0xffffffff |
4705 | mov eax, 0xffffffff |
4704 | mov eax, 0xffffffff |
4706 | ret |
4705 | ret |
4707 | end if |
4706 | end if |
4708 | 4707 | ||
4709 | sys_msg_board_str: |
4708 | sys_msg_board_str: |
4710 | 4709 | ||
4711 | pushad |
4710 | pushad |
4712 | @@: |
4711 | @@: |
4713 | cmp [esi], byte 0 |
4712 | cmp [esi], byte 0 |
4714 | je @f |
4713 | je @f |
4715 | mov ebx, 1 |
4714 | mov ebx, 1 |
4716 | movzx ecx, byte [esi] |
4715 | movzx ecx, byte [esi] |
4717 | call sys_msg_board |
4716 | call sys_msg_board |
4718 | inc esi |
4717 | inc esi |
4719 | jmp @b |
4718 | jmp @b |
4720 | @@: |
4719 | @@: |
4721 | popad |
4720 | popad |
4722 | ret |
4721 | ret |
4723 | 4722 | ||
4724 | sys_msg_board_byte: |
4723 | sys_msg_board_byte: |
4725 | ; in: al = byte to display |
4724 | ; in: al = byte to display |
4726 | ; out: nothing |
4725 | ; out: nothing |
4727 | ; destroys: nothing |
4726 | ; destroys: nothing |
4728 | pushad |
4727 | pushad |
4729 | mov ecx, 2 |
4728 | mov ecx, 2 |
4730 | shl eax, 24 |
4729 | shl eax, 24 |
4731 | jmp @f |
4730 | jmp @f |
4732 | 4731 | ||
4733 | sys_msg_board_word: |
4732 | sys_msg_board_word: |
4734 | ; in: ax = word to display |
4733 | ; in: ax = word to display |
4735 | ; out: nothing |
4734 | ; out: nothing |
4736 | ; destroys: nothing |
4735 | ; destroys: nothing |
4737 | pushad |
4736 | pushad |
4738 | mov ecx, 4 |
4737 | mov ecx, 4 |
4739 | shl eax, 16 |
4738 | shl eax, 16 |
4740 | jmp @f |
4739 | jmp @f |
4741 | 4740 | ||
4742 | sys_msg_board_dword: |
4741 | sys_msg_board_dword: |
4743 | ; in: eax = dword to display |
4742 | ; in: eax = dword to display |
4744 | ; out: nothing |
4743 | ; out: nothing |
4745 | ; destroys: nothing |
4744 | ; destroys: nothing |
4746 | pushad |
4745 | pushad |
4747 | mov ecx, 8 |
4746 | mov ecx, 8 |
4748 | @@: |
4747 | @@: |
4749 | push ecx |
4748 | push ecx |
4750 | rol eax, 4 |
4749 | rol eax, 4 |
4751 | push eax |
4750 | push eax |
4752 | and al, 0xF |
4751 | and al, 0xF |
4753 | cmp al, 10 |
4752 | cmp al, 10 |
4754 | sbb al, 69h |
4753 | sbb al, 69h |
4755 | das |
4754 | das |
4756 | mov cl, al |
4755 | mov cl, al |
4757 | xor ebx, ebx |
4756 | xor ebx, ebx |
4758 | inc ebx |
4757 | inc ebx |
4759 | call sys_msg_board |
4758 | call sys_msg_board |
4760 | pop eax |
4759 | pop eax |
4761 | pop ecx |
4760 | pop ecx |
4762 | loop @b |
4761 | loop @b |
4763 | popad |
4762 | popad |
4764 | ret |
4763 | ret |
4765 | 4764 | ||
4766 | msg_board_data_size = 65536 ; Must be power of two |
4765 | msg_board_data_size = 65536 ; Must be power of two |
4767 | 4766 | ||
4768 | uglobal |
4767 | uglobal |
4769 | msg_board_data rb msg_board_data_size |
4768 | msg_board_data rb msg_board_data_size |
4770 | msg_board_count dd ? |
4769 | msg_board_count dd ? |
4771 | endg |
4770 | endg |
4772 | 4771 | ||
4773 | iglobal |
4772 | iglobal |
4774 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
4773 | msg_board_pos dd 42*6*65536+10 ; for printing debug output on the screen |
4775 | endg |
4774 | endg |
4776 | 4775 | ||
4777 | sys_msg_board: |
4776 | sys_msg_board: |
4778 | ; ebx=1 -> write, cl = byte to write |
4777 | ; ebx=1 -> write, cl = byte to write |
4779 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
4778 | ; ebx=2 -> read, ecx=0 -> no data, ecx=1 -> data in al |
4780 | push eax ebx |
4779 | push eax ebx |
4781 | mov eax, ebx |
4780 | mov eax, ebx |
4782 | mov ebx, ecx |
4781 | mov ebx, ecx |
4783 | mov ecx, [msg_board_count] |
4782 | mov ecx, [msg_board_count] |
4784 | cmp eax, 1 |
4783 | cmp eax, 1 |
4785 | jne .read |
4784 | jne .read |
4786 | 4785 | ||
4787 | if defined debug_com_base |
4786 | if defined debug_com_base |
4788 | push dx ax |
4787 | push dx ax |
4789 | @@: ; wait for empty transmit register |
4788 | @@: ; wait for empty transmit register |
4790 | mov dx, debug_com_base+5 |
4789 | mov dx, debug_com_base+5 |
4791 | in al, dx |
4790 | in al, dx |
4792 | test al, 1 shl 5 |
4791 | test al, 1 shl 5 |
4793 | jz @r |
4792 | jz @r |
4794 | mov dx, debug_com_base ; Output the byte |
4793 | mov dx, debug_com_base ; Output the byte |
4795 | mov al, bl |
4794 | mov al, bl |
4796 | out dx, al |
4795 | out dx, al |
4797 | pop ax dx |
4796 | pop ax dx |
4798 | end if |
4797 | end if |
4799 | 4798 | ||
4800 | mov [msg_board_data+ecx], bl |
4799 | mov [msg_board_data+ecx], bl |
4801 | cmp byte [debug_direct_print], 1 |
4800 | cmp byte [debug_direct_print], 1 |
4802 | jnz .end |
4801 | jnz .end |
4803 | pusha |
4802 | pusha |
4804 | lea edx, [msg_board_data+ecx] |
4803 | lea edx, [msg_board_data+ecx] |
4805 | mov ecx, 0x40FFFFFF |
4804 | mov ecx, 0x40FFFFFF |
4806 | mov ebx, [msg_board_pos] |
4805 | mov ebx, [msg_board_pos] |
4807 | mov edi, 1 |
4806 | mov edi, 1 |
4808 | mov esi, 1 |
4807 | mov esi, 1 |
4809 | call dtext |
4808 | call dtext |
4810 | popa |
4809 | popa |
4811 | add word [msg_board_pos+2], 6 |
4810 | add word [msg_board_pos+2], 6 |
4812 | cmp word [msg_board_pos+2], 105*6 |
4811 | cmp word [msg_board_pos+2], 105*6 |
4813 | jnc @f |
4812 | jnc @f |
4814 | cmp bl, 10 |
4813 | cmp bl, 10 |
4815 | jnz .end |
4814 | jnz .end |
4816 | @@: |
4815 | @@: |
4817 | mov word [msg_board_pos+2], 42*6 |
4816 | mov word [msg_board_pos+2], 42*6 |
4818 | add word [msg_board_pos], 10 |
4817 | add word [msg_board_pos], 10 |
4819 | mov eax, [_display.height] |
4818 | mov eax, [_display.height] |
4820 | sub eax, 10 |
4819 | sub eax, 10 |
4821 | cmp ax, word [msg_board_pos] |
4820 | cmp ax, word [msg_board_pos] |
4822 | jnc @f |
4821 | jnc @f |
4823 | mov word [msg_board_pos], 10 |
4822 | mov word [msg_board_pos], 10 |
4824 | @@: |
4823 | @@: |
4825 | pusha |
4824 | pusha |
4826 | mov eax, [msg_board_pos] |
4825 | mov eax, [msg_board_pos] |
4827 | movzx ebx, ax |
4826 | movzx ebx, ax |
4828 | shr eax, 16 |
4827 | shr eax, 16 |
4829 | mov edx, 105*6 |
4828 | mov edx, 105*6 |
4830 | xor ecx, ecx |
4829 | xor ecx, ecx |
4831 | mov edi, 1 |
4830 | mov edi, 1 |
4832 | mov esi, 9 |
4831 | mov esi, 9 |
4833 | @@: |
4832 | @@: |
4834 | call hline |
4833 | call hline |
4835 | inc ebx |
4834 | inc ebx |
4836 | dec esi |
4835 | dec esi |
4837 | jnz @b |
4836 | jnz @b |
4838 | popa |
4837 | popa |
4839 | .end: |
4838 | .end: |
4840 | inc ecx |
4839 | inc ecx |
4841 | and ecx, msg_board_data_size - 1 |
4840 | and ecx, msg_board_data_size - 1 |
4842 | mov [msg_board_count], ecx |
4841 | mov [msg_board_count], ecx |
4843 | .ret: |
4842 | .ret: |
4844 | pop ebx eax |
4843 | pop ebx eax |
4845 | ret |
4844 | ret |
4846 | 4845 | ||
4847 | @@: |
4846 | @@: |
4848 | mov [esp+32], ecx |
4847 | mov [esp+32], ecx |
4849 | mov [esp+20], ecx |
4848 | mov [esp+20], ecx |
4850 | jmp .ret |
4849 | jmp .ret |
4851 | 4850 | ||
4852 | .read: |
4851 | .read: |
4853 | cmp eax, 2 |
4852 | cmp eax, 2 |
4854 | jne .ret |
4853 | jne .ret |
4855 | test ecx, ecx |
4854 | test ecx, ecx |
4856 | jz @b |
4855 | jz @b |
4857 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4856 | add esp, 8 ; returning data in ebx and eax, so no need to restore them |
4858 | mov eax, msg_board_data+1 |
4857 | mov eax, msg_board_data+1 |
4859 | mov ebx, msg_board_data |
4858 | mov ebx, msg_board_data |
4860 | movzx edx, byte [ebx] |
4859 | movzx edx, byte [ebx] |
4861 | call memmove |
4860 | call memmove |
4862 | dec [msg_board_count] |
4861 | dec [msg_board_count] |
4863 | mov [esp + 32], edx ;eax |
4862 | mov [esp + 32], edx ;eax |
4864 | mov [esp + 20], dword 1 |
4863 | mov [esp + 20], dword 1 |
4865 | ret |
4864 | ret |
4866 | 4865 | ||
4867 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4866 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4868 | ;; 66 sys function. ;; |
4867 | ;; 66 sys function. ;; |
4869 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4868 | ;; in eax=66,ebx in [0..5],ecx,edx ;; |
4870 | ;; out eax ;; |
4869 | ;; out eax ;; |
4871 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4870 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
4872 | iglobal |
4871 | iglobal |
4873 | align 4 |
4872 | align 4 |
4874 | f66call: |
4873 | f66call: |
4875 | dd sys_process_def.1 ; 1 = set keyboard mode |
4874 | dd sys_process_def.1 ; 1 = set keyboard mode |
4876 | dd sys_process_def.2 ; 2 = get keyboard mode |
4875 | dd sys_process_def.2 ; 2 = get keyboard mode |
4877 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4876 | dd sys_process_def.3 ; 3 = get keyboard ctrl, alt, shift |
4878 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4877 | dd sys_process_def.4 ; 4 = set system-wide hotkey |
4879 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4878 | dd sys_process_def.5 ; 5 = delete installed hotkey |
4880 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4879 | dd sys_process_def.6 ; 6 = disable input, work only hotkeys |
4881 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4880 | dd sys_process_def.7 ; 7 = enable input, opposition to f.66.6 |
4882 | endg |
4881 | endg |
4883 | ;----------------------------------------------------------------------------- |
4882 | ;----------------------------------------------------------------------------- |
4884 | align 4 |
4883 | align 4 |
4885 | sys_process_def: |
4884 | sys_process_def: |
4886 | dec ebx |
4885 | dec ebx |
4887 | cmp ebx, 7 |
4886 | cmp ebx, 7 |
4888 | jae .not_support ;if >=8 then or eax,-1 |
4887 | jae .not_support ;if >=8 then or eax,-1 |
4889 | 4888 | ||
4890 | mov edi, [CURRENT_TASK] |
4889 | mov edi, [CURRENT_TASK] |
4891 | jmp dword [f66call+ebx*4] |
4890 | jmp dword [f66call+ebx*4] |
4892 | 4891 | ||
4893 | .not_support: |
4892 | .not_support: |
4894 | or eax, -1 |
4893 | or eax, -1 |
4895 | ret |
4894 | ret |
4896 | ;----------------------------------------------------------------------------- |
4895 | ;----------------------------------------------------------------------------- |
4897 | align 4 |
4896 | align 4 |
4898 | .1: |
4897 | .1: |
4899 | shl edi, 8 |
4898 | shl edi, 8 |
4900 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4899 | mov [edi+SLOT_BASE + APPDATA.keyboard_mode], cl |
4901 | 4900 | ||
4902 | ret |
4901 | ret |
4903 | ;----------------------------------------------------------------------------- |
4902 | ;----------------------------------------------------------------------------- |
4904 | align 4 |
4903 | align 4 |
4905 | .2: ; 2 = get keyboard mode |
4904 | .2: ; 2 = get keyboard mode |
4906 | shl edi, 8 |
4905 | shl edi, 8 |
4907 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4906 | movzx eax, byte [SLOT_BASE+edi + APPDATA.keyboard_mode] |
4908 | mov [esp+32], eax |
4907 | mov [esp+32], eax |
4909 | ret |
4908 | ret |
4910 | ;----------------------------------------------------------------------------- |
4909 | ;----------------------------------------------------------------------------- |
4911 | align 4 |
4910 | align 4 |
4912 | .3: ;3 = get keyboard ctrl, alt, shift |
4911 | .3: ;3 = get keyboard ctrl, alt, shift |
4913 | mov eax, [kb_state] |
4912 | mov eax, [kb_state] |
4914 | mov [esp+32], eax |
4913 | mov [esp+32], eax |
4915 | ret |
4914 | ret |
4916 | ;----------------------------------------------------------------------------- |
4915 | ;----------------------------------------------------------------------------- |
4917 | align 4 |
4916 | align 4 |
4918 | .4: |
4917 | .4: |
4919 | mov eax, hotkey_list |
4918 | mov eax, hotkey_list |
4920 | @@: |
4919 | @@: |
4921 | cmp dword [eax+8], 0 |
4920 | cmp dword [eax+8], 0 |
4922 | jz .found_free |
4921 | jz .found_free |
4923 | add eax, 16 |
4922 | add eax, 16 |
4924 | cmp eax, hotkey_list+16*256 |
4923 | cmp eax, hotkey_list+16*256 |
4925 | jb @b |
4924 | jb @b |
4926 | mov dword [esp+32], 1 |
4925 | mov dword [esp+32], 1 |
4927 | ret |
4926 | ret |
4928 | .found_free: |
4927 | .found_free: |
4929 | mov [eax+8], edi |
4928 | mov [eax+8], edi |
4930 | mov [eax+4], edx |
4929 | mov [eax+4], edx |
4931 | movzx ecx, cl |
4930 | movzx ecx, cl |
4932 | lea ecx, [hotkey_scancodes+ecx*4] |
4931 | lea ecx, [hotkey_scancodes+ecx*4] |
4933 | mov edx, [ecx] |
4932 | mov edx, [ecx] |
4934 | mov [eax], edx |
4933 | mov [eax], edx |
4935 | mov [ecx], eax |
4934 | mov [ecx], eax |
4936 | mov [eax+12], ecx |
4935 | mov [eax+12], ecx |
4937 | test edx, edx |
4936 | test edx, edx |
4938 | jz @f |
4937 | jz @f |
4939 | mov [edx+12], eax |
4938 | mov [edx+12], eax |
4940 | @@: |
4939 | @@: |
4941 | and dword [esp+32], 0 |
4940 | and dword [esp+32], 0 |
4942 | ret |
4941 | ret |
4943 | ;----------------------------------------------------------------------------- |
4942 | ;----------------------------------------------------------------------------- |
4944 | align 4 |
4943 | align 4 |
4945 | .5: |
4944 | .5: |
4946 | movzx ebx, cl |
4945 | movzx ebx, cl |
4947 | lea ebx, [hotkey_scancodes+ebx*4] |
4946 | lea ebx, [hotkey_scancodes+ebx*4] |
4948 | mov eax, [ebx] |
4947 | mov eax, [ebx] |
4949 | .scan: |
4948 | .scan: |
4950 | test eax, eax |
4949 | test eax, eax |
4951 | jz .notfound |
4950 | jz .notfound |
4952 | cmp [eax+8], edi |
4951 | cmp [eax+8], edi |
4953 | jnz .next |
4952 | jnz .next |
4954 | cmp [eax+4], edx |
4953 | cmp [eax+4], edx |
4955 | jz .found |
4954 | jz .found |
4956 | .next: |
4955 | .next: |
4957 | mov eax, [eax] |
4956 | mov eax, [eax] |
4958 | jmp .scan |
4957 | jmp .scan |
4959 | .notfound: |
4958 | .notfound: |
4960 | mov dword [esp+32], 1 |
4959 | mov dword [esp+32], 1 |
4961 | ret |
4960 | ret |
4962 | .found: |
4961 | .found: |
4963 | mov ecx, [eax] |
4962 | mov ecx, [eax] |
4964 | jecxz @f |
4963 | jecxz @f |
4965 | mov edx, [eax+12] |
4964 | mov edx, [eax+12] |
4966 | mov [ecx+12], edx |
4965 | mov [ecx+12], edx |
4967 | @@: |
4966 | @@: |
4968 | mov ecx, [eax+12] |
4967 | mov ecx, [eax+12] |
4969 | mov edx, [eax] |
4968 | mov edx, [eax] |
4970 | mov [ecx], edx |
4969 | mov [ecx], edx |
4971 | xor edx, edx |
4970 | xor edx, edx |
4972 | mov [eax+4], edx |
4971 | mov [eax+4], edx |
4973 | mov [eax+8], edx |
4972 | mov [eax+8], edx |
4974 | mov [eax+12], edx |
4973 | mov [eax+12], edx |
4975 | mov [eax], edx |
4974 | mov [eax], edx |
4976 | mov [esp+32], edx |
4975 | mov [esp+32], edx |
4977 | ret |
4976 | ret |
4978 | ;----------------------------------------------------------------------------- |
4977 | ;----------------------------------------------------------------------------- |
4979 | align 4 |
4978 | align 4 |
4980 | .6: |
4979 | .6: |
4981 | pushfd |
4980 | pushfd |
4982 | cli |
4981 | cli |
4983 | mov eax, [PID_lock_input] |
4982 | mov eax, [PID_lock_input] |
4984 | test eax, eax |
4983 | test eax, eax |
4985 | jnz @f |
4984 | jnz @f |
4986 | ; get current PID |
4985 | ; get current PID |
4987 | mov eax, [CURRENT_TASK] |
4986 | mov eax, [CURRENT_TASK] |
4988 | shl eax, 5 |
4987 | shl eax, 5 |
4989 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4988 | mov eax, [eax+CURRENT_TASK+TASKDATA.pid] |
4990 | ; set current PID for lock input |
4989 | ; set current PID for lock input |
4991 | mov [PID_lock_input], eax |
4990 | mov [PID_lock_input], eax |
4992 | @@: |
4991 | @@: |
4993 | popfd |
4992 | popfd |
4994 | ret |
4993 | ret |
4995 | ;----------------------------------------------------------------------------- |
4994 | ;----------------------------------------------------------------------------- |
4996 | align 4 |
4995 | align 4 |
4997 | .7: |
4996 | .7: |
4998 | mov eax, [PID_lock_input] |
4997 | mov eax, [PID_lock_input] |
4999 | test eax, eax |
4998 | test eax, eax |
5000 | jz @f |
4999 | jz @f |
5001 | ; get current PID |
5000 | ; get current PID |
5002 | mov ebx, [CURRENT_TASK] |
5001 | mov ebx, [CURRENT_TASK] |
5003 | shl ebx, 5 |
5002 | shl ebx, 5 |
5004 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5003 | mov ebx, [ebx+CURRENT_TASK+TASKDATA.pid] |
5005 | ; compare current lock input with current PID |
5004 | ; compare current lock input with current PID |
5006 | cmp ebx, eax |
5005 | cmp ebx, eax |
5007 | jne @f |
5006 | jne @f |
5008 | 5007 | ||
5009 | xor eax, eax |
5008 | xor eax, eax |
5010 | mov [PID_lock_input], eax |
5009 | mov [PID_lock_input], eax |
5011 | @@: |
5010 | @@: |
5012 | ret |
5011 | ret |
5013 | ;----------------------------------------------------------------------------- |
5012 | ;----------------------------------------------------------------------------- |
5014 | uglobal |
5013 | uglobal |
5015 | PID_lock_input dd 0x0 |
5014 | PID_lock_input dd 0x0 |
5016 | endg |
5015 | endg |
5017 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5016 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5018 | ;; 61 sys function. ;; |
5017 | ;; 61 sys function. ;; |
5019 | ;; in eax=61,ebx in [1..3] ;; |
5018 | ;; in eax=61,ebx in [1..3] ;; |
5020 | ;; out eax ;; |
5019 | ;; out eax ;; |
5021 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5020 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5022 | iglobal |
5021 | iglobal |
5023 | align 4 |
5022 | align 4 |
5024 | f61call: |
5023 | f61call: |
5025 | dd sys_gs.1 ; resolution |
5024 | dd sys_gs.1 ; resolution |
5026 | dd sys_gs.2 ; bits per pixel |
5025 | dd sys_gs.2 ; bits per pixel |
5027 | dd sys_gs.3 ; bytes per scanline |
5026 | dd sys_gs.3 ; bytes per scanline |
5028 | endg |
5027 | endg |
5029 | 5028 | ||
5030 | 5029 | ||
5031 | align 4 |
5030 | align 4 |
5032 | 5031 | ||
5033 | sys_gs: ; direct screen access |
5032 | sys_gs: ; direct screen access |
5034 | dec ebx |
5033 | dec ebx |
5035 | cmp ebx, 2 |
5034 | cmp ebx, 2 |
5036 | ja .not_support |
5035 | ja .not_support |
5037 | jmp dword [f61call+ebx*4] |
5036 | jmp dword [f61call+ebx*4] |
5038 | .not_support: |
5037 | .not_support: |
5039 | or [esp+32], dword -1 |
5038 | or [esp+32], dword -1 |
5040 | ret |
5039 | ret |
5041 | 5040 | ||
5042 | 5041 | ||
5043 | .1: ; resolution |
5042 | .1: ; resolution |
5044 | mov eax, [_display.width] |
5043 | mov eax, [_display.width] |
5045 | shl eax, 16 |
5044 | shl eax, 16 |
5046 | mov ax, word [_display.height] |
5045 | mov ax, word [_display.height] |
5047 | mov [esp+32], eax |
5046 | mov [esp+32], eax |
5048 | ret |
5047 | ret |
5049 | .2: ; bits per pixel |
5048 | .2: ; bits per pixel |
5050 | mov eax, [_display.bits_per_pixel] |
5049 | mov eax, [_display.bits_per_pixel] |
5051 | mov [esp+32], eax |
5050 | mov [esp+32], eax |
5052 | ret |
5051 | ret |
5053 | .3: ; bytes per scanline |
5052 | .3: ; bytes per scanline |
5054 | mov eax, [_display.lfb_pitch] |
5053 | mov eax, [_display.lfb_pitch] |
5055 | mov [esp+32], eax |
5054 | mov [esp+32], eax |
5056 | ret |
5055 | ret |
5057 | 5056 | ||
5058 | align 4 ; system functions |
5057 | align 4 ; system functions |
5059 | 5058 | ||
5060 | syscall_setpixel: ; SetPixel |
5059 | syscall_setpixel: ; SetPixel |
5061 | 5060 | ||
5062 | mov eax, ebx |
5061 | mov eax, ebx |
5063 | mov ebx, ecx |
5062 | mov ebx, ecx |
5064 | mov ecx, edx |
5063 | mov ecx, edx |
5065 | mov edx, [TASK_BASE] |
5064 | mov edx, [TASK_BASE] |
5066 | add eax, [edx-twdw+WDATA.box.left] |
5065 | add eax, [edx-twdw+WDATA.box.left] |
5067 | add ebx, [edx-twdw+WDATA.box.top] |
5066 | add ebx, [edx-twdw+WDATA.box.top] |
5068 | mov edi, [current_slot] |
5067 | mov edi, [current_slot] |
5069 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5068 | add eax, [edi+APPDATA.wnd_clientbox.left] |
5070 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5069 | add ebx, [edi+APPDATA.wnd_clientbox.top] |
5071 | xor edi, edi ; no force |
5070 | xor edi, edi ; no force |
5072 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5071 | and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
5073 | ; jmp [putpixel] |
5072 | ; jmp [putpixel] |
5074 | jmp __sys_putpixel |
5073 | jmp __sys_putpixel |
5075 | 5074 | ||
5076 | align 4 |
5075 | align 4 |
5077 | 5076 | ||
5078 | syscall_writetext: ; WriteText |
5077 | syscall_writetext: ; WriteText |
5079 | 5078 | ||
5080 | mov eax, [TASK_BASE] |
5079 | mov eax, [TASK_BASE] |
5081 | mov ebp, [eax-twdw+WDATA.box.left] |
5080 | mov ebp, [eax-twdw+WDATA.box.left] |
5082 | push esi |
5081 | push esi |
5083 | mov esi, [current_slot] |
5082 | mov esi, [current_slot] |
5084 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5083 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5085 | shl ebp, 16 |
5084 | shl ebp, 16 |
5086 | add ebp, [eax-twdw+WDATA.box.top] |
5085 | add ebp, [eax-twdw+WDATA.box.top] |
5087 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5086 | add bp, word[esi+APPDATA.wnd_clientbox.top] |
5088 | pop esi |
5087 | pop esi |
5089 | test ecx, 0x08000000 ; redirect the output to the user area |
5088 | test ecx, 0x08000000 ; redirect the output to the user area |
5090 | jnz @f |
5089 | jnz @f |
5091 | add ebx, ebp |
5090 | add ebx, ebp |
5092 | align 4 |
5091 | align 4 |
5093 | @@: |
5092 | @@: |
5094 | mov eax, edi |
5093 | mov eax, edi |
5095 | test ecx, 0x08000000 ; redirect the output to the user area |
5094 | test ecx, 0x08000000 ; redirect the output to the user area |
5096 | jnz dtext |
5095 | jnz dtext |
5097 | xor edi, edi |
5096 | xor edi, edi |
5098 | jmp dtext |
5097 | jmp dtext |
5099 | 5098 | ||
5100 | align 4 |
5099 | align 4 |
5101 | 5100 | ||
5102 | syscall_drawrect: ; DrawRect |
5101 | syscall_drawrect: ; DrawRect |
5103 | 5102 | ||
5104 | mov edi, edx ; color + gradient |
5103 | mov edi, edx ; color + gradient |
5105 | and edi, 0x80FFFFFF |
5104 | and edi, 0x80FFFFFF |
5106 | test bx, bx ; x.size |
5105 | test bx, bx ; x.size |
5107 | je .drectr |
5106 | je .drectr |
5108 | test cx, cx ; y.size |
5107 | test cx, cx ; y.size |
5109 | je .drectr |
5108 | je .drectr |
5110 | 5109 | ||
5111 | mov eax, ebx ; bad idea |
5110 | mov eax, ebx ; bad idea |
5112 | mov ebx, ecx |
5111 | mov ebx, ecx |
5113 | 5112 | ||
5114 | movzx ecx, ax ; ecx - x.size |
5113 | movzx ecx, ax ; ecx - x.size |
5115 | shr eax, 16 ; eax - x.coord |
5114 | shr eax, 16 ; eax - x.coord |
5116 | movzx edx, bx ; edx - y.size |
5115 | movzx edx, bx ; edx - y.size |
5117 | shr ebx, 16 ; ebx - y.coord |
5116 | shr ebx, 16 ; ebx - y.coord |
5118 | mov esi, [current_slot] |
5117 | mov esi, [current_slot] |
5119 | 5118 | ||
5120 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5119 | add eax, [esi + APPDATA.wnd_clientbox.left] |
5121 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5120 | add ebx, [esi + APPDATA.wnd_clientbox.top] |
5122 | add ecx, eax |
5121 | add ecx, eax |
5123 | add edx, ebx |
5122 | add edx, ebx |
5124 | ; jmp [drawbar] |
5123 | ; jmp [drawbar] |
5125 | jmp vesa20_drawbar |
5124 | jmp vesa20_drawbar |
5126 | .drectr: |
5125 | .drectr: |
5127 | ret |
5126 | ret |
5128 | 5127 | ||
5129 | align 4 |
5128 | align 4 |
5130 | syscall_getscreensize: ; GetScreenSize |
5129 | syscall_getscreensize: ; GetScreenSize |
5131 | mov ax, word [_display.width] |
5130 | mov ax, word [_display.width] |
5132 | dec ax |
5131 | dec ax |
5133 | shl eax, 16 |
5132 | shl eax, 16 |
5134 | mov ax, word [_display.height] |
5133 | mov ax, word [_display.height] |
5135 | dec ax |
5134 | dec ax |
5136 | mov [esp + 32], eax |
5135 | mov [esp + 32], eax |
5137 | ret |
5136 | ret |
5138 | ;----------------------------------------------------------------------------- |
5137 | ;----------------------------------------------------------------------------- |
5139 | align 4 |
5138 | align 4 |
5140 | syscall_cdaudio: |
5139 | syscall_cdaudio: |
5141 | ; ECX - position of CD/DVD-drive |
5140 | ; ECX - position of CD/DVD-drive |
5142 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5141 | ; from 0=Primary Master to 3=Secondary Slave for first IDE contr. |
5143 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5142 | ; from 4=Primary Master to 7=Secondary Slave for second IDE contr. |
5144 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5143 | ; from 8=Primary Master to 11=Secondary Slave for third IDE contr. |
5145 | cmp ecx, 11 |
5144 | cmp ecx, 11 |
5146 | ja .exit |
5145 | ja .exit |
5147 | 5146 | ||
5148 | mov eax, ecx |
5147 | mov eax, ecx |
5149 | shr eax, 2 |
5148 | shr eax, 2 |
5150 | lea eax, [eax*5] |
5149 | lea eax, [eax*5] |
5151 | mov al, [eax+DRIVE_DATA+1] |
5150 | mov al, [eax+DRIVE_DATA+1] |
5152 | 5151 | ||
5153 | push ecx ebx |
5152 | push ecx ebx |
5154 | mov ebx, ecx |
5153 | mov ebx, ecx |
5155 | and ebx, 11b |
5154 | and ebx, 11b |
5156 | shl ebx, 1 |
5155 | shl ebx, 1 |
5157 | mov cl, 6 |
5156 | mov cl, 6 |
5158 | sub cl, bl |
5157 | sub cl, bl |
5159 | shr al, cl |
5158 | shr al, cl |
5160 | test al, 2 ; it's not an ATAPI device |
5159 | test al, 2 ; it's not an ATAPI device |
5161 | pop ebx ecx |
5160 | pop ebx ecx |
5162 | 5161 | ||
5163 | jz .exit |
5162 | jz .exit |
5164 | 5163 | ||
5165 | cmp ebx, 4 |
5164 | cmp ebx, 4 |
5166 | je .eject |
5165 | je .eject |
5167 | 5166 | ||
5168 | cmp ebx, 5 |
5167 | cmp ebx, 5 |
5169 | je .load |
5168 | je .load |
5170 | ;-------------------------------------- |
5169 | ;-------------------------------------- |
5171 | .exit: |
5170 | .exit: |
5172 | ret |
5171 | ret |
5173 | ;-------------------------------------- |
5172 | ;-------------------------------------- |
5174 | .load: |
5173 | .load: |
5175 | call .reserve |
5174 | call .reserve |
5176 | call LoadMedium |
5175 | call LoadMedium |
5177 | jmp .free |
5176 | jmp .free |
5178 | ;-------------------------------------- |
5177 | ;-------------------------------------- |
5179 | .eject: |
5178 | .eject: |
5180 | call .reserve |
5179 | call .reserve |
5181 | call clear_CD_cache |
5180 | call clear_CD_cache |
5182 | call allow_medium_removal |
5181 | call allow_medium_removal |
5183 | call EjectMedium |
5182 | call EjectMedium |
5184 | jmp .free |
5183 | jmp .free |
5185 | ;-------------------------------------- |
5184 | ;-------------------------------------- |
5186 | .reserve: |
5185 | .reserve: |
5187 | call reserve_cd |
5186 | call reserve_cd |
5188 | 5187 | ||
5189 | mov ebx, ecx |
5188 | mov ebx, ecx |
5190 | inc ebx |
5189 | inc ebx |
5191 | mov [cdpos], ebx |
5190 | mov [cdpos], ebx |
5192 | 5191 | ||
5193 | mov eax, ecx |
5192 | mov eax, ecx |
5194 | shr eax, 1 |
5193 | shr eax, 1 |
5195 | and eax, 1 |
5194 | and eax, 1 |
5196 | inc eax |
5195 | inc eax |
5197 | mov [ChannelNumber], al |
5196 | mov [ChannelNumber], al |
5198 | mov eax, ecx |
5197 | mov eax, ecx |
5199 | and eax, 1 |
5198 | and eax, 1 |
5200 | mov [DiskNumber], al |
5199 | mov [DiskNumber], al |
5201 | call reserve_cd_channel |
5200 | call reserve_cd_channel |
5202 | ret |
5201 | ret |
5203 | ;-------------------------------------- |
5202 | ;-------------------------------------- |
5204 | .free: |
5203 | .free: |
5205 | call free_cd_channel |
5204 | call free_cd_channel |
5206 | and [cd_status], 0 |
5205 | and [cd_status], 0 |
5207 | ret |
5206 | ret |
5208 | ;----------------------------------------------------------------------------- |
5207 | ;----------------------------------------------------------------------------- |
5209 | align 4 |
5208 | align 4 |
5210 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5209 | syscall_getpixel_WinMap: ; GetPixel WinMap |
5211 | cmp ebx, [_display.width] |
5210 | cmp ebx, [_display.width] |
5212 | jb @f |
5211 | jb @f |
5213 | cmp ecx, [_display.height] |
5212 | cmp ecx, [_display.height] |
5214 | jb @f |
5213 | jb @f |
5215 | xor eax, eax |
5214 | xor eax, eax |
5216 | jmp .store |
5215 | jmp .store |
5217 | ;-------------------------------------- |
5216 | ;-------------------------------------- |
5218 | align 4 |
5217 | align 4 |
5219 | @@: |
5218 | @@: |
5220 | mov eax, [d_width_calc_area + ecx*4] |
5219 | mov eax, [d_width_calc_area + ecx*4] |
5221 | add eax, [_display.win_map] |
5220 | add eax, [_display.win_map] |
5222 | movzx eax, byte[eax+ebx] ; get value for current point |
5221 | movzx eax, byte[eax+ebx] ; get value for current point |
5223 | ;-------------------------------------- |
5222 | ;-------------------------------------- |
5224 | align 4 |
5223 | align 4 |
5225 | .store: |
5224 | .store: |
5226 | mov [esp + 32], eax |
5225 | mov [esp + 32], eax |
5227 | ret |
5226 | ret |
5228 | ;----------------------------------------------------------------------------- |
5227 | ;----------------------------------------------------------------------------- |
5229 | align 4 |
5228 | align 4 |
5230 | syscall_getpixel: ; GetPixel |
5229 | syscall_getpixel: ; GetPixel |
5231 | mov ecx, [_display.width] |
5230 | mov ecx, [_display.width] |
5232 | xor edx, edx |
5231 | xor edx, edx |
5233 | mov eax, ebx |
5232 | mov eax, ebx |
5234 | div ecx |
5233 | div ecx |
5235 | mov ebx, edx |
5234 | mov ebx, edx |
5236 | xchg eax, ebx |
5235 | xchg eax, ebx |
5237 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5236 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5238 | call dword [GETPIXEL]; eax - x, ebx - y |
5237 | call dword [GETPIXEL]; eax - x, ebx - y |
5239 | mov [esp + 32], ecx |
5238 | mov [esp + 32], ecx |
5240 | ret |
5239 | ret |
5241 | ;----------------------------------------------------------------------------- |
5240 | ;----------------------------------------------------------------------------- |
5242 | align 4 |
5241 | align 4 |
5243 | syscall_getarea: |
5242 | syscall_getarea: |
5244 | ;eax = 36 |
5243 | ;eax = 36 |
5245 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5244 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5246 | ;ecx = [size x]*65536 + [size y] |
5245 | ;ecx = [size x]*65536 + [size y] |
5247 | ;edx = [start x]*65536 + [start y] |
5246 | ;edx = [start x]*65536 + [start y] |
5248 | pushad |
5247 | pushad |
5249 | mov edi, ebx |
5248 | mov edi, ebx |
5250 | mov eax, edx |
5249 | mov eax, edx |
5251 | shr eax, 16 |
5250 | shr eax, 16 |
5252 | mov ebx, edx |
5251 | mov ebx, edx |
5253 | and ebx, 0xffff |
5252 | and ebx, 0xffff |
5254 | dec eax |
5253 | dec eax |
5255 | dec ebx |
5254 | dec ebx |
5256 | ; eax - x, ebx - y |
5255 | ; eax - x, ebx - y |
5257 | mov edx, ecx |
5256 | mov edx, ecx |
5258 | 5257 | ||
5259 | shr ecx, 16 |
5258 | shr ecx, 16 |
5260 | and edx, 0xffff |
5259 | and edx, 0xffff |
5261 | mov esi, ecx |
5260 | mov esi, ecx |
5262 | ; ecx - size x, edx - size y |
5261 | ; ecx - size x, edx - size y |
5263 | 5262 | ||
5264 | mov ebp, edx |
5263 | mov ebp, edx |
5265 | dec ebp |
5264 | dec ebp |
5266 | lea ebp, [ebp*3] |
5265 | lea ebp, [ebp*3] |
5267 | 5266 | ||
5268 | imul ebp, esi |
5267 | imul ebp, esi |
5269 | 5268 | ||
5270 | mov esi, ecx |
5269 | mov esi, ecx |
5271 | dec esi |
5270 | dec esi |
5272 | lea esi, [esi*3] |
5271 | lea esi, [esi*3] |
5273 | 5272 | ||
5274 | add ebp, esi |
5273 | add ebp, esi |
5275 | add ebp, edi |
5274 | add ebp, edi |
5276 | 5275 | ||
5277 | add ebx, edx |
5276 | add ebx, edx |
5278 | ;-------------------------------------- |
5277 | ;-------------------------------------- |
5279 | align 4 |
5278 | align 4 |
5280 | .start_y: |
5279 | .start_y: |
5281 | push ecx edx |
5280 | push ecx edx |
5282 | ;-------------------------------------- |
5281 | ;-------------------------------------- |
5283 | align 4 |
5282 | align 4 |
5284 | .start_x: |
5283 | .start_x: |
5285 | push eax ebx ecx |
5284 | push eax ebx ecx |
5286 | add eax, ecx |
5285 | add eax, ecx |
5287 | 5286 | ||
5288 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5287 | and ecx, 0xFBFFFFFF ;negate 0x04000000 use mouseunder area |
5289 | call dword [GETPIXEL]; eax - x, ebx - y |
5288 | call dword [GETPIXEL]; eax - x, ebx - y |
5290 | 5289 | ||
5291 | mov [ebp], cx |
5290 | mov [ebp], cx |
5292 | shr ecx, 16 |
5291 | shr ecx, 16 |
5293 | mov [ebp+2], cl |
5292 | mov [ebp+2], cl |
5294 | 5293 | ||
5295 | pop ecx ebx eax |
5294 | pop ecx ebx eax |
5296 | sub ebp, 3 |
5295 | sub ebp, 3 |
5297 | dec ecx |
5296 | dec ecx |
5298 | jnz .start_x |
5297 | jnz .start_x |
5299 | pop edx ecx |
5298 | pop edx ecx |
5300 | dec ebx |
5299 | dec ebx |
5301 | dec edx |
5300 | dec edx |
5302 | jnz .start_y |
5301 | jnz .start_y |
5303 | popad |
5302 | popad |
5304 | ret |
5303 | ret |
5305 | ;----------------------------------------------------------------------------- |
5304 | ;----------------------------------------------------------------------------- |
5306 | align 4 |
5305 | align 4 |
5307 | syscall_putarea_backgr: |
5306 | syscall_putarea_backgr: |
5308 | ;eax = 25 |
5307 | ;eax = 25 |
5309 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5308 | ;ebx = pointer to bufer for img BBGGRRBBGGRR... |
5310 | ;ecx = [size x]*65536 + [size y] |
5309 | ;ecx = [size x]*65536 + [size y] |
5311 | ;edx = [start x]*65536 + [start y] |
5310 | ;edx = [start x]*65536 + [start y] |
5312 | pushad |
5311 | pushad |
5313 | mov edi, ebx |
5312 | mov edi, ebx |
5314 | mov eax, edx |
5313 | mov eax, edx |
5315 | shr eax, 16 |
5314 | shr eax, 16 |
5316 | mov ebx, edx |
5315 | mov ebx, edx |
5317 | and ebx, 0xffff |
5316 | and ebx, 0xffff |
5318 | dec eax |
5317 | dec eax |
5319 | dec ebx |
5318 | dec ebx |
5320 | ; eax - x, ebx - y |
5319 | ; eax - x, ebx - y |
5321 | mov edx, ecx |
5320 | mov edx, ecx |
5322 | shr ecx, 16 |
5321 | shr ecx, 16 |
5323 | and edx, 0xffff |
5322 | and edx, 0xffff |
5324 | mov esi, ecx |
5323 | mov esi, ecx |
5325 | ; ecx - size x, edx - size y |
5324 | ; ecx - size x, edx - size y |
5326 | mov ebp, edx |
5325 | mov ebp, edx |
5327 | dec ebp |
5326 | dec ebp |
5328 | shl ebp, 2 |
5327 | shl ebp, 2 |
5329 | 5328 | ||
5330 | imul ebp, esi |
5329 | imul ebp, esi |
5331 | 5330 | ||
5332 | mov esi, ecx |
5331 | mov esi, ecx |
5333 | dec esi |
5332 | dec esi |
5334 | shl esi, 2 |
5333 | shl esi, 2 |
5335 | 5334 | ||
5336 | add ebp, esi |
5335 | add ebp, esi |
5337 | add ebp, edi |
5336 | add ebp, edi |
5338 | 5337 | ||
5339 | add ebx, edx |
5338 | add ebx, edx |
5340 | ;-------------------------------------- |
5339 | ;-------------------------------------- |
5341 | align 4 |
5340 | align 4 |
5342 | .start_y: |
5341 | .start_y: |
5343 | push ecx edx |
5342 | push ecx edx |
5344 | ;-------------------------------------- |
5343 | ;-------------------------------------- |
5345 | align 4 |
5344 | align 4 |
5346 | .start_x: |
5345 | .start_x: |
5347 | push eax ecx |
5346 | push eax ecx |
5348 | add eax, ecx |
5347 | add eax, ecx |
5349 | 5348 | ||
5350 | mov ecx, [ebp] |
5349 | mov ecx, [ebp] |
5351 | rol ecx, 8 |
5350 | rol ecx, 8 |
5352 | test cl, cl ; transparensy = 0 |
5351 | test cl, cl ; transparensy = 0 |
5353 | jz .no_put |
5352 | jz .no_put |
5354 | 5353 | ||
5355 | xor cl, cl |
5354 | xor cl, cl |
5356 | ror ecx, 8 |
5355 | ror ecx, 8 |
5357 | 5356 | ||
5358 | pushad |
5357 | pushad |
5359 | mov edx, [d_width_calc_area + ebx*4] |
5358 | mov edx, [d_width_calc_area + ebx*4] |
5360 | add edx, [_display.win_map] |
5359 | add edx, [_display.win_map] |
5361 | movzx edx, byte [eax+edx] |
5360 | movzx edx, byte [eax+edx] |
5362 | cmp dl, byte 1 |
5361 | cmp dl, byte 1 |
5363 | jne @f |
5362 | jne @f |
5364 | 5363 | ||
5365 | call dword [PUTPIXEL]; eax - x, ebx - y |
5364 | call dword [PUTPIXEL]; eax - x, ebx - y |
5366 | ;-------------------------------------- |
5365 | ;-------------------------------------- |
5367 | align 4 |
5366 | align 4 |
5368 | @@: |
5367 | @@: |
5369 | popad |
5368 | popad |
5370 | ;-------------------------------------- |
5369 | ;-------------------------------------- |
5371 | align 4 |
5370 | align 4 |
5372 | .no_put: |
5371 | .no_put: |
5373 | pop ecx eax |
5372 | pop ecx eax |
5374 | 5373 | ||
5375 | sub ebp, 4 |
5374 | sub ebp, 4 |
5376 | dec ecx |
5375 | dec ecx |
5377 | jnz .start_x |
5376 | jnz .start_x |
5378 | 5377 | ||
5379 | pop edx ecx |
5378 | pop edx ecx |
5380 | dec ebx |
5379 | dec ebx |
5381 | dec edx |
5380 | dec edx |
5382 | jnz .start_y |
5381 | jnz .start_y |
5383 | 5382 | ||
5384 | popad |
5383 | popad |
5385 | ret |
5384 | ret |
5386 | ;----------------------------------------------------------------------------- |
5385 | ;----------------------------------------------------------------------------- |
5387 | align 4 |
5386 | align 4 |
5388 | syscall_drawline: ; DrawLine |
5387 | syscall_drawline: ; DrawLine |
5389 | 5388 | ||
5390 | mov edi, [TASK_BASE] |
5389 | mov edi, [TASK_BASE] |
5391 | movzx eax, word[edi-twdw+WDATA.box.left] |
5390 | movzx eax, word[edi-twdw+WDATA.box.left] |
5392 | mov ebp, eax |
5391 | mov ebp, eax |
5393 | mov esi, [current_slot] |
5392 | mov esi, [current_slot] |
5394 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5393 | add ebp, [esi+APPDATA.wnd_clientbox.left] |
5395 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5394 | add ax, word[esi+APPDATA.wnd_clientbox.left] |
5396 | add ebp, ebx |
5395 | add ebp, ebx |
5397 | shl eax, 16 |
5396 | shl eax, 16 |
5398 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5397 | movzx ebx, word[edi-twdw+WDATA.box.top] |
5399 | add eax, ebp |
5398 | add eax, ebp |
5400 | mov ebp, ebx |
5399 | mov ebp, ebx |
5401 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5400 | add ebp, [esi+APPDATA.wnd_clientbox.top] |
5402 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5401 | add bx, word[esi+APPDATA.wnd_clientbox.top] |
5403 | add ebp, ecx |
5402 | add ebp, ecx |
5404 | shl ebx, 16 |
5403 | shl ebx, 16 |
5405 | xor edi, edi |
5404 | xor edi, edi |
5406 | add ebx, ebp |
5405 | add ebx, ebp |
5407 | mov ecx, edx |
5406 | mov ecx, edx |
5408 | ; jmp [draw_line] |
5407 | ; jmp [draw_line] |
5409 | jmp __sys_draw_line |
5408 | jmp __sys_draw_line |
5410 | 5409 | ||
5411 | 5410 | ||
5412 | align 4 |
5411 | align 4 |
5413 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5412 | syscall_reserveportarea: ; ReservePortArea and FreePortArea |
5414 | 5413 | ||
5415 | call r_f_port_area |
5414 | call r_f_port_area |
5416 | mov [esp+32], eax |
5415 | mov [esp+32], eax |
5417 | ret |
5416 | ret |
5418 | 5417 | ||
5419 | align 4 |
5418 | align 4 |
5420 | syscall_threads: ; CreateThreads |
5419 | syscall_threads: ; CreateThreads |
5421 | ; |
5420 | ; |
5422 | ; ecx=thread entry point |
5421 | ; ecx=thread entry point |
5423 | ; edx=thread stack pointer |
5422 | ; edx=thread stack pointer |
5424 | ; |
5423 | ; |
5425 | ; on return : eax = pid |
5424 | ; on return : eax = pid |
5426 | 5425 | ||
5427 | xor ebx, ebx |
5426 | xor ebx, ebx |
5428 | call new_sys_threads |
5427 | call new_sys_threads |
5429 | 5428 | ||
5430 | mov [esp+32], eax |
5429 | mov [esp+32], eax |
5431 | ret |
5430 | ret |
5432 | 5431 | ||
5433 | align 4 |
5432 | align 4 |
5434 | 5433 | ||
5435 | paleholder: |
5434 | paleholder: |
5436 | ret |
5435 | ret |
5437 | ;------------------------------------------------------------------------------ |
5436 | ;------------------------------------------------------------------------------ |
5438 | align 4 |
5437 | align 4 |
5439 | calculate_fast_getting_offset_for_WinMapAddress: |
5438 | calculate_fast_getting_offset_for_WinMapAddress: |
5440 | ; calculate data area for fast getting offset to _WinMapAddress |
5439 | ; calculate data area for fast getting offset to _WinMapAddress |
5441 | xor eax, eax |
5440 | xor eax, eax |
5442 | mov ecx, [_display.height] |
5441 | mov ecx, [_display.height] |
5443 | mov edi, d_width_calc_area |
5442 | mov edi, d_width_calc_area |
5444 | cld |
5443 | cld |
5445 | @@: |
5444 | @@: |
5446 | stosd |
5445 | stosd |
5447 | add eax, [_display.width] |
5446 | add eax, [_display.width] |
5448 | dec ecx |
5447 | dec ecx |
5449 | jnz @r |
5448 | jnz @r |
5450 | ret |
5449 | ret |
5451 | ;------------------------------------------------------------------------------ |
5450 | ;------------------------------------------------------------------------------ |
5452 | align 4 |
5451 | align 4 |
5453 | calculate_fast_getting_offset_for_LFB: |
5452 | calculate_fast_getting_offset_for_LFB: |
5454 | ; calculate data area for fast getting offset to LFB |
5453 | ; calculate data area for fast getting offset to LFB |
5455 | xor eax, eax |
5454 | xor eax, eax |
5456 | mov ecx, [_display.height] |
5455 | mov ecx, [_display.height] |
5457 | mov edi, BPSLine_calc_area |
5456 | mov edi, BPSLine_calc_area |
5458 | cld |
5457 | cld |
5459 | @@: |
5458 | @@: |
5460 | stosd |
5459 | stosd |
5461 | add eax, [_display.lfb_pitch] |
5460 | add eax, [_display.lfb_pitch] |
5462 | dec ecx |
5461 | dec ecx |
5463 | jnz @r |
5462 | jnz @r |
5464 | ret |
5463 | ret |
5465 | ;------------------------------------------------------------------------------ |
5464 | ;------------------------------------------------------------------------------ |
5466 | align 4 |
5465 | align 4 |
5467 | set_screen: |
5466 | set_screen: |
5468 | ; in: |
5467 | ; in: |
5469 | ; eax - new Screen_Max_X |
5468 | ; eax - new Screen_Max_X |
5470 | ; ecx - new BytesPerScanLine |
5469 | ; ecx - new BytesPerScanLine |
5471 | ; edx - new Screen_Max_Y |
5470 | ; edx - new Screen_Max_Y |
5472 | 5471 | ||
5473 | pushfd |
5472 | pushfd |
5474 | cli |
5473 | cli |
5475 | 5474 | ||
5476 | mov [_display.lfb_pitch], ecx |
5475 | mov [_display.lfb_pitch], ecx |
5477 | 5476 | ||
5478 | mov [screen_workarea.right], eax |
5477 | mov [screen_workarea.right], eax |
5479 | mov [screen_workarea.bottom], edx |
5478 | mov [screen_workarea.bottom], edx |
5480 | 5479 | ||
5481 | push ebx |
5480 | push ebx |
5482 | push esi |
5481 | push esi |
5483 | push edi |
5482 | push edi |
5484 | 5483 | ||
5485 | pushad |
5484 | pushad |
5486 | 5485 | ||
5487 | cmp [do_not_touch_winmap], 1 |
5486 | cmp [do_not_touch_winmap], 1 |
5488 | je @f |
5487 | je @f |
5489 | 5488 | ||
5490 | stdcall kernel_free, [_display.win_map] |
5489 | stdcall kernel_free, [_display.win_map] |
5491 | 5490 | ||
5492 | mov eax, [_display.width] |
5491 | mov eax, [_display.width] |
5493 | mul [_display.height] |
5492 | mul [_display.height] |
5494 | mov [_display.win_map_size], eax |
5493 | mov [_display.win_map_size], eax |
5495 | 5494 | ||
5496 | stdcall kernel_alloc, eax |
5495 | stdcall kernel_alloc, eax |
5497 | mov [_display.win_map], eax |
5496 | mov [_display.win_map], eax |
5498 | test eax, eax |
5497 | test eax, eax |
5499 | jz .epic_fail |
5498 | jz .epic_fail |
5500 | ; store for f.18.24 |
5499 | ; store for f.18.24 |
5501 | mov eax, [_display.width] |
5500 | mov eax, [_display.width] |
5502 | mov [display_width_standard], eax |
5501 | mov [display_width_standard], eax |
5503 | 5502 | ||
5504 | mov eax, [_display.height] |
5503 | mov eax, [_display.height] |
5505 | mov [display_height_standard], eax |
5504 | mov [display_height_standard], eax |
5506 | @@: |
5505 | @@: |
5507 | call calculate_fast_getting_offset_for_WinMapAddress |
5506 | call calculate_fast_getting_offset_for_WinMapAddress |
5508 | ; for Qemu or non standart video cards |
5507 | ; for Qemu or non standart video cards |
5509 | ; Unfortunately [BytesPerScanLine] does not always |
5508 | ; Unfortunately [BytesPerScanLine] does not always |
5510 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5509 | ; equal to [_display.width] * [ScreenBPP] / 8 |
5511 | call calculate_fast_getting_offset_for_LFB |
5510 | call calculate_fast_getting_offset_for_LFB |
5512 | popad |
5511 | popad |
5513 | 5512 | ||
5514 | call repos_windows |
5513 | call repos_windows |
5515 | xor eax, eax |
5514 | xor eax, eax |
5516 | xor ebx, ebx |
5515 | xor ebx, ebx |
5517 | mov ecx, [_display.width] |
5516 | mov ecx, [_display.width] |
5518 | mov edx, [_display.height] |
5517 | mov edx, [_display.height] |
5519 | dec ecx |
5518 | dec ecx |
5520 | dec edx |
5519 | dec edx |
5521 | call calculatescreen |
5520 | call calculatescreen |
5522 | pop edi |
5521 | pop edi |
5523 | pop esi |
5522 | pop esi |
5524 | pop ebx |
5523 | pop ebx |
5525 | 5524 | ||
5526 | popfd |
5525 | popfd |
5527 | ret |
5526 | ret |
5528 | 5527 | ||
5529 | .epic_fail: |
5528 | .epic_fail: |
5530 | hlt ; Houston, we've had a problem |
5529 | hlt ; Houston, we've had a problem |
5531 | 5530 | ||
5532 | ; --------------- APM --------------------- |
5531 | ; --------------- APM --------------------- |
5533 | uglobal |
5532 | uglobal |
5534 | apm_entry dp 0 |
5533 | apm_entry dp 0 |
5535 | apm_vf dd 0 |
5534 | apm_vf dd 0 |
5536 | endg |
5535 | endg |
5537 | 5536 | ||
5538 | align 4 |
5537 | align 4 |
5539 | sys_apm: |
5538 | sys_apm: |
5540 | xor eax, eax |
5539 | xor eax, eax |
5541 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5540 | cmp word [apm_vf], ax ; Check APM BIOS enable |
5542 | jne @f |
5541 | jne @f |
5543 | inc eax |
5542 | inc eax |
5544 | or dword [esp + 44], eax ; error |
5543 | or dword [esp + 44], eax ; error |
5545 | add eax, 7 |
5544 | add eax, 7 |
5546 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5545 | mov dword [esp + 32], eax ; 32-bit protected-mode interface not supported |
5547 | ret |
5546 | ret |
5548 | 5547 | ||
5549 | @@: |
5548 | @@: |
5550 | ; xchg eax, ecx |
5549 | ; xchg eax, ecx |
5551 | ; xchg ebx, ecx |
5550 | ; xchg ebx, ecx |
5552 | 5551 | ||
5553 | cmp dx, 3 |
5552 | cmp dx, 3 |
5554 | ja @f |
5553 | ja @f |
5555 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5554 | and [esp + 44], byte 0xfe ; emulate func 0..3 as func 0 |
5556 | mov eax, [apm_vf] |
5555 | mov eax, [apm_vf] |
5557 | mov [esp + 32], eax |
5556 | mov [esp + 32], eax |
5558 | shr eax, 16 |
5557 | shr eax, 16 |
5559 | mov [esp + 28], eax |
5558 | mov [esp + 28], eax |
5560 | ret |
5559 | ret |
5561 | 5560 | ||
5562 | @@: |
5561 | @@: |
5563 | 5562 | ||
5564 | mov esi, [master_tab+(OS_BASE shr 20)] |
5563 | mov esi, [master_tab+(OS_BASE shr 20)] |
5565 | xchg [master_tab], esi |
5564 | xchg [master_tab], esi |
5566 | push esi |
5565 | push esi |
5567 | mov edi, cr3 |
5566 | mov edi, cr3 |
5568 | mov cr3, edi ;flush TLB |
5567 | mov cr3, edi ;flush TLB |
5569 | 5568 | ||
5570 | call pword [apm_entry] ;call APM BIOS |
5569 | call pword [apm_entry] ;call APM BIOS |
5571 | 5570 | ||
5572 | xchg eax, [esp] |
5571 | xchg eax, [esp] |
5573 | mov [master_tab], eax |
5572 | mov [master_tab], eax |
5574 | mov eax, cr3 |
5573 | mov eax, cr3 |
5575 | mov cr3, eax |
5574 | mov cr3, eax |
5576 | pop eax |
5575 | pop eax |
5577 | 5576 | ||
5578 | mov [esp + 4 ], edi |
5577 | mov [esp + 4 ], edi |
5579 | mov [esp + 8], esi |
5578 | mov [esp + 8], esi |
5580 | mov [esp + 20], ebx |
5579 | mov [esp + 20], ebx |
5581 | mov [esp + 24], edx |
5580 | mov [esp + 24], edx |
5582 | mov [esp + 28], ecx |
5581 | mov [esp + 28], ecx |
5583 | mov [esp + 32], eax |
5582 | mov [esp + 32], eax |
5584 | setc al |
5583 | setc al |
5585 | and [esp + 44], byte 0xfe |
5584 | and [esp + 44], byte 0xfe |
5586 | or [esp + 44], al |
5585 | or [esp + 44], al |
5587 | ret |
5586 | ret |
5588 | ; ----------------------------------------- |
5587 | ; ----------------------------------------- |
5589 | 5588 | ||
5590 | align 4 |
5589 | align 4 |
5591 | 5590 | ||
5592 | undefined_syscall: ; Undefined system call |
5591 | undefined_syscall: ; Undefined system call |
5593 | mov [esp + 32], dword -1 |
5592 | mov [esp + 32], dword -1 |
5594 | ret |
5593 | ret |
5595 | 5594 | ||
5596 | 5595 | ||
5597 | if ~ lang eq sp |
5596 | if ~ lang eq sp |
5598 | diff16 "end of .text segment",0,$ |
5597 | diff16 "end of .text segment",0,$ |
5599 | end if |
5598 | end if |
5600 | 5599 | ||
5601 | include "data32.inc" |
5600 | include "data32.inc" |
5602 | 5601 | ||
5603 | __REV__ = __REV |
5602 | __REV__ = __REV |
5604 | 5603 | ||
5605 | if ~ lang eq sp |
5604 | if ~ lang eq sp |
5606 | diff16 "end of kernel code",0,$ |
5605 | diff16 "end of kernel code",0,$ |
5607 | end if=> |
5606 | end if=> |